[ class tree: functions ] [ index: functions ] [ all elements ]

Procedural File: functions-basic.php

Source Location: /functions-basic.php

Page Details

basic functions used by zenphoto i.php

Keep this file to the minimum to allow the largest available memory for processing images! Headers not sent yet!

Includes
require_once (dirname(__FILE__).'/lib-GD.php') [line 126]
[ Top ]

require_once (dirname(__FILE__).'/functions-db-'.(isset($_zp_conf_vars['db_software'])?$_zp_conf_vars['db_software']:'MySQL').'.php') [line 71]
[ Top ]

require_once (dirname(__FILE__).'/lib-Imagick.php') [line 124]
[ Top ]

require_once (dirname(__FILE__).'/global-definitions.php') [line 11]
[ Top ]

require_once (dirname(__FILE__).'/lib-encryption.php') [line 142]
[ Top ]

require_once (dirname(__FILE__).'/lib-gettext/gettext.inc') [line 13]
[ Top ]

require_once (dirname(__FILE__).'/lib-utf8.php') [line 54]
[ Top ]


Constants
ALBUM_FOLDER_EMPTY  [line 194]

ALBUM_FOLDER_EMPTY = getAlbumFolder('')

[ Top ]

ALBUM_FOLDER_SERVERPATH  [line 193]

ALBUM_FOLDER_SERVERPATH = getAlbumFolder(SERVERPATH)

[ Top ]

ALBUM_FOLDER_WEBPATH  [line 192]

ALBUM_FOLDER_WEBPATH = getAlbumFolder(WEBPATH)

[ Top ]

CHMOD_VALUE  [line 63]

CHMOD_VALUE = 0777

[ Top ]

COOKIE_PESISTENCE  [line 65]

COOKIE_PESISTENCE = 5184000

[ Top ]

DATE_FORMAT  [line 200]

DATE_FORMAT = getOption('date_format')

[ Top ]

FILESYSTEM_CHARSET  [line 58]

FILESYSTEM_CHARSET = $_zp_conf_vars['FILESYSTEM_CHARSET']

[ Top ]

FULLIMAGE_WATERMARK  [line 197]

FULLIMAGE_WATERMARK = getOption('fullsizeimage_watermark')

[ Top ]

FULLWEBPATH  [line 188]

FULLWEBPATH = PROTOCOL."://".$_SERVER['HTTP_HOST'].WEBPATH

[ Top ]

GALLERY_DATA  [line 78]

GALLERY_DATA = getOption('gallery_data')

[ Top ]

GALLERY_SECURITY  [line 90]

GALLERY_SECURITY = $data['gallery_security']

[ Top ]

GALLERY_SESSION  [line 85]

GALLERY_SESSION = $data['album_session']

[ Top ]

GRAPHICS_LIBRARY  [line 130]

GRAPHICS_LIBRARY = $_zp_supported_images['Library']

[ Top ]

HASH_SEED  [line 206]

HASH_SEED = getOption('extra_auth_hash_text')

[ Top ]

IMAGE_WATERMARK  [line 196]

IMAGE_WATERMARK = getOption('fullimage_watermark')

[ Top ]

IM_SUFFIX  [line 202]

IM_SUFFIX = getOption('mod_rewrite_image_suffix')

[ Top ]

IP_TIED_COOKIES  [line 207]

IP_TIED_COOKIES = getOption('IP_tied_cookies')

[ Top ]

LOCAL_CHARSET  [line 96]

LOCAL_CHARSET = $_charset

[ Top ]

MEMBERS_ONLY_COMMENTS  [line 204]

MEMBERS_ONLY_COMMENTS = getOption('comment_form_members_only')

[ Top ]

MOD_REWRITE  [line 191]

MOD_REWRITE = getOption('mod_rewrite')

[ Top ]

NO_WATERMARK  [line 530]

NO_WATERMARK = '!'

[ Top ]

OFFSET_PATH  [line 148]

OFFSET_PATH = 0

[ Top ]

PROTOCOL  [line 178]

PROTOCOL = 'https'

[ Top ]

SAFE_MODE_ALBUM_SEP  [line 189]

SAFE_MODE_ALBUM_SEP = '__'

[ Top ]

SERVERCACHE  [line 190]

SERVERCACHE = SERVERPATH.'/'.CACHEFOLDER

[ Top ]

SERVERPATH  [line 145]

SERVERPATH = str_replace("\\",'/',dirname(dirname(__FILE__)))

[ Top ]

SERVER_PROTOCOL  [line 175]

SERVER_PROTOCOL = getOption('server_protocol')

[ Top ]

THUMB_WATERMARK  [line 198]

THUMB_WATERMARK = getOption('Image_watermark')

[ Top ]

UTF8_IMAGE_URI  [line 203]

UTF8_IMAGE_URI = getOption('UTF8_image_URI')

[ Top ]

WEBPATH  [line 171]

WEBPATH = $const_webpath

OFFSET_PATH definisions:

0 Theme scripts (root index.php) 1 zp-core scripts 2 setup scripts 3 plugin scripts


[ Top ]

ZP_ALBUM  [line 20]

ZP_ALBUM = 2

[ Top ]

ZP_ALBUM_LINKED  [line 25]

ZP_ALBUM_LINKED = 64

[ Top ]

ZP_COMMENT  [line 22]

ZP_COMMENT = 8

[ Top ]

ZP_IMAGE  [line 21]

ZP_IMAGE = 4

[ Top ]

ZP_IMAGE_LINKED  [line 26]

ZP_IMAGE_LINKED = 128

[ Top ]

ZP_INDEX  [line 19]

ZP_INDEX = 1

[ Top ]

ZP_SEARCH  [line 23]

ZP_SEARCH = 16

[ Top ]

ZP_SEARCH_LINKED  [line 24]

ZP_SEARCH_LINKED = 32

[ Top ]

ZP_ZENPAGE_NEWS_ARTICLE  [line 27]

ZP_ZENPAGE_NEWS_ARTICLE = 256

[ Top ]

ZP_ZENPAGE_NEWS_CATEGORY  [line 28]

ZP_ZENPAGE_NEWS_CATEGORY = 512

[ Top ]

ZP_ZENPAGE_NEWS_DATE  [line 29]

ZP_ZENPAGE_NEWS_DATE = 1024

[ Top ]

ZP_ZENPAGE_PAGE  [line 30]

ZP_ZENPAGE_PAGE = 2048

[ Top ]

ZP_ZENPAGE_SINGLE  [line 31]

ZP_ZENPAGE_SINGLE = 4096

[ Top ]


Functions
accessAllAlbums  [line 1360]

Checks access for the album root

Parameters:
bit   $action:  what the caller wants to do


void accessAllAlbums( bit $action  )

[ Top ]
assert_handler  [line 391]

Emits an assertion error

Parameters:
string   $file:  the script file
string   $line:  the line of the assertion
string   $code:  the error message


void assert_handler( string $file, string $line, string $code  )

[ Top ]
checkInstall  [line 1510]

Check to see if the setup script needs to be run


void checkInstall( )

[ Top ]
db_count  [line 1496]
Parameters:
   $table: 
   $clause: 
   $field: 


void db_count( $table, [ $clause = NULL], [ $field = "*"]  )

[ Top ]
db_name  [line 1491]

void db_name( )

[ Top ]
debugLog  [line 1025]

Write output to the debug log Use this for debugging when echo statements would come before headers are sent or would create havoc in the HTML.

Creates (or adds to) a file named debug.log which is located in the zenphoto core folder

Parameters:
string   $message:  the debug information
bool   $reset:  set to true to reset the log to zero before writing the message


void debugLog( string $message, [bool $reset = false]  )

[ Top ]
debugLogArray  [line 1056]

"print_r" equivalent for the debug log

Parameters:
string   $name:  the name (or message) to display for the array
array   $source: 
   $indent: 
   $trail: 


void debugLogArray( string $name, array $source, [ $indent = 0], [ $trail = '']  )

[ Top ]
debugLogBacktrace  [line 1102]

Logs the calling stack

Parameters:
string   $message:  Message to prefix the backtrace


void debugLogBacktrace( string $message  )

[ Top ]
debugLogVar  [line 1137]

Records a Var to the debug log

Parameters:
string   $message:  message to insert in log
mixed   $var:  the variable to record


void debugLogVar( string $message, mixed $var  )

[ Top ]
filesystemToInternal  [line 1197]

Converts a file system filename to UTF-8 for zenphoto internal storage

