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
	#用 google map 的 api 1.0 版提供靜態的地圖.
100
	#用 google map 的 api 1.0 版提供靜態的地圖.
101
	#回傳結果:
101
	#回傳結果:
102
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
102
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
103
	#$result["error"],錯誤訊息	.
103
	#$result["error"],錯誤訊息	.
104
	#$result["function"],當前執行的函數名稱.
104
	#$result["function"],當前執行的函數名稱.
105
	#$result["argu"],使用的參數.
105
	#$result["argu"],使用的參數.
106
	#$result["content"],語法.	
106
	#$result["content"],語法.
107
	#必填參數:
107
	#必填參數:
108
	#無	
108
	#無
109
	#可省略參數:
109
	#可省略參數:
110
	#$conf["center"],字串陣列,地圖的中心位置,預設為array("City Hall","taipei","tw)",亦即"臺灣省(州)-臺北-市政府",也可以用緯經度array("40.714728,-73.998672").
110
	#$conf["center"],字串陣列,地圖的中心位置,預設為array("City Hall","taipei","tw)",亦即"臺灣省(州)-臺北-市政府",也可以用緯經度array("40.714728,-73.998672").
111
	#$conf["center"]=array();
111
	#$conf["center"]=array();
112
	#$conf["zoom"],字串,地圖的縮放等級,預設為16,可用範圍為10~19.
112
	#$conf["zoom"],字串,地圖的縮放等級,預設為16,可用範圍為10~19.
113
	#$conf["zoom"]="";
113
	#$conf["zoom"]="";
114
	#$conf["size"],字串陣列,地圖的大小,預設為array("400","400"),亦即400x400,最大為640x640.
114
	#$conf["size"],字串陣列,地圖的大小,預設為array("400","400"),亦即400x400,最大為640x640.
115
	#$conf["size"]=array();
115
	#$conf["size"]=array();
116
	#$conf["scale"],字串,地圖是否要放大,"false"為否,"true"為要放大.
116
	#$conf["scale"],字串,地圖是否要放大,"false"為否,"true"為要放大.
117
	#$conf["scale"]="false"; 
117
	#$conf["scale"]="false";
118
	#$conf["lang"],字串,要使用的輔助語言,預設為"en_US"為美語."zh_TW"為中文,
118
	#$conf["lang"],字串,要使用的輔助語言,預設為"en_US"為美語."zh_TW"為中文,
119
	#$conf["lang"]="en_US";
119
	#$conf["lang"]="en_US";
120
	#$conf["format"],字串,地圖圖片的檔案類型,預設為"png",若要快速載入可用"jpg".
120
	#$conf["format"],字串,地圖圖片的檔案類型,預設為"png",若要快速載入可用"jpg".
121
	#$conf["format"]="png";
121
	#$conf["format"]="png";
122
	#$conf["demo"],字串,是否為示範模式,"true"為是,"false"為不是,預設為"false",若為"true"則$conf["center"]參數無效.
122
	#$conf["demo"],字串,是否為示範模式,"true"為是,"false"為不是,預設為"false",若為"true"則$conf["center"]參數無效.
123
	#$conf["demo"]="";
123
	#$conf["demo"]="";
124
	#參考資料:
124
	#參考資料:
125
	#static-maps=>https://developers.google.com/maps/documentation/static-maps/?hl=zh-tw
125
	#static-maps=>https://developers.google.com/maps/documentation/static-maps/?hl=zh-tw
126
	*/
126
	*/
