[ class tree: functions ] [ index: functions ] [ all elements ]

Procedural File: functions.php

Source Location: /functions.php

Page Details

basic functions used by zenphoto

Headers not sent yet!

Includes
require_once ($_zp_captcha) [line 26]
[ Top ]

require_once (dirname(__FILE__).'/class-load.php') [line 43]
[ Top ]

require_once (SERVERPATH.'/'.ZENFOLDER.'/lib-htmLawed.php') [line 20]
[ Top ]

require_once (dirname(__FILE__).'/lib-json.php') [line 15]
[ Top ]

require_once (dirname(__FILE__).'/auth_zp.php') [line 44]
[ Top ]

require_once (dirname(__FILE__).'/functions-basic.php') [line 18]
[ Top ]

require_once (dirname(__FILE__).'/'.PLUGIN_FOLDER.'/zenpage/zenpage-template-functions.php') [line 1887]

***************************************

[ Top ]

require_once (dirname(__FILE__).'/functions-filter.php') [line 19]
[ Top ]

require_once (dirname(__FILE__).'/functions-i18n.php') [line 30]
[ Top ]


Constants
COMMENT_BODY_REQUIRED  [line 795]

COMMENT_BODY_REQUIRED = 16

[ Top ]

COMMENT_EMAIL_REQUIRED  [line 791]

COMMENT_EMAIL_REQUIRED = 1

[ Top ]

COMMENT_NAME_REQUIRED  [line 792]

COMMENT_NAME_REQUIRED = 2

[ Top ]

COMMENT_SEND_EMAIL  [line 796]

COMMENT_SEND_EMAIL = 32

[ Top ]

COMMENT_WEB_REQUIRED  [line 793]

COMMENT_WEB_REQUIRED = 4

[ Top ]

USE_CAPTCHA  [line 794]

USE_CAPTCHA = 8

[ Top ]

ZENPHOTO_LOCALE  [line 41]

ZENPHOTO_LOCALE = setMainDomain()

[ Top ]


Functions
addPluginType  [line 1282]

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  )

[ Top ]
add_context  [line 1901]
Parameters:
   $context: 


void add_context( $context  )

[ Top ]
byteConvert  [line 1833]

Returns a byte size from a size value (eg: 100M).

Parameters:
int   $bytes: 


string byteConvert( int $bytes  )

[ Top ]
checkAlbumPassword  [line 535]

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   $album:  album object or name of the album
string   &$hint:  becomes populated with the password hint.


bool checkAlbumPassword( string $album, [string &$hint = NULL]  )

[ Top ]
checkObjectsThumb  [line 199]

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  )

[ Top ]
checkPublishDates  [line 1197]

checks if the item has expired

Parameters:
array   $row:  database row of the object


void checkPublishDates( array $row  )

[ Top ]
commentsAllowed  [line 2158]

Returns true if all the right conditions are set to allow comments for the $type

Parameters:
string   $type:  Which comments


bool commentsAllowed( string $type  )

[ Top ]
cron_starter  [line 2260]

Starts a sechedule script run

Parameters:
string   $script:  The script file to load
array   $params:  "POST" parameters
bool   $inline:  set to true to run the task "in-line". Set false run asynchronously


void cron_starter( string $script, array $params, [bool $inline = false]  )

[ Top ]
dateTimeConvert  [line 1870]

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

[ Top ]
debug404  [line 2216]

produce debugging information on 404 errors

Parameters:
string   $album: 
string   $image: 
string   $theme: 


void debug404( string $album, string $image, string $theme  )

[ Top ]
dircopy  [line 1801]

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  )

[ Top ]
dirsize  [line 333]

Get the size of a directory.

From: http://aidan.dotgeek.org/lib/

Parameters:
string   $directory:  Path to directory

Information Tags:
Author:  Aidan Lister <aidan@php.net>
Version:  1.0.0

void dirsize( string $directory  )

[ Top ]
fetchComments  [line 722]

Gets an array of comments for the current admin

Parameters:
int   $number:  how many comments desired


array fetchComments( int $number  )

[ Top ]
galleryAlbumsPerPage  [line 1218]

Returns the number of album thumbs that go on a gallery page


int galleryAlbumsPerPage( )

[ Top ]
generateListFromArray  [line 1414]

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  )

[ Top ]
generateListFromFiles  [line 1448]

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

[ Top ]
getAllSubAlbumIDs  [line 1095]

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 = '']  )

[ Top ]
getAllTagsCount  [line 1327]

Returns an array indexed by 'tag' with the element value the count of the tag


array getAllTagsCount( )

[ Top ]
getAllTagsUnique  [line 1308]

Returns an array of unique tag names


array getAllTagsUnique( )

