Subversion Repositories php-qbpwcf

Rev

Rev 207 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 207 Rev 226
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 
4
 
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
6
    Copyright (C) 2015~2024 Min-Jhin,Chen
6
    Copyright (C) 2014~2025 MIN ZHI, CHEN
7
 
7
 
8
    This file is part of QBPWCF.
8
    This file is part of QBPWCF.
9
 
9
 
10
    QBPWCF is free software: you can redistribute it and/or modify
10
    QBPWCF is free software: you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
11
    it under the terms of the GNU General Public License as published by
Line 47... Line 47...
47
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
47
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
48
	#備註:
48
	#備註:
49
	#無.
49
	#無.
50
	*/
50
	*/
51
	public function __call($method,$arguments){
51
	public function __call($method,$arguments){
52
		
52
 
53
		#取得當前執行的函式
53
		#取得當前執行的函式
54
		$result["function"]=__FUNCTION__;
54
		$result["function"]=__FUNCTION__;
55
		
55
 
56
		#設置執行不正常
56
		#設置執行不正常
57
		$result["status"]="false";
57
		$result["status"]="false";
58
		
58
 
59
		#設置執行錯誤
59
		#設置執行錯誤
60
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
60
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
61
		
61
 
62
		#設置所丟入的參數
62
		#設置所丟入的參數
63
		$result["error"][]=$arguments;
63
		$result["error"][]=$arguments;
64
		
64
 
65
		#回傳結果
65
		#回傳結果
66
		return $result;
66
		return $result;
67
		
67
 
68
		}#function __call end
68
		}#function __call end
69
		
69
 
70
	/*
70
	/*
71
	#函式說明:
71
	#函式說明:
72
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
72
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
73
	#回傳結果:
73
	#回傳結果:
74
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
74
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 83... Line 83...
83
	#__callStatic=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
83
	#__callStatic=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
84
	#備註:
84
	#備註:
85
	#無.
85
	#無.
86
	*/
86
	*/
87
	public static function __callStatic($method,$arguments){
87
	public static function __callStatic($method,$arguments){
88
		
88
 
89
		#取得當前執行的函式
89
		#取得當前執行的函式
90
		$result["function"]=__FUNCTION__;
90
		$result["function"]=__FUNCTION__;
91
		
91
 
92
		#設置執行不正常
92
		#設置執行不正常
93
		$result["status"]="false";
93
		$result["status"]="false";
94
		
94
 
95
		#設置執行錯誤
95
		#設置執行錯誤
96
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
96
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
97
		
97
 
98
		#設置所丟入的參數
98
		#設置所丟入的參數
99
		$result["error"][]=$arguments;
99
		$result["error"][]=$arguments;
100
		
100
 
101
		#回傳結果
101
		#回傳結果
102
		return $result;
102
		return $result;
103
		
103
 
104
		}#function __callStatic end
104
		}#function __callStatic end
105
	
105
 
106
	/*
106
	/*
107
	#函式說明:		
107
	#函式說明:
108
	#禁止特定的angent訪問我們的網站,例如google與百度的搜尋引擎。
108
	#禁止特定的angent訪問我們的網站,例如google與百度的搜尋引擎。
109
	#回傳結果:
109
	#回傳結果:
110
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
110
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
111
	#$result["error"],錯誤訊息.
111
	#$result["error"],錯誤訊息.
112
	#$result["function"],當前執行的函數名稱.
112
	#$result["function"],當前執行的函數名稱.
Line 123... Line 123...
123
	*/
123
	*/
124
	public static function preventSerchEngine(&$conf){
124
	public static function preventSerchEngine(&$conf){
125
 
125
 
126
		#初始化要回傳的內容
126
		#初始化要回傳的內容
127
		$result=array();
127
		$result=array();
128
		
128
 
129
		#取得當前執行的函式
129
		#取得當前執行的函式
130
		$result["function"]=__FUNCTION__;
130
		$result["function"]=__FUNCTION__;
131
		
131
 
132
		#如果 $conf 不為陣列
132
		#如果 $conf 不為陣列
133
		if(gettype($conf)!="array"){
133
		if(gettype($conf)!="array"){
134
			
134
 
135
			#設置執行失敗
135
			#設置執行失敗
136
			$result["status"]="false";
136
			$result["status"]="false";
137
			
137
 
138
			#設置執行錯誤訊息
138
			#設置執行錯誤訊息
139
			$result["error"][]="\$conf變數須為陣列形態";
139
			$result["error"][]="\$conf變數須為陣列形態";
140
 
140
 
141
			#如果傳入的參數為 null
141
			#如果傳入的參數為 null
142
			if($conf==null){
142
			if($conf==null){
143
				
143
 
144
				#設置執行錯誤訊息
144
				#設置執行錯誤訊息
145
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
145
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
146
				
146
 
147
				}#if end
147
				}#if end
148
 
148
 
149
			#回傳結果
149
			#回傳結果
150
			return $result;
150
			return $result;
151
			
151
 
152
			}#if end
152
			}#if end
153
 
153
 
154
		#debug,檢查 $_SERVER["HTTP_USER_AGENT"] 的內容
154
		#debug,檢查 $_SERVER["HTTP_USER_AGENT"] 的內容
155
		#var_dump($_SERVER['HTTP_USER_AGENT']);
155
		#var_dump($_SERVER['HTTP_USER_AGENT']);
156
		
156
 
157
		#檢查參數
157
		#檢查參數
158
		#函式說明:
158
		#函式說明:
159
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
159
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
160
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
160
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
161
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
161
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 170... Line 170...
170
		#必填寫的參數:
170
		#必填寫的參數:
171
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
171
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
172
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
172
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
173
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
173
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
174
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("disableAngentName");
174
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("disableAngentName");
175
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
175
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object");
176
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
176
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
177
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
177
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
178
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
178
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
179
		#可以省略的參數:
179
		#可以省略的參數:
180
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
180
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
181
		#$conf["canBeEmptyString"]="false";
181
		#$conf["canBeEmptyString"]="false";
182
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
182
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
183
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("transferLocation");
183
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("transferLocation");
184
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
184
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
185
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
185
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
186
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
186
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
187
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("https://zh-tw.facebook.com/isafemoe");
187
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("https://zh-tw.facebook.com/isafemoe");
188
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
188
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
189
		#$conf["arrayCountEqualCheck"][]=array();
189
		#$conf["arrayCountEqualCheck"][]=array();
190
		#參考資料來源:
190
		#參考資料來源:
191
		#array_keys=>http://php.net/manual/en/function.array-keys.php
191
		#array_keys=>http://php.net/manual/en/function.array-keys.php
192
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
192
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
193
		unset($conf["variableCheck::checkArguments"]);
193
		unset($conf["variableCheck::checkArguments"]);
194
				
194
 
195
		#如果檢查失敗
195
		#如果檢查失敗
196
		if($checkArguments["status"]=="false"){
196
		if($checkArguments["status"]=="false"){
197
			
197
 
198
			#設置執行失敗
198
			#設置執行失敗
199
			$result["status"]="false";
199
			$result["status"]="false";
200
			
200
 
201
			#設置執行錯誤訊息
201
			#設置執行錯誤訊息
202
			$result["error"]=$checkArguments;
202
			$result["error"]=$checkArguments;
203
 
203
 
204
			#回傳結果
204
			#回傳結果
205
			return $result;
205
			return $result;
206
			
206
 
207
			}#if end	
207
			}#if end
208
			
208
 
209
		#如果檢查不通過
209
		#如果檢查不通過
210
		if($checkArguments["passed"]=="false"){
210
		if($checkArguments["passed"]=="false"){
211
			
211
 
212
			#設置執行失敗
212
			#設置執行失敗
213
			$result["status"]="false";
213
			$result["status"]="false";
214
			
214
 
215
			#設置執行錯誤訊息
215
			#設置執行錯誤訊息
216
			$result["error"]=$checkArguments;
216
			$result["error"]=$checkArguments;
217
 
217
 
218
			#回傳結果
218
			#回傳結果
219
			return $result;
219
			return $result;
220
			
220
 
221
			}#if end	
221
			}#if end
222
					
222
 
223
		#如果使用者的瀏覽器出現變數 $conf["disableAngentName"] 裡面的關鍵字
223
		#如果使用者的瀏覽器出現變數 $conf["disableAngentName"] 裡面的關鍵字
224
		if(preg_match($conf["disableAngentName"],$_SERVER["HTTP_USER_AGENT"])){
224
		if(preg_match($conf["disableAngentName"],$_SERVER["HTTP_USER_AGENT"])){
225
 
225
 
226
			#則轉址特定頁面
226
			#則轉址特定頁面
227
			#函式說明:
227
			#函式說明:
Line 239... Line 239...
239
			#$conf["sessionValue"]字串陣列,可以指派session變數的內容.
239
			#$conf["sessionValue"]字串陣列,可以指派session變數的內容.
240
			#$conf["sessionValue"]=array("");
240
			#$conf["sessionValue"]=array("");
241
			#參靠資料來源:
241
			#參靠資料來源:
242
			#http://php.net/manual/en/reserved.variables.server.php
242
			#http://php.net/manual/en/reserved.variables.server.php
243
			$redirectionNow=header::redirectionNow($conf["header::redirectionNow"]);
243
			$redirectionNow=header::redirectionNow($conf["header::redirectionNow"]);
244
			unset($conf["header::redirectionNow"]);			
244
			unset($conf["header::redirectionNow"]);
245
	
245
 
246
			#如果轉址失敗
246
			#如果轉址失敗
247
			if($redirectionNow["status"]=="false"){
247
			if($redirectionNow["status"]=="false"){
248
				
248
 
249
				#設置執行失敗
249
				#設置執行失敗
250
				$result["status"]="false";
250
				$result["status"]="false";
251
				
251
 
252
				#設置執行錯誤訊息
252
				#設置執行錯誤訊息
253
				$result["error"]=$redirectionNow;
253
				$result["error"]=$redirectionNow;
254
 
254
 
255
				#回傳結果
255
				#回傳結果
256
				return $result;
256
				return $result;
257
				
257
 
258
				}#if end
258
				}#if end
259
	
259
 
260
			}#if end		
260
			}#if end
261
			
261
 
262
		#執行到這邊代表是可以拜訪的網頁瀏覽器
262
		#執行到這邊代表是可以拜訪的網頁瀏覽器
263
		$result["status"]="true";
263
		$result["status"]="true";
264
		
264
 
265
		#回傳結果
265
		#回傳結果
266
		return $result;
266
		return $result;
267
 
267
 
268
		}#function preventSerchEngine end
268
		}#function preventSerchEngine end
