Advertisement
Guest User

Untitled

a guest
Feb 25th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. <?php
  2. if (!function_exists("GetSQLValueString")) {
  3. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  4. {
  5. if (PHP_VERSION < 6) {
  6. $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  7. }
  8.  
  9. $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  10.  
  11. switch ($theType) {
  12. case "text":
  13. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  14. break;
  15. case "long":
  16. case "int":
  17. $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  18. break;
  19. case "double":
  20. $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  21. break;
  22. case "date":
  23. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  24. break;
  25. case "defined":
  26. $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  27. break;
  28. }
  29. return $theValue;
  30. }
  31. }
  32. ?>
  33. <?php
  34. // *** Validate request to login to this site.
  35. if (!isset($_SESSION)) {
  36. session_start();
  37. }
  38.  
  39. $loginFormAction = $_SERVER['PHP_SELF'];
  40. if (isset($_GET['accesscheck'])) {
  41. $_SESSION['PrevUrl'] = $_GET['accesscheck'];
  42. }
  43.  
  44. if (isset($_POST['textfield'])) {
  45. $loginUsername=$_POST['textfield'];
  46. $password=$_POST['textfield2'];
  47. $MM_fldUserAuthorization = "";
  48. $MM_redirectLoginSuccess = "index.php";
  49. $MM_redirectLoginFailed = "login.php";
  50. $MM_redirecttoReferrer = false;
  51. mysql_select_db($database_prueba, $prueba);
  52.  
  53. $LoginRS__query=sprintf("SELECT perNom, perPW FROM persoas WHERE perNom=%s AND perPW=%s",
  54. GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
  55.  
  56. $LoginRS = mysql_query($LoginRS__query, $prueba) or die(mysql_error());
  57. $loginFoundUser = mysql_num_rows($LoginRS);
  58. if ($loginFoundUser) {
  59. $loginStrGroup = "";
  60.  
  61. if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
  62. //declare two session variables and assign them
  63. $_SESSION['MM_Username'] = $loginUsername;
  64. $_SESSION['MM_UserGroup'] = $loginStrGroup;
  65.  
  66. if (isset($_SESSION['PrevUrl']) && false) {
  67. $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
  68. }
  69. header("Location: " . $MM_redirectLoginSuccess );
  70. }
  71. else {
  72. header("Location: ". $MM_redirectLoginFailed );
  73. }
  74. }
  75.  
  76. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement