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 44... Line 44...
44
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
44
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
45
	#備註:
45
	#備註:
46
	#無
46
	#無
47
	*/
47
	*/
48
	public function __call($method,$arguments){
48
	public function __call($method,$arguments){
49
		
49
 
50
		#取得當前執行的函式
50
		#取得當前執行的函式
51
		$result["function"]=__FUNCTION__;
51
		$result["function"]=__FUNCTION__;
52
		
52
 
53
		#設置執行不正常
53
		#設置執行不正常
54
		$result["status"]="false";
54
		$result["status"]="false";
55
		
55
 
56
		#設置執行錯誤
56
		#設置執行錯誤
57
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
57
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
58
		
58
 
59
		#設置所丟入的參數
59
		#設置所丟入的參數
60
		$result["error"][]=$arguments;
60
		$result["error"][]=$arguments;
61
		
61
 
62
		#回傳結果
62
		#回傳結果
63
		return $result;
63
		return $result;
64
		
64
 
65
		}#function __call end
65
		}#function __call end
66
		
66
 
67
	/*
67
	/*
68
	#函式說明:
68
	#函式說明:
69
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
69
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
70
	#回傳結果:
70
	#回傳結果:
71
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
71
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 80... Line 80...
80
	#__callStatic=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
80
	#__callStatic=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
81
	#備註:
81
	#備註:
82
	#無
82
	#無
83
	*/
83
	*/
84
	public static function __callStatic($method,$arguments){
84
	public static function __callStatic($method,$arguments){
85
		
85
 
86
		#取得當前執行的函式
86
		#取得當前執行的函式
87
		$result["function"]=__FUNCTION__;
87
		$result["function"]=__FUNCTION__;
88
		
88
 
89
		#設置執行不正常
89
		#設置執行不正常
90
		$result["status"]="false";
90
		$result["status"]="false";
91
		
91
 
92
		#設置執行錯誤
92
		#設置執行錯誤
93
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
93
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
94
		
94
 
95
		#設置所丟入的參數
95
		#設置所丟入的參數
96
		$result["error"][]=$arguments;
96
		$result["error"][]=$arguments;
97
		
97
 
98
		#回傳結果
98
		#回傳結果
99
		return $result;
99
		return $result;
100
		
100
 
101
		}#function __callStatic end
101
		}#function __callStatic end
102
	
102
 
103
	/*
103
	/*
104
	#函式說明:
104
	#函式說明:
105
	#記錄當下用戶的瀏覽器與地理位置與時間點等資訊
105
	#記錄當下用戶的瀏覽器與地理位置與時間點等資訊
106
	#回傳結果:
106
	#回傳結果:
107
	#$result["status"],爲查詢是否成功,若爲"true"則成功,若爲"false"則表示失敗了.
107
	#$result["status"],爲查詢是否成功,若爲"true"則成功,若爲"false"則表示失敗了.
Line 126... Line 126...
126
	#無.
126
	#無.
127
	#備註:
127
	#備註:
128
	#無.
128
	#無.
129
	*/
129
	*/
