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


PHP SecurityUtil::generatePassword方法代码示例

本文整理汇总了PHP中SecurityUtil::generatePassword方法的典型用法代码示例。如果您正苦于以下问题:PHP SecurityUtil::generatePassword方法的具体用法?PHP SecurityUtil::generatePassword怎么用?PHP SecurityUtil::generatePassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SecurityUtil的用法示例。


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

示例1: executeAction

 /**
  * (non-PHPdoc)
  * @see IActionController::executeAction()
  */
 public function executeAction($parameters)
 {
     $user = $this->_websoccer->getUser();
     $columns = array();
     // save new password
     if ($parameters["newpassword"] != null) {
         // always create new salt (in order to invalid old cookies)
         $salt = SecurityUtil::generatePasswordSalt();
         $hashedPassword = SecurityUtil::hashPassword($parameters["newpassword"], $salt);
         $columns["passwort_salt"] = $salt;
         $columns["passwort"] = $hashedPassword;
     }
     // handle new e-mail
     if ($parameters["newemail"] != null) {
         $activationKey = SecurityUtil::generatePassword();
         $columns["schluessel"] = $activationKey;
         $columns["status"] = 2;
         $columns["email"] = $parameters["newemail"];
         $user->email = $parameters["newemail"];
         // send e-mail
         $querystr = "key=" . $columns["schluessel"] . "&userid=" . $user->id;
         $tplparameters["activationlink"] = $this->_websoccer->getInternalActionUrl("activate", $querystr, "activate-user", TRUE);
         // send e-mail
         EmailHelper::sendSystemEmailFromTemplate($this->_websoccer, $this->_i18n, $user->email, $this->_i18n->getMessage("activation_changedemail_subject"), "changed_email_activation", $tplparameters);
         $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_WARNING, $this->_i18n->getMessage("profile_changedemail_message_title"), $this->_i18n->getMessage("profile_changedemail_message_content")));
     }
     $columns["name"] = $parameters["realname"];
     $columns["wohnort"] = $parameters["place"];
     $columns["land"] = $parameters["country"];
     $columns["beruf"] = $parameters["occupation"];
     $columns["interessen"] = $parameters["interests"];
     $columns["lieblingsverein"] = $parameters["favorite_club"];
     $columns["homepage"] = $parameters["homepage"];
     $columns["c_hideinonlinelist"] = $parameters["c_hideinonlinelist"];
     if ($parameters["birthday"]) {
         $dateObj = DateTime::createFromFormat($this->_websoccer->getConfig("date_format"), $parameters["birthday"]);
         $columns["geburtstag"] = $dateObj->format("Y-m-d");
     }
     // update record
     if (count($columns)) {
         $fromTable = $this->_websoccer->getConfig("db_prefix") . "_user";
         $whereCondition = "id = %d";
         $this->_db->queryUpdate($columns, $fromTable, $whereCondition, $user->id);
     }
     // success message
     $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("saved_message_title"), ""));
     return "profile";
 }
开发者ID:astroChasqui,项目名称:open-websoccer,代码行数:52,代码来源:SaveProfileController.class.php

示例2: executeAction

 public function executeAction($parameters)
 {
     if (!$this->_websoccer->getConfig("login_allow_sendingpassword")) {
         throw new Exception("Action is disabled.");
     }
     // check captcha
     if ($this->_websoccer->getConfig("register_use_captcha") && strlen($this->_websoccer->getConfig("register_captcha_publickey")) && strlen($this->_websoccer->getConfig("register_captcha_privatekey"))) {
         include_once BASE_FOLDER . "/lib/recaptcha/recaptchalib.php";
         $captchaResponse = recaptcha_check_answer($this->_websoccer->getConfig("register_captcha_privatekey"), $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
         if (!$captchaResponse->is_valid) {
             throw new Exception($this->_i18n->getMessage("registration_invalidcaptcha"));
         }
     }
     $email = $parameters["useremail"];
     $fromTable = $this->_websoccer->getConfig("db_prefix") . "_user";
     // get user
     $columns = "id, passwort_salt, passwort_neu_angefordert";
     $wherePart = "UPPER(email) = '%s' AND status = 1";
     $result = $this->_db->querySelect($columns, $fromTable, $wherePart, strtoupper($email));
     $userdata = $result->fetch_array();
     $result->free();
     if (!isset($userdata["id"])) {
         sleep(5);
         throw new Exception($this->_i18n->getMessage("forgot-password_email-not-found"));
     }
     $now = $this->_websoccer->getNowAsTimestamp();
     $timeBoundary = $now - 24 * 3600;
     if ($userdata["passwort_neu_angefordert"] > $timeBoundary) {
         throw new Exception($this->_i18n->getMessage("forgot-password_already-sent"));
     }
     // create new password
     $salt = $userdata["passwort_salt"];
     if (!strlen($salt)) {
         $salt = SecurityUtil::generatePasswordSalt();
     }
     $password = SecurityUtil::generatePassword();
     $hashedPassword = SecurityUtil::hashPassword($password, $salt);
     // update user
     $columns = array("passwort_salt" => $salt, "passwort_neu_angefordert" => $now, "passwort_neu" => $hashedPassword);
     $whereCondition = "id = %d";
     $parameter = $userdata["id"];
     $this->_db->queryUpdate($columns, $fromTable, $whereCondition, $parameter);
     $this->_sendEmail($email, $password);
     $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("forgot-password_message_title"), $this->_i18n->getMessage("forgot-password_message_content")));
     return "login";
 }
