Advertisement
Guest User

Untitled

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