File/includes/functions.php

Description
Constants
ERRTYPE_ARRAY = 0 (line 14)
ERRTYPE_CP = 2 (line 16)
ERRTYPE_SILENT = 3 (line 17)
ERRTYPE_STANDARD = 1 (line 15)
FETCH_USERINFO_ADMIN = 0x10 (line 1431)
FETCH_USERINFO_AVATAR = 0x02 (line 1428)
FETCH_USERINFO_ISFRIEND = 0x80 (line 1434)
FETCH_USERINFO_LOCATION = 0x04 (line 1429)
FETCH_USERINFO_PROFILEPIC = 0x08 (line 1430)
FETCH_USERINFO_SIGPIC = 0x20 (line 1432)
FETCH_USERINFO_USERCSS = 0x40 (line 1433)
REQ_AUTO = 2 (line 28)
REQ_INCR = 3 (line 29)
REQ_NO = 0 (line 26)
REQ_YES = 1 (line 27)
VF_CODE = 2 (line 21)
VF_METHOD = '_-_mEtHoD_-_' (line 24)
VF_METHODNAME = 3 (line 22)
VF_REQ = 1 (line 20)
VF_TYPE = 0 (line 19)
Functions
addslashes_js (line 6520)

Escapes quotes in strings destined for Javascript

string addslashes_js (string $text, [string $quotetype = "'"])
  • string $text: String to be prepared for Javascript
  • string $quotetype: Type of quote (single or double quote)
add_query (line 3830)

Adds a query string to a path, fixing the query characters.

  • return: The resulting string
string add_query (string $path, [ $query = false])
  • string $path: The path to add the query to
  • $query
build_datastore (line 6416)

Saves the specified data into the datastore

void build_datastore ([string $title = ''], [mixed $data = ''], [integer $unserialize = 0])
  • string $title: The name of the datastore item to save
  • mixed $data: The data to be saved
  • integer $unserialize: 1 or 0 as to whether this value is to be automatically unserialised on retrieval
cache_calendar_permissions (line 5393)

Sets the calendar permissions to the passed user info array

  • return: Calendar permissions component of user info array
array cache_calendar_permissions (array &$user)
  • array &$user: (ref) User info array
cache_ordered_forums (line 4001)

Gets counter information and makes sure the forums are in the proper order for tree iteration. Changes will be made to the forum cache directly.

void cache_ordered_forums ([boolean $getcounters = 0], [boolean $getinvisibles = 0], [integer $userid = 0])
  • boolean $getcounters: Whether or not to get the forum counter info
  • boolean $getinvisibles: Whether to include invisible forums in the liast
  • integer $userid: ID of the user that subscribed forums should be fetched for
cache_permissions (line 5030)

Returns the full set of permissions for the specified user (called by global or init)

  • return: Permissions component of user info array
array cache_permissions (array &$user, [boolean $getforumpermissions = true], [boolean $resetaccess = false])
  • array &$user: (ref) User info array
  • boolean $getforumpermissions: If true, returns combined usergroup permissions, individual forum permissions, individual calendar permissions and attachment permissions
  • boolean $resetaccess: Reset the accesscache array for permissions following access mask update. Only allows one reset.
cache_templates (line 3854)

Fetches a number of templates from the database and puts them into the templatecache

void cache_templates (array $templates, string $templateidlist, [bool $skip_bbcode_style = false])
  • array $templates: List of template names to be fetched
  • string $templateidlist: Serialized array of template name => template id pairs
  • bool $skip_bbcode_style: Whether to skip adding the bbcode style refs
can_moderate (line 5672)

Returns whether or not the given user can perform a specific moderation action in the specified forum

boolean can_moderate ([integer $forumid = 0], [string $do = ''], [integer $userid = -1], [string $usergroupids = ''])
  • integer $forumid: Forum ID
  • string $do: If you want to check a particular moderation permission, name it here
  • integer $userid: User ID
  • string $usergroupids: Comma separated list of usergroups to which the user belongs
construct_language_options (line 6259)

Constructs a language chooser HTML menu

string construct_language_options ([string $depthmark = ''], [boolean $quickchooser = false])
  • string $depthmark: Marker to prepend each language name with
  • boolean $quickchooser: Whether or not this will build the quick chooser menu
construct_memberaction_dropdown (line 3117)

Returns the HTML for the member dwop-down pop-up menu

  • return: Member Drop-Down HTML
string construct_memberaction_dropdown (array $memberinfo, [array $template_hook = array()], [string $page_class = null])
  • array $memberinfo: user information for the drop-down context
  • array $template_hook: template hook, if we dont want to use the global one (like in postbit)
  • string $page_class: class name to apply to the div for context specific stylings
construct_navbits (line 2986)

Returns the HTML for the navigation breadcrumb in the navbar

This function will also set the GLOBAL $pagetitle to equal whatever is the last item in the navbits

string construct_navbits (array $nav_array, boolean 1)
  • boolean 1: Whether to include the forum breadcrumb
  • array $nav_array: Array of link => title pairs from which to build the link chain
construct_page_nav (line 2552)

Returns the HTML for multi-page navigation

  • return: Page navigation HTML
string construct_page_nav (integer $pagenumber, integer $perpage, integer $results, string $address, [string $address2 = ''], [ $anchor = ''], [ $seolink = ''], [ $objectinfo = array()], [ $pageinfo = array()])
  • integer $pagenumber: Page number being displayed
  • integer $perpage: Number of items to be displayed per page
  • integer $results: Total number of items found
  • string $address: Base address for links eg: showthread.php?t=99{&page=4}
  • string $address2: Ending portion of address for links
  • $anchor
  • $seolink
  • $objectinfo
  • $pageinfo
construct_phrase (line 3204)

Construct Phrase

this function is actually just a wrapper for sprintf but makes identification of phrase code easier and will not error if there are no additional arguments. The first parameter is the phrase text, and the (unlimited number of) following parameters are the variables to be parsed into that phrase.

  • return: The parsed phrase
string construct_phrase (string 0, mixed 1, mixed 2)
  • string 0: Text of the phrase
  • mixed 1: First variable to be inserted .. .. ..
  • mixed 2: Nth variable to be inserted
construct_phrase_from_array (line 3243)

Construct Phrase from Array

this function is actually just a wrapper for sprintf but makes identification of phrase code easier and will not error if there are no additional arguments. The first element of the array is the phrase text, and the (unlimited number of) following elements are the variables to be parsed into that phrase.

  • return: The parsed phrase
string construct_phrase_from_array (array $phrase_array)
  • array $phrase_array: array containing phrase and arguments
construct_quick_nav (line 4127)

Returns the HTML for the forum jump menu

void construct_quick_nav ([array $navpopup = array()], [integer $parentid = -1], [boolean $addbox = true], [boolean $override = false])
  • array $navpopup: Information about current page (id, title, and link)
  • integer $parentid: ID of the parent forum for the group to be shown (-1 for all)
  • boolean $addbox: If true, evaluate the forumjump template too
  • boolean $override: Override $complete
construct_style_options (line 6325)

Constructs a style chooser HTML menu

string construct_style_options ([integer $styleid = -1], [string $depthmark = ''], [boolean $init = true], [boolean $quickchooser = false])
  • integer $styleid: Style ID
  • string $depthmark: String repeated before style name to indicate nesting
  • boolean $init: Whether or not to initialize this function (this function is recursive)
  • boolean $quickchooser: Whether or not this will build the quick chooser menu
construct_window_page_nav (line 2799)

Returns the HTML for multi-page navigation without a fully know result set

This handles multipage navigation when we don't have a count for the resultset. The follow things must be true for this logic to work correctly

1) $confirmedcount is less than or equal to the total number of results 2) if $confirmedcount is not the total number of results, it must be at least equal to the "count" of the last result displayed in the window.

These assumptions allow us to display the window links knowing that they will be valid without knowing the full extent of the result set.

  • return: Page navigation HTML
  • see: fetch_seo_url()
  • todo: is it correct to include the pagenav hooks here? Do we need other hooks to replace them?
string construct_window_page_nav (integer $pagenumber, integer $window, integer $perpage, integer $confirmedcount, string $address, [string $address2 = ''], [string $anchor = ''], [array $seolink = ''], [array $objectinfo = ''], [ $pageinfo = ''])
  • integer $pagenumber: Page number being displayed
  • integer $window: Number of pages to show before and after current page
  • integer $perpage: Number of items to be displayed per page
  • integer $confirmedcount: Number of items confirmed in the results
  • string $address: Base address for links eg: showthread.php?t=99{&page=4}
  • string $address2: Ending portion of address for links
  • string $anchor: The base link for seo urls (if this is used address will not be)
  • array $seolink: Additonal object info for generating the seo urls
  • array $objectinfo: Additonal page info for generating the seo urls
  • $pageinfo
convert_bbarray_cookie (line 2282)

Replaces all those none safe characters so we dont waste space in array cookie values with URL entities

array convert_bbarray_cookie (string $cookie, [string $dir = 'get'])
  • string $cookie: Cookie array
  • string $dir: Direction ('get' or 'set')
convert_bits_to_array (line 5001)

Converts a bitfield into an array of 1 / 0 values based on the array describing the resulting fields

array convert_bits_to_array (integer &$bitfield, array $_FIELDNAMES)
  • integer &$bitfield: (ref) Bitfield
  • array $_FIELDNAMES: Array containing field definitions - array('canx' => 1, 'cany' => 2, 'canz' => 4) etc
convert_int_to_utf8 (line 4472)

Converts an integer into a UTF-8 character string

string convert_int_to_utf8 (integer $intval)
  • integer $intval: Integer to be converted
convert_unicode_char_to_charset (line 4558)

Converts a single unicode character to the desired character set if possible.

Attempts to use iconv if it's available. Callback function for the regular expression in convert_urlencoded_unicode.

  • return: Character in desired character set or as an HTML entity
string convert_unicode_char_to_charset (integer $unicode_int, string $charset)
  • integer $unicode_int: Unicode code point value
  • string $charset: Character to convert to
convert_urlencoded_unicode (line 4512)

Converts Unicode entities of the format %uHHHH where each H is a hexadecimal character to &#DDDD; or the appropriate UTF-8 character based on current charset.

  • return: Decoded text
string convert_urlencoded_unicode (string $text)
  • string $text: Encoded text
create_full_url (line 3802)

Translates a relative URL to a fully-qualified URL. URLs not beginning with a / are assumed to be within the main vB-directory

void create_full_url ([string $url = ''], string 1)
  • string 1: Fully-qualified URL
  • string $url: Relative URL
datamanager_init (line 93)

