Procedural File: functions.php
Source Location: /functions.php
Page Details
basic functions used by zenphoto
Headers not sent yet!
Includes
require_once
(dirname(__FILE__).'/functions-filter.php')
[line 23]
require_once
(getPlugin('captcha/'.$_zp_captcha.'.php'))
[line 28]
require_once
(dirname(__FILE__).'/auth_zp.php')
[line 46]
require_once
(dirname(__FILE__).'/'.PLUGIN_FOLDER.'/zenpage/zenpage-template-functions.php')
[line 1714]
require_once
(dirname(__FILE__).'/class-load.php')
[line 45]
require_once
(dirname(__FILE__).'/functions-basic.php')
[line 22]
require_once
(PHPScript('5.0.0','_functions.php'))
[line 2073]
require_once
(dirname(__FILE__).'/lib-json.php')
[line 19]
require_once
(dirname(__FILE__).'/functions-i18n.php')
[line 32]
Constants
COMMENT_BODY_REQUIRED [line 705]
COMMENT_BODY_REQUIRED = 16
|
|
COMMENT_EMAIL_REQUIRED [line 701]
COMMENT_EMAIL_REQUIRED = 1
|
|
COMMENT_NAME_REQUIRED [line 702]
COMMENT_NAME_REQUIRED = 2
|
|
COMMENT_SEND_EMAIL [line 706]
COMMENT_WEB_REQUIRED [line 703]
ZENPAGE_NEWS [line 49]
ZENPAGE_NEWS = getOption("zenpage_news_page")
|
|
ZENPAGE_PAGES [line 50]
ZENPAGE_PAGES = getOption("zenpage_pages_page")
|
|
ZP_ALBUM_LINKED [line 1705]
ZP_IMAGE_LINKED [line 1706]
ZP_INDEX [line 1699]
***************************************
ZP_SEARCH_LINKED [line 1704]
ZP_ZENPAGE_NEWS_ARTICLE [line 1707]
ZP_ZENPAGE_NEWS_ARTICLE = 256
|
|
ZP_ZENPAGE_NEWS_CATEGORY [line 1708]
ZP_ZENPAGE_NEWS_CATEGORY = 512
|
|
ZP_ZENPAGE_NEWS_DATE [line 1709]
ZP_ZENPAGE_NEWS_DATE = 1024
|
|
ZP_ZENPAGE_PAGE [line 1710]
ZP_ZENPAGE_SINGLE [line 1711]
Functions
addPluginScript [line 1101]
Allows plugins to add to the scripts output by zenJavascript()
Parameters:
|
string |
$script: |
the text to be added. |
void addPluginScript(
string $script
)
|
|
addPluginType [line 1112]
Registers a plugin as handler for a file extension
Parameters:
|
string |
$suffix: |
the file extension |
|
string |
$objectName: |
the name of the object that handles this extension |
void addPluginType(
string $suffix, string $objectName
)
|
|
add_context [line 1728]
Parameters:
void add_context(
$context
)
|
|
byteConvert [line 1647]
Returns a byte size from a size value (eg: 100M).
Parameters:
string byteConvert(
int $bytes
)
|
|
checkAlbumPassword [line 461]
Checks to see access is allowed to an album Returns true if access is allowed.
There is no password dialog--you must have already had authorization via a cookie.
Parameters:
|
string |
$albumname: |
the album |
|
string |
&$hint: |
becomes populated with the password hint. |
bool checkAlbumPassword(
string $albumname, string &$hint
)
|
|
checkObjectsThumb [line 176]
Search for a thumbnail for the image
Parameters:
|
string |
$album: |
folder path of the album |
|
string |
$image: |
name of the target |
string checkObjectsThumb(
string $album, string $image
)
|
|
commentsAllowed [line 2005]
Returns true if all the right conditions are set to allow comments for the $type
Parameters:
|
string |
$type: |
Which comments |
bool commentsAllowed(
string $type
)
|
|
dateTimeConvert [line 1682]
Converts a datetime to connoical form
Parameters:
|
string |
$datetime: |
input date/time string |
|
bool |
$raw: |
set to true to return the timestamp otherwise you get a string |
mixed dateTimeConvert(
string $datetime, [bool $raw = false]
)
|
|
debug404 [line 2057]
Parameters:
void debug404(
$album, $image, $theme
)
|
|
dircopy [line 1615]
Copies a directory recursively
Parameters:
|
string |
$srcdir: |
the source directory. |
|
string |
$dstdir: |
the destination directory. |
API Tags:
| Return: | total number of files copied. |
the dircopy(
string $srcdir, string $dstdir
)
|
|
dirsize [line 311]
Get the size of a directory.
From: http://aidan.dotgeek.org/lib/
Parameters:
|
string |
$directory: |
Path to directory |
Information Tags:
void dirsize(
string $directory
)
|
|
fetchComments [line 632]
Gets an array of comments for the current admin
Parameters:
|
int |
$number: |
how many comments desired |
array fetchComments(
int $number
)
|
|
galleryAlbumsPerPage [line 1034]
Returns the number of album thumbs that go on a gallery page
int galleryAlbumsPerPage(
)
|
|
generateListFromArray [line 1268]
Creates the body of a select list
Parameters:
|
array |
$currentValue: |
list of items to be flagged as checked |
|
array |
$list: |
the elements of the select list |
|
bool |
$descending: |
set true for a reverse order sort |
|
|
$localize: |
|
void generateListFromArray(
array $currentValue, array $list, bool $descending, $localize
)
|
|
generateListFromFiles [line 1302]
Generates a selection list from files found on disk
Parameters:
|
strig |
$currentValue: |
the current value of the selector |
|
string |
$root: |
directory path to search |
|
string |
$suffix: |
suffix to select for |
|
bool |
$descending: |
set true to get a reverse order sort |
void generateListFromFiles(
strig $currentValue, string $root, string $suffix, [bool $descending = false]
)
|
|
getAllSubAlbumIDs [line 924]
Returns an array of album ids whose parent is the folder
Parameters:
|
string |
$albumfolder: |
folder name if you want a album different >>from the current album |
array getAllSubAlbumIDs(
[string $albumfolder = '']
)
|
|
getAllTagsCount [line 1162]
Returns an array indexed by 'tag' with the element value the count of the tag
getAllTagsUnique [line 1140]
Returns an array of unique tag names
unknown getAllTagsUnique(
)
|
|
getEnabledPlugins [line 609]
Returns an array of the currently enabled plugins
array getEnabledPlugins(
)
|
|
getManagedAlbumList [line 902]
Populates and returns the $_zp_admin_album_list array
array getManagedAlbumList(
)
|
|
getNotViewableAlbums [line 1387]
Returns a list of album IDs that the current viewer is allowed to see
array getNotViewableAlbums(
)
|
|
getPlugin [line 579]
Returns the fully qualified "require" file name of the plugin file.
Parameters:
|
string |
$plugin: |
is the name of the plugin file, typically something.php |
|
bool |
$inTheme: |
tells where to find the plugin. true means look in the current theme false means look in the zp-core/plugins folder. |
|
|
$path: |
|
string getPlugin(
string $plugin, [bool $inTheme = false], [ $path = SERVERPATH]
)
|
|
getPluginFiles [line 536]
Returns a consolidated list of plugins The array structure is key=plugin name, value=plugin path
Parameters:
|
string |
$pattern: |
File system wildcard matching pattern to limit the search |
|
string |
$folder: |
subfolder within the plugin folders to search |
|
bool |
$stripsuffix: |
set to true to remove the suffix from the key name in the array |
array getPluginFiles(
string $pattern, [string $folder = ''], [bool $stripsuffix = true]
)
|
|
getThemeOption [line 1966]
Returns the value of a theme option
Parameters:
|
string |
$option: |
option key |
|
object |
$album: |
|
|
string |
$default: |
theme name |
mixed getThemeOption(
string $option, [object $album = NULL], [string $default = false]
)
|
|
getUrAlbum [line 219]
Returns the oldest ancestor of an alubm;
Parameters:
|
string |
$album: |
an album object |
object getUrAlbum(
string $album
)
|
|
getUserIP [line 2015]
Returns the viewer's IP address Deals with transparent proxies
handleSearchParms [line 945]
recovers search parameters from stored cookie, clears the cookie
Parameters:
|
string |
$what: |
the page type |
|
string |
$album: |
Name of the album |
|
string |
$image: |
Name of the image |
void handleSearchParms(
string $what, [string $album = NULL], [string $image = NULL]
)
|
|
in_context [line 1725]
Parameters:
void in_context(
$context
)
|
|
isImagePhoto [line 1599]
Returns true if the image is a standard photo type
Parameters:
|
object |
$image: |
optional image object |
bool isImagePhoto(
[object $image = NULL]
)
|
|
isImageVideo [line 1584]
Returns video argument of the current Image.
Parameters:
|
object |
$image: |
optional image object |
bool isImageVideo(
[object $image = NULL]
)
|
|
isValidURL [line 1461]
Checks to see if a URL is valid
Parameters:
|
string |
$url: |
the URL being checked |
bool isValidURL(
string $url
)
|
|
is_connected [line 2047]
Returns true if there is an internet connection
Parameters:
|
string |
$host: |
optional host name to test |
bool is_connected(
[string $host = 'www.zenphoto.org']
)
|
|
is_valid_email_zp [line 345]
Determines if the input is an e-mail address. Adapted from WordPress.
Name changed to avoid conflicts in WP integrations.
Parameters:
|
string |
$input_email: |
email address? |
bool is_valid_email_zp(
string $input_email
)
|
|
is_valid_image [line 163]
Returns true if the file is an image
Parameters:
|
string |
$filename: |
the name of the target |
bool is_valid_image(
string $filename
)
|
|
is_valid_other_type [line 1123]
Returns true if the file is handled by a plugin object
Parameters:
bool is_valid_other_type(
string $filename
)
|
|
logTime [line 1750]
Logs a time into the debug log
Parameters:
|
string |
$tag: |
log annotation |
void logTime(
string $tag
)
|
|
lookupSortKey [line 239]
Returns a sort field part for querying Note: $sorttype may be a comma separated list of field names. If so, these are peckmarked and returned otherwise unchanged.
Parameters:
|
string |
$sorttype: |
the 'Display" name of the sort |
|
string |
$default: |
the default if $sorttype is empty |
|
string |
$filename: |
the value to be used if $sorttype is 'Filename' since the field is different between the album table and the image table. |
string lookupSortKey(
string $sorttype, string $default, string $filename
)
|
|
makeSpecialImageName [line 1664]
Returns an i.php "image name" for an image not within the albums structure
Parameters:
|
string |
$image: |
Path to the image |
string makeSpecialImageName(
string $image
)
|
|
myts_date [line 285]
Simple mySQL timestamp formatting function.
Parameters:
|
string |
$format: |
formatting template |
|
int |
$mytimestamp: |
timestamp |
string myts_date(
string $format, int $mytimestamp
)
|
|
pageError [line 1445]
Emits a page error. Used for attempts to bypass password protection
Parameters:
|
string |
$err: |
error code |
|
string |
$text: |
error message |
void pageError(
string $err, string $text
)
|
|
parseAllowedTags [line 136]
parses the allowed HTML tags for use by htmLawed
Parameters:
|
string |
&$source: |
by name, contains the string with the tag options |
API Tags:
| Return: | the allowed_tags array. |
Information Tags:
array parseAllowedTags(
string &$source
)
|
|
parseThemeDef [line 1416]
Parses and sanitizes Theme definition text
Parameters:
string parseThemeDef(
file $file
)
|
|
postComment [line 727]
Generic comment adding routine. Called by album objects or image objects to add comments.
Returns a comment object
Parameters:
|
string |
$name: |
Comment author name |
|
string |
$email: |
Comment author email |
|
string |
$website: |
Comment author website |
|
string |
$comment: |
body of the comment |
|
string |
$code: |
CAPTCHA code entered |
|
string |
$code_ok: |
CAPTCHA md5 expected |
|
string |
$type: |
'albums' if it is an album or 'images' if it is an image comment |
|
object |
$receiver: |
the object (image or album) to which to post the comment |
|
string |
$ip: |
the IP address of the comment poster |
|
bool |
$private: |
set to true if the comment is for the admin only |
|
bool |
$anon: |
set to true if the poster wishes to remain anonymous |
|
bit |
$check: |
bitmask of which fields must be checked. If set overrides the options |
object postComment(
string $name, string $email, string $website, string $comment, string $code, string $code_ok, object $receiver, string $ip, bool $private, bool $anon, [bit $check = false], string $type
)
|
|
printLargeFileContents [line 516]
Processes a file for createAlbumZip
Parameters:
|
string |
$dest: |
the source [sic] to process |
void printLargeFileContents(
string $dest
)
|
|
printLink [line 1323]
General link printing function
Parameters:
|
string |
$url: |
The link URL |
|
string |
$text: |
The text to go with the link |
|
string |
$title: |
Text for the title tag |
|
string |
$class: |
optional class |
|
string |
$id: |
optional id |
void printLink(
string $url, string $text, [string $title = NULL], [string $class = NULL], [string $id = NULL]
)
|
|
readTags [line 1248]
Retrieves the tags for an album/image Returns them in an array
Parameters:
|
int |
$id: |
the record id of the album/image |
|
string |
$tbl: |
'albums' or 'images' |
unknown readTags(
int $id, string $tbl
)
|
|
rem_context [line 1731]
Parameters:
void rem_context(
$context
)
|
|
restore_context [line 1740]
safe_fnmatch [line 1506]
pattern match function Works with accented characters where the PHP one does not.
Parameters:
|
string |
$pattern: |
pattern |
|
string |
$string: |
haystack |
bool safe_fnmatch(
string $pattern, string $string
)
|
|
safe_glob [line 1471]
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]
)
|
|
seoFriendly [line 2029]
Strips out and/or replaces characters from the string that are not "soe" friendly
Parameters:
string seoFriendly(
string $source
)
|
|
setBoolThemeOption [line 1949]
Sets value for a boolena theme option insures that the value is either zero or one
Parameters:
|
string |
$key: |
Option key |
|
bool |
$bool: |
value to be set |
|
object |
$album: |
album object |
|
string |
$default: |
theme name |
void setBoolThemeOption(
string $key, bool $bool, [object $album = NULL], [string $default = false]
)
|
|
setexifvars [line 122]
initializes the $_zp_exifvars array display state
setThemeOption [line 1891]
Set options local to theme and/or album
Parameters:
|
string |
$key: |
|
|
string |
$value: |
|
|
object |
$album: |
|
|
bool |
$default: |
set to true for setting default theme options (does not set the option if it already exists) |
void setThemeOption(
string $key, string $value, [object $album = NULL], [bool $default = false]
)
|
|
setThemeOptionDefault [line 1929]
Used to set default values for theme specific options
Parameters:
|
string |
$key: |
|
|
mixed |
$value: |
|
void setThemeOptionDefault(
string $key, mixed $value
)
|
|
setupTheme [line 1044]
Returns the theme folder If there is an album theme, loads the theme options.
set_context [line 1721]
Parameters:
void set_context(
$context
)
|
|
sortByMultilingual [line 435]
Sorts the results of a DB search by the current locale string for $field
Parameters:
|
array |
$dbresult: |
the result of the DB query |
|
string |
$field: |
the field name to sort on |
|
bool |
$descending: |
the direction of the sort |
API Tags:
| Return: | the sorted result |
array sortByMultilingual(
array $dbresult, string $field, bool $descending
)
|
|
sortMultiArray [line 1343]
multidimensional array column sort
Parameters:
|
array |
$array: |
The multidimensional array to be sorted |
|
string |
$index: |
Which key should be sorted by |
|
string |
$order: |
true for descending sorts |
|
bool |
$natsort: |
If natural order should be used |
|
bool |
$case_sensitive: |
If the sort should be case sensitive |
|
|
$descending: |
|
Information Tags:
| Author: | redoc (http://codingforums.com/showthread.php?t=71904) |
array sortMultiArray(
array $array, string $index, [ $descending = false], [bool $natsort = true], [bool $case_sensitive = false], string $order
)
|
|
storeTags [line 1203]
Stores tags for an album/image
Parameters:
|
array |
$tags: |
the tag values |
|
int |
$id: |
the record id of the album/image |
|
string |
$tbl: |
'albums' or 'images' |
void storeTags(
array $tags, int $id, string $tbl
)
|
|
truncate_string [line 204]
Returns a truncated string
Parameters:
|
string |
$string: |
souirce string |
|
int |
$length: |
how long it should be |
|
string |
$elipsis: |
the text to tack on indicating shortening |
string truncate_string(
string $string, int $length, [string $elipsis = '...']
)
|
|
zpFormattedDate [line 265]
Returns a formated date for output
Parameters:
|
string |
$format: |
the "strftime" format string |
|
date |
$dt: |
the date to be output |
string zpFormattedDate(
string $format, date $dt
)
|
|
zp_getCookie [line 1515]
Returns the value of a cookie from either the cookies or from $_SESSION[]
Parameters:
|
string |
$name: |
the name of the cookie |
void zp_getCookie(
string $name
)
|
|
zp_handle_password [line 1763]
checks password posting
Parameters:
|
string |
$authType: |
override of athorization type |
|
|
$check_auth: |
|
|
|
$check_user: |
|
void zp_handle_password(
[string $authType = NULL], [ $check_auth = NULL], [ $check_user = NULL]
)
|
|
zp_image_types [line 1568]
returns a list of comment record 'types' for "images"
Parameters:
|
string |
$quote: |
quotation mark to use |
string zp_image_types(
string $quote
)
|
|
zp_mail [line 370]
Send an mail to the mailing list. We also attempt to intercept any form injection attacks by slime ball spammers. Returns error message if send failure.
Parameters:
|
string |
$subject: |
The subject of the email. |
|
string |
$message: |
The message contents of the email. |
|
string |
$from_mail: |
Optional sender for the email. |
|
string |
$from_name: |
Optional sender for the name. |
|
array |
$email_list: |
a list of email addresses |
|
|
$cc_addresses: |
|
Information Tags:
| Author: | Todd Papaioannou (lucky@luckyspin.org) |
| Since: | 1.0.0 |
string zp_mail(
string $subject, string $message, [array $email_list = null], [ $cc_addresses = NULL], string $from_mail, string $from_name
)
|
|
zp_setCookie [line 1546]
Sets a cookie both in the browser cookies and in $_SESSION[]
Parameters:
|
string |
$name: |
The 'cookie' name |
|
string |
$value: |
The value to be stored |
|
timestamp |
$time: |
The time the cookie expires |
|
string |
$path: |
The path on the server in which the cookie will be available on |
|
|
$secure: |
|
void zp_setCookie(
string $name, string $value, [timestamp $time = NULL], [string $path = NULL], [ $secure = false]
)
|
|
|
|