May.23

Feb.04

Sep.10

WordPress Version Checker

With the big security release last week, I had a hard time remembering all of my WordPress sites. Some, like my blog, are obvious. But I also use WordPress to build affiliate sites (like WNY Wine Tastings), and even I don’t recognize they’re WordPress sites. So I figured I could write a script to not only find all of the WordPress installations on my GoDaddy server, but also tell me which are outdated.

This script isn’t commented as nicely as some of my other ones, but it’s only 40 lines long, so I’m sure you can figure it out.

	set_time_limit(0);

	// What's the current WordPress version?
	$cHTML = file_get_contents('http://wordpress.org/download/');
	list( , $cHTML) = explode('latest stable release of WordPress (Version ', $cHTML);
	list($fVersion, ) = explode(')', $cHTML);
	$fVersion = trim($fVersion);

	// echo("Current version:\t$fVersion\n");
	$cMsg = '';


	// Get a list of the sites
	$aResults = explode("\n", shell_exec('find /var/www/vhosts -name "wp-config.php"'));
	array_pop($aResults);	// Blank

	foreach ($aResults as $cSite) {
		$cSite = str_replace('/var/www/vhosts/', 'http://www.', $cSite);
		$cSite = str_replace('httpdocs/', '', $cSite);
		$cSite = str_replace('wp-config.php', '', $cSite);

		$rsMeta = get_meta_tags($cSite);

		if ($rsMeta['generator'] != 'WordPress ' . $fVersion) {
			$cMsg .= "**********************************************************************\n";
			$cMsg .= "WARNING!\n";
			$cMsg .= $rsMeta['generator'] . ' != WordPress ' . $fVersion . "\n";
			$cMsg .= "$cSite\n";
			$cMsg .= "**********************************************************************\n";
		} // ends
	} // ends

	if (!empty($cMsg)) {
		echo("$cMsg");
		mail('eric@ericnagel.com', 'WordPress needs update', $cMsg, "From: eric@ericnagel.com");
	} // ends

First, I check for the current version of WordPress. I have no better way to do this than pull the text off the WordPress download page. I’m sure there’s a better method, but after looking for almost 20 minutes, I gave up.

Then, I run the find command to get a list of all of my sites. This works nicely on my server:

/var/www/vhosts/domain01.com/httpdocs/wp-config.php
/var/www/vhosts/domain02.com/httpdocs/wp-config.php
/var/www/vhosts/domain03.com/httpdocs/wp-config.php
/var/www/vhosts/domain04.com/httpdocs/wp-config.php
/var/www/vhosts/domain05.com/httpdocs/wp-config.php
/var/www/vhosts/domain06.com/httpdocs/wp-config.php
/var/www/vhosts/domain07.tv/httpdocs/wp-config.php
/var/www/vhosts/domain08.us/httpdocs/blog/wp-config.php
/var/www/vhosts/domain09.com/httpdocs/blog/wp-config.php
/var/www/vhosts/domain10.com/httpdocs/wp-config.php
/var/www/vhosts/domain11.com/httpdocs/wp-config.php

Next, I hit each of the sites & get the meta “generator” tag. If the version doesn’t line up, then a warning is appended to a variable. At the end of the script, if the variable isn’t empty, then an email is sent to me.

The “find” command will throw errors if you don’t have permission to search a folder, so when you set-up the daily cron, suppress error messages:

/usr/bin/php -q /home/esnagel/wp-check/wp-check.php 2>/dev/null

It’s not the prettiest, but it gets the job done.

How To & Tips

Aug.24

Getting Noticed

While at Affiliate Summit, one of the sessions I attended was Get Noticed Fast, a panel moderated by @LisaP and consisting of @StephARC, @MikeBuechele, @TrishaLyn and @JGoode. This session really made me think, as my personal brand was all over the place.

On Twitter I’m @esnagel, but my blog was netnagel.com, which included my personal ramblings, family life, and some affiliate stuff. But during the Get Noticed Fast panel, I came up with a plan to start rebranding myself.

The first step was to take the old ericnagel.com and install a new blog, which you’re reading now, and move all of the affiliate marketing posts here. That’s done, and they’re all permanently redirected to ericnagel.com

Then I turned off comments on any old netnagel.com posts, and set the homepage to simply be our lifestream. I removed much of the sidebar and navigation as well. I like having the history there, but won’t be making any more blog posts.

So now I need to start blogging here on ericnagel.com. With my background, a lot of the posts will be rather technical, but all related to Internet marketing.

I’m also looking to get my name out on other blogs, which started this morning on Murray Newlands’ affiliate marketing blog in a post about me as a US & UK Affiliate

Let me know what topics you’d like to see covered, and if I know something about it, I’ll try to cover them.

Conferences