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


PHP Security::hash方法代码示例

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


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

示例1: edit

 function edit()
 {
     if (!empty($this->data)) {
         // is the user updating their password?
         if (isset($this->data['User']['password']) && isset($this->data['User']['password_confirm'])) {
             $this->User->set($this->data);
             $this->User->id = $this->Session->read('Auth.User.id');
             // check that the passwords are valid
             if ($this->User->validates(array('fieldList' => array('password', 'password_confirm')))) {
                 // hash the passwords
                 $password = Security::hash($this->data['User']['password'], null, true);
                 $password_confirm = Security::hash($this->data['User']['password_confirm'], null, true);
                 if ($this->User->saveField('password', $password)) {
                     $this->Session->setFlash('Your password has been updated successfully.');
                 } else {
                     $this->Session->setFlash('There was a problem saving your password', 'error');
                 }
             } else {
                 $this->User->invalidFields();
             }
             // clear out the fields
             $this->data['User']['password'] = '';
             $this->data['User']['password_confirm'] = '';
         }
     }
 }
开发者ID:rtgibbons,项目名称:shelladdict,代码行数:26,代码来源:users_controller.php

示例2: serializeXmlToArray

 /**
  * Serialize to array data from xml
  *
  * @return array Xml serialize array data
  */
 public function serializeXmlToArray()
 {
     //後で修正する
     $xmlData = Xml::toArray(Xml::build(self::NOTIFICATION_URL));
     // rssの種類によってタグ名が異なる
     if (isset($xmlData['feed'])) {
         $items = Hash::get($xmlData, 'feed.entry');
         $dateKey = 'published';
         $linkKey = 'link.@href';
         $summaryKey = 'summary';
     } elseif (Hash::get($xmlData, 'rss.@version') === '2.0') {
         $items = Hash::get($xmlData, 'rss.channel.item');
         $dateKey = 'pubDate';
         $linkKey = 'link';
         $summaryKey = 'description';
     } else {
         $items = Hash::get($xmlData, 'RDF.item');
         $dateKey = 'dc:date';
         $linkKey = 'link';
         $summaryKey = 'description';
     }
     if (!isset($items[0]) && is_array($items)) {
         $items = array($items);
     }
     $data = array();
     foreach ($items as $item) {
         $date = new DateTime($item[$dateKey]);
         $summary = Hash::get($item, $summaryKey);
         $data[] = array('title' => $item['title'], 'link' => Hash::get($item, $linkKey), 'summary' => $summary ? strip_tags($summary) : '', 'last_updated' => $date->format('Y-m-d H:i:s'), 'key' => Security::hash(Hash::get($item, $linkKey), 'md5'));
     }
     return $data;
 }
开发者ID:Onasusweb,项目名称:Notifications,代码行数:37,代码来源:Notification.php

示例3: getActivationHash

	function getActivationHash()
        {
                if (!isset($this->id)) {
                        return false;
                }
                return substr(Security::hash(Configure::read('Security.salt') . $this->field('created') . date('Ymd')), 0, 8);
        }
开发者ID:ninetwentyfour,项目名称:Homkora,代码行数:7,代码来源:user.php

示例4: admin_edit

 function admin_edit($id = null)
 {
     if (!$id) {
         $this->redirect(array('controller' => 'users', 'action' => 'index', 'admin' => true));
     }
     $user = $this->User->read(null, $id);
     $user_groups = $this->User->UserGroup->find('list');
     $errors = array();
     if (!empty($this->data)) {
         if (!empty($this->data['User']['new_password'])) {
             $this->data['User']['password'] = $this->data['User']['new_password'];
             $hashed = Security::hash($this->data['User']['password'], 'sha1', true);
         }
         $this->User->set($this->data);
         if ($this->User->validates()) {
             if (isset($this->data['User']['password'])) {
                 $this->data['User']['password'] = $hashed;
             }
             $this->User->save($this->data, array('validate' => false));
             $this->Session->setFlash('Användaren har nu sparats');
         } else {
             $errors = $this->User->invalidFields();
         }
     } else {
         $this->data = $user;
     }
     $this->set('errors', $errors);
     $this->set('userGroups', $user_groups);
     $this->set('user', $user);
 }
