Forum Moderators: coopster
I was curious how I can get my website to email me when a IP is detected on my site.
I know I would have to get the users $_SERVER['REMOTE_ADDR'] and then run it with the ip I am looking for. The problem is the ip I am looking for is a subnet. So I cant specifically look for 123.45.67.890, but I need to look for 123.45.67.*. How can I do this?
The actual email part is fine I have that setup I guess its just the ripping apart of the $_SERVER['REMOTE_ADDR'] to see if the beginning matches the ip I am looking for.
Does anyone know how I can do this?
Thanks :)
wes
if (preg_match("#123\.45\.67\.[0-9]{1,3}#",$_SERVER['REMOTE_ADDR']) &&!$_COOKIE['MailSent']) {
mail('you@example.com','IP Detected',$_SERVER['REMOTE_ADDR'] . ' Detected!');
setcookie('MailSent','TRUE');
}