This commit is contained in:
Your Name
2020-07-02 17:27:30 +03:00
parent 25a8c8c078
commit 4dfd676d95
8 changed files with 179 additions and 2 deletions

View File

@@ -32,6 +32,83 @@ function api_login($login, $password){
} }
function api_restore_mail($mail){
$date = date("Y-m-d H:i:s");
$hash = md5($mail.$date);
$add = [];
$add['mail'] = $mail;
$add['restore'] = false;
$add['date'] = $date;
$add['hash'] = $hash;
$res = db_insert('restorations', $add);
if ($res > 0)
return $hash;
}
function api_restore_hash($hash){
$re_sql = "
SELECT
`id`, `restore`, `mail`
FROM
`restorations`
WHERE
`hash` = '$hash'
LIMIT
'1'
";
$res = db_get($re_sql);
if (isset($res['restore']) AND $res['restore'] == 0){
db_get("
UPDATE
`restorations`
SET
`restore` = '1'
WHERE
`id` = '${res['id']}'
");
db_get("
UPDATE
`clients`
SET
`clientpassword` = ''
WHERE
`clientmail` = '${res['mail']}'
");
$client_hash = db_get("
SELECT
`clienthash`
FROM
`clients`
WHERE
`client_mail` = '${res['mail']}'
LIMIT
1");
if (isset($client_hash['clienthash']))
return $client_hash;
else
return false;
}
else
return false;
}
function clientbuys_kuri($client_mail, $page = 1, $category_id = 1, $group_id = null, $filter = null){ function clientbuys_kuri($client_mail, $page = 1, $category_id = 1, $group_id = null, $filter = null){
if ($group_id == 1 or $group_id == 2){ if ($group_id == 1 or $group_id == 2){

View File

@@ -4,7 +4,8 @@
"php":">=5.3.0", "php":">=5.3.0",
"masterforweb/kuri":"dev-master", "masterforweb/kuri":"dev-master",
"masterforweb/db_lite":"dev-master", "masterforweb/db_lite":"dev-master",
"mobiledetect/mobiledetectlib": "^2.8" "mobiledetect/mobiledetectlib": "^2.8",
"phpmailer/phpmailer": "^6.1"
}, },
"repositories":[ "repositories":[

View File

@@ -1,6 +1,6 @@
<?php <?php
ini_set('display_errors', 0); ini_set('display_errors', 1);
ini_set('display_startup_errors', 0); ini_set('display_startup_errors', 0);
@@ -30,6 +30,17 @@ define('VIEWPATH', SITEPATH.'views/');
define('API', 'http://api.argumenti.ru/'); define('API', 'http://api.argumenti.ru/');
define('IMGSRV', 'https://imgurl.argumenti.ru/'); define('IMGSRV', 'https://imgurl.argumenti.ru/');
/** отправка уведомлений */
set('mail',
[
'login' => 'noreply@argumenti.ru',
'name' => 'Аргументы Недели',
'password'=>'eessoj8Let',
'port'=>465,
'host'=>'smtp.mail.ru',
'secure' => 'ssl'
]);
db_config('argumentiru', 'mysql:host=mysql;dbname=argumentiru', 'newser', 'Chjk90yuiREY'); db_config('argumentiru', 'mysql:host=mysql;dbname=argumentiru', 'newser', 'Chjk90yuiREY');
db_config('reader', 'mysql:host=mysql;dbname=argumentiru', 'reader', 'ghjyjkUIOhg56Fh'); db_config('reader', 'mysql:host=mysql;dbname=argumentiru', 'reader', 'ghjyjkUIOhg56Fh');

View File

@@ -80,7 +80,48 @@ function addcard($id, $date) {
} }
function restoration_kuri(){
if (isset($_POST['reset_mail'])){
$email = $_POST['reset_mail'];
$title = 'Восстановление пароля';
$hash = api_restore_mail($mail);
if ($hash !== false) {
$hashlink = SITE.'resetlink/'.$hash;
}
echo $hashlink;
$tempcontent = VIEWPATH.'restore_add.phtml';
include VIEWPATH.'layout.phtml';
}
else {
$title = 'Восстановление пароля';
$tempcontent = VIEWPATH.'restore.phtml';
include VIEWPATH.'layout.phtml';
}
return true;
}
function resetlink_kuri($hash){
$res = api_restore_hash($hash);
if (!$res){
}
else {
header("HTTP/1.1 301 Moved Permanently");
header("Location: ${SITE}/resetpwd/"); exit();
}
}

34
app/routes/email.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
function sendmail($config, $mail){
$send = new PHPMailer;
$send->isSMTP();
//$send->SMTPDebug=3; // Set mailer to use SMTP
$send->Host = $config['host']; // Specify main and backup SMTP servers
$send->Username = $config['login']; // SMTP username
$send->Password = $config['password'];
if (isset($frommail['secure'])) {
$send->SMTPSecure = $frommail['secure'];
$send->SMTPAuth = true;
}
else {
$mail->SMTPSecure = false;
$mail->SMTPAutoTLS = false;
}
$send->Port = $config['port']; // TCP port to connect to
$send->setFrom($config['mail'], $config['name']);
$send->addAddress($mail, $mail); // Add a recipient
$send->CharSet = 'UTF-8';
$send->isHTML(True); // Set email format to HTML
$send->Subject = $mail['subject'];
$send->Body = $mail['message'];
return $send->send();
}

View File

@@ -4,6 +4,7 @@
<p><label for="username" id="formtitle">Вход в личный кабинет</label></p> <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="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><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><input class="submit" type="submit" value="ВОЙТИ"></p> <p><input class="submit" type="submit" value="ВОЙТИ"></p>
</form> </form>

9
app/views/restore.phtml Normal file
View File

@@ -0,0 +1,9 @@
<div>
<form id="reset" method="post" action="">
<p><strong><label for="reset_mail">Введите адрес Вашей электронной почты</label></strong></p>
<p><input type="email" id="reset_mail" name="reset_mail" placeholder="shop@argumenti.ru" size="120"></p>
<p><input type="submit" id="reset-submit" name="reset-submit"></p>
</form>
</div>

View File

@@ -0,0 +1,3 @@
<div>
<p>Ссылка для восстановление пароля отправлена на <?=$email?></p>
</div>