The online racing simulator
?action=hosts
Am I right in thinking that to display a simple 'server status' and/or 'racers on server' page requires pulling in the data for every server and then discard the unwanted stuff?

If I am correct could I request the addition of:

?action=host&hostname=xxxxx
Quote from OldBloke :Am I right in thinking that to display a simple 'server status' and/or 'racers on server' page requires pulling in the data for every server and then discard the unwanted stuff?

If I am correct could I request the addition of:

?action=host&hostname=xxxxx

I second that request. What would also be good is if we can filter the host name irrespective of the colour options that are placed inside the hostname text.
Additionally, would it be possible for us to filter the teams action too? It's a similar situation to the hosts issue raised above, where I want to display information about my team (as entered into on LfsWorld) but I have to transfer information about all the teams (currently there are 889) just to get to mine. Possibly a filter on the Id or the name.

Would save bandwidth on both ends
How about increased granularity provided via premium pubstats only?

For example:

?action=pb2&racer=xxxx&car=xxxx&track=xxxxx
Pubstats via Web are great, thanks a lot!

What I miss most is the ability to get player's status - Demo, S1 or S2. I see this was not necessary in the past but since even Demo players now have (or will have officially in [hopefully] very near future) LFSW stats available the licence info would be useful - e.g. it would be possible to see if a Y18+ server in demo config can be safely switched into S1 or S2 mode without anyone losing connection.

One more small thing I miss in the stats is date/time in WR table saying when that record was made or uploaded. Still, the stats are very nice indeed.
Hello, one question: Is possible to get someone's identification key without asking me?
EDIT: No, no... my bad. Now I already see. I don't need id keys of the others...
Hi Victor,

Is there any chance <timestamp> could be added to the 'ch' and 'wr' actions? This would save me a load of queries.
I'd kill for an SQL style syntax to these commands.

SELECT
driver.uid, driver.pname, driver.uname,
records_pb.uid, records_pb.track, records_pb.time,
records_wr.uid, records_wr.track, records_wr.time
FROM
driver, records_pb, records_wr
WHERE
driver.uid = records_pb.uid
OR
driver.uid = records_wr.uid
LIMIT
UPDATED FROM LAST QUERY;

(Yeah, I could see there being many issues with that query, but it's just an example, don't have a tizzy!)
Encoding problems with JSON (s=1) for hot lap charts (ch)
Hi,

while fetching hot laps charts I discovered an encoding problem in racer names when using JSON-style. The LFSW nickname is "Jörg Baumgarth" for the KY2/FXR.

When fetching as JSON (s=1) the LFSW nickname is "J" - so it breaks after "ö":
http://www.lfsworld.net/pubstat/get_stat2.php?idk=<IDENTKEY>&version=1.4&s=1&action=ch&track=410&car=FXR&s=1

When fetching as PHP or TEXT (s=2 or s=3) it works well:
http://www.lfsworld.net/pubstat/get_stat2.php?idk=<IDENTKEY>&version=1.4&s=1&action=ch&track=410&car=FXR&s=2
http://www.lfsworld.net/pubstat/get_stat2.php?idk=<IDENTKEY>&version=1.4&s=1&action=ch&track=410&car=FXR&s=3

(Replace <IDENT_KEY> with your ident key)

Any ideas? Bug?

Kind regards
Peter
Does not like non standard characters. I had that same issue with FireFox and XML files. It did not like Kimi Räikkönen's name at all. So I replaced the ä with an a, and the ö with an o.
Well, it has nothing to do with Firefox. The JSON is valid but the racername corrupted:


