Archive

Archive for March, 2009

strip_tags_smart: strip_tags Enhancement for PHP

March 29th, 2009 1 comment

If you’re working with various HTML in PHP, then you probably know that strim_tags doesn’t deal with all correctly. There are some problems with JS elements, with Microsoft , etc. In order to get clean text, there is a function that holds all these exceptions. Its name is _smart. You’re welcome to check its description here and the download link is located at dklab forum. Since the function uses GNU license, I won’t post any modified elements, you’re welcome to customize it in the way you like.

How to Check Last Modified Date For All Files in a Folder with PHP

March 28th, 2009 No comments

This function will help you if you need to monitor folders for recently changed files, or you may implement it as an anti-hacker solution to check your files. Anyway, I think you find it useful.

<?

//Put here the directory you want to search for. Put / if you want to search your entire domain
$dir=’/var/www/html/domain.com/download’;

//Put the date you want to compare with in the format of:  YYYY-mm-dd hh:mm:ss
$comparedatestr=”2009-03-25 00:00:00″;
$comparedate=($comparedatestr);

//I run the function here to start the search.
$go=modified_time($dir,$comparedate);

var_dump($go);

//This is the function which is doing the search…
function modified_time($address,$comparedate){

$files=array();
@$dir = opendir($address);

if(!$dir){ return 0; }
while($entry = readdir($dir)){
if(is_dir(“$address/$entry”) && ($entry != “..” && $entry != “.”)){
modified_time(“$address/$entry”,$comparedate);
}
else   {

if($entry != “..” && $entry != “.”) {

$fulldir=$address.’/’.$entry;
$last_modified = filemtime($fulldir);
$last_modified_str= date(“Y-m-d h:i:s”, $last_modified);

if($comparedate < $last_modified)  {
$files[$fulldir]=$last_modified_str;
}

}

}

}

return($files);

}
?>

In the sample above we’re getting the list of files that are older than the specified date into an array. We’re taking file paths into array keys and into values. I’ve performed var_dump to show the structure of this array. The original code of this function was found at PHP website.  Hope you like it.

Great Tool To Filter Adsense Ads Shown on Your Site

March 26th, 2009 No comments

If you manage many sites that take profits from Adsense advertising, then you probably know that irrelevant ads are often shown on your pages. This means your visitors won’t click on them and you are simply losing your profits. I have discovered the software that allows to filter these ads by advertisers, as if you’re running a niche site, the advertiser selection isn’t so great. Software I’m talikng about is AdSense Preview Tool . Let me list all the features annonuced:

  • grouping of websites and URLs;
  • flexible geo-targeting settings;
  • automatic checking of advertisers’ websites;
  • ads separation: normal, non-relevant and MFA;
  • sorting of the filter items by an actuality;
  • automatic deletion of old filter items.

There is a free trial available on the site. You’re welcome to try it by yourself, but I think that this software is worth its money.

Adsense Compliant Privacy Policy Page For WordPress

March 24th, 2009 1 comment

Recently I got an e-mail from Google telling me I need to update on my sites. Since I manage may WordPress blogs, that was not a good news from me as I had to update absolutely all sites to create varions pages. I was happy to know that Eric Giguere has created a WordPress plugin named Privacy Policy.

All you need is to download the plugin and extract its contents in default WordPress Plugin Directory. Then it will appear under “Settings” tab where you can customize the output.

This nice plugin will save a lot of time for those who deal with multiple sites that show Google Adsense.  It has been recemtly updated to show privacy policy that is compliant to latest Google guidelines. Must have!