Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 915 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 liveuser 1
<?php
2
 
3
#宣告指派命名空間
4
namespace qbpwcf;
5
 
6
#匯入外部套件
7
include("../allInOne.php");
8
 
9
#提示目前要測試的套件
10
echo "<hr>xml::getContent - testCase 1<br>";
11
 
12
/*
13
 
14
#涵式說明:
15
#讀取xml檔案,並取得所有節點的內容、屬性等資料
16
#回傳的結果:
17
#$result...
18
#必填的參數:
19
$conf["xmlPosition"]="xml/xmlSample.xml";#xml檔案的位置
20
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
21
$conf["fileArgu"]=__FILE__;
22
var_dump($xmlContent=xml::getContent($conf));
23
unset($conf);
24
 
25
*/
26
 
27
#提示目前要測試的套件
28
echo "<hr>xml::getContent - testCase 2<br>";
29
 
30
/*
31
 
32
#涵式說明:
33
#讀取xml檔案,並取得所有節點的內容、屬性等資料
34
#回傳的結果:
35
#$result...
36
#必填的參數:
37
$conf["xmlPosition"]="xml/xmlSample-oneLayer.xml";#xml檔案的位置
38
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
39
$conf["fileArgu"]=__FILE__;
40
var_dump($xmlContent=xml::getContent($conf));
41
unset($conf);
42
 
43
*/
44
 
45
#提示目前要測試的套件
46
echo "<hr>xml::getContent - testCase 3<br>";
47
 
48
/*
49
 
50
#涵式說明:
51
#讀取xml檔案,並取得所有節點的內容、屬性等資料
52
#回傳的結果:
53
#$result...
54
#必填的參數:
55
$conf["xmlPosition"]="xml/xmlSample-twoLayer.xml";#xml檔案的位置
56
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
57
$conf["fileArgu"]=__FILE__;
58
var_dump($xmlContent=xml::getContent($conf));
59
unset($conf);
60
 
61
*/
62
 
63
#提示目前要測試的套件
64
echo "<hr>xml::getTagInfo - testCase 1<br>";
65
 
66
/*
67
 
68
#涵式說明:
69
#取得xml特定標籤的內容
70
#回傳結果:
71
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
72
#$reuslt["error"],執行不正常結束的錯訊息陣列.
73
#$result["function"],當前執行的函式名稱.
74
#$result["content"],xml物件的標籤內容.
75
#必填參數:
76
#$conf["xmlPosition"],字串,xml檔案的位置.
77
$conf["xmlPosition"]="xml/xmlSample-oneLayer.xml";
78
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
79
$conf["fileArgu"]=__FILE__;
80
#$conf["tag"],字串,目標標籤的名稱.
81
$conf["tag"]=array("var2");
82
var_dump($getTagInfo=xml::getTagInfo($conf));
83
unset($conf);
84
echo $getTagInfo["content"];
85
 
86
*/
87
 
88
#提示目前要測試的套件
89
echo "<hr>xml::getTagInfo - testCase 2<br>";
90
 
91
/*
92
 
93
#涵式說明:
94
#取得xml特定標籤的內容
95
#回傳結果:
96
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
97
#$reuslt["error"],執行不正常結束的錯訊息陣列.
98
#$result["function"],當前執行的函式名稱.
99
#$result["content"],xml物件的標籤內容.
100
#必填參數:
101
#$conf["xmlPosition"],字串,xml檔案的位置.
102
$conf["xmlPosition"]="xml/xmlSample-twoLayer.xml";
103
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
104
$conf["fileArgu"]=__FILE__;
105
#$conf["tag"],字串,目標標籤的名稱.
106
$conf["tag"]=array("var1","var1.1");
107
var_dump($getTagInfo=xml::getTagInfo($conf));
108
unset($conf);
109
echo $getTagInfo["content"];
110
 
111
*/
112
 
113
#提示目前要測試的套件
114
echo "<hr>xml::createEmptyXml - testCase 1<br>";
115
 
116
/*
117
 
118
#涵式說明:
119
#建立空的xml檔案
120
#回傳結果:
121
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
122
#$reuslt["error"],執行不正常結束的錯訊息陣列.
123
#$result["function"],當前執行的函式名稱.
124
#$result["content"],xml檔案的路徑.
125
#必填參數:
126
#$conf["xmlPosition"],字串,xml檔案的位置.
127
$conf["xmlPosition"]="xml/empty.xml";
128
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
129
$conf["fileArgu"]=__FILE__; 
130
var_dump(xml::createEmptyXml($conf));
131
unset($conf);
132
 
133
*/
134
 
