From: andi <bin...@li...> - 2001-10-01 09:26:24
|
andi Mon Oct 1 02:25:59 2001 EDT Modified files: /r2/binarycloud/base/core Request.php Log: Fixed a bug in GetVar() that has returned 0 instead of 'undefined'. Thanks to Dave for fixing it. Index: r2/binarycloud/base/core/Request.php diff -u r2/binarycloud/base/core/Request.php:1.10 r2/binarycloud/base/core/Request.php:1.11 --- r2/binarycloud/base/core/Request.php:1.10 Wed Sep 12 08:10:08 2001 +++ r2/binarycloud/base/core/Request.php Mon Oct 1 02:25:58 2001 @@ -1,10 +1,11 @@ <?php // Header {{{ /* - * -File $Id: Request.php,v 1.10 2001/09/12 15:10:08 andi Exp $ - * -License LGPL (http://www.gnu.org/copyleft/lesser.html) - * -Copyright 2001, The Turing Studio, Inc. - * -Authors Andreas Aderhold, <a.a...@th...> + * -File $Id: Request.php,v 1.11 2001/10/01 09:25:58 andi Exp $ + * -License LGPL (http://www.gnu.org/copyleft/lesser.html) + * -Copyright 2001, Thyrell + * -Authors Andreas Aderhold, <a.a...@th...> + * -Authors David Weingart, <dwe...@po...> */ $PACKAGE='binarycloud.core'; @@ -32,8 +33,9 @@ * $tmp = $R->GetVar('mPersistents'); * $val = $tmp['navbar']; * - * @author Andreas Aderhold, a.a...@th... - * @version $Id: Request.php,v 1.10 2001/09/12 15:10:08 andi Exp $ + * @author Andreas Aderhold, <a.a...@th...> + * @author David Weingart, <dwe...@po...> + * @version $Id: Request.php,v 1.11 2001/10/01 09:25:58 andi Exp $ */ class Request { @@ -58,7 +60,6 @@ var $scriptpath; // basepath of current script // method Request($_varOrder) {{{ - /** * Constructor. Sets the default variables order if user wants to * override. Default is setting the php.ini/.htaccess/vhost defaults. @@ -83,7 +84,6 @@ // }}} // method _Request() {{{ - /** * Destructor. Not working yet. Included for future use. * @@ -96,7 +96,6 @@ // }}} // method SetVarOrder($_varOrder) {{{ - /** * Sets the varOrder property. If not given any paramter * the class default is used. You can pass the following @@ -134,52 +133,7 @@ } // }}} - // will be removed {{{ - - /** - * Gets a variable value from path information. You need the Apache Server - * to make use of this feauture. - * Note that you only can fetch "values" so you have to provide the index - * of the value you need. i.e.: - * - * www.foo.com/path/to/php/scriptname/100 - * | | - * | +-- GetPathVar(1); - * GetPathVar(0) --+ - * - * Warning: This method is still experimental and not tested in production - * environments!!! Be careful if you're using it - * - * @access public - * @param int Index of value - * @param string Explicitly cast to type - * @return mixed Value itself - * - * @author Andreas Aderhold, <a.a...@th...> - */ - - function GetPathVar($_index, $_type = null) { - if ($this->pathinfo == "/" || $this->pathinfo === $this->undefined) { - return $this->undefined; - } - - $aryParams = explode('/', $this->pathinfo); - $aryParams[0] = $this->scriptbase; - - if (!isset($aryParams[$_index]) || empty($aryParams[$_index])) { - return $this->undefined; - } - switch ($_type) { - case 'integer': return(intval($aryParams[$_index])); - case 'string': return(strval($aryParams[$_index])); - case 'float': return(doubleval($aryParams[$_index])); - default: return($aryParams[$_index]); - } - } - - // }}} // GetStringVar($_name, $_hash) {{{ - /** * Gets a variable explicitly casted to string. * @@ -201,7 +155,6 @@ // }}} // GetIntegerVar($_name, $_hash) {{{ - /** * Gets a variable explicitly castet to int. * @@ -223,7 +176,6 @@ // }}} // GetFloatVar($_name, $_hash) {{{ - /** * Gets a variable explicitly castet to float. * Note: null-values will be castet to 0 @@ -245,7 +197,6 @@ // }}} // GetDoubleVar($_name, $_hash) {{{ - /** * Alias to GetFloatVar() * @@ -257,7 +208,6 @@ // }}} // method GetVar($_name, $_hash = 'default') {{{ - /** * Fetches and returns a given variable. * @@ -282,20 +232,36 @@ * @return string Urldecoded variable * * @author Andreas Aderhold, <a.a...@th...> + * @author David Weingart, <dwe...@po...> */ - function GetVar($_name, $_hash = 'default') { - $_hash = strtoupper($_hash); // just to be safe ;-) + $_hash = strtoupper($_hash); // just to be safe ;-) + $ret = $this->undefined; // yep - just to be safe ;-) if ($_hash == 'DEFAULT') { for ($i = 0; $i <= strlen($this->varOrder); ++$i) { switch ($this->varOrder[$i]) { - case 'E' : ( $value = $this->_FetchVar($_name,'ENV')) ? ( $ret = $value ) : (null); break; - case 'G' : ( $value = $this->_FetchVar($_name,'GET')) ? ( $ret = $value ) : (null); break; - case 'P' : ( $value = $this->_FetchVar($_name,'POST')) ? ( $ret = $value ) : (null); break; - case 'C' : ( $value = $this->_FetchVar($_name,'COOKIE')) ? ( $ret = $value ) : (null); break; - case 'S' : ( $value = $this->_FetchVar($_name,'SESSION')) ? ( $ret = $value ) : (null); break; + case 'E' : + $value = $this->_FetchVar($_name,'ENV'); + ($value !== $this->undefined) ? ($ret = $value) : (null); + break; + case 'G' : + $value = $this->_FetchVar($_name,'GET'); + ($value !== $this->undefined) ? ($ret = $value) : (null); + break; + case 'P' : + $value = $this->_FetchVar($_name,'POST'); + ($value !== $this->undefined) ? ($ret = $value) : (null); + break; + case 'C' : + $value = $this->_FetchVar($_name,'COOKIE'); + ($value !== $this->undefined) ? ($ret = $value) : (null); + break; + case 'S' : + $value = $this->_FetchVar($_name,'SESSION'); + ($value !== $this->undefined) ? ($ret = $value) : (null); + break; } } } elseif ($_hash == 'METHOD') { @@ -314,7 +280,6 @@ // }}} // method _FetchVar($_name, $_hash) {{{ - /** * Fetching variable out of named array * @@ -346,7 +311,6 @@ // }}} // method _ParseRequestUri() {{{ - /** * Takes the server $REQUEST_URI variable and parses it as if * each subdirectory listing is a key/value pair, separated by @@ -386,7 +350,6 @@ // }}} // method TranslateUri($_uri, $_lose) {{{ - /** * Takes an ordinary URI with GET parameters in it, and returns * a URI compatible with the _ParseRequestUri method. @@ -422,7 +385,6 @@ // }}} // method _Decoe(&$_data) {{{ - /** * Private decode function. Handles decoding of the variable value * you are requesting. |