X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fglobal.php;h=1faeac33917879d79387f97a244b9800fbe273da;hb=aa84daced451fe171b6b606939dba8df6bcab26c;hp=81ccfafe5330986ef333e46c1e0c34829aecc9a9;hpb=6fe417ab9d6dcc115871cae158fd6665d9bd73be;p=squirrelmail.git diff --git a/functions/global.php b/functions/global.php index 81ccfafe..1faeac33 100644 --- a/functions/global.php +++ b/functions/global.php @@ -7,7 +7,7 @@ * It also has some session register functions that work across various * php versions. * - * @copyright © 1999-2006 The SquirrelMail Project Team + * @copyright © 1999-2007 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package squirrelmail @@ -84,59 +84,51 @@ function sqstripslashes(&$array) { } /** - * Merges two variables into a single 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. * - * Similar to PHP array_merge function, but provides same - * functionality as array_merge without losing array values - * with same key names. If the values under identical array - * keys are both strings and $concat_strings is TRUE, those - * values are concatenated together, otherwise they are placed - * in a sub-array and are merged (recursively) in the same manner. + * 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). * - * If either of the elements being merged is not an array, - * it will simply be added to the returned array. - * - * If both values are strings and $concat_strings is TRUE, - * a concatenated string is returned instead of an array. - * - * @param mixed $a First element to be merged - * @param mixed $b Second element to be merged - * @param boolean $concat_strings Whether or not string values - * should be concatenated instead - * of added to different array - * keys (default TRUE) + * @since 1.4.12 and 1.5.2 * - * @return array The merged $a and $b in one array + * @param string $function The function to be executed + * @param array $args The arguments to be passed to the function + * (OPTIONAL; default no arguments) + * NOTE: The caller must take extra action if + * the function being called is supposed + * to use any of the parameters by + * reference. In the following example, + * $x is passed by reference and $y is + * passed by value to the "my_func" + * function. + * sq_call_function_suppress_errors('my_func', array(&$x, $y)); + * + * @return mixed The return value, if any, of the function being + * executed will be returned. * */ -function sq_array_merge($a, $b, $concat_strings=true) { - - $ret = array(); +function sq_call_function_suppress_errors($function, $args=NULL) { + global $sm_debug_mode; - if (is_array($a)) { - $ret = $a; - } else { - if (is_string($a) && is_string($b) && $concat_strings) { - return $a . $b; - } - $ret[] = $a; - } + $display_errors = ini_get('display_errors'); + ini_set('display_errors', '0'); + // if advanced debug mode isn't enabled, don't log the error, either + // + if (!($sm_debug_mode & SM_DEBUG_MODE_ADVANCED)) + $error_reporting = error_reporting(0); - if (is_array($b)) { - foreach ($b as $key => $value) { - if (isset($ret[$key])) { - $ret[$key] = sq_array_merge($ret[$key], $value, $concat_strings); - } else { - $ret[$key] = $value; - } - } - } else { - $ret[] = $b; - } + $ret = call_user_func_array($function, $args); - return $ret; + if (!($sm_debug_mode & SM_DEBUG_MODE_ADVANCED)) + error_reporting($error_reporting); + ini_set('display_errors', $display_errors); + return $ret; } /** @@ -149,9 +141,7 @@ function sqsession_register ($var, $name) { sqsession_is_active(); - $_SESSION["$name"] = $var; - - session_register("$name"); + $_SESSION[$name] = $var; } /** @@ -185,6 +175,91 @@ function sqsession_is_registered ($name) { return $result; } + +/** + * 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 + *