Parameters:
string   $filename:  the file name to convert


string filesystemToInternal( string $filename  )

[ Top ]
getAlbumArray  [line 1222]

getAlbumArray - returns an array of folder names corresponding to the given album string.

Parameters:
string   $albumstring:  is the path to the album as a string. Ex: album/subalbum/my-album
string   $includepaths:  is a boolean whether or not to include the full path to the album in each item of the array. Ex: when $includepaths==false, the above array would be ['album', 'subalbum', 'my-album'], and with $includepaths==true, ['album', 'album/subalbum', 'album/subalbum/my-album']


array getAlbumArray( string $albumstring, [string $includepaths = false]  )

[ Top ]
getAlbumFolder  [line 981]

Returns the fully qualified path to the album folders

Parameters:
string   $root:  the base from whence the path dereives


sting getAlbumFolder( [string $root = SERVERPATH]  )

[ Top ]
getAlbumInherited  [line 1286]

returns the non-empty value of $field from the album or one of its parents

Parameters:
string   $folder:  the album name
string   $field:  the desired field name
int   $id:  will be set to the album `id` of the album which has the non-empty field
   &$id: 


string getAlbumInherited( string $folder, string $field, &$id, int $id  )

[ Top ]
getAllowedTags  [line 764]

Returns an array of html tags allowed

Parameters:
string   $which:  either 'allowed_tags' or 'style_tags' depending on which is wanted.


void getAllowedTags( string $which  )

[ Top ]
getImageCacheFilename  [line 501]

Returns the path of an image for uses in caching it NOTE: character set if for the filesystem

Parameters:
string   $album:  album folder
string   $image:  image file name
array   $args:  cropping arguments
   $album8: 
   $image8: 


string getImageCacheFilename( $album8, $image8, array $args, string $album, string $image  )

[ Top ]
getImageCachePostfix  [line 580]

Returns the crop/sizing string to postfix to a cache image

Parameters:
array   $args:  cropping arguments


string getImageCachePostfix( array $args  )

[ Top ]
getImageParameters  [line 599]

Validates and edits image size/cropping parameters

Parameters:
array   $args:  cropping arguments
   $album: 


array getImageParameters( array $args, [ $album = NULL]  )

[ Top ]
getImageProcessorURI  [line 681]

forms the i.php parameter list for an image.

Parameters:
array   $args: 
string   $album:  the album name
string   $image:  the image name


string getImageProcessorURI( array $args, string $album, string $image  )

[ Top ]
getOption  [line 261]

Get a option stored in the database.

This function reads the options only once, in order to improve performance.

Parameters:
string   $key:  the name of the option.


void getOption( string $key  )

[ Top ]
getOptionList  [line 374]

Retuns the option array


array getOptionList( )

[ Top ]
getSetClause  [line 1477]

Constructs a SET clause ("SET uniqueid1='uniquevalue1', uniqueid2='uniquevalue2' ...") from an array (map) of variables and their values which identifies a unique record in the database table. Used to 'move' records. Note: does not check anything.

Parameters:
string   $new_unique_set:  what to add to the SET clause

API Tags:
Return:  SET cleause

Information Tags:
Since:  0.6

contructed getSetClause( string $new_unique_set  )

[ Top ]
getSuffix  [line 1264]

Returns the suffix of a file name

Parameters:
string   $filename: 


string getSuffix( string $filename  )

[ Top ]
getWatermarkParam  [line 541]

Returns the watermark image to pass to i.php

Note: this should be used for "real" images only since thumbnail handling for Video and TextObjects is special and the "album" thumbnail is not appropriate for the "default" images for those

Parameters:
$image   $image:  image object in question
$use   $use:  what the watermark use is


string getWatermarkParam( $image $image, $use $use  )

[ Top ]
getWatermarkPath  [line 1377]

Returns the path to a watermark

Parameters:
string   $wm:  watermark name


string getWatermarkPath( string $wm  )

[ Top ]
getWhereClause  [line 1457]

Constructs a WHERE clause ("WHERE uniqueid1='uniquevalue1' AND uniqueid2='uniquevalue2' ...") from an array (map) of variables and their values which identifies a unique record in the database table.

Parameters:
string   $unique_set:  what to add to the WHERE clause

API Tags:
Return:  WHERE cleause

