|
From: FlorinCB <ory...@us...> - 2008-09-02 21:05:48
|
Update of /cvsroot/mxbb/core/includes In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26730 Modified Files: Tag: core28x mx_functions_core.php Log Message: fixed request class Index: mx_functions_core.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions_core.php,v retrieving revision 1.52.2.17 retrieving revision 1.52.2.18 diff -C2 -d -r1.52.2.17 -r1.52.2.18 *** mx_functions_core.php 10 Jul 2008 22:30:20 -0000 1.52.2.17 --- mx_functions_core.php 2 Sep 2008 21:05:41 -0000 1.52.2.18 *************** *** 3354,3357 **** --- 3354,3376 ---- /**#@-*/ + /**#@+ + * Class mx_request_vars specific definitions + * + * Following flags are options for the $type parameter in method _read() + * + */ + define('MX_TYPE_ANY' , 0); // Retrieve the get/post var as-is (only stripslashes() will be applied). + define('MX_TYPE_INT' , 1); // Be sure we get a request var of type INT. + define('MX_TYPE_FLOAT' , 2); // Be sure we get a request var of type FLOAT. + define('MX_TYPE_NO_HTML' , 4); // Be sure we get a request var of type STRING (htmlspecialchars). + define('MX_TYPE_NO_TAGS' , 8); // Be sure we get a request var of type STRING (strip_tags + htmlspecialchars). + define('MX_TYPE_NO_STRIP' , 16); // By default strings are slash stripped, this flag avoids this. + define('MX_TYPE_SQL_QUOTED' , 32); // Be sure we get a request var of type STRING, safe for SQL statements (single quotes escaped) + define('MX_TYPE_POST_VARS' , 64); // Read a POST variable. + define('MX_TYPE_GET_VARS' , 128); // Read a GET variable. + define('MX_NOT_EMPTY' , true); // + + /**#@-*/ + /** * Class: mx_request_vars. *************** *** 3407,3414 **** * @return unknown */ ! function _read($var, $type = MX_TYPE_ANY, $dflt = '') { global $HTTP_POST_VARS, $HTTP_GET_VARS; ! if( ($type & (MX_TYPE_POST_VARS|MX_TYPE_GET_VARS)) == 0 ) { --- 3426,3433 ---- * @return unknown */ ! function _read($var, $type = MX_TYPE_ANY, $dflt = '', $not_null = false) { global $HTTP_POST_VARS, $HTTP_GET_VARS; ! if( ($type & (MX_TYPE_POST_VARS|MX_TYPE_GET_VARS)) == 0 ) { *************** *** 3442,3451 **** if( $type & MX_TYPE_INT ) // integer { ! return intval($val); } if( $type & MX_TYPE_FLOAT ) // float { ! return floatval($val); } --- 3461,3470 ---- if( $type & MX_TYPE_INT ) // integer { ! return $not_null && empty($val) ? $dflt : intval($val); } if( $type & MX_TYPE_FLOAT ) // float { ! return $not_null && empty($val) ? $dflt : floatval($val); } *************** *** 3494,3498 **** } ! return $val; } --- 3513,3517 ---- } ! return $not_null && empty($val) ? $dflt : $val; } *************** *** 3512,3518 **** * @return string */ ! function post($var, $type = MX_TYPE_ANY, $dflt = '') { ! return $this->_read($var, ($type | MX_TYPE_POST_VARS), $dflt); } --- 3531,3537 ---- * @return string */ ! function post($var, $type = MX_TYPE_ANY, $dflt = '', $not_null = false) { ! return $this->_read($var, ($type | MX_TYPE_POST_VARS), $dflt, $not_null); } *************** *** 3528,3534 **** * @return string */ ! function get($var, $type = MX_TYPE_ANY, $dflt = '') { ! return $this->_read($var, ($type | MX_TYPE_GET_VARS), $dflt); } --- 3547,3553 ---- * @return string */ ! function get($var, $type = MX_TYPE_ANY, $dflt = '', $not_null = false) { ! return $this->_read($var, ($type | MX_TYPE_GET_VARS), $dflt, $not_null); } *************** *** 3544,3550 **** * @return string */ ! function request($var, $type = MX_TYPE_ANY, $dflt = '') { ! return $this->_read($var, ($type | MX_TYPE_POST_VARS | MX_TYPE_GET_VARS), $dflt); } --- 3563,3569 ---- * @return string */ ! function request($var, $type = MX_TYPE_ANY, $dflt = '', $not_null = false) { ! return $this->_read($var, ($type | MX_TYPE_POST_VARS | MX_TYPE_GET_VARS), $dflt, $not_null); } *************** *** 3562,3566 **** global $HTTP_POST_VARS; // Note: _x and _y are used by (at least IE) to return the mouse position at onclick of INPUT TYPE="img" elements. ! return ( isset($HTTP_POST_VARS[$var]) || ( isset($HTTP_POST_VARS[$var.'_x']) && isset($HTTP_POST_VARS[$var.'_y']) ) ); } --- 3581,3585 ---- global $HTTP_POST_VARS; // Note: _x and _y are used by (at least IE) to return the mouse position at onclick of INPUT TYPE="img" elements. ! return (isset($HTTP_POST_VARS[$var]) || ( isset($HTTP_POST_VARS[$var.'_x']) && isset($HTTP_POST_VARS[$var.'_y']))) ? 1 : 0; } *************** *** 3576,3581 **** function is_get($var) { ! global $HTTP_GET_VARS; ! return ( isset($HTTP_GET_VARS[$var]) ); } --- 3595,3600 ---- function is_get($var) { ! global $HTTP_GET_VARS; ! return isset($HTTP_GET_VARS[$var]) ? 1 : 0 ; } *************** *** 3591,3595 **** function is_request($var) { ! return ( $this->is_get($var) || $this->is_post($var) ); } --- 3610,3659 ---- function is_request($var) { ! return ($this->is_get($var) || $this->is_post($var)) ? 1 : 0; ! } ! /** ! * Is POST var empty? ! * ! * Boolean method to check if POST variable is empty ! * as it might be set but still be empty. ! * ! * @access public ! * @param string $var ! * @return boolean ! */ ! function is_empty_post($var) ! { ! global $HTTP_POST_VARS; ! ! return (empty($HTTP_POST_VARS[$var]) && ( empty($HTTP_POST_VARS[$var.'_x']) || empty($HTTP_POST_VARS[$var.'_y']))) ? 1 : 0 ; ! } ! /** ! * Is GET var empty? ! * ! * Boolean method to check if GET variable is empty ! * as it might be set but still be empty ! * ! * @access public ! * @param string $var ! * @return boolean ! */ ! function is_empty_get($var) ! { ! global $HTTP_GET_VARS; ! return empty($HTTP_GET_VARS[$var]) ? 1 : 0 ; ! } ! ! /** ! * Is REQUEST empty (GET and POST) var? ! * ! * Boolean method to check if REQUEST (both) variable is empty. ! * ! * @access public ! * @param string $var ! * @return boolean ! */ ! function is_empty_request($var) ! { ! return ($this->is_empty_get($var) && $this->is_empty_post($var)) ? 1 : 0; } |