Subversion Repositories php-qbpwcf

Rev

Rev 78 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 78 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
用 \qbpwcf\sock::unixDomainSockServer 建立 unix doamin socket server
27
用 \qbpwcf\sock::unixDomainSockServer 建立 unix doamin socket server
Line 63... Line 63...
63
	#結束執行,回傳shell 1.
63
	#結束執行,回傳shell 1.
64
	exit(1);
64
	exit(1);
65
 
65
 
66
	}#if end
66
	}#if end
67
 
67
 
68
#設置 include path 
68
#設置 include path
69
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
69
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
70
 
70
 
71
#匯入外部套件
71
#匯入外部套件
72
include("allInOne.php");
72
include("allInOne.php");
73
 
73
 
74
#說明函式
74
#說明函式
75
function help(){
75
function help(){
76
 
76
 
77
	#印出指令說明
77
	#印出指令說明
78
	echo "Usage of ".basename(__FILE__).":".PHP_EOL; 
78
	echo "Usage of ".basename(__FILE__).":".PHP_EOL;
79
	echo "--sock unix domain socket 的位置與名稱.".PHP_EOL;
79
	echo "--sock unix domain socket 的位置與名稱.".PHP_EOL;
80
	echo "--addOnProcessFunc namespace\class::function 收到client訊息時要執行的函式.".PHP_EOL;
80
	echo "--addOnProcessFunc namespace\class::function 收到client訊息時要執行的函式.".PHP_EOL;
81
	echo "--funcToRunWhenIdle namespace\class::function 沒收到訊息時要執行的函式.".PHP_EOL;
81
	echo "--funcToRunWhenIdle namespace\class::function 沒收到訊息時要執行的函式.".PHP_EOL;
82
	echo "--onlyOutputCache \"true\"代表輸出 sock::unixDomainSockServer 回傳的 serverCache 結果".PHP_EOL;
82
	echo "--onlyOutputCache \"true\"代表輸出 sock::unixDomainSockServer 回傳的 serverCache 結果".PHP_EOL;
83
	echo "--cacheLayer 代表要輸出 sock::unixDomainSockServer 回傳的 serverCache 變數底下的陣列索引名稱,有幾層就使用幾次該參數".PHP_EOL;
83
	echo "--cacheLayer 代表要輸出 sock::unixDomainSockServer 回傳的 serverCache 變數底下的陣列索引名稱,有幾層就使用幾次該參數".PHP_EOL;
84
	echo "--cacheLayerJson 代表要輸出 sock::unixDomainSockServer 回傳的 serverCache 變數底下的陣列索引名稱,數值為json_encode後urlencode後base64_encode後的字串".PHP_EOL;
84
	echo "--cacheLayerJson 代表要輸出 sock::unixDomainSockServer 回傳的 serverCache 變數底下的陣列索引名稱,數值為json_encode後urlencode後base64_encode後的字串".PHP_EOL;
85
	
85
 
86
	#結束執行
86
	#結束執行
87
	exit;
87
	exit;
88
 
88
 
89
	}#function help end
89
	}#function help end
90
 
90
 
Line 112... Line 112...
112
#如果解析參數失敗
112
#如果解析參數失敗
113
if($parseArgu["status"]==="false"){
113
if($parseArgu["status"]==="false"){
114
 
114
 
115
	#印出結果
115
	#印出結果
116
	var_dump($parseArgu);
116
	var_dump($parseArgu);
117
	
117
 
118
	#結束執行
118
	#結束執行
119
	exit(1);
119
	exit(1);
120
	
120
 
121
	}#if end
121
	}#if end
122
 
122
 
123
#預設的 unix domain socket
123
#預設的 unix domain socket
124
$defaultUnixDomainSocket="./".basename(__FILE__).".sock";
124
$defaultUnixDomainSocket="./".basename(__FILE__).".sock";
125
 
125
 
Line 175... Line 175...
175
#若執行失敗
175
#若執行失敗
176
if($checkArguments["status"]==="false"){
176
if($checkArguments["status"]==="false"){
177
 
177
 
178
	#印出結果
178
	#印出結果
179
	var_dump($checkArguments);
179
	var_dump($checkArguments);
180
	
180
 
181
	#結束執行
181
	#結束執行
182
	exit(1);
182
	exit(1);
183
 
183
 
184
	}#if end
184
	}#if end
185
 
185
 
186
#若檢查不通過
186
#若檢查不通過
187
if($checkArguments["passed"]==="false"){
187
if($checkArguments["passed"]==="false"){
188
 
188
 
189
	#印出結果
189
	#印出結果
190
	var_dump($checkArguments);
190
	var_dump($checkArguments);
191
	
191
 
192
	#結束執行
192
	#結束執行
193
	exit(1);
193
	exit(1);
194
 
194
 
195
	}#if end
195
	}#if end
196
 
196
 
