Guest User

Untitled

a guest
Feb 24th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  2. {
  3. $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  4.  
  5. $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  6.  
  7. switch ($theType) {
  8. case "text":
  9. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  10. break;
  11. case "long":
  12. case "int":
  13. $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  14. break;
  15. case "double":
  16. $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
  17. break;
  18. case "date":
  19. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  20. break;
  21. case "defined":
  22. $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  23. break;
  24. }
  25. return $theValue;
  26. }
  27.  
  28. if (isset($_POST['username'])) {
  29. $loginUsername=$_POST['username'];
  30. $password=$_POST['password'];
  31. $MM_fldUserAuthorization = "";
  32. $MM_redirectLoginSuccess = "main.php";
  33. $MM_redirectLoginFailed = "login_form.php";
  34. $MM_redirecttoReferrer = false;
  35. mysql_select_db($database_connection1, $connection1);
  36.  
  37. $LoginRS__query=sprintf("SELECT username, password FROM member WHERE username=%s AND password=%s",
  38. GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
  39. ...
  40.  
  41. $sql = "SELECT * FROM users WHERE username = " . GetSQLValueString($_GET['username'], 'text');
  42. $result = mysql_query($sql);
  43.  
  44. GetSQLValueString("a value that I want to escape's", 'text');
  45.  
  46. function GetSQLValueString($conn_vote, $theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  47. {
  48. $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  49.  
  50. $theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($conn_vote, $theValue) : mysqli_escape_string($conn_vote, $theValue);`enter code here`
  51.  
  52. switch ($theType) {
  53. case "text":
  54. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  55. break;
  56. case "long":
  57. case "int":
  58. $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  59. break;
  60. case "double":
  61. $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
  62. break;
  63. case "date":
  64. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  65. break;
  66. case "defined":
  67. $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  68. break;
  69. }
  70. return $theValue;
  71. }
  72. }
Add Comment
Please, Sign In to add comment