<?
/*
*eye/index.php
* the pictures and whatnot on the site.
*/
define("IMGDIR","./pics"); //the picture directory
/*showLinks
* @params: st, where to start listing from
* @returns: none
* show the thumbnailed images from the directory
*/
function showLinks($st) {
$st = (int)$st; //where to begin the array display
$files = array(); //grab the array of files so we can sort it
$dir = dir(IMGDIR);
$i = 0;
while($file = $dir->read()) {
if(preg_match("/(_thumb\.(jpg|gif|png))$/",$file)
&& !(is_dir($file))) { //only get _thumbs, since those are thumbnails
//print("<br />" .filemtime(IMGDIR . "/$file")."<br />$file");
//use the $i++ so all files show. otherwise, files with
//the same mtime overwrite each other
$files[filemtime(IMGDIR . "/$file") . "-" . $i++] = $file;
} //end if
} //end while
$dir->close();
krsort($files); //sort the array by timestamp
$ct = count($files); //for the paging
$files = array_slice($files,$st,30); //only use the part we need
if(count($files) == 0) { //no images :(
print("Under construction... please check again later");
} else {
print("<table cellpadding=\"3\" cellspacing=\"2\" border=\"0\">\n<tr>");
//now we have the list, so lets start where we should
//and show the links
$i=1;
foreach($files as $time=>$img) {
$time = strftime("%m.%d.%Y",preg_replace("/-\d+/","",$time));
print("<td><a href=\"showpic.php?p=" .urlencode($img).
"\"><img src=\"pics/$img\" border=\"0\" alt=\"dated: $time\" />
</a></td>");
if($i % 3 == 0) print("</tr>\n<tr>"); //for the line breaks
$i++;
} //end foreach
while(true){ //fill any possible gaps
print("<td> </td>");
if($i++ % 3 == 0) break;
} //end while
print("</tr><tr><td colspan=\"7\" align=\"center\">");
//begin paging mech
for($i=0;$i<$ct;$i+=29) {
print("<a href=\"index.php?st=$i\">" . ($i/29 + 1) . "</a> | ");
} //end for
} //end if
} //end if
require("../includes/header.php");
print("<div class=\"header\" style=\"padding-bottom: 10px;\">images </div>");
showLinks($HTTP_GET_VARS["st"]);
require("../includes/footer.php");
?>