Moved the Agents into their own repo. Kept the agent.pl just for reference

This commit is contained in:
Frank Harris 2025-09-11 13:27:32 -04:00
parent 22381be29a
commit 8680a02b13
18132 changed files with 0 additions and 2569420 deletions

View file

@ -1,139 +0,0 @@
<?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.
*
*/
class MinecraftRcon
{
/*
* Class written by xPaw
*
* Website: http://xpaw.ru
* GitHub: https://github.com/xPaw/PHP-Minecraft-Query
*
* Protocol: https://developer.valvesoftware.com/wiki/Source_RCON_Protocol
*/
// Sending
const SERVERDATA_EXECCOMMAND = 2;
const SERVERDATA_AUTH = 3;
// Receiving
const SERVERDATA_RESPONSE_VALUE = 0;
const SERVERDATA_AUTH_RESPONSE = 2;
private $Socket;
private $RequestId;
public function __destruct( )
{
$this->Disconnect( );
}
public function Connect( $Ip, $Port = 25575, $Password, $Timeout = 3 )
{
$this->RequestId = 0;
if( $this->Socket = FSockOpen( $Ip, (int)$Port ) )
{
Socket_Set_TimeOut( $this->Socket, $Timeout );
if( !$this->Auth( $Password ) )
{
$this->Disconnect( );
}
else
{
return true;
}
}
}
public function Disconnect( )
{
if( $this->Socket )
{
FClose( $this->Socket );
$this->Socket = null;
}
}
public function Command( $String )
{
if( !$this->WriteData( self :: SERVERDATA_EXECCOMMAND, $String ) )
{
return false;
}
$Data = $this->ReadData( );
if( $Data[ 'RequestId' ] < 1 || $Data[ 'Response' ] != self :: SERVERDATA_RESPONSE_VALUE )
{
return false;
}
return $Data[ 'String' ];
}
private function Auth( $Password )
{
if( !$this->WriteData( self :: SERVERDATA_AUTH, $Password ) )
{
return false;
}
$Data = $this->ReadData( );
return $Data[ 'RequestId' ] > -1 && $Data[ 'Response' ] == self :: SERVERDATA_AUTH_RESPONSE;
}
private function ReadData( )
{
$Packet = Array( );
$Size = FRead( $this->Socket, 4 );
$Size = UnPack( 'V1Size', $Size );
$Size = $Size[ 'Size' ];
// TODO: Add multiple packets (Source)
$Packet = FRead( $this->Socket, $Size );
$Packet = UnPack( 'V1RequestId/V1Response/a*String/a*String2', $Packet );
return $Packet;
}
private function WriteData( $Command, $String = "" )
{
// Pack the packet together
$Data = Pack( 'VV', $this->RequestId++, $Command ) . $String . "\x00\x00\x00";
// Prepend packet length
$Data = Pack( 'V', StrLen( $Data ) ) . $Data;
$Length = StrLen( $Data );
return $Length === FWrite( $this->Socket, $Data, $Length );
}
}
?>

View file

@ -1,258 +0,0 @@
<?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.
*
*/
if (empty($server_home["ip"]))
$server_home["ip"] = $ip;
if (empty($server_home["port"]))
$server_home["port"] = $port;
$server_home['ip_port'] = $server_home['ip'] . ':' . $server_home['port'];
$server_home["true"] = "";
$last_param = json_decode($db->getLastParam($server_home["home_id"]), True);
$server_home["max_players"] = isset($cli_param_data['PLAYERS']) ? $cli_param_data['PLAYERS'] : $last_param['players'];
$server_home["webhost_ip"] = $_SERVER['SERVER_ADDR'];
$server_home["incremental"] = $db->incrementalNumByHomeId( $server_home["home_id"], $server_home["mod_cfg_id"], $server_home["remote_server_id"] );
$server_home["map"] = isset($cli_param_data['MAP']) ? $cli_param_data['MAP'] : $last_param['map'];
$isWin = preg_match('/CYGWIN/', $remote->what_os());
if( isset($server_xml->gameq_query_name) )
{
$server_home["query_port"] = get_query_port($server_xml, $server_home['port']);
}
elseif( isset($server_xml->lgsl_query_name) )
{
$get_q_and_s = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $server_home['port'], "", "");
$server_home["query_port"] = $get_q_and_s['1'];
}
$replace_texts = $server_xml->replace_texts->text;
$replace_id = 0;
if($replace_texts)
{
foreach ($replace_texts as $text => $array )
{
$param = (string)$array['key'];
if ($param == 'home_path' && $isWin) {
$info_param = rtrim($remote->exec('cygpath -w /')) . $server_home[$param];
} else {
$info_param = $server_home[$param];
}
$replacements[$replace_id]['info_param'] = $info_param;
foreach ($array as $key => $value )
{
if ($key == "default")
$replacements[$replace_id]['default'] = (string)$value;
if ($key == "var")
$replacements[$replace_id]['var'] = (string)$value;
if ($key == "filepath")
$replacements[$replace_id]['filepath'] = (string)$value;
if ($key == "options")
$replacements[$replace_id]['options'] = (string)$value;
if ($key == "occurrence")
$replacements[$replace_id]['occurrence'] = (string)$value;
}
$replace_id++;
}
}
$custom_fields = json_decode($db->getCustomFields($server_home["home_id"]), True);
$fields = $server_xml->custom_fields->field;
if($fields)
{
foreach ($fields as $text => $array )
{
foreach ($array as $key => $value )
{
if ($key == "default_value")
{
if (array_key_exists((string)$array['key'], $custom_fields))
$replacements[$replace_id]['info_param'] = strip_real_escape_string((string)$custom_fields[(string)$array['key']]);
else
$replacements[$replace_id]['info_param'] = (string)$value;
}
if ($key == "default")
$replacements[$replace_id]['default'] = (string)$value;
if ($key == "var")
$replacements[$replace_id]['var'] = (string)$value;
if ($key == "filepath")
$replacements[$replace_id]['filepath'] = (string)$value;
if ($key == "options")
$replacements[$replace_id]['options'] = (string)$value;
if ($key == "occurrence")
$replacements[$replace_id]['occurrence'] = (string)$value;
}
$replace_id++;
}
}
foreach($replacements as $key => $replacement)
{
$filepath = $replacement['filepath'];
$file_replacements[$filepath][$key] = $replacement;
}
/* echo "<xmp>";
print_r($file_replacements);
echo "</xmp>"; */
require_once('includes/lib_remote.php');
$remote = new OGPRemoteLibrary($server_home['agent_ip'], $server_home['agent_port'], $server_home['encryption_key'], $server_home['timeout']);
foreach($file_replacements as $filepath => $replacements)
{
$file_info = $remote->remote_readfile($server_home['home_path']."/$filepath",$file_content);
if ( $file_info === 0 )
{
$remote->exec( "touch ".$server_home['home_path']."/$filepath" );
$file_info = "";
}
foreach($replacements as $replacement)
{
$info_param = $replacement['info_param'];
$default = $replacement['default'];
$var = $replacement['var'];
$options = $replacement['options'];
$occurrence = !isset($replacement['occurrence']) || empty($replacement['occurrence']) || !is_numeric($replacement['occurrence']) || $replacement['occurrence'] < 1 ? false : $replacement['occurrence'];
if( !in_array( $options, array("tags","tagValueByName","sc","sqc") ) )
{
$match_found = preg_match("/$default/m", $file_content);
if($var == "")
{
$preg_info_param = preg_quote($info_param, "/");
if ($options == "s")//separated
$match_info_param = preg_match("/^\s$preg_info_param/m", $file_content);
elseif ($options == "q")//quoted
$match_info_param = preg_match("/^\"$preg_info_param\"/m", $file_content);
elseif ($options == "sq")//separated & quoted
$match_info_param = preg_match("/^\s\"$preg_info_param\"/m", $file_content);
elseif ($options == "")
$match_info_param = preg_match("/^$preg_info_param/m", $file_content);
if($match_info_param == 1)
continue;
}
}
else
$match_found = 1;
if(!$match_found or $match_found === 0)
{
if ($options == "s")//separated
$file_content .= "\n$var $info_param";
elseif ($options == "q")//quoted
$file_content .= "\n$var\"" . str_replace('"', '\"', $info_param) . "\"";
elseif ($options == "sq")//separated & quoted
$file_content .= "\n$var \"" . str_replace('"', '\"', $info_param) . "\"";
elseif ($options == "key-regex")
{
$var = str_replace("%key%", $info_param, $var);
$file_content .= "\n$var";
}
elseif ($options == "")
$file_content .= "\n$var$info_param";
}
else
{
if ($options == "tags"){
if($occurrence !== false){
$file_content = preg_replace_nth("/(<$default$var>)(.*)(<\/$default>)/m", '${1}'.$info_param.'${3}', $file_content, $occurrence);
}else{
$file_content = preg_replace("/(<$default$var>)(.*)(<\/$default>)/m", '${1}'.$info_param.'${3}', $file_content, 1);
}
}
elseif ($options == "tagValueByName"){
if($occurrence !== false){
$file_content = preg_replace_nth('/('.$default.'.*name="'.$var.'".*value=)(".*")/m', '${1}"' . str_replace('"', '\"', $info_param) . '"', $file_content, $occurrence);
}else{
$file_content = preg_replace('/('.$default.'.*name="'.$var.'".*value=)(".*")/m', '${1}"' . str_replace('"', '\"', $info_param) . '"', $file_content, 1);
}
}
elseif($options == "s"){//separated
if($occurrence !== false){
$file_content = preg_replace_nth("/$default/m", "$var $info_param", $file_content, $occurrence);
}else{
$file_content = preg_replace("/$default/m", "$var $info_param", $file_content, 1);
}
}
elseif ($options == "q"){//quoted
if($occurrence !== false){
$file_content = preg_replace_nth("/$default/m", "$var\"" . str_replace('"', '\"', $info_param) . "\"", $file_content, $occurrence);
}else{
$file_content = preg_replace("/$default/m", "$var\"" . str_replace('"', '\"', $info_param) . "\"", $file_content, 1);
}
}
elseif ($options == "sq"){//separated & quoted
if($occurrence !== false){
$file_content = preg_replace_nth("/$default/m", "$var \"" . str_replace('"','\"',$info_param) . "\"", $file_content, $occurrence);
}else{
$file_content = preg_replace("/$default/m", "$var \"" . str_replace('"','\"',$info_param) . "\"", $file_content, 1);
}
}
elseif ($options == "sc"){//separated & ending with a comma (used in JC2MP Example)
if($occurrence !== false){
$file_content = preg_replace_nth("/$default/m", "$var $info_param,", $file_content, $occurrence);
}else{
$file_content = preg_replace("/$default/m", "$var $info_param,", $file_content, 1);
}
}
elseif ($options == "sqc"){//separated & quoted & ending with a comma
if($occurrence !== false){
$file_content = preg_replace_nth("/$default/m", "$var \"" . str_replace('"', '\"', $info_param) . "\",", $file_content, $occurrence);
}else{
$file_content = preg_replace("/$default/m", "$var \"" . str_replace('"', '\"', $info_param) . "\",", $file_content, 1);
}
}
elseif ($options == "key-regex")//replace %key% in <var> and use a regular expression
{
$var = str_replace("%key%", $info_param, $var);
if($occurrence !== false){
$file_content = preg_replace_nth("/$default/m", "$var", $file_content, $occurrence);
}else{
$file_content = preg_replace("/$default/m", "$var", $file_content, 1);
}
}
else{
if($occurrence !== false){
$file_content = preg_replace_nth("/$default/m", "$var$info_param", $file_content, $occurrence);
}else{
$file_content = preg_replace("/$default/m", "$var$info_param", $file_content, 1);
}
}
}
if ( get_magic_quotes_gpc() )
$file_content=stripslashes($file_content);
}
//echo "<xmp>".$file_content."</xmp>";
$remote->remote_writefile($server_home['home_path'] . "/" . $filepath, $file_content);
}
?>

View file

@ -1,80 +0,0 @@
.monitorbutton{
display: inline-block;
cursor: pointer;
color: #323232;
transition: background-color 0.5s;
-webkit-transition: background-color 0.5s;
outline: 1px solid grey;
width: 48%;
height: 90px;
background-color: #F0F0F6;
vertical-align: middle;
text-align: center;
margin-bottom: 2%;
margin-left: 1%;
margin-right: 1%;
max-width: 175px;
float:left;
}
.monitorbutton.sizeText{
line-height: 90px;
}
.monitorbutton:hover {
background-color:#D9D9D9;
transition: background-color 0.5s;
-webkit-transition: background-color 0.5s;
cursor:pointer;
text-decoration:none;
}
.monitorbutton > img {
height: 50px;
margin: 5px 0px;
}
.monitorbutton > span {
display: block;
font-weight: bold;
color: #000;
}
button:active, button[type="submit"]:active, input[type="submit"]:active, .monitorbutton tr td:active {
background-color:#0F0 !important;
transition: background-color 0.25s;
-webkit-transition: background-color 0.25s;
}
#server_icon{
display:block;
float:left;
overflow:hidden;
margin:2px;
margin-right:10px;
padding-top:1px;
padding-bottom:2px;
padding-right:5px;
border:1px solid gray;
background:transparent;
cursor:pointer;
background-color:white;
border-radius:3px;
font-weight:bold;
}
#server_icon div{
display:inline-block;
vertical-align:middle;
}
.monitorButtonContainer{
text-align: left; /* fallback for older IE */
text-align: initial;
width: 98%;
padding-top: 2%;
}
.operations{
text-align: center;
}

View file

@ -1,471 +0,0 @@
<?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 get_query_port($server_xml, $server_port) {
if ($server_xml->query_port) {
if ($server_xml->query_port['type'] == 'add') {
return $server_port + $server_xml->query_port;
}
if ($server_xml->query_port['type'] == 'subtract') {
return $server_port - $server_xml->query_port;
}
}
return $server_port;
}
function get_start_cmd($remote,$server_xml,$home_info,$mod_id,$ip,$port,$db)
{
$last_param = json_decode($home_info['last_param'], True);
$os = $remote->what_os();
$isAdmin = false;
if(hasValue($_SESSION) && hasValue($_SESSION['user_id'])){
$isAdmin = $db->isAdmin($_SESSION['user_id']);
}
$cli_param_data['GAME_TYPE'] = $home_info['mods'][$mod_id]['mod_key'];
$cli_param_data['IP'] = $ip;
$cli_param_data['PORT'] = $port;
$cli_param_data['HOSTNAME'] = $home_info['home_name'];
$cli_param_data['PID_FILE'] = "ogp_game_startup.pid";
// Linux
if( preg_match("/Linux/", $os) )
{
if(preg_match("/_win(32|64)?$/", $home_info['game_key']))
{
$home_path_wine = $remote->exec("winepath -w ".$home_info['home_path']);
$home_path_wine = str_replace("\\","\\\\", $home_path_wine);
$home_path_wine = trim($home_path_wine);
$cli_param_data['BASE_PATH'] = $home_path_wine;
$cli_param_data['HOME_PATH'] = $home_path_wine;
$cli_param_data['SAVE_PATH'] = $home_path_wine;
$cli_param_data['OUTPUT_PATH'] = $home_path_wine;
$cli_param_data['USER_PATH'] = $home_path_wine;
}
else
{
$cli_param_data['BASE_PATH'] = $home_info['home_path'];
$cli_param_data['HOME_PATH'] = $home_info['home_path'];
$cli_param_data['SAVE_PATH'] = $home_info['home_path'];
$cli_param_data['OUTPUT_PATH'] = $home_info['home_path'];
$cli_param_data['USER_PATH'] = $home_info['home_path'];
}
}
// Windows
elseif( preg_match("/CYGWIN/", $os) )
{
$home_path_win = $remote->exec("cygpath -w ".$home_info['home_path']);
$home_path_win = str_replace("\\","\\\\", $home_path_win);
$home_path_win = trim($home_path_win);
$cli_param_data['BASE_PATH'] = $home_path_win;
$cli_param_data['HOME_PATH'] = $home_path_win;
$cli_param_data['SAVE_PATH'] = $home_path_win;
$cli_param_data['OUTPUT_PATH'] = $home_path_win;
$cli_param_data['USER_PATH'] = $home_path_win;
}
if ($server_xml->protocol == "gameq")
{
$cli_param_data['QUERY_PORT'] = get_query_port ($server_xml, $port);
}
elseif ($server_xml->protocol == "lgsl")
{
require('protocol/lgsl/lgsl_protocol.php');
$get_ports = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $port, "", "");
$cli_param_data['QUERY_PORT'] = $get_ports['1'];
}
elseif ($server_xml->protocol == "teamspeak3")
{
$cli_param_data['QUERY_PORT'] = "10011";
}
$cli_param_data['MAP'] = ($last_param === NULL or !isset($last_param['map'])) ? "" : $last_param['map'];
$cli_param_data['PLAYERS'] = ($last_param === NULL or !isset($last_param['players'])) ?
isset($home_info['mods'][$mod_id]['max_players']) ?
$home_info['mods'][$mod_id]['max_players'] : "1" : $last_param['players'];
$cli_param_data['CONTROL_PASSWORD'] = $home_info['control_password'];
$start_cmd = "";
// If the template is empty then these are not needed.
if ( $server_xml->cli_template )
{
$start_cmd = $server_xml->cli_template;
if ( $server_xml->cli_params )
{
foreach ( $server_xml->cli_params->cli_param as $cli )
{
// If s is found the param is seperated with space
$add_space = preg_match( "/s/", $cli['options'] ) > 0 ? " " : "";
$cli_value = $cli_param_data[(string) $cli['id'] ];
// If q is found we add quotes around the value.
if ( preg_match( "/q/", $cli['options'] ) > 0 )
{
$cli_value = "\"".$cli_value."\"";
}
$start_cmd = preg_replace( "/%".$cli['id']."%/",
$cli['cli_string'].$add_space.$cli_value, $start_cmd );
}
}
if ( $server_xml->reserve_ports )
{
foreach ( $server_xml->reserve_ports->port as $reserve_port )
{
// If s is found the param is seperated with space
$add_space = preg_match( "/s/", $reserve_port['options'] ) > 0 ? " " : "";
$cli_value = $reserve_port['type'] == "add" ? $port + (string) $reserve_port:
$port - (string) $reserve_port;
// If q is found we add quotes around the value.
if ( preg_match( "/q/", $reserve_port['options'] ) > 0 )
{
$cli_value = "\"".$cli_value."\"";
}
$start_cmd = preg_replace( "/%".$reserve_port['id']."%/",
$reserve_port['cli_string'].$add_space.$cli_value, $start_cmd );
}
}
}
if ( $isAdmin )
{
$home_info['access_rights'] = "ufpet";
}
$param_access_enabled = preg_match("/p/",$home_info['access_rights']) > 0 ? TRUE : FALSE;
if ($param_access_enabled && $last_param !== NULL and isset($server_xml->server_params->param) )
{
foreach($server_xml->server_params->param as $param)
{
foreach ($last_param as $paramKey => $paramValue)
{
if (!isset($paramValue))
$paramValue = (string)$param->default;
if ($param['key'] == $paramKey)
{
if (0 == strlen($paramValue))
continue;
if ($param['key'] == $paramValue) // it's a checkbox
$new_param = $paramKey;
elseif($param->option == "ns" or $param->options == "ns")
$new_param = $paramKey.clean_server_param_value($paramValue, $server_xml->cli_allow_chars);
elseif($param->option == "q" or $param->options == "q")
$new_param = $paramKey . '"' . clean_server_param_value($paramValue, $server_xml->cli_allow_chars) . '"';
elseif($param->option == "s" or $param->options == "s")
$new_param = $paramKey . ' ' . clean_server_param_value($paramValue, $server_xml->cli_allow_chars);
else
$new_param = $paramKey . ' "' . clean_server_param_value($paramValue, $server_xml->cli_allow_chars) . '"';
if ($param['id'] == NULL || $param['id'] == "")
$start_cmd .= ' '.$new_param;
else
$start_cmd = preg_replace( "/%".$param['id']."%/", $new_param, $start_cmd );
}
}
if ($param['id'] != NULL && $param['id'] != ""){
$start_cmd = preg_replace( "/%".$param['id']."%/", '', $start_cmd );
}
}
}
$extra_param_access_enabled = preg_match("/e/",$home_info['access_rights']) > 0 ? TRUE:FALSE;
if ( array_key_exists('extra', $last_param) && $extra_param_access_enabled )
$extra_default = $last_param['extra'];
else
$extra_default = $home_info['mods'][$mod_id]['extra_params'];
$start_cmd .= " ".str_replace("\\\\", "\\", clean_server_param_value($extra_default, $server_xml->cli_allow_chars));
return $start_cmd;
}
// This function is used to batch stop/restart servers in background.
function exec_operation( $action, $home_id, $mod_id, $ip, $port, $override = false )
{
if(!is_numeric($port))
return FALSE;
if(!preg_match("/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/",$ip))
return FALSE;
global $db;
$isAdmin = false;
if(hasValue($_SESSION) && hasValue($_SESSION['user_id'])){
$isAdmin = $db->isAdmin($_SESSION['user_id']);
}
if($override || $isAdmin)
$home_info = $db->getGameHome($home_id);
else
$home_info = $db->getUserGameHome($_SESSION['user_id'],$home_id);
if( $home_info === FALSE )
return FALSE;
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']);
if ( !$server_xml )
return FALSE;
require_once('includes/lib_remote.php');
$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'],$home_info['timeout']);
$os = $remote->what_os();
if ( $action != "stop" )
{
if( $server_xml->replace_texts )
{
$server_home = $home_info;
if( isset($server_xml->lgsl_query_name) )
require_once('protocol/lgsl/lgsl_protocol.php');
require_once("modules/gamemanager/cfg_text_replace.php");
}
}
$screen_running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME,$home_info['home_id']) === 1;
if ( $action == "stop" AND $screen_running )
{
$remote_retval = $remote->remote_stop_server($home_info['home_id'],
$ip, $port, $server_xml->control_protocol,
$home_info['control_password'],$server_xml->control_protocol_type, $home_info['home_path']);
$db->logger(get_lang_f('server_stopped', $home_info['home_name'] ) . "($ip:$port)");
if ( $remote_retval === -1 )
return FALSE;
elseif( $remote_retval === -2 )
return FALSE;
else
{
$firewall_settings = $db->getFirewallSettings($home_info['remote_server_id']);
if ($firewall_settings['status'] == "enable")
{
$ip_ports = $db->getHomeIpPorts($home_info['home_id']);
foreach ($ip_ports as $ip_port)
{
if ($server_xml->protocol == "gameq")
{
$query_port = get_query_port($server_xml, $ip_port['port']);
}
elseif ($server_xml->protocol == "lgsl")
{
require('protocol/lgsl/lgsl_protocol.php');
$get_ports = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $ip_port['port'], "", "");
$query_port = $get_ports['1'];
}
elseif ($server_xml->protocol == "teamspeak3")
{
$query_port = "10011";
}
set_firewall($remote, $firewall_settings, 'deny', $ip_port['port'], $ip_port['ip']);
if(isset($query_port) and $query_port != "" and $query_port != $ip_port['port'])
set_firewall($remote, $firewall_settings, 'deny', $query_port, $ip_port['ip']);
}
}
return TRUE;
}
}
elseif ( $action == "restart" AND $screen_running )
{
$start_cmd = get_start_cmd($remote,$server_xml,$home_info,$mod_id,$ip,$port,$db);
// Do text replacements in cfg file
if( $server_xml->replace_texts )
{
foreach($home_info['mods'][$mod_id] as $key => $value)
{
$home_info[$key] = $value;
}
$server_home = $home_info;
if( isset($server_xml->lgsl_query_name) )
require_once('protocol/lgsl/lgsl_protocol.php');
require_once("modules/gamemanager/cfg_text_replace.php");
}
// Run pre-start commands
if(isset($server_xml->pre_start) && !empty($server_xml->pre_start)){
$preStart = trim($server_xml->pre_start);
}else{
$preStart = "";
}
// Environment variables
if(isset($server_xml->environment_variables) && !empty($server_xml->environment_variables)){
$envVars = trim($server_xml->environment_variables);
}else{
$envVars = "";
}
// Additional files to lock
if(isset($server_xml->lock_files) && !empty($server_xml->lock_files)){
$lockFiles = trim($server_xml->lock_files);
}else{
$lockFiles = "";
}
if(!empty($lockFiles)){
// Linux only call
if(preg_match("/Linux/", $os)){
$lockedFilesStatus = $remote->lock_additional_home_files($home_info['home_path'], $lockFiles, "lock");
}
}
$remote_retval = $remote->remote_restart_server($home_info['home_id'],$ip,$port,$server_xml->control_protocol,
$home_info['control_password'],$server_xml->control_protocol_type,$home_info['home_path'],
$server_xml->server_exec_name,$server_xml->exe_location,$start_cmd,
$home_info['mods'][$mod_id]['cpu_affinity'],
$home_info['mods'][$mod_id]['nice'],
$preStart,
$envVars,
$server_xml->game_key,
(isset( $server_xml->console_log ) ? $server_xml->console_log : ""));
$db->logger(get_lang_f('server_restarted', $home_info['home_name']) . "($ip:$port)");
if ( $remote_retval === -1 )
return FALSE;
else if ( $remote_retval === -2 )
return FALSE;
else
{
$ip_id = $db->getIpIdByIp($ip);
$db->delServerStatusCache($ip_id,$port);
}
}
elseif ( $action == "start" AND ! $screen_running )
{
$start_cmd = get_start_cmd($remote,$server_xml,$home_info,$mod_id,$ip,$port,$db);
// Do text replacements in cfg file
if( $server_xml->replace_texts )
{
foreach($home_info['mods'][$mod_id] as $key => $value)
{
$home_info[$key] = $value;
}
$server_home = $home_info;
if( isset($server_xml->lgsl_query_name) )
require_once('protocol/lgsl/lgsl_protocol.php');
require_once("modules/gamemanager/cfg_text_replace.php");
}
// Run pre-start commands
if(isset($server_xml->pre_start) && !empty($server_xml->pre_start)){
$preStart = trim($server_xml->pre_start);
}else{
$preStart = "";
}
// Environment variables
if(isset($server_xml->environment_variables) && !empty($server_xml->environment_variables)){
$envVars = trim($server_xml->environment_variables);
}else{
$envVars = "";
}
// Additional files to lock
if(isset($server_xml->lock_files) && !empty($server_xml->lock_files)){
$lockFiles = trim($server_xml->lock_files);
}else{
$lockFiles = "";
}
if(!empty($lockFiles)){
// Linux only call
if(preg_match("/Linux/", $os)){
$lockedFilesStatus = $remote->lock_additional_home_files($home_info['home_path'], $lockFiles, "lock");
}
}
$start_retval = $remote->universal_start($home_info['home_id'],
$home_info['home_path'],
$server_xml->server_exec_name,
$server_xml->exe_location,
$start_cmd, $port, $ip,
$home_info['mods'][$mod_id]['cpu_affinity'],
$home_info['mods'][$mod_id]['nice'],
$preStart,
$envVars,
$server_xml->game_key,
(isset( $server_xml->console_log ) ? $server_xml->console_log : "")
);
$db->logger(get_lang('server_started') . " (".$home_info['home_name']." $ip:$port)");
if( $start_retval == AGENT_ERROR_NOT_EXECUTABLE or $start_retval <= 0)
return FALSE;
else
{
$firewall_settings = $db->getFirewallSettings($home_info['remote_server_id']);
if ($firewall_settings['status'] == "enable")
{
$ip_ports = $db->getHomeIpPorts($home_info['home_id']);
foreach ($ip_ports as $ip_port)
{
if ($server_xml->protocol == "gameq")
{
$query_port = get_query_port($server_xml, $ip_port['port']);
}
elseif ($server_xml->protocol == "lgsl")
{
require('protocol/lgsl/lgsl_protocol.php');
$get_ports = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $ip_port['port'], "", "");
$query_port = $get_ports['1'];
}
elseif ($server_xml->protocol == "teamspeak3")
{
$query_port = "10011";
}
set_firewall($remote, $firewall_settings, 'allow', $ip_port['port'], $ip_port['ip']);
if(isset($query_port) and $query_port != "" and $query_port != $ip_port['port'])
set_firewall($remote, $firewall_settings, 'allow', $query_port, $ip_port['ip']);
}
}
$ip_id = $db->getIpIdByIp($ip);
$db->delServerStatusCache($ip_id,$port);
return TRUE;
}
}
}
function get_monitor_buttons($server_home, $server_xml)
{
global $db;
$buttons = array();
foreach($db->getInstalledModules() as $installed_module)
{
$buttons_file = "modules/$installed_module[folder]/monitor_buttons.php";
if(file_exists($buttons_file))
{
require($buttons_file);
$buttons = array_merge($buttons, $module_buttons);
unset($module_buttons);
}
}
$buttons_html = "";
foreach($buttons as $button)
$buttons_html .= $button."\n";
return $buttons_html;
}
?>

