function exec_ogp_module() { global $db; echo '<h2>' . get_lang('users') . "</h2>"; echo "<p><a href='?m=user_admin&p=add'>" . get_lang('add_new_user') . "</a></p>"; echo '<table class="center" style="width: 100%;">'; echo '<tr><th>' . get_lang('actions') . "</th><th>" . get_lang('username') . "</th>"; echo "<th>" . get_lang('user_role') . "</th>"; echo "<th>" . get_lang('email_address') . "</th>"; echo "<th>" . get_lang('expires') . "</th>"; echo "<th>" . get_lang('ownedby') . "</th></tr>"; $result = $db->getUserList(); $i = 0; foreach ($result as $row) { // Show user's parent $ownedBy = ""; if (is_null($row['users_parent'])) { if ($row['users_role'] != "admin") { $ownedBy = "Root Admin"; } } else { $ownedBy = $db->getUserById($row['users_parent']); $ownedBy = $ownedBy['users_login']; } $user_expires = read_expire($row['user_expires']); print "<tr class='tr" . $i++ % 2 . "'>"; print "<td><a href='?m=user_games&p=assign&user_id={$row['user_id']}'>[" . get_lang('assign_homes') . "]</a><br />\n <a href='?m=user_admin&p=del&user_id={$row['user_id']}'>[" . get_lang('delete') . "]</a><br />\n <a href='?m=user_admin&p=edit_user&user_id={$row['user_id']}'>[" . get_lang('edit_profile') . "]</a></td>\n <td>{$row['users_login']}</td><td>{$row['users_role']}</td>\n <td>{$row['users_email']}</td>\n <td>{$user_expires}</td>\n <td>{$ownedBy}</td></tr>"; } echo '</table>'; }
function heading() { global $db, $view, $settings; if (!file_exists(CONFIG_FILE)) { print_failure(get_lang('failed_to_read_config')); $view->refresh("index.php"); return; } // Start Output Buffering if (!isset($_SESSION['users_login'])) { print_failure(get_lang('invalid_login_information')); echo "<p class='note' style='color:red;'>" . get_lang('invalid_redirect') . "...</p>"; echo "<meta http-equiv='refresh' content='2;url=index.php'"; return; } else { $info = $db->getUser($_SESSION['users_login']); $chk_expire = $info['user_expires']; $exptime = read_expire($chk_expire); if ($exptime != "X") { list($days, $strd, $hours, $strh, $minutes, $strm) = explode(" ", $exptime); $minutes2expire = $minutes + intval($hours * 60) + intval($days * 24 * 60); if ($minutes2expire <= 0) { echo "<h1>" . get_lang('account_expired') . "</h1>"; echo "<p class='note'>" . get_lang('contact_admin_to_enable_account') . "</p>"; session_destroy(); return; } } if (isset($settings['maintenance_mode']) && $settings['maintenance_mode'] == "1") { if ($_SESSION['users_group'] == "user") { echo "<h2>" . $settings['maintenance_title'] . "</h2>"; echo "<p>" . $settings['maintenance_message'] . "</p>"; $view->setTitle("OGP: Maintenance."); echo "<p class='failure'>" . get_lang('logging_out_10') . "...</p>"; echo "<meta http-equiv='refresh' content='10;url=index.php'"; session_destroy(); return; } } if (isset($_REQUEST['logout'])) { session_destroy(); print_success(get_lang('logout_message')); $view->refresh("index.php"); return; } include "includes/navig.php"; } if (isset($maintenance)) { echo $maintenance; } }
function exec_ogp_module() { global $db; echo "<h2>" . get_lang('game_monitor') . "</h2>"; $refresh = new refreshed(100000); set_time_limit(0); $stats_servers_online = 0; $stats_servers = 0; $stats_players = 0; $stats_maxplayers = 0; $isAdmin = $db->isAdmin($_SESSION['user_id']); if ($isAdmin) { $server_homes = $db->getIpPorts(); } else { $server_homes = $db->getIpPortsForUser($_SESSION['user_id']); } if ($server_homes === FALSE) { // If there are no games, then there can not be any mods either. print_failure(get_lang('no_game_homes_assigned')); if ($isAdmin) { echo "<p><a href='?m=user_games&p=assign&user_id={$_SESSION['user_id']}'>" . get_lang('assign_game_homes') . "</a></p>"; } return; } if (empty($_GET['home_id-mod_id-ip-port'])) { unset($_GET['home_id-mod_id-ip-port']); } if (empty($_GET['home_id'])) { unset($_GET['home_id']); } if ($_GET['home_cfg_id'] == get_lang('game_type')) { unset($_GET['home_cfg_id']); } create_home_selector_game_type($_GET['m'], $_GET['p'], $server_homes); if (!isset($_GET['home_id-mod_id-ip-port']) and !isset($_GET['home_id']) and !isset($_GET['home_cfg_id'])) { create_home_selector_address($_GET['m'], $_GET['p'], $server_homes); $show_all = TRUE; } else { create_home_selector_address($_GET['m'], $_GET['p'], $server_homes); create_home_selector($_GET['m'], $_GET['p'], "show_all"); $show_all = FALSE; } require "protocol/lgsl/lgsl_protocol.php"; ?> <form> <b><?php print_lang('search'); ?> :</b> <input type="text" id="search"> </form> <?php $info = $db->getUser($_SESSION['users_login']); $chk_expire = $info['user_expires']; $exptime = read_expire($chk_expire); $time_to_expire = str_replace('hr', 'hours', $exptime); if ($exptime != "X") { ?> <span style="color:black;font-weight:bold;"> <center> <?php echo print_lang('account_expiration'); ?> : <span style="color:green;"><?php echo date("l, F jS, Y, H:i:s", $chk_expire) . " ( " . $time_to_expire . ")"; ?> </span> </center> </span> <?php } ?> <table id="servermonitor" class="tablesorter"> <thead> <tr> <th style="width:16px;background-position: center;"></th> <th style="width:16px;background-position: center;"></th> <th><?php print_lang('server_name'); ?> </th> <th><?php print_lang('address'); ?> </th> <th><?php print_lang('owner'); ?> </th> <th> <?php print_lang('operations'); ?> <img style="border:0;height:15px;" id="action-stop" src="images/stop.png"/> <img style="border:0;height:15px;" id="action-restart" src="images/restart.png"/> <img style="border:0;height:15px;" id="action-start" src="images/start.png"/> </th> </tr> </thead> <tbody> <?php foreach ($server_homes as $server_home) { $stats_servers++; //Unset variables. if (isset($_GET['home_id-mod_id-ip-port'])) { $pieces = explode("-", $_GET['home_id-mod_id-ip-port']); $post_home_id = $pieces[0]; $post_mod_id = $pieces[1]; $post_ip = $pieces[2]; $post_port = $pieces[3]; } if ($show_all or isset($_GET['home_id']) and $_GET['home_id'] == $server_home['home_id'] or isset($_GET['home_id-mod_id-ip-port']) and $server_home['home_id'] == $post_home_id and $server_home['mod_id'] == $post_mod_id and $post_ip == $server_home['ip'] and $post_port == $server_home['port'] or isset($_GET['home_cfg_id']) and $_GET['home_cfg_id'] == $server_home['home_cfg_id']) { unset($map, $trclass, $first, $second, $onlineT, $ts3opt, $offlineT, $halfT, $ministart, $player_list, $groupsus, $name, $mod_name, $SrvCtrl, $lite_fm, $manager, $user, $pos, $ftp, $addonsmanager, $ctrlChkBoxes); //End if ($isAdmin) { $server_home['access_rights'] = "ufpet"; } else { $home_info = $db->getUserGameHome($_SESSION['user_id'], $server_home['home_id']); $server_home['access_rights'] = $home_info['access_rights']; } $litefm_installed = $db->isModuleInstalled('litefm'); $ftp_installed = $db->isModuleInstalled('ftp'); $addonsmanager_installed = $db->isModuleInstalled('addonsmanager'); $mysql_installed = $db->isModuleInstalled('mysql'); if ($server_home['mod_name'] == "none" or $server_home['mod_name'] == "None") { $mod_name = ""; } elseif ($server_home['mod_name'] != $server_home['game_name']) { $mod_name = " ( " . $server_home['mod_name'] . " )"; } $get_size = "<table align='left' class='monitorbutton' ><tr>" . "<td align='middle' class='size' id='" . $server_home["home_id"] . "'>" . "<img style='border:0;height:40px;vertical-align:middle;' src='images/file_size.png' title='" . get_lang('get_size') . "'/>\n<br /><span style='font-weight:bold;'>" . get_lang('get_size') . "</span></td></tr></table>"; $manager = "<a href='?m=user_games&p=edit&home_id=" . $server_home['home_id'] . "'>\n" . "<table align='left' class='monitorbutton' ><tr><td align='middle' >" . "<img style='border:0;height:40px;vertical-align:middle;' src='images/edit.png' title='" . get_lang('edit') . "'/>\n<br />" . get_lang('edit') . "\n</td></tr></table></a>"; // Only show the filemanager link when the litefm is installed. if (preg_match("/f/", $server_home['access_rights']) > 0 && $litefm_installed) { $lite_fm = "<a href='?m=litefm&home_id=" . $server_home['home_id'] . "'>\n" . "<table align='left' class='monitorbutton' ><tr><td align='middle' >" . "<img style='border:0;height:40px;vertical-align:middle;' src='images/txt.png' title='" . get_lang('file_manager') . "'/>\n<br />" . get_lang('file_manager') . "\n</td></tr></table></a>"; } if (preg_match("/t/", $server_home['access_rights']) > 0 && $ftp_installed) { $ftp = "<a href='?m=ftp&home_id=" . $server_home['home_id'] . "'>\n" . "<table align='left' class='monitorbutton' ><tr><td align='middle' >" . "<img style='border:0;height:40px;vertical-align:middle;' src='images/ftp.png' title='" . get_lang('ftp') . "'/>\n<br>" . get_lang('ftp') . "\n</td></tr></table></a>"; } if ($addonsmanager_installed) { $addons = $db->resultQuery("SELECT DISTINCT addon_id FROM OGP_DB_PREFIXaddons NATURAL JOIN OGP_DB_PREFIXconfig_homes WHERE home_cfg_id=" . $server_home['home_cfg_id']); $addons_qty = count($addons); if ($addons and $addons_qty >= 1) { $addonsmanager = "<a href='?m=addonsmanager&p=user_addons&home_id=" . $server_home['home_id'] . "&ip=" . $server_home['ip'] . "&port=" . $server_home['port'] . "'>\n" . "<table align='left' class='monitorbutton' ><tr><td align='middle' >" . "<img style='border:0;height:40px;vertical-align:middle;' src='modules/administration/images/addons_manager.png' title='" . get_lang('addons') . "'/>\n<br />" . get_lang('addons') . "\n<b style='font-size:0.9em' >(" . $addons_qty . ")</td></tr></table></a>"; } } if ($mysql_installed) { $mysql_dbs = $db->resultQuery("SELECT db_id FROM OGP_DB_PREFIXmysql_databases WHERE enabled=1 AND home_id=" . $server_home['home_id']); if (!empty($mysql_dbs)) { $mysql = "<a href='?m=mysql&p=user_db&home_id=" . $server_home['home_id'] . "'>\n" . "<table align='left' class='monitorbutton' ><tr><td align='middle' >" . "<img style='border:0;height:40px;vertical-align:middle;' src='modules/administration/images/mysql_admin.png' title='" . get_lang('mysql_databases') . "'/>\n<br />" . get_lang('mysql_databases') . "\n</td></tr></table></a>\n"; } } $mod_result = $db->getHomeMods($server_home['home_id']); if ($mod_result === FALSE) { print_failure(get_lang('fail_no_mods')); if ($isAdmin) { $manager .= "<a href='?m=user_games&p=edit&home_id=" . $server_home['home_id'] . "'>" . get_lang('configure_mods') . "</a>"; } continue; } $server_xml = read_server_config(SERVER_CONFIG_LOCATION . "/" . $server_home['home_cfg_file']); $master_server_home_id = $db->getMasterServer($server_home['remote_server_id'], $server_home['home_cfg_id']); if ($master_server_home_id != FALSE) { if (!$db->getGameHomeWithoutMods($master_server_home_id)) { $db->setMasterServer("remove", $master_server_home_id, $server_home['home_cfg_id'], $server_home['remote_server_id']); $master_server_home_id = FALSE; } } if ($server_xml) { if (preg_match("/u/", $server_home['access_rights']) > 0) { // In case game is compatible with steam we offer a way to use steam with the updates. if ($server_xml->installer == "steamcmd") { if ($master_server_home_id != FALSE and $master_server_home_id != $server_home['home_id']) { $manager .= "<form name='steam_master_" . $server_home['home_id'] . "_" . $server_home['mod_id'] . "_" . str_replace(".", "", $server_home['ip']) . "_" . $server_home['port'] . "' action='?m=gamemanager&p=update&home_id=" . $server_home['home_id'] . "&mod_id=" . $server_home['mod_id'] . "&update=update' method='POST' >\n" . "<table align='left' class='monitorbutton' >\n" . "<tr><td align='middle' onclick='document.steam_master_" . $server_home['home_id'] . "_" . $server_home['mod_id'] . "_" . str_replace(".", "", $server_home['ip']) . "_" . $server_home['port'] . ".submit()' ><img style='border:0;height:40px;vertical-align:middle;' src='images/master.png' />" . "<br /><span style='font-weight:bold;'>" . get_lang('update_from_local_master_server') . "</span><input id='master" . $server_home['home_id'] . "' type='hidden' name='master_server_home_id' value='" . $master_server_home_id . "' /></td></tr>\n</table>\n</form>"; } $manager .= "<form name='steam_" . $server_home['home_id'] . "_" . $server_home['mod_id'] . "_" . str_replace(".", "", $server_home['ip']) . "_" . $server_home['port'] . "' action='?m=gamemanager&p=update&home_id=" . $server_home['home_id'] . "&mod_id=" . $server_home['mod_id'] . "&update=update' method='POST' >\n" . "<table align='left' class='monitorbutton' >\n" . "<tr><td align='middle' onclick='document.steam_" . $server_home['home_id'] . "_" . $server_home['mod_id'] . "_" . str_replace(".", "", $server_home['ip']) . "_" . $server_home['port'] . ".submit()' ><img style='border:0;height:40px;vertical-align:middle;' src='images/steam.png' />" . "<br /><span style='font-weight:bold;'>" . get_lang('install_update_steam') . "</span></td></tr>\n</table>\n</form>"; } else { $manager .= "<a href='?m=gamemanager&p=update_manual&home_id=" . $server_home['home_id'] . "&mod_id=" . $server_home['mod_id'] . "&update=update'>\n" . "<table align='left' class='monitorbutton' ><tr><td align='middle' >" . "<img style='border:0;height:40px;vertical-align:middle;' src='images/install.png' title='" . get_lang('install_update_manual') . "'/>\n<br>" . get_lang('install_update_manual') . "\n</td></td></table></a>"; $sync_name = get_sync_name($server_xml); $sync_list = @file("modules/gamemanager/rsync.list", FILE_IGNORE_NEW_LINES); $master_server_home_id = $db->getMasterServer($server_home['remote_server_id'], $server_home['home_cfg_id']); if (in_array($sync_name, $sync_list) or $master_server_home_id != FALSE and $master_server_home_id != $server_home['home_id']) { $manager .= "<a href='?m=gamemanager&p=rsync_install&home_id=" . $server_home['home_id'] . "&mod_id=" . $server_home['mod_id'] . "&update=update'>\n" . "<table align='left' class='monitorbutton' ><tr><td align='middle' >" . "<img style='border:0;height:40px;vertical-align:middle;' src='images/rsync.png' title='" . get_lang('rsync_install') . "'/>\n<br />" . get_lang('rsync_install') . "\n</td></td></table></a>"; } } } } if ($isAdmin) { if ($server_xml->control_protocol == 'rcon' or $server_xml->control_protocol == 'lcon' or $server_xml->control_protocol == 'rcon2' or @$server_xml->gameq_query_name == 'minecraft') { $manager .= "<form name='rcon_preset" . $server_home['home_id'] . "' action='home.php?m=gamemanager&p=rcon_presets&home_id=" . $server_home['home_id'] . "&mod_id=" . $server_home['mod_id'] . "' method='POST'>\n" . "<table align='left' class='monitorbutton' >\n" . "<tr>\n" . "<td align='middle' onclick='document.rcon_preset" . $server_home['home_id'] . ".submit()' ><img style='border:0;height:40px;vertical-align:middle;' src='images/rcon_preset.png' /><br /><span style='font-weight:bold;'>" . get_lang('rcon_presets') . "</span></td>\n" . "</tr>\n" . "</table>\n" . "</form>"; } } $xml_installer = $server_xml->installer; // If query name does not exist use mod key instead. if ($server_xml->protocol == "gameq") { $query_name = $server_xml->gameq_query_name; } elseif ($server_xml->protocol == "lgsl") { $query_name = $server_xml->lgsl_query_name; } elseif ($server_xml->mods->mod['key'] == "none" or $server_xml->mods->mod['key'] == "None") { $query_name = "none"; } else { $query_name = $server_xml->mods->mod['key']; } if ($server_xml->mods->mod['key'] == "none" or $server_xml->mods->mod['key'] == "None") { $mod = "none"; } else { $mod = $server_xml->mods->mod['key']; } //----------+ getting the lgsl image icon $icon_paths = array("images/icons/{$mod}.png", "images/icons/{$query_name}.png", "protocol/lgsl/other/icon_unknown.gif"); $icon_path = get_first_existing_file($icon_paths); //Properties for all servers if (isset($post_home_id) && $post_home_id == $server_home['home_id'] or isset($_GET['home_id']) && $_GET['home_id'] == $server_home['home_id']) { $trclass = " expandme"; } $groupusers = $db->getGroupUsersByHomeId($server_home['home_id']); if ($groupusers) { $groupsus = "<b>" . get_lang('group_users') . "</b><br>"; foreach ($groupusers as $groupu) { $groupsus .= $groupu['users_login'] . "<br>"; } } else { $groupsus = ""; } $view_log = "<a href='?m=gamemanager&p=log&home_id-mod_id-ip-port=" . $server_home['home_id'] . "-" . $server_home['mod_id'] . "-" . $server_home['ip'] . "-" . $server_home['port'] . "'>\n" . "<table align='left' class='monitorbutton' ><tr><td align='middle' >" . "<img style='border:0;height:40px;vertical-align:middle;' src='images/log.png' title='" . get_lang('view_log') . "'/>\n<br>" . get_lang('view_log') . "\n</td></tr></table></a>"; $btns = $view_log . @$ftp . @$lite_fm . @$addonsmanager; //End $remote = new OGPRemoteLibrary($server_home['agent_ip'], $server_home['agent_port'], $server_home['encryption_key'], $server_home['timeout']); $host_stat = $remote->status_chk(); if ($host_stat === 1) { if ($server_home['use_nat'] == 1) { $query_ip = $server_home['agent_ip']; } else { $query_ip = $server_home['ip']; } $address = $query_ip . ":" . $server_home['port']; $screen_running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME, $server_home['home_id']) === 1; $update_in_progress = $remote->is_screen_running(OGP_SCREEN_TYPE_UPDATE, $server_home['home_id']) === 1; if ($screen_running) { // Check if the screen running the server is running. $status = "online"; $order = 1; if ($server_xml->protocol == "lgsl") { $get_q_and_s = lgsl_port_conversion((string) $query_name, $server_home['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']; $address = "<a href='" . lgsl_software_link($query_name, $query_ip, $c_port, $q_port, $s_port) . "'>" . $query_ip . ":" . $server_home['port'] . "</a>"; } if ($server_xml->protocol == "teamspeak3") { $address = "<a href='ts3server://" . $query_ip . ":" . $server_home['port'] . "'>" . $query_ip . ":" . $server_home['port'] . "</a>"; } if ($server_xml->protocol == "gameq" and $server_xml->installer == 'steamcmd') { $address = "<a href='steam://connect/" . $query_ip . ":" . $server_home['port'] . "'>" . $query_ip . ":" . $server_home['port'] . "</a>"; } $pos = $refresh->add("home.php?m=gamemanager&p=ref_servermonitor&type=cleared&server_home=" . $server_home['home_id'] . "&ip=" . $server_home['ip'] . "&port=" . $server_home['port']); if ($server_xml->protocol == "teamspeak3") { require 'protocol/TeamSpeak3/functions.php'; } $startup_file_exists = $remote->rfile_exists("startups/" . $server_home['ip'] . "-" . $server_home['port']) === 1; $ctrlChkBoxes .= '<div id="server_icon" class="action-stop' . $server_home['home_id'] . '" > <div> <input id="action-stop" class="action-stop' . $server_home['home_id'] . '" name="action-' . $server_home['home_id'] . '" value="stop-' . $server_home['home_id'] . '-' . $server_home['mod_id'] . '-' . $server_home['ip'] . '-' . $server_home['port'] . '" type="radio"><img style="border:0;height:15px;" src="images/stop.png"/></div><div> ' . get_lang('stop_server') . '</div></div>'; if ($startup_file_exists) { $ctrlChkBoxes .= '<div id="server_icon" class="action-restart' . $server_home['home_id'] . '" > <div> <input id="action-restart" class="action-restart' . $server_home['home_id'] . '" name="action-' . $server_home['home_id'] . '" value="restart-' . $server_home['home_id'] . '-' . $server_home['mod_id'] . '-' . $server_home['ip'] . '-' . $server_home['port'] . '" type="radio"><img style="border:0;height:15px;" src="images/restart.png"/></div><div> ' . get_lang('restart_server') . '</div></div>'; } $stats_servers_online++; } else { $status = "offline"; if ($db->getLastParam($server_home['home_id']) != FALSE) { if ($update_in_progress) { $ctrlChkBoxes .= '<div id="server_icon" class="action-start' . $server_home['home_id'] . '" > ' . get_lang('update_in_progress') . '</div>'; } else { $ctrlChkBoxes .= '<div id="server_icon" class="action-start' . $server_home['home_id'] . '" > <div> <input id="action-start" class="action-start' . $server_home['home_id'] . '" name="action-' . $server_home['home_id'] . '" value="start-' . $server_home['home_id'] . '-' . $server_home['mod_id'] . '-' . $server_home['ip'] . '-' . $server_home['port'] . '" type="radio"><img style="border:0;height:15px;" src="images/start.png"/></div><div> ' . get_lang('start_server') . '</div></div>'; } } $order = 3; ob_start(); require 'modules/gamemanager/mini_start.php'; $ministart = ob_get_contents(); ob_end_clean(); if ($update_in_progress) { $offlineT = '<div id="server_icon" class="action-start' . $server_home['home_id'] . '" > ' . get_lang('update_in_progress') . '</div>'; } else { $offlineT = $ministart; } } } else { $status = "offline"; $order = 3; $address = "<span style='color:darkred;font-weight:bold;'>Agent Offline</span>"; } $user = $db->getUserById($server_home['user_id_main']); // Template @($first = "<tr class='maintr{$trclass}'>"); $first .= "<td class='collapsible'><span class='hidden'>{$order}</span><a></a>" . "<img src='images/{$status}.png' />" . "</td>"; $first .= "<td>" . "<span class='hidden'>{$mod}</span><img src='{$icon_path}' />" . "</td>"; $first .= "<td class='collapsible'><a></a><b>" . $server_home['home_name'] . "</b>{$mod_name}</td>"; $first .= "<td>" . $address . "</td>"; $first .= "<td>" . $user['users_login'] . "</td>"; $first .= "<td style='width:328px;padding:0px;'>{$ctrlChkBoxes}</td>"; $first .= "</tr>"; $second = "<tr class='expand-child'>"; @($second .= "<td colspan='4'>" . $refresh->getdiv($pos, "width:100%;") . "{$offlineT}</td>"); $second .= "<td width='80'>{$groupsus}</td>"; @($second .= "<td>{$btns}{$manager}<br>{$mysql}<br>{$get_size}<br>{$ts3opt}</td>"); $second .= "</tr>"; //Echo them all echo "{$first}{$second}"; } } echo "</tbody>"; echo "<tfoot style='border:1px solid grey;'>\n\t\t\t<tr>\n\t\t\t <td colspan='6' >\n\t\t\t\t<div class='bloc' >\n\t\t\t\t<img src='images/magnifglass.png' /> " . get_lang('statistics') . ": {$stats_servers_online}/{$stats_servers} " . get_lang('servers') . "\n</div>\n\t\t\t\t<div class='right bloc' >\n\t\t\t\t <label>" . get_lang('execute_selected_server_operations') . "</label>\n\t\t\t\t <input id='execute_operations' type='submit' value='" . get_lang('execute_operations') . "' >\n\n\t\t\t\t</div>\n\t\t\t </td>\n\t\t\t</tr>\n\t\t </tfoot>"; echo "</table>"; ?> <script type="text/javascript"> $(document).ready(function() { <?php echo $refresh->build("8000"); ?> $('input#search').quicksearch('table#servermonitor tbody tr.maintr'); $("#servermonitor") .collapsible("td.collapsible", {collapse: true}) .tablesorter({sortList: [[0,0], [1,0]] , widgets: ['zebra','repeatHeaders']}) ; } ); $("div#server_icon").click(function(){ var id = $(this).attr('class'); if($("input[type=radio]."+id).attr('checked') == 'checked') { $("input[type=radio]."+id).prop('checked', false); } else { $("input[type=radio]."+id).prop('checked', true); } }); $('.size').click(function(){ var $id = $(this).attr('id'); $.get( "home.php?m=user_games&type=cleared&p=get_size&home_id="+$id, function( data ) { $('#'+$id+".size").text( data ); $('#'+$id+".size").css("font-size", "16pt"); }); }); $('#execute_operations').click(function(){ var addpost = {}; $('input[type=radio]:checked').each(function( ){ var name = $(this).attr('name'); var value = $(this).val(); addpost[ name ] = value; }); $('.right.bloc').html('<img src="images/loading.gif" />'); $.ajax({ type: "POST", url: "home.php?m=gamemanager&p=game_monitor", data: addpost, complete: function(){ document.location.reload(); } }); }); $('img#action-stop').click(function(){ $('input[type=radio]#action-stop').each(function( ){ if( this.checked ) { $(this).attr('checked', false); } else { $(this).attr('checked', true); } }); }); $('img#action-restart').click(function(){ $('input[type=radio]#action-restart').each(function( ){ if( this.checked ) { $(this).attr('checked', false); } else { $(this).attr('checked', true); } }); }); $('img#action-start').click(function(){ $('input[type=radio]#action-start').each(function( ){ if( this.checked ) { $(this).attr('checked', false); } else { $(this).attr('checked', true); } }); }); </script> <?php }
function exec_ogp_module() { global $db, $settings; $my_user_id = $_SESSION['user_id']; #who we're logged in as $user_id = $_REQUEST['user_id']; $isAdmin = $db->isAdmin($my_user_id); $mySubUsersAssoc = $db->listSubUsersByParent($my_user_id); if ($mySubUsersAssoc) { foreach ($mySubUsersAssoc as $subuser) { $mySubUsers[] = $subuser['user_id']; } } // Check that we are admin or the user itself. if (!isset($user_id)) { print_failure("Error in parameters."); return; } else { if (!$isAdmin && $my_user_id !== $user_id && @(!in_array($user_id, $mySubUsers))) { print_failure(get_lang('no_rights')); return; } } if ($isAdmin) { $users = $db->getUserList(); foreach ($users as $user) { if ($db->isAdmin($user['user_id'])) { $first_admin_id = $user['user_id']; break; } } if ($db->isAdmin($user_id) and $first_admin_id != $my_user_id and $user_id != $my_user_id) { print_failure(get_lang('no_rights')); return; } } echo "<h2>" . get_lang('your_profile') . "</h2>"; echo "<div align='center'>"; require_once "includes/form_table_class.php"; if ((isset($_POST['new_password']) || isset($_POST['retype_new_password'])) && $_POST['new_password'] !== $_POST['retype_new_password']) { print_failure(get_lang('password_mismatch')); } elseif (isset($_POST['edit_user']) && $my_user_id === $user_id && !$db->is_valid_login($my_user_id, $_REQUEST['current_password'])) { print_failure(get_lang('current_password_mismatch')); } else { if (isset($_POST['edit_user'])) { $user_id = $_POST['user_id']; $newlang = $_POST['newlang']; $login = $_POST['login']; $login = str_replace('"', '', $login); $login = str_replace("'", "", $login); $firstname = $_POST['first_name']; $firstname = str_replace('"', '', $firstname); $firstname = str_replace("'", "", $firstname); $lastname = $_POST['last_name']; $lastname = str_replace('"', '', $lastname); $lastname = str_replace("'", "", $lastname); $email = $_POST['email_address']; $city = $_POST['city']; $province = $_POST['province']; $country = $_POST['country']; $phone = $_POST['phone_number']; $phone = preg_replace("/[^0-9]/", "", $phone); $theme = $_POST['theme']; // OGP needs to set the new theme and language in the current session, only if I'm modifying my own user profile. if ($my_user_id == $user_id) { $_SESSION['users_theme'] = $theme; $_SESSION['users_lang'] = $newlang; } $fields['users_lang'] = $_POST['newlang']; $fields['users_fname'] = $firstname; $fields['users_lname'] = $lastname; $fields['users_phone'] = $phone; $fields['users_city'] = $city; $fields['users_province'] = $province; $fields['users_country'] = $country; if (isset($settings['editable_email'])) { if ($settings['editable_email'] == "1" or $settings['editable_email'] == "0" and $isAdmin) { $fields['users_email'] = $email; } } elseif (!isset($settings['editable_email'])) { $fields['users_email'] = $email; } if ($isAdmin) { $comment = $_POST['comment']; $mins = $_POST['minutes']; $hours = $_POST['hours']; $months = $_POST['month']; $days = $_POST['days']; $years = $_POST['years']; if ($months == 'X' || $days == 'X' || $years == 'X' || $hours == 'X' || $mins == 'X') { $expire_timestamp = "X"; } else { $expire_timestamp = mktime($hours, $mins, 0, $months, $days, $years, -1); } $fields['users_comment'] = $comment; $fields['user_expires'] = $expire_timestamp; $fields['users_login'] = $login; } if (empty($theme)) { $fields['users_theme'] = NULL; } else { $fields['users_theme'] = $theme; } if (isset($_POST['new_password']) && !empty($_POST['new_password'])) { $fields['users_passwd'] = md5($_POST['new_password']); } if (!$db->editUser($fields, $user_id)) { print_failure(get_lang_f('failed_to_update_user_profile_error', $db->getError())); } else { print_success(get_lang_f('profile_of_user_modified_successfully', $login)); $db->logger(get_lang_f('profile_of_user_modified_successfully', $login)); } global $view; if ($isAdmin) { $view->refresh("?m=user_admin"); } else { if (isset($_SESSION['REFER'])) { $view->refresh($_SESSION['REFER']); } else { $view->refresh("?m=user_admin&p=edit_user&user_id=" . $_SESSION['user_id']); } } return; } } $userInfo = $db->getUserById($user_id); $ft = new FormTable(); $ft->start_form('?m=user_admin&p=edit_user'); $ft->add_field_hidden('user_id', $user_id); $ft->start_table(); $login_option = !$isAdmin ? 'readonly="readonly"' : ""; $ft->add_field('string', 'login', $userInfo['users_login'], 50, $login_option); if ($my_user_id === $user_id) { $ft->add_field('password', 'current_password', ''); } $ft->add_field('password', 'new_password', ''); $ft->add_field('password', 'retype_new_password', ''); $locale_files = makefilelist("lang/", ".|..|.svn", true, "folders"); array_push($locale_files, "-"); sort($locale_files); $ft->add_custom_field('language', create_drop_box_from_array($locale_files, "newlang", @$userInfo['users_lang'])); require_once 'modules/settings/functions.php'; $theme = ""; $add_empty = FALSE; if (isset($userInfo['users_theme'])) { $theme = $userInfo['users_theme']; $add_empty = TRUE; } $ft->add_custom_field('theme', get_theme_html_str($theme, $add_empty)); $ft->add_field('string', 'first_name', $userInfo['users_fname']); $ft->add_field('string', 'last_name', $userInfo['users_lname']); $ft->add_field('string', 'phone_number', $userInfo['users_phone']); $email_option = (!$isAdmin and isset($settings['editable_email']) and $settings['editable_email'] == "0") ? 'readonly="readonly"' : ""; $ft->add_field('string', 'email_address', $userInfo['users_email'], 50, $email_option); $ft->add_field('string', 'city', $userInfo['users_city']); $ft->add_field('string', 'province', $userInfo['users_province']); $ft->add_field('string', 'country', $userInfo['users_country']); if ($isAdmin) { $ft->add_field('text', 'comment', $userInfo['users_comment']); ?> <tr> <td align='right'><?php print_lang('expires'); ?> :</td> <?php $timediff = $userInfo["user_expires"]; //echo "Timediff is $timediff<br>"; if (read_expire($timediff) !== 'X') { $exday = date("j", $timediff); $exyear = date("Y", $timediff); $exmonth = date("m", $timediff); $exhour = date("H", $timediff); $exmin = date("i", $timediff); } else { $exday = "X"; $exyear = "X"; $exmonth = "X"; $exhour = "X"; $exmin = "X"; } $minutes = range(0, 59); $pad_length = 2; foreach ($minutes as &$minute) { $minute = str_pad($minute, $pad_length, "0", STR_PAD_LEFT); } $months = array('X' => 'X', '1' => 'Jan', '2' => 'Feb', '3' => 'Mar', '4' => 'Apr', '5' => 'May', '6' => 'Jun', '7' => 'July', '8' => 'Aug', '9' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec'); #The ugliness below is to populate the expiration fields with what is in the db #Looks bad, but it works well echo "<td align='left'>"; $x_array = array('X'); echo create_drop_box_from_array(array_merge($x_array, range(1, 31)), "days", $exday, true); echo create_drop_box_from_array($months, "month", $exmonth, false); echo create_drop_box_from_array(array_merge($x_array, range(date('Y') - 1, date('Y') + 10)), "years", $exyear, true); echo " - "; echo create_drop_box_from_array(array_merge($x_array, range(0, 23)), "hours", $exhour, true); echo ":"; echo create_drop_box_from_array(array_merge($x_array, $minutes), "minutes", $exmin, true); echo "<tr><td colspan='2' class='info'>" . get_lang('expires_info') . "</td></tr>"; } $ft->end_table(); $ft->add_button("submit", "edit_user", get_lang('save_profile')); $ft->end_form(); echo "</div>"; }