[ Top ]
getEnabledPlugins  [line 699]

Returns an array of the currently enabled plugins


array getEnabledPlugins( )

[ Top ]
getLanguageFlag  [line 2359]
Parameters:
   $lang: 


void getLanguageFlag( $lang  )

[ Top ]
getManagedAlbumList  [line 1006]

Populates and returns the $_zp_admin_album_list array


array getManagedAlbumList( )

[ Top ]
getNotViewableAlbums  [line 1575]

Returns a list of album IDs that the current viewer is allowed to see


array getNotViewableAlbums( )

[ Top ]
getOptionFromDB  [line 2045]

Gets an option directly from the database.

Parameters:
string   $key: 


void getOptionFromDB( string $key  )

[ Top ]
getPlugin  [line 664]

Returns the fully qualified file name of the plugin file.

Note: order of selection is: 1-theme folder file (if $inTheme is set) 2-user plugin folder file 3-zp-extensions file first file found is used

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.
bool   $webpath:  return a WEBPATH rather than a SERVERPATH


string getPlugin( string $plugin, [bool $inTheme = false], [bool $webpath = false]  )

[ Top ]
getPluginFiles  [line 614]

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

[ Top ]
getTableAsoc  [line 2315]

Produces the # to table association array


void getTableAsoc( )

[ Top ]
getThemeOption  [line 2117]

Returns the value of a theme option

Parameters:
string   $option:  option key
object   $album: 
string   $theme:  default theme name


mixed getThemeOption( string $option, [object $album = NULL], [string $theme = NULL]  )

[ Top ]
getTinyURL  [line 2324]

Returns a Zenphoto tiny URL to the object

Parameters:
$obj   $obj:  object


void getTinyURL( $obj $obj  )

[ Top ]
getUrAlbum  [line 239]

Returns the oldest ancestor of an alubm;

Parameters:
string   $album:  an album object


object getUrAlbum( string $album  )

[ Top ]
getUserIP  [line 2168]

Returns the viewer's IP address Deals with transparent proxies


string getUserIP( )

[ Top ]
getXSRFToken  [line 2239]

returns an XSRF token

Parameters:
striong   $action: 


void getXSRFToken( striong $action  )

[ Top ]
get_context  [line 1890]

void get_context( )

[ Top ]
handleSearchParms  [line 1116]

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

[ Top ]
in_context  [line 1898]
Parameters:
   $context: 


void in_context( $context  )

[ Top ]
isImagePhoto  [line 1785]

Returns true if the image is a standard photo type

Parameters:
object   $image:  optional image object


bool isImagePhoto( [object $image = NULL]  )

[ Top ]
isImageVideo  [line 1770]

Returns video argument of the current Image.

Parameters:
object   $image:  optional image object


bool isImageVideo( [object $image = NULL]  )

[ Top ]
isValidURL  [line 1651]

Checks to see if a URL is valid

Parameters:
string   $url:  the URL being checked


bool isValidURL( string $url  )

[ Top ]
is_connected  [line 2200]

Returns true if there is an internet connection

Parameters:
string   $host:  optional host name to test


bool is_connected( [string $host = 'www.zenphoto.org']  )

[ Top ]
is_valid_email_zp  [line 366]

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  )

[ Top ]
is_valid_image  [line 186]

Returns true if the file is an image

Parameters:
string   $filename:  the name of the target


bool is_valid_image( string $filename  )

[ Top ]
is_valid_other_type  [line 1293]

Returns true if the file is handled by a plugin object

Parameters:
string   $filename: 


bool is_valid_other_type( string $filename  )

[ Top ]
logTime  [line 1923]

Logs a time into the debug log

Parameters:
string   $tag:  log annotation


void logTime( string $tag  )

[ Top ]
lookupSortKey  [line 259]

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  )

[ Top ]
makeSpecialImageName  [line 1847]

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  )

[ Top ]
myts_date  [line 308]

Simple SQL timestamp formatting function.

Parameters:
string   $format:  formatting template
int   $mytimestamp:  timestamp


string myts_date( string $format, int $mytimestamp  )

[ Top ]
pageError  [line 1635]

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  )

[ Top ]
parseAllowedTags  [line 159]

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:
Since:  1.1.3

array parseAllowedTags( string &$source  )

[ Top ]
parseThemeDef  [line 1606]

Parses and sanitizes Theme definition text

Parameters:
file   $file:  theme file


string parseThemeDef( file $file  )

[ Top ]
populateManagedObjectsList  [line 1035]

Returns a list of album names managed by $id

Parameters:
string   $type:  which kind of object
int   $id:  admin ID
bool   $rights:  set true for album sub-rights


array populateManagedObjectsList( string $type, int $id, [bool $rights = false]  )

