homepage Welcome to WebmasterWorld Guest from 54.196.168.78
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / WebmasterWorld / Webmaster General
Forum Library, Charter, Moderators: phranque & physics

Webmaster General Forum

    
Being notified of particular server requests
How to have an email sent?
directrix




msg:3420235
 5:40 pm on Aug 12, 2007 (gmt 0)

I would like to be sent an email whenever a particular server request is made, such as from a particular IP address for a specific page. The notification doesn't have to be immediate; within the hour would be fine. This is on an Apache server on a Unix box. Are there scripts available to do this?

 

SixTimesEight




msg:3420238
 5:51 pm on Aug 12, 2007 (gmt 0)

Are you using PHP? Here is something I've used.

// create an array of watched IP addresses
$watchedIPs = array('x.x.x.x','x.x.x.x');

// check the remote address against the array of IP addresses
for($i=0, $num=sizeof($watchedIPs); $i<$num; $i++){
if(strpos($_SERVER['REMOTE_ADDR'],$watchedIPs[$i])!== false){
/* send a notification email */
}
}

directrix




msg:3420288
 7:05 pm on Aug 12, 2007 (gmt 0)

Thanks, but except for the search box my site is entirely static.

I can use PHP, but I don't know whether I could intercept the request and deal with it on the fly? Or whether I'd need to process the log file once an hour?

rocknbil




msg:3420551
 6:45 am on Aug 13, 2007 (gmt 0)

Since the request is for a static page, only the web server software is "aware" of the page being requested.

Check out the capabilities of the mod actions [httpd.apache.org] module, it would be a very simple thing to write a script to do this. You could even write it in PHP and have the module execute it for you, although perl is probably more adept at command line scripting.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / Webmaster General
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved