index.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. if ((!isset($_GET['token'])) || ($_SESSION['token'] != $_GET['token'])) {
  9. header('location: /login/');
  10. exit();
  11. }
  12. // If the stored reset token matches the current request one it means that we need
  13. // to prevent the action because the browser automatically reloaded the page when
  14. // the server turned on. This will prevent duplicate restarts.
  15. $reset_token_dir = '/var/tmp/';
  16. if (isset($_GET['system_reset_token']) && is_numeric($_GET['system_reset_token'])) {
  17. clearstatcache();
  18. $reset_token_file = $reset_token_dir . 'hst_reset_' . $_GET['system_reset_token'];
  19. if (file_exists($reset_token_file)) {
  20. unlink($reset_token_file);
  21. sleep(5);
  22. header('location: /list/server/');
  23. exit();
  24. }
  25. if ($_SESSION['user'] == 'admin') {
  26. if (!empty($_GET['hostname'])) {
  27. touch($reset_token_file);
  28. $_SESSION['error_msg'] = 'The system is going down for reboot NOW!';
  29. exec(HESTIA_CMD . "v-restart-system yes", $output, $return_var);
  30. }
  31. unset($output);
  32. }
  33. }
  34. header("Location: /list/server/");
  35. exit();