|
From: MW <jo...@us...> - 2008-02-13 22:16:40
|
Update of /cvsroot/mxbb/core/includes In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23211/includes Modified Files: mx_functions_core.php Log Message: updated the $mx_request_vars class to also deal with empty when requesting vars. Now pass the const MX_NOT_EMPTY to ->post and ->get if empty() should be taken into consideration and not just isset() Ex. $res = $mx_request_vars->post ($var, MX_TYPE_NO_TAGS, $default, MX_NOT_EMPTY) Index: mx_functions_core.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions_core.php,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** mx_functions_core.php 12 Feb 2008 21:24:18 -0000 1.78 --- mx_functions_core.php 13 Feb 2008 22:16:21 -0000 1.79 *************** *** 3590,3593 **** --- 3590,3594 ---- 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); // /**#@-*/ *************** *** 3645,3649 **** * @return unknown */ ! function _read($var, $type = MX_TYPE_ANY, $dflt = '') { if( ($type & (MX_TYPE_POST_VARS|MX_TYPE_GET_VARS)) == 0 ) --- 3646,3650 ---- * @return unknown */ ! function _read($var, $type = MX_TYPE_ANY, $dflt = '', $not_null = false) { if( ($type & (MX_TYPE_POST_VARS|MX_TYPE_GET_VARS)) == 0 ) *************** *** 3678,3687 **** if( $type & MX_TYPE_INT ) // integer { ! return intval($val); } if( $type & MX_TYPE_FLOAT ) // float { ! return floatval($val); } --- 3679,3688 ---- 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); } *************** *** 3730,3734 **** } ! return $val; } --- 3731,3735 ---- } ! return $not_null && empty($val) ? $dflt : $val; } *************** *** 3748,3754 **** * @return string */ ! function post($var, $type = MX_TYPE_ANY, $dflt = '') { ! return $this->_read($var, ($type | MX_TYPE_POST_VARS), $dflt); } --- 3749,3755 ---- * @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); } *************** *** 3764,3770 **** * @return string */ ! function get($var, $type = MX_TYPE_ANY, $dflt = '') { ! return $this->_read($var, ($type | MX_TYPE_GET_VARS), $dflt); } --- 3765,3771 ---- * @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); } *************** *** 3780,3786 **** * @return string */ ! function request($var, $type = MX_TYPE_ANY, $dflt = '') { ! return $this->_read($var, ($type | MX_TYPE_POST_VARS | MX_TYPE_GET_VARS), $dflt); } --- 3781,3787 ---- * @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); } *************** *** 3839,3848 **** function is_empty_post($var) { ! if ( $this->is_post($var)) ! { ! $tmp = $this->_read($var, MX_TYPE_POST_VARS); ! return empty($tmp) ? 1 : 0; ! } ! return true; } /** --- 3840,3844 ---- function is_empty_post($var) { ! return (empty($_POST[$var]) && ( empty($_POST[$var.'_x']) || empty($_POST[$var.'_y']))) ? 1 : 0 ; } /** *************** *** 3858,3867 **** function is_empty_get($var) { ! if ($this->is_get($var)) ! { ! $tmp = $this->_read($var, MX_TYPE_GET_VARS); ! return empty($tmp) ? 1 : 0; ! } ! return true; } --- 3854,3858 ---- function is_empty_get($var) { ! return empty($_GET[$var]) ? 1 : 0 ; } |