Information Tags:
Since:  0.6

contructed getWhereClause( string $unique_set  )

[ Top ]
hasDynamicAlbumSuffix  [line 403]

Returns true if the file has the dynamic album suffix

Parameters:
string   $path: 


bool hasDynamicAlbumSuffix( string $path  )

[ Top ]
html_encode  [line 239]

encodes a pre-sanitized string to be used in an HTML text-only field (value, alt, title, etc.)

Parameters:
string   $this_string: 


string html_encode( string $this_string  )

[ Top ]
imgSrcURI  [line 1253]

Returns an img src URI encoded based on the OS of the server

Parameters:
string   $uri:  uri in FILESYSTEM_CHARSET encoding


string imgSrcURI( string $uri  )

[ Top ]
instrument  [line 1151]

Tool to log execution times of script bits

Parameters:
string   $point:  location identifier


void instrument( string $point  )

[ Top ]
internalToFilesystem  [line 1208]

Converts a Zenphoto Internal filename string to one compatible with the file system

Parameters:
string   $filename:  the file name to convert


string internalToFilesystem( string $filename  )

[ Top ]
is_valid_other  [line 1241]

Returns true if the file is a valid 'other' type

Parameters:
string   $filename:  the name of the target


bool is_valid_other( string $filename  )

[ Top ]
js_encode  [line 249]

encodes a pre-sanitized string to be used as a Javascript parameter

Parameters:
string   $this_string: 


string js_encode( string $this_string  )

[ Top ]
loadLocalOptions  [line 1333]

Loads option table with album/theme options

Parameters:
int   $albumid: 
string   $theme: 


void loadLocalOptions( int $albumid, string $theme  )

[ Top ]
mkdir_recursive  [line 1171]

Makes directory recursively, returns TRUE if exists or was created sucessfuly.

Note: PHP5 includes a recursive parameter to mkdir, but PHP4 does not, so this is required to target PHP4.

Parameters:
string   $pathname:  The directory path to be created.
   $mode: 

API Tags:
Return:  TRUE if exists or made or FALSE on failure.


boolean mkdir_recursive( string $pathname, [ $mode = 0777]  )

[ Top ]
parse_size  [line 1179]

Parses a byte size from a size value (eg: 100M) for comparison.

Parameters:
   $size: 


void parse_size( $size  )

[ Top ]
pathurlencode  [line 929]

rawurlencode function that is path-safe (does not encode /)

Parameters:
string   $path:  URL


string pathurlencode( string $path  )

[ Top ]
prefix  [line 1440]

Prefix a table name with a user-defined string to avoid conflicts.

This MUST be used in all database queries.

Parameters:
string   $tablename:  name of the table

API Tags:
Return:  table name

Information Tags:
Since:  0.6

prefixed prefix( [string $tablename = NULL]  )

[ Top ]
purgeOption  [line 362]
Parameters:
   $key: 


void purgeOption( $key  )

[ Top ]
reconfigure  [line 1520]

Redirects to setup if the files are present. Otherwise notifies need for re-upload


void reconfigure( )

[ Top ]
rewrite_get_album_image  [line 421]

rewrite_get_album_image - Fix special characters in the album and image names if mod_rewrite is on: This is redundant and hacky; we need to either make the rewriting completely internal, or fix the bugs in mod_rewrite. The former is probably a good idea.

Old explanation: rewrite_get_album_image() parses the album and image from the requested URL if mod_rewrite is on, and replaces the query variables with corrected ones. This is because of bugs in mod_rewrite that disallow certain characters.

Parameters:
string   $albumvar:  "$_GET" parameter for the album
string   $imagevar:  "$_GET" parameter for the image


void rewrite_get_album_image( string $albumvar, string $imagevar  )

[ Top ]
rewrite_path  [line 908]

Returns either the rewrite path or the plain, non-mod_rewrite path based on the mod_rewrite option.

The given paths can start /with or without a slash, it doesn't matter.

IDEA: this function could be used to specially escape items in the rewrite chain, like the # character (a bug in mod_rewrite).

This is here because it's used in both template-functions.php and in the classes.

Parameters:
string   $rewrite:  is the path to return if rewrite is enabled. (eg: "/myalbum")
string   $plain:  is the path if rewrite is disabled (eg: "/?album=myalbum")
bool   $webpath:  true if you want the WEBPATH to be returned, false if you want to generate a partly path. A trailing "/" is always added.


