index.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. // Init
  3. error_reporting(null);
  4. ob_start();
  5. session_start();
  6. include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
  7. // Check token
  8. verify_csrf($_GET);
  9. // If the stored reset token matches the current request one it means that we need
  10. // to prevent the action because the browser automatically reloaded the page when
  11. // the server turned on. This will prevent duplicate restarts.
  12. $reset_token_dir = '/var/tmp/';
  13. if (isset($_GET['system_reset_token']) && is_numeric($_GET['system_reset_token'])) {
  14. clearstatcache();
  15. $reset_token_file = $reset_token_dir . 'hst_reset_' . $_GET['system_reset_token'];
  16. if (file_exists($reset_token_file)) {
  17. unlink($reset_token_file);
  18. sleep(5);
  19. header('location: /list/server/');
  20. exit();
  21. }
  22. if ($_SESSION['userContext'] === 'admin') {
  23. if (!empty($_GET['hostname'])) {
  24. touch($reset_token_file);
  25. $_SESSION['error_msg'] = _('The system is going down for reboot NOW!');
  26. exec(HESTIA_CMD . "v-restart-system yes", $output, $return_var);
  27. }
  28. unset($output);
  29. }
  30. }
  31. header("Location: /list/server/");
  32. exit();