@ 2013-09-26T22:47:54Z <?php
define("BF3APIIdent", 'R8tyRf7J5O');
define("BF3APIKey", 'UvVGtyTwb1BlT7nA2dzFT8fKIdUgeksg');
// Platform can be pc, 360, ps3
$platform = 'pc';
$memberObj = new \app\classes\Members();
$queryParam = array(
'WHERE' => "WHERE (usertype_tbusers<>'N')",
'ORDER' => 'ORDER BY lastupdate_tbusers ASC',
'LIMIT' => 'LIMIT ' . 20
);
$results = $memberObj->getAllbyCriteria($queryParam);
$tempData = array('players' => array(), 'opt' => array());
foreach ($results as $newsEntry):
$bf3Stats = updatePlayer($platform, $newsEntry->userid_tbusers);
if ($bf3Stats['status'] == "exists"):
$bf3Stats = lookupPlayer($platform, $newsEntry->userid_tbusers);
if ($bf3Stats['status'] == "exists"):
if ($bf3Stats['task'][result] == "found"):
$tempData['players'][] = $newsEntry->userid_tbusers;
endif;
endif;
endif;
endforeach;
$bf3Stats = getPlayersBF3Info($tempData);
unset($bf3Stats['failed']); // to make sure that non finded players won´t get into it.
$varPlayerPosition = 0;
foreach ($bf3Stats['list'] as $userEntry):
if (isset($userEntry)):
$varKills = $userEntry['stats']['global']['kills'];
$varDeaths = $userEntry['stats']['global']['deaths'];
$varSkill = $userEntry['stats']['global']['elo'];
$varlastUpdate = $userEntry['date_update'];
$varRatio = round(($varKills / $varDeaths), 2);
else:
$varRatio = 0;
$varSkill = 0;
$varlastUpdate = time() - 86400;
endif;
$memberFound = $memberObj->getDataByID($tempData['players'][$varPlayerPosition]);
if (count($memberFound) > 0):
$tempAttributes = array(
'skill_tbusers' => $varSkill,
'ratio_tbusers' => $varRatio,
'lastupdate_tbusers' => date('Y-m-d H:i:s', $varlastUpdate)
);
$memberFound->updateTo($tempAttributes);
endif;
$varPlayerPosition += 1;
endforeach;
//=========================== End of script ====================================================================
function setupClientKey($clientident = null, $name = null) {
$data = array();
$data['ident'] = BF3APIIdent;
$data['time'] = time();
$data['clientident'] = $clientident;
$data['name'] = $name;
return getAPIDataSigned('setupkey', 'global', $data);
}
function getClientKey($clientident) {
$data = array();
$data['ident'] = BF3APIIdent;
$data['time'] = time();
$data['clientident'] = $clientident;
return getAPIDataSigned('getkey', 'global', $data);
}
function lookupPlayer($platform, $name) {
echo BF3APIIdent;
$data = array();
$data['ident'] = BF3APIIdent;
$data['time'] = time();
$data['player'] = $name;
return getAPIDataSigned('playerlookup', $platform, $data);
}
function updatePlayer($platform, $name) {
$data = array();
$data['ident'] = BF3APIIdent;
$data['time'] = time();
$data['player'] = $name;
return getAPIDataSigned('playerupdate', $platform, $data);
}
function getAPIDataSigned($type, $platform, $data) {
// Convert data to JSON
$urlbase64 = array('+' => '-', '/' => '_', '=' => '');
$data = strtr(base64_encode(json_encode($data)), $urlbase64);
$postdata = array();
$postdata['data'] = $data;
$postdata['sig'] = strtr(base64_encode(hash_hmac('sha256', $data, BF3APIKey, true)), $urlbase64);
// Run POST Request via CURL
$c = curl_init('http://api.bf3stats.com/' . $platform . '/' . $type . '/');
curl_setopt($c, CURLOPT_HEADER, false);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_USERAGENT, 'BF3StatsAPI/0.1');
curl_setopt($c, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_POSTFIELDS, $postdata);
$data = curl_exec($c);
$statuscode = curl_getinfo($c, CURLINFO_HTTP_CODE);
curl_close($c);
if ($statuscode == 200) {
// Decode JSON Data
$data = json_decode($data, true);
return $data;
} else {
echo "BF3 Stats API error status: " . $statuscode;
return false;
}
}
function getPlayersBF3Info($data) {
// List of options
$data['opt']['clear'] = true;
$data['opt']['global'] = true;
$data['time'] = time();
// Platform can be pc, 360, ps3
$platform = 'pc';
// Convert lists to JSON
$postdata = array();
$postdata['players'] = json_encode($data['players']);
$postdata['opt'] = json_encode($data['opt']);
// Run POST Request via CURL
$c = curl_init('http://api.bf3stats.com/' . $platform . '/playerlist/');
curl_setopt($c, CURLOPT_HEADER, false);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_USERAGENT, 'BF3StatsAPI/0.1');
curl_setopt($c, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_POSTFIELDS, $postdata);
$data = curl_exec($c);
$statuscode = curl_getinfo($c, CURLINFO_HTTP_CODE);
curl_close($c);
if ($statuscode == 200) {
// Decode JSON Data
$data = json_decode($data, true);
// Print data for debugging
return $data;
// ... now you use $data to do whatever
} else {
return "ERROR";
}
}
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.2.6 0.007 0.007 16.80 7.1.20 0.007 0.007 15.41 7.1.7 0.004 0.004 17.06 7.1.6 0.011 0.015 19.40 7.1.5 0.020 0.013 34.83 7.1.0 0.003 0.047 22.36 7.0.20 0.152 0.006 14.46 7.0.14 0.007 0.070 22.00 7.0.9 0.050 0.067 20.00 7.0.8 0.003 0.087 19.98 7.0.7 0.060 0.060 19.93 7.0.6 0.043 0.070 19.92 7.0.5 0.007 0.043 20.40 7.0.4 0.010 0.080 20.18 7.0.3 0.010 0.070 20.04 7.0.2 0.000 0.053 20.10 7.0.1 0.010 0.057 20.14 7.0.0 0.003 0.047 20.17 5.6.28 0.010 0.070 21.07 5.6.24 0.017 0.067 20.58 5.6.23 0.013 0.070 20.48 5.6.22 0.010 0.057 20.58 5.6.21 0.007 0.047 20.75 5.6.20 0.003 0.043 21.18 5.6.19 0.007 0.083 21.10 5.6.18 0.010 0.063 21.08 5.6.17 0.013 0.083 21.11 5.6.16 0.010 0.080 21.13 5.6.15 0.003 0.060 20.99 5.6.14 0.007 0.050 21.06 5.6.13 0.013 0.087 21.16 5.6.12 0.003 0.043 21.14 5.6.11 0.007 0.083 21.09 5.6.10 0.007 0.047 21.04 5.6.9 0.013 0.043 21.05 5.6.8 0.010 0.057 20.61 5.6.7 0.010 0.073 20.55 5.6.6 0.000 0.050 20.53 5.6.5 0.007 0.033 20.46 5.6.4 0.007 0.040 20.43 5.6.3 0.000 0.047 20.43 5.6.2 0.007 0.040 20.37 5.6.1 0.013 0.027 20.51 5.6.0 0.003 0.040 20.57 5.5.38 0.007 0.073 20.36 5.5.37 0.010 0.070 20.51 5.5.36 0.003 0.093 20.44 5.5.35 0.010 0.083 20.42 5.5.34 0.010 0.037 20.96 5.5.33 0.007 0.100 20.82 5.5.32 0.013 0.077 20.95 5.5.31 0.003 0.087 20.91 5.5.30 0.007 0.060 20.79 5.5.29 0.007 0.083 20.83 5.5.28 0.007 0.067 20.70 5.5.27 0.000 0.063 20.78 5.5.26 0.010 0.073 20.78 5.5.25 0.007 0.040 20.73 5.5.24 0.010 0.057 20.21 5.5.23 0.000 0.043 20.36 5.5.22 0.007 0.037 20.35 5.5.21 0.003 0.040 20.24 5.5.20 0.010 0.043 20.24 5.5.19 0.000 0.057 20.21 5.5.18 0.010 0.037 20.27 5.5.16 0.003 0.033 20.30 5.5.15 0.003 0.033 20.04 5.5.14 0.013 0.030 20.32 5.5.13 0.010 0.033 20.31 5.5.12 0.003 0.040 20.20 5.5.11 0.007 0.043 20.29 5.5.10 0.000 0.037 20.13 5.5.9 0.000 0.033 20.13 5.5.8 0.010 0.043 20.15 5.5.7 0.013 0.070 20.11 5.5.6 0.007 0.037 20.09 5.5.5 0.003 0.040 20.21 5.5.4 0.007 0.033 20.11 5.5.3 0.007 0.037 20.15 5.5.2 0.000 0.040 20.20 5.5.1 0.003 0.040 20.07 5.5.0 0.007 0.037 20.05 5.4.45 0.013 0.047 19.36 5.4.44 0.010 0.063 19.38 5.4.43 0.007 0.043 19.35 5.4.42 0.010 0.037 19.53 5.4.41 0.010 0.063 19.24 5.4.40 0.017 0.060 19.05 5.4.39 0.007 0.077 19.13 5.4.38 0.003 0.040 19.11 5.4.37 0.000 0.040 19.25 5.4.36 0.003 0.047 19.23 5.4.35 0.003 0.040 19.23 5.4.34 0.000 0.043 18.88 5.4.32 0.003 0.030 18.85 5.4.31 0.007 0.030 19.16 5.4.30 0.010 0.033 19.09 5.4.29 0.007 0.030 19.16 5.4.28 0.003 0.033 18.85 5.4.27 0.007 0.030 19.23 5.4.26 0.000 0.043 19.13 5.4.25 0.010 0.023 19.02 5.4.24 0.003 0.030 19.12 5.4.23 0.007 0.057 19.17 5.4.22 0.000 0.057 19.20 5.4.21 0.000 0.047 19.12 5.4.20 0.000 0.043 19.18 5.4.19 0.007 0.030 19.15 5.4.18 0.003 0.040 18.95 5.4.17 0.000 0.043 19.04 5.4.16 0.000 0.033 19.12 5.4.15 0.003 0.033 18.93 5.4.14 0.003 0.037 16.39 5.4.13 0.007 0.037 16.41 5.4.12 0.010 0.023 16.50 5.4.11 0.003 0.037 16.44 5.4.10 0.000 0.040 16.57 5.4.9 0.010 0.030 16.48 5.4.8 0.007 0.037 16.41 5.4.7 0.003 0.030 16.39 5.4.6 0.003 0.030 16.42 5.4.5 0.010 0.023 16.44 5.4.4 0.003 0.030 16.46 5.4.3 0.010 0.027 16.36 5.4.2 0.003 0.030 16.51 5.4.1 0.007 0.067 16.43 5.4.0 0.003 0.030 15.92 5.3.29 0.000 0.047 14.73 5.3.28 0.007 0.030 14.54 5.3.27 0.010 0.040 14.62 5.3.26 0.003 0.030 14.80 5.3.25 0.003 0.037 14.62 5.3.24 0.003 0.033 14.77 5.3.23 0.007 0.080 14.68 5.3.22 0.000 0.033 14.64 5.3.21 0.000 0.037 14.52 5.3.20 0.003 0.043 14.61 5.3.19 0.000 0.040 14.66 5.3.18 0.007 0.027 14.65 5.3.17 0.003 0.033 14.64 5.3.16 0.007 0.027 14.65 5.3.15 0.003 0.030 14.55 5.3.14 0.000 0.040 14.66 5.3.13 0.010 0.037 14.67 5.3.12 0.000 0.037 14.67 5.3.11 0.007 0.030 14.53 5.3.10 0.003 0.070 14.10 5.3.9 0.007 0.073 14.11 5.3.8 0.007 0.057 14.11 5.3.7 0.003 0.080 14.13 5.3.6 0.007 0.083 14.13 5.3.5 0.007 0.037 14.11 5.3.4 0.007 0.060 13.94 5.3.3 0.000 0.040 13.96 5.3.2 0.010 0.060 13.79 5.3.1 0.003 0.063 13.62 5.3.0 0.010 0.033 13.69
preferences:dark mode live preview
32.27 ms | 401 KiB | 5 Q