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 92... Line 92...
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
	#解析 ss 指令的輸出
100
	#解析 ss 指令的輸出
101
	#回傳結果:
101
	#回傳結果:
102
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
102
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 114... Line 114...
114
	#無.
114
	#無.
115
	#備註:
115
	#備註:
116
	#無.
116
	#無.
117
	*/
117
	*/
118
	public static function ss(&$conf){
118
	public static function ss(&$conf){
119
	
119
 
120
		#初始化要回傳的結果
120
		#初始化要回傳的結果
121
		$result=array();
121
		$result=array();
122
		
122
 
123
		#取得當前執行的函數名稱
123
		#取得當前執行的函數名稱
124
		$result["function"]=__FUNCTION__;
124
		$result["function"]=__FUNCTION__;
125
		
125
 
126
		#如果 $conf 不為陣列
126
		#如果 $conf 不為陣列
127
		if(gettype($conf)!="array"){
127
		if(gettype($conf)!="array"){
128
			
128
 
129
			#設置執行失敗
129
			#設置執行失敗
130
			$result["status"]="false";
130
			$result["status"]="false";
131
			
131
 
132
			#設置執行錯誤訊息
132
			#設置執行錯誤訊息
133
			$result["error"][]="\$conf變數須為陣列形態";
133
			$result["error"][]="\$conf變數須為陣列形態";
134
 
134
 
135
			#如果傳入的參數為 null
135
			#如果傳入的參數為 null
136
			if($conf==null){
136
			if($conf==null){
137
				
137
 
138
				#設置執行錯誤訊息
138
				#設置執行錯誤訊息
139
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
139
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
140
				
140
 
141
				}#if end
141
				}#if end
142
 
142
 
143
			#回傳結果
143
			#回傳結果
144
			return $result;
144
			return $result;
145
			
145
 
146
			}#if end
146
			}#if end
147
		
147
 
148
		#取得參數
148
		#取得參數
149
		$result["argu"]=$conf;
149
		$result["argu"]=$conf;
150
			
150
 
151
		#函式說明:
151
		#函式說明:
152
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
152
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
153
		#回傳結果:
153
		#回傳結果:
154
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
154
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
155
		#$result["error"],執行不正常結束的錯訊息陣列.
155
		#$result["error"],執行不正常結束的錯訊息陣列.
Line 198... Line 198...
198
		#array_keys=>http://php.net/manual/en/function.array-keys.php
198
		#array_keys=>http://php.net/manual/en/function.array-keys.php
199
		#備註:
199
		#備註:
200
		#無.
200
		#無.
201
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
201
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
202
		unset($conf["variableCheck::checkArguments"]);
202
		unset($conf["variableCheck::checkArguments"]);
203
	
203
 
204
		#如果執行失敗
204
		#如果執行失敗
205
		if($checkArguments["status"]==="false"){
205
		if($checkArguments["status"]==="false"){
206
		
206
 
207
			#設置執行失敗
207
			#設置執行失敗
208
			$result["status"]="false";
208
			$result["status"]="false";
209
 
209
 
210
			#設置錯誤訊息
210
			#設置錯誤訊息
211
			$result["error"]=$checkArguments;
211
			$result["error"]=$checkArguments;
212
 
212
 
213
			#回傳結果
213
			#回傳結果
214
			return $result;
214
			return $result;
215
		
215
 
216
			}#if end
216
			}#if end
217
			
217
 
218
		#如果參數檢查不通過
218
		#如果參數檢查不通過
219
		if($checkArguments["passed"]==="false"){
219
		if($checkArguments["passed"]==="false"){
220
		
220
 
221
			#設置執行失敗
221
			#設置執行失敗
222
			$result["status"]="false";
222
			$result["status"]="false";
223
 
223
 
224
			#設置錯誤訊息
224
			#設置錯誤訊息
225
			$result["error"]=$checkArguments;
225
			$result["error"]=$checkArguments;
226
 
226
 
227
			#回傳結果
227
			#回傳結果
228
			return $result;
228
			return $result;
229
		
229
 
230
			}#if end
230
			}#if end
231
			
231
 
232
		#取得 header
232
		#取得 header
233
		$headerStr=$conf["input"][0];
233
		$headerStr=$conf["input"][0];
234
				
234
 
235
		#移除標題列
235
		#移除標題列
236
		unset($conf["input"][0]);
236
		unset($conf["input"][0]);
237
	
237
 
238
		#解析 header
238
		#解析 header
239
		#Netid                     Recv-Q                      Send-Q                                                                             Local Address:Port                                             Peer Address:Port 
239
		#Netid                     Recv-Q                      Send-Q                                                                             Local Address:Port                                             Peer Address:Port
240
		#Netid State  Recv-Q Send-Q                                   Local Address:Port        Peer Address:PortProcess
240
		#Netid State  Recv-Q Send-Q                                   Local Address:Port        Peer Address:PortProcess
241
		#函式說明:
241
		#函式說明:
242
		#將固定格式的字串分開,並回傳分開的結果.
242
		#將固定格式的字串分開,並回傳分開的結果.
243
		#回傳結果:
243
		#回傳結果:
244
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
244
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 261... Line 261...
261
		#無.
261
		#無.
262
		#備註:
262
		#備註:
263
		#無.
263
		#無.
264
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
264
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
265
		unset($conf["stringProcess::spiltString"]);
265
		unset($conf["stringProcess::spiltString"]);
266
	
266
 
267
		#debug
267
		#debug
268
		#var_dump(__LINE__,$spiltString);
268
		#var_dump(__LINE__,$spiltString);
269
	
269
 
270
		#如果執行失敗
270
		#如果執行失敗
271
		if($spiltString["status"]==="false"){
271
		if($spiltString["status"]==="false"){
272
		
272
 
273
			#設置執行失敗
273
			#設置執行失敗
274
			$result["status"]="false";
274
			$result["status"]="false";
275
 
275
 
276
			#設置錯誤訊息
276
			#設置錯誤訊息
277
			$result["error"]=$spiltString;
277
			$result["error"]=$spiltString;
278
 
278
 
279
			#回傳結果
279
			#回傳結果
280
			return $result;
280
			return $result;
281
		
281
 
282
			}#if end
282
			}#if end
283
			
283
 
284
		#如果執行失敗
284
		#如果執行失敗
285
		if($spiltString["dataCounts"]<=1){
285
		if($spiltString["dataCounts"]<=1){
286
		
286
 
287
			#設置執行失敗
287
			#設置執行失敗
288
			$result["status"]="false";
288
			$result["status"]="false";
289
 
289
 
290
			#設置錯誤訊息
290
			#設置錯誤訊息
291
			$result["error"]=$spiltString;
291
			$result["error"]=$spiltString;
292
 
292
 
293
			#回傳結果
293
			#回傳結果
294
			return $result;
294
			return $result;
295
		
295
 
296
			}#if end
296
			}#if end
297
		
297
 
298
		#初始化儲存欄位名稱的變數
298
		#初始化儲存欄位名稱的變數
299
		$result["columns"]=array();
299
		$result["columns"]=array();
300
		
300
 
301
		#針對可能的欄位名稱
301
		#針對可能的欄位名稱
302
		for($i=0;$i<count($spiltString["dataArray"]);$i++){
302
		for($i=0;$i<count($spiltString["dataArray"]);$i++){
303
		
303
 
304
			#debug
304
			#debug
305
			#var_dump($result["columns"]);
305
			#var_dump($result["columns"]);
306
		
306
 
307
			#取得該段內容
307
			#取得該段內容
308
			$column=$spiltString["dataArray"][$i];
308
			$column=$spiltString["dataArray"][$i];
309
		
309
 
310
			#如果欄位開頭為空格
310
			#如果欄位開頭為空格
311
			while(strpos($column," ")===0){
311
			while(strpos($column," ")===0){
312
			
312
 
313
				#剔除開頭的空格
313
				#剔除開頭的空格
314
				$column=substr($column,1);
314
				$column=substr($column,1);
315
			
315
 
316
				}#while end
316
				}#while end
317
				
317
 
318
			#如果有下一個欄位
318
			#如果有下一個欄位
319
			if(isset($spiltString["dataArray"][$i+1])){
319
			if(isset($spiltString["dataArray"][$i+1])){
320
			
320
 
321
				#如果下一個不是完整的欄位名稱
321
				#如果下一個不是完整的欄位名稱
322
				if(strpos($spiltString["dataArray"][$i+1],":")!==false){
322
				if(strpos($spiltString["dataArray"][$i+1],":")!==false){
323
				
323
 
324
					#更新欄位名稱
324
					#更新欄位名稱
325
					$column=$column." ".$spiltString["dataArray"][$i+1];
325
					$column=$column." ".$spiltString["dataArray"][$i+1];
326
				
326
 
327
					#跳過下個欄位
327
					#跳過下個欄位
328
					$i=$i+1;
328
					$i=$i+1;
329
				
329
 
330
					}#if end
330
					}#if end
331
			
331
 
332
				}#if end
332
				}#if end
333
			
333
 
334
			#如果需要判斷
334
			#如果需要判斷
335
			if(strlen($column)>=strlen("Process")){
335
			if(strlen($column)>=strlen("Process")){
336
			
336
 
337
				#函式說明:
337
				#函式說明:
338
				#取得符合特定字首與字尾的字串
338
				#取得符合特定字首與字尾的字串
339
				#回傳結果:
339
				#回傳結果:
340
				#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
340
				#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
341
				#$result["function"],當前執行的函數名稱.
341
				#$result["function"],當前執行的函數名稱.
Line 356... Line 356...
356
				#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
356
				#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
357
				#備註:
357
				#備註:
358
				#無.
358
				#無.
359
				$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
359
				$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
360
				unset($conf["search::getMeetConditionsString"]);
360
				unset($conf["search::getMeetConditionsString"]);
361
				
361
 
362
				#debug
362
				#debug
363
				#var_dump(__LINE__,$getMeetConditionsString);
363
				#var_dump(__LINE__,$getMeetConditionsString);
364
				
364
 
365
				#如果執行失敗
365
				#如果執行失敗
366
				if($getMeetConditionsString["status"]==="false"){
366
				if($getMeetConditionsString["status"]==="false"){
367
				
367
 
368
					#設置執行失敗
368
					#設置執行失敗
369
					$result["status"]="false";
369
					$result["status"]="false";
370
 
370
 
371
					#設置錯誤訊息
371
					#設置錯誤訊息
372
					$result["error"]=$getMeetConditionsString;
372
					$result["error"]=$getMeetConditionsString;
373
 
373
 
374
					#回傳結果
374
					#回傳結果
375
					return $result;
375
					return $result;
376
				
376
 
377
					}#if end
377
					}#if end
378
				
378
 
379
				#如果欄位名稱結尾為 "Process"
379
				#如果欄位名稱結尾為 "Process"
380
				if($getMeetConditionsString["founded"]==="true"){
380
				if($getMeetConditionsString["founded"]==="true"){
381
				
381
 
382
					#儲存欄位名稱
382
					#儲存欄位名稱
383
					$result["columns"][]=$getMeetConditionsString["content"];
383
					$result["columns"][]=$getMeetConditionsString["content"];
384
				
384
 
385
					#儲存欄位名稱底下資料用於解析資料位置的資訊
385
					#儲存欄位名稱底下資料用於解析資料位置的資訊
386
					$result["addrForParseContet"][$getMeetConditionsString["content"]]=strpos($headerStr,$getMeetConditionsString["content"]);
386
					$result["addrForParseContet"][$getMeetConditionsString["content"]]=strpos($headerStr,$getMeetConditionsString["content"]);
387
				
387
 
388
					#儲存欄位名稱
388
					#儲存欄位名稱
389
					$result["columns"][]="Process";
389
					$result["columns"][]="Process";
390
				
390
 
391
					#儲存欄位名稱底下資料用於解析資料位置的資訊
391
					#儲存欄位名稱底下資料用於解析資料位置的資訊
392
					$result["addrForParseContet"]["Process"]=strpos($headerStr,"Process");
392
					$result["addrForParseContet"]["Process"]=strpos($headerStr,"Process");
393
					
393
 
394
					#換下一個
394
					#換下一個
395
					continue;
395
					continue;
396
				
396
 
397
					}#if end
397
					}#if end
398
			
398
 
399
				}#if end
399
				}#if end
400
			
400
 
401
			#儲存欄位名稱
401
			#儲存欄位名稱
402
			$result["columns"][]=$column;
402
			$result["columns"][]=$column;
403
		
403
 
404
			#儲存欄位名稱底下資料用於解析資料位置的資訊
404
			#儲存欄位名稱底下資料用於解析資料位置的資訊
405
			$result["addrForParseContet"][$column]=strpos($headerStr,$column);
405
			$result["addrForParseContet"][$column]=strpos($headerStr,$column);
406
			
406
 
407
			#debug
407
			#debug
408
			#var_dump($result["addrForParseContet"]);
408
			#var_dump($result["addrForParseContet"]);
409
					
409
 
410
			}#for end
410
			}#for end
411
		
411
 
412
		#欄位的計數
412
		#欄位的計數
413
		$columnCount=count($result["columns"]);
413
		$columnCount=count($result["columns"]);
414
				
414
 
415
		#debug
415
		#debug
416
		#var_dump(__LINE__,$result);
416
		#var_dump(__LINE__,$result);
417
			
417
 
418
		#break point
418
		#break point
419
		#exit;
419
		#exit;
420
			
420
 
421
		#針對每列內容:
421
		#針對每列內容:
422
		#可能為:
422
		#可能為:
423
		#"nl    UNCONN 0      0                                                    0:47                      *"
423
		#"nl    UNCONN 0      0                                                    0:47                      *"
424
		#"tcp   LISTEN 0      128                                        169.254.1.1:22               0.0.0.0:*    users:(("sshd",pid=2920,fd=3))"
424
		#"tcp   LISTEN 0      128                                        169.254.1.1:22               0.0.0.0:*    users:(("sshd",pid=2920,fd=3))"
425
		#“nl    UNCONN 0      0                                                   18:0                       *"
425
		#“nl    UNCONN 0      0                                                   18:0                       *"
426
		foreach($conf["input"] as $line){
426
		foreach($conf["input"] as $line){
427
		
427
 
428
			#debug
428
			#debug
429
			#var_dump(__LINE__." ".$line);
429
			#var_dump(__LINE__." ".$line);
430
		
430
 
431
			#針對每個欄位
431
			#針對每個欄位
432
			for($i=0;$i<$columnCount;$i++){
432
			for($i=0;$i<$columnCount;$i++){
433
			
433
 
434
				#取得欄位名稱
434
				#取得欄位名稱
435
				$columnName=$result["columns"][$i];
435
				$columnName=$result["columns"][$i];
436
			
436
 
437
				#debug
437
				#debug
438
				#var_dump(__LINE__." ".$columnName);
438
				#var_dump(__LINE__." ".$columnName);
439
			
439
 
440
				#取得參考的位置
440
				#取得參考的位置
441
				$refAddr=$result["addrForParseContet"][$columnName];
441
				$refAddr=$result["addrForParseContet"][$columnName];
442
				
442
 
443
				#若是 "Process" 欄位
443
				#若是 "Process" 欄位
444
				if($columnName==="Process"){
444
				if($columnName==="Process"){
445
				
445
 
446
					#更新資料的起始點
446
					#更新資料的起始點
447
					$refAddr=$refAddr+1;
447
					$refAddr=$refAddr+1;
448
					
448
 
449
					#抓取要解析的process字串
449
					#抓取要解析的process字串
450
					$proStr=substr($line,$refAddr);
450
					$proStr=substr($line,$refAddr);
451
					
451
 
452
					#debug
452
					#debug
453
					#var_dump(__LINE__,$proStr);
453
					#var_dump(__LINE__,$proStr);
454
					
454
 
455
					#users:(("httpd",pid=3065,fd=4),("httpd",pid=1602,fd=4),("httpd",pid=1601,fd=4),("httpd",pid=1600,fd=4),("httpd",pid=1526,fd=4))
455
					#users:(("httpd",pid=3065,fd=4),("httpd",pid=1602,fd=4),("httpd",pid=1601,fd=4),("httpd",pid=1600,fd=4),("httpd",pid=1526,fd=4))
456
					
456
 
457
					#函式說明:
457
					#函式說明:
458
					#取得符合特定字首與字尾的字串
458
					#取得符合特定字首與字尾的字串
459
					#回傳結果:
459
					#回傳結果:
460
					#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
460
					#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
461
					#$result["function"],當前執行的函數名稱.
461
					#$result["function"],當前執行的函數名稱.
Line 474... Line 474...
474
					$conf["search::getMeetConditionsString"]["tailWord"]=")";
474
					$conf["search::getMeetConditionsString"]["tailWord"]=")";
475
					#參考資料:
475
					#參考資料:
476
					#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
476
					#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
477
					#備註:
477
					#備註:
478
					#無.
478
					#無.
479
					
479
 
480
					#debug
480
					#debug
481
					#var_dump($conf["search::getMeetConditionsString"]);
481
					#var_dump($conf["search::getMeetConditionsString"]);
482
					
482
 
483
					$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
483
					$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
484
					unset($conf["search::getMeetConditionsString"]);
484
					unset($conf["search::getMeetConditionsString"]);
485
				
485
 
486
					#如果執行失敗
486
					#如果執行失敗
487
					if($getMeetConditionsString["status"]==="false"){
487
					if($getMeetConditionsString["status"]==="false"){
488
					
488
 
489
						#設置執行失敗
489
						#設置執行失敗
490
						$result["status"]="false";
490
						$result["status"]="false";
491
 
491
 
492
						#設置錯誤訊息
492
						#設置錯誤訊息
493
						$result["error"]=$getMeetConditionsString;
493
						$result["error"]=$getMeetConditionsString;
494
 
494
 
495
						#回傳結果
495
						#回傳結果
496
						return $result;
496
						return $result;
497
					
497
 
498
						}#if end
498
						}#if end
499
						
499
 
500
					#如果沒有符合的關鍵字
500
					#如果沒有符合的關鍵字
501
					if($getMeetConditionsString["founded"]==="false"){
501
					if($getMeetConditionsString["founded"]==="false"){
502
					
502
 
503
						#用欄位名稱來儲存資料
503
						#用欄位名稱來儲存資料
504
						$result["content"][$columnName][]=array();
504
						$result["content"][$columnName][]=array();
505
						
505
 
506
						#跳到下個欄位
506
						#跳到下個欄位
507
						continue;
507
						continue;
508
					
508
 
509
						}#if end
509
						}#if end
510
						
510
 
511
					#("httpd",pid=3065,fd=4),("httpd",pid=1602,fd=4),("httpd",pid=1601,fd=4),("httpd",pid=1600,fd=4),("httpd",pid=1526,fd=4)
511
					#("httpd",pid=3065,fd=4),("httpd",pid=1602,fd=4),("httpd",pid=1601,fd=4),("httpd",pid=1600,fd=4),("httpd",pid=1526,fd=4)
512
					
512
 
513
					#用 "\"" 來進行切割
513
					#用 "\"" 來進行切割
514
					#$getMeetConditionsString["content"];
514
					#$getMeetConditionsString["content"];
515
					
515
 
516
					#函式說明:
516
					#函式說明:
517
					#將固定格式的字串分開,並回傳分開的結果.
517
					#將固定格式的字串分開,並回傳分開的結果.
518
					#回傳結果:
518
					#回傳結果:
519
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
519
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
520
					#$result["error"],錯誤訊息陣列
520
					#$result["error"],錯誤訊息陣列
Line 536... Line 536...
536
					#無.
536
					#無.
537
					#備註:
537
					#備註:
538
					#無.
538
					#無.
539
					$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
539
					$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
540
					unset($conf["stringProcess::spiltString"]);
540
					unset($conf["stringProcess::spiltString"]);
541
				
541
 
542
					#如果執行失敗
542
					#如果執行失敗
543
					if($spiltString["status"]==="false"){
543
					if($spiltString["status"]==="false"){
544
					
544
 
545
						#設置執行失敗
545
						#設置執行失敗
546
						$result["status"]="false";
546
						$result["status"]="false";
547
 
547
 
548
						#設置錯誤訊息
548
						#設置錯誤訊息
549
						$result["error"]=$spiltString;
549
						$result["error"]=$spiltString;
550
 
550
 
551
						#回傳結果
551
						#回傳結果
552
						return $result;
552
						return $result;
553
					
553
 
554
						}#if end
554
						}#if end
555
						
555
 
556
					#如果沒有符合的關鍵字
556
					#如果沒有符合的關鍵字
557
					if($spiltString["found"]==="false"){
557
					if($spiltString["found"]==="false"){
558
					
558
 
559
						#設置執行失敗
559
						#設置執行失敗
560
						$result["status"]="false";
560
						$result["status"]="false";
561
 
561
 
562
						#設置錯誤訊息
562
						#設置錯誤訊息
563
						$result["error"]=$spiltString;
563
						$result["error"]=$spiltString;
564
 
564
 
565
						#回傳結果
565
						#回傳結果
566
						return $result;
566
						return $result;
567
					
567
 
568
						}#if end
568
						}#if end
569
						
569
 
570
					#儲存process陣列的變數
570
					#儲存process陣列的變數
571
					$proArray=array();	
571
					$proArray=array();
572
					
572
 
573
					#針對奇數的內容
573
					#針對奇數的內容
574
					for($j=1;$j<$spiltString["dataCounts"];$j=$j+2){
574
					for($j=1;$j<$spiltString["dataCounts"];$j=$j+2){
575
					
575
 
576
						#儲存 prcess name
576
						#儲存 prcess name
577
						$proArray[]=$spiltString["dataArray"][$j];
577
						$proArray[]=$spiltString["dataArray"][$j];
578
					
578
 
579
						}#if end
579
						}#if end
580
						
580
 
581
					#用欄位名稱來儲存資料
581
					#用欄位名稱來儲存資料
582
					$result["content"][$columnName][]=$proArray;
582
					$result["content"][$columnName][]=$proArray;
583
				
583
 
584
					#換下一個欄位資料
584
					#換下一個欄位資料
585
					continue;
585
					continue;
586
				
586
 
587
					}#if end
587
					}#if end
588
			
588
 
589
				#若是 "Local Address:Port" 欄位
589
				#若是 "Local Address:Port" 欄位
590
				if($columnName==="Local Address:Port"){
590
				if($columnName==="Local Address:Port"){
591
				
591
 
592
					#從 $refAddr 往左右抓內容
592
					#從 $refAddr 往左右抓內容
593
					
593
 
594
					#抓取左邊的內容
594
					#抓取左邊的內容
595
					$leftStr=substr($line,0,$refAddr+strlen("Local Address"));
595
					$leftStr=substr($line,0,$refAddr+strlen("Local Address"));
596
					
596
 
597
					#函式說明:
597
					#函式說明:
598
					#將字串特定關鍵字與其前面的內容剔除
598
					#將字串特定關鍵字與其前面的內容剔除
599
					#回傳結果:
599
					#回傳結果:
600
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
600
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
601
					#$result["error"],錯誤訊息陣列.
601
					#$result["error"],錯誤訊息陣列.
602
					#$result["warning"],警告訊息鎮列.
602
					#$result["warning"],警告訊息鎮列.
603
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
603
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
604
					#$result["function"],當前執行的函數名稱.
604
					#$result["function"],當前執行的函數名稱.
605
					#$result["oriStr"],要處理的原始字串內容.
605
					#$result["oriStr"],要處理的原始字串內容.
606
					#$result["content"],處理好的的字串內容.	
606
					#$result["content"],處理好的的字串內容.
607
					#必填參數:
607
					#必填參數:
608
					#$conf["stringIn"],字串,要處理的字串.
608
					#$conf["stringIn"],字串,要處理的字串.
609
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$leftStr;
609
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$leftStr;
610
					#$conf["keyWord"],字串,特定字串.
610
					#$conf["keyWord"],字串,特定字串.
611
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" ";
611
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" ";
Line 616... Line 616...
616
					#無.
616
					#無.
617
					#備註:
617
					#備註:
618
					#無.
618
					#無.
619
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
619
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
620
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
620
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
621
					
621
 
622
					#如果執行失敗
622
					#如果執行失敗
623
					if($delStrBeforeKeyWord["status"]==="false"){
623
					if($delStrBeforeKeyWord["status"]==="false"){
624
					
624
 
625
						#設置執行失敗
625
						#設置執行失敗
626
						$result["status"]="false";
626
						$result["status"]="false";
627
 
627
 
628
						#設置錯誤訊息
628
						#設置錯誤訊息
629
						$result["error"]=$delStrBeforeKeyWord;
629
						$result["error"]=$delStrBeforeKeyWord;
630
 
630
 
631
						#回傳結果
631
						#回傳結果
632
						return $result;
632
						return $result;
633
					
633
 
634
						}#if end
634
						}#if end
635
										
635
 
636
					#取得資料的左半部
636
					#取得資料的左半部
637
					$leftDataStr=$delStrBeforeKeyWord["content"];
637
					$leftDataStr=$delStrBeforeKeyWord["content"];
638
					
638
 
639
					#抓取右邊的內容
639
					#抓取右邊的內容
640
					$rightStr=substr($line,$refAddr+strlen("Local Address")+1);
640
					$rightStr=substr($line,$refAddr+strlen("Local Address")+1);
641
				
641
 
642
					#函式說明:
642
					#函式說明:
643
					#將字串特定關鍵字與其後面的內容剔除
643
					#將字串特定關鍵字與其後面的內容剔除
644
					#回傳結果:
644
					#回傳結果:
645
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
645
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
646
					#$result["error"],錯誤訊息陣列.
646
					#$result["error"],錯誤訊息陣列.
Line 662... Line 662...
662
					#無.
662
					#無.
663
					#備註:
663
					#備註:
664
					#無.
664
					#無.
665
					$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
665
					$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
666
					unset($conf["stringProcess::delStrAfterKeyWord"]);
666
					unset($conf["stringProcess::delStrAfterKeyWord"]);
667
				
667
 
668
					#如果執行失敗
668
					#如果執行失敗
669
					if($delStrAfterKeyWord["status"]==="false"){
669
					if($delStrAfterKeyWord["status"]==="false"){
670
					
670
 
671
						#設置執行失敗
671
						#設置執行失敗
672
						$result["status"]="false";
672
						$result["status"]="false";
673
 
673
 
674
						#設置錯誤訊息
674
						#設置錯誤訊息
675
						$result["error"]=$delStrAfterKeyWord;
675
						$result["error"]=$delStrAfterKeyWord;
676
 
676
 
677
						#回傳結果
677
						#回傳結果
678
						return $result;
678
						return $result;
679
					
679
 
680
						}#if end
680
						}#if end
681
					
681
 
682
					#取得資料的右半部
682
					#取得資料的右半部
683
					$rightDataStr=$delStrAfterKeyWord["content"];
683
					$rightDataStr=$delStrAfterKeyWord["content"];
684
				
684
 
685
					#用欄位名稱來儲存資料
685
					#用欄位名稱來儲存資料
686
					$result["content"][$columnName][]=array("addr"=>$leftDataStr,"port"=>$rightDataStr);
686
					$result["content"][$columnName][]=array("addr"=>$leftDataStr,"port"=>$rightDataStr);
687
				
687
 
688
					#換下一個欄位資料
688
					#換下一個欄位資料
689
					continue;
689
					continue;
690
				
690
 
691
					}#if end
691
					}#if end
692
					
692
 
693
				#若是 "Peer Address:Port" 欄位
693
				#若是 "Peer Address:Port" 欄位
694
				if($columnName==="Peer Address:Port"){
694
				if($columnName==="Peer Address:Port"){
695
				
695
 
696
					#從 $refAddr 往左右抓內容
696
					#從 $refAddr 往左右抓內容
697
					
697
 
698
					#抓取左邊的內容
698
					#抓取左邊的內容
699
					$leftStr=substr($line,0,$refAddr+strlen("Peer Address"));
699
					$leftStr=substr($line,0,$refAddr+strlen("Peer Address"));
700
					
700
 
701
					#debug
701
					#debug
702
					#var_dump(__LINE__,$leftStr);
702
					#var_dump(__LINE__,$leftStr);
703
					
703
 
704
					#函式說明:
704
					#函式說明:
705
					#將字串特定關鍵字與其前面的內容剔除
705
					#將字串特定關鍵字與其前面的內容剔除
706
					#回傳結果:
706
					#回傳結果:
707
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
707
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
708
					#$result["error"],錯誤訊息陣列.
708
					#$result["error"],錯誤訊息陣列.
709
					#$result["warning"],警告訊息鎮列.
709
					#$result["warning"],警告訊息鎮列.
710
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
710
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
711
					#$result["function"],當前執行的函數名稱.
711
					#$result["function"],當前執行的函數名稱.
712
					#$result["oriStr"],要處理的原始字串內容.
712
					#$result["oriStr"],要處理的原始字串內容.
713
					#$result["content"],處理好的的字串內容.	
713
					#$result["content"],處理好的的字串內容.
714
					#必填參數:
714
					#必填參數:
715
					#$conf["stringIn"],字串,要處理的字串.
715
					#$conf["stringIn"],字串,要處理的字串.
716
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$leftStr;
716
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$leftStr;
717
					#$conf["keyWord"],字串,特定字串.
717
					#$conf["keyWord"],字串,特定字串.
718
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" ";
718
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" ";
Line 723... Line 723...
723
					#無.
723
					#無.
724
					#備註:
724
					#備註:
725
					#無.
725
					#無.
726
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
726
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
727
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
727
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
728
					
728
 
729
					#debug
729
					#debug
730
					#var_dump(__LINE__,$delStrBeforeKeyWord);
730
					#var_dump(__LINE__,$delStrBeforeKeyWord);
731
					
731
 
732
					#如果執行失敗
732
					#如果執行失敗
733
					if($delStrBeforeKeyWord["status"]==="false"){
733
					if($delStrBeforeKeyWord["status"]==="false"){
734
					
734
 
735
						#設置執行失敗
735
						#設置執行失敗
736
						$result["status"]="false";
736
						$result["status"]="false";
737
 
737
 
738
						#設置錯誤訊息
738
						#設置錯誤訊息
739
						$result["error"]=$delStrBeforeKeyWord;
739
						$result["error"]=$delStrBeforeKeyWord;
740
 
740
 
741
						#回傳結果
741
						#回傳結果
742
						return $result;
742
						return $result;
743
					
743
 
744
						}#if end
744
						}#if end
745
						
745
 
746
					#如果沒有找到" "
746
					#如果沒有找到" "
747
					if($delStrBeforeKeyWord["founded"]==="false"){
747
					if($delStrBeforeKeyWord["founded"]==="false"){
748
					
748
 
749
						#用欄位名稱來儲存資料,"*"代表沒有資料
749
						#用欄位名稱來儲存資料,"*"代表沒有資料
750
						$result["content"][$columnName][]="*";
750
						$result["content"][$columnName][]="*";
751
				
751
 
752
						#換下一個欄位資料
752
						#換下一個欄位資料
753
						continue;
753
						continue;
754
					
754
 
755
						}#if end
755
						}#if end
756
					
756
 
757
					#取得資料的左半部
757
					#取得資料的左半部
758
					$leftDataStr=$delStrBeforeKeyWord["content"];
758
					$leftDataStr=$delStrBeforeKeyWord["content"];
759
					
759
 
760
					#抓取右邊的內容
760
					#抓取右邊的內容
761
					$rightStr=substr($line,$refAddr+strlen("Peer Address")+1);
761
					$rightStr=substr($line,$refAddr+strlen("Peer Address")+1);
762
				
762
 
763
					#debug
763
					#debug
764
					#var_dump(__LINE__,$rightStr);
764
					#var_dump(__LINE__,$rightStr);
765
				
765
 
766
					#函式說明:
766
					#函式說明:
767
					#將字串特定關鍵字與其後面的內容剔除
767
					#將字串特定關鍵字與其後面的內容剔除
768
					#回傳結果:
768
					#回傳結果:
769
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
769
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
770
					#$result["error"],錯誤訊息陣列.
770
					#$result["error"],錯誤訊息陣列.
Line 786... Line 786...
786
					#無.
786
					#無.
787
					#備註:
787
					#備註:
788
					#無.
788
					#無.
789
					$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
789
					$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
790
					unset($conf["stringProcess::delStrAfterKeyWord"]);
790
					unset($conf["stringProcess::delStrAfterKeyWord"]);
791
				
791
 
792
					#debug
792
					#debug
793
					#var_dump(__LINE__,$delStrBeforeKeyWord);
793
					#var_dump(__LINE__,$delStrBeforeKeyWord);
794
				
794
 
795
					#如果執行失敗
795
					#如果執行失敗
796
					if($delStrAfterKeyWord["status"]==="false"){
796
					if($delStrAfterKeyWord["status"]==="false"){
797
					
797
 
798
						#設置執行失敗
798
						#設置執行失敗
799
						$result["status"]="false";
799
						$result["status"]="false";
800
 
800
 
801
						#設置錯誤訊息
801
						#設置錯誤訊息
802
						$result["error"]=$delStrAfterKeyWord;
802
						$result["error"]=$delStrAfterKeyWord;
803
 
803
 
804
						#回傳結果
804
						#回傳結果
805
						return $result;
805
						return $result;
806
					
806
 
807
						}#if end
807
						}#if end
808
					
808
 
809
					#如果沒有找到" "
809
					#如果沒有找到" "
810
					if($delStrBeforeKeyWord["founded"]==="false"){
810
					if($delStrBeforeKeyWord["founded"]==="false"){
811
					
811
 
812
						#用欄位名稱來儲存資料,"*"代表沒有資料
812
						#用欄位名稱來儲存資料,"*"代表沒有資料
813
						$result["content"][$columnName][]="*";
813
						$result["content"][$columnName][]="*";
814
				
814
 
815
						#換下一個欄位資料
815
						#換下一個欄位資料
816
						continue;
816
						continue;
817
					
817
 
818
						}#if end
818
						}#if end
819
						
819
 
820
					#取得資料的右半部
820
					#取得資料的右半部
821
					$rightDataStr=$delStrAfterKeyWord["content"];
821
					$rightDataStr=$delStrAfterKeyWord["content"];
822
				
822
 
823
					#如果有 peer addr 資訊
823
					#如果有 peer addr 資訊
824
					if($leftDataStr!=="" && $rightDataStr!==""){
824
					if($leftDataStr!=="" && $rightDataStr!==""){
825
					
825
 
826
						#用欄位名稱來儲存資料
826
						#用欄位名稱來儲存資料
827
						$result["content"][$columnName][]=array("addr"=>$leftDataStr,"port"=>$rightDataStr);
827
						$result["content"][$columnName][]=array("addr"=>$leftDataStr,"port"=>$rightDataStr);
828
					
828
 
829
						}#if end
829
						}#if end
830
				
830
 
831
					#反之
831
					#反之
832
					else{
832
					else{
833
						
833
 
834
						#用欄位名稱來儲存資料
834
						#用欄位名稱來儲存資料
835
						$result["content"][$columnName][]="*";
835
						$result["content"][$columnName][]="*";
836
					
836
 
837
						}#else end
837
						}#else end
838
				
838
 
839
					#換下一個欄位資料
839
					#換下一個欄位資料
840
					continue;
840
					continue;
841
				
841
 
842
					}#if end
842
					}#if end
843
				
843
 
844
				#取得資料字串
844
				#取得資料字串
845
				$dataString=substr($line,$refAddr);
845
				$dataString=substr($line,$refAddr);
846
			
846
 
847
				#debug
847
				#debug
848
				#var_dump(__LINE__,$dataString);
848
				#var_dump(__LINE__,$dataString);
849
			
849
 
850
				#如果數值為空
850
				#如果數值為空
851
				if($dataString===""){
851
				if($dataString===""){
852
				
852
 
853
					#用欄位名稱來儲存資料
853
					#用欄位名稱來儲存資料
854
					$result["content"][$columnName][]="";
854
					$result["content"][$columnName][]="";
855
				
855
 
856
					#換下一個欄位資料
856
					#換下一個欄位資料
857
					continue;
857
					continue;
858
					
858
 
859
					}#if end
859
					}#if end
860
			
860
 
861
				#取得需要的部分
861
				#取得需要的部分
862
				#函式說明:
862
				#函式說明:
863
				#將字串特定關鍵字與其後面的內容剔除
863
				#將字串特定關鍵字與其後面的內容剔除
864
				#回傳結果:
864
				#回傳結果:
865
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
865
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 882... Line 882...
882
				#無.
882
				#無.
883
				#備註:
883
				#備註:
884
				#無.
884
				#無.
885
				$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
885
				$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
886
				unset($conf["stringProcess::delStrAfterKeyWord"]);
886
				unset($conf["stringProcess::delStrAfterKeyWord"]);
887
			
887
 
888
				#如果執行失敗
888
				#如果執行失敗
889
				if($delStrAfterKeyWord["status"]==="false"){
889
				if($delStrAfterKeyWord["status"]==="false"){
890
				
890
 
891
					#設置執行失敗
891
					#設置執行失敗
892
					$result["status"]="false";
892
					$result["status"]="false";
893
 
893
 
894
					#設置錯誤訊息
894
					#設置錯誤訊息
895
					$result["error"]=$delStrAfterKeyWord;
895
					$result["error"]=$delStrAfterKeyWord;
896
 
896
 
897
					#回傳結果
897
					#回傳結果
898
					return $result;
898
					return $result;
899
				
899
 
900
					}#if end
900
					}#if end
901
				
901
 
902
				#如果沒有找到" "
902
				#如果沒有找到" "
903
				if($delStrAfterKeyWord["founded"]==="false"){
903
				if($delStrAfterKeyWord["founded"]==="false"){
904
				
904
 
905
					#設置執行失敗
905
					#設置執行失敗
906
					$result["status"]="false";
906
					$result["status"]="false";
907
 
907
 
908
					#設置錯誤訊息
908
					#設置錯誤訊息
909
					$result["error"]=$delStrAfterKeyWord;
909
					$result["error"]=$delStrAfterKeyWord;
910
 
910
 
911
					#回傳結果
911
					#回傳結果
912
					return $result;
912
					return $result;
913
				
913
 
914
					}#if end
914
					}#if end
915
 
915
 
916
				#用欄位名稱來儲存資料
916
				#用欄位名稱來儲存資料
917
				$result["content"][$columnName][]=$delStrAfterKeyWord["content"];
917
				$result["content"][$columnName][]=$delStrAfterKeyWord["content"];
918
				
918
 
919
				}#for end
919
				}#for end
920
			
920
 
921
			}#foreach end
921
			}#foreach end
922
		
922
 
923
		#設置執行正常
923
		#設置執行正常
924
		$result["status"]="true";
924
		$result["status"]="true";
925
		
925
 
926
		#回傳結果
926
		#回傳結果
927
		return $result;
927
		return $result;
928
	
928
 
929
		}#function ss end
929
		}#function ss end
