Subversion Repositories php-qbpwcf

Rev

Rev 383 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 383 Rev 396
Line 582... Line 582...
582
			$result["status"]="false";
582
			$result["status"]="false";
583
			
583
			
584
			#設置執行錯誤
584
			#設置執行錯誤
585
			$result["error"]=$checkArguments;
585
			$result["error"]=$checkArguments;
586
			
586
			
-
 
587
			#寫入結果到 client
-
 
588
			@fwrite($conf["socket"],json_encode($result));
-
 
589
			
-
 
590
			#關閉跟 client 的連線
-
 
591
			@fclose($conf["socket"]);
-
 
592
			
587
			#回傳結果
593
			#回傳結果
588
			return $result;
594
			return $result;
589
		
595
		
590
			}#if end
596
			}#if end
591
			
597
			
Line 596... Line 602...
596
			$result["status"]="false";
602
			$result["status"]="false";
597
			
603
			
598
			#設置執行錯誤
604
			#設置執行錯誤
599
			$result["error"]=$checkArguments;
605
			$result["error"]=$checkArguments;
600
			
606
			
-
 
607
			#寫入結果到 client
-
 
608
			@fwrite($conf["socket"],json_encode($result));
-
 
609
			
-
 
610
			#關閉跟 client 的連線
-
 
611
			@fclose($conf["socket"]);
-
 
612
			
601
			#回傳結果
613
			#回傳結果
602
			return $result;
614
			return $result;
603
		
615
		
604
			}#if end
616
			}#if end
605
		
617
		
Line 672... Line 684...
672
			$result["status"]="false";
684
			$result["status"]="false";
673
			
685
			
674
			#設置執行錯誤
686
			#設置執行錯誤
675
			$result["error"]=$checkArguments;
687
			$result["error"]=$checkArguments;
676
			
688
			
-
 
689
			#寫入結果到 client
-
 
690
			@fwrite($conf["socket"],json_encode($result));
-
 
691
			
-
 
692
			#關閉跟 client 的連線
-
 
693
			@fclose($conf["socket"]);
-
 
694
			
677
			#回傳結果
695
			#回傳結果
678
			return $result;
696
			return $result;
679
		
697
		
680
			}#if end
698
			}#if end
681
			
699
			
Line 686... Line 704...
686
			$result["status"]="false";
704
			$result["status"]="false";
687
			
705
			
688
			#設置執行錯誤
706
			#設置執行錯誤
689
			$result["error"]=$checkArguments;
707
			$result["error"]=$checkArguments;
690
			
708
			
-
 
709
			#寫入結果到 client
-
 
710
			@fwrite($conf["socket"],json_encode($result));
-
 
711
			
-
 
712
			#關閉跟 client 的連線
-
 
713
			@fclose($conf["socket"]);
-
 
714
			
691
			#回傳結果
715
			#回傳結果
692
			return $result;
716
			return $result;
693
		
717
		
694
			}#if end
718
			}#if end
695
		
719
		
696
		#取得 request data 的參考
720
		#取得 request data 的參考
697
		$rdata=&$conf["request"]["data"];
721
		$rdata=&$conf["request"]["data"];
698
		
722
		
-
 
723
		#debug
-
 
724
		#var_dump(__LINE__,$rdata);
-
 
725
		
699
		#判斷 action
726
		#判斷 action
700
		switch($rdata["action"]){
727
		switch($rdata["action"]){
701
		
728
		
702
			#如果是要寫入
729
			#如果是要寫入
703
			case "write":
730
			case "write":
Line 738... Line 765...
738
								$result["status"]="false";
765
								$result["status"]="false";
739
								
766
								
740
								#設置執行錯誤
767
								#設置執行錯誤
741
								$result["error"]=$uuid;
768
								$result["error"]=$uuid;
742
								
769
								
-
 
770
								#寫入結果到 client
-
 
771
								@fwrite($conf["socket"],json_encode($result));
-
 
772
								
-
 
773
								#關閉連線
-
 
774
								@fclose($conf["socket"]);
-
 
775
								
743
								#回傳結果
776
								#回傳結果
744
								return $result;
777
								return $result;
745
							
778
							
746
								}#if end
779
								}#if end
747
							
780
							
Line 766... Line 799...
766
								}#if end
799
								}#if end
767
						
800
						
768
							#新增資料並指定 id
801
							#新增資料並指定 id
769
							$conf["info"]["resource"][$uuid]=$row;
802
							$conf["info"]["resource"][$uuid]=$row;
770
							
803
							
771
							#設置新增的資料
804
							#設置要回給client的訊息
772
							$result["content"]=array("id"=>$uuid,"info"=>$row);
805
							$res=array("id"=>$uuid,"info"=>$row);
-
 
806
							
-
 
807
							#debug
-
 
808
							#var_dump(__LINE__,$res);
-
 
809
							
-
 
810
							#寫入結果到 client
-
 
811
							fwrite($conf["socket"],json_encode($res));
-
 
812
							
-
 
813
							#關閉連線
-
 
814
							fclose($conf["socket"]);
773
							
815
							
774
							#設置執行正常
816
							#設置執行正常
775
							$result["status"]="true";
817
							$result["status"]="true";
776
							
818
							
777
							#回傳結果
819
							#回傳結果
Line 819... Line 861...
819
							unset($conf["threads::proc"]);
861
							unset($conf["threads::proc"]);
820
						
862
						
821
							#如果執行異常
863
							#如果執行異常
822
							if($proc["status"]==="false"){
864
							if($proc["status"]==="false"){
823
							
865
							
824
								#設置跳過,不適用
866
								#設置執行異常識別
825
								$result["status"]="continue";
867
								$result["status"]="false";
-
 
868
								
-
 
869
								#設置執行錯誤
-
 
870
								$result["error"]=$proc;
-
 
871
								
-
 
872
								#寫入結果到 client
-
 
873
								@fwrite($conf["socket"],json_encode($result));
-
 
874
								
-
 
875
								#關閉連線
-
 
876
								@fclose($conf["socket"]);
826
							
877
								
827
								#回傳結果
878
								#回傳結果
828
								return $result;
879
								return $result;
829
							
880
							
830
								}#if end
881
								}#if end
831
							
882
							
Line 850... Line 901...
850
							unset($conf["threads::proc_update"]);
901
							unset($conf["threads::proc_update"]);
851
							
902
							
852
							#如果執行異常
903
							#如果執行異常
853
							if($proc_update["status"]==="false"){
904
							if($proc_update["status"]==="false"){
854
							
905
							
855
								#設置跳過,不適用
906
								#設置執行異常識別
856
								$result["status"]="continue";
907
								$result["status"]="false";
-
 
908
								
-
 
909
								#設置執行錯誤
-
 
910
								$result["error"]=$proc_update;
-
 
911
								
-
 
912
								#寫入結果到 client
-
 
913
								@fwrite($conf["socket"],json_encode($result));
-
 
914
								
-
 
915
								#關閉連線
-
 
916
								@fclose($conf["socket"]);
857
							
917
								
858
								#回傳結果
918
								#回傳結果
859
								return $result;
919
								return $result;
860
							
920
							
861
								}#if end
921
								}#if end
862
							
922
							
863
							#如果proc裡面的程式執行異常
923
							#如果proc裡面的程式執行異常
864
							if($proc_update["content"]["status"]==="false"){
924
							if($proc_update["content"]["status"]==="false"){
865
							
925
							
866
								#設置跳過,不適用
926
								#設置執行異常識別
867
								$result["status"]="continue";
927
								$result["status"]="false";
-
 
928
								
-
 
929
								#設置執行錯誤
-
 
930
								$result["error"]=$proc_update;
-
 
931
								
-
 
932
								#寫入結果到 client
-
 
933
								@fwrite($conf["socket"],json_encode($result).PHP_EOL);
-
 
934
								
-
 
935
								#關閉連線
-
 
936
								@fclose($conf["socket"]);
868
							
937
								
869
								#回傳結果
938
								#回傳結果
870
								return $result;
939
								return $result;
871
							
940
								
872
								}#if end
941
								}#if end
873
								
942
								
874
							#取得要儲存的php變數
943
							#取得要儲存的php變數
875
							$value=$proc_update["content"][0];
944
							$value=$proc_update["content"][0];
876
						
945
						
Line 899... Line 968...
899
								$result["status"]="false";
968
								$result["status"]="false";
900
								
969
								
901
								#設置執行錯誤
970
								#設置執行錯誤
902
								$result["error"]=$uuid;
971
								$result["error"]=$uuid;
903
								
972
								
-
 
973
								#寫入結果到 client
-
 
974
								@fwrite($conf["socket"],json_encode($result));
-
 
975
								
-
 
976
								#關閉連線
-
 
977
								@fclose($conf["socket"]);
-
 
978
								
904
								#回傳結果
979
								#回傳結果
905
								return $result;
980
								return $result;
906
							
981
							
907
								}#if end
982
								}#if end
908
							
983
							
Line 928... Line 1003...
928
								$row["life"]=time()+$conf["info"]["defaultLifeTime"];
1003
								$row["life"]=time()+$conf["info"]["defaultLifeTime"];
929
							
1004
							
930
								}#if end
1005
								}#if end
931
							
1006
							
932
							#設置新增的資料
1007
							#設置新增的資料
933
							$result["content"]=array("id"=>$uuid,"info"=>$row);
1008
							$msg=array("id"=>$uuid,"info"=>$row);
-
 
1009
							
-
 
1010
							#設置為 json 字串
-
 
