[ Index ]

PHP Cross Reference of phpBB-3.1.10-deutsch




/includes/ -> functions.php (summary)

This file is part of the phpBB Forum Software package.

Copyright: (c) phpBB Limited
License: GNU General Public License, version 2 (GPL-2.0)
File Size: 5667 lines (179 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 85 functions


Functions that are not part of a class:

phpbb_load_extensions_autoloaders($phpbb_root_path)   X-Ref
Load the autoloaders added by the extensions.

param: string $phpbb_root_path Path to the phpbb root directory.

set_var(&$result, $var, $type, $multibyte = false)   X-Ref
Casts a variable to the given type.

request_var($var_name, $default, $multibyte = false, $cookie = false, $request = null)   X-Ref
Wrapper function of \phpbb\request\request::variable which exists for backwards compatability.
See {@link \phpbb\request\request_interface::variable \phpbb\request\request_interface::variable} for
documentation of this function's use.

return: mixed    The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
param: mixed            $var_name    The form variable's name from which data shall be retrieved.
param: mixed            $default    A default value that is returned if the variable was not set.
param: bool            $multibyte    If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters
param: bool            $cookie        This param is mapped to \phpbb\request\request_interface::COOKIE as the last param for
param: \phpbb\request\request_interface|null|false    If an instance of \phpbb\request\request_interface is given the instance is stored in

set_config($config_name, $config_value, $is_dynamic = false, \phpbb\config\config $set_config = null)   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.

return: null
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

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

return: null
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

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)

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

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

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

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

return: mixed                    data array if $string_only is false
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)

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_email_hash($email)   X-Ref
Hashes an email address to a big integer

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

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

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

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.

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

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.

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

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

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

phpbb_own_realpath($path)   X-Ref

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

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

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

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

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

phpbb_format_timezone_offset($tz_offset, $show_null = false)   X-Ref
Format the timezone offset with hours and minutes

return: string        Normalized offset string:    -7200 => -02:00
param: int        $tz_offset    Timezone offset in seconds
param: bool    $show_null    Whether null offsets should be shown

phpbb_tz_select_compare($a, $b)   X-Ref
Compares two time zone labels.
Arranges them in increasing order by timezone offset.
Places UTC before other timezones in the same offset.

phpbb_get_timezone_identifiers($selected_timezone)   X-Ref
Return list of timezone identifiers
We also add the selected timezone if we can create an object with it.
DateTimeZone::listIdentifiers seems to not add all identifiers to the list,
because some are only kept for backward compatible reasons. If the user has
a deprecated value, we add it here, so it can still be kept. Once the user
changed his value, there is no way back to deprecated values.

return: array        DateTimeZone::listIdentifiers and additional
param: string        $selected_timezone        Additional timezone that shall

phpbb_timezone_select($template, $user, $default = '', $truncate = false)   X-Ref
Options to pick a timezone and date/time

return: array        Returns an array containing the options for the time selector.
param: \phpbb\template\template $template    phpBB template object
param: \phpbb\user    $user                Object of the current user
param: string        $default            A timezone to select
param: boolean        $truncate            Shall we truncate the options text

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: string $mode (all, topics, topic, post)
param: int|bool $forum_id Used in all, topics, and topic mode
param: int|bool $topic_id Used in topic and post mode
param: int $post_time 0 means current time(), otherwise to set a specific mark time
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

return: array[int][int]        Topic ids as keys, mark_time of topic as value
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

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

return: true if complete forum got marked read, else false.
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

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

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

return: string The corrected url.
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
param: bool $is_route Is url generated by a route.

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

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

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');

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

phpbb_request_http_version()   X-Ref
Returns the HTTP version used in the current request.

Handles the case of being called before $request is present,
in which case it falls back to the $_SERVER superglobal.

return: string HTTP version

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

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

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

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

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)   X-Ref
Check the form key. Required for all altering actions not secured by confirm_box

return: bool    True, if the form key was valid, false otherwise
param: string    $form_name    The name of the form; has to match the name used
param: int        $timespan    The maximum acceptable age for a submitted 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

return: string the hidden fields
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

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

add_log()   X-Ref
Add log entry

return: int|bool        Returns the log_id, if the entry was added to the database, false otherwise.
param: string    $mode                The mode defines which log_type is used and from which log the entry is retrieved
param: int        $forum_id            Mode 'mod' ONLY: forum id of the related item, NOT INCLUDED otherwise
param: int        $topic_id            Mode 'mod' ONLY: topic id of the related item, NOT INCLUDED otherwise
param: int        $reportee_id        Mode 'user' ONLY: user id of the reportee, NOT INCLUDED otherwise
param: string    $log_operation        Name of the operation
param: array    $additional_data    More arguments can be added, depending on the log_type

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

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

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_ip_normalise($address)   X-Ref
Normalises an internet protocol address,
also checks whether the specified address is valid.

IPv4 addresses are returned 'as is'.

IPv6 addresses are normalised according to
A Recommendation for IPv6 Address Text Representation

return: mixed        false if specified address is not valid,
param: string $address    IP address

phpbb_inet_ntop($in_addr)   X-Ref
Wrapper for inet_ntop()

