From f7b777c90ac54e4c33d9e57ea132e44b49ce487a Mon Sep 17 00:00:00 2001 From: plegall Date: Sun, 18 Sep 2005 00:29:49 +0000 Subject: - 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 --- doc/ChangeLog | 4 + identification.php | 3 +- language/en_UK.iso-8859-1/common.lang.php | 12 ++ language/fr_FR.iso-8859-1/common.lang.php | 12 ++ password.php | 217 ++++++++++++++++++++++++++++++ template/yoga/content.css | 1 + template/yoga/identification.tpl | 2 + template/yoga/password.tpl | 51 +++++++ template/yoga/register.tpl | 1 + template/yoga/theme/lost_password.png | Bin 0 -> 1716 bytes 10 files changed, 301 insertions(+), 2 deletions(-) create mode 100644 password.php create mode 100644 template/yoga/password.tpl create mode 100644 template/yoga/theme/lost_password.png diff --git a/doc/ChangeLog b/doc/ChangeLog index 7f034c412..0a5aa9c64 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -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 diff --git a/identification.php b/identification.php index 772f42722..c55e009ed 100644 --- a/identification.php +++ b/identification.php @@ -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') diff --git a/language/en_UK.iso-8859-1/common.lang.php b/language/en_UK.iso-8859-1/common.lang.php index 756408332..7dddd87ed 100644 --- a/language/en_UK.iso-8859-1/common.lang.php +++ b/language/en_UK.iso-8859-1/common.lang.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'; ?> \ No newline at end of file diff --git a/language/fr_FR.iso-8859-1/common.lang.php b/language/fr_FR.iso-8859-1/common.lang.php index 8b3df9ec9..5c6a9fc7d 100644 --- a/language/fr_FR.iso-8859-1/common.lang.php +++ b/language/fr_FR.iso-8859-1/common.lang.php @@ -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'; ?> \ No newline at end of file diff --git a/password.php b/password.php new file mode 100644 index 000000000..0be971964 --- /dev/null +++ b/password.php @@ -0,0 +1,217 @@ +'."\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 = + '' + .l10n('Contact webmaster') + .'' + ; + + 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'); + +?> \ No newline at end of file diff --git a/template/yoga/content.css b/template/yoga/content.css index 4d3775b21..c9aadf458 100644 --- a/template/yoga/content.css +++ b/template/yoga/content.css @@ -15,6 +15,7 @@ BODY#theProfilePage #content, BODY#theSearchPage #content, BODY#theAboutPage #content, BODY#thePopuphelpPage #content, +BODY#thePasswordPage #content, BODY#theNotificationPage #content { margin: 1em; diff --git a/template/yoga/identification.tpl b/template/yoga/identification.tpl index d120524d0..ef4fc2e8c 100644 --- a/template/yoga/identification.tpl +++ b/template/yoga/identification.tpl @@ -3,6 +3,7 @@
@@ -48,6 +49,7 @@

{L_REGISTER} + {lang:Forgot your password?}

diff --git a/template/yoga/password.tpl b/template/yoga/password.tpl new file mode 100644 index 000000000..e077fa905 --- /dev/null +++ b/template/yoga/password.tpl @@ -0,0 +1,51 @@ + +
+ +
+
    +
  • {lang:home}
  • +
+

{lang:Password forgotten}

+
+ + +
+
    + +
  • {errors.error.ERROR}
  • + +
+
+ + + +
+
    + +
  • {infos.info.INFO}
  • + +
+
+ + +
+
+ {lang:Retrieve password} + +
    +
  • + + +
  • + +
  • + + +
  • +
+
+ +

+
+ +
diff --git a/template/yoga/register.tpl b/template/yoga/register.tpl index 09740e881..5aa861b41 100644 --- a/template/yoga/register.tpl +++ b/template/yoga/register.tpl @@ -42,6 +42,7 @@
  • + ({lang:useful when password forgotten})
  • diff --git a/template/yoga/theme/lost_password.png b/template/yoga/theme/lost_password.png new file mode 100644 index 000000000..76e50305f Binary files /dev/null and b/template/yoga/theme/lost_password.png differ -- cgit v1.2.3