mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-07 14:39:56 +01:00
function_backtrace:
- dont output first function param for unserialize() - limit output of function param to 64 chars
This commit is contained in:
parent
8cbe7774a8
commit
506a6573c8
@ -38,9 +38,9 @@
|
|||||||
function bytes($str)
|
function bytes($str)
|
||||||
{
|
{
|
||||||
static $func_overload;
|
static $func_overload;
|
||||||
|
|
||||||
if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
|
if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
|
||||||
|
|
||||||
return $func_overload & 2 ? mb_strlen($str,'ascii') : strlen($str);
|
return $func_overload & 2 ? mb_strlen($str,'ascii') : strlen($str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +67,7 @@
|
|||||||
* print debug data only when debugging mode is turned on.
|
* print debug data only when debugging mode is turned on.
|
||||||
*
|
*
|
||||||
* @author seek3r
|
* @author seek3r
|
||||||
* This function is used to debugging data.
|
* This function is used to debugging data.
|
||||||
* print_debug('this is some debugging data',$somevar);
|
* print_debug('this is some debugging data',$somevar);
|
||||||
*/
|
*/
|
||||||
function print_debug($message,$var = 'messageonly',$part = 'app', $level = 3)
|
function print_debug($message,$var = 'messageonly',$part = 'app', $level = 3)
|
||||||
@ -169,7 +169,7 @@
|
|||||||
*
|
*
|
||||||
* @author seek3r
|
* @author seek3r
|
||||||
* This function is used to validate param data as well as offer flexible function usage.
|
* This function is used to validate param data as well as offer flexible function usage.
|
||||||
*
|
*
|
||||||
function somefunc()
|
function somefunc()
|
||||||
{
|
{
|
||||||
$expected_args[0] = Array('name'=>'fname','default'=>'joe', 'type'=>'string');
|
$expected_args[0] = Array('name'=>'fname','default'=>'joe', 'type'=>'string');
|
||||||
@ -181,21 +181,21 @@
|
|||||||
//default result would be:
|
//default result would be:
|
||||||
// Full name: joe hick bob<br>
|
// Full name: joe hick bob<br>
|
||||||
}
|
}
|
||||||
|
|
||||||
Using this it is possible to use the function in any of the following ways
|
Using this it is possible to use the function in any of the following ways
|
||||||
somefunc('jack','city','brown');
|
somefunc('jack','city','brown');
|
||||||
or
|
or
|
||||||
somefunc(array('fname'=>'jack','mname'=>'city','lname'=>'brown'));
|
somefunc(array('fname'=>'jack','mname'=>'city','lname'=>'brown'));
|
||||||
or
|
or
|
||||||
somefunc(array('lname'=>'brown','fname'=>'jack','mname'=>'city'));
|
somefunc(array('lname'=>'brown','fname'=>'jack','mname'=>'city'));
|
||||||
|
|
||||||
For the last one, when using named params in an array you dont have to follow any order
|
For the last one, when using named params in an array you dont have to follow any order
|
||||||
All three would result in - Full name: jack city brown<br>
|
All three would result in - Full name: jack city brown<br>
|
||||||
|
|
||||||
When you use this method of handling params you can secure your functions as well offer
|
When you use this method of handling params you can secure your functions as well offer
|
||||||
flexibility needed for both normal use and web services use.
|
flexibility needed for both normal use and web services use.
|
||||||
If you have params that are required just set the default as ##REQUIRED##
|
If you have params that are required just set the default as ##REQUIRED##
|
||||||
Users of your functions can also use ##DEFAULT## to use your default value for a param
|
Users of your functions can also use ##DEFAULT## to use your default value for a param
|
||||||
when using the standard format like this:
|
when using the standard format like this:
|
||||||
somefunc('jack','##DEFAULT##','brown');
|
somefunc('jack','##DEFAULT##','brown');
|
||||||
This would result in - Full name: jack hick brown<br>
|
This would result in - Full name: jack hick brown<br>
|
||||||
@ -210,7 +210,7 @@
|
|||||||
/* This array will contain all types for sanatization checking */
|
/* This array will contain all types for sanatization checking */
|
||||||
/* only used when an array is passed as the first arg */
|
/* only used when an array is passed as the first arg */
|
||||||
$types = Array();
|
$types = Array();
|
||||||
|
|
||||||
/* start by looping thru the expected list and set params with */
|
/* start by looping thru the expected list and set params with */
|
||||||
/* the default values */
|
/* the default values */
|
||||||
$num = count($expected);
|
$num = count($expected);
|
||||||
@ -221,9 +221,9 @@
|
|||||||
{
|
{
|
||||||
$required[$expected[$i]['name']] = True;
|
$required[$expected[$i]['name']] = True;
|
||||||
}
|
}
|
||||||
$types[$expected[$i]['name']] = $expected[$i]['type'];
|
$types[$expected[$i]['name']] = $expected[$i]['type'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure they passed at least one param */
|
/* Make sure they passed at least one param */
|
||||||
if(count($recieved) != 0)
|
if(count($recieved) != 0)
|
||||||
{
|
{
|
||||||
@ -252,7 +252,7 @@
|
|||||||
{
|
{
|
||||||
for ($i = 0; $i < $num; $i++)
|
for ($i = 0; $i < $num; $i++)
|
||||||
{
|
{
|
||||||
$types[$expected[$i]['name']] = $expected[$i]['type'];
|
$types[$expected[$i]['name']] = $expected[$i]['type'];
|
||||||
}
|
}
|
||||||
while(list($key,$val) = each($recieved[0]))
|
while(list($key,$val) = each($recieved[0]))
|
||||||
{
|
{
|
||||||
@ -287,7 +287,7 @@
|
|||||||
* Validate data.
|
* Validate data.
|
||||||
*
|
*
|
||||||
* @author seek3r
|
* @author seek3r
|
||||||
* This function is used to validate input data.
|
* This function is used to validate input data.
|
||||||
* sanitize('number',$somestring);
|
* sanitize('number',$somestring);
|
||||||
*/
|
*/
|
||||||
function sanitize($string,$type)
|
function sanitize($string,$type)
|
||||||
@ -387,7 +387,7 @@
|
|||||||
{
|
{
|
||||||
$pass_verify_non_alpha = True;
|
$pass_verify_non_alpha = True;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(@isset($GLOBALS['egw_info']['server']['pass_require_numbers']) && $GLOBALS['egw_info']['server']['pass_require_numbers'] == True)
|
if(@isset($GLOBALS['egw_info']['server']['pass_require_numbers']) && $GLOBALS['egw_info']['server']['pass_require_numbers'] == True)
|
||||||
{
|
{
|
||||||
$pass_verify_num = False;
|
$pass_verify_num = False;
|
||||||
@ -405,7 +405,7 @@
|
|||||||
{
|
{
|
||||||
$pass_verify_special_char = True;
|
$pass_verify_special_char = True;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($password_length >= $min_length)
|
if ($password_length >= $min_length)
|
||||||
{
|
{
|
||||||
for ($i=0; $i != $password_length; $i++)
|
for ($i=0; $i != $password_length; $i++)
|
||||||
@ -439,7 +439,7 @@
|
|||||||
{
|
{
|
||||||
$GLOBALS['egw_info']['flags']['msgbox_data']['Password requires at least one special character (non-letter and non-number)']=False;
|
$GLOBALS['egw_info']['flags']['msgbox_data']['Password requires at least one special character (non-letter and non-number)']=False;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($pass_verify_num == True && $pass_verify_special_char == True)
|
if ($pass_verify_num == True && $pass_verify_special_char == True)
|
||||||
{
|
{
|
||||||
return True;
|
return True;
|
||||||
@ -649,7 +649,7 @@
|
|||||||
* retrieve a value from either a POST, GET, COOKIE, SERVER or from a class variable.
|
* retrieve a value from either a POST, GET, COOKIE, SERVER or from a class variable.
|
||||||
*
|
*
|
||||||
* @author skeeter
|
* @author skeeter
|
||||||
* This function is used to retrieve a value from a user defined order of methods.
|
* This function is used to retrieve a value from a user defined order of methods.
|
||||||
* $this->id = get_var('id',array('HTTP_POST_VARS'||'POST','HTTP_GET_VARS'||'GET','HTTP_COOKIE_VARS'||'COOKIE','GLOBAL','DEFAULT'));
|
* $this->id = get_var('id',array('HTTP_POST_VARS'||'POST','HTTP_GET_VARS'||'GET','HTTP_COOKIE_VARS'||'COOKIE','GLOBAL','DEFAULT'));
|
||||||
* @param $variable name
|
* @param $variable name
|
||||||
* @param $method ordered array of methods to search for supplied variable
|
* @param $method ordered array of methods to search for supplied variable
|
||||||
@ -667,7 +667,7 @@
|
|||||||
/**
|
/**
|
||||||
* Load a class and include the class file if not done so already.
|
* Load a class and include the class file if not done so already.
|
||||||
*
|
*
|
||||||
* This function is used to create an instance of a class, and if the class file has not been included it will do so.
|
* This function is used to create an instance of a class, and if the class file has not been included it will do so.
|
||||||
* $GLOBALS['egw']->acl =& CreateObject('phpgwapi.acl');
|
* $GLOBALS['egw']->acl =& CreateObject('phpgwapi.acl');
|
||||||
*
|
*
|
||||||
* @author RalfBecker@outdoor-training.de
|
* @author RalfBecker@outdoor-training.de
|
||||||
@ -678,7 +678,7 @@
|
|||||||
function &CreateObject($class)
|
function &CreateObject($class)
|
||||||
{
|
{
|
||||||
list($appname,$classname) = explode('.',$class);
|
list($appname,$classname) = explode('.',$class);
|
||||||
|
|
||||||
if ($classname == 'datetime') $classname = 'egw_datetime'; // php5.2 fix
|
if ($classname == 'datetime') $classname = 'egw_datetime'; // php5.2 fix
|
||||||
|
|
||||||
include_once(EGW_INCLUDE_ROOT.'/'.$appname.'/inc/class.'.$classname.'.inc.php');
|
include_once(EGW_INCLUDE_ROOT.'/'.$appname.'/inc/class.'.$classname.'.inc.php');
|
||||||
@ -727,13 +727,13 @@
|
|||||||
$newobj = 1;
|
$newobj = 1;
|
||||||
$obj =& CreateObject($acm);
|
$obj =& CreateObject($acm);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!method_exists($obj,$method))
|
if (!method_exists($obj,$method))
|
||||||
{
|
{
|
||||||
echo "<p><b>".function_backtrace()."</b>: no methode '$method' in class '$class'</p>\n";
|
echo "<p><b>".function_backtrace()."</b>: no methode '$method' in class '$class'</p>\n";
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
unset($args[0]);
|
unset($args[0]);
|
||||||
$code = '$return =& $obj->'.$method.'(';
|
$code = '$return =& $obj->'.$method.'(';
|
||||||
@ -867,7 +867,7 @@
|
|||||||
* duplicates the result of copying an object under php3/4 even when using php5
|
* duplicates the result of copying an object under php3/4 even when using php5
|
||||||
*
|
*
|
||||||
* This is critical when looping on db object output and updating or inserting to the database using a copy of the db object. This was first added to GroupWhere
|
* This is critical when looping on db object output and updating or inserting to the database using a copy of the db object. This was first added to GroupWhere
|
||||||
*
|
*
|
||||||
* @deprecated use $copy = clone($obj);
|
* @deprecated use $copy = clone($obj);
|
||||||
* @author milosch
|
* @author milosch
|
||||||
* @param $a - Source Object
|
* @param $a - Source Object
|
||||||
@ -956,7 +956,7 @@
|
|||||||
function _debug_array($array,$print=True)
|
function _debug_array($array,$print=True)
|
||||||
{
|
{
|
||||||
$output = '<pre>'.print_r($array,true)."</pre>\n";
|
$output = '<pre>'.print_r($array,true)."</pre>\n";
|
||||||
|
|
||||||
if ($print)
|
if ($print)
|
||||||
{
|
{
|
||||||
echo $output;
|
echo $output;
|
||||||
@ -1134,7 +1134,7 @@
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* prepend a prefix to an array of table names
|
* prepend a prefix to an array of table names
|
||||||
*
|
*
|
||||||
@ -1170,7 +1170,8 @@
|
|||||||
if ($remove-- < 0)
|
if ($remove-- < 0)
|
||||||
{
|
{
|
||||||
$ret[] = (isset($level['class'])?$level['class'].'::':'').$level['function'].
|
$ret[] = (isset($level['class'])?$level['class'].'::':'').$level['function'].
|
||||||
(!$level['class'] ? '('.str_replace(EGW_SERVER_ROOT,'',$level['args'][0]).')' : '');
|
(!$level['class'] && !is_object($level['args'][0]) && $level['function'] != 'unserialize' ?
|
||||||
|
'('.substr(str_replace(EGW_SERVER_ROOT,'',$level['args'][0]),0,64).')' : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_array($ret))
|
if (is_array($ret))
|
||||||
@ -1184,7 +1185,7 @@
|
|||||||
/**
|
/**
|
||||||
* check $_REQUEST data for XSS, vars containing script tags are moved to $GLOBALS['egw_unset_vars']
|
* check $_REQUEST data for XSS, vars containing script tags are moved to $GLOBALS['egw_unset_vars']
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
* @param array &$var reference of array to check
|
* @param array &$var reference of array to check
|
||||||
* @param string $name='' name of the array
|
* @param string $name='' name of the array
|
||||||
*/
|
*/
|
||||||
@ -1212,7 +1213,7 @@
|
|||||||
reset($var);
|
reset($var);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(array('_GET','_POST','_REQUEST','HTTP_GET_VARS','HTTP_POST_VARS') as $n => $where)
|
foreach(array('_GET','_POST','_REQUEST','HTTP_GET_VARS','HTTP_POST_VARS') as $n => $where)
|
||||||
{
|
{
|
||||||
$pregs = array(
|
$pregs = array(
|
||||||
|
Loading…
Reference in New Issue
Block a user