The online racing simulator
PHP4/5 - LFSWorldSDK, class for stats retrieval
(288 posts, started )
You need to create an instance of the SDK with your pubstat key since it's not done in the sample code.
How do I do that?
Put your pubstat key in the SDK where it says

<?php 
$SDK 
= new LFSWorldSDK('Em2EB5oKYk0d33FeKD0cf13Hw18terK7'FALSE);
?>

At least I think so. Set the false flag to true if you're using premium pubstat (not tarpitted).

You can generate the key on LFSWorld, under 'My LFSW settings' > 'Pubstat access'
Hmm I changed it to my own key en changed dygear to my own username didn't work
I did put everything in one .php file cause I need one file for my profile it looks like this now:


<?php 
php

# $SDK = new LFSWorldSDK('Em2EB5oKYk0d33FeKD0cf13Hw18terK7', FALSE);
$SDK = new LFSWorldSDK('92qe7FM72U6uTtGOn4xC0cF3Jh3pjSYw'TRUE);

/*
** Live For Speed World SDK, easily find what you need from the World of Live For Speed.
**
** @package   LFSWorldSDK
** @since     2009-03-14 19:45
** @author    Mark 'Dygear' Tomlin
** @coauthor  Mikael 'filur' Forsberg.
** @coauthor  Victor van Vlaardingen.
** @coauthor  Jeff 'glyphon' DeLamater.
** @coauthor  AndroidXP.
** @coauthor  Dr. Timo 'HorsePower' Bergmann.
** @license   MIT License (http://opensource.org/licenses/mit-license.php)
** @copyright Copyright (C) 2006 - 2009,
**            Mark 'Dygear' Tomlin, Mikael 'filur' Forsberg,
**            Victor van Vlaardingen, Jeff 'glyphon' DeLamater,
**            AndroidXP and Dr. Timo 'HorsePower' Bergmann.
** @version   1.9.1
*/

