Documentation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

v1.4:functions [2012/07/11 03:04]
Franz created
v1.4:functions [2012/10/06 23:23] (current)
Studio384
Line 1: Line 1:
 ====== Functions ====== ====== Functions ======
-FIXME+===== Functions available everywhere ===== 
 +These function are in common.php and functions.php 
 + 
 +==== get_microtime() ==== 
 +Returns the time in milliseconds 
 + 
 +==== check_cookie(&​$pun_user) ==== 
 +Takes $pun_user, and populates it with the user data 
 + 
 +==== escape_cdata($str) ==== 
 +Takes a string with CDATA for scripts in it, and escapes it for HTML 
 +=== Example === 
 +<code php> 
 +$str = '<​script type="​text/​javascript">​ 
 +//<​![CDATA[ 
 +alert('​foo'​);​ 
 +//​]]>';​ 
 +echo escape_cdata($str);​ 
 +</​code>​ 
 + 
 +==== authenticate_user($user,​ $password); ==== 
 +No description at this time 
 + 
 +==== get_current_url($max_length);​ ==== 
 +This gets the URL, and returns null if the URL is longer than $max_length. If $max_length is left out, then it will return the current URL regardless of length. 
 + 
 +==== get_current_protocol() ==== 
 +Returns the protocol being used to access the server ('​http'​ or '​https'​);​ 
 + 
 +==== function get_base_url($support_https) ==== 
 +This returns the base URL of the forum (i.e. what was set up in the configuration),​ and if $support_https is set to true, it will return it in HTTP or HTTPS, depending on how the page is accessed. 
 + 
 +==== set_default_user() ==== 
 +This sets $pun_user to the defaults for a guest. 
 + 
 +==== function forum_hmac($data,​ $key, $raw_output) ==== 
 +A hash function, no better description at this time 
 + 
 +==== pun_setcookie($user_id,​ $password_hash,​ $expire) ==== 
 +Sets a cookie for the current user, based on the settings you put in the parameters 
 + 
 +==== forum_setcookie($name,​ $value, $expire) ==== 
 +This is simply a wrapper for setcookie 
 + 
 +==== check_bans() ==== 
 +This gets the bans and puts them into $pun_bans, and will check for expired ones. 
 + 
 +==== check_username($username,​ $exclude_id) ==== 
 +No description at this time 
 + 
 +==== update_users_online() ==== 
 +Updates the database table containing the users online 
 + 
 +==== generate_profile_menu($page) ==== 
 +This generates the sidebar menu for profile pages. $page may be left blank. 
 + 
 +==== generate_avatar_markup($user_id) ==== 
 +Generates the HTML to display the avatar for the user sent in $user_id 
 + 
 +==== generate_page_title($page_title) ==== 
 +Sets the title for the page you are on. 
 + 
 +==== set_tracked_topics($tracked_topics) ==== 
 +No description at this time. 
 + 
 +==== get_tracked_topics()==== 
 +No description at this time 
 + 
 +==== update_forum($forum_id) ==== 
 +Updates the database entries for the last poster and last post in a forum 
 + 
 +==== delete_avatar($user_id) ==== 
 +Deletes the avatar for the user with ID $user_id 
 + 
 +==== delete_topic($topic_id) ==== 
 +Deletes a topic and all of <​b>​its</​b>​ replies 
 + 
 +==== delete_post($post_id,​ $topic_id) ==== 
 +Deletes the post specified 
 + 
 +==== forum_clear_cache() ==== 
 +Deletes all cached date (i.e. bans, config, etc.) 
 + 
 +==== censor_words($text) ==== 
 +Runs the censoring filter on the text sent in $text, and returns the censored version. 
 + 
 +==== get_title($user) ==== 
 +Gets the user title of the user sent in $user. $user must contain: 
 +<code php> 
 +array ( 
 +'​title'​ => '​*custom user title*',​ 
 +'​username'​ => '​*username*',​ 
 +'​g_user_title'​ => '​*default user group title*'​ 
 +
 +</​code>​ 
 + 
 +==== function paginate($num_pages,​ $cur_page, $link) ==== 
 +Generates the page links (i.e. page 1, page 2, next page, previous page, etc.) 
 + 
 +==== function message($message,​ $no_back_link) ==== 
 +This displays a message to the user and stops the current script. If $no_back_link is left out, then a back link will be displayed. 
 + 
 +==== function format_time($timestamp,​ $date_only = false, $date_format = null, $time_format = null, $time_only = false, $no_text = false) ==== 
 +Formats the time for the user (depending on the user's formatting preferences). 
 + 
 +==== forum_number_format($number,​ $decimals = 0) ==== 
 +No description at this time. 
 + 
 +==== random_key($len,​ $readable = false, $hash = false) ==== 
 +No description at this time. 
 + 
 +==== confirm_referrer($script,​ $error_msg = false) ==== 
 +Makes sure that the HTTP_REFERER is correct. $script should be set to the current page, such as admin_maintenance.php 
 + 
 +==== random_pass($len) ==== 
 +Generates a random password of length $len 
 + 
 +==== pun_hash($str) ==== 
 +A wrapper for the sha1 function 
 + 
 +==== get_remote_address() ==== 
 +Returns the IP address of the current user 
 + 
 +==== pun_htmlspecialchars($str) ==== 
 +Returns $str with all HTML stripped 
 + 
 +==== function pun_htmlspecialchars_decode($str) ==== 
 +No description at this time 
 + 
 +==== pun_strlen($str) ==== 
 +Returns the UTF-8 length of a string 
 + 
 +==== pun_linebreaks($str) ==== 
 +Converts linkbreaks to the standard UNIX style 
 + 
 +==== pun_trim($str,​ $charlist = false) ==== 
 +No description at this time. 
 + 
 +==== is_all_uppercase($string) ==== 
 +Checks if a string is all uppercase 
 + 
 +==== array_insert(&​$input,​ $offset, $element, $key = null) ==== 
 +Inserts $element into $input at $offset. If $key is set, it is used for setting the key for adding into an array where the keys are strings. 
 + 
 +==== maintenance_message() ==== 
 +Displays a maintenance message when the board is in maintenance mode. 
 + 
 +==== redirect($destination_url,​ $message) ==== 
 +Redirects the user to $destination_url with $message 
 + 
 +==== error($message,​ $file = null, $line = null, $db_error = false) ==== 
 +Clears all output and displays an error message 
 +=== Usage === 
 +<code php> 
 +$result = $db->​query('​SELECT id FROM users WHERE id=' . $pun_user['​id'​]) or error('​Could not select user ID', __FILE__, __LINE__, $db->​error());​ 
 +</​code>​ 
 + 
 +==== forum_unregister_globals() ==== 
 +Unset any variables created as a result of register_globals 
 + 
 +==== forum_remove_bad_characters() ==== 
 +Removes any characters that can cause undesired result or are invisible from text. 
 + 
 +==== remove_bad_characters($array) ==== 
 +Removes "​bad"​ characters from the array. 
 + 
 +==== file_size($size) ==== 
 +Converts a file size in bytes into a more human version (e.g. 1024 B changed into 1 KiB) 
 + 
 +==== forum_list_styles() ==== 
 +Returns a list of the smilies 
 + 
 +==== forum_list_langs() ==== 
 +Returns a list of the available languages 
 + 
 +==== generate_stopwords_cache_id() ==== 
 +No description at this time. 
 + 
 +==== forum_list_plugins($is_admin) ==== 
 +Generates a list of the plugins available for the forum 
 + 
 +==== split_text($text,​ $start, $end, $retab = true) ==== 
 +No description at this time. 
 + 
 +==== extract_blocks($text,​ $start, $end, $retab = true) ==== 
 +No description at this time. 
 + 
 +==== url_valid($url) ==== 
 +Checks if $url is a valid URL 
 + 
 +==== ucp_preg_replace($pattern,​ $replace, $subject) ==== 
 +No description at this time. 
 + 
 +==== strip_bad_multibyte_chars($str) ==== 
 +Strips all characters that are multiple bytes. 
 + 
 +==== forum_is_writable($path) ==== 
 +Checks whether $path is writable 
 + 
 +==== display_saved_queries() ==== 
 +Displays all executed queries, if it is enabled 
 + 
 +==== dump() ==== 
 +Shows all variables