Advertisement
Guest User

Untitled

a guest
Jan 6th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. <?php
  2. if(!function_exists('mssql_connect')){
  3. echo 'You must have the php_mssql library for Apache installed and enabled to connect to an MSSQL database. Uncomment the line that says extension=php_mssql.dll in your php.ini (XAMPP/WAMP only). This requires a restart of the Apache service to take effect.'; die();
  4. }
  5. // Database configuration parameters
  6. $db_host = '127.0.0.1\rfsql';
  7. $db_user = 'sa';
  8. $db_pass = 'SA1password';
  9.  
  10. /**
  11. * Sanitize user input to prevent SQL injection. Use this on ALL user input!
  12. * This function is from CodeIgniter.
  13. * I researched other methods of doing this, and this looked the most solid to me - Abrasive
  14. * @param string $data
  15. * @return string
  16. */
  17. function mssql_escape_string($data) {
  18. if(!isset($data) or empty($data)) return '';
  19. if(is_numeric($data)) return $data;
  20. $non_displayables = array(
  21. '/%0[0-8bcef]/', // url encoded 00-08, 11, 12, 14, 15
  22. '/%1[0-9a-f]/', // url encoded 16-31
  23. '/[\x00-\x08]/', // 00-08
  24. '/\x0b/', // 11
  25. '/\x0c/', // 12
  26. '/[\x0e-\x1f]/' // 14-31
  27. );
  28. foreach($non_displayables as $regex)
  29. $data = preg_replace($regex,'',$data);
  30. $data = str_replace("'","''",$data);
  31. return $data;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement