functions-basic.php
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!
Table of Contents
Constants
- ALBUM_FOLDER_EMPTY = \getAlbumFolder('')
- ALBUM_FOLDER_SERVERPATH = \getAlbumFolder(\SERVERPATH)
- ALBUM_FOLDER_WEBPATH = \getAlbumFolder(\WEBPATH)
- CACHE_HASH_LENGTH = \strlen(\sha1(\strval(\HASH_SEED)))
- CHMOD_VALUE = \fileperms(\dirname(__FILE__)) & 0666
- COOKIE_PATH = \WEBPATH
- COOKIE_PERSISTENCE = $persistence
- DATA_MOD = \fileperms(\SERVERPATH . '/' . \DATA_FOLDER . '/' . \CONFIGFILE) & 0777
- DATABASE_DESIRED_VERSION = '5.7.0'
- DATABASE_MARIADB_DESIRED_VERSION = '10.1.0'
- DATABASE_MARIADB_MIN_VERSION = '5.5.0'
- DATABASE_MIN_VERSION = '5.5.3'
- DATABASE_PREFIX = $mysql_prefix
- DATABASE_SOFTWARE = $_zp_conf_vars['db_software']
- DATE_FORMAT = \trim(\strval(\getOption('date_format')))
- DATETIME_DISPLAYFORMAT = \DATETIME_FORMAT
- DATETIME_FORMAT = \DATE_FORMAT . ' ' . \TIME_FORMAT
- DEBUG_LOG_SIZE = \getOption('debug_log_size')
- FILE_MOD = \CHMOD_VALUE & 0666
- FILESYSTEM_CHARSET = $data
- FOLDER_MOD = \CHMOD_VALUE | 0311
- FULLIMAGE_WATERMARK = \getOption('fullsizeimage_watermark')
- FULLWEBPATH = \SERVER_HTTP_HOST . \WEBPATH
- GALLERY_SECURITY = @$data['gallery_security']
- GALLERY_SESSION = @$data['album_session']
- GRAPHICS_LIBRARY = $_zp_cachefile_suffix['Library']
- HASH_SEED = \getOption('extra_auth_hash_text')
- IM_SUFFIX = \getOption('mod_rewrite_image_suffix')
- IMAGE_CACHE_SUFFIX = \getOption('image_cache_suffix')
- IMAGE_WATERMARK = \getOption('fullimage_watermark')
- IMAGEMAGICK_REQUIRED_VERSION = '6.3.8'
- IMAGICK_REQUIRED_VERSION = '3.0.0'
- IP_TIED_COOKIES = \getOption('IP_tied_cookies')
- LOCAL_CHARSET = $data
- LOGS_MOD = \DATA_MOD
- MAX_SIZE = \getOption('image_max_size')
- MEMBERS_ONLY_COMMENTS = \getOption('comment_form_members_only')
- MENU_TRUNCATE_INDICATOR = \getOption('menu_truncate_indicator')
- MENU_TRUNCATE_STRING = \getOption('menu_truncate_string')
- MOD_REWRITE = \getOption('mod_rewrite')
- NO_WATERMARK = '!'
- OFFSET_PATH = 0
- OPEN_IMAGE_CACHE = !\getOption('protected_image_cache')
- PRIMARY_INSTALLATION = true
- SAFE_MODE = \false
- SAFE_MODE_ALBUM_SEP = ''
- SERVER_HTTP_HOST = \PROTOCOL . "://" . $_SERVER['HTTP_HOST']
- SERVER_PROTOCOL = 'http'
- SERVERCACHE = \SERVERPATH . '/' . \CACHEFOLDER
- SERVERPATH = $const_serverpath
- THUMB_WATERMARK = \getOption('Image_watermark')
- TIME_FORMAT = \trim(\strval(\getOption('time_format')))
- UTF8_IMAGE_URI = \getOption('UTF8_image_URI')
- WEBPATH = $const_webpath
- ZP_ALBUM = 2
- ZP_ALBUM_LINKED = 64
- ZP_COMMENT = 8
- ZP_IMAGE = 4
- ZP_IMAGE_LINKED = 128
- ZP_INDEX = 1
- ZP_SEARCH = 16
- ZP_SEARCH_LINKED = 32
- ZP_ZENPAGE_NEWS_ARTICLE = 512
- ZP_ZENPAGE_NEWS_CATEGORY = 1024
- ZP_ZENPAGE_NEWS_DATE = 2048
- ZP_ZENPAGE_NEWS_PAGE = 256
- ZP_ZENPAGE_PAGE = 4096
- ZP_ZENPAGE_SINGLE = 8192
Functions
- js_encode() : string
- encodes a pre-sanitized string to be used as a Javascript parameter
- getOption() : mixed
- Get a option stored in the database.
- setOption() : mixed
- Stores an option value.
- setOptionDefault() : mixed
- Sets the default value of an option.
- loadLocalOptions() : mixed
- Loads option table with album/theme options
- renameOption() : mixed
- Replaces/renames an option. If the old option exits, it creates the new option with the old option's value as the default unless the new option has already been set otherwise. Independently it always deletes the old option.
- purgeOption() : mixed
- Deletes an option from the database
- getOptionList() : array<string|int, mixed>
- Retuns the option array
- hasDynamicAlbumSuffix() : bool
- Returns true if the file has the dynamic album suffix
- isHandledAlbum() : string
- checks if there is a file with the prefix and one of the handled suffixes. Returns the found suffix
- rewrite_get_album_image() : mixed
- Handles the special cases of album/image[rewrite_suffix]
- getImageCacheFilename() : string
- Returns the path of an image for uses in caching it NOTE: character set if for the filesystem
- makeSpecialImageName() : array<string|int, mixed>
- Returns an i.php "image name" for an image not within the albums structure
- getWatermarkParam() : int
- Returns the watermark image to pass to i.php
- getImageCachePostfix() : string
- Returns the crop/sizing string to postfix to a cache image
- getImageParameters() : array<string|int, mixed>
- Validates and edits image size/cropping parameters
- getImageProcessorURI() : string
- forms the i.php parameter list for an image.
- getImageArgs() : array<string|int, mixed>
- Extract the image parameters from the input variables
- getImageProcessorURIFromCacheName() : array<string|int, mixed>
- Extracts the image processor URI from an existing cache filename
- getImageURI() : string
- Returns an URI to the image:
- extractImageExifOrientation() : int
- Extracts integer value (1-9) from the exifOrientation value stored (e.g. '7: 90 deg CCW Mirrored') in the database for images or returns the value if it is an integer
- getImageFlipRotate() : bool|array<string|int, mixed>
- Returns an array with two indexes "rotate" (= degree to rotate) and "flip" ("horizontal" or "vertical") or false if nothing applies
- getAllowedTags() : mixed
- Returns an array of html tags allowed
- rewrite_path() : string
- Returns either the rewrite path or the plain, non-mod_rewrite path based on the mod_rewrite option.
- parse_query() : mixed
- parses a query string WITHOUT url decoding it!
- build_query() : string
- createsa query string from the array passed
- build_url() : string
- Builds a url from parts
- pathurlencode() : string
- rawurlencode function that is path-safe (does not encode /)
- getAlbumFolder() : string
- Returns the fully qualified path to the album folders
- getBackupFolder() : string
- Returns the fully qualified path to the backup folder
- getRootFolder() : string
- Returns the fully qualified path to the root albums or backup folder
- switchLog() : mixed
- Rolls a log over if it has grown too large.
- debugLog() : mixed
- 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.
- instrument() : mixed
- Tool to log execution times of script bits
- parse_size() : mixed
- Parses a byte size from a size value (eg: 100M) for comparison.
- getAlbumArray() : mixed
- getAlbumArray - returns an array of folder names corresponding to the given album string.
- imgSrcURI() : string
- Returns an img src URI encoded based on the OS of the server
- getSuffix() : string
- Returns the suffix of a file name
- stripSuffix() : string
- returns a file name sans the suffix
- getAlbumInherited() : string
- returns the non-empty value of $field from the album or one of its parents
- themeSetup() : string
- primitive theme setup for image handling scripts
- accessAllAlbums() : mixed
- Checks access for the album root
- getWatermarkPath() : string
- Returns the path to a watermark
- secureServer() : bool
- Checks to see if access was through a secure protocol
- getRequestURI() : string
- Returns the script requesting URI.
- safe_glob() : mixed
- Provide an alternative to glob which does not return filenames with accented charactes in them
- checkInstall() : mixed
- Check to see if the setup script needs to be run
- exitZP() : mixed
- Call when terminating a script.
- installSignature() : array<string|int, mixed>
- Computes the "installation signature" of the Zenphoto install
- zp_session_start() : mixed
- Starts a zenphoto session (perhaps a secure one)
- zp_session_destroy() : mixed
- Ends a zenphoto session if there is one and clear the session cookie
- getDefaultRewriteTokens() : array<string|int, mixed>
- Reads the core default rewrite token define array from the config template file `zenphoto_cfg.txt`.
- addMissingDefaultRewriteTokens() : mixed
- Adds missing individual default rewrite tokens to $_zp_conf_vars['special_pages']
- curlRequest() : bool
- Sends a simple cURL request to the $uri specified.
- generateImageCacheFile() : mixed
- Sends a cURL request to i.php to generate the image requested without printing it.
- httpsRedirect() : mixed
- Checks if protocol not https and redirects if https required
- redirectURL() : mixed
- General url redirection handler using header()
- sanitizeRedirect() : string
- Sanitizes a "redirect" post to always be within the site
- callUserFunction() : mixed
- Wrapper to call a plugin or otherwise possibly undefined function or method to avoid themes breaking if the plugin is not active
- deprecationNotice() : mixed
- Logs a deprecated notice including traces in the debuglog
- convertStrftimeFormat() : string
- Basic conversion for a (deprecated) strftime() date format string
- hasPrimaryScripts() : mixed
- Returns true if the install is not a "clone"
Constants
ALBUM_FOLDER_EMPTY
public
mixed
ALBUM_FOLDER_EMPTY
= \getAlbumFolder('')
ALBUM_FOLDER_SERVERPATH
public
mixed
ALBUM_FOLDER_SERVERPATH
= \getAlbumFolder(\SERVERPATH)
ALBUM_FOLDER_WEBPATH
public
mixed
ALBUM_FOLDER_WEBPATH
= \getAlbumFolder(\WEBPATH)
CACHE_HASH_LENGTH
public
mixed
CACHE_HASH_LENGTH
= \strlen(\sha1(\strval(\HASH_SEED)))
CHMOD_VALUE
public
mixed
CHMOD_VALUE
= \fileperms(\dirname(__FILE__)) & 0666
COOKIE_PATH
public
mixed
COOKIE_PATH
= \WEBPATH
COOKIE_PERSISTENCE
public
mixed
COOKIE_PERSISTENCE
= $persistence
DATA_MOD
public
mixed
DATA_MOD
= \fileperms(\SERVERPATH . '/' . \DATA_FOLDER . '/' . \CONFIGFILE) & 0777
DATABASE_DESIRED_VERSION
public
mixed
DATABASE_DESIRED_VERSION
= '5.7.0'
DATABASE_MARIADB_DESIRED_VERSION
public
mixed
DATABASE_MARIADB_DESIRED_VERSION
= '10.1.0'
DATABASE_MARIADB_MIN_VERSION
public
mixed
DATABASE_MARIADB_MIN_VERSION
= '5.5.0'
DATABASE_MIN_VERSION
public
mixed
DATABASE_MIN_VERSION
= '5.5.3'
DATABASE_PREFIX
public
mixed
DATABASE_PREFIX
= $mysql_prefix
DATABASE_SOFTWARE
public
mixed
DATABASE_SOFTWARE
= $_zp_conf_vars['db_software']
DATE_FORMAT
public
mixed
DATE_FORMAT
= \trim(\strval(\getOption('date_format')))
DATETIME_DISPLAYFORMAT
public
mixed
DATETIME_DISPLAYFORMAT
= \DATETIME_FORMAT
DATETIME_FORMAT
public
mixed
DATETIME_FORMAT
= \DATE_FORMAT . ' ' . \TIME_FORMAT
DEBUG_LOG_SIZE
public
mixed
DEBUG_LOG_SIZE
= \getOption('debug_log_size')
FILE_MOD
public
mixed
FILE_MOD
= \CHMOD_VALUE & 0666
FILESYSTEM_CHARSET
public
mixed
FILESYSTEM_CHARSET
= $data
FOLDER_MOD
public
mixed
FOLDER_MOD
= \CHMOD_VALUE | 0311
FULLIMAGE_WATERMARK
public
mixed
FULLIMAGE_WATERMARK
= \getOption('fullsizeimage_watermark')
FULLWEBPATH
public
mixed
FULLWEBPATH
= \SERVER_HTTP_HOST . \WEBPATH
GALLERY_SECURITY
public
mixed
GALLERY_SECURITY
= @$data['gallery_security']
GALLERY_SESSION
public
mixed
GALLERY_SESSION
= @$data['album_session']
GRAPHICS_LIBRARY
public
mixed
GRAPHICS_LIBRARY
= $_zp_cachefile_suffix['Library']
HASH_SEED
public
mixed
HASH_SEED
= \getOption('extra_auth_hash_text')
IM_SUFFIX
public
mixed
IM_SUFFIX
= \getOption('mod_rewrite_image_suffix')
IMAGE_CACHE_SUFFIX
public
mixed
IMAGE_CACHE_SUFFIX
= \getOption('image_cache_suffix')
IMAGE_WATERMARK
public
mixed
IMAGE_WATERMARK
= \getOption('fullimage_watermark')
IMAGEMAGICK_REQUIRED_VERSION
public
mixed
IMAGEMAGICK_REQUIRED_VERSION
= '6.3.8'
IMAGICK_REQUIRED_VERSION
public
mixed
IMAGICK_REQUIRED_VERSION
= '3.0.0'
IP_TIED_COOKIES
public
mixed
IP_TIED_COOKIES
= \getOption('IP_tied_cookies')
LOCAL_CHARSET
public
mixed
LOCAL_CHARSET
= $data
LOGS_MOD
public
mixed
LOGS_MOD
= \DATA_MOD
MAX_SIZE
public
mixed
MAX_SIZE
= \getOption('image_max_size')
MEMBERS_ONLY_COMMENTS
public
mixed
MEMBERS_ONLY_COMMENTS
= \getOption('comment_form_members_only')
MENU_TRUNCATE_INDICATOR
public
mixed
MENU_TRUNCATE_INDICATOR
= \getOption('menu_truncate_indicator')
MENU_TRUNCATE_STRING
public
mixed
MENU_TRUNCATE_STRING
= \getOption('menu_truncate_string')
MOD_REWRITE
public
mixed
MOD_REWRITE
= \getOption('mod_rewrite')
NO_WATERMARK
public
mixed
NO_WATERMARK
= '!'
OFFSET_PATH
public
mixed
OFFSET_PATH
= 0
OPEN_IMAGE_CACHE
public
mixed
OPEN_IMAGE_CACHE
= !\getOption('protected_image_cache')
PRIMARY_INSTALLATION
public
mixed
PRIMARY_INSTALLATION
= true
SAFE_MODE
public
mixed
SAFE_MODE
= \false
SAFE_MODE_ALBUM_SEP
public
mixed
SAFE_MODE_ALBUM_SEP
= ''
SERVER_HTTP_HOST
public
mixed
SERVER_HTTP_HOST
= \PROTOCOL . "://" . $_SERVER['HTTP_HOST']
SERVER_PROTOCOL
public
mixed
SERVER_PROTOCOL
= 'http'
SERVERCACHE
public
mixed
SERVERCACHE
= \SERVERPATH . '/' . \CACHEFOLDER
SERVERPATH
public
mixed
SERVERPATH
= $const_serverpath
THUMB_WATERMARK
public
mixed
THUMB_WATERMARK
= \getOption('Image_watermark')
TIME_FORMAT
public
mixed
TIME_FORMAT
= \trim(\strval(\getOption('time_format')))
UTF8_IMAGE_URI
public
mixed
UTF8_IMAGE_URI
= \getOption('UTF8_image_URI')
WEBPATH
public
mixed
WEBPATH
= $const_webpath
ZP_ALBUM
public
mixed
ZP_ALBUM
= 2
ZP_ALBUM_LINKED
public
mixed
ZP_ALBUM_LINKED
= 64
ZP_COMMENT
public
mixed
ZP_COMMENT
= 8
ZP_IMAGE
public
mixed
ZP_IMAGE
= 4
ZP_IMAGE_LINKED
public
mixed
ZP_IMAGE_LINKED
= 128
ZP_INDEX
public
mixed
ZP_INDEX
= 1
ZP_SEARCH
public
mixed
ZP_SEARCH
= 16
ZP_SEARCH_LINKED
public
mixed
ZP_SEARCH_LINKED
= 32
ZP_ZENPAGE_NEWS_ARTICLE
public
mixed
ZP_ZENPAGE_NEWS_ARTICLE
= 512
ZP_ZENPAGE_NEWS_CATEGORY
public
mixed
ZP_ZENPAGE_NEWS_CATEGORY
= 1024
ZP_ZENPAGE_NEWS_DATE
public
mixed
ZP_ZENPAGE_NEWS_DATE
= 2048
ZP_ZENPAGE_NEWS_PAGE
public
mixed
ZP_ZENPAGE_NEWS_PAGE
= 256
ZP_ZENPAGE_PAGE
public
mixed
ZP_ZENPAGE_PAGE
= 4096
ZP_ZENPAGE_SINGLE
public
mixed
ZP_ZENPAGE_SINGLE
= 8192
Functions
js_encode()
encodes a pre-sanitized string to be used as a Javascript parameter
js_encode(string $this_string) : string
Parameters
- $this_string : string
Return values
stringgetOption()
Get a option stored in the database.
getOption(string $key) : mixed
This function reads the options only once, in order to improve performance.
Parameters
- $key : string
-
the name of the option.
setOption()
Stores an option value.
setOption(string $key, mixed $value[, bool $persistent = true ][, string $creator = NULL ]) : mixed
Parameters
- $key : string
-
name of the option.
- $value : mixed
-
new value of the option.
- $persistent : bool = true
-
set to false if the option is stored in memory only. Otherwise it is preserved in the database
- $creator : string = NULL
-
name of the creator the option belongs to. Normally NULL for backend core options. "zp-core/zp-extensions/
.php" for official plugin and /plugins/ .php for user plugin options
setOptionDefault()
Sets the default value of an option.
setOptionDefault(string $key, mixed $default) : mixed
If the option has never been set it is set to the value passed
Parameters
- $key : string
-
the option name
- $default : mixed
-
the value to be used as the default
loadLocalOptions()
Loads option table with album/theme options
loadLocalOptions(int $albumid, string $theme) : mixed
Parameters
- $albumid : int
- $theme : string
renameOption()
Replaces/renames an option. If the old option exits, it creates the new option with the old option's value as the default unless the new option has already been set otherwise. Independently it always deletes the old option.
renameOption(string $oldkey, string $newkey) : mixed
Parameters
- $oldkey : string
-
Old option name
- $newkey : string
-
New option name
Tags
purgeOption()
Deletes an option from the database
purgeOption(string $key) : mixed
Parameters
- $key : string
Tags
getOptionList()
Retuns the option array
getOptionList() : array<string|int, mixed>
Return values
array<string|int, mixed>hasDynamicAlbumSuffix()
Returns true if the file has the dynamic album suffix
hasDynamicAlbumSuffix(string $path) : bool
Parameters
- $path : string
Return values
boolisHandledAlbum()
checks if there is a file with the prefix and one of the handled suffixes. Returns the found suffix
isHandledAlbum(string $path) : string
Parameters
- $path : string
-
SERVER path to be tested
Return values
stringrewrite_get_album_image()
Handles the special cases of album/image[rewrite_suffix]
rewrite_get_album_image(string $albumvar, string $imagevar) : mixed
Separates the image part from the album if it is an image reference Strips off the mod_rewrite_suffix if present Handles dynamic album names that do not have the .alb suffix appended
Parameters
- $albumvar : string
-
$_GET index for "albums"
- $imagevar : string
-
$_GET index for "images"
getImageCacheFilename()
Returns the path of an image for uses in caching it NOTE: character set if for the filesystem
getImageCacheFilename(mixed $album8, mixed $image8, array<string|int, mixed> $args) : string
Parameters
- $album8 : mixed
- $image8 : mixed
- $args : array<string|int, mixed>
-
cropping arguments
Return values
stringmakeSpecialImageName()
Returns an i.php "image name" for an image not within the albums structure
makeSpecialImageName(string $image) : array<string|int, mixed>
Parameters
- $image : string
-
Path to the image
Return values
array<string|int, mixed>getWatermarkParam()
Returns the watermark image to pass to i.php
getWatermarkParam(object $image, int $use) : int
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 : object
-
image object in question
- $use : int
-
what the watermark use is
Return values
intgetImageCachePostfix()
Returns the crop/sizing string to postfix to a cache image
getImageCachePostfix(array<string|int, mixed> $args) : string
Parameters
- $args : array<string|int, mixed>
-
cropping arguments
Return values
stringgetImageParameters()
Validates and edits image size/cropping parameters
getImageParameters(array<string|int, mixed> $args[, mixed $album = NULL ]) : array<string|int, mixed>
Parameters
- $args : array<string|int, mixed>
-
cropping arguments
- $album : mixed = NULL
Return values
array<string|int, mixed>getImageProcessorURI()
forms the i.php parameter list for an image.
getImageProcessorURI(array<string|int, mixed> $args, string $album, string $image) : string
Parameters
- $args : array<string|int, mixed>
- $album : string
-
the album name
- $image : string
-
the image name
Return values
stringgetImageArgs()
Extract the image parameters from the input variables
getImageArgs(array<string|int, mixed> $set) : array<string|int, mixed>
Parameters
- $set : array<string|int, mixed>
Return values
array<string|int, mixed>getImageProcessorURIFromCacheName()
Extracts the image processor URI from an existing cache filename
getImageProcessorURIFromCacheName(string $match, array<string|int, mixed> $watermarks) : array<string|int, mixed>
Parameters
- $match : string
- $watermarks : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getImageURI()
Returns an URI to the image:
getImageURI(array<string|int, mixed> $args, string $album, string $image, mixed $mtime) : string
If the image is not cached, the uri will be to the image processor If the image is cached then the uri will depend on the site option for cache serving. If the site is set for open cache the uri will point to the cached image. If the site is set for protected cache the uri will point to the image processor (which will serve the image from the cache.) NOTE: this latter implies added overhead for each and every image fetch!
Parameters
- $args : array<string|int, mixed>
- $album : string
-
the album name
- $image : string
-
the image name
- $mtime : mixed
Return values
stringextractImageExifOrientation()
Extracts integer value (1-9) from the exifOrientation value stored (e.g. '7: 90 deg CCW Mirrored') in the database for images or returns the value if it is an integer
extractImageExifOrientation([string|int $exiforientation = '' ]) : int
Parameters
- $exiforientation : string|int = ''
-
String or integer value as stored in the db (e.g. '7: 90 deg CCW Mirrored' or just "7")
Tags
Return values
intgetImageFlipRotate()
Returns an array with two indexes "rotate" (= degree to rotate) and "flip" ("horizontal" or "vertical") or false if nothing applies
getImageFlipRotate(mixed $rotation) : bool|array<string|int, mixed>
Parameters
- $rotation : mixed
Tags
Return values
bool|array<string|int, mixed>getAllowedTags()
Returns an array of html tags allowed
getAllowedTags(string $which) : mixed
Parameters
- $which : string
-
either 'allowed_tags' or 'style_tags' depending on which is wanted.
rewrite_path()
Returns either the rewrite path or the plain, non-mod_rewrite path based on the mod_rewrite option.
rewrite_path(string $rewrite, string $plain[, bool $webpath = NULL ]) : string
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
- $rewrite : string
-
is the path to return if rewrite is enabled. (eg: "/myalbum")
- $plain : string
-
is the path if rewrite is disabled (eg: "/?album=myalbum")
- $webpath : bool = NULL
-
host path to be prefixed. If "false" is passed you will get a localized "WEBPATH"
Return values
stringparse_query()
parses a query string WITHOUT url decoding it!
parse_query(string $str) : mixed
Parameters
- $str : string
build_query()
createsa query string from the array passed
build_query(array<string|int, mixed> $parts) : string
Parameters
- $parts : array<string|int, mixed>
Return values
stringbuild_url()
Builds a url from parts
build_url(array<string|int, mixed> $parts) : string
Parameters
- $parts : array<string|int, mixed>
Return values
stringpathurlencode()
rawurlencode function that is path-safe (does not encode /)
pathurlencode(string $path) : string
Parameters
- $path : string
-
URL
Return values
stringgetAlbumFolder()
Returns the fully qualified path to the album folders
getAlbumFolder([string $root = SERVERPATH ]) : string
Parameters
- $root : string = SERVERPATH
-
the base from whence the path dereives
Return values
stringgetBackupFolder()
Returns the fully qualified path to the backup folder
getBackupFolder([string $root = SERVERPATH ]) : string
Parameters
- $root : string = SERVERPATH
-
the base from whence the path dereives
Tags
Return values
stringgetRootFolder()
Returns the fully qualified path to the root albums or backup folder
getRootFolder([string $folder = 'albumfolder' ][, string $root = SERVERPATH ]) : string
Parameters
- $folder : string = 'albumfolder'
-
The folder path to get: "albumfolder" or "backupfolder"
- $root : string = SERVERPATH
-
the base from whence the path dereives
Tags
Return values
stringswitchLog()
Rolls a log over if it has grown too large.
switchLog(string $log) : mixed
Parameters
- $log : string
debugLog()
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.
debugLog(string|array<string|int, mixed>|object $message[, bool $reset = false ][, string $logname = 'debug' ]) : mixed
Creates (or adds to) a file named debug.log which is located in the zenphoto core folder
Parameters
- $message : string|array<string|int, mixed>|object
-
the debug information. This can also be an array or object. For detailed info about the content use debuglogVar().
- $reset : bool = false
-
set to true to reset the log to zero before writing the message
- $logname : string = 'debug'
-
Optional custom log name to log to, default "debug"
instrument()
Tool to log execution times of script bits
instrument(string $point) : mixed
Parameters
- $point : string
-
location identifier
parse_size()
Parses a byte size from a size value (eg: 100M) for comparison.
parse_size(mixed $size) : mixed
Parameters
- $size : mixed
getAlbumArray()
getAlbumArray - returns an array of folder names corresponding to the given album string.
getAlbumArray(string $albumstring[, string $includepaths = false ]) : mixed
Parameters
- $albumstring : string
-
is the path to the album as a string. Ex: album/subalbum/my-album
- $includepaths : string = false
-
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'] @return array
imgSrcURI()
Returns an img src URI encoded based on the OS of the server
imgSrcURI(string $uri) : string
Parameters
- $uri : string
-
uri in FILESYSTEM_CHARSET encoding
Return values
stringgetSuffix()
Returns the suffix of a file name
getSuffix(string $filename) : string
Parameters
- $filename : string
Return values
stringstripSuffix()
returns a file name sans the suffix
stripSuffix(string $filename) : string
Parameters
- $filename : string
Return values
stringgetAlbumInherited()
returns the non-empty value of $field from the album or one of its parents
getAlbumInherited(string $folder, string $field, int &$id) : string
Parameters
- $folder : string
-
the album name
- $field : string
-
the desired field name
- $id : int
-
will be set to the album
id
of the album which has the non-empty field
Return values
stringthemeSetup()
primitive theme setup for image handling scripts
themeSetup(string $album) : string
we need to conserve memory so loading the classes is out of the question.
Parameters
- $album : string
Return values
stringaccessAllAlbums()
Checks access for the album root
accessAllAlbums(bit $action) : mixed
Parameters
- $action : bit
-
what the caller wants to do
getWatermarkPath()
Returns the path to a watermark
getWatermarkPath(string $wm) : string
Parameters
- $wm : string
-
watermark name
Return values
stringsecureServer()
Checks to see if access was through a secure protocol
secureServer() : bool
Tags
Return values
boolgetRequestURI()
Returns the script requesting URI.
getRequestURI() : string
Uses $_SERVER[REQUEST_URI] if it exists, otherwise it concocts the URI from $_SERVER[SCRIPT_NAME] and $_SERVER[QUERY_STRING]
Return values
stringsafe_glob()
Provide an alternative to glob which does not return filenames with accented charactes in them
safe_glob(string $pattern[, bit $flags = 0 ]) : mixed
NOTE: this function ignores "hidden" files whose name starts with a period!
Parameters
- $pattern : string
-
the 'pattern' for matching files
- $flags : bit = 0
-
glob 'flags'
checkInstall()
Check to see if the setup script needs to be run
checkInstall() : mixed
exitZP()
Call when terminating a script.
exitZP() : mixed
Closes the database to be sure that we do not build up outstanding connections
installSignature()
Computes the "installation signature" of the Zenphoto install
installSignature() : array<string|int, mixed>
Return values
array<string|int, mixed>zp_session_start()
Starts a zenphoto session (perhaps a secure one)
zp_session_start() : mixed
zp_session_destroy()
Ends a zenphoto session if there is one and clear the session cookie
zp_session_destroy() : mixed
getDefaultRewriteTokens()
Reads the core default rewrite token define array from the config template file `zenphoto_cfg.txt`.
getDefaultRewriteTokens([string $token = null ]) : array<string|int, mixed>
Used primarily in case it is missing from the current config file as silent fallback and within the rewriteToken plugin
Parameters
- $token : string = null
-
The token to get, e.g. "gallery". If the token is not existing or NULL the whole definition array is returned
Return values
array<string|int, mixed>addMissingDefaultRewriteTokens()
Adds missing individual default rewrite tokens to $_zp_conf_vars['special_pages']
addMissingDefaultRewriteTokens() : mixed
Tags
curlRequest()
Sends a simple cURL request to the $uri specified.
curlRequest(string $uri[, array<string|int, mixed> $options = array() ]) : bool
Parameters
- $uri : string
-
The uri to send the request to. Sets
curl_setopt($ch, CURLOPT_URL, $uri);
- $options : array<string|int, mixed> = array()
-
An array of cURL options to set (uri is set via the separate parameter) Default is if nothing is set: array( CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 2000 ) See http://php.net/manual/en/function.curl-setopt.php for more info
Return values
boolgenerateImageCacheFile()
Sends a cURL request to i.php to generate the image requested without printing it.
generateImageCacheFile(string $imageuri) : mixed
Returns the uri to the cache version of the image on success or false. It also returns false if cURL is not available.
Parameters
- $imageuri : string
-
The image processor uri to this image
httpsRedirect()
Checks if protocol not https and redirects if https required
httpsRedirect([string $type = 'backend' ]) : mixed
Parameters
- $type : string = 'backend'
-
Tpye to redirect "backend" (default) or "frontend"
redirectURL()
General url redirection handler using header()
redirectURL(string $url[, string $statuscode = null ][, bool $allowexternal = false ]) : mixed
Parameters
- $url : string
-
A full qualified url
- $statuscode : string = null
-
Default null (no status header). Enter the status header code to send. Currently supported: 200, 301, 302, 401, 403, 404 (more may be added if needed later on) If you need custom headers not supported just set to null and add them separately before calling this function.
- $allowexternal : bool = false
-
True to allow redirections outside of the current domain (does not cover subdomains!). Default false.
Tags
sanitizeRedirect()
Sanitizes a "redirect" post to always be within the site
sanitizeRedirect(string $redirectTo) : string
Parameters
- $redirectTo : string
Return values
stringcallUserFunction()
Wrapper to call a plugin or otherwise possibly undefined function or method to avoid themes breaking if the plugin is not active
callUserFunction(string|array<string|int, mixed> $function[, array<string|int, mixed>|mixed $parameter = array() ]) : mixed
Follows PHP's native call_user_func_array() but tries to catch invalid calls
Note: Invalid static calls to non static class methods cannot be catched unless the native PHP extension Reflection is available.
Parameters
- $function : string|array<string|int, mixed>
-
A function name, static class method calls like classname::methodname, an array with a class name and static method name or a cass object and a non static class name
- $parameter : array<string|int, mixed>|mixed = array()
-
Parameters of the function/method as one dimensional array. Alternatively you also add separate argments like the original function defines them
Tags
deprecationNotice()
Logs a deprecated notice including traces in the debuglog
deprecationNotice(string $use[, bool|string $parameter = false ]) : mixed
Parameters
- $use : string
-
Additional message, e.g. what to use instead
- $parameter : bool|string = false
-
Set to true if this should notify about deprecated parameter usage (default false), You can also set the name of the parameter if you want to notify about a specific parameter change only
Tags
convertStrftimeFormat()
Basic conversion for a (deprecated) strftime() date format string
convertStrftimeFormat([string $format = '' ]) : string
Returns a date format string compatible with date() / the DateTime class
Note: There are two exceptions that return a non date format string value because there is no equivalent
- %X => 'locale_preferreddate_time' -'%x' => 'locale_preferreddate_notime'
zpFormattedDate() can handle these internally
Parameters
- $format : string = ''
-
strftime() date format string
Tags
Return values
stringhasPrimaryScripts()
Returns true if the install is not a "clone"
hasPrimaryScripts() : mixed