# URLs for this page are in the form: # rjw_image_viewer.php?IMGNAME=pic.gif # useful PHP URLs at http://uk.php.net/manual/en/ref.array.php # # RJW 17 Nov 2004 # There is nothing to alter in this page, just rename it as desired and dump in a directory. # NOTE: renaming it index.php works, but unlike index.html you MUST write it in the path. $phpdir=getcwd(); # get your current directory # URL is something like http://msslhx.mssl.ucl.ac.uk/~rjw/mssl_only/fte/rjw_image_viewer.php?IMGNAME=fte_005_004.png $fullURL = explode("/",$_SERVER['SCRIPT_FILENAME']); # get URL and split on / $URL = array_pop($fullURL); # Take final part $URLbits = explode("?",$URL); # split on ? in case there are any additions on the end of the file name $thisfilename = array_shift($URLbits); # End up with "rjw_image_viewer.php" $dh = opendir($phpdir); while (false !== ($filename = readdir($dh))) { $list[] = $filename; } sort($list); $file=""; if ($_GET[IMGNAME]) { $file= $_GET[IMGNAME]; if (strlen($file) >100 ) { $file=""; } # Stop huge strings breaking it. } $flag=0; $z=0; $n= count ($list); while ($z<$n) { if ( preg_match("/[\.][pP][nN][gG]$/", $list[$z]) || preg_match("/[\.][gG][iI][fF]$/", $list[$z]) || preg_match("/[\.][jJ][pP][gG]$/", $list[$z]) ) { # Allow png, gif and jpg files $listnew[]=$list[$z]; if ($file == $list[$z]) { $flag=$flag+1;} } $z=$z+1; } $list=$listnew; if ($flag == 1) { # great, found the requested image in the list } else { # Didn't find it, so show all list. $file=""; } ?>
if ($file == "") { $titleText = "Example plotcf plots"; } else { $titleText = "Plot: $file"; } ?>List of all ".count ($list)." example plots
\n"; print "".$list[$z]." | \n"; if (($z+1)/2 == floor (($z+1)/2) ) { print "
List of all ".count ($list)." example plots
\n"; print ""; print "".$prevfileP.""; print " | \n";
print "(".($key+1)." of ".count ($list).") "; print "".$fileP.""; print " | \n "; print "".$nextfileP.""; print " | \n
";
print " | \n