function exec_ogp_module() { global $db; $isAdmin = $db->isAdmin($_SESSION['user_id']); require_once 'includes/lib_remote.php'; if (isset($_GET['home_id']) and $_GET['home_id'] != "total") { 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; } $remote = new OGPRemoteLibrary($game_home['agent_ip'], $game_home['agent_port'], $game_home['encryption_key']); $r = $remote->rfile_exists($game_home['home_path']); if ($r == 1) { $du = $remote->exec("du -sb " . $game_home['home_path']); list($size, $path) = explode("\t", $du); if (isset($_GET['bytes'])) { echo $size; } else { echo numbersFormatting($size); } } else { echo get_lang("does_not_exist_yet"); } } elseif ($isAdmin) { $game_homes = $db->getGameHomes(); $total_size = 0; foreach ($game_homes as $game_home) { $remote = new OGPRemoteLibrary($game_home['agent_ip'], $game_home['agent_port'], $game_home['encryption_key']); $r = $remote->rfile_exists($game_home['home_path']); if ($r == 1) { $du = $remote->exec("du -sb " . $game_home['home_path']); list($kilobytes, $path) = explode("\t", $du); $kilobytes = intval(preg_replace('/\\D/', '', $kilobytes)); $total_size += $kilobytes; } } echo numbersFormatting($total_size); } }
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; require_once 'includes/lib_remote.php'; $access = FALSE; $port = $_REQUEST['port']; $ip = $_REQUEST['ip']; $server_home = $db->getGameHomeByIP($ip, $port); $home_id = $server_home['home_id']; // Is user ?? $users = $db->getUsersByHomeId($home_id); if ($users) { foreach ($users as $user) { if ($user['user_id'] == $_SESSION['user_id']) { $access = TRUE; } } } // Is group user ?? $groupusers = $db->getGroupUsersByHomeId($home_id); if ($groupusers) { foreach ($groupusers as $groupuser) { if ($groupuser['user_id'] == $_SESSION['user_id']) { $access = TRUE; } } } // Is admin ?? $isAdmin = $db->isAdmin($_SESSION['user_id']); if ($isAdmin) { $access = TRUE; } if ($access == FALSE) { print_failure("Access Denied!"); die; } $server_xml = read_server_config(SERVER_CONFIG_LOCATION . "/" . $server_home['home_cfg_file']); $xml_installer = $server_xml->installer; $mod = $server_xml->mods->mod['key']; if ($server_xml->protocol == "gameq") { $query_name = $server_xml->gameq_query_name; } elseif ($server_xml->protocol == "lgsl") { $query_name = $server_xml->lgsl_query_name; } else { $query_name = $mod; } // If query name does not exist use mod key instead. //Properties for all servers if (isset($_GET['home_id']) && $_GET['home_id'] == $server_home['home_id']) { $trclass = "class='expandme'"; } $user = $db->getUserById($server_home['user_id_main']); $btns = "<a href='?m=gamemanager&p=gamemanager&home_id=" . $server_home['home_id'] . "'><img src='images/gamemanager.png' style='border:0;height:16px;' />" . get_lang('gamemanager') . "</a> " . "<a href='?m=gamemanager&p=log&home_id=" . $server_home['home_id'] . "'><img style='border:0;height:16px;' src='images/log.png'/>" . get_lang('view_log') . "</a> " . "<a href='?m=ftp&home_id=" . $server_home['home_id'] . "'><img style='border:0;height:16px;' src='images/ftp.png'/>" . get_lang('ftp') . "</a>"; // Check if the screen running the server is running. if ($server_xml->protocol == "gameq") { require 'protocol/GameQ/functions.php'; require_once 'protocol/GameQ/GameQMonitor.php'; } else { if ($server_xml->protocol == "lgsl") { require 'protocol/lgsl/functions.php'; require_once 'protocol/lgsl/LGSLMonitor.php'; } else { if ($server_xml->protocol == "teamspeak3") { require_once 'protocol/TeamSpeak3/TS3Monitor.php'; } else { // This is here because some servers are not supported by LGSL/GameQ or // because we do not have proper support for them yet. // With properly supported games this should not needed. // (In a perfect world no one would need an insurance.) $status = "online"; $map = $status; $maplocation = get_map_path($query_name, $mod, $map); @($notifications .= get_lang("query_protocol_not_supported")); } } } @($map_icon = "<img class='mapicon' src='{$maplocation}'/>"); @($currentmap = $map); //Properties for Specific Status if ($status == "half" || $status == "online") { if ($status == "online") { $onlineT = "<div>"; $onlineT .= "{$map_icon}"; $onlineT .= "</div>"; $onlineT .= "<div>"; @($onlineT .= get_lang('hostname') . ": <marquee class='hostname'>{$name}</marquee><br />"); @($onlineT .= get_lang('current_map') . ": {$currentmap}"); $onlineT .= "</div>"; } else { if ($status == "half") { @($notifications .= get_lang("failed_querying_server")); } } $remote_server_id = $server_home['remote_server_id']; $rserver = $db->getRemoteServerById($remote_server_id); $remote = new OGPRemoteLibrary($rserver['agent_ip'], $rserver['agent_port'], $rserver['encryption_key'], $rserver['timeout']); $startup_file_exists = $remote->rfile_exists("startups/" . $server_home['ip'] . "-" . $server_home['port']) === 1; $SrvCtrl = "<table class='srvctrl'><tr>"; if ($startup_file_exists) { $SrvCtrl .= "<td style='border:0;text-align:center;background:transparent'><a href='?m=gamemanager&p=restart&home_id=" . $server_home['home_id'] . "&mod_id=" . $server_home['mod_id'] . "&ip=" . $server_home['ip'] . "&port=" . $server_home['port'] . "'><img src='images/restart.png' width='64' border='0' alt='" . get_lang('restart_server') . "' /><br><b>" . get_lang('restart_server') . "</b></a></td>"; } $SrvCtrl .= "<td style='border:0;text-align:center;background:transparent'><a href='?m=gamemanager&p=stop&home_id=" . $server_home['home_id'] . "&ip=" . $server_home['ip'] . "&port=" . $server_home['port'] . "'><img src='images/stop.png' width='64' border='0' alt='" . get_lang('stop_server') . "' /><br><b>" . get_lang('stop_server') . "</b></a></td></tr></table>"; } //Echo them all echo "<div class='monitor-1'>" . @$onlineT . @$halfT . @$offlineT . "</div>" . "<div class='monitor-2 bloc'>" . @$SrvCtrl . "</div>"; if (isset($player_list)) { echo "<div class='monitor-3'>" . @$player_list . "</div>"; } if (isset($notifications)) { echo "<div class='monitor-3 bloc'>" . @$notifications . "</div>"; } }
$mod_id = $server_home['mod_id']; if (!array_key_exists($mod_id, $home_info['mods'])) { print_failure(get_lang('unable_retrieve_mod_info')); return; } 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) { return; } $param_access_enabled = preg_match("/p/", $home_info['access_rights']) > 0 ? TRUE : FALSE; $extra_param_access_enabled = preg_match("/e/", $home_info['access_rights']) > 0 ? TRUE : FALSE; if (!isset($_POST['start_server'])) { $server_exec = clean_path($home_info['home_path'] . "/" . $server_xml->exe_location . "/" . $server_xml->server_exec_name); $r = $remote->rfile_exists($server_exec); if ($r === 0) { print_failure(get_lang_f('game_exec_not_found', $server_exec)); return; } else { if ($r === -1) { print_failure(get_lang("agent_offline")); return; } else { if ($r !== 1) { print_failure(get_lang('unexpected_result_libremote')); return; } } } $ip_info = $db->getHomeIpPorts($home_id);
function exec_ogp_module() { $home_id = $_REQUEST['home_id']; if (empty($home_id)) { print_failure(get_lang('home_id_missing')); return; } global $db, $view; $isAdmin = $db->isAdmin($_SESSION['user_id']); if ($isAdmin) { $home_cfg = $db->getGameHome($home_id); } else { $home_cfg = $db->getUserGameHome($_SESSION['user_id'], $home_id); } if ($home_cfg === FALSE) { print_failure(get_lang('no_access_to_home')); return; } litefm_check($home_id); $remote = new OGPRemoteLibrary($home_cfg['agent_ip'], $home_cfg['agent_port'], $home_cfg['encryption_key']); $os_string = $remote->what_os(); $os = preg_match("/Linux/i", $os_string) ? "linux" : "windows"; echo "<h2>"; echo empty($home_cfg['home_name']) ? get_lang('not_available') : $home_cfg['home_name']; echo "</h2>"; // We must always add the home directory to the fm_cwd so that user // can not go out of the homedir. $path = clean_path($home_cfg['home_path'] . "/" . @$_SESSION['fm_cwd_' . $home_id]); $upload_folder_path = "modules/litefm/uploads/home_id_{$home_id}"; if (isset($_GET['pid']) and $_GET['pid'] != "") { $bytes = $_GET['bytes']; $totalsize = $bytes / 1024; $uploaded_filename = $_GET['uploaded_filename']; $dest_file_path = clean_path($upload_folder_path . "/" . $uploaded_filename . ".txt"); $kbytes = $remote->rsync_progress(clean_path($path . "/" . $uploaded_filename)); list($totalsize, $mbytes, $pct) = explode(";", do_progress($kbytes, $totalsize)); $totalmbytes = round($totalsize / 1024, 2); $pct = $pct > 100 ? 100 : $pct; if ($pct > 0) { echo '<div class="dragbox bloc rounded" style="background-color:#dce9f2;" > <h4>' . get_lang('upload') . " " . $uploaded_filename . " {$mbytes}MB/{$totalmbytes}MB</h4>\n\t\t\t\t <div style='background-color:#dce9f2;' >\n\t\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\t</div>\n\t\t\t\t </div>"; } $pid = $_GET['pid']; if ($remote->is_file_download_in_progress($pid) == 0) { unlink($dest_file_path); $directory = dir($upload_folder_path); $directory_not_empty = FALSE; while (FALSE !== ($item = $directory->read()) && !isset($directory_not_empty)) { if ($item != '.' && $item != '..') { $directory_not_empty = TRUE; } } $directory->close(); if (!$directory_not_empty) { rmdir($upload_folder_path); } print_success(print_lang('upload_complete')); $db->logger(get_lang('upload_complete') . " ( " . clean_path($path . "/" . $uploaded_filename) . " )"); $view->refresh('?m=litefm&home_id=' . $home_id, 2); return; } else { print_success(print_lang('upload_in_progress')); $view->refresh('?m=litefm&home_id=' . $home_id . "&uploaded_filename={$uploaded_filename}&bytes={$bytes}&pid={$pid}&upload=true", 2); return; } } else { echo "<table class='center'><tr><td><a href='?m=gamemanager&p=game_monitor&home_id=" . $home_cfg['home_id'] . "'><< " . get_lang('back') . "</a></td></tr></table>"; $POST_MAX_SIZE = ini_get('post_max_size'); $mul = substr($POST_MAX_SIZE, -1); $mul = $mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1)); if (isset($_GET['upload']) && $_GET['upload'] == "true" && $_SERVER['CONTENT_LENGTH'] > $mul * (int) $POST_MAX_SIZE && $POST_MAX_SIZE) { print_failure(get_lang_f('upload_failed', '( php.ini: upload_max_filesize = ' . ini_get('upload_max_filesize') . ", post_max_size = " . ini_get('post_max_size') . ", memory_limit = " . ini_get('memory_limit') . ' )')); } if (isset($_POST['upload'])) { if (isset($_FILES['uploaded_file'])) { $bytes = $_FILES['uploaded_file']['size']; $bad_chars = preg_replace("/([[:alnum:]_\\.-]*)/", "", $_FILES['uploaded_file']['name']); $bad_arr = str_split($bad_chars); $uploaded_filename = str_replace($bad_arr, "", $_FILES['uploaded_file']['name']); $dest_file_path = clean_path($upload_folder_path . "/" . $uploaded_filename . ".txt"); $s = isset($_SERVER['HTTPS']) ? "s" : ""; $p = isset($_SERVER['SERVER_PORT']) & $_SERVER['SERVER_PORT'] != "80" ? ":" . $_SERVER['SERVER_PORT'] : NULL; $url = 'http' . $s . '://' . $_SERVER['SERVER_NAME'] . $p . $_SERVER['SCRIPT_NAME']; $file_url = str_replace("home.php", $dest_file_path, $url); if ($_FILES['uploaded_file']['error'] > 0) { print_failure(get_lang_f('upload_failed'), $_FILES['uploaded_file']['error']); } else { if (!file_exists($upload_folder_path)) { if (!mkdir($upload_folder_path, 0777, true)) { print_failure(get_lang_f('can_not_create_upload_folder_path'), $upload_folder_path); } } if (file_exists($dest_file_path)) { unlink($dest_file_path); } move_uploaded_file($_FILES["uploaded_file"]["tmp_name"], $dest_file_path); if (file_exists($dest_file_path)) { $remote_file_path = clean_path($path . "/" . $uploaded_filename); if ($remote->rfile_exists($remote_file_path)) { $remote->exec('rm -f ' . $remote_file_path); } $uncompress = isset($_POST['uncompress']) ? "uncompress" : ""; $pid = $remote->start_file_download($file_url, $path, $uploaded_filename, $uncompress); if ($remote->is_file_download_in_progress($pid) < 0) { print_failure(get_lang_f('upload_failed', get_lang_f('url_is_not_accesible_from_agent', $file_url))); } else { $view->refresh('?m=litefm&home_id=' . $home_id . "&uploaded_filename={$uploaded_filename}&bytes={$bytes}&pid={$pid}&upload=true", 1); } } } } } if (isset($_POST['create_folder'])) { $bad_chars = preg_replace("/([[:alnum:]_\\.-]*)/", "", $_POST['folder_name']); $bad_arr = str_split($bad_chars); $folder_name = str_replace($bad_arr, "", $_POST['folder_name']); $remote->exec('mkdir ' . clean_path($path . "/" . $folder_name)); $db->logger(get_lang('create_folder') . " " . clean_path($path . "/" . $folder_name)); } if (isset($_POST['delete'])) { if (!isset($_POST['delete_check'])) { echo "<table class='center' style='width:100%;' ><tr>\n" . "<td>" . get_lang_f('delete_item', clean_path($path . "/" . $_POST['delete'])) . "</td>" . "</tr><tr><td>" . '<form action="?m=litefm&home_id=' . $home_id . '" method="post" enctype="multipart/form-data">' . "\n" . '<input type="hidden" name="delete" value="' . $_POST['delete'] . '">' . "\n" . '<button name="delete_check" value="yes" >' . get_lang('yes') . "</button>\n" . '<button name="delete_check" value="no" >' . get_lang('no') . "</button>\n" . "</form>\n" . "</td>\n" . "</tr>\n" . "</table>\n"; } elseif ($_POST['delete_check'] == "yes") { $remote->exec('rm -Rf "' . clean_path($path . "/" . $_POST['delete']) . '"'); $db->logger('rm -Rf "' . clean_path($path . "/" . $_POST['delete']) . '"'); } } // Chattr Check if (isset($_POST['secureButton'])) { if (!isset($_POST['secure_check'])) { echo "<table class='center' style='width:100%;' ><tr>\n" . "<td>" . get_lang_f('secure_item', clean_path($path . "/" . $_POST['secureFile'])) . "</td>" . "</tr><tr><td>" . '<form action="?m=litefm&home_id=' . $home_id . '" method="post" >' . "\n" . '<input type="hidden" name="secureFile" value="' . $_POST['secureFile'] . '">' . "\n" . '<input type="hidden" name="secureButton" value="' . $_POST['secureButton'] . '">' . "\n" . '<button name="secure_check" value="yes" >' . get_lang('yes') . "</button>\n" . '<button name="secure_check" value="no" >' . get_lang('no') . "</button>\n" . "</form>\n" . "</td>\n" . "</tr>\n" . "</table>\n"; } elseif ($_POST['secure_check'] == "yes") { $chatAction = $_POST['secureButton']; if ($chatAction == get_lang('chattr_yes')) { $action = 'chattr+i'; } else { $action = 'chattr-i'; } $pathToFile = clean_path($path . "/" . $_POST['secureFile']); $remote->secure_path($action, $pathToFile); if ($action == 'chattr+i') { $db->logger(get_lang('chattr_locked') . ": {$pathToFile}"); } else { $db->logger(get_lang('chattr_unlocked') . ": {$pathToFile}"); } } } echo "<table class='center' style='width:100%;' ><tr>\n" . "<td colspan='3' ><h3>" . get_lang_f('currently_viewing', $path) . "</h3></td>" . "</tr><tr><td style='border:1px solid gray;'>" . get_lang('upload_file') . ':<form action="?m=litefm&home_id=' . $home_id . '&upload=true" method="post" enctype="multipart/form-data">' . "\n" . '<input type="file" name="uploaded_file" id="file">' . "\n" . '<input type="checkbox" name="uncompress" value="true"> ' . get_lang('uncompress') . "\n" . '<input type="submit" name="upload" value="' . get_lang('upload') . '">' . "\n" . "</form>\n" . "</td>\n" . "<td>\n" . " " . "</td>\n" . "<td style='border:1px solid gray;' >\n" . get_lang('create_folder') . ':<form action="?m=litefm&home_id=' . $home_id . '&create_folder=true" method="post" >' . "\n" . '<input type="text" name="folder_name" />' . "\n" . '<input type="submit" name="create_folder" value="' . get_lang('create') . '"/>' . "\n" . "</form>\n" . "</td></tr>\n" . "</table>\n"; if (!$remote->rfile_exists($path)) { $path = clean_path($home_cfg['home_path']); if (!$remote->rfile_exists($path)) { print_failure(get_lang_f("dir_not_found", $path)); } else { $_SESSION['fm_cwd_' . $home_id] = str_replace("\\", "", dirname($_SESSION['fm_cwd_' . $home_id])); echo '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=?m=litefm&home_id=' . $home_id . '">'; } } else { $dirlist = $remote->remote_dirlistfm($path); if ($os == "linux") { $lsattr = $remote->exec('lsattr ' . $path); } if (!is_array($dirlist)) { if ($dirlist === -1) { if ($path != $home_cfg['home_path'] . "/") { echo '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=?m=litefm&home_id=' . $home_id . '">'; } else { print_failure('Your game server\'s home path is too long or there is a file with a very long name inside of your game server\'s home folder.'); } } else { if ($remote->rfile_exists($path)) { if (strpos($path, '/') !== FALSE) { $ePath = explode('/', $path); $filename = end($ePath); } else { if (strpos($path, '\\') !== FALSE) { $ePath = explode('\\', $path); $filename = end($ePath); } } $_SESSION['fm_cwd_' . $home_id] = str_replace("\\", "", dirname($_SESSION['fm_cwd_' . $home_id])); echo '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=?m=litefm&home_id=' . $home_id . '&path=' . $filename . '&p=read_file">'; } else { print_failure(get_lang("failed_list")); } } return; } if (empty($dirlist)) { print_lang('empty_directory'); echo "<table class='center' style='width:100%;' >\n" . show_back($home_id) . "</table>"; } else { echo "<table class='center' style='width:100%;' >\n" . show_back($home_id) . "<tr><td style='width:10px;' ></td><td align=left>\n" . get_lang('filename') . "</td>"; if ($os == "linux") { echo "<td>" . get_lang('filesecure') . "</td>"; } echo "<td>" . get_lang('filesize') . " [" . get_lang('bytes') . "]</td><td>" . get_lang('owner') . " " . get_lang('group') . "</td></tr>\n"; $directorys = array(); $files = array(); $binarys = array(); foreach ($dirlist as $item) { # dirlist FM returns an array. Each element has 5 fields separated by the | character list($filename, $size, $user, $group, $type) = explode("|", $item); $filepath = str_replace("/", "\\/", clean_path($path . "/" . $filename)); if ($os == "linux") { preg_match('/(\\S+)\\s' . $filepath . '/', $lsattr, $file_attributes); } // Directory if ($type == 'D') { $directorys[$filename]['filename'] = $filename; $directorys[$filename]['user'] = $user; $directorys[$filename]['group'] = $group; } elseif ($type == 'F') { $files[$filename]['filename'] = $filename; $files[$filename]['size'] = $size; $files[$filename]['user'] = $user; $files[$filename]['group'] = $group; if ($os == "linux") { $files[$filename]['attr'] = $file_attributes[1]; } } elseif ($type == 'B') { $binarys[$filename]['filename'] = $filename; $binarys[$filename]['size'] = $size; $binarys[$filename]['user'] = $user; $binarys[$filename]['group'] = $group; if ($os == "linux") { $binarys[$filename]['attr'] = $file_attributes[1]; } } } foreach ($directorys as $directory) { echo "<tr>\n" . "<td>" . '<form method=POST>' . "<input type=hidden name='delete' value='" . $directory['filename'] . "' class='item' />\n" . '<input type="image" style="width:12px;padding-left:5px;" src="modules/administration/images/remove.gif" />' . "</form>\n" . "</td>" . "<td align=left>" . "<img class=\"viewitem\" src=\"images/folder.png\" alt=\"Directory\" /> " . "<a href=\"?m=litefm&home_id={$home_id}&path=" . $directory['filename'] . "\">" . $directory['filename'] . "</a></td>"; if ($os == "linux") { echo "<td>-</td>"; } echo "<td>-</td> <td>" . $directory['user'] . " " . $directory['group'] . "</td>\n" . "</tr>\n"; } foreach ($files as $file) { if ($os == "linux") { if ($isAdmin) { $secureFile = '<td><form method=POST>'; $secureFile .= "<input type=hidden name='secureFile' value='" . $file['filename'] . "' class='item' />\n"; if (preg_match("/i/", $file['attr'])) { $secureFile .= "<input type='submit' class='chattrButton' name='secureButton' value='" . get_lang('chattr_no') . "' class='item' />\n"; } else { $secureFile .= "<input type='submit' class='chattrButton' name='secureButton' value='" . get_lang('chattr_yes') . "' class='item' />\n"; } $secureFile .= '</form></td>'; } else { $secureFile = "<td><span class="; if (preg_match("/i/", $file['attr'])) { $secureFile .= "'chattrLock'>" . get_lang('chattr_locked'); } else { $secureFile .= "'chattrUnlock'>" . get_lang('chattr_unlocked'); } $secureFile .= "</span></td>\n"; } } else { $secureFile = ""; } echo "<tr>\n" . "<td>" . '<form method=POST>' . "<input type=hidden name='delete' value='" . $file['filename'] . "' class='item' />\n" . '<input type="image" style="width:12px;padding-left:5px;" src="modules/administration/images/remove.gif" />' . "</form>\n" . "</td>" . "<td align=left>"; echo "<img class=\"viewitem\" src=\"images/txt.png\" alt=\"Text file\" /> " . "<a href=\"?m=litefm&home_id={$home_id}&path=" . $file['filename'] . "&p=read_file\">" . get_lang("button_edit") . "</a>" . $file['filename'] . "</td>\n\t\t\t\t\t\t {$secureFile}<td>" . $file['size'] . "</td> <td>" . $file['user'] . " " . $file['group'] . "</td>\n"; echo "</tr>\n"; } foreach ($binarys as $binary) { if ($os == "linux") { if ($isAdmin) { $secureFile = '<td><form method=POST>'; $secureFile .= "<input type=hidden name='secureFile' value='" . $binary['filename'] . "' class='item' />\n"; if (preg_match("/i/", $binary['attr'])) { $secureFile .= "<input type='submit' class='chattrButton' name='secureButton' value='" . get_lang('chattr_no') . "' class='item' />\n"; } else { $secureFile .= "<input type='submit' class='chattrButton' name='secureButton' value='" . get_lang('chattr_yes') . "' class='item' />\n"; } $secureFile .= '</form></td>'; } else { $secureFile = "<td><span class="; if (preg_match("/i/", $binary['attr'])) { $secureFile .= "'chattrLock'>" . get_lang('chattr_locked'); } else { $secureFile .= "'chattrUnlock'>" . get_lang('chattr_unlocked'); } $secureFile .= "</span></td>\n"; } } else { $secureFile = ""; } echo "<tr>\n" . "<td>" . '<form method=POST>' . "<input type=hidden name='delete' value='" . $binary['filename'] . "' class='item' />\n" . '<input type="image" style="width:12px;padding-left:5px;" src="modules/administration/images/remove.gif" />' . "</form>\n" . "</td>" . "<td align=left>"; echo "<img class=\"viewitem\" src=\"images/exec.png\" alt=\"Binary file\" /> " . $binary['filename'] . "</td>\n\t\t\t\t\t\t {$secureFile}<td>" . $binary['size'] . "</td><td>" . $binary['user'] . " " . $binary['group'] . "</td>\n"; echo "</tr>\n"; } echo "</table>\n"; } } } echo "<table class='center'><tr><td><a href='?m=gamemanager&p=game_monitor&home_id=" . $home_cfg['home_id'] . "'><< " . get_lang('back') . "</a></td></tr></table>"; }
function exec_ogp_module() { global $db; global $view; require_once 'includes/lib_remote.php'; $game = "N/A"; $home_id = $_GET['home_id']; $y = isset($_GET['y']) ? $_GET['y'] : ""; $files = isset($_GET['files']) ? $_GET['files'] : ""; $force = isset($_GET['force']) ? $_GET['force'] : ""; $home_info = $db->getGameHomeWithoutMods($home_id); if ($home_info === FALSE) { print_failure("User home_id {$home_id} not found."); $view->refresh("?m=user_games"); return; } if ($y !== 'y') { echo "<p>" . get_lang_f('sure_to_delete_serverid_from_remoteip_and_directory', $home_info['home_id'], $home_info['agent_ip'], $home_info['home_path']) . "</p>"; $server_info = $db->getRemoteServerById($home_info['remote_server_id']); $remote = new OGPRemoteLibrary($server_info['agent_ip'], $server_info['agent_port'], $server_info['encryption_key']); $r = $remote->rfile_exists($home_info['home_path']); if ($r == 1) { echo "<p><a href=\"?m=user_games&p=del&y=y&home_id={$home_id}&files=y\">" . get_lang('yes_and_delete_the_files') . "</a> | "; } echo "<a href=\"?m=user_games&p=del&y=y&home_id={$home_id}\">" . get_lang('yes') . "</a> | <a href=\"?m=user_games\">" . get_lang('no') . "</a></p>"; return; } if ($force == 'y') { if ($db->deleteGameHome($home_id) === FALSE) { print_failure(get_lang('failed_to_remove_gamehome_from_database')); } else { print_success(get_lang_f('successfully_deleted_game_server_with_id', $home_id)); $db->logger(get_lang_f('successfully_deleted_game_server_with_id', $home_id)); } global $view; $view->refresh("?m=user_games"); return; } if ($db->IsFtpEnabled($home_id)) { $ftp_login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id; $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']); if ($remote->ftp_mgr("userdel", $ftp_login) === 0) { print_failure(get_lang('failed_to_remove_ftp_account_from_remote_server')); echo "<p>" . get_lang('remove_it_anyway') . "<p>\n\t\t\t\t<a href=\"?m=user_games&p=del&y=y&force=y&home_id={$home_id}\">" . get_lang('yes') . "</a> | <a href=\"?m=user_games\">" . get_lang('no') . "</a></p>"; return; } else { if ($db->deleteGameHome($home_id) === FALSE) { print_failure(get_lang('failed_to_remove_gamehome_from_database')); } else { print_success(get_lang_f('successfully_deleted_game_server_with_id', $home_info['home_id'])); $db->logger(get_lang_f('successfully_deleted_game_server_with_id', $home_info['home_id'])); } } } else { if ($db->deleteGameHome($home_id) === FALSE) { print_failure(get_lang('failed_to_remove_gamehome_from_database')); } else { print_success(get_lang_f('successfully_deleted_game_server_with_id', $home_info['home_id'])); $db->logger(get_lang_f('successfully_deleted_game_server_with_id', $home_info['home_id'])); } } if ($files == 'y') { $server_info = $db->getRemoteServerById($home_info['remote_server_id']); $remote = new OGPRemoteLibrary($server_info['agent_ip'], $server_info['agent_port'], $server_info['encryption_key']); $del_rc = $remote->remove_home($home_info['home_path']); while (!$del_rc) { sleep(1); } if ($del_rc == 1) { print_success(get_lang_f('sucessfully_deleted', $home_info['home_path'])); $db->logger(get_lang_f('sucessfully_deleted', $home_info['home_path'])); } elseif ($del_rc == 0) { print_failure(get_lang_f('the_agent_had_a_problem_deleting', $home_info['home_path'])); } } global $view; $view->refresh("?m=user_games"); }