View file

@ -1,157 +0,0 @@
<?php
require_once('home_handling_functions.php');
require_once("modules/config_games/server_config_parser.php");
global $view;
echo "home id = " .$home_id;
$user_id = $_SESSION['user_id'];
$isAdmin = $db->isAdmin( $user_id );
if($isAdmin)
$home_info = $db->getGameHome($home_id);
else
$home_info = $db->getUserGameHome($user_id,$home_id);
$current_mod_info = $home_info['mods'][$mod_id];
$home_cfg_id = $current_mod_info['home_cfg_id'];
$mod_cfg_id = $current_mod_info['mod_cfg_id'];
if($home_cfg_id === null && $mod_cfg_id === null){
$home_cfg_id = 67;
$mod_cfg_id = 68;
//print_failure(get_lang('invalid_game_mod_id'));
//return;
}
if ( $home_info === FALSE )
{
//print_failure( get_lang("no_access_to_home") );
//return;
}
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']);
if ( !$server_xml )
{
echo create_back_button( $_GET['m'], 'game_monitor&home_id-mod_id-ip-port='.$_GET['home_id-mod_id-ip-port'] );
return;
}
require_once('includes/lib_remote.php');
$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'],$home_info['timeout']);
$home_log = "";
if( isset( $server_xml->console_log ) )
{
$log_retval = $remote->get_log(OGP_SCREEN_TYPE_HOME,
$home_info['home_id'],
clean_path($home_info['home_path']),
$home_log, 100, (string) $server_xml->console_log);
}
else
{
$log_retval = $remote->get_log(OGP_SCREEN_TYPE_HOME,
$home_info['home_id'],
clean_path($home_info['home_path']."/".$server_xml->exe_location),
$home_log);
}
if ($log_retval == 0)
{
print_failure( get_lang("agent_offline") );
echo create_back_button( $_GET['m'], 'game_monitor&home_id-mod_id-ip-port='.$_GET['home_id-mod_id-ip-port'] );
}
elseif ($log_retval == 1 || $log_retval == 2)
{
// Force log file contents to be UTF-8 (fixes http://www.opengamepanel.org/forum/viewthread.php?thread_id=5379)
if(hasValue($home_log)){
$home_log = utf8_encode($home_log);
}
// Using the refreshed class
if( isset($_GET['refreshed']) )
{
echo "<pre class='log'>".htmlentities($home_log)."</pre>";
}
else
{
echo "<h2>".htmlentities($home_info['home_name'])."</h2>";
if($log_retval == 1)
{
require_once("includes/refreshed.php");
$control = '<form method="GET" >
<input type="hidden" name="m" value="gamemanager" />
<input type="hidden" name="p" value="log" />
<input type="hidden" name="home_id-mod_id-ip-port" value="'.$_GET['home_id-mod_id-ip-port'].'" />';
if(isset($_GET['setInterval']))
$control .= "<input type='hidden' name='setInterval' value='" . $_GET['setInterval'] . "' />";
if(isset($_GET['view_player_commands']))
$control .= "<input type='hidden' name='view_player_commands' value='" . $_GET['view_player_commands'] . "' />";
$control .= '<input type="submit" name="size" value="';
if( isset( $_GET['size'] ) and $_GET['size'] == "+" )
{
$height = "100%";
$control .= '-';
}
else
{
$height = "500px";
$control .= '+';
}
$control .= '" /></form>';
$intervals = array( "4s" => "4000",
"8s" => "8000",
"30s" => "30000",
"2m" => "120000",
"5m" => "300000" );
$intSel = '<form action="" method="GET" >
<input type="hidden" name="m" value="gamemanager" />
<input type="hidden" name="p" value="log" />
<input type="hidden" name="home_id-mod_id-ip-port" value="'.$_GET['home_id-mod_id-ip-port'].'" />';
if(isset($_GET['size']))
$intSel .= "<input type='hidden' name='size' value='" . $_GET['size'] . "' />";
if(isset($_GET['view_player_commands']))
$intSel .= "<input type='hidden' name='view_player_commands' value='" . $_GET['view_player_commands'] . "' />";
$intSel .= get_lang("refresh_interval") . ':<select name="setInterval" onchange="this.form.submit();">';
foreach ($intervals as $interval => $value )
{
$selected = "";
if ( isset( $_GET['setInterval'] ) AND $_GET['setInterval'] == $value )
$selected = 'selected="selected"';
$intSel .= '<option value="'.$value.'" '.$selected.' >'.$interval.'</option>';
}
$intSel .= "</select></form>";
$setInterval = isset($_GET['setInterval']) ? $_GET['setInterval'] : 4000;
$refresh = new refreshed();
$pos = $refresh->add("home.php?m=gamemanager&p=log&type=cleared&refreshed&home_id-mod_id-ip-port=". $_GET['home_id-mod_id-ip-port']);
echo $refresh->getdiv($pos,"height:".$height.";overflow:auto;max-width:1600px;");
?><script type="text/javascript">$(document).ready(function(){ <?php echo $refresh->build("$setInterval"); ?>} ); </script><?php
echo "<table class='center' ><tr><td>$intSel</td><td>$control</td></tr></table>";
if( ($server_xml->control_protocol and preg_match("/^r?l?con2?$/", $server_xml->control_protocol)) OR
($server_xml->gameq_query_name and $server_xml->gameq_query_name == "minecraft") OR
($server_xml->lgsl_query_name and $server_xml->lgsl_query_name == "7dtd") )
require('modules/gamemanager/rcon.php');
}
else
{
echo "<pre class='log'>" . htmlentities($home_log) . "</pre>";
print_failure( get_lang("server_not_running") );
}
echo create_back_button( $_GET['m'], 'game_monitor&home_id-mod_id-ip-port='.$_GET['home_id-mod_id-ip-port'] );
}
}
else
{
print_failure(get_lang_f('unable_to_get_log',$log_retval));
echo create_back_button( $_GET['m'], 'game_monitor&home_id-mod_id-ip-port='.$_GET['home_id-mod_id-ip-port'] );
}
?>

View file

@ -1,726 +0,0 @@
<?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.
*
*/
$param_access_enabled = preg_match("/p/",$server_home['access_rights']) > 0 ? TRUE : FALSE;
$extra_param_access_enabled = preg_match("/e/",$server_home['access_rights']) > 0 ? TRUE:FALSE;
$last_param = json_decode($server_home['last_param'], True);
$isAdmin = $db->isAdmin($_SESSION['user_id']);
if (!function_exists('processParamValue')) {
function processParamValue(&$param, &$server_xml, $paramKey, $paramValue, &$save_param, &$start_cmd){
if (0 == strlen($paramValue))
return false;
if ($paramKey == $paramValue) // it's a checkbox
{
$new_param = $paramKey;
$save_param[$paramKey] = $paramValue;
}
elseif($param->option == "ns" or $param->options == "ns")
{
$new_param = $paramKey.clean_server_param_value($paramValue, $server_xml->cli_allow_chars);
$save_param[$paramKey] = $paramValue;
}
elseif($param->option == "q" or $param->options == "q"){
$new_param = $paramKey . '"' . clean_server_param_value($paramValue, $server_xml->cli_allow_chars) . '"';
$save_param[$paramKey] = $paramValue;
elseif($param->option == "s" or $param->options == "s"){
$new_param = $paramKey . ' ' . clean_server_param_value($paramValue, $server_xml->cli_allow_chars);
$save_param[$paramKey] = $paramValue;
}
else
{
$new_param = $paramKey.' "'.clean_server_param_value($paramValue, $server_xml->cli_allow_chars).'"';
$save_param[$paramKey] = $paramValue;
}
if ($param['id'] == NULL || $param['id'] == "")
{
$start_cmd .= ' '.$new_param;
}
else
{
$start_cmd = preg_replace( "/%".$param['id']."%/", $new_param, $start_cmd );
}
}
}
if( !isset( $_POST['start_server'] ) )
{
$server_exec = clean_path($server_home['home_path']."/".$server_xml->exe_location."/".$server_xml->server_exec_name);
$r = $remote->rfile_exists($server_exec);
if($r === 0)
{
print_failure(get_lang_f('game_exec_not_found',$server_exec));
return;
}
else if($r === -1)
{
print_failure( get_lang("agent_offline") );
return;
}
// If the result is something else than 1 here then there unexpected retval was received.
else if ($r !== 1 )
{
print_failure( get_lang("unexpected_result_libremote") );
return;
}
$ip_info = $db->getHomeIpPorts($server_home['home_id']);
if ( empty($ip_info) )
{
print_failure( get_lang("no_ip_port_pairs_assigned") );
return;
}
echo get_lang_f('select_params_and_start', get_lang("start_server") );
echo "<form action='home.php?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=". $server_home['home_id'] . "-". $server_home['mod_id'] . "-" . $server_home['ip'] . "-" . $server_home['port'] . "' method='post'>\n
<input type='hidden' name='mod_id' value='$server_home[mod_id]' />\n
<input type='hidden' name='home_id' value='$server_home[home_id]' />\n
<input type='hidden' name='remote_server_id' value='".$server_home['remote_server_id']."' />\n
<table class='start-server'>
<tr><td class='right'>". get_lang("ogp_agent_ip") .
":</td><td class='left'>".$server_home['agent_ip']."</td></tr>";
$max_players = $server_home['max_players'];
if ( $max_players > 0 )
{
echo "<tr><td class='right'>". get_lang("max_players") .
":</td><td class='left'>";
$players = array();
for($i = $max_players; $i > 0; $i--)
{
$players["$i"]="$i";
}
echo create_drop_box_from_array($players,'max_players',$last_param['players']);
echo "<span class='info'>(". get_lang("max") .": ".
$max_players.")</span></td></tr>\n";
}
$display_ip = checkDisplayPublicIP($server_home['display_public_ip'],$server_home['ip'] != $server_home['agent_ip'] ? $server_home['ip'] : $server_home['agent_ip']);
echo "<tr><td class='right'>". get_lang("ip_and_port") .
":</td><td class='left'>".$display_ip . ":" . $server_home['port']."<input name='ip_port' type='hidden' value='".$server_home['ip'] . ":" . $server_home['port']."'/></td></tr>";
list($list_type,) = explode(":", $server_xml->map_list);
$map_array = -5;
$maps_found = FALSE;
// use maplist file as primary map location.
if ( $server_xml->map_list )
{
$mapfile = $server_home['home_path']."/".
preg_replace("/mod/",$server_home['mod_key'],$server_xml->map_list);
$read_status = $remote->remote_readfile($mapfile,$map_array);
// If file was found and read successfully then lets seperate the maps.
if ( $read_status == 1 )
{
$map_array = array_filter(preg_split("/\n/",$map_array));
if(!empty($map_array))
$maps_found = "FILE";
}
// Otherwise we have error situation...
else
{
$map_array = $read_status;
}
}
// If we could not find maps from the maps file lets try directory listing
// if possible.
if ( $maps_found === FALSE && $server_xml->maps_location )
{
// replace mod with the modname if nessessary.
$map_path = $server_home['home_path']."/".
preg_replace("/mod/",$server_home['mod_key'],$server_xml->maps_location);
// Then we use the directory.
$map_array = $remote->remote_dirlist($map_path);
// If it is array then we successfully read maps.
if ( is_array($map_array) )
{
$map_array = cleanFilenames($map_array);
$maps_found = "DIR";
}
}
$check_ok = TRUE;
// If there is map list or location defined we should have maps available.
if ( $server_xml->map_list || $server_xml->maps_location )
{
if ( is_array($map_array) )
{
echo "<tr><td class='right'>". get_lang("available_maps") .":</td><td class='left'>\n";
// We remove all lines that start with // because we
// expect those lines to be comments.
$comments = preg_grep( "/^\s*\/\//",$map_array );
$map_array = array_diff( $map_array,$comments );
sort($map_array);
echo create_drop_box_from_array($map_array,'map',$last_param['map']);
echo "</td></tr>";
echo "<tr><td colspan='2' class='info'>". get_lang("maps_read_from") ." ";
if ( $maps_found == "DIR" )
{
echo get_lang("directory") ." ".clean_path($map_path).".";
}
else
{
echo get_lang("file") ." ".clean_path($mapfile).".";
}
echo "</td></tr>\n";
}
else
{
echo "<tr><td colspan='2'>";
print_failure( get_lang("failed_to_read_maps_error_code") .": $map_array");
echo "</td></tr>";
$check_ok = FALSE;
}
}
// Print params if there are any.
if($server_xml->server_params)
{
if (!$param_access_enabled)
echo "<span class='failure info'>". get_lang("no_parameter_access") ."</span>";
foreach($server_xml->server_params->param as $param)
{
renderParam($param, $last_param, $param_access_enabled, $server_home['home_id']);
}
foreach($server_xml->server_params->group as $group)
{
echo "<tr><td><table>";
echo "<tr><th><b>".$group['name']."</b></th></tr>";
foreach($group->param as $param)
{
renderParam($param, $last_param, $param_access_enabled, $server_home['home_id']);
}
echo "</table></td></tr>";
}
}
if (isset($server_home['extra_params']))
{
echo "<tr><td colspan='2'><h3>". get_lang("extra_parameters") ."</h3>";
if (!$extra_param_access_enabled)
echo "<span class='failure info'>". get_lang("no_extra_param_access") ."</span>";
echo "</td></tr>\n";
//get last used param or get default
if (array_key_exists('extra', $last_param))
$extra_default = $last_param['extra'];
else
$extra_default = $server_home['extra_params'];
echo "<tr><td colspan='2'><input name='extra_params' value=\"".str_replace('"', "&quot;", strip_real_escape_string($extra_default))."\" style='width:99%' ";
if (!$extra_param_access_enabled)
echo 'disabled';
echo "/></td></tr>";
echo "<tr><td colspan='2' class='info'>". get_lang("extra_parameters_info") ."</td></tr>";
}
echo "</table>";
echo get_lang("start_wait_note");
if ( $check_ok )
{
echo "<div class='submit-start' ><input type='submit' name='start_server' value='".
get_lang("start_server") ."' /></div>\n";
}
else
{
print_failure( get_lang("unable_get_info") );
}
echo "</form>";
return;
}
// Starting the server
elseif($server_home['home_id'] == $_POST['home_id'])
{
// Maxplayers on POST compares with maxplayers on DB for security reasons (FORM HACKING)
if( isset( $_POST['max_players'] ) and is_numeric( $_POST['max_players'] ) )
{
if ( $_POST['max_players'] <= $server_home['max_players'] )
$cli_param_data['PLAYERS'] = $_POST['max_players'];
else
{
echo "<p>" . get_lang_f('unsuitable_maxplayers_value_maximum_reachable_number_of_slots_has_been_set') . "</p>";
$cli_param_data['PLAYERS'] = $server_home['max_players'];
}
}
if ( $server_xml->map_list OR $server_xml->maps_location )
$cli_param_data['MAP'] = $_POST['map'];
else
$cli_param_data['MAP'] = "";
$ip_port = $_POST['ip_port'];
list($ip, $port) = explode(":", $ip_port);
if($server_home['ip'] == $ip && $server_home['port'] == $port)
{
$cli_param_data['IP'] = $server_home['ip'];
$cli_param_data['PORT'] = $server_home['port'];
}
If ( !isset($cli_param_data['IP']) OR !isset($cli_param_data['PORT']) )
{
echo "<h2>" . get_lang_f('ip_port_pair_not_owned') . "</h2>";
return;
}
$cli_param_data['HOSTNAME'] = $server_home['home_name'];
$cli_param_data['PID_FILE'] = "ogp_game_startup.pid";
$os = $remote->what_os();
if( preg_match("/Linux/", $os) )
{
// Wine
if(preg_match("/_win(32|64)?$/", $server_home['game_key']))
{
$home_path_wine = $remote->exec("winepath -w ".$server_home['home_path']);
$home_path_wine = str_replace("\\","\\\\", $home_path_wine);
$home_path_wine = trim($home_path_wine);
$cli_param_data['BASE_PATH'] = $home_path_wine;
$cli_param_data['HOME_PATH'] = $home_path_wine;
$cli_param_data['SAVE_PATH'] = $home_path_wine;
$cli_param_data['OUTPUT_PATH'] = $home_path_wine;
$cli_param_data['USER_PATH'] = $home_path_wine;
}
// Linux
else
{
$cli_param_data['BASE_PATH'] = $server_home['home_path'];
$cli_param_data['HOME_PATH'] = $server_home['home_path'];
$cli_param_data['SAVE_PATH'] = $server_home['home_path'];
$cli_param_data['OUTPUT_PATH'] = $server_home['home_path'];
$cli_param_data['USER_PATH'] = $server_home['home_path'];
}
}
// Windows
elseif( preg_match("/CYGWIN/", $os) )
{
$home_path_win = $remote->exec("cygpath -w ".$server_home['home_path']);
$home_path_win = str_replace("\\","\\\\", $home_path_win);
$home_path_win = trim($home_path_win);
$cli_param_data['BASE_PATH'] = $home_path_win;
$cli_param_data['HOME_PATH'] = $home_path_win;
$cli_param_data['SAVE_PATH'] = $home_path_win;
$cli_param_data['OUTPUT_PATH'] = $home_path_win;
$cli_param_data['USER_PATH'] = $home_path_win;
}
// We do this check because sometimes server does not answer to lgsl check
// done below and is still running.
if ( $remote->is_screen_running(OGP_SCREEN_TYPE_HOME,$server_home['home_id']) === 1 )
{
echo "<p>".get_lang_f('server_already_running')."<a href=?m=gamemanager&amp;p=stop&amp;home_id=".$server_home['home_id'].
"&amp;ip=".$ip."&amp;port=".
$port.">".get_lang_f('already_running_stop_server')."</a></p>";
return;
}
if ($server_xml->protocol == "gameq")
{
$query_port = get_query_port ($server_xml, $port);
}
elseif ($server_xml->protocol == "lgsl")
{
require('protocol/lgsl/lgsl_protocol.php');
$get_ports = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $port, "", "");
$query_port = $get_ports['1'];
}
elseif ($server_xml->protocol == "teamspeak3")
{
$query_port = "10011";
}
$cli_param_data['QUERY_PORT'] = $query_port;
// Check if the game is supported by lgsl or not.
if ( $server_xml->lgsl_query_name )
{
//error_reporting(E_ERROR);
$data = lgsl_query_live((string)$server_xml->lgsl_query_name, $ip, $port, $query_port, $port, "s");
//error_reporting(E_ALL);
if($data['b']['status'] == '1')
{
print_failure("".get_lang_f('error_server_already_running')." <b>$port</b>.");
return;
}
}
$cli_param_data['GAME_TYPE'] = $server_home['mod_key'];
$cli_param_data['CONTROL_PASSWORD'] = $server_home['control_password'];
$start_cmd = "";
// If the template is empty then these are not needed.
if ( $server_xml->cli_template )
{
$start_cmd = $server_xml->cli_template;
if ( $server_xml->cli_params )
{
foreach ( $server_xml->cli_params->cli_param as $cli )
{
// If s is found the param is seperated with space
$add_space = preg_match( "/s/", $cli['options'] ) > 0 ? " " : "";
$cli_value = $cli_param_data[(string) $cli['id'] ];
// If q is found we add quotes around the value.
if ( preg_match( "/q/", $cli['options'] ) > 0 )
{
$cli_value = "\"".$cli_value."\"";
}
$start_cmd = preg_replace( "/%".$cli['id']."%/",
$cli['cli_string'].$add_space.$cli_value, $start_cmd );
}
}
if ( $server_xml->reserve_ports )
{
foreach ( $server_xml->reserve_ports->port as $reserve_port )
{
// If s is found the param is seperated with space
$add_space = preg_match( "/s/", $reserve_port['options'] ) > 0 ? " " : "";
$cli_value = $reserve_port['type'] == "add" ? $server_home['port'] + (string) $reserve_port:
$server_home['port'] - (string) $reserve_port;
// If q is found we add quotes around the value.
if ( preg_match( "/q/", $reserve_port['options'] ) > 0 )
{
$cli_value = "\"".$cli_value."\"";
}
$start_cmd = preg_replace( "/%".$reserve_port['id']."%/",
$reserve_port['cli_string'].$add_space.$cli_value, $start_cmd );
}
}
}
$save_param = array();
if(isset($server_xml->server_params->param))
{
if($param_access_enabled and isset($_POST['params']))
{
foreach($server_xml->server_params->param as $param)
{
$paramKey = (string)$param['key'];
$paramType = (string)$param['type'];
// Get the last saved value of this param or its default value
if (array_key_exists($paramKey, $last_param))
$savedValue = (string)$last_param[$paramKey];
$lockedByAdmin = (property_exists($param, 'access') and $param->access == "admin" and !$isAdmin);
// Dependency fields...
if($paramType == "other_game_server_path" or $paramType == "other_game_server_path_additional")
{
$postKey = $paramKey."{DEPENDS:$paramType}";
if(isset($_POST['params'][$postKey]) and !empty($_POST['params'][$postKey]))
{
$dependsSection = strrpos($postKey, "{DEPENDS");
$realKey = substr($postKey, 0, $dependsSection);
$dependsSection = substr($postKey, $dependsSection);
$dependsKey = str_replace("{DEPENDS:", "", $dependsSection);
$dependsKey = str_replace("}", "", $dependsKey);
$_POST['params'][$paramKey] = $_POST['params'][$postKey];
if($dependsKey == "other_game_server_path_additional" and isset($_POST['params'][$dependsKey]))
$_POST['params'][$paramKey] .= ltrim($_POST['params'][$dependsKey],'/');
}
}
if(isset($_POST['params'][$paramKey]))
{
$processIt = true;
$paramValue = $_POST['params'][$paramKey];
if($lockedByAdmin)
{
if(isset($savedValue))
$paramValue = $savedValue;
else
$processIt = false;
}
$paramKey = isset($realKey) ? $realKey : $paramKey;
// Process the param value for the start command and for the save params unless its locked by admin and there's no saved value.
if($processIt)
processParamValue($param, $server_xml, $paramKey, $paramValue, $save_param, $start_cmd);
}
else// If the parameter wasn't posted (because it may have been disabled due to access param or a sneaky user deleted it to circumvent security)
{
if($lockedByAdmin and isset($savedValue))
processParamValue($param, $server_xml, $paramKey, $savedValue, $save_param, $start_cmd);
}
if ($param['id'] != NULL && $param['id'] != "")
$start_cmd = preg_replace( "/%".$param['id']."%/", '', $start_cmd );
if(isset($realKey))
unset($realKey);
if(isset($savedValue))
unset($savedValue);
}
}
elseif( !$param_access_enabled )
{
foreach($server_xml->server_params->param as $param)
{
$paramKey = (string)$param['key'];
if(isset($last_param[$paramKey]) and strlen((string)$last_param[$paramKey]) != 0)
{
$paramValue = (string)$last_param[$paramKey];
if ($paramKey == $paramValue) // it's a checkbox
{
$new_param = $paramKey;
$save_param[$paramKey] = $paramValue;
}
elseif($param->option == "ns" or $param->options == "ns")
{
$new_param = $paramKey.clean_server_param_value($paramValue, $server_xml->cli_allow_chars);
$save_param[$paramKey] = $paramValue;
}
elseif($param->option == "q" or $param->options == "q"){
$new_param = $paramKey . '"' . clean_server_param_value($paramValue, $server_xml->cli_allow_chars) . '"';
$save_param[$paramKey] = $paramValue;
}
elseif($param->option == "s" or $param->options == "s"){
$new_param = $paramKey . ' ' . clean_server_param_value($paramValue, $server_xml->cli_allow_chars);
$save_param[$paramKey] = $paramValue;
}
else
{
$new_param = $paramKey.' "'.clean_server_param_value($paramValue, $server_xml->cli_allow_chars).'"';
$save_param[$paramKey] = $paramValue;
}
if($param['id'] == NULL or $param['id'] == "")
{
$start_cmd .= ' '.$new_param;
}
else
{
$start_cmd = preg_replace( "/%".$param['id']."%/", $new_param, $start_cmd );
}
}
else
{
if($param['id'] != NULL and $param['id'] != "")
$start_cmd = preg_replace( "/%".$param['id']."%/", '', $start_cmd );
}
}
}
}
$save_param['map'] = $cli_param_data['MAP'];
$save_param['players'] = $cli_param_data['PLAYERS'];
if ( $extra_param_access_enabled )
{
if(isset($_REQUEST['extra_params']) and $_REQUEST['extra_params'] != "")
{
$start_cmd .= " ".str_replace("\\\\", "\\", clean_server_param_value($_REQUEST['extra_params'], $server_xml->cli_allow_chars));
$save_param['extra'] = $_REQUEST['extra_params'];
}
}
else
{
// If user does not have access to modify extra params then we use
// the last param or default set by admins.
$extra = ($last_param !== NULL and array_key_exists('extra', $last_param) and (string)$last_param['extra'] != "") ?
$last_param['extra'] : $server_home['extra_params'];
$start_cmd .= " ".str_replace("\\\\", "\\", clean_server_param_value($extra, $server_xml->cli_allow_chars));
$save_param['extra'] = $extra;
}
//Save the param used to the database
$db->changeLastParam($server_home['home_id'],json_encode($save_param));
echo "<table class='server-starting'>";
echo "<tr><td class='right'>". get_lang("ogp_agent_ip") .
":</td><td class='left'>".$server_home['agent_ip']."</td></tr>\n";
echo "<tr><td class='right'>". get_lang("game_home") .
":</td><td class='left'>".$server_home['home_path']."</td></tr>";
echo "<tr><td class='right'>". get_lang("startup_cpu") .
":</td><td class='left'>".$server_home['cpu_affinity']."</td></tr>\n";
echo "<tr><td class='right'>". get_lang("startup_nice") .
":</td><td class='left'>".$server_home['nice']."</td></tr>";
echo "<tr><td class='right'>". get_lang("startup_params") .
":</td><td colspan='2' style='word-wrap: break-word'>".strip_real_escape_string($start_cmd)."</td></tr>";
echo "</table>";
if($server_xml->replace_texts OR $server_xml->custom_fields)
require_once("modules/gamemanager/cfg_text_replace.php");
// Run pre-start commands
if(isset($server_xml->pre_start) && !empty($server_xml->pre_start)){
$preStart = trim($server_xml->pre_start);
}else{
$preStart = "";
}
// Environment variables
if(isset($server_xml->environment_variables) && !empty($server_xml->environment_variables)){
$envVars = trim($server_xml->environment_variables);
}else{
$envVars = "";
}
// Additional files to lock
if(isset($server_xml->lock_files) && !empty($server_xml->lock_files)){
$lockFiles = trim($server_xml->lock_files);
}else{
$lockFiles = "";
}
if(!empty($lockFiles)){
// Linux only call
if(preg_match("/Linux/", $os)){
$lockedFilesStatus = $remote->lock_additional_home_files($server_home['home_path'], $lockFiles, "lock");
}
}
$start_retval = $remote->universal_start($server_home['home_id'],
$server_home['home_path'],
$server_xml->server_exec_name,
$server_xml->exe_location,
$start_cmd, $port, $ip,
$server_home['cpu_affinity'],
$server_home['nice'],
$preStart,
$envVars,
$server_xml->game_key
);
$db->logger( get_lang("server_started") . " (".$server_home['home_name']." $ip:$port)" );
if ( $start_retval == AGENT_ERROR_NOT_EXECUTABLE )
{
print_failure( get_lang("server_binary_not_executable") );
return;
}
else if ( $start_retval <= 0 )
{
if( $start_retval == -14 )
{
echo "<p>".get_lang_f('server_already_running')."<a href=?m=gamemanager&amp;p=stop&amp;home_id=".$server_home['home_id'].
"&amp;ip=".$ip."&amp;port=".
$port.">".get_lang_f('already_running_stop_server')."</a></p>";
return;
}
else
{
print_failure(get_lang_f('failed_start_server_code',$start_retval));
return;
}
}
echo "<h3>". get_lang("starting_server_settings") .":</h3>";
$firewall_settings = $db->getFirewallSettings($server_home['remote_server_id']);
if ($firewall_settings['status'] == "enable")
{
$ip_ports = $db->getHomeIpPorts($server_home['home_id']);
foreach ($ip_ports as $ip_port)
{
if ($server_xml->protocol == "gameq")
{
$query_port = get_query_port($server_xml, $ip_port['port']);
}
elseif ($server_xml->protocol == "lgsl")
{
require('protocol/lgsl/lgsl_protocol.php');
$get_ports = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $ip_port['port'], "", "");
$query_port = $get_ports['1'];
}
elseif ($server_xml->protocol == "teamspeak3")
{
$query_port = "10011";
}
set_firewall($remote, $firewall_settings, 'allow', $ip_port['port'], $ip_port['ip']);
if(isset($query_port) and $query_port != "" and $query_port != $ip_port['port'])
set_firewall($remote, $firewall_settings, 'allow', $query_port, $ip_port['ip']);
}
}
echo "<table class='list_table'>";
if (isset($server_xml->lgsl_query_name) || isset($server_xml->gameq_query_name))
{
if(isset($server_xml->lgsl_query_name))$query_name = $server_xml->lgsl_query_name;
else $query_name = $server_xml->gameq_query_name;
}
else $query_name = $server_xml->mods->mod['key'];
if ( $server_xml->map_list || $server_xml->maps_location )
{
$map_lc = preg_replace("/[^a-z0-9_]/", "_", strtolower($cli_param_data['MAP']));
//----------+ getting the maps image location.
$maplocation = get_map_path($query_name,$server_xml->mods->mod['key'],$map_lc);
echo "<tr><td rowspan='6' style='width:160px;'><img src='".$maplocation."' /></td><td class='right'>". get_lang("map") .
":</td><td class='left'>".$cli_param_data['MAP']."</td></tr>";
}
else
{
$icon_paths = array("images/icons/".$server_xml->mods->mod['key'].".png",
"images/icons/$query_name.png",
"protocol/lgsl/other/icon_unknown.gif"); // USE UKNOWN ICON
$icon_path = get_first_existing_file($icon_paths);
echo "<tr><td rowspan='6'><img src='".$icon_path."' /></td>";
}
if ( isset($cli_param_data['PLAYERS']) )
{
echo "<tr><td class='right'>". get_lang("max_players") .
":</td><td class='left'>".$cli_param_data['PLAYERS']."</td></tr>";
}
echo "<tr><td class='right'>". get_lang("server_ip_port") .
":</td><td class='left'>$ip:$port</td></tr>";
echo "<tr><td class='right'>". get_lang("game_type") .
":</td><td class='left'>".$server_xml->mods->mod['key']."</td></tr>";
echo "</table>";
print("<p class='note'>". get_lang("starting_server") ."</p>");
global $view;
$view->refresh("?m=gamemanager&amp;p=start&amp;refresh&amp;home_id=".$server_home['home_id']."&amp;ip=".$ip."&amp;port=".$port."&amp;mod_id=".$server_home['mod_id'],3);
return;
}
?>

View file

@ -1,735 +0,0 @@
<?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.
*
*/
$param_access_enabled = preg_match("/p/",$server_home['access_rights']) > 0 ? TRUE : FALSE;
$extra_param_access_enabled = preg_match("/e/",$server_home['access_rights']) > 0 ? TRUE:FALSE;
$last_param = json_decode($server_home['last_param'], True);
$isAdmin = $db->isAdmin($_SESSION['user_id']);
if (!function_exists('processParamValue')) {
function processParamValue(&$param, &$server_xml, $paramKey, $paramValue, &$save_param, &$start_cmd){
if (0 == strlen($paramValue))
return false;
if ($paramKey == $paramValue) // it's a checkbox
{
$new_param = $paramKey;
$save_param[$paramKey] = $paramValue;
}
elseif($param->option == "ns" or $param->options == "ns")
{
$new_param = $paramKey.clean_server_param_value($paramValue, $server_xml->cli_allow_chars);
$save_param[$paramKey] = $paramValue;
}
elseif($param->option == "q" or $param->options == "q"){
$new_param = $paramKey . '"' . clean_server_param_value($paramValue, $server_xml->cli_allow_chars) . '"';
$save_param[$paramKey] = $paramValue;
}
elseif($param->option == "s" or $param->options == "s"){
$new_param = $paramKey . ' ' . clean_server_param_value($paramValue, $server_xml->cli_allow_chars);
$save_param[$paramKey] = $paramValue;
}
else
{
$new_param = $paramKey.' "'.clean_server_param_value($paramValue, $server_xml->cli_allow_chars).'"';
$save_param[$paramKey] = $paramValue;
}
if ($param['id'] == NULL || $param['id'] == "")
{
$start_cmd .= ' '.$new_param;
}
else
{
$start_cmd = preg_replace( "/%".$param['id']."%/", $new_param, $start_cmd );
}
}
}
if( !isset( $_POST['start_server'] ) )
{
$server_exec = clean_path($server_home['home_path']."/".$server_xml->exe_location."/".$server_xml->server_exec_name);
$r = $remote->rfile_exists($server_exec);
if($r === 0)
{
print_failure(get_lang_f('game_exec_not_found',$server_exec));
return;
}
else if($r === -1)
{
print_failure( get_lang("agent_offline") );
return;
}
// If the result is something else than 1 here then there unexpected retval was received.
else if ($r !== 1 )
{
print_failure( get_lang("unexpected_result_libremote") );
return;
}
$ip_info = $db->getHomeIpPorts($server_home['home_id']);
if ( empty($ip_info) )
{
print_failure( get_lang("no_ip_port_pairs_assigned") );
return;
}
echo get_lang_f('select_params_and_start', get_lang("start_server") );
echo "<form action='home.php?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=". $server_home['home_id'] . "-". $server_home['mod_id'] . "-" . $server_home['ip'] . "-" . $server_home['port'] . "' method='post'>\n
<input type='hidden' name='mod_id' value='$server_home[mod_id]' />\n
<input type='hidden' name='home_id' value='$server_home[home_id]' />\n
<input type='hidden' name='remote_server_id' value='".$server_home['remote_server_id']."' />\n
<table class='start-server'>
<tr><td class='right'>". get_lang("ogp_agent_ip") .
":</td><td class='left'>".$server_home['agent_ip']."</td></tr>";
$max_players = $server_home['max_players'];
if ( $max_players > 0 )
{
echo "<tr><td class='right'>". get_lang("max_players") .
":</td><td class='left'>";
$players = array();
for($i = $max_players; $i > 0; $i--)
{
$players["$i"]="$i";
}
echo create_drop_box_from_array($players,'max_players',$last_param['players']);
echo "<span class='info'>(". get_lang("max") .": ".
$max_players.")</span></td></tr>\n";
}
$display_ip = checkDisplayPublicIP($server_home['display_public_ip'],$server_home['ip'] != $server_home['agent_ip'] ? $server_home['ip'] : $server_home['agent_ip']);
echo "<tr><td class='right'>". get_lang("ip_and_port") .
":</td><td class='left'>".$display_ip . ":" . $server_home['port']."<input name='ip_port' type='hidden' value='".$server_home['ip'] . ":" . $server_home['port']."'/></td></tr>";
list($list_type,) = explode(":", $server_xml->map_list);
$map_array = -5;
$maps_found = FALSE;
// use maplist file as primary map location.
if ( $server_xml->map_list )
{
$mapfile = $server_home['home_path']."/".
preg_replace("/mod/",$server_home['mod_key'],$server_xml->map_list);
$read_status = $remote->remote_readfile($mapfile,$map_array);
// If file was found and read successfully then lets seperate the maps.
if ( $read_status == 1 )
{
$map_array = array_filter(preg_split("/\n/",$map_array));
if(!empty($map_array))
$maps_found = "FILE";
}
// Otherwise we have error situation...
else
{
$map_array = $read_status;
}
}
// If we could not find maps from the maps file lets try directory listing
// if possible.
if ( $maps_found === FALSE && $server_xml->maps_location )
{
// replace mod with the modname if nessessary.
$map_path = $server_home['home_path']."/".
preg_replace("/mod/",$server_home['mod_key'],$server_xml->maps_location);
// Then we use the directory.
$map_array = $remote->remote_dirlist($map_path);
// If it is array then we successfully read maps.
if ( is_array($map_array) )
{
$map_array = cleanFilenames($map_array);
$maps_found = "DIR";
}
}
$check_ok = TRUE;
// If there is map list or location defined we should have maps available.
if ( $server_xml->map_list || $server_xml->maps_location )
{
if ( is_array($map_array) )
{
echo "<tr><td class='right'>". get_lang("available_maps") .":</td><td class='left'>\n";
// We remove all lines that start with // because we
// expect those lines to be comments.
$comments = preg_grep( "/^\s*\/\//",$map_array );
$map_array = array_diff( $map_array,$comments );
sort($map_array);
echo create_drop_box_from_array($map_array,'map',$last_param['map']);
echo "</td></tr>";
echo "<tr><td colspan='2' class='info'>". get_lang("maps_read_from") ." ";
if ( $maps_found == "DIR" )
{
echo get_lang("directory") ." ".clean_path($map_path).".";
}
else
{
echo get_lang("file") ." ".clean_path($mapfile).".";
}
echo "</td></tr>\n";
}
else
{
echo "<tr><td colspan='2'>";
print_failure( get_lang("failed_to_read_maps_error_code") .": $map_array");
echo "</td></tr>";
$check_ok = FALSE;
}
}
// Print params if there are any.
if($server_xml->server_params)
{
if (!$param_access_enabled)
echo "<span class='failure info'>". get_lang("no_parameter_access") ."</span>";
foreach($server_xml->server_params->param as $param)
{
renderParam($param, $last_param, $param_access_enabled, $server_home['home_id']);
}
foreach($server_xml->server_params->group as $group)
{
echo "<tr><td><table>";
echo "<tr><th><b>".$group['name']."</b></th></tr>";
foreach($group->param as $param)
{
renderParam($param, $last_param, $param_access_enabled, $server_home['home_id']);
}
echo "</table></td></tr>";
}
}
//if($isAdmin)
//if (isset($server_home['extra_params']))
if (true)
{
echo "<tr><td colspan='2'><h3>". get_lang("extra_parameters") ."</h3>";
if (!$extra_param_access_enabled)
echo "<span class='failure info'>". get_lang("no_extra_param_access") ."</span>";
echo "</td></tr>\n";
//get last used param or get default
if (array_key_exists('extra', $last_param))
$extra_default = $last_param['extra'];
else
$extra_default = $server_home['extra_params'];
echo "<tr><td colspan='2'><input name='extra_params' value=\"".str_replace('"', "&quot;", strip_real_escape_string($extra_default))."\" style='width:99%' ";
if (!$extra_param_access_enabled)
echo 'disabled';
echo "/></td></tr>";
echo "<tr><td colspan='2' class='info'>". get_lang("extra_parameters_info") ."</td></tr>";
}
echo "</table>";
echo get_lang("start_wait_note");
if ( $check_ok )
{
echo "<div class='submit-start' ><input class='btn btn-success' type='submit' name='start_server' value='".
get_lang("start_server") . "&#9654;'' /></div>\n";
}
else
{
print_failure( get_lang("unable_get_info") );
}
echo "</form>";
return;
}
// Starting the server
elseif($server_home['home_id'] == $_POST['home_id'])
{
// Maxplayers on POST compares with maxplayers on DB for security reasons (FORM HACKING)
if( isset( $_POST['max_players'] ) and is_numeric( $_POST['max_players'] ) )
{
if ( $_POST['max_players'] <= $server_home['max_players'] )
$cli_param_data['PLAYERS'] = $_POST['max_players'];
else
{
echo "<p>" . get_lang_f('unsuitable_maxplayers_value_maximum_reachable_number_of_slots_has_been_set') . "</p>";
$cli_param_data['PLAYERS'] = $server_home['max_players'];
}
}
if ( $server_xml->map_list OR $server_xml->maps_location )
$cli_param_data['MAP'] = $_POST['map'];
else
$cli_param_data['MAP'] = "";
$ip_port = $_POST['ip_port'];
list($ip, $port) = explode(":", $ip_port);
if($server_home['ip'] == $ip && $server_home['port'] == $port)
{
$cli_param_data['IP'] = $ip;
$cli_param_data['PORT'] = $server_home['port'];
}
If ( !isset($cli_param_data['IP']) OR !isset($cli_param_data['PORT']) )
{
echo "<h2>" . get_lang_f('ip_port_pair_not_owned') . "</h2>";
return;
}
$cli_param_data['HOSTNAME'] = $server_home['home_name'];
$cli_param_data['PID_FILE'] = "ogp_game_startup.pid";
$os = $remote->what_os();
if( preg_match("/Linux/", $os) )
{
// Wine
if(preg_match("/_win(32|64)?$/", $server_home['game_key']))
{
$home_path_wine = $remote->exec("winepath -w ".$server_home['home_path']);
$home_path_wine = str_replace("\\","\\\\", $home_path_wine);
$home_path_wine = trim($home_path_wine);
$cli_param_data['BASE_PATH'] = $home_path_wine;
$cli_param_data['HOME_PATH'] = $home_path_wine;
$cli_param_data['SAVE_PATH'] = $home_path_wine;
$cli_param_data['OUTPUT_PATH'] = $home_path_wine;
$cli_param_data['USER_PATH'] = $home_path_wine;
}
// Linux
else
{
$cli_param_data['BASE_PATH'] = $server_home['home_path'];
$cli_param_data['HOME_PATH'] = $server_home['home_path'];
$cli_param_data['SAVE_PATH'] = $server_home['home_path'];
$cli_param_data['OUTPUT_PATH'] = $server_home['home_path'];
$cli_param_data['USER_PATH'] = $server_home['home_path'];
}
}
// Windows
elseif( preg_match("/CYGWIN/", $os) )
{
$home_path_win = $remote->exec("cygpath -w ".$server_home['home_path']);
$home_path_win = str_replace("\\","\\\\", $home_path_win);
$home_path_win = trim($home_path_win);
$cli_param_data['BASE_PATH'] = $home_path_win;
$cli_param_data['HOME_PATH'] = $home_path_win;
$cli_param_data['SAVE_PATH'] = $home_path_win;
$cli_param_data['OUTPUT_PATH'] = $home_path_win;
$cli_param_data['USER_PATH'] = $home_path_win;
}
// We do this check because sometimes server does not answer to lgsl check
// done below and is still running.
if ( $remote->is_screen_running(OGP_SCREEN_TYPE_HOME,$server_home['home_id']) === 1 )
{
echo "<p>".get_lang_f('server_already_running')."<a href=?m=gamemanager&amp;p=stop&amp;home_id=".$server_home['home_id'].
"&amp;ip=".$ip."&amp;port=".
$port.">".get_lang_f('already_running_stop_server')."</a></p>";
return;
}
if ($server_xml->protocol == "gameq")
{
$query_port = get_query_port ($server_xml, $port);
}
elseif ($server_xml->protocol == "lgsl")
{
require('protocol/lgsl/lgsl_protocol.php');
$get_ports = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $port, "", "");
$query_port = $get_ports['1'];
}
elseif ($server_xml->protocol == "teamspeak3")
{
$query_port = "10011";
}
$cli_param_data['QUERY_PORT'] = $query_port;
// Check if the game is supported by lgsl or not.
if ( $server_xml->lgsl_query_name )
{
//error_reporting(E_ERROR);
require_once("includes/functions.php");
$query_port = getQueryPortOverridesForGame((string)$server_xml->lgsl_query_name, $ip, $port, $query_port);
$data = lgsl_query_live((string)$server_xml->lgsl_query_name, $ip, $port, $query_port, $port, "s");
//error_reporting(E_ALL);
if($data['b']['status'] == '1' && strpos((string)$server_xml->lgsl_query_name, 'mohaa') === false) // Skip this check for mohaa since the query ports are random
{
print_failure("".get_lang_f('error_server_already_running')." <b>$port</b>.");
return;
}
}
$cli_param_data['GAME_TYPE'] = $server_home['mod_key'];
$cli_param_data['CONTROL_PASSWORD'] = $server_home['control_password'];
$start_cmd = "";
// If the template is empty then these are not needed.
if ( $server_xml->cli_template )
{
$start_cmd = $server_xml->cli_template;
if ( $server_xml->cli_params )
{
foreach ( $server_xml->cli_params->cli_param as $cli )
{
// If s is found the param is seperated with space
$add_space = preg_match( "/s/", $cli['options'] ) > 0 ? " " : "";
$cli_value = $cli_param_data[(string) $cli['id'] ];
// If q is found we add quotes around the value.
if ( preg_match( "/q/", $cli['options'] ) > 0 )
{
$cli_value = "\"".$cli_value."\"";
}
$start_cmd = preg_replace( "/%".$cli['id']."%/",
$cli['cli_string'].$add_space.$cli_value, $start_cmd );
}
}
if ( $server_xml->reserve_ports )
{
foreach ( $server_xml->reserve_ports->port as $reserve_port )
{
// If s is found the param is seperated with space
$add_space = preg_match( "/s/", $reserve_port['options'] ) > 0 ? " " : "";
$cli_value = $reserve_port['type'] == "add" ? $server_home['port'] + (string) $reserve_port:
$server_home['port'] - (string) $reserve_port;
// If q is found we add quotes around the value.
if ( preg_match( "/q/", $reserve_port['options'] ) > 0 )
{
$cli_value = "\"".$cli_value."\"";
}
$start_cmd = preg_replace( "/%".$reserve_port['id']."%/",
$reserve_port['cli_string'].$add_space.$cli_value, $start_cmd );
}
}
}
$save_param = array();
if(isset($server_xml->server_params->param))
{
if($param_access_enabled and isset($_POST['params']))
{
foreach($server_xml->server_params->param as $param)
{
$paramKey = (string)$param['key'];
$paramType = (string)$param['type'];
// Get the last saved value of this param or its default value
if (array_key_exists($paramKey, $last_param))
$savedValue = (string)$last_param[$paramKey];
$lockedByAdmin = (property_exists($param, 'access') and $param->access == "admin" and !$isAdmin);
// Dependency fields...
if($paramType == "other_game_server_path" or $paramType == "other_game_server_path_additional")
{
$postKey = $paramKey."{DEPENDS:$paramType}";
if(isset($_POST['params'][$postKey]) and !empty($_POST['params'][$postKey]))
{
$dependsSection = strrpos($postKey, "{DEPENDS");
$realKey = substr($postKey, 0, $dependsSection);
$dependsSection = substr($postKey, $dependsSection);
$dependsKey = str_replace("{DEPENDS:", "", $dependsSection);
$dependsKey = str_replace("}", "", $dependsKey);
$_POST['params'][$paramKey] = $_POST['params'][$postKey];
if($dependsKey == "other_game_server_path_additional" and isset($_POST['params'][$dependsKey]))
$_POST['params'][$paramKey] .= ltrim($_POST['params'][$dependsKey],'/');
}
}
if(isset($_POST['params'][$paramKey]))
{
$processIt = true;
$paramValue = $_POST['params'][$paramKey];
if($lockedByAdmin)
{
if(isset($savedValue))
$paramValue = $savedValue;
else
$processIt = false;
}
$paramKey = isset($realKey) ? $realKey : $paramKey;
// Process the param value for the start command and for the save params unless its locked by admin and there's no saved value.
if($processIt)
processParamValue($param, $server_xml, $paramKey, $paramValue, $save_param, $start_cmd);
}
else// If the parameter wasn't posted (because it may have been disabled due to access param or a sneaky user deleted it to circumvent security)
{
if($lockedByAdmin and isset($savedValue))
processParamValue($param, $server_xml, $paramKey, $savedValue, $save_param, $start_cmd);
}
if ($param['id'] != NULL && $param['id'] != "")
$start_cmd = preg_replace( "/%".$param['id']."%/", '', $start_cmd );
if(isset($realKey))
unset($realKey);
if(isset($savedValue))
unset($savedValue);
}
}
elseif( !$param_access_enabled )
{
foreach($server_xml->server_params->param as $param)
{
$paramKey = (string)$param['key'];
if(isset($last_param[$paramKey]) and strlen((string)$last_param[$paramKey]) != 0)
{
$paramValue = (string)$last_param[$paramKey];
if ($paramKey == $paramValue) // it's a checkbox
{
$new_param = $paramKey;
$save_param[$paramKey] = $paramValue;
}
elseif($param->option == "ns" or $param->options == "ns")
{
$new_param = $paramKey.clean_server_param_value($paramValue, $server_xml->cli_allow_chars);
$save_param[$paramKey] = $paramValue;
}
elseif($param->option == "q" or $param->options == "q"){
$new_param = $paramKey . '"' . clean_server_param_value($paramValue, $server_xml->cli_allow_chars) . '"';
$save_param[$paramKey] = $paramValue;
}
elseif($param->option == "s" or $param->options == "s"){
$new_param = $paramKey . ' ' . clean_server_param_value($paramValue, $server_xml->cli_allow_chars);
$save_param[$paramKey] = $paramValue;
}
else
{
$new_param = $paramKey.' "'.clean_server_param_value($paramValue, $server_xml->cli_allow_chars).'"';
$save_param[$paramKey] = $paramValue;
}
if($param['id'] == NULL or $param['id'] == "")
{
$start_cmd .= ' '.$new_param;
}
else
{
$start_cmd = preg_replace( "/%".$param['id']."%/", $new_param, $start_cmd );
}
}
else
{
if($param['id'] != NULL and $param['id'] != "")
$start_cmd = preg_replace( "/%".$param['id']."%/", '', $start_cmd );
}
}
}
}
$save_param['map'] = $cli_param_data['MAP'];
$save_param['players'] = $cli_param_data['PLAYERS'];
if ( $extra_param_access_enabled )
{
if(isset($_REQUEST['extra_params']) and $_REQUEST['extra_params'] != "")
{
$start_cmd .= " ".str_replace("\\\\", "\\", clean_server_param_value($_REQUEST['extra_params'], $server_xml->cli_allow_chars));
$save_param['extra'] = $_REQUEST['extra_params'];
}
}
else
{
// If user does not have access to modify extra params then we use
// the last param or default set by admins.
$extra = ($last_param !== NULL and array_key_exists('extra', $last_param) and (string)$last_param['extra'] != "") ?
$last_param['extra'] : $server_home['extra_params'];
$start_cmd .= " ".str_replace("\\\\", "\\", clean_server_param_value($extra, $server_xml->cli_allow_chars));
$save_param['extra'] = $extra;
}
//Save the param used to the database
$db->changeLastParam($server_home['home_id'],json_encode($save_param));
echo "<table class='server-starting'>";
echo "<tr><td class='right'>". get_lang("ogp_agent_ip") .
":</td><td class='left'>".$server_home['agent_ip']."</td></tr>\n";
echo "<tr><td class='right'>". get_lang("game_home") .
":</td><td class='left'>".$server_home['home_path']."</td></tr>";
echo "<tr><td class='right'>". get_lang("startup_cpu") .
":</td><td class='left'>".$server_home['cpu_affinity']."</td></tr>\n";
echo "<tr><td class='right'>". get_lang("startup_nice") .
":</td><td class='left'>".$server_home['nice']."</td></tr>";
echo "<tr><td class='right'>". get_lang("startup_params") .
":</td><td colspan='2' style='word-wrap: break-word'>".strip_real_escape_string($start_cmd)."</td></tr>";
echo "</table>";
if($server_xml->replace_texts OR $server_xml->custom_fields)
require_once("modules/gamemanager/cfg_text_replace.php");
// Run pre-start commands
if(isset($server_xml->pre_start) && !empty($server_xml->pre_start)){
$preStart = trim($server_xml->pre_start);
}else{
$preStart = "";
}
// Environment variables
if(isset($server_xml->environment_variables) && !empty($server_xml->environment_variables)){
$envVars = trim($server_xml->environment_variables);
}else{
$envVars = "";
}
// Additional files to lock
if(isset($server_xml->lock_files) && !empty($server_xml->lock_files)){
$lockFiles = trim($server_xml->lock_files);
}else{
$lockFiles = "";
}
if(!empty($lockFiles)){
// Linux only call
if(preg_match("/Linux/", $os)){
$lockedFilesStatus = $remote->lock_additional_home_files($server_home['home_path'], $lockFiles, "lock");
}
}
$start_retval = $remote->universal_start($server_home['home_id'],
$server_home['home_path'],
$server_xml->server_exec_name,
$server_xml->exe_location,
$start_cmd, $port, $ip,
$server_home['cpu_affinity'],
$server_home['nice'],
$preStart,
$envVars,
$server_xml->game_key,
(isset( $server_xml->console_log ) ? $server_xml->console_log : "")
);
$db->logger( get_lang("server_started") . " (".$server_home['home_name']." $ip:$port)" );
if ( $start_retval == AGENT_ERROR_NOT_EXECUTABLE )
{
print_failure( get_lang("server_binary_not_executable") );
return;
}
else if ( $start_retval <= 0 )
{
if( $start_retval == -14 )
{
echo "<p>".get_lang_f('server_already_running')."<a href=?m=gamemanager&amp;p=stop&amp;home_id=".$server_home['home_id'].
"&amp;ip=".$ip."&amp;port=".
$port.">".get_lang_f('already_running_stop_server')."</a></p>";
return;
}
else
{
print_failure(get_lang_f('failed_start_server_code',$start_retval));
return;
}
}
echo "<h3>". get_lang("starting_server_settings") .":</h3>";
$firewall_settings = $db->getFirewallSettings($server_home['remote_server_id']);
if ($firewall_settings['status'] == "enable")
{
$ip_ports = $db->getHomeIpPorts($server_home['home_id']);
foreach ($ip_ports as $ip_port)
{
if ($server_xml->protocol == "gameq")
{
$query_port = get_query_port($server_xml, $ip_port['port']);
}
elseif ($server_xml->protocol == "lgsl")
{
require('protocol/lgsl/lgsl_protocol.php');
$get_ports = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $ip_port['port'], "", "");
$query_port = $get_ports['1'];
}
elseif ($server_xml->protocol == "teamspeak3")
{
$query_port = "10011";
}
set_firewall($remote, $firewall_settings, 'allow', $ip_port['port'], $ip_port['ip']);
if(isset($query_port) and $query_port != "" and $query_port != $ip_port['port'])
set_firewall($remote, $firewall_settings, 'allow', $query_port, $ip_port['ip']);
}
}
echo "<table class='list_table'>";
if (isset($server_xml->lgsl_query_name) || isset($server_xml->gameq_query_name))
{
if(isset($server_xml->lgsl_query_name))$query_name = $server_xml->lgsl_query_name;
else $query_name = $server_xml->gameq_query_name;
} elseif ($server_xml->protocol == "teamspeak3") {
$query_name = 'ts3';
} else $query_name = $server_xml->mods->mod['key'];
if ( $server_xml->map_list || $server_xml->maps_location )
{
$map_lc = preg_replace("/[^a-z0-9_]/", "_", strtolower($cli_param_data['MAP']));
//----------+ getting the maps image location.
$maplocation = get_map_path($query_name,$server_xml->mods->mod['key'],$map_lc);
echo "<tr><td rowspan='6' style='width:160px;'><img src='".$maplocation."' /></td><td class='right'>". get_lang("map") .
":</td><td class='left'>".$cli_param_data['MAP']."</td></tr>";
}
else
{
$icon_paths = array("images/icons/".$server_xml->mods->mod['key'].".png",
"images/icons/$query_name.png",
"protocol/lgsl/other/icon_unknown.gif"); // USE UKNOWN ICON
$icon_path = get_first_existing_file($icon_paths);
echo "<tr><td rowspan='6'><img src='".$icon_path."' /></td>";
}
if ( isset($cli_param_data['PLAYERS']) )
{
echo "<tr><td class='right'>". get_lang("max_players") .
":</td><td class='left'>".$cli_param_data['PLAYERS']."</td></tr>";
}
echo "<tr><td class='right'>". get_lang("server_ip_port") .
":</td><td class='left'>$ip:$port</td></tr>";
echo "<tr><td class='right'>". get_lang("game_type") .
":</td><td class='left'>".$server_xml->mods->mod['key']."</td></tr>";
echo "</table>";
print("<p class='note'>". get_lang("starting_server") ."</p>");
global $view;
$view->refresh("?m=gamemanager&amp;p=start&amp;refresh&amp;home_id=".$server_home['home_id']."&amp;ip=".$ip."&amp;port=".$port."&amp;mod_id=".$server_home['mod_id'],3);
return;
}
?>