class LFSWorldSDK {
    
// Constructor
    
function LFSWorldSDK($idk$ps FALSE) {
        
$this->ps $ps;
        
$this->idk $idk;
        
$this->time time();
        
$this->fpass TRUE;
        
$this->compression = (function_exists('gzinflate')) ? 0;
    }
    
// Core Functions.
    
function make_query($qryStr) {
        if (
$this->ps === FALSE && $this->fpass === TRUE && (time() - $this->time) < 5) {
            
sleep(- (time() - $this->time));
            
$this->time time();
            
$this->fpass false;
        }
        
$data file_get_contents("http://www.lfsworld.net/pubstat/get_stat2.php?version=1.4&idk={$this->idk}&ps={$this->ps}&c={$this->compression}&s=2{$qryStr}");
        if (
$this->compression)
            
$data gzinflate($data);
        if (
$this->is_lfsw_error($data))
            return 
$this->make_query($qryStr);
        
$return = @unserialize($data);
        if (
$return === FALSE)
            return 
$data;
        else
            return 
$return;
    }
    function 
is_lfsw_error($data) {
        if (
$data == 'can\'t reload this page that quickly after another')
            return 
TRUE;
        else
            return 
FALSE;
    }
    
// Helper Fuctions.
    
function convert_lfsw_time($time) {
        return 
sprintf('%d:%2.2f'floor($time 60000), (($time 60000) / 1000));
    }
    function 
convert_flags_hlaps($flags_hlaps$toString FALSE) {
        if (
$toString == FALSE) {
            
$data = array();
            
$data[1] = ($flags_hlaps 1)  ? 'LEFTHANDDRIVE' 'RIGHTHANDDRIVE';
            if (
$flags_hlaps 2)        $data[2] = 'GEARCHANGECUT';
            if (
$flags_hlaps 4)        $data[4] = 'GEARCHANGEBLIP';
            if (
$flags_hlaps 8)        $data[8] = 'AUTOGEAR';
            if (
$flags_hlaps 16)        $data[16] = 'SHIFTER'
            if (
$flags_hlaps 64)        $data[64] = 'BRAKEHELP';
            if (
$flags_hlaps 128)        $data[128] = 'THROTTLEHELP';
            if (
$flags_hlaps 512)        $data[512] = 'AUTOCLUTCH'
            if (
$flags_hlaps 1024)    $data[1024] = 'MOUSESTEER';
            if (
$flags_hlaps 2048)    $data[2048] = 'KN';
            if (
$flags_hlaps 4096)    $data[4096] = 'KS';
            if (!(
$flags_hlaps 7168))    $data[7168] = 'WHEEL';
        } else {
            
$data '';
            
$data .= ($flags_hlaps 1)  ? 'L ' 'R ';
            if (
$flags_hlaps 2)        $data .= 'cc&nbsp';
            if (
$flags_hlaps 4)        $data .= 'cb ';
            if (
$flags_hlaps 8)        $data .= 'A ';
            if (
$flags_hlaps 16)        $data .= 'S '
            if (
$flags_hlaps 64)        $data .= 'bh ';
            if (
$flags_hlaps 128)        $data .= 'cl ';
            if (
$flags_hlaps 512)        $data .= 'ac '
            if (
$flags_hlaps 1024)    $data .= 'M ';
            if (
$flags_hlaps 2048)    $data .= 'Kn ';
            if (
$flags_hlaps 4096)    $data .= 'Ks ';
            if (!(
$flags_hlaps 7168))    $data .= 'W ';
        }
        return 
$data;
    }
    function 
convert_team_bits($bits) {
        
$data = array();
        if (
$bits 1)        $data[1]        = 'race';
        if (
$bits 2)        $data[2]        = 'drift';
        if (
$bits 4)        $data[4]        = 'drag';
        if (
$bits 8)        $data[8]        = 'can apply';
        if (
$bits 16)        $data[16]        = 'has host';
        if (
$bits 32)        $data[32]        = 'Demo';
        if (
$bits 64)        $data[64]        = 'S1';
        if (
$bits 128)    $data[128]        = 'S2';
        if (
$bits 256)    $data[256]        = 'S3';
        return 
$data;
    }
    function 
convert_car_bits($bits) {
        
$data = array();
        if (
$bits 1)        $data[1]        = 'XFG';
        if (
$bits 2)        $data[2]        = 'XRG';
        if (
$bits 4)        $data[4]        = 'XRT';
        if (
$bits 8)        $data[8]        = 'RB4';
        if (
$bits 16)        $data[16]        = 'FXO';
        if (
$bits 32)        $data[32]        = 'LX4';
        if (
$bits 64)        $data[64]        = 'LX6';
        if (
$bits 128)    $data[128]        = 'MRT';
        if (
$bits 256)    $data[256]        = 'UF1';
        if (
$bits 512)    $data[512]        = 'RAC';
        if (
$bits 1024)    $data[1024]        = 'FZ5';
        if (
$bits 2048)    $data[2048]        = 'FOX';
        if (
$bits 4096)    $data[4096]        = 'XFR';
        if (
$bits 8192)    $data[8192]        = 'UFR';
        if (
$bits 16384)    $data[16384]    = 'FO8';
        if (
$bits 32768)    $data[32768]    = 'FXR';
        if (
$bits 65536)    $data[65536]    = 'XRR';
        if (
$bits 131072)    $data[131072]    = 'FZR';
        if (
$bits 262144)    $data[262144]    = 'BF1';
        if (
$bits 524288)    $data[524288]    = 'FBM';
        return 
$data;
    }
    function 
convert_rule_bits($bits) {
        
$data = array();
        if (
$bits 1)        $data[1]        = 'CAN_VOTE';
        if (
$bits 2)        $data[2]        = 'CAN_SELECT';
        if (
$bits 4)        $data[4]        = 'QUALIFY';
        if (
$bits 8)        $data[8]        = 'PRIVATE';
        if (
$bits 16)        $data[16]        = 'MODIFIED';
        if (
$bits 32)        $data[32]        = 'MIDRACEJOIN';
        if (
$bits 64)        $data[64]        = 'MUSTPIT';
        if (
$bits 128)    $data[128]        = 'CAN_RESET';
        if (
$bits 256)    $data[256]        = 'FCV';
        return 
$data;
    }
    
// LFSWorld Functions
    
function get_hl($racer) {
        if (
is_array($racer)) {
            foreach(
$racer as $uname) {
                
$result[$uname] = $this->get_hl($uname);
            }
        } else {
            if ((
$result $this->make_query("&action=hl&racer={$racer}")) !== FALSE) {
                if (
is_array($result)) {
                    foreach (
$result as $i => $data) {
                        
$result[$i]['flags_hlaps'] = $this->convert_flags_hlaps($data);
                    }
                }
            }
        }
        return 
$result;
    }
    function 
get_ch($track$car$control null) {
        if (
is_array($track) || is_array($car)) {
            if (
is_array($track) && is_array($car)) {
                foreach(
$track as $tname) {
                    foreach (
$car as $cname) {
                        
$result[$tname][$cname] = $this->get_ch($tname$cname$control);
                    }
                }
            } else if (
is_array($track)) {
                foreach(
$track as $tname) {
                    
$result[$tname] = $this->get_ch($tname$cname$control);
                }
            } else if (
is_array($car)) {
                foreach (
$car as $cname) {
                    
$result[$cname] = $this->get_ch($tname$cname$control);
                }
            }
        } else {
            if ((
$result $this->make_query("&action=ch&track={$track}&car={$car}&control={$control}")) !== FALSE) {
                foreach (
$result as $i => $data) {
                    
$result[$i]['flags_hlaps'] = $this->convert_flags_hlaps($data);
                }
            }
        }
        return 
$result;
    }
    function 
get_wr() {
        if ((
$result $this->make_query("&action=wr")) !== FALSE) {
            foreach (
$result as $i => $data) {
                
$result[$i]['flags_hlaps'] = $this->convert_flags_hlaps($data);
            }
        }
        return 
$result;
    }
    function 
get_pb($racer) {
        if (
is_array($racer)) {
            foreach(
$racer as $uname) {
                
$result[$uname] = $this->get_pb($uname);
            }
        } else {
            
$result $this->make_query("&action=pb&racer={$racer}");
        }
        return 
$result;
    }
    function 
get_fuel($racer) {
        if (
is_array($racer)) {
            foreach(
$racer as $uname) {
                
$result[$uname] = $this->get_fuel($uname);
            }
        } else {
            return 
$this->make_query("&action=fuel&racer={$racer}");
        }
    }
    function 
get_pst($racer) {
        if (
is_array($racer)) {
            foreach(
$racer as $uname) {
                
$result[$uname] = $this->get_pst($uname);
            }
        } else {
            
$result $this->make_query("&action=pst&racer={$racer}");
        }
        return 
$result;
    }
    function 
get_hosts() {
        
$result $this->make_query("&action=hosts");
        foreach (
$result as $i => $data) {
            
$result[$i]['tmlt'] = unpack("ctype/cmain/aletter/ctestId"$data['tmlt']);
            
$result[$i]['tcrm'] = unpack("ctrack/cconfig/creversed/cmax"$data['tcrm']);
            
$result[$i]['cars'] = $this->convert_car_bits($data['cars']);
            
$result[$i]['rules'] = $this->convert_rule_bits($data['rules']);
        }
        return 
$result;
    }
    function 
get_teams() {
        
$result $this->make_query("&action=teams");
        foreach (
$result as $i => $data) {
            
$result[$i]['info'] = urldecode($data['info']);
            
$result[$i]['bits'] = $this->convert_team_bits($data['bits']);
        }
        return 
$result;
    }
    function 
get_hl_log($log_filter 4$lines 150$control null$starttime 0) {
        
$result $this->make_query("&action=hl_log&log_filter={$log_filter}&lines={$lines}&control={$control}&starttime={$starttime}");
        foreach (
$result as $i => $data) {
            
$result[$i]['flags_hlaps'] = $this->convert_flags_hlaps($data);
        }
        return 
$result;
    }
    function 
get_progress($host) {
        if (
is_array($host)) {
            foreach (
$host as $name) {
                
$return $this->get_progress($name);
                
$return[$return['hostinfo']['host_stripped']] = $return;
            }
        } else {
            return 
json_decode(array_pop(explode("\n"file_get_contents('http://www.lfsworld.net/pubstat/hostprogress.php?host='.urlencode($host)))), TRUE);
        }
    }
}


