nyanko
New Member
- Messages
- 57
- Reaction score
- 0
- Points
- 0
Well I need some script that loads this code below every x seconds or minutes automatically, I know it can be done with Ajax but cant find the way to do it, any Ajax oracle out there please help D:
I wrote this code by Myself and it works but, to do the check again, if the server is receiving connections into the ports desired, I need to Hit reload.
This is my php file:
Edit:
bump D: I buried my own post with some of my responses xD
I wrote this code by Myself and it works but, to do the check again, if the server is receiving connections into the ports desired, I need to Hit reload.
This is my php file:
PHP:
<style type="text/css">
#ServerStatus {
opacity: 0.75;
background-color: #4B92B4;
position: absolute;
left: 10%;
top: 20px;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
border: solid 1px #fff;
color:#fff;
padding:5px;
}
</style>
<div id='ServerStatus'>
<?php
//config start
$ip = 'HERE GOES THE IP';
$logport = 'port1';
$charport = 'port2';
$mapport = 'port3';
$offline = '<b><FONT COLOR=red>Offline</b> <img src="./images/RedDownArrow.gif" ALT="Offline"></FONT></b>';
$online = '<b><FONT COLOR=lime>Online</b> <img src="./images/GreenUpArrow.gif" ALT="Online"></FONT></b>';
//config end -- cheching opening listening ports
$login = @fsockopen($ip, $logport, $num, $error, 5);
if(!$login) {
$login_status = $offline;
$logy=0;
} else {
$login_status = $online;
$logy=1;
fclose($login);
}
$char = @fsockopen($ip, $charport, $num, $error, 5);
if(!$char) {
$char_status = $offline;
$chary=0;
} else {
$char_status = $online;
$chary=1;
fclose($char);
}
$map = @fsockopen($ip, $mapport, $num, $error, 5);
if(!$map) {
$map_status = $offline;
$mapy=0;
} else {
$map_status = $online;
$mapy=1;
fclose($map);
}
if ($logy==1&&$chary==1&&$mapy==1){
//Checking Users Online
mysql_connect($ip,'worldmap','') or die();
@mysql_select_db('epitaph');
$query = "SELECT COUNT(*) as total FROM `char` WHERE online = '1'";
$result = mysql_query($query);
mysql_close();
$arr = mysql_fetch_array($result);
$usersonline = "<b><FONT COLOR=lime> $arr[total] </FONT></b>";
} else
$usersonline = '<b><FONT COLOR=red>Offline</b> <img src="./images/RedDownArrow.gif" ALT="Offline"></FONT></b>';
//Printing Results
echo "<b>";
echo "<tbody><table><tr><td>Server Status</tr></td>";
echo "<tr><td>Login Server:</td><td>$login_status</td></tr>";
echo "<tr><td>Char Server:</td><td>$char_status</td></tr>";
echo "<tr><td>Map Server:</td><td>$map_status</td></tr>";
echo "<tr><td>Players Online:</td><td>$usersonline</td></tr></table></tbody>";
echo "</b>";
?>
</div>
bump D: I buried my own post with some of my responses xD
Last edited: