Just got my laptop working today (Damn charger getting lost ... ), I will look into it.
<?php
if (is_array($data)){
foreach($data as ....){
...
}
}
?>
<?php
// Constructor
function LFSWorldSDK($idk, $ps = false, $initial_sleep = true ) {
$this->ps = $ps;
$this->idk = $idk;
$this->compression = (function_exists('gzinflate')) ? 3 : 0;
$this->timestamp = time( );
if ($initial_sleep == false) // this will cause the first query to be done immediately
$this->timestamp -= 5;
}
?>
<?php
if (!$this->ps){
$delta = time( ) - $this->timestamp;
if ($delta < 5) // only sleep if necessary ...
sleep(6 - $delta); // ... and only as long as necessary (up to 6 seconds because 5 will fail occasionally)
$this->timestamp = time( );
}
?>
<?php
function convert_lfsw_time($time) {
return sprintf('%d:%05.2f', floor($time / 60000), (($time % 60000) / 1000));
}
?>
<?php
function convert_flags_hlaps($flags_hlaps) {
$data = array();
if ($flags_hlaps & 1) $data[1] = 'LEFTHANDDRIVE';
if ($flags_hlaps & 2) $data[2] = 'GEARCHANGECUT';
if ($flags_hlaps & 4) $data[4] = 'GEARCHANGEBLIP';
if ($flags_hlaps & 8) $data[8] = 'AUTOGEAR';
if ($flags_hlaps & 16) $data[16] = 'SHIFTER';
if ($flags_hlaps & 64) $data[64] = 'BRAKEHELP';
if ($flags_hlaps & 128) $data[128] = 'AXISCLUTCH';
if ($flags_hlaps & 512) $data[512] = 'AUTOCLUTCH';
if ($flags_hlaps & 1024) $data[1024] = 'MOUSESTEER';
if ($flags_hlaps & 2048) $data[2048] = 'KN';
if ($flags_hlaps & 4096) $data[4096] = 'KS';
if (!($flags_hlaps & 7168)) $data[7168] = 'WHEEL';
return $data;
}
?>
<?php
1 LEFTHANDDRIVE
8 AUTOGEAR
16 SHIFTER
64 BRAKEHELP
128 AXISCLUTCH
512 AUTOCLUTCH
1024 MOUSESTEER *
2048 KN *
4096 KS *
(*) if not 1024, 2048 or 4096, steering is wheel.
?>
<?php
function convert_flags_hlaps_to_letters($flags_hlaps) {
$string = "";
if ($flags_hlaps == "" || $flags_hlaps == 0) return;
if ($flags_hlaps & 1024) $string .= "M ";
if ($flags_hlaps & 2048) $string .= 'Kn ';
if ($flags_hlaps & 4096) $string .= 'Ks ';
if (!($flags_hlaps & 7168)) $string .= 'W ';
if ($flags_hlaps & 1) $string .= "L ";
else $string .= "R ";
if ($flags_hlaps & 2) $string .= "cc "; // obsolete?
if ($flags_hlaps & 4) $string .= "cb "; // obsolete?
if ($flags_hlaps & 8) $string .= "A "; // Autogear
if ($flags_hlaps & 16) $string .= "S "; // Shifter
if ($flags_hlaps & 64) $string .= "bh ";
if ($flags_hlaps & 128) $string .= "cl "; // Axisclutch (pedal)
if ($flags_hlaps & 512) $string .= "ac "; // Autoclutch
return $string;
}
?>
<?php
private $timestamp ,
$query;
// Constructor
function LFSWorldSDK($idk, $ps = false, $initial_sleep = true ) {
$this->ps = $ps;
$this->idk = $idk;
$this->compression = (function_exists('gzinflate')) ? 3 : 0;
$this->timestamp = time( );
if ($initial_sleep == false) // this will cause the first query to be done immediately
$this->timestamp -= 5;
}
// Core Functions.
function make_query($qryStr, $file = 'get_stat2.php') {
if (!$this->ps){
$delta = time( ) - $this->timestamp;
if ($delta < 5) // only sleep if necessary ...
sleep(6 - $delta); // ... and only as long as necessary (up to 6 seconds because 5 will fail occasionally)
$this->timestamp = time( );
}
$data = @file_get_contents("http://www.lfsworld.net/pubstat/{$file}?version=1.4&idk={$this->idk}&ps={$this->ps}{$qryStr}&c={$this->compression}&s=2");
$data = ($this->compression) ? gzinflate($data) : $data;
$data = unserialize($data);
if (is_array($data)) return $data;
return array();
}
?>
<?php
function make_query($qryStr) {
if (!$this->ps)
sleep(6);
$data = file_get_contents("http://www.lfsworld.net/pubstat/get_stat2.php?version=1.4&idk={$this->idk}&ps={$this->ps}&c={$this->compression}&s=2{$qryStr}");
if ($this->compression)
$data = gzinflate($data);
if ($this->is_lfsw_error($data))
return $this->make_query($qryStr);
$return = @unserialize($data);
if ($return === FALSE)
return $data;
else
return $return;
}
function is_lfsw_error($data) {
if ($data == 'can\'t reload this page that quickly after another')
return TRUE;
else
return FALSE;
}
?>
<?php
$result[$i]['info'] = $this->convert_team_bits($data['bits']);
?>
<?php
$result[$i]['bits'] = $this->convert_team_bits($data['bits']);
?>
$data = $this->getUrl("http://www.lfsworld.net/pubstat/get_stat2.php?version=1.4&idk={$this->idk}&ps={$this->ps}&c={$this->compression}&s=2{$qryStr}");
return json_decode(array_pop(explode("\n", $this->getUrl('http://www.lfsworld.net/pubstat/hostprogress.php?host='.urlencode($host)))), TRUE);
function getUrl($url){
if (function_exists('curl_init')) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
return curl_exec($ch);
} else {
return file_get_contents($url);
}
}
<?php
php
include('lfsworldsdk.php');
$trackcode = array(
'000' => 'BL1',
'001' => 'BL1R',
'010' => 'BL2',
'011' => 'BL2R',
'020' => 'BL3',
'100' => 'SO1',
'101' => 'SO1R',
'110' => 'SO2',
'111' => 'SO2R',
'120' => 'SO3',
'121' => 'SO3R',
'130' => 'SO4',
'131' => 'SO4R',
'140' => 'SO5',
'141' => 'SO5R',
'150' => 'SO6',
'151' => 'SO6R',
'200' => 'FE1',
'201' => 'FE1R',
'210' => 'FE2',
'211' => 'FE2R',
'220' => 'FE3',
'221' => 'FE3R',
'230' => 'FE4',
'231' => 'FE4R',
'240' => 'FE5',
'241' => 'FE5R',
'250' => 'FE6',
'251' => 'FE6R',
'300' => 'AU1',
'310' => 'AU2',
'320' => 'AU3',
'330' => 'AU4',
'400' => 'KY1',
'401' => 'KY1R',
'410' => 'KY2',
'411' => 'KY2R',
'420' => 'KY3',
'421' => 'KY3R',
'500' => 'WE1',
'501' => 'WE1R',
'600' => 'AS1',
'601' => 'AS1R',
'610' => 'AS2',
'611' => 'AS2R',
'620' => 'AS3',
'621' => 'AS3R',
'630' => 'AS4',
'631' => 'AS4R',
'640' => 'AS5',
'641' => 'AS5R',
'650' => 'AS6',
'651' => 'AS6R',
'660' => 'AS7',
'661' => 'AS7R'
);
function convert_lfsw_time($time) {
return sprintf('%d:%05.2f', floor($time / 60000), (($time % 60000) / 1000));
}
$wr = $SDK->get_wr();
$pb = $SDK->get_pb('adamshl');
echo '<table width=\"400\" border=\"1\">';
echo '<tr><td> </td><td>Track</td><td>Car</td><td>Time</td><td>WR-diff</td><td>Laps</td><td>Date</td></tr>';
//asort($pb);
$lp = '1';
foreach ($pb as $id) {
if($id['laptime'] != '0' AND $lp <= '20') {
echo '<tr><td>' . $lp++ . '.</td>'
. '<td>' . $trackcode[$id['track']] . '</td>'
. '<td>' . $id['car'] . '</td>'
. '<td>' . convert_lfsw_time($id['laptime']) . '</td>';
foreach ($wr as $diff) {
if($diff['track'] == $id['track'] & $diff['car'] == $id['car']) {
echo '<td>' . convert_lfsw_time($id['laptime'] - $diff['laptime']) . '</td>';
}
}
echo '<td>' . $id['lapcount'] . '</td>'
. '<td>' . date("d.m.Y H:i", $id['timestamp']) . '</td></tr>';
}
}
echo '</table>';
?>
<?php
php include('lfsworldsdk.php');
<table>
<thead>
<tr>
<th>Key</th>
<td>Val</td>
</tr>
</thead>
<tbody>
php forEach ($SDK->get_pst('Dygear') as $key => $val):
<tr>
<th>echo $key; </th>
<td>echo $val; </td>
</tr>
php endForEach;
</tbody>
</table>
?>