<
table>
    <
thead>
        <
tr>
            <
th>Key</th>
            <
td>Val</td>
        </
tr>
    </
thead>
    <
tbody>
   forEach (
$SDK->get_pst('Hoitjes') as $key => $val):    
        <
tr>
            <
th>echo $key; </th>
            <
td>echo $val; </td>
        </
tr>
   endForEach;    
    </
tbody>
</
table>

?>

You probably need to have credit in your account when you use the TRUE flag. You can just use FALSE tbh unless you need to access LFSW every second.
oops forgot that part, but it doesn't affect the outcome
Actually it should work even with the pubstat key originally in the SDK. This works for me:

<?php 
php

include('lfsworldsdk.php');

print_r($SDK->get_pst('notanillusion'));

?>

Output

<?php 
Array
(
    [
0] => Array
        (
            [
distance] => 239963076
            
[fuel] => 7793343
            
[laps] => 57231
            
[joined] => 2838
            
[win] => 1950
            
[second] => 1296
            
[third] => 890
            
[races_finished] => 7521
            
[qual] => 132
            
[pole] => 30
            
[drags] => 0
            
[dragwins] => 0
            
[country] => Finland
            
[ostatus] => 0
            
[hostname] => ^0LR^7|^1Race Center 1
            
[last_time] => 1254756651
            
[track] => 210
            
[car] => XRG
        
)

)
?>

