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
	#放置html5支援的聲音
100
	#放置html5支援的聲音
Line 114... Line 114...
114
	#$conf["type"]="audio/ogg";
114
	#$conf["type"]="audio/ogg";
115
	#$conf["autoplay"],字串,爲是否自動播放,若要自動播放則應填入"true",預設爲不自動播放
115
	#$conf["autoplay"],字串,爲是否自動播放,若要自動播放則應填入"true",預設爲不自動播放
116
	#$conf["autoplay"]="true";
116
	#$conf["autoplay"]="true";
117
	#$conf["loop"],字串,爲是否重複播放,若要重複播放則應填入 "true" ,預設爲不重複
117
	#$conf["loop"],字串,爲是否重複播放,若要重複播放則應填入 "true" ,預設爲不重複
118
	#$conf["loop"]="false";
118
	#$conf["loop"]="false";
119
	*/	
119
	*/
120
	function html5($conf){
120
	function html5($conf){
121
 
121
 
122
		#初始化要回傳的內容
122
		#初始化要回傳的內容
123
		$result=array();
123
		$result=array();
124
		
124
 
125
		#取得當前函數名稱
125
		#取得當前函數名稱
126
		$result["function"]=__FUNCTION__;
126
		$result["function"]=__FUNCTION__;
127
		
127
 
128
		#如果 $conf 不為陣列
128
		#如果 $conf 不為陣列
129
		if(gettype($conf)!="array"){
129
		if(gettype($conf)!="array"){
130
			
130
 
131
			#設置執行失敗
131
			#設置執行失敗
132
			$result["status"]="false";
132
			$result["status"]="false";
133
			
133
 
134
			#設置執行錯誤訊息
134
			#設置執行錯誤訊息
135
			$result["error"][]="\$conf變數須為陣列形態";
135
			$result["error"][]="\$conf變數須為陣列形態";
136
 
136
 
137
			#如果傳入的參數為 null
137
			#如果傳入的參數為 null
138
			if($conf==null){
138
			if($conf==null){
139
				
139
 
140
				#設置執行錯誤訊息
140
				#設置執行錯誤訊息
141
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
141
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
142
				
142
 
143
				}#if end
143
				}#if end
144
 
144
 
145
			#回傳結果
145
			#回傳結果
146
			return $result;
146
			return $result;
147
			
147
 
148
			}#if end
148
			}#if end
149
			
149
 
150
		#初始化要回傳的語法
150
		#初始化要回傳的語法
151
		$result["content"]="";
151
		$result["content"]="";
152
		
152
 
153
		#檢查參數
153
		#檢查參數
154
		#函式說明:
154
		#函式說明:
155
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
155
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
156
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
156
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
157
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
157
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 166... Line 166...
166
		#必填寫的參數:
166
		#必填寫的參數:
167
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
167
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
168
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
168
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
169
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
169
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
170
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","audioPosition");
170
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","audioPosition");
171
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
171
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object");
172
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
172
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
173
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
173
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
174
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
174
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
175
		#可以省略的參數:
175
		#可以省略的參數:
176
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
176
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
177
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
177
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
178
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
178
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
179
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("type","autoplay","loop");
179
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("type","autoplay","loop");
180
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
180
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
181
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
181
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
182
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
182
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
183
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("audio/ogg","false","false");
183
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("audio/ogg","false","false");
184
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
184
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
185
		#$conf["arrayCountEqualCheck"][]=array();
185
		#$conf["arrayCountEqualCheck"][]=array();
186
		#參考資料來源:
186
		#參考資料來源:
187
		#array_keys=>http://php.net/manual/en/function.array-keys.php
187
		#array_keys=>http://php.net/manual/en/function.array-keys.php
188
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
188
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
189
		unset($conf["variableCheck::checkArguments"]);
189
		unset($conf["variableCheck::checkArguments"]);
190
	
190
 
191
		#如果檢查失敗
191
		#如果檢查失敗
192
		if($checkArguments["status"]=="false"){
192
		if($checkArguments["status"]=="false"){
193
			
193
 
194
			#設置錯誤識別
194
			#設置錯誤識別
195
			$result["status"]="false";
195
			$result["status"]="false";
196
			
196
 
197
			#設置錯誤訊息
197
			#設置錯誤訊息
198
			$result["error"]=$checkArguments;
198
			$result["error"]=$checkArguments;
199
			
199
 
200
			#回傳結果
200
			#回傳結果
201
			return $result;
201
			return $result;
202
			
202
 
203
			}#if end
203
			}#if end
204
	
204
 
205
		#如果檢查不通過
205
		#如果檢查不通過
206
		if($checkArguments["passed"]=="false"){
206
		if($checkArguments["passed"]=="false"){
207
			
207
 
208
			#設置錯誤識別
208
			#設置錯誤識別
209
			$result["status"]="false";
209
			$result["status"]="false";
210
			
210
 
211
			#設置錯誤訊息
211
			#設置錯誤訊息
212
			$result["error"]=$checkArguments;
212
			$result["error"]=$checkArguments;
213
			
213
 
214
			#回傳結果
214
			#回傳結果
215
			return $result;
215
			return $result;
216
			
216
 
217
			}#if end
217
			}#if end
218
 
218
 
219
		#檢查語音檔案是否存在
219
		#檢查語音檔案是否存在
220
		#涵式說明:檢查多個檔案與資料夾是否存在.
220
		#涵式說明:檢查多個檔案與資料夾是否存在.
221
		#回傳的結果:
221
		#回傳的結果:
Line 235... Line 235...
235
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
235
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
236
		unset($conf["fileAccess::checkMultiFileExist"]);
236
		unset($conf["fileAccess::checkMultiFileExist"]);
237
 
237
 
238
		#如果檢查失敗
238
		#如果檢查失敗
239
		if($checkMultiFileExist["status"]=="false"){
239
		if($checkMultiFileExist["status"]=="false"){
240
			
240
 
241
			#設置執行不正常
241
			#設置執行不正常
242
			$result["status"]="false";
242
			$result["status"]="false";
243
			
243
 
244
			#設置執行錯誤
244
			#設置執行錯誤
245
			$result["error"]=$checkMultiFileExist;
245
			$result["error"]=$checkMultiFileExist;
246
			
246
 
247
			#回傳結果
247
			#回傳結果
248
			return $result;
248
			return $result;
249
			
249
 
250
			}#if end
250
			}#if end
251
			
251
 
252
		#如果聲音檔案不存在
252
		#如果聲音檔案不存在
253
		if($checkMultiFileExist["varExist"][0]=="false"){
253
		if($checkMultiFileExist["varExist"][0]=="false"){
254
			
254
 
255
			#設置執行不正常
255
			#設置執行不正常
256
			$result["status"]="false";
256
			$result["status"]="false";
257
			
257
 
258
			#設置執行錯誤
258
			#設置執行錯誤
259
			$result["error"][]="聲音檔案「".$checkMultiFileExist["varName"][0]."」不存在!";
259
			$result["error"][]="聲音檔案「".$checkMultiFileExist["varName"][0]."」不存在!";
260
			
260
 
261
			#回傳結果
261
			#回傳結果
262
			return $result;
262
			return $result;
263
			
263
 
264
			}#if end
264
			}#if end
265
			
265
 
266
		#將聲音檔案用 base64 形式壓縮成16近位的英文數字
266
		#將聲音檔案用 base64 形式壓縮成16近位的英文數字
267
		#函數說明:
267
		#函數說明:
268
		#用data:mimeType;base64,fileVar的形式來提供檔案的連結,亦即檔案儲存在變數裡面.
268
		#用data:mimeType;base64,fileVar的形式來提供檔案的連結,亦即檔案儲存在變數裡面.
269
		#回傳結果:
269
		#回傳結果:
270
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
270
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
271
		#$result["error"],錯誤訊息
271
		#$result["error"],錯誤訊息
272
		#$result["content"],檔案變數的內容
272
		#$result["content"],檔案變數的內容
273
		#$result["fileTypeName"],副檔名,ex:「.tar.xz」.
273
		#$result["fileTypeName"],副檔名,ex:「.tar.xz」.
274
		#$result["function"],當前執行的函數名稱 
274
		#$result["function"],當前執行的函數名稱
275
		#必填參數:
275
		#必填參數:
276
		#$conf["filePosition"],要轉存成2元碼的圖片檔案位置與名稱
276
		#$conf["filePosition"],要轉存成2元碼的圖片檔案位置與名稱
277
		$conf["fileAccess::data"]["filePosition"]=$conf["audioPosition"];
277
		$conf["fileAccess::data"]["filePosition"]=$conf["audioPosition"];
278
		#$conf["mimeType"],2元碼的內容是什麼
278
		#$conf["mimeType"],2元碼的內容是什麼
279
		$conf["fileAccess::data"]["mimeType"]=$conf["type"];
279
		$conf["fileAccess::data"]["mimeType"]=$conf["type"];
Line 288... Line 288...
288
		$data=fileAccess::data($conf["fileAccess::data"]);
288
		$data=fileAccess::data($conf["fileAccess::data"]);
289
		unset($conf["fileAccess::data"]);
289
		unset($conf["fileAccess::data"]);
290
 
290
 
291
		#如果將聲音檔案用 base64 形式壓縮成16近位的英文數字失敗
291
		#如果將聲音檔案用 base64 形式壓縮成16近位的英文數字失敗
292
		if($data["status"]=="false"){
292
		if($data["status"]=="false"){
293
			
293
 
294
			#設置執行不正常
294
			#設置執行不正常
295
			$result["status"]="false";
295
			$result["status"]="false";
296
			
296
 
297
			#設置執行錯誤
297
			#設置執行錯誤
298
			$result["error"]=$data;
298
			$result["error"]=$data;
299
			
299
 
300
			#回傳結果
300
			#回傳結果
301
			return $result;
301
			return $result;
302
			
302
 
303
			}#if end
303
			}#if end
304
 
304
 
305
		#如果$conf["autoplay"]為"true"
305
		#如果$conf["autoplay"]為"true"
306
		if($conf["autoplay"]=="true"){
306
		if($conf["autoplay"]=="true"){
307
 
307
 
308
			#則放置自動播放的語法
308
			#則放置自動播放的語法
309
			$conf["autoplay"]=" autoplay=autoplay";
309
			$conf["autoplay"]=" autoplay=autoplay";
310
			
310
 
311
			}#if end
311
			}#if end
312
		
312
 
313
		#反之	
313
		#反之
314
		else{
314
		else{
315
			
315
 
316
			#設為空字串
316
			#設為空字串
317
			$conf["autoplay"]="";
317
			$conf["autoplay"]="";
318
			
318
 
319
			}#else end
319
			}#else end
320
 
320
 
321
		#如果$conf["loop"]為"true"
321
		#如果$conf["loop"]為"true"
322
		if($conf["loop"]=="true"){
322
		if($conf["loop"]=="true"){
323
 
323
 
324
			#則放置重複播放的語法		
324
			#則放置重複播放的語法
325
			$conf["loop"]=" loop=loop";
325
			$conf["loop"]=" loop=loop";
326
			
326
 
327
			}#if end
327
			}#if end
328
			
328
 
329
		#反之	
329
		#反之
330
		else{
330
		else{
331
			
331
 
332
			#設為空字串
332
			#設為空字串
333
			$conf["loop"]="";
333
			$conf["loop"]="";
334
			
334
 
335
			}#else end
335
			}#else end
336
			
336
 
337
		#設定語音類型
337
		#設定語音類型
338
		$conf["type"]=" type=".$conf["type"];
338
		$conf["type"]=" type=".$conf["type"];
339
		
339
 
340
		#顯示聲音播放器控制面板,是否自動播放、是否重複播放。
340
		#顯示聲音播放器控制面板,是否自動播放、是否重複播放。
341
		$result["content"]=$result["content"]."<audio controls=controls ".$conf["autoplay"]." ".$conf["loop"].">";
341
		$result["content"]=$result["content"]."<audio controls=controls ".$conf["autoplay"]." ".$conf["loop"].">";
342
		$base64data="<audio controls=controls ".$conf["autoplay"]." ".$conf["loop"].">";
342
		$base64data="<audio controls=controls ".$conf["autoplay"]." ".$conf["loop"].">";
343
 
343
 
344
		#聲音檔案位置、形態、
344
		#聲音檔案位置、形態、
Line 346... Line 346...
346
		$base64data=$base64data."<source src = ".$data["content"]." ".$conf["type"]." preload=auto />";
346
		$base64data=$base64data."<source src = ".$data["content"]." ".$conf["type"]." preload=auto />";
347
 
347
 
348
		#放置聲音的html5標籤結束
348
		#放置聲音的html5標籤結束
349
		$result["content"]=$result["content"]."</audio>";
349
		$result["content"]=$result["content"]."</audio>";
350
		$base64data=$base64data."</audio>";
350
		$base64data=$base64data."</audio>";
351
		
351
 
352
		#儲存用 base64 形式壓縮成16近位英文數字的聲音檔案
352
		#儲存用 base64 形式壓縮成16近位英文數字的聲音檔案
353
		$result["base64data"]=$base64data;
353
		$result["base64data"]=$base64data;
354
		
354
 
355
		#設置執行正常
355
		#設置執行正常
356
		$result["status"]="true";
356
		$result["status"]="true";
357
		
357
 
358
		#回傳語法
358
		#回傳語法
359
		return $result;
359
		return $result;
360
	
360
 
361
		}#function html5 end
361
		}#function html5 end
362
 
362
 
363
	}#class sound end
363
	}#class sound end
364
 
364
 
365
?>
365
?>