127
	function staticMap(&$conf){
127
	function staticMap(&$conf){
128
		
128
 
129
		#初始化要回傳的結果
129
		#初始化要回傳的結果
130
		$result=array();
130
		$result=array();
131
 
131
 
132
		#取得當前執行的函數名稱
132
		#取得當前執行的函數名稱
133
		$result["function"]=__FUNCTION__;
133
		$result["function"]=__FUNCTION__;
Line 135... Line 135...
135
		#取得參數
135
		#取得參數
136
		$result["argu"]=$conf;
136
		$result["argu"]=$conf;
137
 
137
 
138
		#如果 $conf 不為陣列
138
		#如果 $conf 不為陣列
139
		if(gettype($conf)!="array"){
139
		if(gettype($conf)!="array"){
140
		
140
 
141
			#設置執行失敗
141
			#設置執行失敗
142
			$result["status"]="false";
142
			$result["status"]="false";
143
		
143
 
144
			#設置執行錯誤訊息
144
			#設置執行錯誤訊息
145
			$result["error"][]="\$conf變數須為陣列形態";
145
			$result["error"][]="\$conf變數須為陣列形態";
146
		
146
 
147
			#如果傳入的參數為 null
147
			#如果傳入的參數為 null
148
			if($conf==null){
148
			if($conf==null){
149
			
149
 
150
				#設置執行錯誤訊息
150
				#設置執行錯誤訊息
151
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
151
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
152
			
152
 
153
				}#if end
153
				}#if end
154
 
154
 
155
			#回傳結果
155
			#回傳結果
156
			return $result;
156
			return $result;
157
		
157
 
158
		}#if end
158
		}#if end
159
		
159
 
160
		#檢查參數
160
		#檢查參數
161
		#函式說明:
161
		#函式說明:
162
		#檢查一包含數個可省略變數的陣列變數,其型態是否正確,省略掉的陣列變數可以直接給定預設值。
162
		#檢查一包含數個可省略變數的陣列變數,其型態是否正確,省略掉的陣列變數可以直接給定預設值。
163
		#回傳結果:
163
		#回傳結果:
164
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
164
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 177... Line 177...
177
		$conf["variableCheck::checkSkipableVarType"]["skipableVarTypeArray"]=array("array","string","array","string","string","string","string");
177
		$conf["variableCheck::checkSkipableVarType"]["skipableVarTypeArray"]=array("array","string","array","string","string","string","string");
178
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的變數要初始化為什麼,null代表不指定.
178
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的變數要初始化為什麼,null代表不指定.
179
		$conf["variableCheck::checkSkipableVarType"]["skipableVarDefaultValue"]=array(array("City Hall","taipei","tw"),"16",array("400","400"),"false","en_US","png","false");
179
		$conf["variableCheck::checkSkipableVarType"]["skipableVarDefaultValue"]=array(array("City Hall","taipei","tw"),"16",array("400","400"),"false","en_US","png","false");
180
		$checkSkipableVarType=variableCheck::checkSkipableVarType($conf["variableCheck::checkSkipableVarType"],$argu);
180
		$checkSkipableVarType=variableCheck::checkSkipableVarType($conf["variableCheck::checkSkipableVarType"],$argu);
181
		unset($conf["variableCheck::checkSkipableVarType"]);
181
		unset($conf["variableCheck::checkSkipableVarType"]);
182
		$conf=$argu;		
182
		$conf=$argu;
183
		
183
 
184
		#如果檢查參數失敗
184
		#如果檢查參數失敗
185
		if($checkSkipableVarType["status"]==="false"){
185
		if($checkSkipableVarType["status"]==="false"){
186
			
186
 
187
			#設置執行不正常
187
			#設置執行不正常
188
			$result["status"]="false";
188
			$result["status"]="false";
189
			
189
 
190
			#設置錯誤訊息
190
			#設置錯誤訊息
191
			$result["error"]=$checkSkipableVarType;
191
			$result["error"]=$checkSkipableVarType;
192
			
192
 
193
			#回傳結果
193
			#回傳結果
194
			return $result;
194
			return $result;
195
			
195
 
196
			}#if end
196
			}#if end
197
		
197
 
198
		#如果參數檢查不通過
198
		#如果參數檢查不通過
199
		if($checkSkipableVarType["passed"]==="false"){
199
		if($checkSkipableVarType["passed"]==="false"){
200
			
200
 
201
			#設置執行不正常
201
			#設置執行不正常
202
			$result["status"]="false";
202
			$result["status"]="false";
203
			
203
 
204
			#設置錯誤訊息
204
			#設置錯誤訊息
205
			$result["error"]=$checkSkipableVarType;
205
			$result["error"]=$checkSkipableVarType;
206
			
206
 
207
			#回傳結果
207
			#回傳結果
208
			return $result;
208
			return $result;
209
			
209
 
210
			}#if end
210
			}#if end
211
		
211
 
212
		#如果要demo
212
		#如果要demo
213
		if($conf["demo"]==="true"){
213
		if($conf["demo"]==="true"){
214
			
214
 
215
			#設定示範用的地點
215
			#設定示範用的地點
216
			$demoAddr[]=array("City Hall","taipei","tw");
216
			$demoAddr[]=array("City Hall","taipei","tw");
217
			$demoAddr[]=array("City Hall","new+york","NY");
217
			$demoAddr[]=array("City Hall","new+york","NY");
218
			$demoAddr[]=array("City Hall","Los+angeles","CA");
218
			$demoAddr[]=array("City Hall","Los+angeles","CA");
219
			$demoAddr[]=array("Paris","France");
219
			$demoAddr[]=array("Paris","France");
Line 221... Line 221...
221
			$demoAddr[]=array("Wellington","New Zealand");
221
			$demoAddr[]=array("Wellington","New Zealand");
222
			$demoAddr[]=array("Thanon Na Phra Lan Bangkok Thailand");
222
			$demoAddr[]=array("Thanon Na Phra Lan Bangkok Thailand");
223
			$demoAddr[]=array("Seoul","Korea");
223
			$demoAddr[]=array("Seoul","Korea");
224
			$demoAddr[]=array("Tokyo","Japan");
224
			$demoAddr[]=array("Tokyo","Japan");
225
			$demoAddr[]=array("Melbourne","Victoria","Australia");
225
			$demoAddr[]=array("Melbourne","Victoria","Australia");
226
			
226
 
227
			/*
227
			/*
228
			"臺灣-臺北",
228
			"臺灣-臺北",
229
			"美國-紐約",
229
			"美國-紐約",
230
			"美國-洛杉磯",
230
			"美國-洛杉磯",
231
			"法國-巴黎",
231
			"法國-巴黎",
Line 234... Line 234...
234
			"泰國-曼谷",
234
			"泰國-曼谷",
235
			"韓國-首爾",
235
			"韓國-首爾",
236
			"日本-東京",
236
			"日本-東京",
237
			"澳洲-墨爾本"
237
			"澳洲-墨爾本"
238
			*/
238
			*/
239
			
239
 
240
			/*
240
			/*
241
			"City+Hall,taipei,tw",
241
			"City+Hall,taipei,tw",
242
			"City+Hall,new+york,NY",
242
			"City+Hall,new+york,NY",
243
			"City+Hall,Los+angeles,CA",
243
			"City+Hall,Los+angeles,CA",
244
			"Paris,France",
244
			"Paris,France",
245
			"London,United+Kingdom",
245
			"London,United+Kingdom",
246
			"Wellington,New+Zealand",
246
			"Wellington,New+Zealand",
247
			"Thanon+Na+Phra+Lan+Bangkok+Thailand",
247
			"Thanon+Na+Phra+Lan+Bangkok+Thailand",
248
			"Seoul",
248
			"Seoul",
249
			"Tokyo,Japan",
249
			"Tokyo,Japan",
250
			"Melbourne+Victoria+Australia" 
250
			"Melbourne+Victoria+Australia"
251
			*/
251
			*/
252
			
252
 
253
			#隨機取用一個展示地點
253
			#隨機取用一個展示地點
254
			#函式說明: 
254
			#函式說明:
255
			#亂數產生特定陣列裡面的內容
255
			#亂數產生特定陣列裡面的內容
256
			#回傳的結果:
256
			#回傳的結果:
257
			#$result["status"],執行正常與否,"true"為正常,"false"為不正常.
257
			#$result["status"],執行正常與否,"true"為正常,"false"為不正常.
258
			#$result["function"],當前執行的函數名稱.
258
			#$result["function"],當前執行的函數名稱.
259
			#$result["error"],錯誤訊息陣列.
259
			#$result["error"],錯誤訊息陣列.
Line 264... Line 264...
264
			$conf["math::randomFromArray"]["randomArray"]=$demoAddr;
264
			$conf["math::randomFromArray"]["randomArray"]=$demoAddr;
265
			#可省略參數:
265
			#可省略參數:
266
			#無
266
			#無
267
			$randomFromArray=math::randomFromArray($conf["math::randomFromArray"]);
267
			$randomFromArray=math::randomFromArray($conf["math::randomFromArray"]);
268
			unset($conf["math::randomFromArray"]);
268
			unset($conf["math::randomFromArray"]);
269
			
269
 
270
			#如果隨機取用一個展示地點失敗
270
			#如果隨機取用一個展示地點失敗
271
			if($randomFromArray["status"]==="false"){
271
			if($randomFromArray["status"]==="false"){
272
				
272
 
273
				#設置執行不正常
273
				#設置執行不正常
274
				$result["status"]="false";
274
				$result["status"]="false";
275
				
275
 
276
				#設置錯誤訊息
276
				#設置錯誤訊息
277
				$result["error"]=$randomFromArray;
277
				$result["error"]=$randomFromArray;
278
				
278
 
279
				#回傳結果
279
				#回傳結果
280
				return $result;
280
				return $result;
281
				
281
 
282
				}#if end
282
				}#if end
283
			
283
 
284
			#設置 $conf["center"]
284
			#設置 $conf["center"]
285
			$conf["center"]=$randomFromArray["content"]["value"];
285
			$conf["center"]=$randomFromArray["content"]["value"];
286
			
286
 
287
			}#if end
287
			}#if end
288
					
288
 
289
		#初始化儲存地點
289
		#初始化儲存地點
290
		$center="";
290
		$center="";
291
		
291
 
292
		#處理 $conf["center"]
292
		#處理 $conf["center"]
293
		foreach($conf["center"] as $addClip){
293
		foreach($conf["center"] as $addClip){
294
			
294
 
295
			#涵式說明:
295
			#涵式說明:
296
			#處理字串避免網頁出錯
296
			#處理字串避免網頁出錯
297
			#回傳的結果:
297
			#回傳的結果:
298
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
298
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
299
			#$result["function"],當前執行的函數.
299
			#$result["function"],當前執行的函數.
Line 306... Line 306...
306
				#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
306
				#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
307
				#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
307
				#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
308
			$conf["stringProcess::correctCharacter"]["changeTo"]=array("+");#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
308
			$conf["stringProcess::correctCharacter"]["changeTo"]=array("+");#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
309
			$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
309
			$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
310
			unset($conf["stringProcess::correctCharacter"]);
310
			unset($conf["stringProcess::correctCharacter"]);
311
			
311
 
312
			#如果修正字串失敗
312
			#如果修正字串失敗
313
			if($correctCharacter["status"]==="false"){
313
			if($correctCharacter["status"]==="false"){
314
				
314
 
315
				#設置執行不正常
315
				#設置執行不正常
316
				$result["status"]="false";
316
				$result["status"]="false";
317
				
317
 
318
				#設置錯誤訊息
318
				#設置錯誤訊息
319
				$result["error"]=$correctCharacter;
319
				$result["error"]=$correctCharacter;
320
				
320
 
321
				#回傳結果
321
				#回傳結果
322
				return $result;
322
				return $result;
323
				
323
 
324
				}#if end
324
				}#if end
325
				
325
 
326
			#取得處理好的位置片段
326
			#取得處理好的位置片段
327
			$center=$center.$correctCharacter["content"];
327
			$center=$center.$correctCharacter["content"];
328
			
328
 
329
			}#foreach end
329
			}#foreach end
330
		
330
 
331
		#如果要放大地圖
331
		#如果要放大地圖
332
		if($conf["scale"]==="true"){
332
		if($conf["scale"]==="true"){
333
			
333
 
334
			#設置scale參數
334
			#設置scale參數
335
			$conf["scale"]="2";
335
			$conf["scale"]="2";
336
			
336
 
337
			}#if end
337
			}#if end
338
		
338
 
339
		#反之不放大地圖	
339
		#反之不放大地圖
340
		else{
340
		else{
341
			
341
 
342
			#設置scale參數
342
			#設置scale參數
343
			$conf["scale"]="1";
343
			$conf["scale"]="1";
344
			
344
 
345
			}#else end			
345
			}#else end
346
				
346
 
347
		#初始化 google static map 網址 
347
		#初始化 google static map 網址
348
		$googleStaticMap="http://maps.google.com/maps/api/staticmap?";
348
		$googleStaticMap="http://maps.google.com/maps/api/staticmap?";
349
		
349
 
350
		#設置參數
350
		#設置參數
351
		$googleStaticMap=$googleStaticMap."center=".$center;
351
		$googleStaticMap=$googleStaticMap."center=".$center;
352
		$googleStaticMap=$googleStaticMap."&zoom=".$conf["zoom"];
352
		$googleStaticMap=$googleStaticMap."&zoom=".$conf["zoom"];
353
		$googleStaticMap=$googleStaticMap."&size=".$conf["size"][0]."x".$conf["size"][1];
353
		$googleStaticMap=$googleStaticMap."&size=".$conf["size"][0]."x".$conf["size"][1];
354
		$googleStaticMap=$googleStaticMap."&sensor=false";
354
		$googleStaticMap=$googleStaticMap."&sensor=false";
355
		$googleStaticMap=$googleStaticMap."&scale=".$conf["scale"];
355
		$googleStaticMap=$googleStaticMap."&scale=".$conf["scale"];
356
		$googleStaticMap=$googleStaticMap."&language=".$conf["lang"];
356
		$googleStaticMap=$googleStaticMap."&language=".$conf["lang"];
357
		$googleStaticMap=$googleStaticMap."&format=".$conf["format"];
357
		$googleStaticMap=$googleStaticMap."&format=".$conf["format"];
358
						
358
 
359
		#放置 google static map 圖片的語法 		
359
		#放置 google static map 圖片的語法
360
		$result["content"]="<img src = \"".$googleStaticMap."\">";
360
		$result["content"]="<img src = \"".$googleStaticMap."\">";
361
		
361
 
362
		#設置執行正常
362
		#設置執行正常
363
		$result["status"]="true";
363
		$result["status"]="true";
364
		
364
 
365
		#回傳結果
365
		#回傳結果
366
		return $result;
366
		return $result;
367
		
367
 
368
		}#function demo end	
368
		}#function demo end
369
 
369
 
370
	}#class googleMap end
370
	}#class googleMap end
371
	
371
 
372
?>
372
?>