[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/includes/ -> functions.php (summary)

(no description)

Copyright: (c) 2005 phpBB Group
License: http://opensource.org/licenses/gpl-license.php GNU Public License
Version: $Id$
File Size: 4943 lines (143 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 77 functions

  set_var()
  request_var()
  set_config()
  set_config_count()
  gen_rand_string()
  gen_rand_string_friendly()
  unique_id()
  phpbb_mt_rand()
  phpbb_gmgetdate()
  get_formatted_filesize()
  still_on_time()
  phpbb_hash()
  phpbb_check_hash()
  _hash_gensalt_private()
  _hash_encode64()
  _hash_crypt_private()
  phpbb_email_hash()
  phpbb_version_compare()
  phpbb_chmod()
  phpbb_is_writable()
  array_combine()
  str_split()
  stripos()
  is_absolute()
  phpbb_own_realpath()
  phpbb_realpath()
  phpbb_realpath()
  phpbb_clean_path()
  htmlspecialchars_decode()
  language_select()
  style_select()
  tz_select()
  markread()
  get_topic_tracking()
  get_complete_topic_tracking()
  get_unread_topics()
  update_forum_tracking_info()
  tracking_serialize()
  tracking_unserialize()
  generate_pagination()
  on_page()
  append_sid()
  generate_board_url()
  redirect()
  reapply_sid()
  build_url()
  meta_refresh()
  send_status_line()
  generate_link_hash()
  check_link_hash()
  add_form_key()
  check_form_key()
  confirm_box()
  login_box()
  login_forum_box()
  _build_hidden_fields()
  build_hidden_fields()
  parse_cfg_file()
  add_log()
  get_backtrace()
  get_preg_expression()
  get_censor_preg_expression()
  short_ipv6()
  phpbb_checkdnsrr()
  msg_handler()
  phpbb_filter_root_path()
  obtain_guest_count()
  obtain_users_online()
  obtain_users_online_string()
  phpbb_optionget()
  phpbb_optionset()
  phpbb_http_login()
  page_header()
  page_footer()
  garbage_collection()
  exit_handler()
  phpbb_user_session_handler()

Functions
Functions that are not part of a class:

set_var(&$result, $var, $type, $multibyte = false)   X-Ref
set_var

Set variable, used by {@link request_var the request_var function}


request_var($var_name, $default, $multibyte = false, $cookie = false)   X-Ref
request_var

Used to get passed variable

set_config($config_name, $config_value, $is_dynamic = false)   X-Ref
Sets a configuration option's value.

Please note that this function does not update the is_dynamic value for
an already existing config option.

param: string $config_name   The configuration option's name
param: string $config_value  New configuration value
param: bool   $is_dynamic    Whether this variable should be cached (false) or
return: null

set_config_count($config_name, $increment, $is_dynamic = false)   X-Ref
Increments an integer config value directly in the database.

param: string $config_name   The configuration option's name
param: int    $increment     Amount to increment by
param: bool   $is_dynamic    Whether this variable should be cached (false) or
return: null

gen_rand_string($num_chars = 8)   X-Ref
Generates an alphanumeric random string of given length

return: string

gen_rand_string_friendly($num_chars = 8)   X-Ref
Generates a user-friendly alphanumeric random string of given length
We remove 0 and O so users cannot confuse those in passwords etc.

return: string

unique_id($extra = 'c')   X-Ref
Return unique id

param: string $extra additional entropy

phpbb_mt_rand($min, $max)   X-Ref
Wrapper for mt_rand() which allows swapping $min and $max parameters.

PHP does not allow us to swap the order of the arguments for mt_rand() anymore.
(since PHP 5.3.4, see http://bugs.php.net/46587)

param: int $min        Lowest value to be returned
param: int $max        Highest value to be returned
return: int            Random integer between $min and $max (or $max and $min)

phpbb_gmgetdate($time = false)   X-Ref
Wrapper for getdate() which returns the equivalent array for UTC timestamps.

param: int $time        Unix timestamp (optional)
return: array            Returns an associative array of information related to the timestamp.

get_formatted_filesize($value, $string_only = true, $allowed_units = false)   X-Ref
Return formatted string for filesizes

author: bantu
param: mixed    $value            filesize in bytes
param: bool    $string_only    true if language string should be returned
param: array    $allowed_units    only allow these units (data array indexes)
return: mixed                    data array if $string_only is false

still_on_time($extra_time = 15)   X-Ref
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: bool    Either true if the maximum execution time is nearly reached, or false

phpbb_hash($password)   X-Ref


phpbb_check_hash($password, $hash)   X-Ref
Check for correct password

param: string $password The password in plain text
param: string $hash The stored password hash
return: bool Returns true if the password is correct, false if not.

_hash_gensalt_private($input, &$itoa64, $iteration_count_log2 = 6)   X-Ref
Generate salt for hash generation


_hash_encode64($input, $count, &$itoa64)   X-Ref
Encode hash


_hash_crypt_private($password, $setting, &$itoa64)   X-Ref
The crypt function/replacement


phpbb_email_hash($email)   X-Ref
Hashes an email address to a big integer

param: string $email        Email address
return: string            Unsigned Big Integer

phpbb_version_compare($version1, $version2, $operator = null)   X-Ref
Wrapper for version_compare() that allows using uppercase A and B
for alpha and beta releases.

See http://www.php.net/manual/en/function.version-compare.php

param: string $version1        First version number
param: string $version2        Second version number
param: string $operator        Comparison operator (optional)
return: mixed                    Boolean (true, false) if comparison operator is specified.

phpbb_chmod($filename, $perms = CHMOD_READ)   X-Ref
Global function for chmodding directories and files for internal use

This function determines owner and group whom the file belongs to and user and group of PHP and then set safest possible file permissions.
The function determines owner and group from common.php file and sets the same to the provided file.
The function uses bit fields to build the permissions.
The function sets the appropiate execute bit on directories.

Supported constants representing bit fields are:

CHMOD_ALL - all permissions (7)
CHMOD_READ - read permission (4)
CHMOD_WRITE - write permission (2)
CHMOD_EXECUTE - execute permission (1)

NOTE: The function uses POSIX extension and fileowner()/filegroup() functions. If any of them is disabled, this function tries to build proper permissions, by calling is_readable() and is_writable() functions.

author: faw, phpBB Group
param: string    $filename    The file/directory to be chmodded
param: int    $perms        Permissions to set
return: bool    true on success, otherwise false

phpbb_is_writable($file)   X-Ref
Test if a file/directory is writable

This function calls the native is_writable() when not running under
Windows and it is not disabled.

param: string $file Path to perform write test on
return: bool True when the path is writable, otherwise false.

array_combine($keys, $values)   X-Ref
A wrapper for the PHP5 function array_combine()

param: array $keys contains keys for the resulting array
param: array $values contains values for the resulting array
return: Returns an array by using the values from the keys array as keys and the

str_split($string, $split_length = 1)   X-Ref
A wrapper for the PHP5 function str_split()

param: array $string contains the string to be converted
param: array $split_length contains the length of each chunk
return: Converts a string to an array. If the optional split_length parameter is specified,

stripos($haystack, $needle)   X-Ref
A wrapper for the PHP5 function stripos
Find position of first occurrence of a case-insensitive string

param: string $haystack is the string to search in
param: string $needle is the string to search for
return: mixed Returns the numeric position of the first occurrence of needle in the haystack string. Unlike strpos(), stripos() is case-insensitive.

is_absolute($path)   X-Ref
Checks if a path ($path) is absolute or relative

param: string $path Path to check absoluteness of
return: boolean

phpbb_own_realpath($path)   X-Ref

author: Chris Smith <chris@project-minerva.org>
param: string $path The path which we should attempt to resolve.
return: mixed

phpbb_realpath($path)   X-Ref
A wrapper for realpath


phpbb_realpath($path)   X-Ref
A wrapper for realpath


phpbb_clean_path($path)   X-Ref
Eliminates useless . and .. components from specified path.

param: string $path Path to clean
return: string Cleaned path

htmlspecialchars_decode($string, $quote_style = ENT_COMPAT)   X-Ref
A wrapper for htmlspecialchars_decode


language_select($default = '')   X-Ref
Pick a language, any language ...


style_select($default = '', $all = false)   X-Ref
Pick a template/theme combo,


tz_select($default = '', $truncate = false)   X-Ref
Pick a timezone


markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $user_id = 0)   X-Ref
Marks a topic/forum as read
Marks a topic as posted to

param: int $user_id can only be used with $mode == 'post'

get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $global_announce_list = false)   X-Ref
Get topic tracking info by using already fetched info


get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_list = false)   X-Ref
Get topic tracking info from db (for cookie based tracking only this function is used)


get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001, $sql_limit_offset = 0)   X-Ref
Get list of unread topics

param: int $user_id            User ID (or false for current user)
param: string $sql_extra        Extra WHERE SQL statement
param: string $sql_sort        ORDER BY SQL sorting statement
param: string $sql_limit        Limits the size of unread topics list, 0 for unlimited query
param: string $sql_limit_offset  Sets the offset of the first row to search, 0 to search from the start
return: array[int][int]        Topic ids as keys, mark_time of topic as value

update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_time = false, $mark_time_forum = false)   X-Ref
Check for read forums and update topic tracking info accordingly

param: int $forum_id the forum id to check
param: int $forum_last_post_time the forums last post time
param: int $f_mark_time the forums last mark time if user is registered and load_db_lastread enabled
param: int $mark_time_forum false if the mark time needs to be obtained, else the last users forum mark time
return: true if complete forum got marked read, else false.

tracking_serialize($input)   X-Ref
Transform an array into a serialized format


tracking_unserialize($string, $max_depth = 3)   X-Ref
Transform a serialized array into an actual array


generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = false, $tpl_prefix = '')   X-Ref
Pagination routine, generates page number sequence
tpl_prefix is for using different pagination blocks at one page


on_page($num_items, $per_page, $start)   X-Ref
Return current page (pagination)


