function exec_ogp_module() { global $db; global $view; $user_id = $_GET['user_id']; $y = isset($_GET['y']) ? $_GET['y'] : ""; $user = $db->getUserById($user_id); if (empty($user)) { print_failure(get_lang_f('user_with_id_does_not_exist', $user_id)); return; } $username = $user['users_login']; if ($y !== 'y') { if (!$db->isModuleInstalled("subusers")) { echo "<p>" . get_lang_f('are_you_sure_you_want_to_delete_user', $username) . "</p>"; } else { if (!$db->isSubUser($user_id)) { echo "<p>" . get_lang_f('are_you_sure_you_want_to_delete_user', $username) . get_lang('andSubUsers') . "</p>"; } else { echo "<p>" . get_lang_f('are_you_sure_you_want_to_delete_user', $username) . "</p>"; } } echo "<p><a href=\"?m=user_admin&p=del&user_id={$user_id}&y=y\">" . get_lang('yes') . "</a> <a href=\"?m=user_admin\">" . get_lang('no') . "</a></p>"; return; } if (!$db->delUser($user_id)) { print_failure(get_lang_f('unable_to_delete_user', $username)); $view->refresh("?m=user_admin"); return; } print_success(get_lang_f('successfully_deleted_user', $username)); $db->logger(get_lang_f('successfully_deleted_user', $username)); $view->refresh("?m=user_admin"); }
function exec_ogp_module() { global $db; global $view; $group_id = $_GET['group_id']; if (!$db->isAdmin($_SESSION['user_id'])) { $result = $db->getUserGroupList($_SESSION['user_id']); foreach ($result as $row) { if ($row['group_id'] == $group_id) { $own_group = TRUE; } } } if (!$db->isAdmin($_SESSION['user_id']) && !isset($own_group)) { echo "<p class='note'>" . get_lang('not_available') . "</p>"; return; } // Delete user from group. if (isset($_GET['group_id']) && isset($_GET['user_id'])) { $group_id = trim($_GET['group_id']); $user_id = trim($_GET['user_id']); if (!$db->delUserFromGroup($user_id, $group_id)) { print_failure(get_lang_f('could_not_delete_user_from_group', $user_id, $group_id)); $view->refresh("?m=user_admin"); return; } echo "<p class='success'>" . get_lang_f('successfully_removed_from_group', $user_id, $group_id) . "</p>"; $db->logger(get_lang_f('successfully_removed_from_group', $user_id, $group_id)); $view->refresh("?m=user_admin&p=show_groups"); } }
function get_db_error_text($db_retval, &$error_text) { if (is_a($db_retval, "OGPDatabase")) { return FALSE; } switch ($db_retval) { case -1: $error_text = get_lang("db_error_invalid_host"); break; case -11: $error_text = get_lang("db_error_invalid_user_and_pass"); break; case -12: $error_text = get_lang("db_error_invalid_database"); break; case -98: $error_text = get_lang("db_error_invalid_db_type"); break; case -99: $error_text = get_lang("db_error_module_missing"); break; default: $error_text = get_lang_f("db_unknown_error", $db_retval); break; } return TRUE; }
function exec_ogp_module() { global $db; global $view; $group_id = $_REQUEST['group_id']; if (!$db->isAdmin($_SESSION['user_id'])) { $result = $db->getUserGroupList($_SESSION['user_id']); foreach ($result as $row) { if ($row['group_id'] == $group_id) { $own_group = TRUE; } } } if (!$db->isAdmin($_SESSION['user_id']) && !isset($own_group)) { echo "<p class='note'>" . get_lang('not_available') . "</p>"; return; } if (isset($_POST['add_user_to_group'])) { $group_id = trim($_POST['group_id']); $user_id = trim($_POST['user_to_add']); $username = $db->getUserById($user_id); $group_name = $db->getGroupById($group_id); if (!$db->addUsertoGroup($user_id, $group_id)) { print_failure(get_lang_f('could_not_add_user_to_group', $username['users_login'], $group_name['group_name'])); $view->refresh("?m=user_admin&p=show_groups"); return; } echo "<p class='success'>" . get_lang_f('successfully_added_to_group', $username['users_login'], $group_name['group_name']) . "</p>"; $db->logger(get_lang_f('successfully_added_to_group', $username['users_login'], $group_name['group_name'])); $view->refresh("?m=user_admin&p=show_groups"); } }
function exec_ogp_module() { global $db, $view, $settings; if (!isset($_SESSION)) { session_start(); } if (isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) > 0) { $errmsg = '<table>'; foreach ($_SESSION['ERRMSG_ARR'] as $msg) { $errmsg .= "<tr><td><img width='8px' src='images/offline.png'/></td><td style='text-align:left;color:red;'>" . $msg . '</td></tr>'; } $errmsg .= '</table><br>'; unset($_SESSION['ERRMSG_ARR']); } echo "<h2>" . get_lang('user_registration') . "</h2>"; if (isset($errmsg)) { echo $errmsg; $input = $_SESSION['INPUT']; } $lang_switch = (isset($_GET['lang']) and $_GET['lang'] != "-") ? "&lang=" . $_GET['lang'] : ""; ?> <style> .left { margin-left:auto; margin-right:auto; text-align:left; } .right { margin-left:auto; margin-right:auto; text-align:right; } </style> <?php require_once 'includes/form_table_class.php'; $ft = new FormTable(); $ft->start_form("?m=register&p=exec{$lang_switch}", "post", "name=\"loginForm\""); $ft->start_table(); $ft->add_field('string', 'login_name', @$input['users_login']); $ft->add_field('password', 'users_passwd', ''); $ft->add_field('password', 'users_cpasswd', ''); $ft->add_field('string', 'users_fname', @$input['users_fname']); $ft->add_field('string', 'users_lname', @$input['users_lname']); $ft->add_field('string', 'users_email', @$input['users_email']); $ft->add_field_hidden('users_comment', get_lang_f('registered_on', date("d/m/Y"))); echo "<tr><td> </td><td>"; require_once 'recaptchalib.php'; require_once 'captchakeys.php'; $use_ssl = isset($_SERVER['HTTPS']) ? true : false; echo recaptcha_get_html($publickey, null, $use_ssl); echo "</td></tr>"; $ft->end_table(); $ft->add_button("submit", "Submit", get_lang('register_a_new_user')); $ft->end_form(); }
function exec_ogp_module() { require_once "includes/functions.php"; global $db; global $view; if (!isset($_SESSION)) { session_start(); } // Unset refer session used to redirect back to subusers page after editing account information if (isset($_SESSION['REFER'])) { unset($_SESSION['REFER']); } if (isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) > 0) { $errmsg = '<table>'; foreach ($_SESSION['ERRMSG_ARR'] as $msg) { $errmsg .= "<tr><td><img width='8px' src='images/offline.png'/></td><td style='text-align:left;color:red;'>" . $msg . '</td></tr>'; } $errmsg .= '</table><br>'; unset($_SESSION['ERRMSG_ARR']); } echo "<h2>" . get_lang('delete_sub_user') . "</h2>"; if (isset($errmsg)) { echo $errmsg; } // Subuser Delete Check if (isset($_POST['editUser'])) { $_SESSION['REFER'] = "?m=subusers&p=del"; $userID = $_POST['user_id']; unset($_POST['editUser']); $view->refresh("?m=user_admin&p=edit_user&user_id=" . $userID, 0); } else { if (isset($_POST['delUser'])) { if (!isset($_POST['del_check'])) { $user_info = $db->getUserById($_POST['user_id']); echo "<table class='center' style='width:100%;' ><tr>\n" . "<td>" . get_lang_f('del_subuser_conf') . " " . $user_info['users_login'] . "?</td>" . "</tr><tr><td>" . '<form method="post" >' . "\n" . '<input type="hidden" name="user_id" value="' . $_POST['user_id'] . '">' . "\n" . '<input type="hidden" name="delUser" value="' . $_POST['delUser'] . '">' . "\n" . '<button name="del_check" value="yes" >' . get_lang('yes') . "</button>\n" . '<button name="del_check" value="no" >' . get_lang('no') . "</button>\n" . "</form>\n" . "</td>\n" . "</tr>\n" . "</table><br>\n"; } elseif ($_POST['del_check'] == "yes") { $userID = $_POST['user_id']; $user_info = $db->getUserById($userID); $errflag = false; if (!$db->delUser($userID)) { $errmsg_arr[] = get_lang('err_parent_user'); $errflag = true; } //If there are input validations, redirect back to the registration form if ($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; } else { echo "<p>" . get_lang_f('subuser_deleted', $user_info['users_login']) . "</p>"; } } } $results = listAllSubUsers(); echo $results; } }
function exec_ogp_module() { global $db; global $view; print "<h2>" . get_lang_f('uninstalling_module', $_REQUEST['module']) . "</h2>"; require_once 'modules/modulemanager/module_handling.php'; if (isset($_REQUEST['id']) && isset($_REQUEST['module']) && uninstall_module($db, $_REQUEST['id'], $_REQUEST['module']) === TRUE) { print_success(get_lang_f("successfully_uninstalled_module", $_REQUEST['module'])); } else { print_failure(get_lang_f("failed_to_uninstall_module", $_REQUEST['module'])); } $view->refresh("?m=modulemanager"); }
function exec_ogp_module() { global $db; global $view; print "<h2>" . get_lang_f('updating_modules') . "</h2>"; require_once 'modules/modulemanager/module_handling.php'; $modules = $db->getInstalledModules(); //print_r($modules) foreach ($modules as $row) { update_module($db, $row['id'], $row['folder']); } print "<p>" . get_lang_f('updating_finished') . "</p>"; $view->refresh("?m=modulemanager"); }
function read_server_config($filename) { $dom = new DOMDocument(); if ($dom->load($filename) === FALSE) { print_failure(get_lang_f('unable_to_load_xml', $filename)); return FALSE; } if ($dom->schemaValidate(XML_SCHEMA) != TRUE) { print_failure(get_lang_f('xml_file_not_valid', $filename, XML_SCHEMA)); return FALSE; } $xml = simplexml_load_file($filename); $xml->addChild('home_cfg_file', basename($filename)); return $xml; }
function exec_ogp_module() { global $db; global $view; if (isset($_POST['add_group'])) { $group = trim($_POST['group_name']); if (empty($group)) { print_failure(get_lang('group_name_empty')); return; } if (!$db->addGroup($group, $_SESSION['user_id'])) { print_failure(get_lang_f("failed_to_add_group", $group)); $view->refresh("?m=user_admin&p=show_groups"); return; } print_success(get_lang_f('successfully_added_group', $group)); $db->logger(get_lang_f('successfully_added_group', $group)); $view->refresh("?m=user_admin&p=show_groups"); } }
function exec_ogp_module() { global $db; global $view; print "<h2>" . get_lang_f('installing_module', $_REQUEST['module']) . "</h2>"; require_once 'modules/modulemanager/module_handling.php'; $install_retval = -99; if (isset($_REQUEST['module'])) { $install_retval = install_module($db, $_REQUEST['module']); } if ($install_retval > 0) { print_success(get_lang_f("successfully_installed_module", $_REQUEST['module'])); } else { if ($install_retval == 0) { print_success(get_lang_f("module_already_installed", $_REQUEST['module'])); } else { print_failure(get_lang_f("failed_to_install_module", $_REQUEST['module'])); } } $view->refresh("?m=modulemanager"); }
function exec_ogp_module() { global $db; global $view; $group_id = $_GET['group_id']; if (!$db->isAdmin($_SESSION['user_id'])) { $result = $db->getUserGroupList($_SESSION['user_id']); foreach ($result as $row) { if ($row['group_id'] == $group_id) { $own_group = TRUE; } } } if (!$db->isAdmin($_SESSION['user_id']) && !isset($own_group)) { echo "<p class='note'>" . get_lang('not_available') . "</p>"; return; } $y = isset($_GET['y']) ? $_GET['y'] : ""; $group = $db->getGroupById($group_id); if (empty($group)) { print_failure(get_lang_f('group_with_id_does_not_exist', $group_id)); return; } $groupname = $group['group_name']; if ($y !== 'y') { echo "<p>" . get_lang_f('are_you_sure_you_want_to_delete_group', $groupname) . "</p>"; echo "<p><a href=\"?m=user_admin&p=del_group&group_id={$group_id}&y=y\">" . get_lang('yes') . "</a> <a href=\"?m=user_admin&p=show_groups\">" . get_lang('no') . "</a></p>"; return; } if (!$db->delGroup($group_id)) { print_failure(get_lang_f('unable_to_delete_group', $groupname)); $view->refresh("?m=user_admin&p=show_groups"); return; } print_success(get_lang_f('successfully_deleted_group', $groupname)); $db->logger(get_lang_f('successfully_deleted_group', $groupname)); $view->refresh("?m=user_admin&p=show_groups"); }
function exec_ogp_module() { global $db; $isAdmin = $db->isAdmin($_SESSION['user_id']); if (isset($_REQUEST['user_id']) && !$isAdmin) { echo "<p class='note'>" . get_lang('not_available') . "</p>"; return; } if (isset($_REQUEST['group_id']) && !$isAdmin) { $result = $db->getUserGroupList($_SESSION['user_id']); foreach ($result as $row) { if ($row['group_id'] == $_REQUEST['group_id']) { $own_group = TRUE; } } } if (!$isAdmin && !isset($own_group)) { echo "<p class='note'>" . get_lang('not_available') . "</p>"; return; } if (!isset($_REQUEST['user_id']) && !isset($_REQUEST['group_id'])) { print_failure(get_lang("invalid_url")); return; } /// \todo We might want to save this information to XML file? $selections = array("allow_updates" => "u", "allow_file_management" => "f", "allow_parameter_usage" => "p", "allow_extra_params" => "e", "allow_ftp" => "t", "allow_custom_fields" => "c"); if (isset($_REQUEST['user_id'])) { $assign_id = $_REQUEST['user_id']; $id_type = "user"; $user = $db->getUserById($assign_id); $assign_name = $user['users_login']; } else { if (isset($_REQUEST['group_id'])) { $assign_id = $_REQUEST['group_id']; $id_type = "group"; $group = $db->getGroupById($assign_id); $assign_name = $group['group_name']; } } $submit = isset($_POST['submit']) ? $_POST['submit'] : ""; if (isset($_REQUEST['assign'])) { $access_rights = ""; foreach ($selections as $selection => $flag) { if (isset($_REQUEST[$selection])) { $access_rights .= $flag; } } $hacker = FALSE; if (!$isAdmin) { $home_info = $db->getUserGameHome($_SESSION['user_id'], $_REQUEST['home_id']); if (!$home_info) { print_failure(get_lang_f("failed_to_assign_game_for", $id_type, "(Hacking attempt)")); $hacker = TRUE; } else { foreach ($selections as $selection => $flag) { if (isset($_REQUEST[$selection])) { if (!preg_match("/{$flag}/", $home_info['access_rights'])) { print_failure(get_lang_f("failed_to_assign_game_for", $id_type, "(Hacking attempt)")); $hacker = TRUE; } } } } } if (!$hacker) { if ($db->assignHomeTo($id_type, $assign_id, $_REQUEST['home_id'], $access_rights) === TRUE) { print_success(get_lang_f("assigned_home_to_" . $id_type, $_REQUEST['home_id'], $assign_name)); $db->logger(get_lang_f("assigned_home_to_" . $id_type, $_REQUEST['home_id'], $assign_name)); } else { print_failure(get_lang_f("failed_to_assign_game_for_", $id_type, $db->getError())); } } unset($_POST['home_id']); } else { if (isset($_REQUEST['unassign'])) { if ($db->unassignHomeFrom($id_type, $assign_id, $_REQUEST['home_id']) === TRUE) { print_success(get_lang_f("unassigned_home_from_" . $id_type, $_REQUEST['home_id'], $assign_name)); $db->logger(get_lang_f("unassigned_home_from_" . $id_type, $_REQUEST['home_id'], $assign_name)); } else { print_failure(get_lang_f("failed_to_assign_game_from_", $id_type)); } } } $remote_servers = $db->getRemoteServers(); if (empty($remote_servers)) { print_failure(get_lang("no_remote_servers_available_please_add_at_least_one")); echo "<p><a href='?m=server'>" . get_lang('add_remote_server') . "</a></p>"; return; } if ($isAdmin) { $available_homes = $db->getAvailableHomesFor($id_type, $assign_id); } else { $available_homes = $db->getAvailableUserHomesFor($id_type, $assign_id, $_SESSION['user_id']); } if (!empty($available_homes)) { echo "<h2>" . get_lang_f('assign_new_home_to_' . $id_type, $assign_name) . "</h2>"; echo "<form action='?m=user_games&p=assign' method='post'>"; echo "<input name='" . $id_type . "_id' value='" . $assign_id . "' type='hidden' />\n"; echo "<table class='center'><tr><td align='right'><label for='home_id'>" . get_lang('select_home') . ":</label></td>"; echo '<td align="left"><select id="home_id" name="home_id" onchange="this.form.submit();">'; echo "<option></option>\n"; foreach ($available_homes as $home) { if (isset($_POST['home_id']) && $_POST['home_id'] == $home['home_id']) { $selected = "selected='selected'"; } else { $selected = ""; } echo "<option value='" . $home['home_id'] . "' {$selected} >" . $home['home_name'] . "</option>\n"; } echo "</select></td>\n"; if (isset($_POST['home_id']) and !empty($_POST['home_id'])) { if ($isAdmin) { $access_rights = "ufpetc"; } else { $home_info = $db->getUserGameHome($_SESSION['user_id'], $_POST['home_id']); $access_rights = $home_info['access_rights']; } foreach ($selections as $selection => $flag) { echo create_selection($selection, $flag, $access_rights); } echo "<tr><td colspan='2'><input type='submit' name='assign' value='" . get_lang('assign') . "' /></td></tr>"; } echo "</table></form>"; } else { echo "<h2>" . get_lang("no_more_homes_available_that_can_be_assigned_for_this_{$id_type}") . "</h2>"; //print_lang('you_can_add_a_new_game_server_from'); //echo "<a href='?m=user_games'>".get_lang('game_servers')."</a>.</p>"; if ($isAdmin) { echo get_lang_f("you_can_add_a_new_game_server_from", "<a href='?m=user_games'>" . get_lang('game_servers') . "</a>") . "</p>"; } } // View servers for use if there are any. $game_homes = $db->getHomesFor($id_type, $assign_id); if (empty($game_homes)) { echo "<h3>" . get_lang_f("no_homes_assigned_to_" . $id_type, $assign_name) . "</h3>"; } else { echo "<h2>" . get_lang('assigned_homes') . "</h2>"; echo '<table class="center">'; echo "<tr><th>" . get_lang('home_id') . "</th><th>" . get_lang('game_server') . "</th>\n <th>" . get_lang('game_type') . "</th>\n <th align='center'>" . get_lang('game_home') . "</th>\n <th>" . get_lang('game_home_name') . "</th><th>" . get_lang('access_rights') . "</th>\n <th>" . get_lang('actions') . "</th></tr>"; foreach ($game_homes as $row) { echo "<tr><td>{$row['home_id']}</td>\n <td>" . $row['agent_ip'] . " (Agent)</td>\n <td>{$row['game_name']}</td>\n <td>{$row['home_path']}</td>\n <td>{$row['home_name']}</td>\n <td>"; echo empty($row['access_rights']) ? "-" : $row['access_rights']; echo "</td>\n <td>\n <form action='?m=user_games&p=assign' method='post'>\n <input name='" . $id_type . "_id' value='{$assign_id}' type='hidden' />\n <input name='home_id' value='" . $row['home_id'] . "' type='hidden' />\n <input type='submit' name='unassign' value='" . get_lang('unassign') . "' /></form></td>\n </tr>"; } echo "</table>"; } if ($id_type === "group") { echo create_back_button('user_admin', 'show_groups'); } else { echo create_back_button('user_admin'); } }
function exec_ogp_module() { global $db; global $view; echo "<h2>" . get_lang('add_new_game_home') . "</h2>"; echo "<p><a href='?m=user_games'><< " . get_lang('back_to_game_servers') . "</a></p>"; $remote_servers = $db->getRemoteServers(); if ($remote_servers === FALSE) { echo "<p class='note'>" . get_lang('no_remote_servers_configured') . "</p>\n\t\t\t <p><a href='?m=server'>" . get_lang('add_remote_server') . "</a></p>"; return; } $game_cfgs = $db->getGameCfgs(); $users = $db->getUserList(); if ($game_cfgs === FALSE) { echo "<p class='note'>" . get_lang('no_game_configurations_found') . " <a href='?m=config_games'>" . get_lang('game_configurations') . "</a></p>"; return; } echo "<p> <span class='note'>" . get_lang('note') . ":</span> " . get_lang('add_mods_note') . "</p>"; $selections = array("allow_updates" => "u", "allow_file_management" => "f", "allow_parameter_usage" => "p", "allow_extra_params" => "e", "allow_ftp" => "t", "allow_custom_fields" => "c"); if (isset($_REQUEST['add_game_home'])) { $rserver_id = $_POST['rserver_id']; $home_cfg_id = $_POST['home_cfg_id']; $web_user_id = trim($_POST['web_user_id']); $control_password = genRandomString(8); $access_rights = ""; $ftp = FALSE; foreach ($selections as $selection => $flag) { if (isset($_REQUEST[$selection])) { $access_rights .= $flag; if ($flag == "t") { $ftp = TRUE; } } } if (empty($web_user_id)) { print_failure(get_lang('game_path_empty')); } else { foreach ($game_cfgs as $row) { if ($row['home_cfg_id'] == $home_cfg_id) { $server_name = $row['game_name']; } } foreach ($remote_servers as $server) { if ($server['remote_server_id'] == $rserver_id) { $ogp_user = $server['ogp_user']; } } foreach ($users as $user) { if ($user['user_id'] == $web_user_id) { $web_user = $user['users_login']; } } $ftppassword = genRandomString(8); $game_path = "/home/" . $ogp_user . "/OGP_User_Files/"; if (($new_home_id = $db->addGameHome($rserver_id, $web_user_id, $home_cfg_id, clean_path($game_path), $server_name, $control_password, $ftppassword)) !== FALSE) { $db->assignHomeTo("user", $web_user_id, $new_home_id, $access_rights); if ($ftp) { $home_info = $db->getGameHomeWithoutMods($new_home_id); require_once 'includes/lib_remote.php'; $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']); $host_stat = $remote->status_chk(); if ($host_stat === 1) { $remote->ftp_mgr("useradd", $home_info['home_id'], $home_info['ftp_password'], $home_info['home_path']); } $db->changeFtpStatus('enabled', $new_home_id); } print_success(get_lang('game_home_added')); $db->logger(get_lang('game_home_added') . " ({$server_name})"); $view->refresh("?m=user_games&p=edit&home_id={$new_home_id}"); } else { print_failure(get_lang_f("failed_to_add_home_to_db", $db->getError())); } } } // View form to add more servers. if (!isset($_POST['rserver_id'])) { echo "<form action='?m=user_games&p=add' method='post'>"; echo "<table class='center'>"; echo "<tr><td class='right'>" . get_lang('game_server') . "</td><td class='left'><select onchange=" . '"this.form.submit()"' . " name='rserver_id'>\n"; echo "<option>" . get_lang('select_remote_server') . "</option>\n"; foreach ($remote_servers as $server) { echo "<option value='" . $server['remote_server_id'] . "'>" . $server['remote_server_name'] . " (" . $server['agent_ip'] . ")</option>\n"; } echo "</select>\n"; echo "</form>"; echo "</td></tr></table>"; } else { if (isset($_POST['rserver_id'])) { $rhost_id = $_POST['rserver_id']; } $remote_server = $db->getRemoteServer($rhost_id); require_once 'includes/lib_remote.php'; $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key']); $host_stat = $remote->status_chk(); if ($host_stat === 1) { $os = $remote->what_os(); } else { print_failure(get_lang_f("caution_agent_offline_can_not_get_os_and_arch_showing_servers_for_all_platforms")); $os = "Unknown OS"; } echo "<form action='?m=user_games&p=add' method='post'>"; echo "<table class='center'>"; echo "<tr><td class='right'>" . get_lang('game_type') . "</td><td class='left'> <select name='home_cfg_id'>\n"; // Linux 64 bits + wine if (preg_match("/Linux/", $os) and preg_match("/64/", $os) and preg_match("/wine/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/linux/", $row['game_key'])) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name']; } if (preg_match("/64/", $row['game_key'])) { echo " (64 bit)"; } echo "</option>\n"; } echo "<option style='background:black;color:white;' value=''>" . get_lang('wine_games') . ":</option>\n"; foreach ($game_cfgs as $row) { if (preg_match("/win/", $row['game_key'])) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name']; } if (preg_match("/64/", $row['game_key'])) { echo " (64 bit)"; } echo "</option>\n"; } } elseif (preg_match("/Linux/", $os) and preg_match("/64/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/linux/", $row['game_key'])) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name']; } if (preg_match("/64/", $row['game_key'])) { echo " (64 bit)"; } echo "</option>\n"; } } elseif (preg_match("/Linux/", $os) and preg_match("/wine/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/linux32/", $row['game_key'])) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name'] . "</option>\n"; } } echo "<option style='background:black;color:white;' value=''>" . get_lang('wine_games') . "</option>\n"; foreach ($game_cfgs as $row) { if (preg_match("/win32/", $row['game_key'])) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name'] . "</option>\n"; } } } elseif (preg_match("/Linux/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/linux32/", $row['game_key'])) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name'] . "</option>\n"; } } } elseif (preg_match("/CYGWIN/", $os) and preg_match("/64/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/win/", $row['game_key'])) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name']; } if (preg_match("/64/", $row['game_key'])) { echo " (64 bit)"; } echo "</option>\n"; } } elseif (preg_match("/CYGWIN/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/win32/", $row['game_key'])) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name'] . "</option>\n"; } } } elseif ($os == "Unknown OS") { foreach ($game_cfgs as $row) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name']; if (preg_match("/64/", $row['game_key'])) { echo " (64 bit)"; } echo "</option>\n"; } } echo "</select>\n</td></tr>"; // Select user echo "<tr><td class='right'>" . get_lang('login') . ":</td>\n\t\t\t<td class='left'><select name='web_user_id'>"; $users = $db->getUserList(); foreach ($users as $user) { // Only users and admins can be assigned homes... not subusers if (is_null($user['users_parent'])) { echo "<option value='" . $user['user_id'] . "'>" . $user['users_login'] . "</option>\n"; } } echo "</select>\n</td></tr>"; // Select permisions echo "<tr><td class='right'>" . get_lang('access_rights') . ":</td>\n\t\t\t<td class='left'>"; foreach ($selections as $selection => $flag) { echo create_selection($selection, $flag); } echo "</td></tr>"; // Assign home echo "<tr><td align='center' colspan='2'>\n\t\t\t <input type='hidden' name='rserver_id' value='" . $rhost_id . "' />" . "<input type='submit' name='add_game_home' value='" . get_lang('add_game_home') . "' /></td></tr></table>"; echo "</form>"; } }
function exec_ogp_module() { global $db; global $view; $home_id = isset($_REQUEST['home_id']) ? $_REQUEST['home_id'] : ""; $mod_id = isset($_REQUEST['mod_id']) ? $_REQUEST['mod_id'] : ""; $isAdmin = $db->isAdmin($_SESSION['user_id']); if ($isAdmin) { $home_info = $db->getGameHome($home_id); } else { $home_info = $db->getUserGameHome($_SESSION['user_id'], $home_id); } if ($home_info === FALSE || preg_match("/u/", $home_info['access_rights']) != 1) { print_failure(get_lang('no_rights')); echo "<table class='center'><tr><td><a href='?m=gamemanager&p=game_monitor&home_id=" . $home_info['home_id'] . "'><< " . get_lang('back') . "</a></td></tr></table>"; return; } $game_type = $home_info['game_key']; echo "<h2>Updating game server <em>" . $home_info['home_name'] . "</em></h2>"; $server_xml = read_server_config(SERVER_CONFIG_LOCATION . "/" . $home_info['home_cfg_file']); if ($server_xml->installer != "steamcmd") { print_failure(get_lang('xml_steam_error')); return; } $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']); $host_stat = $remote->status_chk(); if ($remote->is_screen_running(OGP_SCREEN_TYPE_HOME, $home_id) == 1) { print_failure(get_lang('server_running_cant_update')); return; } $log_txt = ''; $update_active = $remote->get_log(OGP_SCREEN_TYPE_UPDATE, $home_id, clean_path($home_info['home_path']), $log_txt); $modkey = $home_info['mods'][$mod_id]['mod_key']; $mod_xml = xml_get_mod($server_xml, $modkey); if (!$mod_xml) { print_failure(get_lang_f('mod_key_not_found_from_xml', $modkey)); return; } if ($update_active === 0) { print_failure(get_lang('agent_offline')); echo "<meta http-equiv='refresh' content='5'>"; return; } else { if ($_REQUEST['update'] == 'update' && $update_active != 1) { $installer_name = $modkey; if (isset($mod_xml->installer_name)) { $installer_name = $mod_xml->installer_name; } $mod_cfg_id = $home_info['mod_cfg_id']; $game_mod_precmd = $db->resultQuery("SELECT DISTINCT precmd FROM OGP_DB_PREFIXgame_mods WHERE mod_id='{$mod_id}'"); if ($game_mod_precmd[0]['precmd'] === NULL or empty($game_mod_precmd[0]['precmd'])) { $config_mod_precmd = $db->resultQuery("SELECT DISTINCT def_precmd FROM OGP_DB_PREFIXconfig_mods WHERE mod_cfg_id='{$mod_cfg_id}'"); if ($config_mod_precmd[0]['def_precmd'] === NULL or empty($config_mod_precmd[0]['def_precmd'])) { $precmd = ""; } else { $precmd = $config_mod_precmd[0]['def_precmd']; } } else { $precmd = $game_mod_precmd[0]['precmd']; } $game_mod_postcmd = $db->resultQuery("SELECT DISTINCT postcmd FROM OGP_DB_PREFIXgame_mods WHERE mod_id='{$mod_id}'"); if ($game_mod_postcmd[0]['postcmd'] === NULL or empty($game_mod_postcmd[0]['postcmd'])) { $config_mod_postcmd = $db->resultQuery("SELECT DISTINCT def_postcmd FROM OGP_DB_PREFIXconfig_mods WHERE mod_cfg_id='{$mod_cfg_id}'"); if ($config_mod_postcmd[0]['def_postcmd'] === NULL or empty($config_mod_postcmd[0]['def_postcmd'])) { $postcmd = ""; } else { $postcmd = $config_mod_postcmd[0]['def_postcmd']; } } else { $postcmd = $game_mod_postcmd[0]['postcmd']; } $exec_folder_path = clean_path($home_info['home_path'] . "/" . $server_xml->exe_location); $exec_path = clean_path($exec_folder_path . "/" . $server_xml->server_exec_name); if (isset($_REQUEST['master_server_home_id'])) { $ms_home_id = $_REQUEST['master_server_home_id']; $ms_info = $db->getGameHome($ms_home_id); $steam_out = $remote->masterServerUpdate($home_id, $home_info['home_path'], $ms_home_id, $ms_info['home_path'], $exec_folder_path, $exec_path, $precmd, $postcmd); } else { if (preg_match("/win32/", $server_xml->game_key) or preg_match("/win64/", $server_xml->game_key)) { $cfg_os = "windows"; } elseif (preg_match("/linux/", $server_xml->game_key)) { $cfg_os = "linux"; } $settings = $db->getSettings(); // Some games like L4D2 require anonymous login if ($mod_xml->installer_login) { $login = $mod_xml->installer_login; $pass = ''; } else { $login = $settings['steam_user']; $pass = $settings['steam_pass']; } $modname = ($installer_name == '90' and !preg_match("/(cstrike|valve)/", $modkey)) ? $modkey : ''; $betaname = isset($mod_xml->betaname) ? $mod_xml->betaname : ''; $betapwd = isset($mod_xml->betapwd) ? $mod_xml->betapwd : ''; $steam_out = $remote->steam_cmd($home_id, $home_info['home_path'], $installer_name, $modname, $betaname, $betapwd, $login, $pass, $settings['steam_guard'], $exec_folder_path, $exec_path, $precmd, $postcmd, $cfg_os); } if ($steam_out === 0) { print_failure(get_lang('failed_to_start_steam_update')); return; } else { if ($steam_out === 1) { print_success(get_lang('update_started')); } else { if ($host_stat === 0) { print_failure(get_lang('agent_offline')); $view->refresh("?m=gamemanager&p=update&update=refresh&home_id={$home_id}&mod_id={$mod_id}", 5); return; } echo "Installing Steam... wait."; $steamcmdtrue = isset($_REQUEST['steamcmd']) ? "&steamcmd=true" : ""; $view->refresh("?m=gamemanager&p=update&update=update&home_id={$home_id}&mod_id={$mod_id}{$steamcmdtrue}", 5); return; } } } else { if (isset($_POST['stop_update_x'])) { $stop_update = sprintf("screen -S OGP_UPDATE_%09d -X quit", $home_id); $remote->exec("{$stop_update}"); } $update_complete = false; if ($update_active == 1) { echo "<p class='note'>" . get_lang('update_in_progress') . "</p>\n"; echo "<form method=POST><input type='image' name='stop_update' onsubmit='submit-form();' src='modules/administration/images/remove.gif'>" . get_lang('stop_update') . "</input></form>"; } else { echo "<meta http-equiv='refresh' content='60'>"; print_success(get_lang('update_completed')); echo "<table class='center'><tr><td><a href='?m=gamemanager&p=game_monitor&home_id=" . $home_info['home_id'] . "'><< " . get_lang('back') . "</a></td></tr></table>"; $update_complete = true; } if (empty($log_txt)) { $log_txt = get_lang('not_available'); } echo "<pre>" . $log_txt . "</pre>\n"; if ($update_complete) { return; } } } echo "<p><a href=\"?m=gamemanager&p=update&update=refresh&home_id={$home_id}&mod_id={$mod_id}\">"; echo get_lang('refresh_steam_status') . "</a></p>"; $view->refresh("?m=gamemanager&p=update&update=refresh&home_id={$home_id}&mod_id={$mod_id}", 5); return; }
function exec_ogp_module() { if ($_SESSION['users_group'] != "admin") { print_failure(get_lang('no_access')); return; } global $db; global $view; echo "<h2>" . get_lang('update') . "</h2>"; $panel_settings = $db->getSettings(); $pversion = "" . $panel_settings['ogp_version'] . ""; echo '<a href="?m=update&p=blacklist" >' . get_lang('blacklist_files') . "</a> " . get_lang('blacklist_files_info') . "</br></br>"; echo get_lang('panel_version') . ": " . $pversion . "</br></br>"; //Get SVN rev. $serverlist_url = "http://svn.code.sf.net/p/hldstart/code/trunk/upload/"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $serverlist_url); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept-Language: es-es,en")); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Save Page $result = curl_exec($ch); curl_close($ch); //Parse the result to get the last version. preg_match_all("(<title>p/hldstart/code - Revision (.*): /trunk/upload</title>)siU", $result, $matches); $last_svn_version = $matches[1][0]; if (isset($last_svn_version) and $last_svn_version != "") { echo get_lang('latest_version') . ": {$last_svn_version}</br></br>"; //Check snapshot file exists. $ch = curl_init("http://master.dl.sourceforge.net/project/ogpextras/Alternative-Snapshot/hldstart-code-{$last_svn_version}.zip"); curl_setopt($ch, CURLOPT_NOBODY, true); curl_exec($ch); $retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); // Run the snapshot creation if it does not exists yet. if ($retcode == '404') { print_failure("The snapshot of the current version has not been created yet."); print_failure("Try again in 5 minutes."); } else { if ($last_svn_version != $pversion) { if (isset($_GET['view_changes'])) { echo "<div style=\"\ttext-align:left;\n\t\t\t\t\t\t\t\t\t\twidth:80%;\n\t\t\t\t\t\t\t\t\t\tmargin:0 auto;\n\t\t\t\t\t\t\t\t\t\tpadding: 10px 5px;\n\t\t\t\t\t\t\t\t\t\tborder: 1px solid rgb(170, 170, 170);\n\t\t\t\t\t\t\t\t\t\tborder-radius: 4px;\n\t\t\t\t\t\t\t\t\t\tbackground-color: rgb(189, 229, 248);\" >"; for ($revision = $pversion + 1; $revision <= $last_svn_version; $revision++) { $serverlist_url = "http://sourceforge.net/p/hldstart/code/{$revision}/"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $serverlist_url); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept-Language: es-es,en")); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Save Page $result = curl_exec($ch); curl_close($ch); //Parse the result to get the last version. preg_match_all("(<div class=\"commit-message\">(.*)</div>\n <div class=\"commit-details\">)siU", $result, $matches); $commit_message = str_replace("<div class=\"markdown_content\">", "\\sl\\", $matches[1][0]); $commit_message = strip_tags($commit_message); $commit_message = str_replace("\\sl\\", "<br>", $commit_message); echo "<b>Revision {$revision} changes</b>: {$commit_message}<br><br>"; } echo "</div>"; } else { echo "<form action='' method='get'>"; echo "<input type='hidden' name='m' value='update' />"; echo "<input type='hidden' name='view_changes' value='true' />"; echo "<input type='submit' value='" . get_lang('view_changes') . "' /></form>"; $messages_qty = $last_svn_version - $pversion; if ($messages_qty >= 3) { print_failure(get_lang_f('get_x_revison_messages_may_take_some_time', $messages_qty)); } } echo "<br>"; $sf_mirrors = file("modules/update/mirrors.list"); echo "<form action='?m=update&p=updating&version=" . $last_svn_version . "' method='post'>"; echo get_lang('select_mirror') . ": " . create_drop_box_from_array_rsync($sf_mirrors, "mirror"); echo "<br><br><input type='submit' value='" . get_lang('update_now') . "' /></form><br><br>"; } else { print_failure(get_lang('the_panel_is_up_to_date')); } } } else { print_failure('sourceforge.net is down or not responding.'); } echo "</div>"; }
function exec_ogp_module() { global $db; global $view; $home_cfg_id = isset($_REQUEST['home_cfg_id']) ? $_REQUEST['home_cfg_id'] : ""; $home_id = isset($_REQUEST['home_id']) ? $_REQUEST['home_id'] : ""; $addon_id = isset($_REQUEST['addon_id']) ? $_REQUEST['addon_id'] : ""; $isAdmin = $db->isAdmin($_SESSION['user_id']); if ($isAdmin) { $home_info = $db->getGameHome($home_id); } else { $home_info = $db->getUserGameHome($_SESSION['user_id'], $home_id); } if ($home_info === FALSE) { print_failure(get_lang('no_rights')); echo create_back_button("addonsmanager", "user_addons"); return; } $server_xml = read_server_config(SERVER_CONFIG_LOCATION . "/" . $home_info['home_cfg_file']); $state = isset($_REQUEST['state']) ? $_REQUEST['state'] : ""; $pid = isset($_REQUEST['pid']) ? $_REQUEST['pid'] : -1; if (!empty($state)) { $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']); $addons_rows = $db->resultQuery("SELECT url, path, post_script FROM OGP_DB_PREFIXaddons WHERE addon_id=" . $addon_id); $addon_info = $addons_rows[0]; $url = $addon_info['url']; $filename = basename($url); #### This makes replacements to the bash script: if (isset($addon_info['post_script']) and !empty($addon_info['post_script']) and $addon_info['post_script'] != "") { $check_passed = FALSE; $address_at_post = $_POST['ip'] . ":" . $_POST['port']; $ip_ports = $db->getHomeIpPorts($home_info["home_id"]); foreach ($ip_ports as $ip_port) { } $address_owned = $ip_port['ip'] . ":" . $ip_port['port']; if ($address_owned == $address_at_post) { $check_passed = TRUE; break; } $ip = $ip_port['ip']; $port = $ip_port['port']; $home_info["ip"] = $check_passed ? $_POST['ip'] : $ip; $home_info["port"] = $check_passed ? $_POST['port'] : $port; if (isset($server_xml->gameq_query_name)) { $home_info["query_port"] = get_query_port($server_xml, $home_info['port']); } elseif (isset($server_xml->lgsl_query_name)) { $get_q_and_s = lgsl_port_conversion((string) $server_xml->lgsl_query_name, $home_info['port'], "", ""); $home_info["query_port"] = $get_q_and_s['1']; } $home_info["incremental"] = $db->incrementalNumByHomeId($home_info["home_id"], $home_info["mod_cfg_id"], $home_info["remote_server_id"]); $post_script = preg_replace("/\\%home_path\\%/i", $home_info["home_path"], $addon_info['post_script']); $post_script = preg_replace("/\\%home_name\\%/i", $home_info["home_name"], $post_script); $post_script = preg_replace("/\\%control_password\\%/i", $home_info["control_password"], $post_script); $post_script = preg_replace("/\\%max_players\\%/i", $home_info["max_players"], $post_script); $post_script = preg_replace("/\\%ip\\%/i", $home_info["ip"], $post_script); $post_script = preg_replace("/\\%port\\%/i", $home_info["port"], $post_script); $post_script = preg_replace("/\\%query_port\\%/i", $home_info["query_port"], $post_script); $post_script = preg_replace("/\\%incremental\\%/i", $home_info["incremental"], $post_script); } else { $post_script = ""; } #### end of replacememnts if ($state == "start" and $addon_id != "") { $pid = $remote->start_file_download($addon_info['url'], $home_info['home_path'] . "/" . $addon_info['path'], $filename, "uncompress", $post_script); } $headers = get_headers($url, 1); $download_available = !$headers ? FALSE : TRUE; // Check if any error occured if ($download_available) { $bytes = is_array($headers['Content-Length']) ? $headers['Content-Length'][1] : $headers['Content-Length']; // Display the File Size $totalsize = $bytes / 1024; clearstatcache(); } $kbytes = $remote->rsync_progress($home_info['home_path'] . "/" . $addon_info['path'] . "/" . $filename); list($totalsize, $mbytes, $pct) = explode(";", do_progress($kbytes, $totalsize)); $totalmbytes = round($totalsize / 1024, 2); $pct = $pct > 100 ? 100 : $pct; echo "<h2>" . $home_info['home_name'] . "</h2>"; echo '<div class="dragbox bloc rounded" style="background-color:#dce9f2;" > <h4>' . get_lang('install') . " " . $filename . " {$mbytes}MB/{$totalmbytes}MB</h4>\n\t\t\t <div style='background-color:#dce9f2;' >\n\t\t\t "; $bar = ''; for ($i = 1; $i <= $pct; $i++) { $bar .= '<img style="width:0.92%;vertical-align:middle;" src="images/progressBar.png">'; } echo "<center>{$bar} <b style='vertical-align:top;display:inline;font-size:1.2em;color:red;' >{$pct}%</b></center>\n\t\t\t\t</div>\n\t\t\t </div>"; if (($pct == "100" or !$download_available) and $post_script != "") { $log_retval = $remote->get_log("post_script", $pid, clean_path($home_info['home_path'] . "/" . $server_xml->exe_location), $script_log); if ($log_retval == 0) { print_failure(get_lang('agent_offline')); } elseif ($log_retval == 1 || $log_retval == 2) { echo "<pre class='log'>" . $script_log . "</pre>"; } elseif ($remote->is_screen_running("post_script", $pid) == 1) { print_failure(get_lang_f('unable_to_get_log', $log_retval)); } } if ($pct == "100" or !$download_available or $download_available and $pct == "-" and $pid > 0) { if (!$download_available) { print_failure(get_lang('failed_to_start_file_download')); } elseif ($remote->is_file_download_in_progress($pid) === 1) { print_success(get_lang_f('wait_while_decompressing', $filename)); echo "<p><a href=\"?m=addonsmanager&p=addons&state=refresh&home_id=" . $home_id . "&addon_id={$addon_id}&pid={$pid}\">" . get_lang('refresh') . "</a></p>"; $view->refresh("?m=addonsmanager&p=addons&state=refresh&home_id=" . $home_id . "&addon_id={$addon_id}&pid={$pid}", 5); } elseif ($remote->is_file_download_in_progress($pid) === 0 and $remote->is_screen_running("post_script", $pid) === 0) { print_success(get_lang('addon_installed_successfully')); $view->refresh("?m=addonsmanager&p=user_addons&home_id=" . $home_id, 10); return; } } else { echo "<p><a href=\"?m=addonsmanager&p=addons&state=refresh&home_id=" . $home_id . "&addon_id={$addon_id}&pid={$pid}\">" . get_lang('refresh') . "</a></p>"; $view->refresh("?m=addonsmanager&p=addons&state=refresh&home_id=" . $home_id . "&addon_id={$addon_id}&pid={$pid}", 5); } } elseif (!empty($_GET['addon_type'])) { ?> <h2><?php echo $home_info['home_name'] . " " . get_lang($_GET['addon_type']); ?> </h2> <table class='center'> <form action='?m=addonsmanager&p=addons<?php echo "&ip=" . $_GET['ip'] . "&port=" . $_GET['port']; ?> ' method='post'> <input type='hidden' name='home_id' value='<?php echo "{$home_id}"; ?> ' /> <input type='hidden' name='state' value='start' /> <tr><td align='right'><?php print_lang('game_name'); ?> : </td><td align='left'><?php echo "{$home_info['game_name']}"; ?> </td></tr> <tr><td align='right'><?php print_lang('directory'); ?> : </td><td align='left'><?php echo "{$home_info['home_path']}"; ?> </td></tr> <tr><td align='right'><?php print_lang('remote_server'); ?> : </td> <td align='left'><?php echo "{$home_info['remote_server_name']} ({$home_info['agent_ip']}:{$home_info['agent_port']})"; ?> </td></tr> <tr><td align='right'><?php print_lang('select_addon'); ?> : </td> <td align='left'> <select name="addon_id"> <?php $addons = $db->resultQuery("SELECT addon_id, name FROM OGP_DB_PREFIXaddons WHERE addon_type='" . $_GET['addon_type'] . "' AND home_cfg_id=" . $home_cfg_id); foreach ($addons as $addon) { ?> <option value="<?php echo $addon['addon_id']; ?> "><?php echo $addon['name']; ?> </option> <?php } ?> </select> </td></tr> <tr><td colspan='2' class='info'> </td></tr> <td align='left'> </td></tr><tr><td align="right"> <input type="submit" name="update" value="<?php print_lang('install'); ?> " /> </form></td><td> <form action="" method="get"> <input type="hidden" name="m" value="addonsmanager" /> <input type="hidden" name="p" value="user_addons" /> <input type="hidden" name="home_id" value="<?php echo "{$home_id}"; ?> " /> <input type="submit" value="<?php print_lang('back'); ?> " /> </form> </td></tr> </table> <?php } return; }
function exec_ogp_module() { global $db, $settings; $isAdmin = $db->isAdmin($_SESSION['user_id']); $OnlineServers = ""; $OnlineServersTitle = ""; if (isset($settings['welcome_title']) && $settings['welcome_title'] == "1") { if (isset($settings['welcome_title_message']) && !empty($settings['welcome_title_message'])) { echo "<div>" . $settings['welcome_title_message'] . "</div>"; } } $OnlineServersTitle .= get_lang('online_servers'); $player_list = ""; if ($isAdmin) { $server_homes = $db->getIpPorts(); } else { $OnlineServersTitle = "Open Game Panel"; $OnlineServers .= "<p>" . get_lang("welcome_text") . "</p><br><b>" . get_lang('online_servers') . ":</b><br><br>"; $server_homes = $db->getIpPortsForUser($_SESSION['user_id']); } require_once "includes/refreshed.php"; $refresh = new refreshed(); if (!$server_homes) { $OnlineServers .= "<p class='failure'>" . get_lang('no_games_to_monitor') . "</p>"; if ($isAdmin) { //$OnlineServers .= "<p class='note'>".get_lang('add_games_in'). //" <a href='?m=user_games&p=add'>".get_lang('game_servers')."</a></p>"; $OnlineServers .= "<p class='note'>" . get_lang_f("add_games_in", "<a href='?m=user_games&p=add'>" . get_lang('game_servers') . "</a>") . "</p>"; } } else { if (isset($settings['old_dashboard_behavior']) and $settings['old_dashboard_behavior'] == 1) { $serverslist = $refresh->add("home.php?m=dashboard&p=query_ref&show=servers&type=cleared"); $playerslist = $refresh->add("home.php?m=dashboard&p=query_ref&show=players&type=cleared"); $OnlineServers .= $refresh->getdiv($serverslist); $player_list .= $refresh->getdiv($playerslist); } else { $player_list = ""; $stats_servers = 0; $stats_servers_online = 0; $stats_players = 0; $stats_maxplayers = 0; $onlinePlayers = ""; $OnlineServers .= "<table style='width:100%;' class='online_servers'>"; require_once "protocol/lgsl/lgsl_protocol.php"; foreach ($server_homes as $server_home) { $remote_server_id = $server_home['remote_server_id']; $rserver = $db->getRemoteServerById($remote_server_id); // Count the number of servers. $stats_servers++; // Remember to clear the old value here. $message = ""; $remote = new OGPRemoteLibrary($server_home['agent_ip'], $server_home['agent_port'], $server_home['encryption_key']); $host_stat = $remote->status_chk(); if ($host_stat === 1) { // Check if the screen running the server is running. $screen_running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME, $server_home['home_id']) === 1; $server_xml = read_server_config(SERVER_CONFIG_LOCATION . "/" . $server_home['home_cfg_file']); if ($screen_running) { // Check if the screen running the server is running. if ($server_home['use_nat'] == 1) { $ip = $server_home['agent_ip']; } else { $ip = $server_home['ip']; } $port = $server_home['port']; $get_q_and_s = lgsl_port_conversion((string) $server_xml->lgsl_query_name, $port, "", ""); //Connection port $c_port = $get_q_and_s['0']; //query port $q_port = $get_q_and_s['1']; //software port $s_port = $get_q_and_s['2']; if ($server_xml->protocol == "lgsl") { $address = "<a href='" . lgsl_software_link($server_xml->lgsl_query_name, $ip, $c_port, $q_port, $s_port) . "'>" . $ip . ":" . $port . "</a>"; } if ($server_xml->protocol == "teamspeak3") { $address = "<a href='ts3server://{$ip}:{$port}'>{$ip}:{$port}</a>"; } elseif ($server_xml->protocol == "gameq" and $server_xml->installer == "steam") { $address = "<a href='steam://connect/{$ip}:{$port}'>{$ip}:{$port}</a>"; } elseif ($server_xml->protocol == "gameq" or !isset($server_xml->protocol)) { $address = "{$ip}:{$port}"; } $OnlineServers .= "<tr><td><div class='name' ><a href='?m=gamemanager&p=game_monitor&home_id-mod_id-ip-port=" . $server_home['home_id'] . "-" . $server_home['mod_id'] . "-" . $server_home['ip'] . "-" . $server_home['port'] . "' ><img style='border:0;height:12px;' src='images/magnifglass.png'/>" . $server_home['home_name'] . "</a></div> | "; $OnlineServers .= "<div id='gamelink' >{$address}</div>"; $OnlineServers .= "</td></tr>"; $stats_servers_online++; } } unset($map, $player_list, $status, $ip, $port, $players, $playersmax, $name, $map, $mod, $xml_mod, $qport, $address, $maplocation); } $OnlineServers .= "</table>"; $OnlineServers .= "<center>" . get_lang('statistics') . ":<br>{$stats_servers_online}/{$stats_servers} " . get_lang('online_servers') . "</center>"; } } ?> <div style="margin-top:20px;"> <?php //$title[$id] = "The Title"; //$content[$id] = "Content of the Widget"; $title = array(); $content = array(); $href = array(); // Game Monitor $title[1] = get_lang('game_monitor'); $content[1] = '<img src="themes/' . $settings['theme'] . '/images/icons/game_monitor.png" style="width:48px;float:right;margin:0 0 0 8px" />' . get_lang('dashboard_game_monitor_text'); $href[1] = 'home.php?m=gamemanager&p=game_monitor'; // Online Server $title[2] = $OnlineServersTitle; $content[2] = $OnlineServers; $href[2] = null; // Currently Online $title[3] = get_lang('currently_online'); $content[3] = $player_list; $href[3] = null; // FTP $title[4] = get_lang('ftp'); $content[4] = '<img src="themes/' . $settings['theme'] . '/images/icons/folder.png" style="width:48px;float:right;margin:0 0 0 8px" />' . get_lang('dashboard_ftp_text'); $href[4] = 'home.php?m=ftp'; // Support $title[5] = get_lang('support'); $content[5] = '<img src="themes/' . $settings['theme'] . '/images/icons/support.png" style="width:48px;float:right;margin:0 0 0 8px" />' . get_lang('dashboard_support_text'); $href[5] = 'http://www.opengamepanel.org/forum'; $columns = array(); $columns[1]['column_id'] = 1; $columns[2]['column_id'] = 2; $columns[3]['column_id'] = 3; foreach ($columns as $column) { echo '<div class="column '; if ($column['column_id'] == 1) { echo 'one_fourth'; } else { if ($column['column_id'] == 2) { echo 'one_two'; } else { if ($column['column_id'] == 3) { echo 'one_fourth'; } } } echo '" id="column' . $column['column_id'] . '" >'; $items = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXwidgets_users WHERE column_id='" . $column['column_id'] . "' AND user_id='" . $_SESSION['user_id'] . "' ORDER BY sort_no"); if ($items) { foreach ($items as $widget) { if ((!isset($settings['old_dashboard_behavior']) or $settings['old_dashboard_behavior'] == 0) and $widget['widget_id'] == "3") { continue; } echo ' <div class="dragbox bloc rounded" id="item' . $widget['widget_id'] . '"> <h4><span class="configure"></span>'; if (!is_null($title[$widget['widget_id']])) { echo $title[$widget['widget_id']]; } echo '</h4> <div class="dragbox-content" '; if (!is_null($href[$widget['widget_id']])) { echo "onclick=\"location.href='" . $href[$widget['widget_id']] . "'\" style=\"cursor:pointer;"; if ($widget['collapsed'] == 1) { echo 'display:none;'; } echo '"'; } elseif ($widget['collapsed'] == 1) { echo 'style="display:none;"'; } echo '>'; if (!is_null($content[$widget['widget_id']])) { echo $content[$widget['widget_id']]; } echo ' </div> </div>'; unset($widget); } } echo '</div>'; } if ($isAdmin and $db->isModuleInstalled('status')) { echo "<h0>Server Status</h0><br>"; $servers = $db->getRemoteServers(); echo "<div style='float:left;width:40%;' >\n\t\t\t <div class='bloc rounded' >\n\t\t\t <h4>Select remote server</h4>\n\t\t\t <div>\n\t\t\t\t<br>\n\t\t\t\t<center>\n\t\t\t <form action='' method='GET'>\n\t\t\t <input type='hidden' name='m' value='" . $_GET['m'] . "'/>\n\t\t\t <input type='hidden' name='p' value='" . $_GET['p'] . "'/>\n\t\t\t <select name='remote_server_id' onchange=" . '"this.form.submit()"' . ">\n"; foreach ($servers as $server_row) { if (!empty($server_row['remote_server_id']) and !isset($_GET['remote_server_id']) or !empty($server_row['remote_server_id']) and empty($_GET['remote_server_id'])) { $_GET['remote_server_id'] = $server_row['remote_server_id']; } if (isset($_GET['remote_server_id']) and $_GET['remote_server_id'] == $server_row['remote_server_id']) { $rhost_id = $_GET['remote_server_id']; $remote_server = $db->getRemoteServer($rhost_id); $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key']); $host_stat = $remote->status_chk(); if ($host_stat === 1) { $checked = "selected='selected'"; } else { $checked = ''; $_GET['remote_server_id'] = 'webhost'; } } else { $checked = ''; } echo "<option value='" . $server_row['remote_server_id'] . "' {$checked} >" . $server_row['remote_server_name'] . "</option>\n"; } if (function_exists('exec')) { $checked = (isset($_GET['remote_server_id']) and $_GET['remote_server_id'] == 'webhost') ? "selected='selected'" : ""; echo "<option value='webhost' {$checked} >Webhost Status</option>"; } echo "\t</select>\n\t\t\t </form>\n\t\t\t\t</center>\n\t\t\t\t<br><br>\n\t\t\t </div>\n\t\t\t </div>\n\t\t\t </div>\n"; if (isset($_GET['remote_server_id']) and $_GET['remote_server_id'] == "webhost") { unset($_GET['remote_server_id']); } if (isset($_GET['remote_server_id']) && !empty($_GET['remote_server_id'])) { $remote_server = "&remote_server_id=" . $_GET['remote_server_id']; } else { $remote_server = ""; } if ($isAdmin and $db->isModuleInstalled('status') and (isset($_GET['remote_server_id']) or function_exists('exec'))) { $status = $refresh->add("home.php?m=status&type=cleared" . $remote_server); echo $refresh->getdiv($status); } } ?> <script type="text/javascript"> var userAgent = navigator.userAgent.toLowerCase(), browser = '', version = 0; $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase()); // Is this a version of IE? if ($.browser.msie) { userAgent = $.browser.version; userAgent = userAgent.substring(0,userAgent.indexOf('.')); version = userAgent; browser = "Internet Explorer"; } // Is this a version of Chrome? if ($.browser.chrome) { userAgent = userAgent.substring(userAgent.indexOf('chrome/') + 7); userAgent = userAgent.substring(0,userAgent.indexOf('.')); version = userAgent; // If it is chrome then jQuery thinks it's safari so we have to tell it it isn't $.browser.safari = false; browser = "Chrome"; } // Is this a version of Safari? if ($.browser.safari) { userAgent = userAgent.substring(userAgent.indexOf('safari/') + 7); userAgent = userAgent.substring(0,userAgent.indexOf('.')); version = userAgent; browser = "Safari"; } // Is this a version of Mozilla? if ($.browser.mozilla) { //Is it Firefox? if (navigator.userAgent.toLowerCase().indexOf('firefox') != -1) { userAgent = userAgent.substring(userAgent.indexOf('firefox/') + 8); userAgent = userAgent.substring(0,userAgent.indexOf('.')); version = userAgent; browser = "Firefox" } // If not then it must be another Mozilla else { browser = "Mozilla (not Firefox)" } } // Is this a version of Opera? if ($.browser.opera) { userAgent = userAgent.substring(userAgent.indexOf('version/') + 8); userAgent = userAgent.substring(0,userAgent.indexOf('.')); version = userAgent; browser = "Opera"; } // Now you have two variables, browser and version // which have the right info $(document).ready( function(){ $('.dragbox') .each(function(){ $(this).hover(function(){ $(this).find('h4').addClass('collapse'); }, function(){ $(this).find('h4').removeClass('collapse'); }) .find('h4').hover(function(){ $(this).find('.configure').css('visibility', 'visible'); }, function(){ $(this).find('.configure').css('visibility', 'hidden'); }) .click(function(){ $(this).siblings('.dragbox-content').toggle(); //Save state on change of collapse state of panel updateWidgetData(); }) .end() .find('.configure').css('visibility', 'hidden'); }); $('.column').sortable({ connectWith: '.column', handle: 'h4', cursor: 'move', placeholder: 'placeholder', forcePlaceholderSize: true, opacity: 0.4, start: function(event, ui){ //Firefox, Safari/Chrome fire click event after drag is complete, fix for that if(browser == "Firefox" || browser == "Mozilla (not Firefox)" || browser == "Safari") $(ui.item).find('.dragbox-content').toggle(); }, stop: function(){ updateWidgetData(); } }) .disableSelection(); } ); function updateWidgetData(){ var items=[]; $('.column').each(function(){ var columnId=$(this).attr('id'); $('.dragbox', this).each(function(i){ var collapsed=0; if($(this).find('.dragbox-content').css('display')=="none") collapsed=1; //Create Item object for current panel var item={ id: $(this).attr('id'), collapsed: collapsed, order : i, column: columnId }; //Push item object into items array items.push(item); }); }); //Assign items array to sortorder JSON variable var sortorder={ items: items }; //Pass sortorder variable to server using ajax to save state $.post('home.php?m=dashboard&p=updateWidgets', 'data='+$.toJSON(sortorder), function(response){ if(response.indexOf("success") < 0){ $("#console").html('<h0><div class="Failed">Failed to save you\'r operation! Please contact OGP...</div></h0>').hide().fadeIn(1000); } }); } $(document).ready(function(){ <?php echo $refresh->build("20000"); ?> }); </script> <?php }
<script src="modules/addonsmanager/jquery-ui.js"></script> <script> $(function() { $( 'input,textarea' ).tooltip(); }); </script> <?php /* * * OGP - Open Game Panel * Copyright (C) Copyright (C) 2008 - 2013 The OGP Development Team * * http://www.opengamepanel.org/ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ function exec_ogp_module() { global $db; if (isset($_POST['create_addon']) and isset($_POST['name']) and $_POST['url'] == "") { print_failure(get_lang("fill_the_url_address_to_a_compressed_file")); } elseif (isset($_POST['create_addon']) and isset($_POST['url']) and $_POST['name'] == "") { print_failure(get_lang("fill_the_addon_name")); } elseif (isset($_POST['create_addon']) and isset($_POST['name']) and isset($_POST['url']) and empty($_POST['addon_type'])) { print_failure(get_lang("select_an_addon_type")); } elseif (isset($_POST['create_addon']) and isset($_POST['name']) and isset($_POST['url']) and isset($_POST['addon_type']) and empty($_POST['home_cfg_id'])) { print_failure(get_lang("select_a_game_type")); } elseif (isset($_POST['create_addon']) and isset($_POST['name']) and isset($_POST['url']) and isset($_POST['addon_type']) and isset($_POST['home_cfg_id'])) { $fields['name'] = $_POST['name']; $fields['url'] = $_POST['url']; $fields['path'] = $_POST['path']; $fields['addon_type'] = $_POST['addon_type']; $fields['home_cfg_id'] = $_POST['home_cfg_id']; $fields['post_script'] = $_POST['post_script']; if (is_numeric($db->resultInsertId('addons', $fields))) { print_success(get_lang_f("addon_has_been_created", $_POST['name'])); if (isset($_POST['addon_id']) && isset($_POST['edit'])) { $db->query("DELETE FROM OGP_DB_PREFIXaddons WHERE addon_id=" . $_POST['addon_id']); } } } echo "<h2>" . get_lang('addons_manager') . "</h2>"; $name = isset($_POST['name']) ? $_POST['name'] : ""; $url = isset($_POST['url']) ? $_POST['url'] : ""; $path = isset($_POST['path']) ? $_POST['path'] : ""; $post_script = isset($_POST['post_script']) ? $_POST['post_script'] : ""; $home_cfg_id = isset($_POST['home_cfg_id']) ? $_POST['home_cfg_id'] : ""; $addon_type = isset($_POST['addon_type']) ? $_POST['addon_type'] : ""; if (isset($_POST['addon_id']) && isset($_POST['edit'])) { $addons_rows = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXaddons WHERE addon_id=" . $_POST['addon_id']); $addon_info = $addons_rows[0]; $name = isset($addon_info['name']) ? $addon_info['name'] : ""; $url = isset($addon_info['url']) ? $addon_info['url'] : ""; $path = isset($addon_info['path']) ? $addon_info['path'] : ""; $post_script = isset($addon_info['post_script']) ? $addon_info['post_script'] : ""; $home_cfg_id = isset($addon_info['home_cfg_id']) ? $addon_info['home_cfg_id'] : ""; $addon_type = isset($addon_info['addon_type']) ? $addon_info['addon_type'] : ""; } ?> <form action="" method="post"> <table class="center"> <tr> <td align="right"> <b><?php print_lang('addon_name'); ?> </b> </td> <td align="left"> <input type="text" value="<?php echo $name; ?> " name="name" size="90" title="<?php print_lang('addon_name_info'); ?> " /> </td> </tr> <tr> <td align="right"> <b><?php print_lang('url'); ?> </b> </td> <td align="left"> <input type="text" value="<?php echo $url; ?> " name="url" size="90" title="<?php print_lang('url_info'); ?> " /> </td> </tr> <!-- If any, you can set the destination path, should be a relative path to the main game server folder. --> <tr> <td align="right"> <b><?php print_lang('path'); ?> </b> </td> <td align="left"> <input type="text" value="<?php echo $path; ?> " name="path" size="90" title="<?php print_lang('path_info'); ?> " /> </td> </tr> <tr> <td align="right"> <b><?php print_lang('post-script'); ?> </b><br> <u><?php print_lang('replacements'); ?> </u><br> %home_path%<br> %home_name%<br> %control_password%<br> %max_players%<br> %ip%<br> %port%<br> %query_port%<br> %incremental%<br> </td> <td align="left"> <textarea name="post_script" style="width:99%;height:175px;" title="<?php print_lang('post-script_info'); ?> " ><?php echo $post_script; ?> </textarea> </td> </tr> <tr> <td align="right"> <b><?php print_lang('select_game_type'); ?> </b> </td> <td align="left"> <select name='home_cfg_id'> <?php $game_cfgs = $db->getGameCfgs(); echo "<option style='background:black;color:white;' value=''>" . get_lang('linux_games') . "</option>\n"; foreach ($game_cfgs as $row) { if (preg_match("/linux/", $row['game_key'])) { $selected = (isset($home_cfg_id) and $row['home_cfg_id'] == $home_cfg_id) ? 'selected="selected"' : ''; echo "<option {$selected} value='" . $row['home_cfg_id'] . "'>" . $row['game_name']; if (preg_match("/64/", $row['game_key'])) { echo " (64bit)"; } echo "</option>\n"; } } echo "<option style='background:black;color:white;' value=''>" . get_lang('windows_games') . "</option>\n"; foreach ($game_cfgs as $row) { if (preg_match("/win/", $row['game_key'])) { $selected = (isset($home_cfg_id) and $row['home_cfg_id'] == $home_cfg_id) ? 'selected=selected' : ''; echo "<option {$selected} value='" . $row['home_cfg_id'] . "'>" . $row['game_name']; if (preg_match("/64/", $row['game_key'])) { echo " (64bit)"; } echo "</option>\n"; } } ?> </select> </td> </tr> <tr> <td align="right"> <b><?php print_lang('type'); ?> </b> </td> <td align="left"> <?php $types = array('plugin', 'mappack', 'config'); foreach ($types as $type) { $checked = (isset($addon_type) and $type == $addon_type) ? 'checked' : ''; echo '<input type="radio" name="addon_type" value="' . $type . '" ' . $checked . '>' . get_lang($type); } ?> </td> </tr> <tr> <td colspan="2" align="center"> <?php if (isset($_POST['addon_id']) && isset($_POST['edit'])) { echo '<input type="hidden" name="addon_id" value="' . $_POST['addon_id'] . '" >'; echo '<input type="hidden" name="edit" value="' . $_POST['edit'] . '" >'; ?> <button name="create_addon" type="submit"> <?php print_lang('edit_addon'); ?> </button> <?php } else { ?> <button name="create_addon" type="submit"> <?php print_lang('create_addon'); ?> </button> <?php } ?> </td> </tr> </table> </form> <br> <h2><?php print_lang('addons_db'); ?> </h2> <table class="center"> <tr> <td align="center"> <form name="remove" action="" method="get"> <input name="m" type="hidden" value="addonsmanager"/> <input name="p" type="hidden" value="addons_manager"/> <b><?php print_lang('game'); ?> </b> <select name='home_cfg_id'> <?php echo "<option style='background:black;color:white;' value=''>" . get_lang('linux_games') . "</option>\n"; foreach ($game_cfgs as $row) { if (preg_match("/linux/", $row['game_key'])) { if (isset($_GET['home_cfg_id']) and $row['home_cfg_id'] == $_GET['home_cfg_id']) { $selected = "selected='selected'"; } else { $selected = ""; } echo "<option value='" . $row['home_cfg_id'] . "' {$selected} >" . $row['game_name'];
function exec_ogp_module() { global $db; global $view; $pieces = explode("-", $_GET['home_id-mod_id-ip-port']); $home_id = $pieces[0]; $mod_id = $pieces[1]; $ip = $pieces[2]; $port = $pieces[3]; $user_id = $_SESSION['user_id']; $isAdmin = $db->isAdmin($user_id); if ($isAdmin) { $home_info = $db->getGameHome($home_id); } else { $home_info = $db->getUserGameHome($user_id, $home_id); } if ($home_info === FALSE) { print_failure(get_lang('no_access_to_home')); return; } $server_xml = read_server_config(SERVER_CONFIG_LOCATION . "/" . $home_info['home_cfg_file']); if (!$server_xml) { echo create_back_button($_GET['m'], 'game_monitor&home_id-mod_id-ip-port=' . $_GET['home_id-mod_id-ip-port']); return; } require_once 'includes/lib_remote.php'; $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']); $home_log = ""; if (isset($server_xml->console_log)) { $log_retval = $remote->remote_readfile($home_info['home_path'] . '/' . $server_xml->console_log, $home_log); } else { $log_retval = $remote->get_log(OGP_SCREEN_TYPE_HOME, $home_info['home_id'], clean_path($home_info['home_path'] . "/" . $server_xml->exe_location), $home_log); } if ($log_retval == 0) { print_failure(get_lang('agent_offline')); echo create_back_button($_GET['m'], 'game_monitor&home_id-mod_id-ip-port=' . $_GET['home_id-mod_id-ip-port']); } elseif ($log_retval == 1 || $log_retval == 2) { // Using the refreshed class if (isset($_GET['refreshed'])) { echo "<pre class='log'>" . $home_log . "</pre>"; } else { echo "<h2>" . $home_info['home_name'] . "</h2>"; require_once "includes/refreshed.php"; $control = '<form method="POST" > <input type="submit" name="'; if (isset($_POST['full'])) { $height = "100%"; $control .= 'default" value="-'; } else { $height = "500px"; $control .= 'full" value="+'; } $control .= '" /></form><br />'; $intervals = array("4s" => "4000", "8s" => "8000", "30s" => "30000", "2m" => "120000", "5m" => "300000"); $intSel = '<form action="" method="GET" > <input type="hidden" name="m" value="gamemanager" /> <input type="hidden" name="p" value="log" /> <input type="hidden" name="home_id-mod_id-ip-port" value="' . $_GET['home_id-mod_id-ip-port'] . '" />' . get_lang('refresh_interval') . ':<select name="setInterval" onchange="this.form.submit();">'; foreach ($intervals as $interval => $value) { $selected = ""; if (isset($_GET['setInterval']) and $_GET['setInterval'] == $value) { $selected = 'selected="selected"'; } $intSel .= '<option value="' . $value . '" ' . $selected . ' >' . $interval . '</option>'; } $intSel .= "</select></form>"; $setInterval = $_GET['setInterval'] ? $_GET['setInterval'] : 4000; $refresh = new refreshed(); $pos = $refresh->add("home.php?m=gamemanager&p=log&type=cleared&refreshed&home_id-mod_id-ip-port=" . $_GET['home_id-mod_id-ip-port']); echo $refresh->getdiv($pos, "height:" . $height . ";overflow:auto;max-width:1600px;"); ?> <script type="text/javascript">$(document).ready(function(){ <?php echo $refresh->build("{$setInterval}"); ?> } ); </script><?php echo "<table class='center' ><tr><td>{$intSel}</td><td>{$control}</td></tr></table>"; if ($remote->is_screen_running(OGP_SCREEN_TYPE_HOME, $home_info['home_id']) != 1) { print_failure(get_lang('server_not_running')); } else { if ($server_xml->control_protocol == 'rcon' or $server_xml->control_protocol == 'rcon2' or @$server_xml->gameq_query_name == "minecraft" or $server_xml->control_protocol == 'lcon' or isset($server_xml->lgsl_query_name) and $server_xml->lgsl_query_name == "7dtd") { require 'modules/gamemanager/rcon.php'; } } echo create_back_button($_GET['m'], 'game_monitor&home_id-mod_id-ip-port=' . $_GET['home_id-mod_id-ip-port']); } } else { print_failure(get_lang_f('unable_to_get_log', $log_retval)); echo create_back_button($_GET['m'], 'game_monitor&home_id-mod_id-ip-port=' . $_GET['home_id-mod_id-ip-port']); } }
function exec_ogp_module() { $modDb = new MySQLModuleDatabase(); require "includes/config.inc.php"; $modDb->connect($db_host, $db_user, $db_pass, $db_name, $table_prefix); global $view, $db; echo "<h2>" . get_lang('add_new_mysql_host') . "</h2>"; if (isset($_GET['add_mysql_server'])) { foreach ($_GET as $name => $value) { $get[$name] = trim($value); } if (empty($get['mysql_ip'])) { print_failure(get_lang('enter_mysql_ip')); } if (!isPortValid($get['mysql_port'])) { print_failure(get_lang('enter_valid_port')); } if (empty($get['mysql_root_passwd'])) { print_failure(get_lang('enter_mysql_root_password')); } if (empty($get['mysql_name'])) { print_failure(get_lang('enter_mysql_name')); } if ($get['privilegies'] == "custom") { $priv = $get; $privilegies_str = ""; unset($priv['m'], $priv['p'], $priv['remote_server_id'], $priv['mysql_ip'], $priv['mysql_port'], $priv['mysql_root_passwd'], $priv['mysql_name'], $priv['privilegies'], $priv['add_mysql_server']); foreach ($priv as $name => $value) { $privilegies_str .= str_replace("_", " ", $name) . ", "; } } else { $privilegies_str = "ALL"; } $privilegies_str = rtrim($privilegies_str, ', '); $mysql_server_id = $modDb->addMysqlServer($get['remote_server_id'], $get['mysql_name'], $get['mysql_ip'], $get['mysql_port'], $get['mysql_root_passwd'], $privilegies_str); if (!$mysql_server_id) { print_failure(get_lang('could_not_add_mysql_server')); $view->refresh("?m=mysql&p=mysql_admin"); return; } print_success(get_lang('server_added')); $view->refresh("?m=mysql&p=mysql_admin"); return; } echo "<p>" . get_lang('note_mysql_host') . "</p>"; $servers = $db->getRemoteServers(); $conn_method[0] = get_lang('direct_connection'); foreach ($servers as $server_row) { $id = $server_row['remote_server_id']; $name = get_lang_f('connection_through_remote_server_named', $server_row['remote_server_name']); $conn_method[$id] = $name; } require_once "includes/form_table_class.php"; $ft = new FormTable(); $ft->start_form("", "GET"); $ft->start_table(); $ft->add_field_hidden('m', 'mysql'); $ft->add_field_hidden('p', 'mysql_admin'); $ft->add_custom_field('connection_method', create_drop_box_from_array($conn_method, "remote_server_id", "0", false)); $ft->add_field('string', 'mysql_name', isset($_GET['mysql_name']) ? $_GET['mysql_name'] : ""); $ft->add_field('string', 'mysql_ip', isset($_GET['mysql_ip']) ? $_GET['mysql_ip'] : "localhost"); $ft->add_field('string', 'mysql_port', isset($_GET['mysql_port']) ? $_GET['mysql_port'] : "3306"); $ft->add_field('string', 'mysql_root_passwd', isset($_GET['mysql_root_passwd']) ? $_GET['mysql_root_passwd'] : ""); $ft->add_custom_field('privilegies', create_drop_box_from_array(array('all' => get_lang('all'), 'custom' => get_lang('custom')), "privilegies", isset($_GET['privilegies']) ? $_GET['privilegies'] : "all", false)); if (isset($_GET['privilegies']) and $_GET['privilegies'] == "custom") { $ft->add_custom_field('alter', '<input type="checkbox" name="ALTER" checked="checked" >'); $ft->add_custom_field('create', '<input type="checkbox" name="CREATE" checked="checked" >'); $ft->add_custom_field('create_temporary_tables', '<input type="checkbox" name="CREATE TEMPORARY TABLES" checked="checked" >'); $ft->add_custom_field('delete', '<input type="checkbox" name="DELETE" checked="checked" >'); $ft->add_custom_field('drop', '<input type="checkbox" name="DROP" checked="checked" >'); $ft->add_custom_field('index', '<input type="checkbox" name="INDEX" checked="checked" >'); $ft->add_custom_field('insert', '<input type="checkbox" name="INSERT" checked="checked" >'); $ft->add_custom_field('lock_tables', '<input type="checkbox" name="LOCK TABLES" checked="checked" >'); $ft->add_custom_field('select', '<input type="checkbox" name="SELECT" checked="checked" >'); $ft->add_custom_field('update', '<input type="checkbox" name="UPDATE" checked="checked" >'); $ft->add_custom_field('grant_option', '<input type="checkbox" name="GRANT OPTION" checked="checked" >'); } $ft->end_table(); $ft->add_button("submit", "add_mysql_server", get_lang('add_mysql_server')); $ft->end_form(); $mysql_servers = $modDb->getMysqlServers(); if ($mysql_servers === FALSE) { return; } $tr = 0; ?> <table id="servermonitor" class="tablesorter remote"> <thead> <tr> <th colspan="4" ><?php print_lang('configured_mysql_hosts'); ?> </th> </tr> </thead> <tbody> <?php foreach ($mysql_servers as $mysql_server) { if ($mysql_server['remote_server_id'] != 0) { $remote_server = $db->getRemoteServer($mysql_server['remote_server_id']); $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key']); $host_stat = $remote->status_chk(); if ($host_stat === 0) { $server_status = "<span class='failure'>" . get_lang('offline') . "</span> "; } elseif ($host_stat === 1) { $server_status = "<span class='success'>" . get_lang('online') . "</span>"; $command = "mysql -h " . $mysql_server['mysql_ip'] . " -P " . $mysql_server['mysql_port'] . " -u root -p" . $mysql_server['mysql_root_passwd'] . ' -e exit; echo $?'; $test_mysql_conn = $remote->exec($command); if ($test_mysql_conn == 0) { $server_status .= " / <span class='success'>" . get_lang('mysql_online') . "</span>"; } else { $server_status .= "/<span class='failure'>" . get_lang('mysql_offline') . "</span>"; } } elseif ($host_stat === -1) { $server_status = "<span class='failure'>" . get_lang('encryption_key_mismatch') . "</span>\n"; } else { $server_status = "<span class='failure'>" . get_lang('unknown_error') . ": {$host_stat}</span>\n"; } } else { @($link = mysql_connect($mysql_server['mysql_ip'] . ':' . $mysql_server['mysql_port'], 'root', $mysql_server['mysql_root_passwd'])); if ($link === FALSE) { $server_status = "<span class='failure'>" . get_lang('mysql_offline') . "</span>"; } else { $server_status = "<span class='success'>" . get_lang('mysql_online') . "</span>"; mysql_close($link); } } $databases = ""; $mysql_server_dbs = $modDb->getMysqlServerDBs($mysql_server['mysql_server_id']); if (!empty($mysql_server_dbs)) { foreach ($mysql_server_dbs as $mysql_db) { $databases .= $mysql_db['db_name'] . "<a href='?m=mysql&p=edit&mysql_server_id=" . $mysql_server['mysql_server_id'] . "&assign=true&db_id=" . $mysql_db['db_id'] . "&edit_db_settings'>[" . get_lang('edit') . "]</a>\n" . "<a href='?m=mysql&p=edit&mysql_server_id=" . $mysql_server['mysql_server_id'] . "&assign=true&db_id=" . $mysql_db['db_id'] . "&remove_db'>[" . get_lang('remove') . "]</a>\n" . "<br>"; } } $conection_type = $mysql_server['remote_server_id'] == 0 ? get_lang('direct_connection') : get_lang_f('connection_through_remote_server_named', $remote_server['remote_server_name']); $buttons = "<a href='?m=mysql&p=edit&mysql_server_id=" . $mysql_server['mysql_server_id'] . "&delete'>[" . get_lang('remove') . "]</a>\n" . "<a href='?m=mysql&p=edit&mysql_server_id=" . $mysql_server['mysql_server_id'] . "&edit'>[" . get_lang('edit') . "]</a>\n" . "<a href='?m=mysql&p=edit&mysql_server_id=" . $mysql_server['mysql_server_id'] . "&assign'>[" . get_lang('assign_db') . "]</a>\n"; $tittle = "<b>ID#:</b> <b style='color:red;'>" . $mysql_server['mysql_server_id'] . "</b></td>\n\t\t\t\t\t<td class='collapsible' ><b>" . get_lang('mysql_server_name') . ":</b> " . $mysql_server['mysql_name'] . "</td>\n\t\t\t\t\t<td class='collapsible' ><b>" . get_lang('server_status') . ":</b>{$server_status}</td>"; $data = "<tr class='expand-child' >\n\t\t\t\t <td>\n\t\t\t\t\t<b>" . get_lang('mysql_ip_port') . ":</b> " . $mysql_server['mysql_ip'] . ":" . $mysql_server['mysql_port'] . "<br />\n\t\t\t\t\t<b>" . get_lang('mysql_root_passwd') . ":</b> " . $mysql_server['mysql_root_passwd'] . "<br />\n\t\t\t\t\t<b>" . get_lang('connection_method') . ":</b> " . $conection_type . "<br />\n\t\t\t\t\t<b>" . get_lang('user_privilegies') . ":</b> " . $mysql_server['privilegies_str'] . "<br />\n\t\t\t\t </td>\n\t\t\t\t <td>\n\t\t\t\t <b>" . get_lang('current_dbs') . ":</b><br />" . $databases . "</td>\n\t\t\t\t <td>\n\t\t\t\t {$buttons}\n\t\t\t\t </td>\n\t\t\t\t </tr>"; // Template $first = "<tr class='maintr'><td class='collapsible' >{$tittle}</td></tr>"; $second = $data; //Echo them all echo "{$first}{$second}"; } echo "</tbody>"; echo "</table>\n"; ?> <script type="text/javascript"> $(document).ready(function(){ $("#servermonitor") .collapsible("td.collapsible", {collapse: true}) .tablesorter({sortList: [[0,0], [1,0]] , widgets: ['zebra','repeatHeaders']}); }); </script> <?php unset($modDb); }
function exec_ogp_module() { $modDb = new MySQLModuleDatabase(); require "includes/config.inc.php"; $modDb->connect($db_host, $db_user, $db_pass, $db_name, $table_prefix); global $view, $db; $mysql_server_id = @$_REQUEST['mysql_server_id']; $mysql_server = $modDb->getMysqlServer($mysql_server_id); if ($mysql_server['remote_server_id'] == "0") { $server_homes = $db->getGameHomes(); } else { $server_homes = $modDb->getGameHomesByRemoteServerId($mysql_server['remote_server_id']); } $homes_array[0] = get_lang('select_game_server'); foreach ($server_homes as $server_home) { $homes_array["{$server_home['home_id']}"] = "(ID " . $server_home['home_id'] . ") " . $server_home['home_name']; } if ($mysql_server === FALSE) { print_failure(get_lang_f('invalid_mysql_server_id', $mysql_server_id)); $view->refresh("?m=mysql&p=mysql_admin"); return; } if (isset($_REQUEST['add_db'])) { $home_id = $_POST['home_id']; $db_user = trim($_POST['db_user']); $db_passwd = trim($_POST['db_passwd']); $db_name = trim($_POST['db_name']); $enabled = $_POST['enabled']; if (empty($db_user)) { print_failure(get_lang('enter_db_user')); } elseif (empty($db_passwd)) { print_failure(get_lang('enter_db_password')); } elseif (empty($db_name)) { print_failure(get_lang('enter_db_name')); } elseif ($home_id == 0) { print_failure(get_lang('select_game_server')); } else { $db_id = $modDb->addMysqlServerDB($mysql_server_id, $home_id, $db_user, $db_passwd, $db_name, $enabled); if (!$db_id) { print_failure(get_lang_f('there_is_another_db_named_or_user_named', $db_name, $db_user)); } else { $mysql_db = $modDb->getMysqlDBbyId($db_id); if (!$mysql_db) { return; } if ($mysql_db['remote_server_id'] != "0") { $remote_server = $db->getRemoteServer($mysql_db['remote_server_id']); $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key']); $host_stat = $remote->status_chk(); if ($host_stat === 1) { $command = "mysql -h localhost -P " . $mysql_db['mysql_port'] . " -u root -p" . $mysql_db['mysql_root_passwd'] . ' -e exit; echo $?'; $test_mysql_conn = $remote->exec($command); if ($test_mysql_conn == 0) { $SQL = "CREATE DATABASE IF NOT EXISTS \\`" . $mysql_db['db_name'] . "\\`;" . "GRANT " . $mysql_db['privilegies_str'] . " ON \\`" . $mysql_db['db_name'] . "\\`.* TO '" . $mysql_db['db_user'] . "'@'localhost' IDENTIFIED BY '" . $mysql_db['db_passwd'] . "';" . "FLUSH PRIVILEGES;"; $command = "mysql --host=localhost --port=" . $mysql_db['mysql_port'] . " -uroot -p" . $mysql_db['mysql_root_passwd'] . " -e \"" . $SQL . "\""; $result = $remote->exec($command); } } } else { @($link = mysql_connect($mysql_db['mysql_ip'] . ':' . $mysql_db['mysql_port'], $mysql_db['db_user'], $mysql_db['db_passwd'])); if ($link === FALSE) { @($link = mysql_connect($mysql_db['mysql_ip'] . ':' . $mysql_db['mysql_port'], 'root', $mysql_db['mysql_root_passwd'])); if ($link !== FALSE) { $queries = array("CREATE DATABASE IF NOT EXISTS `" . $mysql_db['db_name'] . "`;", "GRANT " . $mysql_db['privilegies_str'] . " ON `" . $mysql_db['db_name'] . "`.* TO '" . $mysql_db['db_user'] . "'@'" . $mysql_db['mysql_ip'] . "' IDENTIFIED BY '" . $mysql_db['db_passwd'] . "';", "FLUSH PRIVILEGES;"); foreach ($queries as $query) { @($return = mysql_query($query)); if (!$return) { break; } } mysql_close($link); } } } print_success(get_lang_f('db_added_for_home_id', $_POST['home_id'])); } } $view->refresh("?m=mysql&p=mysql_admin&p=edit&mysql_server_id=" . $mysql_server_id . "&assign", 5); } else { if (isset($_REQUEST['remove_db'])) { $db_id = $_REQUEST['db_id']; $mysql_db = $modDb->getMysqlDBbyId($db_id); if ($mysql_db['remote_server_id'] != "0") { $remote_server = $db->getRemoteServer($mysql_db['remote_server_id']); $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key']); $host_stat = $remote->status_chk(); if ($host_stat === 1) { $remote->exec('mysql --host=localhost --port=' . $mysql_db['mysql_port'] . ' -uroot -p' . $mysql_db['mysql_root_passwd'] . ' -e "DROP DATABASE ' . $mysql_db['db_name'] . ";DROP USER '" . $mysql_db['db_user'] . "'@'" . $mysql_db['mysql_ip'] . "';\""); } } else { @($link = mysql_connect($mysql_db['mysql_ip'] . ':' . $mysql_db['mysql_port'], 'root', $mysql_db['mysql_root_passwd'])); if ($link !== FALSE) { $queries = array("DROP DATABASE " . $mysql_db['db_name'] . ";", "DROP USER '" . $mysql_db['db_user'] . "'@'" . $mysql_db['mysql_ip'] . "';"); foreach ($queries as $query) { @($return = mysql_query($query)); if (!$return) { break; } } mysql_close($link); $modDb->connect($db_host, $db_user, $db_pass, $db_name, $table_prefix); } } if ($modDb->removeMysqlServerDB($db_id) === FALSE) { print_failure(get_lang('could_not_remove_db')); } else { print_success(get_lang_f('db_removed_successfully_from_mysql_server_named', $mysql_db['mysql_name'])); } $view->refresh("?m=mysql&p=mysql_admin&p=edit&mysql_server_id=" . $mysql_server_id . "&assign"); } else { if (isset($_POST['save_db_changes'])) { $db_id = $_POST['db_id']; $home_id = $_POST['home_id']; $post_db_user = trim($_POST['db_user']); $post_db_passwd = trim($_POST['db_passwd']); $post_db_name = trim($_POST['db_name']); $enabled = $_POST['enabled']; if (empty($post_db_passwd)) { print_failure(get_lang('enter_db_password')); } elseif ($home_id == 0) { print_failure(get_lang('select_game_server')); } else { $mysql_db = $modDb->getMysqlDBbyId($db_id); if ($post_db_passwd != $mysql_db['db_passwd']) { if ($mysql_db['remote_server_id'] != "0") { $remote_server = $db->getRemoteServer($mysql_db['remote_server_id']); $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key']); $host_stat = $remote->status_chk(); if ($host_stat === 1) { $SQL = "DROP USER '" . $mysql_db['db_user'] . "'@'" . $mysql_server['mysql_ip'] . "';" . "GRANT " . $mysql_db['privilegies_str'] . " ON \\`" . $mysql_db['db_name'] . "\\`.* TO '" . $mysql_db['db_user'] . "'@'localhost' IDENTIFIED BY '" . $post_db_passwd . "';" . "FLUSH PRIVILEGES;"; $command = "mysql --host=localhost --port=" . $mysql_db['mysql_port'] . " -uroot -p" . $mysql_db['mysql_root_passwd'] . " -e \"" . $SQL . "\""; $remote->exec($command); } } else { @($link = mysql_connect($mysql_db['mysql_ip'] . ':' . $mysql_db['mysql_port'], 'root', $mysql_db['mysql_root_passwd'])); if ($link !== FALSE) { $queries = array("DROP USER '" . $mysql_db['db_user'] . "'@'" . $mysql_server['mysql_ip'] . "';", "GRANT " . $mysql_db['privilegies_str'] . " ON `" . $mysql_db['db_name'] . "`.* TO '" . $mysql_db['db_user'] . "'@'" . $mysql_db['mysql_ip'] . "' IDENTIFIED BY '" . $post_db_passwd . "';", "FLUSH PRIVILEGES;"); foreach ($queries as $query) { @($return = mysql_query($query)); if (!$return) { break; } } mysql_close($link); $modDb->connect($db_host, $db_user, $db_pass, $db_name, $table_prefix); } } } if ($enabled != $mysql_db['enabled']) { if ($mysql_db['remote_server_id'] != "0") { $remote_server = $db->getRemoteServer($mysql_db['remote_server_id']); $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key']); $host_stat = $remote->status_chk(); if ($host_stat === 1) { if ($enabled == "0") { $SQL = "DROP USER '" . $mysql_db['db_user'] . "'@'" . $mysql_server['mysql_ip'] . "';" . "FLUSH PRIVILEGES;"; } else { $SQL = "GRANT " . $mysql_db['privilegies_str'] . " ON \\`" . $mysql_db['db_name'] . "\\`.* TO '" . $mysql_db['db_user'] . "'@'localhost' IDENTIFIED BY '" . $post_db_passwd . "';" . "FLUSH PRIVILEGES;"; } $command = "mysql --host=localhost --port=" . $mysql_db['mysql_port'] . " -uroot -p" . $mysql_db['mysql_root_passwd'] . " -e \"" . $SQL . "\""; $remote->exec($command); } } else { @($link = mysql_connect($mysql_db['mysql_ip'] . ':' . $mysql_db['mysql_port'], 'root', $mysql_db['mysql_root_passwd'])); if ($link !== FALSE) { if ($enabled == "0") { $queries = array("DROP USER '" . $mysql_db['db_user'] . "'@'" . $mysql_server['mysql_ip'] . "';", "FLUSH PRIVILEGES;"); } else { $queries = array("GRANT " . $mysql_db['privilegies_str'] . " ON `" . $mysql_db['db_name'] . "`.* TO '" . $mysql_db['db_user'] . "'@'" . $mysql_db['mysql_ip'] . "' IDENTIFIED BY '" . $post_db_passwd . "';", "FLUSH PRIVILEGES;"); } foreach ($queries as $query) { @($return = mysql_query($query)); if (!$return) { break; } } mysql_close($link); $modDb->connect($db_host, $db_user, $db_pass, $db_name, $table_prefix); } } } if ($modDb->editMysqlServerDB($db_id, $home_id, $post_db_user, $post_db_passwd, $post_db_name, $enabled) === FALSE) { print_failure(get_lang('could_not_be_changed')); } else { print_success(get_lang_f('db_changed_successfully', $post_db_name)); } } $view->refresh("?m=mysql&p=mysql_admin&p=edit&mysql_server_id=" . $mysql_server_id . "&assign"); } else { if (isset($_REQUEST['delete'])) { if (!isset($_REQUEST['y'])) { echo "<p>" . get_lang_f('areyousure_remove_mysql_server', $mysql_server['mysql_name']) . "</p>\n <p><a href='?m=mysql&p=mysql_admin&p=edit&mysql_server_id=" . $mysql_server_id . "&delete&y=y'>" . get_lang('yes') . "</a> <a href='?m=mysql&p=mysql_admin'>" . get_lang('no') . "</a></p>"; return; } else { $mysql_dbs = $modDb->getMysqlServerDBs($mysql_server_id); if (!empty($mysql_dbs)) { foreach ($mysql_dbs as $mysql_db) { if ($mysql_server['remote_server_id'] != "0") { $remote_server = $db->getRemoteServer($mysql_server['remote_server_id']); $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key']); $host_stat = $remote->status_chk(); if ($host_stat === 1) { $remote->exec('mysql --host=localhost --port=' . $mysql_server['mysql_port'] . ' -uroot -p' . $mysql_server['mysql_root_passwd'] . ' -e "DROP DATABASE ' . $mysql_db['db_name'] . ";DROP USER '" . $mysql_db['db_user'] . "'@'" . $mysql_server['mysql_ip'] . "';\""); } } else { @($link = mysql_connect($mysql_server['mysql_ip'] . ':' . $mysql_server['mysql_port'], 'root', $mysql_server['mysql_root_passwd'])); if ($link !== FALSE) { $queries = array("DROP DATABASE " . $mysql_db['db_name'] . ";", "DROP USER '" . $mysql_db['db_user'] . "'@'" . $mysql_server['mysql_ip'] . "';"); foreach ($queries as $query) { @($return = mysql_query($query)); if (!$return) { break; } } mysql_close($link); } } } } if ($modDb->removeMysqlServer($mysql_server_id) === FALSE) { print_failure(get_lang('error_while_remove')); } else { print_success(get_lang_f('mysql_server_removed', $mysql_server['mysql_name'])); } } $view->refresh("?m=mysql&p=mysql_admin"); return; } else { if (isset($_POST['save_settings'])) { foreach ($_POST as $name => $value) { $get[$name] = trim($value); } if (empty($get['mysql_ip'])) { print_failure(get_lang('enter_mysql_ip')); } elseif (!isPortValid($get['mysql_port'])) { print_failure(get_lang('enter_valid_port')); } elseif (empty($get['mysql_root_passwd'])) { print_failure(get_lang('enter_mysql_root_password')); } elseif (empty($get['mysql_name'])) { print_failure(get_lang('enter_mysql_name')); } elseif (!$modDb->editMysqlServer($mysql_server_id, $get['remote_server_id'], $get['mysql_name'], $get['mysql_ip'], $get['mysql_port'], $get['mysql_root_passwd'], $mysql_server['privilegies_str'])) { print_failure(get_lang_f('unable_to_set_changes_to', $mysql_server['mysql_name'])); } else { print_success(get_lang_f('mysql_server_settings_changed', $mysql_server['mysql_name'])); } $view->refresh("?m=mysql&p=mysql_admin&p=edit&mysql_server_id=" . $mysql_server_id . "&edit", 5); } elseif (isset($_GET['edit'])) { echo "<h2>" . get_lang_f('editing_mysql_server', $mysql_server['mysql_name']) . "</h2>"; $mysql_server = $modDb->getMysqlServer($mysql_server_id); $servers = $db->getRemoteServers(); $conn_method[0] = get_lang('direct_connection'); foreach ($servers as $server_row) { $id = $server_row['remote_server_id']; $name = get_lang_f('connection_through_remote_server_named', $server_row['remote_server_name']); $conn_method[$id] = $name; } $ft = new FormTable(); $ft->start_form('?m=mysql&p=edit&mysql_server_id=' . $mysql_server_id . '&edit'); $ft->start_table(); $ft->add_custom_field('connection_method', create_drop_box_from_array($conn_method, "remote_server_id", $mysql_server['remote_server_id'], false)); $ft->add_field('string', 'mysql_name', $mysql_server['mysql_name']); $ft->add_field('string', 'mysql_ip', $mysql_server['mysql_ip']); $ft->add_field('string', 'mysql_port', $mysql_server['mysql_port']); $ft->add_field('string', 'mysql_root_passwd', $mysql_server['mysql_root_passwd']); $ft->end_table(); $ft->add_button("submit", "save_settings", get_lang('save_settings')); $ft->end_form(); echo create_back_button('mysql', 'mysql_admin'); } elseif (isset($_GET['assign'])) { echo "<h2>" . get_lang_f('mysql_dbs_for', $mysql_server['mysql_name']) . "</h2>"; $mysql_server_dbs = $modDb->getMysqlServerDBs($mysql_server['mysql_server_id']); if (!empty($mysql_server_dbs)) { echo "<h4>" . get_lang('edit_dbs') . "</h4>"; foreach ($mysql_server_dbs as $mysql_db) { $home_info = $db->getGameHomeWithoutMods($mysql_db['home_id']); $db_array["{$mysql_db['db_id']}"] = $mysql_db['db_name'] . " (" . $home_info['home_name'] . ")"; } $ft = new FormTable(); $ft->start_form('', 'GET'); $ft->add_field_hidden('m', 'mysql'); $ft->add_field_hidden('p', 'edit'); $ft->add_field_hidden('mysql_server_id', $mysql_server_id); $ft->add_field_hidden('assign', 'true'); $ft->start_table(); $ft->add_custom_field('select_db', create_drop_box_from_array($db_array, "db_id", isset($_GET['db_id']) ? $_GET['db_id'] : "", false)); $ft->end_table(); $ft->add_button('submit', 'edit_db_settings', get_lang('edit_db_settings')); $ft->add_button('submit', 'remove_db', get_lang('remove_db')); $ft->end_form(); if (isset($_GET['edit_db_settings'])) { $mysql_db = $modDb->getMysqlDBbyId($_GET['db_id']); $ft = new FormTable(); $ft->start_form(''); $ft->add_field_hidden('db_id', $mysql_db['db_id']); $ft->start_table(); $ft->add_custom_field('game_server', create_drop_box_from_array($homes_array, "home_id", $mysql_db['home_id'], false)); $ft->add_field('string', 'db_user', $mysql_db['db_user'], "50", "readonly"); $ft->add_field('string', 'db_passwd', $mysql_db['db_passwd']); $ft->add_field('string', 'db_name', $mysql_db['db_name'], "50", "readonly"); $ft->add_field('on_off', 'enabled', $mysql_db['enabled']); $ft->end_table(); $ft->add_button('submit', 'save_db_changes', get_lang('save_db_changes')); $ft->end_form(); } } echo "<h4>" . get_lang('add_db') . "</h4>"; $ft = new FormTable(); $ft->start_form(''); $ft->start_table(); $ft->add_custom_field('game_server', create_drop_box_from_array($homes_array, "home_id", "0", false)); $ft->add_field('string', 'db_user', ''); $ft->add_field('string', 'db_passwd', genRandomString('10')); $ft->add_field('string', 'db_name', ''); $ft->add_field('on_off', 'enabled', '1'); $ft->end_table(); $ft->add_button('submit', 'add_db', get_lang('add_db')); $ft->end_form(); echo create_back_button('mysql', 'mysql_admin'); } else { print_failure("Invalid url."); $view->refresh("?m=mysql&p=mysql_admin"); } } } } } }
function exec_ogp_module() { global $db; global $view; $home_id = $_REQUEST['home_id']; $isAdmin = $db->isAdmin($_SESSION['user_id']); if ($isAdmin) { $home_info = $db->getGameHome($home_id); } else { $home_info = $db->getUserGameHome($_SESSION['user_id'], $home_id); } if ($home_info == FALSE) { print_failure(get_lang('no_rights_to_start_server')); echo "<table class='center'><tr><td><a href='?m=gamemanager&p=game_monitor&home_id-mod_id-ip-port=" . $home_info['home_id'] . "-" . $home_info['mod_id'] . "-" . $_REQUEST['ip'] . "-" . $_REQUEST['port'] . "'><< " . get_lang('back') . "</a></td></tr></table>"; return; } $mod_id = $_REQUEST['mod_id']; if (!array_key_exists($mod_id, $home_info['mods'])) { print_failure("Unable to retrieve mod information from database."); return; } echo "<h2>"; echo empty($home_info['home_name']) ? get_lang('not_available') : $home_info['home_name']; echo "</h2>"; require_once 'includes/lib_remote.php'; $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']); $server_xml = read_server_config(SERVER_CONFIG_LOCATION . "/" . $home_info['home_cfg_file']); if (!$server_xml) { echo "<table class='center'><tr><td><a href='?m=gamemanager&p=game_monitor&home_id-mod_id-ip-port=" . $home_info['home_id'] . "-" . $home_info['mod_id'] . "-" . $_REQUEST['ip'] . "-" . $_REQUEST['port'] . "'><< " . get_lang('back') . "</a></td></tr></table>"; return; } // It compares ip and port on POST with the pair on DB for security reasons (URL HACKING) $home_id = $home_info['home_id']; $ip_info = $db->getHomeIpPorts($home_id); foreach ($ip_info as $ip_ports_row) { if ($ip_ports_row['ip'] == $_REQUEST['ip'] && $ip_ports_row['port'] == $_REQUEST['port']) { $ip = $ip_ports_row['ip']; $port = $ip_ports_row['port']; } } if (!isset($ip) or !isset($port)) { echo "<h2>" . get_lang_f('ip_port_pair_not_owned') . "</h2>"; echo "<table class='center'><tr><td><a href='?m=gamemanager&p=game_monitor&home_id-mod_id-ip-port={$home_id}-{$mod_id}-{$ip}-{$port}'><< " . get_lang('back') . "</a></td></tr></table>"; return; } if (isset($server_xml->console_log)) { $log_retval = $remote->remote_readfile($home_info['home_path'] . '/' . $server_xml->console_log, $home_log); } else { $log_retval = $remote->get_log(OGP_SCREEN_TYPE_HOME, $home_info['home_id'], clean_path($home_info['home_path'] . "/" . $server_xml->exe_location), $home_log); } function getLastLines($string, $n = 1) { $lines = explode("\n", $string); $lines = array_slice($lines, -$n); return implode("\n", $lines); } $home_log = getLastLines($home_log, 40); if ($log_retval > 0) { if ($log_retval == 2) { print_failure(get_lang('server_not_running_log_found')); } echo "<pre style='background:black;color:white;'>" . $home_log . "</pre>"; if ($log_retval == 2) { return; } } else { print_failure(get_lang_f('unable_to_get_log', $log_retval)); } // If game is not supported by lgsl we skip the lgsl checks and // assume successfull start. if ($home_info['use_nat'] == 1) { $query_ip = $home_info['agent_ip']; } else { $query_ip = $ip; } $running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME, $home_info['home_id']); if ($server_xml->lgsl_query_name) { require 'protocol/lgsl/lgsl_protocol.php'; $get_q_and_s = lgsl_port_conversion((string) $server_xml->lgsl_query_name, $port, "", ""); //Connection port $c_port = $get_q_and_s['0']; //query port $q_port = $get_q_and_s['1']; //software port $s_port = $get_q_and_s['2']; $data = lgsl_query_live((string) $server_xml->lgsl_query_name, $query_ip, $c_port, $q_port, $s_port, "sa"); if ($data['b']['status'] == "0") { $running = FALSE; } } elseif ($server_xml->gameq_query_name) { require 'protocol/GameQ/GameQ.php'; $query_port = get_query_port($server_xml, $port); $servers = array(array('id' => 'server', 'type' => (string) $server_xml->gameq_query_name, 'host' => $query_ip . ":" . $query_port)); $gq = new GameQ(); $gq->addServers($servers); $gq->setOption('timeout', 4); $gq->setOption('debug', FALSE); $gq->setFilter('normalise'); $game = $gq->requestData(); if (!$game['server']['gq_online']) { $running = FALSE; } } if (!$running) { if (!isset($_GET['retry'])) { $retry = 0; } else { $retry = $_GET['retry']; } if ($retry >= 5) { echo "<p>" . get_lang('server_running_not_responding') . "\n\t\t\t<a href=?m=gamemanager&p=stop&home_id=" . $home_info['home_id'] . "&ip=" . $ip . "&port=" . $port . ">" . get_lang('already_running_stop_server') . ".</a></p>"; echo "<table class='center'><tr><td><a href='?m=gamemanager&p=game_monitor&home_id-mod_id-ip-port={$home_id}-{$mod_id}-{$ip}-{$port}'><< " . get_lang('back') . "</a></td></tr></table>"; } echo "</b>Retry #" . $retry . ".</b>"; $retry++; print "<p class='note'>" . get_lang('starting_server') . "</p>"; $view->refresh("?m=gamemanager&p=start&refresh&ip={$ip}&port={$port}&home_id={$home_id}&mod_id={$mod_id}&retry=" . $retry, 3); return; } print_success(get_lang('server_started')); $ip_id = $db->getIpIdByIp($ip); $db->delServerStatusCache($ip_id, $port); $view->refresh("?m=gamemanager&p=game_monitor&home_id-mod_id-ip-port={$home_id}-{$mod_id}-{$ip}-{$port}"); return; }
function exec_ogp_module() { global $db; $isAdmin = $db->isAdmin($_SESSION['user_id']); $submit = isset($_REQUEST['submit']) ? $_REQUEST['submit'] : ""; $home_id = $_GET['home_id']; $enabled_mods = $db->getHomeMods($home_id); if ($isAdmin and isset($_POST['change_home_cfg_id'])) { if (!empty($enabled_mods)) { foreach ($enabled_mods as $enabled_rows) { $db->delGameMod($enabled_rows['mod_id']); } } $home_cfg_id = $game_home['home_cfg_id']; $new_home_cfg_id = $_POST['home_cfg_id']; if ($db->updateHomeCfgId($home_id, $new_home_cfg_id)) { print_success(get_lang('successfully_changed_game_server')); $db->logger(get_lang('successfully_changed_game_server') . " HOME ID:{$home_id} - " . get_lang('change_game_type') . ":old home_cfg_id:{$home_cfg_id}, new home_cfg_id:{$new_home_cfg_id}"); } $enabled_mods = $db->getHomeMods($home_id); } if ($isAdmin) { $game_home = $db->getGameHome($_GET['home_id']); } else { $game_home = $db->getUserGameHome($_SESSION['user_id'], $_GET['home_id']); } if (!$game_home and !$isAdmin) { return; } $home_info = $db->getGameHomeWithoutMods($home_id); $server_xml = read_server_config(SERVER_CONFIG_LOCATION . $home_info['home_cfg_file']); include 'includes/lib_remote.php'; $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']); $ftp_installed = $db->isModuleInstalled('ftp'); $screen_running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME, $home_info['home_id']) === 1; if ($isAdmin) { $game_home['access_rights'] = "ufpet"; } echo "<h2>" . get_lang('editing_home_called') . " \"" . $home_info['home_name'] . "\"</h2>"; if (isset($_REQUEST['change_name'])) { $server_name = $_POST['server_name']; if ($db->changeHomeName($home_id, $server_name) === TRUE) { print_success(get_lang('successfully_changed_game_server')); $db->logger(get_lang('successfully_changed_game_server') . " HOME ID:{$home_id} - " . get_lang('game_server_name') . ":{$server_name}"); } else { print_failure("Name update failed."); } } elseif (isset($_REQUEST['change_control_password'])) { $control_password = $_POST['control_password']; if ($db->changeHomeControlPassword($home_id, $control_password) === TRUE) { print_success(get_lang('control_password_updated_successfully')); $db->logger(get_lang('control_password_updated_successfully') . " HOME ID:{$home_id} - " . get_lang('game_control_password') . ":{$control_password}"); } else { print_failure(get_lang('control_password_update_failed')); } } elseif (isset($_REQUEST['change_ftp_login']) && preg_match("/t/", $game_home['access_rights']) > 0) { // Is FTP Module Installed? if ($ftp_installed) { if ($db->IsFtpEnabled($home_id) or $isAdmin) { $post_ftp_login = trim($_POST['ftp_login']); $host_stat = $remote->status_chk(); $user_exists = FALSE; $host_online = FALSE; if ($host_stat === 1) { $host_online = TRUE; $ftp_accounts_list = $remote->ftp_mgr("list"); $ftp_accounts = explode("\n", $ftp_accounts_list); foreach ($ftp_accounts as $ftp_account) { if ($ftp_account != "") { list($ftp_login, $ftp_path) = explode("\t", $ftp_account); $ftp_login = trim($ftp_login); if ($ftp_login == $post_ftp_login) { $user_exists = TRUE; break; } } } } if ($host_online and !$user_exists) { $old_login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id; $change_login_delete_old = $remote->ftp_mgr("userdel", $old_login); if ($change_login_delete_old !== 0) { $change_login_add_new = $remote->ftp_mgr("useradd", $post_ftp_login, $home_info['ftp_password'], $home_info['home_path']); } if (isset($change_login_add_new) and $change_login_add_new !== 0) { if ($db->changeFtpLogin($home_id, $post_ftp_login) === TRUE) { print_success(get_lang('successfully_changed_game_server')); $db->logger(get_lang('successfully_changed_game_server') . " HOME ID:{$home_id} - " . get_lang('server_ftp_login') . ":{$post_ftp_login}"); } } else { print_failure(get_lang('error_ocurred_on_remote_server') . " " . get_lang('ftp_login_can_not_be_changed')); } } else { print_failure(get_lang('error_ocurred_on_remote_server') . " " . get_lang('ftp_login_can_not_be_changed')); } } } } elseif (isset($_REQUEST['change_ftp_password']) && preg_match("/t/", $game_home['access_rights']) > 0) { // Is FTP Module Installed? if ($ftp_installed) { if ($db->IsFtpEnabled($home_id) or $isAdmin) { $ftp_password = $_POST['ftp_password']; $ftp_login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id; $change_passwd_on_remote = $remote->ftp_mgr("passwd", $ftp_login, $ftp_password); if ($change_passwd_on_remote !== 0) { if ($db->changeFtpPassword($home_id, clean_path($ftp_password)) === TRUE) { print_success(get_lang('successfully_changed_game_server')); $db->logger(get_lang('successfully_changed_game_server') . " HOME ID:{$home_id} - " . get_lang('server_ftp_password') . ":{$ftp_password}"); } } else { print_failure(get_lang('error_ocurred_on_remote_server') . " " . get_lang('ftp_password_can_not_be_changed')); } } } } elseif (isset($_POST["force_mod_id"])) { $force_mod_id = $_POST['force_mod_id']; $ip_id = $_POST['ip_id']; $port = $_POST['port']; if ($db->forceModAtAddress($ip_id, $port, $force_mod_id)) { print_success(get_lang('successfully_assigned_mod_to_address')); $db->logger(get_lang('successfully_assigned_mod_to_address')); } else { print_failure("Failed to assign mod to address."); } } elseif ($isAdmin) { if (isset($_REQUEST['create_ftp'])) { $login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id; $create_ftp = $remote->ftp_mgr("useradd", $login, $home_info['ftp_password'], $home_info['home_path']); if ($create_ftp === 0) { print_failure(get_lang('error_ocurred_on_remote_server') . " " . get_lang('ftp_can_not_be_switched_on')); } else { $db->changeFtpStatus('enabled', $home_id); print_success(get_lang('successfully_changed_game_server')); $db->logger(get_lang('successfully_changed_game_server') . " HOME ID:{$home_id} - " . get_lang('change_ftp_account_status') . ":enabled"); } } else { if (isset($_REQUEST['delete_ftp'])) { $login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id; $delete_ftp = $remote->ftp_mgr("userdel", $login); if ($delete_ftp === 0) { print_failure(get_lang('error_ocurred_on_remote_server') . " " . get_lang('ftp_can_not_be_switched_off')); } else { $db->changeFtpStatus('disabled', $home_id); print_success(get_lang('successfully_changed_game_server')); $db->logger(get_lang('successfully_changed_game_server') . " HOME ID:{$home_id} - " . get_lang('change_ftp_account_status') . ":disabled"); } } else { if (isset($_REQUEST['change_user_id_main'])) { $user_id_main = $_POST['user_id_main']; if (isset($_POST['deleteoldassigns'])) { $db->unassignHomeFrom("user", $home_info['user_id_main'], $home_id); $home_groups = $db->getGroupsForHome($home_info['home_id']); if (isset($home_groups)) { foreach ($home_groups as $home_group) { $db->unassignHomeFrom("group", $home_group['group_id'], $home_id); } } } $old_home = $db->getUserGameHome($home_info['user_id_main'], $home_id); if ($db->changeUserIdMain($home_id, clean_path($user_id_main)) === TRUE && $db->assignHomeTo("user", $user_id_main, $home_id, $old_home['access_rights']) === TRUE) { print_success(get_lang('successfully_changed_game_server')); $db->logger(get_lang('successfully_changed_game_server') . " HOME ID:{$home_id} - " . get_lang('change_user_id_main') . ":{$user_id_main}"); } } else { if (isset($_REQUEST['change_home'])) { $home_path = $_POST['home_path']; if ($db->changeHomePath($home_id, clean_path($home_path)) === TRUE) { if ($ftp_installed) { if ($db->IsFtpEnabled($home_id)) { $login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id; $delte_old_ftp_account = $remote->ftp_mgr("userdel", $login); if ($delte_old_ftp_account !== 0) { $create_new_ftp_account = $remote->ftp_mgr("useradd", $login, $home_info['ftp_password'], $home_path); } if (isset($create_new_ftp_account) and $create_new_ftp_account !== 0) { print_success(get_lang('successfully_changed_game_server')); $db->logger(get_lang('successfully_changed_game_server') . " HOME ID:{$home_id} - " . get_lang('home_path') . ":{$home_path}"); } else { print_failure(get_lang('error_ocurred_on_remote_server') . " " . get_lang('ftp_login_can_not_be_changed')); } } else { print_success(get_lang('successfully_changed_game_server')); $db->logger(get_lang('successfully_changed_game_server') . " HOME ID:{$home_id} - " . get_lang('home_path') . ":{$home_path}"); } } else { print_success(get_lang('successfully_changed_game_server')); $db->logger(get_lang('successfully_changed_game_server') . " HOME ID:{$home_id} - " . get_lang('home_path') . ":{$home_path}"); } } } else { if (isset($_REQUEST['master_server'])) { if (isset($_POST['add'])) { $action = "add"; } else { $action = "remove"; } if ($db->setMasterServer($action, $home_id, $home_info['home_cfg_id'], $home_info['remote_server_id']) === TRUE) { print_success(get_lang('successfully_changed_game_server')); $db->logger(get_lang('successfully_changed_game_server') . " HOME ID:{$home_id} - " . get_lang('set_as_master_server') . ":{$action}"); } } } } } } if (isset($_REQUEST['add_mod'])) { $mod_cfg_id = $_POST['mod_cfg_id']; if ($db->addModToGameHome($home_id, $mod_cfg_id) === FALSE) { print_failure(get_lang_f('failed_to_assing_mod_to_home', $mod_cfg_id)); } else { print_success(get_lang_f('successfully_assigned_mod_to_home', $mod_cfg_id)); $db->logger(get_lang_f('successfully_assigned_mod_to_home', $mod_cfg_id) . " [HOME ID:{$home_id}]"); } } else { if ($submit == "delete_mod") { $mod_id = $_GET['mod_id']; if ($db->delGameMod($mod_id) === TRUE) { print_success(get_lang('successfully_removed_mod')); } $db->logger(get_lang('successfully_removed_mod') . " [MOD ID:{$mod_id} HOME ID:{$home_id}]"); } else { if (isset($_REQUEST['set_options'])) { $maxplayers = 0 + @$_POST['maxplayers']; $cliopts = $_POST['cliopts']; $cpus = $_POST['cpus']; $nice = $_POST['nice']; $mod_cfg_id = $_POST['mod_cfg_id']; $db->updateGameModParams($maxplayers, $cliopts, $cpus, $nice, $home_id, $mod_cfg_id); print_success(get_lang("successfully_modified_mod")); $db->logger(get_lang('successfully_modified_mod') . " [MOD CFG ID:{$mod_cfg_id} HOME ID:{$home_id}]"); echo "<meta http-equiv='refresh' content='2'>"; } } } } $home_info = $db->getGameHomeWithoutMods($home_id); $custom_fileds_access_enabled = preg_match("/c/", $game_home['access_rights']) > 0 ? TRUE : FALSE; echo "<p>"; echo "<a href='?m=gamemanager&p=game_monitor&home_id={$home_id}'><< " . get_lang('back_to_game_monitor') . "</a>"; if ($isAdmin) { echo " "; echo "<a href='?m=user_games'><< " . get_lang('back_to_game_servers') . "</a>"; $custom_fileds_access_enabled = TRUE; } if (isset($server_xml->custom_fields) and $custom_fileds_access_enabled) { echo " <a href='?m=user_games&p=custom_fields&home_id=" . $home_id . "'>" . get_lang('go_to_custom_fields') . " >></a>"; } echo "</p>"; echo "<table class='center'>"; if ($isAdmin) { // Form to change game type echo "<tr><td rowspan='2' class='right'>" . get_lang('game_type') . ":</td><td class='left'>"; echo "<form action='?m=user_games&p=edit&home_id=" . $home_id . "' method='post'>"; $game_cfgs = $db->getGameCfgs(); $host_stat = $remote->status_chk(); if ($host_stat === 1) { $os = $remote->what_os(); } else { $os = "Unknown OS"; } echo "<select name='home_cfg_id' >"; // Linux 64 bits + wine if (preg_match("/Linux/", $os) and preg_match("/64/", $os) and preg_match("/wine/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/linux/", $row['game_key'])) { $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : ""; echo "<option value='" . $row['home_cfg_id'] . "' {$selected}>" . $row['game_name']; if (preg_match("/64/", $row['game_key'])) { echo " (64 bit)"; } echo "</option>\n"; } } echo "<option style='background:black;color:white;' value=''>" . get_lang('wine_games') . ":</option>\n"; foreach ($game_cfgs as $row) { if (preg_match("/win/", $row['game_key'])) { $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : ""; echo "<option value='" . $row['home_cfg_id'] . "' {$selected}>" . $row['game_name']; if (preg_match("/64/", $row['game_key'])) { echo " (64 bit)"; } echo "</option>\n"; } } } elseif (preg_match("/Linux/", $os) and preg_match("/64/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/linux/", $row['game_key'])) { $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : ""; echo "<option value='" . $row['home_cfg_id'] . "' {$selected}>" . $row['game_name']; if (preg_match("/64/", $row['game_key'])) { echo " (64 bit)"; } echo "</option>\n"; } } } elseif (preg_match("/Linux/", $os) and preg_match("/wine/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/linux32/", $row['game_key'])) { $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : ""; echo "<option value='" . $row['home_cfg_id'] . "' {$selected}>" . $row['game_name'] . "</option>\n"; } } echo "<option style='background:black;color:white;' value=''>" . get_lang('wine_games') . "</option>\n"; foreach ($game_cfgs as $row) { if (preg_match("/win32/", $row['game_key'])) { $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : ""; echo "<option value='" . $row['home_cfg_id'] . "' {$selected}>" . $row['game_name'] . "</option>\n"; } } } elseif (preg_match("/Linux/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/linux32/", $row['game_key'])) { $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : ""; echo "<option value='" . $row['home_cfg_id'] . "' {$selected}>" . $row['game_name'] . "</option>\n"; } } } elseif (preg_match("/CYGWIN/", $os) and preg_match("/64/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/win/", $row['game_key'])) { $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : ""; echo "<option value='" . $row['home_cfg_id'] . "' {$selected}>" . $row['game_name']; if (preg_match("/64/", $row['game_key'])) { echo " (64 bit)"; } echo "</option>\n"; } } } elseif (preg_match("/CYGWIN/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/win32/", $row['game_key'])) { $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : ""; echo "<option value='" . $row['home_cfg_id'] . "' {$selected}>" . $row['game_name'] . "</option>\n"; } } } elseif ($os == "Unknown OS") { foreach ($game_cfgs as $row) { $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : ""; echo "<option value='" . $row['home_cfg_id'] . "' {$selected}>" . $row['game_name']; if (preg_match("/64/", $row['game_key'])) { echo " (64 bit)"; } echo "</option>\n"; } } echo "</select>\n</td></tr>"; echo "<tr><td class='left'><input type='submit' name='change_home_cfg_id' value='" . get_lang('change_game_type') . "' />"; echo "</form></td></tr>"; echo "<tr><td colspan='2' class='info'>" . get_lang('change_game_type_info') . "</td></tr>"; // Form to edit main user. echo "<tr><td rowspan='3' class='right'>" . get_lang('user_id_main') . ":</td><td class='left'>"; echo "<form action='?m=user_games&p=edit&home_id=" . $home_id . "' method='post'>"; echo "<input type='hidden' name='home_id' value=\"{$home_id}\" />\n"; echo "<select name='user_id_main'>"; $user = $db->getUserById($home_info['user_id_main']); echo "<option value='" . $home_info['user_id_main'] . "'>" . $user['users_login'] . "</option>\n"; $users = $db->getUserList(); foreach ($users as $user) { // Only users and admins can be assigned homes... not subusers if (is_null($user['users_parent'])) { if ($home_info['user_id_main'] != $user['user_id']) { echo "<option value='" . $user['user_id'] . "'>" . $user['users_login'] . "</option>\n"; } } } echo "</select></td></tr>"; echo "<tr><td><input type='checkbox' name='deleteoldassigns' id='deleteoldassigns' /><label for='deleteoldassigns' >" . get_lang('Delete_old_user_assigned_homes') . "</label></td></tr>"; echo "<tr><td class='left'><input type='submit' name='change_user_id_main' value='" . get_lang('change_user_id_main') . "' />"; echo "</form></td></tr>"; echo "<tr><td colspan='2' class='info'>" . get_lang('change_user_id_main_info') . "</td></tr>"; // Form to edit game path. echo "<tr><td class='right'>" . get_lang('home_path') . ":</td><td class='left'>"; echo "<form action='?m=user_games&p=edit&home_id=" . $home_id . "' method='post'>"; echo "<input type='hidden' name='home_id' value=\"{$home_id}\" />\n"; echo "<input type='text' size='30' name='home_path' value=" . $home_info['home_path'] . " />"; echo "<input type='submit' name='change_home' value='" . get_lang('change_home') . "' />"; echo "</form></td></tr>"; echo "<tr><td colspan='2' class='info'>" . get_lang('change_home_info') . "</td></tr>"; } // Form to edit game name echo "<tr><td class='right'>" . get_lang('game_server_name') . ":</td><td class='left'>"; echo "<form action='?m=user_games&p=edit&home_id=" . $home_id . "' method='post'>"; echo "<input type='hidden' name='home_id' value=\"{$home_id}\" />\n"; echo "<input type='text' size='30' name='server_name' value='" . $home_info['home_name'] . "' />"; echo "<input type=submit name='change_name' value='" . get_lang('change_name') . "' />"; echo "</form></td></tr>"; echo "<tr><td colspan='2' class='info'>" . get_lang('change_name_info') . "</td></tr>"; // Form to edit control password echo "<tr><td class='right'>" . get_lang('game_control_password') . ":</td><td class='left'>"; echo "<form action='?m=user_games&p=edit&home_id=" . $home_id . "' method='post'>"; echo "<input type='hidden' name='home_id' value=\"{$home_id}\" />\n"; echo "<input type='text' size='30' name='control_password' value='" . $home_info['control_password'] . "' />"; echo "<input type='submit' name='change_control_password' value='" . get_lang('change_control_password') . "' />"; echo "</form></td></tr>"; echo "<tr><td colspan='2' class='info'>" . get_lang('change_control_password_info') . "</td></tr>"; if (preg_match("/t/", $game_home['access_rights']) > 0 && $ftp_installed && $db->IsFtpEnabled($home_id)) { // Form to edit control ftp login $ftp_login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id; echo "<tr><td class='right'>" . get_lang('server_ftp_login') . ":</td><td class='left'>"; echo "<form action='?m=user_games&p=edit&home_id=" . $home_id . "' method='post'>"; echo "<input type='text' size='30' name='ftp_login' value='" . $ftp_login . "' />"; echo "<input type='submit' name='change_ftp_login' value='" . get_lang('change_ftp_login') . "' />"; echo "</form></td></tr>"; echo "<tr><td colspan='2' class='info'>" . get_lang('change_ftp_login_info') . "</td></tr>"; // Form to edit control ftp password echo "<tr><td class='right'>" . get_lang('server_ftp_password') . ":</td><td class='left'>"; echo "<form action='?m=user_games&p=edit&home_id=" . $home_id . "' method='post'>"; echo "<input type='text' size='30' name='ftp_password' value='" . $home_info['ftp_password'] . "' />"; echo "<input type='submit' name='change_ftp_password' value='" . get_lang('change_ftp_password') . "' />"; echo "</form></td></tr>"; echo "<tr><td colspan='2' class='info'>" . get_lang('change_ftp_password_info') . "</td></tr>"; } if ($isAdmin && $ftp_installed) { // Forms to enable/disable ftp account echo "<tr>"; echo "<td class='right'>" . get_lang('change_ftp_account_status') . ":</td>"; echo "<td class='left'>"; if (!$db->IsFtpEnabled($home_id)) { echo "<div style='display:block;float:left;' ><form action='?m=user_games&p=edit&home_id=" . $home_id . "' method='post'>"; echo "<input type='submit' name='create_ftp' value='" . get_lang('ftp_on') . "' />"; echo "</form></div>"; } else { echo "<div style='display:block;float:left;' ><form action='?m=user_games&p=edit&home_id=" . $home_id . "' method='post'>"; echo "<input type='submit' name='delete_ftp' value='" . get_lang('ftp_off') . "' />"; echo "</form></div>"; } echo "</td></tr>"; echo "<tr><td colspan='2' class='info'>" . get_lang('change_ftp_account_status_info') . "</td>"; echo "</tr>"; } if ($isAdmin) { $master_server_home_id = $db->getMasterServer($home_info['remote_server_id'], $home_info['home_cfg_id']); if ($master_server_home_id != FALSE and $master_server_home_id == $home_id) { $checked = 'checked ="checked"'; } else { $checked = ""; } // Form to enable/disable as master server for local update echo "</tr><tr><td class='right'>" . get_lang('master_server_for_clon_update') . ":</td><td class='left'>"; echo "<form action='?m=user_games&p=edit&home_id=" . $home_id . "' method='post'>"; echo "<input type='checkbox' name='add' {$checked} />"; echo "<input type='submit' name='master_server' value='" . get_lang('set_as_master_server') . "' />"; echo "</form></td></tr>"; echo "<tr><td colspan='2' class='info'>" . get_lang('set_as_master_server_for_local_clon_update') . " (" . get_lang_f('only_available_for', $server_xml->game_name, $home_info['remote_server_name']) . ")</td></tr>"; } echo "</table>"; if ($isAdmin) { $avail_ips = $db->getRemoteServerIPs($home_info['remote_server_id']); $ip_array = array(); if (is_array($avail_ips) && !empty($avail_ips)) { echo "<h3>" . get_lang('ips_and_ports') . "</h3>"; if (!$screen_running) { if (isset($_REQUEST['set_ip'])) { $ip_id = $_POST['ip']; $ip_row = $db->resultQuery("SELECT ip FROM OGP_DB_PREFIXremote_server_ips WHERE ip_id=" . $ip_id); $ip = $ip_row['0']['ip']; $port = $_POST['port']; $port = (int) trim($port); $home_id = $_POST['home_id']; if (!isPortValid($port)) { print_failure(get_lang('port_range_error')); } else { if ($db->addGameIpPort($home_id, $ip_id, $port) === FALSE) { print_failure(get_lang_f('ip_port_already_in_use', $ip, $port)); } else { print_success(get_lang_f('successfully_assigned_ip_port_to_server_id', $ip, $port, $home_id)); $db->logger(get_lang_f('successfully_assigned_ip_port_to_server_id', $ip, $port, $home_id)); } } } if (isset($_REQUEST["delete_ip"])) { $del_ip = $_GET['ip']; $del_port = $_GET['port']; if ($db->delGameIpPort($home_id, $del_ip, $del_port)) { print_success(get_lang('successfully_assigned_ip_port')); $db->logger(get_lang('successfully_assigned_ip_port') . " [unassigned]"); } else { print_failure("Failed to unassign ip:port."); } } echo "<form action='?m=user_games&p=edit&home_id=" . $home_id . "' method='post'>\n"; echo "<input type='hidden' name='home_id' value=\"{$home_id}\" />\n"; echo get_lang('ip') . ":<select name='ip' onchange='this.form.submit();'>"; foreach ($avail_ips as $value) { $selected = (isset($_POST['ip']) and $_POST['ip'] == $value['ip_id']) ? "selected='selected'" : ""; echo "<option value='" . $value['ip_id'] . "' {$selected} >" . $value['ip'] . "</option>\n"; } echo "</select>"; $ip_id = isset($_POST['ip']) ? $_POST['ip'] : $avail_ips[0]['ip_id']; $port = $db->getNextAvailablePort($ip_id, $home_info['home_cfg_id']); echo " " . get_lang('port') . ":<input type='text' name='port' value='" . $port . "' size='6' />"; echo "<input type='submit' name='set_ip' value='" . get_lang('set_ip') . "' />"; echo "</form>"; $assigned = $db->getHomeIpPorts($home_id); if (empty($assigned)) { print_failure(get_lang('no_ip_ports_assigned')); } else { foreach ($assigned as $assigned_rows) { $force_mod = ""; $align = "center"; if (!empty($enabled_mods) and count($enabled_mods) > 1) { $force_mod .= "<td align='left'>\n" . "<form action='?m=user_games&p=edit&home_id=" . $home_id . "' method='post'>\n" . "<input type='hidden' name='ip_id' value=" . $assigned_rows['ip_id'] . " />" . "<input type='hidden' name='port' value=" . $assigned_rows['port'] . " />" . "<select name='force_mod_id' onchange='this.form.submit();'>" . "<option value='0' >" . get_lang('force_mod_on_this_address') . "</option>"; foreach ($enabled_mods as $mod) { $selected = $mod['mod_id'] == $assigned_rows['force_mod_id'] ? "selected='selected'" : ""; $force_mod .= "<option value='" . $mod['mod_id'] . "' {$selected}>" . $mod['mod_name'] . "</option>"; } $force_mod .= "</select>\n</form>\n</td>\n"; $align = "right"; } echo "<table class='center'><tr><td align='{$align}'>" . $assigned_rows['ip'] . ":" . $assigned_rows['port'] . " <a href='?m=user_games&p=edit&home_id={$home_id}&delete_ip&ip=" . $assigned_rows['ip_id'] . "&port=" . $assigned_rows['port'] . "'>[ " . get_lang('delete') . " ]</a></td>\n" . $force_mod . "</tr>\n</table>\n"; } } } else { print_failure(get_lang('server_is_running_change_addresses_not_available')); } } else { print_failure(get_lang('no_ip_addresses_configured') . "<a href='?m=server'>" . get_lang('server_page') . "</a>."); } echo "<h3>" . get_lang('mods') . "</h3>"; echo "<p class='info'>" . get_lang('extra_cmd_line_info') . "</p>\n"; if (empty($enabled_mods)) { print_failure(get_lang('note') . ":" . get_lang('note_no_mods')); $cpu_count = $remote->cpu_count(); if ($cpu_count === -1) { print_failure(get_lang('warning_agent_offline_defaulting_CPU_count_to_1')); $cpu_count = 'NA'; } else { // cpu numbering starts from 0 so lets remove the last cpu. $cpu_count -= 1; } $game_mods = $db->getAvailableModsForGameHome($home_id); foreach ($game_mods as $game_mod) { if ($game_mod['mod_name'] == "none") { $mod_cfg_id = $game_mod['mod_cfg_id']; } if ($game_mod['mod_name'] == "None") { $mod_cfg_id = $game_mod['mod_cfg_id']; } } if (isset($mod_cfg_id)) { $db->addModToGameHome($home_id, $mod_cfg_id); $maxplayers = $server_xml->max_user_amount ? $server_xml->max_user_amount : 0; $db->updateGameModParams($maxplayers, '', 'NA', '0', $home_id, $mod_cfg_id); echo "<meta http-equiv='refresh' content='0'>"; return; } else { echo "<form action='?m=user_games&p=edit&home_id=" . $home_id . "' method='post'>\n"; echo "<input type='hidden' name='home_id' value=\"{$home_id}\" />\n"; echo "<p>" . get_lang('available_mods') . ": <select name='mod_cfg_id'>\n"; foreach ($game_mods as $game_mod) { echo "<option value='" . $game_mod['mod_cfg_id'] . "'>" . $game_mod['mod_name'] . "</option>\n"; } echo "</select>\n"; echo "<input type='submit' name='add_mod' value='" . get_lang('add_mod') . "' /></p>"; echo "</form>"; } } else { $cpu_count = $remote->cpu_count(); if ($cpu_count === -1) { print_failure(get_lang('warning_agent_offline_defaulting_CPU_count_to_1')); $cpu_count = 'NA'; } else { // cpu numbering starts from 0 so lets remove the last cpu. $cpu_count -= 1; } echo "<table class='center'>\n"; echo "<tr><td></td><td><b>" . get_lang('mod_name') . "</b></td>"; if ($server_xml->max_user_amount) { echo "<td><b>" . get_lang('max_players') . "</b></td>"; } echo "<td><b>" . get_lang('extra_cmd_line_args') . "</b></td><td><b>" . get_lang('cpu_affinity') . "</b></td>"; echo "<td><b>" . get_lang('nice_level') . "</b></td><td></td></tr>\n"; foreach ($enabled_mods as $enabled_rows) { echo "<form action='?m=user_games&p=edit&home_id=" . $home_id . "' method='post'><tr><td>\n" . "<input type='hidden' name='home_id' value=\"{$home_id}\" />\n" . "<input type='hidden' name='mod_cfg_id' value=\"" . $enabled_rows['mod_cfg_id'] . "\" />\n" . "<a href='?m=user_games&p=edit&mod_id=" . $enabled_rows['mod_id'] . "&home_id={$home_id}&submit=delete_mod'>[ " . get_lang('remove_mod') . " ]</a><br>" . "<a href='?m=user_games&p=install_cmds&home_id={$home_id}&mod_id=" . $enabled_rows['mod_id'] . "'>" . get_lang('mod_install_cmds') . "</a></td>" . "<td>" . $enabled_rows['mod_name'] . "</td>"; if ($server_xml->max_user_amount) { echo "<td>" . create_drop_box_from_array(range(0, $server_xml->max_user_amount), 'maxplayers', $enabled_rows['max_players'], true) . "</td>"; } echo "<td><input type='text' name='cliopts' size='20' value=\"" . $enabled_rows['extra_params'] . "\" /></td>"; echo "<td>" . create_drop_box_from_array(array_merge(array('NA'), range(0, $cpu_count)), 'cpus', $enabled_rows['cpu_affinity']) . "</td>"; echo "<td>" . create_drop_box_from_array(array_merge(range(-19, 19)), 'nice', $enabled_rows['nice']) . "</td>"; echo "<td><input type='submit' name='set_options' value='" . get_lang('set_options') . "' /></td></tr></form>\n"; } echo "</table>\n"; $game_mods = $db->getAvailableModsForGameHome($home_id); foreach ($game_mods as $game_mod) { if ($game_mod['mod_name'] == "none") { $mods_available = 0; } elseif ($game_mod['mod_name'] == "None") { $mods_available = 0; } else { $mods_available = 1; } } if ($mods_available == 1) { echo "<form action='?m=user_games&p=edit&home_id=" . $home_id . "' method='post'>\n"; echo "<input type='hidden' name='home_id' value=\"{$home_id}\" />\n"; echo "<p>" . get_lang('available_mods') . ": <select name='mod_cfg_id'>\n"; foreach ($game_mods as $game_mod) { echo "<option value='" . $game_mod['mod_cfg_id'] . "'>" . $game_mod['mod_name'] . "</option>\n"; } echo "</select>\n"; echo "<input type='submit' name='add_mod' value='" . get_lang('add_mod') . "' /></p>"; echo "</form>"; } } } else { $assigned = $db->getHomeIpPorts($home_id); if (!empty($assigned) and !empty($enabled_mods) and count($enabled_mods) > 1) { echo "<table class='center'>\n" . "<tr>\n" . "<td colspan='2' align='center'>" . "<h3>" . get_lang('switch_mods') . "</h3>" . "</td>\n" . "</tr>\n"; foreach ($assigned as $assigned_rows) { $force_mod = "<tr>\n<td align='right' style='width:50%' >" . get_lang_f('switch_mod_for_address', $assigned_rows['ip'] . ":" . $assigned_rows['port']) . "</td>\n" . ($force_mod .= "<td align='left' style='width:50%' >\n" . "<form action='?m=user_games&p=edit&home_id=" . $home_id . "' method='post'>\n" . "<input type='hidden' name='ip_id' value=" . $assigned_rows['ip_id'] . " />" . "<input type='hidden' name='port' value=" . $assigned_rows['port'] . " />" . "<select name='force_mod_id' onchange='this.form.submit();'>"); foreach ($enabled_mods as $mod) { $selected = $mod['mod_id'] == $assigned_rows['force_mod_id'] ? "selected='selected'" : ""; $force_mod .= "<option value='" . $mod['mod_id'] . "' {$selected}>" . $mod['mod_name'] . "</option>"; } $force_mod .= "</select>\n</form>\n</td>\n</tr>\n"; } echo $force_mod . "</table>\n"; } } }
function exec_ogp_module() { global $view, $db; $ip = $_REQUEST['ip']; $port = $_REQUEST['port']; $home_id = $_REQUEST['home_id']; $user_id = $_SESSION['user_id']; $home_id = $_REQUEST['home_id']; $isAdmin = $db->isAdmin($_SESSION['user_id']); if ($isAdmin) { $home_info = $db->getGameHome($home_id); } else { $home_info = $db->getUserGameHome($_SESSION['user_id'], $home_id); } require_once 'includes/lib_remote.php'; $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']); $mod_id = $_REQUEST['mod_id']; if ($home_info === FALSE) { print_failure(get_lang('no_rights_to_stop_server')); return; } echo "<h2>"; echo empty($home_info['home_name']) ? get_lang('not_available') : $home_info['home_name']; echo "</h2>"; $server_xml = read_server_config(SERVER_CONFIG_LOCATION . "/" . $home_info['home_cfg_file']); if (!$server_xml) { echo create_back_button("gamemanager", "game_monitor"); return; } $rserver = $db->getRemoteServerById($home_info['remote_server_id']); if (empty($rserver)) { print_failure("" . get_lang('not_found_server') . " " . $home_info['remote_server_id'] . "."); } else { if (isset($_REQUEST['refresh'])) { if (isset($server_xml->console_log)) { $log_retval = $remote->remote_readfile($home_info['home_path'] . '/' . $server_xml->console_log, $home_log); } else { $log_retval = $remote->get_log(OGP_SCREEN_TYPE_HOME, $home_info['home_id'], clean_path($home_info['home_path'] . "/" . $server_xml->exe_location), $home_log); } function getLastLines($string, $n = 1) { $lines = explode("\n", $string); $lines = array_slice($lines, -$n); return implode("\n", $lines); } $home_log = getLastLines($home_log, 40); if ($log_retval > 0) { if ($log_retval == 2) { print_failure(get_lang('server_not_running_log_found')); } echo "<pre style='background:black;color:white;'>" . $home_log . "</pre>"; if ($log_retval == 2) { return; } } else { print_failure(get_lang_f('unable_to_get_log', $log_retval)); } // If game is not supported by lgsl we skip the lgsl checks and // assume successfull start. if ($home_info['use_nat'] == 1) { $query_ip = $home_info['agent_ip']; } else { $query_ip = $ip; } $running = TRUE; if ($server_xml->lgsl_query_name) { require 'protocol/lgsl/lgsl_protocol.php'; $get_q_and_s = lgsl_port_conversion((string) $server_xml->lgsl_query_name, $port, "", ""); //Connection port $c_port = $get_q_and_s['0']; //query port $q_port = $get_q_and_s['1']; //software port $s_port = $get_q_and_s['2']; $data = lgsl_query_live((string) $server_xml->lgsl_query_name, $query_ip, $c_port, $q_port, $s_port, "sa"); if ($data['b']['status'] == "0") { $running = FALSE; } } elseif ($server_xml->gameq_query_name) { require 'protocol/GameQ/GameQ.php'; $query_port = get_query_port($server_xml, $port); $servers = array(array('id' => 'server', 'type' => (string) $server_xml->gameq_query_name, 'host' => $query_ip . ":" . $query_port)); $gq = new GameQ(); $gq->addServers($servers); $gq->setOption('timeout', 4); $gq->setOption('debug', FALSE); $gq->setFilter('normalise'); $game = $gq->requestData(); if (!$game['server']['gq_online']) { $running = FALSE; } } if (!$running) { if (!isset($_GET['retry'])) { $retry = 0; } else { $retry = $_GET['retry']; } if ($retry >= 5) { echo "<p>" . get_lang('server_running_not_responding') . "\n\t\t\t\t\t<a href=?m=gamemanager&p=stop&home_id=" . $home_info['home_id'] . "&ip=" . $ip . "&port=" . $port . ">" . get_lang('already_running_stop_server') . ".</a></p>"; echo "<table class='center'><tr><td><a href='?m=gamemanager&p=game_monitor&home_id-mod_id-ip-port={$home_id}-{$mod_id}-{$ip}-{$port}'><< " . get_lang('back') . "</a></td></tr></table>"; } echo "</b>Retry #" . $retry . ".</b>"; $retry++; print "<p class='note'>" . get_lang('starting_server') . "</p>"; $view->refresh("?m=gamemanager&p=start&refresh&ip={$ip}&port={$port}&home_id={$home_id}&mod_id={$mod_id}&retry=" . $retry, 3); return; } print_success(get_lang_f('server_restarted', $home_info['home_name'])); $ip_id = $db->getIpIdByIp($ip); $db->delServerStatusCache($ip_id, $port); $view->refresh("?m=gamemanager&p=game_monitor&home_id-mod_id-ip-port=" . $home_info['home_id'] . "-" . $home_info['mod_id'] . "-" . $_REQUEST['ip'] . "-" . $_REQUEST['port']); echo "<p>" . get_lang('follow_server_status') . " <a href='?m=gamemanager&p=game_monitor&home_id-mod_id-ip-port=" . $home_info['home_id'] . "-" . $home_info['mod_id'] . "-" . $_REQUEST['ip'] . "-" . $_REQUEST['port'] . "'>" . get_lang('game_monitor') . "</a> " . get_lang('page') . ".</p>"; return; } else { if ($server_xml->replace_texts) { $server_home = $home_info; if (isset($server_xml->lgsl_query_name)) { require_once 'protocol/lgsl/lgsl_protocol.php'; } require_once "modules/gamemanager/cfg_text_replace.php"; } $control_type = isset($server_xml->control_protocol_type) ? $server_xml->control_protocol_type : ""; $run_dir = isset($server_xml->exe_location) ? $server_xml->exe_location : ""; $last_param = json_decode($home_info['last_param'], True); $cli_param_data['GAME_TYPE'] = $home_info['mods'][$mod_id]['mod_key']; $cli_param_data['IP'] = $ip; $cli_param_data['PORT'] = $port; $cli_param_data['HOSTNAME'] = $home_info['home_name']; $cli_param_data['PID_FILE'] = "ogp_game_startup.pid"; $os = $remote->what_os(); // Linux if (preg_match("/Linux/", $os)) { $cli_param_data['BASE_PATH'] = $home_info['home_path']; $cli_param_data['HOME_PATH'] = $home_info['home_path']; $cli_param_data['SAVE_PATH'] = $home_info['home_path']; $cli_param_data['OUTPUT_PATH'] = $home_info['home_path']; $cli_param_data['USER_PATH'] = $home_info['home_path']; } elseif (preg_match("/CYGWIN/", $os)) { $home_path_win = $remote->exec("cygpath -w " . $home_info['home_path']); $home_path_win = str_replace("\\", "\\\\", $home_path_win); $home_path_win = trim($home_path_win); $cli_param_data['BASE_PATH'] = $home_path_win; $cli_param_data['HOME_PATH'] = $home_path_win; $cli_param_data['SAVE_PATH'] = $home_path_win; $cli_param_data['OUTPUT_PATH'] = $home_path_win; $cli_param_data['USER_PATH'] = $home_path_win; } if ($server_xml->protocol == "gameq") { $cli_param_data['QUERY_PORT'] = get_query_port($server_xml, $port); } elseif ($server_xml->protocol == "lgsl") { require 'protocol/lgsl/lgsl_protocol.php'; $get_ports = lgsl_port_conversion((string) $server_xml->lgsl_query_name, $port, "", ""); $cli_param_data['QUERY_PORT'] = $get_ports['1']; } elseif ($server_xml->protocol == "teamspeak3") { $cli_param_data['QUERY_PORT'] = "10011"; } $cli_param_data['MAP'] = empty($last_param['map']) ? "" : $last_param['map']; $cli_param_data['PLAYERS'] = empty($last_param['players']) ? $home_info['mods'][$mod_id]['max_players'] : $last_param['players']; $start_cmd = ""; // If the template is empty then these are not needed. if ($server_xml->cli_template) { $start_cmd = $server_xml->cli_template; if ($server_xml->cli_params) { foreach ($server_xml->cli_params->cli_param as $cli) { // If s is found the param is seperated with space $add_space = preg_match("/s/", $cli['options']) > 0 ? " " : ""; $cli_value = $cli_param_data[(string) $cli['id']]; // If q is found we add quotes around the value. if (preg_match("/q/", $cli['options']) > 0) { $cli_value = "\"" . $cli_value . "\""; } $start_cmd = preg_replace("/%" . $cli['id'] . "%/", $cli['cli_string'] . $add_space . $cli_value, $start_cmd); } } } if ($isAdmin) { $home_info['access_rights'] = "ufpet"; } $param_access_enabled = preg_match("/p/", $home_info['access_rights']) > 0 ? TRUE : FALSE; if ($param_access_enabled && isset($last_param)) { foreach ($server_xml->server_params->param as $param) { foreach ($last_param as $paramKey => $paramValue) { if (!isset($paramValue)) { $paramValue = (string) $param->default; } if ($param['key'] == $paramKey) { if (0 == strlen($paramValue)) { continue; } if ($param['key'] == $paramValue) { // it's a checkbox $new_param = $paramKey; } elseif ($param->option == "ns" or $param->options == "ns") { $new_param = $paramKey . $paramValue; } else { $new_param = $paramKey . ' "' . $paramValue . '"'; } if ($param['id'] == NULL || $param['id'] == "") { $start_cmd .= ' ' . $new_param; } else { $start_cmd = preg_replace("/%" . $param['id'] . "%/", $new_param, $start_cmd); } } } $start_cmd = preg_replace("/%" . $param['id'] . "%/", '', $start_cmd); } } $extra_param_access_enabled = preg_match("/e/", $home_info['access_rights']) > 0 ? TRUE : FALSE; if (array_key_exists('extra', $last_param) && $extra_param_access_enabled) { $extra_default = $last_param['extra']; } else { $extra_default = $home_info['mods'][$mod_id]['extra_params']; } $start_cmd .= " " . $extra_default; $remote_retval = $remote->remote_restart_server($home_info['home_id'], $ip, $port, $server_xml->control_protocol, $home_info['control_password'], $control_type, $home_info['home_path'], $server_xml->server_exec_name, $run_dir, $start_cmd, $home_info['cpu_affinity'], $home_info['nice']); $db->logger(get_lang_f('server_restarted', $home_info['home_name']) . "({$ip}:{$port})"); if ($remote_retval === 1) { print "<p class='note'>" . get_lang('restarting_server') . "</p>"; $view->refresh("?m=gamemanager&p=restart&refresh&ip={$ip}&port={$port}&home_id={$home_id}&mod_id={$mod_id}", 3); return; } else { if ($remote_retval === -1) { print_failure(get_lang('server_cant_start')); $view->refresh("?m=gamemanager&p=game_monitor&home_id-mod_id-ip-port=" . $home_info['home_id'] . "-" . $home_info['mod_id'] . "-" . $ip . "-" . $port, 3); } else { if ($remote_retval === -2) { print_failure(get_lang('server_cant_stop')); $view->refresh("?m=gamemanager&p=game_monitor&home_id-mod_id-ip-port=" . $home_info['home_id'] . "-" . $home_info['mod_id'] . "-" . $ip . "-" . $port, 3); } else { $screen_running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME, $home_info['home_id']); if ($screen_running == 1) { print "<p class='note'>" . get_lang('restarting_server') . "</p>"; $view->refresh("?m=gamemanager&p=restart&refresh&ip={$ip}&port={$port}&home_id={$home_id}&mod_id={$mod_id}", 3); return; } else { print_failure("" . get_lang('error_occured_remote_host') . ".{$remote_retval}"); $view->refresh("?m=gamemanager&p=game_monitor&home_id-mod_id-ip-port=" . $home_info['home_id'] . "-" . $home_info['mod_id'] . "-" . $ip . "-" . $port, 3); } } } } } } }
function update_module($db, $module_id, $module) { if (!is_file("modules/" . $module . "/module.php")) { print_failure("modules/" . $module . " " . get_lang("module_file_missing") . ""); return FALSE; } include "modules/" . $module . "/module.php"; $module_info = $db->getModule($module_id); if ($module_info['version'] != $module_version) { $db->delModuleMenu($module_id); if (isset($module_menus) && is_array($module_menus)) { foreach ($module_menus as $menu) { $db->addModuleMenu($module_id, $menu['subpage'], $menu['group'], $menu['name']); } } } if ($module_info['db_version'] < $db_version) { $i = $module_info['db_version']; while ($i < $db_version) { foreach ($install_queries[$i + 1] as $query) { if ($db->query($query)) { continue; } print_failure("" . get_lang("query_failed") . " (" . $query . ") " . get_lang("query_failed_2") . " ERROR: " . $db->getError() . ""); return -2; } ++$i; } } $db->updateModule($module_id, $module_version, $db_version); echo "<p>" . get_lang_f('updated_module', $module_title) . " - " . $module_info['db_version'] . " to " . $db_version . "</p>"; }
function exec_ogp_module() { if (!function_exists("curl_init")) { print_failure(get_lang('curl_needed')); return; } if ($_SESSION['users_group'] != "admin") { print_failure(get_lang('no_access')); return; } global $db; global $view; $version = $_GET['version']; $vtype = "SVN"; echo "<h4>" . get_lang('dwl_update') . "</h4>\n"; //This is usefull when you are downloading big files, as it //will prevent time out of the script set_time_limit(0); error_reporting(E_ALL); ini_set('display_errors', true); $baseDir = str_replace("modules" . DIRECTORY_SEPARATOR . "update", "", dirname(__FILE__)); if (!is_writable($baseDir)) { if (!@chmod($baseDir, 0755)) { print_failure(get_lang_f('base_dir_not_writable', $baseDir)); return; } } if (is_writable(sys_get_temp_dir())) { // Download file to temporary folder if (isset($_POST['mirror']) && !empty($_POST['mirror'])) { $mirror = $_POST['mirror']; } else { $mirror = "master"; } $temp_dwl = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'svn.tar.gz'; $fp = fopen($temp_dwl, 'w+'); //This is the download destination $url = "http://" . $mirror . ".dl.sourceforge.net/project/ogpextras/Alternative-Snapshot/hldstart-code-{$version}.zip"; //This is the download source $ch = curl_init($url); curl_setopt($ch, CURLOPT_TIMEOUT, 500); curl_setopt($ch, CURLOPT_FILE, $fp); curl_exec($ch); curl_close($ch); fclose($fp); // Check if the file exists and the size is bigger than a 404 error page from sf.net if (file_exists($temp_dwl)) { $stat = stat($temp_dwl); } else { print_failure(get_lang_f('dwl_failed', $url)); return; } if ($stat['size'] > 1500) { print_success(get_lang('dwl_complete')); } else { print_failure(get_lang_f('dwl_failed', $url)); return; } echo "<h4>" . get_lang('install_update') . "</h4>\n"; // Set default values for file checkings before installing $not_writable = get_lang('can_not_update_non_writable_files') . " :<br>"; $filename = ""; $overwritten = 0; $new = 0; $all_writable = TRUE; $filelist = ""; $overwritten_files = ""; $new_files = ""; $unwanted_path = "hldstart-code-{$version}/trunk/upload"; $extract_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "OGP_update"; if (!file_exists($extract_path)) { mkdir($extract_path, 0775); } $blacklist = array('/install.php', '/modules/gamemanager/rsync_sites_local.list'); $blacklisted_files = $db->resultQuery('SELECT file_path FROM `OGP_DB_PREFIXupdate_blacklist`;'); if ($blacklisted_files !== FALSE) { $curren_blacklist = array(); foreach ($blacklisted_files as $blacklisted_file) { $curren_blacklist[] = $blacklisted_file['file_path']; } $blacklist = array_merge($curren_blacklist, $blacklist); } include 'unzip.php'; // array|false extractZip( string $zipFile, string $extract_path [, string $remove_path, array $blacklist, array $whitelist] ) $files = extractZip($temp_dwl, $extract_path, $unwanted_path, $blacklist, ''); if (is_array($files) and count($files) > 0) { // Check file by file if already exists, if it matches, compares both files // looking for changes determining if the file needs to be updated. // Also determines if the file is writable $filelist = array(); $i = 0; foreach ($files as $file) { $filename = str_replace($unwanted_path . "/", "", $file['filename']); if (in_array($filename, $blacklist)) { continue; } $temp_file = $extract_path . DIRECTORY_SEPARATOR . $filename; $web_file = $baseDir . $filename; if (file_exists($web_file)) { $temp = file_get_contents($temp_file); $web = file_get_contents($web_file); if ($temp != $web) { if (!is_writable($web_file)) { if (!@chmod($web_file, 0775)) { $all_writable = FALSE; $not_writable .= $web_file . "<br>"; } else { $filelist[$i] = $file['filename']; $i++; $overwritten_files .= $filename . "<br>"; $overwritten++; } } else { $filelist[$i] = $file['filename']; $i++; $overwritten_files .= $filename . "<br>"; $overwritten++; } } } else { $filelist[$i] = $file['filename']; $i++; $new_files .= $filename . "<br>"; $new++; } } } // Once checkings are done the temp folder is removed if (file_exists($extract_path)) { rmdir_recurse($extract_path); } if ($all_writable) { // Extract the files that are set in $filelist, to the folder at $baseDir and removes 'upload' from the beggining of the path. $files = extractZip($temp_dwl, preg_replace("/\\/\$/", "", $baseDir), $unwanted_path, $blacklist, $filelist); if (is_array($files)) { // Updated files if ($overwritten > 0) { print_success(get_lang_f('files_overwritten', $overwritten)); echo get_lang_f("updated_files", $overwritten_files); } if ($new > 0) { print_success(get_lang_f('new_files', $new)); echo get_lang_f("updated_files", $new_files); } // update version info in db $db->query("UPDATE OGP_DB_PREFIXsettings SET value = '{$version}'\tWHERE setting = 'ogp_version'"); $db->query("UPDATE OGP_DB_PREFIXsettings SET value = '{$vtype}'\tWHERE setting = 'version_type'"); // Remove the downloaded package if (file_exists($temp_dwl)) { unlink($temp_dwl); } // Remove files that are not related to the panel if (file_exists($baseDir . DIRECTORY_SEPARATOR . "hldstart-code-{$version}")) { rmdir_recurse($baseDir . DIRECTORY_SEPARATOR . "hldstart-code-{$version}"); } echo "<br>\n<h4>" . get_lang('updating_modules') . "</h4>\n"; require_once 'modules/modulemanager/module_handling.php'; $modules = $db->getInstalledModules(); foreach ($modules as $row) { update_module($db, $row['id'], $row['folder']); } print_success(get_lang('update_complete')); } else { print_failure("Failed extracting files.<br>There is not enough space available in the system temporary folder (" . sys_get_temp_dir() . ").</b>"); } } else { print_failure($not_writable); } } else { print_failure(get_lang_f('temp_folder_not_writable', sys_get_temp_dir())); } }
function exec_ogp_module() { global $db; $home_id = $_REQUEST['home_id']; $server_row = $db->getGameHomeWithoutMods($home_id); if (empty($server_row)) { print_failure(get_lang('invalid_home_id')); return; } echo "<h2>" . get_lang_f('cloning_home', $server_row['home_name']) . "</h2>"; echo create_back_button('user_games'); include 'includes/lib_remote.php'; $remote = new OGPRemoteLibrary($server_row['agent_ip'], $server_row['agent_port'], $server_row['encryption_key']); if (isset($_REQUEST['clone_home'])) { $server_name = $_POST['new_home_name']; $user_group = $_POST['user_group']; $clone_home_id = $db->addGameHome($server_row['remote_server_id'], $server_row['user_id_main'], $server_row['home_cfg_id'], "/home/" . $server_row['ogp_user'] . "/OGP_User_Files/", $server_name, '', genRandomString(8)); $server_path = "/home/" . $server_row['ogp_user'] . "/OGP_User_Files/" . $clone_home_id; if ($clone_home_id === FALSE) { print_failure(get_lang_f('cloning_of_home_failed', $home_id)); return; } if (isset($_REQUEST['clone_mods'])) { $enabled_mods = $db->getHomeMods($home_id); if (empty($enabled_mods)) { print_failure(get_lang('note') . ": " . get_lang('no_mods_to_clone')); } else { foreach ($enabled_mods as $enabled_rows) { if ($db->addModToGameHome($clone_home_id, $enabled_rows['mod_cfg_id']) === FALSE) { print_failure(get_lang_f('failed_to_add_mod', $enabled_rows['mod_cfg'], $clone_home_id)); return; } if ($db->updateGameModParams($enabled_rows['max_players'], $enabled_rows['extra_params'], $enabled_rows['cpu_affinity'], $enabled_rows['nice'], $clone_home_id, $enabled_rows['mod_cfg_id']) === FALSE) { print_failure(get_lang_f('failed_to_update_mod_settings', $clone_home_id)); return; } } print_success(get_lang_f('successfully_cloned_mods', $clone_home_id)); } } print_success(get_lang('successfully_copied_home_database')); # do the remote copy call here echo "<p>" . get_lang_f('copying_home_remotely', $server_row['home_path'], $server_path) . "</p>"; $db->logger(get_lang_f('copying_home_remotely', $server_row['home_path'], $server_path)); $clone_rc = $remote->clone_home($server_row['home_path'], $server_path, $user_group); if ($clone_rc == -1) { print_success(get_lang('game_server_copy_is_running')); ?> <div class="html5-progress-bar"> <progress id="progressbar" value="0" max="100"></progress> <span class="progress-value">0%</span> </div> <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $.get( "home.php?m=user_games&type=cleared&p=get_size&home_id=<?php echo $home_id; ?> &bytes", function( orig_data ) { var orig_size = parseInt(orig_data,10); var refreshId = setInterval(function() { $.get( "home.php?m=user_games&type=cleared&p=get_size&home_id=<?php echo $clone_home_id; ?> &bytes", function( dest_data ) { var dest_size = parseInt(dest_data,10); var progress = parseInt(dest_size * 100 / orig_size); $('#progressbar').val(progress); $('.progress-value').html(progress + '%'); if(progress == 100) { clearInterval(refreshId); } }); }, 2000); }); }); </script> <?php } elseif ($clone_rc == 1) { print_success(get_lang('game_server_copy_was_successful')); } else { print_failure(get_lang_f('game_server_copy_failed_with_return_code', $clone_rc)); } echo "<br><a href='home.php?m=user_games'><< " . get_lang('back_to_game_servers') . "</a>"; return; } // Form to edit game path. $avail_mods = $db->getHomeMods($home_id); $read_status = $remote->remote_readfile('/etc/passwd', $passwd_array); if ($read_status === -1) { print_failure(get_lang('agent_offline')); return; } else { if ($read_status == 1) { $passwd_array = preg_split("/\n/", $passwd_array); } } require_once "includes/form_table_class.php"; $ft = new FormTable(); $ft->start_form('?m=user_games&p=clone'); $ft->add_field_hidden('home_id', $home_id); $ft->start_table(); $ft->add_custom_field('agent_ip', $server_row['agent_ip']); $ft->add_custom_field('current_home_path', $server_row['home_path']); $ft->add_field('string', 'new_home_name', $server_row['home_name']); echo "<tr><td class='right'>" . get_lang('clone_mods') . ":</td>\n\t\t<td class='left'><input type='checkbox' name='clone_mods' value='y' /></td></tr>"; echo "<input name='user_group' type='hidden' value='" . get_user_uid_gid_from_passwd($passwd_array, $server_row['ogp_user']) . "' /></tr>"; echo "</table>"; $ft->add_button('submit', 'clone_home', get_lang('clone_home')); echo "<p class='info'>" . get_lang('the_name_of_the_server_to_help_users_to_identify_it') . "</p>"; echo "</form>"; echo "<h3>" . get_lang('ips_and_ports_used_in_this_home') . "</h3>"; echo "<p>" . get_lang('note_ips_and_ports_are_not_cloned') . "</p>"; $assigned = $db->getHomeIpPorts($home_id); if (!empty($assigned)) { foreach ($assigned as $assigned_rows) { echo "<p>" . $assigned_rows['ip'] . ":" . $assigned_rows['port'] . "</p>\n"; } } $enabled_mods = $db->getHomeMods($home_id); echo "<h3>" . get_lang('mods_and_settings_for_this_game_server') . "</h3>"; if (empty($enabled_mods)) { print_failure(get_lang('note') . ": " . get_lang('note_no_mods')); return; } echo "<table class='center'>\n"; echo "<tr><td>" . get_lang('mod_name') . "</td><td>" . get_lang('max_players') . "</td><td>" . get_lang('extra_cmd_line_args') . "</td><td>" . get_lang('cpu_affinity') . "</td><td>" . get_lang('nice_level') . "</td></tr>\n"; foreach ($enabled_mods as $enabled_rows) { echo "<tr>"; echo "<td>" . $enabled_rows['mod_name'] . "</td>"; echo "<td>" . $enabled_rows['max_players'] . "</td>"; echo "<td>" . $enabled_rows['extra_params'] . "</td>"; echo "<td>" . $enabled_rows['cpu_affinity'] . "</td>"; echo "<td>" . $enabled_rows['nice'] . "</td></tr>\n"; } echo "</table>\n"; }
} if (!$mod) { $mod = $mod = $server_xml->mods->mod['key']; } if (!$map) { $map = $results['server']['gq_type']; } if (!$players) { $players = 0; } @($stats_players += $players); // COUNT VISIBLE NUMBER OF PLAYERS @($stats_maxplayers += $playersmax); // COUNT VISIBLE NUMBER OF SLOTS if ($results['server']['gq_numplayers'] > 0) { $player_list = print_player_list_gameq($results['server']['players'], $players, $playersmax); } if ($server_xml->installer == 'steamcmd') { $address = "<a href='steam://connect/{$ip}:{$port}'>{$ip}:{$port}</a>"; } else { $address = "{$ip}:{$port}"; } $playersList = $results['server']['players']; $maplocation = get_map_path($query_name, $mod, $map); } else { $status = "half"; } } else { $status = "half"; $notifications = get_lang_f('queries_disabled_by_setting_disable_queries_after', $numberservers_to_skip_query, $num_of_servers); }
function exec_ogp_module() { global $db, $view, $settings; $view->setCharset(get_lang('lang_charset')); $errorCount = 0; if (isset($errors)) { unset($errors); } $moduleLink = "index.php?m=lostpwd"; $lang_switch = (isset($_GET['lang']) and $_GET['lang'] != "") ? '&lang=' . $_GET['lang'] : ""; echo '<h2>' . get_lang("recover") . '</h2>'; // We either need to show the form or process the email address input if (!isset($_GET['user_id']) and !isset($_GET['ch_pass_uid'])) { if (isset($_POST['email_address'])) { /* Start of Process User Input */ $email_address = trim($_POST['email_address']); if (empty($email_address)) { $errorCount++; $errors[] = get_lang('incomplete'); } if (!stristr($email_address, "@") or !stristr($email_address, ".")) { $errorCount++; $errors[] = get_lang('errormail'); } if ($errorCount == 0) { // Check to see if email address is in the database $user_info = $db->getUserByEmail($email_address); if (empty($user_info)) { $errorCount++; $errors[] = get_lang('errormail'); } // Still no errors? if ($errorCount == 0) { $user_id = $user_info['user_id']; $ch_pass_uid = $user_info['users_passwd']; $subject = get_lang('confirm_change_subject'); $s = isset($_SERVER['HTTPS']) ? "s" : ""; $recover_link = '<a href="http' . $s . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . "&user_id=" . $user_id . '&ch_pass_uid=' . $ch_pass_uid . '" >http' . $s . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . "&user_id=" . $user_id . '&ch_pass_uid=' . $ch_pass_uid . '</a>'; $message = get_lang_f('confirm_change_password_message', $recover_link); if (mymail($email_address, $subject, $message, $settings) == TRUE) { echo "<p>" . get_lang('confirm_send') . "</p>"; } else { echo "<p>" . get_lang('mail_failed') . "</p>"; } unset($_POST['email_address']); } } } else { // Show form $showForm = 1; } // Any errors? If so, show the form if ($errorCount > 0) { $showForm = 1; } if (isset($showForm) and $showForm == 1) { echo '<table style="width:200px" align="center" > <tr> <td colspan=2 >'; // Print errors if there are any if (isset($errors) && is_array($errors)) { foreach ($errors as $error) { echo '<p style="color: red;">' . $error . '</p>'; } } echo '<form method="post" action="?m=lostpwd' . $lang_switch . '"> <label for="email_address">' . get_lang("email") . '</label> </td> </tr> <tr> <td> <input type="text" title="' . get_lang("enter_email") . '" name="email_address" size="30" value="'; if (isset($email_address)) { echo $email_address; } echo '"/> </td> </tr> <tr> <td style="text-align:right;"> <input type="submit" value="' . get_lang("submit") . '" class="submit-button"/> </form> </td> </tr> <tr> <td style="text-align:left;"> <form method="post" action="index.php' . str_replace("&", "?", $lang_switch) . '" style="margin-top:-28px;"> <input type="submit" value="<< ' . get_lang("back") . '" class="submit-button"/> </form> </td> </tr></table>'; } } else { if (isset($_GET['user_id']) and isset($_GET['ch_pass_uid'])) { $user_id = trim($_GET['user_id']); $ch_pass_uid = trim($_GET['ch_pass_uid']); $user_info = $db->getUserById($user_id); if (empty($user_info)) { print_failure(get_lang('errormail')); echo "<p><a href='" . $moduleLink . "'><< " . get_lang('back') . "</a></p>"; return; } $email_address = $user_info['users_email']; $random_password = makeRandomPassword(); $db_password = md5($random_password); $old_pass_md5_hash = $user_info['users_passwd']; if ($old_pass_md5_hash != $ch_pass_uid) { print_failure("Failed to update password for user."); echo "<p><a href='" . $moduleLink . "'><< " . get_lang('back') . "</a></p>"; return; } $random_password = makeRandomPassword(); $db_password = md5($random_password); if ($db->updateUsersPassword($user_id, $db_password) === FALSE) { print_failure("Failed to update password for user."); echo "<p><a href='" . $moduleLink . "'><< " . get_lang('back') . "</a></p>"; return; } $subject = get_lang('subject'); $message = get_lang_f('password_message', $random_password); if (mymail($email_address, $subject, $message, $settings) == TRUE) { echo "<p>" . get_lang('send') . "</p>"; } else { echo "<p>" . get_lang('mail_failed') . "</p>"; } echo "<p>" . get_lang('click') . " <a href='index.php'>" . get_lang('here') . "</a> " . get_lang('to_login') . "</p>"; } else { print_failure("Security alert."); } } }