1011
							$msg=json_encode($msg);
934
							
1012
							
935
							#設置執行正常
1013
							#設置執行正常
936
							$result["status"]="true";
1014
							$result["status"]="true";
937
							
1015
							
-
 
1016
							#寫入結果到 client
-
 
1017
							@fwrite($conf["socket"],$msg);
-
 
1018
							
-
 
1019
							#關閉連線
-
 
1020
							@fclose($conf["socket"]);
-
 
1021
							
938
							#回傳結果
1022
							#回傳結果
939
							return $result;
1023
							return $result;
940
						
1024
						
941
							#跳出 switch
1025
							#跳出 switch
942
							break 2;
1026
							break 2;
Line 948... Line 1032...
948
							$result["error"][]="unsupported type:".$rdata["type"];
1032
							$result["error"][]="unsupported type:".$rdata["type"];
949
							
1033
							
950
							#設置執行異常
1034
							#設置執行異常
951
							$result["status"]="false";
1035
							$result["status"]="false";
952
							
1036
							
-
 
1037
							#寫入結果到 client
-
 
1038
							@fwrite($conf["socket"],json_encode($result["content"]));
-
 
1039
							
-
 
1040
							#關閉連線
-
 
1041
							@fclose($conf["socket"]);
-
 
1042
							
953
							#回傳結果
1043
							#回傳結果
954
							return $result;
1044
							return $result;
955
					
1045
					
956
						}#switch end
1046
						}#switch end
957
						
1047
						
Line 1076... Line 1166...
1076
												unset($conf["threads::proc"]);
1166
												unset($conf["threads::proc"]);
1077
											
1167
											
1078
												#如果執行異常
1168
												#如果執行異常
1079
												if($proc["status"]==="false"){
1169
												if($proc["status"]==="false"){
1080
												
1170
												
1081
													#設置跳過,不適用
1171
													#設置異常
1082
													$result["status"]="continue";
1172
													$result["status"]="false";
-
 
1173
													
-
 
1174
													#設置錯誤
-
 
1175
													$result["error"]=$proc;
1083
												
1176
													
1084
													#回傳結果
1177
													#寫入結果到 client
-
 
1178
													@fwrite($conf["socket"],json_encode($result));
-
 
1179
													
1085
													return $result;
1180
													#關閉連線
-
 
1181
													@fclose($conf["socket"]);
1086
												
1182
												
1087
													}#if end
1183
													}#if end
1088
												
1184
												
1089
												#函式說明:
1185
												#函式說明:
1090
												#更新透過proc執行的多程序資訊.
1186
												#更新透過proc執行的多程序資訊.
Line 1107... Line 1203...
1107
												unset($conf["threads::proc_update"]);
1203
												unset($conf["threads::proc_update"]);
1108
												
1204
												
1109
												#如果執行異常
1205
												#如果執行異常
1110
												if($proc_update["status"]==="false"){
1206
												if($proc_update["status"]==="false"){
1111
												
1207
												
1112
													#設置跳過,不適用
1208
													#設置異常
1113
													$result["status"]="continue";
1209
													$result["status"]="false";
-
 
1210
													
-
 
1211
													#設置錯誤
-
 
1212
													$result["error"]=$proc_update;
1114
												
1213
													
1115
													#回傳結果
1214
													#寫入結果到 client
-
 
1215
													@fwrite($conf["socket"],json_encode($result));
-
 
1216
													
1116
													return $result;
1217
													#關閉連線
-
 
1218
													@fclose($conf["socket"]);
1117
												
1219
												
1118
													}#if end
1220
													}#if end
1119
												
1221
												
1120
												#如果proc裡面的程式執行異常
1222
												#如果proc裡面的程式執行異常
1121
												if($proc_update["content"]["status"]==="false"){
1223
												if($proc_update["content"]["status"]==="false"){
1122
												
1224
												
1123
													#設置跳過,不適用
1225
													#設置異常
1124
													$result["status"]="continue";
1226
													$result["status"]="false";
-
 
1227
													
-
 
1228
													#設置錯誤
-
 
1229
													$result["error"]=$proc_update;
1125
												
1230
													
1126
													#回傳結果
1231
													#寫入結果到 client
-
 
1232
													@fwrite($conf["socket"],json_encode($result));
-
 
1233
													
1127
													return $result;
1234
													#關閉連線
-
 
1235
													@fclose($conf["socket"]);
1128
												
1236
												
1129
													}#if end
1237
													}#if end
1130
													
1238
													
1131
												#取得要儲存的php變數
1239
												#取得要儲存的php變數
1132
												$value=$proc_update["content"][0];
1240
												$value=$proc_update["content"][0];
Line 1161... Line 1269...
1161
												$result["error"][]="unsupported type:".$rdata["type"];
1269
												$result["error"][]="unsupported type:".$rdata["type"];