开发者ID:EnkelMagnus,项目名称:m2,代码行数:30,代码来源:users_controller.php

示例5: beforeSave

 /**
  * to encrypt password before save
  * @param array $options
  * @return boolean
  * @author Laxmi Saini
  */
 public function beforeSave($options = array())
 {
     if (isset($this->data['User']['new_password'])) {
         $this->data['User']['password'] = Security::hash($this->data['User']['new_password'], null, true);
     }
     return true;
 }
开发者ID:yogesha3,项目名称:yogesh-test,代码行数:13,代码来源:User.php

示例6: beforeSave

 public function beforeSave($options = array())
 {
     if (isset($this->data[$this->name]['password']) && !empty($this->data[$this->name]['password'])) {
         $this->data[$this->name]['password'] = Security::hash($this->data[$this->name]['password'], 'md5');
     }
     return true;
 }
开发者ID:mnyq,项目名称:case-record-system,代码行数:7,代码来源:User.php

示例7: beforeSave

 public function beforeSave($options = array())
 {
     if (!empty($this->data[$this->alias]['senha'])) {
         $this->data[$this->alias]['senha'] = Security::hash($this->data[$this->alias]['senha'], 'blowfish');
     }
     return true;
 }
开发者ID:Arkanius,项目名称:GHEcommerce,代码行数:7,代码来源:Usuario.php

示例8: forgotPassword

 public function forgotPassword($data)
 {
     $saveData = array();
     $email = $data['email'];
     $respone = array();
     $options = array('conditions' => array('User.email' => $email));
     $user = $this->find("first", $options);
     if ($user) {
         $resetCode = Security::hash(String::uuid(), 'sha1', true);
         $url = Router::url(array('controller' => 'users', 'action' => 'resetPassword'), true) . '?code=' . $resetCode;
         //Removing any previously generated
         $this->ResetPassword->deleteAll(array('ResetPassword.user_id' => $user['User']['id']), false);
         //saving validation code
         $saveData['ResetPassword'] = array('user_id' => $user['User']['id'], 'reset_code' => $resetCode);
         $status = $this->ResetPassword->saveAll($saveData, array('validate' => false));
         if ($status) {
             $Email = new Email();
             $message = 'Reset password';
             $message .= "Copy and Paste following url in your browser:\n";
             $message .= $url;
             if (SEND_EMAIL) {
                 $emailStatus = $Email->sendEmail($email, $message, EMAIL_TPL_RESET_PASSWORD);
             } else {
                 $emailStatus = true;
             }
             if ($emailStatus) {
                 return array('status' => true, 'success_msg' => USER_RESET_PASSWORD_SUCCESS);
             }
         } else {
             return array('status' => false, 'errors' => USER_ERR_RESET_PASSWORD_FAILED);
         }
     } else {
         return array('status' => false, 'errors' => USER_ERR_EMAIL_NOT_REGISTERED);
     }
 }
开发者ID:AshSingh4888,项目名称:olx_fb,代码行数:35,代码来源:User.php

示例9: create_admin

 public function create_admin()
 {
     $this->layout = 'admin';
     if ($this->Session->read('Admin.admin') == null) {
         $this->Session->setFlash("Vous n'avez rien a faire ici, oust !", "error");
         $this->redirect(array('controller' => 'Admin', 'action' => 'index'));
     } else {
         if ($this->Session->read('roles.superadmin') == 0) {
             $this->Session->setFlash("Vous n'avez pas le droit de faire sa", "error");
             $this->redirect(array('controller' => 'Admin', 'action' => 'index'));
         } else {
             $role = $this->Role->find('list');
             $this->set("roles", $role);
             if ($this->request->is('post')) {
                 $d = $this->request->data;
                 $d['Create']['id'] = null;
                 if (!empty($d['Create']['passwd'])) {
                     $d['Create']['passwd'] = Security::hash($d['Create']['passwd'], null, true);
                 }
                 if ($this->Admin->save(array('admin' => $d['Create']['admin'], 'email' => $d['Create']['email'], 'passwd' => $d['Create']['passwd'], 'role' => $d['Create']['Role'], 'username' => $d['Create']['Username']))) {
                     $this->Session->setFlash("Admin créé", "notif");
                 } else {
                     $this->Session->setFlash("Erreur", "error");
                 }
             }
         }
     }
 }
