Herself's Webtools

Scripts, HowTos, Templates, Plugins, Widgets, Tips

Archive for the ‘tools’ Category

Check for altered files on webhost

without comments

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 );

?>

Written by Linda MacPhee-Cobb

September 13th, 2009 at 11:59 am

Posted in php,security,tools

Magazine style automatically updated WordPress blogs

without comments

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.

blog-splash

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.

Written by Linda MacPhee-Cobb

January 15th, 2009 at 5:00 am