Class factory. This is used for instantiating the extended classes.

  • return: An instance of the desired class
vB_DataManager &datamanager_init (string $classtype, vB_Registry &$registry, [integer $errtype = ERRTYPE_STANDARD], [string $forcefile = ''])
  • string $classtype: The type of the class to be called (user, forum etc.)
  • vB_Registry &$registry: An instance of the vB_Registry object.
  • integer $errtype: One of the ERRTYPE_x constants
  • string $forcefile: Option to force loading a class from a specific file; no extension
devdebug (line 4815)

Stuffs a message into the $DEVDEBUG array

void devdebug ([string $text = ''])
  • string $text: Message to store
exec_headers (line 4832)

Sends the appropriate HTTP headers for the page that is being displayed

void exec_headers ([boolean $headers = true], [boolean $nocache = true])
  • boolean $headers: If true, send HTTP 200
  • boolean $nocache: If true, send no-cache headers
exec_header_redirect (line 3751)

Halts execution and redirects to the specified URL invisibly

void exec_header_redirect (string $url, [ $redirectcode = 302])
  • string $url: Destination URL
  • $redirectcode
exec_mail_queue (line 958)

Reads the email message queue and delivers a number of pending emails to the message sender

void exec_mail_queue ()
exec_nocache_headers (line 4874)

Sends no-cache HTTP headers

void exec_nocache_headers ([boolean $sendcontent = true])
  • boolean $sendcontent: If true, send content-type header
exec_shut_down (line 6904)

Performs general clean-up after the system exits, such as running shutdown queries

void exec_shut_down ()
exec_switch_bg (line 2402)

Reads $bgclass and returns the alternate table class

  • return: CSS class name
string exec_switch_bg ([integer $alternate = 0])
  • integer $alternate: If > 0, allows us to have multiple classes on one page without them overwriting each other
exec_vbsetcookie (line 2171)

Calls PHP's setcookie() or sends raw headers if 'httponly' is required.

Should really only be called through vbsetcookie()

  • return: True on success
boolean exec_vbsetcookie (string $name, string $value, int $expires, [string $path = ''], [string $domain = ''], [boolean $secure = false], [boolean $httponly = false])
  • string $name: Name
  • string $value: Value
  • int $expires: Expire
  • string $path: Path
  • string $domain: Domain
  • boolean $secure: Secure
  • boolean $httponly: HTTP only - see http://msdn.microsoft.com/workshop/author/dhtml/httponly_cookies.asp
fetch_bbarray_cookie (line 2220)

Returns the value for an array stored in a cookie

mixed fetch_bbarray_cookie (string $cookiename, mixed $id)
  • string $cookiename: Name of the cookie
  • mixed $id: ID of the data within the cookie
fetch_censored_text (line 733)

Replaces any instances of words censored in $vbulletin->options['censorwords'] with $vbulletin->options['censorchar']

string fetch_censored_text (string $text)
  • string $text: Text to be censored
fetch_email_phrases (line 3290)

Returns 2 lines of eval()-able code -- one sets $message, the other $subject.

string fetch_email_phrases (string $email_phrase, [integer $languageid = -1], [string $emailsub_phrase = ''], [string $varprefix = ''])
  • string $email_phrase: Name of email phrase to fetch
  • integer $languageid: Language ID from which to pull the phrase (see fetch_phrase $languageid)
  • string $emailsub_phrase: If not empty, select the subject phrase with the given name
  • string $varprefix: Optional prefix for $message/$subject variable names (eg: $varprefix = 'test' -> $testmessage, $testsubject)
fetch_error (line 3347)

Fetches an error phrase from the database and inserts values for its embedded variables

  • return: The parsed phrase text
string fetch_error (string 0, mixed 1, mixed 2, mixed 3)
  • string 0: Varname of error phrase
  • mixed 1: Value of 1st variable
  • mixed 2: Value of 2nd variable
  • mixed 3: Value of Nth variable
fetch_error_array (line 3318)

Converts an array of error values to error strings by calling the fetch_error function.

  • return: The array of compiled error messages. Keys are preserved.
Array(string) fetch_error_array (Array(mixed) $errors)
  • Array(mixed) $errors: Errors to compile. Values can either be a string, which is taken be be the error varname or it can be an array in which case it is viewed as a list of parameters to pass to fetch_error
fetch_foruminfo (line 1261)

Returns an array containing info for the specified forum, or false if forum is not found

mixed fetch_foruminfo (integer &$forumid, [boolean $usecache = true])
  • integer &$forumid: (ref) Forum ID
  • boolean $usecache: Whether or not to return the result from the forumcache if it exists
fetch_forum_clause_sql (line 1651)

Returns an SQL condition like (forumid = 1 OR forumid = 2 OR forumid = 3) for each of a forum's parents

string fetch_forum_clause_sql (integer $forumid, [string $field = 'forumid'], [string $joiner = 'OR'], [string $parentlist = ''])
  • integer $forumid: Forum ID
  • string $field: The name of the field to be used in the clause
  • string $joiner: The 'joiner' word - could be 'OR' or 'AND' etc.
  • string $parentlist: The parentlist of the specified forum (comma separated string)
fetch_forum_parent_list (line 1608)

Returns the parentlist of the specified forum

  • return: Comma separated list of parent forum IDs
string fetch_forum_parent_list (integer $forumid)
  • integer $forumid: Forum ID
