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
	#讀取xml檔案,儲存所有標籤的內容,目前尚不能讀取屬性的資訊
100
	#讀取xml檔案,儲存所有標籤的內容,目前尚不能讀取屬性的資訊
Line 120... Line 120...
120
	#取得處理xml的錯誤訊息=>http://php.net/manual/en/function.libxml-get-errors.php
120
	#取得處理xml的錯誤訊息=>http://php.net/manual/en/function.libxml-get-errors.php
121
	#備註:
121
	#備註:
122
	#無.
122
	#無.
123
	*/
123
	*/
124
	public static function getContent(&$conf){
124
	public static function getContent(&$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
		#取得參數
154
		#取得參數
155
		$result["argu"]=$conf;
155
		$result["argu"]=$conf;
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 171... Line 171...
171
		#必填寫的參數:
171
		#必填寫的參數:
172
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
172
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
173
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
173
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
174
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
174
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
175
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","xmlPosition");
175
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","xmlPosition");
176
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
176
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object");
177
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
177
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
178
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
178
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
179
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
179
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
180
		#可以省略的參數:
180
		#可以省略的參數:
181
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
181
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
182
		#$conf["canBeEmptyString"]="false";
182
		#$conf["canBeEmptyString"]="false";
183
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
183
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
184
		#$conf["skipableVariableCanNotBeEmpty"]=array();
184
		#$conf["skipableVariableCanNotBeEmpty"]=array();
185
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
185
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
186
		#$conf["skipableVariableName"]=array();
186
		#$conf["skipableVariableName"]=array();
187
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
187
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
188
		#$conf["skipableVariableType"]=array();
188
		#$conf["skipableVariableType"]=array();
189
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
189
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
190
		#$conf["skipableVarDefaultValue"]=array("");
190
		#$conf["skipableVarDefaultValue"]=array("");
191
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
191
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
192
		#$conf["arrayCountEqualCheck"][]=array();
192
		#$conf["arrayCountEqualCheck"][]=array();
193
		#參考資料來源:
193
		#參考資料來源:
194
		#array_keys=>http://php.net/manual/en/function.array-keys.php
194
		#array_keys=>http://php.net/manual/en/function.array-keys.php
195
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
195
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
196
		unset($conf["variableCheck::checkArguments"]);
196
		unset($conf["variableCheck::checkArguments"]);
197
		
197
 
198
		#如果檢查失敗
198
		#如果檢查失敗
199
		if($checkArguments["status"]=="false"){
199
		if($checkArguments["status"]=="false"){
200
			
200
 
201
			#設置錯誤識別
201
			#設置錯誤識別
202
			$result["status"]="false";
202
			$result["status"]="false";
203
			
203
 
204
			#設置錯誤訊息
204
			#設置錯誤訊息
205
			$result["error"]=$checkArguments;
205
			$result["error"]=$checkArguments;
206
			
206
 
207
			#回傳結果
207
			#回傳結果
208
			return $result;
208
			return $result;
209
			
209
 
210
			}#if end
210
			}#if end
211
	
211
 
212
		#如果檢查不通過
212
		#如果檢查不通過
213
		if($checkArguments["passed"]=="false"){
213
		if($checkArguments["passed"]=="false"){
214
			
214
 
215
			#設置錯誤識別
215
			#設置錯誤識別
216
			$result["status"]="false";
216
			$result["status"]="false";
217
			
217
 
218
			#設置錯誤訊息
218
			#設置錯誤訊息
219
			$result["error"]=$checkArguments;
219
			$result["error"]=$checkArguments;
220
			
220
 
221
			#回傳結果
221
			#回傳結果
222
			return $result;
222
			return $result;
223
			
223
 
224
			}#if end
224
			}#if end
225
			
225
 
226
		#函數說明:
226
		#函數說明:
227
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
227
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
228
		#回傳結果:
228
		#回傳結果:
229
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
229
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
230
		#$result["error"],錯誤訊息陣列.
230
		#$result["error"],錯誤訊息陣列.
231
		#$result["function"],函數名稱. 
231
		#$result["function"],函數名稱.
232
		#$result["argu"],使用的參數.
232
		#$result["argu"],使用的參數.
233
		#$result["content"],網址,若是在命令列執行,則為"null".
233
		#$result["content"],網址,若是在命令列執行,則為"null".
234
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
234
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
235
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
235
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
236
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
236
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
Line 244... Line 244...
244
		$conf["fileAccess::getInternetAddressV2"]["web"]="false";
244
		$conf["fileAccess::getInternetAddressV2"]["web"]="false";
245
		#備註:
245
		#備註:
246
		#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.
246
		#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.
247
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
247
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
248
		unset($conf["fileAccess::getInternetAddressV2"]);
248
		unset($conf["fileAccess::getInternetAddressV2"]);
249
		
249
 
250
		#如果轉換位置失敗
250
		#如果轉換位置失敗
251
		if($getInternetAddressV2["status"]=="false"){
251
		if($getInternetAddressV2["status"]=="false"){
252
			
252
 
253
			#設置執行不正常
253
			#設置執行不正常
254
			$result["status"]="false";
254
			$result["status"]="false";
255
			
255
 
256
			#設置執行錯誤
256
			#設置執行錯誤
257
			$result["error"]=$getInternetAddressV2;
257
			$result["error"]=$getInternetAddressV2;
258
			
258
 
259
			#回傳結果
259
			#回傳結果
260
			return $result;
260
			return $result;
261
			
261
 
262
			}#if end
262
			}#if end
263
		
263
 
264
		#取得轉換好的絕對位置
264
		#取得轉換好的絕對位置
265
		$conf["xmlPosition"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
265
		$conf["xmlPosition"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
266
		
266
 
267
		#檢查xml檔案是否存在
267
		#檢查xml檔案是否存在
268
		#函式說明:檢查多個檔案與資料夾是否存在.
268
		#函式說明:檢查多個檔案與資料夾是否存在.
269
		#回傳的結果:
269
		#回傳的結果:
270
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
270
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
271
		#$result["error"],錯誤訊息陣列.
271
		#$result["error"],錯誤訊息陣列.
Line 281... Line 281...
281
		$conf["fileAccess::checkMultiFileExist"]["web"]="false";
281
		$conf["fileAccess::checkMultiFileExist"]["web"]="false";
282
		#http://php.net/manual/en/function.file-exists.php
282
		#http://php.net/manual/en/function.file-exists.php
283
		#http://php.net/manual/en/control-structures.foreach.php
283
		#http://php.net/manual/en/control-structures.foreach.php
284
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
284
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
285
		unset($conf["fileAccess::checkMultiFileExist"]);
285
		unset($conf["fileAccess::checkMultiFileExist"]);
286
		
286
 
287
		#如果檢查檔案是否存在失敗
287
		#如果檢查檔案是否存在失敗
288
		if($checkMultiFileExist["status"]==="false"){
288
		if($checkMultiFileExist["status"]==="false"){
289
			
289
 
290
			#設置錯誤識別
290
			#設置錯誤識別
291
			$result["status"]="false";
291
			$result["status"]="false";
292
			
292
 
293
			#設置錯誤訊息
293
			#設置錯誤訊息
294
			$result["error"]=$checkMultiFileExist;
294
			$result["error"]=$checkMultiFileExist;
295
			
295
 
296
			#回傳結果
296
			#回傳結果
297
			return $result;
297
			return $result;
298
			
298
 
299
			}#if end
299
			}#if end
300
			
300
 
301
		#如果xml檔案不存在
301
		#如果xml檔案不存在
302
		if($checkMultiFileExist["varExist"][0]==="false"){
302
		if($checkMultiFileExist["varExist"][0]==="false"){
303
			
303
 
304
			#設置錯誤識別
304
			#設置錯誤識別
305
			$result["status"]="false";
305
			$result["status"]="false";
306
			
306
 
307
			#設置錯誤訊息
307
			#設置錯誤訊息
308
			$result["error"][]="檔案路徑為「".$checkMultiFileExist["varName"][0]."」的xml檔案不存在!";
308
			$result["error"][]="檔案路徑為「".$checkMultiFileExist["varName"][0]."」的xml檔案不存在!";
309
			
309
 
310
			#設置沒有找到 xml 檔案
310
			#設置沒有找到 xml 檔案
311
			$result["founded"]="false";
311
			$result["founded"]="false";
312
			
312
 
313
			#回傳結果
313
			#回傳結果
314
			return $result;
314
			return $result;
315
			
315
 
316
			}#if end
316
			}#if end
317
		
317
 
318
		#啟用 xml 的錯誤處理
318
		#啟用 xml 的錯誤處理
319
		libxml_use_internal_errors(true);
319
		libxml_use_internal_errors(true);
320
		
320
 
321
		#讀取目標xml檔案
321
		#讀取目標xml檔案
322
		$xml = simplexml_load_file($conf["xmlPosition"]);
322
		$xml = simplexml_load_file($conf["xmlPosition"]);
323
		
323
 
324
		#如果讀取 xml 檔案失敗
324
		#如果讀取 xml 檔案失敗
325
		if($xml===false){
325
		if($xml===false){
326
			
326
 
327
			#設置錯誤識別
327
			#設置錯誤識別
328
			$result["status"]="false";
328
			$result["status"]="false";
329
			
329
 
330
			#設置錯誤訊息
330
			#設置錯誤訊息
331
			$result["error"][]="讀取xml檔案失敗!";
331
			$result["error"][]="讀取xml檔案失敗!";
332
			
332
 
333
			#解析讀取xml所得到的每個錯誤
333
			#解析讀取xml所得到的每個錯誤
334
			foreach (libxml_get_errors() as $error){
334
			foreach (libxml_get_errors() as $error){
335
							
335
 
336
				#取得每個錯誤訊息
336
				#取得每個錯誤訊息
337
				$result["error"][]=$error;
337
				$result["error"][]=$error;
338
				
338
 
339
				}#foreache end
339
				}#foreache end
340
			
340
 
341
			#回傳結果
341
			#回傳結果
342
			return $result;
342
			return $result;
343
			
343
 
344
			}#if end
344
			}#if end
345
		
345
 
346
		#取得 xml 的內容
346
		#取得 xml 的內容
347
		$result["content"]=$xml;
347
		$result["content"]=$xml;
348
			
348
 
349
		#設置有找到 xml 檔案
349
		#設置有找到 xml 檔案
350
		$result["founded"]="true";	
350
		$result["founded"]="true";
351
								
351
 
352
		#設置執行正常
352
		#設置執行正常
353
		$result["status"]="true";
353
		$result["status"]="true";
354
			
354
 
355
		#回傳抓取到的解果
355
		#回傳抓取到的解果
356
		return $result;
356
		return $result;
357
		
357
 
358
		}#function getContent end
358
		}#function getContent end
359
 
359
 
360
	/*
360
	/*
361
	#函式說明:
361
	#函式說明:
362
	#取得xml特定標籤的內容
362
	#取得xml特定標籤的內容
Line 379... Line 379...
379
	#無.
379
	#無.
380
	#備註:
380
	#備註:
381
	#無.
381
	#無.
382
	*/
382
	*/
383
	static function getTagInfo(&$conf){
383
	static function getTagInfo(&$conf){
384
		
384
 
385
		#初始化要回傳的結果
385
		#初始化要回傳的結果
386
		$result=array();
386
		$result=array();
387
 
387
 
388
		#取得當前執行的函數名稱
388
		#取得當前執行的函數名稱
389
		$result["function"]=__FUNCTION__;
389
		$result["function"]=__FUNCTION__;
390
 
390
 
391
		#如果沒有參數
391
		#如果沒有參數
392
		if(func_num_args()==0){
392
		if(func_num_args()==0){
393
			
393
 
394
			#設置執行失敗
394
			#設置執行失敗
395
			$result["status"]="false";
395
			$result["status"]="false";
396
			
396
 
397
			#設置執行錯誤訊息
397
			#設置執行錯誤訊息
398
			$result["error"]="函數".$result["function"]."需要參數";
398
			$result["error"]="函數".$result["function"]."需要參數";
399
			
399
 
400
			#回傳結果
400
			#回傳結果
401
			return $result;
401
			return $result;
402
			
402
 
403
			}#if end
403
			}#if end
404
 
404
 
405
		#取得參數
405
		#取得參數
406
		$result["argu"]=$conf;
406
		$result["argu"]=$conf;
407
 
407
 
408
		#如果 $conf 不為陣列
408
		#如果 $conf 不為陣列
409
		if(gettype($conf)!="array"){
409
		if(gettype($conf)!="array"){
410
			
410
 
411
			#設置執行失敗
411
			#設置執行失敗
412
			$result["status"]="false";
412
			$result["status"]="false";
413
			
413
 
414
			#設置執行錯誤訊息
414
			#設置執行錯誤訊息
415
			$result["error"][]="\$conf變數須為陣列形態";
415
			$result["error"][]="\$conf變數須為陣列形態";
416
			
416
 
417
			#如果傳入的參數為 null
417
			#如果傳入的參數為 null
418
			if($conf==null){
418
			if($conf==null){
419
				
419
 
420
				#設置執行錯誤訊息
420
				#設置執行錯誤訊息
421
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
421
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
422
				
422
 
423
				}#if end
423
				}#if end
424
 
424
 
425
			#回傳結果
425
			#回傳結果
426
			return $result;
426
			return $result;
427
			
427
 
428
			}#if end
428
			}#if end
429
	
429
 
430
		#檢查參數
430
		#檢查參數
431
		#函式說明:
431
		#函式說明:
432
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
432
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
433
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
433
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
434
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
434
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 455... Line 455...
455
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
455
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
456
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
456
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
457
		#$conf["skipableVariableCanNotBeEmpty"]=array();
457
		#$conf["skipableVariableCanNotBeEmpty"]=array();
458
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
458
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
459
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu","conf","commentsArray");
459
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu","conf","commentsArray");
460
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
460
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
461
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","array");
461
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","array");
462
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
462
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
463
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__,".qbpwcf_tmp/cmd/getFromConf/conf.xml",array("請輸入變數 ".$conf["readVarName"]." 的內容"));
463
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__,".qbpwcf_tmp/cmd/getFromConf/conf.xml",array("請輸入變數 ".$conf["readVarName"]." 的內容"));
464
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
464
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
465
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
465
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
466
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
466
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
467
		#參考資料來源:
467
		#參考資料來源:
468
		#array_keys=>http://php.net/manual/en/function.array-keys.php
468
		#array_keys=>http://php.net/manual/en/function.array-keys.php
469
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
469
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
470
		unset($conf["variableCheck::checkArguments"]);	
470
		unset($conf["variableCheck::checkArguments"]);
471
			
471
 
472
		#如果檢查參數失敗
472
		#如果檢查參數失敗
473
		if($checkArguments["status"]==="false"){
473
		if($checkArguments["status"]==="false"){
474
			
474
 
475
			#設置執行不正常
475
			#設置執行不正常
476
			$result["status"]="false";
476
			$result["status"]="false";
477
			
477
 
478
			#設置執行錯誤
478
			#設置執行錯誤
479
			$result["error"]=$checkArguments;
479
			$result["error"]=$checkArguments;
480
			
480
 
481
			#回傳結果
481
			#回傳結果
482
			return $result;
482
			return $result;
483
			
483
 
484
			}#if end
484
			}#if end
485
			
485
 
486
		#如果檢查參數不通過
486
		#如果檢查參數不通過
487
		if($checkArguments["passed"]==="false"){
487
		if($checkArguments["passed"]==="false"){
488
			
488
 
489
			#設置執行不正常
489
			#設置執行不正常
490
			$result["status"]="false";
490
			$result["status"]="false";
491
			
491
 
492
			#設置執行錯誤
492
			#設置執行錯誤
493
			$result["error"]=$checkArguments;
493
			$result["error"]=$checkArguments;
494
			
494
 
495
			#回傳結果
495
			#回傳結果
496
			return $result;
496
			return $result;
497
			
497
 
498
			}#if end
498
			}#if end
499
		
499
 
500
		#過濾 $conf["tag"] 陣列元素的 「::」 字元
500
		#過濾 $conf["tag"] 陣列元素的 「::」 字元
501
		#函式說明:
501
		#函式說明:
502
		#處理多個字串避免網頁出錯
502
		#處理多個字串避免網頁出錯
503
		#回傳的結果:
503
		#回傳的結果:
504
		#$result["status"],"true"代表執行成功,"false"代表執行失敗。
504
		#$result["status"],"true"代表執行成功,"false"代表執行失敗。
Line 512... Line 512...
512
			#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
512
			#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
513
			#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
513
			#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
514
		#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
514
		#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
515
		$correctMutiStrCharacter=stringProcess::correctMutiStrCharacter($conf["stringProcess::correctMutiStrCharacter"]);
515
		$correctMutiStrCharacter=stringProcess::correctMutiStrCharacter($conf["stringProcess::correctMutiStrCharacter"]);
516
		unset($conf["stringProcess::correctMutiStrCharacter"]);
516
		unset($conf["stringProcess::correctMutiStrCharacter"]);
517
					
517
 
518
		#如果修正標籤名稱失敗
518
		#如果修正標籤名稱失敗
519
		if($correctMutiStrCharacter["status"]==="false"){
519
		if($correctMutiStrCharacter["status"]==="false"){
520
			
520
 
521
			#設置執行不正常
521
			#設置執行不正常
522
			$result["status"]="false";
522
			$result["status"]="false";
523
			
523
 
524
			#設置執行錯誤
524
			#設置執行錯誤
525
			$result["error"]=$correctMutiStrCharacter;
525
			$result["error"]=$correctMutiStrCharacter;
526
			
526
 
527
			#回傳結果
527
			#回傳結果
528
			return $result;
528
			return $result;
529
			
529
 
530
			}#if end
530
			}#if end
531
			
531
 
532
		#取得修正好的tag名稱
532
		#取得修正好的tag名稱
533
		$result["tag"]=$conf["tag"]=$correctMutiStrCharacter["processedStrArray"];
533
		$result["tag"]=$conf["tag"]=$correctMutiStrCharacter["processedStrArray"];
534
		
534
 
535
		#函數說明:
535
		#函數說明:
536
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
536
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
537
		#回傳結果:
537
		#回傳結果:
538
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
538
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
539
		#$result["error"],錯誤訊息陣列.
539
		#$result["error"],錯誤訊息陣列.
540
		#$result["function"],函數名稱. 
540
		#$result["function"],函數名稱.
541
		#$result["argu"],使用的參數.
541
		#$result["argu"],使用的參數.
542
		#$result["content"],網址,若是在命令列執行,則為"null".
542
		#$result["content"],網址,若是在命令列執行,則為"null".
543
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
543
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
544
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
544
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
545
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
545
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
Line 553... Line 553...
553
		$conf["fileAccess::getInternetAddressV2"]["web"]="false";
553
		$conf["fileAccess::getInternetAddressV2"]["web"]="false";
554
		#備註:
554
		#備註:
555
		#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.
555
		#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.
556
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
556
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
557
		unset($conf["fileAccess::getInternetAddressV2"]);
557
		unset($conf["fileAccess::getInternetAddressV2"]);
558
				
558
 
559
		#如果轉換位置失敗
559
		#如果轉換位置失敗
560
		if($getInternetAddressV2["status"]==="false"){
560
		if($getInternetAddressV2["status"]==="false"){
561
			
561
 
562
			#設置執行不正常
562
			#設置執行不正常
563
			$result["status"]="false";
563
			$result["status"]="false";
564
			
564
 
565
			#設置執行錯誤
565
			#設置執行錯誤
566
			$result["error"]=$getInternetAddressV2;
566
			$result["error"]=$getInternetAddressV2;
567
			
567
 
568
			#回傳結果
568
			#回傳結果
569
			return $result;
569
			return $result;
570
			
570
 
571
			}#if end
571
			}#if end
572
		
572
 
573
		#取得轉換好的絕對位置
573
		#取得轉換好的絕對位置
574
		$conf["xmlPosition"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
574
		$conf["xmlPosition"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
575
		
575
 
576
		#函式說明:
576
		#函式說明:
577
		#讀取xml檔案,儲存所有標籤的內容,目前尚不能讀取屬性的資訊
577
		#讀取xml檔案,儲存所有標籤的內容,目前尚不能讀取屬性的資訊
578
		#回傳結果:
578
		#回傳結果:
579
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
579
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
580
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
580
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 592... Line 592...
592
		#取得xml檔案內容的示範=>http://php.net/manual/en/simplexml.examples-basic.php
592
		#取得xml檔案內容的示範=>http://php.net/manual/en/simplexml.examples-basic.php
593
		#啟用處理xml的錯誤處理=>http://php.net/manual/en/function.libxml-use-internal-errors.php
593
		#啟用處理xml的錯誤處理=>http://php.net/manual/en/function.libxml-use-internal-errors.php
594
		#取得處理xml的錯誤訊息=>http://php.net/manual/en/function.libxml-get-errors.php
594
		#取得處理xml的錯誤訊息=>http://php.net/manual/en/function.libxml-get-errors.php
595
		$getContent=xml::getContent($conf["xml::getContent"]);
595
		$getContent=xml::getContent($conf["xml::getContent"]);
596
		unset($conf["xml::getContent"]);
596
		unset($conf["xml::getContent"]);
597
		
597
 
598
		#如果取得 xml 內容失敗
598
		#如果取得 xml 內容失敗
599
		if($getContent["status"]==="false"){
599
		if($getContent["status"]==="false"){
600
						
600
 
601
			#設置執行不正常
601
			#設置執行不正常
602
			$result["status"]="false";
602
			$result["status"]="false";
603
			
603
 
604
			#設置執行錯誤
604
			#設置執行錯誤
605
			$result["error"]=$getContent;
605
			$result["error"]=$getContent;
606
			
606
 
607
			#回傳結果
607
			#回傳結果
608
			return $result;
608
			return $result;
609
			
609
 
610
			}#if end
610
			}#if end
611
		
611
 
612
		#儲存目前所指的tag內容
612
		#儲存目前所指的tag內容
613
		$tagPointer="";
613
		$tagPointer="";
614
					
614
 
615
		#針對每層 $conf["tag"]
615
		#針對每層 $conf["tag"]
616
		foreach($conf["tag"] as $tag){
616
		foreach($conf["tag"] as $tag){
617
			
617
 
618
			#過濾標籤
618
			#過濾標籤
619
			
619
 
620
			#如果 $tagPointer 為 ""
620
			#如果 $tagPointer 為 ""
621
			if($tagPointer===""){
621
			if($tagPointer===""){
622
				
622
 
623
				#如果 $tag 存在 
623
				#如果 $tag 存在
624
				if(isset($getContent["content"]->$tag)){
624
				if(isset($getContent["content"]->$tag)){
625
					
625
 
626
					#取得tag的pointer
626
					#取得tag的pointer
627
					$tagPointer=$getContent["content"]->$tag;
627
					$tagPointer=$getContent["content"]->$tag;
628
					
628
 
629
					}#if end
629
					}#if end
630
					
630
 
631
				#反之
631
				#反之
632
				else{
632
				else{
633
					
633
 
634
					#設置執行不正常
634
					#設置執行不正常
635
					$result["status"]="true";
635
					$result["status"]="true";
636
					
636
 
637
					#設置執行錯誤
637
					#設置執行錯誤
638
					$result["warning"][]="標籤 ".$tag." 不存在";
638
					$result["warning"][]="標籤 ".$tag." 不存在";
639
					
639
 
640
					#設置tag不存在
640
					#設置tag不存在
641
					$result["tagExist"]="false";
641
					$result["tagExist"]="false";
642
					
642
 
643
					#回傳結果
643
					#回傳結果
644
					return $result;
644
					return $result;
645
					
645
 
646
					}#else end
646
					}#else end
647
				
647
 
648
				}#if end
648
				}#if end
649
						
649
 
650
			#如果標籤不存在
650
			#如果標籤不存在
651
			else if(isset($tagPointer->$tag)){
651
			else if(isset($tagPointer->$tag)){
652
				
652
 
653
				#取得tag pointer
653
				#取得tag pointer
654
				$tagPointer=$tagPointer->$tag;
654
				$tagPointer=$tagPointer->$tag;
655
				
655
 
656
				}#if end
656
				}#if end
657
			
657
 
658
			#反之標籤存在
658
			#反之標籤存在
659
			else{				
659
			else{
660
											
660
 
661
				#設置執行不正常
661
				#設置執行不正常
662
				$result["status"]="true";
662
				$result["status"]="true";
663
				
663
 
664
				#設置執行錯誤
664
				#設置執行錯誤
665
				$result["warning"][]="標籤 ".$tag." 不存在";
665
				$result["warning"][]="標籤 ".$tag." 不存在";
666
				
666
 
667
				#設置tag不存在
667
				#設置tag不存在
668
				$result["tagExist"]="false";
668
				$result["tagExist"]="false";
669
				
669
 
670
				#回傳結果
670
				#回傳結果
671
				return $result;								
671
				return $result;
672
												
672
 
673
				}#else end
673
				}#else end
674
			
674
 
675
			}#foreach end	
675
			}#foreach end
676
			
676
 
677
		#設置tag存在
677
		#設置tag存在
678
		$result["tagExist"]="true";
678
		$result["tagExist"]="true";
679
		
679
 
680
		#設置tag內容
680
		#設置tag內容
681
		$result["content"]=$tagPointer;	
681
		$result["content"]=$tagPointer;
682
			
682
 
683
		#設置執行正常
683
		#設置執行正常
684
		$result["status"]="true";				
684
		$result["status"]="true";
685
			
685
 
686
		#回傳結果
686
		#回傳結果
687
		return $result;
687
		return $result;
688
		
688
 
689
		}#function getTagInfo end
689
		}#function getTagInfo end
690
 
690
 
691
	/*
691
	/*
692
	#函式說明:
692
	#函式說明:
693
	#建立空的xml檔案
693
	#建立空的xml檔案
Line 698... Line 698...
698
	#$result["content"],xml檔案的路徑.
698
	#$result["content"],xml檔案的路徑.
699
	#必填參數:
699
	#必填參數:
700
	#$conf["xmlPosition"],字串,xml檔案的位置.
700
	#$conf["xmlPosition"],字串,xml檔案的位置.
701
	$conf["xmlPosition"]="";
701
	$conf["xmlPosition"]="";
702
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
702
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
703
	$conf["fileArgu"]=__FILE__; 
703
	$conf["fileArgu"]=__FILE__;
704
	#可省略參數:
704
	#可省略參數:
705
	#無.
705
	#無.
706
	#參考資料:
706
	#參考資料:
707
	#simplexmlelement=>http://php.net/manual/en/simplexmlelement.asxml.php
707
	#simplexmlelement=>http://php.net/manual/en/simplexmlelement.asxml.php
708
	#備註:
708
	#備註:
709
	#無.
709
	#無.
710
	*/
710
	*/
711
	static function createEmptyXml(&$conf){
711
	static function createEmptyXml(&$conf){
712
		
712
 
713
		#初始化要回傳的結果
713
		#初始化要回傳的結果
714
		$result=array();
714
		$result=array();
715
 
715
 
716
		#取得當前執行的函數名稱
716
		#取得當前執行的函數名稱
717
		$result["function"]=__FUNCTION__;
717
		$result["function"]=__FUNCTION__;
718
 
718
 
719
		#如果沒有參數
719
		#如果沒有參數
720
		if(func_num_args()==0){
720
		if(func_num_args()==0){
721
			
721
 
722
			#設置執行失敗
722
			#設置執行失敗
723
			$result["status"]="false";
723
			$result["status"]="false";
724
			
724
 
725
			#設置執行錯誤訊息
725
			#設置執行錯誤訊息
726
			$result["error"]="函數".$result["function"]."需要參數";
726
			$result["error"]="函數".$result["function"]."需要參數";
727
			
727
 
728
			#回傳結果
728
			#回傳結果
729
			return $result;
729
			return $result;
730
			
730
 
731
			}#if end
731
			}#if end
732
 
732
 
733
		#取得參數
733
		#取得參數
734
		$result["argu"]=$conf;
734
		$result["argu"]=$conf;
735
 
735
 
736
		#如果 $conf 不為陣列
736
		#如果 $conf 不為陣列
737
		if(gettype($conf)!="array"){
737
		if(gettype($conf)!="array"){
738
			
738
 
739
			#設置執行失敗
739
			#設置執行失敗
740
			$result["status"]="false";
740
			$result["status"]="false";
741
			
741
 
742
			#設置執行錯誤訊息
742
			#設置執行錯誤訊息
743
			$result["error"][]="\$conf變數須為陣列形態";
743
			$result["error"][]="\$conf變數須為陣列形態";
744
			
744
 
745
			#如果傳入的參數為 null
745
			#如果傳入的參數為 null
746
			if($conf==null){
746
			if($conf==null){
747
				
747
 
748
				#設置執行錯誤訊息
748
				#設置執行錯誤訊息
749
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
749
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
750
				
750
 
751
				}#if end
751
				}#if end
752
 
752
 
753
			#回傳結果
753
			#回傳結果
754
			return $result;
754
			return $result;
755
			
755
 
756
			}#if end
756
			}#if end
757
	
757
 
758
		#檢查參數
758
		#檢查參數
759
		#函式說明:
759
		#函式說明:
760
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
760
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
761
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
761
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
762
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
762
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 783... Line 783...
783
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
783
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
784
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
784
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
785
		#$conf["skipableVariableCanNotBeEmpty"]=array();
785
		#$conf["skipableVariableCanNotBeEmpty"]=array();
786
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
786
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
787
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu","conf","commentsArray");
787
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu","conf","commentsArray");
788
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
788
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
789
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","array");
789
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","array");
790
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
790
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
791
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__,".qbpwcf_tmp/cmd/getFromConf/conf.xml",array("請輸入變數 ".$conf["readVarName"]." 的內容"));
791
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__,".qbpwcf_tmp/cmd/getFromConf/conf.xml",array("請輸入變數 ".$conf["readVarName"]." 的內容"));
792
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
792
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
793
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
793
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
794
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
794
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
795
		#參考資料來源:
795
		#參考資料來源:
796
		#array_keys=>http://php.net/manual/en/function.array-keys.php
796
		#array_keys=>http://php.net/manual/en/function.array-keys.php
797
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
797
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
798
		unset($conf["variableCheck::checkArguments"]);	
798
		unset($conf["variableCheck::checkArguments"]);
799
			
799
 
800
		#如果檢查參數失敗
800
		#如果檢查參數失敗
801
		if($checkArguments["status"]=="false"){
801
		if($checkArguments["status"]=="false"){
802
			
802
 
803
			#設置執行不正常
803
			#設置執行不正常
804
			$result["status"]="false";
804
			$result["status"]="false";
805
			
805
 
806
			#設置執行錯誤
806
			#設置執行錯誤
807
			$result["error"]=$checkArguments;
807
			$result["error"]=$checkArguments;
808
			
808
 
809
			#回傳結果
809
			#回傳結果
810
			return $result;
810
			return $result;
811
			
811
 
812
			}#if end
812
			}#if end
813
			
813
 
814
		#如果檢查參數不通過
814
		#如果檢查參數不通過
815
		if($checkArguments["passed"]=="false"){
815
		if($checkArguments["passed"]=="false"){
816
			
816
 
817
			#設置執行不正常
817
			#設置執行不正常
818
			$result["status"]="false";
818
			$result["status"]="false";
819
			
819
 
820
			#設置執行錯誤
820
			#設置執行錯誤
821
			$result["error"]=$checkArguments;
821
			$result["error"]=$checkArguments;
822
			
822
 
823
			#回傳結果
823
			#回傳結果
824
			return $result;
824
			return $result;
825
			
825
 
826
			}#if end
826
			}#if end
827
		
827
 
828
		#轉換路徑為絕對路徑
828
		#轉換路徑為絕對路徑
829
		#函數說明:
829
		#函數說明:
830
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
830
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
831
		#回傳結果:
831
		#回傳結果:
832
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
832
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
833
		#$result["error"],錯誤訊息陣列.
833
		#$result["error"],錯誤訊息陣列.
834
		#$result["function"],函數名稱. 
834
		#$result["function"],函數名稱.
835
		#$result["content"],網址,若是在命令列執行,則為"null".
835
		#$result["content"],網址,若是在命令列執行,則為"null".
836
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
836
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
837
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
837
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
838
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
838
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
839
		#必填參數:
839
		#必填參數:
Line 846... Line 846...
846
		$conf["csInformation::getInternetAddress"]["userDir"]="true";
846
		$conf["csInformation::getInternetAddress"]["userDir"]="true";
847
		#備註:
847
		#備註:
848
		#在命令列執行,所得的路徑是錯誤的。
848
		#在命令列執行,所得的路徑是錯誤的。
849
		$getInternetAddress=fileAccess::getInternetAddress($conf["csInformation::getInternetAddress"]);
849
		$getInternetAddress=fileAccess::getInternetAddress($conf["csInformation::getInternetAddress"]);
850
		unset($conf["csInformation::getInternetAddress"]);
850
		unset($conf["csInformation::getInternetAddress"]);
851
		
851
 
852
		#如果轉換位置失敗
852
		#如果轉換位置失敗
853
		if($getInternetAddress["status"]=="false"){
853
		if($getInternetAddress["status"]=="false"){
854
			
854
 
855
			#設置執行不正常
855
			#設置執行不正常
856
			$result["status"]="false";
856
			$result["status"]="false";
857
			
857
 
858
			#設置執行錯誤
858
			#設置執行錯誤
859
			$result["error"]=$getInternetAddress;
859
			$result["error"]=$getInternetAddress;
860
			
860
 
861
			#回傳結果
861
			#回傳結果
862
			return $result;
862
			return $result;
863
			
863
 
864
			}#if end
864
			}#if end
865
		
865
 
866
		#取得轉換好的絕對位置
866
		#取得轉換好的絕對位置
867
		$conf["xmlPosition"]=$getInternetAddress["fileSystemAbsoulutePosition"];
867
		$conf["xmlPosition"]=$getInternetAddress["fileSystemAbsoulutePosition"];
868
		
868
 
869
		#建立xml樣本	
869
		#建立xml樣本
870
		$xmlStr = <<<XML
870
		$xmlStr = <<<XML
871
<root></root>
871
<root></root>
872
XML;
872
XML;
873
		
873
 
874
		#建立xml物件
874
		#建立xml物件
875
		$xml = new \SimpleXMLElement($xmlStr);
875
		$xml = new \SimpleXMLElement($xmlStr);
876
		
876
 
877
		#轉換成xml字串
877
		#轉換成xml字串
878
		$xml=$xml->asXML();
878
		$xml=$xml->asXML();
879
		
879
 
880
		#檢查xml檔有存在
880
		#檢查xml檔有存在
881
		#函式說明:檢查多個檔案與資料夾是否存在.
881
		#函式說明:檢查多個檔案與資料夾是否存在.
882
		#回傳的結果:
882
		#回傳的結果:
883
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
883
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
884
		#$result["error"],錯誤訊息陣列.
884
		#$result["error"],錯誤訊息陣列.
Line 903... Line 903...
903
		#http://php.net/manual/en/control-structures.foreach.php
903
		#http://php.net/manual/en/control-structures.foreach.php
904
		#備註:
904
		#備註:
905
		#函數file_exists檢查的路徑為檔案系統的路徑
905
		#函數file_exists檢查的路徑為檔案系統的路徑
906
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
906
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
907
		unset($conf["fileAccess::checkMultiFileExist"]);
907
		unset($conf["fileAccess::checkMultiFileExist"]);
908
		
908
 
909
		#如果檢查xml檔是否存在失敗
909
		#如果檢查xml檔是否存在失敗
910
		if($checkMultiFileExist["status"]=="false"){
910
		if($checkMultiFileExist["status"]=="false"){
911
			
911
 
912
			#設置執行不正常
912
			#設置執行不正常
913
			$result["status"]="false";
913
			$result["status"]="false";
914
			
914
 
915
			#設置執行錯誤
915
			#設置執行錯誤
916
			$result["error"]=$checkMultiFileExist;
916
			$result["error"]=$checkMultiFileExist;
917
			
917
 
918
			#回傳結果
918
			#回傳結果
919
			return $result;
919
			return $result;
920
			
920
 
921
			}#if end
921
			}#if end
922
			
922
 
923
		#如果xml檔不存在
923
		#如果xml檔不存在
924
		if($checkMultiFileExist["allExist"]=="false"){
924
		if($checkMultiFileExist["allExist"]=="false"){
925
			
925
 
926
			#建立xml檔的路徑
926
			#建立xml檔的路徑
927
			#函式說明:
927
			#函式說明:
928
			#確保路徑存在.
928
			#確保路徑存在.
929
			#回傳的結果:
929
			#回傳的結果:
930
			#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
930
			#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 932... Line 932...
932
			#$resutl["function"],當前執行的涵式名稱.
932
			#$resutl["function"],當前執行的涵式名稱.
933
			#$result["path"],建立好的路徑字串.
933
			#$result["path"],建立好的路徑字串.
934
			#$result["fileName"],檔案名稱,若 $conf["haveFileName"] 為 "true" 則會回傳.
934
			#$result["fileName"],檔案名稱,若 $conf["haveFileName"] 為 "true" 則會回傳.
935
			#必填的參數:
935
			#必填的參數:
936
			#$conf["path"],要檢查的路徑
936
			#$conf["path"],要檢查的路徑
937
			$conf["fileAccess::validatePath"]["path"]=$conf["xmlPosition"];		
937
			$conf["fileAccess::validatePath"]["path"]=$conf["xmlPosition"];
938
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
938
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
939
			$conf["fileAccess::validatePath"]["fileArgu"]=$conf["fileArgu"];
939
			$conf["fileAccess::validatePath"]["fileArgu"]=$conf["fileArgu"];
940
			#可省略參數:
940
			#可省略參數:
941
			#$conf["haveFileName"],字串,"true"代表有$conf["path"]檔案名稱,"false"代表$conf["path"]為純路徑,預設為"false".
941
			#$conf["haveFileName"],字串,"true"代表有$conf["path"]檔案名稱,"false"代表$conf["path"]為純路徑,預設為"false".
942
			$conf["fileAccess::validatePath"]["haveFileName"]="true";
942
			$conf["fileAccess::validatePath"]["haveFileName"]="true";
943
			#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
943
			#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
944
			#$conf["dirPermission"]="";
944
			#$conf["dirPermission"]="";
945
			$validatePath=fileAccess::validatePath($conf["fileAccess::validatePath"]);
945
			$validatePath=fileAccess::validatePath($conf["fileAccess::validatePath"]);
946
			unset($conf["fileAccess::validatePath"]);
946
			unset($conf["fileAccess::validatePath"]);
947
			
947
 
948
			#如果確保xml檔路徑失敗
948
			#如果確保xml檔路徑失敗
949
			if($validatePath["status"]=="false"){
949
			if($validatePath["status"]=="false"){
950
				
950
 
951
				#設置執行不正常
951
				#設置執行不正常
952
				$result["status"]="false";
952
				$result["status"]="false";
953
				
953
 
954
				#設置執行錯誤
954
				#設置執行錯誤
955
				$result["error"]=$validatePath;
955
				$result["error"]=$validatePath;
956
				
956
 
957
				#回傳結果
957
				#回傳結果
958
				return $result;
958
				return $result;
959
				
959
 
960
				}#if end
960
				}#if end
961
			
961
 
962
			#建立xml檔
962
			#建立xml檔
963
			#函式說明:
963
			#函式說明:
964
			#檢查要建立的檔案路徑是否存在,若不存在則建立新檔案,若檔案已存在則會在原檔名後面加上從(1)開始的編號,再度嘗試建立檔案,以避免資料異常.
964
			#檢查要建立的檔案路徑是否存在,若不存在則建立新檔案,若檔案已存在則會在原檔名後面加上從(1)開始的編號,再度嘗試建立檔案,以避免資料異常.
965
			#回傳的結果:
965
			#回傳的結果:
966
			#$result["status"],執行狀態,"true"代表執行正常,"false"代表執行失敗.
966
			#$result["status"],執行狀態,"true"代表執行正常,"false"代表執行失敗.
Line 974... Line 974...
974
			$conf["fileAccess::createFileAfterCheck"]["checkedFileAndPath"]=$conf["xmlPosition"];
974
			$conf["fileAccess::createFileAfterCheck"]["checkedFileAndPath"]=$conf["xmlPosition"];
975
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
975
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
976
			$conf["fileAccess::createFileAfterCheck"]["fileArgu"]=$conf["fileArgu"];
976
			$conf["fileAccess::createFileAfterCheck"]["fileArgu"]=$conf["fileArgu"];
977
			$createFileAfterCheck=fileAccess::createFileAfterCheck($conf["fileAccess::createFileAfterCheck"]);
977
			$createFileAfterCheck=fileAccess::createFileAfterCheck($conf["fileAccess::createFileAfterCheck"]);
978
			unset($conf["fileAccess::createFileAfterCheck"]);
978
			unset($conf["fileAccess::createFileAfterCheck"]);
979
			
979
 
980
			#如果建立xml檔案失敗
980
			#如果建立xml檔案失敗
981
			if($createFileAfterCheck["status"]=="false"){
981
			if($createFileAfterCheck["status"]=="false"){
982
				
982
 
983
				#設置執行不正常
983
				#設置執行不正常
984
				$result["status"]="false";
984
				$result["status"]="false";
985
				
985
 
986
				#設置執行錯誤
986
				#設置執行錯誤
987
				$result["error"]=$createFileAfterCheck;
987
				$result["error"]=$createFileAfterCheck;
988
				
988
 
989
				#回傳結果
989
				#回傳結果
990
				return $result;
990
				return $result;
991
				
991
 
992
				}#if end
992
				}#if end
993
				
993
 
994
			#取得建立好的檔案路徑與名稱
994
			#取得建立好的檔案路徑與名稱
995
			$conf["xmlPosition"]=$createFileAfterCheck["createdFilePathAndName"];
995
			$conf["xmlPosition"]=$createFileAfterCheck["createdFilePathAndName"];
996
				
996
 
997
			#寫入xml檔案
997
			#寫入xml檔案
998
			#函式說明:
998
			#函式說明:
999
			#將字串寫入到檔案
999
			#將字串寫入到檔案
1000
			#回傳的結果:
1000
			#回傳的結果:
1001
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
1001
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
Line 1008... Line 1008...
1008
			$conf["xml::writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
1008
			$conf["xml::writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
1009
			#可省略的參數:
1009
			#可省略的參數:
1010
			#$conf["writeMethod"]="a";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
1010
			#$conf["writeMethod"]="a";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
1011
			$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["xml::writeTextIntoFile"]);
1011
			$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["xml::writeTextIntoFile"]);
1012
			unset($conf["xml::writeTextIntoFile"]);
1012
			unset($conf["xml::writeTextIntoFile"]);
1013
			
1013
 
1014
			#如果寫入xml資料到xml檔案裡面失敗
1014
			#如果寫入xml資料到xml檔案裡面失敗
1015
			if($writeTextIntoFile["status"]=="false"){
1015
			if($writeTextIntoFile["status"]=="false"){
1016
				
1016
 
1017
				#設置執行不正常
1017
				#設置執行不正常
1018
				$result["status"]="false";
1018
				$result["status"]="false";
1019
				
1019
 
1020
				#設置執行錯誤
1020
				#設置執行錯誤
1021
				$result["error"]=$createFileAfterCheck;
1021
				$result["error"]=$createFileAfterCheck;
1022
				
1022
 
1023
				#回傳結果
1023
				#回傳結果
1024
				return $result;
1024
				return $result;
1025
				
1025
 
1026
				}#if end
1026
				}#if end
1027
				
1027
 
1028
			#設置執行正常
1028
			#設置執行正常
1029
			$result["status"]="true";
1029
			$result["status"]="true";
1030
			
1030
 
1031
			#設置xml檔案的路徑
1031
			#設置xml檔案的路徑
1032
			$result["content"]=$conf["xmlPosition"];
1032
			$result["content"]=$conf["xmlPosition"];
1033
			
1033
 
1034
			#回傳結果
1034
			#回傳結果
1035
			return $result;
1035
			return $result;
1036
			
1036
 
1037
			}#if end
1037
			}#if end
1038
		
1038
 
1039
		#反之xml檔案已經存在
1039
		#反之xml檔案已經存在
1040
		else{
1040
		else{
1041
			
1041
 
1042
			#設置執行失敗
1042
			#設置執行失敗
1043
			$result["status"]="false";
1043
			$result["status"]="false";
1044
			
1044
 
1045
			#設置錯誤訊息
1045
			#設置錯誤訊息
1046
			$result["error"][]="xml檔案 ".$conf["xmlPosition"]." 已經存在!";
1046
			$result["error"][]="xml檔案 ".$conf["xmlPosition"]." 已經存在!";
1047
			
1047
 
1048
			#回傳結果
1048
			#回傳結果
1049
			return $result;
1049
			return $result;
1050
			
1050
 
1051
			}#else end
1051
			}#else end
1052
		
1052
 
1053
		}#function createEmptyXml end
1053
		}#function createEmptyXml end
