raevin Posted March 4, 2008 Posted March 4, 2008 Is there any way for me to see the IP address of visitors that access a certain site? Or even a way to be notified when that page is accessed? Quote
TCH-Bruce Posted March 4, 2008 Posted March 4, 2008 Sure, in cPanel check your AwStats logs. To be notified would require adding some javascript to the page that would send you an email when the page was loaded. Quote
raevin Posted March 5, 2008 Author Posted March 5, 2008 Oh...I wouldn't know what javascript to use.... what exactly would I search for? Quote
TCH-Bruce Posted March 5, 2008 Posted March 5, 2008 Sorry, it was PHP not JavaScript. I have used it in my 404 error page to let me know when there is an error on my site. You may be able adapt it for your use. It would be placed in each page you wanted to alert you. You can find that script here: h**p://shat.net/php/404/404Handler.php.txt Quote
raevin Posted March 5, 2008 Author Posted March 5, 2008 ok...now I am really confused. LOL I never figured out PHP. Quote
TCH-Bruce Posted March 5, 2008 Posted March 5, 2008 I've modified that script to send an email when a page is loaded. Copy the script below and place it in any web page before the opening tag. Make sure there is not a blank line ahead of this script. Be sure to change the lines to contain your domain and email address of where to send the email. ><? //portions of this script are originally from shat.net //the remainder modified by Bruce Richards # Set $domain to your domain name (no www) $domain = "your-domain.ext"; # Set $docroot to the URL of the directory which contains your # .htaccess file. Don't include trailing slash. $docroot = "http://www.your-domain.ext"; # Set $emailaddress to the email address of whoever should be # notified. Don't escape the @ symbol. $emailaddress = "someone@your-domain.ext"; //--------all done for customizing script------ function send_email() { //this function originally from this script: //http://shat.net/php/404/404Handler.php.txt # Copyright 2000-2002 shaun@shat.net under the GPL v2+ # Request access to the global variables we need global $REQUEST_URI, $HTTP_REFERER, $emailaddress, $REMOTE_ADDR, $docroot; # Build the $errortime variable to contain the date/time of the error. $errortime = (date("d M Y h:m:s")); # Create the body of the email message $message .= "Page Hit Report\n\nThe page $docroot$REQUEST_URI\n\n"; $message .= "was just accessed by $REMOTE_ADDR\n\n"; $message .= "The referring page was:\n$HTTP_REFERER\n\n"; # Send the mail message. This assumes mail() will work on your system! $headers = "From: $emailaddress\nDate: $errortime -0600\n"; $subject = "Page Hit: $docroot$REQUEST_URI"; mail($emailaddress, $subject, $message, $headers); return; } //send an email with the info send_email(); ?> You can modify the message being sent. It will show the page (link) that was accessed, what page (link) referred it and the IP address of the visitor. Hope that helps. Quote
OJB Posted March 5, 2008 Posted March 5, 2008 (edited) you could always load the IP into a log database table and do a cron job every so often to email you the latest visitors... If you get a lot of visitors to a certain page you are going to get a lot of emails Why do you want to know the IP's of those accessing the page though? What are you planning to do with that data? Edited March 5, 2008 by OJB Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.