|
@@ -0,0 +1,43 @@
|
|
|
+<?php
|
|
|
+ // 設置資料類型 json,編碼格式 utf-8
|
|
|
+ header('Content-Type: application/json; charset=UTF-8');
|
|
|
+
|
|
|
+ // 判斷如果是 GET 請求,則進行搜尋;如果是 POST 請求,則進行新建
|
|
|
+ // $_SERVER['REQUEST_METHOD'] 返回訪問頁面使用的請求方法
|
|
|
+ if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
|
|
+ create();
|
|
|
+ } else if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
|
|
+ create();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 新建員工
|
|
|
+ function create() {
|
|
|
+ if($_REQUEST['opt']!=0 && $_REQUEST['opt']!=1 && $_REQUEST['opt']!=2 && $_REQUEST['opt']!=3 && $_REQUEST['opt']!=4){
|
|
|
+ echo "parameter error, opt should be integer between 0~4";
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+ chdir("/root");
|
|
|
+ exec("'./WebService' 'query'",$output,$return_var);
|
|
|
+ if(count($output)==0){
|
|
|
+// echo '<script>alert("Something went wrong on machine");</script>';
|
|
|
+ echo "Something went wrong on machine";
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+ if(trim($output[0])=="InitShareMemory Error"){
|
|
|
+// echo '<script>alert("InitShareMemory Error");</script>';
|
|
|
+ echo "InitShareMemory Error";
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+ $obj[1] = trim($output[0]);
|
|
|
+ $obj[2] = trim($output[1]);
|
|
|
+ $obj[3] = trim($output[2]);
|
|
|
+ $obj[4] = trim($output[3]);
|
|
|
+ $obj10 = json_decode(trim($output[0]));
|
|
|
+ $obj20 = json_decode(trim($output[1]));
|
|
|
+ $obj30 = json_decode(trim($output[2]));
|
|
|
+ $obj40 = json_decode(trim($output[3]));
|
|
|
+ $arr=array($obj10,$obj20,$obj30,$obj40);
|
|
|
+ $obj[0]=json_encode($arr);
|
|
|
+ echo $obj[$_REQUEST['opt']];
|
|
|
+ }
|
|
|
+?>
|