269
 
269
 
Line 287... Line 287...
287
	#http://www.w3schools.com/jsref/dom_obj_event.asp
287
	#http://www.w3schools.com/jsref/dom_obj_event.asp
288
	#備註:
288
	#備註:
289
	#無.
289
	#無.
290
	*/
290
	*/
291
	public static function copyRight(&$conf){
291
	public static function copyRight(&$conf){
292
	
292
 
293
		#初始化要回傳的結果
293
		#初始化要回傳的結果
294
		$result=array();
294
		$result=array();
295
 
295
 
296
		#取得當前執行的函數名稱
296
		#取得當前執行的函數名稱
297
		$result["function"]=__FUNCTION__;
297
		$result["function"]=__FUNCTION__;
Line 318... Line 318...
318
 
318
 
319
			#回傳結果
319
			#回傳結果
320
			return $result;
320
			return $result;
321
 
321
 
322
			}#if end
322
			}#if end
323
			
323
 
324
		#初始化 content
324
		#初始化 content
325
		$result["content"]="";	
325
		$result["content"]="";
326
		
326
 
327
		#函式說明:
327
		#函式說明:
328
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
328
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
329
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
329
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
330
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
330
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
331
		#$result["function"],當前執行的函式名稱.
331
		#$result["function"],當前執行的函式名稱.
Line 370... Line 370...
370
		#$conf["arrayCountEqualCheck"][]=array();
370
		#$conf["arrayCountEqualCheck"][]=array();
371
		#參考資料來源:
371
		#參考資料來源:
372
		#array_keys=>http://php.net/manual/en/function.array-keys.php
372
		#array_keys=>http://php.net/manual/en/function.array-keys.php
373
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
373
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
374
		unset($conf["variableCheck::checkArguments"]);
374
		unset($conf["variableCheck::checkArguments"]);
375
		
375
 
376
		#如果檢查失敗
376
		#如果檢查失敗
377
		if($checkArguments["status"]=="false"){
377
		if($checkArguments["status"]=="false"){
378
 
378
 
379
			#設置錯誤狀態
379
			#設置錯誤狀態
380
			$result["status"]="false";
380
			$result["status"]="false";
Line 398... Line 398...
398
 
398
 
399
			#回傳結果
399
			#回傳結果
400
			return $result;
400
			return $result;
401
 
401
 
402
			}#if end
402
			}#if end
403
				
403
 
404
		#函式說明:
404
		#函式說明:
405
		#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).
405
		#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).
406
		#回傳結果:
406
		#回傳結果:
407
		#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
407
		#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
408
		#$result["error"],錯誤訊息陣列
408
		#$result["error"],錯誤訊息陣列
409
		#$result["function"],當前執行的函數名稱
409
		#$result["function"],當前執行的函數名稱
410
		#$result["content"],要執行的javaScript語法
410
		#$result["content"],要執行的javaScript語法
411
		#必填參數:
411
		#必填參數:
412
		#$conf["script"],字串,要執行的javaScript語法.
412
		#$conf["script"],字串,要執行的javaScript語法.
413
		$conf["javaScript::toScript"]["script"]="
413
		$conf["javaScript::toScript"]["script"]="
414
		
414
 
415
		
415
 
416
		
416
 
417
		var copyRightSpan=document.createElement('span');
417
		var copyRightSpan=document.createElement('span');
418
		var copyRightText=document.createTextNode('".$conf["name"]."');
418
		var copyRightText=document.createTextNode('".$conf["name"]."');
419
		copyRightSpan.appendChild(copyRightText);
419
		copyRightSpan.appendChild(copyRightText);
420
		
420
 
421
		//建立power by span
421
		//建立power by span
422
		var powerBySpan=document.createElement('span');
422
		var powerBySpan=document.createElement('span');
423
		var powerByA=document.createElement('a');
423
		var powerByA=document.createElement('a');
424
		powerByA.href='".$conf["powerByLink"]."';
424
		powerByA.href='".$conf["powerByLink"]."';
425
		powerByA.target='_blank';
425
		powerByA.target='_blank';
426
		var powerByText=document.createTextNode('Powered by '+'".$conf["powerBy"]."');
426
		var powerByText=document.createTextNode('Powered by '+'".$conf["powerBy"]."');
427
		powerByA.appendChild(powerByText);
427
		powerByA.appendChild(powerByText);
428
		powerBySpan.appendChild(powerByA);
428
		powerBySpan.appendChild(powerByA);
429
		
429
 
430
		//建立 copy right div
430
		//建立 copy right div
431
		var copyRightDiv=document.createElement('div');
431
		var copyRightDiv=document.createElement('div');
432
		copyRightDiv.appendChild(copyRightSpan);
432
		copyRightDiv.appendChild(copyRightSpan);
433
		copyRightDiv.appendChild(powerBySpan);
433
		copyRightDiv.appendChild(powerBySpan);