View file

@ -1,120 +0,0 @@
<?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 = "Game manager";
$module_version = "1.33";
$db_version = 9;
$module_required = TRUE;
$module_menus = array( array( 'subpage' => 'game_monitor', 'name'=>'Game Monitor', 'group'=>'user' ) );
$module_access_rights = array('u' => 'allow_updates', 'p' => 'allow_parameter_usage', 'e' => 'allow_extra_params', 'c' => 'allow_custom_fields');
$install_queries[0] = array(
"DROP TABLE IF EXISTS `".OGP_DB_PREFIX."home_ip_ports`;",
"CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."home_ip_ports` (
`ip_id` int(11) NOT NULL,
`port` int(11) NOT NULL,
`home_id` int(11) NOT NULL,
PRIMARY KEY (`ip_id`,`port`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;",
"DROP TABLE IF EXISTS ".OGP_DB_PREFIX."server_homes",
"CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."server_homes` (
`home_id` int(50) NOT NULL auto_increment,
`remote_server_id` int(11) NOT NULL,
`user_id_main` int(11) NOT NULL,
`home_path` varchar(500) NOT NULL,
`home_cfg_id` int(50) NOT NULL,
`home_name` varchar(500) NOT NULL,
`control_password` VARCHAR( 128 ) NULL,
`ftp_password` VARCHAR( 128 ) NULL,
`last_param` LONGTEXT NULL,
PRIMARY KEY (`home_id`),
UNIQUE KEY remote_server_id (remote_server_id,home_path)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;",
"DROP TABLE IF EXISTS ".OGP_DB_PREFIX."rcon_presets;",
"CREATE TABLE ".OGP_DB_PREFIX."rcon_presets (
`preset_id` int(50) NOT NULL auto_increment,
`name` varchar(20) NOT NULL,
`command` varchar(100) NOT NULL,
`home_cfg_id` int(50) NOT NULL,
`mod_cfg_id` int(50) NOT NULL,
PRIMARY KEY (`preset_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;",
"DROP TABLE IF EXISTS ".OGP_DB_PREFIX."game_mods",
"CREATE TABLE IF NOT EXISTS ".OGP_DB_PREFIX."game_mods (
`mod_id` int(50) NOT NULL auto_increment,
`home_id` int(255) NOT NULL,
`mod_cfg_id` int(11) NOT NULL,
`max_players` smallint(3) default NULL,
`extra_params` varchar(255) default NULL,
`cpu_affinity` varchar(2) default NULL,
`nice` smallint(3) default '0',
`precmd` TEXT,
`postcmd` TEXT,
PRIMARY KEY (mod_id),
UNIQUE KEY home_id (home_id,mod_cfg_id)
) ENGINE=MyISAM;");
$install_queries[1] = array(
"ALTER TABLE `".OGP_DB_PREFIX."server_homes` ADD `ftp_login` varchar(32) NULL;",
"ALTER TABLE `".OGP_DB_PREFIX."server_homes` ADD `ftp_status` int(11) NOT NULL DEFAULT '0';");
$install_queries[2] = array(
"DROP TABLE IF EXISTS `".OGP_DB_PREFIX."status_cache`",
"CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."status_cache` (
`date_timestamp` char(16) NOT NULL,
`ip_id` char(3) NOT NULL,
`port` char(6) NOT NULL,
`server_status_cache` longtext NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
$install_queries[3] = array(
"ALTER TABLE `".OGP_DB_PREFIX."server_homes` ADD `custom_fields` LONGTEXT NULL;");
$install_queries[4] = array(
"ALTER TABLE `".OGP_DB_PREFIX."home_ip_ports` ADD `force_mod_id` int(11) NOT NULL DEFAULT '0';");
$install_queries[5] = array(
"TRUNCATE `".OGP_DB_PREFIX."status_cache`;");
$install_queries[6] = array(
"ALTER TABLE `".OGP_DB_PREFIX."server_homes` ADD `server_expiration_date` VARCHAR(21) NOT NULL default 'X';");
$install_queries[7] = array(
"ALTER TABLE `".OGP_DB_PREFIX."server_homes` drop index `remote_server_id`;"
);
$install_queries[8] = array(
"ALTER TABLE `".OGP_DB_PREFIX."server_homes` ADD `home_user_order` INT NOT NULL default 99999;");
// Increase default column sizes
$install_queries[9] = array(
"ALTER TABLE `".OGP_DB_PREFIX."server_homes` MODIFY COLUMN `home_path` VARCHAR(500);",
"ALTER TABLE `".OGP_DB_PREFIX."server_homes` MODIFY COLUMN `home_name` VARCHAR(500);",
"ALTER TABLE `".OGP_DB_PREFIX."server_homes` MODIFY COLUMN `control_password` VARCHAR(128);",
"ALTER TABLE `".OGP_DB_PREFIX."server_homes` MODIFY COLUMN `ftp_password` VARCHAR(128);");
?>

View file

@ -1,120 +0,0 @@
<?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_buttons = array(
"<a class='monitorbutton' href='?m=gamemanager&amp;p=log&amp;home_id-mod_id-ip-port=".$server_home['home_id']."-".$server_home['mod_id']."-".$server_home['ip']."-".$server_home['port']."'>
<img src='" . check_theme_image("images/log.png") . "' title='". get_lang("view_log") ."'>
<span>". get_lang("view_log") ."</span>
</a>",
"<a class='monitorbutton size' data-home_id='".$server_home['home_id']."'>
<img src='" . check_theme_image("images/file_size.png") . "' title='". get_lang("get_size") ."'>
<span>". get_lang("get_size") ."</span>
</a>"
);
if (preg_match("/u/",$server_home['access_rights']))
{
$hasSteamAutoUpdate = false;
$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;
}
}
// 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'] )
{
$module_buttons[] = "<a class='monitorbutton' href='?m=gamemanager&amp;p=update&amp;home_id=".$server_home['home_id']."&amp;mod_id=".$server_home['mod_id']."&amp;master_server_home_id=".$master_server_home_id."&amp;update=update'>
<img src='" . check_theme_image("images/master.png") . "' title='". get_lang("update_from_local_master_server") ."'>
<span>". get_lang("update_from_local_master_server") ."</span>
</a>";
}
//$module_buttons[] = "<a class='monitorbutton' href='?m=gamemanager&amp;p=update&amp;home_id=".$server_home['home_id']."&amp;mod_id=".$server_home['mod_id']."&amp;update=update'>
$module_buttons[] = "<a class='monitorbutton' href='javascript:confirmarUpdateSteam();'>
<img src='" . check_theme_image("images/steam.png") ."' title='". get_lang("install_update_manually") ."'>
<span>". get_lang("install_update_steam") ."</span>
</a>
<script>
function confirmarUpdateSteam(){
if (confirm('If you continue, you will overwrite any configuration files. BACKUP IMPORTANT FILES!')) {
window.location.href = '?m=gamemanager&p=update&home_id=".$server_home['home_id']."&mod_id=".$server_home['mod_id']."&update=update';
}
}
</script>";
$hasSteamAutoUpdate = true;
}
// In other cases manual update is provided.
if( $server_xml->installer == "manual" )
{
$module_buttons[] = "<a class='monitorbutton' href='?m=gamemanager&amp;p=update_manual&amp;home_id=".$server_home['home_id']."&amp;mod_id=".$server_home['mod_id']."&amp;update=update'>
<img src='" . check_theme_image("images/install.png") . "' title='". get_lang("install_update_manual") ."'>
<span>". get_lang("install_update_manual") ."</span>
</a>";
}
// In other cases rsync update is provided.
if( $server_xml->installer == "rsync" )
{
$sync_name = $server_xml->game_key;
$sync_list = @file("modules/gamemanager/rsync.list", FILE_IGNORE_NEW_LINES);
if ( in_array($sync_name, $sync_list) OR ($master_server_home_id != FALSE and $master_server_home_id != $server_home['home_id']) )
{
$module_buttons[] = "<a class='monitorbutton' href='?m=gamemanager&amp;p=rsync_install&amp;home_id=".$server_home['home_id']."&amp;mod_id=".$server_home['mod_id']."&amp;update=update'>
<img src='" . check_theme_image("images/rsync.png") . "' title='". rsync_install ."'>
<span>". get_lang("rsync_install") ."</span>
</a>";
}
}
/*
$module_buttons[] = "<a class='monitorbutton getAPILinks' hassteam='" . ($hasSteamAutoUpdate ? 'true' : 'false') . "' hasrcon='" . ($server_xml->control_protocol || ($server_xml->lgsl_query_name and $server_xml->lgsl_query_name == "7dtd") || ($server_xml->gameq_query_name and $server_xml->gameq_query_name == "minecraft") ? 'true' : 'false') . "' copyfail='" . get_lang("auto_update_copy_me_fail") . "' copysuccess='" . get_lang("auto_update_copy_me_success") . "' autoupdatetext='" . get_lang("auto_update_title_popup") . "' copyme='" . get_lang("auto_update_copy_me") . "' token='".$db->getApiToken($_SESSION['user_id'])."' ip='".$server_home['ip']."' port='".$server_home['port']."' modkey='".$server_home['mod_key']."' panelurl='" . getOGPSiteURL() . "'>
<img src='" . check_theme_image("images/auto_update.png") . "' title='". get_lang("show_api_actions") . "'>
<span>". get_lang("show_api_actions") . "</span>
</a>";
*/
}
if($_SESSION['users_role'] == "admin")
{
if ( ( $server_xml->control_protocol and preg_match("/^(rcon|lcon|rcon2|armabe)$/" ,$server_xml->control_protocol) ) OR
( $server_xml->gameq_query_name and $server_xml->gameq_query_name == 'minecraft' ) )
{
$module_buttons[] = "<a class='monitorbutton' href='home.php?m=gamemanager&amp;p=rcon_presets&amp;home_id=".$server_home['home_id']."&amp;mod_id=".$server_home['mod_id']."'>
<img src='" . check_theme_image("images/rcon_preset.png") . "' title='".get_lang("rcon_presets")."'>
<span>".get_lang("rcon_presets")."</span>
</a>";
}
}
?>

View file

@ -1,14 +0,0 @@
<navigation>
<page key="game_monitor" file="server_monitor.php" access="admin,user,subuser" />
<page key="start" file="start_server.php" access="admin,user,subuser" />
<page key="stop" file="stop_server.php" access="admin,user,subuser" />
<page key="restart" file="restart_server.php" access="admin,user,subuser" />
<page key="update" file="update_server.php" access="admin,user,subuser" />
<page key="update_manual" file="update_server_manual.php" access="admin,user,subuser" />
<page key="rsync_install" file="rsync_install.php" access="admin,user,subuser" />
<page key="log" file="view_server_log.php" access="admin,user,subuser" />
<page key="rcon_presets" file="rcon_presets.php" access="admin" />
<page key="upload_map_image" file="upload_map_image.php" access="admin" />
<!-- Refreshed PHP Files -->
<page key="ref_servermonitor" file="ref_servermonitor.php" access="admin,user,subuser" />
</navigation>

View file

@ -1,297 +0,0 @@
<table>
<tr>
<td>
<?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 send_command($command, $remote, $server_xml, $home_info, $home_id, $ip, $port )
{
if( $server_xml->gameq_query_name and $server_xml->gameq_query_name == "minecraft" )
{
include_once("MinecraftRcon.class.php");
$server_properties_file = clean_path($home_info['home_path']."/server.properties");
$retval = $remote->remote_readfile($server_properties_file, $data);
if($retval == 1 and strpos($data, 'rcon.port') !== FALSE)
{
$server_properties = parse_ini_string($data);
$rcon_port = $server_properties['rcon.port'];
}
else
{
$rcon_port = $port+10;
}
$rcon = new MinecraftRcon;
if( $rcon->Connect($ip, $rcon_port, $home_info['control_password']) )
{
$return = $rcon->Command($command);
if($return)
return $return;
else
return FALSE;
$rcon->Disconnect();
}
else
return get_lang("need_set_remote_pass") . " " . $home_info['home_name'] . " " . get_lang("before_sending_rcon_com");
}
elseif( $server_xml->lgsl_query_name and $server_xml->lgsl_query_name == "7dtd" )
{
$query_port = $port + 1;
$return = $remote->exec('exec 3<>/dev/tcp/'.$ip.'/'. $query_port .' && echo -en "'.$command.'\\nexit\\n" >&3 && cat <&3');
if(preg_match("/Connected with 7DTD server/",$return))
return $return;
else
return FALSE;
}
else
{
$remote_retval = $remote->remote_send_rcon_command( $home_id, $ip, $port, $server_xml->control_protocol, $home_info['control_password'],$server_xml->control_protocol_type,$command,$return);
if ( $remote_retval === 1 )
return $return;
elseif ( $remote_retval === -10 )
return get_lang("need_set_remote_pass") . " " . $home_info['home_name'] . " " . get_lang("before_sending_rcon_com");
else
return FALSE;
}
}
if(isset($_POST['command']) and !is_array($_POST['command']))
$_POST['command'] = array( '0' => stripcslashes($_POST['command']) );
elseif(isset($_POST['base64_command']))
{
foreach($_POST['base64_command'] as $key => $command)
{
$_POST['command'][$key] = isset($_POST['input']) ? str_replace("%input%", $_POST['input'], base64_decode($command)) : base64_decode($command);
}
}
$presets = $db->getRconPresets($home_info['home_cfg_id'],$home_info['mods'][$mod_id]['mod_cfg_id']);
if($presets > 0)
{
echo '<form action="" method="post">'.
get_lang("rcon_presets") . ':
<select onchange="this.form.submit()" name="command" >
<option></option>\n';
foreach ($presets as $preset)
{
echo '<option value="'.$preset['command'].'" >'.$preset['name'].'</option>\n';
}
echo '<input type="hidden" name="remote_send_rcon_command" value="">';
echo '</form>';
}
?>
</td>
</tr>
</table>
<table class="center" >
<tr>
<td>
<?php echo get_lang("rcon_command_title"); ?></td>
<td>
<form method="post">
<input class="rcon" type="text" name="command" size="200" style="width:98%;" value='<?php
if( isset($_POST['command']) )
echo htmlentities($_POST['command'][0]);
?>' />
</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']))
{
$response = "";
foreach($_POST['command'] as $command)
{
$ret = send_command($command, $remote, $server_xml, $home_info, $home_id, $ip, $port );
if(!$ret)
{
$response = FALSE;
break;
}
else
$response .= $ret;
}
if($response)
{
echo "<div class='bloc' ><h4>" . get_lang("rcon_command_title") . ": [" . htmlentities(implode(" | ", $_POST['command'])) . "] " .
get_lang("has_sent_to") . " " . $home_info['home_name'] . "</h4><xmp style='overflow:auto;' >" .
$response . "</xmp></div>";
}
}
if($server_xml->list_players_command)
{
if(isset($_GET['view_player_commands']))
{
$response = send_command($server_xml->list_players_command, $remote, $server_xml, $home_info, $home_id, $ip, $port );
if($response and $response != "")
{
preg_match_all($server_xml->player_info_regex, $response, $matches);
if(!empty($matches[0]))
{
$data = array();
$infos = array();
$commands = array();
foreach($server_xml->player_info->index as $index )
{
$i = 0;
$key = (string)$index['key'];
$name = (string)$index;
$infos[] = $name;
foreach($matches[$key] as $info)
{
$data[$i][$name] = $info;
$i++;
}
}
foreach($server_xml->player_commands->command as $command)
{
$name = (string)$command['key'];
$commands[] = $name;
$default = (string)$command->default ? (string)$command->default : "";
$options = array();
if($command->option)
{
foreach($command->option as $option)
$options[(string)$option] = (string)$option['value'];
}
$actions = array();
$replacements = array();
foreach($command->string as $action)
{
preg_match_all("#%(\w*)%#", (string)$action, $replace);
$replacements[] = $replace;
$actions[] = (string)$action;
}
$replaced_actions = array();
for($id = 0; $id < $i; $id++)
{
foreach($actions as $key => $action)
{
foreach($replacements[$key][1] as $index)
{
if(isset($data[$id][$index]) and $index != 'input')
{
$action = str_replace("%$index%", $data[$id][$index], $action);
}
}
$replaced_actions[$key] = base64_encode($action);
}
$data[$id]['commands'][$name] = array('actions' => $replaced_actions,
'type' => (string)$command['type'],
'default' => $default,
'options' => $options);
}
unset($actions);
}
$headers = array_merge( $infos, $commands );
$player_actions_table = "<table class='center'>\n<thead>\n<tr>";
foreach($headers as $name)
{
$player_actions_table .= "<th>$name</th>";
}
$player_actions_table .= "</tr>\n</thead>\n<tbody>\n";
foreach($data as $player)
{
$player_actions_table .= "<tr>\n";
foreach($infos as $info)
{
$player_actions_table .= "<td>".htmlentities($player[$info])."</td>\n";
}
foreach($commands as $command)
{
$actions = $player['commands'][$command]['actions'];
$type = $player['commands'][$command]['type'];
$default = $player['commands'][$command]['default'];
$options = $player['commands'][$command]['options'];
/* echo "<xmp>";
print_r($player['commands'][$command]['actions']);
echo "</xmp><br>"; */
$player_actions_table .= "<td>\n<form method='post'>\n";
if($type == 'hidden')
{
foreach($actions as $key => $action)
$player_actions_table .= "<input type='hidden' name='base64_command[$key]' value='$action'/>\n";
}
elseif($type == 'text')
{
foreach($actions as $key => $action)
$player_actions_table .= "<input type='hidden' name='base64_command[$key]' value='$action'/>\n";
$player_actions_table .= "<input type='text' name='input' value='$default'/>\n";
}
elseif($type == 'select')
{
foreach($actions as $key => $action)
$player_actions_table .= "<input type='hidden' name='base64_command[$key]' value='$action'/>\n";
$player_actions_table .= "<select name='input'>";
foreach($options as $key => $value)
{
$player_actions_table .= "<option value='$value' >$key</option>";
}
$player_actions_table .= "<select name='input'>";
}
$player_actions_table .= "<input type='submit' name='remote_send_rcon_command' value='$command'/>\n".
"</form>\n</td>\n";
}
$player_actions_table .= "</tr>\n";
}
$player_actions_table .= "</tbody>\n</table>\n";
echo $player_actions_table;
}
else
print_failure( get_lang("no_online_players") );
}
echo "<form method='GET' >".
"<input type='hidden' name='m' value='gamemanager' />".
"<input type='hidden' name='p' value='log' />".
"<input type='hidden' name='home_id-mod_id-ip-port' value='" . $_GET['home_id-mod_id-ip-port'] . "' />";
if(isset($_GET['setInterval']))
echo "<input type='hidden' name='setInterval' value='" . $_GET['setInterval'] . "' />";
if(isset($_GET['size']))
echo "<input type='hidden' name='size' value='" . $_GET['size'] . "' />";
echo "<input type='submit' name='hide_player_commands' value='" . get_lang("hide_player_commands") . "' />".
"</form>";
}
else
{
echo "<form method='GET' >".
"<input type='hidden' name='m' value='gamemanager' />".
"<input type='hidden' name='p' value='log' />".
"<input type='hidden' name='home_id-mod_id-ip-port' value='" . $_GET['home_id-mod_id-ip-port'] . "' />";
if(isset($_GET['setInterval']))
echo "<input type='hidden' name='setInterval' value='" . $_GET['setInterval'] . "' />";
if(isset($_GET['size']))
echo "<input type='hidden' name='size' value='" . $_GET['size'] . "' />";
echo "<input type='submit' name='view_player_commands' value='" . get_lang("view_player_commands") . "' />".
"</form>";
}
}
?>

View file

@ -1,145 +0,0 @@
<?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 $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 = $current_mod_info['home_cfg_id'];
$mod_cfg_id = $current_mod_info['mod_cfg_id'];
if($home_cfg_id === null && $mod_cfg_id === null){
print_failure(get_lang('invalid_game_mod_id'));
return;
}
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&amp;p=game_monitor&amp;home_id=".$home_id."'><< ".get_lang('back')."</a></td></tr></table>";
}
}
?>

