Advertisement
Guest User

Untitled

a guest
Nov 10th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2. // Database configuration parameters
  3. $db_host = '127.0.0.1';
  4. $db_user = 'Shaiya';
  5. $db_pass = 'Shaiya123';
  6. $database = 'PS_UserData';
  7.  
  8. /**
  9. * Sanitize user input to prevent SQL injection. Use this on ALL user input!
  10. * This function is from CodeIgniter.
  11. * I researched other methods of doing this, and this looked the most solid to me - Abrasive
  12. * @param string $data
  13. * @return string
  14. */
  15. function mssql_escape_string($data) {
  16. if(!isset($data) or empty($data)) return '';
  17. if(is_numeric($data)) return $data;
  18. $non_displayables = array(
  19. '/%0[0-8bcef]/', // url encoded 00-08, 11, 12, 14, 15
  20. '/%1[0-9a-f]/', // url encoded 16-31
  21. '/[\x00-\x08]/', // 00-08
  22. '/\x0b/', // 11
  23. '/\x0c/', // 12
  24. '/[\x0e-\x1f]/' // 14-31
  25. );
  26. foreach($non_displayables as $regex)
  27. $data = preg_replace($regex,'',$data);
  28. $data = str_replace("'","''",$data);
  29. return $data;
  30. }
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement