catch_fatal_errors (line 704)
ocPortal error catcher for fatal versions. This is hooked in only on PHP5.2 as error_get_last() only works on these versions.
void
catch_fatal_errors
()
convert_data_encodings (line 1811)
Performs lots of magic to make sure data encodings are converted correctly. Input, and output too (as often stores internally in UTF or performs automatic dynamic conversions from internal to external charsets).
Roll on PHP6 that has a true internal UTF string model. For now, anyone who uses UTF will get some (albeit minor) imperfections from PHP's manipulations of the strings.
void
convert_data_encodings
([boolean $known_utf8 = false])
-
boolean
$known_utf8: Whether we know we are working in UTF-8. This is the case for AJAX calls.
css_enforce (line 1640)
Force a CSS file to be cached.
string
css_enforce
(string $c, [?ID_TEXT $theme = NULL], [?boolean $minify = NULL])
-
string
$c: The CSS file required
-
?ID_TEXT
$theme: The name of the theme (NULL: current theme)
-
?boolean
$minify: Whether to minify (NULL: read from environment)
css_tempcode (line 1693)
Get tempcode to tie in (to the HTML, in <head>) all the CSS files that have been required.
tempcode
css_tempcode
([boolean $inline = false], [boolean $only_global = false], [?string $context = NULL])
-
boolean
$inline: Force inline CSS
-
boolean
$only_global: Only do global CSS
-
?string
$context: HTML context for which we filter (minimise) any CSS we spit out as inline (NULL: none)
disable_php_memory_limit (line 603)
Disable the PHP memory limit. Do not use this carelessly, use it if a screen is a bit fat or in an importer, don't use it assuming memory is infinite.
void
disable_php_memory_limit
()
either_param (line 1228)
Get a value (either POST [u]or[/u] GET), or the default if neither can be found.
?string
either_param
(ID_TEXT $name, [?mixed $default = false])
-
ID_TEXT
$name: The name of the parameter to get
-
?mixed
$default: The default value to give the parameter if the parameter value is not defined (NULL: allow missing parameter) (false: give error on missing parameter)
either_param_integer (line 1381)
This function is the integeric partner of either_param, as it returns the value as an integer.
You should always use integer specified versions when inputting integers, for the added security that type validation allows. If the value is of the wrong type, it indicates a hack attempt and will be logged.
?integer
either_param_integer
(ID_TEXT $name, [?mixed $default = false])
-
ID_TEXT
$name: The name of the parameter to get
-
?mixed
$default: The default value to give the parameter if the parameter value is not defined or the empty string (NULL: allow missing parameter) (false: give error on missing parameter)
fatal_exit (line 912)
Do a fatal exit, echo the header (if possible) and an error message, followed by a debugging back-trace.
It also adds an entry to the error log, for reference.
void
fatal_exit
(mixed $text)
-
mixed
$text: The error message (string or tempcode)
find_script (line 1088)
Find the URL to a certain external handler script (ocPortal allows these to be moved around between zones, to suit site .htaccess requirements).
URLPATH
find_script
(string $name, [boolean $append_keep = false], [integer $base_url_code = 0])
-
string
$name: The codename of the needed script
-
boolean
$append_keep: Whether to append keep variables
-
integer
$base_url_code: Code representing what base URL type to use (0=guess, 1=http, 2=https)
get_base_url (line 1123)
Get the base url (the minimum fully qualified URL to our installation).
URLPATH
get_base_url
([?boolean $https = NULL], [?ID_TEXT $zone_for = NULL])
-
?boolean
$https: Whether to get the HTTPS base URL (NULL: do so only if the current page uses the HTTPS base URL)
-
?ID_TEXT
$zone_for: The zone the link is for (NULL: root zone)
get_charset (line 621)
Get the character set to use. We try and be clever to allow AJAX scripts to avoid loading up language
string
get_charset
()
get_complex_base_url (line 1216)
Function to get a base URL for an OCF relative-URL. The situation is complex as it needs to take into account OCF multi-site-network's, locally defined theme images, and shared-installs (myocp style).
URLPATH
get_complex_base_url
(URLPATH $at)
-
URLPATH
$at: Short base URL we need to probe
get_cookie_days (line 1053)
Get the number of days to store our cookies.
integer
get_cookie_days
()
get_cookie_domain (line 1041)
Get the ocPortal cookie domain.
?string
get_cookie_domain
()
get_cookie_path (line 1029)
Get the ocPortal cookie path.
?string
get_cookie_path
()
get_custom_base_url (line 1199)
Get the base url (the minimum fully qualified URL to our personal data installation). For a shared install only, this is different to the base-url.
URLPATH
get_custom_base_url
([?boolean $https = NULL])
-
?boolean
$https: Whether to get the HTTPS base URL (NULL: do so only if the current page uses the HTTPS base URL)
get_domain (line 980)
Get the domain the website is installed on (preferably, without any www). The domain is used for e-mail defaults amongst other things.
string
get_domain
()
get_forum_base_url (line 1012)
Get the installed forum base URL.
URLPATH
get_forum_base_url
([boolean $forum_base = false])
-
boolean
$forum_base: Whether to get the base directory of the forum. Unless running OCF, this makes no difference - if possibly running OCF, you need to think about this parameter: are you trying to reach the MSN-central-site or just a link to the forums?
get_forum_type (line 999)
Get the type of forums installed.
string
get_forum_type
()
get_param (line 1296)
Get the value of the specified GET key, if it is found, or the default otherwise.
?string
get_param
(ID_TEXT $name, [?mixed $default = false], [boolean $no_security = false])
-
ID_TEXT
$name: The name of the parameter to get
-
?mixed
$default: The default value to give the parameter if the parameter value is not defined (NULL: allow missing parameter) (false: give error on missing parameter)
-
boolean
$no_security: Whether to skip the security check
get_param_integer (line 1434)
This function is the integeric partner of get_param, as it returns the value as an integer.
?integer
get_param_integer
(ID_TEXT $name, [?mixed $default = false], [boolean $not_string_ok = false])
-
ID_TEXT
$name: The name of the parameter to get
-
?mixed
$default: The default value to give the parameter if the parameter value is not defined or the empty string (NULL: allow missing parameter) (false: give error on missing parameter)
-
boolean
$not_string_ok: If a string is given, use the default parameter rather than giving an error (only use this if you are suffering from a parameter conflict situation between different parts of ocPortal)
get_site_name (line 1064)
Get the site name.
string
get_site_name
()
handle_has_checked_recently (line 937)
Use the url_title_cache table (a bit of a hack but saved changed the DB structure) to see if a check-op was performed has been performed within the last 30 days.
boolean
handle_has_checked_recently
(ID_TEXT $id_code)
-
ID_TEXT
$id_code: Special check code (often a URL but does not need to be).
inform_exit (line 860)
This is a intended to output an informational exit at the same time as terminating execution
void
inform_exit
(mixed $text)
-
mixed
$text: The error message (string or tempcode)
init__global2 (line 24)
Standard code module initialisation function.
void
init__global2
()
in_safe_mode (line 1074)
Find whether we are running in safe mode.
boolean
in_safe_mode
()
is_browser_decacheing (line 813)
Find whether the browser session is set to be doing a hard cache-empty refresh.
boolean
is_browser_decacheing
()
javascript_enforce (line 1493)
Force a Javascript file to be cached (ordinarily we can rely on this to be automated by require_javascript/javascript_tempcode).
string
javascript_enforce
(string $j)
-
string
$j: The javascript file required
javascript_tempcode (line 1539)
Get tempcode to tie in (to the HTML, in <head>) all the Javascript files that have been required.
tempcode
javascript_tempcode
([?string $position = NULL])
-
?string
$position: Position to get Javascript for (NULL: all positions)
load_user_stuff (line 678)
Load stuff that allows user code to work.
void
load_user_stuff
()
log_hack_attack_and_exit (line 925)
Log a hackattack, then displays an error message. It also attempts to send an e-mail to the staff alerting them of the hackattack.
void
log_hack_attack_and_exit
(ID_TEXT $reason, [SHORT_TEXT $reason_param_a = ''], [SHORT_TEXT $reason_param_b = ''])
-
ID_TEXT
$reason: The reason for the hack attack. This has to be a language string codename
-
SHORT_TEXT
$reason_param_a: A parameter for the hack attack language string (this should be based on a unique ID, preferably)
-
SHORT_TEXT
$reason_param_b: A more illustrative parameter, which may be anything (e.g. a title)
make_seed (line 957)
A custom random number seed generator. It returns a random number seed.
integer
make_seed
()
ocportal_error_handler (line 743)
ocPortal error handler (hooked into PHP error system).
boolean
ocportal_error_handler
(integer $errno, PATH $errstr, string $errfile, integer $errline)
-
integer
$errno: The error code-number
-
PATH
$errstr: The error message
-
string
$errfile: The file the error occured in
-
integer
$errline: The line the error occured on
ocp_version_full (line 969)
Get the full string version of ocPortal that you are running.
string
ocp_version_full
()
post_param (line 1243)
Get the value of the specified POST key, if it is found, or the default otherwise.
?string
post_param
(ID_TEXT $name, [?mixed $default = false], [boolean $html = false])
-
ID_TEXT
$name: The name of the parameter to get
-
?mixed
$default: The default value to give the parameter if the parameter value is not defined (NULL: allow missing parameter) (false: give error on missing parameter)
-
boolean
$html: Whether we are cleaning for HTML rather than Comcode/plain-text
post_param_integer (line 1407)
This function is the integeric partner of post_param, as it returns the value as an integer.
?integer
post_param_integer
(ID_TEXT $name, [?mixed $default = false])
-
ID_TEXT
$name: The name of the parameter to get
-
?mixed
$default: The default value to give the parameter if the parameter value is not defined or the empty string (NULL: allow missing parameter) (false: give error on missing parameter)
require_css (line 1753)
Make sure that the given CSS file is loaded up.
void
require_css
(ID_TEXT $css)
-
ID_TEXT
$css: The CSS file required
require_javascript (line 1612)
Make sure that the given javascript file is loaded up.
void
require_javascript
(ID_TEXT $javascript)
-
ID_TEXT
$javascript: The javascript file required
running_script (line 834)
Find whether a certain script is being run to get here.
boolean
running_script
(string $is_this_running)
-
string
$is_this_running: Script filename (canonically we want NO .php file type suffix)
simulated_wildcard_match (line 1365)
Do a wildcard match by converting to a regular expression.
boolean
simulated_wildcard_match
(string $context, string $word, [boolean $full_cover = false])
-
string
$context: The haystack
-
string
$word: The needle (a wildcard expression)
-
boolean
$full_cover: Whether full-coverance is required
suggest_fatalistic (line 883)
Give the user an option to see a stack trace by adding in a link, but only if they have permission
void
suggest_fatalistic
()
sync_file (line 1772)
Provides a hook for file synchronisation between mirrored servers. Called after any file creation, deletion or edit.
void
sync_file
(PATH $filename)
-
PATH
$filename: File/directory name to sync on (full path)
sync_file_move (line 1799)
Provides a hook for file-move synchronisation between mirrored servers. Called after any rename or move action.
void
sync_file_move
(PATH $old, PATH $new)
-
PATH
$old: File/directory name to move from (may be full or relative path)
-
PATH
$new: File/directory name to move to (may be full or relative path)
unixify_line_format (line 1473)
Make sure that lines are seperated by chr(10), with no chr(13)'s there at all. For Mac data, this will be a flip scenario. For Linux data this will be a null operation. For windows data this will be change from chr(13).chr(10) to just chr(10). For a realistic scenario, data could have originated on all kinds of platforms, with some editors converting, some situations being inter-platform, and general confusion. Don't make blind assumptions - use this function to clean data, then write clean code that only considers chr(10)'s.
string
unixify_line_format
(string $in, [?ID_TEXT $desired_charset = NULL], [boolean $html = false])
-
string
$in: The data to clean
-
?ID_TEXT
$desired_charset: The character set it should be in. We don't do any real conversions using this, only make sure that common problems with fed ISO-8859-1 data are resolved (NULL: output character set)
-
boolean
$html: Whether we are cleaning for HTML rather than Comcode/plain-text
warn_exit (line 871)
This is a less-revealing alternative to fatal_exit, that is used for user-errors/common-corruption-scenarios
void
warn_exit
(mixed $text)
-
mixed
$text: The error message (string or tempcode)
will_be_unicode_neutered (line 1936)
Guard for entity_utf8_decode. Checks that the data can be stripped so there is no unicode left. Either the htmlentities function must convert mechanically to entity-characters or all higher ascii character codes (which are actually unicode control codes in a unicode interpretation) that are used happen to be linked to named entities.
boolean
will_be_unicode_neutered
(string $data)
-
string
$data: Data to check.
__param (line 1334)
Helper function to load up a GET/POST parameter.
string
__param
(array $array, string $name, ?mixed $default, [boolean $integer = false], [?boolean $posted = false])
-
array
$array: The array we're extracting parameters from
-
string
$name: The name of the parameter
-
?mixed
$default: The default value to give the parameter if the parameter value is not defined (NULL: allow missing parameter) (false: give error on missing parameter)
-
boolean
$integer: Whether the parameter has to be an integer
-
?boolean
$posted: Whether the parameter is a POST parameter (NULL: undetermined)