string rewrite_path( string $rewrite, string $plain, [bool $webpath = true]  )

[ Top ]
safe_glob  [line 1403]

Provide an alternative to glob which does not return filenames with accented charactes in them

Parameters:
string   $pattern:  the 'pattern' for matching files
bit   $flags:  glob 'flags'


void safe_glob( string $pattern, [bit $flags = 0]  )

[ Top ]
sanitize  [line 746]

Make strings generally clean. Takes an input string and cleans out null-bytes, slashes (if magic_quotes_gpc is on), and optionally use KSES library to prevent XSS attacks and other malicious user input.

Parameters:
string   $input_string:  is a string that needs cleaning.
string   $sanitize_level:  is a number between 0 and 3 that describes the type of sanitizing to perform on $input_string.
  1. - Basic sanitation. Only strips null bytes. Not recommended for submitted form data.
  2. - User specified. (User defined code is allowed. Used for descriptions and comments.)
  3. - Text style/formatting. (Text style codes allowed. Used for titles.)
  4. - Full sanitation. (Default. No code allowed. Used for text only fields)

API Tags:
Return:  the sanitized string.


string sanitize( string $input_string, [string $sanitize_level = 3]  )

[ Top ]
sanitize_numeric  [line 726]

Checks if the input is numeric, rounds if so, otherwise returns false.

Parameters:
mixed   $num:  the number to be sanitized


int sanitize_numeric( mixed $num  )

[ Top ]
sanitize_path  [line 713]

Takes user input meant to be used within a path to a file or folder and removes anything that could be insecure or malicious, or result in duplicate representations for the same physical file.

This function is used primarily for album names. NOTE: The initial and trailing slashes are removed!!!

Returns the sanitized path

Parameters:
string   $filename:  is the path text to filter.


string sanitize_path( string $filename  )

[ Top ]
sanitize_string  [line 794]

returns a sanitized string for the sanitize function

Parameters:
string   $input_string: 
string   $sanitize_level: 

API Tags:
Return:  the sanitized string.


string sanitize_string( string $input_string, string $sanitize_level  )

[ Top ]
secureServer  [line 1390]

Checks to see if access was through a secure protocol


bool secureServer( )

[ Top ]
setOption  [line 300]

Stores an option value.

Parameters:
string   $key:  name of the option.
mixed   $value:  new value of the option.
bool   $persistent:  set to false if the option is stored in memory only otherwise it is preserved in the database


void setOption( string $key, mixed $value, [bool $persistent = true]  )

[ Top ]
setOptionDefault  [line 338]

Sets the default value of an option.

If the option has never been set it is set to the value passed

Parameters:
string   $key:  the option name
mixed   $default:  the value to be used as the default


void setOptionDefault( string $key, mixed $default  )

[ Top ]
size_readable  [line 948]

Return human readable sizes From: http://aidan.dotgeek.org/lib/

Parameters:
int   $size:  Size
int   $unit:  The maximum unit
int   $retstring:  The return string format

Information Tags:
Author:  Aidan Lister <aidan@php.net>
Version:  1.1.0

void size_readable( int $size, [int $unit = null], [int $retstring = null]  )

[ Top ]
stripSuffix  [line 1274]

returns a file name sans the suffix

Parameters:
unknown_type   $filename: 


unknown stripSuffix( unknown_type $filename  )

[ Top ]
themeSetup  [line 1315]

primitive theme setup for image handling scripts

we need to conserve memory so loading the classes is out of the question.

Parameters:
string   $album: 


string themeSetup( string $album  )

[ Top ]
zp_error  [line 842]

Formats an error message If DEBUG_ERROR is set, supplies the calling sequence

Parameters:
string   $message: 
bool   $fatal:  set true to fail the script


void zp_error( string $message, [bool $fatal = true]  )

[ Top ]
zp_html_decode  [line 226]

Decodes HTML Special Characters.

Parameters:
string   $text: 
string   $quote_style: 
   $string: 


string zp_html_decode( $string, [string $quote_style = ENT_QUOTES], string $text  )

[ Top ]


Documentation generated on Tue, 20 Dec 2011 16:07:15 +0100 by phpDocumentor 1.4.3