Subversion Repositories php-qbpwcf

Rev

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

Rev 121 Rev 183
Line 1158... Line 1158...
1158
								#無.
1158
								#無.
1159
								#備註:
1159
								#備註:
1160
								#無.
1160
								#無.
1161
								$record=logs::record($conf["logs::record"]);
1161
								$record=logs::record($conf["logs::record"]);
1162
								unset($conf["logs::record"]);
1162
								unset($conf["logs::record"]);
1163
																	
1163
								
1164
								#如果執行失敗
1164
								#如果執行失敗
1165
								if($record["status"]==="false"){
1165
								if($record["status"]==="false"){
1166
								
1166
								
1167
									#設置執行錯誤識別
1167
									#設置執行錯誤識別
1168
									$result["status"]="false";
1168
									$result["status"]="false";
Line 1245... Line 1245...
1245
									
1245
									
1246
									#結束讀取要求
1246
									#結束讀取要求
1247
									break;	
1247
									break;	
1248
									
1248
									
1249
									}#if end
1249
									}#if end
1250
										
1250
								
1251
								#串接回應
1251
								#串接回應
1252
								$request=$request.$tmp;
1252
								$request=$request.$tmp;
1253
							
1253
							
1254
								}#while end	
1254
								}#while end
1255
											
1255
							
1256
							#印出有連線進來的訊息
1256
							#印出有連線進來的訊息
1257
							echo "received content:".PHP_EOL.$request.PHP_EOL;
1257
							echo "received content:".PHP_EOL.$request.PHP_EOL;
1258
							
1258
							
1259
							#parse request json
1259
							#parse request json
1260
							$request=json_decode($request);
1260
							$request=json_decode($request);
Line 1464... Line 1464...
1464
								$request=$request->custom;
1464
								$request=$request->custom;
1465
							
1465
							
1466
								}#if end
1466
								}#if end
1467
							
1467
							
1468
							#若有要執行的指令 cmd,且非客製化.
1468
							#若有要執行的指令 cmd,且非客製化.
1469
							if( isset($request->cmd) && !isset($request->custom) ){
1469
							if(isset($request->cmd)){
1470
								
1470
								
1471
								#如果是要結束連線
1471
								#如果是要結束連線
1472
								if($request->cmd==="quit"){
1472
								if($request->cmd==="quit"){
1473
								
1473
								
1474
									#設置執行正常
1474
									#設置執行正常
Line 1486... Line 1486...
1486
									#關閉socket連線,將回應輸出.
1486
									#關閉socket連線,將回應輸出.
1487
									fclose($conn);
1487
									fclose($conn);
1488
								
1488
								
1489
									#移除該用戶變數
1489
									#移除該用戶變數
1490
									unset($client[$index]);
1490
									unset($client[$index]);
1491
											
1491
									
1492
									#計數移除了幾個用戶
1492
									#計數移除了幾個用戶
1493
									$res["delCount"]++;
1493
									$res["delCount"]++;
1494
									
1494
									
1495
									#設置執行正常
1495
									#設置執行正常
1496
									$res["status"]="true";
1496
									$res["status"]="true";
Line 1680... Line 1680...
1680
									$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
1680
									$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
1681
									unset($conf["arrays::arrayToString"]);
1681
									unset($conf["arrays::arrayToString"]);
1682
								
1682
								
1683
									#如果執行失敗
1683
									#如果執行失敗
1684
									if($arrayToString["status"]==="false"){
1684
									if($arrayToString["status"]==="false"){
1685
											
1685
										
1686
										#設置執行失敗
1686
										#設置執行失敗
1687
										$result["status"]="false";
1687
										$result["status"]="false";
1688
										
1688
										
1689
										#設置錯誤訊息
1689
										#設置錯誤訊息
1690
										$result["error"]=$arrayToString;
1690
										$result["error"]=$arrayToString;
Line 1727... Line 1727...
1727
								$proc=threads::proc($conf["threads::proc"]);
1727
								$proc=threads::proc($conf["threads::proc"]);
1728
								unset($conf["threads::proc"]);
1728
								unset($conf["threads::proc"]);
1729
							
1729
							
1730
								#如果執行失敗
1730
								#如果執行失敗
1731
								if($proc["status"]==="false"){
1731
								if($proc["status"]==="false"){
1732
										
1732
									
1733
									#設置執行失敗
1733
									#設置執行失敗
1734
									$result["status"]="false";
1734
									$result["status"]="false";
1735
									
1735
									
1736
									#設置錯誤訊息
1736
									#設置錯誤訊息
1737
									$result["error"]=$proc;
1737
									$result["error"]=$proc;
Line 2273... Line 2273...
2273
									}#if end
2273
									}#if end
2274
								
2274
								
2275
								}#if end
2275
								}#if end
2276
								
2276
								
2277
							#更新使用者id與最後一次來request的時間
2277
							#更新使用者id與最後一次來request的時間
2278
							$client[$request->id]["last_req_time"]=$last_req_time;	
2278
							$client[$request->id]["last_req_time"]=$last_req_time;
2279
							
2279
							
2280
							#印出用戶端列表
2280
							#印出用戶端列表
2281
							echo "clients:".print_r($client,true);	
2281
							echo "clients:".print_r($client,true);
2282
							
2282
							
2283
							#等待下個要求
2283
							#等待下個要求
2284
							continue;
2284
							continue;
2285
							
2285
							
2286
							}#if end
2286
							}#if end