note 80349 added to function.stripslashes

From: Date: Fri, 11 Jan 2008 05:39:33 +0000
Subject: note 80349 added to function.stripslashes
Groups: php.notes 
Request: Send a blank email to php-notes+get-135021@lists.php.net to get a copy of this message
I am using this here to clear data in a CMS against SQL injections and other mayhem. The flow is: 1. input into form 2. get from $_GET/$_POST 3. cleanup($data, true) 4. save to SQL 5. load from SQL 6. cleanup($data, false) 7. show in form for new edit or on the website <?php function cleanup($data, $write=false) { if (is_array($data)) { foreach ($data as $key => $value) { $data[$key] = cleanup_lvl2($value, $write); } } else { $data = cleanup_lvl2($data, $write); } return $data; } function cleanup_lvl2($data, $write=false) { if (isset($data)) { // preserve NULL if (get_magic_quotes_gpc()) { $data = stripslashes($data); } if ($write) { $data = mysql_real_escape_string($data); } } return $data; } ?> ---- Server IP: 208.69.120.35 Probable Submitter: 209.93.238.10 ---- Manual Page -- http://www.php.net/manual/en/function.stripslashes.php Edit -- https://master.php.net/note/edit/80349 Del: integrated -- https://master.php.net/note/delete/80349/integrated Del: useless -- https://master.php.net/note/delete/80349/useless Del: bad code -- https://master.php.net/note/delete/80349/bad+code Del: spam -- https://master.php.net/note/delete/80349/spam Del: non-english -- https://master.php.net/note/delete/80349/non-english Del: in docs -- https://master.php.net/note/delete/80349/in+docs Del: other reasons-- https://master.php.net/note/delete/80349 Reject -- https://master.php.net/note/reject/80349 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135021) next »