diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..7d9c8eb --- /dev/null +++ b/.htaccess @@ -0,0 +1 @@ +Options -Indexes \ No newline at end of file diff --git a/config.php b/config.php index c5eb784..8024193 100644 --- a/config.php +++ b/config.php @@ -16,12 +16,12 @@ Please enjoy this free script! */ // EDIT SETTINGS BELOW TO CUSTOMIZE YOUR GALLERY -$thumbs_pr_page = "28"; //Number of thumbnails on a single page -$gallery_width = "900px"; //Gallery width. Eg: "500px" or "70%" +$thumbs_pr_page = "39"; //Number of thumbnails on a single page +$gallery_width = "80%"; //Gallery width. Eg: "500px" or "70%" $backgroundcolor = "white"; //This provides a quick way to change your gallerys background to suit your website. Use either main colors like "black", "white", "yellow" etc. Or HEX colors, eg. "#AAAAAA" -$templatefile = "mano"; //Template filename (must be placed in 'templates' folder) -$title = "MiniGal Nano Testsite"; // Text to be displayed in browser titlebar -$author = "Rybber"; +$templatefile = "darkgold2"; //Template filename (must be placed in 'templates' folder) +$title = "MiniGal Nano test gallery"; // Text to be displayed in browser titlebar +$author = "John Doe"; $folder_color = "black"; // Color of folder icons: blue / black / vista / purple / green / grey $sorting_folders = "name"; // Sort folders by: [name][date] $sorting_files = "name"; // Sort files by: [name][date][size] @@ -30,14 +30,14 @@ $sortdir_files = "ASC"; // Sort direction of files: [ASC][DESC] //LANGUAGE STRINGS $label_home = "Home"; //Name of home link in breadcrumb navigation -$label_new = "New"; //Text to display for new images. Use with $display_new variable +$label_new = "New"; //Text to display for new images. Use with $display_new variable $label_page = "Page"; //Text used for page navigation -$label_all = "All"; //Text used for link to display all images in one page +$label_all = "All"; //Text used for link to display all images in one page $label_noimages = "No images"; //Empty folder text $label_loading = "Loading..."; //Thumbnail loading text //ADVANCED SETTINGS -$thumb_size = 120; //Thumbnail height/width (square thumbs). Changing this will most likely require manual altering of the template file to make it look properly! -$label_max_length = 30; //Maximum chars of a folder name that will be displayed on the folder thumbnail -$display_exif = 1; +$thumb_size = 320; //Thumbnail height/width (square thumbs). Changing this will most likely require manual altering of the template file to make it look properly! +$label_max_length = 40; //Maximum chars of a folder name that will be displayed on the folder thumbnail +$display_exif = 0; ?> \ No newline at end of file diff --git a/config_default.php b/config_default.php index 3a5e016..92bb23d 100644 --- a/config_default.php +++ b/config_default.php @@ -16,10 +16,10 @@ Please enjoy this free script! */ // EDIT SETTINGS BELOW TO CUSTOMIZE YOUR GALLERY -$thumbs_pr_page = "18"; //Number of thumbnails on a single page +$thumbs_pr_page = "21"; //Number of thumbnails on a single page $gallery_width = "900px"; //Gallery width. Eg: "500px" or "70%" $backgroundcolor = "white"; //This provides a quick way to change your gallerys background to suit your website. Use either main colors like "black", "white", "yellow" etc. Or HEX colors, eg. "#AAAAAA" -$templatefile = "mano"; //Template filename (must be placed in 'templates' folder) +$templatefile = "darkgold2"; //Template filename (must be placed in 'templates' folder) $title = "My Gallery"; // Text to be displayed in browser titlebar $author = "Me :)"; $folder_color = "black"; // Color of folder icons: blue / black / vista / purple / green / grey diff --git a/createthumb.php b/createthumb.php index c6b7355..bcf09be 100644 --- a/createthumb.php +++ b/createthumb.php @@ -14,16 +14,62 @@ Community: www.minigal.dk/forum Please enjoy this free script! +Version 0.3.5 modified by Sebastien SAUVAGE (sebsauvage.net): + - Added thumbnail cache (reduces server CPU load, server bandwith and speeds up client page display). + - Thumbnails are now always in JPEG even if the source image is PNG or GIF. USAGE EXAMPLE: File: createthumb.php Example: */ // error_reporting(E_ALL); - + error_reporting(0); +/* if (preg_match("/.jpg$|.jpeg$/i", $_GET['filename'])) header('Content-type: image/jpeg'); if (preg_match("/.gif$/i", $_GET['filename'])) header('Content-type: image/gif'); if (preg_match("/.png$/i", $_GET['filename'])) header('Content-type: image/png'); +*/ + +function str_split_php4( $text, $split = 1 ) { + // place each character of the string into and array + $array = array(); + for ( $i=0; $i < strlen( $text ); ){ + $key = NULL; + for ( $j = 0; $j < $split; $j++, $i++ ) { + $key .= $text[$i]; + } + array_push( $array, $key ); + } + return $array; +} + +function sanitize($name) +{ +// Sanitize image filename (taken from http://iamcam.wordpress.com/2007/03/20/clean-file-names-using-php-preg_replace/ ) +$fname=$name; +$replace="_"; +$pattern="/([[:alnum:]_\.-]*)/"; +$fname=str_replace(str_split_php4(preg_replace($pattern,$replace,$fname)),$replace,$fname); +return $fname; +} + +// Make sure the "thumbs" directory exists. +if (!is_dir('thumbs')) { mkdir('thumbs',0700); } + +// Thumbnail file name and path. +// (We always put thumbnails in jpg for simplification) +$thumbname = 'thumbs/'.sanitize($_GET['filename']).'.jpg'; + +if (file_exists($thumbname)) // If thumbnail exists, serve it. +{ + $fd = fopen($thumbname, "r"); + $cacheContent = fread($fd,filesize ($thumbname)); + fclose($fd); + header('Content-type: image/jpeg'); + echo($cacheContent); +} +else // otherwise, generate thumbnail, send it and save it to file. +{ // Display error image if file isn't found if (!is_file($_GET['filename'])) { @@ -82,11 +128,19 @@ if (preg_match("/.png$/i", $_GET['filename'])) header('Content-type: image/png') imagecopyresampled($target,$source,0,0,$xoord,$yoord,$_GET['size'],$_GET['size'],$width,$height); imagedestroy($source); - if (preg_match("/.jpg$/i", $_GET['filename'])) ImageJPEG($target,null,90); - if (preg_match("/.gif$/i", $_GET['filename'])) ImageGIF($target,null,90); - if (preg_match("/.png$/i", $_GET['filename'])) ImageJPEG($target,null,90); // Using ImageJPEG on purpose + //if (preg_match("/.jpg$/i", $_GET['filename'])) ImageJPEG($target,null,90); + //if (preg_match("/.gif$/i", $_GET['filename'])) ImageGIF($target,null,90); + //if (preg_match("/.png$/i", $_GET['filename'])) ImageJPEG($target,null,90); // Using ImageJPEG on purpose + ob_start(); // Start output buffering. + header('Content-type: image/jpeg'); // We always render the thumbnail in JPEG even if the source is GIF or PNG. + ImageJPEG($target,null,80); imagedestroy($target); + + $cachedImage = ob_get_contents(); // Get the buffer content. + ob_end_flush();// End buffering + $fd = fopen($thumbname, "w"); // Save buffer to disk + if ($fd) { fwrite($fd,$cachedImage); fclose($fd); } - +} ?> \ No newline at end of file diff --git a/index.php b/index.php index fdf4aa5..23e47a5 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,5 @@ - $file, "date" => filemtime($currentdir . "/" . $file . "/folder.jpg"), - "html" => "