Location: PHPKode > projects > World of Warcraft Signature Script > includes/update.php
<?php
if(!defined("INZWOWSIG")) die("blubb");
header("Content-Type: text/html; charset=ISO-8859-15");

$r = new HTTPRequest($xml_stat_location);
$filecontents =  $r->DownloadToString();

$file = 'tmp/stat.xml'; 


$stream=fopen($file,'w');
fwrite($stream,$filecontents);

$xml = new SofeeXmlParser(); 
$xml->parseFile($file); 
$tree = $xml->getTree(); 
unset($xml); 

$uptime=mysql_real_escape_string($tree['stats']['server']['uptime']['value']);
echo "Uptime: $uptime\n";
$load=mysql_real_escape_string($tree['stats']['serverload']['world']['load']['value']);
echo "Systemload: $load\n";
mysql_query("UPDATE wowsig_config SET wowsig_config.value='$uptime' WHERE wowsig_config.key='uptime'");
mysql_query("UPDATE wowsig_config SET wowsig_config.value='$load' WHERE wowsig_config.key='load'");
mysql_query("UPDATE wowsig_config SET wowsig_config.value='".time()."' WHERE wowsig_config.key='lastupdate'");
$players=$tree['stats']['players']['player'];

$i=0;
foreach($players as $k=>$v)
{
  $i++;
  $name=$v['name']['value'];
  $name=mysql_real_escape_string($name);
  $name=utf8_decode($name);
  $race=mysql_real_escape_string($v['race']['value']);
  $class=mysql_real_escape_string($v['class']['value']);
  $level=mysql_real_escape_string($v['level']['value']);
  $map=mysql_real_escape_string($v['map']['value']);
  $zone=mysql_real_escape_string($v['zone']['value']);
  $ping=mysql_real_escape_string($v['ping']['value']);
  $plevel=mysql_real_escape_string($v['plevel']['value']);
  $ip=mysql_real_escape_string($v['ip']['value']);
  $timestamp=time();
  $schonda=mysql_result(mysql_query("SELECT count(name) FROM wowsig_players WHERE name='$name'"),0);

  if ($schonda)
  {
     $query="UPDATE wowsig_players SET
level='$level',
race='$race',
class='$class',
map='$map',
zone='$zone',
ping='$ping',
plevel='$plevel',
timestamp='$timestamp',
ip='$ip'
 WHERE name='$name'";
     echo "update spieler $name\n";
  }
  else
  {
     $query="INSERT INTO wowsig_players (name, level, race, class, map, zone, ping, plevel, timestamp, ip) VALUES ('$name','$level','$race','$class','$map','$zone','$ping','$plevel','$timestamp', '$ip')";
     echo "füge spieler $name hinzu\n";
  }
   if (!mysql_query($query)) echo "Fehler bei benutzer $name\nquery: $query\n";
}
mysql_query("UPDATE wowsig_config SET wowsig_config.value='$i' WHERE wowsig_config.key='playersonline'");
?>
Return current item: World of Warcraft Signature Script