reenadak

clean input function

Sep 16th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. // Function for cleaning input
  2.  
  3. function clean_input($str)
  4. {
  5.     return is_array($str) ? array_map('clean_input', $str) :
  6.         str_replace("\", "\\", htmlspecialchars((get_magic_quotes_gpc() ? stripslashes($str) : $str), ENT_QUOTES));
  7. }
  8.  
  9.  
  10. function clean_input1($i)
  11. {
  12.     if (!get_magic_quotes_gpc())
  13.     {
  14.         $i = addslashes($i);
  15.     }
  16.         $i = rtrim($i);
  17.         $look = array('&', '#', '<', '>', '"', ''', '(', ')');
  18.         $safe = array('&amp;', '&#35', '&lt;', '&gt;', '&quot;', '&#39', '(', ')');
  19.         $i = str_replace($look, $safe, $i);
  20.     return $i;
  21. }
  22.  
  23. // Function for cleaning any input, submitted by any form etc.
  24. function clean($i)
  25. {
  26.     if(!get_magic_quotes_gpc()) $i = addslashes($i);
  27.     $i = rtrim($i);
  28.     $look = array('&amp;', '#', '&lt;', '&gt;', '&quot;', '\'', '(', ')');
  29.     $safe = array('&amp;amp;', '&amp;#35', '&amp;lt;', '&amp;gt;', '&amp;quot;', '&amp;#39', '&amp;#40;', '&amp;#41;');
  30.     $i = str_replace($look, $safe, $i);
  31.     return $i;
  32. }
Add Comment
Please, Sign In to add comment