//error_reporting (E_ALL);
/************************************************************
PHP Image Gallery by "sasha" (sasha@bittersweet2.com)
Last edited November 4, 2002
Based on the Image Galleria, originally written by DrTebi
This is a fairly simple script for displaying thumbnail
images that link to a full size image with optional captions.
Instructions
1. Create thumbnails of your full size images, this script
does not create them for you. The thumbnail image's
name must match the full size image's name exactly.
2. Create two separate directories: one to contain the
thumbnails and one to contain the full size images.
3. Create a 3rd directory if you wish to have captions
appear below your full size image names. The name of the
plain text file should match your images name like this:
your_image_name.jpg.inc. Don't worry if there isn't a
caption file for every image, since the script will ignore
it if there isn't one.
4. All of the editable configuration variables are listed
at the beginning of the script and can be moved to an
external configuration file if desired.
The complete listing of changes I made to this script are
located here, along with the most recent source:
http://www.sketchdiary.com/php/imagegallery.php
You can find working versions of this script at:
http://www.sketchdiary.com/galleries/
-sasha
************************************************************/
/********** editable variables **********/
// thumbnails title
$thumb_title = 0; // set to 1 if you want the image filename below the thumb, 0 otherwise
// full size images title
$full_title = 0; // set to 1 if you want the image filename below the the full size image, 0 otherwise
// how many thumbnails should appear per row?
$cols = 3; // 3 looks the best, but you may want more or less, depending on the size of your thumbnails
// how many thumbnails per page?
$max_thumbs = 12; // a multiple of $cols looks the best, or 0 for all thumbnails on one page
// thumbnail directory name
$thumbs_dir = "gallery/thumbs"; // just make sure your directory name is inside double quotes
// full size image directory name
$full_dir = "gallery/large"; // just make sure your directory name is inside double quotes
// captions directory name
$captions_dir = "gallery/captions"; // if you don't want captions at all, don't worry about this
// extension name
$ext = "php"; // just incase you are using a different extension name for your script; if your server is not set for "index.$ext to be the index page, put "0".
// captions extension
$cext = "inc"; // use whatever you're comfortable with
// show random option for single page view
$showrand = 0; // to turn it off, switch 1 to 0
// print footer options
$print_footer = "print_footer"; // put in the name of the function you use to print the footer of your page. if you don't use one, just leave it as it is.
/********** end editable variables **********/
// figure out this script's name
$self = $HTTP_SERVER_VARS['PHP_SELF'];
if (basename($self) == "index.$ext") {
$self = str_replace(basename($self), "", $self);
}
// do you have an existing function to close your page? if not, use this default...
if (!function_exists($print_footer)) {
function print_gallery_footer() {
?>
}
$print_footer = 'print_gallery_footer';
}
// our error function, cleanly exits the script on user errors
function imgerror($error) {
global $print_footer;
print "
$error
\n\n";
$print_footer();
exit();
}
// get image size function
function gallery_imgsize($image) {
$size = GetImageSize($image);
return "width=$size[0] height=$size[1]";
}
// check for directories
if(!is_dir($thumbs_dir)) {
imgerror('Directory "'.$thumbs_dir.'" does not exist.');
}
if(!is_dir($full_dir)) {
imgerror('Directory "'.$full_dir.'" does not exist.');
}
// get contents of $thumbs_dir
$dir = @opendir($thumbs_dir) or imgerror('Can\'t open ' . $thumbs_dir . ' directory');
$thumbs = array();
while($thumb = readdir($dir)) {
if(preg_match('/(jpg$|jpeg$|gif$|tif$|bmp$|png$)/', $thumb))
array_push($thumbs, $thumb);
}
rsort($thumbs);
// lowest displayed image in the array
// use http_get_vars incase register_globals is off in php.ini
if (!isset($HTTP_GET_VARS['i'])) {
$i = 0;
}
else {
$i = $HTTP_GET_VARS['i'];
}
// check to see if all thumbs are meant to be displayed on one page
if ($max_thumbs == 0) {
$max_thumbs = sizeof($thumbs);
$mt_check = 1;
}
else {
$mt_check = 0;
}
// thumbnail view
if (is_numeric($i)) {
// check to see which thumbnail to start with
if (!$mt_check && $i > 0) {
$start = $max_thumbs * ($i - 1);
}
else {
$start = 0;
}
// are they looking for thumbs pages that don't exist?
if ($start > sizeof($thumbs)) {
print 'index' . "\n\n";
imgerror('Sorry, there are no images to display on this page');
}
?>
include("includes/header.php") ?>
| |
 |
|