SiGal
Simple gallery script provides single-file web gallery.
 All Classes Functions Variables
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
Sigal Class Reference

Simple gallery script provides single-file web gallery. More...

List of all members.

Public Member Functions

 __construct ()
 Actually only redefines $this->html_head and $this->html_tail.
 addAccess ()
 Adds string $user.':'.$pass to array $_SESSION['givenaccess']. The values are obtained from $_POST['fuser'] and $_POST['fpass'].
 showGallery ()
 Shows complete gallery - the albums selection.
 showAlbum ($alb)
 Shows given album.
 showImage ($f)
 Shows detail of given photo.
 showPassForm ()
 Shows form for grant access.
 getAlbums ()
 Get sorted (by name reversed eg. 9->0, Z->A) array of all albums.
 getImages ($dir)
 Returns all images from given directory sorted by name and read possible locks of album.
 getAlbumTitleFile ($album)
 Gets path to title image of given album. If there are no iconificable image, the $this->defaultIcon is used.
 downloadZippedImages ()
 makeThumbImage ($file)
 Creates thumbnail of given image.
 makeMiddleImage ($file)
 Creates middle size image of given original image.
 resizeImage ($path, $max_x)
 Resizes given image (JPG, PNG, GIF, BMP) with respect to aspect ratio. Saves final image to cache.

Public Attributes

 $version = '1.0'
 $dir = './pictures/'
 $cache = './cache/'
 $defaultIcon = '?static=defico'
 $icotitlefname = '000.nfo'
 $lockfname = '000.lock'
 $thumb_x = 160
 $thumb_y = 120
 $middle_x = 800
 $imgTitleLen = 16
 $galTitle = 'SiGal gallery'
 $legal_notice = 'No photos can be distributted without written permission of their author (<a href="http://gimli2.gipix.net">Gimli2</a>).'
 $html_head = '<!DOCTYPE html><head><title>{title}</title></head><body>'
 $html_tail = '</body></html>'
 $exts = array('jpg','jpeg','png','gif','bmp','tif','tiff','svg','swf','flv','mp4', 'mp3')
 $extsIcon = array('jpg','jpeg','png', 'gif', 'bmp')
 $extsExif = array('jpg','jpeg','tif','tiff')
 $extsVideo = array('swf','flv','mp4')
 $extsAudio = array('mp3')
 $defaultMime = 'text/plain'
 $avMime

Private Member Functions

 isAccessible ()
 Test whether given album is accessible. In $_SESSION['givenaccess'] must we at least one valid user from array $this->validusers.
 sanitizePath ($p)
 Sanitize path of file or album. No jumps to parent dirs, no wildcards for glob(), path must start in pictures directory.
 getExt ($file)
 Gets the last extension of file.
 getMimeType ($file)
 Try to get mime type of file.
 getMiddleName ($file)
 Creates a filename for middle size image.
 getThumbName ($file)
 Creates a filename for thumbnail of given image.
 getImageTitle ($file)
 Gets title for image. Of the name is too long, the first 16 chars are used.
 getAlbumTitle ($file)
 Gets title for album. It can reorder parts of dir name, add some infromation like a date of modification etc.
 hasGPSData ($exif)
 Determines whether given array of EXIF contains dome GPS related data.
 getGPSLatLon ($exif)
 Parses EXIF GPS data to double representation.
 getHumanGPS ($lat, $lon)
 Converts double representation of lat/lon to human form eg. N 50° 42.000, E 15° 42.000.

Private Attributes

 $islocked = false
 $validusers = array()

Detailed Description

Simple gallery script provides single-file web gallery.


Constructor & Destructor Documentation

Actually only redefines $this->html_head and $this->html_tail.

Returns:
An instance of SiGal class.

Member Function Documentation

Adds string $user.':'.$pass to array $_SESSION['givenaccess']. The values are obtained from $_POST['fuser'] and $_POST['fpass'].

Get sorted (by name reversed eg. 9->0, Z->A) array of all albums.

Returns:
An array of all albums in defined dir ($this->dir).
Sigal::getAlbumTitle ( file) [private]

Gets title for album. It can reorder parts of dir name, add some infromation like a date of modification etc.

Parameters:
string$fileThe original album dir.
Returns:
HTML H2 tag with title of an album.

Gets path to title image of given album. If there are no iconificable image, the $this->defaultIcon is used.

Parameters:
string$albumPath to album directory with terminating slash
Returns:
URL of title image.
Sigal::getExt ( file) [private]

Gets the last extension of file.

Parameters:
string$fileFile to get extension.
Returns:
The last extension from given file.
Sigal::getGPSLatLon ( exif) [private]

Parses EXIF GPS data to double representation.

Parameters:
array$exifThe array of exif data.
Returns:
array $a[0] => (double) latitude, $a[1] => (double) longitude;
Sigal::getHumanGPS ( lat,
lon 
) [private]

