function caption_for_image($filename, $referer) { $content = file($referer); $index = -1; for($i = 0; $i < sizeof($content); $i++) { if(strpos($content[$i], $filename) !== false) { // Found the filename. Now find the caption... $index = $i + 2; break; } } if($index == -1) return("Untitled"); $caption = $content[$index]; // $caption = strip_tags($caption); // $caption = str_replace('\t', '', $caption); // $caption = str_replace('\n', '', $caption); return($caption); } function is_image_file($filename) { return( ( strpos(strtolower($filename), '.jpg') !== false || strpos(strtolower($filename), '.gif') !== false ) && strpos(strtolower($filename), 'tn_') === false ); } if(!isset($colour)) { $colour = "blue"; } if(!isset($image)) { $image = "./lg.gif"; } ?>
if(!isset($referer)) { $url = parse_url($HTTP_REFERER); $referer = $url["path"]; while(!is_file($referer) && $referer != "") { $referer = substr($referer, strpos($referer, "/") + 1); } } $dirname = dirname($image); $handle = opendir($dirname); $i = 0; while($file = readdir($handle)) { $fullname = $dirname.'/'.$file; if(is_file($fullname) && is_image_file($fullname)) { $images[] = $fullname; $thumbs[] = $dirname.'/tn_'.$file; if($fullname == $image) $index = $i; $i++; } } $firstfile = $images[0]; $nextfile = $images[$index + 1]; $prevfile = $images[$index - 1]; $lastfile = $images[sizeof($images) - 1]; $nextthumb = $thumbs[$index + 1]; $prevthumb = $thumbs[$index - 1]; $nextnextthumb = $thumbs[$index + 2]; $prevprevthumb = $thumbs[$index - 2]; ?>|
if($prevprevthumb != "") { ?>
if($image != $firstfile) { ?> << First } if($prevfile) { ?> < Prev } ?> |
echo caption_for_image($image, $referer) ?> |
if($nextthumb != "") { ?>
if($nextfile) { ?> Next > } if($image != $lastfile) { ?> Last >> } ?> |
|
|
||