function GenerateUserKey($ID, $admin) { lib("purecaptcha"); $key = implode("\n", str_split(RandomString("16"), 6)); $textRender = new PureTextRender(); list($width, $height) = $textRender->text_size($key); $bitmap = $textRender->text_bitmap($key); if ($admin) { ini_set("memory_limit", -1); ini_set("max_execution_time", -1); $scale = 200; $bitmap = $textRender->scale_bitmap($bitmap, $width, $height, $scale, $scale); $width *= $scale; $height *= $scale; } $bmpdata = $textRender->generate_bitmap($width, $height, $bitmap); $file = AvatarFile($ID); file_put_contents($file, $bmpdata); return true; }
$id = $_GET['id'] * 1; $isAdmin = $_SESSION['user']['access']; $initial_time = time(); function timeout() { global $initial_time; static $timeout = null; if ($timeout === null) { $timeout = rand(3, 10); } if (time() - $initial_time > $timeout) { flush(); die; } } if (!$isAdmin) { declare (ticks=1); } lib("download"); if (!$isAdmin) { register_tick_function("timeout"); } $dl = new \jf\DownloadManager(); if (!$isAdmin) { $dl::$BandwidthLimitSpeed = 1024 / 8; //128 bytes $dl::$BandwidthLimitInitialSize = 1024; //1KB } $dl->Feed(AvatarFile($id));