1162
												
1270
												
1163
												#設置執行異常
1271
												#設置執行異常
1164
												$result["status"]="false";
1272
												$result["status"]="false";
1165
												
1273
												
-
 
1274
												#寫入結果到 client
-
 
1275
												@fwrite($conf["socket"],json_encode($result));
-
 
1276
												
-
 
1277
												#關閉連線
-
 
1278
												@fclose($conf["socket"]);
-
 
1279
												
1166
												#回傳結果
1280
												#回傳結果
1167
												return $result;
1281
												return $result;
1168
										
1282
										
1169
											}#switch end
1283
											}#switch end
1170
									
1284
									
1171
										#設置結果
1285
										#設置結果
1172
										$result["content"]=array("id"=>$idInM,"value"=>$conf["info"]["resource"][$valInM]);
1286
										$msg=array("id"=>$idInM,"value"=>$conf["info"]["resource"][$valInM]);
-
 
1287
										
-
 
1288
										#轉換成json字串
-
 
1289
										$msg=json_encode($msg);
1173
										
1290
										
1174
										#設置執行正常
1291
										#設置執行正常
1175
										$result["status"]="true";
1292
										$result["status"]="true";
-
 
1293
										
-
 
1294
										#寫入結果到 client
-
 
1295
										@fwrite($conf["socket"],$msg);
-
 
1296
										
-
 
1297
										#關閉連線
-
 
1298
										@fclose($conf["socket"]);
1176
									
1299
									
1177
										#回傳結果
1300
										#回傳結果
1178
										return $result;
1301
										return $result;
1179
									
1302
									
1180
										}#if end
1303
										}#if end
1181
								
1304
								
1182
									}#foreach end
1305
									}#foreach end
1183
									
1306
									
1184
								#執行到這邊代表沒有符合條件的記錄
1307
								#執行到這邊代表沒有符合條件的記錄
1185
								
1308
								
-
 
1309
								#設置預設要回的訊息為空陣列
-
 
1310
								$msg=array();
-
 
1311
								
1186
								#設置結果為null
1312
								#轉換成json字串
1187
								$result["content"]=null;
1313
								$msg=json_encode($msg);
1188
							
1314
							
1189
								#設置執行正常
1315
								#設置執行正常
1190
								$result["status"]="true";
1316
								$result["status"]="true";
-
 
1317
								
-
 
1318
								#寫入結果到 client
-
 
1319
								@fwrite($conf["socket"],json_encode($msg));
-
 
1320
								
-
 
1321
								#關閉連線
-
 
1322
								@fclose($conf["socket"]);
1191
							
1323
							
1192
								#回傳結果
1324
								#回傳結果
1193
								return $result;
1325
								return $result;
1194
							
1326
							
1195
								#跳出 switch
1327
								#跳出 switch
Line 1310... Line 1442...
1310
												unset($conf["threads::proc"]);
1442
												unset($conf["threads::proc"]);
1311
											
1443
											
1312
												#如果執行異常
1444
												#如果執行異常
1313
												if($proc["status"]==="false"){
1445
												if($proc["status"]==="false"){
1314
												
1446
												
1315
													#設置跳過,不適用
1447
													#設置異常
1316
													$result["status"]="continue";
1448
													$result["status"]="false";
-
 
1449
													
-
 
1450
													#設置錯誤
-
 
1451
													$result["error"]=$proc;
1317
												
1452
													
1318
													#回傳結果
1453
													#寫入結果到 client
-
 
1454
													@fwrite($conf["socket"],json_encode($result));
-
 
1455
													
1319
													return $result;
1456
													#關閉連線
-
 
1457
													@fclose($conf["socket"]);
1320
												
1458
												
1321
													}#if end
1459
													}#if end
1322
												
1460
												
1323
												#函式說明:
1461
												#函式說明:
1324
												#更新透過proc執行的多程序資訊.
1462
												#更新透過proc執行的多程序資訊.
Line 1341... Line 1479...
1341
												unset($conf["threads::proc_update"]);
1479
												unset($conf["threads::proc_update"]);
1342
												
1480
												
1343
												#如果執行異常
1481
												#如果執行異常
1344
												if($proc_update["status"]==="false"){
1482
												if($proc_update["status"]==="false"){
1345
												
1483
												
1346
													#設置跳過,不適用
1484
													#設置異常
1347
													$result["status"]="continue";
1485
													$result["status"]="false";
-
 
1486
													
-
 
1487
													#設置錯誤
-
 
1488
													$result["error"]=$proc_update;
-
 
1489
													
-
 
1490
													#寫入結果到 client
-
 
1491
													@fwrite($conf["socket"],json_encode($result));
-
 
1492
													
-
 
1493
													#關閉連線
-
 
1494
													@fclose($conf["socket"]);
1348
												
1495
													
1349
													#回傳結果
1496
													#回傳結果
1350
													return $result;
1497
													return $result;
1351
												
1498
												
1352
													}#if end
1499
													}#if end
