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]
require_once
(dirname(__FILE__).'/functions-db-'.(isset($_zp_conf_vars['db_software'])?$_zp_conf_vars['db_software']:'MySQL').'.php')
[line 71]
require_once
(dirname(__FILE__).'/lib-Imagick.php')
[line 124]
require_once
(dirname(__FILE__).'/global-definitions.php')
[line 11]
require_once
(dirname(__FILE__).'/lib-encryption.php')
[line 142]
require_once
(dirname(__FILE__).'/lib-gettext/gettext.inc')
[line 13]
require_once
(dirname(__FILE__).'/lib-utf8.php')
[line 54]
Constants
ALBUM_FOLDER_EMPTY [line 194]
ALBUM_FOLDER_EMPTY = getAlbumFolder('')
|
|
ALBUM_FOLDER_SERVERPATH [line 193]
ALBUM_FOLDER_SERVERPATH = getAlbumFolder(SERVERPATH)
|
|
ALBUM_FOLDER_WEBPATH [line 192]
ALBUM_FOLDER_WEBPATH = getAlbumFolder(WEBPATH)
|
|
COOKIE_PESISTENCE [line 65]
COOKIE_PESISTENCE = 5184000
|
|
DATE_FORMAT [line 200]
DATE_FORMAT = getOption('date_format')
|
|
FILESYSTEM_CHARSET [line 58]
FILESYSTEM_CHARSET = $_zp_conf_vars['FILESYSTEM_CHARSET']
|
|
FULLIMAGE_WATERMARK [line 197]
FULLIMAGE_WATERMARK = getOption('fullsizeimage_watermark')
|
|
FULLWEBPATH [line 188]
FULLWEBPATH = PROTOCOL."://".$_SERVER['HTTP_HOST'].WEBPATH
|
|
GALLERY_DATA [line 78]
GALLERY_DATA = getOption('gallery_data')
|
|
GALLERY_SECURITY [line 90]
GALLERY_SECURITY = $data['gallery_security']
|
|
GALLERY_SESSION [line 85]
GALLERY_SESSION = $data['album_session']
|
|
GRAPHICS_LIBRARY [line 130]
GRAPHICS_LIBRARY = $_zp_supported_images['Library']
|
|
HASH_SEED [line 206]
HASH_SEED = getOption('extra_auth_hash_text')
|
|
IMAGE_WATERMARK [line 196]
IMAGE_WATERMARK = getOption('fullimage_watermark')
|
|
IM_SUFFIX [line 202]
IM_SUFFIX = getOption('mod_rewrite_image_suffix')
|
|
IP_TIED_COOKIES [line 207]
IP_TIED_COOKIES = getOption('IP_tied_cookies')
|
|
LOCAL_CHARSET [line 96]
LOCAL_CHARSET = $_charset
|
|
MEMBERS_ONLY_COMMENTS [line 204]
MEMBERS_ONLY_COMMENTS = getOption('comment_form_members_only')
|
|
MOD_REWRITE [line 191]
MOD_REWRITE = getOption('mod_rewrite')
|
|
SAFE_MODE_ALBUM_SEP [line 189]
SAFE_MODE_ALBUM_SEP = '__'
|
|
SERVERCACHE [line 190]
SERVERCACHE = SERVERPATH.'/'.CACHEFOLDER
|
|
SERVERPATH [line 145]
SERVERPATH = str_replace("\\",'/',dirname(dirname(__FILE__)))
|
|
SERVER_PROTOCOL [line 175]
SERVER_PROTOCOL = getOption('server_protocol')
|
|
THUMB_WATERMARK [line 198]
THUMB_WATERMARK = getOption('Image_watermark')
|
|
UTF8_IMAGE_URI [line 203]
UTF8_IMAGE_URI = getOption('UTF8_image_URI')
|
|
WEBPATH [line 171]
OFFSET_PATH definisions:
0 Theme scripts (root index.php) 1 zp-core scripts 2 setup scripts 3 plugin scripts
ZP_ALBUM_LINKED [line 25]
ZP_IMAGE_LINKED [line 26]
ZP_SEARCH_LINKED [line 24]
ZP_ZENPAGE_NEWS_ARTICLE [line 27]
ZP_ZENPAGE_NEWS_ARTICLE = 256
|
|
ZP_ZENPAGE_NEWS_CATEGORY [line 28]
ZP_ZENPAGE_NEWS_CATEGORY = 512
|
|
ZP_ZENPAGE_NEWS_DATE [line 29]
ZP_ZENPAGE_NEWS_DATE = 1024
|
|
ZP_ZENPAGE_PAGE [line 30]
ZP_ZENPAGE_SINGLE [line 31]
Functions
accessAllAlbums [line 1360]
Checks access for the album root
Parameters:
|
bit |
$action: |
what the caller wants to do |
void accessAllAlbums(
bit $action
)
|
|
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
)
|
|
checkInstall [line 1510]
Check to see if the setup script needs to be run
db_count [line 1496]
Parameters:
void db_count(
$table, [ $clause = NULL], [ $field = "*"]
)
|
|
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]
)
|
|
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 = '']
)
|
|
debugLogBacktrace [line 1102]
Logs the calling stack
Parameters:
|
string |
$message: |
Message to prefix the backtrace |
void debugLogBacktrace(
string $message
)
|
|
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
)
|
|
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
)
|
|
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]
)
|
|
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]
)
|
|
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
)
|
|
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
)
|
|
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
)
|
|
getImageCachePostfix [line 580]
Returns the crop/sizing string to postfix to a cache image
Parameters:
|
array |
$args: |
cropping arguments |
string getImageCachePostfix(
array $args
)
|
|
getImageParameters [line 599]
Validates and edits image size/cropping parameters
Parameters:
|
array |
$args: |
cropping arguments |
|
|
$album: |
|
array getImageParameters(
array $args, [ $album = NULL]
)
|
|
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
)
|
|
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
)
|
|
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:
Information Tags:
contructed getSetClause(
string $new_unique_set
)
|
|
getSuffix [line 1264]
Returns the suffix of a file name
Parameters:
string getSuffix(
string $filename
)
|
|
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
)
|
|
getWatermarkPath [line 1377]
Returns the path to a watermark
Parameters:
|
string |
$wm: |
watermark name |
string getWatermarkPath(
string $wm
)
|
|
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:
Information Tags:
contructed getWhereClause(
string $unique_set
)
|
|
hasDynamicAlbumSuffix [line 403]
Returns true if the file has the dynamic album suffix
Parameters:
bool hasDynamicAlbumSuffix(
string $path
)
|
|
html_encode [line 239]
encodes a pre-sanitized string to be used in an HTML text-only field (value, alt, title, etc.)
Parameters:
string html_encode(
string $this_string
)
|
|
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
)
|
|
instrument [line 1151]
Tool to log execution times of script bits
Parameters:
|
string |
$point: |
location identifier |
void instrument(
string $point
)
|
|
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
)
|
|
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
)
|
|
js_encode [line 249]
encodes a pre-sanitized string to be used as a Javascript parameter
Parameters:
string js_encode(
string $this_string
)
|
|
loadLocalOptions [line 1333]
Loads option table with album/theme options
Parameters:
|
int |
$albumid: |
|
|
string |
$theme: |
|
void loadLocalOptions(
int $albumid, string $theme
)
|
|
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]
)
|
|
parse_size [line 1179]
Parses a byte size from a size value (eg: 100M) for comparison.
Parameters:
pathurlencode [line 929]
rawurlencode function that is path-safe (does not encode /)
Parameters:
string pathurlencode(
string $path
)
|
|
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:
Information Tags:
prefixed prefix(
[string $tablename = NULL]
)
|
|
reconfigure [line 1520]
Redirects to setup if the files are present. Otherwise notifies need for re-upload
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
)
|
|
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]
)
|
|
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]
)
|
|
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. - - 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 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
)
|
|
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
)
|
|
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
)
|
|
secureServer [line 1390]
Checks to see if access was through a secure protocol
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]
)
|
|
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
)
|
|
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:
void size_readable(
int $size, [int $unit = null], [int $retstring = null]
)
|
|
stripSuffix [line 1274]
returns a file name sans the suffix
Parameters:
unknown stripSuffix(
unknown_type $filename
)
|
|
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 themeSetup(
string $album
)
|
|
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]
)
|
|
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
)
|
|
|
|