Advertisement
Guest User

Untitled

a guest
Sep 25th, 2012
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.57 KB | None | 0 0
  1. <?php
  2. require("includes/inc.php");
  3.  
  4. $_SESSION['referral'] = $_GET['ref'];
  5. if ($_SESSION['username'] != null) {
  6. //Redirect the user to the member area
  7. header('Location: member.php');
  8. exit();
  9. } else {
  10. //Check if the user is trying to login
  11. if ($_GET['do'] == "login") {
  12. //If they are, process the details they have provided. Else, continue with showing the form
  13. $username = trim(sanitize($_POST['username']));
  14. $password = trim(sanitize($_POST['password']));
  15. //Check if the username and password are empty
  16. if (($username == null) || ($password == null)){
  17. header('Location: login.php?error=details_wrong');
  18. exit();
  19. } else {
  20. $query_accounts = mysql_query("SELECT * FROM users WHERE username = '$username' LIMIT 1");
  21. $query_count = mysql_num_rows($query_accounts);
  22. if ($query_count == 0){ // User not found
  23. header('Location: login.php?error=details_wrong');
  24. exit();
  25. } else {
  26. while($accounts = mysql_fetch_array($query_accounts)) {
  27. if ($accounts['active'] == 0) { //Check if account is active
  28. header('Location: login.php?error=activate');
  29. exit();
  30. } else {
  31. $reason = $accounts['reason'];
  32. if ($accounts['banned'] == 1) {
  33. header('Location: login.php?error=banned');
  34. exit();
  35. } else {
  36. if ($accounts['password'] == password($password)){ // Check if the password matches the user's password
  37. $_SESSION['username'] = $username; // The password is correct, start a session for the user
  38. header('Location: member.php');
  39. exit();
  40. } else {
  41. header('Location: login.php?error=details_wrong'); // Incorrect password
  42. exit();
  43. }
  44. }
  45. }
  46. }
  47. }
  48. }
  49. } else {
  50. ?>
  51. <!DOCTYPE HTML>
  52. <html>
  53. <head>
  54. <title>Test Site</title>
  55. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  56. <link href="/css/bootstrap/css/bootstrap.css" rel="stylesheet">
  57. <?php include "header.php"; ?>
  58. </head>
  59. <body>
  60.  
  61.  
  62. <div class="container">
  63. <div class="hero-unit">
  64. <h1>Upload, Share, Earn</h1>
  65. <p>It's simple upload your files, share it over the web, and get paid for each download.</p>
  66. <em>Get started by <a href="register.php">registering</a> or login below</em>
  67. </div>
  68.  
  69. <form class="form-horizontal" id="login" method='post' action='?do=login'>
  70. <fieldset>
  71. <legend>Login</legend><br />
  72. <?php
  73. //Messages
  74. if ($_GET['error'] == "details_wrong"){ echo "<div class='alert alert-error'>Your <b>username</b> or <b>password</b> was incorrect</div>"; }
  75. elseif ($_GET['error'] == "activate"){ echo "<div class='alert alert-info'>Please <b>activate</b> your account.</div>"; }
  76. elseif ($_GET['error'] == "activating"){ echo "<div class='alert alert-error'>Sorry, we couldn't activate your account.</div>"; }
  77. elseif ($_GET['error'] == "banned"){ echo "<div class='alert alert-error'><b>Your account has been banned</b></div>"; } //ADD REASON
  78. elseif ($_GET['success'] == "logout"){ echo "<div class='alert alert-success'><b>You have successfully logged out</b></div>"; }
  79. elseif ($_GET['success'] == "activated"){ echo "<div class='alert alert-success'>Your account has been activated you may now login.</div>"; }
  80. elseif ($_GET['success'] == "complete"){ echo "<div class='alert alert-info'>You are now registered, please <b>activate</b> your account by visiting your email.</div>"; }
  81. elseif ($_GET['success'] == "pass_sent"){ echo "<div class='alert alert-success'>Your new password has been sent to your email.</div>"; }
  82. ?>
  83. <div class="control-group">
  84. <label class="control-label" for="input01">Username</label>
  85. <div class="controls">
  86. <div class="input-prepend">
  87. <span class="add-on"><i class="icon-user"></i></span><input type="text" class="input" id="username" name="username">
  88. </div>
  89. </div>
  90. </div>
  91.  
  92. <div class="control-group">
  93. <label class="control-label" for="input01">Password</label>
  94. <div class="controls">
  95. <div class="input-prepend">
  96. <span class="add-on"><i class="icon-pencil"></i></span><input type="password" class="input" id="password" name="password">
  97. </div>
  98. <h6><a href="forgotpass.php">Forgot your password?</a></h6>
  99. </div>
  100. </div>
  101. <div class="control-group">
  102. <label class="control-label" for="input01"></label>
  103. <div class="controls">
  104. <button type="submit" class="btn btn-inverse">Login</button>
  105.  
  106. </div>
  107. </div>
  108. </fieldset>
  109. </form>
  110. </div>
  111. </body>
  112. </html>
  113. <?php
  114. } // End Check Login
  115. } // End check if logged in
  116. include "footer.php";
  117. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement