note 68150 added to function.stripslashes

From: Date: Sat, 15 Jul 2006 07:53:04 +0000
Subject: note 68150 added to function.stripslashes
Groups: php.notes 
Request: Send a blank email to php-notes+get-114800@lists.php.net to get a copy of this message
Why double nest the if's like that? All you need to do is check that the value is a string type as only these are effected by GPC. Also need to check for empty to avoid the NULL issues, and if it is empty "" there isn't much reason to do anything anyway. <? if ( get_magic_quotes_gpc() ) { function stripslashes_deep($value) { if( is_array($value) ) { $value = array_map('stripslashes_deep', $value) } elseif ( !empty($value) && is_string($value) ) { $value = stripslashes($value); } return $value; } $_POST = stripslashes_deep($_POST); $_GET = stripslashes_deep($_GET); $_COOKIE = stripslashes_deep($_COOKIE); } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 24.16.41.16 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.stripslashes.php Edit -- http://master.php.net/note/edit/68150 Del: integrated -- http://master.php.net/note/delete/68150/integrated Del: useless -- http://master.php.net/note/delete/68150/useless Del: bad code -- http://master.php.net/note/delete/68150/bad+code Del: spam -- http://master.php.net/note/delete/68150/spam Del: non-english -- http://master.php.net/note/delete/68150/non-english Del: in docs -- http://master.php.net/note/delete/68150/in+docs Del: other reasons-- http://master.php.net/note/delete/68150 Reject -- http://master.php.net/note/reject/68150 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114800) next »