开发者ID:thibaultauvray,项目名称:framework0,代码行数:28,代码来源:AdminController.php

示例10: _makeSrc

 /**
  * _makeSrc
  *
  * @param $file
  * @param $options
  * @return
  */
 function _makeSrc($file = null, $options = array())
 {
     $hash = $this->Session->read('Filebinder.hash');
     $prefix = empty($options['prefix']) ? '' : $options['prefix'];
     $filePath = empty($file['file_path']) ? empty($file['tmp_bind_path']) ? false : $file['tmp_bind_path'] : preg_replace('#/([^/]+)$#', '/' . $prefix . '$1', $file['file_path']);
     if (empty($file) || !$filePath) {
         return false;
     }
     if (!preg_match('#' . WWW_ROOT . '#', $filePath)) {
         if (!empty($file['tmp_bind_path'])) {
             if (empty($file['model_id']) || file_exists($file['tmp_bind_path'])) {
                 $file['model_id'] = 0;
                 $file['file_name'] = preg_replace('#.+/([^/]+)$#', '$1', $file['tmp_bind_path']);
             }
         }
         // over 1.3
         $prefixes = Configure::read('Routing.prefixes');
         if (!$prefixes && Configure::read('Routing.admin')) {
             $prefixes = Configure::read('Routing.admin');
         }
         $url = array();
         foreach ((array) $prefixes as $p) {
             $url[$p] = false;
         }
         $url = array_merge($url, array('plugin' => 'filebinder', 'controller' => 'filebinder', 'action' => 'loader', $file['model'], $file['model_id'], $file['field_name'], Security::hash($file['model'] . $file['model_id'] . $file['field_name'] . $hash), $prefix . $file['file_name']));
         return $url;
     }
     $src = preg_replace('#' . WWW_ROOT . '#', DS, $filePath);
     return $src;
 }
开发者ID:Onasusweb,项目名称:filebinder,代码行数:37,代码来源:label.php

示例11: edit

 public function edit($id = null, $data = null, $conditions = [])
 {
     $conditions['User.id'] = $id;
     $user = $this->find('first', ['conditions' => $conditions]);
     if (empty($user)) {
         throw new OutOfBoundsException(__('Invalid Access', true));
     }
     if (!empty($data)) {
         $this->set($data);
         if (empty($this->data['User']['update_password_flg'])) {
             unset($this->data['User']['password']);
             unset($this->data['User']['password_confirm']);
         } else {
             if (!empty($this->data['User']['password'])) {
                 $this->data['User']['password'] = Security::hash($this->data['User']['password'], null, true);
             }
             if (!empty($this->data['User']['password_confirm'])) {
                 $this->data['User']['password_confirm'] = Security::hash($this->data['User']['password_confirm'], null, true);
             }
         }
         $this->setValidation('edit');
         $result = $this->save(null, true);
         if ($result) {
             $this->data = $result;
             return true;
         } else {
             throw new ValidationException();
         }
     } else {
         unset($user['User']['password']);
         return $user;
     }
 }
开发者ID:k1low,项目名称:sponge,代码行数:33,代码来源:User.php

