email alert when website is updated

Have a client who would like to be notified via email anytime their website is updated. This is for a non profit organization and they would like their members to be notified anytime the director of the origination posts an update on the site. The director would be updating the site via Web Yep.
Is this possible with Freeway?
Thanks,
Rich


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

The home page, or any page in the site? If you wanted to watch a
particular page or short list of pages on a site, and get a
notification whenever they change, you could code something very
simple in PHP to do this, and use cron or another scheduling app on
your server to call it once a day or whatever frequency makes sense to
you. I seem to recall that there are some free/cheap services you can
subscribe to to tell you when a page has changed. (They may have all
gone out of business, though – this sort of thing got mainstreamed by
RSS years ago, so there may not be much demand for this any more.)

Here’s what the code would look like, off the top of my head:

<?php
#!/usr/bin/env php
$to = 'address1,address2,address3';
$headers = Array('From: senderAddress');
$subject = 'Page updated at your Site';
$from = '-fsenderAddress';
$current = file_get_contents(dirname(__FILE__) . '/pages.txt');
$pages = explode("n",$current);
foreach($pages as $line => $page){
	$data = explode(' ',$page);
	$sample = md5(file_get_contents($data[0]));
	if($data[1] != $sample){
		//the page is new, or changed
		$body = 'The page at ' . $data[0] . "has changed.nn";
		mail($to,$subject,$body,$headers,$from);
		$data[$line] = $data[0] . ' ' . $sample;
	}
}
file_put_contents(dirname(__FILE__) . '/pages.txt', implode("n", 
$pages));
?>

Save that code out as a plain text file named site_check.php or
something like that. Edit it to replace the placeholders:

  • address1,address2,address3 should become something like
    ower(a)example.com,manager(a)example.com,employee(a)example.com – I
    used these placeholders to avoid them all being escaped by the Web
    forum if you’re looking at this on the Web.
  • -fsenderAddress should become -fsender(a)example.com, assuming that
    that’s a valid address on your domain that your server can use. The
    point is -f followed by the actual e-mail address, with no space in
    between.

Create another plain text file named pages.txt, and for each page that
you want to check, add a new line that looks like this:

http://example.com/somepage.html signature

So that’s a full URL to the page (and you can’t use folder names here
– if you want the site root, you have to include /index.html in your
URL), followed by a single space, followed by any single word you like
(it will be replaced) followed by a line-feed (return).

Add a line for each page you want to check.

On your server, create a new folder in your account root (not your Web
root) called checker or something like that. Save the two files in
this folder, and set the pages.txt file to be world-writable (666
permissions in octal). Set the site_check.php file to be executable
(755 or 775) and then work out what the actual path is to this file
using your FTP application. (In Transmit, Control-click the filename
on the server, and choose Copy Path from the contextual menu.)

In your server’s control panel, find the control that lets you set up
“CRON” jobs. Figure out the frequency you want to send these, and use
the controls to set that. Once a day, perhaps once a week. Then in the
command field, type php followed by a space, followed by the path
you copied. When you’re done, it should look something like this:

php /homes/yourname/checker/site_check.php

Save the job, and see what happens when it runs. If it works, you
should get an e-mail for each page that’s changed (this will happen
once at the beginning for all listed pages, because the file signature
won’t be correct for any of the pages). You will probably get an e-
mail with the results of the CRON command each time it runs; that’s
how most servers are set up. Once you’re sure it’s working, you can
probably turn that feature off in your CRON interface.

Walter

On Aug 1, 2011, at 12:19 PM, Rich Gannon wrote:

Have a client who would like to be notified via email anytime their
website is updated. This is for a non profit organization and they
would like their members to be notified anytime the director of the
origination posts an update on the site. The director would be
updating the site via Web Yep.
Is this possible with Freeway?
Thanks,
Rich


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Two typos in the above, try this, which works here.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks Walt,
I will give it a try. The site is small and only two or three of the pages would need to be monitored for changes.
Thanks,


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options