开发者ID:astroChasqui,项目名称:open-websoccer,代码行数:46,代码来源:SendPasswordController.class.php

示例3: _createUser

 private function _createUser($parameters, $fromTable)
 {
     $dbcolumns = array();
     $dbcolumns["nick"] = $parameters["nick"];
     $dbcolumns["email"] = strtolower($parameters["email"]);
     $dbcolumns["passwort_salt"] = SecurityUtil::generatePasswordSalt();
     $dbcolumns["passwort"] = SecurityUtil::hashPassword($parameters["pswd"], $dbcolumns["passwort_salt"]);
     $dbcolumns["datum_anmeldung"] = $this->_websoccer->getNowAsTimestamp();
     $dbcolumns["schluessel"] = str_replace("&", "_", SecurityUtil::generatePassword());
     $dbcolumns["status"] = 2;
     $dbcolumns["lang"] = $this->_i18n->getCurrentLanguage();
     if ($this->_websoccer->getConfig("premium_initial_credit")) {
         $dbcolumns["premium_balance"] = $this->_websoccer->getConfig("premium_initial_credit");
     }
     $this->_db->queryInsert($dbcolumns, $fromTable);
     // get user id
     $columns = "id";
     $wherePart = "email = '%s'";
     $result = $this->_db->querySelect($columns, $fromTable, $wherePart, $dbcolumns["email"]);
     $newuser = $result->fetch_array();
     $result->free();
     $querystr = "key=" . $dbcolumns["schluessel"] . "&userid=" . $newuser["id"];
     $tplparameters["activationlink"] = $this->_websoccer->getInternalActionUrl("activate", $querystr, "activate-user", TRUE);
     // send e-mail
     EmailHelper::sendSystemEmailFromTemplate($this->_websoccer, $this->_i18n, $dbcolumns["email"], $this->_i18n->getMessage("activation_email_subject"), "useractivation", $tplparameters);
     // trigger plug-ins
     $event = new UserRegisteredEvent($this->_websoccer, $this->_db, $this->_i18n, $newuser["id"], $dbcolumns["nick"], $dbcolumns["email"]);
     PluginMediator::dispatchEvent($event);
 }
开发者ID:astroChasqui,项目名称:open-websoccer,代码行数:29,代码来源:RegisterFormController.class.php

示例4: array

if ($inputEmail) {
    $now = $website->getNowAsTimestamp();
    if (count($errors) == 0) {
        // correct Pwd?
        $columns = array('id', 'passwort_neu_angefordert', 'name', 'passwort_salt');
        $fromTable = $conf['db_prefix'] . '_admin';
        $whereCondition = 'email = \'%s\'';
        $parameters = $inputEmail;
        $result = $db->querySelect($columns, $fromTable, $whereCondition, $parameters);
        $admin = $result->fetch_array();
        if ($result->num_rows < 1) {
            $errors['inputEmail'] = $i18n->getMessage('sendpassword_admin_usernotfound');
        } elseif ($admin['passwort_neu_angefordert'] > $now - 120 * 60) {
            $errors['inputEmail'] = $i18n->getMessage('sendpassword_admin_alreadysent');
        } else {
            $newPassword = SecurityUtil::generatePassword();
            $hashedPw = SecurityUtil::hashPassword($newPassword, $admin['passwort_salt']);
            // store new PW
            $columns = array('passwort_neu' => $hashedPw, 'passwort_neu_angefordert' => $now);
            $fromTable = $conf['db_prefix'] . '_admin';
            $whereCondition = 'id = %d';
            $parameter = $admin['id'];
            $db->queryUpdate($columns, $fromTable, $whereCondition, $parameter);
            try {
                _sendEmail($inputEmail, $newPassword, $website, $i18n);
                header('location: login.php?newpwd=1');
                die;
            } catch (Exception $e) {
                $errors['inputEmail'] = $e->getMessage();
            }
        }
开发者ID:astroChasqui,项目名称:open-websoccer,代码行数:31,代码来源:forgot-password.php


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