# 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" $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } $slashpos = strrpos($pageURL, "/"); $DIR = substr($pageURL,0,$slashpos+1); $dh = opendir($phpdir); while (false !== ($filename = readdir($dh))) { $list[] = $filename; } sort($list); $file=""; if ($_GET[IMGNAME]) { $file= $_GET[IMGNAME]; $efile=substr($file,5,3).'-'.substr($file,19,4); if (strlen($file) >100 ) { $file=""; } # Stop huge strings breaking it. } $flag=0; $z=0; $n= count ($list); while ($z<$n) { # if ( preg_match("/[\.][jJpP][nNpP][gG]$/", $list[$z]) ) { # Allow png, gif and jpg and ps files #preg_match('#^http:\/\/(.*)\.(gif|png)$#i' if ( preg_match("/CLUSTER/", $list[$z]) ) { $listnew[]=$list[$z]; if ($file == $list[$z]) { $flag=$flag+1; $eventl[$z]=substr($list[$z],5,3).'-'.substr($list[$z],19,4); } } $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=""; } ?>
".$outmonth." ".$outyear." AAR Perigee Passes
\n"; print "".substr($list[$z],0,4)." DOY ".substr($list[$z],4,3)." ".substr($list[$z],7,4)." | \n"; # print "".substr($list[$z],0,8)." | \n"; # if (($z+1)/4 == floor (($z+1)/4) ) { print "
Back to Index
\n"; $ndays = count($list)/4; print "AAR Pass ".floor(($key/4)+1)." of ".$ndays." in current month"; # print "".$prevfile.""; print " | \n";
# print "(".($key+1)." of ".count ($list).") "; # print "".$file.""; print " | \n "; # print "".$nextfile.""; print " | \n
"; #print " "; print " "; print " "; print " "; print " | \n"; print " "; print " "; print " | \n|
"; print " "; print " "; print " "; print " | \n"; print " "; print " "; print " "; print " | \n
Back to Index
\n"; } #print $URL."\n"; ################################################ /*********************************************************************** * Use * * $needle // The item you are looking for * $array // The array you are searching in * * // Return the key * $array_key = array_searcher($needle, $array); * echo "The array's key is : " . $array_key; ***********************************************************************/ function array_searcher($needle, $array) { // Make sure a valid array was passed if(!is_array($array)) { return "Not a valid array"; } // Loop through each part of the array foreach ($array as $key => $item) { // Inner loop foreach($item as $entity) { // Found a match, return the key if ($entity == $needle) { return $key; } } } } ######################################################## ?>