All pastes #804679 Raw Edit

Status Checker class

public php v1 · immutable
·published 2007-12-03 17:58 UTC
rendered paste body
<?php/*Author : 0x586e <dev@0x586e.info>Should : Create a beautiful status checker using xml files.If it doesn't : Then no luck O.oIf you liked it : eMail me a cookieCredits : - Neanne from Ruff-Rose for doing the design that I was fucking lazy to do.- Some people that challenged me on Ruff-Rose irc to recode the whole status checker.*/class MyOwnCounter{private $XmlFile = 'ServCheck.xml';function CheckServerStatus($ServerID){    $xml = simplexml_load_file($this->XmlFile);    $Data = array($xml->Server[ $ServerID ]->ip,$xml->Server[ $ServerID ]->port,$xml->Server[ $ServerID ]->last);    $Date = date('z:H:i');    if (strpos($Data[2],$Date) === false) {        $fp = @fsockopen($Data[0], (int) $Data[1], $errno, $errstr, 1);        if (!$fp)        {            $xml->Server[ $ServerID ]->pic = 'offline.png';            $xml->Server[ $ServerID ]->status = 0;            $xml->Server[ $ServerID ]->last = $Date;        } else {            $xml->Server[ $ServerID ]->pic = 'online.png';            $xml->Server[ $ServerID ]->status = 1;            $xml->Server[ $ServerID ]->last = $Date;        }        $NewXml = $xml->asXML();        file_put_contents($this->XmlFile,$NewXml);        @fclose($fp);    }            }function GetStatus($ServerID){    $this->CheckServerStatus($ServerID);    $xml = simplexml_load_file($this->XmlFile);    return '<img src="'.$xml->Server[ $ServerID ]->pic.'" alt="" />';}function Counting(){    $xml = simplexml_load_file($this->XmlFile);    $xml->Counter = $xml->Counter++;    for ($i = 1;$i <= strlen($xml->Counter); $i++)    {        echo '<img src="nums/'.substr($xml->Counter,$i,1).'.png" alt="" />';    }    $NewXML = $xml->asXML();    file_put_contents($this->XmlFile,$NewXML);}}?>