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
#!/usr/bin/php
1
#!/usr/bin/php
2
<?php
2
<?php
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 17... Line 17...
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
18
    GNU General Public License for more details.
19
 
19
 
20
    You should have received a copy of the GNU General Public License
20
    You should have received a copy of the GNU General Public License
21
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
21
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
22
    
22
 
23
*/
23
*/
24
 
24
 
25
/*
25
/*
26
 
26
 
27
說明:
27
說明:
Line 62... Line 62...
62
	#結束執行,回傳shell 1.
62
	#結束執行,回傳shell 1.
63
	exit(1);
63
	exit(1);
64
 
64
 
65
	}#if end
65
	}#if end
66
 
66
 
67
#設置 include path 
67
#設置 include path
68
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
68
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
69
 
69
 
70
#保存 lib path
70
#保存 lib path
71
$libPath=$output[0];
71
$libPath=$output[0];
72
 
72
 
Line 78... Line 78...
78
 
78
 
79
#說明函式
79
#說明函式
80
function help(){
80
function help(){
81
 
81
 
82
	#印出指令說明
82
	#印出指令說明
83
	echo "Usage of ".basename(__FILE__).":".PHP_EOL; 
83
	echo "Usage of ".basename(__FILE__).":".PHP_EOL;
84
	echo "--unixDomainSocketPath 代表要連接的 unix doamin socket 路徑.預設為 ".qbpwcf_usock_path.PHP_EOL;
84
	echo "--unixDomainSocketPath 代表要連接的 unix doamin socket 路徑.預設為 ".qbpwcf_usock_path.PHP_EOL;
85
	echo "--cmd 代表要執行的指令".PHP_EOL;
85
	echo "--cmd 代表要執行的指令".PHP_EOL;
86
	echo "--param 代表要使用的參數".PHP_EOL;
86
	echo "--param 代表要使用的參數".PHP_EOL;
87
	echo "--debug true 代表要啟動 debug 模式".PHP_EOL;
87
	echo "--debug true 代表要啟動 debug 模式".PHP_EOL;
88
	
88
 
89
	#結束執行
89
	#結束執行
90
	exit;
90
	exit;
91
 
91
 
92
	}#function help end
92
	}#function help end
93
 
93
 
Line 115... Line 115...
115
#如果解析參數失敗
115
#如果解析參數失敗
116
if($parseArgu["status"]==="false"){
116
if($parseArgu["status"]==="false"){
117
 
117
 
118
	#印出結果
118
	#印出結果
119
	var_dump($parseArgu);
119
	var_dump($parseArgu);
120
		
120
 
121
	#結束執行,回傳錯誤代碼1
121
	#結束執行,回傳錯誤代碼1
122
	exit(1);
122
	exit(1);
123
	
123
 
124
	}#if end
124
	}#if end
125
 
125
 
126
#break point
126
#break point
127
#var_dump($parseArgu);exit;
127
#var_dump($parseArgu);exit;
128
 
128
 
Line 181... Line 181...
181
#若執行失敗
181
#若執行失敗
182
if($checkArguments["status"]==="false"){
182
if($checkArguments["status"]==="false"){
183
 
183
 
184
	#印出結果
184
	#印出結果
185
	var_dump($checkArguments);
185
	var_dump($checkArguments);
186
	
186
 
187
	#結束執行,回傳錯誤代碼1.
187
	#結束執行,回傳錯誤代碼1.
188
	exit(1);
188
	exit(1);
189
 
189
 
190
	}#if end
190
	}#if end
191
 
191
 
192
#若檢查不通過
192
#若檢查不通過
193
if($checkArguments["passed"]==="false"){
193
if($checkArguments["passed"]==="false"){
194
 
194
 
195
	#印出結果
195
	#印出結果
196
	var_dump($checkArguments);
196
	var_dump($checkArguments);
197
	
197
 
198
	#結束執行,回傳錯誤代碼1.
198
	#結束執行,回傳錯誤代碼1.
199
	exit(1);
199
	exit(1);
200
 
200
 
201
	}#if end
201
	}#if end
202
 
202
 
Line 206... Line 206...
206
#如果設置要debug
206
#如果設置要debug
207
if($parseArgu["content"]["debug"][0]==="true")
207
if($parseArgu["content"]["debug"][0]==="true")
208
{
208
{
209
	#設置要debug
209
	#設置要debug
210
	$debug=true;
210
	$debug=true;
211
	
211
 
212
	#debug
212
	#debug
213
	system("echo ".$logFile." > /tmp/output.log");
213
	system("echo ".$logFile." > /tmp/output.log");
214
	
214
 
215
}
215
}
216
 
216
 
217
#取得要連接的 unix domain socket path
217
#取得要連接的 unix domain socket path
218
$unixDomainSocketPath=$parseArgu["content"]["unixDomainSocketPath"][0];
218
$unixDomainSocketPath=$parseArgu["content"]["unixDomainSocketPath"][0];
219
 
219
 
Line 251... Line 251...
251
#若執行失敗
251
#若執行失敗
252
if($unixDomainSockClient["status"]==="false"){
252
if($unixDomainSockClient["status"]==="false"){
253
 
253
 
254
	#印出結果
254
	#印出結果
255
	var_dump($unixDomainSockClient);
255
	var_dump($unixDomainSockClient);
256
	
256
 
257
	#如果要debug
257
	#如果要debug
258
	if($debug){
258
	if($debug){
259
	
259
 
260
		#函式說明:
260
		#函式說明:
261
		#撰寫log
261
		#撰寫log
262
		#回傳結果:
262
		#回傳結果:
263
		#$result["status"],狀態,"true"或"false".
263
		#$result["status"],狀態,"true"或"false".
264
		#$result["error"],錯誤訊息陣列.
264
		#$result["error"],錯誤訊息陣列.
Line 278... Line 278...
278
		#無.
278
		#無.
279
		#備註:
279
		#備註:
280
		#無.
280
		#無.
281
		$record=logs::record($conf);
281
		$record=logs::record($conf);
282
		unset($conf);
282
		unset($conf);
283
		
283
 
284
		#如果寫log失敗
284
		#如果寫log失敗
285
		if($record["status"]==="false"){
285
		if($record["status"]==="false"){
286
		
286
 
287
			#印出結果
287
			#印出結果
288
			var_dump($record);
288
			var_dump($record);
289
		
289
 
290
			}#if end
290
			}#if end
291
	
291
 
292
		}#if end
292
		}#if end
293
	
293
 
294
	#結束執行,回傳錯誤代碼1.
294
	#結束執行,回傳錯誤代碼1.
295
	exit(1);
295
	exit(1);
296
 
296
 
297
	}#if end
297
	}#if end
298
	
298
 
299
#解析結果
299
#解析結果
300
$res=(array)(json_decode($unixDomainSockClient["content"]));
300
$res=(array)(json_decode($unixDomainSockClient["content"]));
301
 
301
 
302
#如果取得id失敗
302
#如果取得id失敗
303
if($res["status"]==="false"){
303
if($res["status"]==="false"){
304
 
304
 
305
	#印出結果
305
	#印出結果
306
	var_dump($res);
306
	var_dump($res);
307
	
307
 
308
	#如果要debug
308
	#如果要debug
309
	if($debug){
309
	if($debug){
310
	
310
 
311
		#函式說明:
311
		#函式說明:
312
		#撰寫log
312
		#撰寫log
313
		#回傳結果:
313
		#回傳結果:
314
		#$result["status"],狀態,"true"或"false".
314
		#$result["status"],狀態,"true"或"false".
315
		#$result["error"],錯誤訊息陣列.
315
		#$result["error"],錯誤訊息陣列.
Line 329... Line 329...
329
		#無.
329
		#無.
330
		#備註:
330
		#備註:
331
		#無.
331
		#無.
332
		$record=logs::record($conf);
332
		$record=logs::record($conf);
333
		unset($conf);
333
		unset($conf);
334
		
334
 
335
		#如果寫log失敗
335
		#如果寫log失敗
336
		if($record["status"]==="false"){
336
		if($record["status"]==="false"){
337
		
337
 
338
			#印出結果
338
			#印出結果
339
			var_dump($record);
339
			var_dump($record);
340
		
340
 
341
			}#if end
341
			}#if end
342
	
342
 
343
		}#if end
343
		}#if end
344
	
344
 
345
	#結束執行,回傳錯誤代碼1.
345
	#結束執行,回傳錯誤代碼1.
346
	exit(1);
346
	exit(1);
347
 
347
 
348
	}#if end
348
	}#if end
349
 
349
 
Line 410... Line 410...
410
#若執行失敗
410
#若執行失敗
411
if($unixDomainSockClient["status"]==="false"){
411
if($unixDomainSockClient["status"]==="false"){
412
 
412
 
413
	#印出結果
413
	#印出結果
414
	var_dump($unixDomainSockClient);
414
	var_dump($unixDomainSockClient);
415
	
415
 
416
	#如果要debug
416
	#如果要debug
417
	if($debug){
417
	if($debug){
418
	
418
 
419
		#函式說明:
419
		#函式說明:
420
		#撰寫log
420
		#撰寫log
421
		#回傳結果:
421
		#回傳結果:
422
		#$result["status"],狀態,"true"或"false".
422
		#$result["status"],狀態,"true"或"false".
423
		#$result["error"],錯誤訊息陣列.
423
		#$result["error"],錯誤訊息陣列.
Line 437... Line 437...
437
		#無.
437
		#無.
438
		#備註:
438
		#備註:
439
		#無.
439
		#無.
440
		$record=logs::record($conf);
440
		$record=logs::record($conf);
441
		unset($conf);
441
		unset($conf);
442
		
442
 
443
		#如果寫log失敗
443
		#如果寫log失敗
444
		if($record["status"]==="false"){
444
		if($record["status"]==="false"){
445
		
445
 
446
			#印出結果
446
			#印出結果
447
			var_dump($record);
447
			var_dump($record);
448
		
448
 
449
			}#if end
449
			}#if end
450
	
450
 
451
		}#if end
451
		}#if end
452
	
452
 
453
	#結束執行,回傳錯誤代碼1.
453
	#結束執行,回傳錯誤代碼1.
454
	exit(1);
454
	exit(1);
455
 
455
 
456
	}#if end
456
	}#if end
457
	
457
 
458
#解析結果
458
#解析結果
459
$res=(array)(json_decode($unixDomainSockClient["content"]));
459
$res=(array)(json_decode($unixDomainSockClient["content"]));
460
 
460
 
461
#如果取得id失敗
461
#如果取得id失敗
462
if($res["status"]==="false"){
462
if($res["status"]==="false"){
463
 
463
 
464
	#印出結果
464
	#印出結果
465
	var_dump($res);
465
	var_dump($res);
466
	
466
 
467
	#如果要debug
467
	#如果要debug
468
	if($debug){
468
	if($debug){
469
	
469
 
470
		#函式說明:
470
		#函式說明:
471
		#撰寫log
471
		#撰寫log
472
		#回傳結果:
472
		#回傳結果:
473
		#$result["status"],狀態,"true"或"false".
473
		#$result["status"],狀態,"true"或"false".
474
		#$result["error"],錯誤訊息陣列.
474
		#$result["error"],錯誤訊息陣列.
Line 488... Line 488...
488
		#無.
488
		#無.
489
		#備註:
489
		#備註:
490
		#無.
490
		#無.
491
		$record=logs::record($conf);
491
		$record=logs::record($conf);
492
		unset($conf);
492
		unset($conf);
493
		
493
 
494
		#如果寫log失敗
494
		#如果寫log失敗
495
		if($record["status"]==="false"){
495
		if($record["status"]==="false"){
496
		
496
 
497
			#印出結果
497
			#印出結果
498
			var_dump($record);
498
			var_dump($record);
499
		
499
 
500
			}#if end
500
			}#if end
501
	
501
 
502
		}#if end
502
		}#if end
503
	
503
 
504
	#結束執行,回傳錯誤代碼1.
504
	#結束執行,回傳錯誤代碼1.
505
	exit(1);
505
	exit(1);
506
 
506
 
507
	}#if end
507
	}#if end
508
 
508
 
Line 510... Line 510...
510
for($i=0;$i<count($res["output"]);$i++){
510
for($i=0;$i<count($res["output"]);$i++){
511
 
511
 
512
	#印出結果
512
	#印出結果
513
	echo $res["output"][$i].PHP_EOL;
513
	echo $res["output"][$i].PHP_EOL;
514
 
514
 
515
	}#for end
-
 
516
515
	}#for end
-
 
516