930
 
930
 
931
	/*
931
	/*
932
	#函式說明:
932
	#函式說明:
933
	#解析有規律的字串,分成多個段落.
933
	#解析有規律的字串,分成多個段落.
Line 952... Line 952...
952
	#無.
952
	#無.
953
	#備註:
953
	#備註:
954
	#無.
954
	#無.
955
	*/
955
	*/
956
	public static function section(&$conf){
956
	public static function section(&$conf){
957
	
957
 
958
		#初始化要回傳的結果
958
		#初始化要回傳的結果
959
		$result=array();
959
		$result=array();
960
		
960
 
961
		#取得當前執行的函數名稱
961
		#取得當前執行的函數名稱
962
		$result["function"]=__FUNCTION__;
962
		$result["function"]=__FUNCTION__;
963
		
963
 
964
		#如果 $conf 不為陣列
964
		#如果 $conf 不為陣列
965
		if(gettype($conf)!="array"){
965
		if(gettype($conf)!="array"){
966
			
966
 
967
			#設置執行失敗
967
			#設置執行失敗
968
			$result["status"]="false";
968
			$result["status"]="false";
969
			
969
 
970
			#設置執行錯誤訊息
970
			#設置執行錯誤訊息
971
			$result["error"][]="\$conf變數須為陣列形態";
971
			$result["error"][]="\$conf變數須為陣列形態";
972
 
972
 
973
			#如果傳入的參數為 null
973
			#如果傳入的參數為 null
974
			if($conf==null){
974
			if($conf==null){
975
				
975
 
976
				#設置執行錯誤訊息
976
				#設置執行錯誤訊息
977
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
977
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
978
				
978
 
979
				}#if end
979
				}#if end
980
 
980
 
981
			#回傳結果
981
			#回傳結果
982
			return $result;
982
			return $result;
983
			
983
 
984
			}#if end
984
			}#if end
985
		
985
 
986
		#取得參數
986
		#取得參數
987
		$result["argu"]=$conf;
987
		$result["argu"]=$conf;
988
			
988
 
989
		#函式說明:
989
		#函式說明:
990
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
990
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
991
		#回傳結果:
991
		#回傳結果:
992
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
992
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
993
		#$result["error"],執行不正常結束的錯訊息陣列.
993
		#$result["error"],執行不正常結束的錯訊息陣列.
Line 1036... Line 1036...
1036
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1036
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1037
		#備註:
1037
		#備註:
1038
		#無.
1038
		#無.
1039
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1039
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1040
		unset($conf["variableCheck::checkArguments"]);
1040
		unset($conf["variableCheck::checkArguments"]);
1041
	
1041
 
1042
		#如果執行失敗
1042
		#如果執行失敗
1043
		if($checkArguments["status"]==="false"){
1043
		if($checkArguments["status"]==="false"){
1044
		
1044
 
1045
			#設置執行失敗
1045
			#設置執行失敗
1046
			$result["status"]="false";
1046
			$result["status"]="false";
1047
 
1047
 
1048
			#設置錯誤訊息
1048
			#設置錯誤訊息
1049
			$result["error"]=$checkArguments;
1049
			$result["error"]=$checkArguments;
1050
 
1050
 
1051
			#回傳結果
1051
			#回傳結果
1052
			return $result;
1052
			return $result;
1053
		
1053
 
1054
			}#if end
1054
			}#if end
1055
			
1055
 
1056
		#如果參數檢查不通過
1056
		#如果參數檢查不通過
1057
		if($checkArguments["passed"]==="false"){
1057
		if($checkArguments["passed"]==="false"){
1058
		
1058
 
1059
			#設置執行失敗
1059
			#設置執行失敗
1060
			$result["status"]="false";
1060
			$result["status"]="false";
1061
 
1061
 
1062
			#設置錯誤訊息
1062
			#設置錯誤訊息
1063
			$result["error"]=$checkArguments;
1063
			$result["error"]=$checkArguments;
1064
 
1064
 
1065
			#回傳結果
1065
			#回傳結果
1066
			return $result;
1066
			return $result;
1067
		
1067
 
1068
			}#if end
1068
			}#if end
1069
			
1069
 
1070
		#初始化儲存段落結果的陣列
1070
		#初始化儲存段落結果的陣列
1071
		$result["content"]=array();
1071
		$result["content"]=array();
1072
		
1072
 
1073
		#初始化贊存的單一片段資料
1073
		#初始化贊存的單一片段資料
1074
		$tmpData="";
1074
		$tmpData="";
1075
			
1075
 
1076
		#初始化當前byte的形態,"start"代表開始符號;"end"代表結束符號;"data"代表內容.
1076
		#初始化當前byte的形態,"start"代表開始符號;"end"代表結束符號;"data"代表內容.
1077
		$byteType="";
1077
		$byteType="";
1078
		
1078
 
1079
		#針對每個byte
1079
		#針對每個byte
1080
		for($i=0;$i<strlen($conf["input"]);$i++){
1080
		for($i=0;$i<strlen($conf["input"]);$i++){
1081
		
1081
 
1082
			#debug
1082
			#debug
1083
			#var_dump($conf["input"][$i],$tmpData);
1083
			#var_dump($conf["input"][$i],$tmpData);
1084
		
1084
 
1085
			#判斷每個字
1085
			#判斷每個字
1086
			switch($conf["input"][$i]){
1086
			switch($conf["input"][$i]){
1087
			
1087
 
1088
				#如果是開始符號字串
1088
				#如果是開始符號字串
1089
				case $conf["startSymbol"]:
1089
				case $conf["startSymbol"]:
1090
			
1090
 
1091
					#如果開始結尾的符號字串相同
1091
					#如果開始結尾的符號字串相同
1092
					if($conf["startSymbol"]===$conf["endSymbol"]){
1092
					if($conf["startSymbol"]===$conf["endSymbol"]){
1093
					
1093
 
1094
						#如果剛剛的資料是 data
1094
						#如果剛剛的資料是 data
1095
						if($byteType==="data"){
1095
						if($byteType==="data"){
1096
						
1096
 
1097
							#更新當前byte的形態
1097
							#更新當前byte的形態
1098
							$byteType="end";
1098
							$byteType="end";
1099
					
1099
 
1100
							#保存該段落內容
1100
							#保存該段落內容
1101
							$result["content"][]=$tmpData;
1101
							$result["content"][]=$tmpData;
1102
							
1102
 
1103
							#初始化新的段落內容
1103
							#初始化新的段落內容
1104
							$tmpData="";
1104
							$tmpData="";
1105
					
1105
 
1106
							#結束 switch
1106
							#結束 switch
1107
							break;
1107
							break;
1108
						
1108
 
1109
							}#if end
1109
							}#if end
1110
					
1110
 
1111
						}#if end
1111
						}#if end
1112
			
1112
 
1113
					#更新當前byte的形態
1113
					#更新當前byte的形態
1114
					$byteType="start";
1114
					$byteType="start";
1115
					
1115
 
1116
					#初始化新的段落內容
1116
					#初始化新的段落內容
1117
					$tmpData="";
1117
					$tmpData="";
1118
			
1118
 
1119
					#結束 switch
1119
					#結束 switch
1120
					break;
1120
					break;
1121
					
1121
 
1122
				#如果是結束符號字串
1122
				#如果是結束符號字串
1123
				case $conf["endSymbol"]:
1123
				case $conf["endSymbol"]:
1124
			
1124
 
1125
					#更新當前byte的形態
1125
					#更新當前byte的形態
1126
					$byteType="end";
1126
					$byteType="end";
1127
			
1127
 
1128
					#保存該段落內容
1128
					#保存該段落內容
1129
					$result["content"][]=$tmpData;
1129
					$result["content"][]=$tmpData;
1130
					
1130
 
1131
					#初始化新的段落內容
1131
					#初始化新的段落內容
1132
					$tmpData="";
1132
					$tmpData="";
1133
			
1133
 
1134
					#結束 switch
1134
					#結束 switch
1135
					break;
1135
					break;
1136
					
1136
 
1137
				#其他結果
1137
				#其他結果
1138
				default :
1138
				default :
1139
				
1139
 
1140
					#代表為 data
1140
					#代表為 data
1141
					$byteType="data";
1141
					$byteType="data";
1142
			
1142
 
1143
					#串接段落內容
1143
					#串接段落內容
1144
					$tmpData=$tmpData.$conf["input"][$i];
1144
					$tmpData=$tmpData.$conf["input"][$i];
1145
			
1145
 
1146
				}#switch end
1146
				}#switch end
1147
				
1147
 
1148
			}#for end`
1148
			}#for end`
1149
	
1149
 
1150
		#取得段落數量
1150
		#取得段落數量
1151
		$result["count"]=count($result["content"]);
1151
		$result["count"]=count($result["content"]);
1152
	
1152
 
1153
		#設置執行正常
1153
		#設置執行正常
1154
		$result["status"]="true";
1154
		$result["status"]="true";
1155
		
1155
 
1156
		#回傳結果
1156
		#回傳結果
1157
		return $result;
1157
		return $result;
1158
	
1158
 
1159
		}#function section end
1159
		}#function section end
1160
 
1160
 
1161
	}#class parser end
-
 
1162
1161
	}#class parser end
-
 
1162