Hvis du har PHP installeret på din server, er her et script, der henter dit totale antal point. For at være lidt flink ved exp.dk serveren, er der en slags cache også:
<?
function exp_fetch_user_totalpoints($user) {
if (!$fp = fsockopen("
www.eksperten.dk", 80))
return array("status" => FALSE, "Could not connect to host");
socket_set_timeout($fp, 5);
if (!fputs($fp, "GET /bruger.phtml?navn=".$user."&option=24 HTTP/1.0\r\nHost:
www.eksperten.dk\r\n\r\n"))
return array("status" => FALSE, "Could not write to stream");
if (!$input = fread($fp, 1024 * 12))
return array("status" => FALSE, "Could not read from stream");
if (substr($input, 0, 15) != "HTTP/1.1 200 OK")
return array("status" => FALSE, "Document did not return with status OK. Could be invalid user.");
$match = preg_match("/<TD ALIGN=\"right\"><B>([0-9|.|,]*)<\/B><\/TD>/", substr($input, 10000), $regs);
if (!$match || $regs[1] < 0)
return array("status" => FALSE, "No valid match on point search");
fclose($fp);
return array("status" => TRUE, (int) str_replace(".", "", $regs[1]));
}
function exp_point_cache($file, $user, $interval = 3600) {
$fp = fopen($file, "a+") or die("Could not write to localfile: (".$file.")");
rewind($fp);
while (!feof($fp))
$file_data[] = fgets($fp);
$timestamp = &$file_data[0];
$points = &$file_data[1];
if ($timestamp + $interval < $now = time()) {
$fetch_return = exp_fetch_user_totalpoints($user);
if ($fetch_return['status']) {
$points = $fetch_return[0];
ftruncate($fp, 0);
rewind($fp);
fwrite($fp, $now."\n".$points);
}
}
fclose($fp);
return $points;
}
echo exp_point_cache("upload/exp_data.txt", "riversen");
?>