$ curl 'http://www.lfsworld.net/pubstat/get_stat2.php?idk=<IDENTKEY>&version=1.4&s=1&action=ch&track=410&car=FXR'
[{"id_hl":"29961","split1":"29490","split2":"63940","split3":0,"laptime":"95140","flags_hlaps":"513","racername":"C.Schuht"},{"id_hl":"29750","split1":"29730","split2":"64140","split3":0,"laptime":"95360","flags_hlaps":"513","racername":"crazydav"},{"id_hl":"28002","split1":"29570","split2":"64240","split3":0,"laptime":"95750","flags_hlaps":"1601","racername":"Vugl@"},{"id_hl":"29671","split1":"29890","split2":"64520","split3":0,"laptime":"95890","flags_hlaps":"513","racername":"kiste"},{"id_hl":"29532","split1":"29740","split2":"64760","split3":0,"laptime":"96210","flags_hlaps":"513","racername":"phoenixIlooka"},{"id_hl":"29340","split1":"30160","split2":"65160","split3":0,"laptime":"96740","flags_hlaps":"8705","racername":"tournois"},{"id_hl":"27975","split1":"29970","split2":"64930","split3":0,"laptime":"96930","flags_hlaps":"129","racername":"max92"},{"id_hl":"27263","split1":"30350","split2":"65260","split3":0,"laptime":"97180","flags_hlaps":"8705","racername":"Fall_Angel"},{"id_hl":"28700","split1":"30350","split2":"65940","split3":0,"laptime":"97820","flags_hlaps":"513","racername":"marcel."},{"id_hl":"29312","split1":"31930","split2":"70950","split3":0,"laptime":"104820","flags_hlaps":"1609","racername":"tomona"},{"id_hl":"28427","split1":"32100","split2":"71080","split3":0,"laptime":"104920","flags_hlaps":"513","racername":"J"},{"id_hl":"27105","split1":"35150","split2":"76110","split3":0,"laptime":"111680","flags_hlaps":"8704","racername":"AtomicRacer"}]

This entry has an invalid racername:

{"id_hl":"28427","split1":"32100","split2":"71080","split3":0,"laptime":"104920","flags_hlaps":"513","racername":"J"}

It should read "Jörg Baumgarth" not "J".

Maybe Victor could comment this, please?

Kind regards
Peter
Quote from splattael :Well, it has nothing to do with Firefox. The JSON is valid but the racername corrupted:

I know, I'm just saying, it's quite common for programs, even popular ones not to like special characters.

[
{
"id_hl" : "28427",
"split1" : "32100",
"split2" : "71080",
"split3" : 0,
"laptime" : "104920",
"flags_hlaps" : "513",
[b]"racername" : "Jörg Baumgarth"[/b]
}
]


<?php 
    $url 
'http://www.lfsworld.net/pubstat/get_stat2.php?version=1.4&idk=<IDK>&ps=1&action=ch&track=410&car=FXR&control=0';

    for (
$i 0$i <= 3$i++)
        print 
"<H{$i}>{$i}</H{$i}>"file_get_contents($url '&s=' $i) . "<BR />";
?>

Indeed, it only seems to be an issue with the JSON transport type.
Quote from Dygear :Indeed, it only seems to be an issue with the JSON transport type.

Victor, could you please comment on this?
Quote from splattael :Hi,

while fetching hot laps charts I discovered an encoding problem in racer names when using JSON-style. The LFSW nickname is "Jörg Baumgarth" for the KY2/FXR.

When fetching as JSON (s=1) the LFSW nickname is "J" - so it breaks after "ö":
http://www.lfsworld.net/pubstat/get_stat2.php?idk=<IDENTKEY>&version=1.4&s=1&action=ch&track=410&car=FXR&s=1

When fetching as PHP or TEXT (s=2 or s=3) it works well:
http://www.lfsworld.net/pubstat/get_stat2.php?idk=<IDENTKEY>&version=1.4&s=1&action=ch&track=410&car=FXR&s=2
http://www.lfsworld.net/pubstat/get_stat2.php?idk=<IDENTKEY>&version=1.4&s=1&action=ch&track=410&car=FXR&s=3

(Replace <IDENT_KEY> with your ident key)

Any ideas? Bug?

Kind regards
Peter

