reboot.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2018 The OGP Development Team
  6. *
  7. * http://www.opengamepanel.org/
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. */
  24. require_once('includes/lib_remote.php');
  25. function exec_ogp_module() {
  26. global $view;
  27. global $db;
  28. echo "<h2>".get_lang('reboot')."</h2>";
  29. $rhost_id = @$_REQUEST['rhost_id'];
  30. $remote_server = $db->getRemoteServer($rhost_id);
  31. $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key'], $remote_server['timeout']);
  32. $ipAndName = $remote_server['remote_server_name'] . " " . "(" . $remote_server['agent_ip'] . ")";
  33. // Confirm user wants to reboot the server
  34. if (!isset($_POST['re_check'])) {
  35. echo "<table class='center' style='width:100%;' ><tr>\n" . "<td>" . get_lang_f('confirm_reboot', $ipAndName) . "</td>" . "</tr><tr><td>" . '<form method="post" >' . "\n" . '<input type="hidden" name="rhost_id" value="' . $rhost_id . '">' . "\n" . '<button name="re_check" value="yes" >' . get_lang('yes') . "</button>\n" . '<button name="re_check" value="no" >' . get_lang('no') . "</button>\n" . "</form>\n" . "</td>\n" . "</tr>\n" . "</table><br>\n";
  36. } else if($_POST['re_check'] == "yes") {
  37. // Confirmed... so reboot the server in 10 seconds
  38. $file_info = $remote->remote_rebootnow();
  39. echo "<p>" . get_lang_f('reboot_success', $ipAndName) . "</p>";
  40. // 150 seconds should be enough for the server to come back up?
  41. $view->refresh("?m=server",150);
  42. } else if ($_POST['re_check'] == "no"){
  43. $view->refresh("?m=server",0);
  44. }
  45. }
  46. ?>