1054
 
1054
 
1055
	/*
1055
	/*
1056
	#函式說明:
1056
	#函式說明:
1057
	#在目標層級新增標籤與內容
1057
	#在目標層級新增標籤與內容
Line 1074... Line 1074...
1074
	#addchild->http://php.net/manual/en/simplexmlelement.addchild.php
1074
	#addchild->http://php.net/manual/en/simplexmlelement.addchild.php
1075
	#備註:
1075
	#備註:
1076
	#物件的名稱如果是多維陣列變數,則會出錯,請改用變數儲存.
1076
	#物件的名稱如果是多維陣列變數,則會出錯,請改用變數儲存.
1077
	*/
1077
	*/
1078
	static function addTag(&$conf){
1078
	static function addTag(&$conf){
1079
		
1079
 
1080
		#初始化要回傳的結果
1080
		#初始化要回傳的結果
1081
		$result=array();
1081
		$result=array();
1082
 
1082
 
1083
		#取得當前執行的函數名稱
1083
		#取得當前執行的函數名稱
1084
		$result["function"]=__FUNCTION__;
1084
		$result["function"]=__FUNCTION__;
1085
 
1085
 
1086
		#如果沒有參數
1086
		#如果沒有參數
1087
		if(func_num_args()==0){
1087
		if(func_num_args()==0){
1088
			
1088
 
1089
			#設置執行失敗
1089
			#設置執行失敗
1090
			$result["status"]="false";
1090
			$result["status"]="false";
1091
			
1091
 
1092
			#設置執行錯誤訊息
1092
			#設置執行錯誤訊息
1093
			$result["error"]="函數".$result["function"]."需要參數";
1093
			$result["error"]="函數".$result["function"]."需要參數";
1094
			
1094
 
1095
			#回傳結果
1095
			#回傳結果
1096
			return $result;
1096
			return $result;
1097
			
1097
 
1098
			}#if end
1098
			}#if end
1099
 
1099
 
1100
		#取得參數
1100
		#取得參數
1101
		$result["argu"]=$conf;
1101
		$result["argu"]=$conf;
1102
 
1102
 
1103
		#如果 $conf 不為陣列
1103
		#如果 $conf 不為陣列
1104
		if(gettype($conf)!="array"){
1104
		if(gettype($conf)!="array"){
1105
			
1105
 
1106
			#設置執行失敗
1106
			#設置執行失敗
1107
			$result["status"]="false";
1107
			$result["status"]="false";
1108
			
1108
 
1109
			#設置執行錯誤訊息
1109
			#設置執行錯誤訊息
1110
			$result["error"][]="\$conf變數須為陣列形態";
1110
			$result["error"][]="\$conf變數須為陣列形態";
1111
			
1111
 
1112
			#如果傳入的參數為 null
1112
			#如果傳入的參數為 null
1113
			if($conf==null){
1113
			if($conf==null){
1114
				
1114
 
1115
				#設置執行錯誤訊息
1115
				#設置執行錯誤訊息
1116
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1116
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1117
				
1117
 
1118
				}#if end
1118
				}#if end
1119
 
1119
 
1120
			#回傳結果
1120
			#回傳結果
1121
			return $result;
1121
			return $result;
1122
			
1122
 
1123
			}#if end
1123
			}#if end
1124
	
1124
 
1125
		#檢查參數
1125
		#檢查參數
1126
		#函式說明:
1126
		#函式說明:
1127
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
1127
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
1128
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1128
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1129
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
1129
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 1150... Line 1150...
1150
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
1150
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
1151
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
1151
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
1152
		#$conf["skipableVariableCanNotBeEmpty"]=array();
1152
		#$conf["skipableVariableCanNotBeEmpty"]=array();
1153
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
1153
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
1154
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("tagValue");
1154
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("tagValue");
1155
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
1155
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
1156
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
1156
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
1157
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
1157
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
1158
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("");
1158
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("");
1159
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
1159
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
1160
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
1160
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
1161
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
1161
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
1162
		#參考資料來源:
1162
		#參考資料來源:
1163
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1163
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1164
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1164
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1165
		unset($conf["variableCheck::checkArguments"]);	
1165
		unset($conf["variableCheck::checkArguments"]);
1166
			
1166
 
1167
		#如果檢查參數失敗
1167
		#如果檢查參數失敗
1168
		if($checkArguments["status"]=="false"){
1168
		if($checkArguments["status"]=="false"){
1169
			
1169
 
1170
			#設置執行不正常
1170
			#設置執行不正常
1171
			$result["status"]="false";
1171
			$result["status"]="false";
1172
			
1172
 
1173
			#設置執行錯誤
1173
			#設置執行錯誤
1174
			$result["error"]=$checkArguments;
1174
			$result["error"]=$checkArguments;
1175
			
1175
 
1176
			#回傳結果
1176
			#回傳結果
1177
			return $result;
1177
			return $result;
1178
			
1178
 
1179
			}#if end
1179
			}#if end
1180
			
1180
 
1181
		#如果檢查參數不通過
1181
		#如果檢查參數不通過
1182
		if($checkArguments["passed"]=="false"){
1182
		if($checkArguments["passed"]=="false"){
1183
			
1183
 
1184
			#設置執行不正常
1184
			#設置執行不正常
1185
			$result["status"]="false";
1185
			$result["status"]="false";
1186
			
1186
 
1187
			#設置執行錯誤
1187
			#設置執行錯誤
1188
			$result["error"]=$checkArguments;
1188
			$result["error"]=$checkArguments;
1189
			
1189
 
1190
			#回傳結果
1190
			#回傳結果
1191
			return $result;
1191
			return $result;
1192
			
1192
 
1193
			}#if end
1193
			}#if end
1194
		
1194
 
1195
		#轉換路徑為絕對路徑
1195
		#轉換路徑為絕對路徑
1196
		#函數說明:
1196
		#函數說明:
1197
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
1197
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
1198
		#回傳結果:
1198
		#回傳結果:
1199
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1199
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1200
		#$result["error"],錯誤訊息陣列.
1200
		#$result["error"],錯誤訊息陣列.
1201
		#$result["function"],函數名稱. 
1201
		#$result["function"],函數名稱.
1202
		#$result["content"],網址,若是在命令列執行,則為"null".
1202
		#$result["content"],網址,若是在命令列執行,則為"null".
1203
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
1203
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
1204
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
1204
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
1205
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
1205
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
1206
		#必填參數:
1206
		#必填參數:
Line 1213... Line 1213...
1213
		$conf["csInformation::getInternetAddress"]["userDir"]="true";
1213
		$conf["csInformation::getInternetAddress"]["userDir"]="true";
1214
		#備註:
1214
		#備註:
1215
		#在命令列執行,所得的路徑是錯誤的。
1215
		#在命令列執行,所得的路徑是錯誤的。
1216
		$getInternetAddress=fileAccess::getInternetAddress($conf["csInformation::getInternetAddress"]);
1216
		$getInternetAddress=fileAccess::getInternetAddress($conf["csInformation::getInternetAddress"]);
1217
		unset($conf["csInformation::getInternetAddress"]);
1217
		unset($conf["csInformation::getInternetAddress"]);
1218
		
1218
 
1219
		#如果轉換位置失敗
1219
		#如果轉換位置失敗
1220
		if($getInternetAddress["status"]=="false"){
1220
		if($getInternetAddress["status"]=="false"){
1221
			
1221
 
1222
			#設置執行不正常
1222
			#設置執行不正常
1223
			$result["status"]="false";
1223
			$result["status"]="false";
1224
			
1224
 
1225
			#設置執行錯誤
1225
			#設置執行錯誤
1226
			$result["error"]=$getInternetAddress;
1226
			$result["error"]=$getInternetAddress;
1227
			
1227
 
1228
			#回傳結果
1228
			#回傳結果
1229
			return $result;
1229
			return $result;
1230
			
1230
 
1231
			}#if end
1231
			}#if end
1232
		
1232
 
1233
		#取得轉換好的絕對位置
1233
		#取得轉換好的絕對位置
1234
		$conf["xmlPosition"]=$getInternetAddress["fileSystemAbsoulutePosition"];
1234
		$conf["xmlPosition"]=$getInternetAddress["fileSystemAbsoulutePosition"];
1235
			
1235
 
1236
		#函式說明:
1236
		#函式說明:
1237
		#讀取xml檔案,儲存所有標籤的內容,目前尚不能讀取屬性的資訊
1237
		#讀取xml檔案,儲存所有標籤的內容,目前尚不能讀取屬性的資訊
1238
		#回傳結果:
1238
		#回傳結果:
1239
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1239
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1240
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
1240
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 1251... Line 1251...
1251
		#取得xml檔案內容的示範=>http://php.net/manual/en/simplexml.examples-basic.php
1251
		#取得xml檔案內容的示範=>http://php.net/manual/en/simplexml.examples-basic.php
1252
		#啟用處理xml的錯誤處理=>http://php.net/manual/en/function.libxml-use-internal-errors.php
1252
		#啟用處理xml的錯誤處理=>http://php.net/manual/en/function.libxml-use-internal-errors.php
1253
		#取得處理xml的錯誤訊息=>http://php.net/manual/en/function.libxml-get-errors.php
1253
		#取得處理xml的錯誤訊息=>http://php.net/manual/en/function.libxml-get-errors.php
1254
		$getContent=xml::getContent($conf["xml::getContent"]);
1254
		$getContent=xml::getContent($conf["xml::getContent"]);
1255
		unset($conf["xml::getContent"]);
1255
		unset($conf["xml::getContent"]);
1256
		
1256
 
1257
		#如果取得 xml 內容失敗
1257
		#如果取得 xml 內容失敗
1258
		if($getContent["status"]=="false"){
1258
		if($getContent["status"]=="false"){
1259
			
1259
 
1260
			#設置執行不正常
1260
			#設置執行不正常
1261
			$result["status"]="false";
1261
			$result["status"]="false";
1262
			
1262
 
1263
			#設置執行錯誤
1263
			#設置執行錯誤
1264
			$result["error"]=$getContent;
1264
			$result["error"]=$getContent;
1265
			
1265
 
1266
			#回傳結果
1266
			#回傳結果
1267
			return $result;
1267
			return $result;
1268
			
1268
 
1269
			}#if end
1269
			}#if end
1270
			
1270
 
1271
		#儲存xml的內容
1271
		#儲存xml的內容
1272
		$xmlContent=$getContent["content"];
1272
		$xmlContent=$getContent["content"];
1273
			
1273
 
1274
		#過濾 $conf["tag"] 陣列元素的 「::」 字元
1274
		#過濾 $conf["tag"] 陣列元素的 「::」 字元
1275
		#函式說明:
1275
		#函式說明:
1276
		#處理多個字串避免網頁出錯
1276
		#處理多個字串避免網頁出錯
1277
		#回傳的結果:
1277
		#回傳的結果:
1278
		#$result["status"],"true"代表執行成功,"false"代表執行失敗。
1278
		#$result["status"],"true"代表執行成功,"false"代表執行失敗。
Line 1286... Line 1286...
1286
			#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
1286
			#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
1287
			#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
1287
			#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
1288
		#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
1288
		#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
1289
		$correctMutiStrCharacter=stringProcess::correctMutiStrCharacter($conf["stringProcess::correctMutiStrCharacter"]);
1289
		$correctMutiStrCharacter=stringProcess::correctMutiStrCharacter($conf["stringProcess::correctMutiStrCharacter"]);
1290
		unset($conf["stringProcess::correctMutiStrCharacter"]);
1290
		unset($conf["stringProcess::correctMutiStrCharacter"]);
1291
					
1291
 
1292
		#如果修正標籤名稱失敗
1292
		#如果修正標籤名稱失敗
1293
		if($correctMutiStrCharacter["status"]==="false"){
1293
		if($correctMutiStrCharacter["status"]==="false"){
1294
			
1294
 
1295
			#設置執行不正常
1295
			#設置執行不正常
1296
			$result["status"]="false";
1296
			$result["status"]="false";
1297
			
1297
 
1298
			#設置執行錯誤
1298
			#設置執行錯誤
1299
			$result["error"]=$correctMutiStrCharacter;
1299
			$result["error"]=$correctMutiStrCharacter;
1300
			
1300
 
1301
			#回傳結果
1301
			#回傳結果
1302
			return $result;
1302
			return $result;
1303
			
1303
 
1304
			}#if end
1304
			}#if end
1305
			
1305
 
1306
		#取得修正好的tag名稱
1306
		#取得修正好的tag名稱
1307
		$conf["tag"]=$correctMutiStrCharacter["processedStrArray"];	
1307
		$conf["tag"]=$correctMutiStrCharacter["processedStrArray"];
1308
			
1308
 
1309
		#暫存tag pointer
1309
		#暫存tag pointer
1310
		$tagPointer=&$xmlContent;	
1310
		$tagPointer=&$xmlContent;
1311
			
1311
 
1312
		#儲存每一層用到的物件參考
1312
		#儲存每一層用到的物件參考
1313
		$thisLeyer=array(&$tagPointer);	
1313
		$thisLeyer=array(&$tagPointer);
1314
			
1314
 
1315
		#針對每層 $conf["tag"]
1315
		#針對每層 $conf["tag"]
1316
		for($i=0;$i<count($conf["tag"]);$i++){
1316
		for($i=0;$i<count($conf["tag"]);$i++){
1317
			
1317
 
1318
			#避免指標後面的陣列變數解析錯誤
1318
			#避免指標後面的陣列變數解析錯誤
1319
			$tagName=$conf["tag"][$i];
1319
			$tagName=$conf["tag"][$i];
1320
			
1320
 
1321
			#如果是最後一層
1321
			#如果是最後一層
1322
			if($i===count($conf["tag"])-1){
1322
			if($i===count($conf["tag"])-1){
1323
					
1323
 
1324
				#如果這層是物件
1324
				#如果這層是物件
1325
				if(gettype($thisLeyer[count($thisLeyer)-1])==="object"){
1325
				if(gettype($thisLeyer[count($thisLeyer)-1])==="object"){
1326
					
1326
 
1327
					#這層有幾個元素就執行幾次
1327
					#這層有幾個元素就執行幾次
1328
					for($j=0;$j<count($thisLeyer[count($thisLeyer)-1]);$j++){
1328
					for($j=0;$j<count($thisLeyer[count($thisLeyer)-1]);$j++){
1329
												
1329
 
1330
						#如果下一層tag已經存在
1330
						#如果下一層tag已經存在
1331
						if(isset($thisLeyer[count($thisLeyer)-1][$j]->$tagName)){
1331
						if(isset($thisLeyer[count($thisLeyer)-1][$j]->$tagName)){
1332
							
1332
 
1333
							#檢查其值是否跟要新增的標籤數值一樣
1333
							#檢查其值是否跟要新增的標籤數值一樣
1334
							if($conf["tagValue"]===(string)$thisLeyer[count($thisLeyer)-1][$j]->$tagName){
1334
							if($conf["tagValue"]===(string)$thisLeyer[count($thisLeyer)-1][$j]->$tagName){
1335
																
-
 
-
 
1335
 
1336
								#找下一層
1336
								#找下一層
1337
								continue;
1337
								continue;
1338
								
1338
 
1339
								}#if end							
1339
								}#if end
1340
							
1340
 
1341
							}#if end
1341
							}#if end
1342
						
1342
 
1343
						}#for end
1343
						}#for end
1344
						
1344
 
1345
					#新增標籤
1345
					#新增標籤
1346
					$thisLeyer[count($thisLeyer)-1]->addChild($tagName,$conf["tagValue"]);
1346
					$thisLeyer[count($thisLeyer)-1]->addChild($tagName,$conf["tagValue"]);
1347
					
1347
 
1348
					}#if end	
1348
					}#if end
1349
				
1349
 
1350
				#如果下一層tag已經存在
1350
				#如果下一層tag已經存在
1351
				if(isset($thisLeyer[count($thisLeyer)-1]->$tagName)){
1351
				if(isset($thisLeyer[count($thisLeyer)-1]->$tagName)){
1352
					
1352
 
1353
					#檢查其值是否跟要新增的標籤數值一樣
1353
					#檢查其值是否跟要新增的標籤數值一樣
1354
					if($conf["tagValue"]===(string)$thisLeyer[count($thisLeyer)-1]->$tagName){
1354
					if($conf["tagValue"]===(string)$thisLeyer[count($thisLeyer)-1]->$tagName){
1355
						
1355
 
1356
						#取得該層tag
1356
						#取得該層tag
1357
						$thisLeyer[]=&$thisLeyer[count($thisLeyer)-1]->$tagName;
1357
						$thisLeyer[]=&$thisLeyer[count($thisLeyer)-1]->$tagName;
1358
						
1358
 
1359
						#跳到下一輪
1359
						#跳到下一輪
1360
						continue;
1360
						continue;
1361
						
1361
 
1362
						}#if end
1362
						}#if end
1363
					
1363
 
1364
					}#if end
1364
					}#if end
1365
					
1365
 
1366
				#反之下一層不存在
1366
				#反之下一層不存在
1367
				else{
1367
				else{
1368
					
1368
 
1369
					#新增標籤
1369
					#新增標籤
1370
					$thisLeyer[count($thisLeyer)-1]->addChild($tagName,$conf["tagValue"]);
1370
					$thisLeyer[count($thisLeyer)-1]->addChild($tagName,$conf["tagValue"]);
1371
					
1371
 
1372
					}#else end
1372
					}#else end
1373
					
1373
 
1374
				}#if end
1374
				}#if end
1375
			
1375
 
1376
			#反之不是最後一層
1376
			#反之不是最後一層
1377
			else{
1377
			else{
1378
						
1378
 
1379
				#如果這層是物件
1379
				#如果這層是物件
1380
				if(gettype($thisLeyer[count($thisLeyer)-1])==="object"){
1380
				if(gettype($thisLeyer[count($thisLeyer)-1])==="object"){
1381
					
1381
 
1382
					#如果裡面沒有元素
1382
					#如果裡面沒有元素
1383
					if(count($thisLeyer[count($thisLeyer)-1])===0){
1383
					if(count($thisLeyer[count($thisLeyer)-1])===0){
1384
								
1384
 
1385
						#新增標籤
1385
						#新增標籤
1386
						$thisLeyer[count($thisLeyer)-1]->addChild($conf["tag"][$i]);
1386
						$thisLeyer[count($thisLeyer)-1]->addChild($conf["tag"][$i]);
1387
						
1387
 
1388
						#取得該層
1388
						#取得該層
1389
						$thisLeyer[]=&$thisLeyer[count($thisLeyer)-1]->$tagName;							
1389
						$thisLeyer[]=&$thisLeyer[count($thisLeyer)-1]->$tagName;
1390
												
1390
 
1391
						}#if end
1391
						}#if end
1392
					
1392
 
1393
					#反之裡面有元素
1393
					#反之裡面有元素
1394
					else{
1394
					else{
1395
						
1395
 
1396
						#這層有幾個元素就執行幾次
1396
						#這層有幾個元素就執行幾次
1397
						for($j=0;$j<count($thisLeyer[count($thisLeyer)-1]);$j++){
1397
						for($j=0;$j<count($thisLeyer[count($thisLeyer)-1]);$j++){
1398
															
1398
 
1399
							#如果下一層tag已經存在
1399
							#如果下一層tag已經存在
1400
							if(isset($thisLeyer[count($thisLeyer)-1]->$tagName)){
1400
							if(isset($thisLeyer[count($thisLeyer)-1]->$tagName)){
1401
 
1401
 
1402
								#取得 tag & 進入下層
1402
								#取得 tag & 進入下層
1403
								$thisLeyer[]=&$thisLeyer[count($thisLeyer)-1]->$tagName;
1403
								$thisLeyer[]=&$thisLeyer[count($thisLeyer)-1]->$tagName;
1404
								
1404
 
1405
								#下一層
1405
								#下一層
1406
								continue 2;
1406
								continue 2;
1407
								
1407
 
1408
								}#if end							
1408
								}#if end
1409
													
1409
 
1410
							}#for end
1410
							}#for end
1411
							
1411
 
1412
						#新增標籤
1412
						#新增標籤
1413
						$thisLeyer[count($thisLeyer)-1]->addChild($tagName);	
1413
						$thisLeyer[count($thisLeyer)-1]->addChild($tagName);
1414
							
1414
 
1415
						#取得階層
1415
						#取得階層
1416
						$thisLeyer[]=&$thisLeyer[count($thisLeyer)-1]->$tagName;	
1416
						$thisLeyer[]=&$thisLeyer[count($thisLeyer)-1]->$tagName;
1417
						
1417
 
1418
						}#else end
1418
						}#else end
1419
					
1419
 
1420
					}#if end
1420
					}#if end
1421
					
1421
 
1422
				}#else end
1422
				}#else end
1423
			
1423
 
1424
			}#foreach end
1424
			}#foreach end
1425
			
1425
 
1426
		#儲存新的xml檔案內容
1426
		#儲存新的xml檔案內容
1427
		$xmlContent=$xmlContent->asXML();
1427
		$xmlContent=$xmlContent->asXML();
1428
				
1428
 
1429
		#覆寫xml檔案
1429
		#覆寫xml檔案
1430
		#函式說明:
1430
		#函式說明:
1431
		#將字串寫入到檔案
1431
		#將字串寫入到檔案
1432
		#回傳的結果:
1432
		#回傳的結果:
1433
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
1433
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
Line 1440... Line 1440...
1440
		$conf["xml::writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
1440
		$conf["xml::writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
1441
		#可省略的參數:
1441
		#可省略的參數:
1442
		#$conf["writeMethod"]="a";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
1442
		#$conf["writeMethod"]="a";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
1443
		$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["xml::writeTextIntoFile"]);
1443
		$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["xml::writeTextIntoFile"]);
1444
		unset($conf["xml::writeTextIntoFile"]);
1444
		unset($conf["xml::writeTextIntoFile"]);
1445
		
1445
 
1446
		#如果寫入xml資料到xml檔案裡面失敗
1446
		#如果寫入xml資料到xml檔案裡面失敗
1447
		if($writeTextIntoFile["status"]=="false"){
1447
		if($writeTextIntoFile["status"]=="false"){
1448
			
1448
 
1449
			#設置執行不正常
1449
			#設置執行不正常
1450
			$result["status"]="false";
1450
			$result["status"]="false";
1451
			
1451
 
1452
			#設置執行錯誤
1452
			#設置執行錯誤
1453
			$result["error"]=$writeTextIntoFile;
1453
			$result["error"]=$writeTextIntoFile;
1454
			
1454
 
1455
			#回傳結果
1455
			#回傳結果
1456
			return $result;
1456
			return $result;
1457
			
1457
 
1458
			}#if end
1458
			}#if end
1459
			
1459
 
1460
		#設置執行正常
1460
		#設置執行正常
1461
		$result["status"]="true";
1461
		$result["status"]="true";
1462
		
1462
 
1463
		#設置xml檔案的路徑
1463
		#設置xml檔案的路徑
1464
		$result["content"]=$conf["xmlPosition"];
1464
		$result["content"]=$conf["xmlPosition"];
1465
		
1465
 
1466
		#回傳結果
1466
		#回傳結果
1467
		return $result;	
1467
		return $result;
1468
		
1468
 
1469
		}#function addTag end
1469
		}#function addTag end