fetch_gzipped_text (line 1975)

Returns a gzip-compressed version of the specified string

string fetch_gzipped_text (string $text, [integer $level = 1])
  • string $text: Text to be gzipped
  • integer $level: Level of Gzip compression (1-10)
fetch_language_fields_sql (line 1077)

Returns a portion of an SQL query to select language fields from the database

string fetch_language_fields_sql ([boolean $addtable = true])
  • boolean $addtable: If true, select 'language.fieldname' otherwise 'fieldname'
fetch_lastposter_userinfo (line 3090)

Extracts member information for the action drop-down from the postinfo array

  • return: member information
array fetch_lastposter_userinfo (array $lastpostinfo)
  • array $lastpostinfo: post information
fetch_membergroupids_array (line 529)

Returns an array of usergroupids from all the usergroups to which a user belongs

  • return: Usergroup IDs to which the user belongs
array fetch_membergroupids_array (array $user, [boolean $getprimary = true])
  • array $user: User info array - must contain usergroupid and membergroupid fields
  • boolean $getprimary: Whether or not to fetch the user's primary group as part of the returned array
fetch_moderator_permissions (line 5554)

Returns moderator permissions bitfield for the given forum and user

integer fetch_moderator_permissions (integer $forumid, [integer $userid = -1], [boolean $useglobalperms = false])
  • integer $forumid: Forum ID
  • integer $userid: User ID
  • boolean $useglobalperms: Include Global Permissions for Super Moderators
fetch_musername (line 1193)

fetches the proper username markup and title

string fetch_musername (array &$user, [string $displaygroupfield = 'displaygroupid'], [string $usernamefield = 'username'])
  • array &$user: (ref) User info array
  • string $displaygroupfield: Name of the field representing displaygroupid in the User info array
  • string $usernamefield: Name of the field representing username in the User info array
fetch_options_overrides (line 6160)

Function to override various settings in $vbulletin->options depending on user preferences

void fetch_options_overrides (array $userinfo)
  • array $userinfo: User info array
fetch_permissions (line 5489)

Returns permissions for given forum and user

mixed fetch_permissions ([integer $forumid = 0], [integer $userid = -1], [array $userinfo = false])
  • integer $forumid: Forum ID
  • integer $userid: User ID
  • array $userinfo: User info array
fetch_perpage (line 2525)

Returns the number of items to display on a page based on a desired value and constraints.

If the desired value is not given use the default. Under no circumstances allow a value greater than maxperpage.

  • return: per page results
actual fetch_perpage (integer $perpage, [integer $maxperpage = 20], [integer $defaultperpage = 20])
  • integer $perpage: Desired number of results to show per-page
  • integer $maxperpage: Maximum allowable results to show per-page
  • integer $defaultperpage: Default number of results to show per-page
fetch_postinfo (line 1395)

Returns an array contining info for the specified post, or false if post is not found

mixed fetch_postinfo (integer &$postid)
  • integer &$postid: (ref) Post ID
fetch_profilefield_display (line 1568)

Converts the database value of a profilefield and prepares the displayable value as $profilefield['value']

  • return: Profilefield data including 'value' key
array fetch_profilefield_display (array &$profilefield, string $profilefield_value)
  • array &$profilefield: Profilefield data (SELECT * FROM profilefield WHERE profilefieldid = $profilefieldid)
  • string $profilefield_value: Database value of profilefield
fetch_query_sql (line 1138)

Returns an UPDATE or INSERT query string for use in big queries with loads of fields...

string fetch_query_sql (array $queryvalues, string $table, [string $condition = ''], [array $exclusions = ''])
  • array $queryvalues: Array of fieldname = value pairs - array('userid' => 21, 'username' => 'John Doe')
  • string $table: Name of the table into which the data should be saved
  • string $condition: SQL condition to add to the query string
  • array $exclusions: Array of field names that should be ignored from the $queryvalues array
fetch_random_password (line 460)

Generates a random password that is much stronger than what we currently use.

void fetch_random_password ([integer $length = 8])
  • integer $length: Length of desired password
fetch_random_string (line 487)

vBulletin's hash fetcher, note this may change from a-f0-9 to a-z0-9 in future.

void fetch_random_string ([integer $length = 32])
  • integer $length: Length of desired hash, limited to 40 characters at most
fetch_seo_url (line 6807)

Converts raw link information into an appropriate URL Verifies that the requested linktype can be handled

void fetch_seo_url (string $link, array $linkinfo, [array $pageinfo = null], [string $primaryid = null], [string $primarytitle = null])
  • string $link: Type of link, 'thread', etc
  • array $linkinfo: Specific information relevant to the page being linked to, $threadinfo, etc
  • array $pageinfo: Other information relevant to the page being linked to
  • string $primaryid: Override the default $linkinfo[userid] with $linkinfo[$primaryid]
  • string $primarytitle: Override the default $linkinfo[title] with $linkinfo[$primarytitle]
fetch_soft_break_string (line 884)

Breaks up strings (typically URLs) semi-invisibly to avoid word-wrapping issues

string fetch_soft_break_string (string $string)
  • string $string: Text to be broken
fetch_standard_deviated_levels (line 6996)

Spreads an array of values across the given number of stepped levels based on their standard deviation from the mean value.

The function accepts an array of $id => $value and returns $id => $level.

