Jump to content
  • 0

[help] status checker


Question

Posted
<?php

 

$server = "localhost";

$port = "2106";

 

function pingDomain($server){

    $starttime = microtime(true);//Server 1 Port

    $file      = fsockopen ($domain, 2106, $errno, $errstr, 10);

    $stoptime  = microtime(true);

    $status    = 0;

 

    if (!$file) $status = -1;

    else {

        fclose($file);

        $status = ($stoptime - $starttime) * 1000;

        $status = floor($status);

    }

    return $status;

}     

 

        $status = pingDomain($serverbase);

        if ($status <= 50) $MessageStatus = "Great";

        elseif ($status <= 80) $MessageStatus = "Good";

        elseif ($status <= 100) $MessageStatus = "Ok";

        elseif ($status <= 150) $MessageStatus = "Bad";

        elseif ($status <= 999) $MessageStatus = "Poor";

        else $MessageStatus = "Disconnected";

 

 

$upmessage = "<font size='1' color='white'><br>Stability: </font><font color='gray'

 

size='1'>$MessageStatus</font><br>";

$downmessage = "<font size='1' color='white'><br>Stability: </font><font color='gray'

 

size='1'>Disconnected</font><br>";

$tout = "5";

$server1 = @fsockopen ($server, $port, $errno, $errstr, $tout);

