2018-08-05 11:36:12 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Test Khanat Log</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/";
|
|
|
|
}
|
|
|
|
|
|
|
|
function send(rooturl, id) {
|
|
|
|
//document.getElementById("info").innerHTML = "send " + rooturl + ", " + document.getElementById(id).value;
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
var url = rooturl + "/STDIN";
|
|
|
|
//console.log(url);
|
|
|
|
xhr.open("POST", url, true);
|
|
|
|
xhr.setRequestHeader("content-type", "application/json");
|
|
|
|
xhr.onreadystatechange = function () {
|
2018-10-09 16:03:04 +00:00
|
|
|
console.log(xhr.readyState);
|
|
|
|
console.log(xhr.status);
|
2018-08-05 11:36:12 +00:00
|
|
|
if (xhr.readyState === 4 && xhr.status === 200) {
|
|
|
|
//var json = JSON.parse(xhr.responseText);
|
|
|
|
console.log(xhr.responseText);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var data = JSON.stringify({"name": "<?php echo $_GET['command']; ?>", "action": document.getElementById(id).value});
|
|
|
|
//console.log(data);
|
|
|
|
xhr.send(data);
|
|
|
|
}
|
|
|
|
</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 - LOG)</div>
|
|
|
|
<div id='important_info'><?php echo $_GET['command']; ?></div>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
function get_port($filecfg)
|
|
|
|
{
|
2018-10-09 16:03:04 +00:00
|
|
|
// $ini_array = parse_ini_file($filecfg);
|
2018-08-05 11:36:12 +00:00
|
|
|
// return "${ini_array['port']}";
|
|
|
|
|
|
|
|
$fp = fopen($filecfg, "r");
|
|
|
|
if ($fp) {
|
|
|
|
while (($line = fgets($fp)) !== false) {
|
2019-10-24 17:02:40 +00:00
|
|
|
$datawithoutcomment = explode('#', $line);
|
|
|
|
$data = explode('=', $datawithoutcomment[0]);
|
|
|
|
if ( count($data) >= 2 ) {
|
|
|
|
list($key, $value) = explode('=', $datawithoutcomment[0], 2);
|
|
|
|
} else if ( count($data) == 1 ) {
|
|
|
|
$key = $data[0];
|
|
|
|
$value = "";
|
|
|
|
} else {
|
|
|
|
$key = "";
|
|
|
|
$value = "";
|
|
|
|
}
|
2018-08-05 11:36:12 +00:00
|
|
|
$key = trim($key);
|
|
|
|
if ( $key == "port" ) {
|
|
|
|
return trim($value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose($fp);
|
2018-10-09 16:03:04 +00:00
|
|
|
}
|
2018-08-05 11:36:12 +00:00
|
|
|
return "8000";
|
|
|
|
}
|
|
|
|
|
2019-10-24 17:02:40 +00:00
|
|
|
function is_valid_type($type)
|
|
|
|
{
|
|
|
|
if ( $type == 'INF' ) { // Information
|
|
|
|
return true;
|
|
|
|
} else if ( $type == 'DBG') { // Information
|
|
|
|
return true;
|
|
|
|
} else if ( $type == 'WRN') { // Warning
|
|
|
|
return true;
|
|
|
|
} else if ( $type == 'ERR') { // Error
|
|
|
|
return true;
|
|
|
|
} else if ( $type == 'STT') { // Statistic
|
|
|
|
return true;
|
|
|
|
} else if ( $type == 'AST') { // Assert
|
|
|
|
return true;
|
|
|
|
} else if ( $type == 'UKN') { // Unknown
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-08-05 11:36:12 +00:00
|
|
|
$cfgfile = "/home/gameserver/khanat/khaganat.cfg";
|
|
|
|
|
|
|
|
if (file_exists($cfgfile)) {
|
|
|
|
$info = get_port($cfgfile);
|
|
|
|
$rooturl = "http://" . getHostByName(gethostname()) . ":" . $info ;
|
|
|
|
$url = $rooturl . "/STDOUT";
|
|
|
|
|
|
|
|
// Initiate curl
|
|
|
|
$ch = curl_init();
|
|
|
|
curl_setopt($ch, CURLOPT_URL,$url);
|
2018-10-09 16:03:04 +00:00
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
2018-08-05 11:36:12 +00:00
|
|
|
$data = "{\"name\": \"${_GET['command']}\", \"first-line\": 0}";
|
|
|
|
|
2018-10-09 16:03:04 +00:00
|
|
|
$headers = array(
|
|
|
|
"GET /STDOUT HTTP/1.0",
|
|
|
|
'Content-type: application/json',
|
2018-08-05 11:36:12 +00:00
|
|
|
'Content-Length: ' . strlen($data)
|
2018-10-09 16:03:04 +00:00
|
|
|
);
|
2018-08-05 11:36:12 +00:00
|
|
|
|
2018-10-09 16:03:04 +00:00
|
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
|
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
|
2018-08-05 11:36:12 +00:00
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
|
|
// Execute
|
|
|
|
$result=curl_exec($ch);
|
|
|
|
// Closing
|
|
|
|
curl_close($ch);
|
|
|
|
// var_dump($result);
|
|
|
|
$data = json_decode($result,true);
|
|
|
|
// var_dump($data);
|
|
|
|
///Count
|
|
|
|
$total=count($data);
|
|
|
|
echo "<div>First line:${data['first-line']} Last line:${data['last-line']}<br/>";
|
|
|
|
echo "<table>";
|
|
|
|
echo "<tr><th>Pos</th><th>Date</th><th>Time</th><th>Zone</th><th>Type</th><th>Address</th><th>Program Line</th><th>Message</th></tr>";
|
|
|
|
ksort($data);
|
|
|
|
foreach ($data as $key => $value)
|
|
|
|
{
|
|
|
|
if ( $key == "first-line" or $key == "last-line" )
|
|
|
|
continue;
|
|
|
|
|
2019-10-24 17:02:40 +00:00
|
|
|
list($date, $hour, $timezone, $typesrc, $addr, $program, $line, $msg, $type) = array('', '', '', '', '', '', '', '', '?');
|
|
|
|
|
2018-09-19 08:13:44 +00:00
|
|
|
// 2018/08/03 10:45:36 CEST INF 442b0740 command.cpp 149
|
2019-10-24 17:02:40 +00:00
|
|
|
$arrayret = explode(' ', $value);
|
|
|
|
if ( count($arrayret) >= 8 ) {
|
|
|
|
list($date, $hour, $timezone, $typesrc, $addr, $program, $line, $msg) = explode(' ', $value, 8);
|
|
|
|
if ( ! is_numeric($line) ) {
|
|
|
|
if ( is_valid_type($line) ) {
|
|
|
|
list($date, $hour, $timezone, $data1, $hour1, $kind, $typesrc, $addr, $program, $line, $msg) = explode(' ', $value, 11);
|
|
|
|
$msg = "[$data1 $hour1 $kind] $msg";
|
|
|
|
} else {
|
|
|
|
list($date, $hour, $timezone, $msg) = explode(' ', $value, 4);
|
|
|
|
$msg = "$msg";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$msg = "$msg";
|
|
|
|
}
|
|
|
|
} else if ( count($arrayret) >= 4 ) {
|
|
|
|
$arrayret = explode(' ', $value, 4);
|
|
|
|
list($date, $hour, $timezone, $msg) = explode(' ', $value, 4);
|
|
|
|
} else {
|
|
|
|
$msg = $value;
|
|
|
|
}
|
2018-09-19 08:13:44 +00:00
|
|
|
|
2018-08-05 11:36:12 +00:00
|
|
|
$type = substr( $typesrc, strlen($typesrc) - 3 );
|
2018-09-19 08:13:44 +00:00
|
|
|
if ( $type == 'INF' ) { // Information
|
2018-08-05 11:36:12 +00:00
|
|
|
$fond = "bgcolor=\"SpringGreen \"";
|
2018-09-19 08:13:44 +00:00
|
|
|
} else if ( $type == 'DBG') { // Information
|
2018-08-05 11:36:12 +00:00
|
|
|
$fond = "bgcolor=\"AQUAMARINE\"";
|
2018-09-19 08:13:44 +00:00
|
|
|
} else if ( $type == 'WRN') { // Warning
|
2018-08-05 11:36:12 +00:00
|
|
|
$fond = "bgcolor=\"Yellow\"";
|
2018-09-19 08:13:44 +00:00
|
|
|
} else if ( $type == 'ERR') { // Error
|
2018-08-05 11:36:12 +00:00
|
|
|
$fond = "bgcolor=\"Tomato\"";
|
2018-09-19 08:13:44 +00:00
|
|
|
} else if ( $type == 'STT') { // Statistic
|
2018-08-05 11:36:12 +00:00
|
|
|
$fond = "bgcolor=\"Yellow\"";
|
2018-09-19 08:13:44 +00:00
|
|
|
} else if ( $type == 'AST') { // Assert
|
2018-08-06 21:13:57 +00:00
|
|
|
$fond = "bgcolor=\"Tomato\"";
|
2018-09-19 08:13:44 +00:00
|
|
|
} else if ( $type == 'UKN') { // Unknown
|
2018-08-05 11:36:12 +00:00
|
|
|
$fond = "bgcolor=\"Tomato\"";
|
|
|
|
} else {
|
2019-10-24 17:02:40 +00:00
|
|
|
//$msg = "$typesrc $addr $program $line $msg";
|
2018-08-05 11:36:12 +00:00
|
|
|
$type = "?";
|
2019-10-24 17:02:40 +00:00
|
|
|
//$addr = "";
|
|
|
|
//$program = "";
|
|
|
|
//$line = "";
|
2018-08-05 11:36:12 +00:00
|
|
|
$fond = "bgcolor=\"Tomato\"";
|
|
|
|
}
|
|
|
|
if ( $program != "" && $line != "" )
|
|
|
|
{
|
|
|
|
if ( substr( $program, strlen($program) - 4 ) != ".cpp" and substr( $program, strlen($program) - 2 ) != ".h" )
|
|
|
|
{
|
|
|
|
$msg = "$program $line $msg";
|
|
|
|
$program = "";
|
|
|
|
$line = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "<tr><td>$key</td><td>$date</td><td>$hour</td><td>$timezone</td><td $fond>$type</td><td>$addr</td><td>$program $line</td><td $fond>$msg</td></tr>";
|
2018-10-09 16:03:04 +00:00
|
|
|
|
2018-08-05 11:36:12 +00:00
|
|
|
}
|
|
|
|
echo "</table></div>";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
echo "<a>OpenNelManager not enabled</a>";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<div>
|
|
|
|
Command line :
|
|
|
|
<div id='command_shell'>
|
|
|
|
curl -XGET --header "content-type: application/json" -d '<?php print "{\"name\": \"${_GET['command']}\", \"first-line\": 0}";?>' <?php print $url;?>
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-10-09 16:03:04 +00:00
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<br>
|
|
|
|
Send to STDIN: <input type="text" id="command" value="help" size="100"/>
|
|
|
|
<input type="submit" value="Submit" onclick="send('<?php echo $rooturl; ?>', 'command');"/>
|
|
|
|
<br>
|
|
|
|
<div>
|
|
|
|
Command line :
|
|
|
|
<div id='command_shell'>
|
|
|
|
curl -XPOST --header "content-type: application/json" -d '<?php print "{\"name\": \"${_GET['command']}\", \"action\": \"help\"}";?>' <?php print $rooturl . "/STDIN";?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</p>
|
2018-08-05 11:36:12 +00:00
|
|
|
<p id="info"></p>
|
|
|
|
</body>
|
|
|
|
</html>
|