- new: automatic new password sent by mail when requested by user
git-svn-id: http://piwigo.org/svn/trunk@866 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
60fc8c061a
commit
f7b777c90a
10 changed files with 301 additions and 2 deletions
|
@ -1,3 +1,7 @@
|
|||
2005-09-17 Pierrick LE GALL
|
||||
|
||||
* new: automatic new password sent by mail when requested by user
|
||||
|
||||
2005-09-17 Pierrick LE GALL
|
||||
|
||||
* improvement: add information about how to use an external table
|
||||
|
|
|
@ -71,8 +71,6 @@ $template->set_filenames( array('identification'=>'identification.tpl') );
|
|||
|
||||
$template->assign_vars(
|
||||
array(
|
||||
'MAIL_ADMIN' => $conf['mail_webmaster'],
|
||||
|
||||
'L_TITLE' => $lang['identification'],
|
||||
'L_USERNAME' => $lang['login'],
|
||||
'L_PASSWORD' => $lang['password'],
|
||||
|
@ -83,6 +81,7 @@ $template->assign_vars(
|
|||
'L_REMEMBER_ME'=>$lang['remember_me'],
|
||||
|
||||
'U_REGISTER' => add_session_id(PHPWG_ROOT_PATH.'register.php'),
|
||||
'U_LOST_PASSWORD' => add_session_id(PHPWG_ROOT_PATH.'password.php'),
|
||||
'U_HOME' => add_session_id(PHPWG_ROOT_PATH.'category.php'),
|
||||
|
||||
'F_LOGIN_ACTION' => add_session_id(PHPWG_ROOT_PATH.'identification.php')
|
||||
|
|
|
@ -48,17 +48,21 @@ $lang['Category'] = 'Category';
|
|||
$lang['Close this window'] = 'Close this window';
|
||||
$lang['Confirm Password'] = 'Confirm Password';
|
||||
$lang['Connection settings'] = 'Connection settings';
|
||||
$lang['Contact webmaster'] = 'Contact webmaster';
|
||||
$lang['Create a new account'] = 'Create a new account';
|
||||
$lang['Created on'] = 'Created on';
|
||||
$lang['Current password is wrong'] = 'Current password is wrong';
|
||||
$lang['Dimensions'] = 'Dimensions';
|
||||
$lang['Display'] = 'Display';
|
||||
$lang['Email address is missing'] = 'Email address is missing';
|
||||
$lang['Email address'] = 'Email address';
|
||||
$lang['Enter your personnal informations'] = 'Enter your personnal informations';
|
||||
$lang['Error sending email'] = 'Error sending email';
|
||||
$lang['File'] = 'File';
|
||||
$lang['Filesize'] = 'Filesize';
|
||||
$lang['Filter and display'] = 'Filter and display';
|
||||
$lang['Filter'] = 'Filter';
|
||||
$lang['Forgot your password?'] = 'Forgot your password?';
|
||||
$lang['Go through the gallery as a visitor'] = 'Go through the gallery as a visitor';
|
||||
$lang['Help'] = 'Help';
|
||||
$lang['Identification'] = 'Identification';
|
||||
|
@ -69,9 +73,13 @@ $lang['Mail address'] = 'Mail address';
|
|||
$lang['N/A'] = 'N/A';
|
||||
$lang['New on %s'] = 'New on %s';
|
||||
$lang['New password confirmation does not correspond'] = 'New password confirmation does not correspond';
|
||||
$lang['New password sent by email'] = 'New password sent by email';
|
||||
$lang['No email address'] = 'No email address';
|
||||
$lang['No user matches this email address'] = 'No user matches this email address';
|
||||
$lang['Notification'] = 'Notification';
|
||||
$lang['Number of items'] = 'Number of items';
|
||||
$lang['Original dimensions'] = 'Original dimensions';
|
||||
$lang['Password forgotten'] = 'Password forgotten';
|
||||
$lang['Password'] = 'Password';
|
||||
$lang['PhpWebGallery Help'] = 'PhpWebGallery Help';
|
||||
$lang['Profile'] = 'Profile';
|
||||
|
@ -80,7 +88,9 @@ $lang['Register'] = 'Register';
|
|||
$lang['Registered on'] = 'Registered on';
|
||||
$lang['Registration'] = 'Registration';
|
||||
$lang['Reset'] = 'Reset';
|
||||
$lang['Retrieve password'] = 'Retrieve password';
|
||||
$lang['Search'] = 'Search';
|
||||
$lang['Send new password'] = 'Send new password';
|
||||
$lang['Since'] = 'Since';
|
||||
$lang['Sort by'] = 'Sort by';
|
||||
$lang['Sort order'] = 'Sort order';
|
||||
|
@ -197,6 +207,7 @@ $lang['no_category'] = 'Home';
|
|||
$lang['no_rate'] = 'no rate';
|
||||
$lang['notification'] = 'notification';
|
||||
$lang['only_members'] = 'Only members can access this page';
|
||||
$lang['password updated'] = 'password updated';
|
||||
$lang['password'] = 'Password';
|
||||
$lang['password_hint'] = 'You only have to give your password if you wish to change your e-mail';
|
||||
$lang['periods_error'] = 'Recent period must be a positive integer value';
|
||||
|
@ -286,6 +297,7 @@ $lang['upload_picture'] = 'Upload a picture';
|
|||
$lang['upload_successful'] = 'Picture uploaded with success, an administrator will validate it as soon as possible';
|
||||
$lang['upload_title'] = 'Upload a picture';
|
||||
$lang['upload_username'] = 'Username';
|
||||
$lang['useful when password forgotten'] = 'useful when password forgotten';
|
||||
$lang['w_month'] = 'Month';
|
||||
$lang['yes'] = 'Yes';
|
||||
?>
|
|
@ -47,17 +47,21 @@ $lang['Category'] = 'Cat
|
|||
$lang['Close this window'] = 'Fermer cette fenêtre';
|
||||
$lang['Confirm Password'] = 'Confirmer le mot de passe';
|
||||
$lang['Connection settings'] = 'Paramètres de connexion';
|
||||
$lang['Contact webmaster'] = 'Contacter le webmestre';
|
||||
$lang['Create a new account'] = 'Créer un nouveau compte';
|
||||
$lang['Created on'] = 'Créer le';
|
||||
$lang['Current password is wrong'] = 'Erreur sur le mot de passe actuel';
|
||||
$lang['Dimensions'] = 'Dimensions';
|
||||
$lang['Display'] = 'Affichage';
|
||||
$lang['Email address is missing'] = 'L\'adresse email manque';
|
||||
$lang['Email address'] = 'Adresse email';
|
||||
$lang['Enter your personnal informations'] = 'Entrer vos informations personnelles';
|
||||
$lang['Error sending email'] = 'Erreur à l\'envoi du mail';
|
||||
$lang['File'] = 'Fichier';
|
||||
$lang['Filesize'] = 'Poids';
|
||||
$lang['Filter and display'] = 'Filtrer et afficher';
|
||||
$lang['Filter'] = 'Filtre';
|
||||
$lang['Forgot your password?'] = 'Mot de passe oublié ?';
|
||||
$lang['Go through the gallery as a visitor'] = 'Parcourir la galerie en tant que visiteur';
|
||||
$lang['Help'] = 'Aide';
|
||||
$lang['Identification'] = 'Identification';
|
||||
|
@ -68,9 +72,13 @@ $lang['Mail address'] = $lang['Email address'];
|
|||
$lang['N/A'] = 'non disponible';
|
||||
$lang['New on %s'] = 'Nouveau le %s';
|
||||
$lang['New password confirmation does not correspond'] = 'Erreur de confirmation de mot de passe';
|
||||
$lang['New password sent by email'] = 'Nouveau mot de passe envoyé par mail';
|
||||
$lang['No email address'] = 'Pas d\'adresse email';
|
||||
$lang['No user matches this email address'] = 'Cette adresse email ne correspond à aucun utilisateur';
|
||||
$lang['Notification'] = 'Notification';
|
||||
$lang['Number of items'] = 'Nombre d\'élément';
|
||||
$lang['Original dimensions'] = 'Dimensions d\'origine';
|
||||
$lang['Password forgotten'] = 'Mot de passe oublié';
|
||||
$lang['Password'] = 'Mot de passe';
|
||||
$lang['PhpWebGallery Help'] = 'Aide de PhpWebGallery';
|
||||
$lang['Profile'] = 'Profil';
|
||||
|
@ -79,7 +87,9 @@ $lang['Register'] = 'S\'enregistrer';
|
|||
$lang['Registered on'] = 'Enregistré le';
|
||||
$lang['Registration'] = 'Enregistrement';
|
||||
$lang['Reset'] = 'Annuler';
|
||||
$lang['Retrieve password'] = 'Récupérer un mot de passe';
|
||||
$lang['Search'] = 'Rechercher';
|
||||
$lang['Send new password'] = 'Envoyer le nouveau mot de passe';
|
||||
$lang['Since'] = 'Depuis';
|
||||
$lang['Sort by'] = 'Trier selon';
|
||||
$lang['Sort order'] = 'Ordre de tri';
|
||||
|
@ -196,6 +206,7 @@ $lang['no_category'] = 'Accueil';
|
|||
$lang['no_rate'] = 'pas de note';
|
||||
$lang['notification'] = 'notification';
|
||||
$lang['only_members'] = 'Seuls les membres enregistrés peuvent accéder à cette page';
|
||||
$lang['password updated'] = 'mot de passe mis à jour';
|
||||
$lang['password'] = 'Mot de passe';
|
||||
$lang['password_hint'] = 'Vous n\'avez à donner votre mot de passe que si vous désirez en changer.';
|
||||
$lang['periods_error'] = 'La période de nouveauté doit être un entier positif';
|
||||
|
@ -285,6 +296,7 @@ $lang['upload_picture'] = 'Ajouter une image';
|
|||
$lang['upload_successful'] = 'Image ajoutée avec succès, un administrateur doit valider l\'ajout pour le rendre visible';
|
||||
$lang['upload_title'] = 'Ajouter une image';
|
||||
$lang['upload_username'] = 'Nom utilisateur';
|
||||
$lang['useful when password forgotten'] = 'utile en cas d\'oubli de mot de passe';
|
||||
$lang['w_month'] = 'Mois';
|
||||
$lang['yes'] = 'Oui';
|
||||
?>
|
217
password.php
Normal file
217
password.php
Normal file
|
@ -0,0 +1,217 @@
|
|||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $RCSfile$
|
||||
// | last update : $Date$
|
||||
// | last modifier : $Author$
|
||||
// | revision : $Revision$
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | This program is free software; you can redistribute it and/or modify |
|
||||
// | it under the terms of the GNU General Public License as published by |
|
||||
// | the Free Software Foundation |
|
||||
// | |
|
||||
// | This program is distributed in the hope that it will be useful, but |
|
||||
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||
// | General Public License for more details. |
|
||||
// | |
|
||||
// | You should have received a copy of the GNU General Public License |
|
||||
// | along with this program; if not, write to the Free Software |
|
||||
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||
// | USA. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | initialization |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
define('PHPWG_ROOT_PATH','./');
|
||||
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | functions |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* sends an email, using PhpWebGallery specific informations
|
||||
*/
|
||||
function pwg_mail($to, $from, $infos = '')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$headers = 'From: <'.$from.'>'."\n";
|
||||
$headers.= 'Reply-To: '.$from."\n";
|
||||
|
||||
$options = '-f '.$from;
|
||||
|
||||
$subject = l10n('password updated');
|
||||
|
||||
$content = $infos;
|
||||
$content.= "\n\n-- \nPhpWebGallery ".PHPWG_VERSION;
|
||||
|
||||
return mail($to, $subject, $content, $headers, $options);
|
||||
}
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | send a new password |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
$page['errors'] = array();
|
||||
$page['infos'] = array();
|
||||
|
||||
if (isset($_POST['submit']))
|
||||
{
|
||||
// in case of error, creation of mailto link
|
||||
$query = '
|
||||
SELECT '.$conf['user_fields']['email'].'
|
||||
FROM '.USERS_TABLE.'
|
||||
WHERE '.$conf['user_fields']['id'].' = '.$conf['webmaster_id'].'
|
||||
;';
|
||||
list($mail_webmaster) = mysql_fetch_array(pwg_query($query));
|
||||
|
||||
$mailto =
|
||||
'<a href="mailto:'.$mail_webmaster.'">'
|
||||
.l10n('Contact webmaster')
|
||||
.'</a>'
|
||||
;
|
||||
|
||||
if (isset($_POST['no_mail_address']) and $_POST['no_mail_address'] == 1)
|
||||
{
|
||||
array_push($page['infos'], l10n('Email address is missing'));
|
||||
array_push($page['infos'], $mailto);
|
||||
}
|
||||
else if (isset($_POST['mail_address']) and !empty($_POST['mail_address']))
|
||||
{
|
||||
$mail_address = mysql_escape_string($_POST['mail_address']);
|
||||
|
||||
$query = '
|
||||
SELECT '.$conf['user_fields']['id'].' AS id
|
||||
, '.$conf['user_fields']['username'].' AS username
|
||||
, '.$conf['user_fields']['email'].' AS email
|
||||
FROM '.USERS_TABLE.'
|
||||
WHERE '.$conf['user_fields']['email'].' = \''.$mail_address.'\'
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
|
||||
if (mysql_num_rows($result) > 0)
|
||||
{
|
||||
$error_on_mail = false;
|
||||
$datas = array();
|
||||
|
||||
while ($row = mysql_fetch_array($result))
|
||||
{
|
||||
$new_password = generate_key(6);
|
||||
|
||||
$infos =
|
||||
l10n('Username').': '.$row['username']
|
||||
."\n".l10n('Password').': '.$new_password
|
||||
;
|
||||
|
||||
if (pwg_mail($row['email'], $mail_webmaster, $infos))
|
||||
{
|
||||
$data =
|
||||
array(
|
||||
$conf['user_fields']['id']
|
||||
=> $row['id'],
|
||||
|
||||
$conf['user_fields']['password']
|
||||
=> $conf['pass_convert']($new_password)
|
||||
);
|
||||
|
||||
array_push($datas, $data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$error_on_mail = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($error_on_mail)
|
||||
{
|
||||
array_push($page['errors'], l10n('Error sending email'));
|
||||
array_push($page['errors'], $mailto);
|
||||
}
|
||||
else
|
||||
{
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
mass_updates(
|
||||
USERS_TABLE,
|
||||
array(
|
||||
'primary' => array($conf['user_fields']['id']),
|
||||
'update' => array($conf['user_fields']['password'])
|
||||
),
|
||||
$datas
|
||||
);
|
||||
|
||||
array_push($page['infos'], l10n('New password sent by email'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
array_push($page['errors'], l10n('No user matches this email address'));
|
||||
array_push($page['errors'], $mailto);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | template initialization |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
$title = l10n('Forgot your password?');
|
||||
$page['body_id'] = 'thePasswordPage';
|
||||
include(PHPWG_ROOT_PATH.'include/page_header.php');
|
||||
$template->set_filenames(array('password'=>'password.tpl'));
|
||||
|
||||
$template->assign_vars(
|
||||
array(
|
||||
'U_HOME' => add_session_id(PHPWG_ROOT_PATH.'category.php')
|
||||
)
|
||||
);
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | infos & errors display |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
if (count($page['errors']) != 0)
|
||||
{
|
||||
$template->assign_block_vars('errors', array());
|
||||
|
||||
foreach ($page['errors'] as $error)
|
||||
{
|
||||
$template->assign_block_vars(
|
||||
'errors.error',
|
||||
array(
|
||||
'ERROR' => $error
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($page['infos']) != 0)
|
||||
{
|
||||
$template->assign_block_vars('infos', array());
|
||||
|
||||
foreach ($page['infos'] as $info)
|
||||
{
|
||||
$template->assign_block_vars(
|
||||
'infos.info',
|
||||
array(
|
||||
'INFO' => $info
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | html code display |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
$template->parse('password');
|
||||
include(PHPWG_ROOT_PATH.'include/page_tail.php');
|
||||
|
||||
?>
|
|
@ -15,6 +15,7 @@ BODY#theProfilePage #content,
|
|||
BODY#theSearchPage #content,
|
||||
BODY#theAboutPage #content,
|
||||
BODY#thePopuphelpPage #content,
|
||||
BODY#thePasswordPage #content,
|
||||
BODY#theNotificationPage #content
|
||||
{
|
||||
margin: 1em;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
<div class="titrePage">
|
||||
<ul class="categoryActions">
|
||||
<li><a href="{U_LOST_PASSWORD}" title="{lang:Forgot your password?}"><img src="template/yoga/theme/lost_password.png" alt="{lang:Forgot your password?}"></a></li>
|
||||
<li><a href="{U_REGISTER}" title="{lang:Create a new account}"><img src="./template/yoga/theme/register.png" alt="{lang:register}"/></a></li>
|
||||
<li><a href="{U_HOME}" title="{lang:Go through the gallery as a visitor}"><img src="./template/yoga/theme/home.png" alt="{lang:home}"/></a></li>
|
||||
</ul>
|
||||
|
@ -48,6 +49,7 @@
|
|||
|
||||
<p>
|
||||
<a href="{U_REGISTER}"><img src="template/yoga/theme/register.png" alt=""> {L_REGISTER}</a>
|
||||
<a href="{U_LOST_PASSWORD}"><img src="template/yoga/theme/lost_password.png" alt=""> {lang:Forgot your password?}</a>
|
||||
</p>
|
||||
|
||||
</div> <!-- content -->
|
||||
|
|
51
template/yoga/password.tpl
Normal file
51
template/yoga/password.tpl
Normal file
|
@ -0,0 +1,51 @@
|
|||
<!-- $Id$ -->
|
||||
<div id="content">
|
||||
|
||||
<div class="titrePage">
|
||||
<ul class="categoryActions">
|
||||
<li><a href="{U_HOME}" title="{lang:Go through the gallery as a visitor}"><img src="./template/yoga/theme/home.png" alt="{lang:home}"/></a></li>
|
||||
</ul>
|
||||
<h2>{lang:Password forgotten}</h2>
|
||||
</div>
|
||||
|
||||
<!-- BEGIN errors -->
|
||||
<div class="errors">
|
||||
<ul>
|
||||
<!-- BEGIN error -->
|
||||
<li>{errors.error.ERROR}</li>
|
||||
<!-- END error -->
|
||||
</ul>
|
||||
</div>
|
||||
<!-- END errors -->
|
||||
|
||||
<!-- BEGIN infos -->
|
||||
<div class="infos">
|
||||
<ul>
|
||||
<!-- BEGIN info -->
|
||||
<li>{infos.info.INFO}</li>
|
||||
<!-- END info -->
|
||||
</ul>
|
||||
</div>
|
||||
<!-- END infos -->
|
||||
|
||||
<form action="{F_ACTION}" method="post" class="properties">
|
||||
<fieldset>
|
||||
<legend>{lang:Retrieve password}</legend>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<label for="mail_address">{lang:Email address}</label>
|
||||
<input class="login" type="text" name="mail_address" id="mail_address" size="40" maxlength="40">
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<label>{lang:No email address}</label>
|
||||
<input type="checkbox" name="no_mail_address" value="1">
|
||||
</li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
|
||||
<p><input type="submit" name="submit" value="{lang:Send new password}"></p>
|
||||
</form>
|
||||
|
||||
</div> <!-- content -->
|
|
@ -42,6 +42,7 @@
|
|||
<li>
|
||||
<label for="mail_address">{lang:Mail address}</label>
|
||||
<input type="text" name="mail_address" id="mail_address" value="{F_EMAIL}" onfocus="this.className='focus';" onblur="this.className='nofocus';">
|
||||
({lang:useful when password forgotten})
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
|
BIN
template/yoga/theme/lost_password.png
Normal file
BIN
template/yoga/theme/lost_password.png
Normal file
Binary file not shown.
Loading…
Reference in a new issue