12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?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() {
- // $json = json_decode(file_get_contents("charging.txt"), true);
- // $json = string[];
- // $json['MaxChargingEnergy'] = base_convert($_POST['MaxChargingEnergy'],10,16);
- // $json['MaxChargingPower'] = base_convert($_POST['MaxChargingPower'],10,16);
- // $json['MaxChargingCurrent'] = base_convert($_POST['MaxChargingCurrent'],10,16);
- // $json['MaxChargingDuration'] = base_convert($_POST['MaxChargingDuration'],10,16);
- $json['MaxChargingEnergy'] = (int)$_POST['MaxChargingEnergy'];
- $json['MaxChargingPower'] = (int)$_POST['MaxChargingPower'];
- $json['MaxChargingCurrent'] = (int)$_POST['MaxChargingCurrent'];
- $json['MaxChargingDuration'] = (int)$_POST['MaxChargingDuration'];
- $json['PhaseLossPolicy'] = $_POST['PhaseLossPolicy'];
- $json['LocalWhiteCard0'] = $_POST['LocalWhiteCard0'];
- $json['LocalWhiteCard1'] = $_POST['LocalWhiteCard1'];
- $json['LocalWhiteCard2'] = $_POST['LocalWhiteCard2'];
- $json['LocalWhiteCard3'] = $_POST['LocalWhiteCard3'];
- $json['LocalWhiteCard4'] = $_POST['LocalWhiteCard4'];
- $json['LocalWhiteCard5'] = $_POST['LocalWhiteCard5'];
- $json['LocalWhiteCard6'] = $_POST['LocalWhiteCard6'];
- $json['LocalWhiteCard7'] = $_POST['LocalWhiteCard7'];
- $json['LocalWhiteCard8'] = $_POST['LocalWhiteCard8'];
- $json['LocalWhiteCard9'] = $_POST['LocalWhiteCard9'];
- $json['CcsAuthentication'] = $_POST['CcsAuthentication'];
- $json['AcCcsChargingModel'] = $_POST['AcCcsChargingModel'];
- $json['UserId'] = $_POST['UserId'];
- $json['PresentChargingVoltage'] = $_POST['PresentChargingVoltage'];
- $json['PresentChargingCurrent'] = $_POST['PresentChargingCurrent'];
- $json['PresentChargingPower'] = $_POST['PresentChargingPower'];
- $json['PresentChargedEnergy'] = $_POST['PresentChargedEnergy'];
- $json['PresentChargedDuration'] = $_POST['PresentChargedDuration'];
- $json['RemainChargingDuration'] = $_POST['RemainChargingDuration'];
- $json['EvBatteryMaxVoltage'] = $_POST['EvBatteryMaxVoltage'];
- $json['EvBatterytargetVoltage'] = $_POST['EvBatterytargetVoltage'];
- $json['EvBatterySoc'] = $_POST['EvBatterySoc'];
- var_dump($json);echo "\n\n";
- echo json_encode($json);
- //file_put_contents("system.dat", json_encode($json));
-
- // $json = json_decode(file_get_contents("rateOnline"), true);
- // $json['isOnlineSet'] = false;
- // file_put_contents("./rateOnline", json_encode($json));
-
- ob_start();
-
- // shell_exec('sudo cp /root/wvdial_conf/wvdial.conf_'.$_POST['mDongle'].' /etc/wvdial.conf'.'> /dev/null 2>/dev/null &');
-
- // if($_POST['lan_ip']=="0")
- // shell_exec('sudo cp /root/interfaces/interfaces_static /etc/network/interfaces'.'> /dev/null 2>/dev/null &');
- // else
- // shell_exec('sudo cp /root/interfaces/interfaces_dhcp /etc/network/interfaces'.'> /dev/null 2>/dev/null &');
- // shell_exec('sudo /usr/bin/check_wifi.sh'.'> /dev/null 2>/dev/null &');
-
- //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"].'"');
- //shell_exec('sudo mv .tmate.conf /root/');
- // shell_exec('sudo /usr/bin/run_apn_set.sh /etc/wvdial.conf '.$_POST['apn_name'].' &');
- shell_exec('sync;sync;sync');
- //chdir("/home/phihong/Module_WebService");
- chdir("/root");
- $str_json=json_encode($json);var_dump($str_json);
- exec("'./WebService' '2' '".$str_json."'",$output,$return_var);
- // copy("/var/www/html/system.dat","/home/phihong/Module_WebService/system.txt");
- ob_end_clean();
- // print_r($output);
- //echo "OK";
- }
- ?>
|