force sync from /var/www/html/panel: 2025-09-08T20:36:30Z
This commit is contained in:
commit
4f717c9ee8
18119 changed files with 2566034 additions and 0 deletions
107
modules/server/add_server.php
Executable file
107
modules/server/add_server.php
Executable file
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2018 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 $view;
|
||||
global $db;
|
||||
|
||||
#This will add a remote host to the list
|
||||
if ( isset($_REQUEST['add_remote_host']) )
|
||||
{
|
||||
$rhost_ip = trim($_POST['remote_host']);
|
||||
$rhost_name = trim($_POST['remote_host_name']);
|
||||
$rhost_port = trim($_POST['remote_host_port']);
|
||||
$rhost_ftp_ip = trim($_POST['remote_host_ftp_ip']);
|
||||
$rhost_ftp_port = trim($_POST['remote_host_ftp_port']);
|
||||
$encryption_key = trim($_POST['remote_encryption_key']);
|
||||
$timeout = trim($_POST['timeout']);
|
||||
$use_nat = trim($_POST['use_nat']);
|
||||
$display_public_ip = trim($_POST['display_public_ip']);
|
||||
|
||||
if ( empty($rhost_ip) ){
|
||||
print_failure( get_lang("enter_ip_host") );
|
||||
$view->refresh("?m=server");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !isPortValid($rhost_port) ){
|
||||
print_failure( get_lang("enter_valid_ip") );
|
||||
$view->refresh("?m=server");
|
||||
return;
|
||||
}
|
||||
|
||||
require_once('includes/lib_remote.php');
|
||||
|
||||
$remote = new OGPRemoteLibrary($rhost_ip,$rhost_port,$encryption_key,$timeout);
|
||||
$status = $remote->status_chk();
|
||||
if($status === 0)
|
||||
{
|
||||
print_failure( get_lang("agent_offline") . "<br>" . get_lang("could_not_add_server") . " " . $rhost_ip );
|
||||
echo create_back_button($_GET['m']);
|
||||
return;
|
||||
}
|
||||
elseif($status === -1)
|
||||
{
|
||||
print_failure( get_lang("encryption_key_mismatch") . "<br>" . get_lang("could_not_add_server") . " " . $rhost_ip );
|
||||
echo create_back_button($_GET['m']);
|
||||
return;
|
||||
}
|
||||
|
||||
$rhost_user_name = trim($remote->exec('echo %USERNAME%'));
|
||||
if( $rhost_user_name == '%USERNAME%' ) $rhost_user_name = trim($remote->exec('whoami'));
|
||||
|
||||
$rhost_id = $db->addRemoteServer($rhost_ip,$rhost_name,$rhost_user_name,$rhost_port,$rhost_ftp_ip,$rhost_ftp_port,$encryption_key,$timeout,$use_nat,$display_public_ip);
|
||||
if ( !$rhost_id )
|
||||
{
|
||||
print_failure( get_lang("could_not_add_server") ." ".$rhost_ip." ". get_lang("to_db") );
|
||||
$view->refresh("?m=server");
|
||||
return;
|
||||
}
|
||||
|
||||
print_success( get_lang("added_server") ." $rhost_ip ". get_lang("with_port") ." $rhost_port ". get_lang("to_db_succesfully") );
|
||||
|
||||
$iplist = $remote->discover_ips();
|
||||
|
||||
if ( empty($iplist) )
|
||||
print_failure( get_lang("unable_discover") ." ".$rhost_ip.". ". get_lang("set_ip_manually") );
|
||||
else
|
||||
{
|
||||
print_success( get_lang("found_ips") ." (".implode(",",$iplist).") ". get_lang("for_remote_server") );
|
||||
foreach ( $iplist as $remote_ip )
|
||||
{
|
||||
$remote_ip = trim($remote_ip);
|
||||
if ( empty($remote_ip) )
|
||||
continue;
|
||||
|
||||
if ( !$db->addRemoteServerIp($rhost_id,$remote_ip) )
|
||||
print_failure( get_lang("failed_add_ip") ." (".$remote_ip.") ". get_lang("for_remote_server") );
|
||||
}
|
||||
}
|
||||
$view->refresh("?m=server");
|
||||
return;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
293
modules/server/arrange_ports.php
Executable file
293
modules/server/arrange_ports.php
Executable file
|
|
@ -0,0 +1,293 @@
|
|||
<script type="text/javascript" src="js/jquery/plugins/jquery.numeric.js"></script>
|
||||
<script type="text/javascript" src="js/modules/server.js"></script>
|
||||
<?php
|
||||
function exec_ogp_module()
|
||||
{
|
||||
global $db,$view;
|
||||
|
||||
if( isset( $_GET['rserver_id'] ) and $_GET['rserver_id'] != "" )
|
||||
{
|
||||
$remote_server_ips = $db->getRemoteServerIPs($_GET['rserver_id']);
|
||||
|
||||
if(!empty($remote_server_ips))
|
||||
{
|
||||
if(isset( $_GET['ip_id'] ) and $_GET['ip_id'] != "")
|
||||
{
|
||||
$ip = $db->getIpById($_GET['ip_id']);
|
||||
echo "<h2>".get_lang_f('assign_new_ports_range_for_ip',$ip)."</h2>";
|
||||
if(isset($_POST['assign_range']))
|
||||
{
|
||||
if($_POST['home_cfg_id'] != "0")
|
||||
$cfg_info = $db->getGameCfg($_POST['home_cfg_id']);
|
||||
else
|
||||
$cfg_info['game_name'] = get_lang("unspecified_game_types");
|
||||
|
||||
$retval = $db->addPortsRange($_POST['ip_id'],$_POST['home_cfg_id'],$_POST['start_port'],$_POST['end_port'],$_POST['port_increment']);
|
||||
if($retval === 1)
|
||||
print_failure( get_lang("invalid_values") );
|
||||
elseif($retval === 2)
|
||||
print_failure( get_lang("ports_in_range_already_arranged") );
|
||||
elseif($retval)
|
||||
print_success(get_lang_f('ports_range_added_successfull_for',$cfg_info['game_name']));
|
||||
else
|
||||
print_failure(get_lang_f('ports_range_already_configured_for',$cfg_info['game_name']));
|
||||
|
||||
$view->refresh('?m=server&p=arrange_ports&rserver_id='.$_GET['rserver_id'].'&ip_id='.$_GET['ip_id'],3);
|
||||
}
|
||||
$game_homes = $db->getIpPorts( $_GET['ip_id'] );
|
||||
$game_cfgs = $db->getGameCfgs();
|
||||
//
|
||||
require_once('includes/lib_remote.php');
|
||||
$rhost_id = $_GET['rserver_id'];
|
||||
$remote_server = $db->getRemoteServer($rhost_id);
|
||||
require_once('includes/lib_remote.php');
|
||||
$remote = new OGPRemoteLibrary($remote_server['agent_ip'],$remote_server['agent_port'],$remote_server['encryption_key'],$remote_server['timeout']);
|
||||
$host_stat = $remote->status_chk();
|
||||
if( $host_stat === 1)
|
||||
$os = $remote->what_os();
|
||||
else
|
||||
{
|
||||
print_failure(get_lang_f("caution_agent_offline_can_not_get_os_and_arch_showing_servers_for_all_platforms"));
|
||||
$os = "Unknown OS";
|
||||
}
|
||||
|
||||
echo "<form method='POST' action=''>\n
|
||||
<input type='hidden' name='ip_id' value='". $_GET['ip_id'] . "' />\n
|
||||
<table>\n
|
||||
<tr>\n
|
||||
<td>\n
|
||||
<select name='home_cfg_id'>\n
|
||||
<option style='background:black;color:white;' value='0'>". get_lang("unspecified_game_types") ."</option>\n";
|
||||
|
||||
echo "<b>". get_lang("assign_range_to_game_type") .":</b>";
|
||||
// Linux 64 bits + wine
|
||||
if( preg_match("/Linux/", $os) AND preg_match("/64/", $os) AND preg_match("/wine/", $os) )
|
||||
{
|
||||
foreach ( $game_cfgs as $row )
|
||||
{
|
||||
if ( preg_match("/linux/", $row['game_key']) )
|
||||
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name'];
|
||||
if ( preg_match("/64/", $row['game_key']) ) echo " (64 bit)";
|
||||
echo "</option>\n";
|
||||
}
|
||||
echo "<option style='background:black;color:white;' value=''>". get_lang("wine_games") .":</option>\n";
|
||||
foreach ( $game_cfgs as $row )
|
||||
{
|
||||
if ( preg_match("/win/", $row['game_key']) )
|
||||
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name'];
|
||||
if ( preg_match("/64/", $row['game_key']) ) echo " (64 bit)";
|
||||
echo "</option>\n";
|
||||
}
|
||||
}
|
||||
// Linux 64 bits
|
||||
elseif( preg_match("/Linux/", $os) AND preg_match("/64/", $os) )
|
||||
{
|
||||
foreach ( $game_cfgs as $row )
|
||||
{
|
||||
if ( preg_match("/linux/", $row['game_key']))
|
||||
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name'];
|
||||
if ( preg_match("/64/", $row['game_key']) ) echo " (64 bit)";
|
||||
echo "</option>\n";
|
||||
}
|
||||
}
|
||||
// Linux 32 bits + wine
|
||||
elseif( preg_match("/Linux/", $os) AND preg_match("/wine/", $os) )
|
||||
{
|
||||
foreach ( $game_cfgs as $row )
|
||||
{
|
||||
if ( preg_match("/linux32/", $row['game_key']) )
|
||||
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name']."</option>\n";
|
||||
}
|
||||
echo "<option style='background:black;color:white;' value=''>". get_lang("wine_games") ."</option>\n";
|
||||
foreach ( $game_cfgs as $row )
|
||||
{
|
||||
if ( preg_match("/win32/", $row['game_key']) )
|
||||
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name']."</option>\n";
|
||||
}
|
||||
}
|
||||
// Linux 32 bits
|
||||
elseif( preg_match("/Linux/", $os) )
|
||||
{
|
||||
foreach ( $game_cfgs as $row )
|
||||
{
|
||||
if ( preg_match("/linux32/", $row['game_key']) )
|
||||
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name']."</option>\n";
|
||||
}
|
||||
}
|
||||
// Windows 64 bits (CYGWIN)
|
||||
elseif( preg_match("/CYGWIN/", $os) AND preg_match("/64/", $os))
|
||||
{
|
||||
foreach ( $game_cfgs as $row )
|
||||
{
|
||||
if ( preg_match("/win/", $row['game_key']) )
|
||||
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name'];
|
||||
if ( preg_match("/64/", $row['game_key']) ) echo " (64 bit)";
|
||||
echo "</option>\n";
|
||||
}
|
||||
}
|
||||
// Windows 32 bits (CYGWIN)
|
||||
elseif( preg_match("/CYGWIN/", $os))
|
||||
{
|
||||
foreach ( $game_cfgs as $row )
|
||||
{
|
||||
if ( preg_match("/win32/", $row['game_key']) )
|
||||
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name']."</option>\n";
|
||||
}
|
||||
}
|
||||
elseif ( $os == "Unknown OS" )
|
||||
{
|
||||
foreach ( $game_cfgs as $row )
|
||||
{
|
||||
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name'];
|
||||
if ( preg_match("/64/", $row['game_key']) ) echo " (64 bit)";
|
||||
echo "</option>\n";
|
||||
}
|
||||
}
|
||||
echo "</select>\n
|
||||
</td>\n
|
||||
<td>\n".
|
||||
get_lang("start_port") .
|
||||
"<input type='text' id='start_port' name='start_port' class='add' size='8' />\n
|
||||
</td>\n
|
||||
<td>\n".
|
||||
get_lang("end_port") .
|
||||
"<input type='text' id='end_port' name='end_port' class='add' size='8' />\n
|
||||
</td>\n
|
||||
<td>\n
|
||||
".
|
||||
get_lang("port_increment") .
|
||||
"<input type='text' id='port_increment' name='port_increment' class='add' value='1' size='2' />\n
|
||||
</td>\n
|
||||
<td>\n
|
||||
".
|
||||
get_lang("total_assignable_ports") ."\t<span id='total_assignable_ports' class='add'></span>\n
|
||||
</td>\n
|
||||
<td>\n".
|
||||
"<input type='submit' name='assign_range' value='". get_lang("assign_range") ."' />\n
|
||||
</td>\n
|
||||
</tr>\n
|
||||
</table>\n
|
||||
</form>\n";
|
||||
|
||||
|
||||
echo "<h2>".get_lang_f('assigned_port_ranges_for_ip',$ip)."</h2>";
|
||||
//
|
||||
if(isset($_POST['delete_range']))
|
||||
{
|
||||
if($db->delPortsRange($_POST['range_id']))
|
||||
print_success( get_lang("ports_range_deleted_successfull") );
|
||||
else
|
||||
print_failure( get_lang("failed_to_delete_ports_range") );
|
||||
$view->refresh('?m=server&p=arrange_ports&rserver_id='.$_GET['rserver_id'].'&ip_id='.$_GET['ip_id'],3);
|
||||
}
|
||||
if(isset($_POST['edit_range']))
|
||||
{
|
||||
if($_POST['home_cfg_id'] != "0")
|
||||
$cfg_info = $db->getGameCfg($_POST['home_cfg_id']);
|
||||
else
|
||||
$cfg_info['game_name'] = get_lang("unspecified_game_types");
|
||||
|
||||
$retval = $db->editPortsRange($_POST['range_id'],$_POST['ip_id'],$_POST['start_port'],$_POST['end_port'],$_POST['port_increment']);
|
||||
if($retval === 1)
|
||||
print_failure( get_lang("invalid_values") );
|
||||
elseif($retval === 2)
|
||||
print_failure( get_lang("ports_in_range_already_arranged") );
|
||||
elseif($retval)
|
||||
print_success(get_lang_f('ports_range_edited_successfull_for',$cfg_info['game_name']));
|
||||
else
|
||||
print_failure(get_lang_f('ports_range_already_configured_for',$cfg_info['game_name']));
|
||||
$view->refresh('?m=server&p=arrange_ports&rserver_id='.$_GET['rserver_id'].'&ip_id='.$_GET['ip_id'],3);
|
||||
}
|
||||
$ranges = $db->getPortsRange($_GET['ip_id']);
|
||||
if(!empty($ranges))
|
||||
{
|
||||
echo "<table>\n";
|
||||
foreach($ranges as $range)
|
||||
{
|
||||
if($range['home_cfg_id'] != "0")
|
||||
$cfg_info = $db->getGameCfg($range['home_cfg_id']);
|
||||
else
|
||||
$cfg_info['game_name'] = get_lang("unspecified_game_types");
|
||||
|
||||
|
||||
$available_ports_amount = intval((($range['end_port'] - $range['start_port']) / $range['port_increment']) + 1);
|
||||
|
||||
$usable_range_ports = array();
|
||||
for($port = $range['start_port']; $port >= $range['start_port'] and $port <= $range['end_port']; $port+=$range['port_increment'])
|
||||
{
|
||||
$usable_range_ports[] = $port;
|
||||
}
|
||||
|
||||
$used_ports = array();
|
||||
if(!empty($game_homes))
|
||||
{
|
||||
foreach($game_homes as $game_home)
|
||||
{
|
||||
$used_ports[] = $game_home['port'];
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($used_ports))
|
||||
{
|
||||
foreach($used_ports as $used_port)
|
||||
{
|
||||
if(in_array($used_port,$usable_range_ports))
|
||||
$available_ports_amount--;
|
||||
}
|
||||
}
|
||||
|
||||
echo "<form method='POST' action=''>\n
|
||||
<input type='hidden' name='range_id' value='". $range['range_id'] . "' />\n
|
||||
<input type='hidden' name='ip_id' value='". $range['ip_id'] . "' />\n
|
||||
<input type='hidden' name='home_cfg_id' value='". $range['home_cfg_id'] . "' />\n
|
||||
<tr>\n
|
||||
<td>\n".
|
||||
$cfg_info['game_name'].
|
||||
"</td>\n
|
||||
<td>\n".
|
||||
get_lang("start_port") .
|
||||
"<input type='text' id='start_port' name='start_port' value='".$range['start_port']."' size='8' />\n
|
||||
</td>\n
|
||||
<td>\n".
|
||||
get_lang("end_port") .
|
||||
"<input type='text' id='end_port' name='end_port' value='".$range['end_port']."' size='8' />\n
|
||||
</td>\n
|
||||
<td>\n".
|
||||
get_lang("port_increment") .
|
||||
"<input type='text' id='port_increment' name='port_increment' value='".$range['port_increment']."' value='1' size='2' />\n
|
||||
</td>\n
|
||||
<td>\n".
|
||||
get_lang("available_range_ports") .
|
||||
"\t<span id='available_range_ports'>".$available_ports_amount."</span>\n
|
||||
</td>\n
|
||||
<td>\n
|
||||
<input type='submit' name='edit_range' value='". get_lang("edit_range") ."' />\n
|
||||
<input type='submit' name='delete_range' value='". get_lang("delete_range") ."' />\n
|
||||
</td>\n
|
||||
</tr>\n
|
||||
</form>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
}
|
||||
echo "<h2>".get_lang_f('assigned_ports_for_ip',$ip)."</h2>";
|
||||
if(!empty($game_homes))
|
||||
{
|
||||
echo "<table class='center'>";
|
||||
echo "<tr><th>". get_lang("home_id") ."</th><th>". get_lang("home_path") ."</th><th>". get_lang("game_type") ."</th><th>". get_lang("server_name") ."</th><th>". get_lang("port") ."</th></tr>";
|
||||
foreach($game_homes as $game_home)
|
||||
{
|
||||
echo "<tr><td>".$game_home['home_id']."</td><td>".$game_home['home_path']."</td><td>".$game_home['game_name']."</td><td>".htmlentities($game_home['home_name'])."</td><td>".$game_home['port']."</td></tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "There are no IPs assigned to the selected remote server.";
|
||||
return;
|
||||
}
|
||||
echo create_back_button('server','edit&rhost_id='.$_GET['rserver_id'].'&edit');
|
||||
}
|
||||
}
|
||||
?>
|
||||
219
modules/server/edit_server.php
Executable file
219
modules/server/edit_server.php
Executable file
|
|
@ -0,0 +1,219 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2018 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 $view;
|
||||
global $db;
|
||||
|
||||
$rhost_id = @$_REQUEST['rhost_id'];
|
||||
$remote_server = $db->getRemoteServer($rhost_id);
|
||||
if ( $remote_server === FALSE )
|
||||
{
|
||||
print_failure(get_lang_f('invalid_remote_host_id',$rhost_id));
|
||||
$view->refresh("?m=server");
|
||||
return;
|
||||
}
|
||||
|
||||
echo "<h2>".get_lang_f('editing_remote_server',$remote_server['remote_server_name'])."</h2>";
|
||||
|
||||
#this allows you to define upto 4 IPs for each remote host. The IPs are for binding games to
|
||||
if ( isset($_REQUEST['add_ip']) )
|
||||
{
|
||||
$remote_ip = $_POST['remote_ip'];
|
||||
$remote_ip = preg_replace("/[^0-9\.]/", "", $remote_ip);
|
||||
if ( $db->addRemoteServerIp($rhost_id, $remote_ip) === FALSE )
|
||||
{
|
||||
print_failure( get_lang("could_not_add_ip") );
|
||||
}
|
||||
else
|
||||
{
|
||||
print_success(get_lang_f('ips_set_for_server',$remote_server['remote_server_name']));
|
||||
}
|
||||
$view->refresh("?m=server&p=edit&rhost_id=".$rhost_id."&edit");
|
||||
}
|
||||
|
||||
else if ( isset($_REQUEST['remove_ip']) )
|
||||
{
|
||||
$ip_id = $_POST['ip_id'];
|
||||
|
||||
if ( $db->removeRemoteServerIps($ip_id) === FALSE )
|
||||
{
|
||||
print_failure( get_lang("could_not_remove_ip") );
|
||||
}
|
||||
else
|
||||
{
|
||||
print_success(get_lang_f('ips_set_for_server',$remote_server['remote_server_name']));
|
||||
}
|
||||
$view->refresh("?m=server&p=edit&rhost_id=".$rhost_id."&edit");
|
||||
}
|
||||
|
||||
else if ( isset($_REQUEST['edit_ip']) )
|
||||
{
|
||||
$ip_id = $_POST['ip_id'];
|
||||
$ip = $_POST['ip'];
|
||||
$ip = preg_replace("/[^0-9\.]/", "", $ip);
|
||||
|
||||
if ( $db->editRemoteServerIps($ip_id,$ip) === FALSE )
|
||||
{
|
||||
print_failure( get_lang("could_not_edit_ip") );
|
||||
}
|
||||
else
|
||||
{
|
||||
print_success(get_lang_f('ips_set_for_server',$remote_server['remote_server_name']));
|
||||
}
|
||||
$view->refresh("?m=server&p=edit&rhost_id=".$rhost_id."&edit");
|
||||
}
|
||||
|
||||
#This removes and rhost from the list
|
||||
else if ( isset($_REQUEST['delete']) )
|
||||
{
|
||||
if ( !isset($_REQUEST['y'] ) )
|
||||
{
|
||||
echo "<p>". get_lang("areyousure_removeagent") ." <b>\"".
|
||||
$remote_server['remote_server_name']."\"</b> ". get_lang("areyousure_removeagent2") ."</p>
|
||||
<p><a href='?m=server&p=edit&rhost_id=".$rhost_id."&delete&y=y'>".
|
||||
get_lang("yes") ."</a> <a href='?m=server'>".
|
||||
get_lang("no") ."</a></p>";
|
||||
return;
|
||||
}
|
||||
|
||||
else if ( $db->removeRemoteServer($rhost_id) === FALSE )
|
||||
print_failure( get_lang("error_while_remove") );
|
||||
|
||||
else
|
||||
print_success(get_lang_f('remote_host_removed',$remote_server['remote_server_name']));
|
||||
|
||||
$view->refresh("?m=server");
|
||||
return;
|
||||
}
|
||||
else if ( isset($_REQUEST['save_settings']) )
|
||||
{
|
||||
$db->changeRemoteServerSettings($remote_server['remote_server_id'],
|
||||
$_REQUEST['remote_host'],
|
||||
$_REQUEST['remote_host_port'],
|
||||
$_REQUEST['remote_host_name'],
|
||||
$_REQUEST['ogp_user'],
|
||||
$_REQUEST['remote_host_ftp_ip'],
|
||||
$_REQUEST['remote_host_ftp_port'],
|
||||
$_REQUEST['remote_encryption_key'],
|
||||
$_REQUEST['timeout'],
|
||||
$_REQUEST['use_nat'],
|
||||
$_REQUEST['display_public_ip']);
|
||||
print_success(get_lang_f('remote_server_settings_changed',$remote_server['remote_server_name']));
|
||||
$view->refresh("?m=server&p=edit&rhost_id=".$rhost_id."&edit");
|
||||
}
|
||||
if ( isset($_REQUEST['edit']) )
|
||||
{
|
||||
$remote_server = $db->getRemoteServer($rhost_id);
|
||||
$ftp_ip = empty($remote_server['ftp_ip']) ? $remote_server['agent_ip'] : $remote_server['ftp_ip'];
|
||||
require_once('includes/form_table_class.php');
|
||||
$ft = new FormTable();
|
||||
$ft->start_form('?m=server&p=edit&rhost_id='.$rhost_id.'&edit');
|
||||
$ft->add_field_hidden('rhost_id',$remote_server['remote_server_id']);
|
||||
$ft->start_table();
|
||||
$ft->add_field('string','remote_host',$remote_server['agent_ip']);
|
||||
$ft->add_field('string','remote_host_port',$remote_server['agent_port']);
|
||||
$ft->add_field('string','remote_host_name',$remote_server['remote_server_name']);
|
||||
$ft->add_field('string','ogp_user',$remote_server['ogp_user']);
|
||||
$ft->add_field('string','remote_host_ftp_ip',$ftp_ip);
|
||||
$ft->add_field('string','remote_host_ftp_port',$remote_server['ftp_port']);
|
||||
$ft->add_field('string','remote_encryption_key',$remote_server['encryption_key']);
|
||||
$ft->add_field('string','timeout',$remote_server['timeout']);
|
||||
$ft->add_field('on_off','use_nat',$remote_server['use_nat']);
|
||||
$ft->add_field('string','display_public_ip',$remote_server['display_public_ip']);
|
||||
$ft->end_table();
|
||||
$ft->add_button('submit','save_settings', get_lang("save_settings") );
|
||||
$ft->end_form();
|
||||
echo create_back_button('server');
|
||||
|
||||
echo "<h2>".get_lang_f('remote_ips_for',$remote_server['remote_server_name'])."</h2>";
|
||||
echo "<p class='info'>". get_lang("hint") .": ". get_lang("add_more_ips") ."</p>";
|
||||
echo "<p class='info'>" . get_lang("ips_can_be_internal_external") . "</p>";
|
||||
|
||||
$remote_server_ips = $db->getRemoteServerIPs($remote_server['remote_server_id']);
|
||||
if ( !empty($remote_server_ips) )
|
||||
{
|
||||
echo "<h1>". get_lang("edit_ip") ."s</h1>";
|
||||
|
||||
include_once('includes/lib_remote.php');
|
||||
|
||||
foreach ( $remote_server_ips as $ip_row )
|
||||
{
|
||||
$servers_match_ip_id = $db->getIpPorts( $ip_row['ip_id'] );
|
||||
$servers_running = FALSE;
|
||||
if($servers_match_ip_id)
|
||||
{
|
||||
foreach ( $servers_match_ip_id as $home_info )
|
||||
{
|
||||
$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'],$home_info['timeout']);
|
||||
$screen_running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME,$home_info['home_id']) === 1;
|
||||
if( $screen_running )
|
||||
{
|
||||
$servers_running = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$disabled = $servers_running ? "disabled" : "";
|
||||
$warning = $servers_running ? "<b class='failure' >". get_lang("there_are_servers_running_on_this_ip") ."<b>" : "";
|
||||
echo "<table style='width:auto;'>
|
||||
<tr>
|
||||
<td align='left' >
|
||||
<form method='post' action=''>
|
||||
<input name='ip_id' type='hidden' value='".$ip_row['ip_id']."'/>
|
||||
<input name='ip' type='text' value='".$ip_row['ip']."'/>
|
||||
<input type='submit' name='edit_ip' value='". get_lang("edit_ip") ."' $disabled/>
|
||||
<input type='submit' name='remove_ip' value='". get_lang("remove_ip") ."' $disabled/> $warning
|
||||
</form>
|
||||
</td>
|
||||
<td style='text-align:left;'>
|
||||
<form method='post' action='?m=server&p=arrange_ports&rserver_id=".$rhost_id."&ip_id=".$ip_row['ip_id']."'>
|
||||
<input type='submit' name='arrange_ports' value='". get_lang("arrange_ports") ."'/>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>";
|
||||
}
|
||||
}
|
||||
|
||||
echo "<h1>". get_lang("add_ip") ."s</h1>";
|
||||
|
||||
$ft = new FormTable();
|
||||
$ft->start_form('');
|
||||
$ft->add_field_hidden('rhost_id',$remote_server['remote_server_id']);
|
||||
$ft->start_table();
|
||||
$ft->add_field('string','remote_ip','');
|
||||
$ft->end_table();
|
||||
$ft->add_button('submit','add_ip', get_lang("add_ip") );
|
||||
$ft->end_form();
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure("Invalid url.");
|
||||
$view->refresh("?m=server");
|
||||
}
|
||||
}
|
||||
?>
|
||||
196
modules/server/firewall.php
Executable file
196
modules/server/firewall.php
Executable file
|
|
@ -0,0 +1,196 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2018 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.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once('includes/lib_remote.php');
|
||||
require_once("includes/form_table_class.php");
|
||||
|
||||
function exec_ogp_module() {
|
||||
global $view;
|
||||
global $db;
|
||||
|
||||
$rhost_id = @$_REQUEST['rhost_id'];
|
||||
$remote_server = $db->getRemoteServer($rhost_id);
|
||||
if ( $remote_server === FALSE )
|
||||
{
|
||||
print_failure(get_lang_f('invalid_remote_host_id',$rhost_id));
|
||||
$view->refresh("?m=server");
|
||||
return;
|
||||
}
|
||||
|
||||
echo "<h2>".get_lang_f('editing_firewall_for_remote_server',$remote_server['remote_server_name'])."</h2>";
|
||||
|
||||
$firewall_settings = $db->getFirewallSettings($remote_server['remote_server_id']);
|
||||
|
||||
$remote = new OGPRemoteLibrary($remote_server['agent_ip'],$remote_server['agent_port'],$remote_server['encryption_key'],$remote_server['timeout']);
|
||||
$host_stat = $remote->status_chk();
|
||||
|
||||
if( isset($_POST['reset_firewall']) )
|
||||
{
|
||||
if($host_stat === 1)
|
||||
{
|
||||
$remote->sudo_exec($firewall_settings['disable_firewall_command']);
|
||||
$remote->sudo_exec($firewall_settings['reset_firewall_command']);
|
||||
$addresses = explode(",",$firewall_settings['default_allowed']);
|
||||
if(is_array($addresses))
|
||||
{
|
||||
$trimed_addresses = array();
|
||||
foreach($addresses as $key => $address)
|
||||
{
|
||||
$address = trim($address);
|
||||
if(strpos($address,':'))
|
||||
{
|
||||
list($ip,$port) = explode(':',$address);
|
||||
set_firewall($remote, $firewall_settings, 'allow', $port, $ip);
|
||||
}
|
||||
else
|
||||
{
|
||||
$port = trim($address);
|
||||
set_firewall($remote, $firewall_settings, 'allow', $port);
|
||||
}
|
||||
}
|
||||
}
|
||||
$remote->sudo_exec($firewall_settings['enable_firewall_command']);
|
||||
}
|
||||
}
|
||||
|
||||
if( isset($_POST['save_firewall_settings']) )
|
||||
{
|
||||
$addresses = explode(",",$_POST['default_allowed']);
|
||||
if(is_array($addresses))
|
||||
{
|
||||
$trimed_addresses = array();
|
||||
foreach($addresses as $key => $address)
|
||||
{
|
||||
$address = trim($address);
|
||||
if(strpos($address,':'))
|
||||
{
|
||||
list($ip,$port) = explode(':',$address);
|
||||
if(preg_match('/^[0-9]{1,5}$/',$port)
|
||||
and $port >= 1 and $port <= 65535
|
||||
and filter_var($ip, FILTER_VALIDATE_IP)
|
||||
and !in_array($address,$trimed_addresses))
|
||||
$trimed_addresses[$key] = $address;
|
||||
}
|
||||
else
|
||||
{
|
||||
$port = trim($address);
|
||||
if(preg_match('/^[0-9]{1,5}$/',$port)
|
||||
and $port >= 1
|
||||
and $port <= 65535 and
|
||||
!in_array($port,$trimed_addresses) )
|
||||
$trimed_addresses[$key] = $port;
|
||||
}
|
||||
}
|
||||
$firewall_settings['default_allowed'] = implode(",",$trimed_addresses);
|
||||
}
|
||||
$firewall_settings['allow_port_command'] = trim($_POST['allow_port_command']);
|
||||
$firewall_settings['deny_port_command'] = trim($_POST['deny_port_command']);
|
||||
$firewall_settings['allow_ip_port_command'] = trim($_POST['allow_ip_port_command']);
|
||||
$firewall_settings['deny_ip_port_command'] = trim($_POST['deny_ip_port_command']);
|
||||
$firewall_settings['enable_firewall_command'] = trim($_POST['enable_firewall_command']);
|
||||
$firewall_settings['disable_firewall_command'] = trim($_POST['disable_firewall_command']);
|
||||
$firewall_settings['get_firewall_status_command'] = trim($_POST['get_firewall_status_command']);
|
||||
$firewall_settings['reset_firewall_command'] = trim($_POST['reset_firewall_command']);
|
||||
$db->updateFirewallSettings($remote_server['remote_server_id'],$firewall_settings);
|
||||
}
|
||||
|
||||
if( isset($_GET['ch_fw_status']) )
|
||||
{
|
||||
$firewall_settings['status'] = $_GET['ch_fw_status'];
|
||||
if($host_stat === 1)
|
||||
{
|
||||
if($_GET['ch_fw_status'] == "enable")
|
||||
{
|
||||
$addresses = explode(",",$firewall_settings['default_allowed']);
|
||||
if(is_array($addresses))
|
||||
{
|
||||
$trimed_addresses = array();
|
||||
foreach($addresses as $key => $address)
|
||||
{
|
||||
$address = trim($address);
|
||||
if(strpos($address,':'))
|
||||
{
|
||||
list($ip,$port) = explode(':',$address);
|
||||
set_firewall($remote, $firewall_settings, 'allow', $port, $ip);
|
||||
}
|
||||
else
|
||||
{
|
||||
$port = trim($address);
|
||||
set_firewall($remote, $firewall_settings, 'allow', $port);
|
||||
}
|
||||
}
|
||||
}
|
||||
$remote->sudo_exec($firewall_settings['enable_firewall_command']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$remote->sudo_exec($firewall_settings['disable_firewall_command']);
|
||||
}
|
||||
}
|
||||
|
||||
if($db->updateFirewallSettings($remote_server['remote_server_id'],$firewall_settings))
|
||||
{
|
||||
$firewall_settings = $db->getFirewallSettings($remote_server['remote_server_id']);
|
||||
}
|
||||
}
|
||||
|
||||
if($firewall_settings['status'] == "enable")
|
||||
{
|
||||
echo "<b>".get_lang('status')."</b> ".get_lang('on')."<br />
|
||||
<a href='?m=server&p=firewall&rhost_id=".
|
||||
$remote_server['remote_server_id']."&ch_fw_status=disable'>[".get_lang('stop_firewall')."]</a>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<b>".get_lang('status')."</b> ".get_lang('off')."<br />
|
||||
<a href='?m=server&p=firewall&rhost_id=".
|
||||
$remote_server['remote_server_id']."&ch_fw_status=enable'>[".get_lang('start_firewall')."]</a>\n";
|
||||
}
|
||||
|
||||
$ft = new FormTable();
|
||||
$ft->start_form("?m=server&p=firewall&rhost_id=$rhost_id");
|
||||
$ft->start_table();
|
||||
$ft->add_field('text','default_allowed',$firewall_settings['default_allowed'], 38);
|
||||
$ft->add_field('string','allow_port_command',$firewall_settings['allow_port_command']);
|
||||
$ft->add_field('string','deny_port_command',$firewall_settings['deny_port_command']);
|
||||
$ft->add_field('string','allow_ip_port_command',$firewall_settings['allow_ip_port_command']);
|
||||
$ft->add_field('string','deny_ip_port_command',$firewall_settings['deny_ip_port_command']);
|
||||
$ft->add_field('string','enable_firewall_command',$firewall_settings['enable_firewall_command']);
|
||||
$ft->add_field('string','disable_firewall_command',$firewall_settings['disable_firewall_command']);
|
||||
$ft->add_field('string','get_firewall_status_command',$firewall_settings['get_firewall_status_command']);
|
||||
$ft->add_field('string','reset_firewall_command',$firewall_settings['reset_firewall_command']);
|
||||
$ft->end_table();
|
||||
$ft->add_button('submit','save_firewall_settings',get_lang("save_firewall_settings"));
|
||||
$ft->end_form();
|
||||
|
||||
echo "<h3>".get_lang("firewall_status")."</h3>";
|
||||
echo "<pre class='log'>";
|
||||
echo $remote->sudo_exec($firewall_settings['get_firewall_status_command']);
|
||||
echo "</pre>";
|
||||
$ft = new FormTable();
|
||||
$ft->start_form("?m=server&p=firewall&rhost_id=$rhost_id");
|
||||
$ft->add_button('submit','reset_firewall',get_lang("reset_firewall"));
|
||||
$ft->end_form();
|
||||
echo create_back_button($_GET['m']);
|
||||
}
|
||||
279
modules/server/jquery.numeric.js
Executable file
279
modules/server/jquery.numeric.js
Executable file
|
|
@ -0,0 +1,279 @@
|
|||
/*
|
||||
*
|
||||
* Copyright (c) 2006-2011 Sam Collett (http://www.texotela.co.uk)
|
||||
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
|
||||
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
|
||||
*
|
||||
* Version 1.3
|
||||
* Demo: http://www.texotela.co.uk/code/jquery/numeric/
|
||||
*
|
||||
*/
|
||||
(function($) {
|
||||
/*
|
||||
* Allows only valid characters to be entered into input boxes.
|
||||
* Note: fixes value when pasting via Ctrl+V, but not when using the mouse to paste
|
||||
* side-effect: Ctrl+A does not work, though you can still use the mouse to select (or double-click to select all)
|
||||
*
|
||||
* @name numeric
|
||||
* @param config { decimal : "." , negative : true }
|
||||
* @param callback A function that runs if the number is not valid (fires onblur)
|
||||
* @author Sam Collett (http://www.texotela.co.uk)
|
||||
* @example $(".numeric").numeric();
|
||||
* @example $(".numeric").numeric(","); // use , as separater
|
||||
* @example $(".numeric").numeric({ decimal : "," }); // use , as separator
|
||||
* @example $(".numeric").numeric({ negative : false }); // do not allow negative values
|
||||
* @example $(".numeric").numeric(null, callback); // use default values, pass on the 'callback' function
|
||||
*
|
||||
*/
|
||||
$.fn.numeric = function(config, callback)
|
||||
{
|
||||
if(typeof config === 'boolean')
|
||||
{
|
||||
config = { decimal: config };
|
||||
}
|
||||
config = config || {};
|
||||
// if config.negative undefined, set to true (default is to allow negative numbers)
|
||||
if(typeof config.negative == "undefined") config.negative = true;
|
||||
// set decimal point
|
||||
var decimal = (config.decimal === false) ? "" : config.decimal || ".";
|
||||
// allow negatives
|
||||
var negative = (config.negative === true) ? true : false;
|
||||
// callback function
|
||||
var callback = typeof callback == "function" ? callback : function(){};
|
||||
// set data and methods
|
||||
return this.data("numeric.decimal", decimal).data("numeric.negative", negative).data("numeric.callback", callback).keypress($.fn.numeric.keypress).keyup($.fn.numeric.keyup).blur($.fn.numeric.blur);
|
||||
}
|
||||
|
||||
$.fn.numeric.keypress = function(e)
|
||||
{
|
||||
// get decimal character and determine if negatives are allowed
|
||||
var decimal = $.data(this, "numeric.decimal");
|
||||
var negative = $.data(this, "numeric.negative");
|
||||
// get the key that was pressed
|
||||
var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
|
||||
// allow enter/return key (only when in an input box)
|
||||
if(key == 13 && this.nodeName.toLowerCase() == "input")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(key == 13)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var allow = false;
|
||||
// allow Ctrl+A
|
||||
if((e.ctrlKey && key == 97 /* firefox */) || (e.ctrlKey && key == 65) /* opera */) return true;
|
||||
// allow Ctrl+X (cut)
|
||||
if((e.ctrlKey && key == 120 /* firefox */) || (e.ctrlKey && key == 88) /* opera */) return true;
|
||||
// allow Ctrl+C (copy)
|
||||
if((e.ctrlKey && key == 99 /* firefox */) || (e.ctrlKey && key == 67) /* opera */) return true;
|
||||
// allow Ctrl+Z (undo)
|
||||
if((e.ctrlKey && key == 122 /* firefox */) || (e.ctrlKey && key == 90) /* opera */) return true;
|
||||
// allow or deny Ctrl+V (paste), Shift+Ins
|
||||
if((e.ctrlKey && key == 118 /* firefox */) || (e.ctrlKey && key == 86) /* opera */
|
||||
|| (e.shiftKey && key == 45)) return true;
|
||||
// if a number was not pressed
|
||||
if(key < 48 || key > 57)
|
||||
{
|
||||
/* '-' only allowed at start and if negative numbers allowed */
|
||||
if(this.value.indexOf("-") != 0 && negative && key == 45 && (this.value.length == 0 || ($.fn.getSelectionStart(this)) == 0)) return true;
|
||||
/* only one decimal separator allowed */
|
||||
if(decimal && key == decimal.charCodeAt(0) && this.value.indexOf(decimal) != -1)
|
||||
{
|
||||
allow = false;
|
||||
}
|
||||
// check for other keys that have special purposes
|
||||
if(
|
||||
key != 8 /* backspace */ &&
|
||||
key != 9 /* tab */ &&
|
||||
key != 13 /* enter */ &&
|
||||
key != 35 /* end */ &&
|
||||
key != 36 /* home */ &&
|
||||
key != 37 /* left */ &&
|
||||
key != 39 /* right */ &&
|
||||
key != 46 /* del */
|
||||
)
|
||||
{
|
||||
allow = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// for detecting special keys (listed above)
|
||||
// IE does not support 'charCode' and ignores them in keypress anyway
|
||||
if(typeof e.charCode != "undefined")
|
||||
{
|
||||
// special keys have 'keyCode' and 'which' the same (e.g. backspace)
|
||||
if(e.keyCode == e.which && e.which != 0)
|
||||
{
|
||||
allow = true;
|
||||
// . and delete share the same code, don't allow . (will be set to true later if it is the decimal point)
|
||||
if(e.which == 46) allow = false;
|
||||
}
|
||||
// or keyCode != 0 and 'charCode'/'which' = 0
|
||||
else if(e.keyCode != 0 && e.charCode == 0 && e.which == 0)
|
||||
{
|
||||
allow = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if key pressed is the decimal and it is not already in the field
|
||||
if(decimal && key == decimal.charCodeAt(0))
|
||||
{
|
||||
if(this.value.indexOf(decimal) == -1)
|
||||
{
|
||||
allow = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
allow = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
allow = true;
|
||||
}
|
||||
return allow;
|
||||
}
|
||||
|
||||
$.fn.numeric.keyup = function(e)
|
||||
{
|
||||
var val = this.value;
|
||||
if(val.length > 0)
|
||||
{
|
||||
// get carat (cursor) position
|
||||
var carat = $.fn.getSelectionStart(this);
|
||||
// get decimal character and determine if negatives are allowed
|
||||
var decimal = $.data(this, "numeric.decimal");
|
||||
var negative = $.data(this, "numeric.negative");
|
||||
|
||||
// prepend a 0 if necessary
|
||||
if(decimal != "")
|
||||
{
|
||||
// find decimal point
|
||||
var dot = val.indexOf(decimal);
|
||||
// if dot at start, add 0 before
|
||||
if(dot == 0)
|
||||
{
|
||||
this.value = "0" + val;
|
||||
}
|
||||
// if dot at position 1, check if there is a - symbol before it
|
||||
if(dot == 1 && val.charAt(0) == "-")
|
||||
{
|
||||
this.value = "-0" + val.substring(1);
|
||||
}
|
||||
val = this.value;
|
||||
}
|
||||
|
||||
// if pasted in, only allow the following characters
|
||||
var validChars = [0,1,2,3,4,5,6,7,8,9,'-',decimal];
|
||||
// get length of the value (to loop through)
|
||||
var length = val.length;
|
||||
// loop backwards (to prevent going out of bounds)
|
||||
for(var i = length - 1; i >= 0; i--)
|
||||
{
|
||||
var ch = val.charAt(i);
|
||||
// remove '-' if it is in the wrong place
|
||||
if(i != 0 && ch == "-")
|
||||
{
|
||||
val = val.substring(0, i) + val.substring(i + 1);
|
||||
}
|
||||
// remove character if it is at the start, a '-' and negatives aren't allowed
|
||||
else if(i == 0 && !negative && ch == "-")
|
||||
{
|
||||
val = val.substring(1);
|
||||
}
|
||||
var validChar = false;
|
||||
// loop through validChars
|
||||
for(var j = 0; j < validChars.length; j++)
|
||||
{
|
||||
// if it is valid, break out the loop
|
||||
if(ch == validChars[j])
|
||||
{
|
||||
validChar = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if not a valid character, or a space, remove
|
||||
if(!validChar || ch == " ")
|
||||
{
|
||||
val = val.substring(0, i) + val.substring(i + 1);
|
||||
}
|
||||
}
|
||||
// remove extra decimal characters
|
||||
var firstDecimal = val.indexOf(decimal);
|
||||
if(firstDecimal > 0)
|
||||
{
|
||||
for(var i = length - 1; i > firstDecimal; i--)
|
||||
{
|
||||
var ch = val.charAt(i);
|
||||
// remove decimal character
|
||||
if(ch == decimal)
|
||||
{
|
||||
val = val.substring(0, i) + val.substring(i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
// set the value and prevent the cursor moving to the end
|
||||
this.value = val;
|
||||
$.fn.setSelection(this, carat);
|
||||
}
|
||||
}
|
||||
|
||||
$.fn.numeric.blur = function()
|
||||
{
|
||||
var decimal = $.data(this, "numeric.decimal");
|
||||
var callback = $.data(this, "numeric.callback");
|
||||
var val = this.value;
|
||||
if(val != "")
|
||||
{
|
||||
var re = new RegExp("^\\d+$|\\d*" + decimal + "\\d+");
|
||||
if(!re.exec(val))
|
||||
{
|
||||
callback.apply(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$.fn.removeNumeric = function()
|
||||
{
|
||||
return this.data("numeric.decimal", null).data("numeric.negative", null).data("numeric.callback", null).unbind("keypress", $.fn.numeric.keypress).unbind("blur", $.fn.numeric.blur);
|
||||
}
|
||||
|
||||
// Based on code from http://javascript.nwbox.com/cursor_position/ (Diego Perini <dperini@nwbox.com>)
|
||||
$.fn.getSelectionStart = function(o)
|
||||
{
|
||||
if (o.createTextRange)
|
||||
{
|
||||
var r = document.selection.createRange().duplicate();
|
||||
r.moveEnd('character', o.value.length);
|
||||
if (r.text == '') return o.value.length;
|
||||
return o.value.lastIndexOf(r.text);
|
||||
} else return o.selectionStart;
|
||||
}
|
||||
|
||||
// set the selection, o is the object (input), p is the position ([start, end] or just start)
|
||||
$.fn.setSelection = function(o, p)
|
||||
{
|
||||
// if p is number, start and end are the same
|
||||
if(typeof p == "number") p = [p, p];
|
||||
// only set if p is an array of length 2
|
||||
if(p && p.constructor == Array && p.length == 2)
|
||||
{
|
||||
if (o.createTextRange)
|
||||
{
|
||||
var r = o.createTextRange();
|
||||
r.collapse(true);
|
||||
r.moveStart('character', p[0]);
|
||||
r.moveEnd('character', p[1]);
|
||||
r.select();
|
||||
}
|
||||
else if(o.setSelectionRange)
|
||||
{
|
||||
o.focus();
|
||||
o.setSelectionRange(p[0], p[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
94
modules/server/module.php
Executable file
94
modules/server/module.php
Executable file
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2018 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.
|
||||
*
|
||||
*/
|
||||
|
||||
// Module general information
|
||||
$module_title = "Server manager";
|
||||
$module_version = "1.6.1";
|
||||
$db_version = 7;
|
||||
$module_required = TRUE;
|
||||
$module_menus = array(
|
||||
array( 'subpage' => '', 'name'=>'Servers', 'group'=>'admin' )
|
||||
);
|
||||
|
||||
$install_queries = array();
|
||||
$install_queries[0] = array(
|
||||
"DROP TABLE IF EXISTS `".OGP_DB_PREFIX."remote_server_ips`;",
|
||||
"CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."remote_server_ips` (
|
||||
`ip_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`remote_server_id` int(11) NOT NULL,
|
||||
`ip` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`ip_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;",
|
||||
"DROP TABLE IF EXISTS `".OGP_DB_PREFIX."remote_servers`;",
|
||||
"CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."remote_servers` (
|
||||
`remote_server_id` int(11) NOT NULL auto_increment,
|
||||
`remote_server_name` varchar(100) NOT NULL,
|
||||
`ogp_user` varchar(100) NOT NULL,
|
||||
`agent_ip` varchar(255) NOT NULL,
|
||||
`agent_port` int(11) NOT NULL,
|
||||
`ftp_port` int(11) NOT NULL,
|
||||
`encryption_key` varchar(50) NOT NULL,
|
||||
`timeout` int(11) NOT NULL,
|
||||
PRIMARY KEY (`remote_server_id`),
|
||||
UNIQUE KEY `agent_ip` (`agent_ip`,`agent_port`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Remote servers and IPs';");
|
||||
|
||||
$install_queries[1] = array(
|
||||
"ALTER TABLE `".OGP_DB_PREFIX."remote_servers`
|
||||
ADD `use_nat` int(11) NOT NULL;");
|
||||
$install_queries[2] = array(
|
||||
"ALTER TABLE `OGP_DB_PREFIXremote_servers`
|
||||
ADD `ufw_status` CHAR(8);");
|
||||
$install_queries[3] = array(
|
||||
"ALTER TABLE `OGP_DB_PREFIXremote_servers`
|
||||
ADD `ftp_ip` varchar(255) NOT NULL;");
|
||||
|
||||
$install_queries[4] = array(
|
||||
"DROP TABLE IF EXISTS `".OGP_DB_PREFIX."arrange_ports`;",
|
||||
"CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."arrange_ports` (
|
||||
`range_id` int(11) NOT NULL auto_increment,
|
||||
`ip_id` int(11) NOT NULL,
|
||||
`home_cfg_id` int(11) NOT NULL,
|
||||
`start_port` smallint(11) unsigned NOT NULL,
|
||||
`end_port` smallint(11) unsigned NOT NULL,
|
||||
`port_increment` smallint(11) unsigned NOT NULL,
|
||||
PRIMARY KEY (`range_id`),
|
||||
UNIQUE KEY `ip_id` (`ip_id`,`home_cfg_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Remote servers and IPs';");
|
||||
|
||||
$install_queries[5] = array(
|
||||
"ALTER TABLE `OGP_DB_PREFIXremote_servers`
|
||||
DROP COLUMN `ufw_status`;",
|
||||
"ALTER TABLE `OGP_DB_PREFIXremote_servers`
|
||||
ADD `firewall_settings` LONGTEXT NULL;");
|
||||
|
||||
$install_queries[6] = array(
|
||||
"ALTER TABLE `OGP_DB_PREFIXremote_servers`
|
||||
ADD `display_public_ip` varchar(15) NOT NULL;");
|
||||
|
||||
$install_queries[7] = array(
|
||||
"ALTER TABLE `OGP_DB_PREFIXremote_servers`
|
||||
MODIFY `display_public_ip` varchar(255) NOT NULL;");
|
||||
|
||||
?>
|
||||
84
modules/server/mon_stats.php
Executable file
84
modules/server/mon_stats.php
Executable file
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2018 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.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once('includes/lib_remote.php');
|
||||
function pretty_text_ttf($im, $fontsize, $angle, $x, $y, $color, $font, $string, $outline = false) {
|
||||
$black = imagecolorallocate($bgImg, 0, 0, 0);
|
||||
|
||||
// Black outline
|
||||
if($outline){
|
||||
imagettftext($im, $fontsize, $angle, $x - 1, $y - 1, $black, $font, $string);
|
||||
imagettftext($im, $fontsize, $angle, $x - 1, $y, $black, $font, $string);
|
||||
imagettftext($im, $fontsize, $angle, $x - 1, $y + 1, $black, $font, $string);
|
||||
imagettftext($im, $fontsize, $angle, $x, $y - 1, $black, $font, $string);
|
||||
imagettftext($im, $fontsize, $angle, $x, $y + 1, $black, $font, $string);
|
||||
imagettftext($im, $fontsize, $angle, $x + 1, $y - 1, $black, $font, $string);
|
||||
imagettftext($im, $fontsize, $angle, $x + 1, $y, $black, $font, $string);
|
||||
imagettftext($im, $fontsize, $angle, $x + 1, $y + 1, $black, $font, $string);
|
||||
}
|
||||
|
||||
// Your text
|
||||
imagettftext($im, $fontsize, $angle, $x, $y, $color, $font, $string);
|
||||
return $im;
|
||||
}
|
||||
|
||||
function dsi_make_img($im = false, $cache_on = false, $cache_data = false, $force_cached = false, $format = false){
|
||||
header("Content-type: image/png");
|
||||
|
||||
if($cache_on && $cache_data["file"]){
|
||||
$expire = gmdate("D, d M Y H:i:s", $cache_data["cache_expire"])." GMT";
|
||||
//$last = gmdate("D, d M Y H:i:s", filemtime($cache_data["file"]))." GMT";
|
||||
|
||||
header("Expires: ".$expire);
|
||||
|
||||
if(!$force_cached){ imagepng($im, $cache_data["file"], 9); }
|
||||
readfile($cache_data["file"]);
|
||||
}
|
||||
else{ imagepng($im, null, 9); }
|
||||
|
||||
imagedestroy($im);
|
||||
exit;
|
||||
}
|
||||
|
||||
function exec_ogp_module() {
|
||||
global $db;
|
||||
$remote_server = $db->getRemoteServer($_GET['remote_server_id']);
|
||||
|
||||
$remote = new OGPRemoteLibrary( $remote_server['agent_ip'], $remote_server['agent_port'],
|
||||
$remote_server['encryption_key'], $remote_server['timeout'] );
|
||||
|
||||
$stats = $remote->mon_stats();
|
||||
$im = imagecreatefrompng("images/term.png");
|
||||
$stats_lines_array = explode("\n", $stats);
|
||||
$text_color = ImageColorAllocate($im,225,225,225);
|
||||
$text_font = "includes/fonts/TIMES_SQ.TTF";
|
||||
$i = 40;
|
||||
foreach ($stats_lines_array as $stats_line)
|
||||
{
|
||||
pretty_text_ttf($im,11,0,5,$i,$text_color,$text_font,utf8_decode($stats_line), true); // Servername
|
||||
$i = $i+20;
|
||||
}
|
||||
dsi_make_img($im, true);
|
||||
return;
|
||||
}
|
||||
11
modules/server/navigation.xml
Executable file
11
modules/server/navigation.xml
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
<navigation>
|
||||
<page key="add" file="add_server.php" access="admin" />
|
||||
<page key="edit" file="edit_server.php" access="admin" />
|
||||
<page key="reboot" file="reboot.php" access="admin" />
|
||||
<page key="restart" file="restart.php" access="admin" />
|
||||
<page key="default" file="servers.php" access="admin" />
|
||||
<page key="log" file="view_log.php" access="admin" />
|
||||
<page key="arrange_ports" file="arrange_ports.php" access="admin" />
|
||||
<page key="firewall" file="firewall.php" access="admin" />
|
||||
<page key="mon_stats" file="mon_stats.php" access="admin" />
|
||||
</navigation>
|
||||
56
modules/server/reboot.php
Executable file
56
modules/server/reboot.php
Executable file
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2018 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.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once('includes/lib_remote.php');
|
||||
function exec_ogp_module() {
|
||||
|
||||
global $view;
|
||||
global $db;
|
||||
echo "<h2>".get_lang('reboot')."</h2>";
|
||||
$rhost_id = @$_REQUEST['rhost_id'];
|
||||
$remote_server = $db->getRemoteServer($rhost_id);
|
||||
$remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key'], $remote_server['timeout']);
|
||||
$ipAndName = $remote_server['remote_server_name'] . " " . "(" . $remote_server['agent_ip'] . ")";
|
||||
|
||||
// Confirm user wants to reboot the server
|
||||
if (!isset($_POST['re_check'])) {
|
||||
echo "<table class='center' style='width:100%;' ><tr>\n" . "<td>" . get_lang_f('confirm_reboot', $ipAndName) . "</td>" . "</tr><tr><td>" . '<form method="post" >' . "\n" . '<input type="hidden" name="rhost_id" value="' . $rhost_id . '">' . "\n" . '<button name="re_check" value="yes" >' . get_lang('yes') . "</button>\n" . '<button name="re_check" value="no" >' . get_lang('no') . "</button>\n" . "</form>\n" . "</td>\n" . "</tr>\n" . "</table><br>\n";
|
||||
} else if($_POST['re_check'] == "yes") {
|
||||
// Confirmed... so reboot the server in 10 seconds
|
||||
$file_info = $remote->remote_rebootnow();
|
||||
echo "<p>" . get_lang_f('reboot_success', $ipAndName) . "</p>";
|
||||
|
||||
// 150 seconds should be enough for the server to come back up?
|
||||
$view->refresh("?m=server",150);
|
||||
|
||||
} else if ($_POST['re_check'] == "no"){
|
||||
$view->refresh("?m=server",0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
86
modules/server/restart.php
Executable file
86
modules/server/restart.php
Executable file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2018 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.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once('includes/lib_remote.php');
|
||||
function exec_ogp_module() {
|
||||
|
||||
global $view;
|
||||
global $db;
|
||||
echo "<h2>". get_lang("restart") ."</h2>";
|
||||
$rhost_id = @$_REQUEST['rhost_id'];
|
||||
$remote_server = $db->getRemoteServer($rhost_id);
|
||||
$remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key'], $remote_server['timeout']);
|
||||
|
||||
|
||||
|
||||
if(isset($_GET['refresh']))
|
||||
{
|
||||
|
||||
$host_stat = $remote->status_chk();
|
||||
if($host_stat === 0)
|
||||
{
|
||||
echo get_lang("restarting"); # "Restarting agent... Please wait."
|
||||
$view->refresh("?m=server&p=restart&rhost_id=".$rhost_id."&refresh",5);
|
||||
}
|
||||
else
|
||||
{
|
||||
$remote->remote_readfile( "screenlogs/screenlog.agent_restart", $restart_log );
|
||||
echo "<pre class='log'><xmp>".$restart_log."</xmp></pre>";
|
||||
$remote->remote_readfile( "screenlogs/screenlog.ogp_agent", $agent_log );
|
||||
if($agent_log == "")
|
||||
{
|
||||
$view->refresh("?m=server&p=restart&rhost_id=".$rhost_id."&refresh",5);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<pre class='log'><xmp>".$agent_log."</xmp></pre>";
|
||||
print_success( get_lang("restarted") );
|
||||
echo create_back_button($_GET['m']);
|
||||
$view->refresh("?m=server",15);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Confirm user wants to reboot the server
|
||||
else if (!isset($_POST['re_check'])) {
|
||||
$ipAndName = $remote_server['remote_server_name'] . " " . "(" . $remote_server['agent_ip'] . ")";
|
||||
echo "<table class='center' style='width:100%;' ><tr>\n" . "<td>".
|
||||
get_lang_f('confirm_restart', $ipAndName) . "</td>" . "</tr><tr><td>".
|
||||
'<form method="post" >' . "\n" . '<input type="hidden" name="rhost_id" value="'.
|
||||
$rhost_id . '">' . "\n" . '<button name="re_check" value="yes" >'.
|
||||
get_lang("yes") . "</button>\n" . '<button name="re_check" value="no" >'.
|
||||
get_lang("no") . "</button>\n" . "</form>\n" . "</td>\n" . "</tr>\n" . "</table><br>\n";
|
||||
} else if($_POST['re_check'] == "yes") {
|
||||
// Confirmed... so restart the agent
|
||||
$remote->exec( "if [ -e 'screenlogs/screenlog.agent_restart' ]; then rm -f 'screenlogs/screenlog.agent_restart'; fi && ".
|
||||
"if [ -e 'screenlogs/screenlog.ogp_agent' ]; then rm -f 'screenlogs/screenlog.ogp_agent'; fi" );
|
||||
$file_info = $remote->agent_restart();
|
||||
// 5 seconds should be enough for the agent to come back up
|
||||
echo get_lang("restarting"); # "Restarting agent... Please wait."
|
||||
$view->refresh("?m=server&p=restart&rhost_id=".$rhost_id."&refresh", 5);
|
||||
|
||||
} else if ($_POST['re_check'] == "no"){
|
||||
$view->refresh("?m=server",0);
|
||||
}
|
||||
}
|
||||
?>
|
||||
8
modules/server/server.css
Executable file
8
modules/server/server.css
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
.ui-tooltip {
|
||||
border: 1px solid white !important;
|
||||
max-width: 451px !important;
|
||||
padding: 0 !important;
|
||||
border-radius: 20px;
|
||||
box-shadow: 0 0 7px black !important;
|
||||
overflow:hidden;
|
||||
}
|
||||
176
modules/server/servers.php
Executable file
176
modules/server/servers.php
Executable file
|
|
@ -0,0 +1,176 @@
|
|||
<script type="text/javascript" src="js/modules/server.js"></script>
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2018 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.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once('includes/lib_remote.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_ftp_ip',"");
|
||||
$ft->add_field('string','remote_host_ftp_port',"21");
|
||||
$ft->add_field('string','remote_encryption_key',"");
|
||||
$ft->add_field('string','timeout',"5");
|
||||
$ft->add_field('on_off','use_nat',"0");
|
||||
$ft->add_field('string','display_public_ip',"");
|
||||
$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" class="header sorter-false"><?php print_lang('configured_remote_hosts'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody> <?php
|
||||
foreach ( $servers as $server_row )
|
||||
{
|
||||
#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'],$server_row['timeout']);
|
||||
|
||||
$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>
|
||||
<td class='collapsible' ><b>". get_lang("server_name") .":</b> ".$server_row['remote_server_name']."</td>
|
||||
<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=reboot&rhost_id=".$server_row['remote_server_id'].
|
||||
"'>[". get_lang("reboot") ."]</a>\n<a href='?m=server&p=restart&rhost_id=".$server_row['remote_server_id'].
|
||||
"'>[". get_lang("restart") ."]</a>\n".
|
||||
"<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 src='images/magnifglass.png' data-url='home.php?m=server&p=mon_stats&remote_server_id=$server_row[remote_server_id]&type=cleared' weight='8' class='center' />";
|
||||
}
|
||||
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' >
|
||||
<td>$booble</td><td>
|
||||
<b>". get_lang("ogp_user") .":</b> ".$server_row['ogp_user']."<br />
|
||||
<b>". get_lang("agent_ip_port") .":</b> ".$server_row['agent_ip'].":".$server_row['agent_port']."<br />
|
||||
<b>". get_lang("remote_host_ftp_ip") .":</b> ".$ftp_ip."<br />
|
||||
<b>". get_lang("remote_host_ftp_port") .":</b> ".$server_row['ftp_port']."<br />
|
||||
<b>". get_lang("timeout") .":</b> ".$server_row['timeout']." ". get_lang("seconds") ."<br />
|
||||
<b>". get_lang("encryption_key") .":</b> ".$server_row['encryption_key']."<br />
|
||||
</td>
|
||||
<td>
|
||||
<b>". get_lang("display_public_ip") .":</b><br />".checkDisplayPublicIP($server_row['display_public_ip'], $server_row['agent_ip'])."<br />
|
||||
<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><b>". get_lang("firewall_status") .":</b> ";
|
||||
$firewall_settings = $db->getFirewallSettings($server_row['remote_server_id']);
|
||||
if ( !$firewall_settings )
|
||||
{
|
||||
$status = "disable";
|
||||
}
|
||||
else
|
||||
{
|
||||
$status = isset($firewall_settings['status']) ? $firewall_settings['status'] : "disable";
|
||||
}
|
||||
|
||||
if($status == "enable")
|
||||
{
|
||||
$data .= get_lang("on");
|
||||
}
|
||||
elseif($status == "disable")
|
||||
{
|
||||
|
||||
$data .= get_lang("off");
|
||||
}
|
||||
$data .= "<br />
|
||||
<a href='?m=server&p=firewall&rhost_id=".
|
||||
$server_row['remote_server_id']."'>[". get_lang("firewall_settings") ."]</a>\n<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";
|
||||
}
|
||||
71
modules/server/view_log.php
Executable file
71
modules/server/view_log.php
Executable file
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2018 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.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once('includes/lib_remote.php');
|
||||
function exec_ogp_module() {
|
||||
|
||||
global $view;
|
||||
global $db;
|
||||
echo "<h2>". get_lang("view_log") ."</h2>";
|
||||
$rhost_id = @$_REQUEST['rhost_id'];
|
||||
$remote_server = $db->getRemoteServer($rhost_id);
|
||||
$remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key'], $remote_server['timeout'] );
|
||||
if(isset($_POST['save_file']))
|
||||
{
|
||||
$file_info = $remote->remote_writefile('./ogp_agent.log', strip_real_escape_string($_REQUEST['file_content']));
|
||||
if ( $file_info === 1 )
|
||||
{
|
||||
print_success( get_lang("wrote_changes") );
|
||||
}
|
||||
else if ( $file_info === 0 )
|
||||
print_failure( get_lang("failed_write") );
|
||||
else
|
||||
{
|
||||
print_failure( get_lang("agent_offline") );
|
||||
}
|
||||
}
|
||||
$data = "";
|
||||
$file_info = $remote->remote_readfile('./ogp_agent.log',$data);
|
||||
if ( $file_info === 0 )
|
||||
{
|
||||
print_failure( get_lang("not_found") );
|
||||
return;
|
||||
}
|
||||
else if ( $file_info === -1 )
|
||||
{
|
||||
print_failure( get_lang("agent_offline") );
|
||||
return;
|
||||
}
|
||||
else if ( $file_info === -2 )
|
||||
{
|
||||
print_failure( get_lang("failed_read") );
|
||||
return;
|
||||
}
|
||||
echo "<form action='?m=server&p=log&rhost_id=".$rhost_id."' method='post'>";
|
||||
echo "<textarea name='file_content' style='width:98%;' rows='40'>$data</textarea>";
|
||||
echo "<p><input type='submit' name='save_file' value='Save' /></p>";
|
||||
echo "</form>";
|
||||
echo create_back_button($_GET['m']);
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue