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 ogpHome() { global $db, $view, $settings; ?> %top% <?php if (isset($_SESSION['user_id'])) { $isAdmin = $db->isAdmin($_SESSION['user_id']); if ($isAdmin) { $server_homes = $db->getIpPorts(); } else { $server_homes = $db->getIpPortsForUser($_SESSION['user_id']); } $servers_by_game_name = array(); foreach ($server_homes as $server_home) { $servers_by_game_name["{$server_home['game_name']}"][] = $server_home; } ksort($servers_by_game_name); $game_homes_list = "<ul id='submenu_0' >\n"; foreach ($servers_by_game_name as $game_name => $server_homes) { $game_homes_list .= "<li>\n<a href='?m=gamemanager&p=game_monitor&home_cfg_id=" . $server_homes[0]['home_cfg_id'] . "'>{$game_name}</a>\n<ul id='submenu_1' >\n"; foreach ($server_homes as $server_home) { $button_name = $server_home['home_name']; if (!preg_match("/none/i", $server_home['mod_name'])) { $button_name .= " - " . $server_home['mod_name']; } $game_homes_list .= "<li><a title='" . $server_home['ip'] . ':' . $server_home['port'] . "' class='user_menu_link' 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'] . "'>" . $button_name . "</a></li>\n"; } $game_homes_list .= "</ul>\n</li>\n"; } $game_homes_list .= "</ul>\n"; ?> <div class="menu-bg"> <div class="menu"> <ul> <?php $menus = $db->getMenusForGroup('user'); foreach ($menus as $menu) { $module = $menu['module']; if (!empty($menu['subpage'])) { $subpage = "&p=" . $menu['subpage']; $button = $menu['subpage']; if (isset($_GET['p']) and $_GET['p'] == $menu['subpage']) { $menu_link_class = 'user_menu_link_selected'; } else { $menu_link_class = 'user_menu_link'; } } else { $subpage = ""; $button = $menu['module']; if (isset($_GET['m']) and $_GET['m'] == $menu['module']) { $menu_link_class = 'user_menu_link_selected'; } else { $menu_link_class = 'user_menu_link'; } } $button_url = "?m=" . $module . $subpage; if (preg_match('/\\_?\\_/', get_lang("{$button}"))) { $button_name = $menu['menu_name']; } else { $button_name = get_lang("{$button}"); } echo "<li><a class='" . $menu_link_class . "' href='" . $button_url . "'>" . $button_name . "</a>"; if (!empty($server_homes) and $menu['subpage'] == "game_monitor") { echo $game_homes_list; } echo "</li>\n"; } if (!$isAdmin) { $isSubUser = $db->isSubUser($_SESSION['user_id']); } if ($isAdmin) { ?> <li> <?php $data = ""; $TotalSelected = false; $menus = $db->getMenusForGroup('admin'); foreach ($menus as $key => $row) { if (!empty($row['subpage'])) { $name[$key] = $row['subpage']; } else { $name[$key] = $row['module']; } $translation[$key] = get_lang($name[$key]); } array_multisort($translation, $name, SORT_DESC, $menus); foreach ($menus as $menu) { $module = $menu['module']; if (!empty($menu['subpage'])) { $subpage = "&p=" . $menu['subpage']; $button = $menu['subpage']; if (isset($_GET['p']) and $_GET['p'] == $menu['subpage']) { $menu_link_class = 'admin_menu_link_selected'; } else { $menu_link_class = 'admin_menu_link'; } } else { $subpage = ""; $button = $menu['module']; if (isset($_GET['m']) and $_GET['m'] == $menu['module']) { $menu_link_class = 'admin_menu_link_selected'; } else { $menu_link_class = 'admin_menu_link'; } } if ($menu_link_class == 'admin_menu_link_selected' && isset($_GET['m']) && $_GET['m'] != 'user_admin') { $TotalSelected = true; } else { if (isset($_GET['m']) && $_GET['m'] == 'user_admin') { if (!isset($_GET['p'])) { $TotalSelected = true; } else { if ($_GET['p'] != 'edit_user') { $TotalSelected = true; } } } } $button_url = "?m=" . $module . $subpage; if (preg_match('/\\_?\\_/', get_lang("{$button}"))) { $button_name = $menu['menu_name']; } else { $button_name = get_lang("{$button}"); } $data .= "<li><a class='" . $menu_link_class . "' href='" . $button_url . "'>" . $button_name . "</a></li>\n"; } ?> <a href="?m=administration&p=main" <?php if ((isset($_GET['m']) and $_GET['m'] == "administration") || $TotalSelected) { echo 'class="admin_menu_link_selected"'; } else { echo 'class="admin_menu_link"'; } ?> target="_self" ><?php echo get_lang('administration'); ?> </a> <ul> <?php echo $data; ?> </ul> </li> <?php } ?> <li> <a href="?m=user_admin&p=edit_user&user_id=<?php echo $_SESSION['user_id']; ?> " <?php if (isset($_GET['p']) and $_GET['p'] == "edit_user") { echo 'class="user_menu_link_selected"'; } else { echo 'class="user_menu_link"'; } ?> target="_self" ><?php echo $_SESSION['users_login']; ?> </a> <ul> <?php // Normal users only! if (!$isAdmin && !$isSubUser) { if ($db->isModuleInstalled("subusers")) { ?> <li><a href="?m=subusers&p=submanage"><?php print_lang('sub_users'); ?> </a></li> <?php } ?> <li><a href="?m=user_admin&p=show_groups"><?php print_lang('show_groups'); ?> </a></li> <?php } ?> <li><a href="?logout">[<?php print_lang('logout'); ?> ]</a></li> </ul> </li> <?php if (isset($settings['custom_tab']) && $settings['custom_tab'] == "1") { if (isset($settings['custom_tab_name']) && !empty($settings['custom_tab_name'])) { ?> <li> <a href="<?php echo $settings['custom_tab_link']; ?> " target="<?php echo $settings['custom_tab_target_blank']; ?> " ><?php echo $settings['custom_tab_name']; ?> </a> <?php if (isset($settings['custom_tab_sub']) && $settings['custom_tab_sub'] == "1") { ?> <ul> <li><a href="<?php echo $settings['custom_tab_sub_link']; ?> " target="<?php echo $settings['custom_tab_target_blank']; ?> " ><?php echo $settings['custom_tab_sub_name']; ?> </a></li> <?php if (isset($settings['custom_tab_sub_name2']) && !empty($settings['custom_tab_sub_name2'])) { ?> <li><a href="<?php echo $settings['custom_tab_sub_link2']; ?> " target="<?php echo $settings['custom_tab_target_blank']; ?> " ><?php echo $settings['custom_tab_sub_name2']; ?> </a></li> <?php } if (isset($settings['custom_tab_sub_name3']) && !empty($settings['custom_tab_sub_name3'])) { ?> <li><a href="<?php echo $settings['custom_tab_sub_link3']; ?> " target="<?php echo $settings['custom_tab_target_blank']; ?> " ><?php echo $settings['custom_tab_sub_name3']; ?> </a></li> <?php } if (isset($settings['custom_tab_sub_name4']) && !empty($settings['custom_tab_sub_name4'])) { ?> <li><a href="<?php echo $settings['custom_tab_sub_link4']; ?> " target="<?php echo $settings['custom_tab_target_blank']; ?> " ><?php echo $settings['custom_tab_sub_name4']; ?> </a></li> <?php } ?> </ul> <?php } ?> </li> <?php } } ?> </ul> </div> </div> <?php } ?> %topbody% <?php heading(); //tagged for future use... /* $postdata = ""; foreach($_POST as $key =>$value) $postdata .= ",'$key': '$value'"; $postdata = substr($postdata,1); $postdata = "{".$postdata."}"; */ ?> <div class="clear"></div> %botbody% %bottom% <?php }
function exec_ogp_module() { global $view; global $db; echo "<h2>" . get_lang('add_new_remote_host') . "</h2>"; echo "<p>" . get_lang('note_remote_host') . "</p>"; require_once "includes/form_table_class.php"; $ft = new FormTable(); $ft->start_form("?m=server&p=add"); $ft->start_table(); $ft->add_field('string', 'remote_host', ""); $ft->add_field('string', 'remote_host_port', "12679"); $ft->add_field('string', 'remote_host_name', ""); $ft->add_field('string', 'remote_host_user_name', ""); $ft->add_field('string', 'remote_host_ftp_ip', ""); $ft->add_field('string', 'remote_host_ftp_port', "21"); $ft->add_field('string', 'remote_encryption_key', ""); $ft->add_field('string', 'timeout', "2"); $ft->add_field('on_off', 'use_nat', "0"); $ft->end_table(); $ft->add_button('submit', 'add_remote_host', get_lang('add_remote_host')); $ft->end_form(); $servers = $db->getRemoteServers(); if ($servers === FALSE) { return; } $tr = 0; ?> <table id="servermonitor" class="tablesorter remote"> <thead> <tr> <th colspan="4" ><?php print_lang('configured_remote_hosts'); ?> </th> </tr> </thead> <tbody> <?php foreach ($servers as $server_row) { #generate jQuery code $jqboobles["{$server_row['remote_server_id']}"] = '$("#tonus-' . $server_row['remote_server_id'] . '").tooltip({ delay: 0, showURL: false, bodyHandler: function() { return $("<img/>").attr("src", this.src); } });'; #check to see if the remote daeomns are up status_chk is found in lib_remote.php $remote = new OGPRemoteLibrary($server_row['agent_ip'], $server_row['agent_port'], $server_row['encryption_key']); $host_stat = $remote->status_chk(); $buttons = "<a href='?m=server&p=edit&rhost_id=" . $server_row['remote_server_id'] . "&delete'>[" . get_lang('delete') . "]</a>\n" . "<a href='?m=server&p=edit&rhost_id=" . $server_row['remote_server_id'] . "&edit'>[" . get_lang('edit') . "]</a>\n"; $tittle = "<b>ID#:</b> <b style='color:red;'>" . $server_row['remote_server_id'] . "</b></td>\n\t\t\t\t\t<td class='collapsible' ><b>" . get_lang('server_name') . ":</b> " . $server_row['remote_server_name'] . "</td>\n\t\t\t\t\t<td class='collapsible' ><b>" . get_lang('agent_status') . ":</b> "; $booble = ""; if ($host_stat === 0) { $tittle .= "<span class='failure'>" . get_lang('offline') . "</span> "; } elseif ($host_stat === 1) { $os = $remote->what_os(); $buttons .= "<a href='?m=server&p=log&rhost_id=" . $server_row['remote_server_id'] . "'>[" . get_lang('view_log') . "]</a>\n"; $tittle .= "<span class='success'>" . get_lang('online') . "</span>"; $booble .= "<img id='tonus-{$server_row['remote_server_id']}' src='includes/api.php?remote_server={$server_row['remote_server_id']}&mon_stats' height='20' />"; } elseif ($host_stat === -1) { $tittle .= "<span class='failure'>" . get_lang('encryption_key_mismatch') . "</span>\n"; } else { $tittle .= "<span class='failure'>" . get_lang('unknown_error') . ": {$host_stat}</span>\n"; } $tittle .= "</td><td>{$buttons}</td>"; $ftp_ip = empty($server_row['ftp_ip']) ? $server_row['agent_ip'] : $server_row['ftp_ip']; $data = "<tr class='expand-child' >\n\t\t\t\t <td>{$booble}</td><td>\n\t\t\t\t\t<b>" . get_lang('ogp_user') . ":</b> " . $server_row['ogp_user'] . "<br />\n\t\t\t\t\t<b>" . get_lang('agent_ip_port') . ":</b> " . $server_row['agent_ip'] . ":" . $server_row['agent_port'] . "<br />\n\t\t\t\t\t<b>" . get_lang('remote_host_ftp_ip') . ":</b> " . $ftp_ip . "<br />\n\t\t\t\t\t<b>" . get_lang('remote_host_ftp_port') . ":</b> " . $server_row['ftp_port'] . "<br />\n\t\t\t\t\t<b>" . get_lang('timeout') . ":</b> " . $server_row['timeout'] . " " . get_lang('seconds') . "<br />\n\t\t\t\t\t<b>" . get_lang('encryption_key') . ":</b> " . $server_row['encryption_key'] . "<br />\n\t\t\t\t </td>\n\t\t\t\t <td><b>" . get_lang('ips') . ": </b><br>"; // Next we print the IP addresses and one empty field. $remote_server_ips = $db->getRemoteServerIPs($server_row['remote_server_id']); if (empty($remote_server_ips)) { $data .= "<span class='failure'>" . get_lang('no_ip_for_remote_host') . "</span>"; } else { foreach ($remote_server_ips as $ip_row) { $data .= $ip_row['ip'] . "<br>"; } } $data .= "</td><td>"; if ($host_stat === 1) { $data .= "<b>OS:</b> " . @$os . "<br>"; if (preg_match("/Linux/", $os)) { $data .= "<b>" . get_lang('ufw') . ":</b>"; if (isset($_GET['ch_ufw_status']) and $server_row['remote_server_id'] == $_GET['rhost_id']) { $rhost_id = $_GET['rhost_id']; $ch_ufw_status = $_GET['ch_ufw_status']; $db->query("UPDATE `OGP_DB_PREFIXremote_servers`\n\t\t\t\t\t\t\t\tSET ufw_status = '{$ch_ufw_status}'\n\t\t\t\t\t\t\t\tWHERE remote_server_id = '{$rhost_id}'"); if ($ch_ufw_status == "enable") { $remote->sudo_exec("ufw allow " . $server_row['agent_port']); //OGP agent port $remote->sudo_exec("ufw allow " . $server_row['ftp_port']); //FTP port $remote->sudo_exec("ufw allow 80"); //Apache (web server) port $remote->sudo_exec("ufw allow 22"); //SSH (putty) port $remote->sudo_exec("ufw allow 25"); //SMTP (mail) port $remote->sudo_exec("ufw allow proto tcp to any port 40000:65000"); //unknow range of ports needed by the OGP agent $remote->sudo_exec("echo y | ufw {$ch_ufw_status}"); } else { $remote->sudo_exec("ufw {$ch_ufw_status}"); } } if (!$db->query("SELECT ufw_status FROM `OGP_DB_PREFIXremote_servers`")) { $status = "disable"; } else { $status = $db->resultQuery("SELECT ufw_status \n\t\t\t\t\t\t\t\t\t\t FROM `OGP_DB_PREFIXremote_servers` \n\t\t\t\t\t\t\t\t\t\t WHERE remote_server_id = '" . $server_row['remote_server_id'] . "'"); $status = $status[0]['ufw_status']; if (empty($status)) { $status = "disable"; } } $data .= "<br />"; if ($status == "enable") { $data .= "<b>" . get_lang('status') . "</b> " . get_lang('on') . "<br />\n\t\t\t\t\t\t\t <a href='?m=server&rhost_id=" . $server_row['remote_server_id'] . "&ch_ufw_status=disable'>[" . get_lang('stop_firewall') . "]</a>\n"; } elseif ($status == "disable") { $data .= "<b>" . get_lang('status') . "</b> " . get_lang('off') . "<br />\n\t\t\t\t\t\t\t <a href='?m=server&rhost_id=" . $server_row['remote_server_id'] . "&ch_ufw_status=enable'>[" . get_lang('start_firewall') . "]</a>\n"; } $data .= "<br />"; } } $data .= "</td></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"> $(function() { <?php foreach ($jqboobles as $jqbooble) { echo "{$jqbooble}\n"; } ?> }); </script> <script type="text/javascript"> $(document).ready(function(){ $("#servermonitor") .collapsible("td.collapsible", {collapse: true}) .tablesorter({sortList: [[0,0], [1,0]] , widgets: ['zebra','repeatHeaders']}); }); </script> <?php }
function ogpHome() { global $db, $view, $settings; if (isset($_GET['lang']) and $_GET['lang'] != "-") { $lang = $_GET['lang']; } elseif (isset($settings['panel_language'])) { $lang = $settings['panel_language']; } else { $lang = "English"; } $locale_files = makefilelist("lang/", ".|..|.svn", true, "folders"); $lang_sel = "<form method=GET ><select name='lang' onchange=\"this.form.submit();\" >\n" . "<option>-</option>\n"; for ($i = 0; $i < count($locale_files); $i++) { $selected = (isset($_GET['lang']) and $_GET['lang'] != "-" and $_GET['lang'] == $locale_files[$i]) ? "selected='selected'" : ""; $lang_sel .= "<option {$selected} value='" . $locale_files[$i] . "' >" . $locale_files[$i] . "</option>\n"; } $lang_sel .= "</select></form>\n"; $lang_switch = (isset($_GET['lang']) and $_GET['lang'] != "-") ? "&lang=" . $_GET['lang'] : ""; ?> %top% <div class="menu-bg"> <div class="menu"> <ul> <li><a href="index.php<?php echo preg_replace("/\\&/", "?", $lang_switch); ?> " <?php if (!isset($_GET['m'])) { echo 'class="admin_menu_link_selected"'; } else { echo 'class="admin_menu_link"'; } ?> target="_self" ><?php echo get_lang('login_title'); ?> </a></li> <?php $menus = $db->getMenusForGroup('guest'); if (!empty($menus)) { foreach ($menus as $menu) { $module = $menu['module']; if (!empty($menu['subpage'])) { $subpage = "&p=" . $menu['subpage']; $button = $menu['subpage']; if (isset($_GET['p']) and $_GET['p'] == $menu['subpage']) { $menu_link_class = 'user_menu_link_selected'; } else { $menu_link_class = 'user_menu_link'; } } else { $subpage = ""; $button = $menu['module']; if (isset($_GET['m']) and $_GET['m'] == $menu['module']) { $menu_link_class = 'user_menu_link_selected'; } else { $menu_link_class = 'user_menu_link'; } } $button_url = "?m=" . $module . $subpage . $lang_switch; if (preg_match('/\\_?\\_/', get_lang("{$button}"))) { $button_name = $menu['menu_name']; } else { $button_name = get_lang("{$button}"); } echo "<li><a class='" . $menu_link_class . "' href='" . $button_url . "'>" . $button_name . "</a>\n\t\t\t\t </li>\n"; } } ?> </ul> </div> </div> %topbody% <?php if (isset($_GET['m'])) { heading(); //tagged for future use... /* $postdata = ""; foreach($_POST as $key =>$value) $postdata .= ",'$key': '$value'"; $postdata = substr($postdata,1); $postdata = "{".$postdata."}"; */ } else { if (isset($_SESSION['users_login'])) { $userInfo = $db->getUser($_SESSION['users_login']); if (isset($_SESSION['users_passwd']) and !empty($_SESSION['users_passwd']) and $_SESSION['users_passwd'] == $userInfo['users_passwd']) { print_success(get_lang('already_logged_in_redirecting_to_dashboard') . "."); $view->refresh("home.php?m=dashboard&p=dashboard", 2); echo "%botbody%\n\t\t\t\t\t %bottom%"; return; } } if (isset($_POST['login'])) { if (isset($_SERVER["REMOTE_ADDR"])) { $client_ip = $_SERVER["REMOTE_ADDR"]; } elseif (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) { $client_ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } elseif (isset($_SERVER["HTTP_CLIENT_IP"])) { $client_ip = $_SERVER["HTTP_CLIENT_IP"]; } $ban_list = $db->resultQuery("SHOW TABLES LIKE 'OGP_DB_PREFIXban_list';"); if (empty($ban_list)) { $db->query("CREATE TABLE IF NOT EXISTS `OGP_DB_PREFIXban_list` (\n\t\t\t\t\t\t\t`client_ip` varchar(255) NOT NULL,\n\t\t\t\t\t\t\t`logging_attempts` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t\t`banned_until` varchar(16) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t\t PRIMARY KEY (`client_ip`)\n\t\t\t\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); } $banlist_info = $db->resultQuery("SELECT logging_attempts, banned_until FROM `OGP_DB_PREFIXban_list` WHERE client_ip='" . $client_ip . "';"); $login_attempts = $banlist_info == FALSE ? 0 : $banlist_info['0']['logging_attempts']; if ($banlist_info == FALSE) { $db->query("INSERT INTO `OGP_DB_PREFIXban_list` (`client_ip`) VALUES('{$client_ip}');"); } if ($banlist_info != FALSE and $banlist_info['0']['banned_until'] > 0 and $banlist_info['0']['banned_until'] <= time()) { $db->query("UPDATE `OGP_DB_PREFIXban_list` SET logging_attempts='0', banned_until='0' WHERE client_ip = '{$client_ip}';"); } if ($login_attempts >= 3) { print_failure("Banned until " . date("r", $banlist_info['0']['banned_until'])); echo "%botbody%\n\t\t\t\t\t %bottom%"; return; } $userInfo = $db->getUser($_POST['ulogin']); // If result matched $myusername and $mypassword, table row must be 1 row if (isset($userInfo['users_passwd']) && md5($_POST['upassword']) == $userInfo['users_passwd']) { $_SESSION['user_id'] = $userInfo['user_id']; $_SESSION['users_login'] = $userInfo['users_login']; $_SESSION['users_passwd'] = $userInfo['users_passwd']; $_SESSION['users_group'] = $userInfo['users_role']; $_SESSION['users_lang'] = isset($_GET['lang']) ? $_GET['lang'] : $userInfo['users_lang']; $_SESSION['users_theme'] = $userInfo['users_theme']; print_success(get_lang('logging_in') . "..."); $db->logger(get_lang('logging_in') . "..."); $db->query("UPDATE `OGP_DB_PREFIXban_list` SET logging_attempts='0', banned_until='0' WHERE client_ip = '{$client_ip}';"); $view->refresh("home.php?m=dashboard&p=dashboard", 2); } else { print_failure(get_lang('bad_login')); $login_attempts++; $db->query("UPDATE `OGP_DB_PREFIXban_list` SET logging_attempts='{$login_attempts}' WHERE client_ip = '{$client_ip}';"); if ($login_attempts >= 3) { $banned_until = time() + 300; // Five minutes banned from the panel. $db->query("UPDATE `OGP_DB_PREFIXban_list` SET banned_until='" . $banned_until . "' WHERE client_ip = '{$client_ip}';"); } $view->refresh("index.php", 2); } echo "%botbody%\n\t\t\t\t %bottom%"; return; } ?> <!-- Made for Revolution Theme v2 --> <style type="text/css"> div.main-content { background:transparent; border:none; padding:0; border-radius:0px; -moz-border-radius:0px; } </style> <table style='width:200px' align='center'> <tr style='background-color:transparent;' > <td style='background-color:transparent;' > <div class='bloc' > <h4><?php print_lang('login_title'); ?> </h4> <br> <table> <tr> <td><?php print_lang('lang'); ?> :</td> <td><?php echo $lang_sel; ?> </td> </tr> <form action="index.php<?php echo preg_replace("/\\&/", "?", $lang_switch); ?> " name="login_form" method="post"> <tr> <td><?php print_lang('login'); ?> :</td> <td><input type="text" name="ulogin" id="ulogin" value="" ONFOCUS="clearDefault(this)" size="20" /></td> </tr> <tr> <td><?php print_lang('password'); ?> :</td> <td><input type="password" name="upassword" value="" size="20" /></td> </tr> <tr> <td><input type="submit" name="login" value="<?php print_lang('login_button'); ?> " /></td> <td><a href="?m=lostpwd<?php echo $lang_switch; ?> "><?php print_lang('lost_passwd'); ?> </a></td> </tr> </form> <script language="JavaScript"> document.login_form.ulogin.focus(); </script> </table> <br> </div> </td> </tr> </table> <?php } ?> <div class="clear"></div> %botbody% %bottom% <?php }
function exec_ogp_module() { if (isset($_POST['default'])) { unset($_SESSION['height']); unset($_SESSION['width']); } if (isset($_SESSION['height'])) { $height = $_SESSION['height']; } else { $height = 420; $_SESSION['height'] = $height; } if (isset($_SESSION['width'])) { $width = $_SESSION['width']; } else { $width = 770; $_SESSION['width'] = $width; } if (isset($_POST['h_bigger'])) { $_SESSION['height'] = $_SESSION['height'] + 50; $height = $_SESSION['height']; } if (isset($_POST['h_smaller'])) { $_SESSION['height'] = $_SESSION['height'] - 50; $height = $_SESSION['height']; } if (isset($_POST['w_bigger'])) { $_SESSION['width'] = $_SESSION['width'] + 50; $width = $_SESSION['width']; } if (isset($_POST['w_smaller'])) { $_SESSION['width'] = $_SESSION['width'] - 50; $width = $_SESSION['width']; } ?> <IFRAME SRC="<?php echo $_GET['external_link']; ?> " WIDTH=<?php echo $width; ?> HEIGHT=<?php echo $height; ?> style="border:1px solid transparent;background-color:white" ></IFRAME> <br> <table style='text-align:center;'> <tr> <td colspan=3><form action="" method=POST><input type='submit' value='-H' name='h_smaller'/></form></td> </tr> <tr> <td><form action="" method=POST><input type='submit' value='-W' name='w_smaller'/></form></td> <td><form action="" method=POST><input type='submit' value='0' name='default'/></form></td> <td><form action="" method=POST><input type='submit' value='+W' name='w_bigger'/></form></td> </tr> <tr> <td colspan=3><form action="" method=POST><input type='submit' value='+H' name='h_bigger'/></form></td> </tr> <tr> </tr></table> <a href="?m=administration&p=main"><?php print_lang('back'); ?> </a> <?php }
function exec_ogp_module() { global $db; ?> <div class="center"> <h2><?php print_lang('add_new_group'); ?> </h2> <p><?php print_lang('info_group'); ?> </p> <?php require_once 'includes/form_table_class.php'; $ft = new FormTable(); $ft->start_form('?m=user_admin&p=add_group'); $ft->start_table(); $ft->add_field('string', 'group_name', ''); $ft->end_table(); $ft->add_button('submit', 'add_group', get_lang('add_group')); $ft->end_form(); ?> </div> <?php echo '<h2>' . get_lang('available_groups') . '</h2>'; if ($db->isAdmin($_SESSION['user_id'])) { $result = $db->getGroupList(); } else { $result = $db->getUserGroupList($_SESSION['user_id']); } if ($result === FALSE) { echo "<p class='note'>" . get_lang('no_groups_available') . "</p>"; return; } $i = 0; echo "<table class='center'><tr class='tr{$i}'><td>" . get_lang('actions') . "</td><td>" . get_lang('group_name') . "</td><td>" . get_lang('users') . "</td></tr>"; foreach ($result as $row) { $i++; echo "<tr class='tr{$i}'><td><a href='?m=user_games&p=assign&group_id=" . $row['group_id'] . "'>[" . get_lang('assign_homes') . "]</a><br />\n <a href='?m=user_admin&p=del_group&group_id=" . $row['group_id'] . "'>[" . get_lang('delete_group') . ']</a>'; echo "</td><td>" . $row['group_name'] . "</td>"; echo "<td class='left'>"; $subusersEnabled = $db->isModuleInstalled("subusers"); if (!$subusersEnabled) { $available_users = $db->getAvailableUsersForGroup($row['group_id']); } else { if (!$db->isAdmin($_SESSION['user_id'])) { $available_users = $db->getAvailableSubUsersForGroup($row['group_id'], $_SESSION['user_id']); $subEnabled = true; } else { $available_users = $db->getAvailableUsersForGroup($row['group_id']); } } if (is_array($available_users)) { if (count($available_users) > 0) { echo "<form action=\"?m=user_admin&p=add_to_group\" method=\"post\">" . get_lang('add_user_to_group') . ": <select name=\"user_to_add\">"; foreach ($available_users as $user_row) { echo "<option value=\"{$user_row['user_id']}\">{$user_row['users_login']}</option>"; } echo "</select>\n"; echo "<input type='hidden' name='group_id' value='{$row['group_id']}' />"; echo "<input type='submit' name='add_user_to_group' value='" . get_lang('add_user') . "' />"; echo "</form>\n"; } else { if ($subEnabled) { echo "<p>" . get_lang('no_subusers') . "</p>"; } } } else { if ($subEnabled) { echo "<p>" . get_lang('no_subusers') . "</p>"; } } $group_users = $db->listUsersInGroup($row['group_id']); if (is_array($group_users)) { echo "<ul>"; foreach ($group_users as $user_id) { $user_info = $db->getUserById($user_id['user_id']); echo "<li><a href='?m=user_admin&p=del_from_group&group_id=" . $row['group_id'] . "&user_id=" . $user_id['user_id'] . "'>[" . get_lang('remove_from_group') . "]</a> {$user_info['users_login']}</li>"; } echo "</ul>"; } echo "</td></tr>"; } echo "</table>"; }
function exec_ogp_module() { include 'includes/lib_remote.php'; global $db; global $view; if (isset($_POST['add_ftp_user'])) { $server_row = $db->getRemoteServer($_POST['remote_server_id']); $remote = new OGPRemoteLibrary($server_row['agent_ip'], $server_row['agent_port'], $server_row['encryption_key']); $post_ftp_login = trim($_POST['ftp_login']); $host_stat = $remote->status_chk(); $ftp_accounts_list = $remote->ftp_mgr("list"); $ftp_accounts = explode("\n", $ftp_accounts_list); $user_exists = FALSE; 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 ($user_exists === TRUE) { print_failure(get_lang('ftp_account_already_exists')); } else { $remote->ftp_mgr("useradd", $post_ftp_login, $_POST['ftp_password'], $_POST['full_path']); } } if (isset($_POST['del_ftp_user_y'])) { $server_row = $db->getRemoteServer($_POST['remote_server_id']); $remote = new OGPRemoteLibrary($server_row['agent_ip'], $server_row['agent_port'], $server_row['encryption_key']); $remote->ftp_mgr("userdel", $_POST['ftp_login']); $home_info = $db->getHomeByFtpLogin($server_row['remote_server_id'], $_POST['ftp_login']); $db->changeFtpStatus('disabled', $home_info['home_id']); } if (isset($_POST['edit_ftp_user'])) { $server_row = $db->getRemoteServer($_POST['remote_server_id']); $remote = new OGPRemoteLibrary($server_row['agent_ip'], $server_row['agent_port'], $server_row['encryption_key']); $settings = ""; foreach ($_POST as $key => $value) { if ($key != "edit_ftp_user" and $key != "ftp_login" and $key != "remote_server_id") { $account_settings .= "{$key}\t{$value}\n"; } } $remote->ftp_mgr("usermod", $_POST['ftp_login'], $account_settings); } ?> <style type="text/css"> .collapsible { width: 6px; } .collapsible a.collapsed { margin: 2px; display: block; width: 15px; height: 15px; background: url(images/tablesorter_expand.png) no-repeat 3px 3px; outline: 0; } .collapsible a.expanded { margin: 2px; display: block; width: 15px; height: 15px; background: url(images/tablesorter_expand.png) no-repeat -24px 3px; outline: 0; } </style> <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script> <script type="text/javascript" src="js/jquery.tablesorter.mod.js"></script> <script type="text/javascript" src="js/jquery.tablesorter.collapsible.js"></script> <script type="text/javascript"> $(document).ready( function (){ $(".tablesorter").collapsible("td.collapsible", {collapse: true}) .tablesorter({ // set default sort column sortList: [[4,0]], // don't sort by first column headers: {0: {sorter: false}} // set the widgets being used - zebra stripping , widgets: ['zebra'] , onRenderHeader: function (){ this.wrapInner("<span></span>"); } , debug: false }); } ); </script> <?php echo "<h2>" . get_lang('pure-ftpd_admin') . "</h2>"; $servers = $db->getRemoteServers(); echo "<tr><td colspan='3' >\n\t\t<form method=POST >\n\t\t<table class='center' style='width:100%' ><tr>\n\t\t<td>" . get_lang('remote_server') . " <select style='width:250px' name='remote_server_id' >"; foreach ($servers as $server_row) { echo "<option value='" . $server_row['remote_server_id'] . "' >" . $server_row['remote_server_name'] . " (" . $server_row['agent_ip'] . ":" . $server_row['agent_port'] . ")</option>"; } echo "</select>\n\t\t\t</td>\n\t\t\t<td>" . get_lang('login') . "<input type=text name='ftp_login' /></td>\n\t\t\t<td>" . get_lang('password') . "<input type=text name='ftp_password' /></td>\n\t\t\t<td>" . get_lang('full_path') . "<input type=text name='full_path' /></td>\n\t\t </tr>\n\t\t <tr>\n\t\t\t<td colspan=4 ><input style='width:100%;' type=submit name='add_ftp_user' value='" . get_lang('add_ftp_account') . "' /></td>\n\t\t </tr>\n\t\t </table>\n\t\t </form>\n\t\t </td></tr>"; ?> <table id="servermonitor" class="tablesorter"> <thead> <tr> <th></th><th><?php print_lang('remote_server'); ?> </th><th><?php print_lang('login'); ?> </th><th><?php print_lang('server_name'); ?> </th><th><?php print_lang('full_path'); ?> </th> </tr> </thead> <tbody> <?php foreach ($servers as $server_row) { $remote = new OGPRemoteLibrary($server_row['agent_ip'], $server_row['agent_port'], $server_row['encryption_key']); $host_stat = $remote->status_chk(); $status = ($host_stat === 0 or $host_stat === -1) ? "<span class='failure'>" . get_lang('offline') . "</span>" : "<span class='success'>" . get_lang('online') . "</span>"; if ($host_stat === 1) { $ftp_accounts_list = $remote->ftp_mgr("list"); $ftp_accounts = explode("\n", $ftp_accounts_list); foreach ($ftp_accounts as $ftp_account) { if (!empty($ftp_account)) { list($ftp_login, $ftp_path) = explode("\t", $ftp_account); $ftp_login = trim($ftp_login); $home_info = $db->getHomeByFtpLogin($server_row['remote_server_id'], $ftp_login); $expandme = (isset($_POST['ftp_login']) and $ftp_login == $_POST['ftp_login'] and (isset($_POST['remote_server_id']) and $home_info['remote_server_id'] == $_POST['remote_server_id'])) ? "expandme" : ""; $home_name = isset($home_info['home_name']) ? $home_info['home_name'] : $ftp_path; echo "<tr class='maintr {$expandme}'><td class='collapsible' ></td><td>" . $server_row['remote_server_name'] . " (" . $server_row['agent_ip'] . ")</td><td><b class='failure' >{$ftp_login}</td><td>{$home_name}</td><td>{$ftp_path}</td></tr>\n\t\t\t\t\t\t <tr class='expand-child' ><td colspan='4' >\n\t\t\t\t\t\t <form method=POST >\n\t\t\t\t\t\t <table>"; $account_details = $remote->ftp_mgr("show", $ftp_login); $ftp_account_detail_list = explode("\n", $account_details); foreach ($ftp_account_detail_list as $detail_line) { if (!empty($detail_line)) { list($key, $value) = explode(" : ", $detail_line); $key = trim($key); $value = trim($value); $blacklist = array("Login", "Password", "UID", "GID", "ftp_user_id", "username", "username_prefix", "password", "sys_userid", "sys_groupid", "sys_perm_user", "sys_perm_group", "sys_perm_other", "server_id", "parent_domain_id", "uid", "gid"); if (in_array($key, $blacklist)) { continue; } $value_parts = explode(" ", $value); $value = $value_parts[0]; @($advert = $value_parts[1]); if ($key == "Allowed local IPs" or $key == "ul_ratio" or count($ftp_account_detail_list) == 4 and $key == "Directory") { echo "</table>\n</td><td>\n<table>\n"; } if ($key == "Directory") { $value = str_replace("/./", "", $value); } if ($key == "Username") { $readOnly = true; } echo "<tr><td>{$key}</td><td>\n\t\t\t\t\t\t\t\t\t <input type=text name='{$key}' value='{$value}' "; if (isset($readOnly) && $readOnly) { echo "readonly "; } echo "/>\n\t\t\t\t\t\t\t\t </td><td>{$advert}</td></tr>\n"; unset($readOnly); } } echo "<tr>\n\t\t\t\t\t\t\t<td colspan='2' >\n\t\t\t\t\t\t\t <center>\n\t\t\t\t\t\t\t <input type=hidden name='remote_server_id' value='" . $server_row['remote_server_id'] . "'/>\n\t\t\t\t\t\t\t <input type=hidden name='ftp_login' value='{$ftp_login}'/>\n\t\t\t\t\t\t\t <input type=submit name='edit_ftp_user' value='" . get_lang('change_account_details') . "' />\n\t\t\t\t\t\t\t </center>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t <input type='image' name='del_ftp_user' onsubmit='submit-form();' src='modules/administration/images/remove.gif'>" . get_lang('remove_account') . "</input>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t </tr>\n\t\t\t\t\t\t </table>\n\t\t\t\t\t\t </form>\n\t\t\t\t\t\t </td>\n\t\t\t\t\t\t</tr>"; } } } } echo "</tbody>"; echo "</table>\n"; }
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; global $view; if (isset($_POST['submit'])) { $username = trim($_POST['username']); $user_role = trim($_POST['user_role']); $password = trim($_POST['newpass']); $password2 = trim($_POST['newpass2']); if (empty($password) || empty($password2)) { print_failure(get_lang('you_need_to_enter_both_passwords')); $view->refresh("?m=user_admin"); return; } if ($password !== $password2) { print_failure(get_lang('passwords_did_not_match')); $view->refresh("?m=user_admin"); return; } if (!$db->addUser($username, $password, $user_role)) { print_failure(get_lang_f('could_not_add_user_because_user_already_exists', $username)); $view->refresh("?m=user_admin"); return; } print_success(get_lang_f('successfully_added_user', $username)); $db->logger(get_lang_f('successfully_added_user', $username)); $view->refresh("?m=user_admin"); } else { ?> <div class="center"> <h2><?php print_lang('add_a_new_user'); ?> </h2> <form action="?m=user_admin&p=add" method="post"> <table class="center"> <tr><td align='right'><label for='username'><?php print_lang('username'); ?> :</label></td><td><input id="username" type="text" name="username" value="" /></td></tr> <tr><td align='right'><?php print_lang('user_role'); ?> :</td><td align='left'> <select name='user_role'> <option value="admin"><?php print_lang('admin'); ?> </option> <option value="user" selected="selected"><?php print_lang('user'); ?> </option></select></td></tr> <tr><td align='right'><label for='password'><?php print_lang('password'); ?> :</label></td><td><input id="password" type="password" name="newpass" value="" /></td></tr> <tr><td align='right'><label for='confirm_password'><?php print_lang('confirm_password'); ?> :</label></td> <td><input id="confirm_password" type="password" name="newpass2" value="" /></td></tr> </table> <p><input type="submit" name="submit" value="<?php print_lang('add_user'); ?> " /></p> </form> </div><?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>"; }
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; echo "<h2>" . get_lang('watch_logger') . "</h2>"; ?> <table class="center"> <tr> <td> <form> <b><?php print_lang('search'); ?> :</b> <input type="text" id="search"> </form> </td> <td> <form method=POST> <input type="submit" name="empty_logger" value="<?php print_lang('empty_logger'); ?> " > </form> </td> </tr> </table> <table id="servermonitor" class="tablesorter"> <thead> <tr> <th style="width:16px;background-position: center;"></th> <th><?php print_lang('when'); ?> </th> <th><?php print_lang('who'); ?> </th> <th><?php print_lang('where'); ?> </th> <th><?php print_lang('what'); ?> </th> </tr> </thead> <tbody> <?php if (isset($_POST['log_id'])) { $db->del_logger_log($_POST['log_id']); } if (isset($_POST['empty_logger'])) { $db->empty_logger(); } $logs = $db->read_logger(); foreach ($logs as $log) { $user = $db->getUserById($log['user_id']); $when = $log['date']; $who = $user['users_login']; $where = $log['ip']; $what = $log['message']; $log_id = $log['log_id']; // Template echo "<tr class='maintr'>\n" . "<td class='collapsible'>\n" . "<center>\n" . "<form method=POST>\n" . "<input type='hidden' name='log_id' value='{$log_id}' />\n" . "<input type='image' name='remove_log' onclick=\"this.form.submit();\" src='modules/administration/images/remove.gif' />\n" . "</form>\n" . "</center>\n" . "</td>\n" . "<td class='collapsible'><span class='hidden' >{$log_id}</span><a></a>{$when}</td>\n" . "<td class='collapsible'><a></a>{$who}</td>\n" . "<td class='collapsible'><a></a>{$where}</td>\n" . "<td class='collapsible'><a></a>{$what}</td>\n" . "</tr>\n"; echo "<tr class='expand-child'>\n" . "<td colspan='5' >\n" . "<table>\n"; $show_values = array("users_login", "users_lang", "users_role", "users_email", "user_expires"); foreach ($user as $key => $value) { if (in_array($key, $show_values)) { echo "<tr><td>" . str_replace("_", "", substr($key, 5)) . "</td><td>{$value}</td></tr>\n"; } } echo "</tr>\n" . "</td>\n" . "</table>\n"; } echo "</tbody>\n"; echo "<tfoot style='border:1px solid grey;'></tfoot>\n"; echo "</table>\n"; ?> <script type="text/javascript"> $(document).ready(function() { $('input#search').quicksearch('table#servermonitor tbody tr.maintr'); $("#servermonitor") .collapsible("td.collapsible", {collapse: true}) .tablesorter({sortList: [[1,1]] , widgets: ['zebra','repeatHeaders']}) ; } ); </script> <?php }
function exec_ogp_module() { global $db, $view; echo "<h2>" . get_lang('administration') . "</h2>"; echo "<table class='administration-table'>"; ### MAIN ICONS echo "<tr>\n"; $menus = $db->getMenusForGroup('admin'); foreach ($menus as $key => $row) { if (!empty($row['subpage'])) { $name[$key] = $row['subpage']; } else { $name[$key] = $row['module']; } $translation[$key] = get_lang($name[$key]); } array_multisort($translation, $name, SORT_DESC, $menus); $td = 0; foreach ($menus as $menu) { $module = $menu['module']; if (!empty($menu['subpage'])) { $subpage = "&p=" . $menu['subpage']; $button = $menu['subpage']; } else { $subpage = ""; $button = $menu['module']; } $button_url = "?m=" . $module . $subpage; if (preg_match('/\\_?\\_/', get_lang("{$button}"))) { $button_name = $menu['menu_name']; } else { $button_name = get_lang("{$button}"); } echo "<td><a class='administration-buttons' href='" . $button_url . "' /><div><img src='modules/administration/images/{$button}.png' /><br>{$button_name}</div></a></td><td class='administration-buttons-hmargin' ></td>\n"; $td++; if ($td == 4) { echo "</tr><tr class='administration-buttons-vmargin' ><td></td></tr><tr>\n"; $td = 0; } } echo "<td><a class='administration-buttons' href='?m=administration&p=banlist' />" . "<div><img src='modules/administration/images/banlist.png' /><br>" . get_lang('ban_list') . "</div></a></td>" . "<td class='administration-buttons-hmargin' ></td>\n"; echo "</tr>\n"; echo "</table>\n"; ### END MAIN ICONS ### DB BACKUP echo "<h2>" . get_lang('db_backup') . "</h2>"; ?> <table class='administration-table'> <tr> <td> <form method="POST"> <button name="download"><?php print_lang('download_db_backup'); ?> </button> </form> <br> <form method="POST" enctype="multipart/form-data"> <label for="file"><?php print_lang('sql_file'); ?> :</label> <input type="file" name="file" id="file" /> <button name="restore"><?php print_lang('restore_db_backup'); ?> </button> </form> </td> </tr> </table> <?php if (isset($_POST['download'])) { require 'includes/config.inc.php'; $randomdir = genRandomString('20'); @mkdir($randomdir); @chmod($randomdir, 0700); $file = $db_name . "_" . date("Y-m-d-H-i-s") . '.sql'; $backupFile = $randomdir . "/" . $file; $command = "mysqldump --opt -u {$db_user} -p{$db_pass} {$db_name} > {$backupFile}"; @system($command); echo '<meta HTTP-EQUIV="REFRESH" content="0; url=?m=administration&p=backupdwl&randir=' . $randomdir . '&dwfile=' . $file . '&type=cleared">'; } if (isset($_POST['restore'])) { require 'includes/config.inc.php'; $command = "mysql --user={$db_user} --password={$db_pass} {$db_name} < " . $_FILES["file"]["tmp_name"]; @system($command); } ### END OF DB BACKUP ### ADD ICONS TO IFRAME FORM. echo "<h2>" . get_lang('external_links') . "</h2>"; ?> <table class='center'> <td> <form action="" method=POST ><b><?php print_lang('name'); ?> :</b><input name="name" type=text size=10> <b><?php print_lang('url'); ?> :</b> <input name="url" type=text size=40> <input type=submit value='<?php print_lang('add_it'); ?> !'> </form> </td> </tr> </table> <table class='administration-table'> <tr> <?php if (isset($_POST['url'])) { $add_link = $db->addAdminExternalLink($_POST['name'], $_POST['url'], $_SESSION['user_id']); if ($add_link == FALSE) { print_failure(get_lang('imposible_add_link_this_to_databse')); } } ### END FOR ADD ICONS TO IFRAME FORM. ### ICONS TO FRAMES if (isset($_POST['link_id'])) { $external_links = $db->delAdminExternalLink($_POST['link_id'], $_SESSION['user_id']); if ($external_links == TRUE) { echo $_POST['name'] . " " . get_lang('link_has_been_removed') . "."; } else { print_failure(get_lang('link_does_not_exist')); } } echo "<tr>\n"; $external_links = $db->getAdminExternalLinks($_SESSION['user_id']); $td2 = 0; if ($external_links != 0) { foreach ($external_links as $external_link) { $url = $external_link['url']; $name = $external_link['name']; $link_id = $external_link['link_id']; echo "<td>"; echo "<a href='?m=administration&p=iframe&external_link=" . $url . "' ><img class='administration-buttons' src='modules/administration/images/link.png' /><br>" . $name . "</a>\n"; echo "<form action='' method='POST' ><input type='hidden' name='name' value='" . $name . "'><input type='hidden' name='link_id' value='" . $link_id . "'><input type='image' src='modules/administration/images/remove.gif' class='remove-button' onsubmit=" . '"submit-form();"' . "></form>"; echo "</td>"; $td2++; if ($td2 == 4) { echo "</tr><tr>\n"; $td2 = 0; } } } echo "</tr>\n" . "</table>\n"; ### END ICONS TO FRAMES ### CHANGE MENU ORDER if (isset($_POST['changeOrder'])) { foreach ($_POST as $key => $value) { if (preg_match("/^change_button/", $key)) { list($trash, $module_id) = explode("-", $key); $new_pos = $value; $db->changeMenuPosition($module_id, $new_pos); } } } echo "<h2>" . get_lang('change_buttons_order') . "</h2>"; echo "<table class='center'>" . "<tr>" . "<form method=POST >"; $menus = $db->getMenusForGroup('user'); $pos = 0; foreach ($menus as $menu) { $module = $menu['module']; if (!empty($menu['subpage'])) { $subpage = "&p=" . $menu['subpage']; $button = $menu['subpage']; if (isset($_GET['p']) and $_GET['p'] == $menu['subpage']) { $menu_link_class = 'user_menu_link_selected'; } else { $menu_link_class = 'user_menu_link'; } } else { $subpage = ""; $button = $menu['module']; if (isset($_GET['m']) and $_GET['m'] == $menu['module']) { $menu_link_class = 'user_menu_link_selected'; } else { $menu_link_class = 'user_menu_link'; } } $button_url = "?m=" . $module . $subpage; if (preg_match('/\\_?\\_/', get_lang("{$button}"))) { $button_name = $menu['menu_name']; } else { $button_name = get_lang("{$button}"); } echo "<td><input type=text name='change_button-" . $menu['module_id'] . "' value=" . $menu['pos'] . " style='text-align:right;width:20px;' > {$button_name}</input></td>\n"; $pos++; } echo "</tr>\n" . "<tr>\n" . "<td colspan={$pos} ><input type=submit name=changeOrder value='" . get_lang('change_buttons_order') . "' />\n" . "</form>\n" . "</td>\n" . "</tr>\n" . "</table>\n"; }
$nationality = $db->f("nationality"); echo "<tr><td align=right width=30%>" . $t->translate("Nationality") . ":</td><td width=70%>\n"; print_country($nationality); $actual_country = $db->f("actual_country"); echo "<tr><td align=right width=30%>" . $t->translate("Currently lives in") . ":</td><td width=70%>\n"; print_country($actual_country); echo "<tr><td align=right valign=top width=30%>" . $t->translate("Mother tongue") . ":</td><td width=70%>\n"; $mother_tongue = $db->f("mother_tongue"); print_lang($mother_tongue); echo "<tr><td align=right valign=top width=30%>" . $t->translate("Other languages") . ":</td><td width=70%>\n"; $other_lang_1 = $db->f("other_lang_1"); echo "1. "; print_lang($other_lang_1); $other_lang_2 = $db->f("other_lang_2"); echo "<BR>2. "; print_lang($other_lang_2); echo "</td></tr>\n"; if ($db->f("contact") != "no") { echo "<tr><td align=right width=30%>" . $t->translate("Contact") . ":</td><td width=70%>"; $pquery["devname"] = $db->f("username"); htmlp_link("pmess_compose.php", $pquery, $t->translate("write Developer")); } if ($db->f("showemail") == "yes") { echo "<tr><td align=right width=30%>" . $t->translate("E-Mail") . ":</td><td width=70%><a href=\"mailto:" . $db->f("email_usr") . "\">" . ereg_replace("@", " at ", htmlentities($db->f("email_usr"))) . "</a>\n"; } echo "<tr><td align=right width=30%>" . $t->translate("Developer last modified") . ":</td><td width=70%>\n"; $timestamp = mktimestamp($db->f("modification_usr")); echo timestr($timestamp) . "</td></tr>\n"; echo "<tr><td align=right width=30%>" . $t->translate("Developer created") . ":</td><td width=70%>\n"; $timestamp = mktimestamp($db->f("creation_usr")); echo timestr($timestamp) . "</td></tr>\n";
function exec_ogp_module() { global $db; if (isset($_GET['home_id'])) { $user_id = $_SESSION['user_id']; $home_id = $_GET['home_id']; $mod_id = $_GET['mod_id']; $isAdmin = $db->isAdmin($user_id); if ($isAdmin) { $home_info = $db->getGameHome($home_id); } else { $home_info = $db->getUserGameHome($user_id, $home_id); } $mods = $home_info['mods']; $current_mod_info = $mods[$mod_id]; $mod_name = $current_mod_info['mod_name']; $mod_key = $current_mod_info['mod_key']; if (strtolower($mod_name) == "none") { $mod = $mod_key; } else { $mod = $mod_name; } $game = $home_info['game_name']; $home_cfg_id = $home_info['home_cfg_id']; $mod_cfg_id = $home_info['mod_cfg_id']; echo "<h2>" . get_lang_f("presets_for_game_and_mod", $game, $mod) . "</h2>"; if (isset($_POST['add_rcon_preset'])) { $name = $_POST['name']; $command = $_POST['command']; $db->addRconPreset($name, $command, $home_cfg_id, $mod_cfg_id); } if (isset($_POST['del_rcon_preset'])) { $preset_id = $_POST['preset_id']; $db->delRconPreset($preset_id); } if (isset($_POST['change_rcon_preset'])) { $name = $_POST['name']; $command = $_POST['command']; $preset_id = $_POST['preset_id']; $db->changeRconPreset($name, $command, $preset_id); } ?> <table> <tr> <td> <form action="" method="post"> <?php print_lang('name'); ?> </td> <td> <input type="text" name="name" style="width:120px;" /> </td> <td> <?php print_lang('command'); ?> </td> <td> <input type="text" name="command" style="width:430px;" /> </td> <td> <input type="submit" value="<?php print_lang('add_preset'); ?> " name="add_rcon_preset" /> </form> </td> </tr> </table> <br> <?php $presets = $db->getRconPresets($home_cfg_id, $mod_cfg_id); if ($presets > 0) { echo "<h2>" . get_lang("edit_presets") . "</h2>"; echo "<table>"; foreach ($presets as $preset) { ?> <tr> <td> <form action="" method="post"> <?php print_lang('name'); ?> </td> <td> <input type="text" name="name" style="width:120px;" value="<?php echo $preset['name']; ?> " /> </td> <td> <?php print_lang('command'); ?> </td> <td> <input type="text" name="command" style="width:430px;" value="<?php echo $preset['command']; ?> "/> </td> <td> <input type="hidden" name="preset_id" value="<?php echo $preset['preset_id']; ?> " /> <input type="submit" value="<?php print_lang('change_preset'); ?> " name="change_rcon_preset" /> <input type="submit" value="<?php print_lang('del_preset'); ?> " name="del_rcon_preset" /> </form> </td> </tr> <?php } } echo "</table>"; echo "<table class='center'><tr><td><a href='?m=gamemanager&p=game_monitor&home_id=" . $home_id . "'><< " . get_lang('back') . "</a></td></tr></table>"; } }
function exec_ogp_module() { $home_id = $_GET['home_id']; $mod_id = $_GET['mod_id']; global $db; $home_info = $db->getGameHome($home_id); if (array_key_exists($mod_id, $home_info['mods'])) { echo "<h2>" . get_lang('cmds_for') . " \"" . $home_info['home_name'] . "\" [Mod:" . $home_info['mods'][$mod_id]['mod_name'] . "]</h2>"; include 'includes/lib_remote.php'; $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']); $mod_cfg_id = $home_info['mod_cfg_id']; if (isset($_POST['edit_preinstall_cmds'])) { $precmd = addslashes($_POST['edit_preinstall_cmds']); if (isset($_POST['save_as_default'])) { $game_mod_query = "UPDATE OGP_DB_PREFIXconfig_mods SET def_precmd='{$precmd}' WHERE mod_cfg_id='{$mod_cfg_id}'"; $db->query($game_mod_query); } else { $game_mod_query = "UPDATE OGP_DB_PREFIXgame_mods SET precmd='{$precmd}' WHERE mod_id='{$mod_id}'"; $db->query($game_mod_query); } unset($precmd); } $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 = "[" . get_lang('empty') . "]"; } else { $precmd = $config_mod_precmd[0]['def_precmd']; } } else { $precmd = $game_mod_precmd[0]['precmd']; } if (isset($_POST['edit_postinstall_cmds'])) { $postcmd = addslashes($_POST['edit_postinstall_cmds']); if (isset($_POST['save_as_default'])) { $game_mod_query = "UPDATE OGP_DB_PREFIXconfig_mods SET def_postcmd='{$postcmd}' WHERE mod_cfg_id='{$mod_cfg_id}'"; $db->query($game_mod_query); } else { $game_mod_query = "UPDATE OGP_DB_PREFIXgame_mods SET postcmd='{$postcmd}' WHERE mod_id='{$mod_id}'"; $db->query($game_mod_query); } unset($postcmd); } $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 = "[" . get_lang('empty') . "]"; } else { $postcmd = $config_mod_postcmd[0]['def_postcmd']; } } else { $postcmd = $game_mod_postcmd[0]['postcmd']; } ?> <h2><?php print_lang('preinstall_cmds'); ?> </h2> <table class="center"> <tr> <td> <form method="POST"> <textarea name="edit_preinstall_cmds" style="width:80%;height:200px;" ><?php echo $precmd; ?> </textarea> </td> </tr> <tr> <td> <button><?php print_lang('edit_preinstall_cmds'); ?> </button> <input type="checkbox" name="save_as_default" value="true"/><?php print_lang('save_as_default_for_this_mod'); ?> </form> </td> </tr> </table> <h2><?php print_lang('postinstall_cmds'); ?> </h2> <table class="center"> <tr> <td> <form method="POST"> <textarea name="edit_postinstall_cmds" style="width:80%;height:200px;" ><?php echo $postcmd; ?> </textarea> </td> </tr> <tr> <td> <button><?php print_lang('edit_postinstall_cmds'); ?> </button> <input type="checkbox" name="save_as_default" value="true"/><?php print_lang('save_as_default_for_this_mod'); ?> </form> </td> </tr> </table><?php } echo create_back_button('user_games', 'edit&home_id=' . $home_id); }
function exec_ogp_module() { global $db, $view; $blacklist = array('/install.php', '/modules/gamemanager/rsync_sites_local.list'); $curren_blacklist = array(); $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']; } } if (isset($_POST['save_to_blacklist'])) { foreach ($_POST['blacklist'] as $file) { $db->query("INSERT INTO `OGP_DB_PREFIXupdate_blacklist` SET file_path='{$file}';"); } foreach ($_POST['folder_files'] as $file) { if (in_array($file, $curren_blacklist)) { if (!in_array($file, $_POST['blacklist'])) { $db->query("DELETE FROM `OGP_DB_PREFIXupdate_blacklist` WHERE file_path='{$file}';"); } } } $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']; } } } $curren_blacklist = array_merge($curren_blacklist, $blacklist); path_check(); echo "<h2>"; echo get_lang('blacklist_files'); echo "</h2>"; $baseDir = str_replace("modules" . DIRECTORY_SEPARATOR . "update", "", dirname(__FILE__)); $path = clean_path($baseDir . "/" . @$_SESSION['fm_cwd']); echo "<table class='center' style='width:100%;' ><tr>\n" . "<td colspan='3' ><h3>" . get_lang_f('currently_viewing', $path) . "</h3></td>" . "</tr></table>"; if (!file_exists($path)) { $path = clean_path($baseDir); if (file_exists($path)) { print_failure(get_lang_f("dir_not_found", $path)); } else { $_SESSION['fm_cwd'] = str_replace("\\", "", dirname($_SESSION['fm_cwd'])); $view->refresh('?m=update&p=blacklist', 0); } } else { $dirlist = scandir($path); if (!is_array($dirlist)) { if ($dirlist === -1) { if ($path != $baseDir . "/") { $view->refresh('?m=update&p=blacklist', 0); } else { print_failure('The path is too long or there is a file with a very long name inside of your game server\'s home folder.'); } } else { if (file_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'] = str_replace("\\", "", dirname($_SESSION['fm_cwd'])); $view->refresh('?m=update&p=blacklist' . '&path=' . $filename, 0); } else { print_failure(get_lang("failed_list")); } } return; } if (empty($dirlist)) { print_lang('empty_directory'); } else { echo "<form method=POST>" . "<table class='center' style='width:100%;' >\n" . show_back($home_id) . "<tr>\n" . "<td style='width:10px;' >\n" . "<input type='checkbox' onclick='toggleChecked(this.checked)'>\n" . "</td>\n" . "<td align=left>\n" . get_lang('filename') . "\n</td>\n" . "</tr>\n"; $directorys = array(); $files = array(); $x = 0; $basedir_path = rtrim($_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['SCRIPT_NAME']), DIRECTORY_SEPARATOR); $preg_basedir_path = preg_quote($basedir_path, "/"); foreach ($dirlist as $item) { # dirlist FM returns an array. Each element has 5 fields separated by the | character if ($item == "." or $item == "..") { continue; } $filename = $item; $filepath = clean_path($path . "/" . $filename); // Directory if (is_dir($filepath)) { $directorys[$x]['filename'] = $filename; } else { $files[$x]['filename'] = $filename; $files[$x]['filepath'] = preg_replace("/^" . $preg_basedir_path . "/", "", $filepath); } $x++; } foreach ($directorys as $directory) { echo "<tr>\n" . "<td>" . "</td>" . "<td align=left>" . "<img class=\"viewitem\" src=\"images/folder.png\" alt=\"Directory\" /> " . "<a href=\"?m=update&p=blacklist&path=" . $directory['filename'] . "\">" . $directory['filename'] . "</a></td></tr>\n"; } $i = 0; $unchecked = array(); foreach ($files as $file) { $checked = in_array($file['filepath'], $curren_blacklist) ? "checked='checked'" : ""; echo "<tr>\n" . "<td>" . "<input type=checkbox name='blacklist[{$i}]' value='" . $file['filepath'] . "' class='item' {$checked}/>\n" . "<input type=hidden name='folder_files[{$i}]' value='" . $file['filepath'] . "' />\n" . "</td>" . "<td align=left>"; echo "<img class=\"viewitem\" src=\"images/txt.png\" alt=\"Text file\" /> " . $file['filename'] . "</td>\n" . "</tr>\n"; $i++; } echo "</table>\n" . "<input type=submit name='save_to_blacklist' value='" . get_lang('save_to_blacklist') . "' />\n" . "</form>\n"; } } echo create_back_button('update'); }
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 }
<?php echo get_lang('rcon_command_title'); ?> </td> <td> <form action="" method="post"> <input class="rcon" type="text" name="rcon_command" size="200" style="width:98%;" value="<?php if (isset($_POST['command'])) { echo $_POST['command']; } ?> " /> </td> <td> <input type="submit" name="remote_send_rcon_command" value="<?php print_lang('send_command'); ?> " /> </form> </td> </tr> </table> <?php if (isset($_POST['remote_send_rcon_command'])) { $rconCommand = $_POST['rcon_command']; if (isset($server_xml->control_protocol_type)) { $control_type = $server_xml->control_protocol_type; } else { $control_type = ""; } if (isset($server_xml->gameq_query_name) and $server_xml->gameq_query_name == "minecraft" and !isset($server_xml->control_protocol)) {
<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() { $modDb = new MySQLModuleDatabase(); require "includes/config.inc.php"; $modDb->connect($db_host, $db_user, $db_pass, $db_name, $table_prefix); global $view, $db; $isAdmin = $db->isAdmin($_SESSION['user_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; } echo "<h2>" . get_lang_f('mysql_dbs_for', $game_home['home_name']) . "</h2>"; $home_dbs = $modDb->getMysqlDBsbyHomeId($game_home['home_id']); if (empty($home_dbs)) { print_failure(get_lang_f('there_are_no_databases_assigned_for', $game_home['home_name'])); return; } $db_array["0"] = get_lang('select_db'); foreach ($home_dbs as $home_db) { $db_array["{$home_db['db_id']}"] = $home_db['db_name']; } $ft = new FormTable(); $ft->start_form(''); $ft->start_table(); $ft->add_custom_field('select_db', create_drop_box_from_array($db_array, "db_id", isset($_REQUEST['db_id']) ? $_REQUEST['db_id'] : "0", false)); $ft->end_table(); $ft->end_form(); $database_exists = FALSE; $server_online = FALSE; if (isset($_REQUEST['db_id']) and $_REQUEST['db_id'] != "0") { $db_id = $_REQUEST['db_id']; $mysql_db = $modDb->getMysqlHomeDBbyId($game_home['home_id'], $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) { $user_db = $remote->exec('mysqlshow --user='******'db_user'] . ' --password='******'db_passwd'] . ' ' . $mysql_db['db_name']); if ($user_db != "") { $database_exists = TRUE; } $server_online = TRUE; } } } else { @($link = mysql_connect($mysql_db['mysql_ip'] . ':' . $mysql_db['mysql_port'], $mysql_db['db_user'], $mysql_db['db_passwd'])); if ($link !== FALSE) { $server_online = TRUE; if (mysql_select_db($mysql_db['db_name'], $link) !== FALSE) { $databases = mysql_query("SHOW TABLES;"); $user_db = "Database: " . $mysql_db['db_name'] . "\nTables:\n"; while ($table = mysql_fetch_array($databases)) { $user_db .= $table[0] . "\n"; } $database_exists = TRUE; } } } if (isset($_POST['restore'])) { $command = 'mysql --host=' . $mysql_db['mysql_ip'] . ' --port=' . $mysql_db['mysql_port'] . ' --user='******'db_user'] . ' --password='******'db_passwd'] . ' ' . $mysql_db['db_name'] . ' < ' . $_FILES["file"]["tmp_name"]; if ($mysql_db['remote_server_id'] != "0") { $remote->exec($command, $output); } else { system($command); } $view->refresh('?m=mysql&p=user_db&home_id=' . $game_home['home_id'] . '&db_id=' . $db_id, 0); } if ($server_online and $database_exists) { echo "<table class='database' ><tr><td>\n<div class='dragbox bloc rounded' ><h4>" . get_lang('db_info') . "</h4>\n" . "<table class='database_info' ><tr>" . "<td><b>" . get_lang('mysql_ip') . " :</b></td><td>" . $mysql_db['mysql_ip'] . "</td></tr>\n" . "<td><b>" . get_lang('mysql_port') . " :</b></td><td>" . $mysql_db['mysql_port'] . "</td></tr>\n" . "<td><b>" . get_lang('db_name') . " :</b></td><td>" . $mysql_db['db_name'] . "</td></tr>\n" . "<td><b>" . get_lang('db_user') . " :</b></td><td>" . $mysql_db['db_user'] . "</td></tr>\n" . "<td><b>" . get_lang('db_passwd') . " :</b></td><td>" . $mysql_db['db_passwd'] . "</td></tr>\n" . "<td><b>" . get_lang('privilegies') . " :</b></td><td>" . $mysql_db['privilegies_str'] . "</td></tr></table></div>\n" . "<td><div class='dragbox bloc rounded' style='background:black;' ><h4>" . get_lang('db_tables') . "</h4>" . "<pre><xmp>" . $user_db . "</xmp></pre></div></td></tr></table>"; echo "<h2>" . get_lang('db_backup') . "</h2>"; ?> <table class='administration-table'> <tr> <td> <form method="POST" action="?m=mysql&p=get_dump&home_id=<?php echo $game_home['home_id']; ?> &db_id=<?php echo $db_id; ?> &type=cleared" > <button name="download"><?php print_lang('download_db_backup'); ?> </button> </form> <br> <form method="POST" action="?m=mysql&p=user_db&home_id=<?php echo $game_home['home_id']; ?> &db_id=<?php echo $db_id; ?> " enctype="multipart/form-data"> <label for="file"><?php print_lang('sql_file'); ?> :</label> <input type="file" name="file" id="file" /> <button name="restore"><?php print_lang('restore_db_backup'); ?> </button> </form> </td> </tr> </table> <?php } } }