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]
require
(dirname(dirname(__FILE__)).'/'.DATA_FOLDER.'/zp-config.php')
[line 54]
require_once
(dirname(__FILE__).'/lib-encryption.php')
[line 91]
require_once
(dirname(__FILE__).'/lib-GD.php')
[line 77]
require_once
(dirname(__FILE__).'/lib-Imagick.php')
[line 76]
require_once
(dirname(__FILE__).'/folder-definitions.php')
[line 11]
require_once
(dirname(__FILE__).'/lib-gettext/gettext.inc')
[line 14]
require_once
(dirname(__FILE__).'/functions-db.php')
[line 70]
require_once
(dirname(__FILE__).'/lib-utf8.php')
[line 48]
Constants
COOKIE_PESISTENCE [line 58]
COOKIE_PESISTENCE = 5184000
|
|
DEBUG_404 [line 21]
DEBUG_404 = !defined('RELEASE')
|
|
DEBUG_ERROR [line 19]
DEBUG_ERROR = !defined('RELEASE')
|
|
FILESYSTEM_CHARSET [line 17]
FILESYSTEM_CHARSET = 'ISO-8859-1'
|
|
FULLWEBPATH [line 127]
FULLWEBPATH = PROTOCOL."://".$_SERVER['HTTP_HOST'].WEBPATH
|
|
SAFE_MODE_ALBUM_SEP [line 128]
SAFE_MODE_ALBUM_SEP = '__'
|
|
SERVERCACHE [line 129]
SERVERCACHE = SERVERPATH.'/'.CACHEFOLDER
|
|
SERVERPATH [line 113]
SERVERPATH = str_replace("\\",'/',dirname(dirname(__FILE__)))
|
|
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
)
|
|
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]
)
|
|
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]
)
|
|
debugLogBacktrace [line 893]
Logs the calling stack
Parameters:
|
string |
$message: |
Message to prefix the backtrace |
void debugLogBacktrace(
string $message
)
|
|
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
)
|
|
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
)
|
|
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]
)
|
|
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]
)
|
|
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
)
|
|
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
)
|
|
getImageCachePostfix [line 435]
Returns the crop/sizing string to postfix to a cache image
Parameters:
|
array |
$args: |
cropping arguments |
string getImageCachePostfix(
array $args
)
|
|
getImageParameters [line 453]
Validates and edits image size/cropping parameters
Parameters:
|
array |
$args: |
cropping arguments |
|
|
$album: |
|
array getImageParameters(
array $args, [ $album = NULL]
)
|
|
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
)
|
|
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]
)
|
|
getSuffix [line 1057]
Returns the suffix of a file name
Parameters:
string getSuffix(
string $filename
)
|
|
getWatermarkPath [line 1220]
Returns the path to a watermark
Parameters:
|
string |
$wm: |
watermark name |
string getWatermarkPath(
string $wm
)
|
|
hasDynamicAlbumSuffix [line 327]
Returns true if the file has the dynamic album suffix
Parameters:
bool hasDynamicAlbumSuffix(
string $path
)
|
|
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
)
|
|
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]
)
|
|
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
)
|
|
im_suffix [line 1047]
returns the mod_rewrite suffix
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
)
|
|
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
)
|
|
isWin [line 1027]
Returns true if we are running on a Windows server
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
)
|
|
js_encode [line 171]
encodes a pre-sanitized string to be used in a Javascript alert box
Parameters:
string js_encode(
string $this_string
)
|
|
loadLocalOptions [line 1136]
Loads option table with album/theme options
Parameters:
|
int |
$albumid: |
|
|
string |
$theme: |
|
void loadLocalOptions(
int $albumid, string $theme
)
|
|
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]
)
|
|
parse_size [line 954]
Parses a byte size from a size value (eg: 100M) for comparison.
Parameters:
pathurlencode [line 734]
rawurlencode function that is path-safe (does not encode /)
Parameters:
string pathurlencode(
string $path
)
|
|
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
)
|
|
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
)
|
|
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]
)
|
|
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. - - Basic sanitation. Only strips null bytes. Not recommended for submitted form data.
- - User specified. (User defined code is allowed. Used for descriptions and comments.)
- - Text style/formatting. (Text style codes allowed. Used for titles.)
- - 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]
)
|
|
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
)
|
|
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
)
|
|
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
)
|
|
secureServer [line 1244]
Checks to see if access was through a secure protocol
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
)
|
|
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]
)
|
|
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
)
|
|
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:
void size_readable(
int $size, [int $unit = null], [int $retstring = null]
)
|
|
stripSuffix [line 1067]
returns a file name sans the suffix
Parameters:
unknown stripSuffix(
unknown_type $filename
)
|
|
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 themeSetup(
string $album
)
|
|
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]
)
|
|
zp_escape_string [line 1234]
mysql_real_escape_string standin that insures the DB connection is passed.
Parameters:
string zp_escape_string(
string $string
)
|
|
|
|