2011-10-02, 23:56:03
oh and could you please check my code? It gives no errors, but it dosent works.... im too tired to debug it
Code:
<?php
$ip=$_SERVER['REMOTE_ADDR'];
$key=$_GET["securitykey"];
$status=$_GET["status"];
if ($key=="md5ior6xsomk485asegilsa"){
writeDetails();//change the key here and in your ServerIP config file!
}else{
echo "Fail";
}
function writeDetails()
{
if(isset($_GET["status"])&&isset($_GET["players"])&&isset($_GET["maxplayers"])&&isset($_GET["writeonlineplayers"])){
$ip=$_SERVER['REMOTE_ADDR'];
$status=$_GET["status"];
$players=$_GET["players"];
$maxplayers=$_GET["maxplayers"];
$function=$_GET["writeonlineplayers"];
$File = "status.xml";
$xml = @new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><item></item>');
if ($status=="Offline") $ip="-";
$xml->addChild('ip', $ip);
$xml->addChild('players', $players);
$xml->addChild('maxplayers', $maxplayers);
$xml->addChild('function', $function);
XMLsave($xml, $file);
}else{
echo "Missing data!";
}
}
class SimpleXMLExtended extends SimpleXMLElement{
public function addCData($cdata_text){
$node= dom_import_simplexml($this);
$no = $node->ownerDocument;
$node->appendChild($no->createCDATASection($cdata_text));
}
}
function XMLsave($xml, $file) {
$xml->asXML($file);
if (defined('GSCHMOD')) {
chmod($file, GSCHMOD);
} else {
chmod($file, 0755);
}
}
function getXML($file) {
$xml = @file_get_contents($file);
$data = simplexml_load_string($xml, 'SimpleXMLExtended', LIBXML_NOCDATA);
return $data;
}
?>