<?php get_header(); ?>
<?php global $wp_query, $wpdb;
$hash = $wp_query->get('forget-hash'); ?>
<section class="user-panel rt">

    <div class="rt-entery rt profile-info login-register-form">
        <div class="main">
            <h1 class="titr right rt-bold rt-20 rt-333">فراموشی رمز عبور</h1>
            <a href="<?php echo LOGIN_URL; ?>" class="btn rt-blur rt-222 left rt-8px rt-14">ورود به پنل کاربری <i class="fa fa-angle-left rt-18 left"></i></a>
            <?php
            $ok = false;
            if (!empty($hash)) {
                $limit_request_minute = yascode_panel::$FORGET_TIME_MINUTE;
                $user_id = 0;
                $forget_passwords = yascode_panel::$forget_table;
                $query = "select * from " . $forget_passwords . " where checker = '" . $hash . "' LIMIT 1";
                $forget_row = $wpdb->get_row($query);
                if (!empty($forget_row)) $user_id = $forget_row->user_id;
                if (!empty($user_id)) {
                    $current_time = time();
                    $query = "select * from " . $forget_passwords . " where user_id = '" . $user_id . "' and status = '0' and checker = '" . $hash . "' order by created_at DESC LIMIT 1";
                    $forget_row = $wpdb->get_row($query);
                    if ($forget_row) {
                        $forget_time = $forget_row->created_at;
                        $forget_time = (!empty($forget_time)) ? strtotime($forget_time) : '';
                        if (!empty($forget_time)) {
                            if ($forget_time + ($limit_request_minute * 60) > $current_time) $ok = true;
                        }
                    }
                }
            }
            if ($ok == true) { ?>
                <form class="rt rt-relative" method="post" action="#" data-form="forget-confirm">
                    <input type="hidden" value="<?php echo $hash; ?>" name="user_hash">
                    <div class="loader-box none">
                        <div class="dot-loader">
                            <div class="dot-item"></div>
                            <div class="dot-item second-dot"></div>
                            <div class="dot-item third-dot"></div>
                        </div>
                    </div>
                    <div class="panel-alert none"></div>
                    <input type="password" name="password1" class="rt" placeholder="رمز عبور جدید">
                    <input type="password" name="password2" class="rt" placeholder="تکرار رمز عبور جدید">
                    <input type="submit" name="submit" value="ذخیره" class="submit">
                </form>
            <?php } else { ?>
                <div class="panel-alert warn">درخواست اشتباه میباشد یا منقضی شده است !</div>
            <?php } ?>
        </div>
    </div>

</section>
<?php get_footer(); ?>