View file

@ -1,140 +0,0 @@
<?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('modules/gamemanager/home_handling_functions.php');
require_once("modules/config_games/server_config_parser.php");
require_once('includes/lib_remote.php');
function exec_ogp_module()
{
global $db;
$home_id = $_REQUEST['home_id'];
$mod_id = $_REQUEST['mod_id'];
// Is admin ??
$isAdmin = $db->isAdmin( $_SESSION['user_id'] );
if( $isAdmin )
$server_home = $db->getGameHome($home_id);
else
$server_home = $db->getUserGameHome($_SESSION['user_id'],$home_id);
if ( !$server_home )
return;
$port = $_REQUEST['port'];
$ip = $_REQUEST['ip'];
$server_home['ip'] = $ip;
$server_home['port'] = $port;
$stats_players = 0;
$stats_maxplayers = 0;
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$server_home['home_cfg_file']);
$xml_installer = $server_xml->installer;
$mod_name = $server_home['mods'][$mod_id]['mod_name'];
$mod_key = $server_home['mods'][$mod_id]['mod_key'];
if (strtolower($mod_name) == "none")
$mod = $mod_key;
else
$mod = $mod_name;
if ($server_xml->protocol == "gameq")
$query_name = $server_xml->gameq_query_name;
elseif ($server_xml->protocol == "lgsl")
$query_name = $server_xml->lgsl_query_name;
else
$query_name = $mod; // If query name does not exist use mod key instead.
// Check if the screen running the server is running.
if ($server_xml->protocol == "gameq")
{
require('protocol/GameQ/functions.php');
require_once('protocol/GameQ/GameQMonitor.php');
}
else if ($server_xml->protocol == "lgsl")
{
require('protocol/lgsl/functions.php');
require_once('protocol/lgsl/LGSLMonitor.php');
}
else if ($server_xml->protocol == "teamspeak3")
{
require_once('protocol/TeamSpeak3/TS3Monitor.php');
}
else
{
// This is here because some servers are not supported by LGSL/GameQ or
// because we do not have proper support for them yet.
// With properly supported games this should not needed.
// (In a perfect world no one would need an insurance.)
$status = "online";
$map = $status;
$maplocation = get_map_path($query_name,$mod,$map);
@$notifications .= get_lang("query_protocol_not_supported");
}
$map_image_upload = '<br><button class="upload-image" id="'.$home_id.'" data-map="'.$map.'" data-mod_id="'.$mod_id.'" onClick="uploadMapImg(this);" >'. get_lang("upload_map_image") .'</button>';
@$map_icon = "<img class='mapicon' src='$maplocation'/>";
@$currentmap = $map;
//Properties for Specific Status
if($status == "half" || $status == "online")
{
if($status == "online")
{
$onlineT = "<div class='map-icon' >";
$onlineT .= "$map_icon";
if($isAdmin)
$onlineT .= "$map_image_upload";
$onlineT .= "</div>";
$onlineT .= "<div class='server-info' >";
@$onlineT .= get_lang("hostname") .": <marquee class='hostname'>" . htmlentities($name) . "</marquee><br />";
@$onlineT .= get_lang("current_map") . ": " . ((isset($mapRaw) && !empty($mapRaw)) ? htmlentities($mapRaw) : $currentmap);
$onlineT .= "</div>";
}
else if($status == "half")
{
@$notifications .= get_lang("failed_querying_server");
}
$remote_server_id = $server_home['remote_server_id'];
$rserver = $db->getRemoteServerById($remote_server_id);
$remote = new OGPRemoteLibrary($rserver['agent_ip'], $rserver['agent_port'], $rserver['encryption_key'], $rserver['timeout']);
$startup_file_exists = $remote->rfile_exists( "startups/".$ip."-".$port ) === 1;
$SrvCtrl = "<table class='srvctrl'><tr><td style='border:0;text-align:center;background:transparent'><a href='?m=gamemanager&amp;p=restart&amp;home_id=".
$home_id."&amp;mod_id=".$mod_id."&amp;ip=".$ip."&amp;port=".$port.
"'><img src='" . check_theme_image("images/restart.png") . "' width='64' border='0' alt='". get_lang("restart_server") ."' /><br><b>". get_lang("restart_server") .
"</b></a></td><td style='border:0;text-align:center;background:transparent'><a href='?m=gamemanager&amp;p=stop&amp;home_id=".
$home_id."&amp;mod_id=".$mod_id."&amp;ip=".$ip."&amp;port=".$port."'><img src='" . check_theme_image("images/stop.png") . "' width='64' border='0' alt='".
get_lang("stop_server") ."' /><br><b>". get_lang("stop_server") .
"</b></a></td></tr></table>";
}
//Echo them all
echo "<div class='monitor-1'>".@$onlineT.@$halfT.@$offlineT."</div>";
if( $server_xml->protocol != "teamspeak3" OR ($startup_file_exists and $server_xml->protocol == "teamspeak3") )
echo "<div class='monitor-2 bloc'>".@$SrvCtrl."</div>";
if(isset($player_list))
echo "<div class='monitor-3'>".@$player_list."</div>";
if(isset($notifications))
echo "<div class='monitor-3 bloc'>".@$notifications."</div>";
}
?>

View file

@ -1,285 +0,0 @@
<?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('home_handling_functions.php');
require_once("modules/config_games/server_config_parser.php");
function exec_ogp_module() {
global $view,$db;
$ip = $_REQUEST['ip'];
$port = $_REQUEST['port'];
$home_id = $_REQUEST['home_id'];
$mod_id = $_REQUEST['mod_id'];
$user_id = $_SESSION['user_id'];
$isAdmin = $db->isAdmin($user_id);
if($isAdmin)
$home_info = $db->getGameHome($home_id);
else
$home_info = $db->getUserGameHome($user_id,$home_id);
foreach($home_info['mods'][$mod_id] as $key => $value)
{
$home_info[$key] = $value;
}
require_once('includes/lib_remote.php');
$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'],$home_info['timeout']);
$os = $remote->what_os();
if ( $home_info === FALSE )
{
print_failure(get_lang('no_rights_to_stop_server'));
return;
}
echo "<h2>";
echo empty($home_info['home_name']) ? get_lang('not_available') : htmlentities($home_info['home_name']);
echo "</h2>";
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']);
if ( !$server_xml )
{
echo create_back_button("gamemanager","game_monitor");
return;
}
$rserver = $db->getRemoteServerById($home_info['remote_server_id']);
if ( empty($rserver) )
{
print_failure("".get_lang('not_found_server')." ".$home_info['remote_server_id'].".");
}
else
{
if(isset($_REQUEST['refresh']))
{
if( isset( $server_xml->console_log ) )
{
$log_path = preg_replace("/mod/", $home_info['mods'][$mod_id]['mod_key'], $server_xml->console_log);
$log_retval = $remote->remote_readfile( $home_info['home_path'].'/'.$log_path, $home_log );
}
else
{
$log_retval = $remote->get_log(OGP_SCREEN_TYPE_HOME,
$home_id,
clean_path($home_info['home_path']."/".$server_xml->exe_location),
$home_log);
}
function getLastLines($string, $n = 1) {
$lines = explode("\n", $string);
$lines = array_slice($lines, -$n);
return implode("\n", $lines);
}
$home_log = getLastLines($home_log, 40);
if ($log_retval > 0)
{
if ( $log_retval == 2 )
print_failure(get_lang('server_not_running_log_found'));
echo "<pre style='background:black;color:white;'>".$home_log."</pre>";
if ($log_retval == 2)
return;
}
else
{
print_failure(get_lang_f('unable_to_get_log',$log_retval));
}
// If game is not supported by lgsl we skip the lgsl checks and
// assume successfull start.
if ( $home_info['use_nat'] == 1 )
$query_ip = $home_info['agent_ip'];
else
$query_ip = $ip;
$running = TRUE;
if ( $server_xml->lgsl_query_name )
{
require('protocol/lgsl/lgsl_protocol.php');
$get_q_and_s = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $port, "", "");
//Connection port
$c_port = $get_q_and_s['0'];
//query port
$q_port = $get_q_and_s['1'];
//software port
$s_port = $get_q_and_s['2'];
$data = lgsl_query_live((string)$server_xml->lgsl_query_name, $query_ip, $c_port, $q_port, $s_port, "sa");
if ( $data['b']['status'] == "0" )
{
$running = FALSE;
}
}
elseif ( $server_xml->gameq_query_name )
{
require_once 'protocol/GameQ/Autoloader.php';
$query_port = get_query_port($server_xml, $port);
$servers = array(
array(
'id' => 'server',
'type' => (string)$server_xml->gameq_query_name,
'host' => $query_ip . ":" . $query_port,
)
);
$gq = new \GameQ\GameQ();
$gq->addServers($servers);
$gq->setOption('timeout', 4);
$gq->setOption('debug', FALSE);
$gq->addFilter('normalise');
$game = $gq->process();
if ( ! $game['server']['gq_online'] )
{
$running = FALSE;
}
}
if( ! $running )
{
if (!isset($_GET['retry']))
$retry = 0;
else
$retry = $_GET['retry'];
if ($retry >= 5)
{
echo "<p>".get_lang('server_running_not_responding')."
<a href=?m=gamemanager&amp;p=stop&amp;home_id=".$home_id.
"&amp;ip=".$ip."&amp;port=".
$port.">".get_lang('already_running_stop_server').".</a></p>";
echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=$home_id-$mod_id-$ip-$port'><< ".get_lang('back')."</a></td></tr></table>";
}
echo "</b>Retry #".$retry.".</b>";
$retry++;
print("<p class='note'>".get_lang('starting_server')."</p>");
$view->refresh("?m=gamemanager&amp;p=start&amp;refresh&amp;ip=$ip&amp;port=$port&amp;home_id=$home_id&amp;mod_id=$mod_id&amp;retry=".$retry,3);
return;
}
print_success(get_lang_f('server_restarted',htmlentities($home_info['home_name'])));
$ip_id = $db->getIpIdByIp($ip);
$db->delServerStatusCache($ip_id,$port);
$view->refresh("?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=". $home_id . "-". $mod_id . "-" . $ip . "-" . $port);
echo "<p>".get_lang('follow_server_status')." <a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=".
$home_id . "-". $mod_id . "-" . $ip . "-" . $port . "'>".get_lang('game_monitor')."</a> ".get_lang('page').".</p>";
return;
}
else
{
$server_home = $home_info;
if( $server_xml->replace_texts )
{
if( isset($server_xml->lgsl_query_name) )
require_once('protocol/lgsl/lgsl_protocol.php');
require_once("modules/gamemanager/cfg_text_replace.php");
}
$control_type = isset($server_xml->control_protocol_type) ? $server_xml->control_protocol_type : "";
$run_dir = isset($server_xml->exe_location) ? $server_xml->exe_location : "";
$start_cmd = get_start_cmd($remote, $server_xml, $home_info, $mod_id, $ip, $port, $db);
// Run pre-start commands
if(isset($server_xml->pre_start) && !empty($server_xml->pre_start)){
$preStart = trim($server_xml->pre_start);
}else{
$preStart = "";
}
// Environment variables
if(isset($server_xml->environment_variables) && !empty($server_xml->environment_variables)){
$envVars = trim($server_xml->environment_variables);
}else{
$envVars = "";
}
// Additional files to lock
if(isset($server_xml->lock_files) && !empty($server_xml->lock_files)){
$lockFiles = trim($server_xml->lock_files);
}else{
$lockFiles = "";
}
if(!empty($lockFiles)){
// Linux only call
if(preg_match("/Linux/", $os)){
$lockedFilesStatus = $remote->lock_additional_home_files($home_info['home_path'], $lockFiles, "lock");
}
}
$remote_retval = $remote->remote_restart_server($home_id,$ip,$port,$server_xml->control_protocol,
$home_info['control_password'],$control_type,$home_info['home_path'],
$server_xml->server_exec_name,$run_dir,$start_cmd,
$home_info['cpu_affinity'],$home_info['nice'],$preStart,$envVars, $server_xml->game_key,
(isset( $server_xml->console_log ) ? $server_xml->console_log : ""));
$db->logger(get_lang_f('server_restarted', $home_info['home_name']) . "($ip:$port)");
if ( $remote_retval === 1 )
{
print("<p class='note'>".get_lang('restarting_server')."</p>");
$view->refresh("?m=gamemanager&amp;p=restart&amp;refresh&amp;ip=$ip&amp;port=$port&amp;home_id=$home_id&amp;mod_id=$mod_id",3);
return;
}
else if ( $remote_retval === -1 )
{
print_failure(get_lang('server_cant_start'));
$view->refresh("?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=". $home_id . "-". $mod_id . "-" . $ip . "-" . $port,3);
}
else if ( $remote_retval === -2 )
{
print_failure(get_lang('server_cant_stop'));
$view->refresh("?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=". $home_id . "-". $mod_id . "-" . $ip . "-" . $port,3);
}
else
{
$screen_running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME,$home_id);
if ( $screen_running == 1 )
{
print("<p class='note'>".get_lang('restarting_server')."</p>");
$view->refresh("?m=gamemanager&amp;p=restart&amp;refresh&amp;ip=$ip&amp;port=$port&amp;home_id=$home_id&amp;mod_id=$mod_id",3);
return;
}
else
{
print_failure("".get_lang('error_occured_remote_host').".$remote_retval");
$view->refresh("?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=". $home_id . "-". $mod_id . "-" . $ip . "-" . $port,3);
}
}
}
}
}
?>

View file

@ -1,15 +0,0 @@
bec_win64
bf2
bigbrotherbot_linux32
cstrike_linux32
dod_linux32
fivem_linux32
minecraft_linux64
mumble_linux32
pixark_win64
spigot
spunkybot_linux64
steamcmd
terraria_linux
urt_linux
ut99_linux32

View file