append_sid($url, $params = false, $is_amp = true, $session_id = false)   X-Ref
Append session id to url.
This function supports hooks.

param: string $url The url the session id needs to be appended to (can have params)
param: mixed $params String or array of additional url parameters
param: bool $is_amp Is url using &amp; (true) or & (false)
param: string $session_id Possibility to use a custom session id instead of the global one

generate_board_url($without_script_path = false)   X-Ref
Generate board url (example: http://www.example.com/phpBB)

param: bool $without_script_path if set to true the script path gets not appended (example: http://www.example.com)
return: string the generated board url

redirect($url, $return = false, $disable_cd_check = false)   X-Ref
Redirects the user to another page then exits the script nicely
This function is intended for urls within the board. It's not meant to redirect to cross-domains.

param: string $url The url to redirect to
param: bool $return If true, do not redirect but return the sanitized URL. Default is no return.
param: bool $disable_cd_check If true, redirect() will redirect to an external domain. If false, the redirect point to the boards url if it does not match the current domain. Default is false.

reapply_sid($url)   X-Ref
Re-Apply session id after page reloads


build_url($strip_vars = false)   X-Ref
Returns url from the session/current page with an re-appended SID with optionally stripping vars from the url


meta_refresh($time, $url, $disable_cd_check = false)   X-Ref
Meta refresh assignment
Adds META template variable with meta http tag.

param: int $time Time in seconds for meta refresh tag
param: string $url URL to redirect to. The url will go through redirect() first before the template variable is assigned
param: bool $disable_cd_check If true, meta_refresh() will redirect to an external domain. If false, the redirect point to the boards url if it does not match the current domain. Default is false.

send_status_line($code, $message)   X-Ref
Outputs correct status line header.

Depending on php sapi one of the two following forms is used:

Status: 404 Not Found

HTTP/1.x 404 Not Found

HTTP version is taken from HTTP_VERSION environment variable,
and defaults to 1.0.

Sample usage:

send_status_line(404, 'Not Found');

param: int $code HTTP status code
param: string $message Message for the status code
return: null

generate_link_hash($link_name)   X-Ref
Add a secret hash   for use in links/GET requests

param: string  $link_name The name of the link; has to match the name used in check_link_hash, otherwise no restrictions apply
return: string the hash

check_link_hash($token, $link_name)   X-Ref
checks a link hash - for GET requests

param: string $token the submitted token
param: string $link_name The name of the link
return: boolean true if all is fine

add_form_key($form_name)   X-Ref
Add a secret token to the form (requires the S_FORM_TOKEN template variable)

param: string  $form_name The name of the form; has to match the name used in check_form_key, otherwise no restrictions apply

check_form_key($form_name, $timespan = false, $return_page = '', $trigger = false)   X-Ref
Check the form key. Required for all altering actions not secured by confirm_box

param: string  $form_name The name of the form; has to match the name used in add_form_key, otherwise no restrictions apply
param: int $timespan The maximum acceptable age for a submitted form in seconds. Defaults to the config setting.
param: string $return_page The address for the return link
param: bool $trigger If true, the function will triger an error when encountering an invalid form

confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_body.html', $u_action = '')   X-Ref
Build Confirm box

param: boolean $check True for checking if confirmed (without any additional parameters) and false for displaying the confirm box
param: string $title Title/Message used for confirm box.
param: string $hidden Hidden variables
param: string $html_body Template used for confirm box
param: string $u_action Custom form action

login_box($redirect = '', $l_explain = '', $l_success = '', $admin = false, $s_display = true)   X-Ref
Generate login box or verify password


login_forum_box($forum_data)   X-Ref
Generate forum login box


_build_hidden_fields($key, $value, $specialchar, $stripslashes)   X-Ref
Little helper for the build_hidden_fields function


build_hidden_fields($field_ary, $specialchar = false, $stripslashes = false)   X-Ref
Build simple hidden fields from array

param: array $field_ary an array of values to build the hidden field from
param: bool $specialchar if true, keys and values get specialchared
param: bool $stripslashes if true, keys and values get stripslashed
return: string the hidden fields

parse_cfg_file($filename, $lines = false)   X-Ref
Parse cfg file


add_log()   X-Ref
Add log event


get_backtrace()   X-Ref
Return a nicely formatted backtrace.

Turns the array returned by debug_backtrace() into HTML markup.
Also filters out absolute paths to phpBB root.

return: string    HTML markup

get_preg_expression($mode)   X-Ref
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


get_censor_preg_expression($word, $use_unicode = true)   X-Ref
Generate regexp for naughty words censoring
Depends on whether installed PHP version supports unicode properties

param: string    $word            word template to be replaced
param: bool    $use_unicode    whether or not to take advantage of PCRE supporting unicode
return: string $preg_expr        regex to use with word censor

short_ipv6($ip, $length)   X-Ref
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


phpbb_checkdnsrr($host, $type = 'MX')   X-Ref
Wrapper for php's checkdnsrr function.

author: bantu
param: string $host    Fully-Qualified Domain Name
param: string $type    Resource record type to lookup
return: mixed        true if entry found,

msg_handler($errno, $msg_text, $errfile, $errline)   X-Ref
No description

phpbb_filter_root_path($errfile)   X-Ref
Removes absolute path to phpBB root directory from error messages
and converts backslashes to forward slashes.

param: string $errfile    Absolute file path
return: string            Relative file path

obtain_guest_count($item_id = 0, $item = 'forum')   X-Ref
Queries the session table to get information about online guests

param: int $item_id Limits the search to the item with this id
param: string $item The name of the item which is stored in the session table as session_{$item}_id
return: int The number of active distinct guest sessions

obtain_users_online($item_id = 0, $item = 'forum')   X-Ref
Queries the session table to get information about online users

param: int $item_id Limits the search to the item with this id
param: string $item The name of the item which is stored in the session table as session_{$item}_id
return: array An array containing the ids of online, hidden and visible users, as well as statistical info

obtain_users_online_string($online_users, $item_id = 0, $item = 'forum')   X-Ref
Uses the result of obtain_users_online to generate a localized, readable representation.

param: mixed $online_users result of obtain_users_online - array with user_id lists for total, hidden and visible users, and statistics
param: int $item_id Indicate that the data is limited to one item and not global
param: string $item The name of the item which is stored in the session table as session_{$item}_id
return: array An array containing the string for output to the template

phpbb_optionget($bit, $data)   X-Ref
Get option bitfield from custom data

param: int    $bit        The bit/value to get
param: int    $data        Current bitfield to check
return: bool    Returns true if value of constant is set in bitfield, else false

phpbb_optionset($bit, $set, $data)   X-Ref
Set option bitfield

param: int    $bit        The bit/value to set/unset
param: bool    $set        True if option should be set, false if option should be unset.
param: int    $data        Current bitfield to change
return: int    The new bitfield

phpbb_http_login($param)   X-Ref
Login using http authenticate.

param: array    $param        Parameter array, see $param_defaults array.
return: null

page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum')   X-Ref
Generate page header


page_footer($run_cron = true)   X-Ref
Generate page footer


garbage_collection()   X-Ref
Closing the cache object and the database
Cool function name, eh? We might want to add operations to it later


exit_handler()   X-Ref
Handler for exit calls in phpBB.
This function supports hooks.

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

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




Generated: Wed Oct 2 15:03:47 2013 Cross-referenced by PHPXref 0.7.1