Copy the following code to an index.php file, and drop it into a folder full of webpages with date-formatted filenames, and visitors will go straight to the latest page.
<?php
###################################################
# AUTO LAST LINK INDEX PAGE by Carson Fire #
###################################################
# Drop this in a folder, and users will always #
# be directed to the latest update. #
###################################################
# Your files should have an 8-digit date string #
# somewhere, formatted this way: yyyymmdd #
# #
# 20090126.php, cotc20090126a.php,
# el-20090126-kungfu.php, etc.
# #
# If this string begins at the beginning, set #
# $datestart to "0". If your files have a prefix, #
# then adjust the number. Add to zero the number #
# of characters in the prefix. For example, 4 for #
# "cotc", 3 for "el-". #
$datestart = "0";
# $pagetype should be the file extension of your #
# web pages, including the dot. #
$pagetype = ".php";
# Leave $timezone blank for your server's default #
# server timezone. Change to "gmt" for GMT/UTC. #
$timezone = "gmt";
# That's it! You shouldn't have to edit more. #
###################################################
$num = strlen($pagetype);
$current = time();
if ( $timezone = "gmt" ) {
$year = gmdate("Y",$current);
$current = gmdate("Ymd",$current);
} else {
$year = date("Y",$current);
$current = date("Ymd",$current);
}
$dir = opendir("./");
$batch = array();
while (($files = readdir($dir))!==false) {
if (is_numeric(substr($files,$datestart,8)) &&
(substr($files,$datestart,4)) == $year &&
(substr($files,$datestart,8)) <= "$current" &&
(substr($files,-$num,$num)) == $pagetype ) {
$batch[] = $files; } }
closedir($dir);
sort($batch);
reset($batch);
$f = count($batch);
$goto = $batch[($f-1)];
echo("<script language=\"javascript\">");
echo("top.location.href = \"$goto\";");
echo("</script>");
?>