Converts double representation of lat/lon to human form eg. N 50° 42.000, E 15° 42.000.

Parameters:
double$latLatitude.
double$lonLongitude.
Returns:
array $a['lat'] => (string) latitude, $a['lon'] => (string) longitude;
Sigal::getImages ( dir)

Returns all images from given directory sorted by name and read possible locks of album.

Parameters:
string$dirSource directory for scan with terminating slash.
Returns:
An array of all images.
Sigal::getImageTitle ( file) [private]

Gets title for image. Of the name is too long, the first 16 chars are used.

Parameters:
string$fileThe original filename.
Returns:
HTML H2 tag with title of an image.
Sigal::getMiddleName ( file) [private]

Creates a filename for middle size image.

Parameters:
string$fileThe original filename.
Sigal::getMimeType ( file) [private]

Try to get mime type of file.

Parameters:
string$fileThe original filename.
Returns:
Mime type of given file.
Sigal::getThumbName ( file) [private]

Creates a filename for thumbnail of given image.

Parameters:
string$fileThe original filename.
Sigal::hasGPSData ( exif) [private]

Determines whether given array of EXIF contains dome GPS related data.

Parameters:
array$exifThe array of exif data.
Returns:
boolean TRUE when some GPS related data was found, FALSE otherwise.
Sigal::isAccessible ( ) [private]

Test whether given album is accessible. In $_SESSION['givenaccess'] must we at least one valid user from array $this->validusers.

Returns:
TRUE when album is accessible, FALSE otherwise.

Creates middle size image of given original image.

Parameters:
string$fileThe original filename.
Sigal::makeThumbImage ( file)

Creates thumbnail of given image.

Parameters:
string$fileThe original filename.
Sigal::resizeImage ( path,
max_x 
)

Resizes given image (JPG, PNG, GIF, BMP) with respect to aspect ratio. Saves final image to cache.

Parameters:
string$pathThe original image..
double$max_xFinal width.
Returns:
string Full path of resized image in cache.
Sigal::sanitizePath ( p) [private]

Sanitize path of file or album. No jumps to parent dirs, no wildcards for glob(), path must start in pictures directory.

Parameters:
string$pPath for sanitization.
Returns:
Sanitized path.
Sigal::showAlbum ( alb)

Shows given album.

Parameters:
string$albFull path to album directory with terminating slash.

Shows complete gallery - the albums selection.

Sigal::showImage ( f)

Shows detail of given photo.

Parameters:
string$fPath to original image.

Shows form for grant access.


Member Data Documentation

Initial value:
 array(
    'mp3' => 'audio/mpeg',
    'mp4' => 'video/mp4',
    'swf' => 'application/x-shockwave-flash',
    'flv' => 'video/x-flv'
  )

Mime types for files. The key represents extension, value is mime type.

Sigal::$cache = './cache/'

Directory for caching thumbnails (must be writeable!).

Sigal::$defaultIcon = '?static=defico'

URL to default album and picture icon. May be absolute or relative.

Sigal::$defaultMime = 'text/plain'

Default mime type. It is used when automated recognition fails.

Sigal::$dir = './pictures/'

Directory with pictures.

Sigal::$exts = array('jpg','jpeg','png','gif','bmp','tif','tiff','svg','swf','flv','mp4', 'mp3')

Array of file extensions for scanning in directiories.

Sigal::$extsAudio = array('mp3')

Array of file extensions for audio files.

Sigal::$extsExif = array('jpg','jpeg','tif','tiff')

Array of file extensions with EXIF informations.

Sigal::$extsIcon = array('jpg','jpeg','png', 'gif', 'bmp')

Array of file extensions for which we are able to generate thumbnail.

Sigal::$extsVideo = array('swf','flv','mp4')

Array of file extensions for videofiles.

Sigal::$galTitle = 'SiGal gallery'

Title of whole gallery.

Sigal::$html_head = '<!DOCTYPE html><head><title>{title}</title></head><body>'

HTML head of each page of gallery. You can use string "{title}" which will be replaced by title of gallery defined above.

Sigal::$html_tail = '</body></html>'

HTML tail of each page of galllery.

Sigal::$icotitlefname = '000.nfo'

Name of file with definition of title image.

Number of characters of shortened image title.

Sigal::$islocked = false [private]

Flag for browsing in locked albums.

Sigal::$legal_notice = 'No photos can be distributted without written permission of their author (<a href="http://gimli2.gipix.net">Gimli2</a>).'

String shown in bottom of each page. Designed to some words about legal use of photos.

Sigal::$lockfname = '000.lock'

Name of file with defined usernames/passwords for locked/private albums.

Width of middle size picture - the view size.

Width of thumbnail. Minimal 120px.

Height of thumbnail. Minimal 120px.

Sigal::$validusers = array() [private]

Array of usernames which have access to given album.

Sigal::$version = '1.0'