本文整理汇总了PHP中auth_cookiesalt函数的典型用法代码示例。如果您正苦于以下问题:PHP auth_cookiesalt函数的具体用法?PHP auth_cookiesalt怎么用?PHP auth_cookiesalt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了auth_cookiesalt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle the match
*/
function handle($match, $state, $pos, Doku_Handler $handler)
{
global $ID;
$match = substr($match, 2, -4);
$pos = strrpos($match, '$$');
$text = trim(substr($match, 0, $pos));
$sig = substr($match, $pos + 2, 32);
$user = substr($match, $pos + 36);
$check = md5($ID . $user . trim($text) . auth_cookiesalt());
return array('text' => $text, 'user' => $user, 'valid' => $sig == $check);
}
示例2: authenticate
/**
* Authenticate using currently logged in user
*/
private function authenticate($secondAttempt = false)
{
global $auth, $INPUT;
// Ok, this is evil. We read the login information of the current user and forward it to the HTTPClient
list($this->user, $sticky, $this->pass) = auth_getCookie();
// Logged in in second attempt is now in Session.
if ($secondAttempt && !isset($this->user) && $INPUT->str('u') && $INPUT->str('p')) {
// We hacked directly into the login mechanism which provides the login information without encryption via $INPUT
$this->user = $INPUT->str('u');
$this->pass = $INPUT->str('p');
$sticky = $INPUT->str('r');
} else {
$secret = auth_cookiesalt(!$sticky, true);
//bind non-sticky to session
$this->pass = $this->auth_decrypt($this->pass, $secret);
}
return isset($this->user);
}
示例3: _gather
/**
* Gather all information
*
* @return array The popularity data as an array
*/
function _gather()
{
global $conf;
/** @var $auth DokuWiki_Auth_Plugin */
global $auth;
$data = array();
$phptime = ini_get('max_execution_time');
@set_time_limit(0);
$pluginInfo = $this->getInfo();
// version
$data['anon_id'] = md5(auth_cookiesalt());
$data['version'] = getVersion();
$data['popversion'] = $pluginInfo['date'];
$data['language'] = $conf['lang'];
$data['now'] = time();
$data['popauto'] = (int) $this->isAutoSubmitEnabled();
// some config values
$data['conf_useacl'] = $conf['useacl'];
$data['conf_authtype'] = $conf['authtype'];
$data['conf_template'] = $conf['template'];
// number and size of pages
$list = array();
search($list, $conf['datadir'], array($this, '_search_count'), array('all' => false), '');
$data['page_count'] = $list['file_count'];
$data['page_size'] = $list['file_size'];
$data['page_biggest'] = $list['file_max'];
$data['page_smallest'] = $list['file_min'];
$data['page_nscount'] = $list['dir_count'];
$data['page_nsnest'] = $list['dir_nest'];
if ($list['file_count']) {
$data['page_avg'] = $list['file_size'] / $list['file_count'];
}
$data['page_oldest'] = $list['file_oldest'];
unset($list);
// number and size of media
$list = array();
search($list, $conf['mediadir'], array($this, '_search_count'), array('all' => true));
$data['media_count'] = $list['file_count'];
$data['media_size'] = $list['file_size'];
$data['media_biggest'] = $list['file_max'];
$data['media_smallest'] = $list['file_min'];
$data['media_nscount'] = $list['dir_count'];
$data['media_nsnest'] = $list['dir_nest'];
if ($list['file_count']) {
$data['media_avg'] = $list['file_size'] / $list['file_count'];
}
unset($list);
// number and size of cache
$list = array();
search($list, $conf['cachedir'], array($this, '_search_count'), array('all' => true));
$data['cache_count'] = $list['file_count'];
$data['cache_size'] = $list['file_size'];
$data['cache_biggest'] = $list['file_max'];
$data['cache_smallest'] = $list['file_min'];
if ($list['file_count']) {
$data['cache_avg'] = $list['file_size'] / $list['file_count'];
}
unset($list);
// number and size of index
$list = array();
search($list, $conf['indexdir'], array($this, '_search_count'), array('all' => true));
$data['index_count'] = $list['file_count'];
$data['index_size'] = $list['file_size'];
$data['index_biggest'] = $list['file_max'];
$data['index_smallest'] = $list['file_min'];
if ($list['file_count']) {
$data['index_avg'] = $list['file_size'] / $list['file_count'];
}
unset($list);
// number and size of meta
$list = array();
search($list, $conf['metadir'], array($this, '_search_count'), array('all' => true));
$data['meta_count'] = $list['file_count'];
$data['meta_size'] = $list['file_size'];
$data['meta_biggest'] = $list['file_max'];
$data['meta_smallest'] = $list['file_min'];
if ($list['file_count']) {
$data['meta_avg'] = $list['file_size'] / $list['file_count'];
}
unset($list);
// number and size of attic
$list = array();
search($list, $conf['olddir'], array($this, '_search_count'), array('all' => true));
$data['attic_count'] = $list['file_count'];
$data['attic_size'] = $list['file_size'];
$data['attic_biggest'] = $list['file_max'];
$data['attic_smallest'] = $list['file_min'];
if ($list['file_count']) {
$data['attic_avg'] = $list['file_size'] / $list['file_count'];
}
$data['attic_oldest'] = $list['file_oldest'];
unset($list);
// user count
if ($auth && $auth->canDo('getUserCount')) {
$data['user_count'] = $auth->getUserCount();
//.........这里部分代码省略.........
示例4: decrypt
/**
* Decrypt the given string with the cookie salt
*
* @param string $data
* @return string
*/
public function decrypt($data)
{
$data = base64_decode($data);
if (function_exists('auth_decrypt')) {
return auth_decrypt($data, auth_cookiesalt());
// since binky
} else {
return PMA_blowfish_decrypt($data, auth_cookiesalt());
// deprecated
}
}
示例5: updateprofile
/**
* Update user profile
*
* @author Christopher Smith <chris@jalakai.co.uk>
*/
function updateprofile()
{
global $conf;
global $lang;
/* @var DokuWiki_Auth_Plugin $auth */
global $auth;
/* @var Input $INPUT */
global $INPUT;
if (!$INPUT->post->bool('save')) {
return false;
}
if (!checkSecurityToken()) {
return false;
}
if (!actionOK('profile')) {
msg($lang['profna'], -1);
return false;
}
$changes = array();
$changes['pass'] = $INPUT->post->str('newpass');
$changes['name'] = $INPUT->post->str('fullname');
$changes['mail'] = $INPUT->post->str('email');
// check misspelled passwords
if ($changes['pass'] != $INPUT->post->str('passchk')) {
msg($lang['regbadpass'], -1);
return false;
}
// clean fullname and email
$changes['name'] = trim(preg_replace('/[\\x00-\\x1f:<>&%,;]+/', '', $changes['name']));
$changes['mail'] = trim(preg_replace('/[\\x00-\\x1f:<>&%,;]+/', '', $changes['mail']));
// no empty name and email (except the backend doesn't support them)
if (empty($changes['name']) && $auth->canDo('modName') || empty($changes['mail']) && $auth->canDo('modMail')) {
msg($lang['profnoempty'], -1);
return false;
}
if (!mail_isvalid($changes['mail']) && $auth->canDo('modMail')) {
msg($lang['regbadmail'], -1);
return false;
}
$changes = array_filter($changes);
// check for unavailable capabilities
if (!$auth->canDo('modName')) {
unset($changes['name']);
}
if (!$auth->canDo('modMail')) {
unset($changes['mail']);
}
if (!$auth->canDo('modPass')) {
unset($changes['pass']);
}
// anything to do?
if (!count($changes)) {
msg($lang['profnochange'], -1);
return false;
}
if ($conf['profileconfirm']) {
if (!$auth->checkPass($INPUT->server->str('REMOTE_USER'), $INPUT->post->str('oldpass'))) {
msg($lang['badpassconfirm'], -1);
return false;
}
}
if ($result = $auth->triggerUserMod('modify', array($INPUT->server->str('REMOTE_USER'), &$changes))) {
// update cookie and session with the changed data
if ($changes['pass']) {
list(, $sticky, ) = auth_getCookie();
$pass = auth_encrypt($changes['pass'], auth_cookiesalt(!$sticky, true));
auth_setCookie($INPUT->server->str('REMOTE_USER'), $pass, (bool) $sticky);
}
return true;
}
return false;
}
示例6: checkFileStatus
/**
* Check for media for preconditions and return correct status code
*
* READ: MEDIA, MIME, EXT, CACHE
* WRITE: MEDIA, FILE, array( STATUS, STATUSMESSAGE )
*
* @author Gerry Weissbach <gerry.w@gammaproduction.de>
* @param $media reference to the media id
* @param $file reference to the file variable
* @returns array(STATUS, STATUSMESSAGE)
*/
function checkFileStatus(&$media, &$file)
{
global $MIME, $EXT, $CACHE;
//media to local file
if (preg_match('#^(https?)://#i', $media)) {
//check hash
if (substr(md5(auth_cookiesalt() . $media), 0, 6) != $_REQUEST['hash']) {
return array(412, 'Precondition Failed');
}
//handle external images
if (strncmp($MIME, 'image/', 6) == 0) {
$file = media_get_from_URL($media, $EXT, $CACHE);
}
if (!$file) {
//download failed - redirect to original URL
return array(302, $media);
}
} else {
$media = cleanID($media);
if (empty($media)) {
return array(400, 'Bad request');
}
//check permissions (namespace only)
if (auth_quickaclcheck(getNS($media) . ':X') < AUTH_READ) {
return array(403, 'Forbidden');
}
$file = mediaFN($media);
}
//check file existance
if (!@file_exists($file)) {
return array(404, 'Not Found');
}
return array(200, null);
}
示例7: getSecurityToken
/**
* Return a secret token to be used for CSRF attack prevention
*
* @author Andreas Gohr <andi@splitbrain.org>
* @link http://en.wikipedia.org/wiki/Cross-site_request_forgery
* @link http://christ1an.blogspot.com/2007/04/preventing-csrf-efficiently.html
*
* @return string
*/
function getSecurityToken()
{
/** @var Input $INPUT */
global $INPUT;
return PassHash::hmac('md5', session_id() . $INPUT->server->str('REMOTE_USER'), auth_cookiesalt());
}
示例8: 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
}
示例9: define
<?php
/**
* CAPTCHA antispam plugin - Image generator
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <gohr@cosmocode.de>
*/
if (!defined('DOKU_INC')) {
define('DOKU_INC', dirname(__FILE__) . '/../../../');
}
define('NOSESSION', true);
define('DOKU_DISABLE_GZIP_OUTPUT', 1);
require_once DOKU_INC . 'inc/init.php';
require_once DOKU_INC . 'inc/auth.php';
$ID = $_REQUEST['id'];
$plugin = plugin_load('helper', 'captcha');
$rand = PMA_blowfish_decrypt($_REQUEST['secret'], auth_cookiesalt());
$code = $plugin->_generateCAPTCHA($plugin->_fixedIdent(), $rand);
$plugin->_imageCAPTCHA($code);
//Setup VIM: ex: et ts=4 enc=utf-8 :
示例10: _fixedIdent
/**
* Build a semi-secret fixed string identifying the current page and user
*
* This string is always the same for the current user when editing the same
* page revision, but only for one day. Editing a page before midnight and saving
* after midnight will result in a failed CAPTCHA once, but makes sure it can
* not be reused which is especially important for the registration form where the
* $ID usually won't change.
*
* @return string
*/
public function _fixedIdent()
{
global $ID;
$lm = @filemtime(wikiFN($ID));
$td = date('Y-m-d');
return auth_browseruid() . auth_cookiesalt() . $ID . $lm . $td;
}
示例11: getSecurityToken
/**
* Return a secret token to be used for CSRF attack prevention
*
* @author Andreas Gohr <andi@splitbrain.org>
* @link http://en.wikipedia.org/wiki/Cross-site_request_forgery
* @link http://christ1an.blogspot.com/2007/04/preventing-csrf-efficiently.html
* @return string
*/
function getSecurityToken()
{
return PassHash::hmac('md5', session_id() . $_SERVER['REMOTE_USER'], auth_cookiesalt());
}
示例12: _getUserData
/**
* @param string $user
* @param bool $inbind authldap specific, true if in bind phase
* @return array containing user data or false
*/
protected function _getUserData($user, $inbind = false)
{
global $conf;
if (!$this->_openLDAP()) {
return false;
}
// force superuser bind if wanted and not bound as superuser yet
if ($this->getConf('binddn') && $this->getConf('bindpw') && $this->bound < 2) {
// use superuser credentials
if (!@ldap_bind($this->con, $this->getConf('binddn'), $this->getConf('bindpw'))) {
$this->_debug('LDAP bind as superuser: ' . htmlspecialchars(ldap_error($this->con)), 0, __LINE__, __FILE__);
return false;
}
$this->bound = 2;
} elseif ($this->bound == 0 && !$inbind) {
// in some cases getUserData is called outside the authentication workflow
// eg. for sending email notification on subscribed pages. This data might not
// be accessible anonymously, so we try to rebind the current user here
list($loginuser, $loginsticky, $loginpass) = auth_getCookie();
if ($loginuser && $loginpass) {
$loginpass = auth_decrypt($loginpass, auth_cookiesalt(!$loginsticky, true));
$this->checkPass($loginuser, $loginpass);
}
}
$info = array();
$info['user'] = $user;
$info['server'] = $this->getConf('server');
//get info for given user
$base = $this->_makeFilter($this->getConf('usertree'), $info);
if ($this->getConf('userfilter')) {
$filter = $this->_makeFilter($this->getConf('userfilter'), $info);
} else {
$filter = "(ObjectClass=*)";
}
$sr = $this->_ldapsearch($this->con, $base, $filter, $this->getConf('userscope'));
$result = @ldap_get_entries($this->con, $sr);
$this->_debug('LDAP user search: ' . htmlspecialchars(ldap_error($this->con)), 0, __LINE__, __FILE__);
$this->_debug('LDAP search at: ' . htmlspecialchars($base . ' ' . $filter), 0, __LINE__, __FILE__);
// Don't accept more or less than one response
if (!is_array($result) || $result['count'] != 1) {
return false;
//user not found
}
$user_result = $result[0];
ldap_free_result($sr);
// general user info
$info['dn'] = $user_result['dn'];
$info['gid'] = $user_result['gidnumber'][0];
$info['mail'] = $user_result['mail'][0];
$info['name'] = $user_result['cn'][0];
$info['grps'] = array();
// overwrite if other attribs are specified.
if (is_array($this->getConf('mapping'))) {
foreach ($this->getConf('mapping') as $localkey => $key) {
if (is_array($key)) {
// use regexp to clean up user_result
list($key, $regexp) = each($key);
if ($user_result[$key]) {
foreach ($user_result[$key] as $grpkey => $grp) {
if ($grpkey !== 'count' && preg_match($regexp, $grp, $match)) {
if ($localkey == 'grps') {
$info[$localkey][] = $match[1];
} else {
$info[$localkey] = $match[1];
}
}
}
}
} else {
$info[$localkey] = $user_result[$key][0];
}
}
}
$user_result = array_merge($info, $user_result);
//get groups for given user if grouptree is given
if ($this->getConf('grouptree') || $this->getConf('groupfilter')) {
$base = $this->_makeFilter($this->getConf('grouptree'), $user_result);
$filter = $this->_makeFilter($this->getConf('groupfilter'), $user_result);
$sr = $this->_ldapsearch($this->con, $base, $filter, $this->getConf('groupscope'), array($this->getConf('groupkey')));
$this->_debug('LDAP group search: ' . htmlspecialchars(ldap_error($this->con)), 0, __LINE__, __FILE__);
$this->_debug('LDAP search at: ' . htmlspecialchars($base . ' ' . $filter), 0, __LINE__, __FILE__);
if (!$sr) {
msg("LDAP: Reading group memberships failed", -1);
$this->_debug('LDAP group search: ' . htmlspecialchars(ldap_error($this->con)), 0, __LINE__, __FILE__);
return false;
}
$result = ldap_get_entries($this->con, $sr);
ldap_free_result($sr);
if (is_array($result)) {
foreach ($result as $grp) {
if (!empty($grp[$this->getConf('groupkey')])) {
$group = $grp[$this->getConf('groupkey')];
if (is_array($group)) {
$group = $group[0];
} else {
//.........这里部分代码省略.........
示例13: ml
/**
* Build a link to a media file
*
* Will return a link to the detail page if $direct is false
*
* The $more parameter should always be given as array, the function then
* will strip default parameters to produce even cleaner URLs
*
* @param string $id the media file id or URL
* @param mixed $more string or array with additional parameters
* @param bool $direct link to detail page if false
* @param string $sep URL parameter separator
* @param bool $abs Create an absolute URL
* @return string
*/
function ml($id = '', $more = '', $direct = true, $sep = '&', $abs = false)
{
global $conf;
$isexternalimage = preg_match('#^(https?|ftp)://#i', $id);
if (!$isexternalimage) {
$id = cleanID($id);
}
if (is_array($more)) {
// add token for resized images
if ($more['w'] || $more['h']) {
$more['tok'] = media_get_token($id, $more['w'], $more['h']);
}
// strip defaults for shorter URLs
if (isset($more['cache']) && $more['cache'] == 'cache') {
unset($more['cache']);
}
if (!$more['w']) {
unset($more['w']);
}
if (!$more['h']) {
unset($more['h']);
}
if (isset($more['id']) && $direct) {
unset($more['id']);
}
$more = buildURLparams($more, $sep);
} else {
$matches = array();
if (preg_match_all('/\\b(w|h)=(\\d*)\\b/', $more, $matches, PREG_SET_ORDER)) {
$resize = array('w' => 0, 'h' => 0);
foreach ($matches as $match) {
$resize[$match[1]] = $match[2];
}
$more .= $sep . 'tok=' . media_get_token($id, $resize['w'], $resize['h']);
}
$more = str_replace('cache=cache', '', $more);
//skip default
$more = str_replace(',,', ',', $more);
$more = str_replace(',', $sep, $more);
}
if ($abs) {
$xlink = DOKU_URL;
} else {
$xlink = DOKU_BASE;
}
// external URLs are always direct without rewriting
if ($isexternalimage) {
$xlink .= 'lib/exe/fetch.php';
// add hash:
$xlink .= '?hash=' . substr(md5(auth_cookiesalt() . $id), 0, 6);
if ($more) {
$xlink .= $sep . $more;
$xlink .= $sep . 'media=' . rawurlencode($id);
} else {
$xlink .= $sep . 'media=' . rawurlencode($id);
}
return $xlink;
}
$id = idfilter($id);
// decide on scriptname
if ($direct) {
if ($conf['userewrite'] == 1) {
$script = '_media';
} else {
$script = 'lib/exe/fetch.php';
}
} else {
if ($conf['userewrite'] == 1) {
$script = '_detail';
} else {
$script = 'lib/exe/detail.php';
}
}
// build URL based on rewrite mode
if ($conf['userewrite']) {
$xlink .= $script . '/' . $id;
if ($more) {
$xlink .= '?' . $more;
}
} else {
if ($more) {
$xlink .= $script . '?' . $more;
$xlink .= $sep . 'media=' . $id;
} else {
$xlink .= $script . '?media=' . $id;
//.........这里部分代码省略.........
示例14: define
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <gohr@cosmocode.de>
*
* Simple redirector script to avoid security warnings when embedding HTTP in SSL secured sites
*
* To avoid open redirects, a secret hash has to be provided
*/
if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__) . '/../../../');
define('NOSESSION', true);
require_once(DOKU_INC . 'inc/init.php');
global $INPUT;
$url = $INPUT->str('url');
$hash = $INPUT->str('hash');
if(!$url) die('sorry. no url');
if(!$hash) die('sorry. no hash');
if($hash != md5(auth_cookiesalt() . 'vshare' . $url)) die('sorry. wrong hash');
send_redirect($url);
示例15: media_get_token
/**
* Calculate a token to be used to verify fetch requests for resized or
* cropped images have been internally generated - and prevent external
* DDOS attacks via fetch
*
* @author Christopher Smith <chris@jalakai.co.uk>
*
* @param string $id id of the image
* @param int $w resize/crop width
* @param int $h resize/crop height
* @return string
*/
function media_get_token($id, $w, $h)
{
// token is only required for modified images
if ($w || $h || media_isexternal($id)) {
$token = $id;
if ($w) {
$token .= '.' . $w;
}
if ($h) {
$token .= '.' . $h;
}
return substr(PassHash::hmac('md5', $token, auth_cookiesalt()), 0, 6);
}
return '';
}