283 votes
7,939 views
34 downloads
Author: admin
Posted: January 01st 2008
Did this snippet help you out? If so send this person some money!
This text file contains all the dates you want to display a particular
URL, directory, directory to image, or what ever, as long as each line
only has one space. The format of each line is YYYY-MM-DD URL/Link
if your URL/Link requires a space, use %20 instead of a space.
Default is the default image to use if none match, it MUST be first
in the list in order for this to work.default /logo/logo.gif
2007-04-01 /images/logo1.gif
2007-06-05 /images/logo2.gif
2007-08-10 /images/logo3.gif
2007-09-30 /images/logo4.gif
2007-12-25 /images/logo5.gif
<?php
function imagedate(){
$filename = "dateText.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
$array = explode("n",$contents);
foreach($array as $item){
$arr = explode(" ",$item);
if(date("Y-m-d") == $arr[0]){
$val = $arr[1];
$rtur = TRUE;
break;
}else{
$rtur = FALSE;
}
}
if($rtur){
return $val;
}else{
$def = explode(" ",$array[0]);
return $def[1];
}
}
$url = imagedate();
echo '<a href="'.$url.'">'.$url.'</a>';
?>