No changes

This commit is contained in:
Frank Harris 2025-09-11 13:29:15 -04:00
parent 8680a02b13
commit b6b398f5bf
17374 changed files with 2475441 additions and 0 deletions

View file

@ -0,0 +1,293 @@
<?php
/*
*
* OGP - Open Game Panel
* Copyright (C) 2008 - 2018 The OGP Development Team
*
* http://www.opengamepanel.org/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
function do_progress($kbytes,$totalsize)
{
$mbytes = round($kbytes / 1024, 2);
if($kbytes > 0)
{
$pct = round(( $kbytes / $totalsize ) * 100, 2);
}
else
{
$pct = "-";
}
#echo "Percent is $pct";
return "$totalsize;$mbytes;$pct";
}
require_once("includes/lib_remote.php");
require_once("modules/config_games/server_config_parser.php");
require_once("protocol/lgsl/lgsl_protocol.php");
function exec_ogp_module() {
global $db,$view;
$home_id = $_REQUEST['home_id'];
$mod_id = $_REQUEST['mod_id'];
$ip = $_REQUEST['ip'];
$port = $_REQUEST['port'];
$user_id = $_SESSION['user_id'];
$isAdmin = $db->isAdmin( $_SESSION['user_id'] );
$query_groups = "";
if($isAdmin)
$home_info = $db->getGameHome($home_id);
else
{
$home_info = $db->getUserGameHome($user_id,$home_id);
$groups = $db->getUsersGroups($_SESSION['user_id']);
$query_groups .= " AND (";
foreach($groups as $group)
$query_groups .= "group_id=".$group['group_id']." OR ";
$query_groups .= "group_id=0 OR group_id IS NULL)";
}
if ( $home_info === FALSE )
{
print_failure(get_lang('no_rights'));
echo create_back_button("addonsmanager","user_addons");
return;
}
$home_cfg_id = $home_info['home_cfg_id'];
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']);
$addon_types = array('plugin', 'mappack', 'config');
$addon_type = isset($_REQUEST['addon_type']) ? $_REQUEST['addon_type'] : "";
$state = isset($_REQUEST['state']) ? $_REQUEST['state'] : "";
$pid = isset($_REQUEST['pid']) ? $_REQUEST['pid'] : -1;
if ( $state != "" )
{
$addon_id = (int)$_REQUEST['addon_id'];
$addons_rows = $db->resultQuery("SELECT url, path, post_script FROM OGP_DB_PREFIXaddons WHERE addon_id=".$addon_id.$query_groups);
if (!$addons_rows) {
print_failure(get_lang('invalid_addon'));
$view->refresh('?m=addonsmanager&p=user_addons&home_id='. $home_id .'&mod_id='. $mod_id .'&ip='. $ip .'&port='.$port);
return;
}
$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'],$home_info['timeout']);
$addon_info = $addons_rows[0];
$url = $addon_info['url'];
$filename = basename($url);
#### This makes replacements to the bash script:
if($addon_info['post_script'] != "")
{
$addon_info['post_script'] = strip_real_escape_string($addon_info['post_script']);
$check_passed = FALSE;
$address_at_post = $ip.":".$port;
$ip_ports = $db->getHomeIpPorts($home_info['home_id']);
foreach($ip_ports as $ip_port);
{
$address_owned = $ip_port['ip'].":".$ip_port['port'];
if($address_owned == $address_at_post)
{
$check_passed = TRUE;
$ip = $ip_port['ip'];
$port = $ip_port['port'];
}
}
if($check_passed)
{
$home_info['ip'] = $ip;
$home_info['port'] = $port;
if( isset($server_xml->gameq_query_name) )
{
require_once("modules/gamemanager/home_handling_functions.php");
$home_info['query_port'] = get_query_port($server_xml, $home_info['port']);
}
elseif( isset($server_xml->lgsl_query_name) )
{
$get_q_and_s = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $home_info['port'], "", "");
$home_info['query_port'] = $get_q_and_s['1'];
}
$home_info["incremental"] = $db->incrementalNumByHomeId( $home_info['home_id'], $home_info['mods'][$mod_id]['mod_cfg_id'], $home_info['remote_server_id'] );
$post_script = preg_replace( "/\%home_path\%/i", $home_info['home_path'], $addon_info['post_script']);
$post_script = preg_replace( "/\%home_name\%/i", $home_info['home_name'], $post_script);
$post_script = preg_replace( "/\%control_password\%/i", $home_info['control_password'], $post_script);
$post_script = preg_replace( "/\%max_players\%/i", $home_info['mods'][$mod_id]['max_players'], $post_script);
$post_script = preg_replace( "/\%ip\%/i", $home_info['ip'], $post_script);
$post_script = preg_replace( "/\%port\%/i", $home_info['port'], $post_script);
$post_script = preg_replace( "/\%query_port\%/i", $home_info['query_port'], $post_script);
$post_script = preg_replace( "/\%incremental\%/i", $home_info['incremental'], $post_script);
}
}
#### end of replacememnts
if ( $state == "start" AND $addon_id != "" )
$pid = $remote->start_file_download( $addon_info['url'], $home_info['home_path']."/".$addon_info['path'], $filename, "uncompress", $post_script);
$headers = get_headers($url, 1);
$download_available = !$headers ? FALSE : TRUE;
// Check if any error occured
if($download_available)
{
$bytes = is_array($headers['Content-Length']) ? $headers['Content-Length'][1] : $headers['Content-Length'];
// Display the File Size
$totalsize = $bytes / 1024;
clearstatcache();
}
$kbytes = $remote->rsync_progress($home_info['home_path']."/".$addon_info['path']."/".$filename);
list($totalsize,$mbytes,$pct) = explode(";",do_progress($kbytes,$totalsize));
$totalmbytes = round($totalsize / 1024, 2);
$pct = $pct > 100 ? 100 : $pct;
echo "<h2>" . htmlentities($home_info['home_name']) . "</h2>";
echo '<div class="dragbox bloc rounded" style="background-color:#dce9f2;" >
<h4>'.get_lang('install')." ".$filename." ${mbytes}MB/${totalmbytes}MB</h4>
<div style='background-color:#dce9f2;' >
";
$bar = '';
for( $i = 1; $i <= $pct; $i++ )
{
$bar .= '<img style="width:0.92%;vertical-align:middle;" src="images/progressBar.png">';
}
echo "<center>$bar <b style='vertical-align:top;display:inline;font-size:1.2em;color:red;' >$pct%</b></center>
</div>
</div>";
if ( ( $pct == "100" or !$download_available ) AND $post_script != "" )
{
$log_retval = $remote->get_log( "post_script",
$pid,
clean_path($home_info['home_path']."/".$server_xml->exe_location),
$script_log);
if ($log_retval == 0)
{
print_failure(get_lang('agent_offline'));
}
elseif ($log_retval == 1 || $log_retval == 2)
{
echo "<pre class='log'>".$script_log."</pre>";
}
elseif( $remote->is_screen_running("post_script",$pid) == 1 )
{
print_failure(get_lang_f('unable_to_get_log',$log_retval));
}
}
if( $pct == "100" or !$download_available or ( $download_available and $pct == "-" and $pid > 0 ) )
{
if(!$download_available)
{
print_failure(get_lang('failed_to_start_file_download'));
}
elseif( $remote->is_file_download_in_progress($pid) === 1 )
{
print_success(get_lang_f('wait_while_decompressing', $filename));
echo "<p><a href=\"?m=addonsmanager&amp;p=addons&amp;state=refresh&amp;home_id=$home_id&amp;mod_id=$mod_id".
"&amp;ip=$ip&amp;port=$port&amp;addon_id=$addon_id&amp;pid=$pid\">".get_lang('refresh')."</a></p>";
$view->refresh("?m=addonsmanager&amp;p=addons&amp;state=refresh&amp;home_id=$home_id&amp;mod_id=$mod_id".
"&amp;ip=$ip&amp;port=$port&addon_id=$addon_id&amp;pid=$pid",5);
}
elseif( $remote->is_file_download_in_progress($pid) === 0 AND $remote->is_screen_running("post_script",$pid) === 0 )
{
print_success(get_lang('addon_installed_successfully'));
echo "<p><a href=\"?m=addonsmanager&amp;p=user_addons&amp;home_id=$home_id".
"&amp;mod_id=$mod_id&amp;ip=$ip&amp;port=$port\">".get_lang('back')."</a></p>";
$view->refresh("?m=addonsmanager&amp;p=user_addons&amp;home_id=$home_id".
"&amp;mod_id=$mod_id&amp;ip=$ip&amp;port=$port",10);
return;
}
}
else
{
echo "<p><a href=\"?m=addonsmanager&amp;p=addons&amp;state=refresh&amp;home_id=$home_id&amp;mod_id=$mod_id".
"&amp;ip=$ip&amp;port=$port&amp;addon_id=$addon_id&amp;pid=$pid\">".get_lang('refresh')."</a></p>";
$view->refresh("?m=addonsmanager&amp;p=addons&amp;state=refresh&amp;home_id=$home_id&amp;mod_id=$mod_id".
"&amp;ip=$ip&amp;port=$port&amp;addon_id=$addon_id&amp;pid=$pid",5);
}
}
elseif( $addon_type != "" )
{
if (!in_array($addon_type, $addon_types)) {
print_failure(get_lang('invalid_addon_type'));
$view->refresh('?m=addonsmanager&p=user_addons&home_id='. $home_id .'&mod_id='. $mod_id .'&ip='. $ip .'&port='.$port);
return;
}
?>
<h2><?php echo htmlentities($home_info['home_name'])."&nbsp;".get_lang($addon_type) ;?></h2>
<table class='center'>
<form method='get'>
<input type='hidden' name='m' value='addonsmanager' />
<input type='hidden' name='p' value='addons' />
<input type='hidden' name='home_id' value='<?php echo $home_id; ?>' />
<input type='hidden' name='mod_id' value='<?php echo $mod_id; ?>' />
<input type='hidden' name='ip' value='<?php echo $ip; ?>' />
<input type='hidden' name='port' value='<?php echo $port; ?>' />
<input type='hidden' name='state' value='start' />
<tr><td align='right'><?php print_lang('game_name'); ?>: </td><td align='left'><?php echo $home_info['game_name']; ?></td></tr>
<tr><td align='right'><?php print_lang('directory'); ?>: </td><td align='left'><?php echo $home_info['home_path']; ?></td></tr>
<tr><td align='right'><?php print_lang('remote_server'); ?>: </td>
<td align='left'><?php echo "$home_info[remote_server_name] ($home_info[agent_ip]:$home_info[agent_port])"; ?></td></tr>
<tr><td align='right'><?php print_lang('select_addon'); ?>: </td>
<td align='left'>
<select name="addon_id">
<?php
$addons = $db->resultQuery("SELECT addon_id, name FROM OGP_DB_PREFIXaddons WHERE addon_type='".$addon_type."' AND home_cfg_id=" . $home_cfg_id . $query_groups . " ORDER BY name ASC");
foreach($addons as $addon)
{
?>
<option value="<?php echo $addon['addon_id']; ?>"><?php echo $addon['name']; ?></option>
<?php
}
?>
</select>
</td></tr>
<tr><td colspan='2' class='info'>&nbsp;</td></tr>
<td align='left'>
&nbsp;
</td></tr><tr><td align="right">
<input type="submit" name="update" value="<?php print_lang('install'); ?>" />
</form></td><td>
<form method="get">
<input type="hidden" name="m" value="addonsmanager" />
<input type="hidden" name="p" value="user_addons" />
<input type="hidden" name="home_id" value="<?php echo $home_id; ?>" />
<input type="hidden" name="mod_id" value="<?php echo $mod_id; ?>" />
<input type="hidden" name="ip" value="<?php echo $ip; ?>" />
<input type="hidden" name="port" value="<?php echo $port; ?>" />
<input type="submit" value="<?php print_lang('back'); ?>" />
</form>
</td></tr>
</table>
<?php
}
}
?>

View file

@ -0,0 +1,379 @@
<script type="text/javascript" src="js/modules/addonsmanager.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 exec_ogp_module() {
global $db;
if (isset($_POST['create_addon']) AND isset($_POST['name']) AND $_POST['url']=="")
{
print_failure(get_lang("fill_the_url_address_to_a_compressed_file"));
}
elseif(isset($_POST['create_addon']) AND isset($_POST['url']) AND $_POST['name']=="")
{
print_failure(get_lang("fill_the_addon_name"));
}
elseif(isset($_POST['create_addon']) AND isset($_POST['name']) and isset($_POST['url']) and empty($_POST['addon_type']) )
{
print_failure(get_lang("select_an_addon_type"));
}
elseif(isset($_POST['create_addon']) AND isset($_POST['name']) and isset($_POST['url']) and isset($_POST['addon_type']) and empty($_POST['home_cfg_id']) )
{
print_failure(get_lang("select_a_game_type"));
}
elseif (isset($_POST['create_addon']) AND isset($_POST['name']) AND isset($_POST['url']) AND isset($_POST['addon_type']) and isset($_POST['home_cfg_id']) )
{
$fields['name'] = $_POST['name'];
$fields['url'] = $_POST['url'];
$fields['path'] = $_POST['path'];
$fields['addon_type'] = $_POST['addon_type'];
$fields['home_cfg_id'] = $_POST['home_cfg_id'];
$fields['post_script'] = $_POST['post_script'];
$fields['group_id'] = $_POST['group_id'];
if( is_numeric($db->resultInsertId( 'addons', $fields )) )
{
print_success(get_lang_f("addon_has_been_created",$_POST['name']));
if (isset($_POST['addon_id']) && (int)$_POST['addon_id'] > 0 && isset($_POST['edit']))
$db->query("DELETE FROM OGP_DB_PREFIXaddons WHERE addon_id=" . (int)$_POST['addon_id']);
}
}
echo "<h2>".get_lang('addons_manager')."</h2>";
$name = isset($_POST['name']) ? $_POST['name'] : "";
$url = isset($_POST['url']) ? $_POST['url'] : "";
$path = isset($_POST['path']) ? $_POST['path'] : "";
$post_script = isset($_POST['post_script']) ? $_POST['post_script'] : "";
$home_cfg_id = isset($_POST['home_cfg_id']) ? $_POST['home_cfg_id'] : "";
$addon_type = isset($_POST['addon_type']) ? $_POST['addon_type'] : "";
$group_id = isset($_POST['group_id']) ? $_POST['group_id'] : "";
$addon_types = array('plugin', 'mappack', 'config');
if (isset($_POST['addon_id']) && (int)$_POST['addon_id'] > 0 && isset($_POST['edit']))
{
$addons_rows = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXaddons WHERE addon_id=".(int)$_POST['addon_id']);
$addon_info = $addons_rows[0];
$name = isset($addon_info['name']) ? $addon_info['name'] : "";
$url = isset($addon_info['url']) ? $addon_info['url'] : "";
$path = isset($addon_info['path']) ? $addon_info['path'] : "";
$post_script = isset($addon_info['post_script']) ? $addon_info['post_script'] : "";
$home_cfg_id = isset($addon_info['home_cfg_id']) ? $addon_info['home_cfg_id'] : "";
$addon_type = isset($addon_info['addon_type']) ? $addon_info['addon_type'] : "";
$group_id = isset($addon_info['group_id']) ? $addon_info['group_id'] : "";
}
?>
<form action="" method="post">
<table class="center">
<tr>
<td align="right">
<b><?php print_lang('addon_name'); ?></b>
</td>
<td align="left">
<input type="text" value="<?php echo $name; ?>" name="name" size="85" title="<?php print_lang('addon_name_info'); ?>" />
</td>
</tr>
<tr>
<td align="right">
<b><?php print_lang('url'); ?></b>
</td>
<td align="left">
<input type="text" value="<?php echo $url; ?>" name="url" size="85" title="<?php print_lang('url_info'); ?>" />
</td>
</tr>
<!-- If any, you can set the destination path, should be a relative path to the main game server folder. -->
<tr>
<td align="right">
<b><?php print_lang('path'); ?></b>
</td>
<td align="left">
<input type="text" value="<?php echo $path; ?>" name="path" size="85" title="<?php print_lang('path_info'); ?>" />
</td>
</tr>
<tr>
<td align="right">
<b><?php print_lang('post-script'); ?></b><br>
<u><?php print_lang('replacements'); ?></u><br>
%home_path%<br>
%home_name%<br>
%control_password%<br>
%max_players%<br>
%ip%<br>
%port%<br>
%query_port%<br>
%incremental%<br>
</td>
<td align="left">
<textarea name="post_script" style="width:99%;height:175px;" title="<?php print_lang('post-script_info'); ?>" ><?php echo strip_real_escape_string($post_script); ?></textarea>
</td>
</tr>
<tr>
<td align="right">
<b><?php print_lang('select_game_type'); ?></b>
</td>
<td align="left">
<select name='home_cfg_id'>
<?php
$game_cfgs = $db->getGameCfgs();
echo "<option style='background:black;color:white;' value=''>".get_lang('linux_games')."</option>\n";
foreach ( $game_cfgs as $row )
{
if ( preg_match("/linux/", $row['game_key']) )
{
$selected = (isset($home_cfg_id) AND $row['home_cfg_id'] == $home_cfg_id) ? 'selected="selected"' : '';
echo "<option $selected value='".$row['home_cfg_id']."'>".$row['game_name'];
if ( preg_match("/64/", $row['game_key']) ) echo " (64bit)";
echo "</option>\n";
}
}
echo "<option style='background:black;color:white;' value=''>".get_lang('windows_games')."</option>\n";
foreach ( $game_cfgs as $row )
{
if ( preg_match("/win/", $row['game_key']) )
{
$selected = (isset($home_cfg_id) AND $row['home_cfg_id'] == $home_cfg_id) ? 'selected=selected' : '';
echo "<option $selected value='".$row['home_cfg_id']."'>".$row['game_name'];
if ( preg_match("/64/", $row['game_key']) ) echo " (64bit)";
echo "</option>\n";
}
}
?>
</select>
</td>
</tr>
<tr>
<td align="right">
<b><?php print_lang('type'); ?></b>
</td>
<td align="left">
<?php
$types = array( 'plugin', 'mappack', 'config' );
foreach($types as $type)
{
$checked = ( isset($addon_type) AND $type == $addon_type) ? 'checked' : '';
echo '<input type="radio" name="addon_type" value="'.$type.'" '.$checked.'>'.get_lang($type);
}
?>
</td>
</tr>
<tr>
<td align="right">
<b><?php print_lang('show_to_group'); ?></b>
</td>
<td align="left">
<select name='group_id'>
<option value="0"><?php print_lang('all_groups'); ?></option>
<?php
$groups = $db->getGroupList();
foreach($groups as $group)
{
$selected = (isset($group_id) AND $group['group_id'] == $group_id) ? 'selected=selected' : '';
echo "<option value='".$group['group_id']."' $selected>".$group['group_name']."</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<?php
if (isset($_POST['addon_id']) && isset($_POST['edit']))
{
echo '<input type="hidden" name="addon_id" value="'.$_POST['addon_id'].'" >';
echo '<input type="hidden" name="edit" value="'.$_POST['edit'].'" >';
?>
<button name="create_addon" type="submit">
<?php print_lang('edit_addon'); ?>
</button>
<?php
}
else
{
?>
<button name="create_addon" type="submit">
<?php print_lang('create_addon'); ?>
</button>
<?php
}
?>
</td>
</tr>
</table>
</form>
<br>
<h2><?php print_lang('addons_db'); ?></h2>
<table class="center">
<tr>
<td align="center">
<form name="remove" action="" method="get">
<input name="m" type="hidden" value="addonsmanager"/>
<input name="p" type="hidden" value="addons_manager"/>
<b><?php print_lang('game'); ?></b> <select name='home_cfg_id'>
<?php
echo "<option style='background:black;color:white;' value=''>".get_lang('linux_games')."</option>\n";
foreach ( $game_cfgs as $row )
{
if ( preg_match("/linux/", $row['game_key']) )
{
if(isset($_GET['home_cfg_id']) AND $row['home_cfg_id'] == $_GET['home_cfg_id'])
$selected = "selected='selected'";
else
$selected = "";
echo "<option value='".$row['home_cfg_id']."' $selected >".$row['game_name'];
if ( preg_match("/64/", $row['game_key']) ) echo " (64bit)";
echo "</option>\n";
}
}
echo "<option style='background:black;color:white;' value=''>".get_lang('windows_games')."</option>\n";
foreach ( $game_cfgs as $row )
{
if(isset($_GET['home_cfg_id']) AND $row['home_cfg_id'] == $_GET['home_cfg_id'])
$selected = "selected='selected'";
else
$selected = "";
if ( preg_match("/win/", $row['game_key']) )
{
echo "<option value='".$row['home_cfg_id']."' $selected >".$row['game_name'];
if ( preg_match("/64/", $row['game_key']) ) echo " (64bit)";
echo "</option>\n";
}
}
?>
</select>
<b><?php print_lang('type'); ?></b>
<select name="addon_type">
<?php
$option = '';
foreach ($addon_types as $k) {
$option .= '<option';
if (isset($_GET['addon_type']) && $_GET['addon_type'] == $k) {
$option .= ' selected';
}
$option .= ' value="'. $k .'">'.get_lang($k).'</option>';
}
echo $option;
?>
</select>
<b><?php print_lang('group'); ?></b>
<select name='group_id'>
<option value="0"><?php print_lang('all_groups'); ?></option>
<?php
foreach($groups as $group)
{
$selected = (isset($_GET['group_id']) AND $group['group_id'] == $_GET['group_id']) ? 'selected=selected' : '';
echo "<option value='".$group['group_id']."' $selected>".$group['group_name']."</option>\n";
}
?>
</select>
<button name="show" type="submit">
<?php print_lang('show'); ?>
</button>
</td>
</tr>
<tr>
<td>
<input name="show_game" type="submit" value="<?php print_lang('show_addons_for_selected_game'); ?>"/>
<input name="show_type" type="submit" value="<?php print_lang('show_addons_for_selected_type'); ?>"/>
<input name="show_group" type="submit" value="<?php print_lang('show_addons_for_selected_group'); ?>"/>
<input name="show_all" type="submit" value="<?php print_lang('show_all_addons'); ?>"/>
</td>
</tr>
</form>
</table>
<?php
if (isset($_POST['addon_id']) && (int)$_POST['addon_id'] > 0 && isset($_POST['remove']))
{
if (!$db->query("DELETE FROM OGP_DB_PREFIXaddons WHERE addon_id=" . (int)$_POST['addon_id']))
print_lang('can_not_remove_addon');
}
$home_cfg_id = !empty($_GET['home_cfg_id']) && (int)$_GET['home_cfg_id'] > 0 ? (int)$_GET['home_cfg_id'] : 0;
$addon_type = !empty($_GET['addon_type']) && in_array($_GET['addon_type'], $addon_types) ? $_GET['addon_type'] : "";
$group_id = isset($_GET['group_id']) && is_numeric($_GET['group_id']) ? (int)$_GET['group_id'] : 0;
if ( isset($_GET['show']) )
{
$result = $db->resultQuery("SELECT DISTINCT addon_id, name, game_name, url, path, group_id FROM OGP_DB_PREFIXaddons NATURAL JOIN OGP_DB_PREFIXconfig_homes WHERE addon_type='".$addon_type."' AND home_cfg_id=".$home_cfg_id);
}
elseif ( isset($_GET['show_all']) )
{
$result = $db->resultQuery("SELECT DISTINCT addon_id, name, game_name, url, path, group_id FROM OGP_DB_PREFIXaddons NATURAL JOIN OGP_DB_PREFIXconfig_homes");
}
elseif ( isset($_GET['show_type']))
{
$result = $db->resultQuery("SELECT DISTINCT addon_id, name, game_name, url, path, group_id FROM OGP_DB_PREFIXaddons NATURAL JOIN OGP_DB_PREFIXconfig_homes WHERE addon_type='".$addon_type."'");
}
elseif ( isset($_GET['show_game']))
{
$result = $db->resultQuery("SELECT DISTINCT addon_id, name, game_name, url, path, group_id FROM OGP_DB_PREFIXaddons NATURAL JOIN OGP_DB_PREFIXconfig_homes WHERE home_cfg_id=".$home_cfg_id);
}
elseif ( isset($_GET['show_group']))
{
$group_id = $group_id == '0' ? $group_id." OR group_id IS NULL" : $group_id;
$result = $db->resultQuery("SELECT DISTINCT addon_id, name, game_name, url, path, group_id FROM OGP_DB_PREFIXaddons NATURAL JOIN OGP_DB_PREFIXconfig_homes WHERE group_id=".$group_id);
}
?>
<table class="center">
<?php
$group_names = array();
foreach($groups as $group)
$group_names[$group['group_id']] = $group['group_name'];
if (isset($result) and $result > 0)
{
foreach($result as $row)
{
?>
<tr>
<form action="" method="post">
<td class='left'>
<b><?php echo $row['game_name']; ?></b>
</td>
<td>
<?php echo $row['name'];?>
</td>
<td>
<?php echo "[".get_lang('group').": ". (isset($group_names[$row['group_id']])?$group_names[$row['group_id']]:get_lang('all_groups')) ."]";?>
</td>
<td>
<input name="addon_id" type="hidden" value="<?php echo $row['addon_id'];?>"/>
<input name="edit" type="submit" value="<?php print_lang('edit_addon'); ?>"/>
<input name="remove" type="submit" value="<?php print_lang('remove_addon'); ?>"/>
</td>
</form>
</tr>
<?php
}
}
?>
</table>
<?php
}
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View file

@ -0,0 +1,48 @@
<?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 = "Addons Manager";
$module_version = "1.2";
$db_version = 2;
$module_required = TRUE;
$module_menus = array( array( 'subpage' => 'addons_manager', 'name'=>'Addons Manager', 'group'=>'admin' ) );
$install_queries = array();
$install_queries[0] = array(
"DROP TABLE IF EXISTS `".OGP_DB_PREFIX."addons`;",
"CREATE TABLE IF NOT EXISTS ".OGP_DB_PREFIX."addons
(addon_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(80) NOT NULL,
url VARCHAR(200) NOT NULL,
path VARCHAR(80) NOT NULL,
addon_type VARCHAR(7) NOT NULL,
home_cfg_id VARCHAR(7) NOT NULL) ENGINE=MyISAM;");
$install_queries[1] = array(
"ALTER TABLE `".OGP_DB_PREFIX."addons` ADD `post_script` longtext NOT NULL;");
$install_queries[2] = array(
"ALTER TABLE `".OGP_DB_PREFIX."addons` ADD `group_id` int(11) NULL;");
?>

View file

@ -0,0 +1,48 @@
<?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.
*
*/
$query_groups = "";
if($_SESSION['users_role'] != "admin")
{
$groups = $db->getUsersGroups($_SESSION['user_id']);
$query_groups .= " AND (";
foreach($groups as $group)
$query_groups .= "group_id=".$group['group_id']." OR ";
$query_groups .= "group_id=0 OR group_id IS NULL)";
}
$addons = $db->resultQuery("SELECT addon_id FROM OGP_DB_PREFIXaddons WHERE home_cfg_id=".$server_home['home_cfg_id'].$query_groups);
$addons_qty = count($addons);
if($addons and $addons_qty >= 1){
$module_buttons = array(
"<a class='monitorbutton' href='?m=addonsmanager&amp;p=user_addons&amp;home_id=".
$server_home['home_id']."&amp;mod_id=".$server_home['mod_id'].
"&amp;ip=".$server_home['ip']."&amp;port=".$server_home['port']."'>
<img src='" . check_theme_image("modules/administration/images/addons_manager.png") . "' title='". get_lang("addons") ."'>
<span>". get_lang("addons") ." (".$addons_qty.")</span>
</a>"
);
}
else
$module_buttons = array();
?>

