View Full Version : Commentary on the "getstat" LFS World script
P2M-Unixseb
12th May 2006, 12:22
Is there a chance to obtains date informations regarding "action=pb" (i mean get a timestamp of the date-time when the pb was done) ??
the_angry_angel
12th May 2006, 12:50
Not through the web api :(
wheel4hummer
15th May 2006, 01:00
I tried to make a signature that displays my LFS fuel economy, but the image wont show!
Dygear
15th May 2006, 04:42
The file itself has to end in a extension for this fourm's IMG tag to pick it up.
the_angry_angel
15th May 2006, 07:58
That also assumes you've got show images set to on, in your forum user account.
vanirl
20th May 2006, 10:05
Bearing in mind I am a total twit when it comes to any sort of technical stuff like programming, can anyone assist me?
I have a website (see link below), and would like to show MY racing stats on it. I have read some of the previous posts but got lost big time
Why do I want stats on the site? - public humiliation is my "thing"
In plain simple words (use the KISS method – Keep It Simple for the Stupid)
How can I get my stats on my site
PS if anyone wants to comment on the site (even if only the LFS section) or make some suggestions please do so (either here or using the feeback on site)
As usuall - Many thanks
Victor
20th May 2006, 16:52
first let me ask, do you have any kind of web programming facilities installed on your host? Like php or asp, things like that? I couldn't find any hint that you did, but you'll need a scripting language, so that's the first thing to look at.
vanirl
20th May 2006, 17:25
Sorry Victor - I have no idea - as I say "a bit thick" on all of this stuff
How do I go about finding that out?
Ask them??
necrodon
26th May 2006, 08:14
I have setup a small site for my Live For Speed host here (http://dewy.game-host.org/). Just wondering if its possible and if so how, I could have the leaderboard from the previous/current (which ever is newer) race imported into the page? I am running a clean install of IIS without any mods/addons enabled.
Red Runner
26th May 2006, 17:50
Dear Victor,
there's a bug in the team-list: Concerning your readme, the url of a team shouldn't exceed 64 characters.
If you grab all the teams with (&action=teams), then you'll see, that the full url of the team "Forocoches Team" is returned. This url is longer than 64 characters and isn't cut of.
This makes it a bit hard to parse the data behind that team ;-)
Summary:
Team: Forocoches Team
URL is: http://www.lfs-spain.net/modules.php?op=modload&name=liga&file=info_team&nombre_team=[FC]%20Team
URL should be: http://www.lfs-spain.net/modules.php?op=modload&name=liga&file=i
(or the struct has to be changed)
Kind Regards
Red Runner
--==Gogo==--
10th June 2006, 22:45
There are 2 Teams where the URL exceeds the 64 Bytes:
Forocoches Team (97 Bytes)
and
Majestic Dragon Drivers (82 Bytes)
I guess the only reason why this works is that currently only the 1st byte of the BITS-Section in TEAM_STRUCT is used till now.
BITS :
// 1 : race
// 2 : drift
// 4 : drag
// 8 : can apply
// 16 : has host
// 32 : Demo
// 64 : S1
// 128 : S2
// 256 : S3
Victor
10th June 2006, 23:43
whoops, didn't see this report sooner.
The strings are cut off at their max size now. When going to a new version number i can increase the field size.
--==Gogo==--
11th June 2006, 08:15
THX Victor! :thumb:
Red Runner
11th June 2006, 13:16
Thanks for fixing this :-)
KayJay
19th June 2006, 19:10
NEW : User-identification (login / Ident-Key)
--------------------------------------------
The option to identify yourself has been introduced. For now this will be voluntary, but in the future it will become obligatory for logging purposes, so you best start using this option right now.
There are two ways to identify yourself:
1) Using an Ident-Key which you can generate on behalf of your account on the LFS World settings pages (http://www.lfsworld.net/?win=settings&whichTab=pubstat)
You can feed an Ident-Key to the pubstat script via the following variable:
&idk=<Ident-Key>
If you bind an IP address to an Ident-Key, then pubstat will make sure that only that IP address can use that Ident-Key.
Hi Vic,
Loving your work by the way. :D
Unfortunately, I'm using an ISP which uses cache/proxy servers so binding an IP address does not work. Is it possible for the script your side to check the IP address against both REMOTE_ADDR and HTTP_FORWARDED_FOR? :)
xpjames
19th June 2006, 20:10
Would there also be an option to use the LFSW Pb instead of a hotlap in OLFSL or similar because it allows you to race online with other people and still get the time!
Victor
19th June 2006, 20:15
Hi Vic,
Loving your work by the way. :D
Unfortunately, I'm using an ISP which uses cache/proxy servers so binding an IP address does not work. Is it possible for the script your side to check the IP address against both REMOTE_ADDR and HTTP_FORWARDED_FOR? :)
can you check this script and tell me if it gives the correct ip? (local ip)
http://www.lfsworld.net/pubstat/ip_check.php
Victor
19th June 2006, 20:17
Would there also be an option to use the LFSW Pb instead of a hotlap in OLFSL or similar because it allows you to race online with other people and still get the time!
sorry, but i've no idea what you mean.
KayJay
19th June 2006, 20:45
can you check this script and tell me if it gives the correct ip? (local ip)
http://www.lfsworld.net/pubstat/ip_check.php
Yep, thats the correct IP :)
Hopefully your local ip : 82.*.*.195
Dygear
20th June 2006, 00:08
It's a BAD idea to post your ip address on a public forum.
narcis
20th June 2006, 15:03
Hi. Is possible to get, for example, the list of PBs of any racer in one track?? Why always getting all the PBs or HLVC if I only want to know the times in a concrete track or in a car?
I want to use something like this:
http://www.lfsworld.net/pubstat/get_stat2.php?version=1.2&action=pb&racer=narcis&track=000
And the output would be something like this:
000 FXO 89480 138
000 RB4 88370 239
000 XFG 93180 1047
000 LX6 82480 30
000 XRT 91230 11
(only my times in bl gp normal)
Thanks :).
KayJay
20th June 2006, 15:40
It's a BAD idea to post your ip address on a public forum.
You're just paranoid! :)
My system is locked up tighter that a virgin's chastity belt. I get thousands of portscans per day, a few more won't hurt - unless it saturates my connection :schwitz:
Dygear
20th June 2006, 21:28
Hi. Is possible to get, for example, the list of PBs of any racer in one track?? Why always getting all the PBs or HLVC if I only want to know the times in a concrete track or in a car?
Why not just take that data and if the track name is not equal to what you want then don't add it to your array, or what ever your storeing it in.
narcis
21st June 2006, 08:31
Why not just take that data and if the track name is not equal to what you want then don't add it to your array, or what ever your storeing it in.
Because the premium pubstat service costs more $$$ if you get more data...And the "size of all times" is >>>>>> "size of times I want each time" :shrug:
VorTeX3k
21st June 2006, 11:54
Is it possible that the Laps byte will only be a non-zero value if the server has currently a race running on it?
I have set my server to 10 laps but there's nobody online. And LFSW gives me 0 as value for laps. Is this correct that this value will only change when there's someone driving on the server?
Victor
22nd June 2006, 15:21
Because the premium pubstat service costs more $$$ if you get more data...And the "size of all times" is >>>>>> "size of times I want each time" :shrug:
seriously, the currently biggest premium pubstat spender spends less than 10 pennies a month. Being concerned about $$$ really is exaggerated.
Victor
22nd June 2006, 15:23
Is it possible that the Laps byte will only be a non-zero value if the server has currently a race running on it?
I have set my server to 10 laps but there's nobody online. And LFSW gives me 0 as value for laps. Is this correct that this value will only change when there's someone driving on the server?
if you change something on a host, it should update on lfsworld too. Doesn't matter if someone is on the host or not.
VorTeX3k
22nd June 2006, 16:17
if you change something on a host, it should update on lfsworld too. Doesn't matter if someone is on the host or not.
Well.. in this case there seems to be a problem in my script.. For some servers I get 0 laps (but I know that 10 laps have been set) and for some others I get the correct value :/ Ok, so I should have a look at this.
By the way: is it possible to make pubstat donations via PayPal?
Victor
22nd June 2006, 16:20
yup, just make a payment to lfstech@liveforspeed.net and put your username in the notes.
--==Gogo==--
23rd June 2006, 11:02
Well.. in this case there seems to be a problem in my script.. For some servers I get 0 laps (but I know that 10 laps have been set) and for some others I get the correct value :/ Ok, so I should have a look at this.
By the way: is it possible to make pubstat donations via PayPal?
If I remeber correctly, you get 0 laps if the server is currently running a qualifying session. No matter how many laps are set for the race.
soyobr
24th June 2006, 19:12
Hi guys!
i try this in code for show who of the team is online (page 5):
include("lalala.php");
$con = mysql_connect( $host, $user, $senha );
$sql = "SELECT nick, nome FROM pilotos";
$res = mysql_db_query( $db, $sql, $con );
while( $row = mysql_fetch_array( $res )){
$nick = $row["nick"];
$nome = $row["nome"];
$nicks .= " \"$nick\",";
$nomes .= " \"$nome\",";
}
$nicks = substr("$nicks", 0, -1);
$nomes = substr("$nomes", 0, -1);
$TeamMembers = array($nicks);
$InGameName = array{$nomes);
But this don't work's! :shrug:
I wanna automate the process, i have a little db with team members lfsw nicks and names, so, for i don't need edit the php code every time i add a new team member...
Any light?
Hugs/Abraços,
Saulo Barbosa
filur
24th June 2006, 20:34
Any light?
Can't say i really understand what you're asking for, but if it's the array creation ..
while($row = mysql_fetch_array($res)){
$nicks .= "{$row['nick']},";
$nomes .= "{$row['nome']},";
}
$TeamMembers = explode(",", $nicks);
$InGameName = explode(",", $nomes);
.. or ..
while($row = mysql_fetch_array($res)){
$nicks[] = $row['nick'];
$nomes[] = $row['nome'];
}
soyobr
24th June 2006, 21:20
thank's a lot filur!
i forgot the explode function generate a array too :pillepall hehe
just a little modification:
$nicks .= "{$row['nick']},";
$nomes .= "{$row['nome']},";
}
$nicks = substr("$nicks", 0, -1);
$nomes = substr("$nomes", 0, -1);
$TeamMembers = explode(",", $nicks);
$InGameName = explode(",", $nomes);
Remove the last "," for don't create a new blank member in array :thumb:
hugs/abraços,
Saulo Barbosa
Anarchi-H
25th June 2006, 01:55
Forgive me for being blunt but isn't your code over complicated?
Why put the names in a string only to explode them?
If you don't need the comma delimited list, a tiny alteration to filurs code would be more efficient...
while($row = mysql_fetch_array($res)){
$TeamMembers[] = $row['nick'];
$InGameName[] = $row['nome'];
}
And even if you do need the comma delimited lists, imploding the array would be a better way to achieve it because implode is quicker than explode and you won't need to remove the trailing comma.
$nicks = implode(',', $TeamMembers);
$nomes = implode(',', $TeamMembers);
filur
25th June 2006, 09:31
And why use two arrays when you only need one? :)
while($row = mysql_fetch_array($res)){
$TeamMembers[$row['nick']] = $row['nome'];
}
racemania
4th July 2006, 16:49
hi guys
im not really that good at this but ive tried and failed all i seem to get is all these words on screen when i load to a web page.
ive tried to read through the 285 posts here but its a bit hard and took like 3-4 days to do.
is there somthing that can help out like for a noob to this lol im a BIG noob when it comes to this kind of stuff. the big problem for me is that i cant seem to figure out what im doing wrong. what i want to do is have a part of my site say who is online in the team and what server there on ive seen many other teams with this. if im in the wrong place please tell me.
i just need to know what needs to be done to have these in my webspace.
i have dreamweaver 8 well the full macromeadia 8 which was given to me when i brought my computer long story thats better told at another time.
ive also seen the AAL site they have a place on the side that shows your Hot Laps and all the stuff that LFSW show you about your time online and fule stuff like this.
im just wondering is it hard for someone with little experiance to do this or is it more for the pros.
thanks for any help in advance.
if ive left anything out you need to know please tell me and ill post it.
thanks racemania
filur
4th July 2006, 17:04
the big problem for me is that i cant seem to figure out what im doing wrong.
My guess is you're trying to achieve this without any form of server-side scripting/cgi (php/asp etc.)
Result: you can't, all the code/snippets posted in this thread deals with fetching statistics and info from lfsworld using a server-side scripting language such as PHP (http://php.net) or ASP (http://www.asp.net/Default.aspx?tabid=1), HTML is used to present the information, not gather it.
Solution: find out if your web host offers any server-side script support, if you're running your own web server, find out how to offer it yourself.
racemania
5th July 2006, 03:25
ok thanks for your quick reply im looking into it now thankyou
CrazyICE
7th July 2006, 11:15
well, i've got a qeustion too. don't know if it was requested before, so foregive me if someone asked before...
victor:
is it possible to get the timestamp of a lfs racer when he was the last time online?
Victor
7th July 2006, 15:54
hmm, no, I don't have that value stored atm. I've made a note for the next version of the pubstats.
nikka
11th July 2006, 14:12
Hi, just thought of something that would be very useful (to me at least... :))
It should be possible to somehow subscribe to changes in certain stats.
For example: I want to know when racerA has set a new pb and when racerB has uploaded a new hotlap.
I subsribe to those events with the requests
?subscribe=pb&racer=racerA
and
?subscribe=hl&racer=racerB
Then I have to poll for changes in my subscribed stats with the request
?check_subscription
If for example racerA has set a new pb, check_subscription returns
PB racerA
and if racerA has set a new pb AND racerB has uploaded a new hotlaps, check_subscription returns
PB racerA
HL racerB
(if no changes, check_subscription could return.. "no changes".. :))
A subscription system would make it less painfull to deal with multiple stats. Instead of downloading all my teammates pb, hl and pst say every hour, this way I could just poll for changes and just download the stats that have actually changed. Would save me (and lfsworld) a lot of statdata bandwith.
Is it possible to implement this system (or a variant) in the future?
Victor
11th July 2006, 15:07
for pubstats you mean?
And about bandwidth - again, I'm not really worried about that - I'm more worried about db-queries, which would increase with this subscription thing.
bit OT :
Just compare our forum server with our other server which hosts www.liveforspeed.net , www.lfsworld.net , all the downloadable skins, stats processing, insim relay, etc. The forum server only runs one website and in peak times, is loaded heavily : because vb uses a _lot_ of database queries. Our other server can serve more clients than the forum server can, even though that other server runs much more software! That's why I'm always 'nagging' about db queries, more than bandwidth. Just thought I'd explain that a bit - I'm really careful with db queries. So one doesn't have to bring bandwidth as a pro when suggesting something ;)
but oh yeah, I'll have a think about it. It sounds like a nice feature.
nikka
11th July 2006, 15:38
for pubstats you mean?
uhm yes... :)
And about bandwidth - again, I'm not really worried about that
Well, I use the untarpitted service, so I am..
(well, "worried" is a bit strong since the amounts we're talking about is nothing that will make me poor, but we're trying to keep the costs of running the team to a minimum so every penny counts)
but oh yeah, I'll have a think about it. It sounds like a nice feature.
Cool!
CrazyICE
17th July 2006, 13:07
hey victor,
is it possible to get only a specific team data entry?
don't know if requested before...
maybe it is possible like that:
?action=teams&name=Octrin.Racing
so u only get the data for Octrin.Racing
or is this again an issue of to many database queries?
CrazyICE
19th July 2006, 12:32
next question/request (may asked befor, don't know, so sorry, if was requesed before):
is it possible to get the splits of PBs and HLs too (not only the time)?
St4Lk3R
19th July 2006, 12:49
Is it possible to get the splits of hls/pbs too, not only the times
AFAIK not. If you want hotlap splits then parsing replays is the way to go, but getting the splits of a pb is impossible IIRC...
KayJay
19th July 2006, 21:51
I just wanted to pop back into this thread and thank Victor for sorting out the problem with the proxy IP address so quickly. You work is very much appreciated :D
If anyone is interested, I wrote the following page a couple of weeks ago, and have been tweaking it since. It compares the online lap times of the team I'm in and highlightes the best lap time.
http://www.sonicrealmsracing.co.uk/pages/compare.php
PS I didn't design the site!
Victor
20th July 2006, 00:00
next question/request (may asked befor, don't know, so sorry, if was requesed before):
is it possible to get the splits of PBs and HLs too (not only the time)?
online pb's - no, i just don't store their splits
hl-splits , can consider that for next version (could start working on that soon - there are some updates waiting now)
ORION
20th July 2006, 10:15
Ages ago I suggested to show the wplits when you type /w wr. I would really like to see that, even though I dont remember what you said back then (if its possible).
Victor
20th July 2006, 13:22
i'm thinking it wouldn't fit on 1 line and i really don't like spamming multiple lines.
CrazyICE
21st July 2006, 12:25
hey victor.
i recognised the following issue on getting the PBs of someone.
If a player deletes his PB the lapcount is not resetted!
for example "csimpok" (sorry dude, just recognised now because of testing purpose).
he has not time for BL GP with XFG but he has done 191.
(i get this line of LFSW: 000 XFG 0 191)
well, i can ignore those lines (time = 0) but i just wanted to know, if this is intended...(honestly I do think so)
Victor
21st July 2006, 13:33
laptimes remain when ppl delete their pb
glyphon
26th July 2006, 20:43
I've created a code to generate a an image singature with user name, online status, and some various online stats.
here's the code if anyone would like it...
also, if anyone notices any glaring errors or ways to improve the code, please let me know :)
get the cp_unicode_tables file that is referenced in the include at the top of the script in this thread...
http://www.lfsforum.net/showthread.php?t=3304
also, the msgothic.ttf file is 7.9mb, so i can't attach it here. check your windows/font directory for it. verdana should definately be in that folder.
usage is LFS_online_check.php?name=Valid LFS UserName Here
example images are attached, as is a template for where the stats go. obviously, you can change all that around if you want to change the code for the text placement. :)
updated script (http://www.lfsforum.net/showthread.php?p=187491#post187491)
filur
26th July 2006, 21:21
.. if anyone notices any glaring errors or ways to improve the code, please let me know :)
Support for kilometers / liters? :)
glyphon
26th July 2006, 21:51
Support for kilometers / liters? :)
metric version that gives stats in km & L. :D
also, for anyone using this script, don't forget to put your ID Key in the $idkey variable...the script won't work otherwise.
updated script (http://www.lfsforum.net/showthread.php?p=187491#post187491)
PaulC2K
28th July 2006, 16:31
Hi,
Im trying to hack up (Hack being the exact term unfortunately) someones 'who's online' tracker which was posted around page 3-5 and im just having some 'fun' with the colour codes and how they work.
Its basically taking "^x" and returning "" which is great when its ^1 and its coming back with the colour code, however when your server name is ulitmately seen as
"^4(^d^s) ^7Mercury Racing Team"
which becomes
"() Mercury Racing Team"
its not much help (would seem that ^d is \ and ^s would be /, creating the (\/) logo)
The ^d also causes the existing colour to become a non colour (outside the listed possibilities) so it looks a little messy.
I've managed to pull the colour code part out of the script, colour would be nice, but its not essential. Can someone think of an alternative method of going about the colour code script?
// Function to replace the ^x codes in the Host name to show correct colours on the screen
function format_host_colours($HostName){
for($i = 0; $i < strlen($HostName); $i++){
if(substr($HostName, $i, 1) == "^"){
$CharPos = strpos($HostName, "^", $i);
$ColNum = substr($HostName, strpos($HostName, "^", $i) + 1,1);
$ColourString = get_colour(substr($HostName, strpos($HostName, "^", $i) + 1,1));
if($i == "0"){
// If ^ found at the start of the host string remove the ^[num]
$TmpString = substr($HostName,$i+2);
// Add the html font code to the start of the string and append the
// variable $TmpString with the ^[num] removed
$HostName = "<font color='$ColourString'>".$TmpString;
}
else{
// Get the left part of the string to the next ^[num]
$LTmpString = substr($HostName,0,$i);
// Get the right part of the string after the ^[num]
$RTmpString = substr($HostName,$i+2);
// Add the html close font and add the new html colour to the end of the
// Left part of the string then add the right part of the string
$HostName = $LTmpString."</font><font color='$ColourString'>".$RTmpString;
}
}
}
// Close any html font tag left open in the above
$HostName = $HostName."</font>";
Return $HostName;
}
Ideally the colour code part would look for the ^, if its 2nd character is between 0-7 then run with it, if its x then replace it with z, everything else gets left as is.
Does any of that make sense? :pillepall :D
Victor
28th July 2006, 20:15
assuming you are basically trying to convert the ^x codes, I'll just paste what i use to convert hostnames / playernames into something html can display :
function WriteColor($str) {
codepage_convert ($str);
$foundstart = False;
$tmp = '';
for ($i = 0; $i < strlen(trim($str)); $i++) {
if (($str[$i] == '^') And (ereg("[0-8]", $str[$i+1]))) {
if (!$foundstart) {
$tmp .= '<FONT COLOR="'.getcolorcode($str[$i+1]).'">';
$foundstart = True;
} else {
$tmp .= '</FONT><FONT COLOR="'.getcolorcode($str[$i+1]).'">';
}
$i++;
} else if ($str[$i] == "^" && $str[$i+1] == 9) {
$tmp .= "</FONT>";
$i++;
} else {
$tmp .= $str[$i];
}
}
if ($foundstart) {
$str = $tmp.'</FONT>';
}
return $str;
}
function getcolorcode($type) {
switch ($type) {
case 0 : $type = "#000000"; return $type; Break;
case 1 : $type = "#FF0000"; return $type; Break;
case 2 : $type = "#00FF00"; return $type; Break;
case 3 : $type = "#FFFF00"; return $type; Break;
case 4 : $type = "#0000FF"; return $type; Break;
case 5 : $type = "#FF00FF"; return $type; Break;
case 6 : $type = "#00FFFF"; return $type; Break;
case 7 : $type = "#FFFFFF"; return $type; Break;
case 8 : $type = "#000000"; return $type; Break;
case 9 : $type = "#000000"; return $type; Break;
return $type;
}
}
function UnWriteColor($str) {
$tmp = '';
for ($i = 0; $i < strlen($str); $i++) {
if (($str[$i] == '^') And (ereg("[0-8]", $str[$i+1]))) {
$i+=1;
} else {
$tmp .= $str[$i];
}
}
$str = $tmp;
return $str;
}
function codepage_convert (&$str) {
global $cp_tables;
$newstr = "";
$current_cp = "L";
$len = strlen ($str);
for ($i=0; $i<$len; $i++) {
if ($str{$i} == "^" && is_array ($cp_tables[$str{$i+1}])) {
$i++;
$current_cp = $str{$i};
continue;
}
$decimal = ord ($str{$i});
if ($decimal > 127) $newstr .= sprintf ("&#%05d;", $cp_tables[$current_cp][$decimal]);
else $newstr .= $str{$i};
}
$str = $newstr;
}
// L = Latin 1
// G = Greek
// C = Cyrillic
// J = Japanese
// E = Central Europe
// T = Turkish
// B = Baltic
include ("/PATH TO LACATION OF/cp_unicode_tables.php");
$tr_ptrn = array ("/\^d/", "/\^s/", "/\^c/", "/\^a/", "/\^q/", "/\^t/", "/\^l/", "/\^r/", "/\^v/", "/\^\^/", "/</");
$tr_ptrn_r = array ("\\", "/", ":", "*", "?", "\"", "<", ">", "|", "^", "<");
that gives you all you need basically.
WriteColor ($hostorplayername) would convert all colors and also figure out the alternate codepage characters (basically what you want except one thing - read on)
UnWriteColor ($hostorplayername) strips all color codes and leaves the rest alone
I've left the ^d and ^s and so forth separate. You can do those with preg_replace :
preg_replace ($tr_ptrn, $tr_ptrn_r, $hostorplayername)
So in essence, to convert all special codes in a host or playername :
WriteColor (preg_replace ($tr_ptrn, $tr_ptrn_r, $hostorplayername))
glyphon
28th July 2006, 23:05
couple of fixes...
added a random time generator to the cache time between 120s and 360s, so if there are multiple racer stat images on one page, they won't all try to refresh the cached image at the same time.
I also added in template support, so that different images can be used.
LFS_online_check.php?name=glyphon&template=1
And remember to change the $idkey variable to your ID Key, or the script won't work.
also, a very handy little trick for people using apache servers...
add this to your .htaccess file. with this code, you'll be able to use check#.LFS_USERNAME.jpg to point to the script (with # being the template number)
RewriteEngine on
RewriteRule ^check([0-9]+)\.([A-Za-z0-9]+|.*)\.jpg$ /LFS_online_check.php?name=$2&template=$1 [nc,ns]
updated script (http://www.lfsforum.net/showthread.php?p=187491#post187491)
PaulC2K
29th July 2006, 16:33
assuming you are basically trying to convert the ^x codes, I'll just paste what i use to convert hostnames / playernames into something html can display :
function WriteColor($str) {
codepage_convert ($str);
$foundstart = False;
$tmp = '';
for ($i = 0; $i < strlen(trim($str)); $i++) {
if (($str[$i] == '^') And (ereg("[0-8]", $str[$i+1]))) {
if (!$foundstart) {
$tmp .= '<FONT COLOR="'.getcolorcode($str[$i+1]).'">';
$foundstart = True;
} else {
$tmp .= '</FONT><FONT COLOR="'.getcolorcode($str[$i+1]).'">';
}
$i++;
} else if ($str[$i] == "^" && $str[$i+1] == 9) {
$tmp .= "</FONT>";
$i++;
} else {
$tmp .= $str[$i];
}
}
if ($foundstart) {
$str = $tmp.'</FONT>';
}
return $str;
}
function getcolorcode($type) {
switch ($type) {
case 0 : $type = "#000000"; return $type; Break;
case 1 : $type = "#FF0000"; return $type; Break;
case 2 : $type = "#00FF00"; return $type; Break;
case 3 : $type = "#FFFF00"; return $type; Break;
case 4 : $type = "#0000FF"; return $type; Break;
case 5 : $type = "#FF00FF"; return $type; Break;
case 6 : $type = "#00FFFF"; return $type; Break;
case 7 : $type = "#FFFFFF"; return $type; Break;
case 8 : $type = "#000000"; return $type; Break;
case 9 : $type = "#000000"; return $type; Break;
return $type;
}
}
function UnWriteColor($str) {
$tmp = '';
for ($i = 0; $i < strlen($str); $i++) {
if (($str[$i] == '^') And (ereg("[0-8]", $str[$i+1]))) {
$i+=1;
} else {
$tmp .= $str[$i];
}
}
$str = $tmp;
return $str;
}
function codepage_convert (&$str) {
global $cp_tables;
$newstr = "";
$current_cp = "L";
$len = strlen ($str);
for ($i=0; $i<$len; $i++) {
if ($str{$i} == "^" && is_array ($cp_tables[$str{$i+1}])) {
$i++;
$current_cp = $str{$i};
continue;
}
$decimal = ord ($str{$i});
if ($decimal > 127) $newstr .= sprintf ("&#%05d;", $cp_tables[$current_cp][$decimal]);
else $newstr .= $str{$i};
}
$str = $newstr;
}
// L = Latin 1
// G = Greek
// C = Cyrillic
// J = Japanese
// E = Central Europe
// T = Turkish
// B = Baltic
include ("../../../lfsworld/php/inc/cp_unicode_tables.php");
$tr_ptrn = array ("/\^d/", "/\^s/", "/\^c/", "/\^a/", "/\^q/", "/\^t/", "/\^l/", "/\^r/", "/\^v/", "/\^\^/", "/</");
$tr_ptrn_r = array ("\\", "/", ":", "*", "?", "\"", "<", ">", "|", "^", "<");
that gives you all you need basically.
WriteColor ($hostorplayername) would convert all colors and also figure out the alternate codepage characters (basically what you want except one thing - read on)
UnWriteColor ($hostorplayername) strips all color codes and leaves the rest alone
I've left the ^d and ^s and so forth separate. You can do those with preg_replace :
preg_replace ($tr_ptrn, $tr_ptrn_r, $hostorplayername)
So in essence, to convert all special codes in a host or playername :
WriteColor (preg_replace ($tr_ptrn, $tr_ptrn_r, $hostorplayername))
include ("/PATH TO LACATION OF/cp_unicode_tables.php");
Kinda lost me anyway, but whats that?? Is this a file local to the LFSW server or something knocking about i could/should have installed local to myself.
For the time being ive just ripped out the colour code stuff, and got it to display our server name properly if thats what it returns, so our servername appears correct (in text) but everyone elses server is gonna have the ^ gubbins all over it still and theres no colours
Victor
29th July 2006, 16:41
whoops - that include was copied a bit too literally - should be
include ("/PATH TO LACATION OF/cp_unicode_tables.php");
and you can get that file from here where it is explained how to parse those codepages LFS supports :
http://www.lfsforum.net/showthread.php?t=3304&highlight=parsing+code
about colours in other hostnames - i can only suspect you don't run them through the color writing functions.
braxel
30th July 2006, 21:31
Hi again,
in post 52in this thread ( http://www.lfsforum.net/showthread.php?p=35947#post35947 ) there is a terrific working script to find who is online. I'm using this script and i love it. But there is one little problem with it i think. What about lfs users that have a space in their name? (e.g. like myself "Jos Belgium"). Is there a way to fix this? I've tried some things i could come up with (in the function trim_c_string in the if statement add something like " || $string[$x] == '(just a space here)'"
but i wasn't able to correct this...
Any help? I have the same problem with the script, when user have a space in his TEAMMEMBERNAME they dont show it when the user is online!
e.g.
$TeamMembers = array("braxel","benzinx","Bill Darkman");
$InGameName = array("Braxel","Benzin","Bill Darkman"");
Bill Darkman will never show onlne, all other works.
Sorry for my bad english!
glyphon
31st July 2006, 20:17
I've got a low priority request...could Track and Car data be added to the action=PST query?
Victor
1st August 2006, 15:49
not really sure what you mean. All pb's of that person?
glyphon
1st August 2006, 15:59
nah, nothing that elaborate. just the car/track currently being used if the person is online, or the car/track they were using the last time they were online...like on the racer stats page of LFSWorld.
see example pic.
Victor
1st August 2006, 16:03
k, let me think about that for the next version update
nikka
1st August 2006, 16:05
Also if he's not online, a timestamp for "last seen online" or something would be useful too..
glyphon
1st August 2006, 16:07
k, let me think about that for the next version update
thanks :D
glyphon
7th August 2006, 17:29
Update - v0.9
added support for identkey per user
I left out some information from the installation instruction (thanks banshee). I've updated the instructions and replaced the attached file, so any downloads after now will have the correct instructions.
For everyone that has already downloaded the file, here are the missing instructions...
6. .htaccess
A. No .htaccess file in the Public_HTML directory
Move the supplied .htaccess file to the public_html directory.
B. There is a .htaccess file already in the public_html directory
Open the supplied .htaccess file and copy the code.
Now open the existing .htaccess file in th public_html directory and paste the code.
Make sure there is only one line in the file that has "RewriteEngine on"
Group all lines that start with "RewriteRule" together
Made some fairly significant changes to the code of the script.
Added ability to set template selection to random
Reorganized the directory structure
Changed the way player stats is cached. Now cached as text data instead of as the generated graphic.
Units can now be set to metric or imperial units
Fixed bug that showed offline players as online when script tried to pull the live stats from the LFSWorld server too quickly after just pulling the stats
added switch command for formating user name on signature stats graphic.
changed how racing server names are displayed to fix bug that caused incorrect character to be displayed at times.
switched fonts used for Japanese text. (included)
banshee56
10th August 2006, 03:32
Glyphon, in the readme, you state:
also, through the use of the included .htaccess file, you can use the following url:
http://your-host/check#.LFSUSERNAME.jpg
ie, http://your-host/check1.glyphon.jpg
Shouldn't the url be "http://your-host/LFS_Checker/check1.glyphon.jpg" ??
glyphon
10th August 2006, 07:52
Glyphon, in the readme, you state:
Shouldn't the url be "http://your-host/LFS_Checker/check1.glyphon.jpg" ??
nope. assuming that you make the LFS_Checker folder in the root public_html folder of the webhost, then the "short" url would be http://your-host/check1.banshee56.jpg
if you changed the name of the "LFS_Checker" folder, or place it in a different folder, then you'd have to edit the .htaccess file so that the "short" url would still work, and even then it would be http://your-host/check1.banshee56.jpg :)
banshee56
10th August 2006, 12:09
I entered the url as you typed it (with my web address) within the IMG tags on various forum sigs, and it did not work until I added the "LFS_Checker" to the address. I did not change the file structure and the folder was installed in my website root directory.
One thing that was missing was the rewrite line you posted several posts up as needed in the htaccess file. After I added that, everything worked. :shrug:
glyphon
10th August 2006, 14:34
One thing that was missing was the rewrite line you posted several posts up as needed in the htaccess file. After I added that, everything worked. :shrug:
Oh, you are right...i included the rewrite line in a .htaccess file, but in the zip file it would get uploaded into the LFS_Checker folder, but the code in that file needs to get added to the .htaccess file in the public_html directory.:doh:
good catch. thanks :thumb:
banshee56
10th August 2006, 16:57
Another thing that has me baffled: I tested both versions (off & online) and only the offline image shows. When I went online to see if the online image shows, I only get the url of the PHP, and not the image. I created two different images, named per the instructions, and based on the template. I've looked through the PHP file and can find no reasons why the online wouldn't show. Any ideas?
glyphon
10th August 2006, 19:32
I've looked through the PHP file and can find no reasons why the online wouldn't show. Any ideas?
try and pull up the stats for someone online. then if it displays the same issue, go into the cache directory and open up the cache file for that person. are there any error messages? if there are no error messages, and the cache file has stats in it, then the problem is with the image file. double check the spelling of the online file. also make sure that its a .png file.
if everything is correct, then PM the url to me so i can see if i can figure out what's going on.
banshee56
10th August 2006, 20:02
I can tell you already that the spelling is the same. I checked specifically for that and for the png file format. I know the image is good as it is exactly the same as the offline image, except for one color. I used the same working XAR (Xara Xtreme graphics package) file to create both images.
I will go online tonight and then check for the image to show and then check the cache file for errors.
One other note, I used the userNameSwitch.php file to have my name show up the same as my ingame name. Does this matter?
Also, If I wanted to create these for all my teammates, all I would have to do is to create an LFS_Checker folder for each member and get the ident key from them, correct? Is there a simpler way?
glyphon
10th August 2006, 20:42
the userNameSwitch.php is only necessary if you want the name that displays on the graphic to be different somehow from your actual LFS user name.
for example, one of the guys that is using this registered as mini z, but later decided he didn't like that name, so changed the ingame name to rotary power. but if you try to pull rotary power, nothing comes up. so this is where the userNameSwitch.php file comes into play.
it uses mini z to pull the statistics from the LFS servers, but the name that is displayed on the graphic is rotary power.
like wise, i'm assuming your LFS username is banshee56, but if you wanted the graphic to show [CORE]Banshee56, you'd use the userNameSwitch file.
also, the name variable is case-insentive, BaNshEE56 is basically the same as banshee56. the only difference between the two is how they are displayed on the graphic. both pull the same stats. make sense?
and as for each teammate, all you have to do is change the username in the url (and the template number if you wish, but not necessary).
now, for the ident key...what i'm doing right now is just using my key for all my friends that are using the script (they are just linking the code on my page and putting there username in). Which is fine, except for the "who's online" page that displays all of these graphics on one page, because the LFS server that the stats are pulled from only allows access from one ident key every 5 seconds...so on a page with 6 graphics, that could take ~30 seconds to load them all.
but i just thought of a solution to that. so for now, just let them use your ident key (they won't ever see it), and i'll get a new version out later today or tomorrow (or you could purchase some credits and go with premium access, which has no delay on multiple access.
in short, no, only one folder.
for multiple users, just do the following...
http://your-host/check#.glyphon.jpg
http://your-host/check#.banshee56.jpg
http://your-host/check#.Victor.jpg
...
and keep me updated as to what happens with the online graphic. (make sure its permission is set to 644).
glyphon
10th August 2006, 22:08
2nd attempt...
new version up.
to update, replace LFS_online_check.php with new version, and add identKeys.php to inc/ folder, and then edit with appropriate info.
also, it seems that the Pubstat tarpit (5sec delay) is based off of IP address, and not $identykey (Victor, correct me if i'm wrong), so if the delay really bugs you, go with the premium pubstats. its insanely cheap. each access of my script uses ~50b, and it costs $(gbp)0.0015/mb.
banshee56
11th August 2006, 01:02
Ok, I think I know what I did. I added a variable statement to change the stats font styles in the last group of "imagegettftext" statements. I moved the variable declaration to a place earlier in the file. It works now. I also made a couple of changes to not show the fuel burnt, but rather to show 3rd place finishes and races finished. I also changed the description of "1st" to wins.
Here is the file I have with changes to fonts and the stats shown:
<?php
@extract($_GET);
//If the LFS player name has changed since registering LFS, edit the below file to
//display the correct name and pull the correct stats.
include ("inc/userNameSwitch.php");
//If the template isn't explicitly set as a variable, set it to the default template.
if (!isset ($template) || empty($template)) {
$template = 1;
}
//Reads the number of files in the images directory.
$files = (getDirFiles("images/")) ;
function getDirFiles($dirPath){
if ($dirPath[strlen($dirPath)] != "/")
$dirPath .= "/";
if ($handle = opendir($dirPath)) {
while (false !== ($file = readdir($handle)))
if ($file != "." && $file != ".." && (!is_dir($dirPath . $file))) {
$filesArr[] = trim($file);
};
closedir($handle);
}
return $filesArr;
}
//Calculates the number of unique templates in the images directory.
if ($template == "R") {
$i = count($files);
$i = ($i / 2);
$template = rand(1,$i);
}
//Checks to see if the set template number exists. if not, use default template.
$offline = "images/lfs_check_offline".$template.".png";
$online = "images/lfs_check_online".$template.".png";
if (!file_exists($offline)) {
$offline = "images/lfs_check_offline1.png";
$online = "images/lfs_check_online1.png";
}
if (!file_exists($online)) {
$offline = "images/lfs_check_offline1.png";
$online = "images/lfs_check_online1.png";
}
//UserNames with spaces was breaking the LFS query, so this fixes it.
$name = str_replace(" ", "%20",$name);
$cachefile = 'cache/'.$name.'_cached.php';
//setup random cachetime
$randTime = rand(2,6);
$cachetime = $randTime * 60;
// Serve from the cache if it is younger than $cachetime
if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
$url = $cachefile;
$stream = file_get_contents( $url );
$stats = explode( "\n", $stream );
} else {
$ver = '1.2';
$act = 'pst';
$host = 'http://www.lfsworld.net';
$path = '/pubstat/get_stat2.php';
$query = "?version=$ver&action=$act&racer=";
$idkey = "&idk=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$url = $host . $path . $query . $name . $idkey;
$stream = file_get_contents( $url );
$stats = explode( "\n", $stream );
$calendar = date("M.d.Y ");
$tzMod = 3;
$hour = date("g") + $tzMod;
$time = date(":i a");
$date = $calendar . $hour . $time;
//if refresh too soon is returned, read the cached file.
//if cached file doesn't exist, check LFS server for stats every 5 seconds
if ($stats[0] == "can't reload this page that quickly after another"){
if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
$url = $cachefile;
$stream = file_get_contents( $url );
$stats = explode( "\n", $stream );
} else {
while ($stats[0] == "can't reload this page that quickly after another"){
sleep(5);
$ver = '1.2';
$act = 'pst';
$host = 'http://www.lfsworld.net';
$path = '/pubstat/get_stat2.php';
$query = "?version=$ver&action=$act&racer=";
$idkey = "&idk=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$url = $host . $path . $query . $name . $idkey;
$stream = file_get_contents( $url );
$stats = explode( "\n", $stream );
}
// Cache the output to a file after receiving the live stats.
$fp = fopen($cachefile, 'w');
fwrite($fp, $stream."\n<--cached-->\n".$date);
fclose($fp);
}
} else {
// Cache the output to a file when reading live stats.
$fp = fopen($cachefile, 'w');
fwrite($fp, $stream."\n<--cached-->\n".$date);
fclose($fp);
}
}
//function for converting foreign texts for display on the graphic.
function codepage_convert ($str) {
global $cp_tables;
$newstr = "";
$current_cp = "L";
$len = strlen ($str);
for ($i=0; $i<$len; $i++) {
if ($str{$i} == "^" && is_array ($cp_tables[$str{$i+1}])) {
$i++;
$current_cp = $str{$i};
continue;
}
$decimal = ord ($str{$i});
if ($decimal > 127) $newstr .= sprintf ("&#%05d;", $cp_tables[$current_cp][$decimal]);
else $newstr .= $str{$i};
}
return $newstr;
}
//function that returns the current codepage of a given text.
function codepage_setting ($str) {
global $cp_tables;
$newstr = "";
$current_cp = "L";
$len = strlen ($str);
for ($i=0; $i<$len; $i++) {
if ($str{$i} == "^" && is_array ($cp_tables[$str{$i+1}])) {
$i++;
$current_cp = $str{$i};
}
}
return $current_cp;
}
// Code page indicators
// ^L = Latin 1
// ^G = Greek
// ^C = Cyrillic
// ^J = Japanese
// ^E = Central Europe
// ^T = Turkish
// ^B = Baltic
include ("inc/cp_unicode_tables.php");
// Function to remove the colour code data from a string
function remove_colour_codes($String){
$ColCodes = array("^0","^1","^2","^3","^4","^5","^6","^7","^8","^9");
$NewString = str_replace($ColCodes, "",$String);
return $NewString;
}
$tr_ptrn = array ("/\^d/", "/\^s/", "/\^c/", "/\^a/", "/\^q/", "/\^t/", "/\^l/", "/\^r/", "/\^v/", "/\^\^/", "/</");
$tr_ptrn_r = array ("\", "/", ":", "*", "?", "\"", "<", ">", "|", "^", "<");
// sets Units for Fuel and Distant to either metric or imperial
if ($units == "metric") {
//Convert distance to km, add comna, no decimals
$distDrvn = number_format($stats[0] * .001, 0, ".", ","). " km";
//Convert fuel to liters, add comma, no decimals
$fuel = number_format($stats[1] * .01, 0, ".", ",") . " L";
} else {
//Convert distance to miles, add comna, no decimals
$distDrvn = number_format($stats[0] * .000621371, 0, ".", ","). " miles";
//Convert fuel to gallons, add comma, no decimals
$fuel = number_format($stats[1] * .00264172, 0, ".", ",") . " gal";
}
//Stats, add comma, no decimals
$laps = number_format($stats[2], 0, ".", ",") . " laps";
$wins = number_format($stats[4], 0, ".", ",") . " wins";
$second = number_format($stats[5], 0, ".", ",") . " 2nd";
$third = number_format($stats[6], 0, ".", ",") . " 3rd";
$races = number_format($stats[7], 0, ".", ",") . " races";
$poles = number_format($stats[9], 0, ".", ",") . " poles";
$statfont = "fonts/verdana.ttf";
if ($stats[0] == "pst: no valid username") {
header("content-type: image/jpeg");
$im = imagecreatetruecolor(100,10);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
$font = "fonts/SERPNTBI.TTF";
$text = "invalid username";
imagettftext($im, 8, 0, 1, 9, $black, $font, $text);
imagegif($im);
imagedestroy($im);
unlink($cachefile);
exit;
} elseif ($stats[13] == "0") {
$offlineTxt1 = "is not";
$offlineTxt2 = "racing";
$offlineTxt3 = "online";
header("content-type: image/jpeg");
$font = "fonts/SERPNTBI.TTF";
$statfont = "fonts/verdana.ttf";
$im = imagecreatefrompng($offline);
$white = imagecolorallocate($im, 255,255,255);
$black = imagecolorallocate($im, 0,0,0);
//Add stats to graphics
$grey = imagecolorallocate($im, 175,175,175);
imagettftext($im, 6, 0, 330, 65, $grey, $font, $stats[16]);
imagettftext($im, 6, 0, 315, 75, $grey, $font, $stats[17]);
imagettftext($im, 15, 0, 11, 24, $black, $font, $user);
imagettftext($im, 15, 0, 10, 23, $white, $font, $user);
imagettftext($im, 10, 0, 11, 41, $black, $font, $offlineTxt1);
imagettftext($im, 10, 0, 11, 56, $black, $font, $offlineTxt2);
imagettftext($im, 10, 0, 11, 71, $black, $font, $offlineTxt3);
imagettftext($im, 10, 0, 10, 40, $white, $font, $offlineTxt1);
imagettftext($im, 10, 0, 10, 55, $white, $font, $offlineTxt2);
imagettftext($im, 10, 0, 10, 70, $white, $font, $offlineTxt3);
imagettftext($im, 7, 0, 85, 36, $black, $statfont, $distDrvn);
imagettftext($im, 7, 0, 85, 45, $black, $statfont, $laps);
imagettftext($im, 7, 0, 85, 55, $black, $statfont, $races);
imagettftext($im, 7, 0, 170, 36, $black, $statfont, $wins);
imagettftext($im, 7, 0, 170, 45, $black, $statfont, $second);
imagettftext($im, 7, 0, 170, 55, $black, $statfont, $third);
imagejpeg($im,"",90);
imagedestroy($im);
} else {
//If online, create online graphic
$onlineTxt1 = "is racing";
$onlineTxt2 = "online";
header("content-type: image/jpeg");
$font = "fonts/SERPNTBI.TTF";
$kana = $font;
$fontSize = 8;
$im = imagecreatefrompng($online);
$white = imagecolorallocate($im, 255,255,255);
//if server name is available, adds server name to graphic
if (!empty ($stats[14])) {
$server = remove_colour_codes($stats[14]);
$cp = codepage_setting($server);
if ($cp == "J"){
//$kana = "fonts/msgothic.ttf";
$kana = "fonts/verdana.ttf";
$fontSize = 8;
}
$serverList = codepage_convert($server);
$serverList = preg_replace ($tr_ptrn, $tr_ptrn_r, $serverList);
imagettftext($im, 7, 0, 85, 64, $black, $statfont, "racing on");
imagettftext($im, $fontSize, 0, 85, 74, $black, $kana, $serverList);
}
//Add stats to graphics
$grey = imagecolorallocate($im, 175,175,175);
imagettftext($im, 6, 0, 330, 65, $grey, $font, $stats[16]);
imagettftext($im, 6, 0, 315, 75, $grey, $font, $stats[17]);
imagettftext($im, 15, 0, 11, 24, $black, $font, $user);
imagettftext($im, 15, 0, 10, 23, $white, $font, $user);
imagettftext($im, 10, 0, 11, 41, $black, $font, $onlineTxt1);
imagettftext($im, 10, 0, 11, 56, $black, $font, $onlineTxt2);
imagettftext($im, 10, 0, 10, 40, $white, $font, $onlineTxt1);
imagettftext($im, 10, 0, 10, 55, $white, $font, $onlineTxt2);
imagettftext($im, 7, 0, 85, 36, $black, $statfont, $distDrvn);
imagettftext($im, 7, 0, 85, 45, $black, $statfont, $laps);
imagettftext($im, 7, 0, 85, 55, $black, $statfont, $races);
imagettftext($im, 7, 0, 170, 36, $black, $statfont, $wins);
imagettftext($im, 7, 0, 170, 45, $black, $statfont, $second);
imagettftext($im, 7, 0, 170, 55, $black, $statfont, $third);
imagejpeg($im,"",90);
imagedestroy($im);
}
?>
I will merge my changes with your new file.
Nice work BTW, I really like this sig.
glyphon
11th August 2006, 02:33
Nice work BTW, I really like this sig.
Thanks, and glad you got it figured out. it would have taken me a while to figure that out without knowing you changed it :D
Phlos
12th August 2006, 15:47
Is it possible to get WHOLE LFS username database with account license type please ? :)
Dygear
12th August 2006, 17:22
Is it possible to get WHOLE LFS username database with account license type please ? :)
Sounds like a security problem almost. Reminds of me AOL's search query.
I don't see why not tho. I would like to also see sign up dates, and times.
You can't put in The First name and Last name, and that's really to bad, as I could use that for SimFIA.
arco
16th August 2006, 18:28
Update - v0.9
Great script glyphon, I really like it! :)
One question, is it possible to have the racernames shown with their original colors?
matuka
17th August 2006, 02:23
Please helpme !!
No showme nothing.. :(
Only showme:
he page cannot be found
I make the LFS_Checker folder en the root web site and i typing http://mihost/check#.matuka.jpg but.. nothing...
glyphon
17th August 2006, 13:13
Great script glyphon, I really like it! :)
One question, is it possible to have the racernames shown with their original colors?
maybe, but because of the way that the text is written onto the graphic, the solution isn't readily apparenty to me. I could easily figure out how to make the text the color if there is only one color used, or the first color in multiple color names, but switching colors...that's a bit more tricky (and when i say a bit, i mean a lot). but i'll look into it.
Please helpme !!
No showme nothing.. :(
Only showme:
he page cannot be found
I make the LFS_Checker folder en the root web site and i typing http://mihost/check#.matuka.jpg but.. nothing...
are you typing check#.matuka.jpg, or are you putting a number in the place of the #?
maybe this is a cultural thing (and if it is, i'm sorry), but the # is a place holder, kind of like a variable, that means a number should go there. for example, a valid address would be check1.matuka.jpg.
does that make sense? if you are still having problems, let me know and i'll try and help you fix them.
and thanks :D
arco
17th August 2006, 16:29
maybe, but because of the way that the text is written onto the graphic, the solution isn't readily apparenty to me. I could easily figure out how to make the text the color if there is only one color used, or the first color in multiple color names, but switching colors...that's a bit more tricky (and when i say a bit, i mean a lot). but i'll look into it.
Thanks, if you get it to work that would be arwsome!
filur
17th August 2006, 18:07
.. but switching colors...that's a bit more tricky
Allocate all the standard LFS colors, print each character in the name separately with the current color.
colors = array (
0 = imagecolorallocate( .. black )
1 = .. red
..
)
name = str_split(name)
currentcolor = default color
x = start x
y = start y
for (i = 0; i<=strlen(name); i++)
if (name[i] == "^" && preg_match("/[0-8]/", name[i+1])) {
currentcolor =& colors[i+1]
i += 2
}
imagestring(image, font, x, y, name[i], currentcolor)
x += char spacing x
}
glyphon
17th August 2006, 19:59
excellent. thanks filur! :thumb:
Knarf
19th August 2006, 15:25
I have a question about the hightlight page.
Is there a possibility to add timestamps to it ?
The reason is that I created a java program that calls pubstat every x minutes to fetch pb's of my league members. It then generates a php file (with some extra stuff to show in realtime if someone is online, and where...) and uploads it.
I recently added some stuff fetched from the highlights page (under the header "Laatst gereden pb's"). But it would be nice to also have a date when those pb's where driven.
http://www.vrl-simracing.be/lfs_pb/results.php
PaulC2K
5th September 2006, 11:12
Does anyone happen to have a basic php scripts to do various bits n peices with the LFSW stats?
Im hopeless when it comes to getting the info, but if i have a script that does the basic job then im fine at making it do whatever im looking for it to do, its just getting there that im unable to manage.
I've tried contacting Anachy-H but he seems to have gone AWOL the last 2 months, i had planned to try his LFSW-PPF thingie but i cant get 'PEAR' installed and i've been waiting to hear from him but im guessing he's got computer/internet issues or something, so i was wondering if anyone had any kind of solution to my problems.
Im sure im not the only person looking for something able to pull info for use on a team website, and with very limited coding knowledge it'd be a great help if there were a couple of very basic scripts to pull info like PB/HL times, Online status and stuff like this.
Its the HLVC/PB stats im personally looking for, but if there were other basic scripts for popular stats then im sure many like myself would appreciate this help in getting started.
St4Lk3R
5th September 2006, 12:21
Hi Paul,
I recently created a script that receives a racers personal stats from lfsw and creates a status-image for forum-signatures. I think this will explain pretty good how to do a connection to lfsw and it also does a bit of caching.
You may want to look at it here:
http://www.stalkernet.info/source/lfsstatus/index.php
If you want to get hotlap-data, you will possibly have to filter $iter == 0 and then explode the next received line. like this:
$content = array();
while($line = fgets($lfswconn)) {
// Filter unneeded entries - Chunk size
if($iter != 0) {
$content[] = $line;
}
$iter++;
}
foreach($content as $hl) {
$data = explode(" ", $content);
}
Greets, Stalker
glyphon
5th September 2006, 14:25
I recently created a script that receives a racers personal stats from lfsw and creates a status-image for forum-signatures. I think this will explain pretty good how to do a connection to lfsw and it also does a bit of caching.
You may want to look at it here:
http://www.stalkernet.info/source/lfsstatus/index.php
looks like an early version of my script :D
(functionally that is. your code is very different from mine :nod:)
Dygear
14th September 2006, 06:57
It would be nice if we could get the hole database from lfsworld in one go. That would be tarpitted for a whole day. You could gzip file the and place it on the server. Then with cron, update it evey 24 hours. It would save some querys, and it might save some bandwith in the long run too.
the_angry_angel
14th September 2006, 08:04
It would be nice if we could get the hole database from lfsworld in one go. That would be tarpitted for a whole day. You could gzip file the and place it on the server. Then with cron, update it evey 24 hours. It would save some querys, and it might save some bandwith in the long run too.I recently asked Victor a very similar question via pm. Something that I hadn't really considered was the actual player size of LFS - theres a lot of 'em, and dumping them to csv / other format and then gzipping it wouldnt be particularly economical.
Plus Victor's stated he'd prefer the pubstats to be "live" - which didnt really bother me for my project.
Dygear
14th September 2006, 12:12
I recently asked Victor a very similar question via pm. Something that I hadn't really considered was the actual player size of LFS - theres a lot of 'em, and dumping them to csv / other format and then gzipping it wouldnt be particularly economical.
Plus Victor's stated he'd prefer the pubstats to be "live" - which didnt really bother me for my project.
24 hours is still pretty live. That said, I know it's alot of data, but really how much? 30MB?
the_angry_angel
14th September 2006, 12:33
24 hours is still pretty live. That said, I know it's alot of data, but really how much? 30MB?*shrugs* No idea tbh. Having that much data would allow you to do some interesting stuff with it though.
filur
14th September 2006, 13:01
A database dump would make some stuff simpler for sure, maybe a dump exluding detailed race results could work? I'm thinking about writing something to show statistics on overall team progress, with FLP's meager 6 members it'll still be hundreds of queries.
I could live with such a thing being tarpitted an entire week. :)
Getting a dump of all players in <team> would also be great if a complete one isn't happening.
the_angry_angel
14th September 2006, 13:11
A database dump would make some stuff simpler for sure, maybe a dump exluding detailed race results could work? I'm thinking about writing something to show statistics on overall team progress, with FLP's meager 6 members it'll still be hundreds of queries.:nod: I've been thinking about throwing together something like that, with hotlaps and pbs and stuff, generating + / - % differences, and pretty graphs and stuff for pbs and hotlaps, possibly team size growth (with child-ish league tables based on the results), etc. and mashing it together with links to and from lfsworld and the forums - but its simply not possible with the current system.
I could live with such a thing being tarpitted an entire week. :)Hell yeah. I could probably cope with per-month tbh. I'm specifically thinking something along the lines of Planetarion's old dump's (csv files dumped out, and then gzipped; although this is rather different from what they do now). Although, I'd be perfectly happy with most formats, as long as its well documented :)
Btw Victor, sorry I never got around to actually responding to your pm about this - it kinda got pushed to the bottom of the pile and then I forgot about it until now :s
Dygear
16th September 2006, 00:04
I've gotten part way on the team stats that I co-made with traxxion, traxxion comming up with the original idea. At the end of the day, I'd like to know alot more about the racer so that I can better get information on them. SimFIA's racer db files are built like so.
function write_user_cache($LFSName)
{
$LFSWName = str_replace(' ', '%20', $LFSName);
sleep(5);
$data = file("http://www.lfsworld.net/pubstat/get_stat2.php?version=1.2&idk=8Kz5s8x5PMl7JwImr4VtYX3K99S9s5bf&action=pst&racer=${LFSWName}");
$array['OS']['DIST'] = $data[0];
$array['OS']['FULE'] = $data[1];
$array['OS']['LAPS'] = $data[2];
$array['OS']['JOIN'] = $data[3];
$array['OS']['WINS'] = $data[4];
$array['OS']['SECO'] = $data[5];
$array['OS']['THIR'] = $data[6];
$array['OS']['FINS'] = $data[7];
$array['OS']['QUAL'] = $data[8];
$array['OS']['POLE'] = $data[9];
$array['OS']['CRED'] = $data[10];
$array['OS']['DRAG'] = $data[11];
$array['OS']['DWIN'] = $data[12];
$array['OS']['ONLI'] = $data[13];
$array['OS']['HOST'] = $data[14];
sleep(5);
foreach(file("http://www.lfsworld.net/pubstat/get_stat2.php?version=1.2&idk=8Kz5s8x5PMl7JwImr4VtYX3K99S9s5bf&action=hl&racer=${LFSWName}") as $data)
{
$info = explode(' ', $data);
$array['HL'][] = array('ID_HL' => $info[0], 'TRACK' => $info[1], 'CAR' => $info[2], 'TIME' => $info[3], 'FLAGS' => $info[4]);
}
sleep(5);
foreach(file("http://www.lfsworld.net/pubstat/get_stat2.php?version=1.2&idk=8Kz5s8x5PMl7JwImr4VtYX3K99S9s5bf&action=pb&racer=${LFSWName}") as $data)
{
$info = explode(' ', $data);
$array['PB'][] = array('TRACK' => $info[0], 'CAR' => $info[1], 'TIME' => $info[2], 'LAPS' => $info[3]);
}
file_put_contents("./cache/{$LFSName}.txt", serialize($array));
return $array;
}
function read_user_cache($LFSName)
{
$Path = "./cache/{$LFSName}.txt";
if (file_exists($Path))
return unserialize(file_get_contents($Path));
else
return write_user_cache($LFSName);
}
filur
16th September 2006, 01:33
Very neat Dygear, but it needs a bit more class.
http://lur.h1x.com/plaintext/classy_pst.php :razz: :)
Dygear
16th September 2006, 02:45
:) I am making a classy PHP5 Live For Speed SDK. Want to help me on it?
Oh and while I have your ear, try using complex strings.
file_get_contents("{$this->pubstatURL}&c=2&idk={$this->idKey}&action={$action}&racer={$racer}");
If they would open that up for premium stats only I would sign up for it, even with a one day tar pit.
Dygear
26th October 2006, 09:25
Could you please include split times in the wr action. &splits=true
jscorrea
26th October 2006, 13:09
How to get all information data of the hosts?
In the partial code below shows me only racers and hosts.
// parse the data
while ($x < $len) {
$hostname = "";
$nr_racers = 0;
for ($y=0; $y<32; $y++) $hostname .= $hostlist[$x++];
$hostname = trim_c_string ($hostname);
$x += 20; // skip some host-data
$nr_racers = ord ($hostlist[$x++]);
for ($w=0; $w<$nr_racers; $w++) {
$username = "";
for ($y=0; $y<24; $y++) $username .= $hostlist[$x++];
$users[trim_c_string ($username)] = $hostname;
}
}
JS
paXton
28th October 2006, 01:46
How to get all information data of the hosts?
Adapted from Anarchi's LFSW-PPF (http://dsrc.digiserv.net/forum/showthread.php?t=547), I use the following code:
function getHost($hostname)
{
$rawList = array();
$file = file_get_contents("http://www.lfsworld.net/pubstat/get_stat2.php?version=1.2&user=" . LFS_USER . "&pass=" . md5(LFS_PASS) . "&action=hosts&c=2&ps=" . LFSW_PREMIUM_PUBSTAT);
if (isLFSWorldError($file)) return 0;
$rawList = @gzuncompress($file);
while(true)
{
//grab the next chunk of host data
$blob = substr($rawList, $offset, 53);
//If it's less than 53 then it can't be valid
if(strlen($blob) == 53)
{
//(Re-)Init tmp arrays to parse into
$data = $racers = array();
//Min len is 53. Parse and advance the offset to the end of this chunk
$data = unpack('a32hostName/c1serverType/c1majorVersion/c1minorVersion/c1testVersion/c1track/c1config/c1reversed/c1maxPlayers/L1cars/L1rules/c1laps/c1qualifyMins/x2/c1players', $blob);
$offset+= 53;
//Extract the entire player chunk, split it in to smaller chunks of 24, and explode
$racers = explode('&', chunk_split(substr($rawList, $offset, $data['players']*24), 24, '&'));
//This method always adds an empty entry so just pop it off
array_pop($racers);
//Trim the guff and advance the offset to the next chunk
$racers = array_map('rtrim', $racers);
$offset += $data['players']*24;
/*
//Laps parsing.
$data['hours'] = 0;
//Check if laps are literal
if($data['laps'] > 100)
{
if($data['laps'] < 191)
{
//Laps are in 10 step increment range (101-191)
$data['laps'] = (($data['laps'] - 100) * 10) + 100;
}
else
{
//Laps are hours
$data['hours'] = $data['laps'] - 190;
$data['laps'] = 0;
}
}
*/
//Formatting
//Compound the 3 integers that make up the track in to 1 var and dump the excess
$data['track'] = $data['track'].$data['config'].$data['reversed'];
unset($data['config'], $data['reversed']);
//Put the racers in the output
$data['playerNames'] = implode('&',$racers);
//Version formatting
$data['majorVersion'] /= 10;
$data['minorVersion'] = chr($data['minorVersion']);
if($data['hostName']==$hostname) return $data;
}
else
{
break;
}
}
return 0;
}
I'm not sure if it's 100% correct, but it's working for me. I'm only a PHP beginner.
Pascal aka paXton
Dygear
15th December 2006, 05:48
<?php
function isLFSWorldError($string)
{
switch(trim(substr($string, 0, 50)))
{
case 'Identification is required - http://www.lfsforum.net/showthread.php?t=14480':
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;
}
?>
Dygear
7th December 2009, 05:36
<?php
function isLFSWorldError($string)
{
switch(trim(substr($string, 0, 50)))
{
case 'Identification is required - http://www.lfsforum.net/showthread.php?t=14480':
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;
}
?>
Sorry, for the huge massive bump, but is this still correct for all of the errors that LFSW outputs?
seriously, the currently biggest premium pubstat spender spends less than 10 pennies a month. Being concerned about $$$ really is exaggerated.
I wonder who is the biggest spender now ... I would think it would have to be me, what with me giving out my key with the LFSWorldSDK.
Victor
16th December 2009, 16:02
I can find these additional error messages :
Invalid Ident-Key
not authed (invalid identkey)
not authed (ip)
Invalid login details provided
No authentication method provided.
You shouldn't flood me! You're locked out for 15 minutes now. DO NOT make your program do its requests as fast as it can, until the tarpit is over...
hl_log is only available since version 1.2 and later
And no you're not the 'biggest spender' :) There are a number of bigger spenders in fact.
Some counters for December for interest :
2,507,144 requests (~1.74 per second)
41,907.23 MB (~29.73KB/s)
morpha
16th December 2009, 16:28
Sorry, for the huge massive bump, but is this still correct for all of the errors that LFSW outputs?
Just noticed the first case can never occur, it's 75 characters and can never match a 50 char string :razz:
<?php
function isLFSWorldError($string)
{
switch(trim(substr($string, 0, 149)))
{
case 'Identification is required - http://www.lfsforum.net/showthread.php?t=14480':
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 'Invalid Ident-Key':
case 'not authed (invalid identkey)':
case 'not authed (ip)':
case 'Invalid login details provided'
case 'No authentication method provided.':
case 'You shouldn\'t flood me! You\'re locked out for 15 minutes now. DO NOT make your program do its requests as fast as it can, until the tarpit is over...':
case 'hl_log is only available since version 1.2 and later':
case '':
return true;
}
return false;
}
Dygear
18th December 2009, 07:19
Just noticed the first case can never occur, it's 75 characters and can never match a 50 char string :razz:
Yep, feel like a bit of a boob right now :). Fixed in my version :) 1.9.5 might come out sooner then I thought.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.