1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?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');
- // echo '<font color=#ff0000>Work directory: '.getcwd().'<br>';
- // echo 'System date/time: '.nl2br(shell_exec('date +%Y-%m-%d_%H:%M:%S')).'</font>';
- // ini_set('max_execution_time','120');
- // ini_set('max_input_time','120');
- // ini_set('post_max_size','2048M');
- // ini_set('upload_max_filesize','2048M');
- if($_POST['fw_tag']=='iso')
- {
- if ($_FILES["file"]["error"] > 0)
- {
- echo "Return Code: " . $_FILES["file"]["error"] . "<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["file"]["tmp_name"],"/mnt/".$_FILES["file"]["name"]);
- chdir("/root");
- $str_json=json_encode($json);
- exec("'./WebService' 'upgrade' '".$_FILES["file"]["name"]."'",$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');
- }
- ?>
|