upgrade_iso_action.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. include 'lang.php';
  14. $lang = new Lang;
  15. $lang->getLang();
  16. $message = $lang->showWord("message_upgrade");
  17. chdir('/root');
  18. // echo '<font color=#ff0000>Work directory: '.getcwd().'<br>';
  19. // echo 'System date/time: '.nl2br(shell_exec('date +%Y-%m-%d_%H:%M:%S')).'</font>';
  20. // ini_set('max_execution_time','120');
  21. // ini_set('max_input_time','120');
  22. // ini_set('post_max_size','2048M');
  23. // ini_set('upload_max_filesize','2048M');
  24. if($_POST['fw_tag']=='iso')
  25. {
  26. if ($_FILES["file"]["error"] > 0)
  27. {
  28. echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
  29. }
  30. else
  31. {
  32. // echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  33. // echo "Type: " . $_FILES["file"]["type"] . "<br />";
  34. // echo "Size: " . ($_FILES["file"]["size"]) . " <br />";
  35. // echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
  36. // echo "<font color=#000fff>Upgrade is completed</font><br />";
  37. }
  38. //ob_start();
  39. sleep(1);
  40. move_uploaded_file($_FILES["file"]["tmp_name"],"/mnt/".$_FILES["file"]["name"]);
  41. chdir("/root");
  42. $str_json=json_encode($json);
  43. exec("'./WebService' 'upgrade' '".$_FILES["file"]["name"]."'",$output,$return_var);
  44. // echo 'Result:'.json_decode(trim($output[0]))->{'Result'}.' Message:'.json_decode(trim($output[0]))->{'Message'};
  45. echo '<font color=#ff0000>'.json_decode(trim($output[0]))->{'Message'}.'</font>';
  46. //printf($output);
  47. }
  48. shell_exec('sync;sync;sync');
  49. }
  50. ?>