khanat-opennel-code/code/web/public_php/ams/func/reset_password.php

45 lines
1.8 KiB
PHP
Raw Normal View History

2014-08-18 23:57:20 +00:00
<?php
function reset_password(){
//filter all data
$email = filter_var($_GET["email"], FILTER_SANITIZE_EMAIL);
$user = filter_var($_GET["user"], FILTER_SANITIZE_STRING);
$key = filter_var($_GET["key"], FILTER_SANITIZE_STRING);
2014-09-03 18:27:01 +00:00
2014-08-18 23:57:20 +00:00
$password = filter_var($_POST['NewPass'], FILTER_SANITIZE_STRING);
$confirmpass = filter_var($_POST['ConfirmNewPass'], FILTER_SANITIZE_STRING);
$target_id = WebUsers::getId($user);
$webUser = new WebUsers($target_id);
if( (WebUsers::getIdFromEmail($email) == $target_id) && (hash('sha512',$webUser->getHashedPass()) == $key) ){
$params = Array( 'user' => $user, 'CurrentPass' => "dummy", 'NewPass' => $password, 'ConfirmNewPass' => $confirmpass, 'adminChangesOther' => true);
$result = $webUser->check_change_password($params);
if ($result == "success"){
$result = array();
$status = WebUsers::setPassword($user, $password);
if($status == 'ok'){
$result['SUCCESS_PASS'] = "OK";
}else if($status == 'shardoffline'){
$result['SUCCESS_PASS'] = "SHARDOFF";
}
$result['no_visible_elements'] = 'TRUE';
helpers :: loadtemplate( 'reset_success', $result);
2014-09-03 18:27:01 +00:00
throw new SystemExit();
}
2014-08-18 23:57:20 +00:00
$GETString = "";
foreach($_GET as $key => $value){
$GETString = $GETString . $key . '=' . $value . "&";
2014-09-03 18:27:01 +00:00
}
2014-08-18 23:57:20 +00:00
if($GETString != ""){
$GETString = '?'.$GETString;
}
$result['getstring'] = $GETString;
$result['prevNewPass'] = $password;
$result['prevConfirmNewPass'] = $confirmpass;
$result['no_visible_elements'] = 'TRUE';
helpers :: loadtemplate( 'reset_password', $result);
2014-09-03 18:27:01 +00:00
throw new SystemExit();
2014-08-18 23:57:20 +00:00
}
2014-09-03 18:27:01 +00:00
}