All pastes #800400 Raw Edit

Etwas

public text v1 · immutable
#800400 ·published 2007-11-28 12:38 UTC
rendered paste body
<?php
function fetch_url($url)
{
    $ch = curl_init(); // initialize a cURL session 
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
    $str = curl_exec ($ch);
    curl_close ($ch);

    return (!is_string($str) || !strlen($str)) ? null : $str;
}

// fetch xml feed
$str = fetch_url("http://laanx.fragnetics.com/_xml_reports/server_report.xml");
$xml = new SimpleXMLElement($str);
// print it
//print "<pre>" . str_replace("<", "&lt;", $str) . "</pre>"
$isOnline = $xml->LAANX_ONLINE[0];
$onlineCount = $xml->ONLINE_COUNT[0];

if($isOnline != "YES") {
	echo "Laanx is offline.";
	}
else {
	echo "Laanx is online. -- ";
	echo $onlineCount;
	echo " characters are online.";
}

?>