135
#提示目前要測試的套件
136
echo "<hr>xml::addTag - testCase 1<br>";
137
 
138
/*
139
 
140
#移除 xml/empty.xml
141
#涵式說明:
142
#移除檔案
143
#回傳的結果:
144
#$result["status"],"true"代表移除成功,"false"代表移除失敗.
145
#$result["error"],錯誤訊息陣列
146
#$result["warning"],警告訊息陣列
147
#$result["function"],當前執行的函數名稱
148
#必填的參數:
149
#$conf["fileAddress"],字串,要移除檔案的位置.
150
$conf["fileAddress"]="xml/empty.xml";
151
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
152
$conf["fileArgu"]=__FILE__;
153
#可省略參數:
154
#$conf["commentsArray"],字串陣列,提示的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
155
#$conf["commentsArray"]=array("");
156
$delFile=fileAccess::delFile($conf);
157
unset($conf);
158
 
159
#如果移除檔案失敗
160
if($delFile["status"]==="false"){
161
 
162
	#印出內容
163
	var_dump($delFile);
164
 
165
	#結束執行
166
	exit;
167
 
168
	}#if end
169
 
170
#涵式說明:
171
#建立空的xml檔案
172
#回傳結果:
173
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
174
#$reuslt["error"],執行不正常結束的錯訊息陣列.
175
#$result["function"],當前執行的函式名稱.
176
#$result["content"],xml檔案的路徑.
177
#必填參數:
178
#$conf["xmlPosition"],字串,xml檔案的位置.
179
$conf["xmlPosition"]="xml/empty.xml";
180
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
181
$conf["fileArgu"]=__FILE__; 
182
$createEmptyXml=xml::createEmptyXml($conf);
183
unset($conf);
184
 
185
#如果建立 xml 檔案失敗
186
if($createEmptyXml["status"]==="false"){
187
 
188
	#印出內容
189
	var_dump($createEmptyXml);
190
 
191
	#結束執行
192
	exit;
193
 
194
	}#if end
195
 
196
#涵式說明:
197
#在目標層級新增標籤與內容
198
#回傳結果:
199
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
200
#$reuslt["error"],執行不正常結束的錯訊息陣列.
201
#$result["function"],當前執行的函式名稱.
202
#必填參數:
203
#$conf["xmlPosition"],字串,xml檔案的位置.
204
$conf["xmlPosition"]="xml/empty.xml";
205
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
206
$conf["fileArgu"]=__FILE__;
207
#$conf["tag"],陣列,目標標籤的名稱,每個元素代表層級的名稱.
208
$conf["tag"]=array("home","qbpwcf","Downloads");
209
#$conf["tagValue"],字串,目標標籤的內容要放什麼.
210
$conf["tagValue"]="index.html";
211
#參考資料:
212
#addchild->http://php.net/manual/en/simplexmlelement.addchild.php
213
$addTag=xml::addTag($conf);
214
unset($conf);
215
 
216
#如果新增 tag 失敗
217
if($addTag["status"]==="false"){
218
 
219
	#印出內容
220
	var_dump($addTag);
221
 
222
	#結束執行
223
	exit;
224
 
225
	}#if end
226
 
227
*/
228
 
229
#提示目前要測試的套件
230
echo "<hr>xml::updateTag - testCase 1<br>";
231
 
232
/*
233
 
234
#涵式說明:
235
#更新xml標籤的內容.		
236
#回傳結果:
237
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
238
#$reuslt["error"],執行不正常結束的錯訊息陣列.
239
#$result["function"],當前執行的函式名稱.
240
#必填參數:
241
#$conf["xmlPosition"],字串,xml檔案的位置.
242
$conf["xmlPosition"]="/usr/local/etc/qbpwcf.conf.xml";
243
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
244
$conf["fileArgu"]=__FILE__;
245
#$conf["tag"],陣列,目標標籤的名稱,每個元素代表層級的名稱.
246
$conf["tag"]=array("qbpwcf","cmd","svnci","conf","password");
247
#$conf["tagValue"],字串,目標標籤的內容要放什麼.
248
$conf["tagValue"]="3c4x5z1i";
249
#參考資料:
250
#replacechild=>http://php.net/manual/en/domnode.replacechild.php
251
var_dump(xml::updateTag($conf));
252
unset($conf);
253
 
254
*/
255
 
256
#提示目前要測試的套件
257
echo "<hr>xml::removeTag - testCase 1<br>";
258
 
259
/*
260
 
261
#涵式說明:
262
#移除xml標籤的內容.		
263
#回傳結果:
264
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
265
#$reuslt["error"],執行不正常結束的錯訊息陣列.
266
#$result["function"],當前執行的函式名稱.
267
#必填參數:
268
#$conf["xmlPosition"],字串,xml檔案的位置.
269
$conf["xmlPosition"]="xml/empty.xml";
270
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
271
$conf["fileArgu"]=__FILE__;
272
#$conf["tag"],陣列,目標標籤的名稱,每個元素代表層級的名稱.
273
$conf["tag"]=array("home","qbpwcf","Downloads");	
274
#參考資料:
275
#replacechild=>http://php.net/manual/en/domnode.replacechild.php
276
#loadxml=>http://php.net/manual/en/domdocument.loadxml.php
277
#update xml node value=>http://stackoverflow.com/questions/4748014/updating-xml-node-with-php
278
#備註:
279
#若有多個同名的tag,則只會對於第一個tag進行操作.
280
var_dump(xml::removeTag($conf));
281
unset($conf);
282
 
283
*/	
284
 
285
#提示目前要測試的套件
286
echo "<hr>xml::removeTag - testCase 2<br>";
287
 
288
/*
289
 
290
#涵式說明:
291
#移除xml標籤的內容.		
292
#回傳結果:
293
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
294
#$reuslt["error"],執行不正常結束的錯訊息陣列.
295
#$result["function"],當前執行的函式名稱.
296
#必填參數:
297
#$conf["xmlPosition"],字串,xml檔案的位置.
298
$conf["xmlPosition"]="xml/empty.xml";
299
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
300
$conf["fileArgu"]=__FILE__;
301
#$conf["tag"],陣列,目標標籤的名稱,每個元素代表層級的名稱.
302
$conf["tag"]=array("home");	
303
#參考資料:
304
#replacechild=>http://php.net/manual/en/domnode.replacechild.php
305
#loadxml=>http://php.net/manual/en/domdocument.loadxml.php
306
#update xml node value=>http://stackoverflow.com/questions/4748014/updating-xml-node-with-php
307
#備註:
308
#若有多個同名的tag,則只會對於第一個tag進行操作.
309
var_dump(xml::removeTag($conf));
310
unset($conf);
311
 
312
*/
313
 
314
/*
315
 
316
#xml::parseXMLstring - testCase 1";
317
 
318
#涵式說明:
319
#解析xml字串.
320
#回傳結果:
321
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
322
#$reuslt["error"],執行不正常結束的錯訊息陣列.
323
#$result["function"],當前執行的函式名稱.
324
#$result["content"],xml物件.
325
#必填參數:
326
#$conf["xmlString"],字串,要解析的xml字串.
327
$conf["xmlString"]="<root>root</root>";
328
#可省略參數:
329
#無.
330
#備註:
331
#無.
332
$parseXMLstring=xml::parseXMLstring($conf);
333
unset($conf);
334
 
335
var_dump($parseXMLstring);
336
 
337
*/
338
 
339
/*
340
 
341
#xml::parseXMLstring - testCase 2";
342
 
343
$xmlStr="<response><returncode>SUCCESS</returncode><meetingID>fe50c498-43a9-11ec-922c-525411123501</meetingID><internalMeetingID>f983c0cd1fb2651750e82b95054f251c20fa99b4-1636715794790</internalMeetingID><parentMeetingID>bbb-none</parentMeetingID><attendeePW>MRmecHCX</attendeePW><moderatorPW>ltVj2MQE</moderatorPW><createTime>1636715794790</createTime><voiceBridge>77229</voiceBridge><dialNumber>613-555-1234</dialNumber><createDate>Fri Nov 12 06:16:34 EST 2021</createDate><hasUserJoined>false</hasUserJoined><duration>480</duration><hasBeenForciblyEnded>false</hasBeenForciblyEnded><messageKey></messageKey><message></message></response>";
344
 
345
#涵式說明:
346
#解析xml字串.
347
#回傳結果:
348
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
349
#$reuslt["error"],執行不正常結束的錯訊息陣列.
350
#$result["function"],當前執行的函式名稱.
351
#$result["content"],xml物件.
352
#必填參數:
353
#$conf["xmlString"],字串,要解析的xml字串.
354
$conf["xmlString"]=$xmlStr;
355
#可省略參數:
356
#無.
357
#備註:
358
#無.
359
$parseXMLstring=xml::parseXMLstring($conf);
360
unset($conf);
361
 
362
var_dump($parseXMLstring);
363
 
364
*/
365
 
366
?>