I'm going to conclude it's a bug in the json_encode function, although on the other hand I also made a mistake - strings in JSON should be UTF-8 encoded, but aren't atm. However i tested it with UTF8 strings but the name cutoff in the json output still remained. That's why I think there's a bug in php's json encode function.
Not sure what to do about it at this point. I could write my own json encoding function, or i could replace such accented characters with their unaccented ones - though that may not be the best solution.
Quote from Victor :I could write my own json encoding function, or i could replace such accented characters with their unaccented ones - though that may not be the best solution.

Just need to string replace function ... that will patch it for now.

$spiChars = [url=http://php.net/manual/en/book.array.php]array[/url](
'a' => [url=http://php.net/manual/en/book.array.php]array[/url](
'ª', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'à', 'á', 'â', 'ã', 'ä', 'å', 'Ā', 'ā', 'Ă', 'ă', 'Ą', 'ą'
),
'e' => [url=http://php.net/manual/en/book.array.php]array[/url](
'È', 'É', 'Ê', 'Ë', 'è', 'é', 'ê', 'ë', 'Ē', 'ē', 'Ĕ', 'ĕ', 'Ė', 'ė', 'Ę', 'ę', 'Ě', 'ě'
),
'i' => [url=http://php.net/manual/en/book.array.php]array[/url](
'Ì', 'Í', 'Î', 'Ï', 'ì', 'í', 'î', 'ï', 'Ĩ', 'ĩ', 'Ī', 'Ĭ', 'ĭ', 'Į', 'į', 'İ', 'ı'
),
'o' => [url=http://php.net/manual/en/book.array.php]array[/url](
'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'Ō', 'ō', 'Ŏ', 'ŏ', 'Ő', 'ő'
),
'u' => [url=http://php.net/manual/en/book.array.php]array[/url](
'Ù', 'Ú', 'Û', 'Ü', 'Ũ', 'ũ', 'Ū', 'ū', 'Ŭ', 'ŭ', 'Ů', 'ů', 'Ű', 'ű', 'Ų', 'ų', 'Ǔ', 'ǔ', 'Ǖ', 'ǖ', 'Ǘ', 'ǘ', 'Ǚ', 'ǚ', 'Ǜ', 'ǜ'
)
);

[url=http://php.net/foreach]foreach[/url] ($spiChars as $replace => $search) {
[url=http://php.net/str_replace]str_replace[/url]($search, $replace, $pre_jsoned_string);
}

Something like that should do the trick ... I am missing some, I just took up the Character Map and copyed all of the ones that where to do with each letter according to the Windows Character Map. That said, you should be able to this programmatically ... some how. (If the Character Map knows this information then it must be some where.)
Working fine here.


<?php 
php
    $ext 
= new ReflectionExtension('json');
    echo 
phpversion(), ' / '$ext->getName(), '-'$ext->getVersion(), PHP_EOL// 5.2.6 / json-1.2.1
    
    
echo json_encode('Jörg Baumgarth'), PHP_EOL// "J"
    
echo $json json_encode(mb_convert_encoding('Jörg Baumgarth''UTF-8''ISO-8859-1')), PHP_EOL// "J\u00f6rg Baumgarth"
    
echo mb_convert_encoding(json_decode($json), 'ISO-8859-1''UTF-8'), PHP_EOL// Jörg Baumgarth
?>

yeah actually i had a bug in my json_prepare function. The json_encode function is fine.

But now i wonder if i can just make the json output unicoded. I don't know if that's going to break some applications. So maybe i need to increase the version number for this fix?

@ splattael : maybe you care to comment on that?
Quote from filur :Working fine here.

I was waiting for some one to out program me, I thought it was going to be you.
Quote from Victor :But now i wonder if i can just make the json output unicoded. I don't know if that's going to break some applications. So maybe i need to increase the version number for this fix?

I expect JSON to be UTF-8 unless documented otherwise.

I don't think you need to increase the version number because it's a fix not an enhancement - people using JSON before got wrong data anyway

Thank you for investigating the problem
good point. Ok it's fixed now then.
Works like a charm!


>> LFSWorldHelper.fetch_hot_laps_chart("KY2", "FXR").select {|r| r["id_hl"] == 28427 }
=> [{"racername"=>"Jörg Baumgarth", "split1"=>32100, "flags_hlaps"=>513, "split2"=>71080, "id_hl"=>28427, "split3"=>0, "laptime"=>104920}]

Thank you
Hi, im having a little problem. I'm new to php and the pubstat system, so my code probably needs a little touch up.

Ok, when I upload my page to my server, it won't show if i'm offline/online etc. However, on my WAMP server, it all works fine and displays the way i want it to.


<?php 
php
echo "<p>Niall's Online Status:</p>";
if( 
$str=file_get_contents'http://www.lfsworld.net/pubstat/get_stat2.php?version=1.4&idk=<ident-key>&action=pst&racer=niall09'))
        
    if(
$str[66] == "0")
        echo 
