Advertisement
tjromano

Redirect

Aug 21st, 2012
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.75 KB | None | 0 0
  1. <?
  2.  
  3. //prevents caching
  4. header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
  5. header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
  6. header("Cache-Control: post-check=0, pre-check=0",false);
  7. session_cache_limiter();
  8.  
  9. session_start();
  10.  
  11. //clear session variables
  12. session_unset();
  13.  
  14.  
  15. //require the functions file
  16. require ("config.php");
  17. require ("functions.php");
  18.  
  19. //check to see if cookies are already set, remember me
  20. if ((!$lr_user) || (!$lr_pass))
  21. {
  22.  
  23. $username = $_POST[username];
  24. $password = $_POST[password];
  25.  
  26. }else{
  27.  
  28. $username = $lr_user;
  29. $password = $lr_pass;
  30.  
  31. }
  32.  
  33. //if username or password is blank, send to errorlogin.html
  34. if ((!$username) || (!$password))
  35. {
  36.  
  37.     header("Location:$base_dir/errorlogin.html");
  38.     exit;
  39. }
  40.  
  41. //sets cookies to remember this computer if the user asks to
  42. if ($_POST[remember] == "Yes")
  43. {
  44. setcookie("lr_user", $username, $duration, "/", $domain);
  45. setcookie("lr_pass", $password, $duration, "/", $domain);
  46. }
  47.  
  48. if ($_POST[activate] == "Yes")
  49. {
  50.         //make the connection to the database
  51.         $connection = @mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error());
  52.         $db = @mysql_select_db($db_name,$connection)or die(mysql_error());
  53.                
  54.         //build and issue the query
  55.         $sql ="UPDATE $table_name SET verified = '1' WHERE username = '$_POST[username]'";
  56.         $result = @mysql_query($sql,$connection) or die(mysql_error());
  57. }
  58.  
  59. //sets session variables
  60. sess_vars($base_dir, $server, $dbusername, $dbpassword, $db_name, $table_name, $username, $password);
  61.  
  62. //check to see if the user has to change their password
  63. if ($_SESSION[pchange] == "1")
  64. {
  65.     $_SESSION[redirect] = "$base_dir/pass_change.html";
  66. }
  67.  
  68. //check to see if the user has activated the account
  69. if ($_SESSION[verified] == "0")
  70. {
  71.     $_SESSION[redirect] = "$base_dir/not_activated.html";
  72. }
  73.  
  74. //make the connection to the database
  75. $connection = @mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error());
  76. $db = @mysql_select_db($db_name,$connection)or die(mysql_error());
  77.        
  78. //build and issue the query
  79. $sql ="SELECT * FROM banned";
  80. $result = @mysql_query($sql,$connection) or die(mysql_error());
  81.  
  82. while ($sql = mysql_fetch_object($result))
  83.     {
  84.     $banned = $sql -> no_access;
  85.     if ($username == $banned || $REMOTE_ADDR == $banned)
  86.         {
  87.             include ('banned.html');
  88.             exit;
  89.         }
  90.     }
  91.  
  92. $last_log = last_login();
  93.  
  94. //updates table with last log as now
  95. $sql = "UPDATE $table_name SET last_login = '$last_log' WHERE username = '$_SESSION[user_name]'";
  96. $result = @mysql_query($sql,$connection) or die(mysql_error());
  97.  
  98. if (($_SESSION[redirect] != "$base_dir/errorlogin.html") && ($log_login == "1"))
  99. {
  100.     include('loglogin.php');
  101. }
  102.  
  103. //redirects the user   
  104. header("Location:$_SESSION[redirect]");
  105.  
  106. ?>
  107.  
  108. <head><title>Redirect</title></head>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement