Easy site updates
This was the answer to a problem of mine. I like it because it keeps the website dynamic and interesting while also providing a service to my users by aggregating content of interest to them.
The Problem
I manage the website of a local non-profit group. There is a section of the frontpage set aside for news updates but new information is rarely posted. It isn’t that the group doesn’t do anything, they members simply don’t think to use the website for communication. I wanted to encourage the members to use the website more and to provide updates to the website on a regular basis without having to handle it manually.
The Solution
feed on feeds is a web-based aggregator for RSS files. It’s a piece of software that runs on your webserver and lists the latest updates from syndicated sites as a webpage. “Hacking” it for my use was very easy. I first installed it in a password-protected directory on the webserver. Once the installation was working, I added feeds from a selection of library-related sources.
Next was adding the list of headlines to the public homepage. This was done with the code:
<pre><?php
/*
* This file is part of FEED ON FEEDS - http://feedonfeeds.com/
* view.php - views items based on query parameters
* Copyright (C) 2004 Stephen Minutillo
* steve@minutillo.com - http://minutillo.com/steve/
* Distributed under the GPL - see LICENSE
*/
include_once("../relative/path/to/init.php");
if($_GET['how'] == 'paged' && !isset($_GET['which']))
{
$which = 0;
}
else
{
$which = $_GET['which'];
}
$title = fof_view_title($_GET['feed'], $_GET['what'], $_GET['when'], $which, $_GET['howmany']);
$noedit = $_GET['noedit'];
?>
<?php
$result = fof_get_items($_GET['feed'], $_GET['what'], $_GET['when'], $which, $_GET['howmany']);
while($row = mysql_fetch_array($result))
{
$items = true;
$feed_link = htmlspecialchars($row['feed_link']);
$feed_title = htmlspecialchars($row['feed_title']);
$feed_description = htmlspecialchars($row['feed_description']);
$item_id = $row['item_id'];
$item_link = htmlspecialchars($row['item_link']);
$item_title = htmlspecialchars($row['item_title']);
$item_content = fof_balanceTags($row['item_content']);
print '<div class="item">';
print "<h3><a href="$item_link">$item_title</a></h3> ";
print "<h4><a href="$feed_link" title="$feed_description">$feed_title</a></h4>";
print "<p>$item_content</p>";
print '</div>';}
?></pre>
Notice, I included the copyright statement from the author. This will hopefully help future website managers to understand what the code is doing. After making sure that the code was working as expected, I styled it (using CSS) to fit the rest of the webpage.
The final step was to set it up to update automatically. The software creator has instructions for this on his site but they didn’t work for me because my version of php was running as an Apache module instead of as CGI. (Ask your server admin which you have.) Also, his method only adds more titles to the result list, it doesn’t delete the previous ones.
What worked for me is:
<pre>30 4 * * * lynx -auth username:password -source http://domain/pathto/mark-read.php</pre>
<pre>00 5 * * * lynx -auth username:password -source http://domain/pathto/update-quiet.php</pre>
Every morning, at 4:30am, the webrowser lynx is run on my shell account. It loads to page “mark-read.php,” which marks everything in the database “read” so it won’t show up on the public list anymore.
Why a browser?
Because delivering the page to a browser causes the server to process and follow the instructions in the php file.
The second line does the same at 5am with “update-quiet.php,” which checks all of the feeds for new stories.
The homepage now has new, useful content every day without my having to try to keep up with another blog or adding more work to our already too busy members. The working version is at MALC.
