Could you please include split times in the wr action. &splits=true
<?php
// parse the data
while ($x < $len) {
$hostname = "";
$nr_racers = 0;
for ($y=0; $y<32; $y++) $hostname .= $hostlist[$x++];
$hostname = trim_c_string ($hostname);
$x += 20; // skip some host-data
$nr_racers = ord ($hostlist[$x++]);
for ($w=0; $w<$nr_racers; $w++) {
$username = "";
for ($y=0; $y<24; $y++) $username .= $hostlist[$x++];
$users[trim_c_string ($username)] = $hostname;
}
}
?>
<?php
function getHost($hostname)
{
$rawList = array();
$file = file_get_contents("http://www.lfsworld.net/pubstat/get_stat2.php?version=1.2&user=" . LFS_USER . "&pass=" . md5(LFS_PASS) . "&action=hosts&c=2&ps=" . LFSW_PREMIUM_PUBSTAT);
if (isLFSWorldError($file)) return 0;
$rawList = @gzuncompress($file);
while(true)
{
//grab the next chunk of host data
$blob = substr($rawList, $offset, 53);
//If it's less than 53 then it can't be valid
if(strlen($blob) == 53)
{
//(Re-)Init tmp arrays to parse into
$data = $racers = array();
//Min len is 53. Parse and advance the offset to the end of this chunk
$data = unpack('a32hostName/c1serverType/c1majorVersion/c1minorVersion/c1testVersion/c1track/c1config/c1reversed/c1maxPlayers/L1cars/L1rules/c1laps/c1qualifyMins/x2/c1players', $blob);
$offset+= 53;
//Extract the entire player chunk, split it in to smaller chunks of 24, and explode
$racers = explode('&', chunk_split(substr($rawList, $offset, $data['players']*24), 24, '&'));
//This method always adds an empty entry so just pop it off
array_pop($racers);
//Trim the guff and advance the offset to the next chunk
$racers = array_map('rtrim', $racers);
$offset += $data['players']*24;
/*
//Laps parsing.
$data['hours'] = 0;
//Check if laps are literal
if($data['laps'] > 100)
{
if($data['laps'] < 191)
{
//Laps are in 10 step increment range (101-191)
$data['laps'] = (($data['laps'] - 100) * 10) + 100;
}
else
{
//Laps are hours
$data['hours'] = $data['laps'] - 190;
$data['laps'] = 0;
}
}
*/
//Formatting
//Compound the 3 integers that make up the track in to 1 var and dump the excess
$data['track'] = $data['track'].$data['config'].$data['reversed'];
unset($data['config'], $data['reversed']);
//Put the racers in the output
$data['playerNames'] = implode('&',$racers);
//Version formatting
$data['majorVersion'] /= 10;
$data['minorVersion'] = chr($data['minorVersion']);
if($data['hostName']==$hostname) return $data;
}
else
{
break;
}
}
return 0;
}
?>
<?php
php
function isLFSWorldError($string)
{
switch(trim(substr($string, 0, 50)))
{
case 'Identification is required - http://www.lfsforum.net/showthread.php?t=14480':
case 'hl: no hotlaps found':
case 'hl: no racer':
case 'ch: invalid track':
case 'ch: invalid car':
case 'pst: no valid username':
case 'pb: racer has no pbs':
case 'no output':
case 'can\'t reload this page that quickly after another':
case '':
return true;
}
return false;
}
?>
<?php
php
function isLFSWorldError($string)
{
switch(trim(substr($string, 0, 149)))
{
case 'Identification is required - http://www.lfsforum.net/showthread.php?t=14480':
case 'hl: no hotlaps found':
case 'hl: no racer':
case 'ch: invalid track':
case 'ch: invalid car':
case 'pst: no valid username':
case 'pb: racer has no pbs':
case 'no output':
case 'can\'t reload this page that quickly after another':
case 'Invalid Ident-Key':
case 'not authed (invalid identkey)':
case 'not authed (ip)':
case 'Invalid login details provided'
case 'No authentication method provided.':
case 'You shouldn\'t flood me! You\'re locked out for 15 minutes now. DO NOT make your program do its requests as fast as it can, until the tarpit is over...':
case 'hl_log is only available since version 1.2 and later':
case '':
return true;
}
return false;
}
?>