1353
												
1500
												
1354
												#如果proc裡面的程式執行異常
1501
												#如果proc裡面的程式執行異常
1355
												if($proc_update["content"]["status"]==="false"){
1502
												if($proc_update["content"]["status"]==="false"){
1356
												
1503
												
1357
													#設置跳過,不適用
1504
													#設置異常
1358
													$result["status"]="continue";
1505
													$result["status"]="false";
-
 
1506
													
-
 
1507
													#設置錯誤
-
 
1508
													$result["error"]=$proc_update;
-
 
1509
												
-
 
1510
													#寫入結果到 client
-
 
1511
													@fwrite($conf["socket"],json_encode($result));
-
 
1512
													
-
 
1513
													#關閉連線
-
 
1514
													@fclose($conf["socket"]);
1359
												
1515
												
1360
													#回傳結果
1516
													#回傳結果
1361
													return $result;
1517
													return $result;
1362
												
1518
												
1363
													}#if end
1519
													}#if end
Line 1395... Line 1551...
1395
												$result["error"][]="unsupported type:".$rdata["type"];
1551
												$result["error"][]="unsupported type:".$rdata["type"];
1396
												
1552
												
1397
												#設置執行異常
1553
												#設置執行異常
1398
												$result["status"]="false";
1554
												$result["status"]="false";
1399
												
1555
												
-
 
1556
												#寫入結果到 client
-
 
1557
												@fwrite($conf["socket"],json_encode($result));
-
 
1558
												
-
 
1559
												#關閉連線
-
 
1560
												@fclose($conf["socket"]);
-
 
1561
												
1400
												#回傳結果
1562
												#回傳結果
1401
												return $result;
1563
												return $result;
1402
											
1564
											
1403
											}#switch end
1565
											}#switch end
1404
									
1566
									
Line 1406... Line 1568...
1406
								
1568
								
1407
									}#foreach end
1569
									}#foreach end
1408
									
1570
									
1409
								#執行到這邊代表沒有符合條件的記錄
1571
								#執行到這邊代表沒有符合條件的記錄
1410
								
1572
								
1411
								#設置結果為null
1573
								#設置結果為空陣列 
-
 
1574
								$msg=array();
-
 
1575
								
-
 
1576
								#變成json字串
1412
								$result["content"]=null;
1577
								$msg=json_encode($msg);
1413
							
1578
							
1414
								#設置執行正常
1579
								#設置執行正常
1415
								$result["status"]="true";
1580
								$result["status"]="true";
-
 
1581
								
-
 
1582
								#寫入結果到 client
-
 
1583
								@fwrite($conf["socket"],json_encode($msg));
-
 
1584
								
-
 
1585
								#關閉連線
-
 
1586
								@fclose($conf["socket"]);
1416
							
1587
							
1417
								#回傳結果
1588
								#回傳結果
1418
								return $result;
1589
								return $result;
1419
							
1590
							
1420
								#跳出 switch
1591
								#跳出 switch
Line 1495... Line 1666...
1495
												if($currentType==="proc"){
1666
												if($currentType==="proc"){
1496
												
1667
												
1497
													#pid
1668
													#pid
1498
													#$valInM["proc_get_status"]["pid"];
1669
													#$valInM["proc_get_status"]["pid"];
1499
													
1670
													
1500
													#關閉程序
1671
													#關閉既有程序
1501
													proc_close($valInM["process"]);
1672
													proc_close($valInM["process"]);
1502
												
1673
												
1503
													}#if end
1674
													}#if end
1504
													
1675
													
1505
												#取得要運行的程式與參數
1676
												#取得要運行的程式與參數
Line 1538... Line 1709...
1538
												unset($conf["threads::proc"]);
1709
												unset($conf["threads::proc"]);
1539
											
1710
											
1540
												#如果執行異常
1711
												#如果執行異常
1541
												if($proc["status"]==="false"){
1712
												if($proc["status"]==="false"){
1542
												
1713
												
1543
													#設置跳過,不適用
1714
													#設置異常
1544
													$result["status"]="continue";
1715
													$result["status"]="false";
-
 
1716
												
-
 
1717
													#設置錯誤訊息
-
 
1718
													$result["error"]=$proc;
-
 
1719
												
-
 
1720
													#寫入結果到 client
-
 
1721
													@fwrite($conf["socket"],json_encode($result).PHP_EOL);
-
 
1722
													
-
 
1723
													#關閉連線
-
 
1724
													@fclose($conf["socket"]);
1545
												
1725
												
1546
													#回傳結果
1726
													#回傳結果
1547
													return $result;
1727
													return $result;
1548
												
1728
												
1549
													}#if end
1729
													}#if end
