コード例 #1
0
ファイル: login.php プロジェクト: nickfun/newlifeblogger
             $client = new nlb_user($db);
             $id = $client->getIdByName($username);
             $client->setId($id);
             // create new password. 6 random letters + numbers
             $newpass = uniqid(rand(), true);
             $newpass = substr($newpass, 0, 6);
             $hash = md5($newpass);
             $link = full_url . script_path . 'login.php';
             $message = $l['log-forgot-email'];
             $message = str_replace('%USERNAME%', $client->get('username'), $message);
             $message = str_replace('%PASSWORD%', $newpass, $message);
             $message = str_replace('%LINK%', $link, $message);
             $mail->AddAddress($client->get('email'), $client->get('username'));
             $mail->Subject = $config->get('site_name') . $l['log-forgot-subject'];
             $mail->Body = $message;
             if (!$mail->Send()) {
                 // if we can't send the email, then don't write the
                 // new password in the db
                 $ets->page_body = $l['log-forgot-failed'];
                 break;
             } else {
                 // email was sent, set the password to something new
                 $client->set('password', $hash);
                 $client->updateDB();
                 $ets->page_body = $l['log-forgot-success'];
             }
         }
     }
 }
 if (empty($_POST) || !empty($err)) {
     if (!empty($err)) {
コード例 #2
0
    /**
     * @return bool
     * @param object nlb_config $config
     * @desc Force a user to validate his email address. Returns true if sent, false otherwise
     * @date 02-08-04
     */
    function validateEmail(&$config)
    {
        global $l;
        $mail = new nlb_mail($this->sql);
        if ($mail->Active) {
            // make code.
            $code = md5(uniqid(rand(), true));
            $link = build_link('index.php', array('action' => 'validate', 'code' => $code));
            $link = full_url . $link;
            $body = $l['validation_email'];
            $body = str_replace("%LINK%", $link, $body);
            $body = str_replace("%SITE%", $config->get('site_name'), $body);
            $body = str_replace("%USER%", $this->get('username'), $body);
            $mail->AddAddress($this->get('email'), $this->get('username'));
            $mail->Subject = $l['validation_subject'];
            $mail->Body = $body;
            if (!$mail->Send()) {
                // mail was not sent, must set user to valid.
                $this->set('valid', 1);
                $this->updateDB();
                return false;
            }
            // add record in validation table.
            $this->sql->query(' # Add validation row
			INSERT INTO `nlb3_validate` ( `validate_id` , `owner_id` , `code` , `date` )
			VALUES (
			"", "' . $this->id . '", "' . $code . '", "' . time() . '"
			);');
            $this->set('valid', 0);
            $this->updateDB();
            return true;
        }
        // Server is not sending email's, assume user gave a good email.
        $this->set('valid', 1);
        $this->updateDB();
        return false;
    }