void fetch_standard_deviated_levels (array $values, [integer $levels = 5])
  • array $values:
    • Array of id => values
  • integer $levels:
    • Number of levels to assign
fetch_start_end_total_array (line 2962)

Returns an array so you can print 'Showing results $arr[first] to $arr[last] of $totalresults'

  • return: In the format of - array('first' => x, 'last' => y)
array fetch_start_end_total_array (integer $pagenumber, integer $perpage, integer $total)
  • integer $pagenumber: Current page number
  • integer $perpage: Results to show per-page
  • integer $total: Total results found
fetch_stylevars (line 6099)

Sets up the Fakey stylevars

array fetch_stylevars (array &$style, array $userinfo)
  • array &$style: (ref) Style info array
  • array $userinfo: User info array
fetch_template (line 3916)

Returns a single template from the templatecache or the database

string fetch_template (string $templatename, [integer $escape = 0], [boolean $gethtmlcomments = true])
  • string $templatename: Name of template to be fetched
  • integer $escape: Escape quotes in template? 1: escape template; -1: unescape template; 0: do nothing
  • boolean $gethtmlcomments:

    Wrap template in HTML comments showing the template name?

    TODO Delete this function

fetch_threadinfo (line 1314)

Returns an array containing info for the speficied thread, or false if thread is not found

mixed fetch_threadinfo (integer &$threadid, [ $usecache = true])
  • integer &$threadid: (ref) Thread ID
  • $usecache
fetch_time_data (line 4225)

Sets various time and date related variables according to visitor's preferences

Sets $timediff, $datenow, $timenow, $copyrightyear

void fetch_time_data ()
fetch_trimmed_title (line 830)

Trims a string to the specified length while keeping whole words

string fetch_trimmed_title (string $title, [integer $chars = -1], [boolean $append = true])
  • string $title: String to be trimmed
  • integer $chars: Number of characters to aim for in the trimmed string
  • boolean $append: Append "..." to shortened text
fetch_userinfo (line 1456)

Fetches an array containing info for the specified user, or false if user is not found

Values for Option parameter:

  1. - Nothing ...
  2. - Get avatar
4 - Process user's online location 8 - Join the customprofilpic table to get the userid just to check if we have a picture 16 - Join the administrator table to get various admin options 32 - Join the sigpic table to get the userid just to check if we have a picture 64 - Get user's custom CSS 128 - Is the logged in User a friend of this person? Therefore: Option = 6 means 'Get avatar' and 'Process online location' See fetch_userinfo() in the do=getinfo section of member.php if you are still confused

  • return: The information for the requested user
array fetch_userinfo (integer &$userid, [integer $option = 0], [ $languageid = 0])
  • integer &$userid: (ref) User ID
  • integer $option: Bitfield Option (see description)
  • $languageid
fetch_word_wrapped_string (line 795)

Attempts to intelligently wrap excessively long strings onto multiple lines

string fetch_word_wrapped_string (string $text, [integer $limit = false], [string $wraptext = ' '])
  • string $text: Text to be wrapped
  • integer $limit: If specified, max word wrap length
  • string $wraptext: Text to insert at the wrap point
file_extension (line 935)

Fetches the remaining characters in a filename after the final dot

  • return: The extension of the provided file
string file_extension (string $filename)
  • string $filename: The filename to test
iif (line 48)

Essentially a wrapper for the ternary operator.

  • return: Either the second or third parameter of this function
  • deprecated: Deprecated as of 3.5. Use the ternary operator.
mixed iif (string $expression, mixed $returntrue, [mixed $returnfalse = ''])
  • string $expression: Expression to be evaluated
  • mixed $returntrue: Return this if the expression evaluates to true
  • mixed $returnfalse: Return this if the expression evaluates to false
implode_both (line 6858)

Implodes an array using both values and keys

  • return: - The imploded result
string implode_both ([string $glue1 = ''], [string $glue2 = ''], mixed $array, [boolean $skip_empty = false])
  • string $glue1:
    • Glue between key and value
  • string $glue2:
    • Glue between value and key
  • mixed $array:
    • Arr to implode
  • boolean $skip_empty:
    • Whether to skip empty elements
init_language (line 6207)

Returns the initial $vbphrase array

array init_language ()
ini_size_to_bytes (line 61)

Converts shorthand string version of a size to bytes, 8M = 8388608

  • return: Value expanded to bytes
integer ini_size_to_bytes (string $value)
  • string $value: The value from ini_get that needs converted to bytes
in_coventry (line 628)

Works out if the specified user is 'in Coventry'

boolean in_coventry (integer $userid, [boolean $includeself = false])
  • integer $userid: User ID
  • boolean $includeself: Whether or not to confirm that the visiting user is himself in Coventry or not
is_browser (line 5894)

Browser detection system - returns whether or not the visiting browser is the one specified

boolean is_browser (string $browser, [float $version = 0])
  • string $browser: Browser name (opera, ie, mozilla, firebord, firefox... etc. - see $is array)
  • float $version: Minimum acceptable version for true result (optional)
is_came_from_search_engine (line 6441)

Checks whether or not user came from search engine

void is_came_from_search_engine ()
is_demo_mode (line 5880)

Returns whether or not vBulletin is running in demo mode

if DEMO_MODE is defined and set to true in config.php this function will return false, the main purpose of which is to disable parsing of stuff that is undesirable for a board running with a publicly accessible admin control panel

boolean is_demo_mode ()
is_member_of (line 560)