Line 1569... Line 1749...
1569
												unset($conf["threads::proc_update"]);
1749
												unset($conf["threads::proc_update"]);
1570
												
1750
												
1571
												#如果執行異常
1751
												#如果執行異常
1572
												if($proc_update["status"]==="false"){
1752
												if($proc_update["status"]==="false"){
1573
												
1753
												
1574
													#設置跳過,不適用
1754
													#設置異常
1575
													$result["status"]="continue";
1755
													$result["status"]="false";
-
 
1756
 
-
 
1757
													#設置異常錯誤
-
 
1758
													$result["error"]=$proc_update;
-
 
1759
												
-
 
1760
													#寫入結果到 client
-
 
1761
													@fwrite($conf["socket"],json_encode($result).PHP_EOL);
-
 
1762
													
-
 
1763
													#關閉連線
-
 
1764
													@fclose($conf["socket"]);
1576
												
1765
												
1577
													#回傳結果
1766
													#回傳結果
1578
													return $result;
1767
													return $result;
1579
												
1768
												
1580
													}#if end
1769
													}#if end
1581
												
1770
												
1582
												#如果proc裡面的程式執行異常
1771
												#如果proc裡面的程式執行異常
1583
												if($proc_update["content"][0]["status"]==="false"){
1772
												if($proc_update["content"][0]["status"]==="false"){
1584
												
1773
												
1585
													#設置跳過,不適用
1774
													#設置異常
1586
													$result["status"]="continue";
1775
													$result["status"]="false";
-
 
1776
 
-
 
1777
													#設置異常錯誤
-
 
1778
													$result["error"]=$proc_update;
-
 
1779
												
-
 
1780
													#寫入結果到 client
-
 
1781
													@fwrite($conf["socket"],json_encode($result).PHP_EOL);
-
 
1782
													
-
 
1783
													#關閉連線
-
 
1784
													@fclose($conf["socket"]);
1587
												
1785
												
1588
													#回傳結果
1786
													#回傳結果
1589
													return $result;
1787
													return $result;
1590
												
1788
												
1591
													}#if end
1789
													}#if end
Line 1623... Line 1821...
1623
												$result["error"][]="unsupported type:".$rdata["type"];
1821
												$result["error"][]="unsupported type:".$rdata["type"];
1624
												
1822
												
1625
												#設置執行異常
1823
												#設置執行異常
1626
												$result["status"]="false";
1824
												$result["status"]="false";
1627
												
1825
												
-
 
1826
												#寫入結果到 client
-
 
1827
												@fwrite($conf["socket"],json_encode($result));
-
 
1828
												
-
 
1829
												#關閉連線
-
 
1830
												@fclose($conf["socket"]);
-
 
1831
												
1628
												#回傳結果
1832
												#回傳結果
1629
												return $result;
1833
												return $result;
1630
											
1834
											
1631
											}#switch end
1835
											}#switch end
1632
										
1836
										
1633
										}#if end
1837
										}#if end
1634
								
1838
								
1635
									}#foreach end
1839
									}#foreach end
1636
									
1840
									
1637
								#執行到這邊代表沒有符合條件的記錄
1841
								#執行到這邊代表沒有符合條件的記錄,可供寫入/更新.
1638
								
1842
								
1639
								#設置結果為null
1843
								#設置結果為空陣列
-
 
1844
								$msg=array();
-
 
1845
								
-
 
1846
								#變成json字串
1640
								$result["content"]=null;
1847
								$msg=json_encode($msg);
1641
							
1848
							
1642
								#設置執行正常
1849
								#設置執行正常
1643
								$result["status"]="true";
1850
								$result["status"]="true";
1644
							
1851
							
-
 
1852
								#寫入結果到 client
-
 
1853
								@fwrite($conf["socket"],$msg);
-
 
1854
								
-
 
1855
								#關閉連線
-
 
1856
								@fclose($conf["socket"]);
-
 
1857
							
1645
								#回傳結果
1858
								#回傳結果
1646
								return $result;
1859
								return $result;
1647
							
1860
							
1648
								#跳出 switch
1861
								#跳出 switch
1649
								break;
1862
								break;
Line 1655... Line 1868...
1655
								$result["error"][]="unsupported column:".$key;
1868
								$result["error"][]="unsupported column:".$key;
1656
								
1869
								
1657
								#設置執行異常
1870
								#設置執行異常
1658
								$result["status"]="false";
1871
								$result["status"]="false";
1659
								
1872
								
-
 
1873
								#寫入結果到 client
-
 
1874
								@fwrite($conf["socket"],json_encode($result));
-
 
1875
								
-
 
1876
								#關閉連線
-
 
1877
								@fclose($conf["socket"]);
-
 
1878
								
1660
								#回傳結果
1879
								#回傳結果
1661
								return $result;
1880
								return $result;
