Code Search for Developers
 
 
  

lostPasswordAction.php from Brim at Krugle


Show lostPasswordAction.php syntax highlighted

<?php

require_once ('framework/util/databaseConnection.php');
require_once ('framework/util/StringUtils.php');
include_once ('framework/sql/authQueries.php');
include_once ('framework/sql/userQueries.php');
require_once ('framework/model/AdminServices.php');
require_once ('framework/model/User.php');
require_once ('framework/model/UserFactory.php');
require_once ('framework/model/Preference.php');

/**
 * This file is part of the Brim project.
 * The brim-project is located at the following
 * location: {@link http://www.brim-project.org/ http://www.brim-project.org/}
 *
 * <pre> Enjoy :-) </pre>
 *
 * @author Barry Nauta
 * @package org.brim-project.framework
 *
 * @copyright [brim-project.org] - Copyright (c) 2003 - 2006 Barry Nauta
 *
 * @license http://opensource.org/licenses/gpl-license.php
 * The GNU Public License
 */

$stringUtils = new StringUtils ();
$userFactory = new UserFactory ();
if (isset($_POST['submit']))
{
	if ($_POST['user'] == 'test')
	{
		$message='notAllowedForTestUser';
		Header ("Location: lostPassword.php?message=".$message);
		exit;
	}
	//
	// Check for username and email on POST.
	//
	if (!(isset ($_POST['user'])) && !(isset($_POST['password'])))
	{
		$message='provideEmailAndPassword';
		Header ("Location: lostPassword.php?message=".$message);
		exit;
	}
	//
	// Now retrieve the email adres for the user and see
	// whether they match
	//
	$query = sprintf ($queries['getEmail'], $_POST['user']);
	$result = $db->Execute($query) or die ($db->ErrorMsg ());
	$dbEmail = $result->fields[0];
	if ($dbEmail == $_POST['email'])
	{
		$adminServices = new AdminServices ();
		$adminEmail = $adminServices->getAdminConfig ('admin_email');
		//
		// Ok, credentials appear to be correct
		// Generate a (pseudo) random password
		//
		$random =  $stringUtils->randomString (10);
		$randomPassword = MD5($random);
		//
		// Set the users password
		//
		$query = sprintf ($queries ['setPassword'],
			$randomPassword, $_POST['user']);
		$db -> Execute ($query) or die ($db->ErrorMsg ());
		//
		// And send the user a mail
		//
		$message = "Hello ".$_POST['user'].",";
		$message .= "\r\n";
		$message .= "\r\n";
		$message .= "You (or someone pretending to be you) ";
		$message .= "requested a new password. ";
		$message .= "\r\n";
		$message .= "Server name: [".$_SERVER['SERVER_NAME']."] ";
		$message .= "Remote address: [".$_SERVER['REMOTE_ADDR']."] ";
		$message .= "Remote host: [".$_SERVER['REMOTE_HOST']."] ";
		$message .= "\r\n";
		$message .= "Please go to your Brim site and login ";
		$message .= "(username: ".$_POST['user'].") ";
		$message .= "using the following password: ".$random." .";
		$message .= "\r\n";
		$message .= "\r\n";
		$message .= "You can change your temporary password to a simpler one through the ";
		$message .= "Preferences once you log in.";
		$message .= "\r\n";
		$message .= "\r\n";
		$message .= "Sincerely,";
		$message .= "\r\n";
		$message .= "Brim administrator";
		$subject = "Lost Brim password";
		$headers = "MIME-Version: 1.0\r\n";
    		$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
		$headers .= "From: Brim administrator <".$adminEmail.">\r\n";
		$headers .= "To: Brim user <".$_POST['email'].">\r\n";
		$headers .= "X-Mailer: Brim";
		//
		// Now mail it
		//
		mail($dbEmail, $subject, $message, $headers);
		$message = 'tempPasswordSent';
		Header ("Location: login.php?message=".$message);
		exit;
	}
	else
	{
		$message = 'usernamePasswordMismatch';
		Header ("Location: lostPassword.php?message=".$message);
		exit;
	}
}
?>




See more files for this project here

Brim

BRIM is a MVC framework, written in PHP and based on items with a hierarchical relationship. The list of plugins make BRIM a Information Manager with plugins like bookmarks, a calendar, contacts tasks, notes, RSS etc. The application is multilingual.

Project homepage: http://sourceforge.net/projects/brim
Programming language(s): JavaScript,PHP,SQL
License: other

  documentation/
    css/
      brim.css
      index.php
    pics/
      background.jpg
      design.png
      feet_booby.jpg
      index.php
      mvc.gif
      question_booby.gif
      question_booby.jpg
      shadow.gif
      shadow2.gif
      shadowAlpha.png
      sleeping_booby.jpg
      treeback.jpg
      white_boobies.jpg
    booby2brim_changes.txt
    changelog.txt
    coding_conventions.html
    contributions.html
    design.html
    directory_structure.html
    faq.html
    gpl.html
    how_to_enable_calendar_reminders_per_email.html
    how_to_enable_calendar_reminders_per_email.txt
    how_to_write_a_template.html
    how_to_write_a_template.txt
    index.php
    installation_guide.html
    mvc.html
    security.html
    todo.txt
    uninstall.html
    upgrade_guide.html
    used_versions.txt
    which_package.html
  ext/
    File/
      IMC/
        Build/
          vCard.php
        Parse/
          vCalendar.php
          vCard.php
        Build.php
        Parse.php
      IMC.php
    Savant/
      Savant/
        docs/
          README
          index.php
        filters/
          Savant_Filter_colorizeCode.php
          Savant_Filter_trimwhitespace.php
          index.php
        plugins/
          Savant_Plugin_ahref.php
          Savant_Plugin_checkbox.php
          Savant_Plugin_checkboxes.php
          Savant_Plugin_cycle.php
          Savant_Plugin_dateformat.php
          Savant_Plugin_image.php
          Savant_Plugin_input.php
          Savant_Plugin_javascript.php
          Savant_Plugin_modify.php
          Savant_Plugin_options.php
          Savant_Plugin_radios.php
          Savant_Plugin_stylesheet.php
          Savant_Plugin_textarea.php
          index.php
        Filter.php
        Plugin.php
        index.php
      Savant.php
      index.php
    adodb/
      contrib/
      datadict/
      drivers/
      lang/
      pear/
      perf/
      session/
      xsl/
      adodb-csvlib.inc.php
    jQuery/
    javascript/
    overlib/
    simpletest/
    JSON.php
    PEAR.php
    index.php
    json.js
    package.xml
  framework/
  plugins/
  templates/
  tools/
  AboutController.php
  AdminController.php
  BookmarkController.php
  BookmarkSidebarController.php
  HelpController.php
  PluginController.php
  PreferenceController.php
  README.txt
  SearchController.php
  SysinfoController.php
  TranslateController.php
  UPGRADE.txt
  UserController.php
  brim.php
  favicon.ico
  index.php
  install.php
  login.php
  loginAction.php
  logout.php
  lostPassword.php
  lostPasswordAction.php
  signup.php
  signupAction.php
  test.php