Line 249... Line 249...
249
#如果程式
249
#如果程式
250
if($unixDomainSockServer["status"]==="false"){
250
if($unixDomainSockServer["status"]==="false"){
251
 
251
 
252
	#印出 cache 的內容
252
	#印出 cache 的內容
253
	echo ob_get_contents();
253
	echo ob_get_contents();
254
			
254
 
255
	#清空buffer,結束buffer的使用
255
	#清空buffer,結束buffer的使用
256
	ob_end_clean();
256
	ob_end_clean();
257
 
257
 
258
	#印出結果
258
	#印出結果
259
	var_dump($unixDomainSockServer);
259
	var_dump($unixDomainSockServer);
260
	
260
 
261
	#結束執行
261
	#結束執行
262
	exit(1);
262
	exit(1);
263
 
263
 
264
	}#if end
264
	}#if end
265
 
265
 
Line 269... Line 269...
269
	#debug
269
	#debug
270
	#var_dump(__LINE__,$parseArgu["content"]);
270
	#var_dump(__LINE__,$parseArgu["content"]);
271
 
271
 
272
	#如果不存在 serverCache
272
	#如果不存在 serverCache
273
	if(!isset($unixDomainSockServer["serverCache"])){
273
	if(!isset($unixDomainSockServer["serverCache"])){
274
	
274
 
275
		#印出 cache 的內容
275
		#印出 cache 的內容
276
		echo ob_get_contents();
276
		echo ob_get_contents();
277
				
277
 
278
		#清空buffer,結束buffer的使用
278
		#清空buffer,結束buffer的使用
279
		ob_end_clean();
279
		ob_end_clean();
280
	
280
 
281
		#印出結果
281
		#印出結果
282
		var_dump($unixDomainSockServer);
282
		var_dump($unixDomainSockServer);
283
		
283
 
284
		#結束執行並回傳1
284
		#結束執行並回傳1
285
		exit(1);
285
		exit(1);
286
	
286
 
287
		}#if end
287
		}#if end
288
	
288
 
289
	#如果無設置 cacheLayer
289
	#如果無設置 cacheLayer
290
	if(!(isset($parseArgu["content"]["cacheLayer"]))){
290
	if(!(isset($parseArgu["content"]["cacheLayer"]))){
291
	
291
 
292
		#印出json結果
292
		#印出json結果
293
		echo json_encode($unixDomainSockServer["serverCache"]);
293
		echo json_encode($unixDomainSockServer["serverCache"]);
294
	
294
 
295
		#結束執行並回傳0
295
		#結束執行並回傳0
296
		exit;
296
		exit;
297
	
297
 
298
		}#if end
298
		}#if end
299
	
299
 
300
	#反之
300
	#反之
301
	else{
301
	else{
302
	
302
 
303
		#儲存當前的cache參考
303
		#儲存當前的cache參考
304
		$currentCache=&$unixDomainSockServer["serverCache"];
304
		$currentCache=&$unixDomainSockServer["serverCache"];
305
		
305
 
306
		#debug,印出 cache 的內容,清空buffer,結束buffer的使用.
306
		#debug,印出 cache 的內容,清空buffer,結束buffer的使用.
307
		#echo ob_get_contents();ob_end_clean();exit;
307
		#echo ob_get_contents();ob_end_clean();exit;
308
		
308
 
309
		#針對每個 cacheLayer
309
		#針對每個 cacheLayer
310
		foreach($parseArgu["content"]["cacheLayer"] as $cacheLayer){
310
		foreach($parseArgu["content"]["cacheLayer"] as $cacheLayer){
311
		
311
 
312
			#如果存在該階層
312
			#如果存在該階層
313
			if(isset($currentCache[$cacheLayer])){
313
			if(isset($currentCache[$cacheLayer])){
314
			
314
 
315
				#取得當前階層的參考
315
				#取得當前階層的參考
316
				$currentCache=&$currentCache[$cacheLayer];
316
				$currentCache=&$currentCache[$cacheLayer];
317
			
317
 
318
				}#if end
318
				}#if end
319
		
319
 
320
			}#foreach end
320
			}#foreach end
321
		
321
 
322
		#清空buffer,結束buffer的使用
322
		#清空buffer,結束buffer的使用
323
		ob_end_clean();
323
		ob_end_clean();
324
		
324
 
325
		#印出指定的cache內容
325
		#印出指定的cache內容
326
		echo json_encode($currentCache);
326
		echo json_encode($currentCache);
327
		
327
 
328
		#結束執行並回傳0
328
		#結束執行並回傳0
329
		exit;
329
		exit;
330
	
330
 
331
		}#else end
331
		}#else end
332
 
332
 
333
	}#if end
333
	}#if end
334
 
334
 
335
#印出 cache 的內容
335
#印出 cache 的內容
336
echo ob_get_contents();
336
echo ob_get_contents();
337
		
337
 
338
#清空buffer,結束buffer的使用
338
#清空buffer,結束buffer的使用
339
ob_end_clean();
339
ob_end_clean();
340
 
340
 
341
#debug
341
#debug
342
#var_dump(__LINE__,$parseArgu);exit;
342
#var_dump(__LINE__,$parseArgu);exit;