View file

@ -0,0 +1,5 @@
<navigation>
<page key="user_addons" file="user_addons.php" access="admin,user" />
<page key="addons_manager" file="addons_manager.php" access="admin" />
<page key="addons" file="addons_installer.php" access="admin,user" />
</navigation>

View file

@ -0,0 +1,97 @@
<?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;
$home_id = $_GET['home_id'];
$mod_id = $_GET['mod_id'];
$ip = $_GET['ip'];
$port = $_GET['port'];
$user_id = $_SESSION['user_id'];
// Check if user has some games.
$isAdmin = $db->isAdmin( $user_id );
$query_groups = "";
if($isAdmin)
$home_info = $db->getGameHome($home_id);
else
{
$home_info = $db->getUserGameHome($user_id,$home_id);
$groups = $db->getUsersGroups($_SESSION['user_id']);
$query_groups .= " AND (";
foreach($groups as $group)
$query_groups .= "group_id=".$group['group_id']." OR ";
$query_groups .= "group_id=0 OR group_id IS NULL)";
}
if ($home_info)
{
$home_cfg_id = $home_info['home_cfg_id'];
echo "<h2>".get_lang('user_addons').": ".htmlentities($home_info['home_name'])."</h2>\n".
"<table class='center' >\n".
"<tr><td>\n";
$plugins = $db->resultQuery("SELECT DISTINCT addon_id, name, game_name ".
"FROM OGP_DB_PREFIXaddons ".
"NATURAL JOIN OGP_DB_PREFIXconfig_homes ".
"WHERE addon_type='plugin' ".
"AND home_cfg_id=".$home_cfg_id.$query_groups);
$plugins_qty = count($plugins);
if($plugins and $plugins_qty >= 1)
echo "<a href='?m=addonsmanager&amp;p=addons&amp;home_id=".$home_id.
"&amp;mod_id=".$mod_id."&amp;addon_type=plugin&amp;ip=".$ip.
"&amp;port=".$port."'>".get_lang('install_plugin')."(".$plugins_qty.")</a>\n";
$mappacks = $db->resultQuery("SELECT DISTINCT addon_id, name, game_name ".
"FROM OGP_DB_PREFIXaddons ".
"NATURAL JOIN OGP_DB_PREFIXconfig_homes ".
"WHERE addon_type='mappack' ".
"AND home_cfg_id=".$home_cfg_id.$query_groups);
$mappacks_qty = count($mappacks);
if($mappacks and $mappacks_qty >= 1){
echo "</td><td>";
echo "<a href='?m=addonsmanager&amp;p=addons&amp;home_id=".$home_id.
"&amp;mod_id=".$mod_id."&amp;addon_type=mappack&amp;ip=".$ip.
"&amp;port=".$port."'>".get_lang('install_mappack')."(".$mappacks_qty.")</a>\n";
}
$configs = $db->resultQuery("SELECT DISTINCT addon_id, name, game_name ".
"FROM OGP_DB_PREFIXaddons ".
"NATURAL JOIN OGP_DB_PREFIXconfig_homes ".
"WHERE addon_type='config' ".
"AND home_cfg_id=".$home_cfg_id.$query_groups);
$configs_qty = count($configs);
if($configs and $configs_qty >= 1){
echo "</td><td>";
echo "<a href='?m=addonsmanager&amp;p=addons&amp;home_id=".$home_id.
"&amp;mod_id=".$mod_id."&amp;addon_type=config&amp;ip=".$ip.
"&amp;port=".$port."'>".get_lang('install_config')."(".$configs_qty.")</a>\n";
}
echo "</td></tr>\n".
"</table>\n".
"<form action='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=$home_id-$mod_id-$ip-$port' method='POST'>\n".
"<input type='submit' value='".get_lang('back')."' />\n".
"</form>\n".
"<br>\n";
}
else
print_failure(get_lang('no_games_servers_available'));
}
?>