$size[1]) {//fat images $srcSizeX = $size[1]; $srcSizeY = $size[1]; $srcY = 0; $srcX = ($size[0]-$size[1])/2; } else if($size[0]<$size[1]) { //tall images $srcSizeX = $size[0]; $srcSizeY = $size[0]; $srcX = 0; $srcY = ($size[1]-$size[0])/2; } else { //square $srcY = 0; $srcX = 0; $srcSizeX = $size[0]; $srcSizeY = $size[0]; } $yoffset = 0; //draw in dest at 0,0 $xoffset = 0; $newWidth = $dim; $newHeight = $dim; } else { if($size[0]>$size[1]) { //fat images $ratio = $size[0]/$dim; $newWidth=$dim; $newHeight = round($size[1]/$ratio,0); } else if($size[0]<$size[1]) { //tall images $ratio = $size[1]/$dim; $newWidth= round($size[0]/$ratio,0); $newHeight = $dim; } else { //square $newWidth = $dim; $newHeight = $dim; } $srcSizeX = $size[0]; $srcSizeY = $size[1]; $srcY = 0; //draw from src at 0,0 $srcX = 0; $yoffset = ($dim-$newHeight)/2; //draw in dest at offset $xoffset = ($dim-$newWidth)/2; if($yoffset<0) $yoffset=0; if($xoffset<0) $xoffset=0; } //make the new image if($gd_Version>=2) $destImage = imagecreatetruecolor( $dim, $dim); else $destImage = ImageCreate( $dim, $dim); $color = ImageColorAllocate($destImage,$image_bkgd[0],$image_bkgd[1],$image_bkgd[2]); imagefill($destImage, 0, 0, $color); //paint it white first //copy the passed image into the new image at the proper scale if($gd_Version>=2) imagecopyresampled( $destImage, $im, $xoffset, $yoffset, $srcX, $srcY, $newWidth, $newHeight, $srcSizeX, $srcSizeY ); else ImageCopyResized( $destImage, $im, $xoffset, $yoffset, $srcX, $srcY, $newWidth+1, $newHeight+1, $srcSizeX, $srcSizeY ); ImageDestroy($im); //clean up the old image if(checkExifversion()==1 && $autorotate==1) { $details = @exif_read_data($path); if(!empty($details['Orientation'])) { switch($details['Orientation']) { case 1: $rotation = 0; break; case 3: $rotation = 180; break; case 8: $rotation = 90; break; case 6: $rotation = 270; break; default: $rotation = 0; break; } if ($rotation>0) $destImage = @imagerotate($destImage,$rotation,$color); } } return $destImage; //return the new image } function makeSquareSIPS($path, $save, $dim) { global $image_crop; if($image_crop==1) { //zoom in and crop square $size = @GetImageSize($path); if($size[0]>$size[1]) $size[0] = $size[1]; $command = "sips -s format jpeg --cropToHeightWidth ".$size[0]." ".$size[0]." ".escapeshellarg($path)." --out ".escapeshellarg($save); exec($command); $command = "sips --resampleHeightWidthMax ".$dim." ".escapeshellarg($save); exec($command); } else { //pad it $command = "sips -s format jpeg --resampleHeightWidthMax ".$dim." --padToHeightWidth ".$dim." ".$dim." ".escapeshellarg($path)." --out ".escapeshellarg($save); exec($command); } if(checkExifversion()==1) { $details = @exif_read_data($path); if(!empty($details['Orientation'])) { switch($details['Orientation']) { case 1: $rotation = 0; break; case 3: $rotation = 180; break; case 6: $rotation = 90; break; case 8: $rotation = 270; break; default: $rotation = 0; break; } if($rotation>0) { //rotate it $command = "sips --rotate ".$rotation." ".escapeshellarg($save); exec($command); } } } } function makeScaled($path, $dim) { //This function will resize the image keeping the same aspect ratio //the max width or height will be $dim global $image_bkgd; $gd_Version = checkGDversion(); if($gd_Version<1) return -1; if(stristr($path,".png")) $im = @imagecreatefrompng($path); else $im = @imagecreatefromjpeg($path); if(!$im) return -1; $size = @GetImageSize($path); if(checkExifversion()==1 && $autorotate==1) { $details = @exif_read_data($path); if(!empty($details['Orientation'])) { switch($details['Orientation']) { case 1: $rotation = 0; break; case 3: $rotation = 180; break; case 8: $rotation = 90; break; case 6: $rotation = 270; break; default: $rotation = 0; break; } if ($rotation>0) { $im = @imagerotate($im,$rotation,0); if($rotation==90 || $rotation==270) { $temp = $size[0]; $size[0]=$size[1]; $size[1]=$temp; } } } } if($size[0]<=$dim && $size[1]<=$dim) return $im; if($size[0]>$size[1]) { //fat images $ratio = $size[0]/$dim; $newWidth=$dim; $newHeight = round($size[1]/$ratio,0); } else if($size[0]<$size[1]) { //tall images $ratio = $size[1]/$dim; $newWidth= round($size[0]/$ratio,0); $newHeight = $dim; } else { //square $newWidth = $dim; $newHeight = $dim; } //make the new image if($gd_Version>=2) $destImage = imagecreatetruecolor( $newWidth, $newHeight); else $destImage = ImageCreate( $newWidth, $newHeight); $color = ImageColorAllocate($destImage,$image_bkgd[0],$image_bkgd[1],$image_bkgd[2]); imagefill($destImage, 0, 0, $color); //paint it white first //copy the passed image into the new image at the proper scale if($gd_Version>=2) imagecopyresampled( $destImage, $im, 0, 0, 0, 0, $newWidth, $newHeight, $size[0], $size[1] ); else ImageCopyResized( $destImage, $im, 0, 0, 0, 0, $newWidth+1, $newHeight+1, $size[0], $size[1] ); ImageDestroy($im); //clean up the old image return $destImage; //return the new image } function makeScaledSIPS($path, $save, $dim) { $command = "sips -s format jpeg --resampleHeightWidthMax ".$dim." ".escapeshellarg($path)." --out ".escapeshellarg($save); exec($command); if(checkExifversion()==1) { $details = @exif_read_data($path); if(!empty($details['Orientation'])) { switch($details['Orientation']) { case 1: $rotation = 0; break; case 3: $rotation = 180; break; case 6: $rotation = 90; break; case 8: $rotation = 270; break; default: $rotation = 0; break; } if($rotation>0) { //rotate it $command = "sips --rotate ".$rotation." ".escapeshellarg($save); exec($command); } } } } //Scans the directory and puts the photo names in an array function getPhotoList($path) { global $sort_method; $photos = array(); $srcTime=0; $extra = 1000; if(!is_dir($path)) return -1; if($d = dir($path)) { while (false !== ($entry = $d->read())) { $extra++; if(stristr($entry,".jpg") || stristr($entry,".png")) { if($sort_method>2) $srcTime = @filemtime($path."/".$entry).$extra; else $srcTime++; $photos[$srcTime] = $entry; } } $d->close(); } else { return -2; } if($sort_method==1) asort($photos); if($sort_method==2) arsort($photos); if($sort_method==3) ksort($photos); if($sort_method==4) krsort($photos); return $photos; } //Scans the directory and puts the sub-directory names in an array function getDirList($path) { global $sort_method; $dirs = array(); $srcTime=0; $extra = 1000; if(!is_dir($path)) return -1; if($d = dir($path)) { while (false !== ($entry = $d->read())) { $extra++; if(substr($entry,0,1)!="." && !eregi("_cache",$entry) && is_dir($path."/".$entry)) { if($sort_method>2) $srcTime = filemtime($path."/".$entry).$extra; else $srcTime++; $dirs[$srcTime] = $entry; } } $d->close(); } else { return -2; } if($sort_method==1) asort($dirs); if($sort_method==2) arsort($dirs); if($sort_method==3) ksort($dirs); if($sort_method==4) krsort($dirs); return $dirs; } function truncate($name, $len) { global $show_extension; if($show_extension==0) $name = substr($name,0, strrpos($name,".")); if(strlen($name)<=$len) return $name; return substr($name,0,$len-1)."..."; } function rmdirR($dir) { $handle = opendir($dir); while (false!==($e = readdir($handle))) { if($e != "." && $e != "..") { if(is_dir("$dir/$e")) rmdirR("$dir/$e"); else @unlink("$dir/$e"); } } closedir($handle); $worked = @rmdir($dir); return $worked; } function sanatizePath($path) { $path = str_replace("..","",$path); //remove .. to prevent viewing higher directories $path = strip_tags($path); //remove html tags to prevent XSS return $path; } //END FUNCTIONS //START OUTPUT GENERATION $version = "2.51"; //login if(!empty($HTTP_POST_VARS['admin'])) { if(!empty($password) && $HTTP_POST_VARS['admin']==$password) { setcookie ("admin", md5($HTTP_POST_VARS['admin']), time() + 7200); $_COOKIE['admin']=md5($HTTP_POST_VARS['admin']); } else { setcookie ("admin", '', time() - 7200); $_COOKIE['admin']=""; } if(!empty($HTTP_POST_VARS['path'])) $HTTP_GET_VARS['path'] = $HTTP_POST_VARS['path']; if(!empty($HTTP_POST_VARS['file'])) $HTTP_GET_VARS['file'] = $HTTP_POST_VARS['file']; if(!empty($HTTP_POST_VARS['op'])) $HTTP_GET_VARS['op'] = $HTTP_POST_VARS['op']; } //logout if(!empty($HTTP_GET_VARS['admin'])) { setcookie ("admin", '', time() - 7200); $_COOKIE['admin']=""; } if(!isset($HTTP_GET_VARS['op'])) $HTTP_GET_VARS['op']=0; if(!empty($HTTP_GET_VARS['path'])) $HTTP_GET_VARS['path'] = sanatizePath($HTTP_GET_VARS['path']); if(!empty($HTTP_GET_VARS['file'])) $HTTP_GET_VARS['file'] = sanatizePath($HTTP_GET_VARS['file']); if(!empty($HTTP_GET_VARS['rename'])) $HTTP_GET_VARS['rename'] = sanatizePath($HTTP_GET_VARS['rename']); if(empty($HTTP_GET_VARS['path'])) $file_path = "."; else $file_path = "./".$HTTP_GET_VARS['path']; if(empty($HTTP_GET_VARS['path'])) $web_path = ""; else $web_path = $HTTP_GET_VARS['path']; if(!empty($HTTP_GET_VARS['file'])) $HTTP_GET_VARS['file'] = $HTTP_GET_VARS['file']; if(empty($web_path)) $slash=""; else $slash = "/"; //delete file or folder if(!empty($admin) && $admin==1 && isset($HTTP_GET_VARS['del']) && $HTTP_GET_VARS['del']==1 && (!empty($HTTP_GET_VARS['path']) || !empty($HTTP_GET_VARS['file'])) && !empty($_COOKIE['admin']) && $_COOKIE['admin']==md5($password)) { if(empty($HTTP_GET_VARS['file'])) { rmdirR($file_path); rmdirR("./_cache/".$HTTP_GET_VARS['path']); if($display_errors==1 && file_exists($file_path)) { echo "
".$l_del_fol_err."
"; } else { $array = split("/",$HTTP_GET_VARS['path']); array_pop($array); $HTTP_GET_VARS['path'] = implode("/",$array); if(empty($HTTP_GET_VARS['path'])) $file_path = "."; else $file_path = "./".$HTTP_GET_VARS['path']; if(empty($HTTP_GET_VARS['path'])) $web_path = ""; else $web_path = ($HTTP_GET_VARS['path']); if(empty($web_path)) $slash=""; else $slash = "/"; } } else { @unlink($file_path."/".$HTTP_GET_VARS['file']); @unlink("./_cache/".$HTTP_GET_VARS['path']."/_thumbnails/".$HTTP_GET_VARS['file']); @unlink("./_cache/".$HTTP_GET_VARS['path']."/_screen/".$HTTP_GET_VARS['file']); if($display_errors==1 && file_exists($file_path."/".$HTTP_GET_VARS['file'])) { echo "
".$l_del_fil_err."
"; } } } //regenerate cache for photo if(!empty($admin) && $admin==1 && isset($HTTP_GET_VARS['regen']) && $HTTP_GET_VARS['regen']==1 && (!empty($HTTP_GET_VARS['path']) || !empty($HTTP_GET_VARS['file'])) && !empty($_COOKIE['admin']) && $_COOKIE['admin']==md5($password)) { @unlink("./_cache/".$HTTP_GET_VARS['path']."/_thumbnails/".$HTTP_GET_VARS['file']); @unlink("./_cache/".$HTTP_GET_VARS['path']."/_screen/".$HTTP_GET_VARS['file']); $HTTP_GET_VARS['op'] = 5; } //rename folder or rename and add keyword/rating to file if(!empty($admin) && $admin==1 && !empty($HTTP_GET_VARS['rename']) && !empty($_COOKIE['admin']) && $_COOKIE['admin']==md5($password)) { if($HTTP_GET_VARS['rename']!=$HTTP_GET_VARS['file'] || $HTTP_GET_VARS['path']!=$HTTP_GET_VARS['movepath']) { $rename_path = str_replace("index.php","",$HTTP_SERVER_VARS["SCRIPT_FILENAME"]); if(empty($HTTP_GET_VARS['path'])) $slash=""; else $slash = "/"; if(empty($HTTP_GET_VARS['movepath'])) $moveslash=""; else $moveslash = "/"; $worked = @rename($rename_path.$HTTP_GET_VARS['path'].$slash.$HTTP_GET_VARS['file'],$rename_path.$HTTP_GET_VARS['movepath'].$moveslash.$HTTP_GET_VARS['rename']); if($worked===FALSE) { echo "
".$l_rename_err."
"; } if($HTTP_GET_VARS['renamewhat']==2) { //its a folder if($worked) @rename($rename_path."_cache/".$HTTP_GET_VARS['path'].$slash.$HTTP_GET_VARS['file'],$rename_path."_cache/".$HTTP_GET_VARS['movepath'].$moveslash.$HTTP_GET_VARS['rename']); if($worked) $HTTP_GET_VARS['path'] = $HTTP_GET_VARS['movepath'].$moveslash.$HTTP_GET_VARS['rename']; $file_path = "./".$HTTP_GET_VARS['path']; $web_path = $HTTP_GET_VARS['path']; } else if($HTTP_GET_VARS['renamewhat']==1) { //its a file if($worked) @rename($rename_path."_cache/".$HTTP_GET_VARS['path'].$slash."_thumbnails/".$HTTP_GET_VARS['file'],$rename_path."_cache/".$HTTP_GET_VARS['path'].$slash."_thumbnails/".$HTTP_GET_VARS['rename']); if($worked) @rename($rename_path."_cache/".$HTTP_GET_VARS['path'].$slash."_screen/".$HTTP_GET_VARS['file'],$rename_path."_cache/".$HTTP_GET_VARS['path'].$slash."_screen/".$HTTP_GET_VARS['rename']); if($worked) @rename($rename_path."_cache/".$HTTP_GET_VARS['path'].$slash."_photoinfo/".$HTTP_GET_VARS['file'].".txt",$rename_path."_cache/".$HTTP_GET_VARS['path'].$slash."_photoinfo/".$HTTP_GET_VARS['rename'].".txt"); if($worked) $HTTP_GET_VARS['file'] = $HTTP_GET_VARS['rename']; $HTTP_GET_VARS['op'] = 5; } } else { $HTTP_GET_VARS['op'] = 5; } $handle = @fopen("./_cache/".$web_path.$slash."/_photoinfo/".$HTTP_GET_VARS['file'].".txt", "wb"); @fwrite($handle,$HTTP_GET_VARS['rating']."\n"); @fwrite($handle,stripslashes($HTTP_GET_VARS['keywords'])."\n"); @fclose($handle); } //add a friend if(!empty($admin) && $admin==1 && !empty($HTTP_GET_VARS['friend']) && $HTTP_GET_VARS['friend']!="http://" && !empty($_COOKIE['admin']) && $_COOKIE['admin']==md5($password)) { $handle = @fopen($HTTP_GET_VARS['friend'], "rb"); $temp = @fgets($handle,1024); while(!stristr($temp,"")) { $temp = @fgets($handle,1024); } $title = trim(strip_tags($temp)); fclose($handle); $handle = @fopen("./_cache/friend.txt", "a"); @fwrite($handle,$HTTP_GET_VARS['friend']."\n"); @fwrite($handle,$title."\n"); fclose($handle); } //flatten subdirectories //LIMITATIONS: if the file/folder exist, it prefixes some random letters. Doesnt work on root. if(!empty($_GET['flatten'])) { $subdirs = getDirList($_GET['path']); foreach($subdirs as $s) { $flat_path = $_GET['path']."/".$s; if(is_dir($flat_path)) { if($d = dir($flat_path)) { while (false !== ($entry = $d->read())) { if(substr($entry,0,1)!="." && !eregi("_cache",$entry)) { $prefx=''; if(file_exists($_GET['path']."/".$entry)) { $prefx = substr(md5(uniqid("_")),0,3)."_"; } if(!file_exists($_GET['path']."/".$prefx.$entry)) { $worked = @rename($flat_path."/".$entry,$_GET['path']."/".$prefx.$entry); if($worked && is_dir($_GET['path']."/".$entry)) { //moved dir @rename("_cache/".$flat_path."/".$entry,"_cache/".$_GET['path']."/".$prefx.$entry); } else if($worked) { //moved photo @rename("_cache/".$flat_path."/_thumbnails/".$entry,"_cache/".$_GET['path']."/_thumbnails/".$prefx.$entry); @rename("_cache/".$flat_path."/_screen/".$entry,"_cache/".$_GET['path']."/_screen/".$prefx.$entry); @rename("_cache/".$flat_path."/_photoinfo/".$entry.".txt","_cache/".$_GET['path']."/_photoinfo/".$prefx.$entry.".txt"); } else { //error } } } } $d->close(); } } } } if(isset($HTTP_GET_VARS['op']) && ($HTTP_GET_VARS['op']==1 || $HTTP_GET_VARS['op']==2)) { //image generation if($HTTP_GET_VARS['op']==1) { $subdir = "_thumbnails"; $image_size = $thumb_size; } else if($HTTP_GET_VARS['op']==2) { $subdir = "_screen"; $image_size = $screen_size; } if(!isset($HTTP_GET_VARS['path']) || $HTTP_GET_VARS['path']=="") { $file_path = $HTTP_GET_VARS['file']; $save_path = "./_cache/".$subdir."/".$HTTP_GET_VARS['file']; } else { $file_path = $HTTP_GET_VARS['path']."/".$HTTP_GET_VARS['file']; $save_path = "./_cache/".$HTTP_GET_VARS['path']."/".$subdir."/".$HTTP_GET_VARS['file']; } $image = 0; if(!file_exists($save_path)) { //thumbnail does not exist. Lets make it! if($use_sips) { if($HTTP_GET_VARS['op']==1) { //thumbnail makeSquareSIPS($file_path,$save_path,$image_size); } if($HTTP_GET_VARS['op']==2) { //screen makeScaledSIPS($file_path,$save_path,$image_size); } } else { if($HTTP_GET_VARS['op']==1) $image = makeSquare($file_path, $image_size); if($HTTP_GET_VARS['op']==2) $image = makeScaled($file_path, $image_size); if($image!=-1) { $success = @Imagejpeg($image,$save_path,$jpeg_compression); } } } Header("Content-type: image/jpeg"); $im = @imagecreatefromjpeg($save_path); if($im) { Imagejpeg($im,'',$jpeg_compression); } else if($image) { Imagejpeg($image,'',$jpeg_compression); } else { $im = ImageCreate($image_size,$image_size); $white = ImageColorAllocate($im,255,255,255); $black = ImageColorAllocate($im,0,0,0); imagefill($im, 0, 0, $white); imagestring($im,1,2,2,$l_error,$black); if(!isset($success)) imagestring($im,1,2,10,$l_not_jpeg,$black); else imagestring($im,1,2,10,$l_perm_err,$black); Imagejpeg($im,'',80); } if($im) ImageDestroy($im); if($image) ImageDestroy($image); } else if(isset($HTTP_GET_VARS['op']) && $HTTP_GET_VARS['op']==4) { //folder icon generation Header("Content-type: image/jpeg"); $im = ImageCreate(15,14); $white = ImageColorAllocate($im,255,255,255); $tan = ImageColorAllocate($im,192,128,64); $black = ImageColorAllocate($im,0,0,0); imagefill($im, 0, 0, $white); imageline($im,2,4,4,2,$black); //left tab edge imageline($im,7,2,9,4,$black); //right tab edge imageline($im,4,2,7,2,$black); //tab top imageline($im,2,4,2,13,$black); //left side imageline($im,2,13,14,13,$black); //bottom imageline($im,14,13,14,5,$black); //right imageline($im,13,4,9,4,$black); //top imagefill($im, 10, 10, $tan); Imagejpeg($im,'',80); ImageDestroy($im); } else { //directory output //Please leave the following invisible html comments in place. ?> <!-- This photo gallery was generated with Fotopholder <?php echo $version?> --> <!-- http://www.jakeo.com/software/fotopholder/index.php --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head> <? $hasGD = checkGDversion(); if(!file_exists("./_cache") || !file_exists("./_cache/config.php")) { //cache doesnt exist. First time through. if(!file_exists("./_cache")) $success = @mkdir("./_cache",0777); if(is_writable (".") && is_writable ("./_cache") && $hasGD) { if(!empty($_POST['settings'])) { $handle = fopen("./_cache/config.php", "wb"); $data = "<?php\n"; $data .= "\$album_name = \"".$_POST['album_name']."\"; //The name of your album\n"; $data .= "\$display_errors = ".$_POST['display_errors']."; //set to 0 once you are satisfied that the script is installed correctly\n"; $data .= "\$no_screen = ".$_POST['no_screen']."; //set to 1 and the original image will be used for display when you click the thumbnail instead of a medium sized generated image\n"; $data .= "\$use_sips = ".$_POST['use_sips']."; //For Mac os X users only. Try setting to 1 to see if you get a speedup of thumbnail creation\n"; $data .= "\$screen_size = ".$_POST['screen_size']."; //max width or height of the screen sized image\n"; $data .= "\$thumb_size = ".$_POST['thumb_size']."; //width and height of the thumbnail\n"; $data .= "\$tiny_size = ".$_POST['tiny_size']."; //width and height of the tiny thumbnail used in folder listings\n"; $data .= "\$num_tinys = ".$_POST['num_tinys']."; //number of tiny thumnials to display in a folder listing\n"; $data .= "\$thumb_cols = ".$_POST['thumb_cols']."; //number of regular thumbnails to show per row\n"; $data .= "\$thumbs_page = ".$_POST['thumbs_page']."; //number of thumbnails to display per page for big folders\n"; $data .= "\$autorotate = ".$_POST['autorotate']."; //set to 1 to attempt to rotate an image if the camera sets the exif orientation\n"; $data .= "\$sort_method = ".$_POST['sort_method']."; //how to sort the directories and filenames Possible Values: 0=no sort, 1=alphabetical ascending, 2=alphabetical descending 3=date asc 4-date desc\n"; $data .= "\$show_filename = ".$_POST['show_filename']."; //1 shows filename of photos in list view. 0 hides filename \n"; $data .= "\$display_rating = ".$_POST['display_rating']."; //1 shows the rating stars. 0 hides them\n"; $data .= "\$show_extension = ".$_POST['show_extension']."; //1 shows filename extension. 0 hides extension \n"; $data .= "\$max_file_length = ".$_POST['max_file_length']."; //filenames longer than this will be truncated for display purposes\n"; $data .= "\$show_extra_info = ".$_POST['show_extra_info']."; //1=show extra info about an image if available (aperture, shutter speed, etc)\n"; $data .= "\$jpeg_compression = ".$_POST['jpeg_compression']."; //image compression of thumbails. 100=big, 0=ugly\n"; $data .= "\$image_crop = ".$_POST['image_crop']."; //1=thumbnail is zoomed and cropped to a square 0=thumbnail is padded to a square\n"; $data .= "\$admin = ".$_POST['admin']."; //set to 1 to turn on admin tools for deleting and renaming folders and files\n"; $data .= "\$admin_only = ".$_POST['admin_only']."; //set to 1 to make a private album with photos hidden till you type the password\n"; $data .= "\$password = '".$_POST['password']."'; //this is the admin password needed to make changes\n"; $data .= "\$delete_tiny_files = ".$_POST['delete_tiny_files']."; //set to 1 to automatically delete itty bitty images (probably old thumbnails)\n"; $data .= "\$tiny_file_max_kbytes = ".$_POST['tiny_file_max_kbytes']."; //this is the max size for the itty bitty images that will be deleted\n"; $data .= "\$delete_empty_folders = ".$_POST['delete_empty_folders']."; //set to 1 to automatically delete empty folders\n"; $data .= "\$gallery_link = ".$_POST['gallery_link']."; //set to 1 to display a link to your photo gallery on the fotopholder home page\n"; $data .= "\$gallery_link_url = \"".$_POST['gallery_link_url']."\"; //the url of your photo gallery if you want to share it on the fotopholder website.\n"; if(!empty($_POST['image_bkgd']) && $_POST['image_bkgd']==1) $data .= "\$image_bkgd = array( 0,0,0 ); //(red, green, blue) color of filler space in padded thumbnails\n"; else if(!empty($_POST['image_bkgd']) && $_POST['image_bkgd']==2) $data .= "\$image_bkgd = array( 128,128,128 ); //(red, green, blue) color of filler space in padded thumbnails\n"; else $data .= "\$image_bkgd = array( 255,255,255 ); //(red, green, blue) color of filler space in padded thumbnails\n"; $data .= "?>"; fwrite($handle,$data."\n"); fclose($handle); if(file_exists("./_cache/config.php")) { ?> <title>FotoPholder <?php echo $version?>

Success

Your gallery has been setup.


View Gallery FotoPholder <?php echo $version?>

Welcome to FotoPholder

Everything looks good so far. Please check these default settings for your new gallery.

Album Name
Screen Sized Image
Whether to use the original or make a smaller version for display on screen.
Use Original Shrink to below dimensions
Max width or height:
Thumbnail Size
Width and height of the thumbnail.
Tiny Size
Width and height of the tiny thumbnail used in folder listings.
Number of Tinys
Number of tiny thumbnails to display in a folder listing.
Columns
Number of columns of thumbnails.
Thumbnails per Page
Number of thumbnails per page. Make it a multiple of the number of columns for pretty pages.
Show Filename
Whether to show the filename in the folder listing.
Yes No
Max Filename Length
Filenames longer than this will be truncated.
Display Star Ratings
Displays the star ratings that you set for each photo.
Yes No
Show Extensions
Shows the file extension of the photo.
Yes No
Show Extra (EXIF) Photo Info
Show extra info about an image if available (aperture, shutter speed, etc)
Yes No
Technical Settings
JPEG Compression
Enter the amount of compression you want to apply as a percentage. 100=big and 0=ugly.
%
Use SIPS
For Mac OS X users only. Try setting to see if you get a speedup of thumbnail creation.
Yes No
Autorotate Images
Attempt to rotate an image if the camera sets the orientation flag.
Yes No
Sort Method
How to sort the directories and filenames.
No Sorting
Alphabetical A-Z
Alphabetical Z-A
File Modification Date (oldest first)
File Modification Date (newest first)
Thumbnail Cropping
How to make square thumbnails out of rectangular photos.
Zoom and crop images to a square.
Pad images to a square with Image Background Color
Image Background Color
Only used when thumbnail padding is set above
White Black Grey
Administrative Settings
Enable Admin Utilities
Allow admin to sign in and use utilities to manage photos
Yes No
Admin Password
The password used to enable the admin utilities
Make Photos Private
This will make your entire album password protected.
Yes No
Delete Tiny Files
Any files smaller than the minimum filesize will be deleted. Use this to clean out old thumbnail images created by other gallery software.
Yes No
Minimum Filesize: Kilobytes
Delete Empty Folders
Any empty folders will be deleted.
Yes No
Display Errors
If this script encounters any errors, do you want to display them?
Yes No
Share my Gallery
If you select 'Yes' a link to your photo gallery will be displayed on the home page for the fotopholder script.
Yes No
Your gallery's url:

These settings will be stored in the following file: _cache/config.php . You can edit this file to change your settings in the future.

FotoPholder <?php echo $version?>

Welcome to FotoPholder

Your file permissions are setup incorrectly. This script needs read and write access to your photos directory.


Under Unix

You'll need to use a telnet application to signin to your server as root. Use this command to give read and write access to this script: chmod -R 777


Under Mac OS X

Find the directory. Control click on the directory and select "Get Info". At the bottom of the info window under 'Details' make sure it says 'Read & Write' for all three sections. Then click 'Apply to enclosed items'.


Under Windows

Find the directory and give this script write access to it.

FotoPholder <?php echo $version?>

Welcome to FotoPholder

It doesn't look like your system is capable of running this software. You need to have PHP compiled with the GD library. More information about GD and PHP can be found Here.

<?php echo $album_name?> <?php if(!empty($web_path)) echo ":"; ?> <?php echo str_replace("/"," : ",$web_path)?> ".$data.""; } else { ?>
".$album_name.""; $total = ""; $num=0; foreach ($crumbs as $crumb) { if($crumb!="" && $crumb!=".") { $num++; if($total!="") $total.="/"; $total.=$crumb; if($num!=sizeof($crumbs)) echo " : ".$crumb.""; else if($HTTP_GET_VARS['op']==5) echo " : ".$crumb.""; else echo " : ".$crumb; } } if($HTTP_GET_VARS['op']==5) echo " : ".$HTTP_GET_VARS['file']; // END CRUMBS ?>
"; } else { $prev_icon = "<--"; } if(file_exists("./_cache/_icons/next.gif")) { $next_icon = ">"; } else { $next_icon = "-->"; } ?>
".truncate($HTTP_GET_VARS['file'],strlen($HTTP_GET_VARS['file']))."

"; if(!empty($details) && $show_extra_info==1) { ?> :
:
:
:
:
:
:
:
"; } else { $star_icon = "*"; } if(!empty($info_rating) && $display_rating) { echo "".$l_rating.": "; for($i=0;$i<$info_rating;$i++) echo $star_icon; echo "
"; } ?> ".$l_comments.": ".$info_keywords."
"; } ?>
".$l_download; } else { $download = $l_download; } ?> "> ( k)
alt="" />

:
"; } else { $trash = ""; } ?>
   


:
:
:



Fotopholder
".$l_bad_dir.": ".$file_path.""; } if($dirs==-2) { if($display_errors==1) echo "
".$l_bad_dir2.": ".$file_path."
"; $print_errors=1; } if($dirs==-3) { echo "
".$l_private."
"; } //tries to make the cache sub directory if its not there already if(is_dir($file_path) && !file_exists("./_cache/".$web_path)) { if($display_errors == 1) echo "
".$l_make_dir.": ./_cache/".$web_path."
"; umask(0); $success = @mkdir("./_cache/".$web_path,0777); if(!$success) $print_errors = 1; } //tries to make the thumbnail sub directory if its not there already if(is_dir($file_path) && !file_exists("./_cache/".$web_path.$slash."_thumbnails")) { if($display_errors == 1) echo "
".$l_make_dir.": ./_cache/".$web_path.$slash."_thumbnails
"; umask(0); $success = @mkdir("./_cache/".$web_path.$slash."_thumbnails",0777); if(!$success) $print_errors = 1; } //tries to make the screen sub directory if its not there already if(is_dir($file_path) && !file_exists("./_cache/".$web_path.$slash."_screen")) { if($display_errors == 1) echo "
".$l_make_dir.": ./_cache/".$web_path.$slash."_screen
"; umask(0); $success = @mkdir("./_cache/".$web_path.$slash."_screen",0777); if(!$success) $print_errors = 1; } //tries to make the photoinfo sub directory if its not there already if(is_dir($file_path) && !file_exists("./_cache/".$web_path.$slash."_photoinfo")) { if($display_errors == 1) echo "
".$l_make_dir.": ./_cache/".$web_path.$slash."_photoinfo
"; umask(0); $success = @mkdir("./_cache/".$web_path.$slash."_photoinfo",0777); if(!$success) $print_errors = 1; } //tries to make the icon sub directory if its not there already if(!file_exists("./_cache/_icons")) { if($display_errors == 1) echo "
".$l_make_dir.": ./_cache/_icons
"; umask(0); $success = @mkdir("./_cache/_icons",0777); if(!$success) $print_errors = 1; } function download_icon($icon) { $handle = @fopen("http://jakeo.com/software/fotopholder/icons/".$icon, "rb"); $downloaded_icon = @fread($handle, 10000); @fclose($handle); if(!empty($downloaded_icon)) { $handle = @fopen("./_cache/_icons/".$icon, "wb"); @fwrite($handle,$downloaded_icon); @fclose($handle); } } //download icons if not there if(!file_exists("./_cache/_icons/folder.gif")) download_icon("folder.gif"); if(!file_exists("./_cache/_icons/trash.gif")) download_icon("trash.gif"); if(!file_exists("./_cache/_icons/download.gif")) download_icon("download.gif"); if(!file_exists("./_cache/_icons/prev.gif")) download_icon("prev.gif"); if(!file_exists("./_cache/_icons/next.gif")) download_icon("next.gif"); if(!file_exists("./_cache/_icons/star.gif")) download_icon("star.gif"); if($print_errors==1 && $display_errors == 1) { //prints errors of it could make the above folders echo "
"; echo $l_make_err; echo "
"; } if(is_array($dirs) && sizeof($dirs)>0) { ?>"; } else if($count==0) { if(count($subdir)==0) { echo "Empty"; if($admin==1 && $delete_empty_folders==1 && $_COOKIE['admin']==md5($password)) { $worked = rmdirR($file_path."/".$entry); if($worked==FALSE) echo " (".$l_perm_err.")"; } } else { $count = 0; foreach($subdir as $sd) { $count++; if($count>$num_tinys) { echo "".$l_more.""; break; } if(file_exists("./_cache/_icons/folder.gif")) { ?>">">"; } else { echo ""; } } if(is_array($dirs) && sizeof($dirs)>0) echo "

".$num_photos." ".$l_photos."
".$num_dirs." ".$l_subfold.""; } ?>
0) { $count=0; while (is_array($photos) && false !== ($thumb = current($photos)) && $count<$num_tinys) { //cycle through photos in subdir to make tinys //delete too-small images if($admin==1 && !empty($_COOKIE['admin']) && $_COOKIE['admin']==md5($password) && $delete_tiny_files==1 && round(filesize($file_path."/".$entry."/".$thumb)/1024,0)<$tiny_file_max_kbytes) { @unlink($file_path."/".$entry."/".$thumb); next($photos); continue; } $count++; if(file_exists("./_cache/".$web_path.$slash.$entry."/_thumbnails/".$thumb)) { ?> ".$l_more."
"; // END DIRECTORY DISPLAY ?>
0;$skip--) next($photos); } else { $_GET['page'] = 1; } //next and previous links if($max_images>$thumbs_page || $_GET['page']>1) { $last_page = ceil($max_images/$thumbs_page); ?>1) { echo ""; } echo ""; if($max_images>$_GET['page']*$thumbs_page) { echo ""; } ?>
".$l_prev_pg.""; for($i=1;$i<=$last_page;$i++) { if($i==$_GET['page']) echo "".$i."  "; else echo "".$i."  "; } echo "".$l_next_pg."

0) { ?>"; $col++; $images++; ?> "; $col=0; } } if($col>0) { for($col;$col<$thumb_cols;$col++) echo ""; echo ""; } //empty folder if(count($photos)==0 && count($dirs)==0) { echo ""; } //try to cache the number of photos and folders per directory $handle = @fopen("./_cache/".$web_path.$slash."info.txt", "wb"); @fwrite($handle,(count($photos)+$dir_pho_cnt)."\n"); @fwrite($handle,(count($dirs)+$dir_sub_cnt)."\n"); @fclose($handle); if($images>0) echo "
" width="">

"; ?> "; } else { $star_icon = "*"; } if(file_exists("./_cache/".$web_path.$slash."/_photoinfo/".$entry.".txt")) { $handle = @fopen("./_cache/".$web_path.$slash."/_photoinfo/".$entry.".txt", "rb"); $info_rating = @fgets($handle,1024); for($i=0;$i<$info_rating;$i++) echo $star_icon; if($info_rating>0) echo "
"; @fclose($handle); } } ?> ( k) "; } else { $trash = "del"; } ?>
 

".$l_fol_empty."

"; //next and previous links if($max_images>$thumbs_page || $_GET['page']>1) { $last_page = ceil($max_images/$thumbs_page); ?>
1) { echo ""; } echo ""; if($max_images>$_GET['page']*$thumbs_page) { echo ""; } ?>
".$l_prev_pg.""; for($i=1;$i<=$last_page;$i++) { if($i==$_GET['page']) echo "".$i."  "; else echo "".$i."  "; } echo "".$l_next_pg."



:
"; } else { $trash = ""; } if(!empty($_GET['cache']) && $no_screen==0) { ?>
"; echo ""; next($photos); } ?>


   





: :


:
".$l_download_zip."
"; ?>

Fotopholder ".$whats_new; } @fclose($handle); ?>