1470
 
1470
 
1471
	/*
1471
	/*
1472
	#函式說明:
1472
	#函式說明:
1473
	#更新xml標籤的內容.		
1473
	#更新xml標籤的內容.
1474
	#回傳結果:
1474
	#回傳結果:
1475
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1475
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1476
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
1476
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
1477
	#$result["function"],當前執行的函式名稱.
1477
	#$result["function"],當前執行的函式名稱.
1478
	#必填參數:
1478
	#必填參數:
Line 1492... Line 1492...
1492
	#update xml node value=>http://stackoverflow.com/questions/4748014/updating-xml-node-with-php
1492
	#update xml node value=>http://stackoverflow.com/questions/4748014/updating-xml-node-with-php
1493
	#備註:
1493
	#備註:
1494
	#若有多個同名的tag,則只會對於第一個tag進行操作.
1494
	#若有多個同名的tag,則只會對於第一個tag進行操作.
1495
	*/
1495
	*/
1496
	static function updateTag(&$conf){
1496
	static function updateTag(&$conf){
1497
		
1497
 
1498
		#初始化要回傳的結果
1498
		#初始化要回傳的結果
1499
		$result=array();
1499
		$result=array();
1500
 
1500
 
1501
		#取得當前執行的函數名稱
1501
		#取得當前執行的函數名稱
1502
		$result["function"]=__FUNCTION__;
1502
		$result["function"]=__FUNCTION__;
1503
 
1503
 
1504
		#如果沒有參數
1504
		#如果沒有參數
1505
		if(func_num_args()==0){
1505
		if(func_num_args()==0){
1506
			
1506
 
1507
			#設置執行失敗
1507
			#設置執行失敗
1508
			$result["status"]="false";
1508
			$result["status"]="false";
1509
			
1509
 
1510
			#設置執行錯誤訊息
1510
			#設置執行錯誤訊息
1511
			$result["error"]="函數".$result["function"]."需要參數";
1511
			$result["error"]="函數".$result["function"]."需要參數";
1512
			
1512
 
1513
			#回傳結果
1513
			#回傳結果
1514
			return $result;
1514
			return $result;
1515
			
1515
 
1516
			}#if end
1516
			}#if end
1517
 
1517
 
1518
		#取得參數
1518
		#取得參數
1519
		$result["argu"]=$conf;
1519
		$result["argu"]=$conf;
1520
 
1520
 
1521
		#如果 $conf 不為陣列
1521
		#如果 $conf 不為陣列
1522
		if(gettype($conf)!="array"){
1522
		if(gettype($conf)!="array"){
1523
			
1523
 
1524
			#設置執行失敗
1524
			#設置執行失敗
1525
			$result["status"]="false";
1525
			$result["status"]="false";
1526
			
1526
 
1527
			#設置執行錯誤訊息
1527
			#設置執行錯誤訊息
1528
			$result["error"][]="\$conf變數須為陣列形態";
1528
			$result["error"][]="\$conf變數須為陣列形態";
1529
			
1529
 
1530
			#如果傳入的參數為 null
1530
			#如果傳入的參數為 null
1531
			if($conf==null){
1531
			if($conf==null){
1532
				
1532
 
1533
				#設置執行錯誤訊息
1533
				#設置執行錯誤訊息
1534
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1534
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1535
				
1535
 
1536
				}#if end
1536
				}#if end
1537
 
1537
 
1538
			#回傳結果
1538
			#回傳結果
1539
			return $result;
1539
			return $result;
1540
			
1540
 
1541
			}#if end
1541
			}#if end
1542
	
1542
 
1543
		#檢查參數
1543
		#檢查參數
1544
		#函式說明:
1544
		#函式說明:
1545
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
1545
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
1546
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1546
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1547
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
1547
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 1568... Line 1568...
1568
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
1568
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
1569
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
1569
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
1570
		#$conf["skipableVariableCanNotBeEmpty"]=array();
1570
		#$conf["skipableVariableCanNotBeEmpty"]=array();
1571
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
1571
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
1572
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("tagValue");
1572
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("tagValue");
1573
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
1573
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
1574
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
1574
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
1575
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
1575
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
1576
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("");
1576
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("");
1577
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
1577
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
1578
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
1578
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
1579
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
1579
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
1580
		#參考資料來源:
1580
		#參考資料來源:
1581
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1581
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1582
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1582
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1583
		unset($conf["variableCheck::checkArguments"]);	
1583
		unset($conf["variableCheck::checkArguments"]);
1584
			
1584
 
1585
		#如果檢查參數失敗
1585
		#如果檢查參數失敗
1586
		if($checkArguments["status"]==="false"){
1586
		if($checkArguments["status"]==="false"){
1587
			
1587
 
1588
			#設置執行不正常
1588
			#設置執行不正常
1589
			$result["status"]="false";
1589
			$result["status"]="false";
1590
			
1590
 
1591
			#設置執行錯誤
1591
			#設置執行錯誤
1592
			$result["error"]=$checkArguments;
1592
			$result["error"]=$checkArguments;
1593
			
1593
 
1594
			#回傳結果
1594
			#回傳結果
1595
			return $result;
1595
			return $result;
1596
			
1596
 
1597
			}#if end
1597
			}#if end
1598
			
1598
 
1599
		#如果檢查參數不通過
1599
		#如果檢查參數不通過
1600
		if($checkArguments["passed"]==="false"){
1600
		if($checkArguments["passed"]==="false"){
1601
			
1601
 
1602
			#設置執行不正常
1602
			#設置執行不正常
1603
			$result["status"]="false";
1603
			$result["status"]="false";
1604
			
1604
 
1605
			#設置執行錯誤
1605
			#設置執行錯誤
1606
			$result["error"]=$checkArguments;
1606
			$result["error"]=$checkArguments;
1607
			
1607
 
1608
			#回傳結果
1608
			#回傳結果
1609
			return $result;
1609
			return $result;
1610
			
1610
 
1611
			}#if end
1611
			}#if end
1612
			
1612
 
1613
		#轉換路徑為絕對路徑
1613
		#轉換路徑為絕對路徑
1614
		#函數說明:
1614
		#函數說明:
1615
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
1615
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
1616
		#回傳結果:
1616
		#回傳結果:
1617
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1617
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1618
		#$result["error"],錯誤訊息陣列.
1618
		#$result["error"],錯誤訊息陣列.
1619
		#$result["function"],函數名稱. 
1619
		#$result["function"],函數名稱.
1620
		#$result["content"],網址,若是在命令列執行,則為"null".
1620
		#$result["content"],網址,若是在命令列執行,則為"null".
1621
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
1621
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
1622
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
1622
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
1623
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
1623
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
1624
		#必填參數:
1624
		#必填參數:
Line 1631... Line 1631...
1631
		$conf["csInformation::getInternetAddress"]["userDir"]="true";
1631
		$conf["csInformation::getInternetAddress"]["userDir"]="true";
1632
		#備註:
1632
		#備註:
1633
		#在命令列執行,所得的路徑是錯誤的。
1633
		#在命令列執行,所得的路徑是錯誤的。
1634
		$getInternetAddress=fileAccess::getInternetAddress($conf["csInformation::getInternetAddress"]);
1634
		$getInternetAddress=fileAccess::getInternetAddress($conf["csInformation::getInternetAddress"]);
1635
		unset($conf["csInformation::getInternetAddress"]);
1635
		unset($conf["csInformation::getInternetAddress"]);
1636
		
1636
 
1637
		#如果轉換位置失敗
1637
		#如果轉換位置失敗
1638
		if($getInternetAddress["status"]==="false"){
1638
		if($getInternetAddress["status"]==="false"){
1639
			
1639
 
1640
			#設置執行不正常
1640
			#設置執行不正常
1641
			$result["status"]="false";
1641
			$result["status"]="false";
1642
			
1642
 
1643
			#設置執行錯誤
1643
			#設置執行錯誤
1644
			$result["error"]=$getInternetAddress;
1644
			$result["error"]=$getInternetAddress;
1645
			
1645
 
1646
			#回傳結果
1646
			#回傳結果
1647
			return $result;
1647
			return $result;
1648
			
1648
 
1649
			}#if end
1649
			}#if end
1650
		
1650
 
1651
		#取得轉換好的絕對位置
1651
		#取得轉換好的絕對位置
1652
		$conf["xmlPosition"]=$getInternetAddress["fileSystemAbsoulutePosition"];	
1652
		$conf["xmlPosition"]=$getInternetAddress["fileSystemAbsoulutePosition"];
1653
			
1653
 
1654
		#函式說明:
1654
		#函式說明:
1655
		#讀取xml檔案,儲存所有標籤的內容,目前尚不能讀取屬性的資訊
1655
		#讀取xml檔案,儲存所有標籤的內容,目前尚不能讀取屬性的資訊
1656
		#回傳結果:
1656
		#回傳結果:
1657
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1657
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1658
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
1658
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 1669... Line 1669...
1669
		#取得xml檔案內容的示範=>http://php.net/manual/en/simplexml.examples-basic.php
1669
		#取得xml檔案內容的示範=>http://php.net/manual/en/simplexml.examples-basic.php
1670
		#啟用處理xml的錯誤處理=>http://php.net/manual/en/function.libxml-use-internal-errors.php
1670
		#啟用處理xml的錯誤處理=>http://php.net/manual/en/function.libxml-use-internal-errors.php
1671
		#取得處理xml的錯誤訊息=>http://php.net/manual/en/function.libxml-get-errors.php
1671
		#取得處理xml的錯誤訊息=>http://php.net/manual/en/function.libxml-get-errors.php
1672
		$getContent=xml::getContent($conf["xml::getContent"]);
1672
		$getContent=xml::getContent($conf["xml::getContent"]);
1673
		unset($conf["xml::getContent"]);
1673
		unset($conf["xml::getContent"]);
1674
		
1674
 
1675
		#如果取得 xml 內容失敗
1675
		#如果取得 xml 內容失敗
1676
		if($getContent["status"]==="false"){
1676
		if($getContent["status"]==="false"){
1677
			
1677
 
1678
			#設置執行不正常
1678
			#設置執行不正常
1679
			$result["status"]="false";
1679
			$result["status"]="false";
1680
			
1680
 
1681
			#設置執行錯誤
1681
			#設置執行錯誤
1682
			$result["error"]=$getContent;
1682
			$result["error"]=$getContent;
1683
			
1683
 
1684
			#回傳結果
1684
			#回傳結果
1685
			return $result;
1685
			return $result;
1686
			
1686
 
1687
			}#if end
1687
			}#if end
1688
		
1688
 
1689
		#儲存暫存的xml檔案內容
1689
		#儲存暫存的xml檔案內容
1690
		$xmlContent=$getContent["content"];
1690
		$xmlContent=$getContent["content"];
1691
		
1691
 
1692
		#過濾 $conf["tag"] 陣列元素的 「::」 字元
1692
		#過濾 $conf["tag"] 陣列元素的 「::」 字元
1693
		#函式說明:
1693
		#函式說明:
1694
		#處理多個字串避免網頁出錯
1694
		#處理多個字串避免網頁出錯
1695
		#回傳的結果:
1695
		#回傳的結果:
1696
		#$result["status"],"true"代表執行成功,"false"代表執行失敗。
1696
		#$result["status"],"true"代表執行成功,"false"代表執行失敗。
Line 1704... Line 1704...
1704
			#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
1704
			#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
1705
			#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
1705
			#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
1706
		#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
1706
		#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
1707
		$correctMutiStrCharacter=stringProcess::correctMutiStrCharacter($conf["stringProcess::correctMutiStrCharacter"]);
1707
		$correctMutiStrCharacter=stringProcess::correctMutiStrCharacter($conf["stringProcess::correctMutiStrCharacter"]);
1708
		unset($conf["stringProcess::correctMutiStrCharacter"]);
1708
		unset($conf["stringProcess::correctMutiStrCharacter"]);
1709
					
1709
 
1710
		#如果修正標籤名稱失敗
1710
		#如果修正標籤名稱失敗
1711
		if($correctMutiStrCharacter["status"]==="false"){
1711
		if($correctMutiStrCharacter["status"]==="false"){
1712
			
1712
 
1713
			#設置執行不正常
1713
			#設置執行不正常
1714
			$result["status"]="false";
1714
			$result["status"]="false";
1715
			
1715
 
1716
			#設置執行錯誤
1716
			#設置執行錯誤
1717
			$result["error"]=$correctMutiStrCharacter;
1717
			$result["error"]=$correctMutiStrCharacter;
1718
			
1718
 
1719
			#回傳結果
1719
			#回傳結果
1720
			return $result;
1720
			return $result;
1721
			
1721
 
1722
			}#if end
1722
			}#if end
1723
			
1723
 
1724
		#取得修正好的tag名稱
1724
		#取得修正好的tag名稱
1725
		$conf["tag"]=$correctMutiStrCharacter["processedStrArray"];
1725
		$conf["tag"]=$correctMutiStrCharacter["processedStrArray"];
1726
		
1726
 
1727
		#針對每層 $conf["tag"]
1727
		#針對每層 $conf["tag"]
1728
		for($i=0;$i<count($conf["tag"]);$i++){
1728
		for($i=0;$i<count($conf["tag"]);$i++){
1729
			
1729
 
1730
			#如果是最後一層
1730
			#如果是最後一層
1731
			if($i==count($conf["tag"])-1){
1731
			if($i==count($conf["tag"])-1){
1732
				
1732
 
1733
				#另存變數
1733
				#另存變數
1734
				$key=$conf["tag"][$i];
1734
				$key=$conf["tag"][$i];
1735
				
1735
 
1736
				#新增標籤
1736
				#新增標籤
1737
				$getContent["content"]->$key=$conf["tagValue"];
1737
				$getContent["content"]->$key=$conf["tagValue"];
1738
				
1738
 
1739
				}#if end
1739
				}#if end
1740
			
1740
 
1741
			#反之不是最後一層
1741
			#反之不是最後一層
1742
			else{
1742
			else{
1743
				
1743
 
1744
				#另存變數
1744
				#另存變數
1745
				$key=$conf["tag"][$i];
1745
				$key=$conf["tag"][$i];
1746
				
1746
 
1747
				#新增標籤
1747
				#新增標籤
1748
				$getContent["content"]=$getContent["content"]->$key;	
1748
				$getContent["content"]=$getContent["content"]->$key;
1749
				
1749
 
1750
				}#else end
1750
				}#else end
1751
			
1751
 
1752
			}#foreach end
1752
			}#foreach end
1753
			
1753
 
1754
		#儲存新的xml檔案內容
1754
		#儲存新的xml檔案內容
1755
		$xmlContent=$xmlContent->asXML();
1755
		$xmlContent=$xmlContent->asXML();
1756
		
1756
 
1757
		#覆寫xml檔案
1757
		#覆寫xml檔案
1758
		#函式說明:
1758
		#函式說明:
1759
		#將字串寫入到檔案
1759
		#將字串寫入到檔案
1760
		#回傳的結果:
1760
		#回傳的結果:
1761
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
1761
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
Line 1768... Line 1768...
1768
		$conf["xml::writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
1768
		$conf["xml::writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
1769
		#可省略的參數:
1769
		#可省略的參數:
1770
		#$conf["writeMethod"]="a";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
1770
		#$conf["writeMethod"]="a";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
1771
		$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["xml::writeTextIntoFile"]);
1771
		$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["xml::writeTextIntoFile"]);
1772
		unset($conf["xml::writeTextIntoFile"]);
1772
		unset($conf["xml::writeTextIntoFile"]);
1773
		
1773
 
1774
		#如果寫入xml資料到xml檔案裡面失敗
1774
		#如果寫入xml資料到xml檔案裡面失敗
1775
		if($writeTextIntoFile["status"]=="false"){
1775
		if($writeTextIntoFile["status"]=="false"){
1776
			
1776
 
1777
			#設置執行不正常
1777
			#設置執行不正常
1778
			$result["status"]="false";
1778
			$result["status"]="false";
1779
			
1779
 
1780
			#設置執行錯誤
1780
			#設置執行錯誤
1781
			$result["error"]=$createFileAfterCheck;
1781
			$result["error"]=$createFileAfterCheck;
1782
			
1782
 
1783
			#回傳結果
1783
			#回傳結果
1784
			return $result;
1784
			return $result;
1785
			
1785
 
1786
			}#if end
1786
			}#if end
1787
			
1787
 
1788
		#設置執行正常
1788
		#設置執行正常
1789
		$result["status"]="true";
1789
		$result["status"]="true";
1790
		
1790
 
1791
		#設置xml檔案的路徑
1791
		#設置xml檔案的路徑
1792
		$result["content"]=$conf["xmlPosition"];
1792
		$result["content"]=$conf["xmlPosition"];
1793
		
1793
 
1794
		#回傳結果
1794
		#回傳結果
1795
		return $result;
1795
		return $result;
1796
		
1796
 
1797
		}#function updateTag end
1797
		}#function updateTag end
1798
		
1798
 
1799
	/*
1799
	/*
1800
	#函式說明:
1800
	#函式說明:
1801
	#移除xml標籤的內容.		
1801
	#移除xml標籤的內容.
1802
	#回傳結果:
1802
	#回傳結果:
1803
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1803
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1804
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
1804
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
1805
	#$result["function"],當前執行的函式名稱.
1805
	#$result["function"],當前執行的函式名稱.
1806
	#必填參數:
1806
	#必填參數:
Line 1818... Line 1818...
1818
	#update xml node value=>http://stackoverflow.com/questions/4748014/updating-xml-node-with-php
1818
	#update xml node value=>http://stackoverflow.com/questions/4748014/updating-xml-node-with-php
1819
	#備註:
1819
	#備註:
1820
	#若有多個同名的tag,則會針對每個符合的tag進行操作.
1820
	#若有多個同名的tag,則會針對每個符合的tag進行操作.
1821
	*/
1821
	*/
1822
	static function removeTag(&$conf){
1822
	static function removeTag(&$conf){
1823
		
1823
 
1824
		#初始化要回傳的結果
1824
		#初始化要回傳的結果
1825
		$result=array();
1825
		$result=array();
1826
 
1826
 
1827
		#取得當前執行的函數名稱
1827
		#取得當前執行的函數名稱
1828
		$result["function"]=__FUNCTION__;
1828
		$result["function"]=__FUNCTION__;
1829
 
1829
 
1830
		#如果沒有參數
1830
		#如果沒有參數
1831
		if(func_num_args()==0){
1831
		if(func_num_args()==0){
1832
			
1832
 
1833
			#設置執行失敗
1833
			#設置執行失敗
1834
			$result["status"]="false";
1834
			$result["status"]="false";
1835
			
1835
 
1836
			#設置執行錯誤訊息
1836
			#設置執行錯誤訊息
1837
			$result["error"]="函數".$result["function"]."需要參數";
1837
			$result["error"]="函數".$result["function"]."需要參數";
1838
			
1838
 
1839
			#回傳結果
1839
			#回傳結果
1840
			return $result;
1840
			return $result;
1841
			
1841
 
1842
			}#if end
1842
			}#if end
1843
 
1843
 
1844
		#取得參數
1844
		#取得參數
1845
		$result["argu"]=$conf;
1845
		$result["argu"]=$conf;
1846
 
1846
 
1847
		#如果 $conf 不為陣列
1847
		#如果 $conf 不為陣列
1848
		if(gettype($conf)!="array"){
1848
		if(gettype($conf)!="array"){
1849
			
1849
 
1850
			#設置執行失敗
1850
			#設置執行失敗
1851
			$result["status"]="false";
1851
			$result["status"]="false";
1852
			
1852
 
1853
			#設置執行錯誤訊息
1853
			#設置執行錯誤訊息
1854
			$result["error"][]="\$conf變數須為陣列形態";
1854
			$result["error"][]="\$conf變數須為陣列形態";
1855
			
1855
 
1856
			#如果傳入的參數為 null
1856
			#如果傳入的參數為 null
1857
			if($conf==null){
1857
			if($conf==null){
1858
				
1858
 
1859
				#設置執行錯誤訊息
1859
				#設置執行錯誤訊息
1860
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1860
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1861
				
1861
 
1862
				}#if end
1862
				}#if end
1863
 
1863
 
1864
			#回傳結果
1864
			#回傳結果
1865
			return $result;
1865
			return $result;
1866
			
1866
 
1867
			}#if end
1867
			}#if end
1868
	
1868
 
1869
		#檢查參數
1869
		#檢查參數
1870
		#函式說明:
1870
		#函式說明:
1871
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
1871
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
1872
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1872
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1873
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
1873
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 1894... Line 1894...
1894
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
1894
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
1895
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
1895
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
1896
		#$conf["skipableVariableCanNotBeEmpty"]=array();
1896
		#$conf["skipableVariableCanNotBeEmpty"]=array();
1897
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
1897
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
1898
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("tagValue");
1898
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("tagValue");
1899
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
1899
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
1900
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
1900
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
1901
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
1901
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
1902
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("");
1902
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("");
1903
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
1903
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
1904
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
1904
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
1905
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
1905
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
1906
		#參考資料來源:
1906
		#參考資料來源:
1907
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1907
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1908
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1908
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1909
		unset($conf["variableCheck::checkArguments"]);	
1909
		unset($conf["variableCheck::checkArguments"]);
1910
			
1910
 
1911
		#如果檢查參數失敗
1911
		#如果檢查參數失敗
1912
		if($checkArguments["status"]=="false"){
1912
		if($checkArguments["status"]=="false"){
1913
			
1913
 
1914
			#設置執行不正常
1914
			#設置執行不正常
1915
			$result["status"]="false";
1915
			$result["status"]="false";
1916
			
1916
 
1917
			#設置執行錯誤
1917
			#設置執行錯誤
1918
			$result["error"]=$checkArguments;
1918
			$result["error"]=$checkArguments;
1919
			
1919
 
1920
			#回傳結果
1920
			#回傳結果
1921
			return $result;
1921
			return $result;
1922
			
1922
 
1923
			}#if end
1923
			}#if end
1924
			
1924
 
1925
		#如果檢查參數不通過
1925
		#如果檢查參數不通過
1926
		if($checkArguments["passed"]=="false"){
1926
		if($checkArguments["passed"]=="false"){
1927
			
1927
 
1928
			#設置執行不正常
1928
			#設置執行不正常
1929
			$result["status"]="false";
1929
			$result["status"]="false";
1930
			
1930
 
1931
			#設置執行錯誤
1931
			#設置執行錯誤
1932
			$result["error"]=$checkArguments;
1932
			$result["error"]=$checkArguments;
1933
			
1933
 
1934
			#回傳結果
1934
			#回傳結果
1935
			return $result;
1935
			return $result;
1936
			
1936
 
1937
			}#if end
1937
			}#if end
1938
		
1938
 
1939
		#轉換路徑為絕對路徑
1939
		#轉換路徑為絕對路徑
1940
		#函數說明:
1940
		#函數說明:
1941
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
1941
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
1942
		#回傳結果:
1942
		#回傳結果:
1943
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1943
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1944
		#$result["error"],錯誤訊息陣列.
1944
		#$result["error"],錯誤訊息陣列.
1945
		#$result["function"],函數名稱. 
1945
		#$result["function"],函數名稱.
1946
		#$result["content"],網址,若是在命令列執行,則為"null".
1946
		#$result["content"],網址,若是在命令列執行,則為"null".
1947
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
1947
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
1948
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
1948
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
1949
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
1949
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
1950
		#必填參數:
1950
		#必填參數:
Line 1957... Line 1957...
1957
		$conf["csInformation::getInternetAddress"]["userDir"]="true";
1957
		$conf["csInformation::getInternetAddress"]["userDir"]="true";
1958
		#備註:
1958
		#備註:
1959
		#在命令列執行,所得的路徑是錯誤的。
1959
		#在命令列執行,所得的路徑是錯誤的。
1960
		$getInternetAddress=fileAccess::getInternetAddress($conf["csInformation::getInternetAddress"]);
1960
		$getInternetAddress=fileAccess::getInternetAddress($conf["csInformation::getInternetAddress"]);
1961
		unset($conf["csInformation::getInternetAddress"]);
1961
		unset($conf["csInformation::getInternetAddress"]);
1962
		
1962
 
1963
		#如果轉換位置失敗
1963
		#如果轉換位置失敗
1964
		if($getInternetAddress["status"]=="false"){
1964
		if($getInternetAddress["status"]=="false"){
1965
			
1965
 
1966
			#設置執行不正常
1966
			#設置執行不正常
1967
			$result["status"]="false";
1967
			$result["status"]="false";
1968
			
1968
 
1969
			#設置執行錯誤
1969
			#設置執行錯誤
1970
			$result["error"]=$getInternetAddress;
1970
			$result["error"]=$getInternetAddress;
1971
			
1971
 
1972
			#回傳結果
1972
			#回傳結果
1973
			return $result;
1973
			return $result;
1974
			
1974
 
1975
			}#if end
1975
			}#if end
1976
		
1976
 
1977
		#取得轉換好的絕對位置
1977
		#取得轉換好的絕對位置
1978
		$conf["xmlPosition"]=$getInternetAddress["fileSystemAbsoulutePosition"];
1978
		$conf["xmlPosition"]=$getInternetAddress["fileSystemAbsoulutePosition"];
1979
			
1979
 
1980
		#函式說明:
1980
		#函式說明:
1981
		#讀取xml檔案,儲存所有標籤的內容,目前尚不能讀取屬性的資訊
1981
		#讀取xml檔案,儲存所有標籤的內容,目前尚不能讀取屬性的資訊
1982
		#回傳結果:
1982
		#回傳結果:
1983
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1983
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1984
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
1984
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 1995... Line 1995...
1995
		#取得xml檔案內容的示範=>http://php.net/manual/en/simplexml.examples-basic.php
1995
		#取得xml檔案內容的示範=>http://php.net/manual/en/simplexml.examples-basic.php
1996
		#啟用處理xml的錯誤處理=>http://php.net/manual/en/function.libxml-use-internal-errors.php
1996
		#啟用處理xml的錯誤處理=>http://php.net/manual/en/function.libxml-use-internal-errors.php
1997
		#取得處理xml的錯誤訊息=>http://php.net/manual/en/function.libxml-get-errors.php
1997
		#取得處理xml的錯誤訊息=>http://php.net/manual/en/function.libxml-get-errors.php
1998
		$getContent=xml::getContent($conf["xml::getContent"]);
1998
		$getContent=xml::getContent($conf["xml::getContent"]);
1999
		unset($conf["xml::getContent"]);
1999
		unset($conf["xml::getContent"]);
2000
		
2000
 
2001
		#如果取得 xml 內容失敗
2001
		#如果取得 xml 內容失敗
2002
		if($getContent["status"]=="false"){
2002
		if($getContent["status"]=="false"){
2003
			
2003
 
2004
			#設置執行不正常
2004
			#設置執行不正常
2005
			$result["status"]="false";
2005
			$result["status"]="false";
2006
			
2006
 
2007
			#設置執行錯誤
2007
			#設置執行錯誤
2008
			$result["error"]=$getContent;
2008
			$result["error"]=$getContent;
2009
			
2009
 
2010
			#回傳結果
2010
			#回傳結果
2011
			return $result;
2011
			return $result;
2012
			
2012
 
2013
			}#if end
2013
			}#if end
2014
		
2014
 
2015
		#儲存暫存的xml檔案內容
2015
		#儲存暫存的xml檔案內容
2016
		$xmlContent=$getContent["content"];
2016
		$xmlContent=$getContent["content"];
2017
		
2017
 
2018
		#針對每層 $conf["tag"]
2018
		#針對每層 $conf["tag"]
2019
		for($i=0;$i<count($conf["tag"]);$i++){
2019
		for($i=0;$i<count($conf["tag"]);$i++){
2020
			
2020
 
2021
			#如果是最後一層
2021
			#如果是最後一層
2022
			if($i==count($conf["tag"])-1){
2022
			if($i==count($conf["tag"])-1){
2023
				
2023
 
2024
				#移除標籤
2024
				#移除標籤
2025
				unset($getContent["content"]->$conf["tag"][$i]);
2025
				unset($getContent["content"]->$conf["tag"][$i]);
2026
				
2026
 
2027
				}#if end
2027
				}#if end
2028
			
2028
 
2029
			#反之不是最後一層
2029
			#反之不是最後一層
2030
			else{
2030
			else{
2031
				
2031
 
2032
				#新增標籤
2032
				#新增標籤
2033
				$getContent["content"]=$getContent["content"]->$conf["tag"][$i];	
2033
				$getContent["content"]=$getContent["content"]->$conf["tag"][$i];
2034
				
2034
 
2035
				}#else end
2035
				}#else end
2036
			
2036
 
2037
			}#foreach end
2037
			}#foreach end
2038
			
2038
 
2039
		#儲存新的xml檔案內容
2039
		#儲存新的xml檔案內容
2040
		$xmlContent=$xmlContent->asXML();
2040
		$xmlContent=$xmlContent->asXML();
2041
		
2041
 
2042
		#覆寫xml檔案
2042
		#覆寫xml檔案
2043
		#函式說明:
2043
		#函式說明:
2044
		#將字串寫入到檔案
2044
		#將字串寫入到檔案
2045
		#回傳的結果:
2045
		#回傳的結果:
2046
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
2046
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
Line 2053... Line 2053...
2053
		$conf["xml::writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
2053
		$conf["xml::writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
2054
		#可省略的參數:
2054
		#可省略的參數:
2055
		#$conf["writeMethod"]="a";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
2055
		#$conf["writeMethod"]="a";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
2056
		$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["xml::writeTextIntoFile"]);
2056
		$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["xml::writeTextIntoFile"]);
2057
		unset($conf["xml::writeTextIntoFile"]);
2057
		unset($conf["xml::writeTextIntoFile"]);
2058
		
2058
 
2059
		#如果寫入xml資料到xml檔案裡面失敗
2059
		#如果寫入xml資料到xml檔案裡面失敗
2060
		if($writeTextIntoFile["status"]=="false"){
2060
		if($writeTextIntoFile["status"]=="false"){
2061
			
2061
 
2062
			#設置執行不正常
2062
			#設置執行不正常
2063
			$result["status"]="false";
2063
			$result["status"]="false";
2064
			
2064
 
2065
			#設置執行錯誤
2065
			#設置執行錯誤
2066
			$result["error"]=$createFileAfterCheck;
2066
			$result["error"]=$createFileAfterCheck;
2067
			
2067
 
2068
			#回傳結果
2068
			#回傳結果
2069
			return $result;
2069
			return $result;
2070
			
2070
 
2071
			}#if end
2071
			}#if end
2072
			
2072
 
2073
		#設置執行正常
2073
		#設置執行正常
2074
		$result["status"]="true";
2074
		$result["status"]="true";
2075
		
2075
 
2076
		#設置xml檔案的路徑
2076
		#設置xml檔案的路徑
2077
		$result["content"]=$conf["xmlPosition"];
2077
		$result["content"]=$conf["xmlPosition"];
2078
		
2078
 
2079
		#回傳結果
2079
		#回傳結果
2080
		return $result;
2080
		return $result;
2081
		
2081
 
2082
		}#function updateTag end	
2082
		}#function updateTag end
