$folderName = stripslashes($_GET['fldr']);
$picName = stripslashes($_GET['pic']);
//printf("$folderName ");
$dir = "/home/users/web/b2603/dom.rsmcclure75/public_html/webservice5/bobandemily/kids/pictures/" . $folderName;
$fileArray = array();
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false)
{
if( $file != "." && $file != ".." ){
$fileArray[] = $file;
}
}
closedir($dh);
}
}
//sort
sort($fileArray);
//find our pic
//printf("$picName ");
$picIndex = 0;
$numPics = 0;
$done = false;
foreach($fileArray as $file){
// printf("$file ");
if( $done == false ){
if( strcmp( $picName, $folderName . "/" . $file) == 0 ){
$done=true;
}else{
$picIndex++;
}
}
if( substr( $file, 0, 3 ) == "tn_" ){
break;
}else{
$numPics++;
}
}
//printf("$picIndex / $numPics ");
//make next and back
$lastPic = "";
$nextPic = "";
if( $picIndex < $numPics )
{
if( $picIndex > 0 ){
$lastPicName = stripslashes( $fileArray[$picIndex-1] );
$lastPic = "<<< last pic";
}
if( $picIndex < $numPics-1 ){
$nextPicName = stripslashes( $fileArray[$picIndex+1] );
$nextPic = "next pic >>>";
}
}
?>
|