Converts a packed internet address to a human readable representation
inet_ntop() is supported by PHP since 5.1.0, since 5.3.0 also on Windows.

return: mixed        false on failure,
param: string $in_addr    A 32bit IPv4, or 128bit IPv6 address.

phpbb_inet_pton($address)   X-Ref
Wrapper for inet_pton()

Converts a human readable IP address to its packed in_addr representation
inet_pton() is supported by PHP since 5.1.0, since 5.3.0 also on Windows.

return: mixed        false if address is invalid,
param: string $address    A human readable IPv4 or IPv6 address.

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

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

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.

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

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

return: int The number of active distinct guest sessions
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

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

return: array An array containing the ids of online, hidden and visible users, as well as statistical info
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

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.

return: array An array containing the string for output to the template
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

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

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

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

return: int    The new 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

phpbb_get_plural_form($rule, $number)   X-Ref
Determine which plural form we should use.
For some languages this is not as simple as for English.

return: int        The plural-case we need to use for the number plural-rule combination
param: $rule        int            ID of the plural rule we want to use, see http://wiki.phpbb.com/Plural_Rules#Plural_Rules
param: $number    int|float    The number we want to get the plural case for. Float numbers are floored.

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

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

phpbb_quoteattr($data, $entities = null)   X-Ref
Escapes and quotes a string for use as an HTML/XML attribute value.

This is a port of Python xml.sax.saxutils quoteattr.

The function will attempt to choose a quote character in such a way as to
avoid escaping quotes in the string. If this is not possible the string will
be wrapped in double quotes and double quotes will be escaped.

return: string Escaped and quoted string
param: string $data The string to be escaped
param: array $entities Associative array of additional entities to be escaped

phpbb_build_hidden_fields_for_query_params($request, $exclude = null)   X-Ref
Converts query string (GET) parameters in request into hidden fields.

Useful for forwarding GET parameters when submitting forms with GET method.

It is possible to omit some of the GET parameters, which is useful if
they are specified in the form being submitted.

sid is always omitted.

return: string HTML with hidden fields
param: \phpbb\request\request $request Request object
param: array $exclude A list of variable names that should not be forwarded

phpbb_get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false, $lazy = false)   X-Ref
Get user avatar

return: string Avatar html
param: array $user_row Row from the users table
param: string $alt Optional language string for alt tag within image, can be a language key or text
param: bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
param: bool $lazy If true, will be lazy loaded (requires JS)

phpbb_get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false, $lazy = false)   X-Ref
Get group avatar

return: string Avatar html
param: array $group_row Row from the groups table
param: string $alt Optional language string for alt tag within image, can be a language key or text
param: bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
param: bool $lazy If true, will be lazy loaded (requires JS)

phpbb_get_avatar($row, $alt, $ignore_config = false, $lazy = false)   X-Ref
Get avatar

return: string Avatar html
param: array $row Row cleaned by \phpbb\avatar\manager::clean_row
param: string $alt Optional language string for alt tag within image, can be a language key or text
param: bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
param: bool $lazy If true, will be lazy loaded (requires JS)

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

phpbb_check_and_display_sql_report(\phpbb\request\request_interface $request, \phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db)   X-Ref
Check and display the SQL report if requested.

param: \phpbb\request\request_interface        $request    Request object
param: \phpbb\auth\auth                        $auth        Auth object
param: \phpbb\db\driver\driver_interface        $db            Database connection

phpbb_generate_debug_output(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\auth\auth $auth, \phpbb\user $user, \phpbb\event\dispatcher_interface $phpbb_dispatcher)   X-Ref
Generate the debug output string

return: string
param: \phpbb\db\driver\driver_interface    $db            Database connection
param: \phpbb\config\config                $config        Config object
param: \phpbb\auth\auth                    $auth        Auth object
param: \phpbb\user                        $user        User object
param: \phpbb\event\dispatcher_interface    $phpbb_dispatcher    Event dispatcher

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

param: bool $run_cron Whether or not to run the cron
param: bool $display_template Whether or not to display the template
param: bool $exit_handler Whether or not to run the exit_handler()

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 \phpbb\user::setup();
This function supports hooks.

phpbb_pcre_utf8_support()   X-Ref
Check if PCRE has UTF-8 support
PHP may not be linked with the bundled PCRE lib and instead with an older version

return: bool    Returns true if PCRE (the regular expressions library) supports UTF-8 encoding

phpbb_to_numeric($input)   X-Ref
Casts a numeric string $input to an appropriate numeric type (i.e. integer or float)

return: int|float            Integer $input if $input fits integer,
param: string $input        A numeric string.

phpbb_get_board_contact(\phpbb\config\config $config, $phpEx)   X-Ref
Get the board contact details (e.g. for emails)

return: string
param: \phpbb\config\config    $config
param: string                    $phpEx

phpbb_get_board_contact_link(\phpbb\config\config $config, $phpbb_root_path, $phpEx)   X-Ref
Get a clickable board contact details link

return: string
param: \phpbb\config\config    $config
param: string                    $phpbb_root_path
param: string                    $phpEx

Generated: Sun Feb 19 19:52:41 2017 Cross-referenced by PHPXref 0.7.1