No changes
This commit is contained in:
parent
8680a02b13
commit
b6b398f5bf
17374 changed files with 2475441 additions and 0 deletions
114
ControlPanel/modules/editconfigfiles/array_column.php
Normal file
114
ControlPanel/modules/editconfigfiles/array_column.php
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of the array_column library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey (http://benramsey.com)
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
if (!function_exists('array_column')) {
|
||||
/**
|
||||
* Returns the values from a single column of the input array, identified by
|
||||
* the $columnKey.
|
||||
*
|
||||
* Optionally, you may provide an $indexKey to index the values in the returned
|
||||
* array by the values from the $indexKey column in the input array.
|
||||
*
|
||||
* @param array $input A multi-dimensional array (record set) from which to pull
|
||||
* a column of values.
|
||||
* @param mixed $columnKey The column of values to return. This value may be the
|
||||
* integer key of the column you wish to retrieve, or it
|
||||
* may be the string key name for an associative array.
|
||||
* @param mixed $indexKey (Optional.) The column to use as the index/keys for
|
||||
* the returned array. This value may be the integer key
|
||||
* of the column, or it may be the string key name.
|
||||
* @return array
|
||||
*/
|
||||
function array_column($input = null, $columnKey = null, $indexKey = null)
|
||||
{
|
||||
// Using func_get_args() in order to check for proper number of
|
||||
// parameters and trigger errors exactly as the built-in array_column()
|
||||
// does in PHP 5.5.
|
||||
$argc = func_num_args();
|
||||
$params = func_get_args();
|
||||
|
||||
if ($argc < 2) {
|
||||
trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!is_array($params[0])) {
|
||||
trigger_error(
|
||||
'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',
|
||||
E_USER_WARNING
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!is_int($params[1])
|
||||
&& !is_float($params[1])
|
||||
&& !is_string($params[1])
|
||||
&& $params[1] !== null
|
||||
&& !(is_object($params[1]) && method_exists($params[1], '__toString'))
|
||||
) {
|
||||
trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($params[2])
|
||||
&& !is_int($params[2])
|
||||
&& !is_float($params[2])
|
||||
&& !is_string($params[2])
|
||||
&& !(is_object($params[2]) && method_exists($params[2], '__toString'))
|
||||
) {
|
||||
trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
$paramsInput = $params[0];
|
||||
$paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
|
||||
|
||||
$paramsIndexKey = null;
|
||||
if (isset($params[2])) {
|
||||
if (is_float($params[2]) || is_int($params[2])) {
|
||||
$paramsIndexKey = (int) $params[2];
|
||||
} else {
|
||||
$paramsIndexKey = (string) $params[2];
|
||||
}
|
||||
}
|
||||
|
||||
$resultArray = array();
|
||||
|
||||
foreach ($paramsInput as $row) {
|
||||
$key = $value = null;
|
||||
$keySet = $valueSet = false;
|
||||
|
||||
if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
|
||||
$keySet = true;
|
||||
$key = (string) $row[$paramsIndexKey];
|
||||
}
|
||||
|
||||
if ($paramsColumnKey === null) {
|
||||
$valueSet = true;
|
||||
$value = $row;
|
||||
} elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
|
||||
$valueSet = true;
|
||||
$value = $row[$paramsColumnKey];
|
||||
}
|
||||
|
||||
if ($valueSet) {
|
||||
if ($keySet) {
|
||||
$resultArray[$key] = $value;
|
||||
} else {
|
||||
$resultArray[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $resultArray;
|
||||
}
|
||||
}
|
||||
89
ControlPanel/modules/editconfigfiles/configFileList.php
Normal file
89
ControlPanel/modules/editconfigfiles/configFileList.php
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2017 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/editconfigfiles/functions.php');
|
||||
require_once("modules/config_games/server_config_parser.php");
|
||||
|
||||
function exec_ogp_module()
|
||||
{
|
||||
global $db, $view;
|
||||
|
||||
$home_id = (int)$_GET['home_id'];
|
||||
$isAdmin = $db->isAdmin($_SESSION['user_id']);
|
||||
|
||||
if (empty($home_id) || $home_id === 0) {
|
||||
print_failure(get_lang('no_server_specfied'));
|
||||
$view->refresh("?m=gamemanager&p=game_monitor");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($isAdmin) {
|
||||
$server_home = $db->getGameHome($home_id);
|
||||
} else {
|
||||
$server_home = $db->getUserGameHome($_SESSION['user_id'], $home_id);
|
||||
}
|
||||
|
||||
if ($server_home === false) {
|
||||
print_failure(get_lang('no_home'));
|
||||
$view->refresh("?m=gamemanager&p=game_monitor");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$server_xml = read_server_config(SERVER_CONFIG_LOCATION .'/'. $server_home['home_cfg_file']);
|
||||
|
||||
$files = getFilesInXML($server_xml->configuration_files);
|
||||
|
||||
if (empty($files)) {
|
||||
print_failure(get_lang('no_configs_for_game'));
|
||||
$view->refresh("?m=gamemanager&p=game_monitor");
|
||||
} else {
|
||||
echo '<h2>'.get_lang('configuration_files').'</h2>';
|
||||
|
||||
echo '<table width="100%">
|
||||
<tr>
|
||||
<th>'.get_lang('name').'</th>
|
||||
<th>'.get_lang('description').'</th>
|
||||
<th>'.get_lang('actions').'</th>
|
||||
</tr>';
|
||||
|
||||
foreach ($files as $file) {
|
||||
echo '<tr>
|
||||
<td>'. $file['name'] .'</td>
|
||||
<td>'. ($file['description'] ?: '<i>'.get_lang('no_description').'</i>') .'</td>
|
||||
<td><a href="?m=editconfigfiles&p=modify&home_id='.$server_home['home_id'].'&file='.rawurlencode($file['path']).'">[ '.get_lang('edit').' ]</a></td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
$modKey = key($server_home['mods']);
|
||||
$IpPorts = $db->getHomeIpPorts($home_id);
|
||||
|
||||
echo '<div style="margin-top:12px">
|
||||
<a href="?m=gamemanager&p=game_monitor&home_id-mod_id-ip-port='. $home_id .'-'. $server_home['mods'][$modKey]['mod_id'] .'-'. $IpPorts[0]['ip'] .'-'. $IpPorts[0]['port'] .'">'.get_lang('go_back').'</a>
|
||||
</div>';
|
||||
}
|
||||
22
ControlPanel/modules/editconfigfiles/functions.php
Normal file
22
ControlPanel/modules/editconfigfiles/functions.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
function getFilesInXML($files)
|
||||
{
|
||||
$values = array();
|
||||
|
||||
if (isset($files->file)) {
|
||||
foreach ($files->file as $file) {
|
||||
if ((string)$file == false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values[] = array(
|
||||
'name' => (string)$file,
|
||||
'description' => $file['description'],
|
||||
'path' => (string)$file
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
105
ControlPanel/modules/editconfigfiles/modify.php
Normal file
105
ControlPanel/modules/editconfigfiles/modify.php
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2017 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 'modules/editconfigfiles/array_column.php';
|
||||
require 'modules/editconfigfiles/functions.php';
|
||||
require_once 'modules/config_games/server_config_parser.php';
|
||||
require 'includes/lib_remote.php';
|
||||
|
||||
function exec_ogp_module()
|
||||
{
|
||||
global $db, $view;
|
||||
|
||||
$home_id = (int)$_GET['home_id'];
|
||||
$isAdmin = $db->isAdmin($_SESSION['user_id']);
|
||||
|
||||
if ($isAdmin) {
|
||||
$server_home = $db->getGameHome($home_id);
|
||||
} else {
|
||||
$server_home = $db->getUserGameHome($_SESSION['user_id'], $home_id);
|
||||
}
|
||||
|
||||
if ($server_home === false) {
|
||||
print_failure(get_lang('no_home'));
|
||||
$view->refresh("?m=gamemanager&p=game_monitor");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$server_xml = read_server_config(SERVER_CONFIG_LOCATION .'/'. $server_home['home_cfg_file']);
|
||||
$files = getFilesInXML($server_xml->configuration_files);
|
||||
|
||||
$file = ($_SERVER['REQUEST_METHOD'] === 'POST' ? rawurldecode($_POST['file']) : rawurldecode($_GET['file']));
|
||||
|
||||
if (array_search($file, array_column($files, 'path')) === false) {
|
||||
print_failure(get_lang('invalid_file'));
|
||||
$view->refresh("?m=editconfigfiles&home_id=". (int)$server_home['home_id']);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$remote = new OGPRemoteLibrary($server_home['agent_ip'], $server_home['agent_port'], $server_home['encryption_key'], $server_home['timeout']);
|
||||
|
||||
if ($remote->status_chk() === 0) {
|
||||
print_failure(get_lang('agent_offline'));
|
||||
$view->refresh("?m=gamemanager&p=game_monitor");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$file_info = $remote->remote_writefile($server_home['home_path'] . '/' . $file, strip_real_escape_string($_POST['file_content']));
|
||||
|
||||
if ($file_info === 1) {
|
||||
print_success(get_lang('wrote_changes'));
|
||||
$view->refresh("?m=editconfigfiles&home_id=". (int)$server_home['home_id']);
|
||||
|
||||
return;
|
||||
} else {
|
||||
print_failure(get_lang('failed_write'));
|
||||
$view->refresh("?m=editconfigfiles&home_id=". (int)$server_home['home_id']);
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$newFile = ($remote->rfile_exists($server_home['home_path'] . '/' . $file) == 0 ? true : false);
|
||||
$file_info = $remote->remote_readfile($server_home['home_path'] . '/' . $file, $data);
|
||||
|
||||
if ($file_info !== 1) {
|
||||
print_failure(get_lang('failed_read'));
|
||||
$view->refresh("?m=editconfigfiles");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<h2>'.get_lang('editing_file').'</h2><p><b>'.($newFile ? get_lang('new_file').':' : '') .' '. htmlentities($file).'</b></p>';
|
||||
echo '<form action="?m=editconfigfiles&p=modify&home_id='.$server_home['home_id'].'" method="POST">';
|
||||
echo '<input type="hidden" name="file" value="'.rawurlencode($_GET['file']).'">';
|
||||
echo '<input type="hidden" name="action" value="save">';
|
||||
echo '<textarea name="file_content" style="width:98%;" rows="40">'. $data .'</textarea>';
|
||||
echo '<p><input type="submit" name="write" value="'. get_lang('save') . '" /></p>';
|
||||
echo '</form>';
|
||||
echo '<div><a href="?m=editconfigfiles&home_id='. (int)$server_home['home_id'].'">'.get_lang('go_back').'</a></div>';
|
||||
}
|
||||
}
|
||||
29
ControlPanel/modules/editconfigfiles/module.php
Normal file
29
ControlPanel/modules/editconfigfiles/module.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2017 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 = "Edit Config Files";
|
||||
$module_version = "0.2";
|
||||
$db_version = 0;
|
||||
$module_required = false;
|
||||
35
ControlPanel/modules/editconfigfiles/monitor_buttons.php
Normal file
35
ControlPanel/modules/editconfigfiles/monitor_buttons.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2018 The OGP Development Team
|
||||
*
|
||||
* http://www.opengamepanel.org/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
if(!empty($server_xml->configuration_files)) {
|
||||
$module_buttons = array(
|
||||
"<a href=\"?m=editconfigfiles&home_id=".(int)$server_home['home_id']."\" class=\"monitorbutton\">
|
||||
<img src='" . check_theme_image("images/editconfig.png") . "' title='". get_lang("edit_configuration_files") ."'>
|
||||
<span>". get_lang("edit_configuration_files") ."</span>
|
||||
</a>"
|
||||
);
|
||||
}
|
||||
else
|
||||
$module_buttons = array();
|
||||
?>
|
||||
4
ControlPanel/modules/editconfigfiles/navigation.xml
Normal file
4
ControlPanel/modules/editconfigfiles/navigation.xml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<navigation>
|
||||
<page key="modify" file="modify.php" access="user,admin,subuser" />
|
||||
<page key="default" file="configFileList.php" access="user,admin,subuser" />
|
||||
</navigation>
|
||||
Loading…
Add table
Add a link
Reference in a new issue