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
#匯入外部套件
70
#匯入外部套件
71
include("allInOne.php");
71
include("allInOne.php");
72
 
72
 
Line 121... Line 121...
121
	$conf["outputStringArray"][]="-h/--help 顯示本說明";
121
	$conf["outputStringArray"][]="-h/--help 顯示本說明";
122
	$conf["outputStringArray"][]="--program2kill 要結束的特定程式關鍵字,若有多個則代表有多個程序要結束";
122
	$conf["outputStringArray"][]="--program2kill 要結束的特定程式關鍵字,若有多個則代表有多個程序要結束";
123
	$conf["outputStringArray"][]="--program2run 要執行的程式位置與名稱";
123
	$conf["outputStringArray"][]="--program2run 要執行的程式位置與名稱";
124
	$echoMultiLine=cmd::echoMultiLine($conf);
124
	$echoMultiLine=cmd::echoMultiLine($conf);
125
	unset($conf);
125
	unset($conf);
126
	
126
 
127
	#結束執行
127
	#結束執行
128
	exit;
128
	exit;
129
	
129
 
130
	}
130
	}
131
 
131
 
132
#第一個參數
132
#第一個參數
133
$firsArgu=$getArgu["content"][1];
133
$firsArgu=$getArgu["content"][1];
134
 
134
 
Line 148... Line 148...
148
	$conf["outputStringArray"][]="-h/--help 顯示本說明";
148
	$conf["outputStringArray"][]="-h/--help 顯示本說明";
149
	$conf["outputStringArray"][]="--program2kill 要結束的程式關鍵字";
149
	$conf["outputStringArray"][]="--program2kill 要結束的程式關鍵字";
150
	$conf["outputStringArray"][]="--program2run 要執行的程式位置與名稱";
150
	$conf["outputStringArray"][]="--program2run 要執行的程式位置與名稱";
151
	$echoMultiLine=cmd::echoMultiLine($conf);
151
	$echoMultiLine=cmd::echoMultiLine($conf);
152
	unset($conf);
152
	unset($conf);
153
	
153
 
154
	#結束執行
154
	#結束執行
155
	exit;
155
	exit;
156
	
156
 
157
	}
157
	}
158
 
158
 
159
#函式說明:
159
#函式說明:
160
#解析參數.
160
#解析參數.
161
#回傳結果:
161
#回傳結果:
Line 203... Line 203...
203
	#$result["statusCode"],執行結束後的代碼.
203
	#$result["statusCode"],執行結束後的代碼.
204
	#必填的參數
204
	#必填的參數
205
	#$conf["command"],字串,要執行的指令與.
205
	#$conf["command"],字串,要執行的指令與.
206
	$conf["command"]="ps";
206
	$conf["command"]="ps";
207
	#$conf["fileArgu"],字串,變數__FILE__的內容.
207
	#$conf["fileArgu"],字串,變數__FILE__的內容.
208
	$conf["fileArgu"]=__FILE__;		
208
	$conf["fileArgu"]=__FILE__;
209
	#可省略參數:
209
	#可省略參數:
210
	#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
210
	#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
211
	$conf["argu"]=array("auxwf","|","grep",$program2kill);
211
	$conf["argu"]=array("auxwf","|","grep",$program2kill);
212
	#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
212
	#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
213
	#$conf["arguIsAddr"]=array();	
213
	#$conf["arguIsAddr"]=array();
214
	#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
214
	#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
215
	#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
215
	#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
216
	#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
216
	#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
217
	#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
217
	#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
218
	$conf["enablePrintDescription"]="true";
218
	$conf["enablePrintDescription"]="true";
Line 253... Line 253...
253
		#印出訊息
253
		#印出訊息
254
		var_dump($result);
254
		var_dump($result);
255
 
255
 
256
		#結束執行
256
		#結束執行
257
		exit;
257
		exit;
258
		
258
 
259
		}
259
		}
260
 
260
 
261
	#取得輸出
261
	#取得輸出
262
	$output=$callShell["output"];
262
	$output=$callShell["output"];
263
 
263
 
264
	#剔除有grep關鍵字的程式	
264
	#剔除有grep關鍵字的程式
265
	#函式說明:
265
	#函式說明:
266
	#檢查多個字串中的每個字串是否有多個關鍵字
266
	#檢查多個字串中的每個字串是否有多個關鍵字
267
	#回傳的結果:
267
	#回傳的結果:
268
	#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
268
	#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
269
	#$result["function"],當前執行的函數名稱.
269
	#$result["function"],當前執行的函數名稱.
Line 333... Line 333...
333
		$spiltString=stringProcess::spiltString($conf);
333
		$spiltString=stringProcess::spiltString($conf);
334
		unset($conf);
334
		unset($conf);
335
 
335
 