yeah that worked for me too,
But I want it to be displayed nice in tables
therfor the code


<?php 
   
include('lfsworldsdk.php');    
<
table>
    <
thead>
        <
tr>
            <
th>Key</th>
            <
td>Val</td>
        </
tr>
    </
thead>
    <
tbody>
   forEach (
$SDK->get_pst('Dygear') as $key => $val):    
        <
tr>
            <
th>echo $key; </th>
            <
td>echo $val; </td>
        </
tr>
   endForEach;    
    </
tbody>
</
table>
?>

and then it does not work or something
The get_pst() returns a nested array, which is why it's not working. You can see it from the print_r() output. I'd do something like

<?php 
   
include('lfsworldsdk.php');    
<
table>
    <
thead>
        <
tr>
            <
th>Key</th>
            <
td>Val</td>
        </
tr>
    </
thead>
    <
tbody>
php    $pst $SDK->get_pst('Dygear');
        forEach (
$pst[0] as $key => $val):    
        <
tr>
            <
th>echo $key; </th>
            <
td>echo $val; </td>
        </
tr>
   endForEach;    
    </
tbody>
</
table>
?>

thanks it works now!
I tried to change some things but that didn't work. So I have a few questions left (a)
Is there a way to modify the tekst output under the key column?
Is there a way to change the online status to display online / offline instead of 0 or 1
Is there a way to change the way the time is displayed in last activity?
Is there a way to change the track code to a actual name of the track?
Quote from NotAnIllusion :The get_pst() returns a nested array, which is why it's not working. You can see it from the print_r() output. I'd do something like

