Archive for the ‘tools’ Category
Check for altered files on webhost
Every time I change webhosts I have to dust off files and slightly re-arrange the way I do security.
Instead of running the file check through a WP plugin I decided to run it from a command line and email myself the results.
The following PHP code will check for altered files in the previous 7 days ( $days = 7 ) and email you the files altered.
You should give this code a random file name and place it somewhere off the beaten path on your server. I set permissions to r–r–r–.
<?php
/*
Tripwire for webserver to tell when files altered or have 777 permissions
Author: Linda MacPhee-Cobb
Author URI: http://timestocome.com
Support URI: http://herselfswebtools.com
*/
// date
date_default_timezone_set('UTC');
// info we need
$date = time(); // current date+time
$one_day = 86400; // number of seconds in one day
$days = 7; // user selected number of days back to check files
$dir_count = 0; // init loop
$directories_to_read[0] = getcwd() . "/"; // start at the beginning
$i = 0; // loop counter
// time diff
$go_back = $one_day * $days;
$diff = $date - $go_back;
//email
$to = 'you@gmail.com';
$subject = 'file check';
$headers = "From: webmaster@your_domain.com";
$message = "";
while ( $i <= $dir_count ){
// get file info
$current_directory = $directories_to_read[$i];
$read_path = opendir( $directories_to_read[$i] );
while ( $file_name = readdir( $read_path)){
if (( $file_name != '.' )&&( $file_name != '..' )){
if ( is_dir( $current_directory . "/" . $file_name ) == "dir" ){
// need to grab files from each directory all the way down to leaves
$d_file_name = "$current_directory" . "$file_name";
$dir_count++;
$directories_to_read[$dir_count] = $d_file_name . "/";
}else{
$file_name = "$current_directory" . "$file_name";
// if time modified newer than x days print - else skip
if ( (filemtime( $file_name)) > $diff ){
$message .= "\nFILE ALTERED $file_name";
$date_changed = filectime( $file_name );
$pretty_date = date( "F j, Y g:i a", $date_changed);
$message .= " ::: $pretty_date " ;
}
}
}
}
closedir ( $read_path );
$i++;
}
$mail_sent = @mail( $to, $subject, $message, $headers );
?>
Magazine style automatically updated WordPress blogs
I’ve been wanting a magazine style template for my main website splash page for about six months. And I’d been wondering how those scrapers, scraped you rss feed into their blog. Sometimes procrastination is a good thing when I finally got around to looking into it all I found most of the pieces had already been written.

Herself’s Green Things picks up the rss feeds from all my websites, turns them into blog posts and posts them in a magazine style theme all automatically.
I tried all the magazine themes I could find on the WordPress theme pages. The Magadine theme was the one that was most stable and easiest to hack so that’s the one I choose. Colors and fonts are very easy to change as are the number of columns and rows. ( change rows and columns in index.php )
<?php
if($count == 2 ) {
echo “<div style=’clear:both;’></div>”;
$count = 0;
}else{
$count += 1;
}
?>
count == 2 will give you 3 columns, count == 1 will give you two, count == 3 gives you four columns.
There are several WP plugins that will turn rss feeds into posts. I chose Syndication which appears to have been pulled by the author because he/she didn’t want spammers using it. That’s a shame, maybe if you ask nicely the coder will give you a copy, I’ll respect the coder’s wishes and not provide copies. I like it best because it turns the title of the post into a link back to the original blog.
There are about a half dozen other choices available on the Wordpress plugins site. Try them all see what suits you best. I thought WP-o-Matic and FeedWordPress also did excellent jobs.
After activating your syndication plugin you tell it which feeds to pull and all the ones I looked at gave you several options for credit, links how much of the feed entry to post ect.
Now you shouldn’t have to be told you should only be pulling your own content as I’m doing, or content from other blogs where you have permission. It can be a great way to consolidate your blogs or promote other’s blogs.
You should also only use partial feeds to keep the search engine gods happy, and clicking on the title of the post should take your viewer to the original entry not wandering around the consolidated site.
One problem I had is that I couldn’t fetch 4 of my 13 feeds. I have no idea what or why so what I did was great a Yahoo Pipe of all my blog feeds, then have the syndication plugin grab that feed.
Magpierss allows you to easily build portals
TimesToCome was once a bleeding edge website. The splash page had a black starry background with a javascript ufo flying around as any self respecting cool website did in the 1990s. Times changed, and animations fell from favor so it went static. Over time the designs changed but the splash page remained just a link list to various sections of the website. TimesToCome was late moving to a blog setup. It is even later in becoming a portal, but better late than never.
RSS feeds can be used to create portals or to being live, current information to your blogs. Magpierss is built into WordPress. So you can easily use it to bring your other blogs rss feeds into your main blog, or to bring breaking news in your subject area to your blog with a custom rss.
TimesToCome was broken up and spread across eight blogs when I modernized it. The portal grabs the rss feeds from all eight blogs using magpierss.
If you need to install magpierss download it and follow the directions in the “INSTALL” file. It was the simplest install of any web software I’ve look at yet.
Be very sure to follow the directions to set up the cache. If you do not then every time the page loads it will grab fresh copies of the feeds slowing it down as well as any sites it is pulling rss feeds from.
Included in magpie are a README file and a cookbook file. Both contain examples of how to use magpierss. You can just cut and paste the examples and change the names to protect the innocent.
If you are pulling a bunch of feeds and using more than the links, be sure to leave lots of white space in your layout. I’m not a design person. The design took me about four times as long to put together as did the code. But it is simple to remember to use large margins and lots and lots of white space to make things legible. I also used the Coppermine script I wrote as a WordPress plugin to bring in three feeds of latest photos to the portal. It breaks up all the text.
So in summery, if you want to build a portal or incorporate live rss into your site use magpierss. If you are using WordPress it is already installed you just need to read the directions.
TimesToCome portal splash page. I refer to it as ‘The Wonder of me page’. ;D
Herself’s Green Things carries just the garden and houseplant blog rss feeds and photos.
