php防止恶意访问小程序
本来写PAYPAL IPN response 时用来防止反复尝试的函数,保护性很差,后来改成原地址审核($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);if(!preg_match('/paypal\.com$/', $hostname)) {.....),所以个就弃用了。在删之前记录不来,应该有更好的算法,不知道谁有研究。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | if (!avoid_refresh ('15')) die ("Hacking Attempt!!"); ..... ..... ..... function avoid_refresh ($time){ session_start(); if (isset($_SESSION["post_sep"])) { if (time() - $_SESSION["post_sep"] < $time) { $_SESSION["post_sep"] = time(); return false; } else { $_SESSION["post_sep"] = time(); return true; } } else { $_SESSION["post_sep"] = time(); return true; } } |












































