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,150 +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()
|
||||
{
|
||||
include "modules/tshock/shared.php";
|
||||
if($continue)
|
||||
{
|
||||
?>
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a href="?m=tshock&p=bans&show=create&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">
|
||||
Create
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="?m=tshock&p=bans&show=list&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">
|
||||
List
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="?m=tshock&p=bans&show=read&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">
|
||||
Read
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<?php
|
||||
if($_GET['show'] == 'create')//Create a new ban entry.
|
||||
{
|
||||
?>
|
||||
<div id="tab4" class="tab-pane" role="tabpanel">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p class="mbr-text py-5 mbr-fonts-style display-7"></p>
|
||||
<form action="?m=tshock&p=bans&show=create&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>" method="POST">
|
||||
IP: <input type="text" name="ip" placeholder="The IP to ban" size="34"><br><br>
|
||||
Name: <input type="text" name="name" placeholder="The name to ban" size="30"><br><br>
|
||||
Reason: <input type="text" name="reason" placeholder="Reason to assign the ban" size="29"><br>
|
||||
<br><input type="submit" name="create" value="Ban User">
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
If(isset($_POST['create'])){
|
||||
if($token){
|
||||
$params = array('token' => $token,
|
||||
'ip' => $_POST['ip'],
|
||||
'name' => $_POST['name'],
|
||||
'reason' => $_POST['reason']);
|
||||
$response = getResponse($ip, $port, '/bans/create/', $params);
|
||||
print_success($response['response']);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure("No Token Found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($_GET['show'] == 'list') //View all bans in the tshock database.
|
||||
{
|
||||
if($token){
|
||||
$params = array('token' => $token);
|
||||
$response = getResponse($ip, $port, '/v2/bans/list/', $params);
|
||||
$bans_table = "<table>";
|
||||
foreach($response['bans'] as $ban)
|
||||
{
|
||||
$bans_table .= "<tr>";
|
||||
foreach($ban as $ban_key => $ban_value)
|
||||
$bans_table .= "<td><b>".strtoupper($ban_key)."</b>: ".$ban_value."</td>";
|
||||
$bans_table .= "</tr>";
|
||||
}
|
||||
$bans_table .= "</table>";
|
||||
echo $bans_table;
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure("No Token Found!");
|
||||
}
|
||||
}
|
||||
|
||||
if($_GET['show'] == 'read') //View the details of a specific ban.
|
||||
{
|
||||
?>
|
||||
<div id="tab4" class="tab-pane" role="tabpanel">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p class="mbr-text py-5 mbr-fonts-style display-7"></p>
|
||||
<form action="?m=tshock&p=bans&show=read&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>" method="POST">
|
||||
Username or IP: <input type="text" name="ban" placeholder="IP or name to look up" size="35"><br><br>
|
||||
Type: <input type="radio" name="type" value="ip" checked> IP
|
||||
<input type="radio" name="type" value="name"> Name<br><br>
|
||||
<input type="checkbox" name="caseinsensitive" value="caseinsensitive">Case Sensitive (Name lookups should be case sensitive.)<br>
|
||||
<br><input type="submit" name="read" value="Show Details">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div><?php
|
||||
if(isset($_POST['read'])){
|
||||
if($token){
|
||||
$caseinsensitive = isset($_POST['caseinsensitive'])?'true':'false';
|
||||
$params = array('token' => $token,
|
||||
'ban' => $_POST['ban'],
|
||||
'type' => $_POST['type'],
|
||||
'caseinsensitive' => $caseinsensitive);
|
||||
$response = getResponse($ip, $port, '/v2/bans/read/', $params);
|
||||
if($response['status'] == '200')
|
||||
{
|
||||
$bans_table = "<table><tr>";
|
||||
foreach($response as $ban_key => $ban_value)
|
||||
if($ban_key != 'status')
|
||||
$bans_table .= "<td><b>".strtoupper($ban_key)."</b>: ".$ban_value."</td>";
|
||||
$bans_table .= "</tr></table>";
|
||||
echo $bans_table;
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure($response['error']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure("No Token Found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,64 +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()
|
||||
{
|
||||
include "modules/tshock/shared.php";
|
||||
if($continue)
|
||||
{
|
||||
?>
|
||||
<div id="tab4" class="tab-pane" role="tabpanel">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p class="mbr-text py-5 mbr-fonts-style display-7"></p>
|
||||
<form action="?m=tshock&p=create_token&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>" method="POST">
|
||||
Username: <input type="text" name="username" placeholder="Superadmin Username"><br>
|
||||
Password: <input type="text" name="password" placeholder="Superadmin Password"><br>
|
||||
<input type="submit" name="create_token" value="Create Token">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
If(isset($_POST['create_token'])){
|
||||
$response = getResponse($ip, $port, '/v2/token/create', array('username' => $_POST['username'], 'password' => $_POST['password']));
|
||||
|
||||
If($response['status'] == '200'){
|
||||
if(saveToken($ip, $port, $response['token']))
|
||||
{
|
||||
print_success("Token Saved!");
|
||||
$view->refresh('home.php?m=tshock&home_id-mod_id-ip-port='.$_GET['home_id-mod_id-ip-port'], 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure("Failed saving the token.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure($response['error']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
|
||||
function getResponse($ip, $port, $query, $params = array()){
|
||||
$api_request = 'http://'.$ip.':'.($port + 101).$query;
|
||||
if(!empty($params))
|
||||
{
|
||||
$api_request .= '?';
|
||||
foreach($params as $param_key => $param_value)
|
||||
$api_request .= $param_key."=".urlencode($param_value)."&";
|
||||
}
|
||||
return json_decode(file_get_contents($api_request), True);
|
||||
}
|
||||
|
||||
function istshockAvailable($ip, $port){
|
||||
$api_url = 'http://'.$ip.':'.($port + 101);
|
||||
if(!file_get_contents($api_url))
|
||||
{
|
||||
print_failure("tshock is not available in the selected server, or the server is offline");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function saveToken($ip, $port, $token){
|
||||
global $db;
|
||||
$query = sprintf("DELETE FROM `%stshock` WHERE `ip` = '%s' AND `port` = '%d'",
|
||||
$db->getTablePrefix(),
|
||||
$db->realEscapeSingle($ip),
|
||||
$db->realEscapeSingle($port));
|
||||
if($db->query($query))
|
||||
{
|
||||
$query = sprintf("INSERT INTO `%stshock` (`ip`,`port`,`token`) VALUES('%s', '%d', '%s')",
|
||||
$db->getTablePrefix(),
|
||||
$db->realEscapeSingle($ip),
|
||||
$db->realEscapeSingle($port),
|
||||
$db->realEscapeSingle($token));
|
||||
if($db->query($query))
|
||||
{
|
||||
return True;
|
||||
}
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
function getToken($ip, $port){
|
||||
global $db;
|
||||
$query = sprintf("SELECT `token` FROM `%stshock` WHERE `ip`='%s' AND `port`='%d';",
|
||||
$db->getTablePrefix(),
|
||||
$db->realEscapeSingle($ip),
|
||||
$db->realEscapeSingle($port));
|
||||
$result = $db->resultQuery($query);
|
||||
if($result != FALSE)
|
||||
{
|
||||
$last = end($result);
|
||||
return $last['token'];
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
|
@ -1,42 +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 = "tshock";
|
||||
$module_version = "Alpha";
|
||||
$db_version = 0;
|
||||
$module_required = FALSE;
|
||||
$module_menus = array( array( 'subpage' => '', 'name'=>'tshock', 'group'=>'user' ) );
|
||||
|
||||
$install_queries = array();
|
||||
$install_queries[0] = array(
|
||||
"DROP TABLE IF EXISTS ".OGP_DB_PREFIX."tshock;",
|
||||
"CREATE TABLE ".OGP_DB_PREFIX."tshock (
|
||||
`token_id` int(11) NOT NULL auto_increment,
|
||||
`ip` varchar(255) NOT NULL,
|
||||
`port` int(11) NOT NULL,
|
||||
`token` varchar(64) NOT NULL,
|
||||
PRIMARY KEY (`token_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
?>
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<navigation>
|
||||
<page key="default" file="server.php" access="admin,user,subuser" />
|
||||
<page key="users" file="users.php" access="admin,user,subuser" />
|
||||
<page key="bans" file="bans.php" access="admin,user,subuser" />
|
||||
<page key="create_token" file="create_token.php" access="admin,user,subuser" />
|
||||
<page key="select_server" file="select_server.php" access="admin,user,subuser" />
|
||||
</navigation>
|
||||
|
|
@ -1,350 +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()
|
||||
{
|
||||
include "modules/tshock/shared.php";
|
||||
if($continue)
|
||||
{
|
||||
?>
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a href="?m=tshock&show=broadcast&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">
|
||||
Broadcast
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="?m=tshock&show=motd&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">
|
||||
Message Of The Day
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="?m=tshock&show=off&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">
|
||||
Off
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="?m=tshock&show=rawcmd&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">
|
||||
Rawcmd
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="?m=tshock&show=reload&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">
|
||||
Reload
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="?m=tshock&show=restart&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">
|
||||
Restart
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="?m=tshock&show=rules&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">
|
||||
Rules
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="?m=tshock&show=status&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">
|
||||
Status
|
||||
</a>
|
||||
</li>
|
||||
</ul><?php
|
||||
if($_GET['show'] == 'broadcast') //Broadcast a server wide message.
|
||||
{
|
||||
?>
|
||||
<div id="tab4" class="tab-pane" role="tabpanel">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p class="mbr-text py-5 mbr-fonts-style display-7"></p>
|
||||
<form action="?m=tshock&show=broadcast&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>" method="POST">
|
||||
Message: <input type="text" name="msg" placeholder="The message to broadcast" size="45"><br>
|
||||
<br><input type="submit" name="broadcast" value="Submit">
|
||||
</form><?php
|
||||
if(isset($_POST['broadcast'])){
|
||||
if($token){
|
||||
$params = array('token' => $token,
|
||||
'msg' => $_POST['msg']);
|
||||
$response = getResponse($ip, $port, '/v2/server/broadcast/', $params);
|
||||
if($response['status'] == '200')
|
||||
print_success($response['response']);
|
||||
else
|
||||
print_failure($response['error']);
|
||||
}
|
||||
else
|
||||
print_failure("No Token Found!");
|
||||
}?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if($_GET['show'] == 'motd') //Returns the motd, if it exists.
|
||||
{
|
||||
if($token){
|
||||
$params = array('token' => $token);
|
||||
$response = getResponse($ip, $port, '/v3/server/motd/', $params);
|
||||
if($response['status'] == '200')
|
||||
print_success('Message of the day:<br>'.$response['response']);
|
||||
else
|
||||
print_failure($response['error']);
|
||||
}
|
||||
else
|
||||
print_failure("No Token Found!");
|
||||
}
|
||||
|
||||
if($_GET['show'] == 'off') //Turn the server off.
|
||||
{?>
|
||||
<div id="tab4" class="tab-pane" role="tabpanel">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p class="mbr-text py-5 mbr-fonts-style display-7"></p>
|
||||
<form action="?m=tshock&show=off&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>" method="POST">
|
||||
Message: <input type="text" name="message" placeholder="The shutdown message" size="35"><br><br>
|
||||
Confrim (Required to confirm that you want to turn the server off):<input type="checkbox" name="confirm" value="confirm"><br><br>
|
||||
No save (Shutdown without saving):<input type="checkbox" name="nosave" value="nosave"><br>
|
||||
<br><input type="submit" name="off" value="Submit">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div><?php
|
||||
if(isset($_POST['off'])){
|
||||
if($token){
|
||||
$confirm = isset($_POST['confirm'])?"true":"false";
|
||||
$nosave = isset($_POST['nosave'])?"true":"false";
|
||||
$params = array('token' => $token,
|
||||
'message' => $_POST['message'],
|
||||
'confirm' => $confirm,
|
||||
'nosave' => $nosave);
|
||||
$response = getResponse($ip, $port, '/v2/server/off/', $params);
|
||||
if($response['status'] == '200')
|
||||
print_success($response['response']);
|
||||
else
|
||||
print_failure($response['error']);
|
||||
}
|
||||
else
|
||||
print_failure("No Token Found!");
|
||||
}
|
||||
}
|
||||
|
||||
if($_GET['show'] == 'rawcmd') //Executes a remote command on the server, and returns the output of the command.
|
||||
{
|
||||
?>
|
||||
<div id="tab4" class="tab-pane" role="tabpanel">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p class="mbr-text py-5 mbr-fonts-style display-7"></p>
|
||||
<form action="?m=tshock&show=rawcmd&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>" method="POST">
|
||||
cmd: <input type="text" name="cmd" placeholder="The command and arguments to execute" size="45"><br>
|
||||
<br><input type="submit" name="rawcmd" value="Submit">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
if(isset($_POST['rawcmd'])){
|
||||
if($token){
|
||||
$params = array('token' => $token,
|
||||
'cmd' => $_POST['cmd']);
|
||||
$response = getResponse($ip, $port, '/v3/server/rawcmd/', $params);
|
||||
if($response['status'] == '200')
|
||||
{
|
||||
$response_table = "<pre>";
|
||||
foreach($response['response'] as $line)
|
||||
$response_table .= $line."<br>";
|
||||
$response_table .= "</pre>";
|
||||
echo $response_table;
|
||||
}
|
||||
else
|
||||
print_failure($response['error']);
|
||||
}
|
||||
else
|
||||
print_failure("No Token Found!");
|
||||
}
|
||||
}
|
||||
|
||||
if($_GET['show'] == 'reload') //Reload config files for the server.
|
||||
{?>
|
||||
<div id="tab4" class="tab-pane" role="tabpanel">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p class="mbr-text py-5 mbr-fonts-style display-7"></p>
|
||||
<form action="?m=tshock&show=reload&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>" method="POST">
|
||||
<input type="submit" name="reload" value="Reload configuration, permissions and regions">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div><?php
|
||||
if(isset($_POST['reload'])){
|
||||
if($token){
|
||||
$params = array('token' => $token);
|
||||
$response = getResponse($ip, $port, '/v3/server/reload/', $params);
|
||||
if($response['status'] == '200')
|
||||
{
|
||||
print_success($response['response']);
|
||||
}
|
||||
else
|
||||
print_failure($response['error']);
|
||||
}
|
||||
else
|
||||
print_failure("No Token Found!");
|
||||
}
|
||||
}
|
||||
|
||||
if($_GET['show'] == 'restart') //Attempt to restart the server.
|
||||
{?>
|
||||
<div id="tab4" class="tab-pane" role="tabpanel">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p class="mbr-text py-5 mbr-fonts-style display-7"></p>
|
||||
<form action="?m=tshock&show=restart&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>" method="POST">
|
||||
Message: <input type="text" name="message" placeholder="The shutdown message" size="35"><br><br>
|
||||
Confrim (Required to confirm that you want to restart the server):<input type="checkbox" name="confirm" value="confirm"><br><br>
|
||||
No save (Shutdown without saving):<input type="checkbox" name="nosave" value="nosave"><br>
|
||||
<br><input type="submit" name="restart" value="Submit">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div><?php
|
||||
if(isset($_POST['restart'])){
|
||||
if($token){
|
||||
$confirm = isset($_POST['confirm'])?"true":"false";
|
||||
$nosave = isset($_POST['nosave'])?"true":"false";
|
||||
$params = array('token' => $token,
|
||||
'message' => $_POST['message'],
|
||||
'confirm' => $confirm,
|
||||
'nosave' => $nosave);
|
||||
$response = getResponse($ip, $port, '/v3/server/restart/', $params);
|
||||
if($response['status'] == '200')
|
||||
print_success($response['response']);
|
||||
else
|
||||
print_failure($response['error']);
|
||||
}
|
||||
else
|
||||
print_failure("No Token Found!");
|
||||
}
|
||||
}
|
||||
|
||||
if($_GET['show'] == 'rules') //Returns the rules, if they exist.
|
||||
{
|
||||
?>
|
||||
<div id="tab4" class="tab-pane" role="tabpanel">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p class="mbr-text py-5 mbr-fonts-style display-7"></p>
|
||||
<form action="?m=tshock&show=rules&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>" method="POST">
|
||||
<input type="submit" name="rules" value="Show Rules">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div><?php
|
||||
if(isset($_POST['rules'])){
|
||||
if($token){
|
||||
$params = array('token' => $token);
|
||||
$response = getResponse($ip, $port, '/v3/server/rules/', $params);
|
||||
if($response['status'] == '200')
|
||||
{
|
||||
$rules_div = "<div><ul class='rules'>";
|
||||
foreach($response['rules'] as $line)
|
||||
$rules_div .= "<li>".$line."</li>";
|
||||
$rules_div .= "</ul></div>";
|
||||
echo $rules_div;
|
||||
}
|
||||
else
|
||||
print_failure($response['error']);
|
||||
}
|
||||
else
|
||||
print_failure("No Token Found!");
|
||||
}
|
||||
}
|
||||
|
||||
if($_GET['show'] == 'status') //The status endpoint returns basic information about the server's status.
|
||||
{
|
||||
?>
|
||||
<div id="tab4" class="tab-pane" role="tabpanel">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p class="mbr-text py-5 mbr-fonts-style display-7"></p>
|
||||
<form action="?m=tshock&show=status&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>" method="POST">
|
||||
Show Players:<input type="checkbox" name="players" value="players"><br>
|
||||
Show Rules:<input type="checkbox" name="rules" value="rules"><br>
|
||||
<br><input type="submit" name="status" value="Submit">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
if(isset($_POST['status'])){
|
||||
if($token){
|
||||
$players = isset($_POST['players'])?"true":"false";
|
||||
$rules = isset($_POST['rules'])?"true":"false";
|
||||
$params = array('token' => $token,
|
||||
'players' => $players,
|
||||
'rules' => $rules);
|
||||
$response = getResponse($ip, $port, '/v2/server/status/', $params);
|
||||
if($response['status'] == '200')
|
||||
{
|
||||
$status_table = "<table class='status'>";
|
||||
foreach($response as $key => $value)
|
||||
{
|
||||
if($key == "status")
|
||||
continue;
|
||||
if(is_array($value))
|
||||
{
|
||||
$status_table .= "<tr class='entry_t1'><td class='key'>".$key."</td><td><table class='status'>";
|
||||
foreach($value as $v_key => $v_value)
|
||||
{
|
||||
if(is_array($v_value))
|
||||
{
|
||||
$status_table .= "<tr><td class='key'>".$v_key."</td><td><table class='status'>";
|
||||
foreach($v_value as $v_subkey => $v_subvalue)
|
||||
{
|
||||
$status_table .= "<tr class='entry_t2'><td class='key'>".$v_subkey."</td><td class='value'>".$v_subvalue."</td></tr>";
|
||||
}
|
||||
$status_table .= "</table></td></tr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$status_table .= "<tr class='entry_t3'><td class='key'>".$v_key."</td><td class='value'>".$v_value."</td></tr>";
|
||||
}
|
||||
|
||||
}
|
||||
$status_table .= "</table></td></tr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$status_table .= "<tr class='entry_t4'><td class='key'>".$key."</td><td class='value'>".$value."</td></tr>";
|
||||
}
|
||||
}
|
||||
$status_table .= "</table>";
|
||||
echo $status_table;
|
||||
}
|
||||
else
|
||||
print_failure($response['error']);
|
||||
}
|
||||
else
|
||||
print_failure("No Token Found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
<h2 class="mbr-section-title align-center pb-5 mbr-fonts-style display-2">
|
||||
tshock API Module
|
||||
</h2>
|
||||
<?php
|
||||
global $db, $view;
|
||||
$continue = True;
|
||||
if(isset($_GET['home_id-mod_id-ip-port']))
|
||||
list($home_id, $mod_id, $ip, $port) = explode("-", $_GET['home_id-mod_id-ip-port']);
|
||||
|
||||
$home_cfg_ids = array();
|
||||
foreach($db->getGameCfgs() as $cfg)
|
||||
{
|
||||
if(preg_match('/terraria/i', $cfg['home_cfg_file']))
|
||||
$home_cfg_ids[] = $cfg['home_cfg_id'];
|
||||
}
|
||||
|
||||
if(!empty($home_cfg_ids))
|
||||
{
|
||||
$server_homes = array();
|
||||
$isAdmin = $db->isAdmin($_SESSION['user_id']);
|
||||
foreach($home_cfg_ids as $home_cfg_id)
|
||||
{
|
||||
if($isAdmin)
|
||||
$server_homes = array_merge($server_homes, $db->getHomesFor_limit('admin', $_SESSION['user_id'], 1, 9999, $home_cfg_id,''));
|
||||
else
|
||||
$server_homes = array_merge($server_homes, $db->getHomesFor_limit('user_and_group', $_SESSION['user_id'], 1, 9999, $home_cfg_id,''));
|
||||
}
|
||||
|
||||
if(empty($server_homes))
|
||||
{
|
||||
print_failure(get_lang('no_game_homes_assigned'));
|
||||
$continue = False;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
create_home_selector_address($_GET['m'], 'default', $server_homes);
|
||||
|
||||
if(isset($_GET['home_id-mod_id-ip-port']) && $_GET['home_id-mod_id-ip-port'] != "")
|
||||
list($home_id, $mod_id, $ip, $port) = explode("-", $_GET['home_id-mod_id-ip-port']);
|
||||
else
|
||||
{
|
||||
print_failure("No server selected.");
|
||||
$continue = False;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure("No Terraria XML found");
|
||||
$continue = False;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
include 'modules/tshock/functions.php';
|
||||
|
||||
if($_GET['p'] != 'create_token')
|
||||
{
|
||||
$token = getToken($ip, $port);
|
||||
|
||||
if(!$token)
|
||||
{
|
||||
$view->refresh('home.php?m=tshock&p=create_token&home_id-mod_id-ip-port='.$_GET['home_id-mod_id-ip-port'], 0);
|
||||
$continue = False;
|
||||
return;
|
||||
}
|
||||
|
||||
$token_test = getResponse($ip, $port, '/tokentest/', array('token' => $token));
|
||||
|
||||
if($token_test['status'] != '200')
|
||||
{
|
||||
$view->refresh('home.php?m=tshock&p=create_token&home_id-mod_id-ip-port='.$_GET['home_id-mod_id-ip-port'], 0);
|
||||
$continue = False;
|
||||
return;
|
||||
}
|
||||
|
||||
$game_home = $db->getGameHomeByIP($ip, $port);
|
||||
|
||||
if ($game_home === FALSE)
|
||||
{
|
||||
print_failure( get_lang("no_access_to_home") );
|
||||
$continue = False;
|
||||
return;
|
||||
}
|
||||
|
||||
if($game_home['home_cfg_file'] != 'terraria_win64.xml')
|
||||
{
|
||||
print_failure( "The given address is not for Terraria" );
|
||||
$continue = False;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!istshockAvailable($ip, $port))
|
||||
$continue = False;
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a href="?m=tshock&p=bans&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">Bans</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="?m=tshock&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">Server</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="?m=tshock&p=users&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">Users</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
.status{
|
||||
border: 1px solid black;
|
||||
width:50%;
|
||||
}
|
||||
.key{
|
||||
vertical-align:top;
|
||||
font-weight:bold;
|
||||
}
|
||||
.value{
|
||||
font-style: italic;
|
||||
}
|
||||
.entry_t1{
|
||||
background-color:#ccc;
|
||||
}
|
||||
.entry_t2{
|
||||
background-color:#ddd;
|
||||
}
|
||||
.entry_t3{
|
||||
background-color:#bbb;
|
||||
}
|
||||
.entry_t4{
|
||||
background-color:#eee;
|
||||
color:blue;
|
||||
}
|
||||
|
|
@ -1,237 +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()
|
||||
{
|
||||
include "modules/tshock/shared.php";
|
||||
if($continue)
|
||||
{
|
||||
?>
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item"><a href="?m=tshock&p=users&show=create&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">
|
||||
Create User
|
||||
</a></li>
|
||||
<li class="nav-item"><a href="?m=tshock&p=users&show=destroy&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">
|
||||
Destroy User
|
||||
</a></li>
|
||||
<li class="nav-item"><a href="?m=tshock&p=users&show=activelist&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">
|
||||
Active List
|
||||
</a></li>
|
||||
<li class="nav-item"><a href="?m=tshock&p=users&show=list&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">
|
||||
List
|
||||
</a></li>
|
||||
<li class="nav-item"><a href="?m=tshock&p=users&show=read&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">
|
||||
Read
|
||||
</a></li>
|
||||
<li class="nav-item"><a href="?m=tshock&p=users&show=update&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>">
|
||||
Update
|
||||
</a></li>
|
||||
</ul>
|
||||
<?php
|
||||
if($_GET['show'] == 'create') //Create a new tshock user account.
|
||||
{
|
||||
?>
|
||||
<div id="tab4" class="tab-pane" role="tabpanel">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p class="mbr-text py-5 mbr-fonts-style display-7"></p>
|
||||
<form action="?m=tshock&p=users&show=create&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>" method="POST">
|
||||
Username: <input type="text" name="user" placeholder="The user account name for the new account" size="45"><br><br>
|
||||
Group: <input type="text" name="group" placeholder="The group the new account should be assigned" size="49"><br><br>
|
||||
Password: <input type="text" name="password" placeholder="The password for the new account" size="46"><br><br>
|
||||
<input type="submit" name="create" value="Create Account">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div><?php
|
||||
if(isset($_POST['create'])){
|
||||
if($token){
|
||||
$params = array('token' => $token,
|
||||
'user' => $_POST['user'],
|
||||
'group' => $_POST['group'],
|
||||
'password' => $_POST['password']);
|
||||
$response = getResponse($ip, $port, '/v2/users/create/', $params);
|
||||
if($response['status'] == '200')
|
||||
{
|
||||
print_success($response['response']);
|
||||
}
|
||||
else
|
||||
print_failure($response['error']);
|
||||
}
|
||||
else
|
||||
print_failure("No Token Found!");
|
||||
}
|
||||
}
|
||||
|
||||
if($_GET['show'] == 'destroy') //Destroy a tshock user account
|
||||
{
|
||||
?>
|
||||
<div id="tab4" class="tab-pane" role="tabpanel">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p class="mbr-text py-5 mbr-fonts-style display-7"></p>
|
||||
<form action="?m=tshock&p=users&show=destroy&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>" method="POST">
|
||||
Username/ID: <input type="text" name="user" placeholder="Name or id of account to lookup" size="35"><br><br>
|
||||
Lookup Type: <input type="radio" name="type" value="name" checked> Name
|
||||
<input type="radio" name="type" value="id"> ID<br><br>
|
||||
<input type="submit" name="destroy" value="Remove Account">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div><?php
|
||||
if(isset($_POST['destroy'])){
|
||||
if($token){
|
||||
$params = array('token' => $token,
|
||||
'user' => $_POST['user'],
|
||||
'type' => $_POST['type']);
|
||||
$response = getResponse($ip, $port, '/v2/users/destroy/', $params);
|
||||
if($response['status'] == '200')
|
||||
{
|
||||
print_success($response['response']);
|
||||
}
|
||||
else
|
||||
print_failure($response['error']);
|
||||
}
|
||||
else
|
||||
print_failure("No Token Found!");
|
||||
}
|
||||
}
|
||||
|
||||
if($_GET['show'] == 'activelist') //Returns the list of user accounts that are currently in use on the server.
|
||||
{
|
||||
if($token){
|
||||
$params = array('token' => $token);
|
||||
$response = getResponse($ip, $port, '/v2/users/activelist/', $params);
|
||||
if($response['status'] == '200')
|
||||
{
|
||||
if($response['activeusers'] != "")
|
||||
print_success($response['activeusers']);
|
||||
else
|
||||
print_failure("There are no active users online.");
|
||||
}
|
||||
else
|
||||
print_failure($response['error']);
|
||||
}
|
||||
else
|
||||
print_failure("No Token Found!");
|
||||
}
|
||||
|
||||
if($_GET['show'] == 'list') //Lists all user accounts in the tshock database.
|
||||
{
|
||||
if($token){
|
||||
$params = array('token' => $token);
|
||||
$response = getResponse($ip, $port, '/v2/users/list/', $params);
|
||||
if($response['status'] == '200')
|
||||
{
|
||||
$users_table = "<table class='users_list'><theader><td>ID</td><td>Name</td><td>Group</td></theader>";
|
||||
foreach($response['users'] as $user)
|
||||
$users_table .= "<tr><td class='user_id'>".$user['id']."</td><td class='user_name'>".$user['name']."</td><td class='user_group'>".$user['group']."</td></tr>";
|
||||
$users_table .= "</table>";
|
||||
echo $users_table;
|
||||
}
|
||||
else
|
||||
print_failure($response['error']);
|
||||
}
|
||||
else
|
||||
print_failure("No Token Found!");
|
||||
}
|
||||
|
||||
if($_GET['show'] == 'read') //List detailed information for a user account.
|
||||
{
|
||||
?>
|
||||
<div id="tab4" class="tab-pane" role="tabpanel">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p class="mbr-text py-5 mbr-fonts-style display-7"></p>
|
||||
<form action="?m=tshock&p=users&show=read&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>" method="POST">
|
||||
Username: <input type="text" name="user" placeholder="username or id of account to look up" size="35"><br><br>
|
||||
Lookup Type: <input type="radio" name="type" value="name" checked> Name
|
||||
<input type="radio" name="type" value="id"> ID<br><br>
|
||||
<input type="submit" name="read" value="Submit">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div><?php
|
||||
if(isset($_POST['read'])){
|
||||
if($token){
|
||||
$params = array('token' => $token,
|
||||
'user' => $_POST['user'],
|
||||
'type' => $_POST['type']);
|
||||
$response = getResponse($ip, $port, '/v2/users/read/', $params);
|
||||
if($response['status'] == '200')
|
||||
{
|
||||
print_success("ID: ".$response['id'].", Group: ".$response['group'].", Name: ".$response['name']);
|
||||
}
|
||||
else
|
||||
print_failure($response['error']);
|
||||
}
|
||||
else
|
||||
print_failure("No Token Found!");
|
||||
}
|
||||
}
|
||||
|
||||
if($_GET['show'] == 'update') //Update a users information.
|
||||
{
|
||||
?>
|
||||
<div id="tab4" class="tab-pane" role="tabpanel">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p class="mbr-text py-5 mbr-fonts-style display-7"></p>
|
||||
<form action="?m=tshock&p=users&show=update&home_id-mod_id-ip-port=<?=$_GET['home_id-mod_id-ip-port']?>" method="POST">
|
||||
Username: <input type="text" name="user" placeholder="name or id of account to lookup" size="35"><br><br>
|
||||
Lookup Type: <input type="radio" name="type" value="name" checked> Name
|
||||
<input type="radio" name="type" value="id"> ID<br><br>
|
||||
Password: <input type="text" name="password" placeholder="The users new password" size="35"><br><br>
|
||||
Group: <input type="text" name="group" placeholder="The new group for the user" size="38"><br><br>
|
||||
<input type="submit" name="update" value="Update">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div><?php
|
||||
if(isset($_POST['update'])){
|
||||
if($token){
|
||||
$params = array('token' => $token,
|
||||
'user' => $_POST['user'],
|
||||
'type' => $_POST['type'],
|
||||
'password' => $_POST['password'],
|
||||
'group' => $_POST['group']);
|
||||
$response = getResponse($ip, $port, '/v2/users/update/', $params);
|
||||
if($response['status'] == '200')
|
||||
{
|
||||
foreach($response as $key => $resp)
|
||||
{
|
||||
if($key == "status")
|
||||
continue;
|
||||
print_success($resp);
|
||||
}
|
||||
}
|
||||
else
|
||||
print_failure($response['error']);
|
||||
}
|
||||
else
|
||||
print_failure("No Token Found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue