<?php
if(!function_exists('remove_unused_png'))
{
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Desc
#
function remove_unused_png($dir,$file_wild,$older_than_days='2')
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
list($file_name,$file_ext)=explode('.',$file_wild);
$dd=@opendir($dir) or die('Impossible to read directory: '.$dir.' (remove_unused_png.inc)');
$today=date('Ymd');
while($dir_entry=@readdir($dd))
{
if($dir_entry!='.' && $dir_entry!='..')
{
$temp=explode('.', $dir_entry);
$entry_name=$temp[0];
$entry_ext =$temp[count($temp)-1];
if($file_name=='*' && $entry_ext==$file_ext)
{
$file_date =date('Ymd',filemtime($dir.'/'.$dir_entry));
$check_date=$today-$file_date;
if($check_date>=$older_than_days) { @unlink($dir.'/'.$dir_entry); }
}
}
}
@closedir($dd);
}
}
?>