Skip to content

Instantly share code, notes, and snippets.

@leegao
Created August 8, 2011 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leegao/1130984 to your computer and use it in GitHub Desktop.
Save leegao/1130984 to your computer and use it in GitHub Desktop.
USGN -> Username
<?php
header('Content-type: application/lua');
header('Content-Disposition: attachment; filename="usgn_names.lua"');
$last = explode(",", file_get_contents("last.dat"));
if (time() - $last[1] > 3600){
$url = 'http://unrealsoftware.de/users.php?raw&s=' .$last[0]. '&c=1000';
$userraw = file_get_contents($url);
$users = explode("\n", $userraw);
for ($i = 0; $i < count($users); $i++) {
if ($users[$i] == true){
$user = explode(",",$users[$i]);
file_put_contents("usgn_names.lua", 'usgn_name['.$user[0].'] = [['.$user[1].']]' . "\n", FILE_APPEND);
}else{
// rewrite last.dat 54948
$last_s = $last[0]+$i;
file_put_contents("last.dat", $last_s.",".time(), LOCK_EX);
echo "-- last updated on ".date('Y-m-d H:i:s')."\n";
}
}
} else {
echo "-- last updated on ".date('Y-m-d H:i:s',$last[1])."\n";
}
readfile("usgn_names.lua");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment