PHP Album ver 1.0 http://www.whiteangle.com/ PHP Album ver 2.0 Dec, 2003 Aaron Newton email: php (AT) epitonic (DOT) org PHP FTP Id: ftp.php,v 2.2 2002/03/12 23:21:28 pauls Exp This software came from http://inebria.com/ Copyright (c) 2000 Paul Southworth. All rights reserved. M-ZIP Library: unzipping files using command line tools Original author: Francesco M. Munafo' EMail: phpDev (AT) eSurfers (DOT) com Download latest at http://eSurfers.com/m-lib/ Smarty http://smarty.php.net Monte Ohrt Andrei Zmievski overLIB 3.50 -- This notice must remain untouched at all times. Copyright Erik Bosrup 1998-2001. All rights reserved. By Erik Bosrup (erik@bosrup.com). Last modified 2001-08-28. Portions by Dan Steinman (dansteinman.com). Additions by other people are listed on the overLIB homepage. Get the latest version at http://www.bosrup.com/web/overlib/ IMPORTANT NOTE ON VERSION 2!!!! This version is incompatible with the database structure in version 1. Installing this will require that you rebuild your database and you will loose all comments, hit counts, captions, and descriptions! This version contains many, many new features that you may consider worth the trouble, but know that installing it will cost you any data created by previous versions. FIRST TIME INSTALLATION: Skip everything until you see == PHP Album ver 2.0 = INSTALLATION INSTRUCTIONS ======== and read the system requirements. then skip all the notes about version 2.0 until you see - File Setup - and continue. UPGRADING: Move your old installation aside and unzip this package into it's place. Put your images back (instructions below on image location, but basically it's the same as ver 1). Set up database (I recommend a new one in case you decide to revert to the previous version) using instructions below. Log in to the admin interface and scan your directory tree. Also note that this version allows for sub-directories so if you want to rearrange, now's the time to do it! See info below on directories. == PHP Album ver 2.0 = INSTALLATION INSTRUCTIONS ======== -System Requirements- 1. a web server running PHP. (APACHE htaccess is used to authenticate admin system users by default but any server that provides directory protection will do) 2. access to a MySQL database on this server >>optional: == as of ver 2.0 ======================================== 3. an ftp server to upload files using the upload interface - this server should have access to the gallery doc root ========================================================= 4. imagemagick (netpbm code is kinda there, but not complete) == upgrade notes: version 2.0 =========================== the database scheme for version 2.0 is incompatible with previous versions in order to allow for the following features: >>>> changes to directories (affected table: al_directories) <<<< >> longer descriptions folders can now have long descriptions. in ver. 1 this field was mostly used for a descriptive name. now it's more like an actual description. >> sub folders! this is one of the biggest upgrades. now folders can contain folders. each folder in the database has an entry for it's 'parent' and thus allows for folders within folders. this means you can have, essentially, categories of galleries that each contain galleries themselves. this also required making the entry for the folder's location longer than the ver. 1 setting of 30 characters since subdirectories can get deep. >> longer names this allows for folders to be up to 100 characters, vs the old option of 30 >>>> changes to images (affected table: al_images) <<<< >> 'featured' images it's possible to specify images in a gallery as being featured. this is useful if you want to create a representation of the gallery with some example thumbnails and there are some images that are better than others for display. Another way to use them is to create a slideshow of the best images if you want to post everything, but your visitors might just want the highlights >> credits images now can have a photo credit for the photographer. the interface includes the ability to credit the photos in an entire directory at once >> longer names images can now have names up to 180 characters so that each can be more descriptive. note that just as in ver 1.0, image name refers to the file name of the image and isn't set by the user through the interface (though it's obviously set by the user when they name the file...). >> longer image captions there's no longer a size restriction on captions for images. == other updates with ver 2.0 ============================ >> automatic captions now, when the script adds images to the database, it will set their caption to the image's file name sans extension. so the image "My Dog Fetching.jpg" will get the caption "My Dog Fetching" >> ftp upload for files you can now access and upload files on the server via the web browser provided you are running an ftp server. the interface allows for the creation of directories, the removal of files, and unzipping files on the server (this distribution includes unzip.exe for windows platforms, other platforms will require you to set up your own unzip program). note that the file uploader/upload.php will allow you to upload files via http (no need for an ftp server) but I decided to go with ftp and abandoned it. it's mostly functional if someone wants to finish it. >> smarty templates this distribution includes a copy of smarty 2.6.0 and /index.php uses it to generate the front end of the gallery. this template language allows for far greater flexibility in the look and feel as well as the functionality of your gallery. There's a set of example templates in the smarty/templates directory. in the smarty/code directory is a file called album.php which includes an entirely new album class that is designed for use of ver 2.0 display functionality. I'm still using a lot of the ver 1.0 interface for data entry, but display of the gallery uses this new album class. It's much more configurable and portable. I haven't written a smarty api to instruct on the use of the templates. much can be learned at smarty.php.net, but it's intricately tied to the album class. I'll document this sometime, but if anyone asks me to do it (email: php (AT) epitonic (DOT) org) I'll crank it out sooner. the old index file from ver 1 still works (though lacks most of this new functionality) and can be found in the root directory of this distribution. >> thumbnails and slides no longer on the fly ver 1.0 generated thumbnails on the fly and resized images for display on the fly. this is very processor intensive. ver 2 can be configured to generate these files and place them on the file system instead. doing so creates images (with the same file name) in sub directories for slides and thumbnails. you can set the names of these directories in the config file. the software will create these folders if they are not present. additionally, you may create your own and upload them. if it encounters any images it doesn't overwrite them unless you tell it to in the config file. you can also instruct it to rebuild any directory's thumbnails, slides, or both from the management interface. >> scan a single directory you can still scan the entire directory structure, but you can also instruct the software to rescan only a single directory from the directory's management page. >> move directories you can now move a directory to a new location and enter this change in the interface. this allows you to keep all data associated with it instead of removing the old files from the db and adding the new ones. the only catch is that if you move the location instead of just renaming it, the parent directory setting will still reference it's old parent, so it'll still look like it's in it's old gallery to the database (and to the user). changing this requires moving the directory and rescanning the system and things like image captions and hit counters will be lost >> supports overlib this is done using smarty. pops up a box with things like the caption of an image and it's photo credit. >> SMARTY TEMPLATES DO NOT USE PERMISSIONS YET I personally don't have any use for this, so I didn't implement it. If you want to use this and don't want to code it yourself, let me know and I'll get around to it. >> SMARTY TEMPLATES DO NOT USE COMMENTS I didn't include the comment functionality in the smarty code or the album class. I personally don't need them. If someone really wants it, just let me know. ========================================================= - File Setup - 1. unzip the install files with the directory structure intact. 2. FTP all the files, with directory structure intact, to your site (preferably a subdirectory somewhere for neatness) 3. Create a folder called "images" into which you will be putting all your image files. There should be another folder called "admin" that was created when you uploaded all the application files in step 2. Note: "images" is the default. You may create a folder of any name, just update the config file. - MYSQL setup - 1. connect to mysql 2. create the database by typing in: CREATE DATABASE ; where is whatever you want your db to be named - Configuration - Configuration changes are made by editing the config.php file that should be in your album's root directory. A standard text editor will be fine to make these changes. 1. change the value of $cfg['dbase'] to whatever your database is called. The default is "album". 2. change $cfg['dbuser'] and $cfg['dbpwd'] to your user name and password for accessing this database >>Aaron here: I couldn't get this next step to work (but I didn't spend much time trying). >>instead I recommend creating htaccess protection for the admin, smarty, and upload directories 3. IMPORTANT - administration system authentication is done through the script by default. If you prefer to protect the directory that the admin system resides in by setting it up on your server, you can disable $cfg['requireValid']. Otherwise, you should set the username and password for the Admin system with $cfg['adminuser'] and $cfg['adminpwd'], respectively. 4. The album will attempt to auto-generate thumbnails on the fly by default. This requires the PHP GD Graphics library which comes standard with PHP 4.3.0. If your thumbnails are not appearing, chances are your version of PHP doesn't have the library installed. setting $cfg['autoThumbnail'] to false disables the auto-generate option but also means that you must create the thumbnails yourself :-). See tree structure below for details. - Other configurables - There are a number of settings that can be configured from within the config.php file so if you are wondering whether it is possible to change that way something works, check through the config file - you might be surprised. Configurable items include: the colour scheme (table backgrounds etc from the config file) styles are configured in the "albumstyle.css" style sheet. you can specify a different style sheet but be aware of the style definitions that the album requires. table sizes the title of the album the number of thumbnails displayed per row == new as of ver 2.0: ========================= >> upload file size restrictions note: php has it's own setting for this in php.ini set the following in that file: file_uploads=On; (Whether to allow HTTP file uploads) upload_max_filesize=20M; (Maximum allowed size for uploaded files) post_max_size=20M; (Maximum allows size of any form submission) >> link from slides to full sized original >> random depth the smarty templates (specifically, the album class) allow(s) for a randomization of a gallery request this means that instead of getting the first X files, it should get more than that, shuffle them and then return X random files. this random depth denotes how many files it should get first. >> default width and height of slides and thumbnails - Directory structure - Once you have the album up and running, you will be wanting to populate it with images. This is a simple process that will require you to FTP the image files to the "images" directory that you created earlier. By default, this directory is called "images" and sits in the directory that your album is running from. You can set this to a different directory by changing $cfg['imagePath'] (path to the images directory from the album root) in the config file. The directory structure underneath your images folder must follow this pattern: root[folder] |- admin[folder] L images[folder] <-- note directory structure within "images --> Lphoto set 1[folder] |- image 1[file] |- image 2 . . |- image z L thumbnails [folder required if auto-generate thumbnails feature is off] |- image 1 [file-thumbnail version of image1 but with same name] . . L image z |-photo set 1[folder] |- image 1 |- image 2 . . |- image z L thumbnails [folder required if auto-generate thumbnails feature is off] |- image 1 [file-thumbnail version of image1 but with same name] . . L image z i.e. each set of images that will register as a link from your album's index page must be in its own directory under the main images directory. The name of each of these folders is not crucial as you can re-label them to something more descriptive in the administration system. == ver 2.0 changes in Directory Structure =============== Everything above is still valid, only now folders and contain sub folders which will be interpreted as "sub galleries". Also, a "slides" directory may be created as well. root[folder] |- admin[folder] |- javascript [contains overlib] L smarty L code [contains album.php and smarty files] L templates [these are all your templates files] |- index.tpl |- header.tpl ...etc. L images[folder] <-- note directory structure within "images --> Lphoto set 1[folder] |- image 1[file] |- image 2 . . |- image z L thumbnails [folder required for thumbnail files] |- image 1 [file-thumbnail version of image1 but with same name] . . L image z L slides [folder required for slide files] |- image 1 [file-slide version of image1 but with same name] . . L image z L photo set 1.1 etc. L photo set 1.2 L photo set 1.2.1 L photo set 1.2.1.1 etc... This allows for something like: Vacations ->Hawaii ->Europe ->Italy ->France The Kids ->Billy ->Year 1 ->Year 2 ->Suzie ->Year 1 etc. ========================================================= THUMBNAILS If your can not use the auto-generate thumbnails feature then you will have to create the thumbnails yourself and upload them to a sub-directory (called "thumbnails") of the folder in which all the full-sized images are saved. So each set of images will have a "thumbnails" subdirectory which contains all the carefully constructed thumbnails that go with the images. The longest side of the thumbnails should be not much longer than 60 pixels. Adobe Photoshop has a nice batch job feature that you can configure to create thumbnails for you. ADDING IMAGES TO YOUR ALBUM - File upload - 1. connect to your host via FTP and create a sub-directory under your "images" directory for the new set of images to go 2. upload all the images to the new directory == ver 2 changes to thumbnails ========================== The script now creates thumbnails to the disk. You can upload your own, or have it build them. See section above on directory structures for more details. ========================================================= - Update database - 1. point your browser at the administration tool (http://yourdomain.com/album/admin) 2. select "scan directories" from the menu. You should see feedback about which new folders and images were found and added to the database. ADDING/REMOVING IMAGES/FOLDERS FROM EXISTING ALBUM Simply add or removed whatever files or folders you wish, using your FTP program of choice. Once you have made all your changes on the server, go to the Administration tool and "scan directories". The changes will be detected and your database, updated. == ver 2 note on scanning =============================== Note that the first time you scan the directory can take a while if you've instructed it to build thumbnails and slides for you (or if you have set the config file to overwrite all thumbs and slides that it finds). Additionally, you can now rescan a single directory at a time by going to that directory's page in the admin tool and clicking the rescan link there. You can also force rebuild thumbnails and slides on a directory by directory basis the same way. =========================================================