global.php
This includes code to update < 4.1.0 globals to the newer format It also has some session register functions that work across various php versions.
returns true if current php version is at mimimum a.b.c
Called: check_php_version(4,1)
returns true if the current internal SM version is at minimum a.b.c These are plain integer comparisons, as our internal version is constructed by us, as an array of 3 ints.
Called: check_sm_version(1,3,3)
Endeavor to detect what user and group PHP is currently running as. Probably only works in non-Windows environments.
Get an immutable copy of a configuration variable if SquirrelMail
is in "secured configuration" mode. This guarantees the caller gets a copy of the requested value as it is set in the main application configuration (including config_local overrides), and not what it might be after possibly having been modified by some other code (usually a plugin overriding configuration values for one reason or another).
WARNING: Please use this function as little as possible, because every time it is called, it forcibly reloads the main configuration file(s).
Caller beware that this function will do nothing if SquirrelMail is not in "secured configuration" mode per the $secured_config setting.
Detect whether or not we have a SSL secured (HTTPS) connection connection to the browser
It is thought to be so if you have 'SSLOptions +StdEnvVars' in your Apache configuration, OR if you have HTTPS set to a non-empty value (except "off") in your HTTP_SERVER_VARS, OR if you have HTTP_X_FORWARDED_PROTO=https in your HTTP_SERVER_VARS, OR if you are on port 443.
Note: HTTP_X_FORWARDED_PROTO could be sent from the client and therefore possibly spoofed/hackable. Thus, SquirrelMail ignores such headers by default. The administrator can tell SM to use such header values by setting $sq_ignore_http_x_forwarded_headers to boolean FALSE in config/config.php or by using config/conf.pl.
Note: It is possible to run SSL on a port other than 443, and if that is the case, the administrator should set $sq_https_port in config/config.php or by using config/conf.pl.
session_regenerate_id replacement for PHP < 4.3.2
This code is borrowed from Gallery, session.php version 1.53.2.1
php_self
Attempts to determine the path and filename and any arguments for the currently executing script. This is usually found in $_SERVER['REQUEST_URI'], but some environments may differ, so this function tries to standardize this value.
Note that before SquirrelMail version 1.5.1, this function was stored in function/strings.php.
Print variable
sm_print_r($some_variable, [$some_other_variable [, ...]]);
Debugging function - does the same as print_r, but makes sure special characters are converted to htmlentities first. This will allow values like <[email protected]> to be displayed. The output is wrapped in <pre> and </pre> tags. Since 1.4.2 accepts unlimited number of arguments.
Search for the variable $name in one or more of the global variables $_SESSION, $_POST, $_GET, $_COOKIE, and $_SERVER, and set the value of it in the variable $vaule.
$search must be one of the defined constants below. The default is SQ_INORDER. Both SQ_INORDER and SQ_FORM stops on the first match.
SQ_INORDER searches $_SESSION, then $_POST, and then $_GET. SQ_FORM searches $_POST and then $_GET. SQ_COOKIE searches $_COOKIE only. SQ_GET searches $_GET only. SQ_POST searches $_POST only. SQ_SERVER searches $_SERVER only. SQ_SESSION searches $_SESSION only.
Example: sqgetGlobalVar('username', $username, SQ_SESSION); // No quotes around the last parameter, it's a constant - not a string!
Retrieves a form variable, from a set of possible similarly named
form variables, based on finding a different, single field. This is intended to allow more than one same-named inputs in a single <form>, where the submit button that is clicked tells us which input we should retrieve. An example is if we have: <select name="startMessage_1"> <select name="startMessage_2"> <input type="submit" name="form_submit_1" /> <input type="submit" name="form_submit_2" /> and we want to know which one of the select inputs should be returned as $startMessage (without the suffix!), this function decides by looking for either "form_submit_1" or "form_submit_2" (both should not appear). In this example, $name should be "startMessage" and $indicator_field should be "form_submit".
NOTE that form widgets must be named with the suffix "_1", "_2", "_3" and so on, or this function will not work.
If more than one of the indicator fields is found, the first one (numerically) will win.
If an indicator field is found without a matching input ($name) field, FALSE is returned.
If no indicator fields are found, a field of $name *without* any suffix is searched for (but only if $fallback_no_suffix is TRUE), and if not found, FALSE is ultimately returned.
It should also be possible to use the same string for both $name and $indicator_field to look for the first possible widget with a suffix that can be found (and possibly fallback to a widget without a suffix).
Deletes an existing session, more advanced than the standard PHP session_destroy(), it explicitly deletes the cookies and global vars.
WARNING: Older PHP versions have some issues with session management. See http://bugs.php.net/11643 (warning, spammed bug tracker) and http://bugs.php.net/13834. SID constant is not destroyed in PHP 4.1.2, 4.2.3 and maybe other versions. If you restart session after session is destroyed, affected PHP versions produce PHP notice. Bug should be fixed only in 4.3.0
Function to verify a session has been started. If it hasn't
start a session up. php.net doesn't tell you that $_SESSION (even though autoglobal), is not created unless a session is started, unlike $_POST, $_GET and such Update: (see #1685031) the session ID is left over after the session is closed in some PHP setups; this function just becomes a passthru to sqsession_start(), but leaving old code in for edification.
Checks to see if a variable has already been registered in the session.
Add a variable to the session.
Function to start the session and store the cookie with the session_id as
HttpOnly cookie which means that the cookie isn't accessible by javascript (IE6 only) Note that as sqsession_is_active() no longer discriminates as to when it calls this function, session_start() has to have E_NOTICE suppression (thus the @ sign).
Delete a variable from the session.
Set a cookie
Recursively strip slashes from the values of an array.
Squelch error output to screen (only) for the given function.
If the SquirrelMail debug mode SM_DEBUG_MODE_ADVANCED is not enabled, error output will not go to the log, either.
This provides an alternative to the @ error-suppression operator where errors will not be shown in the interface but will show up in the server log file (assuming the administrator has configured PHP logging).
Sanitize a value using sm_encode_html_special_chars() or similar, but also recursively run sm_encode_html_special_chars() (or similar) on array keys and values.
If $value is not a string or an array with strings in it, the value is returned as is.
Documentation generated on Mon, 13 Jan 2020 04:22:40 +0100 by phpDocumentor 1.4.3