\n"; print "\n"; if ($mode == "album" or $mode == "view") { print "PHPix: $album\n"; } else { print "PHPix: List of Albums\n"; } print "\n"; print "\n"; print "
\n"; print "
"; print ""; print "\n"; set_time_limit(0); $handle=opendir("$pix_base/$album"); $colcounter = 0; while (($file = readdir($handle)) != '') { if (preg_match("/.*\.jpg/i",$file) and !preg_match("/__scaled_/",$file) ) { $filelist[] = $file; } } rewinddir($handle); while (($file = readdir($handle)) != '') { if (is_dir($realbase . "/$album/" . $file) and $file != "." and $file != ".." ) { $dirlist[] = $file; } } is_array($dirlist) and sort($dirlist); is_array($filelist) and sort($filelist); $totalfiles = sizeof($filelist); print ""; for ($i = 0 ; $i < sizeof($dirlist) ; $i++) { $dirname = $dirlist[$i]; if ($colcounter == $display_cols) { print "\n"; $colcounter = 0; } print "\n"; $colcounter++; } for ($x = $start ; $x < $start+$items_per_page and $filelist[$x] ; $x++) { $file = $filelist[$x]; if ($colcounter == $display_cols) { print "\n"; $colcounter = 0; } if (is_dir($realbase . "/$album/" . $file)) { print "\n"; $colcounter++; } else if (preg_match("/.*\.jpg/i",$file)) { $sourcefile = "$realbase/$album/$file"; preg_match("/(.*)\.jpg/i",$file, $parts); $thumbpic = "$parts[1]__scaled_$thumb_size.jpg"; $thumbfile = "$dynbase/$album/$thumbpic"; checkDir("$dynbase/$album"); /* if (!file_exists("$dynbase/$album")) { */ /* mkdir("$dynbase/$album",0755); */ /* } */ createImage($thumb_size, $sourcefile, $thumbfile, $thumb_border); $thumb_degree = getPreferredAngle($file); $thumb_degree = validate($thumb_degree); /* rotate thumbnail if necessary */ if ($thumb_degree) { $thumbpic = "$parts[1]__scaled_" . $thumb_size . "__rotated_" . $thumb_degree . ".jpg"; $rotated = "$dynbase/$album/$thumbpic"; rotateImage($thumbfile, $rotated, $thumb_degree); $thumbfile = $rotated; } $thumbsize = GetImageSize($thumbfile); $imgsrc = preg_replace('/ /',"%20", "/$dyn_base/$album/$thumbpic"); print "\n"; $colcounter++; } } for ($i = 0 ; $i < ($display_cols - $colcounter); $i++) { print "\n"; } print "\n"; print ""; } else if ($mode == 'view') { $handle=opendir("$pix_base/$album"); while (($file = readdir($handle)) != '') { if (preg_match("/.*\.jpg/i",$file) and !preg_match("/__scaled_/",$file) ) { $filelist[] = $file; } } sort($filelist); $picindex = -1; for($i=0 ; $i\n"; clearstatcache(); $sourcefile = "$realbase/$album/$pic"; $dlinksize = $dispsize; $srcsize = GetImageSize("$sourcefile"); if ($dispsize >= $srcsize[0]) { $dispsize = "Original"; } if ($dispsize == 'Original') { $viewfile = $sourcefile; $viewpic = $pic; preg_match("/(.*)\.jpg/i", $pic, $parts); $imgsrc = preg_replace('/ /',"%20","/$pix_base/$album/$viewpic"); } else { preg_match("/(.*)\.jpg/i",$pic, $parts); $viewpic = "$parts[1]__scaled_$dispsize.jpg"; $viewfile = "$dynbase/$album/$viewpic"; $imgsrc = preg_replace('/ /',"%20","/$dyn_base/$album/$viewpic"); } createImage($dispsize, $sourcefile, $viewfile); if (!$rotate) { $degree = getPreferredAngle($pic); } else { updatedPreferredAngle($degree, $pic); } $degree = validate($degree); /* rotate image */ if ($degree) { $viewpic = "$parts[1]__scaled_" . $dispsize . "__rotated_" . $degree . ".jpg"; $rotated = "$dynbase/$album/$viewpic"; rotateImage($viewfile, $rotated, $degree); $imgsrc = preg_replace('/ /',"%20","/$dyn_base/$album/$viewpic"); $viewfile = $rotated; } $viewsize = GetImageSize("$viewfile"); print ""; print "\n"; #if ($show_exif) { #$exif = read_exif_data($sourcefile); #while(list($k,$v)=each($exif)) { #echo "$k: $v
\n"; #} #} } print "
"; preg_match("/(.*\/).*$/",$SCRIPT_FILENAME,$matches); $realbase = $matches[1] . $pix_base; $dynbase = $matches[1] . $dyn_base; $imgbase = dirname($SCRIPT_NAME); ($imgbase == '/') and $imgbase = ''; if ($dispsize == '') $dispsize = $default_size; if ($start == '') $start = 0; if (preg_match("/\.\./",$pic) or preg_match("/\.\./",$album)) { print "Please refrain from trying to access unauthorized files in this manner.
"; print "Have a nice day."; } else if ($mode == 'home' or $mode == '') { print "

Albums:

\n"; $handle=opendir($pix_base); while (($file = readdir($handle)) != '') { if ($file != "." && $file != "..") { $alblist[] = $file; } } is_array($alblist) and sort($alblist); for ($i = 0 ; $i < sizeof($alblist) ; $i++) { PrintAlbumName($pix_base, $alblist[$i]); } closedir($handle); ## Album View (Thumbnails) } else if ($mode == 'album') { NavBar("album",$album,$start); print "
" . ""; print "$dirname\n"; print "
"; print "$file\n"; print "" . ""; print "
$file\n"; print "
\n"; print "
\n"; print "Start | "; if ($start > 0) { print "Prev $items_per_page | "; } else { print "Prev $items_per_page | "; } if ($totalfiles > $x) { print "Next $items_per_page | "; } else { print "Next $items_per_page | "; } print ""; if ($totalfiles > 0) { print "Images " . ($start+1) . " to $x of $totalfiles
\n"; } else { print " "; } print "
"; print ""; print "
\n"; print "\n"; } print "\n"; print ""; ############ print "\n"; } $totalfiles = sizeof($filelist); #print "Charcoal\n"; #print " | Paint\n"; #print " | Shade\n"; #print "
\n"; print "
\n"; if ($filelist[($picindex-1)] != '') { $prevfile = $filelist[($picindex-1)]; $sourcefile = "$realbase/$album/$prevfile"; preg_match("/(.*)\.jpg/i",$prevfile,$parts); checkDir("$dynbase/$album"); /* if (!file_exists("$dynbase/$album")) { */ /* mkdir("$dynbase/$album",0755); */ /* } */ $thumbpic = "$parts[1]__scaled_$thumb_size.jpg"; $thumbfile = "$dynbase/$album/$thumbpic"; createImage($thumb_size, $sourcefile, $thumbfile, $thumb_border); $thumb_degree = getPreferredAngle($prevfile); $thumb_degree = validate($thumb_degree); /* rotate thumbnail if necessary */ if ($thumb_degree) { $thumbpic = "$parts[1]__scaled_" . $thumb_size . "__rotated_" . $thumb_degree . ".jpg"; $rotated = "$dynbase/$album/$thumbpic"; rotateImage($thumbfile, $rotated, $thumb_degree); $thumbfile = $rotated; } $thumbsize = GetImageSize($thumbfile); $imgsrc = preg_replace('/ /',"%20","/$dyn_base/$album/$thumbpic"); print ""; print "<-Prev
"; } else { print "
"; print "
\n"; print "\n"; print "\n"; print "\n"; print ""; print "
(Original Photo Size = $srcsize[0]x$srcsize[1])
\n"; /* print combobox for rotation here. Right now, only ImageMagick is supported. */ global $ImageTool; if ($ImageTool == "im" && $show_rotation_controls) { $degrees = array(0, 90, 180, 270); print "
\n"; print ""; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print ""; print "
\n"; } print "
\n"; if ($filelist[($picindex+1)] != '') { $nextfile = $filelist[($picindex+1)]; $sourcefile = "$realbase/$album/$nextfile"; preg_match("/(.*)\.jpg/i",$nextfile,$parts); checkDir("$dynbase/$album"); #if (!file_exists("$dynbase/$album")) { #mkdir("$dynbase/$album",0755); #} $thumbpic = "$parts[1]__scaled_$thumb_size.jpg"; $thumbfile = "$dynbase/$album/$thumbpic"; createImage($thumb_size, $sourcefile, $thumbfile, $thumb_border); $thumb_degree = getPreferredAngle($nextfile); $thumb_degree = validate($thumb_degree); /* rotate thumbnail if necessary */ if ($thumb_degree) { $thumbpic = "$parts[1]__scaled_" . $thumb_size . "__rotated_" . $thumb_degree . ".jpg"; $rotated = "$dynbase/$album/$thumbpic"; rotateImage($thumbfile, $rotated, $thumb_degree); $thumbfile = $rotated; } $thumbsize = GetImageSize($thumbfile); $imgsrc = preg_replace('/ /',"%20","/$dyn_base/$album/$thumbpic"); print ""; print "Next ->
"; print "
"; } else { print "
\n"; print "Generated by PHPix $version"; print "
\n"; print "\n"; print "\n"; ?>