http://www.lfsworld.net/pubstat/get_stat2.php?version=1.3&idk=<MY ID KEY>&action=pst&racer=jscorrea
typedef struct {
char LFSMPR[6]; // 0 : do not read file if no match
byte game_version; // 6 : ignore
byte game_revision; // 7 : ignore
byte MPR_version; // 8 : ignore
byte immediate_start; // 9 : joined already running game
byte reserved1; // 10 : -
byte reserved2; // 11 : -
int rules; // 12 : -
int flags; // 16 : -
byte laps_byte; // 20 : laps / hours (see notes)
byte skill; // 21 : skill level (0,1,2,3,4)
byte wind; // 22 : 0=off 1=weak 2=strong
byte num_players; // 23 : players at start of race
char LFS_version[8]; // 24 : text, ends 0
char short_track_name[4]; // 32 : e.g. BL2R
int start_time; // 36 : seconds since 00:00 1/1/1970
char track_name[32]; // 40 : text, ends 0
byte config; // 72 : 1,2,3.. (first config is 1)
byte reversed; // 73 : 0=no 1=yes
byte weather; // 74 : 0,1,2.. (first weather is 0)
byte num_finished; // 75 : players in results table
int zero; // 76 : -
} __attribute__ ((packed)) MPR_HEADER;
typedef struct {
char player_name[24]; // 0 : text, ends 0, no colours
char number_plate[8]; // 24 : text, NOTE : NO ZERO AT END
char short_car_name[4]; // 32 : text, ends 0
byte zero1[24]; // 36 : -
word laps_done; // 60 : total laps completed
word player_flags; // 62 : driver settings (see NOTES)
byte confirm_flags; // 64 : penalties (see NOTES)
byte number_of_stops; // 65 : pit stops count
word penalty_seconds; // 66 : penalty time added
int overall_time; // 68 : milliseconds
int best_lap_time; // 72 : milliseconds
int zero2; // 76 : -
} __attribute__ ((packed)) RESULT_INFO;
typedef struct {
word username_info_ident; //always 0x73C
byte unknown[3];
char player_name[24];
char number_plate[8];
char lfs_username[24];///this is my dream LOL
} __attribute__ ((packed)) LFS_USERNAME_INFO;
<?php
function data($file)
{
$areas = array("Blackwood" => "BL", "South City" => "SO", "Fern Bay" => "FE", "Autocross" => "AU", "Aston" => "AS", "Kyoto Ring" => "KY", "Westhill" => "WE");
$rp = fopen($file, "rb");
if(fread($rp, 6) == "LFSMPR")
{
fread($rp, 14);
$r["laps"] = hexdec(bin2hex(fread($rp, 1)));
$r["skill"] = hexdec(bin2hex(fread($rp, 1)));
$r["wind"] = hexdec(bin2hex(fread($rp, 1)));
$r["started"] = hexdec(bin2hex(fread($rp, 1)));
$r["version"] = trim(fread($rp, 8));
$r["track"] = trim(fread($rp, 4));
$r["stime"] = hexdec(bin2hex(fread($rp, 4)));
$area = trim(fread($rp, 32));
$config = hexdec(bin2hex(fread($rp, 1)));
$reversed = hexdec(bin2hex(fread($rp, 1)));
$r["ilm"] = hexdec(bin2hex(fread($rp, 1)));
$finished = hexdec(bin2hex(fread($rp, 1)));
$r["finished"] = $finished;
fread($rp, 4);
$fastestlap=9999999;
for($i = 0;$i < $finished; $i++)
//$i > $finished
{
$o[$i]["driver"] = trim(fread($rp, 24));//player name
$o[$i]["plate"] = trim(fread($rp, 8));// plate
$o[$i]["auto"] = trim(fread($rp, 4));//car name
fread($rp, 24);
$o[$i]["laps_c"] = hexdec(bin2hex(fread($rp, 2)))/256;//laps completed
fread($rp, 2);
$o[$i]["maha"] = fread($rp, 1);//confirm flags
$o[$i]["pits"] = hexdec(bin2hex (fread($rp, 1). $pits[$i]));//n pits
fread($rp, 1);
fread($rp, 1);
$o[$i]["ttime"] = hexdec(bin2hex(fread($rp, 4)));//total time
$o[$i]["btime"] = hexdec(bin2hex(fread($rp, 4)));//best time
fread($rp, 4);
}
}
$r["res"] = $o;
return $r;
}
?>
<?php
$o[$i]["ttime"] = msht(fread($rp, 4));//total time
$o[$i]["btime"] = msht(fread($rp, 4));//best time
?>