Skip to content

Commit 1b3960e

Browse files
committedJan 5, 2012
v2.1 final
1 parent cd8cc88 commit 1b3960e

File tree

6 files changed

+111
-81
lines changed

6 files changed

+111
-81
lines changed
 

‎files/empty_file.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

‎home.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<td>'.$txt['index_new_pw'].' :</td><td><input type="password" size="10" name="new_pw" id="new_pw"/></td>
3838
</tr>
3939
<tr><td>'.$txt['index_change_pw_confirmation'].' :</td><td><input type="password" size="10" name="new_pw2" id="new_pw2" /></td></tr>
40-
<tr><td colspan="2"><input type="button" onClick="ChangerMdp()" value="'.$txt['index_change_pw_button'].'" /></td></tr>
40+
<tr><td colspan="2"><input type="button" onClick="ChangeMyPass()" value="'.$txt['index_change_pw_button'].'" /></td></tr>
4141
</table>
4242
</div>';
4343
}elseif ( !empty($_SESSION['derniere_connexion']) ){

‎install/install_ajax.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
('admin','custom_login_text',''),
187187
('admin','default_language','english'),
188188
('admin', 'send_stats', '".$_SESSION['send_stats']."'),
189-
('admin', 'send_mail_on_user_login', '0');
189+
('admin', 'send_mail_on_user_login', '0'),
190190
('cron', 'sending_emails', '0');");
191191
if ( $res4 ){
192192
echo 'document.getElementById("tbl_4").innerHTML = "<img src=\"images/tick.png\">";';

‎load.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ function aes_encrypt(text) {
351351
if ( $("#new_pw").val() != "" && $("#new_pw").val() == $("#new_pw2").val() ){
352352
if($("#pw_strength_value").val() >= $("#user_pw_complexity").val()){
353353
var data = "{\"new_pw\":\""+protectString($("#new_pw").val())+"\"}";
354-
355354
$.post(
356355
"sources/main.queries.php",
357356
{
@@ -598,6 +597,23 @@ function(data){
598597
);
599598
})
600599
600+
function ChangeMyPass(){
601+
var data = "{\"new_pw\":\""+protectString($("#new_pw").val())+"\"}";
602+
$.post(
603+
"sources/main.queries.php",
604+
{
605+
type : "change_pw",
606+
change_pw_origine : "first_change",
607+
complexity : "",
608+
data : aes_encrypt(data)
609+
},
610+
function(data){
611+
document.main_form.submit();
612+
},
613+
"json"
614+
);
615+
}
616+
601617
//Permits to upload passwords from KEEPASS file
602618
function ImportKEEPASS(file){
603619
//clean divs

‎sources/items.queries.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ function is_utf8($string)
244244
stripslashes($data_received['label']);
245245
if (!empty($data_received['description']) && isset($_SESSION['settings']['show_description']) && $_SESSION['settings']['show_description'] == 1)
246246
$html .= '&nbsp;<font size=2px>['.strip_tags(stripslashes(substr(CleanString($data_received['description']),0,30))).']</font>';
247-
$html .= '</a>';
247+
$html .= '</a><span style="float:right;margin:2px 10px 0px 0px;">';
248248

249249
// display quick icon shortcuts ?
250250
if (isset($_SESSION['settings']['copy_to_clipboard_small_icons']) && $_SESSION['settings']['copy_to_clipboard_small_icons'] == 1) {
@@ -257,7 +257,7 @@ function is_utf8($string)
257257
if (!empty($data_received['pw'])) {
258258
$item_pw = '<img src="includes/images/mini_lock_enable.png" id="icon_pw_'.$new_id.'" class="copy_clipboard" title="'.$txt['item_menu_copy_pw'].'" />';
259259
}
260-
$html .= '<span style="float:right;margin:2px 10px 0px 0px;">'.$item_login.'&nbsp;'.$item_pw;
260+
$html .= $item_login.'&nbsp;'.$item_pw;
261261
//$html .= '<input type="hidden" id="item_pw_in_list_'.$new_id.'" value="'.$data_received['pw'].'"><input type="hidden" id="item_login_in_list_'.$new_id.'" value="'.$data_received['login'].'">';
262262
}
263263

‎sources/main.queries.php

+89-76
Original file line numberDiff line numberDiff line change
@@ -46,89 +46,102 @@
4646
//Prepare variables
4747
$new_pw = encrypt(htmlspecialchars_decode($data_received['new_pw']));
4848

49-
if(isset($_POST['change_pw_origine']) && $_POST['change_pw_origine'] == "user_change"){
50-
//User has decided to change is PW
51-
52-
//Get a string with the old pw array
53-
$last_pw = explode(';',$_SESSION['last_pw']);
54-
55-
//if size is bigger then clean the array
56-
if ( sizeof($last_pw) > $_SESSION['settings']['number_of_used_pw'] && $_SESSION['settings']['number_of_used_pw'] > 0 ){
57-
for($x=0;$x<$_SESSION['settings']['number_of_used_pw'];$x++)
58-
unset($last_pw[$x]);
59-
60-
//reinit SESSION
61-
$_SESSION['last_pw'] = implode(';',$last_pw);
62-
}
63-
//specific case where admin setting "number_of_used_pw" is 0
64-
else if ( $_SESSION['settings']['number_of_used_pw'] == 0 ){
65-
$_SESSION['last_pw'] = "";
66-
$last_pw = array();
67-
}
49+
//User has decided to change is PW
50+
if(isset($_POST['change_pw_origine']) && $_POST['change_pw_origine'] == "user_change"){
51+
//Get a string with the old pw array
52+
$last_pw = explode(';',$_SESSION['last_pw']);
53+
54+
//if size is bigger then clean the array
55+
if ( sizeof($last_pw) > $_SESSION['settings']['number_of_used_pw'] && $_SESSION['settings']['number_of_used_pw'] > 0 ){
56+
for($x=0;$x<$_SESSION['settings']['number_of_used_pw'];$x++)
57+
unset($last_pw[$x]);
58+
59+
//reinit SESSION
60+
$_SESSION['last_pw'] = implode(';',$last_pw);
61+
}
62+
//specific case where admin setting "number_of_used_pw" is 0
63+
else if ( $_SESSION['settings']['number_of_used_pw'] == 0 ){
64+
$_SESSION['last_pw'] = "";
65+
$last_pw = array();
66+
}
6867

69-
//check if new pw is different that old ones
70-
if ( in_array($new_pw,$last_pw) ){
71-
echo '[ { "error" : "already_used" } ]';
72-
}else{
73-
//update old pw with new pw
74-
if ( sizeof($last_pw) == ($_SESSION['settings']['number_of_used_pw']+1) ){
75-
unset($last_pw[0]);
76-
}else{
77-
array_push($last_pw,$new_pw);
78-
}
68+
//check if new pw is different that old ones
69+
if ( in_array($new_pw,$last_pw) ){
70+
echo '[ { "error" : "already_used" } ]';
71+
}else{
72+
//update old pw with new pw
73+
if ( sizeof($last_pw) == ($_SESSION['settings']['number_of_used_pw']+1) ){
74+
unset($last_pw[0]);
75+
}else{
76+
array_push($last_pw,$new_pw);
77+
}
7978

80-
//create a list of last pw based on the table
81-
$old_pw = "";
82-
foreach($last_pw as $elem){
83-
if ( !empty($elem) ){
84-
if (empty($old_pw)) $old_pw = $elem;
85-
else $old_pw .= ";".$elem;
86-
}
87-
}
79+
//create a list of last pw based on the table
80+
$old_pw = "";
81+
foreach($last_pw as $elem){
82+
if ( !empty($elem) ){
83+
if (empty($old_pw)) $old_pw = $elem;
84+
else $old_pw .= ";".$elem;
85+
}
86+
}
8887

89-
//update sessions
90-
$_SESSION['last_pw'] = $old_pw;
91-
$_SESSION['last_pw_change'] = mktime(0,0,0,date('m'),date('d'),date('y'));
92-
$_SESSION['validite_pw'] = true;
93-
94-
//update DB
95-
$db->query_update(
96-
"users",
97-
array(
98-
'pw' => $new_pw,
99-
'last_pw_change' => mktime(0,0,0,date('m'),date('d'),date('y')),
100-
'last_pw' => $old_pw
101-
),
102-
"id = ".$_SESSION['user_id']
103-
);
104-
105-
echo '[ { "error" : "none" } ]';
106-
}
107-
}else
108-
//ADMIN has decided to change the USER's PW
109-
if(isset($_POST['change_pw_origine']) && $_POST['change_pw_origine'] == "admin_change"){
110-
//Check KEY
111-
if ($data_received['key'] != $_SESSION['key']) {
112-
echo '[ { "error" : "key_not_conform" } ]';
113-
exit();
114-
}
88+
//update sessions
89+
$_SESSION['last_pw'] = $old_pw;
90+
$_SESSION['last_pw_change'] = mktime(0,0,0,date('m'),date('d'),date('y'));
91+
$_SESSION['validite_pw'] = true;
11592

11693
//update DB
117-
$db->query_update(
118-
"users",
119-
array(
120-
'pw' => $new_pw,
121-
'last_pw_change' => mktime(0,0,0,date('m'),date('d'),date('y'))
122-
),
123-
"id = ".$data_received['user_id']
124-
);
125-
126-
echo '[ { "error" : "none" } ]';
127-
}
94+
$db->query_update(
95+
"users",
96+
array(
97+
'pw' => $new_pw,
98+
'last_pw_change' => mktime(0,0,0,date('m'),date('d'),date('y')),
99+
'last_pw' => $old_pw
100+
),
101+
"id = ".$_SESSION['user_id']
102+
);
128103

129-
else{
130-
echo '[ { "error" : "nothing_to_do" } ]';
104+
echo '[ { "error" : "none" } ]';
131105
}
106+
}
107+
//ADMIN has decided to change the USER's PW
108+
elseif(isset($_POST['change_pw_origine']) && $_POST['change_pw_origine'] == "admin_change"){
109+
//Check KEY
110+
if ($data_received['key'] != $_SESSION['key']) {
111+
echo '[ { "error" : "key_not_conform" } ]';
112+
exit();
113+
}
114+
115+
//update DB
116+
$db->query_update(
117+
"users",
118+
array(
119+
'pw' => $new_pw,
120+
'last_pw_change' => mktime(0,0,0,date('m'),date('d'),date('y'))
121+
),
122+
"id = ".$data_received['user_id']
123+
);
124+
125+
echo '[ { "error" : "none" } ]';
126+
}
127+
//ADMIN first login
128+
if(isset($_POST['change_pw_origine']) && $_POST['change_pw_origine'] == "first_change"){
129+
//update DB
130+
$db->query_update(
131+
"users",
132+
array(
133+
'pw' => $new_pw,
134+
'last_pw_change' => mktime(0,0,0,date('m'),date('d'),date('y'))
135+
),
136+
"id = ".$_SESSION['user_id']
137+
);
138+
$_SESSION['last_pw_change'] = mktime(0,0,0,date('m'),date('d'),date('y'));
139+
echo '[ { "error" : "none" } ]';
140+
}
141+
//DEFAULT case
142+
else{
143+
echo '[ { "error" : "nothing_to_do" } ]';
144+
}
132145

133146
break;
134147

0 commit comments

Comments
 (0)
Please sign in to comment.