View file wu-engine/wu-actions/acc_change_password.php

File size: 1.17Kb
<?php
require_once('../wu_init.php');
if (!wu_token()) { exit('wu-error'); }
if (!USER_LOGGED) { exit('wu-error'); }

if(isset($_POST['pnow']) && isset($_POST['pnew'])){
if(!empty($_POST['pnow']) && !empty($_POST['pnew'])){
$pnow = mysqli_real_escape_string($connect_db, trim($_POST['pnow']));
$pnew = mysqli_real_escape_string($connect_db, trim($_POST['pnew']));
if(strlen($pnew) < '3'){ exit('5'); }
$now_pass = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT uid,pas,regdate FROM ".DB_PREFIX."_users WHERE uid = '$u_id' LIMIT 1"));
$npas = md5(md5(trim($now_pass['regdate'].'_'.$pnow)));
$newp = md5(md5(trim($now_pass['regdate'].'_'.$pnew)));
if ($npas != $now_pass['pas']) { wu_log_act(1, 'Пытался сменить пароль с неверным вводом старого пароля'); exit('0'); }
if ($newp == $now_pass['pas']) { wu_log_act(1, 'Пытался сменить пароль на существующий'); exit('2'); }
mysqli_query($connect_db, "UPDATE `".DB_PREFIX."_users` SET `pas` = '$newp' WHERE uid = '$u_id' LIMIT 1");
wu_log_act(0, 'Сменил пароль');
$_SESSION['pas'] = md5($newp);
exit('1');
} else { exit('4'); }
} else { exit('wu-error'); }
?>