336
		#如果執行失敗
336
		#如果執行失敗
337
		if($spiltString["status"]==="false"){
337
		if($spiltString["status"]==="false"){
338
		
338
 
339
			#設置執行失敗
339
			#設置執行失敗
340
			$result["status"]="false";
340
			$result["status"]="false";
341
 
341
 
342
			#設置執行錯誤訊息
342
			#設置執行錯誤訊息
343
			$result["error"]=$spiltString;
343
			$result["error"]=$spiltString;
Line 345... Line 345...
345
			#印出訊息
345
			#印出訊息
346
			var_dump($result);
346
			var_dump($result);
347
 
347
 
348
			#結束執行
348
			#結束執行
349
			exit;
349
			exit;
350
		
350
 
351
			}
351
			}
352
		
352
 
353
		#取得程序的pid
353
		#取得程序的pid
354
		$pid=$spiltString["dataArray"][1];
354
		$pid=$spiltString["dataArray"][1];
355
		
355
 
356
		#涵式說明:
356
		#涵式說明:
357
		#呼叫shell執行系統命令,並取得回傳的內容.
357
		#呼叫shell執行系統命令,並取得回傳的內容.
358
		#回傳的結果:
358
		#回傳的結果:
359
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
359
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
360
		#$result["error"],錯誤訊息陣列.
360
		#$result["error"],錯誤訊息陣列.
Line 369... Line 369...
369
		#$result["statusCode"],執行結束後的代碼.
369
		#$result["statusCode"],執行結束後的代碼.
370
		#必填的參數
370
		#必填的參數
371
		#$conf["command"],字串,要執行的指令與.
371
		#$conf["command"],字串,要執行的指令與.
372
		$conf["command"]="kill";
372
		$conf["command"]="kill";
373
		#$conf["fileArgu"],字串,變數__FILE__的內容.
373
		#$conf["fileArgu"],字串,變數__FILE__的內容.
374
		$conf["fileArgu"]=__FILE__;		
374
		$conf["fileArgu"]=__FILE__;
375
		#可省略參數:
375
		#可省略參數:
376
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
376
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
377
		$conf["argu"]=array($pid);
377
		$conf["argu"]=array($pid);
378
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
378
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
379
		#$conf["arguIsAddr"]=array();	
379
		#$conf["arguIsAddr"]=array();
380
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
380
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
381
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
381
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
382
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
382
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
383
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
383
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
384
		$conf["enablePrintDescription"]="true";
384
		$conf["enablePrintDescription"]="true";
Line 407... Line 407...
407
		$callShell=external::callShell($conf);
407
		$callShell=external::callShell($conf);
408
		unset($conf);
408
		unset($conf);
409
 
409
 
410
		#如果執行失敗
410
		#如果執行失敗
411
		if($callShell["status"]==="false"){
411
		if($callShell["status"]==="false"){
412
		
412
 
413
			#設置執行失敗
413
			#設置執行失敗
414
			$result["status"]="false";
414
			$result["status"]="false";
415
 
415
 
416
			#設置執行錯誤訊息
416
			#設置執行錯誤訊息
417
			$result["error"]=$getArgu;
417
			$result["error"]=$getArgu;
Line 419... Line 419...
419
			#印出訊息
419
			#印出訊息
420
			var_dump($result);
420
			var_dump($result);
421
 
421
 
422
			#結束執行
422
			#結束執行
423
			exit;
423
			exit;
424
			
424
 
425
			}
425
			}
426
		
426
 
427
		#印出執行的結果
427
		#印出執行的結果
428
		var_dump($callShell);
428
		var_dump($callShell);
429
 
429
 
430
		}
430
		}
431
 
431
 
Line 448... Line 448...
448
#$result["statusCode"],執行結束後的代碼.
448
#$result["statusCode"],執行結束後的代碼.
449
#必填的參數
449
#必填的參數
450
#$conf["command"],字串,要執行的指令與.
450
#$conf["command"],字串,要執行的指令與.
451
$conf["command"]=$program2run;
451
$conf["command"]=$program2run;
452
#$conf["fileArgu"],字串,變數__FILE__的內容.
452
#$conf["fileArgu"],字串,變數__FILE__的內容.
453
$conf["fileArgu"]=__FILE__;		
453
$conf["fileArgu"]=__FILE__;
454
#可省略參數:
454
#可省略參數:
455
#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
455
#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
456
#$conf["argu"]=array($pid);
456
#$conf["argu"]=array($pid);
457
#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
457
#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
458
#$conf["arguIsAddr"]=array();	
458
#$conf["arguIsAddr"]=array();
459
#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
459
#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
460
#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
460
#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
461
#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
461
#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
462
#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
462
#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
463
$conf["enablePrintDescription"]="true";
463
$conf["enablePrintDescription"]="true";