434
		copyRightDiv.style.backgroundColor='".$conf["bgColor"]."';
434
		copyRightDiv.style.backgroundColor='".$conf["bgColor"]."';
435
		copyRightDiv.style.textAlign='center';
435
		copyRightDiv.style.textAlign='center';
436
		
436
 
437
		//顯現 copy right
437
		//顯現 copy right
438
		document.body.appendChild(copyRightDiv);
438
		document.body.appendChild(copyRightDiv);
439
		
439
 
440
		";
440
		";
441
		#可省略參數:
441
		#可省略參數:
442
		#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
442
		#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
443
		#$conf["onReady"]="true";
443
		#$conf["onReady"]="true";
444
		#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
444
		#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
Line 447... Line 447...
447
		#$conf["jsFunciton"]=array();
447
		#$conf["jsFunciton"]=array();
448
		#參考資料:
448
		#參考資料:
449
		#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
449
		#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
450
		$toScript=javaScript::toScript($conf["javaScript::toScript"]);
450
		$toScript=javaScript::toScript($conf["javaScript::toScript"]);
451
		unset($conf["javaScript::toScript"]);
451
		unset($conf["javaScript::toScript"]);
452
			
452
 
453
		#如果建立 javascript 語法失敗
453
		#如果建立 javascript 語法失敗
454
		if($toScript["status"]==="false"){	
454
		if($toScript["status"]==="false"){
455
			
455
 
456
			#設置執行失敗
456
			#設置執行失敗
457
			$result["status"]="false";
457
			$result["status"]="false";
458
			
458
 
459
			#設置執行錯誤訊息
459
			#設置執行錯誤訊息
460
			$result["error"]=$toScript;
460
			$result["error"]=$toScript;
461
 
461
 
462
			#回傳結果
462
			#回傳結果
463
			return $result;	
463
			return $result;
464
			
464
 
465
			}#if end
465
			}#if end
466
		
466
 
467
		#傳接 content	
467
		#傳接 content
468
		$result["content"]=$result["content"].$toScript["content"];
468
		$result["content"]=$result["content"].$toScript["content"];
469
			
469
 
470
		#保護版權的語法
470
		#保護版權的語法
471
		#oncontextmenu,按下滑鼠右鍵
471
		#oncontextmenu,按下滑鼠右鍵
472
		#onContextMenu,按下滑鼠右鍵
472
		#onContextMenu,按下滑鼠右鍵
473
		#ondragstart,開始拖曳
473
		#ondragstart,開始拖曳
474
		#onselsect,選取區塊時
474
		#onselsect,選取區塊時
475
		#onselectstart,開始選取區塊
475
		#onselectstart,開始選取區塊
476
		#onkeydown='if(event.tKey && event.ctrlKey),按下ctrl+t開分頁時
476
		#onkeydown='if(event.tKey && event.ctrlKey),按下ctrl+t開分頁時
477
		$result["content"]=$result["content"]."
477
		$result["content"]=$result["content"]."
478
			<html
478
			<html
479
			oncontextmenu=\"return false\" 
479
			oncontextmenu=\"return false\"
480
			onContextMenu=\"window.event.returnValue=false\"
480
			onContextMenu=\"window.event.returnValue=false\"
481
			onselect=\"return false\"
481
			onselect=\"return false\"
482
			onselectstart=\"return false\" 
482
			onselectstart=\"return false\"
483
			ondragstart=\"return false\" 
483
			ondragstart=\"return false\"
484
			oncopy=\"return false\"
484
			oncopy=\"return false\"
485
			onbeforeprint=\"return false\"
485
			onbeforeprint=\"return false\"
486
			>\r\n";
486
			>\r\n";
487
		
487
 
488
		#設置執行正常
488
		#設置執行正常
489
		$result["status"]="true";
489
		$result["status"]="true";
490
		
490
 
491
		#回傳語法
491
		#回傳語法
492
		return $result;
492
		return $result;
493
		
493
 
494
		}#函式結束
494
		}#函式結束
495
 
495
 
496
	/*
496
	/*
497
	#函式說明: 
497
	#函式說明:
498
	#放置用空白圖片擋住要呈現的圖片
498
	#放置用空白圖片擋住要呈現的圖片
499
	#回傳結果:
499
	#回傳結果:
500
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
500
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
501
	#$result["error"],錯誤訊息.
501
	#$result["error"],錯誤訊息.
502
	#$result["function"],當前執行的函數名稱.
502
	#$result["function"],當前執行的函數名稱.
Line 517... Line 517...
517
	#$conf["useBase64"]="true";
517
	#$conf["useBase64"]="true";
518
	#參考資料:
518
	#參考資料:
519
	#無.
519
	#無.
520
	#備註:
520
	#備註:
521
	#無.
521
	#無.
522
	*/	
522
	*/