Forgot that it was a nested array. I could of swore that if you only queried one item then it did not place it in an extra level of an array. But I'm pretty sure now that I left it like that so when you do multiple querys that in one function call you could use the same parser for both.

Quote from NotAnIllusion :Actually it should work even with the pubstat key originally in the SDK. This works for me:

I'm pretty sure that works because I'm pretty sure in that release I gave out my premium pubstats key. Funny thing is, no one has noticed that until now .

Quote from Hoitjes :thanks it works now!
I tried to change some things but that didn't work. So I have a few questions left (a)
[a]Is there a way to modify the tekst output under the key column?
[b]Is there a way to change the online status to display online / offline instead of 0 or 1
[c]Is there a way to change the way the time is displayed in last activity?
[d]Is there a way to change the track code to a actual name of the track?
  • Yes there is, but what do you want to change? And to what would you have it changed too?
  • Yes, in much the same way as you would change the key's value.
  • Yes, again the answer is the same as to two before hand.
  • Yes, but this would require another array, I would use an array but that's just me, to be present to change the information you see.
Meters Driven
Fuel burned in cl
Laps Driven
Hosts joined
Race wins
Second
Third
Races finished
Qualifications
Pole positions
Drags
Drags won
Country
Online status (Offline/Spectating/In pits/In race)
Current / Last entered hostname
Last active on (13-10-2009 14:30)
Current / Last driven track (track name)
Current / last driven car

Thanks in advance,
You guys are already so helpfull
Hoitjes

<?php 
php
    
include('lfsworldsdk.php');
    function 
trackToName($trackCode) {
        switch(
$trackCode[0]) {
            case 
0$rtn 'Blackwood ';
                switch(
$trackCode[1]) {
                    case 
0$rtn .= 'GP Track'; break;
                    case 
1$rtn .= 'Rally Cross'; break;
                    case 
2$rtn .= 'Car Park'; break;
                }
            break;
            case 
1$rtn 'South City ';
                switch(
$trackCode[1]) {
                    case 
0$rtn .= 'Classic'; break;
                    case 
1$rtn .= 'Sprint Track 1'; break;
                    case 
2$rtn .= 'Sprint Track 2'; break;
                    case 
3$rtn .= 'Long'; break;
                    case 
4$rtn .= 'Town Course'; break;
                    case 
5$rtn .= 'Chicane Route'; break;
                }
            break;
            case 
2$rtn 'Fern Bay ';
                switch(
$trackCode[1]) {
                    case 
0$rtn .= 'Club'; break;
                    case 
1$rtn .= 'Green Track'; break;
                    case 
2$rtn .= 'Gold Track'; break;
                    case 
3$rtn .= 'Black Track'; break;
                    case 
4$rtn .= 'Rally Cross'; break;
                    case 
5$rtn .= 'RallyX Green'; break;
                }
            break;
            case 
3$rtn 'Autocross ';
                switch(
$trackCode[1]) {
                    case 
0$rtn .= 'Autocross'; break;
                    case 
1$rtn .= 'Skid Pad'; break;
                    case 
2$rtn .= 'Drag Strip'; break;
                    case 
3$rtn .= '8 Lane Drag'; break;
                }
            break;
            case 
4$rtn 'Kyoto Ring ';
                switch(
$trackCode[1]) {
                    case 
0$rtn .= 'Oval'; break;
                    case 
1$rtn .= 'National'; break;
                    case 
2$rtn .= 'GP Long'; break;
                }
            break;
            case 
5$rtn 'Westhill ';
                switch(
$trackCode[1]) {
                    case 
0$rtn .= 'International'; break;
                }
            break;
            case 
6$rtn 'Aston ';
                switch(
$trackCode[1]) {
                    case 
0$rtn .= 'Cadet'; break;
                    case 
1$rtn .= 'Club'; break;
                    case 
2$rtn .= 'National'; break;
                    case 
3$rtn .= 'Historic'; break;
                    case 
4$rtn .= 'Grand Prix'; break;
                    case 
5$rtn .= 'Grand Touring'; break;
                    case 
6$rtn .= 'North'; break;
                }
            break;
            default: return 
'Unknown Track';
        }
        if (
$trackCode[2] === 1)
            return 
"$rtn Reversed";
        else
            return 
$rtn;
    }

