2018-10-09 16:03:04 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Test Khanat Config</title>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
#command_shell{
|
|
|
|
background: #F3E2A9;
|
|
|
|
border:3px solid #151515;
|
|
|
|
color: #000000;
|
|
|
|
margin:10px;
|
|
|
|
padding:3px;
|
|
|
|
top:40px;left:3%;right:3%;
|
|
|
|
text-align:left;
|
|
|
|
max-width:100vw;
|
|
|
|
}
|
|
|
|
#title_info{
|
|
|
|
background: #00FFFF;
|
|
|
|
border:3px solid #8A0808;
|
|
|
|
color: #000000;
|
|
|
|
font-size:20px;
|
|
|
|
font-weight:500;
|
|
|
|
margin:50px;
|
|
|
|
padding:3px;
|
|
|
|
top:40px;left:3%;right:3%;
|
|
|
|
text-align:center;
|
|
|
|
}
|
|
|
|
#important_info{
|
|
|
|
background: #A9E2F3;
|
|
|
|
border:3px solid #088A08;
|
|
|
|
color: #000000;
|
|
|
|
font-size:15px;
|
|
|
|
font-weight:500;
|
|
|
|
margin:30px;
|
|
|
|
padding:3px;
|
|
|
|
top:40px;left:3%;right:3%;
|
|
|
|
text-align:left;
|
|
|
|
}
|
|
|
|
table, th, td {
|
|
|
|
border: 1px solid black;
|
|
|
|
border-collapse: collapse;
|
|
|
|
}
|
|
|
|
#alert_javascript{
|
|
|
|
background: #F3F781;
|
|
|
|
border:3px solid #610B0B;
|
|
|
|
color: #DF0101;
|
|
|
|
font-size:20px;
|
|
|
|
font-weight:700;
|
|
|
|
margin:0;
|
|
|
|
padding:3px;
|
|
|
|
top:40px;left:3%;right:3%;
|
|
|
|
text-align:center;
|
|
|
|
max-width:100vw;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
function setHref() {
|
|
|
|
document.getElementById('admin-href').href = window.location.protocol + "//" + window.location.hostname + ":40916/ams/";
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<noscript>
|
|
|
|
<div id='alert_javascript'>
|
|
|
|
This website need Javascript.<br>
|
|
|
|
Could you please enable Javascript?
|
|
|
|
</div>
|
|
|
|
</noscript>
|
|
|
|
|
|
|
|
<body onload="setHref()">
|
|
|
|
<p>
|
|
|
|
<a href="/" id="home" >Home</a>
|
|
|
|
<?php
|
|
|
|
if (file_exists('/home/gameserver/opennelmanager.flag')) {
|
|
|
|
echo "<a href=\"/opennelmanager.php\">OpenNelManager</a>";
|
|
|
|
} else {
|
|
|
|
echo "<a>opennelmanager not used</a>";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<a href="/EnableJavascript" id="admin-href" >Administration</a>
|
|
|
|
<a href="/phpmyadmin/">phpmyadmin</a>
|
|
|
|
<a href="/patch/">patch</a>
|
|
|
|
</p>
|
|
|
|
<div id='title_info'>KHANAT SERVER DOCKER (TEST ENVIRONMENT - ADMIN COMMAND)</div>
|
|
|
|
<div id='important_info'><?php echo $_GET['command']; ?></div>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
function get_port($filecfg)
|
|
|
|
{
|
|
|
|
// $ini_array = parse_ini_file($filecfg);
|
|
|
|
// return "${ini_array['port']}";
|
|
|
|
|
|
|
|
$fp = fopen($filecfg, "r");
|
|
|
|
if ($fp) {
|
|
|
|
while (($line = fgets($fp)) !== false) {
|
|
|
|
list($data, $comment) = explode('#', $line, 2);
|
|
|
|
list($key, $value) = explode('=', $line, 2);
|
|
|
|
$key = trim($key);
|
|
|
|
if ( $key == "port" ) {
|
|
|
|
return trim($value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose($fp);
|
|
|
|
}
|
|
|
|
return "8000";
|
|
|
|
}
|
|
|
|
|
|
|
|
$cfgfile = "/home/gameserver/khanat/khaganat.cfg";
|
|
|
|
|
|
|
|
if (file_exists($cfgfile)) {
|
|
|
|
$info = get_port($cfgfile);
|
|
|
|
$rooturl = "http://" . getHostByName(gethostname()) . ":" . $info ;
|
|
|
|
$url = $rooturl . "/ADMINCOMMAND";
|
|
|
|
|
|
|
|
// Initiate curl
|
|
|
|
$ch = curl_init();
|
|
|
|
curl_setopt($ch, CURLOPT_URL,$url);
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
$data = "{\"name\": \"${_GET['command']}\"}";
|
|
|
|
|
|
|
|
$headers = array(
|
|
|
|
"GET /CONFIG HTTP/1.0",
|
|
|
|
'Content-type: application/json',
|
|
|
|
'Content-Length: ' . strlen($data)
|
|
|
|
);
|
|
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
|
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
|
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
|
|
// Execute
|
|
|
|
$result=curl_exec($ch);
|
|
|
|
// Closing
|
|
|
|
curl_close($ch);
|
|
|
|
$data = json_decode($result,true);
|
|
|
|
ksort($data);
|
2018-10-10 22:48:24 +00:00
|
|
|
if ( $data )
|
2018-10-09 16:03:04 +00:00
|
|
|
{
|
2018-10-10 22:48:24 +00:00
|
|
|
echo "<table>";
|
|
|
|
echo "<tr><th>Line</th>";
|
|
|
|
foreach ($data as $key => $value)
|
2018-10-09 16:03:04 +00:00
|
|
|
{
|
2018-10-10 22:48:24 +00:00
|
|
|
ksort($value);
|
|
|
|
foreach ($value as $key2 => $value2)
|
|
|
|
{
|
|
|
|
echo "<th>$key2</th>";
|
|
|
|
}
|
|
|
|
break;
|
2018-10-09 16:03:04 +00:00
|
|
|
}
|
2018-10-10 22:48:24 +00:00
|
|
|
echo "</tr>";
|
|
|
|
foreach ($data as $key => $value)
|
2018-10-09 16:03:04 +00:00
|
|
|
{
|
2018-10-10 22:48:24 +00:00
|
|
|
echo "<tr><td>$key</td>";
|
|
|
|
ksort($value);
|
|
|
|
foreach ($value as $key2 => $value2)
|
|
|
|
{
|
|
|
|
echo "<td align=\"right\">$value2</td>";
|
|
|
|
}
|
2018-10-09 16:03:04 +00:00
|
|
|
}
|
2018-10-10 22:48:24 +00:00
|
|
|
echo "</table></div>";
|
|
|
|
} else {
|
|
|
|
echo "<b>No admin command executed</b>";
|
2018-10-09 16:03:04 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
echo "<a>OpenNelManager not enabled</a>";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</p>
|
|
|
|
<div>
|
|
|
|
Command line :
|
|
|
|
<div id='command_shell'>
|
|
|
|
curl -XGET --header "content-type: application/json" -d '<?php print "{\"name\": \"${_GET['command']}\"}";?>' <?php print $url;?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<p id="info"></p>
|
|
|
|
</body>
|
|
|
|
</html>
|