|
From: Markus P. <mar...@us...> - 2005-04-03 14:30:53
|
Update of /cvsroot/mxbb/core/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9454 Modified Files: mx_functions.php Log Message: Added flag MX_TYPE_ANY to mx_request_vars. It might make this class easier to use in some circumstancies. Index: mx_functions.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions.php,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** mx_functions.php 17 Mar 2005 19:48:41 -0000 1.31 --- mx_functions.php 3 Apr 2005 14:30:26 -0000 1.32 *************** *** 1123,1126 **** --- 1123,1127 ---- // 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. *************** *** 1135,1142 **** // Additional notes: // ! // More than one can specified by OR'ing the $type argument. Example: ! // For instance, we can use ( MX_TYPE_POST_VARS | MX_TYPE_GET_VARS ), see method request(). ! // or we can use ( MX_TYPE_NO_TAGS | MX_TYPE_NO_SQL ). ! // However, MX_TYPE_NO_HTML and MX_TYPE_NO_TAGS can't be specified at a time (defaults to MX_TYPE_NO_HTML). // Also, MX_TYPE_INT and MX_TYPE_FLOAT ignore flags MX_TYPE_NO_* // --- 1136,1143 ---- // Additional notes: // ! // More than one flag can specified by OR'ing the $type argument. Examples: ! // For instance, we could use ( MX_TYPE_POST_VARS | MX_TYPE_GET_VARS ), see method request(). ! // or we could use ( MX_TYPE_NO_TAGS | MX_TYPE_NO_SQL ). ! // However, MX_TYPE_NO_HTML and MX_TYPE_NO_TAGS can't be specified at a time (defaults to MX_TYPE_NO_TAGS which is more restritive). // Also, MX_TYPE_INT and MX_TYPE_FLOAT ignore flags MX_TYPE_NO_* // *************** *** 1144,1152 **** // ! // This class must be instatiated in common.php ;-) // // Usage examples: // - // $mx_request_vars = new mx_request_vars(); // $mode = $mx_request_vars->post('mode', MX_TYPE_NO_TAGS, ''); // $page_id = $mx_request_vars->get('page', MX_TYPE_INT, 1); --- 1145,1152 ---- // ! // This class IS instatiated in common.php ;-) // // Usage examples: // // $mode = $mx_request_vars->post('mode', MX_TYPE_NO_TAGS, ''); // $page_id = $mx_request_vars->get('page', MX_TYPE_INT, 1); *************** *** 1188,1192 **** // the passed argument. This is tipical practice in languages like C, but it can also be done with PHP. // ! function _read($var, $type = 0, $dflt = '') { global $HTTP_POST_VARS, $HTTP_GET_VARS; --- 1188,1192 ---- // the passed argument. This is tipical practice in languages like C, but it can also be done with PHP. // ! function _read($var, $type = MX_TYPE_ANY, $dflt = '') { global $HTTP_POST_VARS, $HTTP_GET_VARS; *************** *** 1227,1231 **** return floatval($val); } ! if( $type & MX_TYPE_NO_HTML ) // no slashes nor html { if( is_array($val) ) --- 1227,1231 ---- return floatval($val); } ! if( $type & MX_TYPE_NO_TAGS ) // ie username { if( is_array($val) ) *************** *** 1233,1245 **** foreach( $val as $k => $v ) { ! $val[$k] = htmlspecialchars(ltrim(rtrim($v, " \t\n\r\0\x0B\\"))); } } else { ! $val = htmlspecialchars(ltrim(rtrim($val, " \t\n\r\0\x0B\\"))); } } ! elseif( $type & MX_TYPE_NO_TAGS ) // ie username { if( is_array($val) ) --- 1233,1245 ---- foreach( $val as $k => $v ) { ! $val[$k] = htmlspecialchars(strip_tags(ltrim(rtrim($v, " \t\n\r\0\x0B\\")))); } } else { ! $val = htmlspecialchars(strip_tags(ltrim(rtrim($val, " \t\n\r\0\x0B\\")))); } } ! elseif( $type & MX_TYPE_NO_HTML ) // no slashes nor html { if( is_array($val) ) *************** *** 1247,1256 **** foreach( $val as $k => $v ) { ! $val[$k] = htmlspecialchars(strip_tags(ltrim(rtrim($v, " \t\n\r\0\x0B\\")))); } } else { ! $val = htmlspecialchars(strip_tags(ltrim(rtrim($val, " \t\n\r\0\x0B\\")))); } } --- 1247,1256 ---- foreach( $val as $k => $v ) { ! $val[$k] = htmlspecialchars(ltrim(rtrim($v, " \t\n\r\0\x0B\\"))); } } else { ! $val = htmlspecialchars(ltrim(rtrim($val, " \t\n\r\0\x0B\\"))); } } *************** *** 1279,1291 **** // _read() wrappers to retrieve POST, GET or any REQUEST (both) variable. // ! function post($var, $type = 0, $dflt = '') { return $this->_read($var, ($type | MX_TYPE_POST_VARS), $dflt); } ! function get($var, $type = 0, $dflt = '') { return $this->_read($var, ($type | MX_TYPE_GET_VARS), $dflt); } ! function request($var, $type = 0, $dflt = '') { return $this->_read($var, ($type | MX_TYPE_POST_VARS | MX_TYPE_GET_VARS), $dflt); --- 1279,1291 ---- // _read() wrappers to retrieve POST, GET or any REQUEST (both) variable. // ! function post($var, $type = MX_TYPE_ANY, $dflt = '') { return $this->_read($var, ($type | MX_TYPE_POST_VARS), $dflt); } ! function get($var, $type = MX_TYPE_ANY, $dflt = '') { return $this->_read($var, ($type | MX_TYPE_GET_VARS), $dflt); } ! function request($var, $type = MX_TYPE_ANY, $dflt = '') { return $this->_read($var, ($type | MX_TYPE_POST_VARS | MX_TYPE_GET_VARS), $dflt); |