示例12: import

 public function import()
 {
     $file = $this->args[0];
     App::import('Core', array('File', 'Security'));
     $file = new File($file);
     if (!$file->exists()) {
         $this->out('Error: File does not exist: ' . $file->name);
         return;
     }
     $row = 1;
     $handle = fopen($file->path, 'r');
     //		$this->User->deleteAll(array());
     while (($data = fgetcsv($handle, 1000, ',')) !== FALSE) {
         $num = count($data);
         if ($num != 4) {
             continue;
         }
         $row++;
         $this->User->create(array('role' => 'user', 'username' => $data[1], 'password' => Security::hash($data[2], null, true), 'email' => $data[3]));
         if ($this->User->save()) {
             $this->out('Saved: ' . $data[1]);
         } else {
             $this->out('Error: Failed saving: ' . $data[1]);
         }
     }
     fclose($handle);
 }
开发者ID:predominant,项目名称:CakeMatsuri-Todo,代码行数:27,代码来源:user.php

示例13: admin_new

 public function admin_new()
 {
     $this->set('current_crumb', __('New Admin', true));
     $this->set('title_for_layout', __('New Admin', true));
     if (empty($this->data)) {
         $dataRoles = $this->User->Role->find('list', array('conditions' => array(), 'recursive' => -1, 'fields' => array('Role.id', 'Role.role_name')));
         $this->set('dataRoles', $dataRoles);
     } else {
         // Redirect if the user pressed cancel
         if (isset($this->data['cancelbutton'])) {
             $this->redirect('/users/admin/');
             die;
         }
         // Check for other users with this username
         $check_username = $this->User->find('count', array('conditions' => array('username' => $this->data['User']['username'])));
         if ($check_username > 0) {
             $this->Session->setFlash(__('Could not create user account. User exists.', true));
             $this->redirect('/users/admin/');
             die;
         }
         $this->request->data['User']['password'] = Security::hash($this->data['User']['password'], 'sha1', true);
         $this->User->save($this->data);
         // Set some default preferences
         $user_id = $this->User->getLastInsertId();
         $this->Session->setFlash(__('Record created.', true));
         $this->redirect('/users/admin/');
     }
 }
开发者ID:hoangtrongvinh,项目名称:Restaurant,代码行数:28,代码来源:UsersController.php

示例14: validate_current_password

 /**
  * Validate Old Password from Database
  * @return bool
  */
 public function validate_current_password()
 {
     $user = $this->find('first', array('conditions' => array('User.id' => AuthComponent::user('id')), 'fields' => array('secret')));
     $storedHash = $user['User']['secret'];
     $newHash = Security::hash($this->data[$this->alias]['secretcurrent'], 'blowfish', $storedHash);
     return $storedHash == $newHash;
 }
开发者ID:sanjaysuthar,项目名称:auditmgmt,代码行数:11,代码来源:User.php

示例15: login

 public function login()
 {
     $errors = array();
     $datas = array();
     if (!empty($this->request->data)) {
         //verifications angularjs
         if (empty($this->request->data['username'])) {
             //validations username
             $errors['username'] = "Veuillez entrer un nom d'utilisateur";
         }
         if (empty($this->request->data['password'])) {
             //validations password
             $errors['password'] = 'Veuillez entrer un mot de passe';
         }
         if (!empty($errors)) {
             //vcrifications d'erreurs
             $datas['success'] = false;
             $datas['errors'] = $errors;
         }
         //connexion
         $data = $this->request->data;
         $data['password'] = Security::hash($data['password'], 'sha1', true);
         $user = $this->User->find('first', array('conditions' => array('User.username' => $data['username'], 'User.password' => $data['password'])));
         if (!empty($user)) {
             if ($this->Auth->login($user['User'])) {
                 $datas['success'] = true;
                 $datas['message'] = 'Vous êtes connecté';
             }
         } else {
             $datas['success'] = false;
             $datas['errors']['identifiant'] = 'Identifiants incorrects';
         }
         echo json_encode($datas);
     }
 }
开发者ID:TO-AL,项目名称:site,代码行数:35,代码来源:UsersController.php


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