index.php 1.1 KB

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