The online racing simulator
about to rewrite the whole thing hehe - great suggestion Eldarion
wow, talking about versions - I see there are still massive amounts of requests using the get_stat.php from the S1 era

hummmm some folks need to update their scripts you'd think
ok there you go:

script url: http://www.lfsworld.net/pubstat/get_stat2.php?version=1.1&action=...

and

-----------
?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)

See the first post of this thread for all the details
Thank you Victor ! It will be great helpufll ! Thank's again !!!! xD
Great idea Elda ;-) lol
yeah!
thanks a lot Victor

NFR power
Hi!
Just wanted to show my first little php script and it works. This is so fun (php I mean)
Attached images
Hotlap_script.JPG
Hey folks!

What are the possible error messages the '?action=hl', '?action=pb' and '?action=pst' may return?
I need to know because I'm working on a script that needs to know if I have to retry or not.

The ones I got:
'can't reload this page that quickly after another'
'hl: no hotlaps found'
'pb: racer has no pbs'
'pb: no valid username'
'pst: no valid username'

Guess there also are some messages indicating problems with the lfsworld server/database or something.

Victor? Anyone?
These are the only ones I've ever encountered, but that isn't to say there aren't more should something catastrophic happen like gerbils in the stat server or something.

Pulled straight from ppf.


<?php 
function isLFSWorldError($string)
{
    switch(
trim(substr($string050)))
    {
        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;
}
?>

These were obtained by just throwing random crap at the stat server to see how it would respond.
-
(th84) DELETED by th84
Thanks for your reply!


<?php 
case 'no output':
?>

Do you remember how and why you got this one?
?action=hosts

As I found out, the Demo-Hosts are not send by lfsworld. Am i right here?

How do I get the Demo Hosts?

Thanx.
Yo Victor! Quick question, as I'm sure I read somewhere about LFSW being altered with regards to the new codepages in LFS; but I cant see it anywhere in the readme's, or this forum. Was it my imagination?
:doh: Right under my nose! Yes, thats the bugger Cheers Victor :s
Big Edit:

If you are using D34N0's code above, but want to turn the hostnames into working links for Join2LFS, then use the following code to replace the same sections in D34N0's code.


<?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>&nbsp</td></tr>";
     }
}
}
?>

The lfs join link has the following anatomy;

lfs://|$hostname|$private|$type|/

Where $hostname is an urlencoded hostname with colour codes intact.
$private is 0 if the host is public, or 1 if the host is private.
$type is either S1, S2 or Demo.

As such, that code will only join a public S2 server, but other than that your code looks ok.
to be completely precise - the urlencoding of the LFS:// url only has to be done for browsers other than IE. IE in turn needs only the '+' sign converted DOUBLE (to my knowledge there are no other characters that need conversion, but maybe there are - i haven't met any yet).

So:

IE:
$hostname = preg_replace ("'\+'", "%252B", $hostname);

ANY OTHER BROWSER:
$hostname = urlencode ($hostname);
Damn you all (in a nice way).

Well, now I'm not going to be satisfied until it works properly for all servers people might join.

So, based on D34N0's code above, and my alterations, what should I use to find out if a host is:
S1/S2 (Demo doesn't use usernames, so not a problem in this case)?
Public or Private?

Then it should just be a case of assigning variables to those values, and sticking them in the link.

For what Victor said about IE being the perennial pain the arse it always is, can I use the preg_replace for all other browsers, or do I need to somehow add a check for which browser type is being used? Sorry for being a total b00n, but I am trying to learn

Edit: I noticed I'd editted my above post before you replied. Just tried my current implementation (above now, which doesn't use any urlencoding) and it works fine in IE and Firefox, so not touching that anymore.

Edit2: So I need to parse for the first byte of TMLT. Right okay. Reads more of Victors first post and starts the trial and error process... I've never done anything like this before, so bear with me...

Would this work? Then I have $HostType which will be either 0,1 or 2. And is the $x += 20; still right, or should that now be 19, as I've already moved one byte along?

<?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;
    }
}
?>

hey!

It would be great if the action=hl also could return the position on chart.

Now I have to do a action=ch for each combo action=hl returnes to find the chart position. Obviously a lot of bandwith/scrip calls wasted.

Any chance this could be implemented?
I was wondering if there is a LFSWorld SDK, or something like that, like a list of functions for parsing the information that the script's spew out. If there is not one, why not make one. I would be happy to donate some code to the LFSWorld SDK. It would be like the best toolkit for geting information to your website from LFSWorld. We would need to have a pretty good cache system, if this thing should be come main stream. Like, I'd said, I would be more then happy to head up the project, its just that my programing know how is not so good, but I can get around the most programing languages pretty well. I think that our angry angle would be the best one the head up the project. It would have to be open souce software, and it would most likey be GPL'ed. So, what do you say? Want to give this a shot? Oh, and it would have to be in PHP.
Anarchi recently rewrote his PHP classes to deal with LFSW: http://dsrc.digiserv.net/forum/forumdisplay.php?f=69
As for why more people dont use it, I really dont know. They;re good, and need pimping more.

With regards to an application version, I've been perpetually working on a C based version which will run on linux and windows. I've rewritten the code about 3 times now - but I'm fairly confident that I'll get it done this time (extra christmas holidays rock for this kind of stuff). I've got tomorrow off, and I'm planning on reintegrating libcURL support, and fixing the SQLite stuff so it perpetually updates properly. Other than that, I've just got to write some docs and stuff.

So in short, there are libraries out there, but no one seems to use them on websites. Plus the overridding issue is that not everyone uses PHP, C (running as CGI). There are nutters out there using perl, java, and .NET, and writing one more bloodly framework for each is a nutty idea. Plus most of the time, people dont need the entire overhead for LFSW PPF, for example.
Quote from nikka :hey!

It would be great if the action=hl also could return the position on chart.

Now I have to do a action=ch for each combo action=hl returnes to find the chart position. Obviously a lot of bandwith/scrip calls wasted.

Any chance this could be implemented?

i'll keep this in mind for a future update.
Quote from the_angry_angel :Anarchi recently rewrote his PHP classes to deal with LFSW: http://dsrc.digiserv.net/forum/forumdisplay.php?f=69
As for why more people dont use it, I really dont know. They;re good, and need pimping more.

Thanks

It's probably the same reason people are still coding their own database abstraction libs instead of using pear::db or adodb; they are lazy.

It may take more time to code than if they were to use the lib, but it takes less effort, unless the interface to the lib is extremely minimal, otherwise the coder is forced to read docs, which no one really likes doing.

LFSW-PPF is about due for an update, during which I may minimalize the required interface further, but still maintaing backwards compatibility and the modular structure.

Your closing comment about PPF actually made me realize how little I documented the structure of the classes. If you really wanted to, you could use your own cache & request mechanism and only include the actual 'provider' (which is just the parsing loop, and all of which take a string as input, and a reference to an array as output, returning true on success or false on failure).
Of course you'd have to do lfsworld error checking and decompression yourself.

Hmmm, I think I'll go minimalize and document now
I must admit Anarchi, that most people dont use existing solutions, if the documentation isnt there. Believe it or not, between things I'm still working on libLFSW, and I've hit a lot of issues - I want to keep it as portable as possible, but not so that it makes my life difficult. I've gone from writing my own little cache system, to eventually using SQLite (which could eventually be patched to using MySQL or PostgreSQL) - but the main issue I've found whilst looking into all existing packages to make my life easier, is that without some sound documentation behind it, you're pretty much on your own.

A perfect example is if you want to do anything GTK based with Python, you're shafted at the moment as theres literally no documentation, and you have to find a developer to drive nuts for a few hours before you can get anywhere. Now I'm not saying your docs are bad, but if you're not the one who wrote it sometimes things arent obvious i.e. I was pretty sure you could override things in LFSW-PPF (as with most PHP apps), but not to the extent and ease that you seem to be promoting. It all sounds very cool .

Shame documentation is the boring bit. LFSW-PPF definately needs pimping more though
Tooby the noob :)
Hi!
Is there a way to recive data from lfsworld or direct from a host?
Exampel:
If I race on our team server is it possible to get the data from those races?

<track><laps>
<racer><car><time>

/Tooby

FGED GREDG RDFGDR GSFDG