sign-remind.php
См. документацию.
1 <?php
2 
3 /**
4  * @file
5  * @brief обработчик формы восстановления пароля
6  */
7 
8 isset($user) or require $_SERVER['DOCUMENT_ROOT'] . '/page/404.php';
9 
10 header("Content-type: application/json");
11 
12 if (empty($_POST['password']) || mb_strlen(trim($_POST['password']), 'utf-8') < 5) {
13  exit(json_encode(['error' => 'password']));
14 }
15 
16 if (empty($_POST['password2']) || $_POST['password'] != $_POST['password2']) {
17  exit(json_encode(['error' => 'password2']));
18 }
19 
20 if (empty($_POST['user_id']) || empty($_POST['md5'])) {
21  exit;
22 }
23 
24 if (!Wrong\Auth\Hcaptcha::check() && (empty($_POST['h-captcha-response']) || !Wrong\Auth\Hcaptcha::get($_POST['h-captcha-response']))) {
25  exit(json_encode(['error' => 'hcaptcha']));
26 }
27 
29 
30 if ($user = Wrong\Auth\User::is_remind($_POST['user_id'], $_POST['md5'])) {
31  if ($user = new Wrong\Auth\User($user->id)) {
32  $user->set_password($_POST['password']);
34  exit(json_encode(['result' => 'ok']));
35  }
36 }
37 
$_POST['groups']
Definition: add-action.php:16
static session($init_id=0)
Definition: User.php:222
$user
Definition: from-user.php:38
setcookie('FROM_UID', $uid, [ 'expires'=> time()+31536000, 'path'=> '/', 'domain'=> $_SERVER['HTTP_HOST'], 'secure'=> Wrong\Start\Env::$e->IS_SECURE, 'httponly'=> false, 'samesite'=> Wrong\Start\Env::$e->IS_SECURE ? 'None' :'Lax']) or setcookie('FROM_UID' $_SERVER['HTTP_HOST']
Definition: from-user.php:36
if(($dbh=Connect::getInstance(true) ->dbh) && $dbh->query("SHOW TABLES") ->fetchAll() && $dbh->query("SELECT COUNT(*) FROM `users`") ->fetchColumn()) if(!empty($_POST)) exit
Definition: install.php:198