Works out if a user is a member of the specified usergroup(s)

This function can be overloaded to test multiple usergroups: is_member_of($user, 1, 3, 4, 6...)

boolean is_member_of (array $userinfo, integer $usergroupid, [boolean $cache = true])
  • array $userinfo: User info array - must contain userid, usergroupid and membergroupids fields
  • integer $usergroupid: Usergroup ID to test
  • boolean $cache: Pull result from cache
is_server (line 6061)

Check webserver's make and model

boolean is_server (string $server_name, [float $version = 0])
  • string $server_name: Browser name (apache, iis, samber, nginx... etc. - see $is array)
  • float $version: Minimum acceptable version for true result (optional)
is_valid_email (line 948)

Tests a string to see if it's a valid email address

boolean is_valid_email (string $email)
  • string $email: Email address
ncrencode (line 4709)

Converts a UTF-8 string into unicode NCR equivelants.

  • return: Encoded string
string ncrencode (string $str, [bool $skip_ascii = false])
  • string $str: String to encode
  • bool $skip_ascii: Only ncrencode unicode bytes
ncrencode_matches (line 4736)

NCR encodes matches from a preg_replace.

Single byte characters are preserved.

  • return: The encoded character
string ncrencode_matches (string $matches, [ $skip_ascii = false])
  • string $matches: The character to encode
  • $skip_ascii
ord_uni (line 4754)

Gets the Unicode Ordinal for a UTF-8 character.

  • return: Ordinal value or false if invalid
int ord_uni (string $chr)
  • string $chr: Character to convert
print_no_permission (line 3395)

Halts execution and shows an error message stating that the visitor does not have permission to view the page

void print_no_permission ()
print_output (line 6593)

Finishes off the current page (using templates), prints it out to the browser and halts execution

void print_output (string $vartext, [boolean $sendheader = true])
  • string $vartext: The HTML of the page to be printed
  • boolean $sendheader: Send the content length header?
print_standard_error (line 3532)

Returns eval()-able code to initiate a standard error

  • deprecated: Deprecated since 3.5. Use standard_error(fetch_error(...)) instead.
string print_standard_error (string $err_phrase, [boolean $doquery = true], [boolean $savebadlocation = true])
  • string $err_phrase: Name of error phrase
  • boolean $doquery: If false, use the name of error phrase as the phrase text itself
  • boolean $savebadlocation: If true, set the visitor's status on WOL to error page
print_standard_redirect (line 3652)

Returns eval()-able code to initiate a standard redirect

The global variable $url should contain the URL target for the redirect

string print_standard_redirect (string $redir_phrase, [boolean $doquery = true], [boolean $forceredirect = false], [integer $languageid = -1])
  • string $redir_phrase: Name of redirect phrase
  • boolean $doquery: If false, use the name of redirect phrase as the phrase text itself
  • boolean $forceredirect: Whether or not to force a redirect message to be shown
  • integer $languageid: Language ID to fetch the phrase from (-1 uses the page-wide default)
process_replacement_vars (line 6548)

Returns the provided string with occurences of replacement variables replaced with their appropriate replacement values

string process_replacement_vars (string $newtext, [array $paramstyle = false])
  • string $newtext: Text containing replacement variables
  • array $paramstyle: Override global $style if specified
render_navbar_template (line 3038)

Renders the navbar template with the specified navbits

  • return: Navbar HTML
string render_navbar_template (array $navbits)
  • array $navbits: Array of navbit information
render_option_template (line 3071)

Renders the option template. Simply a helper method to shorten the length of code to do this.

  • return: Option HTML
string render_option_template (string $optiontitle, string $optionvalue, [string $optionselected = ''], [string $optionclass = ''])
  • string $optiontitle: Title of the option
  • string $optionvalue: Value of the option (sent to the server on submission)
  • string $optionselected: If selected, should be string: selected="selected"
  • string $optionclass: A class to apply to the option
sanitize_maxposts (line 2454)

Ensures that the variables for a multi-page display are sane

  • return: Maximum posts perpage that a user can see
integer sanitize_maxposts ([ $perpage = 0])
  • $perpage
sanitize_pageresults (line 2494)

Ensures that the variables for a multi-page display are sane

void sanitize_pageresults (integer $numresults, integer &$page, integer &$perpage, [integer $maxperpage = 20], [integer $defaultperpage = 20])
  • integer $numresults: Total number of items to be displayed
  • integer &$page: (ref) Current page number
  • integer &$perpage: (ref) Desired number of results to show per-page
  • integer $maxperpage: Maximum allowable results to show per-page
  • integer $defaultperpage: Default number of results to show per-page
set_bbarray_cookie (line 2251)

Sets the value for data stored in an array-cookie

void set_bbarray_cookie (string $cookiename, mixed $id, mixed $value, [boolean $permanent = false])
  • string $cookiename: Name of the cookie
  • mixed $id: ID of the data within the cookie
  • mixed $value: Value for the data
  • boolean $permanent: If true, make this a permanent cookie
sign_client_string (line 2312)

Signs a string we intend to pass to the client but don't want them to alter

  • return: MD5 hash followed immediately by the string
string sign_client_string (string $string, [ $extra_entropy = ''])
  • string $string: String to be signed
  • $extra_entropy
split_string (line 167)

Splits a string into individual words for use in the search index

  • return: Array of words based on the input string