if(!$server1){ echo"<br><font color='C8B560' size='2' style='Arial'><strong>Login</strong></font><br><font

 

size='1' color='white'>Status:</font><font color='red' size='1' style='Arial'> Off</font>$downmessage"; }

else { echo"<br><font color='C8B560' size='2' style='Arial'><strong>Login</strong></font><br><font size='1'

 

color='white'>Status:</font><font color='green' size='1' style='Arial'> On</font>$upmessage"; }

 

$server2 = "localhost";

$port2 = "7777";

 

function pingDomain2($server2){

    $starttime2 = microtime(true);//Server 2 Port

    $file2      = fsockopen ($domain2, 7777, $errno, $errstr, 10);

    $stoptime2  = microtime(true);

    $status2    = 0;

 

    if (!$file2) $status2 = -1;

    else {

        fclose($file2);

        $status2 = ($stoptime2 - $starttime2) * 1000;

        $status2 = floor($status2);

    }

}     

 

        $status2 = pingDomain2($serverbase2);

        if ($status2 <= 50) $MessageStatus2 = "Great";

        elseif ($status2 <= 80) $MessageStatus2 = "Good";

        elseif ($status2 <= 100) $MessageStatus2 = "Ok";

        elseif ($status2 <= 150) $MessageStatus2 = "Bad";

        elseif ($status2 <= 999) $MessageStatus2 = "Poor";

        else $MessageStatus2 = "Disconnected";

 

 

$upmessage2 = "<font size='1' color='white'><br>Stability: </font><font color='gray'

 

size='1'>$MessageStatus2</font><br>";

$downmessage2 = "<font size='1' color='white'><br>Stability: </font><font color='gray'

 

size='1'>Disconnected</font><br>";

$tout = "5";

$server2 = @fsockopen ($server2, $port2, $errno, $errstr, $tout);

if(!$server2){ echo"<br><font color='C8B560' size='2'

 

style='Arial'><strong>Gameserver</strong></font><br><font size='1' color='white'>Status:</font><font

 

color='red' size='1' style='Arial'> Off</font>$downmessage2"; }

else { echo"<br><font color='C8B560' size='2' style='Arial'><strong>Gameserver</strong></font><br><font

 

size='1' color='white'>Status:</font><font color='green' size='1' style='Arial'> On</font>$upmessage2"; }

?>

 

Λοιπόν αυτό το status checker μου φένεται πως είναι το καλύτερο... Αλλά δεν καταλαβένω γιατί αργεί...

Αν μπορεί καποιος που είναι πιο έμπειρος να μου το editarei ωστε να δείχνει μόνο το status  του login/game server και όχι το stability. Διαφορετικά πείτε μου τι να κάνω ώστε να φορτώνει πρώτα την ιστοσελίδα μου και αφού τελείωσει να φορτώνει τον status checker. Btw ο κώδικας της ιστοσελίδας μου είναι ο παρακάτω.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Shadow Warez!</title>

<link href="style.css" rel="stylesheet" type="text/css" />

<style type="text/css">

<!--

 

-->

</style>

 

<script type="text/javascript">

<!--

 

var alternate=0

var standardbrowser=!document.all&&!document.getElementById

 

if (standardbrowser)

document.write('<form name="tick"><input type="text" name="tock" size="11"></form>')

 

function show(){

if (!standardbrowser)

var clockobj=document.getElementById? document.getElementById("digitalclock") : document.all.digitalclock

var Digital=new Date()

var hours=Digital.getHours()

var minutes=Digital.getMinutes()

var dn="ΠM"

 

if (hours==12) dn=""

if (hours>12){

dn="ΜΜ"

hours=hours-12

}

if (hours==0) hours=12

if (hours.toString().length==1)

hours="0"+hours

if (minutes<=9)

minutes="0"+minutes

 

if (standardbrowser){

if (alternate==0)

document.tick.tock.value=hours+" : "+minutes+" "+dn

else

document.tick.tock.value=hours+"   "+minutes+" "+dn

}

else{

if (alternate==0)

clockobj.innerHTML=hours+" : "+minutes+" "+"<sup style='font-size:1px'>"+dn+"</sup>"

else

clockobj.innerHTML=hours+" : "+minutes+" "+"<sup style='font-size:1px'>"+dn+"</sup>"

}

alternate=(alternate==0)? 1 : 0

setTimeout("show()",1000)

}

window.onload=show

 

//-->

</script>

<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>

</head>

<body>

<div class="header">

    <img src="icons/header.jpg" width="700" height="188" style="float:left;" />

   <u>Latest News</u> <br />

     <li style="color:#990000;" /><span style="color: #FFFFFF; text-align: center; font-size: 12px;">Welcome to our site!

     </span> <br />

     <span style="font-size:10px;color:#990000; text-align:left;margin-left: 10px; font-style:normal;">Hope you have an enjoyable time in our site

</span>

     <li style="color:#990000;" /><span style="color: #FFFFFF; text-align: center; font-size: 12px;">Site is under Construct </span>

<br /><span style="font-size:10px;color:#990000; text-align:left;margin-left: 10px; font-style:normal;">Last Update at: Monday, January 12, 2009 9:43 PM</span></div>

<div class="time">

<script type="text/javascript">

var mydate=new Date()

var year=mydate.getYear()

if (year < 1000)

year+=1900

var day=mydate.getDay()

var month=mydate.getMonth()

var daym=mydate.getDate()

if (daym<10)

daym="0"+daym

var dayarray=new Array("Κυριακή","Δευτέρα","Τρίτη","Τετάρτη","Πέμτπη","Παρασκευή","Σάββατο")

var montharray=new Array("1","2","3","4","5","6","7","8","9","10","11","12")

document.write(""+dayarray[day]+", "+daym+"/"+montharray[month]+"/"+year+"")

</script> /

<span id="digitalclock"></span>

</div>

<div class="navbarl">

<table border="0" cellpadding="0" cellspacing="0" width="200">

<tr><td height="40" style="background:url('icons/15.gif');color:#333333;" align="center"><b>Site menu</b></td></tr>

<tr><td><A href="http://ntellos.freehostia.com/" target="_blank"><STRONG><span style="margin-left: 20px;color:#FFFFFF;">Forum</span></STRONG></A></LI></span></td></tr>

<tr><td><A href="mailto:ntellos13@hotmail.com"><STRONG><span style="padding-left: 20px;color:#FFFFFF;">Επικοινωνήστε μαζί μας!</span></STRONG></A></LI></span></td></tr>

<tr><td><A href=""><STRONG><span style="padding-left: 20px;color:#FFFFFF;"></span></STRONG></A></LI></span></td></tr>

<tr><td><A href=""><STRONG><span style="padding-left: 20px;color: #FFFFFF;"></span></STRONG></A></LI></td></tr>

</table>

<br />

<table border="0" cellpadding="0" cellspacing="0" width="200">

<tr><td height="40" style="background:url('icons/15.gif');color:#333333;" align="center"><b>Site Status</b></td></tr>

<tr><td><?php

 

$server = "localhost";

$port = "2106";

 

function pingDomain($server){

    $starttime = microtime(true);//Server 1 Port

    $file      = fsockopen ($domain, 2106, $errno, $errstr, 10);

    $stoptime  = microtime(true);

    $status    = 0;

 

    if (!$file) $status = -1;

    else {

        fclose($file);

        $status = ($stoptime - $starttime) * 1000;

        $status = floor($status);

    }

    return $status;

}     

 

        $status = pingDomain($serverbase);

        if ($status <= 50) $MessageStatus = "Great";

        elseif ($status <= 80) $MessageStatus = "Good";

        elseif ($status <= 100) $MessageStatus = "Ok";

        elseif ($status <= 150) $MessageStatus = "Bad";

        elseif ($status <= 999) $MessageStatus = "Poor";

        else $MessageStatus = "Disconnected";

 

 

$upmessage = "<font size='1' color='white'><br>Stability: </font><font color='gray'

 

size='1'>$MessageStatus</font><br>";

$downmessage = "<font size='1' color='white'><br>Stability: </font><font color='gray'

 

size='1'>Disconnected</font><br>";

$tout = "5";

$server1 = @fsockopen ($server, $port, $errno, $errstr, $tout);

if(!$server1){ echo"<br><font color='C8B560' size='2' style='Arial'><strong>Login</strong></font><br><font

 

size='1' color='white'>Status:</font><font color='red' size='1' style='Arial'> Off</font>$downmessage"; }

else { echo"<br><font color='C8B560' size='2' style='Arial'><strong>Login</strong></font><br><font size='1'

 

color='white'>Status:</font><font color='green' size='1' style='Arial'> On</font>$upmessage"; }

 

$server2 = "localhost";

$port2 = "7777";

 

function pingDomain2($server2){

    $starttime2 = microtime(true);//Server 2 Port

    $file2      = fsockopen ($domain2, 7777, $errno, $errstr, 10);

    $stoptime2  = microtime(true);

    $status2    = 0;

 

    if (!$file2) $status2 = -1;

    else {

        fclose($file2);

        $status2 = ($stoptime2 - $starttime2) * 1000;

        $status2 = floor($status2);

    }

}     

 

        $status2 = pingDomain2($serverbase2);

        if ($status2 <= 50) $MessageStatus2 = "Great";

        elseif ($status2 <= 80) $MessageStatus2 = "Good";

        elseif ($status2 <= 100) $MessageStatus2 = "Ok";

        elseif ($status2 <= 150) $MessageStatus2 = "Bad";

        elseif ($status2 <= 999) $MessageStatus2 = "Poor";

        else $MessageStatus2 = "Disconnected";

 

 

$upmessage2 = "<font size='1' color='white'><br>Stability: </font><font color='gray'

 

size='1'>$MessageStatus2</font><br>";

$downmessage2 = "<font size='1' color='white'><br>Stability: </font><font color='gray'

 

size='1'>Disconnected</font><br>";

$tout = "5";

$server2 = @fsockopen ($server2, $port2, $errno, $errstr, $tout);

if(!$server2){ echo"<br><font color='C8B560' size='2'

 

style='Arial'><strong>Gameserver</strong></font><br><font size='1' color='white'>Status:</font><font

 

color='red' size='1' style='Arial'> Off</font>$downmessage2"; }

else { echo"<br><font color='C8B560' size='2' style='Arial'><strong>Gameserver</strong></font><br><font

 

size='1' color='white'>Status:</font><font color='green' size='1' style='Arial'> On</font>$upmessage2"; }

?></td>

</tr>

</table><br />

</div>

 

<div class="navbarr">

<table border="0" cellpadding="0" cellspacing="0" width="200">

<tr><td height="40" style="background:url('icons/15.gif');color:#333333;" align="center"><b>Login</b></td></tr>

<tr><td><center><span style="color:#990000;">Closed!</span>

<br />

<span style="color:#FFFF66; font-size:9px;">Although you can login normally in our forum</span>

</center>

</td></tr>

<tr><td height="40" style="background:url('icons/15.gif');color:#333333;" align="center"><b>Friendly Sites</b></td></tr>

<tr><td><tr><td><A href="http://turboradio.ucoz.com/" target="_blank"><STRONG><span style="margin-left: 75px;color:#FFFFFF;">turbo radio</span></STRONG></A></LI></span></td>

</tr>

</table>

</div>

 

<div class="centerbox">

<table border="0" cellpadding="0" cellspacing="0" width="500">

<tr><td height="40" style="background:url(''); color:#333333;" align="center">Server Updates!</b></td></tr>

<tr><td>

<center><u>Quick Links</u>

<br /><a href="http://www.google.gr">Google.gr</a>

<br /><a href="http://www.youtube.com">Youtube.com</a>

<br />

<br />

<br /><a href="info.php">My PHP info</a>

<br /><a href="/forum/">SMF Test Forum</a>

<br /><a href="/forum2/">VB Test Forum</a>

<br /><a href="/forum2/admincp/index.php">VB admin panel</a>

<br /><a href="/pma/">PhpMyAdmin</a>

<br />

<br /></center><span style="color:#990000;">=ADMIN=Ntellos</span>

<br />

</tr></td>

 

</table>

</div>

 

 

 

 

 

<div class=sig>

<table border="0" cellpadding="0" height="45" cellspacing="0" style="background:url('icons/16.gif') #C9C9C9;">

<tr><td align="left"><img src="icons/17.gif" border="0"></td><td align="center" style="color:#333333;">2008 Shadow-warez all rights reserved |</td><td align="center" style="color:#333333;"> Powered by <span style="color:#990000">=Admin=Ntellos</span> |

<a href="http://validator.w3.org/check?uri=http%3A%2F%2Fntellos13.freehostia.com%2F&charset=(detect+automatically)&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.606">

<img  style="border:0;width:48px;height:11px"

        src="http://www.w3.org/Icons/valid-xhtml10-blue"

        alt="Valid XHTML 1.0 Transitional" />

</a>

<a href="http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fntellos13.freehostia.com%2F&profile=css21&usermedium=all&warning=1&lang=en">

    <img  style="border:0;width:48px;height:11px"

        src="http://jigsaw.w3.org/css-validator/images/vcss-blue"

        alt="Valid CSS!" />

</a>

</td><td align="right"><img src="icons/18.gif" border="0"></td></tr>

</table>

</div>

</body>

</html>

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...