<
html>
    <
head>
        <
title>Page for echo $_GET['racer']; </title>
    </
head>
    <
body>
        <
table>
            <
tbody>
php    $pst $SDK->get_pst($_GET['racer']);
        forEach (
$pst[0] as $key => $val):    
                <
tr>
php        switch ($key):
                case 
'distance':    
                    <
th>Meters Driven</th>
                    <
td>echo $val; </td>
php            break;
                case 
'fuel':    
                    <
th>Fuel burned in cl</th>
                    <
td>echo $val; </td>
php            break;
                case 
'laps':    
                    <
th>Laps Driven</th>
                    <
td>echo $val; </td>
php            break;
                case 
'joined':    
                    <
th>Hosts joined</th>
                    <
td>echo $val; </td>
php            break;
                case 
'win':    
                    <
th>Race wins</th>
                    <
td>echo $val; </td>
php            break;
                case 
'races_finished':    
                    <
th>Races finished</th>
                    <
td>echo $val; </td>
php            break;
                case 
'qual':    
                    <
th>Qualifications</th>
                    <
td>echo $val; </td>
php            break;
                case 
'pole':    
                    <
th>Pole positions</th>
                    <
td>echo $val; </td>
php            break;
                case 
'dragwins':    
                    <
th>Drags won</th>
                    <
td>echo $val; </td>
php            break;
                case 
'ostatus':    
                    <
th>Online status</th>
                    <
td>php
                        
switch ($val) {
                            case 
0:    echo 'Offline'; break;
                            case 
1: echo 'Spectating'; break;
                            case 
2: echo 'In pits'; break;
                            case 
3: echo 'In race'; break;
                        }
                    </
td>
php            break;
                case 
'last_time':    
                    <
th>Last active on</th>
                    <
td>echo date('d-m-Y H:i'$val); </td>
php            break;
                case 
'track':    
                    <
th>Track</th>
                    <
td>echo trackToName($val); </td>
php            break;
                default:

                    <
th>echo ucwords($key); </th>
                    <
td>echo $val; </td>
php        endSwitch;    
                </
tr>
php
    
endForEach;

            </
tbody>
        </
table>
    </
body>
</
html>
?>

LFSWorldSDK 1.9.2
Live For Speed World Software Development Kit. Version 1.9.2:

In this version I have a work around for servers that don't allow php to connect to http:// schema addresses with the file_get_conents() function. If the function fails it will attempt to make a connection attempt with cURL, and should that fail, then the SDK will trigger an error. No new features have been added, it just improves support for more server configurations.
Attached files
LFSWorldSDK 1.9.2.zip - 3 KB - 202 views
Live For Speed World Software Development Kit. Version 1.9.3:

FIX:
$sdk->get_progress method now works.
Now works on servers in 'safe mode' so long as cURL is installed.

Changed:
get_progress now uses fetch_data method.
make_query now uses fetch_data method.
Attached files
LFSWorldSDK 1.9.3.zip - 3 KB - 329 views
Combining the LFSWorldSDK's newest version on my web server running in PHP's safe mode, and Hoitjes' request for a profile page, this is what I've come up with. It's a profile page for all us the current LFSWorldSDK devs. (I'm only keeping the link up for a week, sorry, but I don't like files littering my root.)

Mr. Mark 'Dygear' Tomlin, Mr. Mikael 'filur' Forsberg, Mr. Victor van Vlaardingen, Mr. Jeff 'glyphon' DeLamater, Mr. Anonymous 'AndroidXP' and Dr. Timo 'HorsePower' Bergmann.

