Webcam script

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <HTML> <HEAD> <TITLE>STELLA WebCam</TITLE> <META NAME="author" CONTENT="Michael Weber"> <META HTTP-EQUIV="Reply-to" CONTENT="mweber@aip.de"> <meta http-equiv="expires" content="600"> </HEAD> <BODY bgcolor=white link=red vlink=red text=black> <center> <h2>Latest image</h2> (updated every 10 minutes)<br> <font size="-1">Some <a href="webcam-info.html">info</a> about the Webcam and its location</font> <p> <?php // Script to display the current Webcam image and links to archived images // mweber@aip.de, July 2002 // Name is webcam.php $scripname = "webcam.php"; $basedir = "webcam/"; $defaultimage = "stella-latest.jpg"; if ( $what == "" || file_exists(sprintf("$basedir%s",$what))==FALSE ) $what = $defaultimage; if ( $format == "") $format = "short"; echo "<img src=\"$basedir$what\" alt=\"Stella Webcam image\">\n"; echo "<h2>Recent images</h2>"; function GetDirArray($sPath, $sMatch, $sTimeDiff) { $now=time(); $handle=opendir($sPath); while (false !== ($file = readdir($handle))) { if ( ereg($sMatch, $file) ) { $fName = "$sPath/$file"; $fTime = filemtime($fName); $diff = $now-$fTime; if ($diff <= $sTimeDiff || $sTimeDiff == 0) { $fileArr[$file] = $fTime; } } } closedir($handle); arsort($fileArr); return $fileArr; } if ($format == short) // 1 week $timediff = 604800; else if ($format == long) // 1 month (30 days) $timediff = 2592000; else // all $timediff = 0; // // 1st param is directory name // 2nd is regexp for the images (.jpg$ lists all files ending with .jpg) // 3rd is the maximum age (in seconds) for the displayed archived images // $iArr = GetDirArray("$basedir", ".jpg$", $timediff); $num = sizeof($iArr); for($t=0;$t<$num;$t++) { $thisFile = each($iArr); $thisName = $thisFile[0]; $then = $thisFile[1]; $a_then=getdate($then); if ( $a_then["yday"] != $prevday) { echo "<br>\n"; echo strftime("%A %x: ",$then); } $prevday=$a_then["yday"]; echo "<a href=\"$scriptname?what=$thisName&format=$format\">"; echo strftime("%H:%M",$then)."</a>\n"; } echo "<p>"; if ( $format != "short" ) echo "<a href=\"$scriptname?what=$what&format=short\">last week's images</a> |\n"; else echo " <em>last weeks images</em> |\n"; if ( $format != "long" ) echo "<a href=\"$scriptname?what=$what&format=long\">last month's images</a> |\n"; else echo " <em>last month's images</em> |\n"; if ( $format != "all" ) echo " <a href=\"$scriptname?what=$what&format=all\">all images</a>\n"; else echo " <em>all images</em>\n"; echo "</center></BODY></HTML>\n"; ?>