add reminder
This commit is contained in:
@@ -252,7 +252,6 @@ function client_secret($id, $password){
|
||||
|
||||
function client_add_password($client_id, $password, $confirm, $minlen = 5){
|
||||
|
||||
|
||||
if ($password == ''){
|
||||
return 'пароль не задан';
|
||||
}
|
||||
@@ -268,11 +267,8 @@ function client_add_password($client_id, $password, $confirm, $minlen = 5){
|
||||
$clientpassword = password_hash($password, PASSWORD_DEFAULT);
|
||||
$sqlupdate = "UPDATE `clients` SET `clientpassword` = '$clientpassword' WHERE `client_id` = '$client_id'";
|
||||
|
||||
|
||||
$result = db_get($sqlupdate, 'chitatel');
|
||||
|
||||
|
||||
|
||||
return ['newpassword' => $clientpassword];
|
||||
|
||||
}
|
||||
|
||||
@@ -110,6 +110,100 @@ function test_client_hash_kuri($hash){
|
||||
}
|
||||
|
||||
|
||||
|
||||
function reminder_kuri(){
|
||||
|
||||
|
||||
if (isset($_POST['resetmail'])){
|
||||
|
||||
$resetmail = trim(mb_strtolower($_POST['resetmail']));
|
||||
|
||||
|
||||
$client = db_get("SELECT * FROM `clients` WHERE `clientmail` = '$resetmail' LIMIT 1");
|
||||
|
||||
|
||||
if (count($client) > 0 ) {
|
||||
|
||||
$resetdate = date('Y-m-d G:i:s');
|
||||
|
||||
$items = array();
|
||||
$items['resetmail'] = $resetmail;
|
||||
$items['client_id'] = $client['client_id'];
|
||||
$items['resetdate'] = $resetdate;
|
||||
$items['resetstatus'] = 0;
|
||||
$items['resethash'] = md5($resetmail.$resetdate);
|
||||
|
||||
$result = db_insert('resetpwd', $items, 'klan');
|
||||
|
||||
$link = SITE.'resetpassword/'.$items['resethash'];
|
||||
|
||||
$tempcontent = VIEWPATH.'reminder_end.phtml';
|
||||
include VIEWPATH.'layout_lite.phtml'; //центральный шаблон
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
$error = 'Адрес электронной почты не найден';
|
||||
$tempcontent = VIEWPATH.'reminder.phtml';
|
||||
include VIEWPATH.'layout_lite.phtml'; //центральный шаблон
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
$tempcontent = VIEWPATH.'reminder.phtml';
|
||||
include VIEWPATH.'layout_lite.phtml'; //центральный шаблон
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function resetpassword_kuri($hash){
|
||||
|
||||
$url = "/resetpassword/$hash";
|
||||
$minlen = 5;
|
||||
|
||||
$resetsql = "SELECT * FROM `resetpwd` WHERE `resethash` = '$hash' AND `resetstatus` = '0' LIMIT 1";
|
||||
$resetclient = db_get($resetsql);
|
||||
|
||||
if (count($resetclient) > 0){
|
||||
|
||||
if (isset($_POST['reset-submit'])){
|
||||
|
||||
$result = client_add_password($resetclient['client_id'], $_POST['new-password'], $_POST['confirm-password'], $minlen);
|
||||
|
||||
if (isset($result['newpassword'])){
|
||||
|
||||
db_get("UPDATE `resetpwd` SET `resetstatus` = 1 WHERE `resetpwd_id` = ${$client['client_id']}");
|
||||
|
||||
add_user_cookie($client['client_id'], $result['newpassword']);
|
||||
$linklab = SITE.'mybooks';
|
||||
$viewform = False;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
$viewform = True;
|
||||
}
|
||||
|
||||
$tempcontent = VIEWPATH.'reset.phtml';
|
||||
include VIEWPATH.'layout_lite.phtml';
|
||||
}
|
||||
|
||||
|
||||
|
||||
else {
|
||||
echo 'неверная ссылка';
|
||||
return false;
|
||||
}
|
||||
|
||||
return True;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if(password_verify($_POST["password"],$hashed_password))
|
||||
|
||||
function resetpwd_kuri($hash){
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<p><label for="username" id="formtitle">Вход в личный кабинет*</label></p>
|
||||
<p><input name="username" type="email" autocomplete="on" placeholder="Введите электронную почту" required autofocus /><span class="icon"><i class="far fa-envelope"></i></span></p>
|
||||
<p><input name="password" type="password" minlength="5" autocomplete="current-password" placeholder="Введите пароль" required ><span class="icon"><i class="fas fa-key"></i></p>
|
||||
<p><a href="<?=SITE?>restoration">забыли пароль</a></p>
|
||||
<p><a href="<?=SITE?>reminder">забыли пароль</a></p>
|
||||
<p><input class="submit" type="submit" value="ВОЙТИ"></p>
|
||||
</form>
|
||||
|
||||
|
||||
0
app/views/noreset.phtml
Normal file
0
app/views/noreset.phtml
Normal file
16
app/views/reminder.phtml
Normal file
16
app/views/reminder.phtml
Normal file
@@ -0,0 +1,16 @@
|
||||
<div id="container_form">
|
||||
|
||||
<h1>Восстановление пароля</h1>
|
||||
|
||||
<?if (isset($error)):?>
|
||||
<div id="error" style="color: red;"><?=$error?></div>
|
||||
<?endif?>
|
||||
|
||||
<form method="POST" action="reminder">
|
||||
|
||||
<p><input name="resetmail" type="email" autocomplete="on" placeholder="Введите электронную почту" required autofocus /><span class="icon"><i class="far fa-envelope"></i></span></p>
|
||||
<p><input class="submit" type="submit" value="ОТПРАВИТЬ"></p>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
5
app/views/reminder_end.phtml
Normal file
5
app/views/reminder_end.phtml
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>Ссылка на восстановление пароля выслана на Вашу электронную почту</h1>
|
||||
|
||||
<?if (isset($link)):?>
|
||||
<div><a href="<?=$link?>">Для установки пароля пройдите по ссылке</a></div>
|
||||
<?endif?>
|
||||
Reference in New Issue
Block a user