Thank you all for your support.

(Yeah, I know, the page is not pretty, but it's just some ideas thrown around.
[Damn it Jim, I'm a programmer, not a: designer!])
Quote from Dygear :

<?php 
php
    
include('lfsworldsdk.php');
    function 
trackToName($trackCode) {
        switch(
$trackCode[0]) {
            case 
0$rtn 'Blackwood ';
                switch(
$trackCode[1]) {
                    case 
0$rtn .= 'GP Track'; break;
                    case 
1$rtn .= 'Rally Cross'; break;
                    case 
2$rtn .= 'Car Park'; break;
                }
            break;
            case 
1$rtn 'South City ';
                switch(
$trackCode[1]) {
                    case 
0$rtn .= 'Classic'; break;
                    case 
1$rtn .= 'Sprint Track 1'; break;
                    case 
2$rtn .= 'Sprint Track 2'; break;
                    case 
3$rtn .= 'Long'; break;
                    case 
4$rtn .= 'Town Course'; break;
                    case 
5$rtn .= 'Chicane Route'; break;
                }
            break;
            case 
2$rtn 'Fern Bay ';
                switch(
$trackCode[1]) {
                    case 
0$rtn .= 'Club'; break;
                    case 
1$rtn .= 'Green Track'; break;
                    case 
2$rtn .= 'Gold Track'; break;
                    case 
3$rtn .= 'Black Track'; break;
                    case 
4$rtn .= 'Rally Cross'; break;
                    case 
5$rtn .= 'RallyX Green'; break;
                }
            break;
            case 
3$rtn 'Autocross ';
                switch(
$trackCode[1]) {
                    case 
0$rtn .= 'Autocross'; break;
                    case 
1$rtn .= 'Skid Pad'; break;
                    case 
2$rtn .= 'Drag Strip'; break;
                    case 
3$rtn .= '8 Lane Drag'; break;
                }
            break;
            case 
4$rtn 'Kyoto Ring ';
                switch(
$trackCode[1]) {
                    case 
0$rtn .= 'Oval'; break;
                    case 
1$rtn .= 'National'; break;
                    case 
2$rtn .= 'GP Long'; break;
                }
            break;
            case 
5$rtn 'Westhill ';
                switch(
$trackCode[1]) {
                    case 
0$rtn .= 'International'; break;
                }
            break;
            case 
6$rtn 'Aston ';
                switch(
$trackCode[1]) {
                    case 
0$rtn .= 'Cadet'; break;
                    case 
1$rtn .= 'Club'; break;
                    case 
2$rtn .= 'National'; break;
                    case 
3$rtn .= 'Historic'; break;
                    case 
4$rtn .= 'Grand Prix'; break;
                    case 
5$rtn .= 'Grand Touring'; break;
                    case 
6$rtn .= 'North'; break;
                }
            break;
            default: return 
'Unknown Track';
        }
        if (
$trackCode[2] === 1)
            return 
"$rtn Reversed";
        else
            return 
$rtn;
    }

<
html>
    <
head>
        <
title>Page for echo $_GET['racer']; </title>
    </
head>
    <
body>
        <
table>
            <
tbody>
   
$pst $SDK->get_pst($_GET['racer']);
        forEach (
$pst[0] as $key => $val):    
                <
tr>
       switch (
$key):
                case 
'distance':    
                    <
th>Meters Driven</th>
                    <
td>echo $val; </td>
           break;
                case 
'fuel':    
                    <
th>Fuel burned in cl</th>
                    <
td>echo $val; </td>
           break;
                case 
'laps':    
                    <
th>Laps Driven</th>
                    <
td>echo $val; </td>
           break;
                case 
'joined':    
                    <
th>Hosts joined</th>
                    <
td>echo $val; </td>
           break;
                case 
'win':    
                    <
th>Race wins</th>
                    <
td>echo $val; </td>
           break;
                case 
'races_finished':    
                    <
th>Races finished</th>
                    <
td>echo $val; </td>
           break;
                case 
'qual':    
                    <
th>Qualifications</th>
                    <
td>echo $val; </td>
           break;
                case 
'pole':    
                    <
th>Pole positions</th>
                    <
td>echo $val; </td>
           break;
                case 
'dragwins':    
                    <
th>Drags won</th>
                    <
td>echo $val; </td>
           break;
                case 
'ostatus':    
                    <
th>Online status</th>
                    <
td>php
                        
switch ($val) {
                            case 
0:    echo 'Offline'; break;
                            case 
1: echo 'Spectating'; break;
                            case 
2: echo 'In pits'; break;
                            case 
3: echo 'In race'; break;
                        }
                    </
td>
           break;
                case 
'last_time':    
                    <
th>Last active on</th>
                    <
td>echo date('d-m-Y H:i'$val); </td>
           break;
                case 
'track':    
                    <
th>Track</th>
                    <
td>echo trackToName($val); </td>
           break;
                default:

                    <
th>echo ucwords($key); </th>
                    <
td>echo $val; </td>
       endSwitch;    
                </
tr>
php
    
endForEach;

            </
tbody>
        </
table>
    </
body>
</
html>
?>


Sorry for my late reaction i had a lot of work to do.
I got this error message:

Warning: Invalid argument supplied for foreach() in /usr/home/deb9356n2/domains/teamrockracing.com/public_html/test/lfsstats/lfsworldsdk2.php on line 339

this error message comes from the part below, first sentence


<?php 
   $pst 
$SDK->get_pst($_GET['racer']);
        forEach (
$pst[0] as $key => $val):    
                <
tr>
?>

Quote from Hoitjes :Sorry for my late reaction i had a lot of work to do.
I got this error message:

Warning: Invalid argument supplied for foreach() in /usr/home/deb9356n2/domains/teamrockracing.com/public_html/test/lfsstats/lfsworldsdk2.php on line 339

this error message comes from the part below, first sentence


<?php 
   $pst 
$SDK->get_pst($_GET['racer']);
        forEach (
$pst[0] as $key => $val):    
                <
tr>
?>


The error suggests that the racer does not exist.
and where in this code should I fill in the racers username?
It's in the $_GET['racer'] variable. So add ?racer=Racer_name behind the url.
Wat he sed.
Quote from Hoitjes :and where in this code should I fill in the racers username?

Please don't re-post the SDK's source code, it's an unnecessary burden on the LFS Forum's database. Also, your not using the latest version of the SDK, (1.9.3) your using 1.9.1. They will both work, I'm just saying there is some added functionally in the newest version along with a other issues that where fixed.

[That is to say the current version is 1.9.3 at the time of this post (Oct 18 2009).]
Thanks alot guys it is working now!
Now lets see if I can implement it in the website
Going to be difficult with my little knowledge of php
If I get it working I let it know here, and post the files with ofcourse permission from the original authors of this part, so other people can use it as well.
It is going to be community builder based on a joomla website

Quote from Dygear :Please don't re-post the SDK's source code, it's an unnecessary burden on the LFS Forum's database. Also, your not using the latest version of the SDK, (1.9.3) your using 1.9.1. They will both work, I'm just saying there is some added functionally in the newest version along with a other issues that where fixed.

[That is to say the current version is 1.9.3 at the time of this post (Oct 18 2009).]

Sorry for that I deleted it from my post, and now used version 1.9.3 Thanks!
Quote from Flame CZE :It's in the $_GET['racer'] variable. So add ?racer=Racer_name behind the url.

please can u give an example code with some driver license?

thank u

PHP4/5 - LFSWorldSDK, class for stats retrieval
(288 posts, started )
FGED GREDG RDFGDR GSFDG