set_charging_action.php 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. // 設置資料類型 json,編碼格式 utf-8
  3. header('Content-Type: application/json; charset=UTF-8');
  4. // 判斷如果是 GET 請求,則進行搜尋;如果是 POST 請求,則進行新建
  5. // $_SERVER['REQUEST_METHOD'] 返回訪問頁面使用的請求方法
  6. if ($_SERVER['REQUEST_METHOD'] == "GET") {
  7. create();
  8. } else if ($_SERVER['REQUEST_METHOD'] == "POST") {
  9. create();
  10. }
  11. // 新建員工
  12. function create() {
  13. // $json = json_decode(file_get_contents("charging.txt"), true);
  14. // $json = string[];
  15. // $json['MaxChargingEnergy'] = base_convert($_POST['MaxChargingEnergy'],10,16);
  16. // $json['MaxChargingPower'] = base_convert($_POST['MaxChargingPower'],10,16);
  17. // $json['MaxChargingCurrent'] = base_convert($_POST['MaxChargingCurrent'],10,16);
  18. // $json['MaxChargingDuration'] = base_convert($_POST['MaxChargingDuration'],10,16);
  19. $json['MaxChargingEnergy'] = (int)$_POST['MaxChargingEnergy'];
  20. $json['MaxChargingPower'] = (int)$_POST['MaxChargingPower'];
  21. $json['MaxChargingCurrent'] = (int)$_POST['MaxChargingCurrent'];
  22. $json['MaxChargingDuration'] = (int)$_POST['MaxChargingDuration'];
  23. $json['PhaseLossPolicy'] = $_POST['PhaseLossPolicy'];
  24. $json['LocalWhiteCard0'] = $_POST['LocalWhiteCard0'];
  25. $json['LocalWhiteCard1'] = $_POST['LocalWhiteCard1'];
  26. $json['LocalWhiteCard2'] = $_POST['LocalWhiteCard2'];
  27. $json['LocalWhiteCard3'] = $_POST['LocalWhiteCard3'];
  28. $json['LocalWhiteCard4'] = $_POST['LocalWhiteCard4'];
  29. $json['LocalWhiteCard5'] = $_POST['LocalWhiteCard5'];
  30. $json['LocalWhiteCard6'] = $_POST['LocalWhiteCard6'];
  31. $json['LocalWhiteCard7'] = $_POST['LocalWhiteCard7'];
  32. $json['LocalWhiteCard8'] = $_POST['LocalWhiteCard8'];
  33. $json['LocalWhiteCard9'] = $_POST['LocalWhiteCard9'];
  34. $json['CcsAuthentication'] = $_POST['CcsAuthentication'];
  35. $json['AcCcsChargingModel'] = $_POST['AcCcsChargingModel'];
  36. $json['UserId'] = $_POST['UserId'];
  37. $json['PresentChargingVoltage'] = $_POST['PresentChargingVoltage'];
  38. $json['PresentChargingCurrent'] = $_POST['PresentChargingCurrent'];
  39. $json['PresentChargingPower'] = $_POST['PresentChargingPower'];
  40. $json['PresentChargedEnergy'] = $_POST['PresentChargedEnergy'];
  41. $json['PresentChargedDuration'] = $_POST['PresentChargedDuration'];
  42. $json['RemainChargingDuration'] = $_POST['RemainChargingDuration'];
  43. $json['EvBatteryMaxVoltage'] = $_POST['EvBatteryMaxVoltage'];
  44. $json['EvBatterytargetVoltage'] = $_POST['EvBatterytargetVoltage'];
  45. $json['EvBatterySoc'] = $_POST['EvBatterySoc'];
  46. var_dump($json);echo "\n\n";
  47. echo json_encode($json);
  48. //file_put_contents("system.dat", json_encode($json));
  49. // $json = json_decode(file_get_contents("rateOnline"), true);
  50. // $json['isOnlineSet'] = false;
  51. // file_put_contents("./rateOnline", json_encode($json));
  52. ob_start();
  53. // shell_exec('sudo cp /root/wvdial_conf/wvdial.conf_'.$_POST['mDongle'].' /etc/wvdial.conf'.'> /dev/null 2>/dev/null &');
  54. // if($_POST['lan_ip']=="0")
  55. // shell_exec('sudo cp /root/interfaces/interfaces_static /etc/network/interfaces'.'> /dev/null 2>/dev/null &');
  56. // else
  57. // shell_exec('sudo cp /root/interfaces/interfaces_dhcp /etc/network/interfaces'.'> /dev/null 2>/dev/null &');
  58. // shell_exec('sudo /usr/bin/check_wifi.sh'.'> /dev/null 2>/dev/null &');
  59. //file_put_contents(".tmate.conf", 'set-option -g tmate-webhook-url "http://folus.no-ip.org:8090/tmate_update_payload.php"'."\n".'set-option -g tmate-webhook-userdata "'.$_POST["new_id"].'"');
  60. //shell_exec('sudo mv .tmate.conf /root/');
  61. // shell_exec('sudo /usr/bin/run_apn_set.sh /etc/wvdial.conf '.$_POST['apn_name'].' &');
  62. shell_exec('sync;sync;sync');
  63. //chdir("/home/phihong/Module_WebService");
  64. chdir("/root");
  65. $str_json=json_encode($json);var_dump($str_json);
  66. exec("'./WebService' '2' '".$str_json."'",$output,$return_var);
  67. // copy("/var/www/html/system.dat","/home/phihong/Module_WebService/system.txt");
  68. ob_end_clean();
  69. // print_r($output);
  70. //echo "OK";
  71. }
  72. ?>