本文整理汇总了PHP中sha1函数的典型用法代码示例。如果您正苦于以下问题:PHP sha1函数的具体用法?PHP sha1怎么用?PHP sha1使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sha1函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: actionModify
function actionModify()
{
$id = (int) $this->_context->get('id');
$rs = Account::find('user_id = ?', $id)->getOne();
if (!$rs->id()) {
return $this->msg($tip = '参数错误', url('manage::account'));
}
$form = Form_Common::createForm('', 'manage/profile');
if ($this->_context->isPOST() && $form->validate($_POST)) {
$post = $form->values();
$user_mail = $post['user_mail'];
$user_pass = $post['user_pass'];
$is_locked = $post['is_locked'] ? '1' : '0';
#dump($post);
if ($user_pass) {
$user_pass = sha1(md5('sike' . $post['user_pass'] . Q::ini('appini/secret_key')));
$rs->user_pass;
}
$rs->user_mail = $user_mail;
$rs->is_locked = $is_locked;
$rs->save();
return $this->msg($tip = '修改成功', url('manage::account/modify', array('id' => $id)));
}
$form->import($rs->toArray());
$form->element('user_pass')->value = '';
$form->element('is_locked')->checked = $rs->is_locked;
#dump($form->element('is_locked'));
$this->_view['form'] = $form;
$this->_view['rs'] = $rs;
$order = Order::find('user_id = ?', $id)->order('created DESC')->getAll();
$this->_view['order'] = $order;
$this->_view['_UDI'] = 'manage::account/index';
}
开发者ID:xyz12810,项目名称:xiao3vpn,代码行数:33,代码来源:account_controller.php
示例2: assignfeedback_editpdf_pluginfile
/**
* Serves assignment feedback and other files.
*
* @param mixed $course course or id of the course
* @param mixed $cm course module or id of the course module
* @param context $context
* @param string $filearea
* @param array $args
* @param bool $forcedownload
* @return bool false if file not found, does not return if found - just send the file
*/
function assignfeedback_editpdf_pluginfile($course, $cm, context $context, $filearea, $args, $forcedownload)
{
global $USER, $DB, $CFG;
if ($context->contextlevel == CONTEXT_MODULE) {
require_login($course, false, $cm);
$itemid = (int) array_shift($args);
if (!($assign = $DB->get_record('assign', array('id' => $cm->instance)))) {
return false;
}
$record = $DB->get_record('assign_grades', array('id' => $itemid), 'userid,assignment', MUST_EXIST);
$userid = $record->userid;
if ($assign->id != $record->assignment) {
return false;
}
// Check is users feedback or has grading permission.
if ($USER->id != $userid and !has_capability('mod/assign:grade', $context)) {
return false;
}
$relativepath = implode('/', $args);
$fullpath = "/{$context->id}/assignfeedback_editpdf/{$filearea}/{$itemid}/{$relativepath}";
$fs = get_file_storage();
if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
return false;
}
// Download MUST be forced - security!
send_stored_file($file, 0, 0, true);
// Check if we want to retrieve the stamps.
}
}
开发者ID:pzhu2004,项目名称:moodle,代码行数:40,代码来源:lib.php
示例3: authorizeTask
/**
* Authorize
*
* @return void
*/
public function authorizeTask()
{
$oauth_token = \Request::getVar('oauth_token');
if (empty($oauth_token)) {
throw new Exception('Forbidden', 403);
}
$db = \App::get('db');
$db->setQuery("SELECT * FROM `#__oauthp_tokens` WHERE token=" . $db->Quote($oauth_token) . " AND user_id=0 LIMIT 1;");
$result = $db->loadObject();
if ($result === false) {
throw new Exception('Internal Server Error', 500);
}
if (empty($result)) {
throw new Exception('Forbidden', 403);
}
if (Request::method() == 'GET') {
$this->view->oauth_token = $oauth_token;
$this->view->display();
return;
}
if (Request::method() == 'POST') {
$token = Request::get('token', '' . 'post');
if ($token != sha1($this->verifier)) {
throw new Exception('Forbidden', 403);
}
echo "posted";
return;
}
throw new Exception('Method Not Allowed', 405);
}
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:35,代码来源:authorize.php
示例4: ghost_command
public static function ghost_command($nick, $ircdata = array())
{
$unick = $ircdata[0];
$password = $ircdata[1];
// get the parameters.
if (trim($unick) == '' || trim($password) == '') {
services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_SYNTAX_RE, array('help' => 'GHOST'));
return false;
}
// invalid syntax
if (!isset(core::$nicks[$unick])) {
services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_NOT_IN_USE, array('nick' => $unick));
return false;
// nickname isn't in use
}
if ($user = services::user_exists($unick, false, array('display', 'pass', 'salt'))) {
if ($user->pass == sha1($password . $user->salt) || core::$nicks[$nick]['ircop'] && services::user_exists($nick, true, array('display', 'identified')) !== false) {
ircd::kill(core::$config->nickserv->nick, $unick, 'GHOST command used by ' . core::get_full_hostname($nick));
core::alog(core::$config->nickserv->nick . ': GHOST command used on ' . $unick . ' by ' . core::get_full_hostname($nick));
} else {
services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_PASSWORD);
// password isn't correct
}
} else {
services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ISNT_REGISTERED, array('nick' => $unick));
return false;
// doesn't even exist..
}
}
开发者ID:rickihastings,项目名称:acorairc,代码行数:29,代码来源:ghost.ns.php
示例5: addUser
public function addUser($add = array())
{
if (empty($add['staff_name']) and empty($add['username']) and empty($add['password'])) {
return TRUE;
}
$this->db->where('staff_email', strtolower($add['site_email']));
$this->db->delete('staffs');
$this->db->set('staff_email', strtolower($add['site_email']));
$this->db->set('staff_name', $add['staff_name']);
$this->db->set('staff_group_id', '11');
$this->db->set('staff_location_id', '0');
$this->db->set('language_id', '11');
$this->db->set('timezone', '0');
$this->db->set('staff_status', '1');
$this->db->set('date_added', mdate('%Y-%m-%d', time()));
$query = $this->db->insert('staffs');
if ($this->db->affected_rows() > 0 and $query === TRUE) {
$staff_id = $this->db->insert_id();
$this->db->where('username', $add['username']);
$this->db->delete('users');
$this->db->set('username', $add['username']);
$this->db->set('staff_id', $staff_id);
$this->db->set('salt', $salt = substr(md5(uniqid(rand(), TRUE)), 0, 9));
$this->db->set('password', sha1($salt . sha1($salt . sha1($add['password']))));
$query = $this->db->insert('users');
}
return $query;
}
开发者ID:tastyigniter,项目名称:tastyigniter,代码行数:28,代码来源:Setup_model.php
示例6: actionUpdate
/**
* Updates an existing User model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->setScenario('update');
$oldFile = $model->getImageFile();
$oldImage = $model->pict;
if ($model->load(Yii::$app->request->post())) {
$model->attributes = $model->load(Yii::$app->request->post());
if (!empty($model->newpass)) {
$model->password = sha1($model->salt . $model->newpass);
}
$image = $model->uploadImage();
// revert back if image not valid
if ($image === FALSE) {
$model->pict = $oldImage;
}
if ($model->save()) {
// upload jika image nya valid
if ($image !== FALSE) {
if (is_file($oldFile)) {
unlink($oldFile);
}
$path = $model->getImageFile();
$image->saveAs($path);
}
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', ['model' => $model]);
}
} else {
return $this->render('update', ['model' => $model]);
}
}
开发者ID:iwansusanto,项目名称:jurnalrumah,代码行数:39,代码来源:UserController.php
示例7: sign
/**
* Create the signed assertion.
* @param string $openid - Openid of the entity being asserted.
* @param string $attribute - The attribute name being asserted.
* @param string $value - The attribute value being asserted.
*/
function sign($openid, $attribute, $value)
{
$samlObj = new SAML();
$responseXmlString = $samlObj->createSamlAssertion($openid, $this->notBefore, $this->notOnOrAfter, $this->rsadsa, $this->acsURI, $attribute, sha1($value), $this->assertionTemplate);
$signedAssertion = $samlObj->signAssertion($responseXmlString, $this->private_key, $this->public_key_certificate);
return $signedAssertion;
}
开发者ID:hudx,项目名称:paypal-identity-demo,代码行数:13,代码来源:AP.php
示例8: _addLocalization
/**
* Add localization data to xml object
*
* @param Mage_XmlConnect_Model_Simplexml_Element $xml
* @return Mage_XmlConnect_Block_Adminhtml_Connect_Config
*/
protected function _addLocalization(Mage_XmlConnect_Model_Simplexml_Element $xml)
{
/** @var $translateHelper Mage_XmlConnect_Helper_Translate */
$translateHelper = Mage::helper('xmlconnect/translate');
$xml->addCustomChild('localization', $this->getUrl('*/*/localization'), array('hash' => sha1(serialize($translateHelper->getLocalizationArray()))));
return $this;
}
开发者ID:blazeriaz,项目名称:youguess,代码行数:13,代码来源:Config.php
示例9: hash
/**
* Create a security hash from the job, email and contact ids
*
* @param array The ids to be hashed
* @return int The hash
* @access public
* @static
*/
function hash($params)
{
$jobId = $params['job_id'];
$emailId = $params['email_id'];
$contactId = $params['contact_id'];
return sha1("{$jobId}:{$emailId}:{$contactId}:" . time());
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:15,代码来源:Queue.php
示例10: join
/**
* 加密/校验流程:
* 1. 将token、timestamp、nonce三个参数进行字典序排序
* 2. 将三个参数字符串拼接成一个字符串进行sha1加密
* 3. 开发者获得加密后的字符串可与signature对比,标识该请求来源于易信
*
* 若确认此次GET请求来自易信服务器,请原样返回echostr参数内容,则接入生效,否则接入失败。
*/
public function join($params)
{
$signature = $params['signature'];
$timestamp = $params['timestamp'];
$nonce = $params['nonce'];
$echostr = $params['echostr'];
$mpa = TMS_APP::G('mp\\mpaccount');
$p = array($mpa->token, $timestamp, $nonce);
asort($p);
$s = implode('', $p);
$ss = sha1($s);
if ($ss === $signature) {
/**
* 断开连接
*/
TMS_APP::model()->update('xxt_mpaccount', array('yx_joined' => 'N'), "yx_appid='{$mpa->yx_appid}' and yx_appsecret='{$mpa->yx_appsecret}'");
/**
* 确认建立连接
*/
TMS_APP::model()->update('xxt_mpaccount', array('yx_joined' => 'Y'), "mpid='{$this->mpid}'");
return array(true, $echostr);
} else {
return array(false, 'failed');
}
}
开发者ID:ahmatjan,项目名称:xinxintong,代码行数:33,代码来源:yx.php
示例11: validateDigest
public function validateDigest($digest, $nonce, $created, $secret)
{
// Generate created Token time difference
$now = new \DateTime('now', new \DateTimeZone('UTC'));
$then = new \Datetime($created, new \DateTimeZone('UTC'));
$diff = $now->diff($then, true);
// Check created time is not in the future
if (strtotime($created) > time()) {
throw new AuthenticationException("Back to the future...");
}
// Validate timestamp is recent within 5 minutes
$seconds = time() - strtotime($created);
if ($seconds > 300) {
throw new AuthenticationException('Expired timestamp. Seconds: ' . $seconds);
}
// Validate nonce is unique within 5 minutes
if (file_exists($this->cacheDir . '/' . $nonce) && file_get_contents($this->cacheDir . '/' . $nonce) + 300 > time()) {
throw new NonceExpiredException('Previously used nonce detected');
}
if (!is_dir($this->cacheDir)) {
mkdir($this->cacheDir, 0777, true);
}
file_put_contents($this->cacheDir . '/' . $nonce, time());
// Validate Secret
$expected = base64_encode(sha1(base64_decode($nonce) . $created . $secret, true));
// Return TRUE if our newly-calculated digest is the same as the one provided in the validateDigest() call
return $expected === $digest;
}
开发者ID:raziel057,项目名称:angular-symfony,代码行数:28,代码来源:WsseProvider.php
示例12: ajaxSignIn
public function ajaxSignIn()
{
extract($_POST['input']);
if (isset($remember)) {
\Models\Auth::remember($username, $password);
}
$user = Models\User::signIn($username, sha1($password));
if (!isset($user['id'])) {
$data['name'] = 'password';
$data['notice'] = 'Invalid login or password. Please try again.';
echo json_encode($data, JSON_UNESCAPED_UNICODE);
die;
}
$activated_at = \Models\User::getUserActivatedAt($username, sha1($password));
if (!isset($activated_at['activated_at']) || $activated_at['activated_at'] == null) {
$data['name'] = 'password';
$data['notice'] = 'Your account is not activated. Please, activate it at first.';
echo json_encode($data, JSON_UNESCAPED_UNICODE);
die;
} else {
\Models\Auth::userInSession($user);
$data['notice'] = true;
$data['id'] = $user['id'];
echo json_encode($data, JSON_UNESCAPED_UNICODE);
die;
}
}
开发者ID:kazak600,项目名称:Task-manager,代码行数:27,代码来源:sign_in.php
示例13: testSetPath
public function testSetPath()
{
$exporter = $this->getMockForAbstractClass(AbstractExporter::class);
$path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . sha1(time()) . DIRECTORY_SEPARATOR;
$exporter->setPath($path);
$this->assertEquals($path, $exporter->getPath());
}
开发者ID:fireguard,项目名称:report,代码行数:7,代码来源:AbstractExporterTest.php
示例14: connect
public function connect()
{
if ($this->_connection) {
return;
}
// Extract the connection parameters, adding required variabels
extract($this->_config['connection'] + array('hostname' => '', 'port' => '', 'password' => '', 'timeout' => 2.5, 'lifetime' => 1800, 'persistent' => FALSE));
// Prevent this information from showing up in traces
unset($this->_config['connection']['password']);
$this->_connection = new Redis();
try {
if ($persistent) {
// Create a persistent connection
$this->_connection->pconnect($hostname, $port, $timeout);
} else {
// Create a connection and force it to be a new link
$this->_connection->connect($hostname, $port, $timeout);
}
} catch (Exception $e) {
// No connection exists
$this->_connection = NULL;
throw new Redis_Exception(':error', array(':error' => $e->getMessage()), $e->getCode());
}
// \xFF is a better delimiter, but the PHP driver uses underscore
$this->_connection_id = sha1($hostname . '_' . $password);
if (!empty($this->_config['connection']['variables'])) {
// Set session variables
$variables = array();
foreach ($this->_config['connection']['variables'] as $var => $val) {
$variables[] = 'SESSION ' . $var . ' = ' . $this->quote($val);
}
//mysql_query('SET '.implode(', ', $variables), $this->_connection);
}
}
开发者ID:sttt,项目名称:kohana-phpredis,代码行数:34,代码来源:Default.php
示例15: get_capsidea_data
function get_capsidea_data($capsidea_client_secret)
{
$ret = array();
$parsed_url = parse_url($_SERVER['HTTP_REFERER']);
$var = explode('&', $parsed_url['query']);
foreach ($var as $val) {
$x = explode('=', $val);
$arr[$x[0]] = $x[1];
}
unset($val, $x, $var, $qry, $parsed_url, $ref);
if (isset($arr["token"])) {
$token = $arr["token"];
} else {
die("cant find capsidea.com token, please contact application support");
}
if (36 != strlen($token)) {
die("capsidea.com token incorrect, please contact application support");
}
$ret["c"] = $str = preg_replace('/[^A-Za-z0-9\\-]/', '', $token);
$ret["t"] = sha1($capsidea_client_secret . $token);
if (isset($arr["schemakey"])) {
$ret["k"] = (int) $arr["schemakey"];
}
return $ret;
}
开发者ID:digideskio,项目名称:capsidea-ds,代码行数:25,代码来源:cbr-inc.php
示例16: address_to_xml
/**
* Retrieves the XML geocode address lookup.
* ! Results of this method are cached for 1 day.
*
* @param string $address adress
* @return object SimpleXML
*/
public static function address_to_xml($address)
{
static $cache;
// Load Cache
if ($cache === NULL) {
$cache = Cache::instance();
}
// Address cache key
$key = 'gmap-address-' . sha1($address);
if ($xml = $cache->get($key)) {
// Return the cached XML
return simplexml_load_string($xml);
} else {
// Set the XML URL
$xml = Gmap::api_url('maps/geo', array('output' => 'xml', 'q' => $address), '&');
// Disable error reporting while fetching the feed
$ER = error_reporting(~E_NOTICE);
// Load the XML
$xml = simplexml_load_file($xml);
if (is_object($xml) and $xml instanceof SimpleXMLElement and (int) $xml->Response->Status->code === 200) {
// Cache the XML
$cache->set($key, $xml->asXML(), array('gmaps'), 86400);
} else {
// Invalid XML response
$xml = FALSE;
}
// Turn error reporting back on
error_reporting($ER);
}
return $xml;
}
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:38,代码来源:Gmap.php
示例17: Login
public function Login()
{
global $ly;
// post info and session start
$html = "";
// Take care of _GET/_POST variables. Store them in a variable (if they are set).
$user = isset($_POST['user']) ? $_POST['user'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
// get user table from db
$res = $ly->db->select(TBL_PREFIX . "Users", "username = '{$user}'");
if ($res->num_rows > 0) {
$row = $res->fetch_object();
// is there a user with that name/pass
if ($row->pass == sha1("{$row->username}{$password}")) {
$html .= "<div class='success'>Login successful. Welcome {$user}.</div>";
}
// save sessions vars
$_SESSION["id"] = $row->id;
$_SESSION["user"] = $row->username;
} else {
// else login failed
$html .= "<div class='error'>User not found</div>";
}
$ly->template->regions->main = $html;
}
开发者ID:reechani,项目名称:slydia,代码行数:25,代码来源:CCtrl4Login.php
示例18: changePassword
private function changePassword()
{
$msg = '';
if (empty($_POST['current_password']) || empty($_POST['new_password']) || empty($_POST['new_password2'])) {
$msg = 'You forgot to fill in something!';
} else {
$check = sha1($this->player->secret_key . $_POST['current_password'] . SECRET_KEY);
if ($check != $this->player->password) {
$msg = 'The password you entered does not match this account\'s password.';
} else {
if (!isPassword($_POST['new_password'])) {
$msg = 'Your password must be longer than 3 characters!';
} else {
if ($_POST['new_password'] != $_POST['new_password2']) {
$msg = 'You didn\'t confirm your new password correctly!';
} else {
$new_password = sha1($this->player->secret_key . $_POST['new_password2'] . SECRET_KEY);
$this->db->execute('UPDATE `<ezrpg>players` SET `password`=? WHERE `id`=?', array($new_password, $this->player->id));
$msg = 'You have changed your password.';
}
}
}
}
header('Location: index.php?mod=AccountSettings&msg=' . urlencode($msg));
}
开发者ID:BGCX067,项目名称:ezrpg-hg-to-git,代码行数:25,代码来源:index.php
示例19: voting_item_detail
/**
* Show form to vote an item. (itemDetail)
*/
function voting_item_detail()
{
if (osc_is_this_category('voting', osc_item_category_id()) && osc_get_preference('item_voting', 'voting') == '1') {
$aux_vote = ModelVoting::newInstance()->getItemAvgRating(osc_item_id());
$aux_count = ModelVoting::newInstance()->getItemNumberOfVotes(osc_item_id());
$vote['vote'] = $aux_vote['vote'];
$vote['total'] = $aux_count['total'];
$hash = '';
if (osc_logged_user_id() == 0) {
$hash = $_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR'];
$hash = sha1($hash);
} else {
$hash = null;
}
$vote['can_vote'] = true;
if (osc_get_preference('user', 'voting') == 1) {
if (!osc_is_web_user_logged_in()) {
$vote['can_vote'] = false;
}
}
if (!can_vote(osc_item_id(), osc_logged_user_id(), $hash)) {
$vote['can_vote'] = false;
}
require 'item_detail.php';
}
}
开发者ID:michaelxizhou,项目名称:myeden69-original-backup,代码行数:29,代码来源:index.php
示例20: __construct
/**
* What is ran when first loading.
*
* @access public
* @param mixed $param1 (default: null)
* @param mixed $options (default: null)
* @return void
*/
public function __construct($param1 = null, $param2 = null, $dbid = null)
{
if (is_null($param1)) {
throw new \Exception('ERROR');
} else {
if ($param1 == \Reports\Query::RUN) {
$this->id = $param2;
$this->_load();
$this->_run();
} else {
if ($param1 == \Reports\Query::LOAD) {
$this->id = $param2;
$this->_load();
} else {
if ($param1 == \Reports\Query::CREATE && !is_null($param2) && !is_null($dbid)) {
$this->query = $param2;
$this->query_hash = sha1($param2);
$this->database_id = $dbid;
$this->request_date = date("Y-m-d H:i:s");
$this->status = 1;
$this->_create();
} else {
throw new \Exception('Parameters not given correctly');
}
}
}
}
return $this;
}
开发者ID:ClixLtd,项目名称:pccupload,代码行数:37,代码来源:query.php
注:本文中的sha1函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论