130
	public static function recordUserInfo(&$conf){
130
	public static function recordUserInfo(&$conf){
131
	
131
 
132
		#初始化要回傳的內容
132
		#初始化要回傳的內容
133
		$result=array();
133
		$result=array();
134
 
134
 
135
		#取得當前執行的函數名稱
135
		#取得當前執行的函數名稱
136
		$result["function"]=__FUNCTION__;
136
		$result["function"]=__FUNCTION__;
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
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
163
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
164
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
164
		#$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"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
173
		#$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
174
		$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("dbAddress","dbAccount","dbName","fileArgu");
174
		$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("dbAddress","dbAccount","dbName","fileArgu");
175
		#$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
175
		#$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
176
		$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("string","string","string","string");
176
		$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("string","string","string","string");
177
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
177
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
178
		$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
178
		$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
179
		#可以省略的參數:
179
		#可以省略的參數:
180
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
180
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
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("dbPassword","dbName");
183
		$conf["variableCheck.checkArguments"]["skipableVariableName"]=array("dbPassword","dbName");
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","string");
185
		$conf["variableCheck.checkArguments"]["skipableVariableType"]=array("string","string");
186
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
186
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
187
		$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"]=array(null,"qbpwcf");
187
		$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"]=array(null,"qbpwcf");
188
		$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
188
		$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
189
		unset($conf["variableCheck.checkArguments"]);
189
		unset($conf["variableCheck.checkArguments"]);
190
		
190
 
191
		#如果 檢查參數 失敗
191
		#如果 檢查參數 失敗
192
		if($checkResult["status"]=="false"){
192
		if($checkResult["status"]=="false"){
193
			
193
 
194
			#設置執行不正常
194
			#設置執行不正常
195
			$result["status"]="false";
195
			$result["status"]="false";
196
			
196
 
197
			#設置執行錯誤
197
			#設置執行錯誤
198
			$result["error"]=$checkResult;
198
			$result["error"]=$checkResult;
199
			
199
 
200
			#回傳節果
200
			#回傳節果
201
			return $result;
201
			return $result;
202
			
202
 
203
			}#if end
203
			}#if end
204
			
204
 
205
		#如果 檢查參數 不通過
205
		#如果 檢查參數 不通過
206
		if($checkResult["passed"]=="false"){
206
		if($checkResult["passed"]=="false"){
207
			
207
 
208
			#設置執行不正常
208
			#設置執行不正常
209
			$result["status"]="false";
209
			$result["status"]="false";
210
			
210
 
211
			#設置執行錯誤
211
			#設置執行錯誤
212
			$result["error"]=$checkResult;
212
			$result["error"]=$checkResult;
213
			
213
 
214
			#回傳節果
214
			#回傳節果
215
			return $result;
215
			return $result;
216
			
216
 
217
			}#if end
217
			}#if end
218
	
218
 
219
		#涵式說明:
219
		#涵式說明:
220
		#取得 dns/ip 的地理位置資訊
220
		#取得 dns/ip 的地理位置資訊
221
		#回傳結果:
221
		#回傳結果:
222
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
222
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
223
		#$result["error"],錯誤訊息陣列.
223
		#$result["error"],錯誤訊息陣列.
Line 237... Line 237...
237
		#如果取得 geo 資訊失敗
237
		#如果取得 geo 資訊失敗
238
		if($getIpGeo["status"]==="false"){
238
		if($getIpGeo["status"]==="false"){
239
 
239
 
240
			#設置執行失敗
240
			#設置執行失敗
241
			$result["status"]="false";
241
			$result["status"]="false";
242
			
242
 
243
			#設置執行錯誤
243
			#設置執行錯誤
244
			$result["error"]=$getIpGeo;
244
			$result["error"]=$getIpGeo;
245
			
245
 
246
			#回傳結果
246
			#回傳結果
247
			return $result;
247
			return $result;
248
 
248
 
249
			}#if end
249
			}#if end
250
			
250
 
251
		#取得地理位置資訊
251
		#取得地理位置資訊
252
		$geoJson=$getIpGeo["content"];
252
		$geoJson=$getIpGeo["content"];
253
 
253
 
254
		#設置geo參數
254
		#設置geo參數
255
		$result["content"]["geo"]=$geoJson;
255
		$result["content"]["geo"]=$geoJson;
256
	
256
 
257
		#取得瀏覽器的資訊
257
		#取得瀏覽器的資訊
258
		#涵式說明:
258
		#涵式說明:
259
		#取得用戶端的瀏覽器版本資訊,並回傳。
259
		#取得用戶端的瀏覽器版本資訊,並回傳。
260
		#回傳結果:
260
		#回傳結果:
261
		#$result,瀏覽器的資訊
261
		#$result,瀏覽器的資訊
262
		$getUserBrowserType=csInformation::getUserBrowserType();
262
		$getUserBrowserType=csInformation::getUserBrowserType();
263
 
263
 
264
		#設置瀏覽器資訊
264
		#設置瀏覽器資訊
265
		$result["content"]["agent"]=$getUserBrowserType;
265
		$result["content"]["agent"]=$getUserBrowserType;
266
		
266
 
267
		#記錄當下要求的頁面等資訊
267
		#記錄當下要求的頁面等資訊
268
		$result["content"]["_SERVER"]=$_SERVER;
268
		$result["content"]["_SERVER"]=$_SERVER;
269
		
269
 
270
		#設置當下的時間點(無時區)
270
		#設置當下的時間點(無時區)
271
		$result["content"]["time"]=time();
271
		$result["content"]["time"]=time();
272
		
272
 
273
		#涵式說明:
273
		#涵式說明:
274
		#插入資料到指定的資料表裡面,插入資料完畢可以選擇是否要進行轉址。
274
		#插入資料到指定的資料表裡面,插入資料完畢可以選擇是否要進行轉址。
275
		#回傳的數值:	
275
		#回傳的數值:
276
		#$result["status"],爲查詢是否成功,若爲"true"則成功,若爲"false"則表示失敗了.
276
		#$result["status"],爲查詢是否成功,若爲"true"則成功,若爲"false"則表示失敗了.
277
		#$result["error"],錯誤訊息.
277
		#$result["error"],錯誤訊息.
278
		#$result["sql"],執行的sql語法.
278
		#$result["sql"],執行的sql語法.
279
		#$result["lastInsertId"],新增的資料id.
279
		#$result["lastInsertId"],新增的資料id.
280
		#$result["function"],當前執行的涵式
280
		#$result["function"],當前執行的涵式
281
		#必填的參數:
281
		#必填的參數:
282
		$conf["db::insertData"]["dbAddress"]=$conf["dbAddress"];#爲mysql-Server的位置
282
		$conf["db::insertData"]["dbAddress"]=$conf["dbAddress"];#爲mysql-Server的位置
283
		$conf["db::insertData"]["dbAccount"]=$conf["dbAccount"];#爲用於連入mysql-Server時要使用的帳號
283
		$conf["db::insertData"]["dbAccount"]=$conf["dbAccount"];#爲用於連入mysql-Server時要使用的帳號
284
		$conf["db::insertData"]["selectedDataBaseName"]=$conf["dbName"];#要選取的資料庫名稱	
284
		$conf["db::insertData"]["selectedDataBaseName"]=$conf["dbName"];#要選取的資料庫名稱
285
		$conf["db::insertData"]["tableName"]="call_record";#爲要插入資料的資料表名稱
285
		$conf["db::insertData"]["tableName"]="call_record";#爲要插入資料的資料表名稱
286
		$conf["db::insertData"]["columnName"]=array("json");#爲資料表的項目名稱,
286
		$conf["db::insertData"]["columnName"]=array("json");#爲資料表的項目名稱,
287
			#例如:$conf["columnName"]=array("columnName1","columnName2","columnName3",...);
287
			#例如:$conf["columnName"]=array("columnName1","columnName2","columnName3",...);
288
		$conf["db::insertData"]["insertValue"]=array(json_encode($result["content"]));#爲要插入度數值,
288
		$conf["db::insertData"]["insertValue"]=array(json_encode($result["content"]));#爲要插入度數值,
289
			#例如:$conf["insertValue"]=array("insertValue1","insertValue2","insertValue3",...);
289
			#例如:$conf["insertValue"]=array("insertValue1","insertValue2","insertValue3",...);
290
		#可以省略的變數:
290
		#可以省略的變數:
291
		
291
 
292
		#如果有設置密碼
292
		#如果有設置密碼
293
		if(isset($conf["dbPassword"])){
293
		if(isset($conf["dbPassword"])){
294
		
294
 
295
			#設置密碼
295
			#設置密碼
296
			$conf["db::insertData"]["dbPassword"]=$conf["dbPassword"];#爲連線到mysql-Server時要使用的密碼,可省略,若省略則代表不使用密碼
296
			$conf["db::insertData"]["dbPassword"]=$conf["dbPassword"];#爲連線到mysql-Server時要使用的密碼,可省略,若省略則代表不使用密碼
297
		
297
 
298
			}#if end
298
			}#if end
299
				
299
 
300
		#參考資料來源:
300
		#參考資料來源:
301
		#http://www.javaworld.com.tw/jute/post/view?bid=21&id=173738&sty=1
301
		#http://www.javaworld.com.tw/jute/post/view?bid=21&id=173738&sty=1
302
		$insertData=db::insertData($conf["db::insertData"]);
302
		$insertData=db::insertData($conf["db::insertData"]);
303
		unset($conf["db::insertData"]);
303
		unset($conf["db::insertData"]);
304
 
304
 
305
		#如果新增資料失敗
305
		#如果新增資料失敗
306
		if($insertData["status"]==="false"){
306
		if($insertData["status"]==="false"){
307
 
307
 
308
			#設置執行失敗
308
			#設置執行失敗
309
			$result["status"]="false";
309
			$result["status"]="false";
310
			
310
 
311
			#設置執行錯誤
311
			#設置執行錯誤
312
			$result["error"]=$inserData;
312
			$result["error"]=$inserData;
313
			
313
 
314
			#回傳結果
314
			#回傳結果
315
			return $result;
315
			return $result;
316
			
316
 
317
			}#if end
317
			}#if end
318
	
318
 
319
		#新增的資料id.
319
		#新增的資料id.
320
		$result["lastInsertId"]=$insertData["lastInsertId"];
320
		$result["lastInsertId"]=$insertData["lastInsertId"];
321
		
321
 
322
		#新增的資料id.
322
		#新增的資料id.
323
		$result["sql"]=$insertData["sql"];
323
		$result["sql"]=$insertData["sql"];
324
		
324
 
325
		#設置執行正常
325
		#設置執行正常
326
		$result["status"]="true";
326
		$result["status"]="true";
327
		
327
 
328
		#回傳結果
328
		#回傳結果
329
		return $result;
329
		return $result;
330
	
330
 
331
		}#function recordUserInfo end
331
		}#function recordUserInfo end