@ -1,415 +0,0 @@
<?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 do_progress($kbytes,$rsyncPath)
{
$mbytes = round($kbytes / 1024, 2);
$sizes = file("modules/gamemanager/sizes.list", FILE_IGNORE_NEW_LINES)or print_failure("Can't open sizes.list");
# Adds a backslash on each slash so it can be used as patern at preg_match
$rsyncPath = addcslashes($rsyncPath,"/");
# Sets a default file size
$totalsize = 0;
# loops all available sizes to work over a string instead of an array.
foreach($sizes as $key => $size)
{
# If the rsync path matches the path at the string on the variable $size
# then lists the path and the total size on separated variables
# using explode over the string saved on $size
if ( preg_match("/$rsyncPath/i", $size) )
list( $path, $totalsize ) = explode( ";", $size );
}
if($kbytes > 0)
{
$pct = round(( $kbytes / $totalsize ) * 100, 2);
}
else
{
$pct = "unavailable";
}
#echo "Percent is $pct";
$pct = $pct > 100 ? 100 : $pct;
return "$totalsize;$mbytes;$pct";
}
function update_local_copies()
{
$last_updated = filemtime("modules/gamemanager/sizes.list");
$nowtime=time();
$diff = $nowtime - $last_updated;
if( $diff < 86400)
{
#echo "Now $nowtime last $last_updated diff $diff<br>";
return 0;
}
echo "Updating local cache of rsync meta data files<br>";
$update_files = array('sizes.list', 'rsync.list', 'rsync_sites.list');
$update_urls = array('rsync.opengamepanel.org', 'dls.atl.webehostin.com');
$context = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
foreach($update_files as $file_chk)
{
#echo "Trying to update $file_chk<br>";
foreach($update_urls as $site)
{
#echo "Trying $file_chk from $site<br>";
if(!is_writable("modules/gamemanager/$file_chk"))
{
print_failure("modules/gamemanager/$file_chk is not writable...please make it writable by the webserver");
}
if($tmp_content = file_get_contents("http://$site/sync_data/$file_chk", false, $context))
{
if(!file_put_contents("modules/gamemanager/$file_chk",$tmp_content)){echo "Failed to write<br>";};
break;
}
}
}
if(is_writable('modules/gamemanager'))
{
$tmp = 'modules/gamemanager';
}
elseif(is_writable('/tmp'))
{
$tmp = 'modules/gamemanager';
}
else
{
return "-1";
}
}
require_once("includes/lib_remote.php");
require_once("modules/config_games/server_config_parser.php");
function exec_ogp_module() {
//update_local_copies(); #Disabled until the rsync_sites.list file from master servers is corrected.
global $db,$view,$settings;
$home_id = isset($_REQUEST['home_id']) ? $_REQUEST['home_id'] : "";
$mod_id = isset($_REQUEST['mod_id']) ? $_REQUEST['mod_id'] : "";
$state = isset($_POST['state']) ? $_POST['state'] : "";
$update = isset($_GET['update']) ? $_GET['update'] : "";
$rsync_remote_sites = file("modules/gamemanager/rsync_sites.list"); #load offical rsync sites
$rsync_local_sites = file("modules/gamemanager/rsync_sites_local.list"); #load user custom sites
$settings['rsync_available'] = isset($settings['rsync_available']) ? $settings['rsync_available'] : "1";
if(is_array($rsync_local_sites) && $settings['rsync_available'] == "1") {
$rsync_sites = array_merge($rsync_remote_sites, $rsync_local_sites);
} elseif($settings['rsync_available'] == "2") {
$rsync_sites = $rsync_remote_sites;
} elseif( $settings['rsync_available'] == "3") {
$rsync_sites = $rsync_local_sites;
}
$isAdmin = $db->isAdmin($_SESSION['user_id']);
if ($isAdmin) {
$home_info = $db->getGameHome($home_id);
} else {
$home_info = $db->getUserGameHome($_SESSION['user_id'],$home_id);
}
if ( $home_info === FALSE || preg_match("/u/",$home_info['access_rights']) != 1 )
{
print_failure( get_lang("no_rights") );
echo create_back_button("gamemanager","game_monitor");
return;
}
$home_id = $home_info['home_id'];
$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'],$home_info['timeout']);
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']);
if( isset($server_xml->lgsl_query_name) )
{
$lgslname = $server_xml->lgsl_query_name;
if($lgslname == "quake3")
{
if($server_xml->game_name == "Quake 3")
$lgslname = "q3";
}
}
elseif( isset($server_xml->gameq_query_name) )
{
$lgslname = $server_xml->gameq_query_name;
if($lgslname == "minecraft")
{
if($server_xml->game_name == "Bukkit")
$lgslname = "bukkit";
elseif($server_xml->game_name == "Tekkit")
$lgslname = "tekkit";
}
}
elseif( isset($server_xml->protocol) )
$lgslname = $server_xml->protocol;
else
$lgslname = $server_xml->mods->mod['key'];
//SKIP ABOVE AND JUST SET RS_GNAME TO GAME xml NAME
$rs_gname = $server_xml->game_key;
if( preg_match("/win32/", $server_xml->game_key) OR preg_match("/win64/", $server_xml->game_key) )
$os = "windows";
elseif( preg_match("/linux/", $server_xml->game_key) )
$os = "linux";
echo "<h2>Update $home_info[home_name]</h2>";
if ( $remote->is_screen_running(OGP_SCREEN_TYPE_HOME,$home_id) == 1 )
{
print_failure( get_lang("server_running_cant_update") );
return;
}
$update_active = $remote->get_log(OGP_SCREEN_TYPE_UPDATE,
// Note exec location should not be added here as the log is in root where rsync is executed.
$home_id,clean_path($home_info['home_path']),
$log_txt,30);
if ($update_active === 0)
{
print_failure( get_lang("agent_offline") );
$view->refresh("{CURRENT_PAGE}", 5);
return;
}
// Start update.
elseif ($state == 'start' && $update_active != 1)
{
$precmd = $home_info['mods'][$mod_id]['precmd'] == "" ?
( $home_info['mods'][$mod_id]['def_precmd'] == "" ? $server_xml->pre_install :
$home_info['mods'][$mod_id]['def_precmd'] ) : $home_info['mods'][$mod_id]['precmd'];
$postcmd = $home_info['mods'][$mod_id]['postcmd'] == "" ?
( $home_info['mods'][$mod_id]['def_postcmd'] == "" ? $server_xml->post_install :
$home_info['mods'][$mod_id]['def_precmd'] ) : $home_info['mods'][$mod_id]['postcmd'];
$exec_folder_path = clean_path($home_info['home_path'] . "/" . $server_xml->exe_location );
$exec_path = clean_path($exec_folder_path . "/" . $server_xml->server_exec_name );
if( isset( $_REQUEST['master_server_home_id'] ) )
{
$ms_home_id = $_REQUEST['master_server_home_id'];
if ($db->getMasterServer($home_info['remote_server_id'], $home_info['home_cfg_id']) == $ms_home_id) {
if ($ms_home_id !== $home_id) {
$ms_info = $db->getGameHome($ms_home_id);
print_success(get_lang_f("starting_copy_with_master_server_named",htmlentities($ms_info['home_name'])));
$rsync = $remote->masterServerUpdate( $home_id,$home_info['home_path'],$ms_home_id,$ms_info['home_path'],$exec_folder_path,$exec_path,$precmd,$postcmd );
$master = "&amp;master=true";
} else {
print_failure(get_lang('cannot_update_from_own_self'));
$view->refresh('?m=gamemanager&p=game_monitor', 2);
return;
}
} else {
$db->logger(get_lang_f('update_attempt_from_nonmaster_server', $_SESSION['users_login'], $home_id, $ms_home_id));
print_failure(get_lang('attempting_nonmaster_update'));
$view->refresh('?m=gamemanager&p=game_monitor', 2);
return;
}
}
else
{
$url_id = (isset($_POST['url_id']) && (int)$_POST['url_id'] > 0 ? (int)$_POST['url_id'] -1 : null);
if (!is_null($url_id) && array_key_exists($url_id, $rsync_sites)) {
$urlArr = explode('|', $rsync_sites[$url_id]);
$url = $urlArr[0] . "/rsync_installer/$rs_gname/$os/";
} else {
print_failure(get_lang('unknown_rsync_mirror'));
$view->refresh('?m=gamemanager&p=game_monitor');
return;
}
print_success(get_lang_f("starting_sync_with", $url));
// Additional files to lock
if(isset($server_xml->lock_files) && !empty($server_xml->lock_files)){
$lockFiles = trim($server_xml->lock_files);
}else{
$lockFiles = "";
}
$rsync = $remote->start_rsync_install($home_id, $home_info['home_path'], $url, $exec_folder_path, $exec_path, $precmd, $postcmd, $lockFiles);
$master = "";
}
if( $rsync === 0 )
{
print_failure( get_lang("failed_to_start_rsync_update") );
return;
}
else if ( $rsync === 1 )
{
print_success(get_lang("update_started"));
echo "<p><a href=\"?m=gamemanager&amp;p=rsync_install&amp;update=refresh&amp;home_id=$home_id&amp;mod_id=$mod_id$master\">".
get_lang("refresh_rsync_status") ."</a></p>";
$view->refresh("?m=gamemanager&amp;p=rsync_install&amp;update=refresh&amp;home_id=$home_id&amp;mod_id=$mod_id$master",5);
return;
}
elseif( $rsync === 0 )
{
print_failure( get_lang("agent_offline") );
return;
}
}
elseif($update_active == 1)
{
echo "<p class='note'></p>\n";
if ( isset( $_POST['stop_update_x'] ) )
{
$remote->stop_update($home_id);
print_success("Update stopped.");
$view->refresh("?m=gamemanager&amp;p=rsync_install&amp;update=refresh&amp;home_id=$home_id&amp;mod_id=$mod_id", 2);
return;
}
$update_complete = false;
echo "<form method=POST><input type='image' name='stop_update' onsubmit='submit-form();' src='modules/administration/images/remove.gif'>". get_lang("stop_update") ."</input></form>";
if (empty($log_txt))
$log_txt = not_available;
if(!isset($_GET['master']))
{
$kbytes = $remote->rsync_progress($home_info['home_path']);
list($totalsize,$mbytes,$pct) = explode(";",do_progress($kbytes,$rs_gname."/".$os));
$totalmbytes = round($totalsize / 1024, 2);
echo '<div class="dragbox bloc rounded" style="background-color:#dce9f2;" >
<h4>'. get_lang("update_in_progress") ." ${mbytes}MB/${totalmbytes}MB</h4>
<div style='background-color:#dce9f2;' >
";
$bar = '';
for( $i = 1; $i <= $pct; $i++ )
{
$bar .= '<img style="width:0.92%;vertical-align:middle;" src="images/progressBar.png">';
}
echo "$bar <b style='vertical-align:top;display:inline;font-size:1.2em;color:red;' >$pct%</b>
</div>
</div><br>";
}
else
{
echo '<h4>'. get_lang("update_in_progress") .'</h4>';
}
echo "<pre>".$log_txt."</pre>\n".
"<p><a href=\"?m=gamemanager&amp;p=rsync_install&amp;update=refresh&amp;home_id=$home_id&amp;mod_id=$mod_id\">".
get_lang("refresh_rsync_status") ."</a></p>";
$view->refresh("?m=gamemanager&amp;p=rsync_install&amp;update=refresh&amp;home_id=$home_id&amp;mod_id=$mod_id",5);
return;
}
elseif($update != "update")
{
$view->refresh("{CURRENT_PAGE}", 60);
print_success(get_lang("update_completed") );
echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id=".$home_info['home_id']."'><< ". get_lang("back") ."</a></td></tr></table>";
echo "<pre>".$log_txt."</pre>\n";
echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id=".$home_info['home_id']."'><< ". get_lang("back") ."</a></td></tr></table>";
$update_complete = true;
}
else
{
#echo "LGSL or GameQ query name is $server_xml->lgsl_query_name$server_xml->gameq_query_name";
$sync_list = @file("modules/gamemanager/rsync.list", FILE_IGNORE_NEW_LINES);
if(!is_array($sync_list))
{
if(!is_file("modules/gamemanager/rsync.list"))
{
print_failure("Trouble accessing http://www.opengamepanel.org/rsync.list<br>".
"Make sure allow_fopen_url is set to \"On\" in your php.ini and opengamepanel.org is online<br>".
"In the mean time, you can get a local copy of the file by running wget http://www.opengamepanel.org/sync_data/rsync.list -O /path/to/ogpweb/modules/gamemanager/rsync.list");
return;
}
# print_failure("Error loading rsync.list");
# return;
$sync_list = @file("modules/gamemanager/rsync.list", FILE_IGNORE_NEW_LINES);
if(!is_array($sync_list))
{
print_failure("Failed to open local copy of rsync.list in modules/gamemanager/rsync.list");
return;
}
}
$master_server_home_id = $db->getMasterServer( $home_info['remote_server_id'], $home_info['home_cfg_id'] );
if ( in_array($rs_gname, $sync_list) )
{
echo "<form action='?m=gamemanager&amp;p=rsync_install' method='post'>
<table class='center'>
<input type='hidden' name='home_id' value='$home_id' />
<input type='hidden' name='mod_id' value='$mod_id' />
<input type='hidden' name='lgslname' value='$rs_gname' />
<input type='hidden' name='state' value='start' />
<tr><td align='right'>Game name:</td><td align='left'>$home_info[game_name]</td></tr>
<tr><td align='right'>Directory:</td><td align='left'>$home_info[home_path]</td></tr>
<tr><td align='right'>Remoteserver:</td>
<td align='left'>$home_info[remote_server_name] ($home_info[agent_ip]:$home_info[agent_port])</td></tr>
<tr><td align='right'>Rsync Server:</td>
<td align='left'>".create_drop_box_from_array_rsync($rsync_sites,"url_id")."<br>";
if( $master_server_home_id != FALSE AND $master_server_home_id != $home_id )
{
echo "<input type='checkbox' name='master_server_home_id' value='$master_server_home_id' /><b>". get_lang("update_from_local_master_server") ."</b>";
}
echo "</td></tr></table><p><input type='submit' name='update' value='". get_lang("update_from_selected_rsync_server") ."' /></p>
</form>";
}
elseif($master_server_home_id != FALSE AND $master_server_home_id != $home_id)
{
$ms_home_info = $db->getGameHome($master_server_home_id);
echo "<br>
<p class='success'>Master server update available</p><br>
<form action='?m=gamemanager&amp;p=rsync_install' method='post'>
<table class='center'>
<input type='hidden' name='home_id' value='$home_id' />
<input type='hidden' name='mod_id' value='$mod_id' />
<input type='hidden' name='lgslname' value='$rs_gname' />
<input type='hidden' name='state' value='start' />
<tr><td align='right'>Game name:</td><td align='left'>$home_info[game_name]</td></tr>
<tr><td align='right'>Master Server Name:</td><td align='left'>$ms_home_info[home_name]</td></tr>
<tr><td align='right'>Master Server Directory:</td><td align='left'>$ms_home_info[home_path]</td></tr>
<tr><td align='right'>Local Directory:</td><td align='left'>$home_info[home_path]</td></tr>".
"<input type='hidden' name='master_server_home_id' value='$master_server_home_id' />".
"</td></tr></table><p><input type='submit' name='update' value='". get_lang("update_from_local_master_server") ."' /></p>
</form>";
}
else
{
print_failure("This game type [ $lgslname ] is not yet supported with rsync install");
}
}
}
?>

View file

@ -1,2 +0,0 @@
files.iareserver.com|Kansas City USA

View file

@ -1 +0,0 @@
files.iareserver.com|Kansas City USA

View file

