The online racing simulator
A vivid imagination, often a good sign of a strong overall programmer.
I've made some gaint strides with this, that fell stunninly short due to a limitation in the PHP engine not allowing for consts to be assigned by expression within the class. (Augh!)

This is not valid PHP code, and it's such a pitty.


<?php 
final class WorldSDK extends LFS
{
    
/* Constants */
    // Strings
    # 0: Makes no change to the LFS mark'ed up strings.
    
const STRING_NONE            = (<< 0);
    
# 1: Changes player names only.
    
const STRING_NAMES            = (<< 1);
    
# 2: Changes host names only.
    
const STRING_HOSTS            = (<< 2);
    
# 3: Changes both player names and host names.
    
const STRING_BOTH            STRING_NAMES STRING_HOSTS;
?>

Back to the drawing board.
A const value needs to be a literal in most all languages I think. In C# you can work around this by using static readonly parameters to make the result of an expression constant, I don't know if PHP may have an equivalent you could use.

static readonly string STRING_NONE = (1 << 0).ToString();

It's a constant value as it pertains to run time information. It's bugging the crap out of me that I can't find a work around for this as it would improve readability of the code by leaps and bounds.
In LFSWorldSDK1.9.5-Alpha-1 is warning:
[B]Warning[/B]: Invalid error type specified in [B]lfsworldsdk.php[/B] on line [B]49[/B]

Line 49 is

<?php 
trigger_error
('Your server\'s configuration is not supported by this version of LFSWorldSDK.'E_WARNING);
?>

i do not understand what is wrong. Only {} was missing after else but this don't help.

PHP: php-5.2.9-2.fc10.i386
httpd: httpd-2.2.14-1.fc10.i386
Operating system is Linux - Fedora 10

Okram
Quote from Okram :In LFSWorldSDK1.9.5-Alpha-1 is warning:

Change E_WARNING to E_USER_WARNING
Quote from filur :Change E_WARNING to E_USER_WARNING

Nice, now this work. What does this warning is mean? What change in server configuration?

Okram
Quote from filur :Change E_WARNING to E_USER_WARNING

Your right, but I thought it would not ever get to that point unless file_get_contents was not enabled for remote warppers and cURL was not installed.

Speaking of file_get_contents and cURL, i've seen some benchmarks that show cURL is much faster. So I'll love that up to the first operation from now on.

Quote from Okram :Nice, now this work. What does this warning is mean? What change in server configuration?

Okram

nothing changed server side really, unless someone installed cURL on enabled fopen urls while you where waiting for an answer on this. He did fix my stupid mistake tho as only the engine can produce a E_WARNING, but I've never seen this to be a show stopping bug.
hello, im trying to embed on a website some informations of get_pst.php , so i can't use that way of inserting username like this:

?racer=username

i need to know where i insert the racername on the code, i've tried to insert on code but didnt work, look what i've tried:

$pst = $SDK->get_pst($_GET['juniox_dias'])

it didnt work, so how can i embed this on a website without using ?racer=username ???

<?php 
$pst 
$SDK->get_pst('juniox_dias');
?>

Try this.
Quote from misiek08 :

<?php 
$pst 
$SDK->get_pst('juniox_dias');
?>

Try this.

i've tried what u said but, didnt work, look:




i think it didnt work becouse of this code above the one u said on get_pst.php :

<?php if (empty($_GET['racer'])): ?>
<form target="_SELF" method="GET">
<lable for="racer">LFS Username:</lable><input type="textbox" id="racer" name="racer" /><br />
<input type="submit" value="Get Info" />
</form>

yes, the ($_GET['racer']) is empty on the link , but this is what im trying to do

i tried to delete this line "if" but didnt work to =/ .


But thank u for helping, maybe u know how to help me.

thank u guys, im waiting more posts
can someone help me ?

<?php 
include('lfsworldsdk.php');
    
$racer = (empty($_GET['racer'])) ? 'juniox_dias' urldecode($_GET['racer']);

<
html>
    <
head>
        <
title>echo (empty($racer)) ? 'Please Input a Racer\'s Name' 'Page for ' htmlentities($racerENT_QUOTES); </title>
    </
head>
    <
body>
php    if (empty($racer)): 
        <
form target="_SELF" method="GET">
            <
label for="racer">LFS Username:</label><input type="textbox" id="racer"  name="racer" /><br />
            <
input type="submit" value="Get Info" />
        </
form>
php    else:     
        <
table>
            <
tbody>
php        $pst $SDK->get_pst($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 
'hostname':    
                    <
th>Hostname</th>
                    <
td>echo LFSWorldSDK::convert_lfs_text($val); </td>
php                break;
                    case 
'last_time':    
                    <
th>Last active on</th>
                    <
td>echo date('M jS Y @ H:i'$val); </td>
php                break;
                    case 
'track':    
                    <
th>Track</th>
                    <
td>echo LFSWorldSDK::convert_track_name($val); </td>
php                break;
                    default:

                    <
th>echo ucwords($key); </th>
                    <
td>echo $val; </td>
php            endSwitch;    
                </
tr>
php        endForEach;    
            </
tbody>
        </
table>
php    endIf;    
    </
body>
</
html>
?>

thank you a lot @Dygear ! it will works for me, i will insert a variable on racername for gridlfs league forum.


i just got this error, every information above hostname are ok but on hostname i got this:

Hostname
[B]Fatal error[/B]: Call to undefined method LFSWorldSDK::convert_lfs_text() in [B]/home2/gridlfsc/public_html/forum/lfswsdk/get_pst2.php[/B] on line [B]70[/B]

line 70:
<td><?php echo LFSWorldSDK::convert_lfs_text($val); ?></td>

what i have to do here?
Make sure you have the latest version of LFSWorldSDK, as that has the function you need.
thank you dygear, i updated the lfswsdk, now everything is ok

i just had a problem with that line 48 or 49 i've changed e_warning to e_user_warning, didnt work so i deleted the line and everything works good

im sorry that im noob on programming but im trying to get better =)
Just for info: Your missing at least one error-message, namely
Quote :pb: no valid username

I'll keep that in mind, I was pretty sure that Victor gave me that list too.
Well, maybe that is a new one ...
also missing (I came across that one today): "fuel: no valid username"
Victor, can you please post the whole list of error messages in the LFSWorld Stats thread.
Quote from Dygear :Victor, can you please post the whole list of error messages in the LFSWorld Stats thread.

And on that subject:

Quote from Victor :These should be all of them :

don't block your ip please.
Identification is required - http://www.lfsforum.net/showthread.php?t=14480
Invalid Ident-Key
not authed (invalid identkey)
not authed (ip)
Invalid login details provided
No authentication method provided.
can't reload this page that quickly after another
hl_log is only available since version 1.2 and later
no output
ch: invalid track
ch: invalid car
fuel: no valid username
hl: no racer
hl: no hotlaps found
pb: no valid username
pb: racer has no pbs
pst: no valid username

Just discovered the SDK and am currently having a play.... fantastic work btw.
I have however noticed a "feature"; the SDK->get_pb function isnt retrieving (or returning maybe) the fuel column, if i query LFSW manually using the pubstat url i get a final fuel column.

I have tried to decypher the code to work out where the issue lies, but the code is a bit too complex for me to work out what the hell is going on.

I am using 1.9.5 alpha btw

cheers
I'll be sure to update that when I get home, expect a fix in the next 12 hours.
wow,

uber fast response... impressed

while im on i did make a slight change to the convert_lfsw_time function. changed the padding to make the second have a leading zero as times such as 1:07.34 would display as 1:7.34


function convert_lfsw_time($time) {
return sprintf('%d:%06.3F', floor($time / 60000), (($time % 60000) / 1000));
}

Ok, I'll merge that in as well.

[Edit] The next version will be 1.9.9, and it will be the last version of this branch.

FGED GREDG RDFGDR GSFDG