332
 
332
 
333
	/*
333
	/*
334
	#函式說明:
334
	#函式說明:
335
	#記錄程式輸出的結果.
335
	#記錄程式輸出的結果.
Line 348... Line 348...
348
	#無.
348
	#無.
349
	#備註:
349
	#備註:
350
	#無.
350
	#無.
351
	*/
351
	*/
352
	public static function getOutput(&$conf){
352
	public static function getOutput(&$conf){
353
	
353
 
354
		#初始化要回傳的內容
354
		#初始化要回傳的內容
355
		$result=array();
355
		$result=array();
356
 
356
 
357
		#取得當前執行的函數名稱
357
		#取得當前執行的函數名稱
358
		$result["function"]=__FUNCTION__;
358
		$result["function"]=__FUNCTION__;
359
 
359
 
360
		#如果 $conf 不為陣列
360
		#如果 $conf 不為陣列
361
		if(gettype($conf)!="array"){
361
		if(gettype($conf)!="array"){
362
			
362
 
363
			#設置執行失敗
363
			#設置執行失敗
364
			$result["status"]="false";
364
			$result["status"]="false";
365
			
365
 
366
			#設置執行錯誤訊息
366
			#設置執行錯誤訊息
367
			$result["error"][]="\$conf變數須為陣列形態";
367
			$result["error"][]="\$conf變數須為陣列形態";
368
 
368
 
369
			#如果傳入的參數為 null
369
			#如果傳入的參數為 null
370
			if($conf==null){
370
			if($conf==null){
371
				
371
 
372
				#設置執行錯誤訊息
372
				#設置執行錯誤訊息
373
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
373
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
374
				
374
 
375
				}#if end
375
				}#if end
376
 
376
 
377
			#回傳結果
377
			#回傳結果
378
			return $result;
378
			return $result;
379
			
379
 
380
			}#if end
380
			}#if end
381
		
381
 
382
		#檢查參數
382
		#檢查參數
383
		#函式說明:
383
		#函式說明:
384
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
384
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
385
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
385
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
386
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
386
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 392... Line 392...
392
		#必填寫的參數:
392
		#必填寫的參數:
393
		#$conf["variableCheck.checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
393
		#$conf["variableCheck.checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
394
		$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
394
		$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
395
		#$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
395
		#$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
396
		$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("code2run");
396
		$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("code2run");
397
		#$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
397
		#$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
398
		$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("array");
398
		$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("array");
399
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
399
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
400
		$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
400
		$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
401
		#可以省略的參數:
401
		#可以省略的參數:
402
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
402
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
403
		#$conf["canBeEmptyString"]="false";
403
		#$conf["canBeEmptyString"]="false";
404
		#$conf["variableCheck.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
404
		#$conf["variableCheck.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
405
		$conf["variableCheck.checkArguments"]["skipableVariableName"]=array("varPassed");
405
		$conf["variableCheck.checkArguments"]["skipableVariableName"]=array("varPassed");
406
		#$conf["variableCheck.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
406
		#$conf["variableCheck.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
407
		$conf["variableCheck.checkArguments"]["skipableVariableType"]=array(null);
407
		$conf["variableCheck.checkArguments"]["skipableVariableType"]=array(null);
408
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
408
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
409
		$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"]=array(null);
409
		$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"]=array(null);
410
		$checkArguments=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
410
		$checkArguments=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
411
		unset($conf["variableCheck.checkArguments"]);
411
		unset($conf["variableCheck.checkArguments"]);
412
		
412
 
413
		#如果 檢查參數 失敗
413
		#如果 檢查參數 失敗
414
		if($checkArguments["status"]==="false"){
414
		if($checkArguments["status"]==="false"){
415
			
415
 
416
			#設置執行不正常
416
			#設置執行不正常
417
			$result["status"]="false";
417
			$result["status"]="false";
418
			
418
 
419
			#設置執行錯誤
419
			#設置執行錯誤
420
			$result["error"]=$checkArguments;
420
			$result["error"]=$checkArguments;
421
			
421
 
422
			#回傳節果
422
			#回傳節果
423
			return $result;
423
			return $result;
424
			
424
 
425
			}#if end
425
			}#if end
426
			
426
 
427
		#如果 檢查參數 不通過
427
		#如果 檢查參數 不通過
428
		if($checkArguments["passed"]==="false"){
428
		if($checkArguments["passed"]==="false"){
429
			
429
 
430
			#設置執行不正常
430
			#設置執行不正常
431
			$result["status"]="false";
431
			$result["status"]="false";
432
			
432
 
433
			#設置執行錯誤
433
			#設置執行錯誤
434
			$result["error"]=$checkArguments;
434
			$result["error"]=$checkArguments;
435
			
435
 
436
			#回傳節果
436
			#回傳節果
437
			return $result;
437
			return $result;
438
			
438
 
439
			}#if end
439
			}#if end
440
	
440
 
441
		#開始將輸出存入buffer
441
		#開始將輸出存入buffer
442
		ob_start();
442
		ob_start();
443
		
443
 
444
		#取得要在eval中使用的變數
444
		#取得要在eval中使用的變數
445
		$varPassed=&$conf["varPassed"];
445
		$varPassed=&$conf["varPassed"];
446
		
446
 
447
		#針對每段要執行的程式
447
		#針對每段要執行的程式
448
		foreach($conf["code2run"] as $phpCode){
448
		foreach($conf["code2run"] as $phpCode){
449
		
449
 
450
			#如果不是字串
450
			#如果不是字串
451
			if(gettype($phpCode)!=="string"){
451
			if(gettype($phpCode)!=="string"){
452
			
452
 
453
				#設置執行不正常
453
				#設置執行不正常
454
				$result["status"]="false";
454
				$result["status"]="false";
455
				
455
 
456
				#設置執行錯誤
456
				#設置執行錯誤
457
				$result["error"]="element of code2run should be String";
457
				$result["error"]="element of code2run should be String";
458
				
458
 
459
				#回傳節果
459
				#回傳節果
460
				return $result;
460
				return $result;
461
			
461
 
462
				}#if end
462
				}#if end
463
		
463
 
464
			#若不為「;」結尾
464
			#若不為「;」結尾
465
			if($phpCode[strlen($phpCode)-1]!==";"){
465
			if($phpCode[strlen($phpCode)-1]!==";"){
466
			
466
 
467
				#設置執行不正常
467
				#設置執行不正常
468
				$result["status"]="false";
468
				$result["status"]="false";
469
				
469
 
470
				#設置執行錯誤
470
				#設置執行錯誤
471
				$result["error"]="element of code2run should be end with 「;」";
471
				$result["error"]="element of code2run should be end with 「;」";
472
				
472
 
473
				#回傳節果
473
				#回傳節果
474
				return $result;
474
				return $result;
475
			
475
 
476
				}#if end
476
				}#if end
477
		
477
 
478
			#運行php程式
478
			#運行php程式
479
			eval($phpCode);
479
			eval($phpCode);
480
		
480
 
481
			}#foreach end
481
			}#foreach end
482
		
482
 
483
		#取得buffer的內容
483
		#取得buffer的內容
484
		$result["content"]=ob_get_contents();
484
		$result["content"]=ob_get_contents();
485
		
485
 
486
		#清空buffer,結束buffer的使用
486
		#清空buffer,結束buffer的使用
487
		ob_end_clean();
487
		ob_end_clean();
488
		
488
 
489
		#設置執行正常
489
		#設置執行正常
490
		$result["status"]="true";
490
		$result["status"]="true";
491
		
491
 
492
		#回傳結果
492
		#回傳結果
493
		return $result;
493
		return $result;
494
		
494
 
495
		}#function getOutput end
495
		}#function getOutput end
496
 
496
 
497
	}#class record end
497
	}#class record end
498
 
498
 
499
?>
499
?>