@ -1,633 +0,0 @@
<script type="text/javascript" src="js/modules/gamemanager.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('modules/gamemanager/home_handling_functions.php');
require_once("modules/config_games/server_config_parser.php");
require_once("includes/refreshed.php");
require_once('includes/lib_remote.php');
function renderParam($param, $last_param, $param_access_enabled, $home_id)
{
global $db;
$isAdmin = $db->isAdmin($_SESSION['user_id']);
$attributesString = "";
foreach ($param->attribute as $attribute)
$attributesString .= $attribute['key']. "='$attribute' ";
$disabledString = ((($param_access_enabled) && (!property_exists($param, 'access') || $param->access != "admin")) || $isAdmin) ? "" : "disabled ";
if (array_key_exists((string)$param['key'], $last_param))
$paramValue = (string)$last_param[(string)$param['key']];
else
$paramValue = (string)$param->default;
$idString = "id='".clean_id_string($param['key'])."'";
$nameString = "name='params[".$param['key']."]'";
$paramType = $param['type'];
if ($paramType == "select")
{
$inputElementString = "<select $idString $nameString $disabledString>";
foreach ($param->option as $option)
{
$optionValue = (string)($option['value']);
$selectedString = ($optionValue == $paramValue) ? "selected='selected'" : "";
$valueString = "value=\"".str_replace('"', "&quot;", strip_real_escape_string($optionValue))."\"";
$inputElementString .= "<option $selectedString $valueString>$option</option>";
}
$inputElementString .="</select>";
}else if($paramType == "other_game_server_path" || $paramType == "other_game_server_path_additional"){
if($isAdmin){
$dbTypeHomesStr = "admin";
}else{
$dbTypeHomesStr = "user_and_group";
}
// Get homes
$homes = $db->getHomesFor($dbTypeHomesStr, $_SESSION['user_id']);
// Move current home_id home_path to the front of the array so that it is selected by default if no other option has been selected.
$homes = customShift($homes, "home_id", $home_id);
$inputElementString = "<select $idString name='params[" . $param['key'] . "{DEPENDS:$paramType}]'" . $disabledString . ">";
foreach($homes as $home){
if($home["home_path"][strlen($home["home_path"])-1] != "/"){
$home["home_path"] = $home["home_path"] . "/";
}
if(stripos($paramValue, $home["home_path"]) !== false){
$selectedString = "selected='selected'";
$selectedHome = $home["home_path"];
}else{
$selectedString = "";
}
$inputElementString .= '<option value="' . $home["home_path"] . '" ' . $selectedString . '>' . $home["home_path"] . '</option>';
}
$inputElementString .="</select>";
if($paramType == "other_game_server_path_additional"){
$inputElementString .="<input type='text' value='" . (stripos($paramValue, $selectedHome) !== false ? substr($paramValue, strlen($selectedHome)) : (hasValue((string)$param->default) ? (string)$param->default : "")) . "' name='params[other_game_server_path_additional]' " . $disabledString .">";
}
}else{
if ($paramType == "checkbox_key_value") {
if ($paramValue) // convert the XML object to string
$attributesString .= "checked='checked' ";
$paramValue = $param['key'];
$paramType = "checkbox";
}
else if ($paramType == "checkbox")
{
if ($paramValue) // convert the XML object to string
$attributesString .= "checked='checked' ";
}
$inputElementString = "<input $idString $nameString ".
"type='$paramType' value=\"".str_replace('"', "&quot;", strip_real_escape_string($paramValue))."\" ".
"$disabledString $attributesString/>";
}
echo "<tr><td class='right'><label for='".clean_id_string($param['key'])."'>".$param['key'].
":</label></td><td class='left'>$inputElementString<label for='".clean_id_string($param['key'])."'>";
if ( !empty($param->caption) )
echo $param->caption;
if ( !empty($param->desc) )
echo "<br/><span class='info'>(".$param->desc.")</span>";
echo "</label></td></tr>\n";
}
function get_sync_name($server_xml)
{
if( $server_xml->game_key )
{
$sync_name = $server_xml->game_key;
}
elseif( isset($server_xml->protocol) )
$sync_name = $server_xml->protocol;
else
$sync_name = $server_xml->mods->mod['key'];
return $sync_name;
}
function exec_ogp_module() {
global $db, $settings, $loggedInUserInfo;
echo "<h2 class='gameMonitor " . ($db->isAdmin( $_SESSION['user_id'] ) ? "isAdminUser" : "") . "'>". get_lang("game_monitor") ."</h2>";
$refresh = new refreshed();
set_time_limit(0);
$stats_servers_online = 0;
$stats_servers = 0;
$stats_players = 0;
$stats_maxplayers = 0;
$home_id = $_GET['home_id'];
$home_info = $db->getGameHomeWithoutMods($home_id);
$home_page = (isset($_GET['page']) && (int)$_GET['page'] > 0) ? (int)$_GET['page'] : 1;
$home_limit = (isset($_GET['limit']) && (int)$_GET['limit'] > 0) ? (int)$_GET['limit'] : 10;
$home_cfg_id = (isset($_GET['home_cfg_id']) && (int)$_GET['home_cfg_id'] > 0) ? (int)$_GET['home_cfg_id'] : false;
$search_field = (isset($_GET['search']) && !empty($_GET['search'])) ? $_GET['search'] : false;
if(hasValue($loggedInUserInfo) && is_array($loggedInUserInfo) && $loggedInUserInfo["users_page_limit"] && !(isset($_GET['limit']) and !empty($_GET['limit']))){
$home_limit = $loggedInUserInfo["users_page_limit"];
}
$isAdmin = $db->isAdmin( $_SESSION['user_id'] );
if ( $isAdmin )
{
$show_games_type = $db->getHomesFor('admin', $_SESSION['user_id']);
if(isset($_GET['home_id']) OR isset($_GET['home_id-mod_id-ip-port']))
$server_homes = $db->getHomesFor('admin', $_SESSION['user_id']);
else
$server_homes = $db->getHomesFor_limit('admin', $_SESSION['user_id'],$home_page,$home_limit,$home_cfg_id,$search_field);
}
else
{
$show_games_type = $db->getHomesFor('user_and_group', $_SESSION['user_id']);
if(isset($_GET['home_id']) OR isset($_GET['home_id-mod_id-ip-port']))
$server_homes = $db->getHomesFor('user_and_group', $_SESSION['user_id']);
else
$server_homes = $db->getHomesFor_limit('user_and_group', $_SESSION['user_id'],$home_page,$home_limit,$home_cfg_id,$search_field);
}
if( $server_homes === FALSE )
{
// If there are no games, then there can not be any mods either.
if (!empty($search_field)) {
print_failure(get_lang_f('no_results_found', htmlentities($search_field)));
} else {
print_failure(get_lang('no_game_homes_assigned'));
}
if ( $isAdmin )
{
echo "<p><a href='?m=user_games&amp;p=assign&amp;user_id=$_SESSION[user_id]'>".
get_lang("assign_game_homes") ."</a></p>";
}
return;
}
?>
<form action="home.php" style="float:right;">
<b><?php print_lang('search'); ?>:</b>
<input type ="hidden" name="m" value="gamemanager" />
<input type ="hidden" name="p" value="game_monitor" />
<input name="search" type="text" id="search" value="<?php if(hasValue($search_field)){ echo $search_field; } ?>" />
<input type="submit" value="<?php echo get_lang('search'); ?>" />
</form>
<?php
foreach($_POST as $key => $value)
{
if( preg_match( "/^action/", $key ) )
{
list($action,$home_id,$mod_id,$ip,$port) = explode("-", $value);
exec_operation( $action, $home_id, $mod_id, $ip, $port );
}
}
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 ( isset($_GET['home_cfg_id']) and $_GET['home_cfg_id'] == get_lang('game_type') )
unset( $_GET['home_cfg_id'] );
create_home_selector_game_type($_GET['m'], $_GET['p'], $show_games_type);
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");
$info = $db->getUserById($_SESSION['user_id']);
if($info['user_expires'] != "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", $info['user_expires'] ).
" ( ".str_replace('hr', 'hours', read_expire($info['user_expires'])).")"; ?></span>
</center>
</span>
<?php
}
if($settings["show_server_id_game_monitor"]){
echo "<p class='serverIdToggle' showtext='" . get_lang('show_server_id') . "' hidetext='" . get_lang('hide_server_id') . "'>" . get_lang('show_server_id') . "</p>";
}
echo "<table id='servermonitor' class='tablesorter' data-sortlist='[[0,0],[3,1]]'>".
"<thead>".
"<tr>".
"\t<th style='width:16px;background-position: center;'></th>".
"\t<th style='width:16px;background-position: center;'></th>".
"\t<th class=\"hide serverId\">" . get_lang("server_id") . "</th>".
"\t<th>" . get_lang("server_name") . "</th>".
"\t<th>IP and Port</th>".
"\t<th>" . get_lang("owner") . "</th>".
"\t<th>Server Expiration".
"\t</th>".
"</tr>".
"</thead>".
"<tbody>";
if( isset( $_GET['home_id-mod_id-ip-port']) )
list( $post_home_id,
$post_mod_id,
$post_ip,
$post_port ) = explode( "-", $_GET['home_id-mod_id-ip-port'] );
$j = 1;
foreach( $server_homes as $server_home )
{
if( ( $show_all or isset($_GET['home_cfg_id']) ) AND ( !isset($server_home['ip']) or !isset($server_home['mod_id']) ) ){
$j++;
continue;
}
// Count the number of servers.
$stats_servers++;
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 variables.
unset($map,
$trclass,
$first,
$second,
$onlineT,
$ts3opt,
$offlineT,
$halfT,
$ministart,
$player_list,
$groupsus,
$name,
$mod_name,
$SrvCtrl,
$user,
$pos,
$ctrlChkBoxes,
$expiration_dates);
if ( $isAdmin )
$server_home['access_rights'] = $db->getFullAccessRightsString();
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']." )";
//set the display of how long server has until expired
//default is it never expires
$expiration_dates = "This Server Will NEVER Expire";
//get all orders thare are active or invoiced
$query = "SELECT * FROM ogp_billing_orders WHERE home_id = " . $server_home['home_id'] . " AND status >= -2" ;
$results = $db->resultQuery($query);
if(!is_null($results[0]['status']))
{
//there is an end date
if($results[0]['status'] > 0)
{
$expire_date = $results[0]['finish_date'];
$expiration_dates = "<font color='green'>" . read_expire($expire_date) . "</font>";
}
// 0 its expire, invoice printed
if($results[0]['status'] == 0)
{
$expire_date = $results[0]['finish_date'];
$expiration_dates = "<font color='yellow'>". read_expire($expire_date) . "</font><a href='home.php?m=billing&p=cart'> Invoice</a>";
}
// -1 its expire, invoice printed
if($results[0]['status'] == -1)
{
$expire_date = $results[0]['finish_date'];
$expiration_dates = "<font color='yellow'>". read_expire($expire_date) . "</font><a href='home.php?m=billing&p=cart'> Invoice</a>";
}
// -2 its suspended, invoice still available
if($results[0]['status'] == -2)
{
$expire_date = $results[0]['finish_date'];
$expiration_dates = "<font color='red'> SUSPENDED </font><a href='home.php?m=billing&p=cart'> Invoice</a>";
}
}//end isnull
if( !isset($server_home['mod_id']) )
{
$ministart = get_lang("fail_no_mods");
if ( $isAdmin )
{
$ministart .= " <a href='?m=user_games&amp;p=edit&amp;home_id=".$server_home['home_id']."'>" . get_lang("configure_mods") . "</a>";
}
}
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$server_home['home_cfg_file']);
$mod = $server_home['mod_key'];
// 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->protocol == "teamspeak3")
$query_name = 'ts3';
else
$query_name = $mod;
//----------+ 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']);
$groupsus = "";
if($groupusers)
{
foreach($groupusers as $groupu)
{
if($groupu['user_id'] == $server_home['user_id_main'])
continue;
$groupsus .= $groupu['users_login']."<br>";
}
}
$groupsus = $groupsus != "" ? $groupsus = "<b>". get_lang("group_users") ."</b><br>".$groupsus : "";
$owners = $db->getUsersByHomeId($server_home['home_id']);
$other_owners = "";
if($owners)
{
foreach($owners as $owner)
{
if($owner['user_id'] == $server_home['user_id_main'])
continue;
$other_owners .= $owner['users_login'].'<br>';
}
}
$other_owners = $other_owners != "" ? $other_owners = "<b>". get_lang("assigned_to") ."</b><br>".$other_owners : "";
$btns = get_monitor_buttons($server_home, $server_xml);
//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)
{
$ip = $server_home['ip'];
$query_ip = checkDisplayPublicIP($server_home['display_public_ip'], ($server_home['use_nat'] == 1 ? $server_home['agent_ip'] : $ip));
$displayIP = checkDisplayPublicIP($server_home['display_public_ip'], $ip);
$address = "";
$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 + $j;
if ($server_xml->protocol == "lgsl")
{
$get_q_and_s = lgsl_port_conversion($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) . "' >Connect</a>";
}
if ($server_xml->protocol == "teamspeak3")
$address = "<a href='ts3server://" . $query_ip . ":" . $server_home['port'] . "'>".$displayIP.":".$server_home['port']."</a>";
if($server_xml->protocol == "gameq" and $server_xml->installer == 'steamcmd')
$address = "<a href='steam://connect/" . $query_ip . ":" . $server_home['port'] . "'>" . $displayIP . ":" . $server_home['port'] . "</a>";
$pos = $refresh->add("home.php?m=gamemanager&p=ref_servermonitor&type=cleared&home_id=". $server_home['home_id'] . "&mod_id=". $server_home['mod_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;
if( isset($server_home['ip']) and isset($server_home['mod_id']) and ($server_xml->protocol != "teamspeak3" or ($startup_file_exists and $server_xml->protocol == "teamspeak3")) )
{
//$ctrlChkBoxes .= '';
$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="' . check_theme_image("images/stop.png") . '"/></div><div>&nbsp;'.
get_lang("stop_server") .'</div></div><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="' . check_theme_image("images/restart.png") . '"/></div><div>&nbsp;'.
get_lang("restart_server") .'</div></div>';
}
$stats_servers_online++;
}
else
{
$status = "offline";
if ($server_home['last_param'] != "" and isset($server_home['ip']) and isset($server_home['mod_id']))
{
if($update_in_progress)
$ctrlChkBoxes .= '<div id="server_icon" class="action-start'.$server_home['home_id'].'" >&nbsp;'. get_lang("update_in_progress") .'</div>';
else
//$ctrlChkBoxes .= '';
$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="' . check_theme_image("images/start.png") . '"/></div><div>&nbsp;'.
get_lang("start_server") .'</div></div>';
}
$order = 3;
if(isset($server_home['mod_id']))
{
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'].'" >&nbsp;'. 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']);
$query = "SELECT * FROM ogp_billing_orders WHERE home_id = " . $server_home['home_id'] . " AND status > 0" ;
//DISABLE SHOWING EXPIRATION DATES
//$expiration_dates = "";
// Template
@$first = "<tr class='maintr$trclass'>";
$first .= "<td class='collapsible' data-status='$status' data-pos='$pos'><span class='hidden'>$order</span>" . "<img src='" . check_theme_image("images/$status.png") . "' />" . "</td>";
$first .= "<td class='collapsible'>" . "<span class='hidden'>$mod</span><img src='$icon_path' />" . "</td>";
$first .= "<td class='collapsible serverId hide'>" . $server_home["home_id"] . "</td>";
$first .= "<td class='collapsible' data-status='$status' data-pos='$pos'><b>" . htmlentities($server_home['home_name']) . "</b>$mod_name</td>";
$first .= "<td>" . $server_home['ip'] . ":" . $server_home['port'] ." " . $address . "</td>";
//$first .= "<td class='collapsible serverIPAddress ignoreSortable' data-status='$status' data-pos='$pos'>" . $address . "</td>";
//$first .= "<td class='collapsible serverIPAddress ignoreSortable' data-status='$status' data-pos='$pos'>" . $server_home['ip'] . ":" . $server_home['port'] . "</td>";
$first .= "<td class='owner collapsible serverOwner ignoreSortable'>" . $user['users_login'] . "</td>";
if ($isAdmin){
$first .= "<td style='width:328px;padding:0px;'>" . $expiration_dates . "<br>". $ctrlChkBoxes . "</td>";
} else {
$first .= "<td style='width:328px;padding:0px;'>" . $expiration_dates . "</td>";
}
$first .= "</tr>";
$second = "<tr class='expand-child'>";
@$second .= "<td colspan='4'>" . $refresh->getdiv($pos,"width:100%;") . "$offlineT</td>";
$second .= "<td class='owner' >$other_owners$groupsus</td>";
if( $server_xml->protocol != "teamspeak3" OR ($startup_file_exists and $server_xml->protocol == "teamspeak3") OR ($status == "offline" and $server_xml->protocol == "teamspeak3") )
@$second .= "<td class='operations'><div class='inline-block monitorButtonContainer'>" . trim($btns) . trim($ts3opt) . "<b class='failure' style='float:left; color:yellow; ' ></b></div></td>";
else
$second .= "<td class='operations' >$ts3opt</td>";
$second .= "</tr>";
//Echo them all
echo "$first$second";
}
$j++;
}
echo "</tbody>";
echo "<tfoot style='border:1px solid grey;'>
<tr>
<td colspan='7' >
<div class='bloc' >
<img src='" . check_theme_image("images/magnifglass.png") . "' /> ". get_lang("statistics") .": $stats_servers_online/$stats_servers ". get_lang("servers") ."\n</div>
<div class='right bloc' >";
if($isAdmin){
echo "<label>". get_lang("execute_selected_server_operations") ."</label>";
echo "<input id='execute_operations' type='submit' value='". get_lang("execute_operations") ."' >\n";
}
echo "</div>
</td>
</tr>
</tfoot>";
echo "</table>";
if ($isAdmin) {
$homes_count = $db->getHomesFor_count('admin', $_SESSION['user_id'], $home_cfg_id,$search_field);
} else {
$isSubUser = $db->isSubUser($_SESSION['user_id']);
if ($isSubUser) {
$homes_count = $db->getHomesFor_count('subuser',$_SESSION['user_id'], $home_cfg_id,$search_field);
} else {
$homes_count = $db->getHomesFor_count('user_and_group',$_SESSION['user_id'], $home_cfg_id,$search_field);
}
}
if(isset($_GET['home_cfg_id']) && !empty($_GET['home_cfg_id'])){
$uri = '?m=gamemanager&p=game_monitor&home_cfg_id='.$_GET['home_cfg_id'].''.($search_field ? "&search=$search_field" : "").'&limit='.$home_limit.'&page=';
}
else{
$uri = '?m=gamemanager&p=game_monitor'.($search_field ? "&search=$search_field" : "").'&limit='.$home_limit.'&page=';
}
if(!isset($_GET['home_id-mod_id-ip-port']) && !isset($_GET['home_id']))
{echo paginationPages($homes_count[0]['total'], $home_page, $home_limit, $uri, 3, 'serverMonitor');}
/*
echo "<div id=translation data-title='". get_lang("upload_map_image") .
"' data-upload_button='". get_lang("upload_image") .
"' data-bad_file='". get_lang("jpg_gif_png_less_than_1mb") .
"' data-upload_failure='". get_lang("check_dev_console") .
"' >put the log file here</div>\n";
*/
echo "<div>Put the log file here</div>";
//include("log.php");
?>
<script type="text/javascript">
<?php echo $refresh->build(isset($settings['query_cache_life']) ? $settings['query_cache_life'] * 2000 : 60000); ?>
</script>
<?php
}
?>

View file

@ -1,34 +0,0 @@
bec_win64/windows;27024
bf2/linux;12816
bf2/windows;21364
bigbrotherbot_linux32/linux;10004
cstrike_linux32/cstrike_install.sh;4
cstrike_linux32/linux;807732
dod_linux32/dod_install.sh;4
dod_linux32/linux;808656
fivem_linux32/linux;132144
fivem_linux32/update.sh;4
minecraft_linux64/linux;91296
mumble_linux32/linux;36512
pixark_win64/windows;4
spigot/BuildData;36348
spigot/BuildTools.jar;3904
spigot/BuildTools.log.txt;1064
spigot/Bukkit;10592
spigot/CraftBukkit;27536
spigot/Spigot;117616
spigot/apache-maven-3.6.0;10608
spigot/spigot-1.15.2.jar;31744
spigot/work;177760
spunkybot_linux64/linux;1740
steamcmd/linux32;36320
steamcmd/linux64;29016
steamcmd/package;51604
steamcmd/public;224
steamcmd/siteserverui;145048
steamcmd/steam;484
steamcmd/steamcmd.sh;4
steamcmd/steamcmd_linux.tar.gz;2372
terraria_linux/linux;52088
urt_linux/linux;1450964
ut99_linux32/linux;291268

View file

@ -1,258 +0,0 @@
<?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('home_handling_functions.php');
require_once("modules/config_games/server_config_parser.php");
function exec_ogp_module()
{
global $db;
global $view;
$home_id = $_REQUEST['home_id'];
$isAdmin = $db->isAdmin( $_SESSION['user_id'] );
if($isAdmin)
$home_info = $db->getGameHome($home_id);
else
$home_info = $db->getUserGameHome($_SESSION['user_id'],$home_id);
if ( $home_info == FALSE )
{
print_failure(get_lang('no_rights_to_start_server'));
echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=". $home_info['home_id'] . "-". $home_info['mod_id'] . "-" . $_REQUEST['ip'] . "-" . $_REQUEST['port'] . "'><< ".get_lang('back')."</a></td></tr></table>";
return;
}
$mod_id = $_REQUEST['mod_id'];
if ( !array_key_exists($mod_id,$home_info['mods']) )
{
print_failure("Unable to retrieve mod information from database.");
return;
}
echo "<h2>";
echo empty($home_info['home_name']) ? get_lang('not_available') : htmlentities($home_info['home_name']);
echo "</h2>";
require_once('includes/lib_remote.php');
$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'],$home_info['timeout']);
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']);
if ( !$server_xml )
{
echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=". $home_info['home_id'] . "-". $home_info['mod_id'] . "-" . $_REQUEST['ip'] . "-" . $_REQUEST['port'] . "'><< ".get_lang('back')."</a></td></tr></table>";
return;
}
// It compares ip and port on POST with the pair on DB for security reasons (URL HACKING)
$home_id = $home_info['home_id'];
$ip_info = $db->getHomeIpPorts($home_id);
foreach ( $ip_info as $ip_ports_row )
{
if($ip_ports_row['ip'] == $_REQUEST['ip'] && $ip_ports_row['port'] == $_REQUEST['port'])
{
$ip = $_REQUEST['ip'];
$port = $ip_ports_row['port'];
}
}
If (!isset($ip) OR !isset($port))
{
echo "<h2>" . get_lang_f('ip_port_pair_not_owned') . "</h2>";
echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=$home_id-$mod_id-$ip-$port'><< ".get_lang('back')."</a></td></tr></table>";
return;
}
if( isset( $server_xml->console_log ) )
{
$log_path = preg_replace("/%mod%/i", $home_info['mods'][$mod_id]['mod_key'], $server_xml->console_log);
$log_retval = $remote->remote_readfile( $home_info['home_path'].'/'.$log_path, $home_log );
}
else
{
$log_retval = $remote->get_log(OGP_SCREEN_TYPE_HOME,
$home_info['home_id'],
clean_path($home_info['home_path']."/".$server_xml->exe_location),
$home_log);
}
function getLastLines($string, $n = 1) {
$lines = explode("\n", $string);
$lines = array_slice($lines, -$n);
return implode("\n", $lines);
}
//PUT STARTUP MESSAGES HERE
if (!isset($_GET['retry']))
$retry = 0;
else
$retry = $_GET['retry'];
if($retry == 1)
{
echo "Starting the server ...";
}
if($retry==2)
{
echo "... Starting the server ...";
}
if($retry==3)
{
echo "...... Starting the server ...";
}
/*
if($retry > 3)
{
echo "<p>Still Starting Server .. </br>
Something <b>MIGHT</b> be wrong .. </br>
or it just might need more time<br>
You can return to the <a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=$home_id-$mod_id-$ip-$port'>Game Monitor</a></br>
Or you can <a href='?m=gamemanager&amp;p=stop&amp;home_id=$home_id&amp;mod_id=$mod_id&amp;ip=$ip&amp;port=$port' >Stop the Server</a></p>";
}
*/
$home_log = getLastLines($home_log, 40);
if ($log_retval > 0)
{
if ( $log_retval == 2 )
print_failure(get_lang('server_not_running_log_found'));
//echo "<pre style='background:black;color:white;'>".$home_log."</pre>";
if ($log_retval == 2)
return;
}
else
{
print_failure(get_lang_f('unable_to_get_log',$log_retval));
}
// If game is not supported by lgsl we skip the lgsl checks and
// assume successfull start.
if ( $home_info['use_nat'] == 1 )
$query_ip = $home_info['agent_ip'];
else
$query_ip = $ip;
$running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME,$home_info['home_id']);
if ( $server_xml->lgsl_query_name )
{
require('protocol/lgsl/lgsl_protocol.php');
$get_q_and_s = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $port, "", "");
//Connection port
$c_port = $get_q_and_s['0'];
//query port
$q_port = $get_q_and_s['1'];
//software port
$s_port = $get_q_and_s['2'];
$data = lgsl_query_live((string)$server_xml->lgsl_query_name, $query_ip, $c_port, $q_port, $s_port, "sa");
if ( $data['b']['status'] == "0" )
{
$running = FALSE;
}
}
elseif ( $server_xml->gameq_query_name )
{
require_once 'protocol/GameQ/Autoloader.php';
$query_port = get_query_port($server_xml, $port);
$servers = array(
array(
'id' => 'server',
'type' => (string)$server_xml->gameq_query_name,
'host' => $query_ip . ":" . $query_port,
)
);
$gq = new \GameQ\GameQ();
$gq->addServers($servers);
$gq->setOption('timeout', 4);
$gq->setOption('debug', FALSE);
$gq->addFilter('normalise');
$game = $gq->process();
if ( ! $game['server']['gq_online'] )
{
$running = FALSE;
}
}
if( ! $running )
{
if (!isset($_GET['retry']))
$retry = 0;
else
$retry = $_GET['retry'];
if ($retry > 3)
{
//echo "<p>".get_lang('server_running_not_responding').
// "<a href='?m=gamemanager&amp;p=stop&amp;home_id=$home_id&amp;mod_id=$mod_id&amp;ip=$ip&amp;port=$port' >".
// get_lang('already_running_stop_server').".</a></p>".
//"<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=$home_id-$mod_id-$ip-$port'><< ".
$view->refresh("?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=$home_id-$mod_id-$ip-$port");
//get_lang('back')."</a></td></tr></table>";
return;
}
//echo "</b>Retry #".$retry.".</b>";
$retry++;
print("<p class='note'>".get_lang('starting_server')."</p>");
$view->refresh("?m=gamemanager&amp;p=start&amp;refresh&amp;ip=$ip&amp;port=$port&amp;home_id=$home_id&amp;mod_id=$mod_id&amp;retry=".$retry,3);
return;
}
print_success(get_lang('server_started'));
$ip_id = $db->getIpIdByIp($ip);
$db->delServerStatusCache($ip_id,$port);
$view->refresh("?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=$home_id-$mod_id-$ip-$port" );
return;
}
?>

View file

@ -1,178 +0,0 @@
<?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('home_handling_functions.php');
require_once("modules/config_games/server_config_parser.php");
function exec_ogp_module() {
global $view,$db;
require_once('includes/lib_remote.php');
$ip = $_REQUEST['ip'];
$port = $_REQUEST['port'];
$home_id = $_REQUEST['home_id'];
$mod_id = $_REQUEST['mod_id'];
$user_id = $_SESSION['user_id'];
// Check ip/port inputs
if(!is_numeric($port))
return;
if(!preg_match("/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/",$ip))
return;
$isAdmin = $db->isAdmin( $user_id );
if($isAdmin)
$home_info = $db->getGameHome($home_id);
else
$home_info = $db->getUserGameHome($user_id,$home_id);
if ( $home_info === FALSE )
{
print_failure(get_lang('no_rights_to_stop_server'));
return;
}
$home_id = $home_info['home_id'];
$home_path = clean_path($home_info['home_path']."/");
echo "<h2>".htmlentities($home_info['home_name'])."</h2>";
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']);
if ( !$server_xml )
{
echo create_back_button("gamemanager","game_monitor");
return;
}
$rserver = $db->getRemoteServerById($home_info['remote_server_id']);
if ( empty($rserver) )
{
print_failure("Could not find the remote server with ID ".$home_info['remote_server_id'].".");
}
else
{
$remote = new OGPRemoteLibrary($rserver['agent_ip'],
$rserver['agent_port'],
$rserver['encryption_key'],
$rserver['timeout']);
if(isset($server_xml->control_protocol_type))$control_type = $server_xml->control_protocol_type; else $control_type = "";
if ($server_xml->protocol == "gameq")
{
$query_port = get_query_port($server_xml, $port);
}
elseif ($server_xml->protocol == "lgsl")
{
require('protocol/lgsl/lgsl_protocol.php');
$get_ports = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $port, "", "");
$query_port = $get_ports['1'];
}
elseif ($server_xml->protocol == "teamspeak3")
{
$query_port = "10011";
}
$remote_retval = $remote->remote_stop_server($home_id,
$ip, $port, $server_xml->control_protocol,
$home_info['control_password'],$control_type, $home_path);
$db->logger(get_lang_f('server_stopped', $home_info['home_name'] ) . "($ip:$port)");
$firewall_settings = $db->getFirewallSettings($home_info['remote_server_id']);
if ( $remote_retval === 1 )
{
print_success(get_lang_f("server_stopped",htmlentities($home_info['home_name'])));
if ($firewall_settings['status'] == "enable")
{
$ip_ports = $db->getHomeIpPorts($home_id);
foreach ($ip_ports as $ip_port)
{
if ($server_xml->protocol == "gameq")
{
$query_port = get_query_port($server_xml, $ip_port['port']);
}
elseif ($server_xml->protocol == "lgsl")
{
require('protocol/lgsl/lgsl_protocol.php');
$get_ports = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $ip_port['port'], "", "");
$query_port = $get_ports['1'];
}
elseif ($server_xml->protocol == "teamspeak3")
{
$query_port = "10011";
}
set_firewall($remote, $firewall_settings, 'deny', $ip_port['port'], $ip_port['ip']);
if(isset($query_port) and $query_port != "" and $query_port != $ip_port['port'])
set_firewall($remote, $firewall_settings, 'deny', $query_port, $ip_port['ip']);
}
}
}
elseif ( $remote_retval === 0 )
{
$remote_retval = $remote->remote_stop_server($home_info['home_id'],
$ip, $port, $server_xml->control_protocol,"",$control_type,$home_path);
if ($remote_retval === 1 )
{
print_success(get_lang_f("server_stopped",htmlentities($home_info['home_name'])));
if ($firewall_settings['status'] == "enable")
{
$ip_ports = $db->getHomeIpPorts($home_id);
foreach ($ip_ports as $ip_port)
{
if ($server_xml->protocol == "gameq")
{
$query_port = get_query_port($server_xml, $ip_port['port']);
}
elseif ($server_xml->protocol == "lgsl")
{
require('protocol/lgsl/lgsl_protocol.php');
$get_ports = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $ip_port['port'], "", "");
$query_port = $get_ports['1'];
}
elseif ($server_xml->protocol == "teamspeak3")
{
$query_port = "10011";
}
$remote->sudo_exec(str_replace("%PORT%",$ip_port['port'],$firewall_settings['deny_port_command']));
if(isset($query_port))
{
$remote->sudo_exec(str_replace("%PORT%",$query_port,$firewall_settings['deny_port_command']));
}
}
}
}
}
if ( $remote_retval === 0 )
print_failure(get_lang("agent_offline"));
elseif ( $remote_retval !== 1 )
print_failure("Error occurred on the remote host.");
}
$view->refresh("?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=". $home_id . "-". $mod_id . "-" . $ip . "-" . $port,3);
}
?>

View file

