-
- if(array_key_exists( 'istrue',$_POST))
- {
- if($_POST[ 'istrue'])
- {
- $istrue=$_POST[ 'istrue'];
- }
- }else{
- $istrue='';
- }
Copy the code
The subsequent judgment can be as follows
to avoid such errors. You can refer to how to do some program systems.
For details, please refer to the code of dedecms or phpcms.
-
-
//Check and register externally submitted variables - foreach($_REQUEST as $_k=>$_v)
- {
- if( strlen($_k)> ;0 && eregi('^(cfg_|GLOBALS)',$_k) )
- {
- exit('Request var not allow!');
- }
- }
- function _RunMagicQuotes(&$svar)
- {
- if(! get_magic_quotes_gpc())
- {
- if( is_array($svar) )
- {
- foreach($svar as $_k => $_v) $svar[$_k] = _RunMagicQuotes($_v);
- }
- else
- {
- $svar = addslashes($svar);
- }
- }
- return $svar;
- }
foreach(Array('_GET','_POST','_COOKIE') as $_request )
- {
- foreach($$_request as $_k => $_v) ${$_k} = _RunMagicQuotes($_v);
- }
- if(empty($istrue))
- {
- $istrue = '';
- }
-
Copy code
|