523
	public static function imgProtect(&$conf){
523
	public static function imgProtect(&$conf){
524
 
524
 
525
		#初始化要回傳的內容
525
		#初始化要回傳的內容
526
		$result=array();
526
		$result=array();
527
		
527
 
528
		#取得當前執行的函式
528
		#取得當前執行的函式
529
		$result["function"]=__FUNCTION__;
529
		$result["function"]=__FUNCTION__;
530
		
530
 
531
		#如果 $conf 不為陣列
531
		#如果 $conf 不為陣列
532
		if(gettype($conf)!="array"){
532
		if(gettype($conf)!="array"){
533
			
533
 
534
			#設置執行失敗
534
			#設置執行失敗
535
			$result["status"]="false";
535
			$result["status"]="false";
536
			
536
 
537
			#設置執行錯誤訊息
537
			#設置執行錯誤訊息
538
			$result["error"][]="\$conf變數須為陣列形態";
538
			$result["error"][]="\$conf變數須為陣列形態";
539
 
539
 
540
			#如果傳入的參數為 null
540
			#如果傳入的參數為 null
541
			if($conf==null){
541
			if($conf==null){
542
				
542
 
543
				#設置執行錯誤訊息
543
				#設置執行錯誤訊息
544
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
544
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
545
				
545
 
546
				}#if end
546
				}#if end
547
 
547
 
548
			#回傳結果
548
			#回傳結果
549
			return $result;
549
			return $result;
550
			
550
 
551
			}#if end
551
			}#if end
552
 
552
 
553
		#初始化程式碼
553
		#初始化程式碼
554
		$result["content"]="";
554
		$result["content"]="";
555
	
555
 
556
		#檢查參數
556
		#檢查參數
557
		#函式說明:
557
		#函式說明:
558
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
558
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
559
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
559
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
560
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
560
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 569... Line 569...
569
		#必填寫的參數:
569
		#必填寫的參數:
570
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
570
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
571
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
571
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
572
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
572
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
573
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("imgAddress","imgWidth","imgHeight","imgLeft","imgTop");
573
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("imgAddress","imgWidth","imgHeight","imgLeft","imgTop");
574
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
574
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object");
575
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string","string","string");
575
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string","string","string");
576
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
576
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
577
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
577
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
578
		#可以省略的參數:
578
		#可以省略的參數:
579
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
579
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
580
		#$conf["canBeEmptyString"]="false";
580
		#$conf["canBeEmptyString"]="false";
581
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
581
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
582
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("useBase64");
582
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("useBase64");
583
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
583
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
584
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
584
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
585
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
585
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
586
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true");
586
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true");
587
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
587
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
588
		#$conf["arrayCountEqualCheck"][]=array();
588
		#$conf["arrayCountEqualCheck"][]=array();
589
		#參考資料來源:
589
		#參考資料來源:
590
		#array_keys=>http://php.net/manual/en/function.array-keys.php
590
		#array_keys=>http://php.net/manual/en/function.array-keys.php
591
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
591
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
592
		unset($conf["variableCheck::checkArguments"]);
592
		unset($conf["variableCheck::checkArguments"]);
593
				
593
 
594
		#如果檢查失敗
594
		#如果檢查失敗
595
		if($checkArguments["status"]=="false"){
595
		if($checkArguments["status"]=="false"){
596
			
596
 
597
			#設置執行失敗
597
			#設置執行失敗
598
			$result["status"]="false";
598
			$result["status"]="false";
599
			
599
 
600
			#設置執行錯誤訊息
600
			#設置執行錯誤訊息
601
			$result["error"]=$checkArguments;
601
			$result["error"]=$checkArguments;
602
 
602
 
603
			#回傳結果
603
			#回傳結果
604
			return $result;
604
			return $result;
605
			
605
 
606
			}#if end	
606
			}#if end
607
			
607
 
608
		#如果檢查不通過
608
		#如果檢查不通過
609
		if($checkArguments["passed"]=="false"){
609
		if($checkArguments["passed"]=="false"){
610
			
610
 
611
			#設置執行失敗
611
			#設置執行失敗
612
			$result["status"]="false";
612
			$result["status"]="false";
613
			
613
 
614
			#設置執行錯誤訊息
614
			#設置執行錯誤訊息
615
			$result["error"]=$checkArguments;
615
			$result["error"]=$checkArguments;
616
 
616
 
617
			#回傳結果
617
			#回傳結果
618
			return $result;
618
			return $result;
619
			
619
 
620
			}#if end
620
			}#if end
621
 
621
 
622
		#建立要放置的圖片樣式
622
		#建立要放置的圖片樣式
623
		#函式說明: 
623
		#函式說明:
624
		#創建 css 樣式
624
		#創建 css 樣式
625
		#回傳結果:
625
		#回傳結果:
626
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
626
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
627
		#$result["css"],css設定內容
627
		#$result["css"],css設定內容
628
		#$result["function"],當前執行的函數
628
		#$result["function"],當前執行的函數
629
		#$result["error"],涵式錯誤訊息,若爲""則表示沒有錯誤 
629
		#$result["error"],涵式錯誤訊息,若爲""則表示沒有錯誤
630
		$conf["css"]["createCssStyle"]["cssStyleName"]="imgStyle-".$conf["imgLeft"].$conf["imgTop"];
630
		$conf["css"]["createCssStyle"]["cssStyleName"]="imgStyle-".$conf["imgLeft"].$conf["imgTop"];
631
		$conf["css"]["createCssStyle"]["attributes"]=array("width","height","position","top","left");
631
		$conf["css"]["createCssStyle"]["attributes"]=array("width","height","position","top","left");
632
		$conf["css"]["createCssStyle"]["content"]=array($conf["imgWidth"],$conf["imgHeight"],"absolute",$conf["imgTop"],$conf["imgLeft"]);
632
		$conf["css"]["createCssStyle"]["content"]=array($conf["imgWidth"],$conf["imgHeight"],"absolute",$conf["imgTop"],$conf["imgLeft"]);
633
		$css=css::createCssStyle($conf["css"]["createCssStyle"]);
633
		$css=css::createCssStyle($conf["css"]["createCssStyle"]);
634
		unset($conf["css"]["createCssStyle"]);#清空變數避免出錯
634
		unset($conf["css"]["createCssStyle"]);#清空變數避免出錯
635
		
635
 
636
		#如果建立css樣式失敗
636
		#如果建立css樣式失敗
637
		if($css["status"]=="false"){
637
		if($css["status"]=="false"){
638
			
638
 
639
			#設置執行失敗
639
			#設置執行失敗
640
			$result["status"]="false";
640
			$result["status"]="false";
641
			
641
 
642
			#設置執行錯誤訊息
642
			#設置執行錯誤訊息
643
			$result["error"]=$css;
643
			$result["error"]=$css;
644
 
644
 
645
			#回傳結果
645
			#回傳結果
646
			return $result;
646
			return $result;
647
			
647
 
648
			}#if end
648
			}#if end
649
		
649
 
650
		#串接css語法
650
		#串接css語法
651
		$result["content"]=$result["content"].$css["css"];
651
		$result["content"]=$result["content"].$css["css"];
652
 
652
 
653
		#如果要用base64顯示圖片
653
		#如果要用base64顯示圖片
654
		if($conf["useBase64"]=="true"){
654
		if($conf["useBase64"]=="true"){
655
			
655
 
656
			#將圖片用base64加密呈現
656
			#將圖片用base64加密呈現
657
			#函數說明:
657
			#函數說明:
658
			#用data:mimeType;base64,imgVar的形式來提供圖片的連結,亦即圖片儲存在變數裡面,本函式包含顯示圖片的語法.
658
			#用data:mimeType;base64,imgVar的形式來提供圖片的連結,亦即圖片儲存在變數裡面,本函式包含顯示圖片的語法.
659
			#回傳結果:
659
			#回傳結果:
660
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
660
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
661
			#$result["error"],錯誤訊息
661
			#$result["error"],錯誤訊息
662
			#$result["content"],圖片的連結資訊
662
			#$result["content"],圖片的連結資訊
663
			#$result["function"],當前執行的函數名稱 
663
			#$result["function"],當前執行的函數名稱
664
			#必填參數:
664
			#必填參數:
665
			#$conf["img::data"]["imgPosition"],要轉存成2元碼的圖片檔案位置與名稱
665
			#$conf["img::data"]["imgPosition"],要轉存成2元碼的圖片檔案位置與名稱
666
			$conf["img::data"]["imgPosition"]=$conf["imgAddress"];
666
			$conf["img::data"]["imgPosition"]=$conf["imgAddress"];
667
			#可省略參數:
667
			#可省略參數:
668
			#$conf["img::data"]["alt"],若沒有圖片要用什麼文字顯示。
668
			#$conf["img::data"]["alt"],若沒有圖片要用什麼文字顯示。
Line 681... Line 681...
681
			$data=img::data($conf["img::data"]);
681
			$data=img::data($conf["img::data"]);
682
			unset($conf["img::data"]);
682
			unset($conf["img::data"]);
683
 
683
 
684
			#將圖片用base64加密呈現失敗
684
			#將圖片用base64加密呈現失敗
685
			if($data["status"]=="false"){
685
			if($data["status"]=="false"){
686
							
686
 
687
				#設置執行失敗
687
				#設置執行失敗
688
				$result["status"]="false";
688
				$result["status"]="false";
689
				
689
 
690
				#設置執行錯誤訊息
690
				#設置執行錯誤訊息
691
				$result["error"]=$data;
691
				$result["error"]=$data;
692
 
692
 
693
				#回傳結果
693
				#回傳結果
694
				return $result;
694
				return $result;
695
				
695
 
696
				}#if end
696
				}#if end
697
			
697
 
698
			#取得用base64放置圖片的語法
698
			#取得用base64放置圖片的語法
699
			$result["content"]=$result["content"].$data["content"];
699
			$result["content"]=$result["content"].$data["content"];
700
			
700
 
701
			}#if end
701
			}#if end
702
 
702
 
703
		#反之為一般放置圖片的方式
703
		#反之為一般放置圖片的方式
704
		else{
704
		else{
705
			
705
 
706
			#放置要放的圖片
706
			#放置要放的圖片
707
			#函式說明:
707
			#函式說明:
708
			#放置可以套用css樣式的圖片
708
			#放置可以套用css樣式的圖片
709
			#回傳結果:
709
			#回傳結果:
710
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
710
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
711
			#$result["error"],錯誤訊息陣列
711
			#$result["error"],錯誤訊息陣列
712
			#$result["function"],當前函數執行的名稱
712
			#$result["function"],當前函數執行的名稱
713
			#$result["content"],印出圖片的語法。		
713
			#$result["content"],印出圖片的語法。
714
			$conf["img"]["show"]["position"]=$conf["imgAddress"];
714
			$conf["img"]["show"]["position"]=$conf["imgAddress"];
715
			$conf["img"]["show"]["alt"]="not found";
715
			$conf["img"]["show"]["alt"]="not found";
716
			$conf["img"]["show"]["class"]="imgStyle-".$conf["imgLeft"].$conf["imgTop"];
716
			$conf["img"]["show"]["class"]="imgStyle-".$conf["imgLeft"].$conf["imgTop"];
717
			$show=img::show($conf["img"]["show"]);
717
			$show=img::show($conf["img"]["show"]);
718
			unset($conf["img"]["show"]);#清空變數避免出錯
718
			unset($conf["img"]["show"]);#清空變數避免出錯
719
 
719
 
720
			#如果放置圖片的語法建立失敗
720
			#如果放置圖片的語法建立失敗
721
			if($show["status"]=="false"){
721
			if($show["status"]=="false"){
722
				
722
 
723
				#設置執行失敗
723
				#設置執行失敗
724
				$result["status"]="false";
724
				$result["status"]="false";
725
				
725
 
726
				#設置執行錯誤訊息
726
				#設置執行錯誤訊息
727
				$result["error"]=$show;
727
				$result["error"]=$show;
728
 
728
 
729
				#回傳結果
729
				#回傳結果
730
				return $result;
730
				return $result;
731
				
731
 
732
				}#if end
732
				}#if end
733
			
733
 
734
			#串接顯示圖片的語法
734
			#串接顯示圖片的語法
735
			$result["content"]=$result["content"].$show["content"];
735
			$result["content"]=$result["content"].$show["content"];
736
			
736
 
737
			}#else end
737
			}#else end
738
 
738
 
739
		#建立圖片隔離層樣式
739
		#建立圖片隔離層樣式
740
		$conf["css"]["createCssStyle"]["cssStyleName"]="imgIsolationLayerStyle".$conf["imgLeft"].$conf["imgTop"];
740
		$conf["css"]["createCssStyle"]["cssStyleName"]="imgIsolationLayerStyle".$conf["imgLeft"].$conf["imgTop"];
741
		$conf["css"]["createCssStyle"]["attributes"]=array("width","height","opacity","position","top","left");
741
		$conf["css"]["createCssStyle"]["attributes"]=array("width","height","opacity","position","top","left");
742
		$conf["css"]["createCssStyle"]["content"]=array($conf["imgWidth"],$conf["imgHeight"],".0","absolute",$conf["imgTop"],$conf["imgLeft"]);
742
		$conf["css"]["createCssStyle"]["content"]=array($conf["imgWidth"],$conf["imgHeight"],".0","absolute",$conf["imgTop"],$conf["imgLeft"]);
743
		$css=css::createCssStyle($conf["css"]["createCssStyle"]);
743
		$css=css::createCssStyle($conf["css"]["createCssStyle"]);
744
		unset($conf["css"]["createCssStyle"]);#清空變數避免出錯
744
		unset($conf["css"]["createCssStyle"]);#清空變數避免出錯
745
	
745
 
746
		#如果建立css樣式失敗
746
		#如果建立css樣式失敗
747
		if($css["status"]=="false"){
747
		if($css["status"]=="false"){
748
			
748
 
749
			#設置執行失敗
749
			#設置執行失敗
750
			$result["status"]="false";
750
			$result["status"]="false";
751
			
751
 
752
			#設置執行錯誤訊息
752
			#設置執行錯誤訊息
753
			$result["error"]=$css;
753
			$result["error"]=$css;
754
 
754
 
755
			#回傳結果
755
			#回傳結果
756
			return $result;
756
			return $result;
757
			
757
 
758
			}#if end
758
			}#if end
759
			
759
 
760
		#取得圖片隔離層樣式程式碼
760
		#取得圖片隔離層樣式程式碼
761
		$result["content"]=$result["content"].$css["css"];
761
		$result["content"]=$result["content"].$css["css"];
762
 
762
 
763
		#放置隔離層
763
		#放置隔離層
764
		#函式說明:
764
		#函式說明:
765
		#放置可以套用css樣式的圖片
765
		#放置可以套用css樣式的圖片
766
		#回傳結果:
766
		#回傳結果:
767
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
767
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
768
		#$result["error"],錯誤訊息陣列
768
		#$result["error"],錯誤訊息陣列
769
		#$result["function"],當前函數執行的名稱
769
		#$result["function"],當前函數執行的名稱
770
		#$result["content"],印出圖片的語法。		
770
		#$result["content"],印出圖片的語法。
771
		#必填參數:
771
		#必填參數:
772
		$conf["img"]["show"]["position"]="copyRight.png";#圖片位置
772
		$conf["img"]["show"]["position"]="copyRight.png";#圖片位置
773
		#可省略參數:
773
		#可省略參數:
774
		#$conf["img"]["show"]["alt"]="not found";#若沒有圖片要用什麼文字顯示。
774
		#$conf["img"]["show"]["alt"]="not found";#若沒有圖片要用什麼文字顯示。
775
		$conf["img"]["show"]["class"]="imgIsolationLayerStyle".$conf["imgLeft"].$conf["imgTop"];#要套用的css樣式類別名稱。
775
		$conf["img"]["show"]["class"]="imgIsolationLayerStyle".$conf["imgLeft"].$conf["imgTop"];#要套用的css樣式類別名稱。
776
		$show=img::show($conf["img"]["show"]);
776
		$show=img::show($conf["img"]["show"]);
777
		unset($conf["img"]["show"]);
777
		unset($conf["img"]["show"]);
778
		
778
 
779
		#如果放置圖片的語法建立失敗
779
		#如果放置圖片的語法建立失敗
780
		if($show["status"]=="false"){
780
		if($show["status"]=="false"){
781
			
781
 
782
			#設置執行失敗
782
			#設置執行失敗
783
			$result["status"]="false";
783
			$result["status"]="false";
784
			
784
 
785
			#設置執行錯誤訊息
785
			#設置執行錯誤訊息
786
			$result["error"]=$show;
786
			$result["error"]=$show;
787
 
787
 
788
			#回傳結果
788
			#回傳結果
789
			return $result;
789
			return $result;
790
			
790
 
791
			}#if end
791
			}#if end
792
		
792
 
793
		#串接顯示隔離層圖片的語法
793
		#串接顯示隔離層圖片的語法
794
		$result["content"]=$result["content"].$show["content"];
794
		$result["content"]=$result["content"].$show["content"];
795
 
795
 
796
		#執行到這邊代表執行成功
796
		#執行到這邊代表執行成功
797
		$result["status"]="true";
797
		$result["status"]="true";
798
		
798
 
799
		#回傳語法
799
		#回傳語法
800
		return $result;
800
		return $result;
801
 
801
 
802
		}#function imgProtect end
802
		}#function imgProtect end
