当前位置: 首页>>代码示例>>PHP>>正文


PHP auth_sendPassword函数代码示例

本文整理汇总了PHP中auth_sendPassword函数的典型用法代码示例。如果您正苦于以下问题:PHP auth_sendPassword函数的具体用法?PHP auth_sendPassword怎么用?PHP auth_sendPassword使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了auth_sendPassword函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _notifyUser

 /**
  * send password change notification email
  */
 function _notifyUser($user, $password)
 {
     if ($sent = auth_sendPassword($user, $password)) {
         msg($this->lang['notify_ok'], 1);
     } else {
         msg($this->lang['notify_fail'], -1);
     }
     return $sent;
 }
开发者ID:houshuang,项目名称:folders2web,代码行数:12,代码来源:admin.php

示例2: act_resendpwd

/**
 * Send a  new password
 *
 * This function handles both phases of the password reset:
 *
 *   - handling the first request of password reset
 *   - validating the password reset auth token
 *
 * @author Benoit Chesneau <benoit@bchesneau.info>
 * @author Chris Smith <chris@jalakai.co.uk>
 * @author Andreas Gohr <andi@splitbrain.org>
 *
 * @return bool true on success, false on any error
 */
function act_resendpwd()
{
    global $lang;
    global $conf;
    /* @var auth_basic $auth */
    global $auth;
    /* @var Input $INPUT */
    global $INPUT;
    if (!actionOK('resendpwd')) {
        msg($lang['resendna'], -1);
        return false;
    }
    $token = preg_replace('/[^a-f0-9]+/', '', $INPUT->str('pwauth'));
    if ($token) {
        // we're in token phase - get user info from token
        $tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
        if (!@file_exists($tfile)) {
            msg($lang['resendpwdbadauth'], -1);
            $INPUT->remove('pwauth');
            return false;
        }
        // token is only valid for 3 days
        if (time() - filemtime($tfile) > 3 * 60 * 60 * 24) {
            msg($lang['resendpwdbadauth'], -1);
            $INPUT->remove('pwauth');
            @unlink($tfile);
            return false;
        }
        $user = io_readfile($tfile);
        $userinfo = $auth->getUserData($user);
        if (!$userinfo['mail']) {
            msg($lang['resendpwdnouser'], -1);
            return false;
        }
        if (!$conf['autopasswd']) {
            // we let the user choose a password
            $pass = $INPUT->str('pass');
            // password given correctly?
            if (!$pass) {
                return false;
            }
            if ($pass != $INPUT->str('passchk')) {
                msg($lang['regbadpass'], -1);
                return false;
            }
            // change it
            if (!$auth->triggerUserMod('modify', array($user, array('pass' => $pass)))) {
                msg('error modifying user data', -1);
                return false;
            }
        } else {
            // autogenerate the password and send by mail
            $pass = auth_pwgen();
            if (!$auth->triggerUserMod('modify', array($user, array('pass' => $pass)))) {
                msg('error modifying user data', -1);
                return false;
            }
            if (auth_sendPassword($user, $pass)) {
                msg($lang['resendpwdsuccess'], 1);
            } else {
                msg($lang['regmailfail'], -1);
            }
        }
        @unlink($tfile);
        return true;
    } else {
        // we're in request phase
        if (!$INPUT->post->bool('save')) {
            return false;
        }
        if (!$INPUT->post->str('login')) {
            msg($lang['resendpwdmissing'], -1);
            return false;
        } else {
            $user = trim($auth->cleanUser($INPUT->post->str('login')));
        }
        $userinfo = $auth->getUserData($user);
        if (!$userinfo['mail']) {
            msg($lang['resendpwdnouser'], -1);
            return false;
        }
        // generate auth token
        $token = md5(auth_cookiesalt() . $user);
        //secret but user based
        $tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
        $url = wl('', array('do' => 'resendpwd', 'pwauth' => $token), true, '&');
//.........这里部分代码省略.........
开发者ID:AlexanderS,项目名称:Part-DB,代码行数:101,代码来源:auth.php

示例3: act_resendpwd

/**
 * Send a  new password
 *
 * This function handles both phases of the password reset:
 *
 *   - handling the first request of password reset
 *   - validating the password reset auth token
 *
 * @author Benoit Chesneau <benoit@bchesneau.info>
 * @author Chris Smith <chris@jalakai.co.uk>
 * @author Andreas Gohr <andi@splitbrain.org>
 *
 * @return bool true on success, false on any error
 */
function act_resendpwd()
{
    global $lang;
    global $conf;
    global $auth;
    if (!actionOK('resendpwd')) {
        return false;
    }
    if (!$auth) {
        return false;
    }
    // should not be able to get here without modPass being possible...
    if (!$auth->canDo('modPass')) {
        msg($lang['resendna'], -1);
        return false;
    }
    $token = preg_replace('/[^a-f0-9]+/', '', $_REQUEST['pwauth']);
    if ($token) {
        // we're in token phase
        $tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
        if (!@file_exists($tfile)) {
            msg($lang['resendpwdbadauth'], -1);
            return false;
        }
        $user = io_readfile($tfile);
        @unlink($tfile);
        $userinfo = $auth->getUserData($user);
        if (!$userinfo['mail']) {
            msg($lang['resendpwdnouser'], -1);
            return false;
        }
        $pass = auth_pwgen();
        if (!$auth->triggerUserMod('modify', array($user, array('pass' => $pass)))) {
            msg('error modifying user data', -1);
            return false;
        }
        if (auth_sendPassword($user, $pass)) {
            msg($lang['resendpwdsuccess'], 1);
        } else {
            msg($lang['regmailfail'], -1);
        }
        return true;
    } else {
        // we're in request phase
        if (!$_POST['save']) {
            return false;
        }
        if (empty($_POST['login'])) {
            msg($lang['resendpwdmissing'], -1);
            return false;
        } else {
            $user = trim($auth->cleanUser($_POST['login']));
        }
        $userinfo = $auth->getUserData($user);
        if (!$userinfo['mail']) {
            msg($lang['resendpwdnouser'], -1);
            return false;
        }
        // generate auth token
        $token = md5(auth_cookiesalt() . $user);
        //secret but user based
        $tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
        $url = wl('', array('do' => 'resendpwd', 'pwauth' => $token), true, '&');
        io_saveFile($tfile, $user);
        $text = rawLocale('pwconfirm');
        $text = str_replace('@DOKUWIKIURL@', DOKU_URL, $text);
        $text = str_replace('@FULLNAME@', $userinfo['name'], $text);
        $text = str_replace('@LOGIN@', $user, $text);
        $text = str_replace('@TITLE@', $conf['title'], $text);
        $text = str_replace('@CONFIRM@', $url, $text);
        if (mail_send($userinfo['name'] . ' <' . $userinfo['mail'] . '>', $lang['regpwmail'], $text, $conf['mailfrom'])) {
            msg($lang['resendpwdconfirm'], 1);
        } else {
            msg($lang['regmailfail'], -1);
        }
        return true;
    }
    return false;
    // never reached
}
开发者ID:halfbyte,项目名称:rugtool,代码行数:94,代码来源:auth.php

示例4: _notifyUser

 /**
  * Send password change notification email
  *
  * @param string $user         id of user
  * @param string $password     plain text
  * @param bool   $status_alert whether status alert should be shown
  * @return bool whether succesful
  */
 protected function _notifyUser($user, $password, $status_alert = true)
 {
     if ($sent = auth_sendPassword($user, $password)) {
         if ($status_alert) {
             msg($this->lang['notify_ok'], 1);
         }
     } else {
         if ($status_alert) {
             msg($this->lang['notify_fail'], -1);
         }
     }
     return $sent;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:21,代码来源:admin.php

示例5: act_resendpwd

/**
 * Send a  new password
 *
 * This function handles both phases of the password reset:
 *
 *   - handling the first request of password reset
 *   - validating the password reset auth token
 *
 * @author Benoit Chesneau <benoit@bchesneau.info>
 * @author Chris Smith <chris@jalakai.co.uk>
 * @author Andreas Gohr <andi@splitbrain.org>
 *
 * @return bool true on success, false on any error
 */
function act_resendpwd()
{
    global $lang;
    global $conf;
    global $auth;
    if (!actionOK('resendpwd')) {
        msg($lang['resendna'], -1);
        return false;
    }
    $token = preg_replace('/[^a-f0-9]+/', '', $_REQUEST['pwauth']);
    if ($token) {
        // we're in token phase - get user info from token
        $tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
        if (!@file_exists($tfile)) {
            msg($lang['resendpwdbadauth'], -1);
            unset($_REQUEST['pwauth']);
            return false;
        }
        // token is only valid for 3 days
        if (time() - filemtime($tfile) > 3 * 60 * 60 * 24) {
            msg($lang['resendpwdbadauth'], -1);
            unset($_REQUEST['pwauth']);
            @unlink($tfile);
            return false;
        }
        $user = io_readfile($tfile);
        $userinfo = $auth->getUserData($user);
        if (!$userinfo['mail']) {
            msg($lang['resendpwdnouser'], -1);
            return false;
        }
        if (!$conf['autopasswd']) {
            // we let the user choose a password
            // password given correctly?
            if (!isset($_REQUEST['pass']) || $_REQUEST['pass'] == '') {
                return false;
            }
            if ($_REQUEST['pass'] != $_REQUEST['passchk']) {
                msg($lang['regbadpass'], -1);
                return false;
            }
            $pass = $_REQUEST['pass'];
            if (!$auth->triggerUserMod('modify', array($user, array('pass' => $pass)))) {
                msg('error modifying user data', -1);
                return false;
            }
        } else {
            // autogenerate the password and send by mail
            $pass = auth_pwgen();
            if (!$auth->triggerUserMod('modify', array($user, array('pass' => $pass)))) {
                msg('error modifying user data', -1);
                return false;
            }
            if (auth_sendPassword($user, $pass)) {
                msg($lang['resendpwdsuccess'], 1);
            } else {
                msg($lang['regmailfail'], -1);
            }
        }
        @unlink($tfile);
        return true;
    } else {
        // we're in request phase
        if (!$_POST['save']) {
            return false;
        }
        if (empty($_POST['login'])) {
            msg($lang['resendpwdmissing'], -1);
            return false;
        } else {
            $user = trim($auth->cleanUser($_POST['login']));
        }
        $userinfo = $auth->getUserData($user);
        if (!$userinfo['mail']) {
            msg($lang['resendpwdnouser'], -1);
            return false;
        }
        // generate auth token
        $token = md5(auth_cookiesalt() . $user);
        //secret but user based
        $tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
        $url = wl('', array('do' => 'resendpwd', 'pwauth' => $token), true, '&');
        io_saveFile($tfile, $user);
        $text = rawLocale('pwconfirm');
        $text = str_replace('@DOKUWIKIURL@', DOKU_URL, $text);
        $text = str_replace('@FULLNAME@', $userinfo['name'], $text);
//.........这里部分代码省略.........
开发者ID:nblock,项目名称:dokuwiki,代码行数:101,代码来源:auth.php


注:本文中的auth_sendPassword函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。