The GD Library is strongly recommended. Enhanced Simple PHP Gallery will automatically detect (and attempt to append onto sp_config.php) what version of GD is installed on your server. If you would like to see what version of GD you have, upload the included gd_detect.php file to your server and load it in your browser. This script will display your version of GD and output code to be added to sp_config.php, should you want to add this information manually.
Note: The resizing feature will be disabled if your version of GD is older than 2.0. This is due to the poor quality of images produced by GD 1.x. Quality is generally passable for thumbnails, but decidedly not for full-size images.
In order to support the mod_rewrite links, your site must run on an Apache web server installation with mod_rewrite enabled. Contact your hosting provider if you are unsure of your server's configuration.
Note that Enhanced Simple PHP Gallery is designed to be as easy to use and hassle-free as possible. With this in mind, default settings that should have the best compatibility have already been set in the included sp_config.php file. If you are so inclined, you should be able to just upload files without having to manually configure anything.
First, open the file named "sp_config.php" This file controls all of the configuration options for Enhanced Simple PHP Gallery Here is what the various options do:
The title of your gallery. This will be on every page of the gallery, both in the <title> tag and the <h1> tag.
Default Value:
$title = 'Test Gallery';
If the GD extension is installed, this variable controls the maximum width of generated thumbnails, in pixels.
Default Value:
$maxthumbwidth = 120;
If the GD extension is installed, this variable controls the maximum height of generated thumbnails, in pixels.
Default Value:
$maxthumbheight = 120;
Quality of the generated thumbnails, higher the number the better the quality, upto a max of 100.
Default Value:
$thumbquality = 75;
If set to false, then a simple listing of directories/sub folders will be shown. If set to true, a random image from the relevant directory will be shown next to the sub-folder name.
Warning: If a directory does not contain an image, an error may be generated.
Default Value:
$cat_thumbs = false;
The algorithm used by Enhanced Simple PHP Gallery to create thumbnails can produce images that appear soft. If $thumb_applyunsharpmask
is true, an unsharp mask (USM) filter is applied to each thumbnail. Unsharp mask (USM) can restore sharpness to the thumbnails, making them appear crisper and more defined. USM does this by increasing contrast along edges in the image. (Please note that USM cannot refocus out-of-focus images. By increasing edge contrast, USM merely enhances sharpness that already exists.)
The USM settings in Enhanced Simple PHP Gallery mimic those in advanced image editing programs such as Adobe Photoshop and Jasc Paint Shop Pro:
Longer-winded explanations of USM can be found on The Luminous Landscape and Thom Hogan’s website.
Default Values:
// Unsharp mask settings for thumbnails
$thumb_applyunsharpmask = true;
$thumb_amount = 50;
$thumb_radius = 0.5;
$thumb_threshold = 2;
Note: The unsharp mask code is taken from the phpThumb() package available on Sourceforge.
Why bother resizing all of your pictures by hand, when you can let Enhanced Simple PHP Gallery do it for you automatically? Setting this option to true will enable image resizing.
Note that this option will not work if either $maxwidth or $maxheight is less than or equal to 0, or if your version of GD is older than 2.0.
Default Value:
$resize = false;
If $resize is true, this variable controls the maximum width of resized images, in pixels.
Default Value:
$maxwidth = 640;
If $resize is true, this variable controls the maximum height of resized images, in pixels.
Default Value:
$maxheight = 640;
Quality of the resized images, higher the number the better the quality, upto a max of 100.
Default Value:
$resizequality = 75;
If true, an unsharp mask filter (see above) is applied to resized images.
Default Values:
// Unsharp mask settings for resized images
$resize_applyunsharpmask = true;
$resize_amount = 50;
$resize_radius = 0.5;
$resize_threshold = 2;
This variable controls whether the script outputs query string links or mod_rewrite links. If your server supports mod_rewrite, and you have uploaded or appended the included .htaccess file, this should be set to true. If your server does not support mod_rewrite, if you don't want to use mod_rewrite, or if you just have no idea what this is about and would prefer not to fool with it, set it to false.
The difference in this script output looks like this:
$modrewrite = true;
> links look like this:
<a href="galleryroot/folder/dir/subdir/subsubdir/">
$modrewrite = false;
> links look like this:
<a href="galleryroot/sp_index.php?dir=./dir/subdir/subsubdir/">
Using mod_rewrite links is nice because it hides the technology and overlays a virtual directory structure over your physical directories. The user never leaves the index file, but it looks to them as if they were navigating a directory tree. mod_rewrite links are also nice because they are easier to remember and link directly.
Default Value:
$modrewrite = false;
This variable controls whether the Enhanced Simple PHP Gallery should cache the thumbnails it generates. If caching is on, each thumbnail will only be generated once, then saved to the server. When a thumnail is requested, the script will automatically detect whether it has previously generated the thumbnail. If it has, it will serve the file on disk, rather than generate a new thumbnail. Setting this to true takes a large burden off of the server, so you probably want to leave it set to the default. If caching fails for any reason (usually inability to read/write the cache folder), caching will be disabled, regardless of this setting. If you change this variable to false after thumbnails have already been cached, the cache folder (specified below) and all contents will be deleted automatically.
Also note that enabling thumbnail caching will also cause Enhanced Simple PHP Gallery to generate a file in the cache folder named cache.ini. This file is meant to be used in conjunction with Dan Benjamin's "Better Image Rotator".
Default Value:
$cachethumbs = true;
If $cachethumbs is true, this variable sets the folder that the thumbnails should be saved into. This folder is created in the same directory as sp_index.php and will not show up as a folder in your gallery. Note that if caching is enabled, but the cache folder does not exist, the script will attempt to create it and chmod it to 755.
Default Value:
$cachefolder = 'cache';
If $resize is true, this variable controls whether Enhanced Simple PHP Gallery should cache the resized images it generates. If caching is on, each image will only be resized once, then saved to the server. When an image is requested, the script will automatically detect whether it has previously resized the image. If it has, it will serve the file on disk, rather than generate a new resized image. Setting this to true takes a large burden off of the server, so you probably want to leave it set to the default. If caching fails for any reason (usually inability to read/write the cache folder), caching will be disabled, regardless of this setting. If you change this variable to false after thumbnails have already been cached, the cache folder (specified below) and all contents will be deleted automatically.
Default Value:
$cacheresized = true;
If $cacheresized is true, this variable sets the folder that the resized images should be saved into. This folder is created in the same directory as sp_index.php and will not show up as a folder in your gallery. Note that if caching is enabled, but the cache folder does not exist, the script will attempt to create it and chmod it to 755.
Default Value:
$cacheresizedfolder = 'rcache';
When viewing single images, enabling this option will cause the previous and next images to load into the background, so that they will already be in the browser's cache when visitors click the "Previous" or "Next" buttons. This gives the appearance of near-instantaneous image loading for your visitors. Note that this feature will not work if $resize is true and $cacheresized is false.
Default Value:
$precache = true;
This is a special setting, an array of folder names that should not show up in your gallery. Just add a line for each folder you wish to hide. Follow this format:
$hidefolders[] = 'hiddenfolder1';
$hidefolders[] = 'hiddenfolder2';
...and so on.
Folders named 'cgi-bin' are hidden by default.
Default Value:
$hidefolders[] = 'cgi-bin';
Allow the deleting of images and directories
Default Value:
$allowdeleting = true;
Allow uploading of images, and creation of new sub folders
Default Value:
$allowmaking = true;
Max image upload size default is 150Kb or 153600 bytes
Default Value:
$max_size = 153600;
The number of thumbnails to appear per page
Default Value:
$limit = 20;
This variable controls whether the comments are allowed. If set to true, amendments are need in the comment.php script. See that file for details.
Default Value:
$showcomments = false;
This variable controls whether the number of images and folders appears in parentheses next to links to subfolders.
Default Value:
$showfolderdetails = true;
This variable controls whether image titles appear below thumbnails. If an image title for a particular thumbnail cannot be found in sp_descriptions.ini, the filename will be used instead.
Default Value:
$showimgtitles = true;
This variable controls whether the date a picture was added, if set, will appear on the below the thumbnail.
Default Value:
$showdatesonthumbspage = false;
This variable controls whether thumbnails should be aligned into columns, regardless of their width. When set to false, thumbnails will float left and bunch up accordingly.
Default Value:
$alignimages = true;
This variable controls whether the resized image is viewed with a small loading screen, which fades the image in slowly.
Default Value:
$image_fade_in = true;
This variable controls whether the directories are sorted by title (true) or folder name (false)
Default Value:
$sortfoldersbytitle = false;
You will notice that this option is not initially found in sp_config.php. Enhanced Simple PHP Gallery will detect this setting automatically and attempt to append a line similar to the following to sp_config.php:
$gd_version = '//your GD version here';
If Enhanced Simple PHP Gallery is unable to write to sp_config.php, it will simply re-detect the version every time the script is loaded. This is a minor additional burden on your server. If sp_config.php is not writeable on your server, you may wish to add this setting manually.
To manually set $gd_version, upload the file named gd_detect.php to your server and load it into your browser. The proper line of code to add to sp_config.php will be automatically generated for you.
Using your favourite text editor open up the validate.php and change these values:
$admin_user_name = "demo";
$admin_password = "demo";
Remember to choose something obscure
The sp_descriptions.ini can be amended by hand, but is no longer recommended. With the advent of the editing functions you are now able to edit the Gallery online, directory by directory and image by image.
Online forms can be used to amend directory naming, upload images to the directory you are currently in and amend image details. Hopefully everythig is self explanatory.
To allow for a quick and easy method of skinning the gallery, or integrating into existing sites we have supplied header.php and footer.php. These are the only files that should need amending in order to integrate the gallery into your site
Once you have finished configuring the script, copy the files to your web server in the directory that you want to be the root folder of your gallery:
If ccache and rcache and not generated by the script, create them manually and upload.
You then have to CHMOD the following:
(note: these may not be necessary on your server, suggest testing them out)
If you have set $modrewrite=true in sp_config.php, you will also need to copy or append the contents of
the following file into a new or existing file called ".htaccess" in the root folder of your gallery:
htaccess.txt
If you do not append the contents of the included .htaccess file, you should at least add a directive to
make sp_index.php the default document for the folder:
DirectoryIndex sp_index.php
You can also just upload the .htaccess file included in the distribution archive (if your OS allows you to see .htaccess files)
(this can be handled by the online scripts for one at a time uploading)
To add a new folder or image to your gallery, just upload it to the appropriate folder under the root folder of your gallery. New folders and images will automatically added to the gallery. If caching is enabled, new thumbnails will be generated and cached for the new images upon the first viewing of the page.
Enhanced Simple PHP Gallery currently supports JPEG (.jpg, .jpeg), GIF (.gif), and PNG (.png) image formats.
You can add additional folder aliases and image descriptions into your sp_descriptions.ini file and re-upload it at any time. Changes will be immediate.
If the config sub folder is uploaded, open the config/validate.php file and amend the username/password. If this is set the same as the main gallery, then you only have to login once to access this.
To access the online config editor, from the gallery directory, open /config/index.php
Note: this is experimental, and has not bee n fully tested, be sure to backup your sp_config.php
comments.php includes some settings at the top of the script that may need amending, however I would recommned that:
$comment_settings['admin_email'] = email@invalid.invalid;
is amended to your own email address. If you don't you run the risk of missing a comment added to one of your images.
For the initial Simple PHP Gallery scripts:
Paul Griffin who developed Simple PHP Gallery.
Erik Sagen
Ryan Parman
Matt Burris
The initial edit idea and script:
Bryan Hansel and Douglas Waldron.
These instructions relate to version 1.5 of Enhanced Simple PHP Gallery and may not be entirely complete and accurate.
Enhanced Simple PHP Gallery brought to you by Rich Pedley