2083
 
2083
 
2084
	/*
2084
	/*
2085
	#函式說明:
2085
	#函式說明:
2086
	#解析xml字串.
2086
	#解析xml字串.
2087
	#回傳結果:
2087
	#回傳結果:
Line 2099... Line 2099...
2099
	#https://www.w3schools.com/php/php_xml_simplexml_read.asp
2099
	#https://www.w3schools.com/php/php_xml_simplexml_read.asp
2100
	#備註:
2100
	#備註:
2101
	#無.
2101
	#無.
2102
	*/
2102
	*/
2103
	public static function parseXMLstring(&$conf){
2103
	public static function parseXMLstring(&$conf){
2104
	
2104
 
2105
		#初始化要回傳的結果
2105
		#初始化要回傳的結果
2106
		$result=array();
2106
		$result=array();
2107
 
2107
 
2108
		#取得當前執行的函數名稱
2108
		#取得當前執行的函數名稱
2109
		$result["function"]=__FUNCTION__;
2109
		$result["function"]=__FUNCTION__;
2110
 
2110
 
2111
		#如果沒有參數
2111
		#如果沒有參數
2112
		if(func_num_args()==0){
2112
		if(func_num_args()==0){
2113
			
2113
 
2114
			#設置執行失敗
2114
			#設置執行失敗
2115
			$result["status"]="false";
2115
			$result["status"]="false";
2116
			
2116
 
2117
			#設置執行錯誤訊息
2117
			#設置執行錯誤訊息
2118
			$result["error"]="函數".$result["function"]."需要參數";
2118
			$result["error"]="函數".$result["function"]."需要參數";
2119
			
2119
 
2120
			#回傳結果
2120
			#回傳結果
2121
			return $result;
2121
			return $result;
2122
			
2122
 
2123
			}#if end
2123
			}#if end
2124
 
2124
 
2125
		#取得參數
2125
		#取得參數
2126
		$result["argu"]=$conf;
2126
		$result["argu"]=$conf;
2127
 
2127
 
2128
		#如果 $conf 不為陣列
2128
		#如果 $conf 不為陣列
2129
		if(gettype($conf)!="array"){
2129
		if(gettype($conf)!="array"){
2130
			
2130
 
2131
			#設置執行失敗
2131
			#設置執行失敗
2132
			$result["status"]="false";
2132
			$result["status"]="false";
2133
			
2133
 
2134
			#設置執行錯誤訊息
2134
			#設置執行錯誤訊息
2135
			$result["error"][]="\$conf變數須為陣列形態";
2135
			$result["error"][]="\$conf變數須為陣列形態";
2136
			
2136
 
2137
			#如果傳入的參數為 null
2137
			#如果傳入的參數為 null
2138
			if($conf==null){
2138
			if($conf==null){
2139
				
2139
 
2140
				#設置執行錯誤訊息
2140
				#設置執行錯誤訊息
2141
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
2141
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
2142
				
2142
 
2143
				}#if end
2143
				}#if end
2144
 
2144
 
2145
			#回傳結果
2145
			#回傳結果
2146
			return $result;
2146
			return $result;
2147
			
2147
 
2148
			}#if end
2148
			}#if end
2149
	
2149
 
2150
		#檢查參數
2150
		#檢查參數
2151
		#函式說明:
2151
		#函式說明:
2152
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
2152
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
2153
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2153
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2154
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
2154
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 2175... Line 2175...
2175
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
2175
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
2176
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
2176
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
2177
		#$conf["skipableVariableCanNotBeEmpty"]=array();
2177
		#$conf["skipableVariableCanNotBeEmpty"]=array();
2178
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
2178
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
2179
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("tagValue");
2179
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("tagValue");
2180
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
2180
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
2181
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
2181
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
2182
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
2182
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
2183
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("");
2183
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("");
2184
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
2184
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
2185
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
2185
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
2186
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
2186
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
2187
		#參考資料來源:
2187
		#參考資料來源:
2188
		#array_keys=>http://php.net/manual/en/function.array-keys.php
2188
		#array_keys=>http://php.net/manual/en/function.array-keys.php
2189
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
2189
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
2190
		unset($conf["variableCheck::checkArguments"]);	
2190
		unset($conf["variableCheck::checkArguments"]);
2191
			
2191
 
2192
		#如果檢查參數失敗
2192
		#如果檢查參數失敗
2193
		if($checkArguments["status"]=="false"){
2193
		if($checkArguments["status"]=="false"){
2194
			
2194
 
2195
			#設置執行不正常
2195
			#設置執行不正常
2196
			$result["status"]="false";
2196
			$result["status"]="false";
2197
			
2197
 
2198
			#設置執行錯誤
2198
			#設置執行錯誤
2199
			$result["error"]=$checkArguments;
2199
			$result["error"]=$checkArguments;
2200
			
2200
 
2201
			#回傳結果
2201
			#回傳結果
2202
			return $result;
2202
			return $result;
2203
			
2203
 
2204
			}#if end
2204
			}#if end
2205
			
2205
 
2206
		#如果檢查參數不通過
2206
		#如果檢查參數不通過
2207
		if($checkArguments["passed"]=="false"){
2207
		if($checkArguments["passed"]=="false"){
2208
			
2208
 
2209
			#設置執行不正常
2209
			#設置執行不正常
2210
			$result["status"]="false";
2210
			$result["status"]="false";
2211
			
2211
 
2212
			#設置執行錯誤
2212
			#設置執行錯誤
2213
			$result["error"]=$checkArguments;
2213
			$result["error"]=$checkArguments;
2214
			
2214
 
2215
			#回傳結果
2215
			#回傳結果
2216
			return $result;
2216
			return $result;
2217
			
2217
 
2218
			}#if end
2218
			}#if end
2219
	
2219
 
2220
		#var_dump($conf["xmlString"]);exit;
2220
		#var_dump($conf["xmlString"]);exit;
2221
	
2221
 
2222
		#建立xml物件
2222
		#建立xml物件
2223
		$xml=simplexml_load_string($conf["xmlString"]);
2223
		$xml=simplexml_load_string($conf["xmlString"]);
2224
 
2224
 
2225
		#設置執行正常
2225
		#設置執行正常
2226
		$result["status"]="true";
2226
		$result["status"]="true";
2227
 
2227
 
2228
		#取得xml物件
2228
		#取得xml物件
2229
		$result["content"]=$xml;
2229
		$result["content"]=$xml;
2230
	
2230
 
2231
		#取得xml格式的文字
2231
		#取得xml格式的文字
2232
		$result["xmlStr"]=$xml->asXML();
2232
		$result["xmlStr"]=$xml->asXML();
2233
 
2233
 
2234
		#回傳結果
2234
		#回傳結果
2235
		return $result;
2235
		return $result;
2236
	
2236
 
2237
		}#function parseXMLstring end
2237
		}#function parseXMLstring end
2238
 
2238
 
2239
	}#class xml end
2239
	}#class xml end
2240
	
2240
 
2241
?>
2241
?>