[ 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
include (dirname(__FILE__).'/version.php') [line 12]
[ Top ]

require (dirname(dirname(__FILE__)).'/'.DATA_FOLDER.'/zp-config.php') [line 54]
[ Top ]

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

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

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

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

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

require_once (dirname(__FILE__).'/functions-db.php') [line 70]
[ Top ]

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


Constants
CHMOD_VALUE  [line 56]

CHMOD_VALUE = 0777

[ Top ]

COOKIE_PESISTENCE  [line 58]

COOKIE_PESISTENCE = 5184000

[ Top ]

DEBUG_404  [line 21]

DEBUG_404 = !defined('RELEASE')

[ Top ]

DEBUG_ERROR  [line 19]

DEBUG_ERROR = !defined('RELEASE')

[ Top ]

DEBUG_EXIF  [line 22]

DEBUG_EXIF = false

[ Top ]

DEBUG_IMAGE  [line 20]

DEBUG_IMAGE = false

[ Top ]

DEBUG_LOGIN  [line 18]

DEBUG_LOGIN = false

[ Top ]

DEBUG_PLUGINS  [line 23]

DEBUG_PLUGINS = false

[ Top ]

FILESYSTEM_CHARSET  [line 17]

FILESYSTEM_CHARSET = 'ISO-8859-1'

[ Top ]

FULLWEBPATH  [line 127]

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

[ Top ]

OFFSET_PATH  [line 57]

OFFSET_PATH = 0

[ Top ]

PROTOCOL  [line 117]

PROTOCOL = $protocol

[ Top ]

SAFE_MODE_ALBUM_SEP  [line 128]

SAFE_MODE_ALBUM_SEP = '__'

[ Top ]

SERVERCACHE  [line 129]

SERVERCACHE = SERVERPATH.'/'.CACHEFOLDER

[ Top ]

SERVERPATH  [line 113]

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

[ Top ]

WEBPATH  [line 112]

WEBPATH = $const_webpath

[ Top ]


Functions
assert_handler  [line 315]

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 ]
debugLog  [line 828]

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.txt 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
   $date: 


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

[ Top ]
debugLogArray  [line 844]

"print_r" equivalent for the debug log

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


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

[ Top ]
debugLogBacktrace  [line 893]

Logs the calling stack

Parameters:
string   $message:  Message to prefix the backtrace


void debugLogBacktrace( string $message  )

[ Top ]
debugLogVar  [line 928]

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 972]

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 997]

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 783]

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 1089]

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 ]
getImageCacheFilename  [line 404]

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 435]

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

Parameters:
array   $args:  cropping arguments


string getImageCachePostfix( array $args  )

[ Top ]
getImageParameters  [line 453]

Validates and edits image size/cropping parameters

Parameters:
array   $args:  cropping arguments
   $album: 


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

[ Top ]
getImageProcessorURI  [line 533]

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 184]

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.
bool   $db:  set to true to force retrieval from the database.


void getOption( string $key, [bool $db = false]  )

[ Top ]
getOptionList  [line 298]

Retuns the option array


array getOptionList( )

[ Top ]
getSuffix  [line 1057]

Returns the suffix of a file name

Parameters:
string   $filename: 


string getSuffix( string $filename  )

[ Top ]
getWatermarkPath  [line 1220]

Returns the path to a watermark

Parameters:
string   $wm:  watermark name


string getWatermarkPath( string $wm  )

[ Top ]
hasDynamicAlbumSuffix  [line 327]

Returns true if the file has the dynamic album suffix

Parameters:
string   $path: 


bool hasDynamicAlbumSuffix( string $path  )

[ Top ]
htmlspecialchars_decode  [line 146]

Decodes HTML Special Characters. Function for backwards compatability with PHP 4.1.

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


string htmlspecialchars_decode( $string, [string $quote_style = ENT_COMPAT], string $text  )

[ Top ]
html_encode  [line 159]

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

Parameters:
string   $this_string: 
   $striptags: 


string html_encode( string $this_string, [ $striptags = true]  )

[ Top ]
imgSrcURI  [line 1037]

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 ]
im_suffix  [line 1047]

returns the mod_rewrite suffix


string im_suffix( )

[ Top ]
internalToFilesystem  [line 983]

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 ]
isMyAlbum  [line 1177]

Checks to see if the loggedin Admin has rights to the album

Parameters:
string   $albumfolder:  the album to be checked
int   $action:  what the user wishes to do action will be compared with the logged in user's RIGHTS. If the user has rights to do the action, access will be allowed.


void isMyAlbum( string $albumfolder, int $action  )

[ Top ]
isWin  [line 1027]

Returns true if we are running on a Windows server


bool isWin( )

[ Top ]
is_valid_other  [line 1016]

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 171]

encodes a pre-sanitized string to be used in a Javascript alert box

Parameters:
string   $this_string: 


string js_encode( string $this_string  )

[ Top ]
loadLocalOptions  [line 1136]

Loads option table with album/theme options

Parameters:
int   $albumid: 
string   $theme: 


void loadLocalOptions( int $albumid, string $theme  )

[ Top ]
mkdir_recursive  [line 946]

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 954]

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

Parameters:
   $size: 


void parse_size( $size  )

[ Top ]
pathurlencode  [line 734]

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

Parameters:
string   $path:  URL


string pathurlencode( string $path  )

[ Top ]
PHPScript  [line 1077]

Returns the Require string for the appropriate script based on the PHP version

Parameters:
string   $v:  The version dermarkation
string   $script:  the script name


string PHPScript( string $v, string $script  )

[ Top ]
rewrite_get_album_image  [line 345]

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 713]

Returns either the rewrite path or the plain, non-mod_rewrite path based on the mod_rewrite option in zp-config.php.

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 ]
sanitize  [line 598]

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 578]

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 564]

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 615]

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 1244]

Checks to see if access was through a secure protocol


bool secureServer( )

[ Top ]
setBoolOption  [line 262]

Converts a boolean value to 1 or 0 and sets the option with it

Parameters:
string   $key:  the option
bool   $value:  the value to be set


void setBoolOption( string $key, bool $value  )

[ Top ]
setOption  [line 226]

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 278]

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 749]

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 1067]

returns a file name sans the suffix

Parameters:
unknown_type   $filename: 


unknown stripSuffix( unknown_type $filename  )

[ Top ]
themeSetup  [line 1118]

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 653]

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_escape_string  [line 1234]

mysql_real_escape_string standin that insures the DB connection is passed.

Parameters:
string   $string: 


string zp_escape_string( string $string  )

[ Top ]


Documentation generated on Mon, 09 Aug 2010 17:23:58 +0200 by phpDocumentor 1.4.1