Shared Hosting Fix… Uhm, fix.

WordPress Maintenance, Backups, Updates & Security
I highly recommend working with WP Maintainer to maintain, secure & update your WordPress site. They’ve partnered with Sucuri Security to monitor your site from future hacks, too!

So I’ve had some reports that the shared hosting hack fix that I wrote as a quick bridge to a real solution left some people with PHP documents that contained a bit of leading whitespace, which can really b0rk up your WordPress install or any PHP application if it’s in the right file the wrong way.

So, I give you the cleaner (special thanks to Michael Safovich for requesting and testing).

What’s it do

It recursively looks through it’s current directory (and subdirectories) for PHP files (by default it’s looking for php, php4, php5 and phtml extensions, but this is customizable) and killing any whitespace in the beginning of the file, turning:

<?php include_once './wp-blog-header.php'; ?>

into this:

<?php include_once './wp-blog-header.php'; ?>

Make sense? Good, here’s the download link.

Tips & Customization

BACK UP YOUR FILES. You agree to take responsibility for running this, because I sure don’t (though I think you’ll be fine).

To run on custom file types, edit the $fileTypes array to include the types you want to strip leading whitespace from.

The script will run for the current directory. You will need to set the $directory variable to contain the path you’d like to recursively clean, in most cases you’d drop the cleaner.php file in your document root and hit it in the browser.

It will run immediately and output a log. Hope it helps. ¡Hasta luego!

1 Comment

  1. PleaseHelp says…

    Please re-upload! I need to rid the server of this scum! Thanks in advance!

RSS feed for comments on this post. TrackBack URL

Leave a Comment

June 29, 2010

Filed in Development, Wordpress

There are 1 comments »

« Back to the Blog