Subversion Repositories php-qbpwcf

Rev

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

Rev 3 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 43... Line 43...
43
	#$arguments,陣列,為呼叫方法時所用的參數.
43
	#$arguments,陣列,為呼叫方法時所用的參數.
44
	#參考資料:
44
	#參考資料:
45
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
45
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
46
	*/
46
	*/
47
	public function __call($method,$arguments){
47
	public function __call($method,$arguments){
48
		
48
 
49
		#取得當前執行的函式
49
		#取得當前執行的函式
50
		$result["function"]=__FUNCTION__;
50
		$result["function"]=__FUNCTION__;
51
		
51
 
52
		#設置執行不正常
52
		#設置執行不正常
53
		$result["status"]="false";
53
		$result["status"]="false";
54
		
54
 
55
		#設置執行錯誤
55
		#設置執行錯誤
56
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
56
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
57
		
57
 
58
		#設置所丟入的參數
58
		#設置所丟入的參數
59
		$result["error"][]=$arguments;
59
		$result["error"][]=$arguments;
60
		
60
 
61
		#回傳結果
61
		#回傳結果
62
		return $result;
62
		return $result;
63
		
63
 
64
		}#function __call end
64
		}#function __call end
65
		
65
 
66
	/*
66
	/*
67
	#函式說明:
67
	#函式說明:
68
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
68
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
69
	#回傳結果:
69
	#回傳結果:
70
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
70
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 75... Line 75...
75
	#$arguments,陣列,為呼叫方法時所用的參數.
75
	#$arguments,陣列,為呼叫方法時所用的參數.
76
	#參考資料:
76
	#參考資料:
77
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
77
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
78
	*/
78
	*/
79
	public static function __callStatic($method,$arguments){
79
	public static function __callStatic($method,$arguments){
80
		
80
 
81
		#取得當前執行的函式
81
		#取得當前執行的函式
82
		$result["function"]=__FUNCTION__;
82
		$result["function"]=__FUNCTION__;
83
		
83
 
84
		#設置執行不正常
84
		#設置執行不正常
85
		$result["status"]="false";
85
		$result["status"]="false";
86
		
86
 
87
		#設置執行錯誤
87
		#設置執行錯誤
88
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
88
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
89
		
89
 
90
		#設置所丟入的參數
90
		#設置所丟入的參數
91
		$result["error"][]=$arguments;
91
		$result["error"][]=$arguments;
92
		
92
 
93
		#回傳結果
93
		#回傳結果
94
		return $result;
94
		return $result;
95
		
95
 
96
		}#function __callStatic end
96
		}#function __callStatic end
97
 
97
 
98
	/*
98
	/*
99
	#涵式說明:
99
	#涵式說明:
100
	#類別函數,將flash嵌入,會自動去背。
100
	#類別函數,將flash嵌入,會自動去背。
Line 118... Line 118...
118
	*/
118
	*/
119
	function show(&$conf){
119
	function show(&$conf){
120
 
120
 
121
		#初始化要回傳的變數
121
		#初始化要回傳的變數
122
		$result=array();
122
		$result=array();
123
		
123
 
124
		#設置當前執行的涵式
124
		#設置當前執行的涵式
125
		$result["function"]=__FUNCTION__;
125
		$result["function"]=__FUNCTION__;
126
		
126
 
127
		#如果 $conf 不為陣列
127
		#如果 $conf 不為陣列
128
		if(gettype($conf)!="array"){
128
		if(gettype($conf)!="array"){
129
			
129
 
130
			#設置執行失敗
130
			#設置執行失敗
131
			$result["status"]="false";
131
			$result["status"]="false";
132
			
132
 
133
			#設置執行錯誤訊息
133
			#設置執行錯誤訊息
134
			$result["error"][]="\$conf變數須為陣列形態";
134
			$result["error"][]="\$conf變數須為陣列形態";
135
 
135
 
136
			#如果傳入的參數為 null
136
			#如果傳入的參數為 null
137
			if($conf==null){
137
			if($conf==null){
138
				
138
 
139
				#設置執行錯誤訊息
139
				#設置執行錯誤訊息
140
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
140
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
141
				
141
 
142
				}#if end
142
				}#if end
143
 
143
 
144
			#回傳結果
144
			#回傳結果
145
			return $result;
145
			return $result;
146
			
146
 
147
			}#if end
147
			}#if end
148
		
148
 
149
		#檢查參數
149
		#檢查參數
150
		#函式說明:
150
		#函式說明:
151
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
151
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
152
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
152
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
153
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
153
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 162... Line 162...
162
		#必填寫的參數:
162
		#必填寫的參數:
163
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
163
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
164
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
164
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
165
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
165
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
166
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","swfFileLocation");
166
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","swfFileLocation");
167
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
167
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
168
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
168
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
169
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
169
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
170
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
170
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
171
		#可以省略的參數:
171
		#可以省略的參數:
172
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
172
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
173
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
173
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
174
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
174
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
175
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("width","height");
175
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("width","height");
176
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
176
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
177
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
177
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
178
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
178
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
179
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("100%","100%");
179
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("100%","100%");
180
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
180
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
181
		#$conf["arrayCountEqualCheck"][]=array();
181
		#$conf["arrayCountEqualCheck"][]=array();
Line 184... Line 184...
184
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
184
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
185
		unset($conf["variableCheck::checkArguments"]);
185
		unset($conf["variableCheck::checkArguments"]);
186
 
186
 
187
		#如果 $checkArguments["status"] 等於 "false"
187
		#如果 $checkArguments["status"] 等於 "false"
188
		if($checkArguments["status"]=="false"){
188
		if($checkArguments["status"]=="false"){
189
			
189
 
190
			#設置錯誤識別
190
			#設置錯誤識別
191
			$result["status"]="false";
191
			$result["status"]="false";
192
			
192
 
193
			#設置錯誤訊息
193
			#設置錯誤訊息
194
			$result["error"]=$checkArguments;
194
			$result["error"]=$checkArguments;
195
			
195
 
196
			#回傳結果
196
			#回傳結果
197
			return $result;				
197
			return $result;
198
			
198
 
199
			}#if end
199
			}#if end
200
			
200
 
201
		#如果 $checkArguments["passed"] 等於 "false"
201
		#如果 $checkArguments["passed"] 等於 "false"
202
		if($checkArguments["passed"]=="false"){
202
		if($checkArguments["passed"]=="false"){
203
			
203
 
204
			#設置錯誤識別
204
			#設置錯誤識別
205
			$result["status"]="false";
205
			$result["status"]="false";
206
			
206
 
207
			#設置錯誤訊息
207
			#設置錯誤訊息
208
			$result["error"]=$checkArguments;
208
			$result["error"]=$checkArguments;
209
			
209
 
210
			#回傳結果
210
			#回傳結果
211
			return $result;				
211
			return $result;
212
			
212
 
213
			}#if end
213
			}#if end
214
		
214
 
215
		#檢查flash檔案是否存在
215
		#檢查flash檔案是否存在
216
		#涵式說明:檢查多個檔案與資料夾是否存在.
216
		#涵式說明:檢查多個檔案與資料夾是否存在.
217
		#回傳的結果:
217
		#回傳的結果:
218
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
218
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
219
		#$result["error"],錯誤訊息陣列.
219
		#$result["error"],錯誤訊息陣列.
Line 237... Line 237...
237
		#http://php.net/manual/en/control-structures.foreach.php
237
		#http://php.net/manual/en/control-structures.foreach.php
238
		#備註:
238
		#備註:
239
		#函數file_exists檢查的路徑為檔案系統的路徑
239
		#函數file_exists檢查的路徑為檔案系統的路徑
240
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
240
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
241
		unset($conf["fileAccess::checkMultiFileExist"]);
241
		unset($conf["fileAccess::checkMultiFileExist"]);
242
		
242
 
243
		#如果檢查檔案失敗
243
		#如果檢查檔案失敗
244
		if($checkMultiFileExist["status"]=="false"){
244
		if($checkMultiFileExist["status"]=="false"){
245
			
245
 
246
			#設置錯誤識別
246
			#設置錯誤識別
247
			$result["status"]="false";
247
			$result["status"]="false";
248
			
248
 
249
			#設置錯誤訊息
249
			#設置錯誤訊息
250
			$result["error"]=$checkMultiFileExist;
250
			$result["error"]=$checkMultiFileExist;
251
			
251
 
252
			#回傳結果
252
			#回傳結果
253
			return $result;
253
			return $result;
254
			
254
 
255
			}#if end
255
			}#if end
256
			
256
 
257
		#如果檔案不存在
257
		#如果檔案不存在
258
		if($checkMultiFileExist["allExist"]=="false"){
258
		if($checkMultiFileExist["allExist"]=="false"){
259
			
259
 
260
			#設置錯誤識別
260
			#設置錯誤識別
261
			$result["status"]="false";
261
			$result["status"]="false";
262
			
262
 
263
			#設置錯誤訊息
263
			#設置錯誤訊息
264
			$result["error"]=$checkMultiFileExist;
264
			$result["error"]=$checkMultiFileExist;
265
			
265
 
266
			#回傳結果
266
			#回傳結果
267
			return $result;
267
			return $result;
268
			
268
 
269
			}#if end
269
			}#if end
270
											
270
 
271
		#設定寬度
271
		#設定寬度
272
		$conf["width"]="width = ".$conf["width"];
272
		$conf["width"]="width = ".$conf["width"];
273
 
273
 
274
		#設定高度
274
		#設定高度
275
		$conf["height"]="height = ".$conf["height"];
275
		$conf["height"]="height = ".$conf["height"];
276
		
276
 
277
		#wmode=transparent 這是去背的語法
277
		#wmode=transparent 這是去背的語法
278
		$result["content"]="<embed src = ".$checkMultiFileExist["varName"][0]." ".$conf["width"]." ".$conf["height"]." wmode = transparent>";       	
278
		$result["content"]="<embed src = ".$checkMultiFileExist["varName"][0]." ".$conf["width"]." ".$conf["height"]." wmode = transparent>";
279
	
279
 
280
		#將flash壓縮成base64字串
280
		#將flash壓縮成base64字串
281
		#application/x-shockwave-flash
281
		#application/x-shockwave-flash
282
		#函數說明:
282
		#函數說明:
283
		#用data:mimeType;base64,fileVar的形式來提供檔案的連結,亦即檔案儲存在變數裡面.
283
		#用data:mimeType;base64,fileVar的形式來提供檔案的連結,亦即檔案儲存在變數裡面.
284
		#回傳結果:
284
		#回傳結果:
285
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
285
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
286
		#$result["error"],錯誤訊息
286
		#$result["error"],錯誤訊息
287
		#$result["content"],檔案變數的內容
287
		#$result["content"],檔案變數的內容
288
		#$result["fileTypeName"],副檔名,ex:「.tar.xz」.
288
		#$result["fileTypeName"],副檔名,ex:「.tar.xz」.
289
		#$result["function"],當前執行的函數名稱 
289
		#$result["function"],當前執行的函數名稱
290
		#必填參數:
290
		#必填參數:
291
		#$conf["filePosition"],要轉存成2元碼的圖片檔案位置與名稱
291
		#$conf["filePosition"],要轉存成2元碼的圖片檔案位置與名稱
292
		$conf["fileAccess::data"]["filePosition"]=$checkMultiFileExist["varNameFullPath"][0];
292
		$conf["fileAccess::data"]["filePosition"]=$checkMultiFileExist["varNameFullPath"][0];
293
		#$conf["mimeType"],2元碼的內容是什麼
293
		#$conf["mimeType"],2元碼的內容是什麼
294
		$conf["fileAccess::data"]["mimeType"]="application/x-shockwave-flash";
294
		$conf["fileAccess::data"]["mimeType"]="application/x-shockwave-flash";
Line 300... Line 300...
300
		#參考資料:
300
		#參考資料:
301
		#將檔案用字串變數儲存起來=>http://php.net/manual/en/function.file-get-contents.php
301
		#將檔案用字串變數儲存起來=>http://php.net/manual/en/function.file-get-contents.php
302
		#壓縮2元碼=>http://php.net/manual/en/function.base64-encode.php
302
		#壓縮2元碼=>http://php.net/manual/en/function.base64-encode.php
303
		$data=fileAccess::data($conf["fileAccess::data"]);
303
		$data=fileAccess::data($conf["fileAccess::data"]);
304
		unset($conf["fileAccess::data"]);
304
		unset($conf["fileAccess::data"]);
305
			
305
 
306
		#如果加密成base64失敗
306
		#如果加密成base64失敗
307
		if($data["status"]=="false"){
307
		if($data["status"]=="false"){
308
			
308
 
309
			#設置錯誤識別
309
			#設置錯誤識別
310
			$result["status"]="false";
310
			$result["status"]="false";
311
			
311
 
312
			#設置錯誤訊息
312
			#設置錯誤訊息
313
			$result["error"]=$data;
313
			$result["error"]=$data;
314
			
314
 
315
			#回傳結果
315
			#回傳結果
316
			return $result;
316
			return $result;
317
			
317
 
318
			}#if end
318
			}#if end
319
	
319
 
320
		#儲存用base64加密的嵌入flash語法
320
		#儲存用base64加密的嵌入flash語法
321
		$result["contentBase64"]="<embed src = ".$data["content"]." ".$conf["width"]." ".$conf["height"]." wmode = transparent>";				
321
		$result["contentBase64"]="<embed src = ".$data["content"]." ".$conf["width"]." ".$conf["height"]." wmode = transparent>";
322
				
322
 
323
		#設置執行正常
323
		#設置執行正常
324
		$result["status"]="true";
324
		$result["status"]="true";
325
		
325
 
326
		#回傳結果
326
		#回傳結果
327
		return $result;
327
		return $result;
328
	
328
 
329
		}#function show end
329
		}#function show end
330
 
330
 
331
	}#class flash end
331
	}#class flash end
332
 
332
 
333
?>
333
?>