Textpattern | PHP Cross Reference | Content Management Systems |
Description: Collection of miscellaneous tools.
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
timezone:: (13 methods):
selectInput()
details()
key()
is_dst()
is_supported()
install_textpack()
form_token()
assert_system_requirements()
bouncer()
http_accept_format()
status_list()
getStatusNum()
check_file_integrity()
Dealing with timezones.
selectInput($name = '', $value = '', $blank_first = '', $onchange = '', $select_id = '') line: 6373 |
Render HTML <select> element for choosing a timezone. return: string HTML markup param: string $name Element name param: string $value Selected timezone param: bool $blank_first Add empty first option param: bool|string $onchange param: string $select_id HTML id attribute |
details() line: 6428 |
Build a matrix of timezone details. return: array Array of timezone details indexed by timezone key |
key($gmtoffset) line: 6441 |
Find a timezone key matching a given GMT offset. NB: More than one key might fit any given GMT offset, thus the returned value is ambiguous and merely useful for presentation purposes. return: string timezone key param: int $gmtoffset |
is_dst($timestamp, $timezone_key) line: 6462 |
Is DST in effect? return: bool param: int $timestamp When? param: string $timezone_key Where? |
is_supported() line: 6477 |
Check for run-time timezone support. As of 4.6.0, always returns TRUE. return: bool Timezone feature is enabled |
install_textpack($textpack, $add_new_langs = false) line: 6492 |
Installs localisation strings from a Textpack. Created strings get a well-known static modifcation date set in the past. This is done to avoid tampering with lastmod dates used for RPC server interactions, caching and update checks. return: int Number of installed strings param: string $textpack The Textpack to install param: bool $add_new_langs If TRUE, installs strings for any included language |
form_token() line: 6556 |
Generate a ciphered token. The token is reproducible, unique among sites and users, expires later. return: string The token |
assert_system_requirements() line: 6581 |
Assert system requirements. |
bouncer($step, $steps) line: 6594 |
Validates admin steps and protects against CSRF attempts using tokens. Takes an admin step and validates it against an array of valid steps. The valid steps array indicates the step's token based session riding protection needs. If the step requires CSRF token protection, and the request doesn't come with a valid token, the request is terminated, defeating any CSRF attempts. If the $step isn't in valid steps, it returns FALSE, but the request isn't terminated. If the $step is valid and passes CSRF validation, returns TRUE. return: bool If the $step is valid, proceeds and returns TRUE. Dies on CSRF attempt. param: string $step Requested admin step param: array $steps An array of valid steps with flag indicating CSRF needs, e.g. array('savething' => true, 'listthings' => false) |
http_accept_format($format) line: 6652 |
Test whether the client accepts a certain response format. Discards formats with a quality factor below 0.1 return: boolean $format TRUE if accepted param: string $format One of 'html', 'txt', 'js', 'css', 'json', 'xml', 'rdf', 'atom', 'rss' |
status_list($labels = true, $exclude = array() line: 6705 |
Return a list of status codes and their associated names. The list can be extended with a 'status.types > types' callback event. Callback functions get passed three arguments: '$event', '$step' and '$status_list'. The third parameter contains a reference to an array of 'status_code => label' pairs. return: array A status array param: bool Return the list with L10n labels (for UI purposes) or raw values (for comparisons) param: array List of status keys (numbers) to exclude |
getStatusNum($name, $default = STATUS_LIVE) line: 6746 |
Translates article status names into numerical status codes. return: int Matching numerical status param: string $name Status name param: int $default Status code to return if $name is not a defined status name |
check_file_integrity($flags = INTEGRITY_STATUS) line: 6767 |
Checks install's file integrity and returns results. Depending on the given $flags this function will either return an array of file statuses, checksums or the digest of the install. It can also return the parsed contents of the checksum file. return: array|bool Array of files and status, or FALSE on error param: int $flags Options are INTEGRITY_MD5 | INTEGRITY_STATUS | INTEGRITY_REALPATH | INTEGRITY_DIGEST |
Functions that are not part of a class:
deNull($in) line: 30 |
Strips NULL bytes. return: mixed param: string|array $in The input value |
deCRLF($in) line: 42 |
Strips carriage returns and linefeeds. return: mixed param: string|array $in The input value |
doArray($in, $function) line: 54 |
Applies a callback to a given string or an array. return: mixed param: string|array $in An array or a string to run through the callback function param: callback $function The callback function |
doStrip($in) line: 77 |
Un-quotes a quoted string or an array of values. return: mixed param: string|array $in The input value |
doStripTags($in) line: 89 |
Strips HTML and PHP tags from a string or an array. return: mixed param: string|array $in The input value |
doDeEnt($in) line: 103 |
Converts entity escaped brackets back to characters. return: mixed param: string|array $in The input value |
deEntBrackets($in) line: 115 |
Converts entity escaped brackets back to characters. return: string param: string $in The input value |
doSlash($in) line: 140 |
Escapes special characters for use in an SQL statement. Always use this function when dealing with user-defined values in SQL statements. If this function is not used to escape user-defined data in a statement, the query is vulnerable to SQL injection attacks. return: mixed An array of escaped values or a string depending on $in param: string|array $in The input value |
doLike($in) line: 159 |
Escape SQL LIKE pattern's wildcards for use in an SQL statement. return: mixed An array of escaped values or a string depending on $in param: string|array $in The input value |
txpspecialchars($string, $flags = ENT_QUOTES, $encoding = 'UTF-8', $double_encode = true) line: 175 |
A shell for htmlspecialchars() with $flags defaulting to ENT_QUOTES. return: string param: string $string The string being converted param: int $flags A bitmask of one or more flags. The default is ENT_QUOTES param: string $encoding Defines encoding used in conversion. The default is UTF-8 param: bool $double_encode When double_encode is turned off PHP will not encode existing HTML entities, the default is to convert everything |
doSpecial($in) line: 208 |
Converts special characters to HTML entities. return: mixed The array or string with HTML syntax characters escaped param: array|string $in The input value |
_null($a) line: 221 |
Converts the given value to NULL. return: null param: mixed $a The input value |
array_null($in) line: 235 |
Converts an array of values to NULL. return: array param: array $in The array |
escape_title($title) line: 248 |
Escapes a page title. Converts <, >, ', " characters to HTML entities. return: string The string escaped param: string $title The input string |
escape_js($js) line: 266 |
Sanitises a string for use in a JavaScript string. Escapes \, \n, \r, " and ' characters. It removes 'PARAGRAPH SEPARATOR' (U+2029) and 'LINE SEPARATOR' (U+2028). When you need to pass a string from PHP to JavaScript, use this function to sanitise the value to avoid XSS attempts. return: string Escaped JavaScript param: string $js JavaScript input |
escape_output($str) line: 287 |
A shell for htmlspecialchars() with $flags defaulting to ENT_QUOTES. return: string param: string $str The input string |
escape_tags($str) line: 304 |
Replaces < and > characters with entities. return: string param: string $str The input string |
escape_cdata($str) line: 324 |
Escapes CDATA section for an XML document. return: string XML representation wrapped in CDATA tags param: string $str The string |
gTxt($var, $atts = array() line: 337 |
Returns a localisation string. return: string A localisation string param: string $var String name param: array $atts Replacement pairs param: string $escape Convert special characters to HTML entities. Either "html" or "" |
gTxtScript($var, $atts = array() line: 378 |
Loads client-side localisation scripts. Passes localisation strings from the database to JavaScript. Only works on the admin-side pages. param: string|array $var Scalar or array of string keys param: array $atts Array or array of arrays of variable substitution pairs param: array $route Optional events/steps upon which to add the strings |
gTime($timestamp = 0) line: 411 |
Returns given timestamp in a format of 01 Jan 2001 15:19:16. return: string A formatted date param: int $timestamp The UNIX timestamp |
dmp() line: 428 |
Creates a dumpfile from a backtrace and outputs given parameters. |
load_lang($lang, $events = null) line: 470 |
Gets the given language's strings from the database. Fetches the given language from the database and returns the strings as an array. If no $events is specified, only appropriate strings for the current context are returned. If 'txpinterface' constant equals 'admin' all strings are returned. Otherwise, only strings from events 'common' and 'public'. If $events is FALSE, returns all strings. return: array param: string $lang The language code param: array|string|bool $events An array of loaded events |
load_lang_dates($lang) line: 522 |
Loads date definitions from a localisation file. param: string $lang The language |
load_lang_event($event, $lang = LANG) line: 553 |
Gets language strings for the given event. If no $lang is specified, the strings are loaded from the currently active language. return: array|string Array of string on success, or an empty string when no strings were found param: string $event The event to get, e.g. "common", "admin", "public" param: string $lang The language code |
check_privs() line: 589 |
Requires privileges from a user. |
add_privs($res, $perm = '1') line: 610 |
Grants privileges to user-groups. Will not let you override existing privs. param: string $res The resource param: string $perm List of user-groups, e.g. '1,2,3' |
has_privs($res, $user = '') line: 632 |
Checks if a user has privileges to the given resource. return: bool param: string $res The resource param: string $user The user. If no user name is supplied, assume the current logged in user |
require_privs($res = null, $user = '') line: 671 |
Require privileges from a user to the given resource. Terminates the script if user doesn't have required privileges. param: string|null $res The resource, or NULL param: string $user The user. If no user name is supplied, assume the current logged in user |
the_privileged($res) line: 693 |
Gets a list of users having access to a resource. return: array A list of usernames param: string $res The resource, e.g. 'article.edit.published' |
get_groups() line: 713 |
Gets a list of user groups. return: array |
sizeImage($name) line: 731 |
Gets the dimensions of an image for a HTML <img> tag. return: string|bool height="100" width="40", or FALSE on failure param: string $name The filename |
get_safe_image_types($type = null) line: 751 |
Lists image types that can be safely uploaded. Returns different results based on the logged in user's privileges. return: mixed param: int $type If set, validates the given value |
check_gd($image_type) line: 783 |
Checks if GD supports the given image type. return: bool TRUE if the type is supported param: string $image_type Either '.gif', '.png', '.jpg' |
image_data($file, $meta = array() line: 814 |
Uploads an image. Can be used to upload a new image or replace an existing one. If $id is specified, the image will be replaced. If $uploaded is set FALSE, $file can take a local file instead of HTTP file upload variable. All uploaded files will included on the Images panel. return: array|string An array of array(message, id) on success, localized error string on error param: array $file HTTP file upload variables param: array $meta Image meta data, allowed keys 'caption', 'alt', 'category' param: int $id Existing image's ID param: bool $uploaded If FALSE, $file takes a filename instead of upload vars |
imageFetchInfo($where) line: 948 |
Gets an image as an array. return: array|bool An image data, or FALSE on failure param: string $where SQL where clause |
image_format_info($image) line: 972 |
Formats image info. Takes an image data array generated by imageFetchInfo() and formats the contents. return: array param: array $image The image |
link_format_info($link) line: 993 |
Formats link info. return: array Formatted link data param: array $link The link to format |
gps($thing) line: 1011 |
Gets a HTTP GET or POST parameter. Internally handles and normalises MAGIC_QUOTES_GPC, strips CRLF from GET parameters and removes NULL bytes. return: string|array The value of $thing, or an empty string param: string $thing The parameter to get |
gpsa($array) line: 1052 |
Gets an array of HTTP GET or POST parameters. return: array param: array $array The parameters to extract |
ps($thing) line: 1081 |
Gets a HTTP POST parameter. Internally handles and normalises MAGIC_QUOTES_GPC, and removes NULL bytes. return: string|array The value of $thing, or an empty string param: string $thing The parameter to get |
psa($array) line: 1113 |
Gets an array of HTTP POST parameters. return: array param: array $array The parameters to extract |
psas($array) line: 1136 |
Gets an array of HTTP POST parameters and strips HTML and PHP tags from values. return: array param: array $array The parameters to extract |
stripPost() line: 1154 |
Gets all received HTTP POST parameters. return: array |
serverSet($thing) line: 1174 |
Gets a variable from $_SERVER global array. return: mixed The variable, or an empty string on error param: mixed $thing The variable |
remote_addr() line: 1189 |
Gets the client's IP address. Supports proxies and uses 'X_FORWARDED_FOR' HTTP header if deemed necessary. return: string |
pcs($thing) line: 1215 |
Gets a variable from HTTP POST or a prefixed cookie. Fetches either a HTTP cookie of the given name prefixed with 'txp_', or a HTTP POST parameter without a prefix. return: array|string The variable or an empty string param: string $thing The variable |
cs($thing) line: 1250 |
Gets a HTTP cookie. Internally normalises MAGIC_QUOTES_GPC. return: string The cookie or an empty string param: string $thing The cookie |
yes_no($status) line: 1278 |
Converts a boolean to a localised "Yes" or "No" string. return: string No if FALSE, Yes otherwise param: bool $status The boolean. Ignores type and as such can also take a string or an integer |
getmicrotime() line: 1293 |
Gets UNIX timestamp with microseconds. return: float |
load_plugin($name, $force = false) line: 1309 |
Loads the given plugin or checks if it was loaded. return: bool TRUE if the plugin is loaded param: string $name The plugin param: bool $force If TRUE loads the plugin even if it's disabled |
require_plugin($name) line: 1378 |
Loads a plugin. Identical to load_plugin() except upon failure it issues an E_USER_ERROR. return: bool param: string $name The plugin |
include_plugin($name) line: 1399 |
Loads a plugin. Identical to load_plugin() except upon failure it issues an E_USER_WARNING. return: bool param: string $name The plugin |
pluginErrorHandler($errno, $errstr, $errfile, $errline) line: 1420 |
Error handler for plugins. param: int $errno param: string $errstr param: string $errfile param: int $errline |
tagErrorHandler($errno, $errstr, $errfile, $errline) line: 1471 |
Error handler for page templates. param: int $errno param: string $errstr param: string $errfile param: int $errline |
feedErrorHandler($errno, $errstr, $errfile, $errline) line: 1539 |
Error handler for XML feeds. param: int $errno param: string $errstr param: string $errfile param: int $errline |
adminErrorHandler($errno, $errstr, $errfile, $errline) line: 1561 |
Error handler for admin-side pages. param: int $errno param: string $errstr param: string $errfile param: int $errline |
updateErrorHandler($errno, $errstr, $errfile, $errline) line: 1658 |
Error handler for update scripts. param: int $errno param: string $errstr param: string $errfile param: int $errline |
publicErrorHandler($errno, $errstr, $errfile, $errline) line: 1683 |
Error handler for public-side. param: int $errno param: string $errstr param: string $errfile param: int $errline |
load_plugins($type = false) line: 1732 |
Loads plugins. param: bool $type If TRUE loads admin-side plugins, otherwise public |
register_callback($func, $event, $step = '', $pre = 0) line: 1797 |
Attachs a handler to a callback event. param: callback $func The callback function param: string $event The callback event param: string $step The callback step param: bool $pre Before or after. Works only with selected callback events |
register_page_extension($func, $event, $step = '', $top = 0) line: 1824 |
Registers an admin-side extension page. For now this just does the same as register_callback(). param: callback $func The callback function param: string $event The callback event param: string $step The callback step param: bool $top The top or the bottom of the page |
callback_event($event, $step = '', $pre = 0) line: 1843 |
Call an event's callback. Executes all callback handlers attached to the matched event and step. When called, any event handlers attached with register_callback() to the matching event, step and pre will be called. The handlers, callback functions, will be executed in the same order they were registered. Any extra arguments will be passed to the callback handlers in the same argument position. This allows passing any type of data to the attached handlers. Callback handlers will also receive the event and the step. Returns a combined value of all values returned by the callback handlers. return: mixed The value returned by the attached callback functions, or an empty string param: string $event The callback event param: string $step Additional callback step param: bool|int|array $pre Allows two callbacks, a prepending and an appending, with same event and step. Array allows return values chaining |
callback_event_ref($event, $step = '', $pre = 0, &$data = null, &$options = null) line: 1930 |
Call an event's callback with two optional byref parameters. return: array Collection of return values from event handlers param: string $event The callback event param: string $step Optional callback step param: bool $pre Allows two callbacks, a prepending and an appending, with same event and step param: mixed $data Optional arguments for event handlers param: mixed $options Optional arguments for event handlers |
callback_tostring($callback) line: 1970 |
Converts a callable to a string presentation. <code> echo callback_tostring(array('class', 'method')); </code> return: string The $callback as a human-readable string param: callback $callback The callback |
has_handler($event, $step = '', $pre = 0) line: 1990 |
Checks if a callback event has active handlers. return: bool TRUE if the event is active, FALSE otherwise param: string $event The callback event param: string $step The callback step param: bool $pre The position |
callback_handlers($event, $step = '', $pre = 0, $as_string = true) line: 2011 |
Lists handlers attached to an event. return: array|bool An array of handlers, or FALSE param: string $event The callback event param: string $step The callback step param: bool $pre The position param: bool $as_string Return callables in string representation |
register_tab($area, $panel, $title) line: 2051 |
Registers a new admin-side panel and adds a navigation link to the menu. param: string $area The menu the panel appears in, e.g. "home", "content", "presentation", "admin", "extensions" param: string $panel The panel's event param: string $title The menu item's label |
pluggable_ui($event, $element, $default = '') line: 2073 |
Call an event's pluggable UI function. return: mixed Returned value from a callback handler, or $default if no custom UI was provided param: string $event The event param: string $element The element selector param: string $default The default interface markup |
getAtt($name, $default = null) line: 2096 |
Gets an attribute from the $theatts global. return: string param: string $name param: string $default |
gAtt(&$atts, $name, $default = null) line: 2115 |
Gets an attribute from the given array. return: string param: array $atts param: string $name param: string $default |
lAtts($pairs, $atts, $warn = true) line: 2134 |
Merge the second array into the first array. return: array The two arrays merged param: array $pairs The first array param: array $atts The second array param: bool $warn If TRUE triggers errors if second array contains values that are not in the first |
select_buttons() line: 2159 |
Generates All, None and Range selection buttons. return: string HTML |
stripSpace($text, $force = false) line: 2177 |
Sanitises a string for use in an article's URL title. return: string|null param: string $text The title or an URL param: bool $force Force sanitisation |
sanitizeForUrl($text) line: 2199 |
Sanitises a string for use in a URL. Be aware that you still have to urlencode the string when appropriate. This function just makes the string look prettier and excludes some unwanted characters, but leaves UTF-8 letters and digits intact. return: string param: string $text The string |
sanitizeForFile($text) line: 2230 |
Sanitises a string for use in a filename. return: string param: string $text The string |
sanitizeForPage($text) line: 2254 |
Sanitises a string for use in a page template's name. return: string param: string $text The string |
dumbDown($str, $lang = LANG) line: 2274 |
Transliterates a string to ASCII. Used to generate RFC 3986 compliant and pretty ASCII-only URLs. param: string $str The string to convert param: string $lang The language which translation table is used |
clean_url($url) line: 2399 |
Cleans a URL. return: string param: string $url The URL |
noWidow($str) line: 2413 |
Replace the last space with a   non-breaking space. return: string param: string $str The string |
is_blacklisted($ip, $checks = '') line: 2429 |
Checks if an IP is on a spam blacklist. return: string|bool The lists the IP is on or FALSE param: string $ip The IP address param: string|array $checks The checked lists. Defaults to 'spam_blacklists' preferences string |
is_logged_in($user = '') line: 2471 |
Checks if the user is authenticated on the public-side. return: array|bool An array containing details about the user; name, RealName, email, privs. FALSE when the user hasn't authenticated. param: string $user The checked username. If not provided, any user is accepted |
updateSitePath($here) line: 2503 |
Updates the path to the site. param: string $here The path |
splat($text) line: 2516 |
Converts Textpattern tag's attribute list to an array. return: array Array of attributes param: string $text The attribute list, e.g. foobar="1" barfoo="0" |
strip_rn($str) line: 2586 |
Replaces CR and LF with spaces, and drops NULL bytes. Used for sanitising email headers. return: string param: string $str The string |
is_valid_email($address) line: 2603 |
Validates a string as an email address. <code> if (is_valid_email('john.doe@example.com')) { echo "'john.doe@example.com' validates."; } </code> return: bool param: string $address The email address |
txpMail($to_address, $subject, $body, $reply_to = null) line: 2625 |
Sends an email message as the currently logged in user. <code> if (txpMail('john.doe@example.com', 'Subject', 'Some message')) { echo "Email sent to 'john.doe@example.com'."; } </code> return: bool Returns FALSE when sending failed param: string $to_address The receiver param: string $subject The subject param: string $body The message param: string $reply_to The reply to address |
encode_mailheader($string, $type) line: 2694 |
Encodes a string for use in an email header. return: string param: string $string The string param: string $type The type of header, either "text" or "phrase" |
eE($txt) line: 2714 |
Converts an email address into unicode entities. return: string Encoded email address param: string $txt The email address |
stripPHP($in) line: 2729 |
Strips PHP tags from a string. return: string param: string $in The input |
event_category_popup($name, $cat = '', $id = '') line: 2741 |
Gets a HTML select field containing all categories, or sub-categories. return: string|bool HTML select field or FALSE on error param: string $name Return specified parent category's sub-categories param: string $cat The selected category option param: string $id The HTML ID |
create_form($name, $type, $Form) line: 2762 |
Creates a form template. On a successful run, will trigger a 'form.create > done' callback event. return: bool FALSE on error param: string $name The name param: string $type The type param: string $Form The template |
form_exists($name) line: 2799 |
Checks if a form template exists. return: bool TRUE if the form exists param: string $name The form |
is_valid_form($name) line: 2813 |
Validates a string as a form template name. return: bool TRUE if the string validates param: string $name The form name |
get_form_types() line: 2833 |
Gets a list of form types. The list form types can be extended with a 'form.types > types' callback event. Callback functions get passed three arguments: '$event', '$step' and '$types'. The third parameter contains a reference to an array of 'type => label' pairs. return: array An array of form types |
get_essential_forms() line: 2867 |
Gets a list of essential form templates. These forms can not be deleted or renamed. The list forms can be extended with a 'form.essential > forms' callback event. Callback functions get passed three arguments: '$event', '$step' and '$essential'. The third parameter contains a reference to an array of forms. return: array An array of form names |
event_change_pageby($name = null) line: 2902 |
Updates a list's per page number. Gets the per page number from a "qty" HTTP POST/GET parameter and creates a user-specific preference value "$name_list_pageby". param: string|null $name The name of the list |
event_multiedit_form($name, $methods = null, $page, $sort, $dir, $crit, $search_method) line: 2927 |
Generates a multi-edit widget. param: string $name param: array $methods param: int $page param: string $sort param: string $dir param: string $crit param: string $search_method |
event_multi_edit($table, $id_key) line: 2962 |
Generic multi-edit form's edit handler shared across panels. Receives an action from a multi-edit form and runs it in the given database table. return: string Comma-separated list of affected items param: string $table The database table param: string $id_key The database column selected items match to. Column should be integer type |
since($stamp) line: 2996 |
Gets a "since days ago" date format from a given UNIX timestamp. return: string "n days ago" param: int $stamp UNIX timestamp |
tz_offset($timestamp = null) line: 3022 |
Calculates a timezone offset. Calculates the offset between the server local time and the user's selected timezone at a given point in time. return: int The offset in seconds param: int $timestamp The timestamp. Defaults to time() |
safe_strftime($format, $time = '', $gmt = false, $override_locale = '') line: 3076 |
Formats a time. Respects the locale and local timezone, and makes sure the output string is encoded in UTF-8. return: string Formatted date param: string $format The date format param: int $time UNIX timestamp. Defaults to time() param: bool $gmt Return GMT time param: string $override_locale Override the locale |
safe_strtotime($time_str) line: 3160 |
Converts a time string from the Textpattern timezone to GMT. return: int UNIX timestamp param: string $time_str The time string |
myErrorHandler($errno, $errstr, $errfile, $errline) line: 3177 |
Generic error handler. param: int $errno param: string $errstr param: string $errfile param: int $errline |
find_temp_dir() line: 3236 |
Verifies temporary directory. Verifies that the temporary directory is writeable. return: bool|null NULL on error, TRUE on success param: string $dir The directory to check |
get_uploaded_file($f, $dest = '') line: 3291 |
Moves an uploaded file and returns its new location. return: string|bool The new path or FALSE on error param: string $f The filename of the uploaded file param: string $dest The destination of the moved file. If omitted, the file is moved to the temp directory |
get_filenames() line: 3323 |
Gets an array of files in the Files directory that weren't uploaded from Textpattern. Used for importing existing files on the server to Textpattern's files panel. return: array An array of file paths |
make_download_link($id, $label = '', $filename = '') line: 3378 |
Renders a download link. return: string HTML param: int $id The file ID param: string $label The label param: string $filename The filename |
set_error_level($level) line: 3402 |
Sets error reporting level. param: string $level The level. Either "debug", "live" or "testing" |
shift_uploaded_file($f, $dest) line: 3424 |
Moves a file. return: bool TRUE on success, or FALSE on error param: string $f The file to move param: string $dest The destination |
upload_get_errormsg($err_code) line: 3448 |
Translates upload error code to a localised error message. return: string The $err_code as a message param: int $err_code The error code |
format_filesize($bytes, $decimals = 2, $format = '') line: 3498 |
Formats a file size. return: string Formatted file size param: int $bytes Size in bytes param: int $decimals Number of decimals param: string $format The format the size is represented |
fileDownloadFetchInfo($where) line: 3530 |
Gets a file download as an array. return: array|bool An array of files, or FALSE on failure param: string $where SQL where clause |
file_download_format_info($file) line: 3554 |
Formats file download info. Takes a data array generated by fileDownloadFetchInfo() and formats the contents. return: array Formatted file info param: array $file The file info to format |
fileDownloadFormatTime($params) line: 3579 |
Formats file download's modification and creation timestamps. Used by file_download tags. return: string param: array $params |
is_windows() line: 3608 |
Checks if the system is Windows. Exists for backwards compatibility. return: bool |
is_cgi() line: 3624 |
Checks if PHP is run as CGI. Exists for backwards compatibility. return: bool |
is_mod_php() line: 3640 |
Checks if PHP is run as Apache module. Exists for backwards compatibility. return: bool |
is_disabled($function) line: 3656 |
Checks if a function is disabled. return: bool TRUE if the function is disabled param: string $function The function name |
build_file_path($base, $path) line: 3680 |
Joins two strings to form a single filesystem path. return: string A path to a file param: string $base The base directory param: string $path The second path, a relative filename |
get_author_name($name) line: 3697 |
Gets a user's real name. return: string A real name, or username if empty param: string $name The username |
get_author_email($name) line: 3719 |
Gets a user's email address. return: string param: string $name The username |
has_single_author($table, $col = 'author') line: 3741 |
Checks if a database table contains items just from one user. return: bool param: string $table The database table param: string $col The column |
is_valid_username($name) line: 3767 |
Validates a string as a username. return: bool TRUE if the string valid param: string $name The username |
assign_user_assets($owner, $new_owner) line: 3792 |
Assigns assets to a different user. Changes the owner of user's assets. It will move articles, files, images and links from one user to another. Should be run when a user's permissions are taken away, a username is renamed or the user is removed from the site. Affected database tables can be extended with a 'user.assign_assets > columns' callback event. Callback functions get passed three arguments: '$event', '$step' and '$columns'. The third parameter contains a reference to an array of 'table => column' pairs. On a successful run, will trigger a 'user.assign_assets > done' callback event. return: bool FALSE on error param: string|array $owner List of current owners param: string $new_owner The new owner |
new_user_prefs($user_name) line: 3853 |
Return private preferences required to be set for the given (new) user. The returned structure comprises a nested array. Each row is an array, with key being the pref event, and array made up of: -> pref type -> position -> html control -> name (gTxt) -> value -> user name param: string $user_name The user name against which to assign the prefs |
create_user($name, $email, $password, $realname = '', $group = 0) line: 3879 |
Creates a user account. On a successful run, will trigger a 'user.create > done' callback event. return: bool FALSE on error param: string $name The login name param: string $email The email address param: string $password The password param: string $realname The real name param: int $group The user group |
update_user($user, $email = null, $realname = null, $meta = array() line: 3937 |
Updates a user. Updates a user account's properties. The $user argument is used for selecting the updated user, and rest of the arguments new values. Use NULL to omit an argument. On a successful run, will trigger a 'user.update > done' callback event. return: bool FALSE on error param: string $user The updated user param: string|null $email The email address param: string|null $realname The real name param: array|null $meta Additional meta fields |
change_user_password($user, $password) line: 3992 |
Changes a user's password. On a successful run, will trigger a 'user.password_change > done' callback event. return: bool FALSE on error param: string $user The updated user param: string $password The new password |
remove_user($user, $new_owner) line: 4032 |
Removes a user. The user's assets are assigned to the given new owner. On a successful run, will trigger a 'user.remove > done' callback event. return: bool FALSE on error param: string|array $user List of removed users param: string $new_owner Assign assets to |
rename_user($user, $newname) line: 4076 |
Renames a user. On a successful run, will trigger a 'user.rename > done' callback event. return: bool FALSE on error param: string $user Updated user param: string $newname The new name |
user_exists($user) line: 4118 |
Checks if a user exists. return: bool TRUE if the user exists param: string $user The user |
change_user_group($user, $group) line: 4137 |
Changes a user's group. On a successful run, will trigger a 'user.change_group > done' callback event. return: bool FALSE on error param: string|array $user Updated users param: int $group The new group |
txp_validate($user, $password, $log = true) line: 4179 |
Validates the given user credentials. Validates a given login and a password combination. If the combination is correct, the user's login name is returned, FALSE otherwise. If $log is TRUE, also checks that the user has permissions to access the admin side interface. On success, updates the user's last access timestamp. return: string|bool The user's login name or FALSE on error param: string $user The login param: string $password The password param: bool $log If TRUE, requires privilege level greater than 'none' |
txp_hash_password($password) line: 4236 |
Calculates a password hash. return: string A hash param: string $password The password |
generate_user_token($ref, $type, $expiryTimestamp, $pass, $nonce) line: 4258 |
Create a secure token hash in the database from the passed information. return: string Secure token suitable for emailing as part of a link param: int $ref Reference to the user's account (user_id) param: string $type Flavour of token to create param: int $expiryTimestamp UNIX timestamp of when the token will expire param: string $pass Password, used as part of the token generation param: string $nonce Random nonce associated with the user's account |
EvalElse($thing, $condition) line: 4303 |
Extracts a statement from a if/else condition. return: string Either if or else statement param: string $thing Statement in Textpattern tag markup presentation param: bool $condition TRUE to return if statement, FALSE to else |
fetch_form($name) line: 4343 |
Gets a form template's contents. The form template's reading method can be modified by registering a handler to a 'form.fetch' callback event. Any value returned by the callback function will be used as the form template markup. return: string param: string $name The form |
parse_form($name) line: 4386 |
Parses a form template. return: string The parsed contents param: string $name The form |
fetch_page($name) line: 4423 |
Gets a page template's contents. The page template's reading method can be modified by registering a handler to a 'page.fetch' callback event. Any value returned by the callback function will be used as the template markup. return: string|bool The page template, or FALSE on error param: string $name The template |
parse_page($name) line: 4457 |
Parses a page template. return: string|bool The parsed page template, or FALSE on error param: string $name The template |
fetch_category_title($name, $type = 'article') line: 4485 |
Gets a category's title. return: string|bool The title or FALSE on error param: string $name The category param: string $type Category's type. Either "article", "file", "image" or "link" |
fetch_section_title($name) line: 4514 |
Gets a section's title. return: string|bool The title or FALSE on error param: string $name The section |
update_comments_count($id) line: 4548 |
Updates an article's comment count. return: bool param: int $id The article |
clean_comment_counts($parentids) line: 4566 |
Recalculates and updates comment counts. param: array $parentids List of articles to update |
markup_comment($msg) line: 4597 |
Parses and formats comment message using Textile. return: string HTML markup param: string $msg The comment message |
update_lastmod($trigger = '', $rs = array() line: 4612 |
Updates site's last modification date. When this action is performed, it will trigger a 'site.update > {event}' callback event and pass any record set that triggered the update, along with the exact time the update was triggered. param: $trigger Textpattern event or step that triggered the update param: $rs Record set data at the time of update |
get_lastmod($unix_ts = null) line: 4636 |
Gets the site's last modification date. return: int UNIX timestamp param: int $unix_ts UNIX timestamp |
handle_lastmod($unix_ts = null, $exit = true) line: 4658 |
Sends and handles a lastmod header. return: array|null Array of sent HTTP status and the lastmod header, or NULL param: int|null $unix_ts The last modification date as a UNIX timestamp param: bool $exit If TRUE, terminates the script |
get_prefs($user = '') line: 4706 |
Gets preferences as an array. Returns preference values from the database as an array. Shouldn't be used to retrieve selected preferences, see get_pref() instead. By default only the global preferences are returned. If the optional user name parameter is supplied, the private preferences for that user are returned. return: array param: string $user User name. |
set_pref($name, $val, $event = 'publish', $type = PREF_CORE, $html = 'text_input', $position = 0, $is_private = PREF_GLOBAL) line: 4737 |
Creates or updates a preference. return: bool FALSE on error param: string $name The name param: string $val The value param: string $event The section the preference appears in param: int $type Either PREF_CORE, PREF_PLUGIN, PREF_HIDDEN param: string $html The HTML control type the field uses. Can take a custom function name param: int $position Used to sort the field on the Preferences panel param: bool $is_private If PREF_PRIVATE, is created as a user pref |
get_pref($thing, $default = '', $from_db = false) line: 4771 |
Gets a preference string. Prefers global system-wide preferences over a user's private preferences. return: string Preference value or $default param: string $thing The named variable param: mixed $default Used as a replacement if named pref isn't found param: bool $from_db If TRUE checks database opposed $prefs variable in memory |
remove_pref($name = null, $event = null, $user_name = null) line: 4814 |
Removes a preference string. Removes preference strings based on the given arguments. Use NULL to omit an argument. return: bool TRUE on success param: string|null $name The preference string name param: string|null $event The preference event param: string|null|bool $user_name The owner. If PREF_PRIVATE, the current user |
pref_exists($name, $user_name = null) line: 4865 |
Checks if a preference string exists. Searches for matching preference strings based on the given arguments. The $user_name argument can be used to limit the search to a specifc user, or to global and private strings. If NULL, matches are searched from both private and global strings. return: bool TRUE if the string exists, or FALSE on error param: string $name The preference string name param: string|null|bool $user_name Either the username, NULL, PREF_PRIVATE or PREF_GLOBAL |
create_pref($name, $val, $event = 'publish', $type = PREF_CORE, $html = 'text_input', $position = 0, $user_name = PREF_GLOBAL) line: 4912 |
Creates a preference string. When a string is created, will trigger a 'preference.create > done' callback event. return: bool TRUE if the string exists, FALSE on error param: string $name The name param: string $val The value param: string $event The section the preference appears in param: int $type Either PREF_CORE, PREF_PLUGIN, PREF_HIDDEN param: string $html The HTML control type the field uses. Can take a custom function name param: int $position Used to sort the field on the Preferences panel param: string|bool $user_name The user name, PREF_GLOBAL or PREF_PRIVATE |
update_pref($name, $val = null, $event = null, $type = null, $html = null, $position = null, $user_name = PREF_GLOBAL) line: 4971 |
Updates a preference string. Updates a preference string's properties. The $name and $user_name arguments are used for selecting the updated string, and rest of the arguments take the new values. Use NULL to omit an argument. When a string is updated, will trigger a 'preference.update > done' callback event. return: bool FALSE on error param: string $name The update preference string's name param: string|null $val The value param: string|null $event The section the preference appears in param: int|null $type Either PREF_CORE, PREF_PLUGIN, PREF_HIDDEN param: string|null $html The HTML control type the field uses. Can take a custom function name param: int|null $position Used to sort the field on the Preferences panel param: string|bool|null $user_name The updated string's owner, PREF_GLOBAL or PREF_PRIVATE |
rename_pref($newname, $name, $user_name = null) line: 5031 |
Renames a preference string. When a string is renamed, will trigger a 'preference.rename > done' callback event. return: bool FALSE on error param: string $newname The new name param: string $name The current name param: string $user_name Either the username, PREF_GLOBAL or PREF_PRIVATE |
getCustomFields() line: 5077 |
Gets a list of custom fields. return: array |
buildCustomSql($custom, $pairs) line: 5106 |
Build a query qualifier to filter non-matching custom fields from the result set. return: bool|string An SQL qualifier for a query's 'WHERE' part param: array $custom An array of 'custom_field_name' => field_number tupels param: array $pairs Filter criteria: An array of 'name' => value tupels |
txp_status_header($status = '200 OK') line: 5132 |
Sends a HTTP status header. param: string $status The HTTP status code |
txp_die($msg, $status = '503', $url = '') line: 5152 |
Terminates normal page rendition and outputs an error page. param: string|array $msg The error message param: string $status HTTP status code param: string $url Redirects to the specified URL. Can be used with $status of 301, 302 and 307 |
join_qs($q) line: 5251 |
Gets a URL-encoded and HTML entity-escaped query string for a URL. Builds a HTTP query string from an associative array. return: string The query, including starting "?". param: array $q The parameters for the query |
join_atts($atts, $flags = TEXTPATTERN_STRIP_EMPTY_STRING) line: 5282 |
Builds a HTML attribute list from an array. Takes an array of raw HTML attributes, and returns a properly sanitised HTML attribute string for use in a HTML tag. Internally handles HTML boolean attributes, array lists and query strings. If an attributes value is set as a boolean, the attribute is considered as one too. If a value is NULL, it's omitted and the attribute is added without a value. An array value is converted to a space-separated list, or for 'href' and 'src' to a URL encoded query string. return: string HTML attribute list param: array|string $atts HTML attributes param: int $flags TEXTPATTERN_STRIP_EMPTY_STRING |
pagelinkurl($parts, $inherit = array() line: 5335 |
Builds a page URL from an array of parameters. The $inherit can be used to add parameters to an existing url, e.g: pagelinkurl(array('pg' => 2), $pretext). Cannot be used to link to an article. See permlinkurl() and permlinkurl_id() instead. return: string param: array $parts The parts used to construct the URL param: array $inherit Can be used to add parameters to an existing url |
permlinkurl_id($id) line: 5423 |
Gets a URL for the given article. If you need to generate a list of article URLs from already fetched table rows, consider using permlinkurl() over this due to performance benefits. return: string The URL param: int $id The article ID |
permlinkurl($article_array) line: 5456 |
Generates an article URL from the given data array. return: string The URL param: array $article_array An array consisting of keys 'thisid', 'section', 'title', 'url_title', 'posted', 'expires' |
filedownloadurl($id, $filename = '') line: 5556 |
Gets a file download URL. return: string param: int $id The ID param: string $filename The filename |
imagesrcurl($id, $ext, $thumbnail = false) line: 5589 |
Gets an image's absolute URL. return: string param: int $id The image param: string $ext The file extension param: bool $thumbnail If TRUE returns a URL to the thumbnail |
in_list($val, $list, $delim = ',') line: 5607 |
Checks if a value exists in a list. return: bool Returns TRUE if $val is found, FALSE otherwise param: string $val The searched value param: string $list The value list param: string $delim The list boundary |
do_list($list, $delim = ',') line: 5628 |
Split a string by string. Trims the created values of whitespace. return: array param: string $list The string param: string $delim The boundary |
do_list_unique($list, $delim = ',', $flags = TEXTPATTERN_STRIP_EMPTY_STRING) line: 5647 |
Split a string by string, returning only unique results. Trims unique values of whitespace. Flags permit exclusion of empty strings. return: array param: string $list The string param: string $delim The boundary param: int $flags TEXTPATTERN_STRIP_NONE | TEXTPATTERN_STRIP_EMPTY | TEXTPATTERN_STRIP_EMPTY_STRING |
doQuote($val) line: 5677 |
Wraps a string in single quotes. return: string param: string $val The input string |
quote_list($in) line: 5689 |
Escapes special characters for use in an SQL statement and wraps the value in quote. Useful for creating an array of values for use in an SQL statement. return: mixed param: string|array $in The input value |
trace_add($msg, $level = 0, $dummy = null) line: 5712 |
Adds a line to the tag trace. param: string $msg The message param: int $tracelevel_diff Change trace level |
article_push() line: 5740 |
Push current article on the end of data stack. Populates $stack_article global with the current $thisarticle. |
article_pop() line: 5752 |
Advance to the next article in the current data stack. Populates $thisarticle global with the last article from the stack stored in $stack_article. |
relative_path($path, $pfx = null) line: 5765 |
Gets a path relative to the site's root directory. return: string The absolute $path converted to relative param: string $path The filename to parse param: string $pfx The root directory |
get_caller($num = 1, $start = 2) line: 5783 |
Gets a backtrace. return: array A backtrace param: int $num The limit param: int $start The offset |
getlocale($lang) line: 5838 |
Sets a locale. The function name is misleading but remains for legacy reasons. return: string Current locale param: string $lang |
getMetaDescription($type = null) line: 5862 |
Fetch meta description from the given (or automatic) context. Category context may be refined by specifying the content type as well after a dot. e.g. category.image to check image context category. param: string $type Flavour of meta content to fetch (section, category, article) |
assert_article() line: 5917 |
Assert article context error. |
assert_comment() line: 5930 |
Assert comment context error. |
assert_file() line: 5943 |
Assert file context error. |
assert_image() line: 5956 |
Assert image context error. |
assert_link() line: 5969 |
Assert link context error. |
assert_section() line: 5982 |
Assert section context error. |
assert_category() line: 5995 |
Assert category context error. |
assert_int($myvar) line: 6008 |
Validate a variable as an integer. return: int|bool The variable or FALSE on error param: mixed $myvar The variable |
assert_string($myvar) line: 6026 |
Validate a variable as a string. return: string|bool The variable or FALSE on error param: mixed $myvar The variable |
assert_array($myvar) line: 6044 |
Validate a variable as an array. return: array|bool The variable or FALSE on error param: mixed $myvar The variable |
replace_relative_urls($html, $permalink = '') line: 6062 |
Converts relative links in HTML markup to absolute. return: string HTML param: string $html The HTML to check param: string $permalink Optional URL part appended to the links |
show_clean_test($pretext) line: 6093 |
Used for clean URL test. param: array $pretext |
pager($total, $limit, $page) line: 6111 |
Calculates paging. Takes a total number of items, a per page limit and the current page number, and in return returns the page number, an offset and a number of pages. return: array Array of page, offset and number of pages. param: int $total The number of items in total param: int $limit The number of items per page param: int $page The page number |
soft_wrap($text, $width, $break = '&) line: 6141 |
Word-wrap a string using a zero width space. return: string param: string $text The input string param: int $width Target line lenght param: string $break Is not used |
strip_prefix($str, $pfx) line: 6175 |
Removes prefix from a string. return: string param: string $str The string param: string $pfx The prefix |
send_xml_response($response = array() line: 6188 |
Sends an XML envelope. Wraps an array of name => value tupels into an XML envelope, supports one level of nested arrays at most. return: string XML envelope param: array $response |
send_script_response($out = '') line: 6242 |
Sends a text/javascript response. param: string $out The JavaScript |
send_json_response($out = '') line: 6264 |
Sends an application/json response. If the provided $out is not a string, its encoded as JSON. Any string is treated as it were valid JSON. param: mixed $out The JSON |
modal_halt($thing) line: 6293 |
Display a modal client message in response to an AJAX request and halt execution. param: string|array $thing The $thing[0] is the message's text; $thing[1] is the message's type (one of E_ERROR or E_WARNING, anything else meaning "success"; not used) |
announce($message, $type = 0, $flags = TEXTPATTERN_ANNOUNCE_ADAPTIVE) line: 6312 |
Sends an activity message to the client. param: string|array $message The message param: int $type The type, either 0, E_ERROR, E_WARNING param: int $flags Flags, consisting of TEXTPATTERN_ANNOUNCE_ADAPTIVE | TEXTPATTERN_ANNOUNCE_ASYNC | TEXTPATTERN_ANNOUNCE_MODAL | TEXTPATTERN_ANNOUNCE_REGULAR |
janitor() line: 6343 |
Performs regular housekeeping. |
title