X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;ds=sidebyside;f=functions%2Fglobal.php;h=f470a481475c78918af34bd3ec06d2aa79656fa6;hb=5619673737450c926cf406d4aeb802d0544f52ed;hp=b9d63097676b9ba9bc4bafa85376d3ee88d4e86d;hpb=d7c82551df7a28530139681c44a283836be6b6fc;p=squirrelmail.git diff --git a/functions/global.php b/functions/global.php index b9d63097..f470a481 100644 --- a/functions/global.php +++ b/functions/global.php @@ -1,144 +1,734 @@ $value) { - if (is_array($array["$index"])) { - sqstripslashes($array["$index"]); - } - else { - $array["$index"] = stripslashes($value); + if(count($array) > 0) { + foreach ($array as $index=>$value) { + if (is_array($array[$index])) { + sqstripslashes($array[$index]); + } + else { + $array[$index] = stripslashes($value); + } } } } +/** + * Add a variable to the session. + * @param mixed $var the variable to register + * @param string $name the name to refer to this variable + * @return void + */ function sqsession_register ($var, $name) { - if ( (float)substr(PHP_VERSION,0,3) < 4.1 ) { - global $HTTP_SESSION_VARS; - $HTTP_SESSION_VARS["$name"] = $var; - } - else { - $_SESSION["$name"] = $var; - } + + sqsession_is_active(); + + $_SESSION[$name] = $var; } + +/** + * Delete a variable from the session. + * @param string $name the name of the var to delete + * @return void + */ function sqsession_unregister ($name) { - if ( (float)substr(PHP_VERSION,0,3) < 4.1 ) { - global $HTTP_SESSION_VARS; - unset($HTTP_SESSION_VARS["$name"]); - } - else { - unset($_SESSION["$name"]); - } + + sqsession_is_active(); + + unset($_SESSION[$name]); + + session_unregister("$name"); } + +/** + * Checks to see if a variable has already been registered + * in the session. + * @param string $name the name of the var to check + * @return bool whether the var has been registered + */ function sqsession_is_registered ($name) { $test_name = &$name; $result = false; - if ( (float)substr(PHP_VERSION,0,3) < 4.1 ) { - global $HTTP_SESSION_VARS; - if (isset($HTTP_SESSION_VARS[$test_name])) { - $result = true; + + if (isset($_SESSION[$test_name])) { + $result = true; + } + + 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 + *