about to rewrite the whole thing hehe - great suggestion Eldarion
script url: http://www.lfsworld.net/pubstat/get_stat2.php?version=1.1&action=...
-----------
?action=pst
-----------
(online statistics of one racer)
requires: &racer=<racer>
optional: -
returns: distance in metres
fuel burnt in dl
laps
hosts joined
wins
second
third
finished
quals
pole
online credits
drags
drag wins
**NEW** online or not (0 = no, 1 = yes)
**NEW** hostname (or blank line if not online or on hidden host)
<?php
function isLFSWorldError($string)
{
switch(trim(substr($string, 0, 50)))
{
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
case 'no output':
?>
<?php
// Function to display Team Members online in a dynamic table
function display_expandable_table($TeamMembers, $LfsUsers, $InGameName){
// Set the variable to count the members online
$MembersOnline = 0;
// Count the number of members
$TotalMembers = count($TeamMembers);
// Create Header row for the table
echo "<tr bgcolor='#CCCCCC' align='center'><th>Team Racer</th><th>On Server</th></tr>";
// search through the file for Team Members and add a row to the
// table showing the name and server they are on
foreach ($LfsUsers as $LfsUser => $LfsHost) {
for($i = 0; $i < $TotalMembers; $i++){
if(strtolower($LfsUser) == $TeamMembers[$i]){
$LfsUser = remove_colour_codes($LfsUser);
$LfsLink = remove_colour_codes($LfsHost);
$LfsHost = format_host_colours($LfsHost);
echo "<tr bgcolor='#FFFFFF'>";
echo "<td>$InGameName[$i]</td>";
echo"<td><a href='lfs://|$LfsLink|0|S2|/'>$LfsHost</a></td></tr>";
$MembersOnline =+ 1;
}
}
}
// Display this row only if no members are online
if($MembersOnline == 0){
echo "<tr bgcolor='#FFFFFF' align='center'><td>No Members</td><td>Are Online</td></tr>";
}
}
// Function to display all Team Member Status in a fixed table
function display_fixed_table($TeamMembers, $LfsUsers, $InGameName){
/// Count the number of members
$TotalMembers = count($TeamMembers);
// Create Header row for the table
echo "<tr bgcolor='#CCCCCC' align='center'><th>Team Racer</th><th>Status</th><th>On Server</th></tr>";
for($i = 0; $i < $TotalMembers; $i++){
echo "<tr bgcolor='#FFFFFF'>";
foreach ($LfsUsers as $LfsUser => $LfsHost) {
if(strtolower($LfsUser) == $TeamMembers[$i]){
$LfsLink = remove_colour_codes($LfsHost);
$LfsHost = format_host_colours($LfsHost);
echo "<td>$InGameName[$i]</td>";
echo "<td>Online</td>";
echo"<td><a href='lfs://|$LfsLink|0|S2|/'>$LfsHost</a></td></tr>";
$Found = "True";
break;
}
else{
$Found = "False";
}
}
if($Found == "False"){
echo "<td>$InGameName[$i]</td>";
echo "<td>Offline</td>";
echo"<td> </td></tr>";
}
}
}
?>
<?php
// init some vars
$LfsUsers = array ();
$x = 0;
$LfsHostList = "";
// get the hostlist
$LfsHostList = file_get_contents ("http://lfsworld.net/pubstat/get_stat2.php?action=hosts");
$len = strlen ($LfsHostList);
if ($len < 52) exit ("<a href='javascript:document.location.reload();'>Couldn't get hostlist. Click to retry...</a>");
// parse the data
while ($x < $len) {
$LfsHostName = "";
$nr_racers = 0;
for ($y=0; $y<32; $y++) $LfsHostName .= $LfsHostList[$x++];
$LfsHostName = trim_c_string ($LfsHostName);
$x += 1; // skip some host-data
$HostType = ord ($LfsHostList[$x++]);
$x += 20; // skip some host-data
$nr_racers = ord ($LfsHostList[$x++]);
for ($w=0; $w<$nr_racers; $w++) {
$LfsUserName = "";
for ($y=0; $y<24; $y++) $LfsUserName .= $LfsHostList[$x++];
$LfsUsers[trim_c_string ($LfsUserName)] = $LfsHostName;
}
}
?>