The online racing simulator
Quote from juniox_dias :please can u give an example code with some driver license?

thank u

If you run the script on page.php, the URL will look like page.php?racer=juniox_dias and it will output details of your username.
It looks like a great script, but I'm stuck . Anything I try the page looks like in the attached screenshot.

That's my index.php (found in this topic):

<?php 
php

include('lfsworldsdk.php');

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

 
?>

I've set the SDK correctly.
Attached images
kantz-0001.jpg
Quote from kantzorf :It looks like a great script, but I'm stuck . Anything I try the page looks like in the attached screenshot.

That's my index.php (found in this topic):

<?php 
php

include('lfsworldsdk.php');

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

 
?>

I've set the SDK correctly.

It's also doing the examples as well, just remove the examples.
Quote from juniox_dias :please can u give an example code with some driver license?

thank u

Could some one with an S1 license please login to the front page of the website and post the background image for the table with the class "license_login". Or would Vic mind posting the template png file for the S1, S2 and S3 license ...
Attached images
lfs_license_card_login.png
lfs_license_card_s2.png
Oh, i was editing another copy of the page, not the one in htdocs .
Quote from kantzorf :Oh, i was editing another copy of the page, not the one in htdocs .

It happens to the best of us mate. We all have a do'h moment every now and again.
I have the same problem as Hoitjes in post #218, but it happens only if I upload the script on the online host. On localhost everything is fine.
Quote from kantzorf :I have the same problem as Hoitjes in post #218, but it happens only if I upload the script on the online host. On localhost everything is fine.

And my answer remains the same.

Quote from Dygear :The error suggests that the racer does not exist.

Quote from Hoitjes :and where in this code should I fill in the racers username?

Quote from Flame CZE :It's in the $_GET['racer'] variable. So add ?racer=Racer_name behind the url.

Quote from Hoitjes :Thanks alot guys it is working now!

Here is the code:

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

And this is the url, try it yourself: http://watf.ro/sig/test.php?racer=kantzorf

I'll try a PHP update, maybe that's the problem.
Ok, here is my answer to that, and I've updated the code to be used in the next LFSWorld release as an example page on how to parse the PST result (thus, the page is called get_pst.php).

An example of this page running can be found here:
http://area51.wlvacc.org/lfs/get_pst.php?racer=Dygear
Attached files
get_pst.zip - 2.1 KB - 467 views
Live For Speed World Software Development Kit. Version 1.9.4:

Removed:
Index.php - No longer required to showcase functions.

FIXed:
get_hl, get_pb, get_fuel, & get_pst functions now work when the username as a space in it (urlencoded strings).

Added:
get_pst.php - Added to showcase get_pst function in action.
Attached files
LFSWorldSDK1.9.4.zip - 4.7 KB - 503 views
Everything looks fine now .
In get_pst.php, there's a badly-spelled HTML tag - <lable> should be <label>.
Quote from Flame CZE :In get_pst.php, there's a badly-spelled HTML tag - <lable> should be <label>.

Lol, thanks for that. Funny, normally NotePad2 picks on on my mistakes like that. (Does not highlight the attributes.) I'm going to leave that for now. I'll fix it in my version and I'll release the new patch when I have the rest of the functions have a show case script.
I've added some things to the latest version, mainly an example script for all functions. I am not 100% happy with them all, but I'm going to release it anyway later today. Some of the 'showcase' scripts, as I've come to call them, are just the direct function calls. I'll get around to them on the later updates. Until then, consider theses a preview release for the up comming 2.0 that should, I hope, make it easier to program with the SDK.

The showcase scripts have made me eat my own dog food, and as such, I've come to relize some of the short commings.
LFSWorldSDK 1.9.5 Alpha 1
Hard to post a full change log. Just have a look around, and don't use it on a production server. (All of the functions in the SDK do work, and it COULD replace the old version, if you needed it too, but that is not recommended.)

All showcase pages are present, but not to the standard I wish. I'll be updating them over the coming days, and weeks. This is the long press on to version 2.0.0 ... See ya there!
Attached files
LFSWorldSDK1.9.5-Alpha-1.zip - 8.7 KB - 825 views
Version 2.0 coming out in the next few days, including a rewrite. Anyone have any blaring issues with the current code base, let me know now.
#246 - Bub
oh this will be nice can`t wait till test it out
A round of applause please
Thanks for all your hard work on this Dygear, most appreciated. Looking forward to v2.0.0 with excited anticipation.

I'm just starting out on the LFS PHP road and with no professional programming experience, it's certainly proving most challenging - but in a rewarding kind of way.

On a completely different matter, I wonder if Victor et al would consider recording fastest laps in the database?

Cheers,
Madskillz12
Quote from Madskillz12 :Thanks for all your hard work on this Dygear, most appreciated. Looking forward to v2.0.0 with excited anticipation.

Thank you, it's nice to know work my is getting used, and is appreciated.

Quote from Madskillz12 :I'm just starting out on the LFS PHP road and with no professional programming experience, it's certainly proving most challenging - but in a rewarding kind of way.

Yeah, php is a novel language to learn and start out with. A lot easier then some out there, but also provides for it's own level of interesting quirks. It's fun to move from a procedural sort of programming into a Classy Object Oriented Programming, then from there move into an Event / Callback system. And remember, your not a real programmer until you've written your own recursive function, and understand something about Perl Regular Expression (So, that counts me out then, lol!). It's not about being the best, it's about trying your hardest, and doing the best you can with the information you have.

Quote from Madskillz12 :On a completely different matter, I wonder if Victor et al would consider recording fastest laps in the database?

Those who can't do, program? I jest, I jest! I'm sure he can just edit the MySQL table to reflect a much faster lap time. Save some face that way. I'm sure he is much to busy with the next version of pubstats to be turning laps.
Quote from Dygear : I'm sure he is much to busy with the next version of pubstats to be turning laps.

ROFL A sense of humour is essential to maintain one's sanity while hacking PHP I'm finding. Nice one Dygear.

Cheers,

Madz
Quote from Madskillz12 :
On a completely different matter, I wonder if Victor et al would consider recording fastest laps in the database?

LMAO - way too much double entendre in my statement, I've got mental images of Victor blasting around Blackwood in a MySQL table!! Weird eh???
Cheerz,
Madz

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