PageRenderTime 35ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/banned/login.php

http://globalban-spanish.googlecode.com/
PHP | 139 lines | 99 code | 14 blank | 26 comment | 20 complexity | a90601329f90fb2432e5311cf923eb9b MD5 | raw file
  1. <?php
  2. /*
  3. This file is part of GlobalBan.
  4. Written by Stefan Jonasson <soynuts@unbuinc.net>
  5. Copyright 2008 Stefan Jonasson
  6. GlobalBan is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. GlobalBan is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with GlobalBan. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. require_once(ROOTDIR."/include/database/class.UserQueries.php"); // User specific queries
  18. require_once(ROOTDIR."/include/objects/class.User.php"); // User class to store user info
  19. $lan_file = ROOTDIR.'/languages/'.$LANGUAGE.'/lan_loginout.php';
  20. include(file_exists($lan_file) ? $lan_file : ROOTDIR."/languages/English/lan_loginout.php");
  21. $userQuery = new UserQueries;
  22. $user = new User;
  23. $error = false;
  24. $emailError = true;
  25. // Make variables empty
  26. $username = "";
  27. $password = "";
  28. $remember = "";
  29. // Post Data from form
  30. if(isset($_POST['username'])) {
  31. $username = $_POST['username'];
  32. }
  33. if(isset($_POST['lpassword'])) {
  34. $password = $_POST['lpassword'];
  35. }
  36. if(isset($_POST['remember'])) {
  37. $remember = $_POST['remember'];
  38. }
  39. // User has entered a user name and password
  40. if(!empty($username) && !empty($password)) {
  41. // Check if username and password is valid
  42. if($userQuery->verifyUser($username, $password)) {
  43. // Grab user information object
  44. $user = $userQuery->getUserInfo($username);
  45. if($remember) { // User wants to be remembered... set up cookies
  46. setcookie("gbu", $user->getName(), time()+60*60*24*100, "/"); // 100 days
  47. setcookie("gbp", $user->getPassword(), time()+60*60*24*100, "/"); // 100 days
  48. }
  49. // Store stuff into session (creates a valid session)
  50. $_SESSION['name'] = $user->getName();
  51. $_SESSION['password'] = $user->getPassword(); // password should already be md5 encrypted
  52. $_SESSION['accessLevel'] = $user->getAccessLevel(); // Level of access
  53. header("Location: index.php?page=banlist"); // Requires ob_start and ob_flush
  54. }
  55. else {
  56. $error = true;
  57. }
  58. }
  59. // User has submitted that they forgot their password
  60. if(isset($_POST['forgotPassword'])) {
  61. if($userQuery->forgotPassword($_POST['email'])) {
  62. $emailError = false;
  63. } else {
  64. $emailError = true;
  65. }
  66. }
  67. if(isset($_GET['created'])) {
  68. if($_GET['created'] == 1) {
  69. ?><h5><?php echo $LANLOGINOUT_001; ?></h5><?php
  70. }
  71. }
  72. ?>
  73. <div class="tborder">
  74. <div id="tableHead">
  75. <div><b><?php echo $LANLOGINOUT_002; ?></b></div>
  76. </div>
  77. <form action="index.php?page=login" method="post" id="form">
  78. <table class="bordercolor" width="100%" cellspacing="1" cellpadding="5" border="0" style="margin-top: 1px;">
  79. <tr>
  80. <td class="rowColor1" width="1%" nowrap><?php echo $LANLOGINOUT_003; ?> :</td>
  81. <td class="rowColor1" ><input type="text" name="username" /></td>
  82. </tr>
  83. <tr>
  84. <td class="rowColor2" width="1%" nowrap><?php echo $LANLOGINOUT_004; ?> :</td>
  85. <td class="rowColor2"><input type="password" name="lpassword" /></td>
  86. </tr>
  87. <tr>
  88. <td colspan="2" align="left" class="rowColor1"><?php echo $LANLOGINOUT_005; ?>
  89. <input type="checkbox" name="remember" value="1" />
  90. <?php
  91. if($error) {
  92. ?>
  93. <span class="error"><?php echo $LANLOGINOUT_006; ?></span>
  94. <?php
  95. }
  96. ?>
  97. </td>
  98. </tr>
  99. <tr>
  100. <td align="left" colspan="2" class="rowColor2">
  101. <input type="submit" name="login" value="<?php echo $LANLOGINOUT_016; ?>" class="button" /></td>
  102. </tr>
  103. </table>
  104. </form>
  105. </div>
  106. <p><?php echo $LANLOGINOUT_007; ?> <a href="index.php?page=newuser"><?php echo $LANLOGINOUT_008; ?></a></p>
  107. <p><?php echo $LANLOGINOUT_009; ?></p>
  108. <form action="index.php?page=login" method="post"> <?php echo $LANLOGINOUT_010; ?><input type="text" name="email" size="60" maxlength="80"/>
  109. <input type="submit" name="forgotPassword" value="<?php echo $LANLOGINOUT_017; ?>" class="button">
  110. </form>
  111. <?php
  112. if(!$emailError && isset($_POST['forgotPassword'])) {
  113. ?>
  114. <p class="error"><?php echo $LANLOGINOUT_011; ?></p>
  115. <?php
  116. } else if($emailError && isset($_POST['forgotPassword'])) {
  117. ?>
  118. <p class="error"><?php echo $LANLOGINOUT_012; ?></p>
  119. <?php
  120. }
  121. ?>