DAlbum 1.42 build 162

This is a printable version of the document. Original contents is available at www.delx.ca/dalbum

Table of contents

DAlbum

DAlbum is a free PHP photo album. It is small, easy to install and highly customizable at the same time. Features include slide shows, image comments, support for video and PDF files and many more.

DAlbum screenshot

See DAlbum demos:

To access administration user interface, login as user admin with password admin. Please note that your changes will be ignored in demo mode.

[ Top ]

News

16 Aug 2006

1.42 build 155. There have been many changes since 1.38, some of which include:

25 Jan 2005

1.38 build 143. The issue with Firefox incorrectly displaying DAlbum index page is (hopefully) fixed.

14 Aug 2004

1.38 build 130. Another bug fix release but there are few new features this time.

26 Jul 2004

1.37 build 127. This is mainly a bug-fix release. I have finally reinstalled PHP and my (fairly complex) DAlbum release engine, so new updates will be more frequent now.

14 Dec 2003

29 Nov 2003

22 Nov 2003

9 Nov 2003

1 Nov 2003

[ Top ]

Features

DAlbum is a personal photo album. It was designed to provide an easy and secure way to share pictures with friends and family.

The script itself includes only basic functionality for the sake of code size and simplicity. It can be easily extended with required features or embedded into an existing web-site.

It's easy to view pictures:

It's easy to install and configure:

It's easy to upload images:

Finally, it's scalable, customizable and secure:

[ Top ]

System requirements

Server

Client

[ Top ]

Installation

[ Top ]

New installation

To install DAlbum and upload digital pictures you need:

  1. Web-space. Check links for some cheap or even free options.
  2. FTP client software. Check links if you don't have any installed.

When you have your web-site and FTP client up and running, follow the next 10 steps:

  1. Download DAlbum 1.42 build 162 from dalbum142_162.zip (180kb) or dalbum142_162.tar.gz.
  2. Create a directory on your web-site. The following assumes that the created directory is /photo inside your web-root.
  3. Extract dalbum142_162.zip file into your /photo directory. The following directory structure will be created:
    Warning: Many FTP clients do not display files and directories starting with dot (like .private) by default. Please check your FTP client settings. If you can't find the setting search for show hidden files [Your FTP Client Name] for instructions.
  4. Adjust access rights so PHP has write access to /photo/.private and /photo/pictures. On *nix with PHP running as nobody, chmod these directories to 0777.
  5. Connect to www.mysite.com/photo/index.php , click 'Log in' and login as user admin with password admin.
  6. Follow 'Reindex' link to reindex you photo album. Wait a few seconds until initial reindexing is completed.
  7. Return to the main page, you should be able to see a test picture there.
  8. If the test picture did not appear please check Troubleshooting section.
  9. Change admin password in user manager (to start user manager follow 'Users' link on the main page).
  10. Upload your digital pictures to /photo/pictures and reindex again.

If you're not satisfied with default configuration settings, please check Configuration and customization section to find out how to change DAlbum settings and modify its appearance.

Or just start editing ./config/config.php if you don't feel like reading now.

You may also consider installing Bonus Pack 1 to add slide show, video and other features.

[ Top ]

Upgrade

DAlbum was specially designed to be easily updatable to newer versions. When only configuration files are customized and the other installation files are not modified, upgrading DAlbum is very fast and easy.

Upgrade can be done either automatically or manually.

Manual upgrade

To upgrade your installation manually, download a special update only distribution which does not contain any configuration files and extract it into DAlbum folder. That's all.

Automatic upgrade

If you have DAlbum 1.20 or later installed, you can upgrade DAlbum automatically:

  1. Download and extract DAlbum update utility (Win32, 110Kb) to your harddrive.
    Do not run the utility directly out of the updalbum.zip file!
  2. Run the utility, press Add button and add your DAlbum FTP site to the list.
  3. Select sites to be updated and press Update button. You can select more than one site at once.
  4. Press 'Update' button. Update utility will automatically connect to www.delx.ca/dalbum and download the latest DAlbum build. If your site is running an older version it will be updated automatically. Your configuration files will remain untouched.

Note: The update utility provided does NOT send ANY personal information to delx.ca site. Only version.txt and dalbum.cab are downloaded using HTTP protocol. If still in doubt, download the source code here (it's quick&dirty, mind you :) ).

Upgrade notes

Upgrading to 1.30-1.31 to 1.32

In 1.32 configuration files are moved to a separate folder ./config. DAlbum still will be able to locate your configuration in ./include directory, but it is recommended to move them into ./config manually.

If you would like to use "fit-to-window" image resizing on your site, please update your t_showimg.php file from the 1.32 distribution or from here. This updated template contains several important fixes.

Upgrading 1.06-1.22 to 1.3

When manually upgrading to version 1.3, you will need to create two new template files: include/t_index.php and include/t_showimg.php. You can download just these two templates from here.

Upgrading 1.01-1.06

Upgrade is not supported for DAlbum 1.06 and earlier - too many changes and new files have been added since. Do complete reinstall in this case.

[ Top ]

Troubleshooting

So it does not work? It will. So far no PHP 4.1+ server has been found where DAlbum could not have been started eventually. Chances are good that problem can be solved even without calling your ISP.

First of all download test.zip and extract test.php from it to DAlbum installation directory. Run the file. Several tests will be performed and the produced detailed error report helps to identify the most common configuration and permission problems. Read the error messages - they might give you a clue. Very often there is a problem with permissions or invalid configuration.

Few additional recommendations:

If you have been unable to fix the problem yourself, ask in DAlbum forum. Try to search for an existing answer first. Please give a detailed report. URL of your problem site and test.php output would be useful too.

[ Top ]

Download

DAlbum installation
dalbum142_162.zip (228.2KB)
dalbum142_162.tar.gz (162.6KB)
Full DAlbum installation package (see New Installation)
dalbum142_162_upd.zip (173.2KB)
dalbum142_162_upd.tar.gz (119.4KB)
Package without configuration files to update existing installations (see Upgrade)
Old versions
dalbum134_89.zip (0 bytes)Version 1.34 build 89. Full package
Documentation
dalbum_docs.zip (11.5KB)
dalbum_docs.tar.gz (6.2KB)
Printable version of this site archived.
Additional files
test.zip (28.1KB)
test.tar.gz (28KB)
DAlbum test script (see Troubleshooting)
templates.zip (3.1KB)
templates.tar.gz (2KB)
Default t_showimg.php and t_index.php page templates (required to upgrade DAlbum to version 1.30+ from earlier versions.)
rsnetpbm.zip (799 bytes)
rsnetpbm.tar.gz (666 bytes)
Perl script for NetPBM support in DAlbum (see FAQ)
Utilities
updalbum.zip (112.2KB)DAlbum automatic update utility (see Upgrade)
Additional stylesheets
all24css.zip (85.4KB)24 DAlbum stylesheets ( created by mrbass [at] mrbass [dot] org )
Patched DAlbum templates
slideshow.zip (7.6KB)
slideshow.tar.gz (6.6KB)
Page templates with slide show capabilities (see Slide show)
comments.zip (7.2KB)
comments.tar.gz (6.2KB)
Page templates with image comments capabilities (see Image comments)
exifline.zip (1.8KB)
exifline.tar.gz (1.5KB)
exifline.php file for Display EXIF line sample.
customimg.zip (31.3KB)
customimg.tar.gz (13.6KB)
A set of code snippets and graphics files with custom folder graphics. (see Modify folder thumbnail graphics for details)
customtypes.zip (68.5KB)
customtypes.tar.gz (64.9KB)
Page templates with support for additional file types. (see Add video support for details)
nuke.zip (8.4KB)
nuke.tar.gz (5.2KB)
PHP-Nuke module (see PHP-Nuke for details)
bonus1.zip (88.5KB)
bonus1.tar.gz (77.8KB)
Bonus pack 1. Page templates with built-in additional file types support, slide show and EXIF line
[ Top ]

Configuration

Before you begin playing with configuration it might be worth checking some of the following topics:

[ Top ]

Basics

File manager user interface

DAlbum user interface and model of operation was copied from a file manager. There is a tree of directories on the left, and thumbnails displayed on the right.

This similarity goes beyound user interface. DAlbum expects images to be stored as you probably have them already - in a system of nested directories and subdirectories.

For example:

Serving images

Album users have access to only two DAlbum pages. The first page is index page with tree view and thumbnails. The second page is displayed when user clicks on the thumbnail and shows a large version of the image.

Every image is stored in DAlbum in maximum three different sizes:

Resized image is not created if the Original is small enough (i.e. smaller than 800x600 by default). Thumbnail is created even if the Original is smaller than thumbnail size.

Images are resized in advance by album reindexing procedure. Resampling of an average 3 Megapixel image requires up to 2 seconds on PentiumIV-1.5MHz so it would not be possible to do it "on fly".

Sorting images and directories

Exactly as many file managers do, DAlbum orders images and directories in alphabetical order of their filenames. This way images produced by modern digital cameras as "IMG_0001","IMG_0002" are sorted automatically. Things get worse with custom filenames. In the example above album "Birthday 2003" is displayed above "Christmas 2002" although chronologically it must be vice versa.

Solution is obvious - either a new level of subdirectories is produced:

Or a date is added before the folder name:

Please note that only filenames will have the leading digits - it is possible to change album and image titles aftewards to produce a tree as follows:

Leading digits can also be removed automatically by using a method described in FAQ.

Another suggestion is not to use spaces and special characters in names of files and directories as these names will be used in a page url.

For example, if a directory is named "2002-Christmas-2002", the produced URL to it would be http://www.mysite.com/index.php?folder=2003-Christmas-2002. It certainly looks better than the URL for "2002 Christmas 2002" - http://www.mysite.com/index.php?folder=2002%20Christmas2%202002.

[ Top ]

What does reindexing do?

When you press 'Reindex' button on the index page, DAlbum scans all subdirectories of  /photo/pictures for .JPG, .GIF and .PNG image files.

For every found image DAlbum creates a thumbnail in _thm subdirectory, and a resized version of the image in _res subdirectory.

For example /photo/pictures/2003/Birthday directory contains 2048x1536px img001.jpg:

DAlbum creates a 128x128 thumbnail (resolution is configured in config.php) of the image as _thm/thm_img001.jpg and 800x600 resized version as _res/res_img001.jpg:

In addition to that, a skeleton of album definition file .albumdef.ini is created in every directory. This file contains various information - album name, comments, access-control directives and titles of individual images.

Convenient web-interface is provided for editing .albumdef.ini files, but you can modify it with any text editor. Please note that after making changes with an external editor you need to reindex the album manually for your settings to apply. Changes made through web-interface apply immediately.

Example of .albumdef.ini:

[Album]
; Album title, date and comments.
Title=Baby Shower party
Date=Jun 2003
Comment=
CommentHTML=This was my <b>Baby Shower</b>party

; Title image specifies album image that will be shown as album thumbnail.
; First image is default if not specified
TitleImage=pic1.jpg

; Default=1 - show this album when DAlbum is started
Default=0

; Access control - comma-separated user list or 'valid-user' for "any user"
; Empty string or 'all' allows anonymous access
Access=valid-user

; --------------- Album files --------------------------
[pic1.jpg]
Title=This is picture1
Comment=This is plain-text comment
CommentHTML=

[pic2.jpg]
Title= This is picture2
Comment=
CommentHTML=<b>HTML</b> comments are <strike>cool</strike>

You can use multi-line parameters (useful for comments) by terminating the line with "\" character. For example:

CommentHTML=\
This was my <b>Baby Shower</b>party<BR>\
This is the second line!

After reindexing, a file /photo/.private/.album_index.dat is created. This file contains photo album structure and is used every time the album tree is displayed. When album folder is renamed or other big change occurs, reindex should be done again to update this directory structure file.

In addition to /photo/.private/.album_index.dat file, a special .album_hash.dat hidden file is created in every _thm directory. This file is used to detect possible changes made to album original images and regenate corresponging thumbnails.

Notes:

  1. Files and directories starting with _ or with . are skipped by reindexing process.
  2. Thumbnails and resized images are created only if they do not exist or if the size of original image has changed. There are three possible ways to regenerate already existing thumbnails:
  3. By default resized image size is set to 50000x600. In other words, no resized image can exceed 600 pixels in height but is practically unlimited in width. This was made on purpose to support panoramic images.
  4. GIF and PNG files are not resized by default. If you need to display a map or screenshot in your album that should not be resized to preserve image quality - put it in GIF or PNG format. It is also possible to change this setting individually for each picture in .albumdef.ini file by adding Resize=1 or Resize=0 variable to the file section.
[ Top ]

Access control

Configuring access control

In default configuration anonymous access is allowed to all images and there is an administrator who can do album reindexing and/or change .albumdef.ini files. It is possible to change this configuration of course.

For example, there are three users:

and four albums:

In order to add users, login as admin (default password is admin) and proceed to user manager by clicking "Users" button. Alternatively you can manually edit the users file as described in notes below.

Then you need to modify .albumdef.ini files. Login as admin and use 'Edit' link next to the album title to open the file. Set Allowed users: field in every album as follows:

Album Allowed users:
Tremblant all
Private admin
Drinking party valid-user
Family only admin, family

After making these changes, reindex your photo album.

Note:

  1. Access control is cumulative. For example, if you have folder MyFolder accessible only to user admin, and allow anonymous access to MyFolder/SubFolder, only admin will be able to access MyFolder/SubFolder anyway.
  2. User list is contained in /photo/private/.htpasswd file. In order to modify the file you need a htpasswd command-line utility which is a part of Apache web-server. If you don't have the utility, download Win32 binary from http://users.tibus.com/support/passwd.php

Multiple administrator accounts

By default only user admin has access to album reindexing. You can change your administrators by editing config.php

$g_sAdminUsers=array("admin","friend");

Having multiple administrators can be useful if you decide to share web-space between several users. For example, user friend can create his own albums under /pictures/friend directory and user family under /pictures/family. DAlbum by itself does not contain any code to handle image upload, but you can setup FTP permissions accordingly or use Comet WebFileManager.

Please note than only first administrator has access to the user manager. The other administrators are allowed to reindex only.

Access control modes

DAlbum can authenticate users in two modes: session mode and Basic HTTP Authentication.

Session mode (default) is used when $g_bHTTPAuth is set to false in config.php. In this case users are authenticated by using a custom logon page, which will set a session cookie to authenticate a user. The good thing is that session mode works on any web-server and any PHP configuration (CGI or Apache module), and there is a nice "Log out" button. However, this mode is slower than "Basic HTTP Authentication" and does not work with browser cookies disabled.

Basic HTTP Authentication  is used when $g_bHTTPAuth is set to true in config.php. This mode currently requires Apache web server and PHP installed as Apache module. In this case users are authenticated by Apache automatically according to .htaccess files which are created by DAlbum during reindexing, and standard "Enter your password" dialog is used instead of the custom page. This method is slightly faster than the first one and works well if cookies are disabled. The drawback is that it is not possible to log out without restarting the browser.

URL login in Session mode

Starting version 1.38 it is possible to login a user from the URL with username and password separated with colon: www.delx.ca/dalbum/sample/index.php?login=user:user. Very convenient for sending links by e-mail.

Another new feature is that you can add "temporary" users who do not need a password, but are allowed to view explicitly allowed albums only.

For example, you want to send a link to DAlbum sample album "Tremblant" to a friend, but don't want to create a special user for him or to allow him to see your other personal pictures.

Now it is possible to set album access list to "user,-tremblant2222" and hurrah! - a link www.delx.ca/dalbum/sample/index.php?login=-tremblant2222 will give access to the album, and, more good news, automatically direct the user to the album "Tremblant".

Should it become necessary to revoke this url - remove "-tremblant2222" from the access list and that's it!

[ Top ]

Securing DAlbum installation

Secure DAlbum installation ensures that:

Contents:

How DAlbum creates links to images

An image pictures/folder1/test.jpg can be accessed by client browser in two ways:

This behavior is configured by $g_bDirectAccess variable in config.php.

Indirect links

When $g_bDirectAccess is set to false (default setting), all images are returned indirectly through PHP script photo.php. photo.php verifies that user has appropriate access rights to view the image and, if all is fine, returns it to client browser.

The obvious drawback of this method is that PHP script is executed every time an image is downloaded and security check is performed even if the image is publicly available.

The benefit is flexibility - DAlbum script has control of every image download and may deny access if a certain condition is true. This can be used to prevent direct linking as will be discussed in FAQ.

Another benefit of indirect linking is that images can be stored outside of your web root location. For example, if the web root is /var/www/html, images can be stored in /home/john and be accessible.

Direct links

When $g_bDirectAccess is set to true, all public images are returned with direct links and DAlbum does not get control when an image is downloaded. Private images (which are available only to authenticated users) are still returned with indirect links to enable permission check. However, when Basic HTTP Authentication is enabled, private image paths are also returned as direct links - it's up to Apache to verify access rights in this case.

Direct linking is fast: images are served by web server without calling PHP. Flexibility suffers a little as image files must be kept inside web root. Script also must know how to translate a filename (/photo/folder1/test.jpg) to a URL visible from outside (www.mysite.com/something/photo/filder1/test.jpg). This is achieved by setting $g_sAlbumsRootBrowser variable.

For example, there is a shared hosting and

From browser this pictures directory would be accessible as www.mysite.com/users/john/pictures. To let DAlbum correctly translate filename to browser URL, $g_sAlbumsRootBrowser must be set as follows:

$g_sAlbumsRootBrowser="/users/john/pictures";

This way an image /home/users/john/pictures/folder1/test.jpg will be linked as www.mysite.com/users/john/pictures/folder1/test.jpg and successfully displayed in client browser.

Securing DAlbum installation on Apache

When Apache web-server is used, DAlbum installation is relatively secure right after it is unpacked. Access security is achieved via set of .htaccess files.

The main .htaccess file located in the installation directory disables access to files starting with a dot:

Satisfy All

<Files ~ "^\.">
order allow,deny
allow from all
deny from all
</Files>

Files in .private folder contain only files starting with a dot and thus cannot not be accessed. Additional .htaccess in ./config blocks all access to this directory, and files from ./include do not contain any sensitive information nor can be used to hack the script.

The only directory that requires additional protection is ./pictures and its subdirectories. To prevent unauthorized access to private images, DAlbum reindex automatically creates .htaccess in all private folders.

Format of this .htaccess file depends on $g_sPrivateDir directory setting. If $g_sPrivateDir starts with a dot and thus contains a relative path, DAlbum creates a simple .htaccess file that blocks all HTTP access to the folder.

When$g_sPrivateDir contains absolute path, basic HTTP authentication can be used to access the image.

For example, DAlbum samples contain protected album "Tremblant" which can be accessed only by users user and admin.

$g_sPrivateDir is set to absolute path:

$g_sPrivateDir="/var/html/sample/pictures/.private";

A special variable $g_sSiteRootDir may also be required on virtual hosts to specify URL prefix from Apache perspective. In my particular hosting case the setting is:

$g_sSiteRootDir="/home/virtual/site221/fst";

but it will be different on your host, check already existing .htaccess files, Apache logs or contact your ISP to obtain this information. Quite likely your host will be satisfied with the default value which is an empty string.

Generated .htaccess file for "Tremblant" folder looks as follows:

AuthName "Photo Album"
AuthType Basic
AuthUserFile /home/virtual/site221/fst/var/html/dalbum/sample/.private/.htpasswd
Satisfy All

<Limit GET POST>
require user admin user
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
<Files .albumdef.ini>
order allow,deny
deny from all
</Files>

In other words, DAlbum .htpasswd file is used for authentication by Apache and access is only granted to admin and user. You may verify it by connecting to http://www.delx.ca/dalbum/sample/pictures/Mountains/Tremblant/_res/res_IMG_2879.JPG . The username/password is user/user or admin/admin.

Basic HTTP authentication

Basic HTTP authentication can only be used if PHP is installed as Apache module on Apache web server. It cannot be used with Microsoft IIS, or if PHP is running as CGI (most ISPs have PHP installed as CGI for security reasons).

In this case there are no Login/Logoff pages any longer and standard browser "Enter password" dialog is used instead:

It speeds up the server considerably: Apache does authentication and permission checks much faster than interpreted PHP script.

Before enabling basic HTTP authentication, specify $g_sPrivateDir as absolute path, reindex and verify on one of your private albums that correct .htaccess files are created.

Then edit config.php and set:

$g_bDirectAccess=true;
...
$g_bHTTPAuth=true;

Basic HTTP authentication and PHP CGI

If all images in your album are password protected, basic HTTP authentication can be used even with PHP in CGI mode.

In order to use it follow instructions in Basic HTTP authentication and create the following .htaccess file in DAlbum root directory:

AuthName "Photo Album"
AuthType Basic
AuthUserFile /var/html/dalbum/sample/.private/.htpasswd
Satisfy All
require valid-user

<Files ~ "^\.">
order allow,deny
allow from all
deny from all
</Files>

First four lines should be taken from .htaccess files inside ./pictures directory. It is very important that AuthName and AuthUserFile are identical in all .htaccess files. AuthName for .htaccess DAlbum creates is configured in $g_sAuthName variable in config.php.

Note that username/password will be required at all times to access pictures and no anonymous access is allowed.

Securing DAlbum on Microsoft IIS

As MicrosoftIIS ignores all .htaccess files supplied with DAlbum, you need to secure your installation manually. Go to Properties of the following DAlbum subdirectories:

and disable Read, Write and Directory browsing:

As DAlbum cannot change access control rights to directories with .htaccess files and cannot share .htpasswd file with IIS, it is best to keep direct access to images switched off in config.php (these are default settings):

$g_bDirectAccess=false;
...
$g_bHTTPAuth=false;

 

[ Top ]

Uploading images

FTP

DAlbum by itself does not contain any image uploading code. In my opinion, FTP is much better suited for handling multiple uploads than any web-interface: it is faster, easier to use, allows multiple upload threads etc. When there are 100 pictures to upload, there is no other choice but FTP.

It is also questionable whether FTP is too complex for an average user. An average user typing ftp://user:pass@ftp.myserver.com in Microsoft Internet Explorer receives friendly and relatively convenient file management interface. Drag&drop can be used to move files back and forth often without realizing that upload/download is being done. Nothing new really: no web interfaces with their limitations, no security problems with PHP and file ownership etc.

PHP file managers

When FTP is not an option, a separate PHP file manager can be installed. One of the following is recommended (all are free):

You may also try searching Google or HotScripts for other file manager scripts, but the bulk majority of the free ones (I tried about 20 of them) are either too simple, or do not work, or look ugly, or require register_globals to be on, or are dangerously insecure etc. Perhaps I was not lucky enough.

In future there also will be DAlbum PHP file manager extension (available as separate download) that will respect DAlbum permission settings and color schemes.

Adding upload button

So the following assumes that either you have decided to allow users to use FTP, or have one of the PHP file managers in place.

Now you need to add 'Upload' button to the DAlbum toolbar when DAlbum is in admin mode.

The recommended solution would be to edit config/custom.php, uncomment customGetButton function and change it as follows:

 function customGetButton($id$href$text$title$nSpacer$target)
{
    
$ret=getButton($id,$href,$text,$title,$nSpacer,$target,false);;

    if (
$id=='reindex')
    {
        
// change here!
       
$uploadURL="ftp://user:password@ftp.mysite.com/public_html/photo/pictures";
        
// Add 'Upload' button after reindex
        
$ret.=getButton('upload',"$uploadURL","Upload","Upload files",2,"_new",false);
    }
    return 
$ret;
}

Change $uploadURL to point to your PHP file manager or FTP location.

[ Top ]

Configuration files

DAlbum is a relatively small and flexible script, and can be easily tailored to suit your needs. All you need to do is to edit a few configuration files.

So far there is no web-interface provided for changing these files, so please use your favorite text editor.

DAlbum configuration consists of four separate files:

There is also fifth configuration file custom.css which resides in the main directory. This file contains your custom styles and is included into all produced pages after the main stylesheet (which is configured in /config/config.php). This is useful when you're happy with one of the supplied templates but need to tweak a few colors.

It is a good idea not to modify any code beyond these configuration files. This way upgrades can be done easily or almost automatically (with the utility provided). It does not limit your freedom much. This site, for example, is also running DAlbum and only configuration files were changed - everything else was left intact.

[ Top ]

Customization

This section provides a number of DAlbum customizations and information how to add your own ones.

Usually no PHP knowledge is required to use the samples listed, but some basic programming experience would be very helpful.

[ Top ]

Allow users to add comments

The purpose of this sample is to demonstrate how to add simple image commenting system to your album. Number of image comments is displayed on the index page.

Administrator can see IP addresses of comment senders and delete unwanted messages. As comments are stored in a simple text files one line per comment, administration can also be done with a text editor over FTP.

Depending on configuration anonymous users may not be allowed to post comments or even view comments at all. Administrator may be notified by e-mail when a new comment is posted.

Please check demo for an example.

Comments are stored in .cmt files next to original album images. For example, comments for /photo/album1/picture1.jpg are stored in /photo/album1/picture1.cmt.

Instructions

If you don't feel like patching configuration files yourself, download and install already patched set of templates from comments.zip.

1. Edit your t_showimg.php page template and insert the following code snippet at the beginning of the file (after the title comments:)
  <?php
    
////////////// Image Comments customization 1 of 2 begins ///////////////
    
include(DALBUM_ROOT "/config/comments.php");

    
$nCommentsAuth=1/*   0=all users can view and post messages,
                           1=all users can view, but only authenticated can post
                           2=anonymous users do not see any comments */

    
$sAdminEmail="";  /* Put admin e-mail here. Ex. john@hotmail.com */
    
$sFromEmail="DAlbum <dalbum@mysite.com>";

     if (
DAlbum_Comments_Plugin_Send(    $nCommentsAuth,
                                        
$sAdminEmail,
                                        
$sFromEmail ))
    {
        
header("Location: " base64_decode(encodeCurrentLocation()));
        return;
    }
    
////////////// Image Comments customization 1 of 2 ends ///////////////
?>

Modify configuration variables appropriately.

Then insert the following piece of code just before '<!-- Row 3: copyright -->' line:

  <?php
////////////// Image Comments customization 2 of 2 begins ///////////////
DAlbum_Comments_Plugin_Display($nCommentsAuth);
////////////// Image Comments customization 2 of 2 ends ///////////////
?>

2. Edit your custom.php and find and uncomment customTitle function. Replace its body with the following code snippet:

 function customTitle(&$object$titleDefault)
{
    
$ret=$titleDefault;

    if (
$object->IsImage())
    {
        
$imagefname=absfname($object->m_sFullFilename);
        
$textfname=dirname_ex($imagefname) . "/" getfname($imagefname) . ".cmt";

        
$cnt=0;
        if (
file_exists($textfname))
        {
            
$f=@safe_read_file($textfname);
            foreach (
$f as $line)
                if (
strlen(trim($line)))
                    
$cnt++;
        }
        if (
$cnt)
            
$ret="<span class='imageTitle'>" $object->GetTitle() .
                 
"&nbsp;($cnt&nbsp;comments)</span>";
    }

    return 
$ret;
}

3. Edit your custom.css and append the following lines to the file:

  .imagecommentsRow
{
    /* Uncomment the next line for main_blue.css */
    /* background-color: #444444; */

    /* Uncomment the next line for main_cyan.css */
    /* background-color: #CCDDFF; */
}
table.imagecomments
{
    margin-top: 20px;
    font-size: 80%;
    border-top: 2px solid black;

    /* Uncomment the next line for main_cyan.css */
    /* color: black; */
}

table.imagecomments th
{
    padding: 10px;
}

table.imagecomments td.imagecomment
{
    border-top: 1px dashed black;
}

table.imagecomments td.imagecommentform
{
    border-top: 1px dashed black;
}

table.imagecomments td.imagecommentform table
{
    font-size: 100%;
}

You may need to adjust colors in this snippet to match your color scheme.

4. Create comments.php file in ./config directory and paste the following text:
  <?php

if (!defined('DALBUM_ROOT')) die("Security violation!");

// localization strings have been added to distribution already
/*
$lang['cCommentsImageComments']="Image comments";
$lang['cCommentsLoginToAddComments']='Please #loginbutton# to add your comments.<BR>&nbsp;';
$lang['cCommentsYourName']='Your name:';
$lang['cCommentsComment']='Comment:';
$lang['cCommentsSendButtonText']='Send';
$lang['cCommentsDeleteButtonText']='Delete';
$lang['cCommentsMailSubject']="New comment about image #image# ( Album: #album# )";
$lang['cCommentsMailBody']   ="New comment posted by #user#, IP: #ip#,".
                              "DNS: #dns#\n\n#body#\n\nPage URL: #url#\n";
$lang['cCommentsDateFormat'] ="F j, Y, g:i a";
*/

function DAlbum_Comments_Plugin_Send(   $nCommentsAuth,
                                        
$sAdminMail,
                                        
$sFromLine )
{
    global 
$lang,$sUserName,$image,$bAdminMode,$album;
    
//
    
$bShowComments=($nCommentsAuth<|| !empty($sUserName));
    
$bShowForm=($nCommentsAuth==|| !empty($sUserName));
    
$bShowLogin=($nCommentsAuth==&& empty($sUserName));

    if (!
$bShowComments || !$bShowForm)
        return 
false;

    
// $image variable is set to displayed image
    
$imagefname=absfname($image->m_sFullFilename);
    
$textfname=dirname_ex($imagefname) . "/" getfname($imagefname) . ".cmt";

    
// Add new comments
    
if (!isset($_POST['comment']))
        return 
false;

    
$arr=array();
    
$arr[]=$_POST['realname'];

    
// Add IP address
    
$ip=$_SERVER['REMOTE_ADDR'];
    if (@
$_SERVER["HTTP_X_FORWARDED_FOR"])
        
$ip=$_SERVER["HTTP_X_FORWARDED_FOR"];

    
$arr[]=$ip;

    
// Change to your preferred date format here
    
$arr[]=date($lang['cCommentsDateFormat']);

    
$body=trim($_POST['comment']);
    if (empty(
$body))
        return 
false;
    
$arr[]=$body;

    
// Notify admin by mail
    
if (!empty($sAdminMail))
    {
        
$dns=@gethostbyaddr($ip);

        
$subject strtr$lang['cCommentsMailSubject'], array(
                            
"#image#"=>$image->m_sBaseFilename,
                            
"#album#"=>$album->GetTitle() ));

        
$url="http://" $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']
                         . 
"?" . @$_SERVER['QUERY_STRING'];

        global 
$g_sCharset;

        if (
preg_match('/[^a-zA-Z0-9!@#$%&*()-{}]/',$subject))
            
$subject="=?$g_sCharset?B?".base64_encode($subject)."?=";
        else
            
$subject=$subject;


        
$headers="";
        if (!empty(
$sFromLine))
            
$headers="From: " $sFromLine."\n";

        
$headers.="Content-type: text/plain; charset=$g_sCharset\n";
        
$headers.="MIME-Version: 1.0\nX-Priority: 3 (Normal)\n";
        
$headers.="X-MSMail-Priority: Normal\n";
        
$headers.="X-Mailer: DAlbum\n";

        
$message strtr$lang['cCommentsMailBody'], array(
                            
'#user#'=>$arr[0],
                            
'#ip#'=>$arr[1],
                            
'#dns#'=>$dns,
                            
'#body#'=>$body,
                            
'#url#'=>$url));

        
mail($sAdminMail$subject$message$headers);
    }

    
// Cut very long strings and quote HTML
    
for ($i=0;$i<count($arr);++$i)
    {
        if (
strlen($arr[$i])>2000)
            
$arr[$i]=substr($arr[$i],0,2000)+"...";

        
$arr[$i]=str_replace("\n",'',nl2br(quotehtml($arr[$i])));
        
$arr[$i]=str_replace("",'',$arr[$i]);
    }

    
$handle=fopen($textfname,"at");
    if (
$handle)
    {
        
$line=join(":|:",$arr)."\n";
        @
fwrite($handle,$line);
        @
fclose($handle);

        global 
$g_newDirRights;
        @
chmod($textfname,$g_newDirRights);
    }
    return 
true;
}

function 
DAlbum_Comments_Plugin_Display($nCommentsAuth)
{
    global 
$lang,$sUserName,$image,$bAdminMode,$album;

    
//
    
$bShowComments=($nCommentsAuth<|| !empty($sUserName));
    
$bShowForm=($nCommentsAuth==|| !empty($sUserName));
    
$bShowLogin=($nCommentsAuth==&& empty($sUserName));

    if (
$bShowComments)
    {
        
// $image variable is set to displayed image
        
$imagefname=absfname($image->m_sFullFilename);
        
$textfnamedirname_ex($imagefname) . "/" .
                    
getfname($imagefname) . ".cmt";

        
//////////// Image comments header begins  ////////////
        
?>
            <!-- Image comments code begin -->
            <tr>
            <td align="center" class="imagecommentsRow">
            <table class="imagecomments">
            <tr><th><?php print $lang['cCommentsImageComments']; ?></th></tr>
<?php   //////////// Image comments header ends  ////////////

        // Display existing comments

        
if (file_exists($textfname))
        {
            
$file=safe_read_file($textfname);

            
$bChanged=false;
            
$hashDelete="";
            if (
$bAdminMode && isset($_POST['deleteComment']))
                
$hashDelete=$_POST['hashComment'];

            for (
$i=0;$i<count($file);++$i)
            {
                
$line=trim($file[$i]);
                if (empty(
$line))
                    continue;

                
$linehash=md5($line);

                
// If this line was marked to delete - make it empty
                
if (!empty($hashDelete) && $hashDelete==$linehash)
                {
                    
$file[$i]="";
                    
$hashDelete="";
                    
$bChanged=true;
                    continue;
                }

                
// Display found line
                
$arr=explode(":|:",$line);
                
$name=$arr[0];
                
$ip  =$arr[1];
                
$date=$arr[