PageRenderTime 30ms CodeModel.GetById 5ms RepoModel.GetById 0ms app.codeStats 0ms

/public/forgot.php

#
PHP | 147 lines | 107 code | 14 blank | 26 comment | 16 complexity | 1423a360e370d110f5e9b1624f76f7b0 MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. /**
  3. * @License(name="GNU General Public License", version="3.0")
  4. *
  5. * Copyright (C) 2010 UnWebmaster.Com.Ar
  6. * Copyright (C) 2010, 2011 Tom Kaczocha <freedomdeveloper@yahoo.com>
  7. *
  8. * This file is part of LaMantengo.
  9. *
  10. * LaMantengo is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * LaMantengo is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with LaMantengo. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. define('INSITE', 1);
  25. require_once("../includes/initialise.php");
  26. $title = $language->translate("title_forgot");
  27. $errors = "";
  28. if ($uid) { // already logged in
  29. $errors .= $language->translate("error_already_loggedin");
  30. }
  31. else { // Not logged. I look if I'm dating or not
  32. if ($_POST) { // Came in POST data, bone, and put the username / email
  33. if ($_POST['username'] == "") {
  34. $errors .= $language->translate("error_username");
  35. $username = "";
  36. }
  37. else {
  38. $username = $_POST['username'];
  39. }
  40. if ($_POST['email'] == "") {
  41. $errors .= $language->translate("error_email_empty");
  42. }
  43. else {
  44. $email = $_POST['email'];
  45. }
  46. /* * *********************** recaptcha check **************************************
  47. include('recaptcha_check.php');
  48. /********************** recaptcha check order ************************************* */
  49. if (!($errors)) {
  50. $query = "SELECT uid,username,email,realname,active FROM users WHERE LOWER(username) ='" . strtolower($username) . "' AND email='" . strtolower($email) . "'";
  51. $rs = mysql_query($query);
  52. if ($fila = mysql_fetch_object($rs)) { // matches users and mail ... new genus pass, and sent him
  53. if (!$fila->active) {
  54. $errors .= $language->translate("error_user_disabled");
  55. $_POST['email'] = "";
  56. $_POST['username'] = "";
  57. }
  58. else {
  59. $uid = $fila->uid;
  60. $username = $fila->username;
  61. $email = $fila->email;
  62. $realname = $fila->realname;
  63. include("generar_password.php");
  64. $password = generar_pass();
  65. include("email_forgot.php");
  66. $password = md5($password);
  67. $query = "UPDATE `users` SET `password`='$password' WHERE `uid`=$uid;";
  68. $password = "";
  69. $rs = mysql_query($query);
  70. if ($errors)
  71. $success = $cuerpo;
  72. else
  73. $success = $language->translate("password_updated");
  74. $uid = "";
  75. $username = "";
  76. $realname = "";
  77. $email = "";
  78. }
  79. }else {
  80. $errors .= $language->translate("error_email_nomatch");
  81. }
  82. }
  83. }
  84. // If you come here, or did not get data, or there were errors. Show form
  85. include("header.php");
  86. ?>
  87. <div id="contents">
  88. <?php
  89. if ($errors) {
  90. ?>
  91. <div id="errores">
  92. <?php echo $errors; ?>
  93. </div>
  94. <?php
  95. }
  96. if ($success) {
  97. ?>
  98. <div id="success">
  99. <?php echo $success; ?>
  100. </div>
  101. <?php
  102. }
  103. ?>
  104. <div id="form_reg">
  105. <form action="forgot.php" method="POST">
  106. <table id="table_reg">
  107. <tr id="tr_reg">
  108. <td id="td_reg1">User*:</td>
  109. <td id="td_reg"><input id="text_reg" type="text" name="username" value="<?php echo $username; ?>" /></td>
  110. </tr>
  111. <tr id="tr_reg">
  112. <td id="td_reg1">Email*:</td>
  113. <td id="td_reg"><input id="text_reg" type="text" name="email" value="<?php echo $email; ?>" /></td>
  114. </tr>
  115. <!--<tr id="tr_reg">
  116. <td colspan="3"><?php include('recaptcha_form.php'); ?></td>
  117. </tr>!-->
  118. <tr>
  119. <td colspan="3">
  120. <input type="submit" id="submit_reg" value="<?php echo $language->translate("reset_password"); ?>" />
  121. </td>
  122. </tr>
  123. </table>
  124. </form>
  125. </div>
  126. </div>
  127. <div id="explanation">
  128. <?php
  129. echo $language->translate("reset_explanation");
  130. echo "</div>";
  131. include("footer.php");
  132. }
  133. ?>