1662
						
1881
						
1663
							}#switch end
1882
							}#switch end
1664
						
1883
						
Line 1670... Line 1889...
1670
				break;
1889
				break;
1671
				
1890
				
1672
			#如果是 read
1891
			#如果是 read
1673
			case "read":
1892
			case "read":
1674
			
1893
			
-
 
1894
				#debug
-
 
1895
				#var_dump(__LINE__,$rdata);
-
 
1896
			
1675
				#如果是空的,亦即沒有條件,代表要取得全部.
1897
				#如果是空的,亦即沒有條件,代表要取得全部.
1676
				if(empty($rdata["condition"])){
1898
				if(empty($rdata["condition"])){
1677
				
1899
				
-
 
1900
					#初始化要回的訊息
-
 
1901
					$msg=array();
-
 
1902
				
1678
					#針對每筆記錄
1903
					#針對每筆記錄
1679
					foreach($conf["info"]["resource"] as $idInM => $valInM){
1904
					foreach($conf["info"]["resource"] as $idInM => $valInM){
1680
					
1905
					
1681
						#設置要取得的內容
1906
						#設置要取得的內容
1682
						$result["content"][]=array("id"=>$idInM,"value"=>$valInM);
1907
						$msg[]=array("id"=>$idInM,"value"=>$valInM);
1683
					
1908
					
1684
						}#foreach end
1909
						}#foreach end
-
 
1910
					
-
 
1911
					#設置成json字串
-
 
1912
					$msg=json_encode($msg);	
1685
						
1913
						
1686
					#設置執行正常
1914
					#設置執行正常
1687
					$result["status"]="true";
1915
					$result["status"]="true";
-
 
1916
					
-
 
1917
					#寫入結果到 client
-
 
1918
					$fwrite=@fwrite($conf["socket"],$msg);
-
 
1919
					
-
 
1920
					#debug
-
 
1921
					var_dump(__LINE__,$fwrite,$msg);
-
 
1922
					
-
 
1923
					#關閉連線
-
 
1924
					@fclose($conf["socket"]);
1688
				
1925
				
1689
					#回傳結果
1926
					#回傳結果
1690
					return $result;
1927
					return $result;
1691
				
1928
				
1692
					}#if end
1929
					}#if end
Line 1712... Line 1949...
1712
										#設置結果
1949
										#設置結果
1713
										$result["content"][]=array("id"=>$idInM,"value"=>$valInM);
1950
										$result["content"][]=array("id"=>$idInM,"value"=>$valInM);
1714
										
1951
										
1715
										#設置執行正常
1952
										#設置執行正常
1716
										$result["status"]="true";
1953
										$result["status"]="true";
-
 
1954
										
-
 
1955
										#寫入結果到 client
-
 
1956
										@fwrite($conf["socket"],json_encode($result).PHP_EOL);
-
 
1957
										
-
 
1958
										#關閉連線
-
 
1959
										@fclose($conf["socket"]);
1717
									
1960
									
1718
										#回傳結果
1961
										#回傳結果
1719
										return $result;
1962
										return $result;
1720
									
1963
									
1721
										}#if end
1964
										}#if end
Line 1727... Line 1970...
1727
								#設置結果為null
1970
								#設置結果為null
1728
								$result["content"]=null;
1971
								$result["content"]=null;
1729
							
1972
							
1730
								#設置執行正常
1973
								#設置執行正常
1731
								$result["status"]="true";
1974
								$result["status"]="true";
-
 
1975
								
-
 
1976
								#寫入結果到 client
-
 
1977
								@fwrite($conf["socket"],json_encode($result).PHP_EOL);
-
 
1978
								
-
 
1979
								#關閉連線
-
 
1980
								@fclose($conf["socket"]);
1732
							
1981
							
1733
								#回傳結果
1982
								#回傳結果
1734
								return $result;
1983
								return $result;
1735
							
1984
							
1736
								#跳出 switch
1985
								#跳出 switch
Line 1757... Line 2006...
1757
										$result["content"]=array("id"=>$idInM,"value"=>$valInM);
2006
										$result["content"]=array("id"=>$idInM,"value"=>$valInM);
1758
										
2007
										
1759
										#設置執行結果
2008
										#設置執行結果
1760
										$result["status"]="true";
2009
										$result["status"]="true";
1761
										
2010
										
-
 
2011
										#寫入結果到 client
-
 
2012
										@fwrite($conf["socket"],json_encode($result).PHP_EOL);
-
 
2013
										
-
 
2014
										#關閉連線
-
 
2015
										@fclose($conf["socket"]);
-
 
2016
										
1762
										#回傳結果
2017
										#回傳結果
1763
										return $result;
2018
										return $result;
1764
										
2019
										
1765
										}#if end
2020
										}#if end
1766
								
2021
								
Line 1771... Line 2026...
1771
								#設置結果為null
2026
								#設置結果為null
1772
								$result["content"]=null;
2027
								$result["content"]=null;
1773
							
2028
							
1774
								#設置執行正常
2029
								#設置執行正常
1775
								$result["status"]="true";
2030
								$result["status"]="true";
-
 
2031
								
-
 
2032
								#寫入結果到 client
-
 
2033
								@fwrite($conf["socket"],json_encode($result).PHP_EOL);
-
 
2034
								
-
 
2035
								#關閉連線
-
 
2036
								@fclose($conf["socket"]);
1776
							
2037
							
1777
								#回傳結果
2038
								#回傳結果
1778
								return $result;
2039
								return $result;
1779
							
2040
							
1780
								#跳出 switch
2041
								#跳出 switch
Line 1804... Line 2065...
1804
										$result["content"]=array("id"=>$idInM,"value"=>$valInM);
2065
										$result["content"]=array("id"=>$idInM,"value"=>$valInM);
1805
										
2066
										
1806
										#設置執行結果
2067
										#設置執行結果
1807
										$result["status"]="true";
2068
										$result["status"]="true";
1808
										
2069
										
-
 
2070
										#寫入結果到 client
-
 
2071
										@fwrite($conf["socket"],json_encode($result).PHP_EOL);
-
 
2072
										
-
 
2073
										#關閉連線
-
 
2074
										@fclose($conf["socket"]);
-
 
2075
										
1809
										#回傳結果
2076
										#回傳結果
1810
										return $result;
2077
										return $result;
1811
										
2078
										
1812
										}#if end
2079
										}#if end
1813
								
2080
								
Line 1818... Line 2085...
1818
								#設置結果為null
2085
								#設置結果為null
1819
								$result["content"]=null;
2086
								$result["content"]=null;
1820
							
2087
							
1821
								#設置執行正常
2088
								#設置執行正常
1822
								$result["status"]="true";
2089
								$result["status"]="true";
-
 
2090
								
-
 
2091
								#寫入結果到 client
-
 
2092
								@fwrite($conf["socket"],json_encode($result).PHP_EOL);
-
 
2093
								
-
 
2094
								#關閉連線
-
 
2095
								@fclose($conf["socket"]);
1823
							
2096
							
1824
								#回傳結果
2097
								#回傳結果
1825
								return $result;
2098
								return $result;
1826
							
2099
							
1827
								#跳出 switch
2100
								#跳出 switch
Line 1834... Line 2107...
1834
								$result["error"][]="unsupported column:".$key;
2107
								$result["error"][]="unsupported column:".$key;
1835
								
2108
								
1836
								#設置執行異常
2109
								#設置執行異常
1837
								$result["status"]="false";
2110
								$result["status"]="false";
1838
								
2111
								
-
 
2112
								#寫入結果到 client
-
 
2113
								@fwrite($conf["socket"],json_encode($result).PHP_EOL);
-
 
2114
								
-
 
2115
								#關閉連線
-
 
2116
								@fclose($conf["socket"]);
-
 
2117
								
1839
								#回傳結果
2118
								#回傳結果
1840
								return $result;
2119
								return $result;
1841
						
2120
						
1842
							}#switch end
2121
							}#switch end
1843
					
2122
					
Line 1855... Line 2134...
1855
				$result["error"][]="unsupported action:".$conf["request"]["action"];
2134
				$result["error"][]="unsupported action:".$conf["request"]["action"];
1856
				
2135
				
1857
				#設置執行異常
2136
				#設置執行異常
1858
				$result["status"]="false";
2137
				$result["status"]="false";
1859
				
2138
				
-
 
2139
				#寫入結果到 client
-
 
2140
				@fwrite($conf["socket"],json_encode($result).PHP_EOL);
-
 
2141
				
-
 
2142
				#關閉連線
-
 
2143
				@fclose($conf["socket"]);
-
 
2144
				
1860
				#回傳結果
2145
				#回傳結果
1861
				return $result;
2146
				return $result;
1862
		
2147
		
1863
			}#switch end
2148
			}#switch end
1864
		
2149
		
Line 2391... Line 2676...
2391
	#$conf["condition"]=array();
2676
	#$conf["condition"]=array();
2392
	#參考資料:
2677
	#參考資料:
2393
	#無.
2678
	#無.
2394
	#備註:
2679
	#備註:
2395
	#僅能在命令列環境下運行.
2680
	#僅能在命令列環境下運行.
2396
	#若於proc中運行,則不會因為無法存取socket而報錯並結束執行.
-
 
2397
	*/
2681
	*/
2398
	public static function client(&$conf){
2682
	public static function client(&$conf){
2399
	
2683
	
2400
		#初始化要回傳的結果
2684
		#初始化要回傳的結果
2401
		$result=array();
2685
		$result=array();