/includes/functions.php

Description
  • version: $Id: functions.php,v 1.645 2007/11/18 15:37:17 naderman Exp $
  • copyright: (c) 2005 phpBB Group
  • license: GNU Public License
Functions
add_form_key (line 2022)

Add a secret token to the form (requires the S_FORM_TOKEN template variable)

void add_form_key (string $form_name)
  • string $form_name: The name of the form; has to match the name used in check_form_key, otherwise no restrictions apply
add_log (line 2614)

Add log event

void add_log ()
append_sid (line 1633)

Append session id to url.

This function supports hooks.

void append_sid (string $url, [mixed $params = false], [bool $is_amp = true], [string $session_id = false])
  • string $url: The url the session id needs to be appended to (can have params)
  • mixed $params: String or array of additional url parameters
  • bool $is_amp: Is url using & (true) or & (false)
  • string $session_id:

    Possibility to use a custom session id instead of the global one

    Examples:

    1.  append_sid("{$phpbb_root_path}viewtopic.$phpEx?t=1&f=2");
    2.  append_sid("{$phpbb_root_path}viewtopic.$phpEx"'t=1&f=2');
    3.  append_sid("{$phpbb_root_path}viewtopic.$phpEx"'t=1&f=2'false);
    4.  append_sid("{$phpbb_root_path}viewtopic.$phpEx"array('t' => 1'f' => 2));

array_combine (line 450)

A wrapper for the PHP5 function array_combine()

  • return: an array by using the values from the keys array as keys and the values from the values array as the corresponding values. Returns false if the number of elements for each array isn't equal or if the arrays are empty.
Returns array_combine (array $keys, array $values)
  • array $keys: contains keys for the resulting array
  • array $values: contains values for the resulting array
build_hidden_fields (line 2548)

Build simple hidden fields from array

  • return: the hidden fields
string build_hidden_fields (array $field_ary, [bool $specialchar = false], [bool $stripslashes = false])
  • array $field_ary: an array of values to build the hidden field from
  • bool $specialchar: if true, keys and values get specialchared
  • bool $stripslashes: if true, keys and values get stripslashed
build_url (line 1943)

Returns url from the session/current page with an re-appended SID with optionally stripping vars from the url

void build_url ([ $strip_vars = false])
  • $strip_vars
check_form_key (line 2046)

Check the form key. Required for all altering actions not secured by confirm_box

void check_form_key (string $form_name, [int $timespan = false], [string $return_page = ''], [bool $trigger = false], [int $minimum_time = false])
  • string $form_name: The name of the form; has to match the name used in add_form_key, otherwise no restrictions apply
  • int $timespan: The maximum acceptable age for a submitted form in seconds. Defaults to the config setting.
  • string $return_page: The address for the return link
  • bool $trigger: If true, the function will triger an error when encountering an invalid form
  • int $minimum_time: The minimum acceptable age for a submitted form in seconds
confirm_box (line 2098)

Build Confirm box

void confirm_box (boolean $check, [string $title = ''], [string $hidden = ''], [string $html_body = 'confirm_body.html'], [string $u_action = ''])
  • boolean $check: True for checking if confirmed (without any additional parameters) and false for displaying the confirm box
  • string $title: Title/Message used for confirm box. message text is _CONFIRM appended to title. If title cannot be found in user->lang a default one is displayed If title_CONFIRM cannot be found in user->lang the text given is used.
  • string $hidden: Hidden variables
  • string $html_body: Template used for confirm box
  • string $u_action: Custom form action
exit_handler (line 3517)

Handler for exit calls in phpBB.

This function supports hooks.

Note: This function is called after the template has been outputted.

void exit_handler ()
garbage_collection (line 3494)

Closing the cache object and the database

Cool function name, eh? We might want to add operations to it later

void garbage_collection ()
generate_board_url (line 1718)

Generate board url (example: http://www.example.com/phpBB)

void generate_board_url ([bool $without_script_path = false])
  • bool $without_script_path: if set to true the script path gets not appended (example: http://www.example.com)
generate_pagination (line 1514)

Pagination routine, generates page number sequence

tpl_prefix is for using different pagination blocks at one page

void generate_pagination ( $base_url,  $num_items,  $per_page,  $start_item, [ $add_prevnext_text = false], [ $tpl_prefix = ''])
  • $base_url
  • $num_items
  • $per_page
  • $start_item
  • $add_prevnext_text
  • $tpl_prefix
gen_rand_string (line 170)

Generates an alphanumeric random string of given length

void gen_rand_string ([ $num_chars = 8])
  • $num_chars
get_backtrace (line 2672)

Return a nicely formatted backtrace (parts from the php manual by diz at ysagoon dot com)

void get_backtrace ()
get_complete_topic_tracking (line 1154)

Get topic tracking info from db (for cookie based tracking only this function is used)

void get_complete_topic_tracking ( $forum_id,  $topic_ids, [ $global_announce_list = false])
  • $forum_id
  • $topic_ids
  • $global_announce_list
get_preg_expression (line 2735)

This function returns a regular expression pattern for commonly used expressions

Use with / as delimiter for email mode and # for url modes mode can be: email|bbcode_htm|url|url_inline|www_url|www_url_inline|relative_url|relative_url_inline|ipv4|ipv6

void get_preg_expression ( $mode)
  • $mode
get_topic_tracking (line 1074)

Get topic tracking info by using already fetched info

void get_topic_tracking ( $forum_id,  $topic_ids,  &$rowset,  $forum_mark_time, [ $global_announce_list = false])
  • $forum_id
  • $topic_ids
  • &$rowset
  • $forum_mark_time
  • $global_announce_list
is_absolute (line 534)

Checks if a path ($path) is absolute or relative

boolean is_absolute (string $path)
  • string $path: Path to check absoluteness of
language_select (line 733)

Pick a language, any language ...

void language_select ([ $default = ''])
  • $default
login_box (line 2201)

Generate login box or verify password

void login_box ([ $redirect = ''], [ $l_explain = ''], [ $l_success = ''], [ $admin = false], [ $s_display = true])
  • $redirect
  • $l_explain
  • $l_success
  • $admin
  • $s_display
login_forum_box (line 2435)

Generate forum login box

void login_forum_box ( $forum_data)
  • $forum_data
markread (line 815)

Marks a topic/forum as read Marks a topic as posted to

void markread ( $mode, [ $forum_id = false], [ $topic_id = false], [ $post_time = 0], [int $user_id = 0])
  • int $user_id: can only be used with $mode == 'post'
  • $mode
  • $forum_id
  • $topic_id
  • $post_time
meta_refresh (line 2004)

Meta refresh assignment

void meta_refresh ( $time,  $url)
  • $time
  • $url
msg_handler (line 2877)

Error and message handler, call with trigger_error if reqd

void msg_handler ( $errno,  $msg_text,  $errfile,  $errline)
  • $errno
  • $msg_text
  • $errfile
  • $errline
on_page (line 1597)

Return current page (pagination)

void on_page ( $num_items,  $per_page,  $start)
  • $num_items
  • $per_page
  • $start
page_footer (line 3402)

Generate page footer

void page_footer ([ $run_cron = true])
  • $run_cron
page_header (line 3069)

Generate page header

void page_header ([ $page_title = ''], [ $display_online_list = true])
  • $page_title
  • $display_online_list
parse_cfg_file (line 2566)

Parse cfg file

void parse_cfg_file ( $filename, [ $lines = false])
  • $filename
  • $lines
phpbb_checkdnsrr (line 2829)

Wrapper for php's checkdnsrr function.

The windows failover is from the php manual Please make sure to check the return value for === true and === false, since NULL could be returned too.

  • return: if entry found, false if not, NULL if this function is not supported by this environment
true phpbb_checkdnsrr ( $host, [ $type = ''])
  • $host
  • $type
phpbb_check_hash (line 304)

Check for correct password

void phpbb_check_hash ( $password,  $hash)
  • $password
  • $hash
phpbb_hash (line 265)
  • version:

    Version 0.1 / $Id: functions.php,v 1.645 2007/11/18 15:37:17 naderman Exp $

    Portable PHP password hashing framework.

    Written by Solar Designer <solar at openwall.com> in 2004-2006 and placed in the public domain.

    There's absolutely no warranty.

    The homepage URL for this framework is:

    http://www.openwall.com/phpass/

    Please be sure to update the Version line if you edit this file in any way. It is suggested that you leave the main version number intact, but indicate your project name (after the slash) and add your own revision information.

    Please do not change the "private" password hashing method implemented in here, thereby making your hashes incompatible. However, if you must, please change the hash type identifier (the "$P$") to something different.

    Obviously, since this code is in the public domain, the above are not requirements (there can be none), but merely suggestions.

    Hash the password

void phpbb_hash ( $password)
  • $password
phpbb_realpath (line 545)
mixed phpbb_realpath (string $path)
  • string $path: The path which we should attempt to resolve.
phpbb_user_session_handler (line 3536)

Handler for init calls in phpBB. This function is called in user::setup(); This function supports hooks.

void phpbb_user_session_handler ()
reapply_sid (line 1910)

Re-Apply session id after page reloads

void reapply_sid ( $url)
  • $url
redirect (line 1766)

Redirects the user to another page then exits the script nicely

void redirect ( $url, [ $return = false])
  • $url
  • $return
request_var (line 63)

request_var

Used to get passed variable

void request_var ( $var_name,  $default, [ $multibyte = false], [ $cookie = false])
  • $var_name
  • $default
  • $multibyte
  • $cookie
set_config (line 141)

Set config value. Creates missing config entry.

void set_config ( $config_name,  $config_value, [ $is_dynamic = false])
  • $config_name
  • $config_value
  • $is_dynamic
set_var (line 28)

set_var

Set variable, used by the request_var function

  • access: private
void set_var ( &$result,  $var,  $type, [ $multibyte = false])
  • &$result
  • $var
  • $type
  • $multibyte
short_ipv6 (line 2795)

Returns the first block of the specified IPv6 address and as many additional ones as specified in the length paramater.

If length is zero, then an empty string is returned. If length is greater than 3 the complete IP will be returned

void short_ipv6 ( $ip,  $length)
  • $ip
  • $length
still_on_time (line 207)

Determine whether we are approaching the maximum execution time. Should be called once at the beginning of the script in which it's used.

  • return: Either true if the maximum execution time is nearly reached, or false if some time is still left.
bool still_on_time ([ $extra_time = 15])
  • $extra_time
stripos (line 515)

A wrapper for the PHP5 function stripos Find position of first occurrence of a case-insensitive string

  • return: Returns the numeric position of the first occurrence of needle in the haystack string. Unlike strpos(), stripos() is case-insensitive. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return boolean FALSE.
mixed stripos (string $haystack, string $needle)
  • string $haystack: is the string to search in
  • string $needle: is the string to search for
str_split (line 484)

A wrapper for the PHP5 function str_split()

  • return: a string to an array. If the optional split_length parameter is specified, the returned array will be broken down into chunks with each being split_length in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string, the entire string is returned as the first (and only) array element.
Converts str_split (array $string, [array $split_length = 1])
  • array $string: contains the string to be converted
  • array $split_length: contains the length of each chunk
style_select (line 756)

Pick a template/theme combo,

void style_select ([ $default = ''], [ $all = false])
  • $default
  • $all
tracking_serialize (line 1390)

Transform an array into a serialized format

void tracking_serialize ( $input)
  • $input
tracking_unserialize (line 1410)

Transform a serialized array into an actual array

void tracking_unserialize ( $string, [ $max_depth = 3])
  • $string
  • $max_depth
tz_select (line 781)

Pick a timezone

void tz_select ([ $default = ''], [ $truncate = false])
  • $default
  • $truncate
unique_id (line 182)

Return unique id

void unique_id ([string $extra = 'c'])
  • string $extra: additional entropy
update_forum_tracking_info (line 1290)

Check for read forums and update topic tracking info accordingly

  • return: if complete forum got marked read, else false.
true update_forum_tracking_info (int $forum_id, int $forum_last_post_time, [int $f_mark_time = false], [int $mark_time_forum = false])
  • int $forum_id: the forum id to check
  • int $forum_last_post_time: the forums last post time
  • int $f_mark_time: the forums last mark time if user is registered and load_db_lastread enabled
  • int $mark_time_forum: false if the mark time needs to be obtained, else the last users forum mark time
_build_hidden_fields (line 2514)

Little helper for the build_hidden_fields function

void _build_hidden_fields ( $key,  $value,  $specialchar,  $stripslashes)
  • $key
  • $value
  • $specialchar
  • $stripslashes
_hash_crypt_private (line 379)

The crypt function/replacement

void _hash_crypt_private ( $password,  $setting,  &$itoa64)
  • $password
  • $setting
  • &$itoa64
_hash_encode64 (line 335)

Encode hash

void _hash_encode64 ( $input,  $count,  &$itoa64)
  • $input
  • $count
  • &$itoa64
_hash_gensalt_private (line 318)

Generate salt for hash generation

void _hash_gensalt_private ( $input,  &$itoa64, [ $iteration_count_log2 = 6])
  • $input
  • &$itoa64
  • $iteration_count_log2

Documentation generated on Wed, 28 Nov 2007 19:40:17 +0100 by phpDocumentor 1.4.0