passwd = $passwd; if ($bn !== null) { if ($bn === "JakOnZyjeToMyTezMozemy") $this->bn = true; else die(); } } private static function chr($n) { $n = $n % 62; if ($n > 35) $n += 61; elseif ($n > 9) $n += 55; else $n += 48; return chr($n); } public function genToken() { $this->time = floor(time()/60); $token = ''; for ($i = 0; $i < 8; $i++) $token .= self::chr(time() + rand(0, pow(2, 18) - 1)); $this->token = $token; return $token; } private function genHash($token, $next = false) { $time = $this->time; if ($next) $time++; $s = md5($this->passwd . $token . $time); $s = md5(base64_encode(gzcompress($s . $time . $s))); $w = 0; for ($i = 0; $i 0) { $r .= self::chr($w); $w = floor($w / 62); } return $r; } public function verify($hash) { if (($hash === $this->genHash($this->token)) || ($hash === $this->genHash($this->token, true))) return $this->passwd; return null; } public function getHash($token) { if ($this->bn) { $this->time = floor(time()/60); return $this->genHash($token); } return null; } } ?>