Posts Tagged ‘web’

Annual Review of the Church’s Web Site

November 21, 2009

I’m thinking about doing a “state of the web” type report for the church at the top of the year.  It would consist of:

  1. a review of the site metrics (most hit pages, referrers, etc.)
  2. a review of the site with respect to best practices (per something like 70+ tips for effective church sites from Internet Evangelism Day)
  3. a reflection of the initiatives of the past year
  4. an outline of initiatives for the coming year

Does anyone else do something like this for their church?

Auto-Email Web Server Errors with WordPress

April 30, 2009

404/403 Website Error Pages with PHP Auto-Mailer from Nettuts+ scrolled through my RSS feeds the other day.  I was thinking that since I have WordPress installed it should be really easy to add some auto-emailing to the 404 template page.  While there are a few 404 WordPress plugins I didn’t see any that added the emailing.  So I added this to the bottom of my 404.php file:

$s_headers = "";
$s_to = "" ;
$s_subject = "404 Page Generated" ;
$s_message = "<ul>" ;
$s_message .= "<li>Request URL:" . $_SERVER['REQUEST_URI'] . "</li>";
$s_message .= "<li>Request Method:" . $_SERVER['REQUEST_METHOD'] . "</li>";
$s_message .= "<li>Referer:" . $_SERVER['HTTP_REFERER'] . "</li>";
$s_message .= "<li>Remote Address:" . $_SERVER['REMOTE_ADDR'] . "</li>";
$s_message .= "</ul>";
mail($s_to, $s_subject, $s_message, $s_headers ) ;

So when a 404 gets generated I now am informed what failed, where it came from, who it came from and if it was a GET or POST.

What about other errors?

Ok, that was easy for the 404 because it was built into the WP template system.  But what about other errors like 500 (server error) and 403 (forbidden)?  WP doesn’t have templates for them.  Well, its pretty easy to take an arbitrary PHP script and include the entire WP environment.  I created a 500.php file that looks something like this:

define('WP_USE_THEMES', true);
<?php get_header(); ?>
<div id="content" class="narrowcolumn">
<h2 class="center">Server Error - Pray For Us</h2>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
<?php /* all that emailing code I just wrote in the 404.php file but used "500" instead of 404 */ ?>

The define() and require_once() functions pull in the WordPress environment.  You only need to watch out for the relative path to the wp-load.php file since it depends on where your PHP script is executing.  Now, duplicate code is a poor programming practice and I had access to all of WP; that means I had access to the functions.php file for the current template.  So, I took the original emailing code and wrote it into a function in the functions.php file.  Of course, if I change the theme I’ll have to make sure this function moves also.  The alternative is to put it into a separate PHP script and include it like the wp-load.php script.  The last line of the 404.php and 500.php files now look like:

<?php mail_request_info( "404 Page" ) ; ?>


<?php mail_request_info( "500 Page" ) ; ?>

Wrapping Up

You’ll want to follow their tutorial for how to update your Apache environment to reference the 500.php in the event of a server error.  I also wrote a 403.php file that worked the same way.  This effort paid immediate dividends for me as I found a couple of minor broken links on the site.  Nothing an HTML validator wouldn’t have found but I don’t run one against the site unless I’m redesigning it.  Between these scripts and the Redirection Plugin there are now very few broken pages since the major redesign on the site.  One note of caution, if you’re a high-volume site you might get flooded with emails.

Question: What are you doing for site backups?

April 21, 2009

Recently I read of some web host failures. It got me thinking about what it would take to recover my church’s site. I periodically back up the WordPress db, but that doesn’t save the uploaded content.  So nothing would be preserved in the WP uploads folder or the sermons and other media that’s uploaded via FTP. If my host couldn’t recover the files we’d be very much out of luck and I don’t have local back ups of multiple years of MP3 and uploaded event pictures.

So how would you fair if your web host lost everything?  What is your disaster recovery strategy for your church’s web site?