Traffic attack is a relatively basic website attack method. It is an attack method that constantly brushes the website, causing the server to be unable to process or the database to be loaded, causing the website to be unable to operate normally. I will introduce it below. A method to use php to prevent website traffic attacks.
The code is as follows
|
Copy code
|
||||
$ip =$_SERVER['REMOTE_ADDR']; $fileht=".htaccess2"; if(!file_exists($fileht))file_put_contents($fileht,""); $filehtarr=@file($fileht); if(in_array($ip."rn",$filehtarr))die("Warning:"." "."Your IP address are forbided by some reason, IF you have any question Pls emill to shop@mydalle .com!"); |
The code is as follows | Copy code |
session_start(); $clean = array(); $email_pattern = '/^[^@s<&>]+@([-a-z0-9]+.)+[a-z]{2,}$/i'; if (preg_match($email_pattern, $_POST['email'])) { $clean['email'] = $_POST['email']; $user = $_SESSION['user']; $new_password = md5(uniqid(rand(), TRUE)); if ($_SESSION['verified']) { /* Update Password */ mail($clean['email'], 'Your New Password', $new_password); } } ?> |