"<p><span class='off'>Offline</span></p>";
        
    if(
$str[66] == "1")
        echo 
"<p><span class='spec'>Spectating</span></p>";
        
    if(
$str[66] == "2")
        echo 
"<p><span class='pit'>in the pits</span></p>";
        
    if(
$str[66] == "3")
        echo 
"<p><span class='race'>Racing</span></p>";
?>

Any help would be appreciated
since you say from a WAMP configured server it working , i think it probaly a configuration difference your probleme.

Only thing i can think of is this:
Help on the command "file_get_contents()" from the php manuel.
Quote :Tip You can use a URL as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename and Appendix O, List of Supported Protocols/Wrappers for a list of supported URL protocols.

Hope it help.

P.S. the php manuel can be downloaded into a .chm format and is very simple and well done to get help with php.
Check your php.ini on you server. I know this was an issue for me the first time I started with php.


;;;;;;;;;;;;;;;;;;
; Fopen wrappers ;
;;;;;;;;;;;;;;;;;;

; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
allow_url_fopen = On

Practical suggestions
PubStats via Web are great, I use them a lot in the AIRIO tracker. However I dare to come forward with a few suggestions. I posted some of those already in June last year, but without response. First the most troublesome matter:

1) After a bit of testing I came to the conclusion that the PubStat service is checking IP address the requests are coming from and if "tarpitted" (meaning limited, not paid) service is used, it will refuse requests from one IP coming faster than with 5 seconds delay. It does not matter the requests are coming with a key belonging to some other person, they come too fast from the same IP and are refused.

Well, in my view that approach limits usability of the service. There may be different people/applications on the same IP (without knowing the fact) and they may get random refusals. I know a server where Airio cannot download LFSW data in approx. 20 percent of requests, and I believe it is because there is already some other application on the same IP. An admin there can do nothing about it, generating new key for himself will not help, binding it to IP will not help either.

I can understand this is implemented so that people do not generate dozens of pubstat keys for themselves under different names and using many of those at the same time. Still, it prevents also legitimate pubstats usage. Paying for the service may provide only partial solutions, because if one person on the same IP pays for the service and sends many requests, while the other not, well - the one wanting to use free requests once every 5 seconds will be rather seriously damaged, wont he, with many requests turned down for no apparent reason?

My suggestion: Remove the IP check, let it run only on pubstat key basis, but at the same time let only licensed people generate and use the keys. As I see it, all the above troubles will be solved. And I can assure you, they are real troubles. I saw wrong people being kicked in LFS prior to patch Z when IP was used instead of username in demo, and this seems a similar matter to me. Limiting and deciding something based on IP is not good with the lot of shared IPs around the world.

2) What I miss most in PubStat data is the ability to get player's status - Demo, S1 or S2. I see this was not necessary in the past but since even Demo players have since patch Z LFSW stats available the licence info would be useful - e.g. it would be possible to see if a server in demo config can be safely switched into S1 or S2 mode without anyone losing connection.

3) One more small thing I miss in the stats is date/time in WR table saying when that record was made or uploaded.

Thanks for reading this far. I really believe especially point 1 needs serious attention, that is if something obvious did not escape me and I'm not making a big mistake somewhere. I also hope I did not miss some previous post concerning this, but searching gave me no similar results.

FGED GREDG RDFGDR GSFDG