[ Top ]
postComment  [line 817]

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 hash 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  )

[ Top ]
printLargeFileContents  [line 594]

Processes a file for createAlbumZip

Parameters:
string   $dest:  the source [sic] to process


void printLargeFileContents( string $dest  )

[ Top ]
printLink  [line 1471]

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

[ Top ]
readTags  [line 1392]

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  )

[ Top ]
read_exif_data_protected  [line 2341]

Provides an error protected read of image EXIF/IPTC data

Parameters:
string   $path:  image path


array read_exif_data_protected( string $path  )

[ Top ]
rem_context  [line 1904]
Parameters:
   $context: 


void rem_context( $context  )

[ Top ]
restore_context  [line 1913]

void restore_context( )

[ Top ]
safe_fnmatch  [line 1662]

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  )

[ Top ]
save_context  [line 1909]

void save_context( )

[ Top ]
seoFriendly  [line 2182]

Strips out and/or replaces characters from the string that are not "soe" friendly

Parameters:
string   $source: 


string seoFriendly( string $source  )

[ Top ]
setexifvars  [line 59]

initializes the $_zp_exifvars array display state


void setexifvars( )

[ Top ]
setThemeOption  [line 2060]

Set options local to theme and/or album

Parameters:
string   $key: 
string   $value: 
object   $album: 
string   $theme:  default theme
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], [string $theme = NULL], [bool $default = false]  )

[ Top ]
setThemeOptionDefault  [line 2102]

Used to set default values for theme specific options

Parameters:
string   $key: 
mixed   $value: 


void setThemeOptionDefault( string $key, mixed $value  )

[ Top ]
setupTheme  [line 1228]

Returns the theme folder If there is an album theme, loads the theme options.


string setupTheme( )

[ Top ]
set_context  [line 1894]
Parameters:
   $context: 


void set_context( $context  )

[ Top ]
sortByKey  [line 1492]

sorts the found albums (images) by the required key(s)

NB: this sort is sensitive to the key(s) chosen and makes the appropriate sorts based on same. Some multi-key sorts will not make any sense and will give unexpected results. Most notably any that contain the keys "title" or "desc" as these require multi-lingual sorts.

Parameters:
array   $results: 
string   $sortkey: 
string   $order: 


void sortByKey( array $results, string $sortkey, string $order  )

[ Top ]
sortByMultilingual  [line 509]

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  )

[ Top ]
sortMultiArray  [line 1525]

multidimensional array column sort

Parameters:
array   $array:  The multidimensional array to be sorted
mixed   $index:  Which key(s) 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: 
   $preservekeys: 

Information Tags:
Author:  redoc (http://codingforums.com/showthread.php?t=71904)

array sortMultiArray( array $array, mixed $index, [ $descending = false], [bool $natsort = true], [bool $case_sensitive = false], [ $preservekeys = false], string $order  )

[ Top ]
storeTags  [line 1348]

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  )

[ Top ]
truncate_string  [line 220]

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 = '...']  )

[ Top ]
XSRFToken  [line 2248]

Emits a "hidden" input for the XSRF token

Parameters:
string   $action: 


void XSRFToken( string $action  )

[ Top ]
zpFormattedDate  [line 288]

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  )

[ Top ]
zp_cookieEncode  [line 1699]

Encodes a cookie value tying it to the user IP

Parameters:
$value   $value: 


void zp_cookieEncode( $value $value  )

[ Top ]
zp_getCookie  [line 1671]

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  )

[ Top ]
zp_handle_password  [line 1936]

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

[ Top ]
zp_image_types  [line 1754]

returns a list of comment record 'types' for "images"

Parameters:
string   $quote:  quotation mark to use


string zp_image_types( string $quote  )

[ Top ]
zp_loggedin  [line 2306]

Check if logged in (with specific rights) Returns a true value if there is a user logged on with the required rights

Parameters:
bit   $rights:  rights required by the caller


bool zp_loggedin( [bit $rights = ALL_RIGHTS]  )

[ Top ]
zp_mail  [line 393]

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
array   $cc_addresses:  a list of addresses to send copies to.
array   $bcc_addresses:  a list of addresses to send blind copies to.

Information Tags:
Author:  Todd Papaioannou (lucky@luckyspin.org)
Since:  1.0.0

string zp_mail( string $subject, string $message, [array $email_list = NULL], [array $cc_addresses = NULL], [array $bcc_addresses = NULL], string $from_mail, string $from_name  )

[ Top ]
zp_setCookie  [line 1715]

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 delta until 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]  )

[ Top ]


Documentation generated on Tue, 20 Dec 2011 16:07:19 +0100 by phpDocumentor 1.4.3