dokeos-auth
[ class tree: dokeos-auth ] [ index: dokeos-auth ] [ all elements ]

Source for file lostPassword.php

Documentation is available at lostPassword.php

  1. <?php
  2.  
  3. // $Id: lostPassword.php 11873 2007-04-04 19:46:04Z pcool $
  4. /*
  5. ==============================================================================
  6.     Dokeos - elearning and course management software
  7.  
  8.     Copyright (c) 2004 Dokeos S.A.
  9.     Copyright (c) 2003 Ghent University (UGent)
  10.     Copyright (c) 2001 Universite catholique de Louvain (UCL)
  11.     Copyright (c) various contributors
  12.  
  13.     For a full list of contributors, see "credits.txt".
  14.     The full license can be read in "license.txt".
  15.  
  16.     This program is free software; you can redistribute it and/or
  17.     modify it under the terms of the GNU General Public License
  18.     as published by the Free Software Foundation; either version 2
  19.     of the License, or (at your option) any later version.
  20.  
  21.     See the GNU General Public License for more details.
  22.  
  23.     Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  24. ==============================================================================
  25. */
  26. /**
  27. ==============================================================================
  28.  * SCRIPT PURPOSE :
  29.  *
  30.  * This script allows users to retrieve the password of their profile(s)
  31.  * on the basis of their e-mail address. The password is send via email
  32.  * to the user.
  33.  *
  34.  * Special case : If the password are encrypted in the database, we have
  35.  * to generate a new one.
  36. *
  37. *    @todo refactor, move relevant functions to code libraries
  38. *
  39. *    @package dokeos.auth
  40. ==============================================================================
  41. */
  42. // name of the language file that needs to be included
  43. $language_file "registration";
  44. require ('../inc/global.inc.php');
  45. require_once ('lost_password.lib.php');
  46. require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  47. $tool_name get_lang('LostPassword');
  48. Display :: display_header($tool_name);
  49.  
  50. // Forbidden to retrieve the lost password
  51. if (get_setting('allow_lostpassword'== "false")
  52. {
  53.     api_not_allowed();
  54. }
  55. if (isset ($_GET["reset"]&& isset ($_GET["id"]))
  56. {
  57.     $msg reset_password($_GET["reset"]$_GET["id"]);
  58.     $msg .= '. <br/>'.get_lang('YourPasswordHasBeenEmailed');
  59.     $msg .= '<br/><br/><a href="'.api_get_path(WEB_PATH).'main/auth/lostPassword.php">&lt;&lt; '.get_lang('Back').'</a>';
  60.     echo $msg;
  61. }
  62. else
  63. {
  64.     $form new FormValidator('lost_password');
  65.     $form->add_textfield('email'get_lang('Email')false'size="40"');
  66.     $form->applyFilter('email','strtolower');
  67.     $form->addElement('submit''submit'get_lang('Ok'));
  68.     if ($form->validate())
  69.     {
  70.         $values $form->exportValues();
  71.         $email $values['email'];
  72.         $result api_sql_query("SELECT user_id AS uid, lastname AS lastName, firstname AS firstName,
  73.                                             username AS loginName, password, email, status AS status,
  74.                                             official_code, phone, picture_uri, creator_id
  75.                                             FROM ".$tbl_user."
  76.                                             WHERE LOWER(email) = '".mysql_real_escape_string($email)."'
  77.                                             AND   email != '' "__FILE____LINE__);
  78.         if ($result && mysql_num_rows($result))
  79.         {
  80.             while ($data mysql_fetch_array($result))
  81.             {
  82.                 $user[$data;
  83.             }
  84.             if ($userPasswordCrypted)
  85.             {
  86.                 $msg handle_encrypted_password($user);
  87.             }
  88.             else
  89.             {
  90.                 send_password_to_user($user);
  91.             }
  92.         }
  93.         else
  94.         {
  95.             Display::display_error_message(get_lang('_no_user_account_with_this_email_address'));
  96.         }
  97.         $msg .= '<br/><br/><a href="'.api_get_path(WEB_PATH).'main/auth/lostPassword.php">&lt;&lt; '.get_lang('Back').'</a>';
  98.         echo '<p>'.$msg.'</p>';
  99.     }
  100.     else
  101.     {
  102.         echo '<p>';
  103.         echo get_lang('_enter_email_and_well_send_you_password');
  104.         echo '</p>';
  105.         $form->display();
  106.         ?>
  107.         <a href="<?php echo api_get_path(WEB_PATH)?>">&lt;&lt; <?php echo get_lang('Back')?></a>
  108.         <?php
  109.     }
  110. }
  111.  
  112. //////////////////////////////////////////////////////////////////////////////
  113. ?>

Documentation generated on Thu, 12 Jun 2008 14:01:16 -0500 by phpDocumentor 1.4.1