3 @include_once(
"/etc/squirrelmail/alternc-changepass.conf");
4 if (!defined(
"ALTERNC_CHANGEPASS_LOC")) {
5 error_log(
"No configuration for squirrelmail plugin at /etc/squirrelmail/alternc-changepass.conf, please check");
9 bindtextdomain(
"alternc", ALTERNC_CHANGEPASS_LOC.
"/bureau/locales");
10 if (!function_exists(
"__")) {
11 function __($str) { echo _($str); }
22 $chars=
"./0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
24 $salt.=substr($chars,(mt_rand(0,strlen($chars))),1);
28 return crypt($pass,$salt);
32 ALTERNC_CHANGEPASS_MYSQL_HOST,
33 ALTERNC_CHANGEPASS_MYSQL_USER,
34 ALTERNC_CHANGEPASS_MYSQL_PASSWORD
37 mysql_select_db(ALTERNC_CHANGEPASS_MYSQL_DB);
39 __(
"Can't connect to MySQL server on AlternC!");
43 define(
'SM_PATH',
'../../');
46 require_once(
SM_PATH .
'include/validate.php');
47 require_once(
SM_PATH .
'functions/page_header.php');
48 require_once(
SM_PATH .
'functions/imap.php');
49 require_once(
SM_PATH .
'include/load_prefs.php');
52 sqgetGlobalVar(
'username',
$username, SQ_SESSION);
57 textdomain(
"alternc");
64 if ($_POST[
'acp_oldpass'] && $_POST[
'acp_newpass'] && $_POST[
'acp_verify']) {
65 if ($_POST[
'acp_newpass']!=$_POST[
'acp_verify']) {
66 $errstr=_(
"Your new passwords are differents, pleasy try again.");
69 $r=mysql_query(
"SELECT a.password, a.id FROM address a,domaines d WHERE a.address='".addslashes(
$login).
"' AND a.domain_id=d.id AND d.domaine='".addslashes(
$domain).
"';");
71 if (!(
$c=mysql_fetch_array(
$r))) {
72 $errstr=_(
"Your account has not been found, please try again later or ask an administrator.");
74 if (
$c[
"password"]!=
_md5cr($_POST[
'acp_oldpass'],
$c[
"password"])) {
75 $errstr=_(
"Your current password is incorrect, please try again.");
85 $acp_newpass=$_POST[
'acp_newpass'];
86 $newp=
_md5cr($acp_newpass);
87 mysql_query(
"UPDATE address SET password='".addslashes($newp).
"' WHERE id=".
$c[
"id"].
" ;");
88 $errstr=_(
"Your password has been successfully changed. Don't forget to change it in your mail software if you are using one (Outlook, Mozilla, Thunderbird, Eudora ...)");
91 $onetimepad = OneTimePadCreate(strlen($acp_newpass));
101 textdomain(
"squirrelmail");
103 displayPageHeader($color,
'None');
105 textdomain(
"alternc");
107 if (
$errstr) echo
"<p><b>".$errstr.
"</b></p>";
111 <h2><?php
__(
"Changing your mail password"); ?></h2>
112 <form method=
"post" action=
"change.php" name=
"main" id=
"main">
115 <th align=
"right"><label
for=
"acp_oldpass"><?php
__(
"Old Password:"); ?></label></th>
116 <td><input type=
"password" name=
"acp_oldpass" id=
"acp_oldpass" value=
"" size=
"20" /></td>
120 <th align=
"right"><label
for=
"acp_newpass"><?php
__(
"New Password:"); ?></label></th>
121 <td><input type=
"password" name=
"acp_newpass" id=
"acp_newpass" value=
"" size=
"20" /></td>
124 <th align=
"right"><label
for=
"acp_verify"><?php
__(
"Verify New Password:"); ?></label></th>
125 <td><input type=
"password" name=
"acp_verify" id=
"acp_verify" value=
"" size=
"20" /></td>
129 <td align=
"center" colspan=
"2"><input type=
"submit" value=
"<?php __("Change my mail password
"); ?>" name=
"plugin_changepass" /></td>
135 <script type=
"text/javascript">
136 document.forms[
'main'].acp_oldpass.focus();
137 document.forms[
'main'].setAttribute(
'autocomplete',
'off');
144 textdomain(
"squirrelmail");
if(!function_exists("__")) _md5cr($pass, $salt="")
Hashe un mot de passe en clair en MD5 avec un salt aléatoire.