@ -1,230 +0,0 @@
<?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("modules/config_games/server_config_parser.php");
function exec_ogp_module() {
global $db;
global $view;
$home_id = isset($_REQUEST['home_id']) ? $_REQUEST['home_id'] : "";
$mod_id = isset($_REQUEST['mod_id']) ? $_REQUEST['mod_id'] : "";
$isAdmin = $db->isAdmin( $_SESSION['user_id'] );
if($isAdmin)
$home_info = $db->getGameHome($home_id);
else
$home_info = $db->getUserGameHome($_SESSION['user_id'],$home_id);
if ( $home_info === FALSE || preg_match("/u/",$home_info['access_rights']) != 1 )
{
print_failure( get_lang("no_rights") );
echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id=".$home_info['home_id']."'><< ". get_lang("back") ."</a></td></tr></table>";
return;
}
$home_id = $home_info['home_id'];
$game_type = $home_info['game_key'];
echo "<h2>Updating game server <em>".htmlentities($home_info['home_name'])."</em></h2>";
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']);
if ( $server_xml->installer != "steamcmd" )
{
print_failure( get_lang("xml_steam_error") );
return;
}
$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'], $home_info['timeout']);
$host_stat = $remote->status_chk();
if( $host_stat === 0 )
{
print_failure( get_lang("agent_offline") );
$view->refresh("?m=gamemanager&amp;p=update&amp;update=".$_GET['update']."&amp;home_id=$home_id&amp;mod_id=$mod_id",5);
return;
}
else
{
if ( $remote->is_screen_running(OGP_SCREEN_TYPE_HOME,$home_id) == 1 )
{
print_failure( get_lang("server_running_cant_update") );
return;
}
$log_txt = '';
$update_active = $remote->get_log(OGP_SCREEN_TYPE_UPDATE,
// Note exec location should not be added here as the log is in root where steam is executed.
$home_id,clean_path($home_info['home_path']),
$log_txt);
$modkey = $home_info['mods'][$mod_id]['mod_key'];
$mod_xml = xml_get_mod($server_xml, $modkey);
if (!$mod_xml)
{
print_failure(get_lang_f('mod_key_not_found_from_xml',$modkey));
return;
}
// Start update.
else if ($_GET['update'] == 'update' && $update_active != 1)
{
$installer_name = $modkey;
if ( isset( $mod_xml->installer_name ) )
{
$installer_name = $mod_xml->installer_name;
}
$precmd = $home_info['mods'][$mod_id]['precmd'] == "" ?
( $home_info['mods'][$mod_id]['def_precmd'] == "" ? $server_xml->pre_install :
$home_info['mods'][$mod_id]['def_precmd'] ) : $home_info['mods'][$mod_id]['precmd'];
$postcmd = $home_info['mods'][$mod_id]['postcmd'] == "" ?
( $home_info['mods'][$mod_id]['def_postcmd'] == "" ? $server_xml->post_install :
$home_info['mods'][$mod_id]['def_precmd'] ) : $home_info['mods'][$mod_id]['postcmd'];
$exec_folder_path = clean_path($home_info['home_path'] . "/" . $server_xml->exe_location );
$exec_path = clean_path($exec_folder_path . "/" . $server_xml->server_exec_name );
if( isset( $_REQUEST['master_server_home_id'] ) )
{
$ms_home_id = $_REQUEST['master_server_home_id'];
if ($db->getMasterServer($home_info['remote_server_id'], $home_info['home_cfg_id']) == $ms_home_id) {
if ($ms_home_id !== $home_id) {
$ms_info = $db->getGameHome($ms_home_id);
$steam_out = $remote->masterServerUpdate( $home_id,$home_info['home_path'],$ms_home_id,$ms_info['home_path'],$exec_folder_path,$exec_path,$precmd,$postcmd );
} else {
print_failure(get_lang('cannot_update_from_own_self'));
$view->refresh('?m=gamemanager&p=game_monitor', 2);
return;
}
} else {
$db->logger(get_lang_f('update_attempt_from_nonmaster_server', $_SESSION['users_login'], $home_id, $ms_home_id));
print_failure(get_lang('attempting_nonmaster_update'));
$view->refresh('?m=gamemanager&p=game_monitor', 2);
return;
}
}
else
{
if( preg_match("/win32/", $server_xml->game_key) OR preg_match("/win64/", $server_xml->game_key) )
$cfg_os = "windows";
elseif( preg_match("/linux/", $server_xml->game_key) )
$cfg_os = "linux";
$settings = $db->getSettings();
// Some games like L4D2 require anonymous login
if($mod_xml->installer_login){
$login = $mod_xml->installer_login;
$pass = '';
}else{
$login = $settings['steam_user'];
$pass = $settings['steam_pass'];
}
$modname = ( $installer_name == '90' ) ? $modkey : '';
$betaname = isset($mod_xml->betaname) ? $mod_xml->betaname : '';
$betapwd = isset($mod_xml->betapwd) ? $mod_xml->betapwd : '';
$arch = isset($mod_xml->steam_bitness) ? $mod_xml->steam_bitness : '';
// Additional files to lock
if(isset($server_xml->lock_files) && !empty($server_xml->lock_files)){
$lockFiles = trim($server_xml->lock_files);
}else{
$lockFiles = "";
}
$steam_out = $remote->steam_cmd( $home_id,$home_info['home_path'],$installer_name,$modname,
$betaname,$betapwd,$login,$pass,$settings['steam_guard'],
$exec_folder_path,$exec_path,$precmd,$postcmd,$cfg_os,$lockFiles,$arch);
}
if( $steam_out === 0 )
{
print_failure( get_lang("failed_to_start_steam_update") );
return;
}
else if ( $steam_out === 1 )
{
print_success( get_lang("update_started") );
}
}
// Refresh update page.
else
{
if(isset($_POST['sgc']))
{
$remote->send_steam_guard_code($home_id, $_POST['sgc']);
return;
}
if ( isset( $_POST['stop_update_x'] ) )
{
$remote->stop_update($home_id);
print_success("Update stopped.");
$view->refresh("?m=gamemanager&amp;p=update&amp;update=refresh&amp;home_id=$home_id&amp;mod_id=$mod_id", 2);
return;
}
$update_complete = false;
if ( $update_active == 1 )
{
echo "<p class='note'>". get_lang("update_in_progress") ."</p>\n";
echo "<form method=POST><input type='image' name='stop_update' onsubmit='submit-form();' src='modules/administration/images/remove.gif'>". get_lang("stop_update") ."</input></form>";
}
else
{
$view->refresh("{CURRENT_PAGE}", 60);
print_success( get_lang("update_completed") );
echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id=".$home_info['home_id']."'><< ". get_lang("back") ."</a></td></tr></table>";
$update_complete = true;
}
if (empty($log_txt))
$log_txt = get_lang("not_available");
echo "<pre>".$log_txt."</pre>\n<script type=\"text/javascript\" src=\"js/modules/gamemanager_update.js\"></script>\n<div id='dialog' ></div>\n";
if(preg_match('/Two-factor code:$/m', $log_txt) and !isset($_GET['get_sgc']))
{
$view->refresh("?m=gamemanager&amp;p=update&amp;update=refresh&amp;home_id=$home_id&amp;mod_id=$mod_id&amp;get_sgc=show", 0);
return;
}
if(isset($_GET['get_sgc']) && $_GET['get_sgc'] == 'show')
return;
if ( $update_complete )
return;
}
echo "<p><a href=\"?m=gamemanager&amp;p=update&amp;update=refresh&amp;home_id=$home_id&amp;mod_id=$mod_id\">";
echo get_lang("refresh_steam_status") ."</a></p>";
$view->refresh("?m=gamemanager&amp;p=update&amp;update=refresh&amp;home_id=$home_id&amp;mod_id=$mod_id",5);
return;
}
}
?>

View file

@ -1,168 +0,0 @@
<?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 do_progress($kbytes,$totalsize)
{
$mbytes = round($kbytes / 1024, 2);
if($kbytes > 0)
{
$pct = round(( $kbytes / $totalsize ) * 100, 2);
}
else
{
$pct = unavailable;
}
#echo "Percent is $pct";
return "$totalsize;$mbytes;$pct";
}
require_once("includes/lib_remote.php");
require_once("modules/config_games/server_config_parser.php");
function exec_ogp_module() {
global $db, $view;
$home_id = isset($_REQUEST['home_id']) ? $_REQUEST['home_id'] : "";
$mod_id = isset($_REQUEST['mod_id']) ? $_REQUEST['mod_id'] : "";
$isAdmin = $db->isAdmin( $_SESSION['user_id'] );
if($isAdmin)
$home_info = $db->getGameHome($home_id);
else
$home_info = $db->getUserGameHome($_SESSION['user_id'],$home_id);
if ( $home_info === FALSE || preg_match("/u/",$home_info['access_rights']) != 1 )
{
print_failure( get_lang("no_rights") );
echo create_back_button("gamemanager","gamemanager");
return;
}
$home_id = $home_info['home_id'];
$state = isset($_REQUEST['state']) ? $_REQUEST['state'] : "";
$pid = isset($_REQUEST['pid']) ? $_REQUEST['pid'] : -1;
$filename = isset($_REQUEST['filename']) ? $_REQUEST['filename'] : "";
echo "<h2>". get_lang("install_update_manual") ." $home_info[home_name]</h2>";
if ( !empty($state) )
{
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']);
$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'],$home_info['timeout']);
if ( $state == "start" )
{
$postinstall = $server_xml->post_install ? $server_xml->post_install : "";
$pid = $remote->start_file_download($_REQUEST['url'],$home_info['home_path'],
$filename,"uncompress",$postinstall);
if ( $pid < 0 )
{
print_failure( get_lang("failed_to_start_file_download") );
return;
}
}
$url = $_REQUEST['url'];
$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']."/".$filename);
list($totalsize,$mbytes,$pct) = explode(";",do_progress($kbytes,$totalsize));
$totalmbytes = round($totalsize / 1024, 2);
$pct = $pct > 100 ? 100 : $pct;
echo '<div class="dragbox bloc rounded" style="background-color:#dce9f2;" >
<h4>'. get_lang("update_in_progress") ." ${mbytes}MB/${totalmbytes}MB</h4>
<div style='background-color:#dce9f2;' >
";
$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>
</div>
</div>";
if ( $remote->is_file_download_in_progress($pid) == 0 )
{
// Lock the executable when done
$remote->secure_path("chattr+i", $home_info['home_path'] . "/" . ($server_xml->exe_location ? $server_xml->exe_location . "/" : "") . $server_xml->server_exec_name);
print_success( get_lang("finished_manual_update") );
}
else
{
echo "<p><a href=\"?m=gamemanager&amp;p=update_manual&amp;state=refresh&amp;home_id=".
$home_id."&amp;mod_id=$mod_id&amp;pid=$pid&amp;url=$url&amp;filename=$filename\">Refresh</a></p>";
$view->refresh("?m=gamemanager&amp;p=update_manual&amp;state=refresh&amp;home_id=".
$home_id."&amp;mod_id=$mod_id&amp;pid=$pid&amp;url=$url&amp;filename=$filename",5);
}
echo create_back_button($_GET['m'],"game_monitor&amp;home_id=".$home_id);
}
else
{
echo "<form action='?m=gamemanager&amp;p=update_manual' method='post'>
<table class='center'>
<input type='hidden' name='home_id' value='$home_id' />
<input type='hidden' name='mod_id' value='$mod_id' />
<input type='hidden' name='state' value='start' />
<tr><td align='right'>". get_lang("game_name") .":</td><td align='left'>$home_info[game_name]</td></tr>
<tr><td align='right'>". get_lang("dest_dir") .":</td><td align='left'>$home_info[home_path]</td></tr>
<tr><td align='right'>". get_lang("remote_server") .":</td>
<td align='left'>$home_info[remote_server_name] ($home_info[agent_ip]:$home_info[agent_port])</td></tr>
<tr><td align='right'>". get_lang("file_url") .":</td>
<td align='left'><input type='text' id='url' name='url' value='' onChange='setFilename(this.value)' size='50' /></td></tr>
<tr><td colspan='2' class='info'>". get_lang("file_url_info") ."</td></tr>
<tr><td align='right'>". get_lang("dest_filename") .":</td>
<td align='left'><input type='text' id='filename' name='filename' value='' size='50'/></td></tr>
<tr><td colspan='2' class='info'>". get_lang("dest_filename_info") ."</td></tr>
</table>
<p><input type='submit' name='update' value='". get_lang("update_server") ."' /></p>
</form>";
?>
<script type="text/javascript">
function setFilename(url)
{
filename = url.substring(url.lastIndexOf('/')+1);
document.getElementById('filename').setAttribute('value', filename);
}
</script>
<?php
}
return;
}
?>

View file

@ -1,210 +0,0 @@
<?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("modules/config_games/server_config_parser.php");
function smart_resize_image($file,
$string = null,
$width = 0,
$height = 0,
$proportional = false,
$output = 'file',
$delete_original = true,
$use_linux_commands = false,
$quality = 100) {
if ( $height <= 0 && $width <= 0 ) return false;
if ( $file === null && $string === null ) return false;
# Setting defaults and meta
$info = $file !== null ? getimagesize($file) : getimagesizefromstring($string);
$image = '';
$final_width = 0;
$final_height = 0;
list($width_old, $height_old) = $info;
$cropHeight = $cropWidth = 0;
# Calculating proportionality
if ($proportional)
{
if ($width == 0)$factor = $height/$height_old;
elseif ($height == 0)$factor = $width/$width_old;
else $factor = min( $width / $width_old, $height / $height_old );
$final_width = round( $width_old * $factor );
$final_height = round( $height_old * $factor );
}
else
{
$final_width = ( $width <= 0 ) ? $width_old : $width;
$final_height = ( $height <= 0 ) ? $height_old : $height;
$widthX = $width_old / $width;
$heightX = $height_old / $height;
$x = min($widthX, $heightX);
$cropWidth = ($width_old - $width * $x) / 2;
$cropHeight = ($height_old - $height * $x) / 2;
}
# Loading image to memory according to type
switch ( $info[2] ) {
case IMAGETYPE_JPEG: $file !== null ? $image = imagecreatefromjpeg($file) : $image = imagecreatefromstring($string); break;
case IMAGETYPE_GIF: $file !== null ? $image = imagecreatefromgif($file) : $image = imagecreatefromstring($string); break;
case IMAGETYPE_PNG: $file !== null ? $image = imagecreatefrompng($file) : $image = imagecreatefromstring($string); break;
default: return false;
}
# This is the resizing/resampling/transparency-preserving magic
$image_resized = imagecreatetruecolor( $final_width, $final_height );
if ( ($info[2] == IMAGETYPE_GIF) || ($info[2] == IMAGETYPE_PNG) ) {
$transparency = imagecolortransparent($image);
$palletsize = imagecolorstotal($image);
if ($transparency >= 0 && $transparency < $palletsize)
{
$transparent_color = imagecolorsforindex($image, $transparency);
$transparency = imagecolorallocate($image_resized, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']);
imagefill($image_resized, 0, 0, $transparency);
imagecolortransparent($image_resized, $transparency);
}
elseif ($info[2] == IMAGETYPE_PNG)
{
imagealphablending($image_resized, false);
$color = imagecolorallocatealpha($image_resized, 0, 0, 0, 127);
imagefill($image_resized, 0, 0, $color);
imagesavealpha($image_resized, true);
}
}
imagecopyresampled($image_resized, $image, 0, 0, $cropWidth, $cropHeight, $final_width, $final_height, $width_old - 2 * $cropWidth, $height_old - 2 * $cropHeight);
# Taking care of original, if needed
if ( $delete_original )
{
if ( $use_linux_commands ) exec('rm '.$file);
else @unlink($file);
}
# Preparing a method of providing result
switch ( strtolower($output) )
{
case 'browser':
$mime = image_type_to_mime_type($info[2]);
header("Content-type: $mime");
$output = NULL;
break;
case 'file':
$output = $file;
break;
case 'return':
return $image_resized;
break;
default:
break;
}
# Writing image according to type to the output destination and image quality
switch ( $info[2] ) {
case IMAGETYPE_GIF: imagegif($image_resized, $output); break;
case IMAGETYPE_JPEG: imagejpeg($image_resized, $output, $quality); break;
case IMAGETYPE_PNG:
$quality = 9 - (int)((0.9*$quality)/10.0);
imagepng($image_resized, $output, $quality);
break;
default: return false;
}
return true;
}
function exec_ogp_module() {
global $db;
if( isset($_POST['home_id']) and isset($_POST['mod_id']) and isset($_POST['map']) and isset($_POST['extension']) )
{
$home_id = $_POST['home_id'];
$mod_id = $_POST['mod_id'];
$map = $_POST['map'];
$extension = $_POST['extension'];
$home_info = $db->getGameHome($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;
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']);
if ($server_xml->protocol == "gameq")
$query_name = $server_xml->gameq_query_name;
elseif ($server_xml->protocol == "lgsl")
$query_name = $server_xml->lgsl_query_name;
else
$query_name = $mod; // If query name does not exist use mod key instead.
$dest_path = "protocol". DIRECTORY_SEPARATOR ."lgsl". DIRECTORY_SEPARATOR ."maps". DIRECTORY_SEPARATOR ."$query_name". DIRECTORY_SEPARATOR ."$mod";
$dest_file = $dest_path . DIRECTORY_SEPARATOR . "$map.$extension";
if( $_FILES['map-image']['error'] == 0 )
{
if( !file_exists($dest_path))
{
if(!@mkdir($dest_path, 0700, true))
{
echo get_lang_f('cant_create_folder',$dest_path);
return;
}
}
if(@move_uploaded_file( $_FILES["map-image"]["tmp_name"], $dest_file ))
{
print_lang('uploaded_successfully');
smart_resize_image($dest_file, null, 160, 120, true);
}
else
{
echo get_lang_f('cant_write_file',$dest_file);
}
}
else
{
switch ($_FILES['map-image']['error'])
{
case UPLOAD_ERR_INI_SIZE:
echo get_lang_f('exceeded_php_directive','upload_max_filesize='.ini_get('upload_max_filesize'));
case UPLOAD_ERR_FORM_SIZE:
echo get_lang_f('exceeded_php_directive','post_max_size='.ini_get('post_max_size'));
default:
print_lang('unknown_errors');
}
}
}
}
?>

View file

@ -1,181 +0,0 @@
<?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('home_handling_functions.php');
require_once("modules/config_games/server_config_parser.php");
function exec_ogp_module()
{
global $db;
global $view;
list($home_id, $mod_id, $ip, $port) = explode("-", $_GET['home_id-mod_id-ip-port']);
$user_id = $_SESSION['user_id'];
$isAdmin = $db->isAdmin( $user_id );
if($isAdmin)
$home_info = $db->getGameHome($home_id);
else
$home_info = $db->getUserGameHome($user_id,$home_id);
$current_mod_info = $home_info['mods'][$mod_id];
$home_cfg_id = $current_mod_info['home_cfg_id'];
$mod_cfg_id = $current_mod_info['mod_cfg_id'];
if($home_cfg_id === null && $mod_cfg_id === null){
print_failure(get_lang('invalid_game_mod_id'));
return;
}
if ( $home_info === FALSE )
{
print_failure( get_lang("no_access_to_home") );
return;
}
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']);
if ( !$server_xml )
{
echo create_back_button( $_GET['m'], 'game_monitor&home_id-mod_id-ip-port='.$_GET['home_id-mod_id-ip-port'] );
return;
}
require_once('includes/lib_remote.php');
$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'],$home_info['timeout']);
$home_log = "";
if( isset( $server_xml->console_log ) )
{
$log_retval = $remote->get_log(OGP_SCREEN_TYPE_HOME,
$home_info['home_id'],
clean_path($home_info['home_path']),
$home_log, 100, (string) $server_xml->console_log);
}
else
{
$log_retval = $remote->get_log(OGP_SCREEN_TYPE_HOME,
$home_info['home_id'],
clean_path($home_info['home_path']."/".$server_xml->exe_location),
$home_log);
}
if ($log_retval == 0)
{
print_failure( get_lang("agent_offline") );
echo create_back_button( $_GET['m'], 'game_monitor&home_id-mod_id-ip-port='.$_GET['home_id-mod_id-ip-port'] );
}
elseif ($log_retval == 1 || $log_retval == 2)
{
// Force log file contents to be UTF-8 (fixes http://www.opengamepanel.org/forum/viewthread.php?thread_id=5379)
if(hasValue($home_log)){
$home_log = utf8_encode($home_log);
}
// Using the refreshed class
if( isset($_GET['refreshed']) )
{
echo "<pre class='log'>".htmlentities($home_log)."</pre>";
}
else
{
echo "<h2>".htmlentities($home_info['home_name'])."</h2>";
if($log_retval == 1)
{
require_once("includes/refreshed.php");
$control = '<form method="GET" >
<input type="hidden" name="m" value="gamemanager" />
<input type="hidden" name="p" value="log" />
<input type="hidden" name="home_id-mod_id-ip-port" value="'.$_GET['home_id-mod_id-ip-port'].'" />';
if(isset($_GET['setInterval']))
$control .= "<input type='hidden' name='setInterval' value='" . $_GET['setInterval'] . "' />";
if(isset($_GET['view_player_commands']))
$control .= "<input type='hidden' name='view_player_commands' value='" . $_GET['view_player_commands'] . "' />";
$control .= '<input type="submit" name="size" value="';
if( isset( $_GET['size'] ) and $_GET['size'] == "+" )
{
$height = "100%";
$control .= '-';
}
else
{
$height = "500px";
$control .= '+';
}
$control .= '" /></form>';
$intervals = array( "4s" => "4000",
"8s" => "8000",
"30s" => "30000",
"2m" => "120000",
"5m" => "300000" );
$intSel = '<form action="" method="GET" >
<input type="hidden" name="m" value="gamemanager" />
<input type="hidden" name="p" value="log" />
<input type="hidden" name="home_id-mod_id-ip-port" value="'.$_GET['home_id-mod_id-ip-port'].'" />';
if(isset($_GET['size']))
$intSel .= "<input type='hidden' name='size' value='" . $_GET['size'] . "' />";
if(isset($_GET['view_player_commands']))
$intSel .= "<input type='hidden' name='view_player_commands' value='" . $_GET['view_player_commands'] . "' />";
$intSel .= get_lang("refresh_interval") . ':<select name="setInterval" onchange="this.form.submit();">';
foreach ($intervals as $interval => $value )
{
$selected = "";
if ( isset( $_GET['setInterval'] ) AND $_GET['setInterval'] == $value )
$selected = 'selected="selected"';
$intSel .= '<option value="'.$value.'" '.$selected.' >'.$interval.'</option>';
}
$intSel .= "</select></form>";
$setInterval = isset($_GET['setInterval']) ? $_GET['setInterval'] : 4000;
$refresh = new refreshed();
$pos = $refresh->add("home.php?m=gamemanager&p=log&type=cleared&refreshed&home_id-mod_id-ip-port=". $_GET['home_id-mod_id-ip-port']);
echo $refresh->getdiv($pos,"height:".$height.";overflow:auto;max-width:1600px;");
?><script type="text/javascript">$(document).ready(function(){ <?php echo $refresh->build("$setInterval"); ?>} ); </script><?php
echo "<table class='center' ><tr><td>$intSel</td><td>$control</td></tr></table>";
if( ($server_xml->control_protocol and preg_match("/^r?l?con2?$/", $server_xml->control_protocol)) OR
($server_xml->gameq_query_name and $server_xml->gameq_query_name == "minecraft") OR
($server_xml->lgsl_query_name and $server_xml->lgsl_query_name == "7dtd") )
require('modules/gamemanager/rcon.php');
}
else
{
echo "<pre class='log'>" . htmlentities($home_log) . "</pre>";
print_failure( get_lang("server_not_running") );
}
echo create_back_button( $_GET['m'], 'game_monitor&home_id-mod_id-ip-port='.$_GET['home_id-mod_id-ip-port'] );
}
}
else
{
print_failure(get_lang_f('unable_to_get_log',$log_retval));
echo create_back_button( $_GET['m'], 'game_monitor&home_id-mod_id-ip-port='.$_GET['home_id-mod_id-ip-port'] );
}
}
?>