Moved the Agents into their own repo. Kept the agent.pl just for reference
This commit is contained in:
parent
22381be29a
commit
8680a02b13
18132 changed files with 0 additions and 2569420 deletions
|
|
@ -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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
function create_selection($selection,$flag)
|
||||
{
|
||||
return "<tr><td align='right'><label for='".clean_id_string($selection)."'>".get_lang($selection).":</label></td>
|
||||
<td align='left'><input id='".clean_id_string($selection)."' type='checkbox' name='".$selection."' value='1' checked='checked' /></td></tr><tr>
|
||||
<td align='left' class='info' colspan='2'>".get_lang($selection.'_info')."</td></tr>";
|
||||
}
|
||||
function exec_ogp_module()
|
||||
{
|
||||
global $db, $settings;
|
||||
global $view;
|
||||
echo "<h2>".get_lang('add_new_game_home')."</h2>";
|
||||
echo "<p><a href='?m=user_games'><< ".get_lang('back_to_game_servers')."</a></p>";
|
||||
|
||||
$default_home_dir = $settings["default_game_server_home_path_prefix"];
|
||||
|
||||
$remote_servers = $db->getRemoteServers();
|
||||
if( $remote_servers === FALSE )
|
||||
{
|
||||
echo "<p class='note'>".get_lang('no_remote_servers_configured')."</p>
|
||||
<p><a href='?m=server'>".get_lang('add_remote_server')."</a></p>";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$game_cfgs = $db->getGameCfgs();
|
||||
$users = $db->getUserList();
|
||||
|
||||
if ( $game_cfgs === FALSE )
|
||||
{
|
||||
echo "<p class='note'>".get_lang('no_game_configurations_found')." <a href='?m=config_games'>".get_lang('game_configurations')."</a></p>";
|
||||
return;
|
||||
}
|
||||
|
||||
echo "<p> <span class='note'>".get_lang('note').":</span> ".get_lang('add_mods_note')."</p>";
|
||||
|
||||
$selections = array();
|
||||
foreach($db->getModulesAccessRights() as $ar)
|
||||
$selections[$ar['description']] = $ar['flag'];
|
||||
|
||||
if ( isset($_REQUEST['add_game_home']) )
|
||||
{
|
||||
$rserver_id = $_POST['rserver_id'];
|
||||
$home_cfg_id = $_POST['home_cfg_id'];
|
||||
$web_user_id = trim($_POST['web_user_id']);
|
||||
$control_password = genRandomString(8);
|
||||
$access_rights = "";
|
||||
|
||||
$ftp = FALSE;
|
||||
foreach ($selections as $selection => $flag)
|
||||
{
|
||||
if (isset($_REQUEST[$selection]))
|
||||
{
|
||||
$access_rights .= $flag;
|
||||
if ($flag == "t")
|
||||
{
|
||||
$ftp = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( empty( $web_user_id ) )
|
||||
{
|
||||
print_failure(get_lang('game_path_empty'));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ( $game_cfgs as $row )
|
||||
{
|
||||
if($row['home_cfg_id'] == $home_cfg_id){
|
||||
$server_name = $row['game_name'];
|
||||
$game_key = $row['game_key'];
|
||||
$readable_game_key = substr($game_key, 0, stripos($game_key, "_"));
|
||||
$readable_game_key = strtolower($readable_game_key);
|
||||
}
|
||||
}
|
||||
foreach ( $remote_servers as $server )
|
||||
{
|
||||
if($server['remote_server_id'] == $rserver_id) $ogp_user = $server['ogp_user'];
|
||||
}
|
||||
foreach ( $users as $user )
|
||||
{
|
||||
if($user['user_id'] == $web_user_id) $web_user = $user['users_login'];
|
||||
}
|
||||
$ftppassword = genRandomString(8);
|
||||
|
||||
// Game path logic
|
||||
$game_path = "/home/".$ogp_user."/OGP_User_Files/"; // Default
|
||||
|
||||
$skipId = false;
|
||||
if(hasValue($default_home_dir)){
|
||||
// Replace some user supported variables with actual value.
|
||||
$game_path = $default_home_dir;
|
||||
$game_path = str_replace("{USERNAME}", $web_user, $game_path);
|
||||
if(stripos($game_path, "{SKIPID}") !== false){
|
||||
$skipId = true;
|
||||
}
|
||||
$game_path = str_replace("{SKIPID}", "", $game_path);
|
||||
$game_path = str_replace("{GAMEKEY}", $readable_game_key, $game_path);
|
||||
}
|
||||
|
||||
if($game_path[strlen($game_path)-1] != "/"){ // Make sure the path ends with forward slash
|
||||
$game_path .= "/";
|
||||
}
|
||||
|
||||
$game_path = clean_path($game_path); // Clean it
|
||||
// End game path logic
|
||||
|
||||
if ( ( $new_home_id = $db->addGameHome($rserver_id,$web_user_id,$home_cfg_id,
|
||||
clean_path($game_path),$server_name,$control_password,$ftppassword,$skipId) )!== FALSE )
|
||||
{
|
||||
$success = $db->assignHomeTo("user",$web_user_id,$new_home_id,$access_rights);
|
||||
if($success){
|
||||
$home_info = $db->getGameHomeWithoutMods($new_home_id);
|
||||
require_once('includes/lib_remote.php');
|
||||
$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'],$home_info['timeout']);
|
||||
|
||||
// Create new home directory if it doesn't already exist
|
||||
$remote->exec("mkdir -p " . clean_path($game_path) . (!$skipId ? $new_home_id : ""));
|
||||
|
||||
if($ftp)
|
||||
{
|
||||
$host_stat = $remote->status_chk();
|
||||
if( $host_stat === 1)
|
||||
$remote->ftp_mgr("useradd", $home_info['home_id'], $home_info['ftp_password'], $home_info['home_path']);
|
||||
$db->changeFtpStatus('enabled',$new_home_id);
|
||||
}
|
||||
print_success(get_lang('game_home_added'));
|
||||
$db->logger(get_lang('game_home_added')." ($server_name)");
|
||||
$view->refresh("?m=user_games&p=edit&home_id=$new_home_id", 0);
|
||||
}else{
|
||||
print_failure(get_lang_f("failed_to_assign_home_to_user", $new_home_id, $web_user . " " . $db->getError()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure(get_lang_f("failed_to_add_home_to_db",$db->getError()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// View form to add more servers.
|
||||
if( !isset($_POST['rserver_id']) )
|
||||
{
|
||||
echo "<form action='?m=user_games&p=add' method='post'>";
|
||||
echo "<table class='center'>";
|
||||
echo "<tr><td class='right'>".get_lang('game_server')."</td><td class='left'><select onchange=".'"this.form.submit()"'." name='rserver_id'>\n";
|
||||
echo "<option>".get_lang('select_remote_server')."</option>\n";
|
||||
foreach ( $remote_servers as $server )
|
||||
{
|
||||
echo "<option value='".$server['remote_server_id']."'>".
|
||||
$server['remote_server_name']." (".$server['agent_ip'].")</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo "</form>";
|
||||
echo "</td></tr></table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isset($_POST['rserver_id']))
|
||||
$rhost_id = $_POST['rserver_id'];
|
||||
$remote_server = $db->getRemoteServer($rhost_id);
|
||||
require_once('includes/lib_remote.php');
|
||||
$remote = new OGPRemoteLibrary($remote_server['agent_ip'],$remote_server['agent_port'],$remote_server['encryption_key'],$remote_server['timeout']);
|
||||
$host_stat = $remote->status_chk();
|
||||
if( $host_stat === 1)
|
||||
$os = $remote->what_os();
|
||||
else
|
||||
{
|
||||
print_failure(get_lang_f("caution_agent_offline_can_not_get_os_and_arch_showing_servers_for_all_platforms"));
|
||||
$os = "Unknown OS";
|
||||
}
|
||||
echo "<form action='?m=user_games&p=add' method='post'>";
|
||||
echo "<table class='center'>";
|
||||
echo "<tr><td class='right'>".get_lang('game_type')."</td><td class='left'> <select name='home_cfg_id'>\n";
|
||||
echo get_game_selector($os, $game_cfgs);
|
||||
echo "</select>\n</td></tr>";
|
||||
// Select user
|
||||
echo "<tr><td class='right'>".get_lang('login').":</td>
|
||||
<td class='left'><select name='web_user_id'>";
|
||||
$users = $db->getUserList();
|
||||
|
||||
foreach ( $users as $user ){
|
||||
// Only users and admins can be assigned homes... not subusers
|
||||
if(is_null($user['users_parent'])){
|
||||
echo "<option value='".$user['user_id']."'>".$user['users_login']."</option>\n";
|
||||
}
|
||||
}
|
||||
echo "</select>\n</td></tr>";
|
||||
// Select permisions
|
||||
echo "<tr><td class='right'>".get_lang('access_rights').":</td>
|
||||
<td class='left'>";
|
||||
foreach ( $selections as $selection => $flag)
|
||||
{
|
||||
echo create_selection($selection,$flag);
|
||||
}
|
||||
echo "</td></tr>";
|
||||
// Assign home
|
||||
echo "<tr><td align='center' colspan='2'>
|
||||
<input type='hidden' name='rserver_id' value='".$rhost_id."' />".
|
||||
"<input type='submit' name='add_game_home' value='".
|
||||
get_lang('add_game_home')."' /></td></tr></table>";
|
||||
echo "</form>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,228 +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 create_selection($selection,$flag)
|
||||
{
|
||||
return "<tr><td align='right'><label for='".clean_id_string($selection)."'>".get_lang($selection).":</label></td>
|
||||
<td align='left'><input id='".clean_id_string($selection)."' type='checkbox' name='".$selection."' value='1' checked='checked' /></td></tr><tr>
|
||||
<td align='left' class='info' colspan='2'>".get_lang($selection.'_info')."</td></tr>";
|
||||
}
|
||||
function exec_ogp_module()
|
||||
{
|
||||
global $db, $settings;
|
||||
global $view;
|
||||
echo "<h2>".get_lang('add_new_game_home')."</h2>";
|
||||
echo "<p><a href='?m=user_games'><< ".get_lang('back_to_game_servers')."</a></p>";
|
||||
|
||||
$default_home_dir = $settings["default_game_server_home_path_prefix"];
|
||||
|
||||
$remote_servers = $db->getRemoteServers();
|
||||
if( $remote_servers === FALSE )
|
||||
{
|
||||
echo "<p class='note'>".get_lang('no_remote_servers_configured')."</p>
|
||||
<p><a href='?m=server'>".get_lang('add_remote_server')."</a></p>";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$game_cfgs = $db->getGameCfgs();
|
||||
$users = $db->getUserList();
|
||||
|
||||
if ( $game_cfgs === FALSE )
|
||||
{
|
||||
echo "<p class='note'>".get_lang('no_game_configurations_found')." <a href='?m=config_games'>".get_lang('game_configurations')."</a></p>";
|
||||
return;
|
||||
}
|
||||
|
||||
echo "<p> <span class='note'>".get_lang('note').":</span> ".get_lang('add_mods_note')."</p>";
|
||||
|
||||
$selections = array();
|
||||
foreach($db->getModulesAccessRights() as $ar)
|
||||
$selections[$ar['description']] = $ar['flag'];
|
||||
|
||||
if ( isset($_REQUEST['add_game_home']) )
|
||||
{
|
||||
$rserver_id = $_POST['rserver_id'];
|
||||
$home_cfg_id = $_POST['home_cfg_id'];
|
||||
$web_user_id = trim($_POST['web_user_id']);
|
||||
$control_password = genRandomString(8);
|
||||
$access_rights = "";
|
||||
|
||||
$ftp = FALSE;
|
||||
foreach ($selections as $selection => $flag)
|
||||
{
|
||||
if (isset($_REQUEST[$selection]))
|
||||
{
|
||||
$access_rights .= $flag;
|
||||
if ($flag == "t")
|
||||
{
|
||||
$ftp = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( empty( $web_user_id ) )
|
||||
{
|
||||
print_failure(get_lang('game_path_empty'));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ( $game_cfgs as $row )
|
||||
{
|
||||
if($row['home_cfg_id'] == $home_cfg_id){
|
||||
$server_name = $row['game_name'];
|
||||
$game_key = $row['game_key'];
|
||||
$readable_game_key = substr($game_key, 0, stripos($game_key, "_"));
|
||||
$readable_game_key = strtolower($readable_game_key);
|
||||
}
|
||||
}
|
||||
foreach ( $remote_servers as $server )
|
||||
{
|
||||
if($server['remote_server_id'] == $rserver_id) $ogp_user = $server['ogp_user'];
|
||||
}
|
||||
foreach ( $users as $user )
|
||||
{
|
||||
if($user['user_id'] == $web_user_id) $web_user = $user['users_login'];
|
||||
}
|
||||
$ftppassword = genRandomString(8);
|
||||
|
||||
// Game path logic
|
||||
$game_path = "/home/".$ogp_user."/OGP_User_Files/"; // Default
|
||||
|
||||
$skipId = false;
|
||||
if(hasValue($default_home_dir)){
|
||||
// Replace some user supported variables with actual value.
|
||||
$game_path = $default_home_dir;
|
||||
$game_path = str_replace("{USERNAME}", $web_user, $game_path);
|
||||
if(stripos($game_path, "{SKIPID}") !== false){
|
||||
$skipId = true;
|
||||
}
|
||||
$game_path = str_replace("{SKIPID}", "", $game_path);
|
||||
$game_path = str_replace("{GAMEKEY}", $readable_game_key, $game_path);
|
||||
}
|
||||
|
||||
if($game_path[strlen($game_path)-1] != "/"){ // Make sure the path ends with forward slash
|
||||
$game_path .= "/";
|
||||
}
|
||||
|
||||
$game_path = clean_path($game_path); // Clean it
|
||||
// End game path logic
|
||||
|
||||
if ( ( $new_home_id = $db->addGameHome($rserver_id,$web_user_id,$home_cfg_id,
|
||||
clean_path($game_path),$server_name,$control_password,$ftppassword,$skipId) )!== FALSE )
|
||||
{
|
||||
$success = $db->assignHomeTo("user",$web_user_id,$new_home_id,$access_rights);
|
||||
if($success){
|
||||
$home_info = $db->getGameHomeWithoutMods($new_home_id);
|
||||
require_once('includes/lib_remote.php');
|
||||
$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'],$home_info['timeout']);
|
||||
|
||||
// Create new home directory if it doesn't already exist
|
||||
$remote->exec("mkdir -p " . clean_path($game_path) . (!$skipId ? $new_home_id : ""));
|
||||
|
||||
if($ftp)
|
||||
{
|
||||
$host_stat = $remote->status_chk();
|
||||
if( $host_stat === 1)
|
||||
$remote->ftp_mgr("useradd", $home_info['home_id'], $home_info['ftp_password'], $home_info['home_path']);
|
||||
$db->changeFtpStatus('enabled',$new_home_id);
|
||||
}
|
||||
print_success(get_lang('game_home_added'));
|
||||
$db->logger(get_lang('game_home_added')." ($server_name)");
|
||||
$view->refresh("?m=user_games&p=edit&home_id=$new_home_id", 0);
|
||||
}else{
|
||||
print_failure(get_lang_f("failed_to_assign_home_to_user", $new_home_id, $web_user . " " . $db->getError()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure(get_lang_f("failed_to_add_home_to_db",$db->getError()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// View form to add more servers.
|
||||
if( !isset($_POST['rserver_id']) )
|
||||
{
|
||||
echo "<form action='?m=user_games&p=add' method='post'>";
|
||||
echo "<table class='center'>";
|
||||
echo "<tr><td class='right'>".get_lang('game_server')."</td><td class='left'><select onchange=".'"this.form.submit()"'." name='rserver_id'>\n";
|
||||
echo "<option>".get_lang('select_remote_server')."</option>\n";
|
||||
foreach ( $remote_servers as $server )
|
||||
{
|
||||
echo "<option value='".$server['remote_server_id']."'>".
|
||||
$server['remote_server_name']." (".$server['agent_ip'].")</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo "</form>";
|
||||
echo "</td></tr></table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isset($_POST['rserver_id']))
|
||||
$rhost_id = $_POST['rserver_id'];
|
||||
$remote_server = $db->getRemoteServer($rhost_id);
|
||||
require_once('includes/lib_remote.php');
|
||||
$remote = new OGPRemoteLibrary($remote_server['agent_ip'],$remote_server['agent_port'],$remote_server['encryption_key'],$remote_server['timeout']);
|
||||
$host_stat = $remote->status_chk();
|
||||
if( $host_stat === 1)
|
||||
$os = $remote->what_os();
|
||||
else
|
||||
{
|
||||
print_failure(get_lang_f("caution_agent_offline_can_not_get_os_and_arch_showing_servers_for_all_platforms"));
|
||||
$os = "Unknown OS";
|
||||
}
|
||||
echo "<form action='?m=user_games&p=add' method='post'>";
|
||||
echo "<table class='center'>";
|
||||
echo "<tr><td class='right'>".get_lang('game_type')."</td><td class='left'> <select name='home_cfg_id'>\n";
|
||||
echo get_game_selector($os, $game_cfgs);
|
||||
echo "</select>\n</td></tr>";
|
||||
// Select user
|
||||
echo "<tr><td class='right'>".get_lang('login').":</td>
|
||||
<td class='left'><select name='web_user_id'>";
|
||||
$users = $db->getUserList();
|
||||
foreach ( $users as $user ){
|
||||
// Only users and admins can be assigned homes... not subusers
|
||||
if(is_null($user['users_parent'])){
|
||||
echo "<option value='".$user['user_id']."'>".$user['users_login']."</option>\n";
|
||||
}
|
||||
}
|
||||
echo "</select>\n</td></tr>";
|
||||
// Select permisions
|
||||
echo "<tr><td class='right'>".get_lang('access_rights').":</td>
|
||||
<td class='left'>";
|
||||
foreach ( $selections as $selection => $flag)
|
||||
{
|
||||
echo create_selection($selection,$flag);
|
||||
}
|
||||
echo "</td></tr>";
|
||||
// Assign home
|
||||
echo "<tr><td align='center' colspan='2'>
|
||||
<input type='hidden' name='rserver_id' value='".$rhost_id."' />".
|
||||
"<input type='submit' name='add_game_home' value='".
|
||||
get_lang('add_game_home')."' /></td></tr></table>";
|
||||
echo "</form>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,320 +0,0 @@
|
|||
<script type="text/javascript" src="js/modules/user_games-assign.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.
|
||||
*
|
||||
*/
|
||||
|
||||
function create_selection($selection,$flag,$access_rights)
|
||||
{
|
||||
$right = "<tr><td align='right'><label for='".clean_id_string($selection)."'>".get_lang($selection).":</label></td>
|
||||
<td align='left'><input id='".clean_id_string($selection)."' type='checkbox' name='".$selection."' value='1' checked='checked' /></td></tr>
|
||||
<tr><td colspan='2' class='info'>".get_lang($selection.'_info')."</td></tr>";
|
||||
|
||||
if (preg_match("/$flag/",$access_rights))
|
||||
return $right;
|
||||
}
|
||||
|
||||
function exec_ogp_module()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$isAdmin = $db->isAdmin($_SESSION['user_id']);
|
||||
|
||||
if(isset($_REQUEST['user_id'])){
|
||||
if(empty($_REQUEST['user_id']) || $db->getUserById($_REQUEST['user_id']) == null)
|
||||
{
|
||||
print_failure(get_lang("valid_user"));
|
||||
return;
|
||||
}
|
||||
}else if(isset($_REQUEST['group_id'])){
|
||||
if(empty($_REQUEST['group_id']) || $db->getGroupById($_REQUEST['group_id']) == null)
|
||||
{
|
||||
print_failure(get_lang("valid_group"));
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
print_failure(get_lang("invalid_url"));
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['user_id'] ) && !$isAdmin )
|
||||
{
|
||||
echo "<p class='note'>".get_lang("not_available")."</p>";
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['group_id'] ) && !$isAdmin )
|
||||
{
|
||||
$result = $db->getUserGroupList($_SESSION['user_id']);
|
||||
foreach ( $result as $row ) #loop through the groups
|
||||
{
|
||||
if ( $row['group_id'] == $_REQUEST['group_id'] )
|
||||
{
|
||||
$own_group = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !$isAdmin && !isset($own_group) )
|
||||
{
|
||||
echo "<p class='note'>".get_lang("not_available")."</p>";
|
||||
return;
|
||||
}
|
||||
|
||||
$selections = array();
|
||||
$full_access = '';
|
||||
foreach($db->getModulesAccessRights() as $ar)
|
||||
{
|
||||
$selections[$ar['description']] = $ar['flag'];
|
||||
$full_access .= $ar['flag'];
|
||||
}
|
||||
|
||||
if(isset($_POST['change_access_rights']))
|
||||
{
|
||||
if(is_array($_POST['home_ids']))
|
||||
{
|
||||
if($isAdmin)
|
||||
$access_right_flags = implode('',$_POST['flags']);
|
||||
|
||||
foreach($_POST['home_ids'] as $i => $home_id)
|
||||
{
|
||||
if(!$isAdmin)
|
||||
{
|
||||
$home_info = $db->getUserGameHome($_SESSION['user_id'],$home_id);
|
||||
$access_rights = $home_info['access_rights'];
|
||||
$flags = $_POST['flags'];
|
||||
foreach($flags as $i => $flag)
|
||||
{
|
||||
if(!strstr($access_rights, $flag))
|
||||
unset($flags[$i]);
|
||||
}
|
||||
$access_right_flags = implode('',$flags);
|
||||
}
|
||||
if(!$db->updateAccessRightsFor($_POST['id_type'],$_POST['assign_id'],$home_id,$access_right_flags))
|
||||
print_failure(get_lang_f("failed_to_assign_game_for_",$id_type,$db->getError()));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset($_REQUEST['user_id']) )
|
||||
{
|
||||
$assign_id = $_REQUEST['user_id'];
|
||||
$id_type = "user";
|
||||
$user = $db->getUserById($assign_id);
|
||||
$assign_name = $user['users_login'];
|
||||
}
|
||||
else if ( isset($_REQUEST['group_id']) )
|
||||
{
|
||||
$assign_id = $_REQUEST['group_id'];
|
||||
$id_type = "group";
|
||||
$group = $db->getGroupById($assign_id);
|
||||
$assign_name = $group['group_name'];
|
||||
}
|
||||
|
||||
$submit = isset($_POST['submit']) ? $_POST['submit'] : "";
|
||||
|
||||
if( isset($_REQUEST['assign']) )
|
||||
{
|
||||
$access_rights = "";
|
||||
|
||||
foreach ($selections as $selection => $flag)
|
||||
{
|
||||
if (isset($_REQUEST[$selection]))
|
||||
$access_rights .= $flag;
|
||||
}
|
||||
|
||||
$hacker = FALSE;
|
||||
if( !$isAdmin )
|
||||
{
|
||||
$home_info = $db->getUserGameHome($_SESSION['user_id'],$_REQUEST['home_id']);
|
||||
if(!$home_info)
|
||||
{
|
||||
print_failure(get_lang_f("failed_to_assign_game_for",$id_type,"(Hacking attempt)"));
|
||||
$hacker = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($selections as $selection => $flag)
|
||||
{
|
||||
if (isset($_REQUEST[$selection]))
|
||||
{
|
||||
if( !preg_match("/$flag/",$home_info['access_rights']) )
|
||||
{
|
||||
print_failure(get_lang_f("failed_to_assign_game_for",$id_type,"(Hacking attempt)"));
|
||||
$hacker = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$hacker)
|
||||
{
|
||||
if ( $db->assignHomeTo($id_type,$assign_id,$_REQUEST['home_id'], $access_rights) === TRUE )
|
||||
{
|
||||
$db->updateExpirationDate($_REQUEST['home_id'], $_POST['expiration_date'], $id_type, $assign_id);
|
||||
print_success(get_lang_f("assigned_home_to_".$id_type,$_REQUEST['home_id'],$assign_name));
|
||||
$db->logger(get_lang_f("assigned_home_to_".$id_type,$_REQUEST['home_id'],$assign_name));
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure(get_lang_f("failed_to_assign_game_for_",$id_type,$db->getError()));
|
||||
}
|
||||
}
|
||||
unset($_POST['home_id']);
|
||||
}
|
||||
else if ( isset($_REQUEST['unassign']) )
|
||||
{
|
||||
if ( $db->unassignHomeFrom($id_type,$assign_id,$_REQUEST['home_id']) === TRUE )
|
||||
{
|
||||
print_success(get_lang_f("unassigned_home_from_".$id_type,$_REQUEST['home_id'],$assign_name));
|
||||
$db->logger(get_lang_f("unassigned_home_from_".$id_type,$_REQUEST['home_id'],$assign_name));
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure(get_lang_f("failed_to_assign_game_from_",$id_type));
|
||||
}
|
||||
}
|
||||
|
||||
$remote_servers = $db->getRemoteServers();
|
||||
|
||||
if ( empty($remote_servers) )
|
||||
{
|
||||
print_failure(get_lang("no_remote_servers_available_please_add_at_least_one"));
|
||||
echo "<p><a href='?m=server'>".get_lang("add_remote_server")."</a></p>";
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $isAdmin )
|
||||
$available_homes = $db->getAvailableHomesFor($id_type,$assign_id);
|
||||
else
|
||||
$available_homes = $db->getAvailableUserHomesFor($id_type,$assign_id,$_SESSION['user_id']);
|
||||
|
||||
if ( !empty($available_homes) )
|
||||
{
|
||||
echo "<h2>".get_lang_f('assign_new_home_to_'.$id_type,$assign_name)."</h2>";
|
||||
echo "<form action='?m=user_games&p=assign' method='post'>";
|
||||
echo "<input name='".$id_type."_id' value='".$assign_id."' type='hidden' />\n";
|
||||
echo "<table class='center'><tr><td align='right'><label for='home_id'>".get_lang("select_home").":</label></td>";
|
||||
echo '<td align="left"><select id="home_id" name="home_id" onchange="this.form.submit();">';
|
||||
echo "<option></option>\n";
|
||||
foreach ( $available_homes as $home )
|
||||
{
|
||||
if( isset($_POST['home_id']) && $_POST['home_id'] == $home['home_id'])
|
||||
$selected="selected='selected'";
|
||||
else
|
||||
$selected="";
|
||||
echo "<option value='".$home['home_id']."' $selected >".htmlentities($home['home_name'])."</option>\n";
|
||||
}
|
||||
echo "</select></td>\n";
|
||||
if( isset($_POST['home_id']) and !empty($_POST['home_id']) )
|
||||
{
|
||||
?>
|
||||
<link rel="stylesheet" type="text/css" href="js/datetimepicker/jquery.datetimepicker.min.css">
|
||||
<script src="js/datetimepicker/jquery.datetimepicker.full.min.js"></script>
|
||||
<script type="text/javascript" src="js/modules/user_games.js"></script>
|
||||
<?php
|
||||
if( $isAdmin )
|
||||
{
|
||||
$access_rights = $full_access;
|
||||
}
|
||||
else
|
||||
{
|
||||
$home_info = $db->getUserGameHome($_SESSION['user_id'],$_POST['home_id']);
|
||||
$access_rights = $home_info['access_rights'];
|
||||
}
|
||||
foreach ( $selections as $selection => $flag)
|
||||
{
|
||||
echo create_selection($selection,$flag,$access_rights);
|
||||
}
|
||||
echo "<tr><td class='right'>".get_lang("assign_expiration_date").":</td>\n".
|
||||
"<td class='left'>\n".
|
||||
"<tr><td class='right'>".get_lang("server_expiration_date").":</td>\n".
|
||||
"<td class='left'>".
|
||||
"<div id='datetimepicker' class='input-append date'>".
|
||||
"<input name='expiration_date' placeholder='dd/MM/yyyy hh:mm:ss' type='text' value='X' data-today='".date('d/m/Y H:i:s')."' >\n".
|
||||
"</div></td></tr>\n".
|
||||
"<tr><td colspan='2' class='info'>". get_lang("assign_expiration_date_info") ."</td></tr>\n";
|
||||
echo "<tr><td colspan='2'><input type='submit' name='assign' value='".get_lang("assign")."' /></td></tr>\n";
|
||||
}
|
||||
echo "</table></form>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<h2>".get_lang("no_more_homes_available_that_can_be_assigned_for_this_$id_type")."</h2>";
|
||||
|
||||
if( $isAdmin )
|
||||
echo get_lang_f("you_can_add_a_new_game_server_from","<a href='?m=user_games'>".get_lang("game_servers")."</a>")."</p>";
|
||||
}
|
||||
// View servers for use if there are any.
|
||||
$game_homes = $db->getHomesFor($id_type,$assign_id);
|
||||
|
||||
if( empty($game_homes) )
|
||||
{
|
||||
echo "<h3>".get_lang_f("no_homes_assigned_to_".$id_type,$assign_name)."</h3>";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<h2>".get_lang("assigned_homes")."</h2>";
|
||||
echo '<table class="center">';
|
||||
echo "<tr><th>".get_lang("home_id")."</th><th>".get_lang("game_server")."</th>
|
||||
<th>".get_lang("game_type")."</th>
|
||||
<th align='center'>".get_lang("game_home")."</th>
|
||||
<th>".get_lang("game_home_name")."</th><th>".get_lang("access_rights")."</th>
|
||||
<th>".get_lang("assign_expiration_date")."</th>
|
||||
<th>".get_lang("actions")."</th></tr>";
|
||||
foreach( $game_homes as $row )
|
||||
{
|
||||
$access_rights = empty($row['access_rights']) ? "-" : $row['access_rights'];
|
||||
$type = $id_type == "group" ? "user_group_expiration_date" : "user_expiration_date";
|
||||
$expiration = $row[$type] == "X" ? "X" : date('d/m/Y H:i:s', $row[$type]);
|
||||
echo "<tr><td><input type=checkbox class='change_access_rights' data-home_id='$row[home_id]' >$row[home_id]</td>
|
||||
<td>".$row['agent_ip']." (Agent)</td>
|
||||
<td>$row[game_name]</td>
|
||||
<td>$row[home_path]</td>
|
||||
<td>" . htmlentities($row["home_name"]) . "</td>
|
||||
<td>$access_rights</td>
|
||||
<td>$expiration</td>
|
||||
<td>
|
||||
<form action='?m=user_games&p=assign' method='post'>
|
||||
<input name='".$id_type."_id' value='$assign_id' type='hidden' />
|
||||
<input name='home_id' value='".$row['home_id']."' type='hidden' />
|
||||
<input type='submit' name='unassign' value='".get_lang("unassign")."' /></form></td>
|
||||
</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
echo "<button id=\"change_access_rights_submit\" onclick=\"change_access_rights('".trim($id_type)."', '".trim($assign_id),"')\">".get_lang('change_access_rights_for_selected_servers')."</button>\n".
|
||||
"<div id='dialog' ";
|
||||
foreach ( $selections as $selection => $flag)
|
||||
{
|
||||
echo "data-$flag=\"$selection\" ";
|
||||
}
|
||||
echo "></div>";
|
||||
}
|
||||
|
||||
if ( $id_type === "group" )
|
||||
echo create_back_button('user_admin','show_groups');
|
||||
else
|
||||
echo create_back_button('user_admin');
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
.levelup, .folder, #addfolder {
|
||||
cursor:pointer;
|
||||
}
|
||||
|
|
@ -1,143 +0,0 @@
|
|||
<script type="text/javascript" src="js/modules/user_games.js"></script>
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2018 The OGP Development Team
|
||||
*
|
||||
* http://www.opengamepanel.org/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once('includes/lib_remote.php');
|
||||
|
||||
function litefm_check($home_id)
|
||||
{
|
||||
if (isset($_GET['folder']))
|
||||
$_SESSION['browser_cwd_'.$home_id] = stripslashes($_GET['folder']);
|
||||
|
||||
if (isset($_GET['item']))
|
||||
{
|
||||
if($_SESSION['browser_folders_'.$home_id][$_GET['item']])
|
||||
{
|
||||
$_SESSION['browser_cwd_'.$home_id] = clean_path(@$_SESSION['browser_cwd_'.$home_id] . "/" .
|
||||
$_SESSION['browser_folders_'.$home_id][$_GET['item']]);
|
||||
}
|
||||
}
|
||||
// To go back a dir, we just use dirname to strip the last directory or file off the path
|
||||
if (isset($_GET['back']))
|
||||
{
|
||||
$_SESSION['browser_cwd_'.$home_id] = dirname( $_SESSION['browser_cwd_'.$home_id] );
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function exec_ogp_module()
|
||||
{
|
||||
$home_id = $_REQUEST['home_id'];
|
||||
|
||||
if (empty($home_id))
|
||||
{
|
||||
print_failure(get_lang('home_id_missing'));
|
||||
return;
|
||||
}
|
||||
|
||||
global $db;
|
||||
$isAdmin = $db->isAdmin( $_SESSION['user_id'] );
|
||||
if($isAdmin)
|
||||
$home_cfg = $db->getGameHome($home_id);
|
||||
else
|
||||
$home_cfg = $db->getUserGameHome($_SESSION['user_id'],$home_id);
|
||||
|
||||
if ($home_cfg === FALSE)
|
||||
{
|
||||
print_failure(get_lang('no_access_to_home'));
|
||||
return;
|
||||
}
|
||||
|
||||
$home_id = $home_cfg['home_id'];
|
||||
|
||||
litefm_check($home_id);
|
||||
|
||||
$remote = new OGPRemoteLibrary($home_cfg['agent_ip'], $home_cfg['agent_port'], $home_cfg['encryption_key'], $home_cfg['timeout']);
|
||||
|
||||
if($isAdmin and isset($_GET['all_fs']))
|
||||
$path = clean_path("/".@$_SESSION['browser_cwd_'.$home_id]);
|
||||
else
|
||||
$path = clean_path($home_cfg['home_path'].@$_SESSION['browser_cwd_'.$home_id]);
|
||||
|
||||
while(!$remote->rfile_exists($path))
|
||||
{
|
||||
$_SESSION['browser_cwd_'.$home_id] = dirname( $_SESSION['browser_cwd_'.$home_id] );
|
||||
if($isAdmin && $_GET['all_fs'])
|
||||
$path = clean_path("/".@$_SESSION['browser_cwd_'.$home_id]);
|
||||
else
|
||||
$path = clean_path($home_cfg['home_path'].@$_SESSION['browser_cwd_'.$home_id]);
|
||||
}
|
||||
|
||||
if( isset( $_GET['create_folder'] ) )
|
||||
{
|
||||
$folder_name = stripslashes($_GET['folder_name']);
|
||||
$folder_path = clean_path( $path . "/" . $folder_name );
|
||||
$remote->shell_action('create_dir', $folder_path);
|
||||
$db->logger( get_lang("create_folder") . ": " . $folder_path );
|
||||
}
|
||||
|
||||
$dirlist = $remote->remote_dirlistfm($path);
|
||||
$_SESSION['browser_folders_'.$home_id] = array();
|
||||
if ( is_array($dirlist) )
|
||||
{
|
||||
$selected_path = clean_path("/".@$_SESSION['browser_cwd_'.$home_id]);
|
||||
echo "<p id=selected_path >$selected_path</p>".
|
||||
"<table class='center' width='440px' >\n<b class='levelup' title='".
|
||||
get_lang("level_up_info")."' data-home-id='".$home_id."' data-path='".$path."' >";
|
||||
if( $path != "/" )
|
||||
echo '.. '.get_lang("level_up");
|
||||
echo "</b><tr><td align=left >\n".
|
||||
get_lang('folder')."</td>".
|
||||
"<td align=center >".get_lang('owner').
|
||||
"</td><td align=center >".get_lang('group')."</td></tr>\n";
|
||||
|
||||
if(isset($dirlist['directorys']) and is_array($dirlist['directorys']))
|
||||
{
|
||||
$dirlist['directorys'] = array_orderby($dirlist['directorys'], 'filename', SORT_ASC);
|
||||
$i = 0;
|
||||
foreach($dirlist['directorys'] as $directory)
|
||||
{
|
||||
echo "<tr>\n".
|
||||
"<td class='folder' align=left data-item='$i' >".
|
||||
"<img src=\"" . check_theme_image("images/folder.png") . "\" alt=\"Directory\" /> ".
|
||||
"<b>" . $directory['filename'] . "</b></td>";
|
||||
echo "<td align=center >" . $directory['user'] . "</td>".
|
||||
"<td align=center >" . $directory['group']. "</td>\n".
|
||||
"</tr>\n";
|
||||
$_SESSION['browser_folders_'.$home_id][$i] = $directory['filename'];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
echo "<tr>\n".
|
||||
"<td align=left>".
|
||||
"<input style='width:100%;' type=text name=dirname placeholder='".
|
||||
get_lang("add_folder")."' title='".get_lang("add_folder_info").
|
||||
"' ></td><td align=left > <img id='addfolder' src=\"" . check_theme_image("images/addfolder.png") . "\" title=\"".
|
||||
get_lang("add_folder")."\" /> ".
|
||||
"</td>\n".
|
||||
"</tr>\n".
|
||||
"</table>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,63 +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;
|
||||
$expired_servers = $db->resultQuery("SELECT home_name, home_id, server_expiration_date FROM OGP_DB_PREFIXserver_homes WHERE server_expiration_date NOT LIKE 'X' AND server_expiration_date <= ".time().";");
|
||||
if($expired_servers)
|
||||
{
|
||||
foreach($expired_servers as $expired_server)
|
||||
{
|
||||
$db->logger(date('d/m/Y H:i:s', $expired_server['server_expiration_date'])." : SERVER EXPIRED: HOME ID:$expired_server[home_id] ($expired_server[home_name])");
|
||||
$db->check_expire_date(0, $expired_server['home_id'], array('server'));
|
||||
}
|
||||
}
|
||||
|
||||
$expired_users = $db->resultQuery("SELECT user_id, home_id, user_expiration_date FROM OGP_DB_PREFIXuser_homes WHERE user_expiration_date NOT LIKE 'X' AND user_expiration_date <= ".time().";");
|
||||
if($expired_users)
|
||||
{
|
||||
foreach($expired_users as $expired_user)
|
||||
{
|
||||
$db->logger(date('d/m/Y H:i:s', $expired_user['user_expiration_date'])." : USER ASSIGNATION EXPIRED : HOME ID:$expired_user[home_id] TO USER ID:$expired_user[user_id]");
|
||||
$db->check_expire_date($expired_user['user_id'], $expired_user['home_id'], array('user'));
|
||||
}
|
||||
}
|
||||
|
||||
$expired_groups = $db->resultQuery("SELECT g.group_id, g.home_id, g.user_group_expiration_date, ug.user_id
|
||||
FROM OGP_DB_PREFIXuser_group_homes g
|
||||
INNER JOIN
|
||||
OGP_DB_PREFIXuser_groups ug
|
||||
ON ug.group_id=g.group_id
|
||||
WHERE g.user_group_expiration_date NOT LIKE 'X' AND g.user_group_expiration_date <= ".time()." GROUP BY g.home_id;");
|
||||
if($expired_groups)
|
||||
{
|
||||
foreach($expired_groups as $expired_group)
|
||||
{
|
||||
$db->logger(date('d/m/Y H:i:s', $expired_group['user_group_expiration_date'])." : GROUP ASSIGNATION EXPIRED : HOME ID:$expired_group[home_id] TO GROUP ID:$expired_group[group_id]");
|
||||
$db->check_expire_date($expired_group['user_id'], $expired_group['home_id'], array('user_group'));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
.html5-progress-bar {
|
||||
padding: 15px 15px;
|
||||
border-radius: 3px;
|
||||
background-color: #f5f5f5;
|
||||
box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, .2);
|
||||
}
|
||||
.html5-progress-bar progress {
|
||||
background-color: #f3f3f3;
|
||||
border: 0;
|
||||
width: 93%;
|
||||
height: 18px;
|
||||
border-radius: 9px;
|
||||
}
|
||||
.html5-progress-bar progress::-webkit-progress-bar {
|
||||
background-color: #e3e3e3;
|
||||
border-radius: 9px;
|
||||
}
|
||||
.html5-progress-bar progress::-webkit-progress-value {
|
||||
background: #cdeb8e;
|
||||
background: -moz-linear-gradient(top, #cdeb8e 0%, #a5c956 100%);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#cdeb8e), color-stop(100%,#a5c956));
|
||||
background: -webkit-linear-gradient(top, #cdeb8e 0%,#a5c956 100%);
|
||||
background: -o-linear-gradient(top, #cdeb8e 0%,#a5c956 100%);
|
||||
background: -ms-linear-gradient(top, #cdeb8e 0%,#a5c956 100%);
|
||||
background: linear-gradient(to bottom, #cdeb8e 0%,#a5c956 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cdeb8e', endColorstr='#a5c956',GradientType=0 );
|
||||
border-radius: 9px;
|
||||
}
|
||||
.html5-progress-bar progress::-moz-progress-bar {
|
||||
background: #cdeb8e;
|
||||
background: -moz-linear-gradient(top, #cdeb8e 0%, #a5c956 100%);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#cdeb8e), color-stop(100%,#a5c956));
|
||||
background: -webkit-linear-gradient(top, #cdeb8e 0%,#a5c956 100%);
|
||||
background: -o-linear-gradient(top, #cdeb8e 0%,#a5c956 100%);
|
||||
background: -ms-linear-gradient(top, #cdeb8e 0%,#a5c956 100%);
|
||||
background: linear-gradient(to bottom, #cdeb8e 0%,#a5c956 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cdeb8e', endColorstr='#a5c956',GradientType=0 );
|
||||
border-radius: 9px;
|
||||
}
|
||||
.html5-progress-bar .progress-value {
|
||||
padding: 0px 5px;
|
||||
line-height: 20px;
|
||||
margin-left: 5px;
|
||||
font-size: 1.2em;
|
||||
color: #555;
|
||||
height: 18px;
|
||||
float: right;
|
||||
}
|
||||
|
|
@ -1,246 +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, $settings;
|
||||
|
||||
$home_id = $_REQUEST['home_id'];
|
||||
$default_home_dir = $settings["default_game_server_home_path_prefix"];
|
||||
|
||||
$server_row = $db->getGameHomeWithoutMods($home_id);
|
||||
$game_key = $server_row["game_key"];
|
||||
$readable_game_key = substr($game_key, 0, stripos($game_key, "_"));
|
||||
$readable_game_key = strtolower($readable_game_key);
|
||||
|
||||
if ( empty($server_row) )
|
||||
{
|
||||
print_failure(get_lang('invalid_home_id'));
|
||||
return;
|
||||
}
|
||||
|
||||
echo "<h2>".get_lang_f('cloning_home',htmlentities($server_row['home_name']))."</h2>";
|
||||
echo create_back_button('user_games');
|
||||
|
||||
include_once('includes/lib_remote.php');
|
||||
$remote = new OGPRemoteLibrary($server_row['agent_ip'],$server_row['agent_port'],$server_row['encryption_key'],$server_row['timeout']);
|
||||
|
||||
if(isset($_REQUEST['clone_home']))
|
||||
{
|
||||
$server_name = $_POST['new_home_name'];
|
||||
$user_group = $_POST['user_group'];
|
||||
$web_user = $db->getUserById($server_row['user_id_main']);
|
||||
$web_user = $web_user["users_login"];
|
||||
|
||||
// Game path logic
|
||||
$game_path = "/home/".$server_row['ogp_user']."/OGP_User_Files/"; // Default
|
||||
|
||||
$skipId = false;
|
||||
if(hasValue($default_home_dir)){
|
||||
$game_path = $default_home_dir;
|
||||
$game_path = str_replace("{USERNAME}", $web_user, $game_path); // Replace some user supported variables with actual value.
|
||||
if(stripos($game_path, "{SKIPID}") !== false){
|
||||
$skipId = true;
|
||||
}
|
||||
$game_path = str_replace("{SKIPID}", "", $game_path);
|
||||
$game_path = str_replace("{GAMEKEY}", $readable_game_key, $game_path);
|
||||
}
|
||||
|
||||
if($game_path[strlen($game_path)-1] != "/"){ // Make sure the path ends with forward slash
|
||||
$game_path .= "/";
|
||||
}
|
||||
|
||||
$game_path = clean_path($game_path); // Clean it
|
||||
// End game path logic
|
||||
|
||||
$clone_home_id = $db->addGameHome($server_row['remote_server_id'], $server_row['user_id_main'],
|
||||
$server_row['home_cfg_id'], $game_path, $server_name, '', genRandomString(8), $skipId);
|
||||
|
||||
$server_path = $game_path;
|
||||
|
||||
if(!$skipId)
|
||||
$server_path .= $clone_home_id;
|
||||
|
||||
// Create new home directory if it doesn't already exist
|
||||
$remote->exec("mkdir -p " . clean_path($server_path));
|
||||
|
||||
|
||||
if ( $clone_home_id === FALSE )
|
||||
{
|
||||
print_failure(get_lang_f('cloning_of_home_failed',$home_id));
|
||||
return;
|
||||
}
|
||||
|
||||
if( isset($_REQUEST['clone_mods']) )
|
||||
{
|
||||
$enabled_mods = $db->getHomeMods($home_id);
|
||||
if( empty($enabled_mods) )
|
||||
{
|
||||
print_failure(get_lang('note').": ".get_lang('no_mods_to_clone'));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ( $enabled_mods as $enabled_rows )
|
||||
{
|
||||
if ( $db->addModToGameHome($clone_home_id,
|
||||
$enabled_rows['mod_cfg_id']) === FALSE )
|
||||
{
|
||||
print_failure(get_lang_f('failed_to_add_mod',$enabled_rows['mod_cfg'],
|
||||
$clone_home_id));
|
||||
return;
|
||||
}
|
||||
if ( $db->updateGameModParams($enabled_rows['max_players'],
|
||||
$enabled_rows['extra_params'],$enabled_rows['cpu_affinity'],
|
||||
$enabled_rows['nice'],$clone_home_id,
|
||||
$enabled_rows['mod_cfg_id']) === FALSE )
|
||||
{
|
||||
print_failure(get_lang_f('failed_to_update_mod_settings',$clone_home_id));
|
||||
return;
|
||||
}
|
||||
}
|
||||
print_success(get_lang_f('successfully_cloned_mods',$clone_home_id));
|
||||
}
|
||||
}
|
||||
|
||||
print_success(get_lang('successfully_copied_home_database'));
|
||||
|
||||
# do the remote copy call here
|
||||
echo "<p>".get_lang_f('copying_home_remotely',$server_row['home_path'],$server_path)."</p>";
|
||||
$db->logger(get_lang_f('copying_home_remotely',$server_row['home_path'],$server_path));
|
||||
$clone_rc = $remote->clone_home($server_row['home_path'],$server_path,$user_group);
|
||||
|
||||
if($clone_rc == -1)
|
||||
{
|
||||
print_success(get_lang('game_server_copy_is_running'));
|
||||
?>
|
||||
<div class="html5-progress-bar">
|
||||
<progress id="progressbar" value="0" max="100"></progress>
|
||||
<span class="progress-value">0%</span>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function()
|
||||
{
|
||||
$.get( "home.php?m=user_games&type=cleared&p=get_size&home_id=<?php echo $home_id;?>&bytes", function( orig_data ) {
|
||||
var orig_size = parseInt(orig_data,10);
|
||||
var refreshId = setInterval(function() {
|
||||
$.get( "home.php?m=user_games&type=cleared&p=get_size&home_id=<?php echo $clone_home_id;?>&bytes", function( dest_data ) {
|
||||
var dest_size = parseInt(dest_data,10);
|
||||
var progress = parseInt(dest_size * 100 / orig_size);
|
||||
$('#progressbar').val(progress);
|
||||
$('.progress-value').html(progress + '%');
|
||||
if(progress == 100)
|
||||
{
|
||||
clearInterval(refreshId);
|
||||
}
|
||||
});
|
||||
}, 2000);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
elseif($clone_rc == 1)
|
||||
{
|
||||
print_success(get_lang('game_server_copy_was_successful'));
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure(get_lang_f('game_server_copy_failed_with_return_code', $clone_rc));
|
||||
}
|
||||
echo "<br><a href='home.php?m=user_games'><< ".get_lang('back_to_game_servers')."</a>";
|
||||
return;
|
||||
}
|
||||
|
||||
// Form to edit game path.
|
||||
$avail_mods = $db->getHomeMods($home_id);
|
||||
|
||||
$read_status = $remote->remote_readfile('/etc/passwd', $passwd_array);
|
||||
if ( $read_status === -1 )
|
||||
{
|
||||
print_failure(get_lang('agent_offline'));
|
||||
return;
|
||||
}
|
||||
else if ( $read_status == 1 )
|
||||
{
|
||||
$passwd_array = preg_split("/\n/",$passwd_array);
|
||||
}
|
||||
|
||||
require_once("includes/form_table_class.php");
|
||||
|
||||
$ft = new FormTable();
|
||||
|
||||
$ft->start_form('?m=user_games&p=clone');
|
||||
$ft->add_field_hidden('home_id',$home_id);
|
||||
$ft->start_table();
|
||||
$ft->add_custom_field('agent_ip',$server_row['agent_ip']);
|
||||
$ft->add_custom_field('current_home_path',$server_row['home_path']);
|
||||
$ft->add_field('string','new_home_name',htmlentities($server_row['home_name']));
|
||||
echo "<tr><td class='right'>".get_lang('clone_mods').":</td>
|
||||
<td class='left'><input type='checkbox' name='clone_mods' value='y' /></td></tr>";
|
||||
echo "<input name='user_group' type='hidden' value='".get_user_uid_gid_from_passwd($passwd_array,$server_row['ogp_user'])."' /></tr>";
|
||||
echo "</table>";
|
||||
$ft->add_button('submit','clone_home',get_lang('clone_home'));
|
||||
echo "<p class='info'>".get_lang('the_name_of_the_server_to_help_users_to_identify_it')."</p>";
|
||||
echo "</form>";
|
||||
|
||||
echo "<h3>".get_lang('ips_and_ports_used_in_this_home')."</h3>";
|
||||
echo "<p>".get_lang('note_ips_and_ports_are_not_cloned')."</p>";
|
||||
|
||||
$assigned = $db->getHomeIpPorts($home_id);
|
||||
if( !empty($assigned) )
|
||||
{
|
||||
foreach ( $assigned as $assigned_rows )
|
||||
{
|
||||
echo "<p>".$assigned_rows['ip'].":".$assigned_rows['port']."</p>\n";
|
||||
}
|
||||
}
|
||||
|
||||
$enabled_mods = $db->getHomeMods($home_id);
|
||||
|
||||
echo "<h3>".get_lang('mods_and_settings_for_this_game_server')."</h3>";
|
||||
if( empty($enabled_mods) )
|
||||
{
|
||||
print_failure(get_lang('note').": ".get_lang('note_no_mods'));
|
||||
return;
|
||||
}
|
||||
|
||||
echo "<table class='center'>\n";
|
||||
echo "<tr><td>".get_lang('mod_name')."</td><td>".
|
||||
get_lang('max_players')."</td><td>".
|
||||
get_lang('extra_cmd_line_args')."</td><td>".
|
||||
get_lang('cpu_affinity')."</td><td>".
|
||||
get_lang('nice_level')."</td></tr>\n";
|
||||
|
||||
foreach ( $enabled_mods as $enabled_rows )
|
||||
{
|
||||
echo "<tr>";
|
||||
echo "<td>".$enabled_rows['mod_name']."</td>";
|
||||
echo "<td>".$enabled_rows['max_players']."</td>";
|
||||
echo "<td>".$enabled_rows['extra_params']."</td>";
|
||||
echo "<td>".$enabled_rows['cpu_affinity']."</td>";
|
||||
echo "<td>".$enabled_rows['nice']."</td></tr>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,183 +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");
|
||||
require_once('includes/form_table_class.php');
|
||||
|
||||
$custom_fields = array();
|
||||
$isAdmin = false;
|
||||
function renderCustomFields($field, $home_id)
|
||||
{
|
||||
global $db, $custom_fields, $isAdmin;
|
||||
$attributesString = "";
|
||||
$disabledString = ((!property_exists($field, 'access') || $field->access != "admin") || $isAdmin) ? "" : "disabled ";
|
||||
|
||||
foreach ($field->attribute as $attribute)
|
||||
$attributesString .= $attribute['key']. "='$attribute' ";
|
||||
|
||||
if (is_array($custom_fields) and array_key_exists((string)$field['key'], $custom_fields))
|
||||
$fieldValue = (string)$custom_fields[(string)$field['key']];
|
||||
else
|
||||
$fieldValue = (string)$field->default_value;
|
||||
|
||||
$idString = "id='".clean_id_string($field['key'])."'";
|
||||
$nameString = "name='fields[".$field['key']."]'";
|
||||
$fieldType = $field['type'];
|
||||
if ($fieldType == "select")
|
||||
{
|
||||
$inputElementString = "<select $idString $nameString $disabledString>";
|
||||
foreach ($field->option as $option)
|
||||
{
|
||||
$optionValue = (string)($option['value']);
|
||||
$selectedString = ($optionValue == $fieldValue) ? "selected='selected'" : "";
|
||||
$valueString = "value=\"".str_replace('"', """, strip_real_escape_string($optionValue))."\"";
|
||||
$inputElementString .= "<option $selectedString $valueString>$option</option>";
|
||||
}
|
||||
$inputElementString .="</select>";
|
||||
} else
|
||||
{
|
||||
if ($fieldType == "checkbox_key_value") {
|
||||
if ($fieldValue) // convert the XML object to string
|
||||
$attributesString .= "checked='checked' ";
|
||||
$fieldValue = $field['key'];
|
||||
$fieldType = "checkbox";
|
||||
}
|
||||
else if ($fieldType == "checkbox")
|
||||
{
|
||||
if ($fieldValue) // convert the XML object to string
|
||||
$attributesString .= "checked='checked' ";
|
||||
}
|
||||
$inputElementString = "<input $idString $nameString ".
|
||||
"type='$fieldType' value=\"".str_replace('"', """, strip_real_escape_string($fieldValue))."\" $attributesString $disabledString/>";
|
||||
}
|
||||
|
||||
echo "<tr><td class='right'><label for='".clean_id_string($field['key'])."'>".$field['key'].
|
||||
":</label></td><td class='left'>$inputElementString<label for='".clean_id_string($field['key'])."'>";
|
||||
|
||||
if ( !empty($field->caption) )
|
||||
echo $field->caption;
|
||||
if ( !empty($field->desc) )
|
||||
echo "<br/><span class='info'>(".$field->desc.")</span>";
|
||||
|
||||
echo "</label></td></tr>\n";
|
||||
}
|
||||
|
||||
function exec_ogp_module()
|
||||
{
|
||||
global $db,$view,$custom_fields,$isAdmin;
|
||||
|
||||
$home_id = $_GET['home_id'];
|
||||
|
||||
$isAdmin = $db->isAdmin( $_SESSION['user_id'] );
|
||||
if( $isAdmin )
|
||||
{
|
||||
$home_info = $db->getGameHome($home_id);
|
||||
$custom_fileds_access_enabled = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$home_info = $db->getUserGameHome($_SESSION['user_id'],$home_id);
|
||||
$custom_fileds_access_enabled = preg_match("/c/",$home_info['access_rights']) > 0 ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
if( !$home_info OR !$custom_fileds_access_enabled )
|
||||
return;
|
||||
|
||||
//get used custom value or get default
|
||||
$custom_fields = json_decode($db->getCustomFields($home_id), True);
|
||||
|
||||
$server_xml = read_server_config(SERVER_CONFIG_LOCATION.$home_info['home_cfg_file']);
|
||||
|
||||
include_once('includes/lib_remote.php');
|
||||
$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'],$home_info['timeout']);
|
||||
|
||||
echo "<h2>".get_lang('editing_home_called')." \"".htmlentities($home_info['home_name'])."\"</h2>";
|
||||
|
||||
echo "<p>";
|
||||
echo "<a href='?m=gamemanager&p=game_monitor&home_id=$home_id'><< ".get_lang('back_to_game_monitor')."</a>";
|
||||
echo "</p>";
|
||||
|
||||
if(isset($_POST['update_settings']))
|
||||
{
|
||||
$save_field = $_POST['fields'];
|
||||
$updatedSettings = array();
|
||||
foreach($server_xml->custom_fields->field as $field)
|
||||
{
|
||||
if (array_key_exists((string)$field['key'], $custom_fields)){
|
||||
$origValue = (string)$custom_fields[(string)$field['key']];
|
||||
}else{
|
||||
$origValue = "";
|
||||
}
|
||||
|
||||
$found = 0;
|
||||
foreach ($save_field as $key => $value )
|
||||
{
|
||||
if($key == (string)$field['key']){
|
||||
$found++;
|
||||
|
||||
// If locked by an admin, ignore the value posted by the user
|
||||
$lockedByAdmin = false;
|
||||
if(property_exists($field, 'access') && $field->access == "admin")
|
||||
{
|
||||
$lockedByAdmin = true;
|
||||
if(!$isAdmin){
|
||||
$value = $origValue; // Set it to the old saved value (which was last set by an admin) or set it to its default value
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen(trim($value)) > 0) {
|
||||
$updatedSettings[$key] = $value;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($found == 0 && !empty($origValue)){
|
||||
$updatedSettings[(string)$field['key']] = $origValue;
|
||||
}
|
||||
}
|
||||
|
||||
if(is_array($updatedSettings) && count($updatedSettings) > 0){
|
||||
$db->changeCustomFields($home_info['home_id'],json_encode($updatedSettings));
|
||||
}else{
|
||||
$db->changeCustomFields($home_info['home_id'],"");
|
||||
}
|
||||
|
||||
print_success(get_lang('settings_updated'));
|
||||
$view->refresh("?m=user_games&p=custom_fields&home_id=".$home_id);
|
||||
}
|
||||
|
||||
$ft = new FormTable();
|
||||
$ft->start_form("", "post", "autocomplete=\"off\"");
|
||||
$ft->start_table();
|
||||
foreach($server_xml->custom_fields->field as $field)
|
||||
{
|
||||
renderCustomFields($field, $home_info['home_id']);
|
||||
}
|
||||
$ft->end_table();
|
||||
$ft->add_button("submit","update_settings",get_lang('update_settings'));
|
||||
$ft->end_form();
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,186 +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 logHandling($home_id, $action = 'delete', &$remote){
|
||||
$fileId = str_pad($home_id, 9, '0', STR_PAD_LEFT);
|
||||
|
||||
$files = array(
|
||||
'screenlogs/screenlog.OGP_HOME_'.$fileId => 'file',
|
||||
'screenlogs/screenlog.OGP_UPDATE_'.$fileId => 'file',
|
||||
'screenlogs/home_id_'.$home_id.'/' => 'dir',
|
||||
);
|
||||
|
||||
if($action == 'backup'){
|
||||
$remote->exec('tar czf screenlogs/home_log_backup_'.$home_id.'.tar.gz '.implode(' ', array_keys($files)));
|
||||
}
|
||||
|
||||
foreach($files as $file => $type){
|
||||
if($remote->rfile_exists($file)){
|
||||
if($type == 'file'){
|
||||
$remote->exec('rm '.$file);
|
||||
}
|
||||
|
||||
if($type == 'dir'){
|
||||
$remote->exec('rm -r '.$file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function exec_ogp_module() {
|
||||
global $db, $view;
|
||||
require_once('includes/lib_remote.php');
|
||||
$home_id = $_GET['home_id'];
|
||||
$y = isset($_GET['y']) ? $_GET['y'] : "";
|
||||
$files = isset($_GET['files']) ? $_GET['files'] : "";
|
||||
$force = isset($_GET['force']) ? $_GET['force'] : "";
|
||||
$logAction = !empty($_GET['logAction']) ? $_GET['logAction'] : false;
|
||||
|
||||
$home_info = $db->getGameHomeWithoutMods($home_id);
|
||||
|
||||
if( $home_info === FALSE )
|
||||
{
|
||||
print_failure("User home_id $home_id not found.");
|
||||
$view->refresh("?m=user_games");
|
||||
return;
|
||||
}
|
||||
|
||||
$remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key'], $home_info['timeout']);
|
||||
$agent_online = $remote->status_chk() === 1;
|
||||
|
||||
if($y != 'y')
|
||||
{
|
||||
echo "<p>".get_lang_f('sure_to_delete_serverid_from_remoteip_and_directory',
|
||||
$home_info['home_id'], $home_info['agent_ip'], $home_info['home_path'])."</p>";
|
||||
if($agent_online)
|
||||
{
|
||||
$r = $remote->rfile_exists($home_info['home_path']);
|
||||
if($r == 1)
|
||||
{
|
||||
echo "<p><a href=\"?m=user_games&p=del&y=y&home_id=$home_id&files=y\" id=\"deleteLink\">" .
|
||||
get_lang("yes_and_delete_the_files") . "</a> ";
|
||||
echo '<input type="checkbox" name="logAction" id="doBackup"><label for="doBackup">Delete and Backup Logs</label> |';
|
||||
}
|
||||
}
|
||||
else
|
||||
print_failure(get_lang("agent_offline") . " " . get_lang("remove_it_anyway") . "?");
|
||||
echo "<a href=\"?m=user_games&p=del&y=y&home_id=$home_id\">".
|
||||
get_lang("yes") . "</a> | <a href=\"?m=user_games\">".
|
||||
get_lang("no") . "</a></p>";
|
||||
|
||||
// Not the prettiest way to do this...
|
||||
echo '<script>
|
||||
$(function(){
|
||||
var linkElement = $("#deleteLink"),
|
||||
defaultLink = linkElement.attr("href"),
|
||||
newLink = linkElement.attr("href");
|
||||
|
||||
$("#doBackup").change(function(){
|
||||
if($(this).is(":checked")){
|
||||
linkElement.attr("href", newLink + "&logAction=backup");
|
||||
}else{
|
||||
linkElement.attr("href", defaultLink);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $db->IsFtpEnabled($home_id) and $force != 'y' and $agent_online )
|
||||
{
|
||||
$ftp_login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id;
|
||||
if ( $remote->ftp_mgr("userdel", $ftp_login) === 0 )
|
||||
{
|
||||
$del_files = $files == 'y' ? '&files=y' : '';
|
||||
print_failure(get_lang("failed_to_remove_ftp_account_from_remote_server"));
|
||||
echo "<p>" . get_lang("remove_it_anyway") . "<p>
|
||||
<a href=\"?m=user_games&p=del&y=y&force=y&home_id=$home_id$del_files\">".
|
||||
get_lang("yes") . "</a> | <a href=\"?m=user_games\">".
|
||||
get_lang("no") . "</a></p>";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if($y == 'y')
|
||||
{
|
||||
if($agent_online)
|
||||
{
|
||||
$assigned = $db->getHomeIpPorts($home_id);
|
||||
if( !empty($assigned) )
|
||||
{
|
||||
foreach($assigned as $address)
|
||||
{
|
||||
if($remote->rfile_exists( "startups/".$address['ip']."-".$address['port'] ) === 1)
|
||||
{
|
||||
require_once("modules/gamemanager/home_handling_functions.php");
|
||||
require_once("modules/config_games/server_config_parser.php");
|
||||
exec_operation('stop', $home_id, FALSE, $address['ip'], $address['port']);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($logAction && is_numeric($home_id)){
|
||||
logHandling($home_id, $logAction, $remote);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete cronjobs
|
||||
if(file_exists('modules/cron/shared_cron_functions.php')){
|
||||
require_once('modules/cron/shared_cron_functions.php');
|
||||
if(function_exists("deleteJobsByHomeServerID")){
|
||||
deleteJobsByHomeServerID($home_id);
|
||||
}
|
||||
}
|
||||
|
||||
if ( $db->deleteGameHome($home_id) === FALSE )
|
||||
{
|
||||
print_failure(get_lang("failed_to_remove_gamehome_from_database"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
print_success(get_lang_f('successfully_deleted_game_server_with_id', $home_info['home_id']));
|
||||
$db->logger(get_lang_f('successfully_deleted_game_server_with_id', $home_info['home_id']));
|
||||
}
|
||||
}
|
||||
|
||||
if($files == 'y' and $agent_online)
|
||||
{
|
||||
if($remote->remove_home($home_info['home_path']) == 1)
|
||||
{
|
||||
print_success(get_lang_f('sucessfully_deleted', $home_info['home_path']));
|
||||
$db->logger(get_lang_f('sucessfully_deleted', $home_info['home_path']));
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure(get_lang_f('the_agent_had_a_problem_deleting', $home_info['home_path']));
|
||||
}
|
||||
}
|
||||
$view->refresh("?m=user_games");
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
.levelup, .folder, #addfolder {
|
||||
cursor:pointer;
|
||||
}
|
||||
|
|
@ -1,943 +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 exec_ogp_module()
|
||||
{
|
||||
global $db;
|
||||
$isAdmin = $db->isAdmin( $_SESSION['user_id'] );
|
||||
$home_id = $_GET['home_id'];
|
||||
|
||||
if( $isAdmin )
|
||||
$game_home['access_rights'] = "ufpetc";
|
||||
else
|
||||
$game_home = $db->getUserGameHome($_SESSION['user_id'],$home_id);
|
||||
|
||||
if ( !$game_home and !$isAdmin )
|
||||
return;
|
||||
|
||||
$submit = isset($_REQUEST['submit']) ? $_REQUEST['submit'] : "";
|
||||
|
||||
$home_info = $db->getGameHomeWithoutMods($home_id);
|
||||
$servers_with_same_path = $db->getGameServersWithSamePath($home_info['remote_server_id'], $home_info['home_path']);
|
||||
$servers_with_same_path = (is_array($servers_with_same_path) ? count($servers_with_same_path) : 0);
|
||||
|
||||
$home_id = $home_info['home_id'];
|
||||
$enabled_mods = $db->getHomeMods($home_id);
|
||||
|
||||
if( $isAdmin and isset( $_POST['change_home_cfg_id'] ) )
|
||||
{
|
||||
if( !empty($enabled_mods) )
|
||||
{
|
||||
foreach ( $enabled_mods as $enabled_rows )
|
||||
{
|
||||
$db->delGameMod($enabled_rows['mod_id']);
|
||||
}
|
||||
}
|
||||
$home_cfg_id = $home_info['home_cfg_id'];
|
||||
$new_home_cfg_id = $_POST['home_cfg_id'];
|
||||
if($db->updateHomeCfgId($home_id, $new_home_cfg_id))
|
||||
{
|
||||
$json_message = array('result' => 'success', 'info' => get_lang("successfully_changed_game_server"));
|
||||
|
||||
echo json_encode($json_message);
|
||||
$db->logger( get_lang("successfully_changed_game_server") ." HOME ID:$home_id - ". get_lang("change_game_type") .":old home_cfg_id:$home_cfg_id, new home_cfg_id:$new_home_cfg_id");
|
||||
}
|
||||
else
|
||||
echo json_encode(array('result' => 'failure', 'info' => 'Error while updating game type.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$server_xml = read_server_config(SERVER_CONFIG_LOCATION.$home_info['home_cfg_file']);
|
||||
include_once('includes/lib_remote.php');
|
||||
$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'],$home_info['timeout']);
|
||||
$ftp_installed = $db->isModuleInstalled('ftp');
|
||||
|
||||
if( isset($_REQUEST['change_name']) )
|
||||
{
|
||||
//$server_name = strip_tags(strip_real_escape_string($_POST['server_name']));
|
||||
$server_name = $_POST['server_name'];
|
||||
if ( $db->changeHomeName($home_id, $server_name) === TRUE )
|
||||
{
|
||||
echo json_encode(array('result' => 'success', 'info' => get_lang("successfully_changed_game_server")));
|
||||
$db->logger( get_lang("successfully_changed_game_server") ." HOME ID:$home_id - ". get_lang("game_server_name") .":$server_name");
|
||||
}
|
||||
else
|
||||
echo json_encode(array('result' => 'failure', 'info' => 'Name update failed.'));
|
||||
return;
|
||||
}
|
||||
elseif ( isset($_REQUEST['change_control_password']) )
|
||||
{
|
||||
$control_password = $_POST['control_password'];
|
||||
if($control_password != "")
|
||||
{
|
||||
$control_password = validate_login($control_password);
|
||||
if(!$control_password)
|
||||
{
|
||||
echo json_encode(array('result' => 'failure', 'info' => 'Not allowed characters'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $db->changeHomeControlPassword($home_id, $control_password) === TRUE )
|
||||
{
|
||||
echo json_encode(array('result' => 'success', 'info' => get_lang("control_password_updated_successfully")));
|
||||
$db->logger( get_lang("control_password_updated_successfully") ." HOME ID:$home_id - ". get_lang("game_control_password") .":$control_password");
|
||||
}
|
||||
else
|
||||
echo json_encode(array('result' => 'failure', 'info' => get_lang("control_password_update_failed")));
|
||||
return;
|
||||
}
|
||||
elseif( isset($_REQUEST['change_ftp_login']) && preg_match("/t/",$game_home['access_rights']) > 0 )
|
||||
{
|
||||
// Is FTP Module Installed?
|
||||
if($ftp_installed){
|
||||
if ($db->IsFtpEnabled($home_id) OR $isAdmin)
|
||||
{
|
||||
$old_login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id;
|
||||
$post_ftp_login = $_POST['ftp_login'];
|
||||
if($post_ftp_login != "")
|
||||
{
|
||||
$post_ftp_login = validate_login($post_ftp_login);
|
||||
if(!$post_ftp_login)
|
||||
{
|
||||
echo json_encode(array('result' => 'failure', 'info' => 'Not allowed characters'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode(array('result' => 'failure', 'info' => 'Empty input not permitted.'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Validation
|
||||
|
||||
// Is the same user old and new?
|
||||
if($old_login == $post_ftp_login)
|
||||
{
|
||||
echo json_encode(array('result' => 'success', 'info' => ''));
|
||||
return;
|
||||
}
|
||||
|
||||
if(strlen($post_ftp_login) > 20){
|
||||
echo json_encode(array('result' => 'failure', 'info' => get_lang("ftp_account_username_too_long")));
|
||||
return;
|
||||
}
|
||||
|
||||
$host_stat = $remote->status_chk();
|
||||
$user_exists = FALSE;
|
||||
$old_login_exists = FALSE;
|
||||
$host_online = FALSE;
|
||||
if( $host_stat === 1 )
|
||||
{
|
||||
$host_online = TRUE;
|
||||
$ftp_accounts_list = $remote->ftp_mgr("list");
|
||||
$ftp_accounts = explode("\n",$ftp_accounts_list);
|
||||
|
||||
foreach($ftp_accounts as $ftp_account)
|
||||
{
|
||||
if( $ftp_account != "" )
|
||||
{
|
||||
list($ftp_login, $ftp_path) = explode("\t",$ftp_account);
|
||||
$ftp_login = trim($ftp_login);
|
||||
|
||||
if ($ftp_login == $old_login)
|
||||
$old_login_exists = TRUE;
|
||||
if ($ftp_login == $post_ftp_login)
|
||||
$user_exists = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( $host_online and ! $user_exists )
|
||||
{
|
||||
if($old_login_exists)
|
||||
$change_login_delete_old = $remote->ftp_mgr("userdel", $old_login);
|
||||
else
|
||||
$change_login_delete_old = 1;
|
||||
|
||||
if ($change_login_delete_old !== 0)
|
||||
{
|
||||
$change_login_add_new = $remote->ftp_mgr("useradd", $post_ftp_login, $home_info['ftp_password'], $home_info['home_path']);
|
||||
}
|
||||
|
||||
if (isset($change_login_add_new) and $change_login_add_new !== 0)
|
||||
{
|
||||
if ( $db->changeFtpLogin($home_id,$post_ftp_login) === TRUE )
|
||||
{
|
||||
echo json_encode(array('result' => 'success', 'info' => get_lang("successfully_changed_game_server")));
|
||||
$db->logger( get_lang("successfully_changed_game_server") ." HOME ID:$home_id - ". get_lang("server_ftp_login") .":$post_ftp_login");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode(array('result' => 'failure', 'info' => get_lang("error_ocurred_on_remote_server") .
|
||||
" " . get_lang("ftp_login_can_not_be_changed")));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode(array('result' => 'failure', 'info' => get_lang("error_ocurred_on_remote_server") .
|
||||
" " . get_lang("ftp_login_can_not_be_changed")));
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
elseif( isset( $_REQUEST['change_ftp_password']) && preg_match("/t/",$game_home['access_rights']) > 0 )
|
||||
{
|
||||
// Is FTP Module Installed?
|
||||
if($ftp_installed){
|
||||
if ($db->IsFtpEnabled($home_id) OR $isAdmin)
|
||||
{
|
||||
$ftp_password = $_POST['ftp_password'];
|
||||
if($ftp_password != "")
|
||||
{
|
||||
$ftp_password = validate_login($ftp_password);
|
||||
if(!$ftp_password)
|
||||
{
|
||||
echo json_encode(array('result' => 'failure', 'info' => 'Not allowed characters'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode(array('result' => 'failure', 'info' => 'Empty input not permitted.'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Validation
|
||||
|
||||
// Is the same password old and new?
|
||||
if($home_info['ftp_password'] == $ftp_password)
|
||||
{
|
||||
echo json_encode(array('result' => 'success', 'info' => ''));
|
||||
return;
|
||||
}
|
||||
|
||||
if(strlen($ftp_password) > 20){
|
||||
echo json_encode(array('result' => 'failure', 'info' => get_lang("ftp_account_password_too_long")));
|
||||
return;
|
||||
}
|
||||
|
||||
$host_stat = $remote->status_chk();
|
||||
$current_login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id;
|
||||
$login_exists = FALSE;
|
||||
$host_online = FALSE;
|
||||
|
||||
if( $host_stat === 1 )
|
||||
{
|
||||
$host_online = TRUE;
|
||||
$ftp_accounts_list = $remote->ftp_mgr("list");
|
||||
$ftp_accounts = explode("\n",$ftp_accounts_list);
|
||||
foreach($ftp_accounts as $ftp_account)
|
||||
{
|
||||
if( $ftp_account != "" )
|
||||
{
|
||||
list($ftp_login, $ftp_path) = explode("\t",$ftp_account);
|
||||
$ftp_login = trim($ftp_login);
|
||||
if ($ftp_login == $current_login)
|
||||
{
|
||||
$login_exists = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($host_online)
|
||||
{
|
||||
if(!$login_exists)
|
||||
{
|
||||
if($remote->ftp_mgr("useradd", $current_login, $ftp_password, $home_info['home_path']) !== 0)
|
||||
{
|
||||
echo json_encode(array('result' => 'success', 'info' => get_lang("successfully_changed_game_server")));
|
||||
$db->logger( get_lang("successfully_changed_game_server") ." HOME ID:$home_id - ". get_lang("server_ftp_password") .":$ftp_password");
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode(array('result' => 'failure', 'info' => get_lang("error_ocurred_on_remote_server") .
|
||||
" " . get_lang("ftp_password_can_not_be_changed")));
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($remote->ftp_mgr("passwd", $current_login, $ftp_password) !== 0)
|
||||
{
|
||||
if ( $db->changeFtpPassword($home_id,clean_path($ftp_password)) === TRUE )
|
||||
{
|
||||
echo json_encode(array('result' => 'success', 'info' => get_lang("successfully_changed_game_server")));
|
||||
$db->logger( get_lang("successfully_changed_game_server") ." HOME ID:$home_id - ". get_lang("server_ftp_password") .":$ftp_password");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode(array('result' => 'failure', 'info' => get_lang("error_ocurred_on_remote_server") .
|
||||
" " . get_lang("ftp_password_can_not_be_changed")));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
echo json_encode(array('result' => 'failure', 'info' => get_lang("error_ocurred_on_remote_server") .
|
||||
" " . get_lang("ftp_password_can_not_be_changed")));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
elseif (isset($_POST["force_mod_id"]))
|
||||
{
|
||||
$force_mod_id = $_POST['force_mod_id'];
|
||||
$ip_id = $_POST['ip_id'];
|
||||
$port = $_POST['port'];
|
||||
|
||||
if ( $db->forceModAtAddress($ip_id, $port, $force_mod_id) )
|
||||
{
|
||||
echo "Assigned MOD to this Server";
|
||||
//json_encode (array('result' => 'success', 'info' => get_lang("successfully_assigned_mod_to_address")));
|
||||
$db->logger( get_lang("successfully_assigned_mod_to_address") );
|
||||
echo" <meta http-equiv='refresh' content='3'>";
|
||||
|
||||
}
|
||||
else
|
||||
echo json_encode(array('result' => 'failure', 'info' => "Failed to assign mod to address."));
|
||||
return;
|
||||
}
|
||||
elseif ( $isAdmin )
|
||||
{
|
||||
if( isset( $_REQUEST['create_ftp']) )
|
||||
{
|
||||
$login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id;
|
||||
|
||||
$success = true;
|
||||
if(strlen($login) > 20){
|
||||
$result = get_lang("ftp_account_username_too_long");
|
||||
$type = "failure";
|
||||
$success = false;
|
||||
}
|
||||
|
||||
if($success){
|
||||
if ($remote->ftp_mgr("useradd", $login, $home_info['ftp_password'], $home_info['home_path']) === 0)
|
||||
{
|
||||
$result = get_lang("error_ocurred_on_remote_server") ." ". get_lang("ftp_can_not_be_switched_on");
|
||||
$type = "failure";
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->changeFtpStatus('enabled',$home_id);
|
||||
$result = get_lang("successfully_changed_game_server");
|
||||
$type = "success";
|
||||
$db->logger( get_lang("successfully_changed_game_server") ." HOME ID:$home_id - ". get_lang("change_ftp_account_status") .":enabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( isset( $_REQUEST['delete_ftp']) )
|
||||
{
|
||||
$login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id;
|
||||
$host_stat = $remote->status_chk();
|
||||
$user_exists = FALSE;
|
||||
$host_online = FALSE;
|
||||
if( $host_stat === 1 )
|
||||
{
|
||||
$host_online = TRUE;
|
||||
$ftp_accounts_list = $remote->ftp_mgr("list");
|
||||
$ftp_accounts = explode("\n",$ftp_accounts_list);
|
||||
foreach($ftp_accounts as $ftp_account)
|
||||
{
|
||||
if( $ftp_account != "" )
|
||||
{
|
||||
list($ftp_login, $ftp_path) = explode("\t",$ftp_account);
|
||||
$ftp_login = trim($ftp_login);
|
||||
|
||||
if ($ftp_login == $login)
|
||||
{
|
||||
$user_exists = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($host_online and $ftp_accounts_list !== 0)
|
||||
{
|
||||
if( $user_exists )
|
||||
{
|
||||
$delete_ftp = $remote->ftp_mgr("userdel", $login);
|
||||
if ($delete_ftp === 0)
|
||||
{
|
||||
$result = get_lang("error_ocurred_on_remote_server") ." ". get_lang("ftp_can_not_be_switched_off");
|
||||
$type = "failure";
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->changeFtpStatus('disabled',$home_id);
|
||||
$result = get_lang("successfully_changed_game_server");
|
||||
$type = "success";
|
||||
$db->logger( get_lang("successfully_changed_game_server") ." HOME ID:$home_id - ". get_lang("change_ftp_account_status") .":disabled");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->changeFtpStatus('disabled',$home_id);
|
||||
$result = get_lang("successfully_changed_game_server");
|
||||
$type = "success";
|
||||
$db->logger( get_lang("successfully_changed_game_server") ." HOME ID:$home_id - ". get_lang("change_ftp_account_status") .":disabled");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = get_lang("error_ocurred_on_remote_server") ." ". get_lang("ftp_can_not_be_switched_off");
|
||||
$type = "failure";
|
||||
}
|
||||
}
|
||||
else if( isset( $_REQUEST['change_user_id_main']) )
|
||||
{
|
||||
$user_id_main = $_POST['user_id_main'];
|
||||
$old_home = $db->getUserGameHome($home_info['user_id_main'],$home_id);
|
||||
if(isset($_POST['deleteoldassigns']))
|
||||
{
|
||||
$db->unassignHomeFrom("user",$home_info['user_id_main'],$home_id);
|
||||
$home_groups = $db->getGroupsForHome($home_info['home_id']);
|
||||
if( isset( $home_groups ) )
|
||||
{
|
||||
foreach($home_groups as $home_group)
|
||||
{
|
||||
$db->unassignHomeFrom("group",$home_group['group_id'],$home_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $db->changeUserIdMain($home_id,$user_id_main) == TRUE )
|
||||
{
|
||||
$db->assignHomeTo("user",$user_id_main,$home_id,$old_home['access_rights']);
|
||||
$query="UPDATE `ogp_billing_orders` SET `user_id`=".$user_id_main." WHERE `home_id` = ".$home_id.";";
|
||||
$db->query($query);
|
||||
echo json_encode(array('result' => 'success', 'info' => get_lang("successfully_changed_game_server")));
|
||||
$db->logger( get_lang("successfully_changed_game_server") ." HOME ID:$home_id - ". get_lang("change_user_id_main") .":$user_id_main");
|
||||
}
|
||||
else
|
||||
echo json_encode(array('result' => 'failure', 'info' => "Unable to change main user."));
|
||||
return;
|
||||
}
|
||||
else if( isset( $_REQUEST['change_home'] ) )
|
||||
{
|
||||
$home_path = strip_real_escape_string($_POST['home_path']);
|
||||
if(preg_match("/^[a-z]:\//i", $home_path))
|
||||
{
|
||||
$home_path = str_replace("/", "\\\\", $home_path);
|
||||
$home_path = rtrim($remote->exec("cygpath -u $home_path"));
|
||||
}
|
||||
if(preg_match("/^\//",$home_path))
|
||||
{
|
||||
if ( $db->changeHomePath($home_id,clean_path($home_path)) === TRUE )
|
||||
{
|
||||
$home_info = $db->getGameHomeWithoutMods($home_id);
|
||||
$servers_with_same_path = $db->getGameServersWithSamePath($home_info['remote_server_id'], $home_info['home_path']);
|
||||
$servers_with_same_path = (is_array($servers_with_same_path) ? count($servers_with_same_path) : 0);
|
||||
|
||||
$success_json = array('result' => 'success', 'info' => get_lang("successfully_changed_game_server"));
|
||||
|
||||
if($servers_with_same_path > 1){
|
||||
$success_json["warning_info"] = get_lang('other_servers_exist_with_path_please_change');
|
||||
}
|
||||
|
||||
// Create new home directory if it doesn't already exist
|
||||
$remote->exec("mkdir -p " . clean_path($home_path));
|
||||
|
||||
// If FTP is enabled, update the FTP info.
|
||||
if($ftp_installed){
|
||||
if ($db->IsFtpEnabled($home_id))
|
||||
{
|
||||
$login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id;
|
||||
$delte_old_ftp_account = $remote->ftp_mgr("userdel", $login);
|
||||
if ($delte_old_ftp_account !== 0)
|
||||
{
|
||||
$create_new_ftp_account = $remote->ftp_mgr("useradd", $login, $home_info['ftp_password'], $home_path);
|
||||
}
|
||||
|
||||
if (isset($create_new_ftp_account) and $create_new_ftp_account !== 0)
|
||||
{
|
||||
echo json_encode($success_json);
|
||||
$db->logger( get_lang("successfully_changed_game_server") ." HOME ID:$home_id - ". get_lang("home_path") .":$home_path");
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode(array('result' => 'failure', 'info' => get_lang("error_ocurred_on_remote_server") .
|
||||
" " . get_lang("ftp_login_can_not_be_changed")));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode($success_json);
|
||||
$db->logger( get_lang("successfully_changed_game_server") ." HOME ID:$home_id - ". get_lang("home_path") .":$home_path");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode($success_json);
|
||||
$db->logger( get_lang("successfully_changed_game_server") ." HOME ID:$home_id - ". get_lang("home_path") .":$home_path");
|
||||
}
|
||||
}
|
||||
else
|
||||
echo json_encode(array('result' => 'failure', 'info' => get_lang("selected_path_already_in_use")));
|
||||
}
|
||||
else
|
||||
echo json_encode(array('result' => 'failure', 'info' => get_lang("invalid_path")));
|
||||
return;
|
||||
}
|
||||
else if( isset( $_REQUEST['master_server'] ) )
|
||||
{
|
||||
if ( isset( $_POST['add'] ) )
|
||||
$action = "add";
|
||||
else
|
||||
$action = "remove";
|
||||
if ( $db->setMasterServer($action, $home_id, $home_info['home_cfg_id'], $home_info['remote_server_id']) === TRUE )
|
||||
{
|
||||
$result = get_lang("successfully_changed_game_server");
|
||||
$type = "success";
|
||||
$db->logger( get_lang("successfully_changed_game_server") ." HOME ID:$home_id - ". get_lang("set_as_master_server") .":$action");
|
||||
}
|
||||
}
|
||||
|
||||
if( isset($_REQUEST['add_mod']) )
|
||||
{
|
||||
$mod_cfg_id = $_POST['mod_cfg_id'];
|
||||
if ( $db->addModToGameHome($home_id,$mod_cfg_id) === FALSE )
|
||||
{
|
||||
$result = get_lang_f('failed_to_assing_mod_to_home',$mod_cfg_id);
|
||||
$type = "failure";
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = get_lang_f('successfully_assigned_mod_to_home',$mod_cfg_id);
|
||||
$type = "success";
|
||||
$db->logger(get_lang_f('successfully_assigned_mod_to_home',$mod_cfg_id)." [HOME ID:$home_id]");
|
||||
}
|
||||
}
|
||||
|
||||
else if($submit == "delete_mod")
|
||||
{
|
||||
$mod_id = $_GET['mod_id'];
|
||||
if ( $db->delGameMod($mod_id) === TRUE )
|
||||
{
|
||||
$result = get_lang("successfully_removed_mod");
|
||||
$type = "success";
|
||||
$db->logger( get_lang("successfully_removed_mod") ." [MOD ID:$mod_id HOME ID:$home_id]");
|
||||
}
|
||||
}
|
||||
|
||||
else if(isset($_REQUEST['set_options']))
|
||||
{
|
||||
$maxplayers = 0 + @$_POST['maxplayers'];
|
||||
$cliopts = $_POST['cliopts'];
|
||||
|
||||
// Get the total CPU count. and, if the agent is offline, set the CPU to NA.
|
||||
$remoteCpus = $remote->cpu_count();
|
||||
$validCpus = $remoteCpus === -1 ? 'NA' : $remoteCpus-1;
|
||||
|
||||
if(isset($_POST['cpus']) && $validCpus !== 'NA')
|
||||
{
|
||||
$cpuArray = explode(',', $_POST['cpus']);
|
||||
|
||||
// Check if a a valid core has been submitted. eg, the checkbox hasn't been manually edited.
|
||||
foreach($cpuArray as $cpu)
|
||||
{
|
||||
if($cpu > $validCpus || !is_numeric($cpu))
|
||||
{
|
||||
$cpus = 'NA';
|
||||
break;
|
||||
} else {
|
||||
$cpus[] = $cpu;
|
||||
}
|
||||
}
|
||||
|
||||
// If $cpus is an array, seperate all the values with a comma. Otherwise, just pass $cpus to the query - which, as above, will be NA.
|
||||
$cpus = is_array($cpus) ? implode(',', $cpus) : $cpus;
|
||||
|
||||
} else {
|
||||
$cpus = 'NA';
|
||||
}
|
||||
|
||||
// If we're on Windows, and some cores have been selected...
|
||||
if (preg_match('/cygwin/i', $remote->what_os()) && $cpus !== 'NA') {
|
||||
$result = 0;
|
||||
$cores = explode(',', $cpus);
|
||||
|
||||
foreach ($cores as $core) {
|
||||
$coreNum = intval($core);
|
||||
$result |= (1 << $coreNum);
|
||||
}
|
||||
|
||||
$cpus = strtoupper(dechex($result));
|
||||
}
|
||||
|
||||
$nice = isset($_POST['nice']) ? (int)$_POST['nice'] : 0;
|
||||
$mod_cfg_id = $_POST['mod_cfg_id'];
|
||||
|
||||
if ( $db->updateGameModParams($maxplayers,$cliopts,$cpus,$nice,$home_id,$mod_cfg_id) === TRUE )
|
||||
{
|
||||
echo json_encode(array('result' => 'success', 'info' => get_lang("successfully_modified_mod")));
|
||||
$db->logger( get_lang("successfully_modified_mod") ." [MOD CFG ID:$mod_cfg_id HOME ID:$home_id]");
|
||||
}
|
||||
else
|
||||
echo json_encode(array('result' => 'failure', 'info' => "The mod could not be changed."));
|
||||
return;
|
||||
}
|
||||
else if( isset( $_REQUEST['set_expiration_date'] ) )
|
||||
{
|
||||
if ( $db->updateExpirationDate($home_id, $_POST['expiration_date'], 'server') === TRUE )
|
||||
{
|
||||
echo json_encode(array('result' => 'success', 'info' => get_lang('expiration_date_changed')));
|
||||
$db->logger( get_lang('expiration_date_changed') ." [ HOME ID:$home_id NEW DATE:$_POST[expiration_date] ]");
|
||||
}
|
||||
else
|
||||
echo json_encode(array('result' => 'failure', 'info' => get_lang('expiration_date_could_not_be_changed')));
|
||||
return;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<link rel="stylesheet" type="text/css" href="js/datetimepicker/jquery.datetimepicker.min.css"/>
|
||||
<script src="js/datetimepicker/jquery.datetimepicker.full.min.js"></script>
|
||||
<script type="text/javascript" src="js/modules/user_games.js"></script>
|
||||
<?php
|
||||
echo "<h2>". get_lang("editing_home_called") ." \"".htmlentities($home_info['home_name'])."\"</h2><div id='result' >";
|
||||
if(isset($result))
|
||||
{
|
||||
if($type == 'success')
|
||||
print_success($result);
|
||||
elseif($type = 'failure')
|
||||
print_failure($result);
|
||||
}
|
||||
echo "</div>";
|
||||
$home_info = $db->getGameHomeWithoutMods($home_id);
|
||||
echo "<p>";
|
||||
echo "<a href='?m=gamemanager&p=game_monitor&home_id=$home_id'><< ". get_lang("back_to_game_monitor") ."</a>";
|
||||
if ( $isAdmin )
|
||||
{
|
||||
echo " ";
|
||||
echo "<a href='?m=user_games'><< ". get_lang("back_to_game_servers") ."</a>";
|
||||
}
|
||||
echo "</p>";
|
||||
echo "<table class='center' id='main_settings' >";
|
||||
if ( $isAdmin )
|
||||
{
|
||||
// Form to change game type
|
||||
echo "<tr><td rowspan='2' class='right'>". get_lang("game_type") .":</td><td class='left'>";
|
||||
echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
|
||||
$game_cfgs = $db->getGameCfgs();
|
||||
$host_stat = $remote->status_chk();
|
||||
if( $host_stat === 1)
|
||||
$os = $remote->what_os();
|
||||
else
|
||||
$os = "Unknown OS";
|
||||
echo "<select name='home_cfg_id' >";
|
||||
echo get_game_selector($os, $game_cfgs, $home_info['home_cfg_id']);
|
||||
echo "</select>";
|
||||
echo "<input type='submit' name='change_home_cfg_id' value='". get_lang("change_game_type") ."' />";
|
||||
echo "</form></td></tr>";
|
||||
echo "<tr><td colspan='2' class='info'>". get_lang("change_game_type_info") ."</td></tr>";
|
||||
// Form to edit main user.
|
||||
echo "<tr><td class='right'>". get_lang("user_id_main") .":</td><td class='left'>";
|
||||
echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
|
||||
echo "<input type='hidden' name='home_id' value=\"$home_id\" />\n";
|
||||
echo "<select name='user_id_main'>";
|
||||
$user = $db->getUserById($home_info['user_id_main']);
|
||||
echo "<option value='".$home_info['user_id_main']."'>".$user['users_login']."</option>\n";
|
||||
$users = $db->getUserList();
|
||||
foreach ( $users as $user ){
|
||||
// Only users and admins can be assigned homes... not subusers
|
||||
if(is_null($user['users_parent'])){
|
||||
if($home_info['user_id_main'] != $user['user_id']){
|
||||
echo "<option value='".$user['user_id']."'>".$user['users_login']."</option>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "</select><br>";
|
||||
echo "<input type='checkbox' name='deleteoldassigns' id='deleteoldassigns' style='width:auto;' /><label for='deleteoldassigns' >". get_lang("Delete_old_user_assigned_homes") ."</label>";
|
||||
echo "<input type='submit' name='change_user_id_main' value='". get_lang("change_user_id_main") ."' />";
|
||||
echo "</form>";
|
||||
echo "</td></tr><tr><td colspan='2' class='info'>" . get_lang("change_user_id_main_info") ."</td></tr>";
|
||||
|
||||
// Form to edit game path.
|
||||
echo "<tr><td class='right'>". get_lang("home_path") .":</td><td class='left'>".
|
||||
"<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>".
|
||||
"<input type='hidden' name='home_id' value=\"$home_id\" />\n".
|
||||
"<input type='text' size='30' name='home_path' value=\"".str_replace('"', """, $home_info['home_path'])."\" />".
|
||||
"<input type='submit' name='change_home' value='". get_lang("change_home") ."' id='change_home_path' />".
|
||||
"</form><button data-path=\"".str_replace('"', """, $home_info['home_path'])."\" data-home-id='".$home_id."' id='browse'>".
|
||||
get_lang("browse") ."</button>";
|
||||
if($servers_with_same_path > 1){
|
||||
print_failure(get_lang('other_servers_exist_with_path_please_change'), "warning");
|
||||
}
|
||||
echo "</td></tr>".
|
||||
"<tr><td colspan='2' class='info'>". get_lang("change_home_info") ."</td></tr>";
|
||||
|
||||
//Jquery path browser dialog
|
||||
echo "<div id='dialog".
|
||||
"' data-select_home_path='". get_lang("select_home_path") .
|
||||
"' data-set_this_path='". get_lang("set_this_path") .
|
||||
"' data-cancel='". get_lang("cancel") .
|
||||
"' ></div>";
|
||||
}
|
||||
|
||||
// Form to edit game name
|
||||
echo "<tr><td class='right'>". get_lang("game_server_name") .":</td><td class='left'>";
|
||||
echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
|
||||
echo "<input type='hidden' name='home_id' value=\"$home_id\" />\n";
|
||||
echo "<input type='text' size='30' name='server_name' value=\"".str_replace('"', """, htmlentities($home_info['home_name']))."\" />";
|
||||
echo "<input type=submit name='change_name' value='". get_lang("change_name") ."' />";
|
||||
echo "</form></td></tr>";
|
||||
echo "<tr><td colspan='2' class='info'>". get_lang("change_name_info") ."</td></tr>";
|
||||
|
||||
// Form to edit control password
|
||||
echo "<tr><td class='right'>". get_lang("game_control_password") .":</td><td class='left'>";
|
||||
echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
|
||||
echo "<input type='hidden' name='home_id' value=\"$home_id\" />\n";
|
||||
echo "<input type='text' size='30' name='control_password' value=\"".str_replace('"', """, $home_info['control_password'])."\" />";
|
||||
echo "<input type='submit' name='change_control_password' value='". get_lang("change_control_password") ."' />";
|
||||
echo "</form></td></tr>";
|
||||
echo "<tr><td colspan='2' class='info'>". get_lang("change_control_password_info") ."</td></tr>";
|
||||
if ( $isAdmin && $ftp_installed )
|
||||
{
|
||||
// Forms to enable/disable ftp account
|
||||
echo "<tr>";
|
||||
echo "<td class='right'>". get_lang("change_ftp_account_status") .":</td>";
|
||||
echo "<td class='left'>";
|
||||
if ( !$db->IsFtpEnabled( $home_id ) )
|
||||
{
|
||||
echo "<div style='display:block;float:left;' ><form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
|
||||
echo "<input type='submit' name='create_ftp' value='". get_lang("ftp_on") ."' />";
|
||||
echo "</form></div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<div style='display:block;float:left;' ><form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
|
||||
echo "<input type='submit' name='delete_ftp' value='". get_lang("ftp_off") ."' />";
|
||||
echo "</form></div>";
|
||||
}
|
||||
echo "</td></tr>";
|
||||
echo "<tr><td colspan='2' class='info'>". get_lang("change_ftp_account_status_info") ."</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
if ( preg_match("/t/",$game_home['access_rights']) > 0 && $ftp_installed && $db->IsFtpEnabled($home_id) )
|
||||
{
|
||||
// Form to edit control ftp login
|
||||
$ftp_login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id;
|
||||
echo "<tr><td class='right'>". get_lang("server_ftp_login") .":</td><td class='left'>";
|
||||
echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
|
||||
echo "<input type='text' size='30' name='ftp_login' value=\"".str_replace('"', """, $ftp_login)."\" />";
|
||||
echo "<input type='submit' name='change_ftp_login' value='". get_lang("change_ftp_login") ."' />";
|
||||
echo "</form></td></tr>";
|
||||
echo "<tr><td colspan='2' class='info'>". get_lang("change_ftp_login_info") ."</td></tr>";
|
||||
// Form to edit control ftp password
|
||||
echo "<tr><td class='right'>". get_lang("server_ftp_password") .":</td><td class='left'>";
|
||||
echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
|
||||
echo "<input type='text' size='30' name='ftp_password' value=\"".str_replace('"', """, $home_info['ftp_password'])."\" />";
|
||||
echo "<input type='submit' name='change_ftp_password' value='". get_lang("change_ftp_password") ."' />";
|
||||
echo "</form></td></tr>";
|
||||
echo "<tr><td colspan='2' class='info'>". get_lang("change_ftp_password_info") ."</td></tr>";
|
||||
}
|
||||
|
||||
if ( $isAdmin )
|
||||
{
|
||||
$master_server_home_id = $db->getMasterServer( $home_info['remote_server_id'], $home_info['home_cfg_id'] );
|
||||
$expiration_date = !empty($home_info['server_expiration_date']) ? date( "d/m/Y H:i:s", $home_info['server_expiration_date'] ) : '';
|
||||
|
||||
if( $master_server_home_id != FALSE AND $master_server_home_id == $home_id )
|
||||
$checked = 'checked ="checked"';
|
||||
else
|
||||
$checked = "";
|
||||
// Form to enable/disable as master server for local update
|
||||
echo "</tr><tr><td class='right'>". get_lang("master_server_for_clon_update") .":</td><td class='left'>";
|
||||
echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
|
||||
echo "<input type='checkbox' name='add' $checked />";
|
||||
echo "<input type='submit' name='master_server' value='". get_lang("set_as_master_server") ."' />";
|
||||
echo "</form></td></tr>";
|
||||
echo "<tr><td colspan='2' class='info'>". get_lang("set_as_master_server_for_local_clon_update") .
|
||||
" (".get_lang_f( 'only_available_for', $server_xml->game_name, $home_info['remote_server_name']).")</td></tr>";
|
||||
// Expiration
|
||||
echo "<tr><td class='right'>".get_lang('server_expiration_date').":</td>\n".
|
||||
"<td class='left'><form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>".
|
||||
"<div id='datetimepicker' class='input-append date'>".
|
||||
"<input name='expiration_date' placeholder='dd/MM/yyyy hh:mm:ss' type='text' value='".$expiration_date.
|
||||
"' data-today='".date('d/m/Y H:i:s')."' >\n".
|
||||
"</div>".
|
||||
"<input type='submit' name='set_expiration_date' value='". get_lang("set_expiration_date") ."' />".
|
||||
"</form></td></tr>\n".
|
||||
"<tr><td colspan='2' class='info'>". get_lang("server_expiration_date_info") ."</td></tr>";
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
|
||||
if ( $isAdmin )
|
||||
{
|
||||
$avail_ips = $db->getRemoteServerIPs($home_info['remote_server_id']);
|
||||
|
||||
$ip_array = array();
|
||||
|
||||
if ( is_array($avail_ips) && !empty($avail_ips) )
|
||||
{
|
||||
echo "<h3>". get_lang("ips_and_ports") ."</h3>";
|
||||
$screen_running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME,$home_info['home_id']) === 1;
|
||||
if( ! $screen_running )
|
||||
{
|
||||
if( isset($_REQUEST['set_ip']) )
|
||||
{
|
||||
$ip_id = $db->real_escape_string($_POST['ip']);
|
||||
$ip_row = $db->resultQuery( "SELECT ip FROM OGP_DB_PREFIXremote_server_ips WHERE ip_id=".$ip_id );
|
||||
$ip = $ip_row['0']['ip'];
|
||||
$port = $_POST['port'];
|
||||
$port = (int)(trim($port));
|
||||
$home_id = $_POST['home_id'];
|
||||
|
||||
if ( !isPortValid($port) )
|
||||
{
|
||||
print_failure( get_lang("port_range_error") );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $db->addGameIpPort($home_id, $ip_id, $port) === FALSE )
|
||||
{
|
||||
print_failure(get_lang_f('ip_port_already_in_use', $ip, $port));
|
||||
}
|
||||
else {
|
||||
print_success(get_lang_f('successfully_assigned_ip_port_to_server_id', $ip, $port, $home_id));
|
||||
$db->logger(get_lang_f('successfully_assigned_ip_port_to_server_id', $ip, $port, $home_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_REQUEST["delete_ip"]))
|
||||
{
|
||||
$del_ip = $_GET['ip'];
|
||||
$del_port = $_GET['port'];
|
||||
|
||||
if ( $db->delGameIpPort($home_id,$del_ip,$del_port) )
|
||||
{
|
||||
print_success( get_lang("successfully_assigned_ip_port") );
|
||||
$db->logger( get_lang("successfully_assigned_ip_port") ." [unassigned]");
|
||||
}
|
||||
else
|
||||
print_failure("Failed to unassign ip:port.");
|
||||
}
|
||||
|
||||
echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>\n";
|
||||
echo "<input type='hidden' name='home_id' value=\"$home_id\" />\n";
|
||||
echo get_lang("ip") .":<select name='ip' onchange='this.form.submit();'>";
|
||||
|
||||
foreach($avail_ips as $value)
|
||||
{
|
||||
$selected = ( isset($_POST['ip']) and $_POST['ip'] == $value['ip_id'] ) ? "selected='selected'" : "";
|
||||
echo "<option value='".$value['ip_id']."' $selected >".$value['ip']."</option>\n";
|
||||
}
|
||||
|
||||
echo "</select>";
|
||||
|
||||
$ip_id = isset($_POST['ip']) ? $_POST['ip'] : $avail_ips[0]['ip_id'];
|
||||
$port = $db->getNextAvailablePort($ip_id,$home_info['home_cfg_id']);
|
||||
|
||||
echo " ". get_lang("port") .":<input type='text' name='port' value='".$port."' size='6' />";
|
||||
echo "<input type='submit' name='set_ip' value='". get_lang("set_ip") ."' />";
|
||||
echo "</form>";
|
||||
$assigned = $db->getHomeIpPorts($home_id);
|
||||
if( empty($assigned) )
|
||||
{
|
||||
print_failure( get_lang("no_ip_ports_assigned") );
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ( $assigned as $assigned_rows )
|
||||
{
|
||||
$force_mod = "";
|
||||
$align = "center";
|
||||
if( !empty($enabled_mods) and count($enabled_mods) > 1 )
|
||||
{
|
||||
$force_mod .= "<td align='left'>\n".
|
||||
"<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>\n".
|
||||
"<input type='hidden' name='ip_id' value=".$assigned_rows['ip_id']." />".
|
||||
"<input type='hidden' name='port' value=".$assigned_rows['port']." />".
|
||||
"<select name='force_mod_id' onchange='this.form.submit();'>".
|
||||
"<option value='0' >". get_lang("force_mod_on_this_address") ."</option>";
|
||||
foreach($enabled_mods as $mod)
|
||||
{
|
||||
$selected = $mod['mod_id'] == $assigned_rows['force_mod_id'] ? "selected='selected'" : "";
|
||||
$force_mod .= "<option value='".$mod['mod_id']."' $selected>".$mod['mod_name']."</option>";
|
||||
}
|
||||
$force_mod .= "</select>\n</form>\n</td>\n";
|
||||
$align = "right";
|
||||
}
|
||||
echo "<table class='center'><tr><td align='$align'>".$assigned_rows['ip'].":".$assigned_rows['port'].
|
||||
" <a href='?m=user_games&p=edit&home_id=$home_id&delete_ip&ip=".
|
||||
$assigned_rows['ip_id']."&port=".$assigned_rows['port'].
|
||||
"'>[ ". delete ." ]</a></td>\n".
|
||||
$force_mod.
|
||||
"</tr>\n</table>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure( get_lang("server_is_running_change_addresses_not_available") );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure( get_lang("no_ip_addresses_configured") ."<a href='?m=server'>". get_lang("server_page") ."</a>." );
|
||||
}
|
||||
echo "<div id='mods'></div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$assigned = $db->getHomeIpPorts($home_id);
|
||||
if( !empty($assigned) and !empty($enabled_mods) and count($enabled_mods) > 1 )
|
||||
{
|
||||
echo "<table class='center'>\n".
|
||||
"<tr>\n".
|
||||
"<td colspan='2' align='center'>".
|
||||
"<h3>". get_lang("switch_mods") ."</h3>".
|
||||
"</td>\n".
|
||||
"</tr>\n";
|
||||
$force_mod = "";
|
||||
foreach ( $assigned as $assigned_rows )
|
||||
{
|
||||
$force_mod .= "<tr>\n<td align='right' style='width:50%' >".get_lang_f('switch_mod_for_address',$assigned_rows['ip'].":".$assigned_rows['port']).
|
||||
"</td>\n<td align='left' style='width:50%' >\n".
|
||||
"<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>\n".
|
||||
"<input type='hidden' name='ip_id' value=".$assigned_rows['ip_id']." />".
|
||||
"<input type='hidden' name='port' value=".$assigned_rows['port']." />".
|
||||
"<select name='force_mod_id' onchange='this.form.submit();'>".
|
||||
"<option value='0' >". get_lang("force_mod_on_this_address") ."</option>";
|
||||
foreach($enabled_mods as $mod)
|
||||
{
|
||||
$selected = $mod['mod_id'] == $assigned_rows['force_mod_id'] ? "selected='selected'" : "";
|
||||
$force_mod .= "<option value='".$mod['mod_id']."' $selected>".$mod['mod_name']."</option>";
|
||||
}
|
||||
$force_mod .= "</select>\n</form>\n</td>\n</tr>\n";
|
||||
}
|
||||
echo $force_mod."</table>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
function numbersFormatting($bytes){
|
||||
$si_prefix = array( 'B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB' );
|
||||
$base = 1024;
|
||||
$class = min((int)log($bytes , $base) , count($si_prefix) - 1);
|
||||
return sprintf('%1.2f' , $bytes / pow($base,$class)) . ' ' . $si_prefix[$class];
|
||||
}
|
||||
|
||||
function exec_ogp_module()
|
||||
{
|
||||
global $db;
|
||||
$isAdmin = $db->isAdmin( $_SESSION['user_id'] );
|
||||
require_once('includes/lib_remote.php');
|
||||
if(isset($_GET['home_id']) and $_GET['home_id'] != "total")
|
||||
{
|
||||
if( $isAdmin )
|
||||
$game_home = $db->getGameHome($_GET['home_id']);
|
||||
else
|
||||
$game_home = $db->getUserGameHome($_SESSION['user_id'],$_GET['home_id']);
|
||||
if ( ! $game_home and ! $isAdmin )
|
||||
return;
|
||||
|
||||
$remote = new OGPRemoteLibrary($game_home['agent_ip'], $game_home['agent_port'], $game_home['encryption_key'], $game_home['timeout']);
|
||||
$r = $remote->rfile_exists($game_home['home_path']);
|
||||
if($r == 1)
|
||||
{
|
||||
$home_path = preg_replace("/('+)/", "'\"$1\"'", $game_home['home_path']);
|
||||
$size = $remote->shell_action('size', $home_path);
|
||||
if(isset($_GET['bytes']))
|
||||
echo $size;
|
||||
else
|
||||
echo numbersFormatting($size);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo get_lang("does_not_exist_yet");
|
||||
}
|
||||
}
|
||||
elseif( $isAdmin )
|
||||
{
|
||||
$game_homes = $db->getGameHomes();
|
||||
$total_size = 0;
|
||||
foreach($game_homes as $game_home)
|
||||
{
|
||||
$remote = new OGPRemoteLibrary($game_home['agent_ip'], $game_home['agent_port'], $game_home['encryption_key'], $game_home['timeout']);
|
||||
$r = $remote->rfile_exists($game_home['home_path']);
|
||||
if($r == 1)
|
||||
{
|
||||
$home_path = preg_replace("/('+)/", "'\"$1\"'", $game_home['home_path']);
|
||||
$kilobytes = $remote->shell_action('size', $home_path);
|
||||
$total_size += $kilobytes;
|
||||
}
|
||||
}
|
||||
echo numbersFormatting($total_size);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,216 +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, $settings;
|
||||
$home_id = $_GET['home_id'];
|
||||
echo "<h3>". get_lang("mods") ."</h3>";
|
||||
echo "<p class='info'>". get_lang("extra_cmd_line_info") ."</p>\n";
|
||||
$enabled_mods = $db->getHomeMods($home_id);
|
||||
$home_info = $db->getGameHomeWithoutMods($home_id);
|
||||
$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( empty($enabled_mods) )
|
||||
{
|
||||
$cpu_count = $remote->cpu_count();
|
||||
if($cpu_count === -1)
|
||||
{
|
||||
print_failure( get_lang("warning_agent_offline_defaulting_CPU_count_to_1") );
|
||||
$cpu_count = 'NA';
|
||||
}
|
||||
else
|
||||
{
|
||||
// cpu numbering starts from 0 so lets remove the last cpu.
|
||||
$cpu_count -= 1;
|
||||
}
|
||||
|
||||
$game_mods = $db->getAvailableModsForGameHome($home_id);
|
||||
foreach ( $game_mods as $game_mod )
|
||||
{
|
||||
if( preg_match("/^none$/i", $game_mod['mod_name']) )
|
||||
{
|
||||
$mod_cfg_id = $game_mod['mod_cfg_id'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( isset($mod_cfg_id) )
|
||||
{
|
||||
if ( $db->addModToGameHome($home_id,$mod_cfg_id) === FALSE )
|
||||
{
|
||||
print_failure(get_lang_f('failed_to_assing_mod_to_home',$mod_cfg_id));
|
||||
}
|
||||
else
|
||||
{
|
||||
$maxplayers = $server_xml->max_user_amount ? $server_xml->max_user_amount : 0;
|
||||
if( $db->updateGameModParams($maxplayers,'','NA','0',$home_id,$mod_cfg_id) === FALSE )
|
||||
{
|
||||
print_failure(get_lang_f('failed_to_assing_mod_to_home',$mod_cfg_id));
|
||||
}
|
||||
else
|
||||
$enabled_mods = $db->getHomeMods($home_id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure( get_lang("note") .":". get_lang("note_no_mods") );
|
||||
echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>\n";
|
||||
echo "<input type='hidden' name='home_id' value=\"$home_id\" />\n";
|
||||
echo "<p>". get_lang("available_mods") .": <select name='mod_cfg_id'>\n";
|
||||
foreach ( $game_mods as $game_mod )
|
||||
{
|
||||
echo "<option value='".$game_mod['mod_cfg_id']."'>".$game_mod['mod_name']."</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo "<input type='submit' name='add_mod' value='". get_lang("add_mod") ."' /></p>";
|
||||
echo "</form>";
|
||||
}
|
||||
}
|
||||
|
||||
if( !empty($enabled_mods) )
|
||||
{
|
||||
$cpu_count = $remote->cpu_count();
|
||||
|
||||
if($cpu_count === -1)
|
||||
{
|
||||
print_failure( get_lang("warning_agent_offline_defaulting_CPU_count_to_1") );
|
||||
$cpu_count = 'NA';
|
||||
} else {
|
||||
// cpu numbering starts from 0 so lets remove the last cpu.
|
||||
--$cpu_count;
|
||||
}
|
||||
|
||||
echo "<table class='center'>\n".
|
||||
"<tr>".
|
||||
"<td></td>".
|
||||
"<td><b>". get_lang("mod_name") ."</b></td>";
|
||||
if ( $server_xml->max_user_amount )
|
||||
echo "<td><b>". get_lang("max_players") ."</b></td>";
|
||||
echo "<td><b>". get_lang("extra_cmd_line_args") ."</b></td>".
|
||||
"<td><b>". get_lang("nice_level") ."</b></td><td></td>".
|
||||
"</tr>\n";
|
||||
foreach ( $enabled_mods as $enabled_rows ) {
|
||||
echo "<tr id='mod_cfg_id_$enabled_rows[mod_cfg_id]'>".
|
||||
"<td><a href='?m=user_games&p=edit&mod_id=".$enabled_rows['mod_id'].
|
||||
"&home_id=$home_id&submit=delete_mod'>[ ". get_lang("remove_mod") ." ]</a><br>".
|
||||
"<a href='?m=user_games&p=install_cmds&home_id=$home_id&mod_id=".$enabled_rows['mod_id'].
|
||||
"'>". get_lang("mod_install_cmds") ."</a></td>\n".
|
||||
"<td>".$enabled_rows['mod_name']."</td>\n".
|
||||
"<td>\n";
|
||||
if ( $server_xml->max_user_amount )
|
||||
{
|
||||
echo create_drop_box_from_array(range(0,$server_xml->max_user_amount),
|
||||
'maxplayers',$enabled_rows['max_players'],true).
|
||||
"</td><td>";
|
||||
}
|
||||
echo "<input id='cliopts' type='text' name='cliopts' size='20' value=\"".
|
||||
str_replace('"', """, strip_real_escape_string($enabled_rows['extra_params']))."\" />".
|
||||
"</td><td>\n";
|
||||
|
||||
echo create_drop_box_from_array(array_merge(range(-19,19)),
|
||||
'nice',$enabled_rows['nice']).
|
||||
"</td><td>\n".
|
||||
"<button class='set_options' id='$enabled_rows[mod_cfg_id]' >". get_lang("set_options") ."</button>\n".
|
||||
"</td></tr>\n";
|
||||
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
|
||||
$game_mods = $db->getAvailableModsForGameHome($home_id);
|
||||
$mods_available = 0;
|
||||
foreach ( $game_mods as $game_mod )
|
||||
{
|
||||
if( !preg_match("/^none$/i", $game_mod['mod_name']) )
|
||||
{
|
||||
$mods_available++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($mods_available > 0)
|
||||
{
|
||||
echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>\n".
|
||||
"<input type='hidden' name='home_id' value=\"$home_id\" />\n".
|
||||
"<p>" . get_lang("available_mods") . ": <select name='mod_cfg_id'>\n";
|
||||
foreach ( $game_mods as $game_mod )
|
||||
{
|
||||
echo "<option value='".$game_mod['mod_cfg_id']."'>".$game_mod['mod_name']."</option>\n";
|
||||
}
|
||||
echo "</select>\n".
|
||||
"<input type='submit' name='add_mod' value='". get_lang("add_mod") ."' /></p>".
|
||||
"</form>";
|
||||
}
|
||||
|
||||
// Get the selected cores if the setting is enabled
|
||||
if(@$settings['allow_setting_cpu_affinity']){
|
||||
echo '<h3>'.get_lang('cpu_affinity').'</h3>';
|
||||
echo "<p class='info'>". get_lang("cpu_affinity_info") ."</p>\n";
|
||||
echo '<div id="cpu_select" class="cpu_select_div inline-block">';
|
||||
|
||||
$enabledCores = $db->getHomeAffinity($home_id);
|
||||
$cores = array();
|
||||
|
||||
if ($enabledCores !== 'NA')
|
||||
{
|
||||
|
||||
if (preg_match('/win/', $remote->what_os()))
|
||||
{
|
||||
$coreHex = hexdec($enabledCores);
|
||||
$cores = array();
|
||||
$core = 0;
|
||||
|
||||
while ($coreHex > 0)
|
||||
{
|
||||
if ($coreHex & 1 === 1)
|
||||
{
|
||||
$cores[] = $core;
|
||||
}
|
||||
|
||||
$core++;
|
||||
$coreHex >>= 1;
|
||||
}
|
||||
} else {
|
||||
$cores = explode(',', $enabledCores);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$cores = array_filter($cores, 'strlen'); // Don't strip out 0 as a value... default to unchecked
|
||||
|
||||
for($x = 0; $x <= $cpu_count; ++$x)
|
||||
{
|
||||
echo '<span><label for="cpu_'.$x.'">CPU '.$x.'</label> <input type="checkbox" name="cpus[]" value="'.$x.'" id="cpu_'.$x.'" class="cpus" '. ( in_array($x, $cores) ? 'checked' : '' ) .'/></span>';
|
||||
}
|
||||
|
||||
echo '<button class="set_options set_affinity_button" id="'.$enabled_rows['mod_cfg_id'].'" style="margin-left:10px;">'.get_lang('set_affinity').'</button></div>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript" src="js/modules/user_games-mods.js"></script>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,127 +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 exec_ogp_module()
|
||||
{
|
||||
$home_id = $_GET['home_id'];
|
||||
$mod_id = $_GET['mod_id'];
|
||||
global $db;
|
||||
$home_info = $db->getGameHome($home_id);
|
||||
|
||||
if ( array_key_exists($mod_id, $home_info['mods']) )
|
||||
{
|
||||
echo "<h2>".get_lang('cmds_for')." \"".htmlentities($home_info['home_name'])."\" [Mod:".$home_info['mods'][$mod_id]['mod_name']."]</h2>";
|
||||
$server_xml = read_server_config(SERVER_CONFIG_LOCATION.$home_info['home_cfg_file']);
|
||||
$mod_cfg_id = $home_info['mods'][$mod_id]['mod_cfg_id'];
|
||||
|
||||
if(isset($_POST['edit_preinstall_cmds']))
|
||||
{
|
||||
$precmd = $db->real_escape_string($_POST['edit_preinstall_cmds']);
|
||||
if( isset( $_POST['save_as_default'] ) )
|
||||
{
|
||||
$game_mod_query = "UPDATE OGP_DB_PREFIXconfig_mods SET def_precmd='$precmd' WHERE mod_cfg_id='$mod_cfg_id'";
|
||||
$db->query($game_mod_query);
|
||||
}
|
||||
else
|
||||
{
|
||||
$game_mod_query = "UPDATE OGP_DB_PREFIXgame_mods SET precmd='$precmd' WHERE mod_id='$mod_id'";
|
||||
$db->query($game_mod_query);
|
||||
}
|
||||
$home_info = $db->getGameHome($home_id);
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_postinstall_cmds']))
|
||||
{
|
||||
$postcmd = $db->real_escape_string($_POST['edit_postinstall_cmds']);
|
||||
if( isset( $_POST['save_as_default'] ) )
|
||||
{
|
||||
$game_mod_query = "UPDATE OGP_DB_PREFIXconfig_mods SET def_postcmd='$postcmd' WHERE mod_cfg_id='$mod_cfg_id'";
|
||||
$db->query($game_mod_query);
|
||||
}
|
||||
else
|
||||
{
|
||||
$game_mod_query = "UPDATE OGP_DB_PREFIXgame_mods SET postcmd='$postcmd' WHERE mod_id='$mod_id'";
|
||||
$db->query($game_mod_query);
|
||||
}
|
||||
$home_info = $db->getGameHome($home_id);
|
||||
}
|
||||
|
||||
$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'];
|
||||
?>
|
||||
<h2><?php
|
||||
print_lang('preinstall_cmds');
|
||||
?></h2>
|
||||
<table class="center">
|
||||
<tr>
|
||||
<td>
|
||||
<form method="POST">
|
||||
<textarea name="edit_preinstall_cmds" placeholder="<?php echo "[".get_lang('empty')."]"; ?>" style="width:80%;height:200px;" ><?php
|
||||
echo $precmd;
|
||||
?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button><?php
|
||||
print_lang('edit_preinstall_cmds');
|
||||
?></button>
|
||||
<input type="checkbox" name="save_as_default" value="true"/><?php print_lang('save_as_default_for_this_mod');?>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><?php
|
||||
print_lang('postinstall_cmds');
|
||||
?></h2>
|
||||
<table class="center">
|
||||
<tr>
|
||||
<td>
|
||||
<form method="POST">
|
||||
<textarea name="edit_postinstall_cmds" placeholder="<?php echo "[".get_lang('empty')."]"; ?>" style="width:80%;height:200px;" ><?php
|
||||
echo $postcmd;
|
||||
?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button><?php
|
||||
print_lang('edit_postinstall_cmds');
|
||||
?></button>
|
||||
<input type="checkbox" name="save_as_default" value="true"/><?php print_lang('save_as_default_for_this_mod');?>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table><?php
|
||||
}
|
||||
echo create_back_button('user_games','edit&home_id='.$home_id);
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,72 +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 = "User games";
|
||||
$module_version = "1.3";
|
||||
$db_version = 3;
|
||||
$module_required = TRUE;
|
||||
$module_menus = array(
|
||||
array( 'subpage' => '', 'name'=>'Game Servers', 'group'=>'admin' )
|
||||
);
|
||||
$install_queries = array();
|
||||
$install_queries[0] = array(
|
||||
"DROP TABLE IF EXISTS `".OGP_DB_PREFIX."user_homes`;",
|
||||
"CREATE TABLE IF NOT EXISTS ".OGP_DB_PREFIX."user_homes (
|
||||
`home_id` int(11) NOT NULL,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`access_rights` varchar(63) default NULL,
|
||||
PRIMARY KEY (`user_id`,`home_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;",
|
||||
"DROP TABLE IF EXISTS ".OGP_DB_PREFIX."user_group_remote_servers;",
|
||||
"CREATE TABLE ".OGP_DB_PREFIX."user_group_remote_servers (
|
||||
`remote_server_id` int(11) NOT NULL,
|
||||
`group_id` int(11) NOT NULL,
|
||||
`access_rights` varchar(63) default NULL,
|
||||
PRIMARY KEY (`remote_server_id`, `group_id`)
|
||||
)ENGINE=MyISAM DEFAULT CHARSET=latin1;",
|
||||
"DROP TABLE IF EXISTS ".OGP_DB_PREFIX."user_group_homes;",
|
||||
"CREATE TABLE ".OGP_DB_PREFIX."user_group_homes (
|
||||
`home_id` int(11) NOT NULL,
|
||||
`group_id` int(11) NOT NULL,
|
||||
`access_rights` varchar(63) default NULL,
|
||||
PRIMARY KEY (`home_id`, `group_id`)
|
||||
)ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
|
||||
$install_queries[1] = array(
|
||||
"DROP TABLE IF EXISTS `".OGP_DB_PREFIX."master_server_homes`;",
|
||||
"CREATE TABLE IF NOT EXISTS ".OGP_DB_PREFIX."master_server_homes (
|
||||
`home_id` int(11) NOT NULL,
|
||||
`home_cfg_id` int(11) NOT NULL,
|
||||
`remote_server_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`remote_server_id`, `home_cfg_id`)
|
||||
)ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
|
||||
$install_queries[2] = array(
|
||||
"ALTER TABLE `".OGP_DB_PREFIX."user_homes` ADD `user_expiration_date` VARCHAR(21) NOT NULL default 'X';",
|
||||
"ALTER TABLE `".OGP_DB_PREFIX."user_group_homes` ADD `user_group_expiration_date` VARCHAR(21) NOT NULL default 'X';");
|
||||
|
||||
$install_queries[3] = array(
|
||||
"ALTER TABLE `".OGP_DB_PREFIX."game_mods` modify column `cpu_affinity` varchar(64) null AFTER `extra_params`, comment = 'utf8mb4_general_ci';");
|
||||
?>
|
||||
|
|
@ -1,40 +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=user_games&p=edit&home_id=".$server_home['home_id']."'>
|
||||
<img src='" . check_theme_image("images/edit.png") . "' title='". get_lang("edit") ."'>
|
||||
<span>". get_lang("edit") ."</span>
|
||||
</a>"
|
||||
);
|
||||
|
||||
if(preg_match("/c/",$server_home['access_rights'])){
|
||||
if( isset($server_xml->custom_fields) ) {
|
||||
$module_buttons[] = "<a href=\"?m=user_games&p=custom_fields&home_id=".$server_home['home_id']."\" class=\"monitorbutton\">
|
||||
<img src='" . check_theme_image("images/customfields.png") . "' title='". get_lang("custom_fields") ."'>
|
||||
<span>". get_lang("custom_fields") ."</span>
|
||||
</a>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
<navigation>
|
||||
<page key="assign" file="assign_home.php" access="admin,user" />
|
||||
<page key="add" file="add_home.php" access="admin" />
|
||||
<page key="mods" file="home_mods.php" access="user,admin" />
|
||||
<page key="edit" file="edit_home.php" access="admin,user,subuser" />
|
||||
<page key="del" file="del_home.php" access="admin" />
|
||||
<page key="clone" file="clone_home.php" access="admin" />
|
||||
<page key="default" file="show_homes.php" access="admin" />
|
||||
<page key="install_cmds" file="install_cmds.php" access="admin" />
|
||||
<page key="get_size" file="get_size.php" access="admin,user,subuser" />
|
||||
<page key="custom_fields" file="custom_fields.php" access="admin,user,subuser" />
|
||||
<page key="browser" file="browser.php" access="admin,user,subuser" />
|
||||
<page key="check_expire" file="check_expire.php" access="admin,user,subuser,guest" />
|
||||
</navigation>
|
||||
|
|
@ -1,125 +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, $view, $loggedInUserInfo;
|
||||
|
||||
$page_GameHomes = (isset($_GET['page']) && (int)$_GET['page'] > 0) ? (int)$_GET['page'] : 1;
|
||||
$limit_GameHomes = (isset($_GET['limit']) && (int)$_GET['limit'] > 0) ? (int)$_GET['limit'] : 10;
|
||||
|
||||
$searchString = (isset($_GET['search']) && !empty($_GET['search'])) ? $_GET['search'] : false;
|
||||
$searchTypes = array('ip_port' => 'IP / Port', 'ownedBy' => 'Server Owner', 'rserver' => 'Remote Server', 'home_name' => 'Server Name');
|
||||
$searchType = isset($_GET['searchType']) ? $_GET['searchType'] : false;
|
||||
|
||||
if(hasValue($loggedInUserInfo) && is_array($loggedInUserInfo) && $loggedInUserInfo["users_page_limit"] && !(isset($_GET['limit']) and !empty($_GET['limit']))){
|
||||
$limit_GameHomes = $loggedInUserInfo["users_page_limit"];
|
||||
}
|
||||
|
||||
$game_homes = $db->getGameHomes_limit($page_GameHomes, $limit_GameHomes, $searchType, $searchString);
|
||||
|
||||
echo "<h2>".get_lang('game_servers')."</h2>";
|
||||
echo '<table style="width: 100%; margin-bottom: 50px;">
|
||||
<tr>
|
||||
<td style="width: 50%; vertical-align: middle; text-align: left;">
|
||||
<p><a href="?m=user_games&p=add">'.get_lang("add_new_game_home").'</a></p>
|
||||
</td>
|
||||
<td style="width: 50%; vertical-align: middle; text-align: right;">
|
||||
<form action="home.php" method="GET" style="float:right;">
|
||||
<input type ="hidden" name="m" value="user_games" />
|
||||
'. create_drop_box_from_array($searchTypes, 'searchType', $searchType, false) .'
|
||||
<input name="search" type="text" id="search" value="' . $searchString . '" />
|
||||
<input type="submit" value="'.get_lang('search').'" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
if (empty($game_homes)) {
|
||||
if (!empty($search_field)) {
|
||||
print_failure(get_lang_f('no_results_found', htmlentities($search_field)));
|
||||
|
||||
$view->refresh("?m=user_games", 5);
|
||||
} else {
|
||||
print_failure(get_lang('no_game_homes_found'));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
echo "<h2>".get_lang('available_game_homes')."</h2>";
|
||||
echo '<table class="center">';
|
||||
echo "<tr><th>".get_lang('home_id')."</th><th>".get_lang('game_server')."</th>
|
||||
<th>".get_lang('game_type')."</th>
|
||||
<th align='center'>".get_lang('game_home')."</th>
|
||||
<th>".get_lang('game_home_name')."</th>
|
||||
<th>".get_lang('server_expiration_date')."</th>
|
||||
<th>".get_lang('actions')."</th></tr>";
|
||||
$i = 0;
|
||||
// sort($game_homes);
|
||||
foreach( $game_homes as $row )
|
||||
{
|
||||
$display_ip = checkDisplayPublicIP($row['display_public_ip'], (isset($row['ip']) and $row['ip'] != $row['agent_ip']) ? $row['ip'] : $row['agent_ip']);
|
||||
|
||||
$os_arch = preg_match('/win/',$row['game_key']) ? "(Windows" : "(Linux";
|
||||
$os_arch .= preg_match('/(win|linux)64/',$row['game_key']) ? " 64bit)" : ")";
|
||||
echo "<tr class='tr".($i++%2)."'><td class='tdh'>$row[home_id]</td><td>".$display_ip."</td>".
|
||||
"<td class='tdh'>$row[game_name] $os_arch</td><td>$row[home_path]<br><div class='size' id='".$row["home_id"].
|
||||
"' style='cursor:pointer;' >[".get_lang('get_size')."]</div></td><td class='tdh'>";
|
||||
echo empty($row['home_name']) ? get_lang('not_available') : htmlentities($row['home_name']);
|
||||
$expiration_date = $row['server_expiration_date'] == "X" ? "X" : date('d/m/Y H:i:s', $row['server_expiration_date']);
|
||||
echo "</td><td>".$expiration_date."</td><td>
|
||||
<a href='?m=user_games&p=del&home_id=$row[home_id]'>[".get_lang('delete')."]</a>
|
||||
<a href='?m=user_games&p=edit&home_id=$row[home_id]'>[".get_lang('edit')."]</a>
|
||||
<a href='?m=user_games&p=clone&home_id=$row[home_id]'>[".get_lang('clone')."]</a>
|
||||
</td></tr>";
|
||||
}
|
||||
|
||||
echo "<tr><td colspan='3' style='border:none;' ></td><td style='border:none;' ><div style='float:left;margin-left:5px;' >".get_lang('total_size').":</div><div class='size' id='total' ".
|
||||
"style='cursor:pointer;float:left;margin-left:5px;' >[".get_lang('get_size')."]</div></td><td colspan='2' style='border:none;' ></td></tr>";
|
||||
|
||||
echo "</table>";
|
||||
|
||||
$count_GameHomes = $db->get_GameHomes_count($searchType, $searchString);
|
||||
|
||||
if (isset($_GET['search']) && !empty($_GET['search'])) {
|
||||
$uri = '?m=user_games&search='.$_GET['search'].'&limit='.$limit_GameHomes.'&page=';
|
||||
} else {
|
||||
$uri = '?m=user_games&limit='.$limit_GameHomes.'&page=';
|
||||
}
|
||||
|
||||
echo paginationPages($count_GameHomes[0]['total'], $page_GameHomes, $limit_GameHomes, $uri, 3, 'userGames');
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$('.size').click(function(){
|
||||
var $id = $(this).attr('id');
|
||||
$.get( "home.php?m=user_games&type=cleared&p=get_size&home_id="+$id, function( data ) {
|
||||
$('#'+$id+".size").text( data );
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue