Example #1
0
if (isset($_POST['forgotpass'])) {
    // Check token first
    if (isset($_POST['token']) && Token::isExist($_POST['token'])) {
        /*check if username is exist or not */
        $username = Typo::cleanX(Typo::strip($_POST['username']));
        $sql = sprintf("SELECT `userid`,`email`,`status`,`activation` FROM `user` WHERE `userid` = '%s'", $username);
        $usr = Db::result($sql);
        $c = Db::$num_rows;
        //echo $c;
        //print_r($usr);
        if ($c == "1") {
            //$alertgreen = "";
            // check if user is active
            if ($usr[0]->status == '1') {
                /* get user password */
                $newpass = User::generatePass();
                $id = User::id($username);
                $pass = User::randpass($newpass);
                $vars = array('id' => $id, 'user' => array('pass' => $pass));
                User::update($vars);
                $date = Date::format(date("Y-m-d H:i:s"));
                $msg = "\n\t\tHello {$usr[0]->userid},\n\n\t\tYou are requesting Password Reset at " . Site::$name . " on {$date}. \n\t\tBelow are your new Password :\n\n\t\t{$newpass}\n\n\t\tNow you can login with your new Password at " . Site::$url . "\n\n\n\t\tBest Regards,\n\n\n\t\t" . Site::$name . "\n\t\t" . Site::$email . "\n\t\t\t\t";
                $vars = array('to' => $usr[0]->email, 'to_name' => $usr[0]->userid, 'message' => $msg, 'subject' => 'Password Reset at ' . Site::$name, 'msgtype' => 'text');
                //echo "<pre>".$msg."</pre>";
                if (Mail::send($vars)) {
                    $alertgreen = PASSWORD_SENT_NOTIF;
                }
            } else {
                if ($usr[0]->activation != '') {
                    $alertred[] = ACOUNT_NOT_ACTIVE;
                } else {