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


PHP Hash::password_hash方法代码示例

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


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

示例1: doProcess


//.........这里部分代码省略.........
             $mHash = new Hash();
             $insert = array();
             $insert['did'] = $values->did;
             $insert['parent'] = $values->parent;
             $insert['version'] = $values->version;
             $insert['history'] = $values->history;
             if ($values->idx == null) {
                 if ($this->checkPermission('write') == false && $values->post->midx != $this->IM->getModule('member')->getLogged()) {
                     $results->success = false;
                     $results->message = $this->getLanguage('error/forbidden');
                 } else {
                     $reg_date = time();
                     $insert['reg_date'] = $reg_date;
                     $values->idx = $this->db()->insert($this->table->post_version, $insert)->execute();
                     $results->redirect = $this->IM->getUrl($values->menu, $values->page, 'view', $values->parent);
                 }
                 // Action Register
             } else {
                 $oCategory = $post->category;
                 $reg_date = $post->reg_date;
                 if ($this->checkPermission('post_modify') == false && ($post->midx != 0 && $post->midx != $this->IM->getModule('member')->getLogged())) {
                     $results->success = false;
                     $results->message = $this->getLanguage('error/forbidden');
                 } elseif ($post->midx == 0) {
                     if ($mHash->password_validate($values->password, $post->password) == false) {
                         $results->success = false;
                         $results->errors = array('password' => $this->getLanguage('error/incorrectPassword'));
                         $results->message = $this->getLanguage('error/incorrectPassword');
                     }
                 }
                 if ($results->success == true) {
                     if ($this->IM->getModule('member')->isLogged() == false) {
                         $insert['name'] = $values->name;
                         $insert['password'] = $values->password ? $mHash->password_hash($values->password) : '';
                         $insert['email'] = $values->email;
                         $insert['ip'] = $_SERVER['REMOTE_ADDR'];
                     }
                     $this->db()->update($this->table->post, $insert)->where('idx', $post->idx)->execute();
                 }
                 $insert['reg_date'] = $post['reg_date'];
             }
             if ($results->success == true) {
                 if (isset($_FILES['file']['tmp_name']) == true && $_FILES['file']['tmp_name']) {
                     $fileName = $_FILES['file']['name'];
                     $fileIdx = $this->IM->getModule('attachment')->fileSave($fileName, $_FILES['file']['tmp_name'], 'dataroom', 'file');
                     $this->db()->update($this->table->post_version, array('file' => $fileIdx))->where('idx', $values->idx)->execute();
                 }
                 $lastVersion = $this->db()->select($this->table->post_version)->where('parent', $values->parent)->orderBy('reg_date', 'desc')->getOne();
                 $this->db()->update($this->table->post, array('last_version' => $lastVersion->version, 'last_update' => $lastVersion->reg_date))->where('idx', $values->parent)->execute();
                 if ($values->post->category != 0) {
                     $this->db()->update($this->table->category, array('last_post' => $lastVersion->reg_date))->where('idx', $values->post->category)->execute();
                 }
                 $lastPost = $this->db()->select($this->table->post)->where('did', $values->did)->orderBy('last_update', 'desc')->getOne();
                 $this->db()->update($this->table->dataroom, array('last_post' => $lastPost->last_update))->where('did', $values->did)->execute();
                 $this->IM->setArticle('dataroom', $values->did, 'post', $values->post->idx, time());
                 $page = $this->IM->getPages($values->menu, $values->page);
                 $results->redirect = $this->IM->getUrl($values->menu, $values->page, 'view', $values->parent);
             }
         } else {
             $results->success = false;
             $results->message = $this->getLanguage('error/required');
             $results->errors = $values->errors;
         }
     }
     if ($action == 'getQna') {
         $values->get = Request('get');
开发者ID:parangma,项目名称:iModule3,代码行数:67,代码来源:ModuleDataroom.class.php

示例2: doProcess


//.........这里部分代码省略.........
                     $results->message = $this->getLanguage('error/' . $check->status);
                 }
             }
         }
         $_SESSION['loginFail'] = $loginFail;
     }
     if ($action == 'logout') {
         unset($_SESSION['MEMBER_LOGGED']);
         $results->success = true;
     }
     if ($action == 'cert') {
         $results->success = true;
     }
     if ($action == 'signup') {
         $errors = array();
         $email = CheckEmail(Request('email')) == true ? Request('email') : ($errors['email'] = $this->getLanguage('signup/help/email/error'));
         $password = strlen(Request('password')) >= 4 ? Request('password') : ($errors['password'] = $this->getLanguage('signup/help/password/error'));
         if (strlen(Request('password')) < 4 || Request('password') != Request('password_confirm')) {
             $errors['password_confirm'] = $this->getLanguage('signup/help/password_confirm/error');
         }
         $name = CheckNickname(Request('name')) == true ? Request('name') : ($errors['name'] = $this->getLanguage('signup/help/name/error'));
         $nickname = CheckNickname(Request('nickname')) == true ? Request('nickname') : ($errors['nickname'] = $this->getLanguage('signup/help/nickname/error'));
         if ($this->db()->select($this->table->member)->where('email', $email)->has() == true) {
             $errors['email'] = $this->getLanguage('signup/help/email/duplicated');
         }
         if ($this->db()->select($this->table->member)->where('nickname', $nickname)->has() == true) {
             $errors['nickname'] = $this->getLanguage('signup/help/nickname/duplicated');
         }
         if (empty($errors) == true) {
             $mHash = new Hash();
             $insert = array();
             $insert['gidx'] = Request('registerGIDX', 'session');
             $insert['email'] = $email;
             $insert['password'] = $mHash->password_hash($password);
             $insert['name'] = $name;
             $insert['nickname'] = $nickname;
             $insert['status'] = 'VERIFYING';
             $idx = $this->db()->insert($this->table->member, $insert)->execute();
             if ($idx !== false) {
                 $results->success = true;
                 $_SESSION['MEMBER_REGISTER_IDX'] = Encoder($idx);
                 $this->sendVerifyEmail($idx);
                 unset($_SESSION['registerGIDX']);
             } else {
                 $results->success = false;
             }
         } else {
             $results->success = false;
             $results->errors = $errors;
         }
     }
     if ($action == 'verifyEmail') {
         $registerIDX = Request('registerIDX');
         if ($registerIDX == null) {
             $results->success = false;
         } else {
             $email = Request('email');
             $email_verify_code = Request('email_verify_code');
             $check = $this->db()->select($this->table->email)->where('midx', $registerIDX)->where('email', $email)->getOne();
             if ($check == null) {
                 $results->success = false;
                 $results->errors = array('email' => $this->getLanguage('verifyEmail/help/email/notFound'));
             } elseif ($check->code == $email_verify_code) {
                 $this->db()->update($this->table->email, array('status' => 'VERIFIED'))->where('midx', $registerIDX)->where('email', $email)->execute();
                 $this->db()->update($this->table->member, array('status' => 'ACTIVE'))->where('idx', $registerIDX)->execute();
                 $results->success = true;
开发者ID:akairain,项目名称:iModule3,代码行数:67,代码来源:ModuleMember.class.php

示例3: doProcess

 function doProcess($action)
 {
     $results = new stdClass();
     $values = new stdClass();
     if ($action == 'listUrl') {
         $menu = Request('menu');
         $page = Request('page');
         $page = $this->IM->getPages($menu, $page);
         $oKey = Request('oKey');
         $oKeyword = Request('oKeyword');
         $oCategory = Request('oCategory');
         $oSort = Request('oSort');
         $oDirection = Request('oDirection');
         $key = Request('key');
         $keyword = Request('keyword');
         $category = Request('category');
         $sort = Request('sort');
         $direction = Request('direction');
         $key = Request('key');
         $keyword = Request('keyword');
         $p = Request('p') ? Request('p') : 1;
         $queryString = 'menu=' . $page->menu . '&page=' . $page->page . '&key=' . $key . '&keyword=' . $keyword . '&category=' . $category . '&sort=' . $sort . '&direction=' . $direction . '&p=' . $p;
         if ($oKey != $key || $oKeyword != $keyword || $oCategory != $category || $oSort != $sort || $oDirection != $direction) {
             $p = 1;
         }
         $default = array();
         if (strlen($keyword) == 0) {
             $default['key'] = '';
             $default['keyword'] = '';
         }
         if ($sort == 'idx' && $direction == 'desc') {
             $default['sort'] = $default['direction'] = '';
         }
         if (isset($page->context->config->category) == true && $page->context->config->category == $category) {
             $default['category'] = '';
         }
         $url = $this->IM->getUrl($page->menu, $page->page, 'list', $p) . $this->IM->getQueryString($default, $queryString);
         $results->success = true;
         $results->url = $url;
     }
     if ($action == 'postWrite') {
         $values->errors = array();
         $values->idx = Request('idx');
         $values->bid = Request('bid');
         $values->menu = Request('menu');
         $values->page = Request('page');
         $values->category = Request('category');
         $values->title = Request('title') ? Request('title') : ($values->errors['title'] = $this->getLanguage('postWrite/help/title/error'));
         $values->content = Request('content') ? Request('content') : ($values->errors['content'] = $this->getLanguage('postWrite/help/content/error'));
         $values->is_notice = Request('is_notice') && $this->checkPermission('notice') == true ? 'TRUE' : 'FALSE';
         $values->is_html_title = Request('is_html_title') && $this->checkPermission('html_title') == true ? 'TRUE' : 'FALSE';
         $values->is_secret = Request('is_secret') ? 'TRUE' : 'FALSE';
         $values->is_hidename = Request('is_hidename') && $this->getModule('member')->isLogged() == true ? 'TRUE' : 'FALSE';
         if ($this->IM->getModule('member')->isLogged() == false) {
             $values->name = Request('name') ? Request('name') : ($values->errors['name'] = $this->getLanguage('postWrite/help/name/error'));
             $values->password = Request('password') ? Request('password') : ($values->errors['password'] = $this->getLanguage('postWrite/help/password/error'));
             $values->email = Request('email');
             $values->midx = 0;
         } else {
             $values->name = $this->IM->getModule('member')->getMember()->nickname;
             $values->password = '';
             $values->email = $this->IM->getModule('member')->getMember()->email;
             $values->midx = $this->IM->getModule('member')->getLogged();
         }
         $values->attachments = is_array(Request('attachments')) == true ? Request('attachments') : array();
         for ($i = 0, $loop = count($values->attachments); $i < $loop; $i++) {
             $values->attachments[$i] = Decoder($values->attachments[$i]);
         }
         $values->content = $this->encodeContent($values->content, $values->attachments);
         $values->board = $this->getBoard($values->bid);
         if ($values->board->use_category != 'NONE') {
             if ($values->board->use_category == 'FORCE' && ($values->category == null || preg_match('/^[1-9]+[0-9]*$/', $values->category) == false)) {
                 $values->errors['category'] = $this->getLanguage('postWrite/help/category/error');
             }
         } else {
             $values->category = 0;
         }
         if (empty($values->errors) == true) {
             $results->success = true;
             $mHash = new Hash();
             $insert = array();
             $insert['bid'] = $values->bid;
             $insert['category'] = $values->category;
             $insert['title'] = $values->title;
             $insert['content'] = $values->content;
             $insert['search'] = GetString($values->content, 'index');
             $insert['is_notice'] = $values->is_notice;
             $insert['is_html_title'] = $values->is_html_title;
             $insert['is_secret'] = $values->is_secret;
             $insert['is_hidename'] = $values->is_hidename;
             if ($values->idx == null) {
                 $post = null;
                 $insert['midx'] = $values->midx;
                 $insert['password'] = $values->password;
                 $insert['name'] = $values->name;
                 $insert['password'] = $values->password ? $mHash->password_hash($values->password) : '';
                 $insert['email'] = $values->email;
                 $insert['reg_date'] = $insert['last_ment'] = time();
                 $insert['ip'] = $_SERVER['REMOTE_ADDR'];
                 $values->idx = $this->db()->insert($this->table->post, $insert)->execute();
//.........这里部分代码省略.........
开发者ID:JRevirthuum,项目名称:iModule,代码行数:101,代码来源:ModuleBoard.class.php

示例4: doProcess


//.........这里部分代码省略.........
                 }
             }
         }
         $_SESSION['loginFail'] = $loginFail;
     }
     if ($action == 'logout') {
         unset($_SESSION['MEMBER_LOGGED']);
         $results->success = true;
     }
     if ($action == 'cert') {
         $results->success = true;
     }
     if ($action == 'signup') {
         $siteType = $this->IM->getSites($this->IM->domain)->member;
         $errors = array();
         $email = CheckEmail(Request('email')) == true ? Request('email') : ($errors['email'] = $this->getLanguage('signup/help/email/error'));
         $password = strlen(Request('password')) >= 4 ? Request('password') : ($errors['password'] = $this->getLanguage('signup/help/password/error'));
         if (strlen(Request('password')) < 4 || Request('password') != Request('password_confirm')) {
             $errors['password_confirm'] = $this->getLanguage('signup/help/password_confirm/error');
         }
         $name = CheckNickname(Request('name')) == true ? Request('name') : ($errors['name'] = $this->getLanguage('signup/help/name/error'));
         $nickname = CheckNickname(Request('nickname')) == true ? Request('nickname') : ($errors['nickname'] = $this->getLanguage('signup/help/nickname/error'));
         if ($this->db()->select($this->table->member)->where('email', $email)->where('domain', $siteType == 'MERGE' ? '*' : $this->IM->domain)->has() == true || $this->db()->select($this->table->member)->where('email', $email)->where('type', 'ADMINISTRATOR')->has() == true) {
             $errors['email'] = $this->getLanguage('signup/help/email/duplicated');
         }
         if ($this->db()->select($this->table->member)->where('nickname', $nickname)->where('domain', $siteType == 'MERGE' ? '*' : $this->IM->domain)->has() == true || $this->db()->select($this->table->member)->where('nickname', $nickname)->where('type', 'ADMINISTRATOR')->has() == true) {
             $errors['nickname'] = $this->getLanguage('signup/help/nickname/duplicated');
         }
         if (empty($errors) == true) {
             $mHash = new Hash();
             $insert = array();
             $insert['email'] = $email;
             $insert['domain'] = $siteType == 'MERGE' ? '*' : $this->IM->domain;
             $insert['password'] = $mHash->password_hash($password);
             $insert['name'] = $name;
             $insert['nickname'] = $nickname;
             $insert['status'] = 'VERIFYING';
             $insert['reg_date'] = time();
             $idx = $this->db()->insert($this->table->member, $insert)->execute();
             if ($idx !== false) {
                 $results->success = true;
                 $_SESSION['MEMBER_REGISTER_IDX'] = Encoder($idx);
                 $this->sendVerifyEmail($idx);
                 unset($_SESSION['registerGIDX']);
             } else {
                 $results->success = false;
             }
         } else {
             $results->success = false;
             $results->errors = $errors;
         }
     }
     if ($action == 'verifyEmail') {
         $registerIDX = Request('registerIDX');
         if ($registerIDX == null) {
             $results->success = false;
         } else {
             $email = Request('email');
             $email_verify_code = Request('email_verify_code');
             $check = $this->db()->select($this->table->email)->where('midx', $registerIDX)->where('email', $email)->getOne();
             if ($check == null) {
                 $results->success = false;
                 $results->errors = array('email' => $this->getLanguage('verifyEmail/help/email/notFound'));
             } elseif ($check->code == $email_verify_code) {
                 $this->db()->update($this->table->email, array('status' => 'VERIFIED'))->where('midx', $registerIDX)->where('email', $email)->execute();
                 $this->db()->update($this->table->member, array('status' => 'ACTIVE'))->where('idx', $registerIDX)->execute();
开发者ID:JRevirthuum,项目名称:iModule,代码行数:67,代码来源:ModuleMember.class.php

示例5: Hash

<?php

if ($target == 'member') {
    $Module = $IM->getModule('member');
    if ($action == 'login') {
        if ($results->success == false && isset($values->email) == true && isset($values->password) == true) {
            $check = $Module->db()->select($Module->getTable('member'))->where('email', $values->email)->getOne();
            if ($check != null && $check->status == 'ACTIVE') {
                $mHash = new Hash();
                if ($mHash->password_validate(md5(strtolower($values->password)), $check->password) == true || $mHash->password_validate(md5($values->password), $check->password) == true) {
                    $Module->db()->update($Module->getTable('member'), array('password' => $mHash->password_hash($values->password)))->where('idx', $check->idx)->execute();
                    exit(json_encode($Module->doProcess('login'), JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK));
                }
            }
        }
    }
}
开发者ID:JRevirthuum,项目名称:iModule,代码行数:17,代码来源:afterDoProcess.php


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