array split_string (string $string)
  • string $string: String to be seperated into individual words
standard_error (line 3560)

Halts execution and shows the specified error message

void standard_error ([string $error = ''], [string $headinsert = ''], [boolean $savebadlocation = true], [string $override_template = ''])
  • string $error: Error message
  • string $headinsert: Optional HTML code to insert in the <head> of the error page
  • boolean $savebadlocation: If true, set the visitor's status on WOL to error page
  • string $override_template: Optional template to force the display to use. Ignored if showing a lite error
standard_redirect (line 3682)

Halts execution and redirects to the address specified

If the 'useheaderredirect' option is on, the system will attempt to redirect invisibly using header('Location... However, 'useheaderredirect' is overridden by setting $forceredirect to a true value.

void standard_redirect ([string $message = ''], [string $forceredirect = false])
  • string $message: Redirect message
  • string $forceredirect: URL to which to redirect the browser
stripncrs (line 4697)

Strips NCRs from a string.

  • return: The result
string stripncrs (string $str)
  • string $str: The string to strip from
strip_bbcode (line 1899)

Strips away bbcode from a given string, leaving plain text

string strip_bbcode (string $message, [boolean $stripquotes = false], [boolean $fast_and_dirty = false], [boolean $showlinks = true], [boolean $stripimg = false])
  • string $message: Text to be stripped of bbcode tags
  • boolean $stripquotes: If true, strip away quote tags AND their contents
  • boolean $fast_and_dirty: If true, use the fast-and-dirty method rather than the shiny and nice method
  • boolean $showlinks: If true, display the url of the link in parenthesis after the link text
  • boolean $stripimg: If true, strip away img/video tags and their contents
strip_blank_ascii (line 673)

Replaces any non-printing ASCII characters with the specified string.

This also supports removing Unicode characters automatically when the entered value is >255 or starts with a 'u'.

string strip_blank_ascii (string $text, string $replace)
  • string $text: Text to be processed
  • string $replace: String with which to replace non-printing characters
strip_quotes (line 1791)

Strips away [quote] tags and their contents from the specified string

string strip_quotes (string $text)
  • string $text: Text to be stripped of quote tags
to_ascii (line 292)

Transliterates non ASCII chars to ASCII.

This is an approximation.

Note: Performance and accuracy is gained if the pecl translit extension is available.

string to_ascii (string $str)
  • string $str: String to transliterate
to_charset (line 4660)

Converts a string from one character encoding to another.

If the target encoding is not specified then it will be resolved from the current language settings.

  • return: The target encoding
string to_charset (string $in, string $in_encoding, [ $target_encoding = false])
  • string $in: The string to convert
  • string $in_encoding: The source encoding
  • $target_encoding
to_utf8 (line 4603)

Converts a string to utf8

  • return: The reencoded string
string to_utf8 (string $in, [string $charset = false])
  • string $in: The variable to clean
  • string $charset: The source charset
unhtmlspecialchars (line 4454)

Returns a string where HTML entities have been converted back to their original characters

string unhtmlspecialchars (string $text, [boolean $doUniCode = false])
  • string $text: String to be parsed
  • boolean $doUniCode: Convert unicode characters back from HTML entities?
update_loadavg (line 6483)

Updates the LoadAverage DataStore

void update_loadavg ()
urlencode_uni (line 4587)

Poor man's urlencode that only encodes specific characters and preserves unicode.

Use urldecode() to decode.

  • return: Encoded string
string urlencode_uni (string $str)
  • string $str: String to encode
urlimplode (line 6887)

Implodes an assoc array into a partial url query string

  • return: - The parsed result
string urlimplode (mixed $array, [boolean $skip_empty = true], [ $skip_urlencode = false], [ $preserve_uni = false])
  • mixed $array:
    • Array to parse
  • boolean $skip_empty:
    • Whether to skip empty elements
  • $skip_urlencode
  • $preserve_uni
vbchop (line 223)

Chops off a string at a specific length, counting entities as once character and using multibyte-safe functions if available.

  • return: Chopped string
string vbchop (string $string, integer $length)
  • string $string: String to chop
  • integer $length: Number of characters to chop at
vbdate (line 4288)

Formats a UNIX timestamp into a human-readable string according to vBulletin prefs

Note: Ifvbdate() is called with a date format other than than one in $vbulletin->options[], set $locale to false unless you dynamically set the date() and strftime() formats in the vbdate() call.

  • return: Formatted date string
string vbdate (string $format, [integer $timestamp = TIMENOW], [boolean $doyestoday = false], [boolean $locale = true], [boolean $adjust = true], [boolean $gmdate = false], [array $userinfo = ''])
  • string $format: Date format string (same syntax as PHP's date() function)
  • integer $timestamp: Unix time stamp
  • boolean $doyestoday: If true, attempt to show strings like "Yesterday, 12pm" instead of full date string
  • boolean $locale: If true, and user has a language locale, use strftime() to generate language specific dates
  • boolean $adjust: If true, don't adjust time to user's adjusted time .. (think gmdate instead of date!)
  • boolean $gmdate: If true, uses gmstrftime() and gmdate() instead of strftime() and date()
  • array $userinfo: If set, use specified info instead of $vbulletin->userinfo
vbheaders_sent (line 2025)

Checks whether or not any headers have been sent to the browser yet

  • return: True if headers have been sent
boolean vbheaders_sent (string &$filename, integer &$linenum)
  • string &$filename: (ref) File name (> PHP 4.3.x)
  • integer &$linenum: (ref) Line number (> PHP 4.3.x)
vbmail (line 1001)

Starts the process of sending an email - either immediately or by adding it to the mail queue.

void vbmail (string $toemail, string $subject, string $message, [boolean $notsubscription = false], [string $from = ''], [string $uheaders = ''], [string $username = ''])
  • string $toemail: Destination email address
  • string $subject: Email message subject
  • string $message: Email message body
  • boolean $notsubscription: If true, do not use the mail queue and send immediately
  • string $from: Optional name/email to use in 'From' header
  • string $uheaders: Additional headers
  • string $username: Username of person sending the email
vbmail_end (line 1059)

Stop adding mail to the mail queue and insert the mailqueue data for sending later

void vbmail_end ()
vbmail_start (line 979)

Begin adding email to the mail queue

void vbmail_start ()
vbrand (line 502)

vBulletin's own random number generator

void vbrand ([integer $min = 0], [integer $max = 0], [mixed $seed = -1])
  • integer $min: Minimum desired value
  • integer $max: Maximum desired value
  • mixed $seed: Seed for the number generator (if not specified, a new seed will be generated)
vbsetcookie (line 2040)

Sets a cookie based on vBulletin environmental settings

void vbsetcookie (string $name, [mixed $value = ''], [boolean $permanent = true], [boolean $allowsecure = true], [boolean $httponly = false])
  • string $name: Cookie name
  • mixed $value: Value to store in the cookie
  • boolean $permanent: If true, do not set an expiry date for the cookie
  • boolean $allowsecure: Allow secure cookies (SSL)
  • boolean $httponly: Set 'httponly' for cookies in supported browsers
vbstrlen (line 195)

Attempts to do a character-based strlen on data that might contain HTML entities.

By default, it only converts numeric entities but can optional convert &quot;, &lt;, etc. Uses a multi-byte aware function to do the counting if available.

  • return: Length of string
integer vbstrlen (string $string, [boolean $unhtmlspecialchars = false])
  • string $string: String to be measured
  • boolean $unhtmlspecialchars: If true, run unhtmlspecialchars on string to count &quot; as one, etc.
vbstrtolower (line 144)

Converts A-Z to a-z, doesn't change any other characters

  • return: Lowercase string
string vbstrtolower (string $string)
  • string $string: String to convert to lowercase
vb_number_format (line 387)

Formats a number with user's own decimal and thousands chars

  • return: The formatted number
mixed vb_number_format (mixed $number, [integer $decimals = 0], [boolean $bytesize = false], [ $decimalsep = null], [ $thousandsep = null])
  • mixed $number: Number to be formatted: integer / 8MB / 16 GB / 6.0 KB / 3M / 5K / ETC
  • integer $decimals: Number of decimal places to display
  • boolean $bytesize: Special case for byte-based numbers
  • $decimalsep
  • $thousandsep
verify_client_string (line 2335)

Verifies a string return from a client that it has been unaltered

  • return: String without the verification hash or false on failure
string|boolean verify_client_string (string $string, [ $extra_entropy = ''])
  • string $string: String from the client to be verified
  • $extra_entropy
verify_forum_password (line 4905)

Returns whether or not the visiting user can view the specified password-protected forum

boolean verify_forum_password (integer $forumid, string $password, [boolean $showerror = true])
  • integer $forumid: Forum ID
  • string $password: Provided password
  • boolean $showerror: If true, show error when access is denied
verify_id (line 1692)

Multi-purpose function to verify that an item exists and fetch data at the same time

This function works with threads, forums, posts, users and other tables that obey the {item}id, title convention. If the data is not found and execution is not halted, a false value will be returned

mixed verify_id (string $idname, integer &$id, [boolean $alert = true], [boolean $selall = false], [integer $options = 0])
  • string $idname: Name of the ID field to be fetched (forumid, threadid etc.)
  • integer &$id: (ref) ID of the item to be fetched
  • boolean $alert: If true, halt and show error when data is not found
  • boolean $selall: If true, 'SELECT *' instead of selecting just the ID field
  • integer $options: Bitfield options to be passed to fetch_userinfo()
verify_ip_ban (line 896)

Checks to see if the IP address of the visiting user is banned from visiting

This function will show an error and halt execution if the IP is banned.

void verify_ip_ban ()
verify_security_token (line 2367)

Verifies a security token is valid

  • return: True if the hash matches and is within the correct TTL
boolean verify_security_token (string $request_token, string $user_token)
  • string $request_token: Security token from the REQUEST data
  • string $user_token: Security token used in the hash
verify_seo_url (line 6826)

Verifies that we are at the proper canonical seo url based on admin settings

void verify_seo_url (string $link, array $linkinfo, [array $pageinfo = null], [string $primaryid = null], [string $primarytitle = null])
  • string $link: Type of link, 'thread', etc
  • array $linkinfo: Specific information relevant to the page being linked to, $threadinfo, etc
  • array $pageinfo: Other information relevant to the page being linked to
  • string $primaryid: Override the default $linkinfo[userid] with $linkinfo[$primaryid]
  • string $primarytitle: Override the default $linkinfo[title] with $linkinfo[$primarytitle]

Documentation generated on Tue, 26 Jan 2010 15:15:57 -0600 by phpDocumentor 1.4.3