PEEL Shopping
Open source ecommerce : PEEL Shopping
oubli_mot_passe.php
Go to the documentation of this file.
1 <?php
2 // This file should be in UTF8 without BOM - Accents examples: éèê
3 // +----------------------------------------------------------------------+
4 // | Copyright (c) 2004-2015 Advisto SAS, service PEEL - contact@peel.fr |
5 // +----------------------------------------------------------------------+
6 // | This file is part of PEEL Shopping 8.0.0, which is subject to an |
7 // | opensource GPL license: you are allowed to customize the code |
8 // | for your own needs, but must keep your changes under GPL |
9 // | More information: https://www.peel.fr/lire/licence-gpl-70.html |
10 // +----------------------------------------------------------------------+
11 // | Author: Advisto SAS, RCS 479 205 452, France, https://www.peel.fr/ |
12 // +----------------------------------------------------------------------+
13 // $Id: oubli_mot_passe.php 46935 2015-09-18 08:49:48Z gboussin $
14 define('IN_GET_PASSWORD', true);
15 
16 include("../configuration.inc.php");
17 include("../lib/fonctions/display_user_forms.php");
18 
19 $GLOBALS['page_name'] = 'oubli_mot_passe';
20 $GLOBALS['DOC_TITLE'] = $GLOBALS["STR_GET_PASSWORD"];
21 
22 // Le formulaire a été soumis, vérifie si l'identification est ok
23 $frm = $_POST;
25 $output = '';
26 $mode = 'filing_email';
27 
28 if (!empty($_POST['token'])) {
29  if (!verify_token('oubli_mot_passe', 120, false)) {
30  $form_error_object->add('token', $GLOBALS['STR_INVALID_TOKEN']);
31  }
32  // vérification de la présence de l'email dans le formulaire de demande de renouvellement.
33  if (empty($_POST['email'])) {
34  $form_error_object->add('email', $GLOBALS['STR_ERR_EMAIL_VIDE']);
35  }
36 }
37 // cas de réception de l'utilisateur via le lien fourni dans l'email de demande de renouvellement de mot de passe. Les informations sont envoyé en GET.
38 if (!empty($_GET['hash']) && !empty($_GET['time']) && !empty($_GET['email']) && empty($frm)) {
39  $qid = query("SELECT mot_passe, id_utilisateur
40  FROM peel_utilisateurs
41  WHERE email = '" . nohtml_real_escape_string($_GET["email"]) . "' AND " . get_filter_site_cond('utilisateurs') . "");
42  $utilisateur = fetch_assoc($qid);
43  $new_hash = sha256($_GET["email"] . $_GET['time'] . $utilisateur['id_utilisateur'] . $utilisateur['mot_passe']);
44  if (($_GET['hash'] == $new_hash)) {
45  if ($_GET['time'] + (3600 * 24) > time()) {
46  $mode = 'renew_password';
47  } else {
48  $noticemsg = $GLOBALS['tplEngine']->createTemplate('global_error.tpl', array('message' => $GLOBALS['STR_ERR_TIME']))->fetch();
49  }
50  } else {
51  $noticemsg = $GLOBALS['tplEngine']->createTemplate('global_error.tpl', array('message' => $GLOBALS['STR_ERR_HASH']))->fetch();
52  }
53 } elseif (!empty($_POST['email'])) {
54  if (a_priv('demo')) {
55  echo $GLOBALS['tplEngine']->createTemplate('global_error.tpl', array('message' => array('message' => $GLOBALS['STR_DEMO_RIGHTS_LIMITED'])))->fetch();
56  die();
57  }
58  $form_error_object->valide_form($frm, array('email' => $GLOBALS['STR_ERR_EMAIL']));
59 
60  if (!$form_error_object->has_error('email')) {
61  $frm['email'] = trim($frm['email']);
62  if (!EmailOK($frm['email'])) {
63  $form_error_object->add('email', $GLOBALS['STR_ERR_EMAIL_BAD']);
64  } elseif ((num_rows(query("SELECT 1
65  FROM peel_utilisateurs
66  WHERE email = '" . nohtml_real_escape_string($frm["email"]) . "' AND priv NOT IN ('" . implode("','", $GLOBALS['disable_login_by_privilege']) . "') AND etat=1 AND " . get_filter_site_cond('utilisateurs') . "")) == 0)) {
67  // Compte inexistant, ou désactivé. Un compte désactivé n'est pas censé pouvoir retrouver son mot de passe.
68  $form_error_object->add('email', $GLOBALS['STR_ERR_NOEMAIL']);
69  }
70  }
71  if (!$form_error_object->count()) {
72  initialise_mot_passe($_POST["email"]);
73  $noticemsg = $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => $GLOBALS['STR_PASSWORD_EMAIL']))->fetch();
74  }
75 } elseif (!empty($_GET['email'])) {
76  if ((!empty($_POST['password_once']) && !empty($_POST['password_twice']) && String::strlen($_POST['password_once'])>=vb($GLOBALS['site_parameters']['password_length_required'], 8)) && !empty($_GET['email'])) {
77  $password_once = trim($_POST['password_once']);
78  $password_twice = trim($_POST['password_twice']);
79  $email = trim($_GET['email']);
80  if ($password_twice == $password_once) {
81  query("UPDATE peel_utilisateurs
82  SET mot_passe='" . real_escape_string(get_user_password_hash($password_once)) . "'
83  WHERE email='" . nohtml_real_escape_string($email) . "' AND " . get_filter_site_cond('utilisateurs') . "");
84  $noticemsg = $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => $GLOBALS['STR_RECOVER_PASSWORD_OK']))->fetch();
85  } else {
86  $mode = 'renew_password';
87  $form_error_object->add('mismatch_password', $GLOBALS['STR_ERR_MISMATCH_PASSWORD']);
88  }
89  // Vérification de la présence des deux mots de passe dans le formulaire de renouvellement de mot de passe.
90  } else {
91  $mode = 'renew_password';
92  $form_error_object->add('empty_field', sprintf($GLOBALS['STR_ERR_NEWPASS'], vb($GLOBALS['site_parameters']['password_length_required'], 8)));
93  }
94 }
95 
96 if (empty($noticemsg)) {
97  if ($form_error_object->has_error('token')) {
98  $output .= $form_error_object->text('token');
99  }
100  $output .= get_recover_password_form($frm, $form_error_object, $mode);
101 } else {
102  $output .= $GLOBALS['tplEngine']->createTemplate('recover_password_form.tpl', array('message' => $noticemsg, 'get_password' => $GLOBALS['STR_GET_PASSWORD']))->fetch();
103 }
104 
105 include($GLOBALS['repertoire_modele'] . "/haut.php");
106 echo $output;
107 include($GLOBALS['repertoire_modele'] . "/bas.php");
108 
initialise_mot_passe($email)
Initialise le renouvellement de mot de passe.
Definition: user.php:645
static strlen($string)
Returns the length of the given string.
Definition: String.php:36
nohtml_real_escape_string($value, $allowed_tags=null)
Protège les données pour insertion dans MySQL ET supprime les tags HTML pour protéger de toute sorte ...
Definition: database.php:400
$form_error_object
real_escape_string($value)
real_escape_string()
Definition: database.php:374
$GLOBALS['page_name']
get_filter_site_cond($table_technical_code, $table_alias=null, $use_strict_rights_if_in_admin=false, $specific_site_id=null, $exclude_public_items=false, $admin_force_multisite_if_allowed=false)
Retourne la condition SQL permettant de filtrer les données pour une table.
Definition: fonctions.php:4643
query($query, $die_if_error=false, $database_object=null, $silent_if_error=false, $security_sql_filter=true)
The query() function is meant to be called anywhere you want to make a query.
Definition: database.php:158
vb(&$var, $default=null)
Variable blanche if $var n'est pas défini, retourne $default, sinon retourne $var.
Definition: format.php:97
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
Definition: chart-data.php:160
get_user_password_hash($password, $tested_hash=null, $password_given_as_first_password_hash=false, $password_length_if_given_as_first_password_hash=null)
get_user_password_hash()
Definition: user.php:817
num_rows($query_result)
num_rows()
Definition: database.php:321
EmailOK($email)
Vérification du format d'adresse email trouvée sur http://www.phpinfo.net/?p=trucs&rub=astuces.
Definition: emails.php:282
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
$noticemsg
a_priv($requested_priv, $demo_allowed=false, $site_configuration_modification=false, $user_id=null)
Renvoie true si l'utilisateur de la session a le privilège $requested_priv ou un droit supérieur Des ...
Definition: user.php:63
verify_token($name= 'general', $delay_in_minutes=60, $check_referer_if_set_by_server=true, $cancel_token=true, $minimum_wait_in_seconds_before_use=0)
Vérification de la validité d'un token Par défaut, un token est valide 1h, et utilisable 1 seule fois...
Definition: fonctions.php:118

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:40 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.