123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?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() {
- include 'lang.php';
- $lang = new Lang;
- $lang->getLang();
- $message = $lang->showWord("message_upgrade");
- chdir('/root');
- // if($_POST['fw_tag']=='iso')
- // {
- exec("rm /mnt/*.zip");
- $fileCount = count($_FILES['files']['name']);
- for ($i = 0; $i < $fileCount; $i++) {
- if ($_FILES["files"]["error"][$i] > 0)
- {
- echo "Return Code: " . $_FILES["files"]["error"][$i] . "<br />";
- }
- else
- {
- // echo "Upload: " . $_FILES["file"]["name"] . "<br />";
- // echo "Type: " . $_FILES["file"]["type"] . "<br />";
- // echo "Size: " . ($_FILES["file"]["size"]) . " <br />";
- // echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
- // echo "<font color=#000fff>Upgrade is completed</font><br />";
- }
- //ob_start();
- sleep(1);
- move_uploaded_file($_FILES["files"]["tmp_name"][$i],"/mnt/".$_FILES["files"]["name"][$i]);
- }
- $fCount = count($_FILES['file']['name']);
- if($fCount>0){
- if ($_FILES["file"]["error"] > 0)
- {
- echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
- }
- sleep(1);
- move_uploaded_file($_FILES["file"]["tmp_name"],"/mnt/".$_FILES["file"]["name"]);
- }
- chdir("/root");
- exec("'./WebService' 'upgrade' '".$_FILES["files"]["name"][0]."'",$output,$return_var);
- // echo 'Result:'.json_decode(trim($output[0]))->{'Result'}.' Message:'.json_decode(trim($output[0]))->{'Message'};
- echo '<font color=#ff0000>'.json_decode(trim($output[0]))->{'Message'}.'</font>';
- //printf($output);
- // }
- shell_exec('sync;sync;sync');
- }
- ?>
|