803
 
803
 
Line 820... Line 820...
820
	#無.
820
	#無.
821
	#備註:
821
	#備註:
822
	#僅支援單行只出現<?php、?>、其他內容的PHP檔案格式內容.
822
	#僅支援單行只出現<?php、?>、其他內容的PHP檔案格式內容.
823
	*/
823
	*/
824
	public static function encodePHP(&$conf){
824
	public static function encodePHP(&$conf){
825
	
825
 
826
		#初始化要回傳的內容
826
		#初始化要回傳的內容
827
		$result=array();
827
		$result=array();
828
		
828
 
829
		#取得當前執行的函式
829
		#取得當前執行的函式
830
		$result["function"]=__FUNCTION__;
830
		$result["function"]=__FUNCTION__;
831
		
831
 
832
		#如果 $conf 不為陣列
832
		#如果 $conf 不為陣列
833
		if(gettype($conf)!="array"){
833
		if(gettype($conf)!="array"){
834
			
834
 
835
			#設置執行失敗
835
			#設置執行失敗
836
			$result["status"]="false";
836
			$result["status"]="false";
837
			
837
 
838
			#設置執行錯誤訊息
838
			#設置執行錯誤訊息
839
			$result["error"][]="\$conf變數須為陣列形態";
839
			$result["error"][]="\$conf變數須為陣列形態";
840
 
840
 
841
			#如果傳入的參數為 null
841
			#如果傳入的參數為 null
842
			if($conf==null){
842
			if($conf==null){
843
				
843
 
844
				#設置執行錯誤訊息
844
				#設置執行錯誤訊息
845
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
845
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
846
				
846
 
847
				}#if end
847
				}#if end
848
 
848
 
849
			#回傳結果
849
			#回傳結果
850
			return $result;
850
			return $result;
851
			
851
 
852
			}#if end
852
			}#if end
853
 
853
 
854
		#初始加密好的php程式內容
854
		#初始加密好的php程式內容
855
		$result["content"]="";
855
		$result["content"]="";
856
	
856
 
857
		#檢查參數
857
		#檢查參數
858
		#函式說明:
858
		#函式說明:
859
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
859
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
860
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
860
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
861
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
861
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 870... Line 870...
870
		#必填寫的參數:
870
		#必填寫的參數:
871
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
871
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
872
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
872
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
873
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
873
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
874
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("phpFile","fileArgu");
874
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("phpFile","fileArgu");
875
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
875
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object");
876
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
876
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
877
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
877
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
878
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
878
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
879
		#可以省略的參數:
879
		#可以省略的參數:
880
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
880
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
881
		#$conf["canBeEmptyString"]="false";
881
		#$conf["canBeEmptyString"]="false";
882
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
882
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
883
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("useBase64");
883
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("useBase64");
884
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
884
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
885
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
885
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
886
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
886
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
887
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true");
887
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true");
888
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
888
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
889
		#$conf["arrayCountEqualCheck"][]=array();
889
		#$conf["arrayCountEqualCheck"][]=array();
890
		#參考資料來源:
890
		#參考資料來源:
891
		#array_keys=>http://php.net/manual/en/function.array-keys.php
891
		#array_keys=>http://php.net/manual/en/function.array-keys.php
892
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
892
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
893
		unset($conf["variableCheck::checkArguments"]);
893
		unset($conf["variableCheck::checkArguments"]);
894
				
894
 
895
		#如果檢查失敗
895
		#如果檢查失敗
896
		if($checkArguments["status"]=="false"){
896
		if($checkArguments["status"]=="false"){
897
			
897
 
898
			#設置執行失敗
898
			#設置執行失敗
899
			$result["status"]="false";
899
			$result["status"]="false";
900
			
900
 
901
			#設置執行錯誤訊息
901
			#設置執行錯誤訊息
902
			$result["error"]=$checkArguments;
902
			$result["error"]=$checkArguments;
903
 
903
 
904
			#回傳結果
904
			#回傳結果
905
			return $result;
905
			return $result;
906
			
906
 
907
			}#if end	
907
			}#if end
908
			
908
 
909
		#如果檢查不通過
909
		#如果檢查不通過
910
		if($checkArguments["passed"]=="false"){
910
		if($checkArguments["passed"]=="false"){
911
			
911
 
912
			#設置執行失敗
912
			#設置執行失敗
913
			$result["status"]="false";
913
			$result["status"]="false";
914
			
914
 
915
			#設置執行錯誤訊息
915
			#設置執行錯誤訊息
916
			$result["error"]=$checkArguments;
916
			$result["error"]=$checkArguments;
917
 
917
 
918
			#回傳結果
918
			#回傳結果
919
			return $result;
919
			return $result;
920
			
920
 
921
			}#if end
921
			}#if end
922
			
922
 
923
		#函式說明:
923
		#函式說明:
924
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
924
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
925
		#回傳的變數說明:
925
		#回傳的變數說明:
926
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
926
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
927
		#$result["error"],錯誤訊息提示.
927
		#$result["error"],錯誤訊息提示.
Line 945... Line 945...
945
		#file=>http:#php.net/manual/en/function.file.php
945
		#file=>http:#php.net/manual/en/function.file.php
946
		#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
946
		#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
947
		#filesize=>http://php.net/manual/en/function.filesize.php
947
		#filesize=>http://php.net/manual/en/function.filesize.php
948
		$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
948
		$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
949
		unset($conf["fileAccess::getFileContent"]);
949
		unset($conf["fileAccess::getFileContent"]);
950
	
950
 
951
		#如果讀取檔案內容失敗
951
		#如果讀取檔案內容失敗
952
		if($getFileContent["status"]==="false"){
952
		if($getFileContent["status"]==="false"){
953
		
953
 
954
			#設置執行失敗
954
			#設置執行失敗
955
			$result["status"]="false";
955
			$result["status"]="false";
956
			
956
 
957
			#設置執行錯誤訊息
957
			#設置執行錯誤訊息
958
			$result["error"]=$getFileContent;
958
			$result["error"]=$getFileContent;
959
 
959
 
960
			#回傳結果
960
			#回傳結果
961
			return $result;
961
			return $result;
962
		
962
 
963
			}#if end
963
			}#if end
964
		
964
 
965
		#加密過後的php內容
965
		#加密過後的php內容
966
		$contentWithoutPhpTagArray=array();
966
		$contentWithoutPhpTagArray=array();
967
		
967
 
968
		#識別是否開始php語法了.
968
		#識別是否開始php語法了.
969
		$isPHP=false;
969
		$isPHP=false;
970
		
970
 
971
		#識別是否讀取到php tag開頭
971
		#識別是否讀取到php tag開頭
972
		$phpStart=false;
972
		$phpStart=false;
973
		
973
 
974
		#識別是否讀取到php tag結尾
974
		#識別是否讀取到php tag結尾
975
		$phpEed=true;
975
		$phpEed=true;
976
		
976
 
977
		#針對每行內容
977
		#針對每行內容
978
		foreach($getFileContent["fileContent"] as $index=>$line){
978
		foreach($getFileContent["fileContent"] as $index=>$line){
979
		
979
 
980
			#debug
980
			#debug
981
			#echo "處理第".($index+1)."行".PHP_EOL;
981
			#echo "處理第".($index+1)."行".PHP_EOL;
982
		
982
 
983
			#函式說明:
983
			#函式說明:
984
			#將固定格式的字串分開,並回傳分開的結果。
984
			#將固定格式的字串分開,並回傳分開的結果。
985
			#回傳結果:
985
			#回傳結果:
986
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
986
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
987
			#$result["error"],錯誤訊息陣列
987
			#$result["error"],錯誤訊息陣列
Line 1002... Line 1002...
1002
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
1002
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
1003
			unset($conf["stringProcess::spiltString"]);
1003
			unset($conf["stringProcess::spiltString"]);
1004
 
1004
 
1005
			#如果執行失敗
1005
			#如果執行失敗
1006
			if($spiltString["status"]==="false"){
1006
			if($spiltString["status"]==="false"){
1007
			
1007
 
1008
				#設置執行失敗
1008
				#設置執行失敗
1009
				$result["status"]="false";
1009
				$result["status"]="false";
1010
				
1010
 
1011
				#設置執行錯誤訊息
1011
				#設置執行錯誤訊息
1012
				$result["error"]=$spiltString;
1012
				$result["error"]=$spiltString;
1013
 
1013
 
1014
				#回傳結果
1014
				#回傳結果
1015
				return $result;
1015
				return $result;
1016
			
1016
 
1017
				}#if end
1017
				}#if end
1018
			
1018
 
1019
			#初始化該行的資訊描述
1019
			#初始化該行的資訊描述
1020
			$lineInfo=array();
1020
			$lineInfo=array();
1021
							
1021
 
1022
			#如果沒有關鍵字
1022
			#如果沒有關鍵字
1023
			if($spiltString["found"]==="false" && $isPHP===false){
1023
			if($spiltString["found"]==="false" && $isPHP===false){
1024
			
1024
 
1025
				#初始化暫存的資訊
1025
				#初始化暫存的資訊
1026
				$tempLineInfo=array();
1026
				$tempLineInfo=array();
1027
			
1027
 
1028
				#預設該行不是php的內容
1028
				#預設該行不是php的內容
1029
				$tempLineInfo["isPHP"]=false;
1029
				$tempLineInfo["isPHP"]=false;
1030
				
1030
 
1031
				#放置內容
1031
				#放置內容
1032
				$tempLineInfo["content"]=$line;
1032
				$tempLineInfo["content"]=$line;
1033
				
1033
 
1034
				#儲存一行資訊描述
1034
				#儲存一行資訊描述
1035
				$lineInfo[]=$tempLineInfo;
1035
				$lineInfo[]=$tempLineInfo;
1036
			
1036
 
1037
				}#if end
1037
				}#if end
1038
 
1038
 
1039
			#反之有關鍵字且 現在是屬於 php 的範圍
1039
			#反之有關鍵字且 現在是屬於 php 的範圍
1040
			else if($spiltString["found"]==="false" && $isPHP===true){
1040
			else if($spiltString["found"]==="false" && $isPHP===true){
1041
			
1041
 
1042
				#確認該段目前沒有 "?".">" 結尾
1042
				#確認該段目前沒有 "?".">" 結尾
1043
			
1043
 
1044
				#函式說明:
1044
				#函式說明:
1045
				#將固定格式的字串分開,並回傳分開的結果。
1045
				#將固定格式的字串分開,並回傳分開的結果。
1046
				#回傳結果:
1046
				#回傳結果:
1047
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1047
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1048
				#$result["error"],錯誤訊息陣列
1048
				#$result["error"],錯誤訊息陣列
Line 1063... Line 1063...
1063
				$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
1063
				$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
1064
				unset($conf["stringProcess::spiltString"]);
1064
				unset($conf["stringProcess::spiltString"]);
1065
 
1065
 
1066
				#如果執行失敗
1066
				#如果執行失敗
1067
				if($spiltString["status"]==="false"){
1067
				if($spiltString["status"]==="false"){
1068
				
1068
 
1069
					#設置執行失敗
1069
					#設置執行失敗
1070
					$result["status"]="false";
1070
					$result["status"]="false";
1071
					
1071
 
1072
					#設置執行錯誤訊息
1072
					#設置執行錯誤訊息
1073
					$result["error"]=$spiltString;
1073
					$result["error"]=$spiltString;
1074
 
1074
 
1075
					#回傳結果
1075
					#回傳結果
1076
					return $result;
1076
					return $result;
1077
				
1077
 
1078
					}#if end
1078
					}#if end
1079
			
1079
 
1080
				#反之有關鍵字且 現在是屬於 php 的範圍
1080
				#反之有關鍵字且 現在是屬於 php 的範圍
1081
				if($spiltString["found"]==="false" && $isPHP===true){
1081
				if($spiltString["found"]==="false" && $isPHP===true){
1082
				
1082
 
1083
					#初始化暫存的資訊
1083
					#初始化暫存的資訊
1084
					$tempLineInfo=array();
1084
					$tempLineInfo=array();
1085
				
1085
 
1086
					#預設該行不是php的內容
1086
					#預設該行不是php的內容
1087
					$tempLineInfo["isPHP"]=true;
1087
					$tempLineInfo["isPHP"]=true;
1088
					
1088
 
1089
					#放置內容
1089
					#放置內容
1090
					$tempLineInfo["content"]=$line;
1090
					$tempLineInfo["content"]=$line;
1091
					
1091
 
1092
					#儲存一行資訊描述
1092
					#儲存一行資訊描述
1093
					$lineInfo[]=$tempLineInfo;
1093
					$lineInfo[]=$tempLineInfo;
1094
				
1094
 
1095
					}#if end
1095
					}#if end
1096
			
1096
 
1097
				#反之有找到關鍵字,且現在屬於 php 的範圍
1097
				#反之有找到關鍵字,且現在屬於 php 的範圍
1098
				else if($spiltString["found"]==="true" && $isPHP===true){
1098
				else if($spiltString["found"]==="true" && $isPHP===true){
1099
 
1099
 
1100
					#如果分割成0段
1100
					#如果分割成0段
1101
					if($spiltString["dataCounts"]===0){
1101
					if($spiltString["dataCounts"]===0){
1102
				
1102
 
1103
						#識別是否開始php語法了.
1103
						#識別是否開始php語法了.
1104
						$isPHP=false;
1104
						$isPHP=false;
1105
						
1105
 
1106
						#識別是否讀取到php tag開頭
1106
						#識別是否讀取到php tag開頭
1107
						$phpStart=false;
1107
						$phpStart=false;
1108
						
1108
 
1109
						#識別是否讀取到php tag結尾
1109
						#識別是否讀取到php tag結尾
1110
						$phpEed=true;
1110
						$phpEed=true;
1111
				
1111
 
1112
						}#if end
1112
						}#if end
1113
						
1113
 
1114
					#如果分割成其他段落
1114
					#如果分割成其他段落
1115
					else{
1115
					else{
1116
					
1116
 
1117
						#設置執行錯誤訊息
1117
						#設置執行錯誤訊息
1118
						$result["error"][]="not supported now";
1118
						$result["error"][]="not supported now";
1119
					
1119
 
1120
						}#else end
1120
						}#else end
1121
				
1121
 
1122
					}#if end
1122
					}#if end
1123
			
1123
 
1124
				}#if end
1124
				}#if end
1125
 
1125
 
1126
			#反之有關鍵字
1126
			#反之有關鍵字
1127
			else if($spiltString["found"]==="true"){
1127
			else if($spiltString["found"]==="true"){
1128
			
1128
 
1129
				#識別是否開始php語法了.
1129
				#識別是否開始php語法了.
1130
				$isPHP=true;
1130
				$isPHP=true;
1131
				
1131
 
1132
				#識別是否讀取到php tag開頭
1132
				#識別是否讀取到php tag開頭
1133
				$phpStart=true;
1133
				$phpStart=true;
1134
				
1134
 
1135
				#識別是否讀取到php tag結尾
1135
				#識別是否讀取到php tag結尾
1136
				$phpEed=false;
1136
				$phpEed=false;
1137
			
1137
 
1138
				#如果切成兩段
1138
				#如果切成兩段
1139
				if($spiltString["dataCounts"]===2){
1139
				if($spiltString["dataCounts"]===2){
1140
				
1140
 
1141
					#儲存非 php 的字串
1141
					#儲存非 php 的字串
1142
					$noPHPstr=$spiltString["dataArray"][0];
1142
					$noPHPstr=$spiltString["dataArray"][0];
1143
				
1143
 
1144
					#初始化暫存的資訊
1144
					#初始化暫存的資訊
1145
					$tempLineInfo=array();
1145
					$tempLineInfo=array();
1146
					
1146
 
1147
					#預設該行不是php的內容
1147
					#預設該行不是php的內容
1148
					$tempLineInfo["isPHP"]=false;
1148
					$tempLineInfo["isPHP"]=false;
1149
				
1149
 
1150
					#放置內容
1150
					#放置內容
1151
					$tempLineInfo["content"]=$noPHPstr;
1151
					$tempLineInfo["content"]=$noPHPstr;
1152
				
1152
 
1153
					#儲存屬於 php 的字串
1153
					#儲存屬於 php 的字串
1154
					$phpStr=$spiltString["dataArray"][1];
1154
					$phpStr=$spiltString["dataArray"][1];
1155
										
1155
 
1156
					#初始化暫存的資訊
1156
					#初始化暫存的資訊
1157
					$tempLineInfo=array();
1157
					$tempLineInfo=array();
1158
					
1158
 
1159
					#預設該行不是php的內容
1159
					#預設該行不是php的內容
1160
					$tempLineInfo["isPHP"]=true;
1160
					$tempLineInfo["isPHP"]=true;
1161
				
1161
 
1162
					#放置內容
1162
					#放置內容
1163
					$tempLineInfo["content"]=$noPHPstr;
1163
					$tempLineInfo["content"]=$noPHPstr;
1164
				
1164
 
1165
					}#if end
1165
					}#if end
1166
				
1166
 
1167
				#反之切成一段
1167
				#反之切成一段
1168
				else if($spiltString["dataCounts"]===1){
1168
				else if($spiltString["dataCounts"]===1){
1169
				
1169
 
1170
					#設置執行失敗
1170
					#設置執行失敗
1171
					$result["status"]="false";
1171
					$result["status"]="false";
1172
					
1172
 
1173
					#設置執行錯誤訊息
1173
					#設置執行錯誤訊息
1174
					$result["error"][]="not supported now";
1174
					$result["error"][]="not supported now";
1175
 
1175
 
1176
					#回傳結果
1176
					#回傳結果
1177
					return $result;
1177
					return $result;
1178
				
1178
 
1179
					}#else end
1179
					}#else end
1180
				
1180
 
1181
				#反之切成0段
1181
				#反之切成0段
1182
				else if($spiltString["dataCounts"]===0){
1182
				else if($spiltString["dataCounts"]===0){
1183
				
1183
 
1184
					#do nothing
1184
					#do nothing
1185
				
1185
 
1186
					}#else end
1186
					}#else end
1187
				
1187
 
1188
				#反之
1188
				#反之
1189
				else{
1189
				else{
1190
					#設置執行失敗
1190
					#設置執行失敗
1191
					$result["status"]="false";
1191
					$result["status"]="false";
1192
					
1192
 
1193
					#設置執行錯誤訊息
1193
					#設置執行錯誤訊息
1194
					$result["error"][]="not supported now";
1194
					$result["error"][]="not supported now";
1195
 
1195
 
1196
					#回傳結果
1196
					#回傳結果
1197
					return $result;
1197
					return $result;
1198
				
1198
 
1199
					}#else end
1199
					}#else end
1200
			
1200
 
1201
				}#else end
1201
				}#else end
1202
 
1202
 
1203
			#真對每個字串
1203
			#真對每個字串
1204
			foreach($lineInfo as $linfo){
1204
			foreach($lineInfo as $linfo){
1205
			
1205
 
1206
				#記錄起來			
1206
				#記錄起來
1207
				$contentWithoutPhpTagArray[]=$linfo;
1207
				$contentWithoutPhpTagArray[]=$linfo;
1208
			
1208
 
1209
				}#foreach end
1209
				}#foreach end
1210
						
1210
 
1211
			}#foreach end
1211
			}#foreach end
1212
			
1212
 
1213
		#debug
1213
		#debug
1214
		#var_dump($contentWithoutPhpTagArray);
1214
		#var_dump($contentWithoutPhpTagArray);
1215
		
1215
 
1216
		#儲存每行的檔案內容
1216
		#儲存每行的檔案內容
1217
		$res=array();
1217
		$res=array();
1218
		
1218
 
1219
		#php段落
1219
		#php段落
1220
		$phpSection="";
1220
		$phpSection="";
1221
		
1221
 
1222
		#針對每行程式
1222
		#針對每行程式
1223
		foreach($contentWithoutPhpTagArray as $lineInfo){
1223
		foreach($contentWithoutPhpTagArray as $lineInfo){
1224
		
1224
 
1225
			#如果不是 php
1225
			#如果不是 php
1226
			if($lineInfo["isPHP"]===false){
1226
			if($lineInfo["isPHP"]===false){
1227
			
1227
 
1228
				#如果有php段落
1228
				#如果有php段落
1229
				if(!empty($phpSection)){
1229
				if(!empty($phpSection)){
1230
				
1230
 
1231
					#加密php程式			
1231
					#加密php程式
1232
					$encodedPHP=base64_encode($phpSection);
1232
					$encodedPHP=base64_encode($phpSection);
1233
				
1233
 
1234
					#串接內容
1234
					#串接內容
1235
					$res[]="<?php eval(base64_decode(\"".$encodedPHP."\")); ?>";
1235
					$res[]="<?php eval(base64_decode(\"".$encodedPHP."\")); ?>";
1236
				
1236
 
1237
					}#if end
1237
					}#if end
1238
					
1238
 
1239
				#清空php段落
1239
				#清空php段落
1240
				$phpSection="";
1240
				$phpSection="";
1241
					
1241
 
1242
				#串接內容
1242
				#串接內容
1243
				$res[]=$lineInfo["content"].PHP_EOL;
1243
				$res[]=$lineInfo["content"].PHP_EOL;
1244
			
1244
 
1245
				}#if end
1245
				}#if end
1246
				
1246
 
1247
			#反之是 PHP 內容
1247
			#反之是 PHP 內容
1248
			else{
1248
			else{
1249
				#有內容才處理
1249
				#有內容才處理
1250
				if(!empty($lineInfo["content"])){
1250
				if(!empty($lineInfo["content"])){
1251
			
1251
 
1252
					#串接php語法
1252
					#串接php語法
1253
					$phpSection=$phpSection.$lineInfo["content"].PHP_EOL;
1253
					$phpSection=$phpSection.$lineInfo["content"].PHP_EOL;
1254
						
1254
 
1255
					}#if end
1255
					}#if end
1256
			
1256
 
1257
				}#else end
1257
				}#else end
1258
		
1258
 
1259
			}#foreach end
1259
			}#foreach end
1260
		
1260
 
1261
		#如果有php段落
1261
		#如果有php段落
1262
		if(!empty($phpSection)){
1262
		if(!empty($phpSection)){
1263
		
1263
 
1264
			#加密php程式			
1264
			#加密php程式
1265
			$encodedPHP=base64_encode($phpSection);
1265
			$encodedPHP=base64_encode($phpSection);
1266
		
1266
 
1267
			#串接內容
1267
			#串接內容
1268
			$res[]="<?php eval(base64_decode(\"".$encodedPHP."\")); ?>";
1268
			$res[]="<?php eval(base64_decode(\"".$encodedPHP."\")); ?>";
1269
		
1269
 
1270
			}#if end
1270
			}#if end
1271
			
1271
 
1272
		#var_dump($res);exit;
1272
		#var_dump($res);exit;
1273
		
1273
 
1274
		#針對每個要寫入的行內容
1274
		#針對每個要寫入的行內容
1275
		foreach($res as $line){
1275
		foreach($res as $line){
1276
		
1276
 
1277
			$result["content"]=$result["content"].$line;
1277
			$result["content"]=$result["content"].$line;
1278
		
1278
 
1279
			}#foreach end
1279
			}#foreach end
1280
		
1280
 
1281
		#設置執行正常
1281
		#設置執行正常
1282
		$result["status"]="true";
1282
		$result["status"]="true";
1283
	
1283
 
1284
		#回傳結果
1284
		#回傳結果
1285
		return $result;
1285
		return $result;
1286
	
1286
 
1287
		}#function encodePHP end
1287
		}#function encodePHP end
1288
 
1288
 
1289
	}#class security end
1289
	}#class security end
1290
 
1290
 
1291
?>
1291
?>