[ Index ]

PHP Cross Reference of phpBB-3.3.11-deutsch

title

Body

[close]

/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: 4430 lines (149 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 65 functions

  gen_rand_string()
  gen_rand_string_friendly()
  unique_id()
  phpbb_mt_rand()
  phpbb_gmgetdate()
  get_formatted_filesize()
  still_on_time()
  phpbb_version_compare()
  language_select()
  style_select()
  phpbb_format_timezone_offset()
  phpbb_tz_select_compare()
  phpbb_get_timezone_identifiers()
  phpbb_timezone_select()
  markread()
  get_topic_tracking()
  get_complete_topic_tracking()
  get_unread_topics()
  update_forum_tracking_info()
  tracking_serialize()
  tracking_unserialize()
  append_sid()
  generate_board_url()
  redirect()
  reapply_sid()
  build_url()
  meta_refresh()
  send_status_line()
  phpbb_request_http_version()
  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()
  get_backtrace()
  get_preg_expression()
  get_censor_preg_expression()
  short_ipv6()
  phpbb_ip_normalise()
  msg_handler()
  phpbb_filter_root_path()
  obtain_guest_count()
  obtain_users_online()
  obtain_users_online_string()
  phpbb_optionget()
  phpbb_optionset()
  phpbb_quoteattr()
  phpbb_get_user_avatar()
  phpbb_get_group_avatar()
  phpbb_get_avatar()
  page_header()
  phpbb_check_and_display_sql_report()
  phpbb_generate_debug_output()
  page_footer()
  garbage_collection()
  exit_handler()
  phpbb_user_session_handler()
  phpbb_to_numeric()
  phpbb_get_board_contact()
  phpbb_get_board_contact_link()

Functions
Functions that are not part of a class:

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

return: string
param: int $num_chars Length of random string, defaults to 8.

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
param: int $num_chars Length of random string, defaults to 8.

unique_id()   X-Ref
Return unique id


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

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

return: string            HTML options for language selection dropdown list.
param: string $default    Language ISO code to be selected by default in the dropdown list
param: array $langdata    Language data in format of array(array('lang_iso' => string, lang_local_name => string), ...)

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

return: string            HTML options for style selection dropdown list.
param: string $default    Style ID to be selected by default in the dropdown list
param: bool $all            Flag indicating if all styles data including inactive ones should be fetched
param: array $styledata    Style data in format of array(array('style_id' => int, style_name => string), ...)

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: 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 & (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, $is_route = false)   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, $template_variable_suffix = '')   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
param: string  $template_variable_suffix A string that is appended to the name of the template variable to which the form elements are assigned

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

return: bool True if confirmation was successful, false if not
param: boolean $check True for checking if confirmed (without any additional parameters) and false for displaying the confirm box
param: string|array $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


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

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 parameter.
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(string $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
http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-07

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

msg_handler($errno, $msg_text, $errfile, $errline)   X-Ref
Error and message handler, call with trigger_error if read


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_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_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($group_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_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: Sat Nov 4 14:26:03 2023 Cross-referenced by PHPXref 0.7.1