Created
August 8, 2011 00:26
-
-
Save leegao/1130984 to your computer and use it in GitHub Desktop.
USGN -> Username
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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