Created
July 14, 2010 15:31
-
-
Save artlung/475570 to your computer and use it in GitHub Desktop.
Get notifications when page visited.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// add ip addresses you don't care about here | |
$no_mail = array( | |
'24.254.148.80', | |
'67.145.115.105', | |
'207.46.149.50', | |
); | |
$url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'; | |
$to_email = 'me@example.com'; | |
if (!in_array($_SERVER['REMOTE_ADDR'], $no_mail)): | |
$body = $url . "\n\n". print_r($_SERVER, true); | |
$headers = 'From: webmaster@example.com' . "\n" . | |
'Reply-To: webmaster@example.com' . "\n" . | |
'X-Mailer: PHP/' . phpversion() . "\n"; | |
mail($to_email, | |
'Email from '. url . $_SERVER['REMOTE_ADDR'], | |
$body | |
, $headers) or die("<!-- error with email -->"); | |
print "<!-- notification sent -->"; | |
else: | |
print "<!-- no notification sent -->"; | |
endif; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment