240 lines
7 KiB
PHP
240 lines
7 KiB
PHP
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>Test Khanat States</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 type="text/javascript">
|
||
function setHref() {
|
||
document.getElementById('admin-href').href = window.location.protocol + "//" + window.location.hostname + ":40916/ams/";
|
||
}
|
||
function start(rooturl, cmd) {
|
||
//document.getElementById("info").innerHTML = "Start " + rooturl + " " + cmd;
|
||
var xhr = new XMLHttpRequest();
|
||
var url = rooturl + "/START";
|
||
//console.log(url);
|
||
xhr.open("POST", url, true);
|
||
xhr.setRequestHeader("content-type", "application/json");
|
||
xhr.onreadystatechange = function () {
|
||
console.log(xhr.readyState);
|
||
console.log(xhr.status);
|
||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||
//var json = JSON.parse(xhr.responseText);
|
||
console.log(xhr.responseText);
|
||
}
|
||
};
|
||
var data = JSON.stringify({"name": cmd});
|
||
//console.log(data);
|
||
xhr.send(data);
|
||
}
|
||
function stop(rooturl, cmd) {
|
||
//document.getElementById("info").innerHTML = "Stop " + rooturl + " " + cmd;
|
||
var xhr = new XMLHttpRequest();
|
||
var url = rooturl + "/STOP";
|
||
//console.log(url);
|
||
xhr.open("POST", url, true);
|
||
xhr.setRequestHeader("content-type", "application/json");
|
||
xhr.onreadystatechange = function () {
|
||
console.log(xhr.readyState);
|
||
console.log(xhr.status);
|
||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||
//var json = JSON.parse(xhr.responseText);
|
||
console.log(xhr.responseText);
|
||
}
|
||
};
|
||
var data = JSON.stringify({"name": cmd});
|
||
//console.log(data);
|
||
xhr.send(data);
|
||
}
|
||
var timeout = setTimeout("updateRefresh();",1000);
|
||
var enable = true;
|
||
var timer = 10;
|
||
function updateRefresh() {
|
||
//clearTimeout(timeout);
|
||
//timeout = setTimeout("updateRefresh();",10000);
|
||
//document.getElementById("refreshMsg").value = "Refresh";
|
||
timer = timer - 1;
|
||
if ( timer > 0 ) {
|
||
clearTimeout(timeout);
|
||
document.getElementById("refreshMsg").lastChild.textContent = timer + "s" ;
|
||
timeout = setTimeout("updateRefresh();",1000);
|
||
} else {
|
||
timer = 10;
|
||
location.reload(true);
|
||
}
|
||
}
|
||
function toggleRefresh()
|
||
{
|
||
if ( enable ) {
|
||
enable = false;
|
||
document.getElementById("refreshMsg").lastChild.textContent = "Off";
|
||
clearTimeout(timeout);
|
||
} else {
|
||
enable = true;
|
||
timer = 10;
|
||
document.getElementById("refreshMsg").lastChild.textContent = "10s";
|
||
clearTimeout(timeout);
|
||
timeout = setTimeout("updateRefresh();",1000);
|
||
}
|
||
}
|
||
</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>
|
||
<a>OpenNelManager</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 - STATES)</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";
|
||
}
|
||
|
||
if (file_exists('/home/gameserver/opennelmanager.flag')) {
|
||
$cfgfile = "/home/gameserver/khanat/khaganat.cfg";
|
||
|
||
if (file_exists($cfgfile)) {
|
||
$info = get_port($cfgfile);
|
||
$rooturl = "http://" . getHostByName(gethostname()) . ":" . $info ;
|
||
$url = $rooturl . "/STATUSALL";
|
||
|
||
// Initiate curl
|
||
$ch = curl_init();
|
||
curl_setopt($ch, CURLOPT_URL,$url);
|
||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||
// Execute
|
||
$result=curl_exec($ch);
|
||
// Closing
|
||
curl_close($ch);
|
||
$data = json_decode($result,true);
|
||
///Count
|
||
$total=count($data);
|
||
echo '<div>Number command:'.$total.'<br/>';
|
||
echo "<table>";
|
||
echo "<tr><th>Command</th><th>Start</th><th>Stop</th><th>State</th><th>Num. launch</th><th>Last line log</th><th>Detail</th></tr>";
|
||
ksort($data);
|
||
foreach ($data as $key => $value)
|
||
{
|
||
list($val1, $val2) = explode(':', $value, 2);
|
||
$state=$value['state'];
|
||
$number_launch=$value['number_launch'];
|
||
$number_launch=$value['number_launch'];
|
||
$last_line=$value['last_line'];
|
||
$filter=$value['filter'];
|
||
$egs=$value['egs'];
|
||
$extra="";
|
||
if ( $state == 'started' ) {
|
||
$fond = "bgcolor=\"SpringGreen \"";
|
||
} else {
|
||
$fond = "bgcolor=\"Tomato\"";
|
||
}
|
||
if ( $filter == 'True' ) {
|
||
$extra="$extra <a href=\"/opennelmanager_filter.php?command=$key\">filter</a>";
|
||
}
|
||
if ( $egs == 'True' ) {
|
||
$extra="$extra <a href=\"/opennelmanager_player.php?command=$key\">player</a>";
|
||
$extra="$extra <a href=\"/opennelmanager_admin.php?command=$key\">admin</a>";
|
||
}
|
||
list($type, $command) = explode(':', $key, 2);
|
||
echo "<tr><td>$command</td><td><button onclick=\"start('$rooturl', '$key')\">Start</button></td>";
|
||
echo "<td><button onclick=\"stop('$rooturl', '$key')\">Stop</button></td><td $fond>$state</td><";
|
||
echo "td align=\"right\">$number_launch</td><td align=\"right\">$last_line</td>";
|
||
echo "<td><a href=\"/opennelmanager_log.php?command=$key\">log</a> <a href=\"/opennelmanager_config.php?command=$key\">config</a> <a href=\"/opennelmanager_info.php?command=$key\">info</a> $extra</td></tr>";
|
||
}
|
||
echo "</table></div>";
|
||
} else {
|
||
echo "<a>OpenNelManager not used</a>";
|
||
}
|
||
} else {
|
||
echo "<a>OpenNelManager not actiavted</a>";
|
||
}
|
||
|
||
?>
|
||
</p>
|
||
<div>
|
||
Command line :
|
||
<div id='command_shell'>
|
||
curl -XGET <?php print $url;?>
|
||
</div>
|
||
</div>
|
||
<p id="info"></p>
|
||
<p>Refresh : <button id="refreshMsg" size="10" onclick="toggleRefresh();"/>10s</button></p>
|
||
</body>
|
||
</html>
|