本文整理汇总了PHP中JUtility::getHash方法的典型用法代码示例。如果您正苦于以下问题:PHP JUtility::getHash方法的具体用法?PHP JUtility::getHash怎么用?PHP JUtility::getHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUtility
的用法示例。
在下文中一共展示了JUtility::getHash方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAfterInitialise
function onAfterInitialise()
{
$app = JFactory::getApplication();
// No remember me for admin
if ($app->isAdmin()) {
return;
}
$user = JFactory::getUser();
if ($user->get('guest')) {
jimport('joomla.utilities.utility');
$hash = JUtility::getHash('JLOGIN_REMEMBER');
if ($str = JRequest::getString($hash, '', 'cookie', JREQUEST_ALLOWRAW | JREQUEST_NOTRIM)) {
jimport('joomla.utilities.simplecrypt');
//Create the encryption key, apply extra hardening using the user agent string
$key = JUtility::getHash(@$_SERVER['HTTP_USER_AGENT']);
$crypt = new JSimpleCrypt($key);
$str = $crypt->decrypt($str);
$options = array();
$options['silent'] = true;
if (!$app->login(@unserialize($str), $options)) {
$config = JFactory::getConfig();
$cookie_domain = $config->get('cookie_domain', '');
$cookie_path = $config->get('cookie_path', '/');
// Clear the remember me cookie
setcookie(JUtility::getHash('JLOGIN_REMEMBER'), false, time() - 86400, $cookie_path, $cookie_domain);
}
}
}
}
示例2: getHash
public function getHash($seed = '')
{
if (DiscussHelper::getJoomlaVersion() >= '2.5') {
return JApplication::getHash($seed);
}
return JUtility::getHash($seed);
}
示例3: requestReset
/**
* Verifies the validity of a username/e-mail address
* combination and creates a token to verify the request
* was initiated by the account owner. The token is
* sent to the account owner by e-mail
*
* @since 1.5
* @param string Username string
* @param string E-mail address
* @return bool True on success/false on failure
*/
function requestReset($email)
{
jimport('joomla.mail.helper');
jimport('joomla.user.helper');
$db =& JFactory::getDBO();
// Make sure the e-mail address is valid
if (!JMailHelper::isEmailAddress($email)) {
$this->setError(JText::_('INVALID_EMAIL_ADDRESS'));
return false;
}
// Build a query to find the user
$query = 'SELECT id FROM #__users' . ' WHERE email = ' . $db->Quote($email) . ' AND block = 0';
$db->setQuery($query);
// Check the results
if (!($id = $db->loadResult())) {
$this->setError(JText::_('COULD_NOT_FIND_USER'));
return false;
}
// Generate a new token
$token = JUtility::getHash(JUserHelper::genRandomPassword());
$salt = JUserHelper::getSalt('crypt-md5');
$hashedToken = md5($token . $salt) . ':' . $salt;
$query = 'UPDATE #__users' . ' SET activation = ' . $db->Quote($hashedToken) . ' WHERE id = ' . (int) $id . ' AND block = 0';
$db->setQuery($query);
// Save the token
if (!$db->query()) {
$this->setError(JText::_('DATABASE_ERROR'));
return false;
}
// Send the token to the user via e-mail
if (!$this->_sendConfirmationMail($email, $token)) {
return false;
}
return true;
}
示例4: alreadyVoted
function alreadyVoted($id)
{
$mainframe = JFactory::getApplication();
$cookieName = JUtility::getHash($mainframe->getName() . 'poll' . $id);
$voted = JRequest::getVar($cookieName, '0', 'COOKIE', 'INT');
return $voted;
}
示例5: parseLang
public function parseLang($vars)
{
if (Mijosef::getConfig()->multilang == 0) {
return;
}
if (empty($vars['lang'])) {
$lang = JRequest::getWord('lang', '');
if (empty($lang)) {
return;
}
$vars['lang'] = $lang;
}
$languages = JLanguageHelper::getLanguages('sef');
$lang_code = $languages[$vars['lang']]->lang_code;
// if current language, don't bother
if ($lang_code == JFactory::getLanguage()->getTag()) {
//self::checkHomepage($vars['lang']);
return;
}
// Create a cookie
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('config.cookie_domain', '');
$cookie_path = $conf->get('config.cookie_path', '/');
setcookie(JUtility::getHash('language'), $lang_code, time() + 365 * 86400, $cookie_path, $cookie_domain);
// set the request var
JRequest::setVar('language', $lang_code);
// set current language
jimport('joomla.language.language');
$conf = JFactory::getConfig();
$debug = $conf->get('debug_lang');
$lang = JLanguage::getInstance($lang_code, $debug);
JFactory::$language = $lang;
self::$_lang = $vars['lang'];
}
示例6: populateState
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState()
{
jimport('joomla.utilities.utility');
$basename = JRequest::getString(JUtility::getHash($this->_context . '.basename'), '__SITE__', 'cookie');
$this->setState('basename', $basename);
$compressed = JRequest::getInt(JUtility::getHash($this->_context . '.compressed'), 1, 'cookie');
$this->setState('compressed', $compressed);
}
示例7: requiresActivation
/**
* Automatically sets the activation token for the user.
*
* @return LibUsersDomainEntityUser
*/
public function requiresActivation()
{
jimport('joomla.user.helper');
$token = JUtility::getHash(JUserHelper::genRandomPassword());
$salt = JUserHelper::getSalt();
$hashedToken = sha1($token . $salt) . ':' . $salt;
$this->activation = $hashedToken;
return $this;
}
示例8: alreadyVoted
function alreadyVoted($id)
{
$mainframe = JFactory::getApplication();
if (MijopollsHelper::is30()) {
$cookieName = JApplication::getHash($mainframe->getName() . 'poll' . $id);
} else {
$cookieName = JUtility::getHash($mainframe->getName() . 'poll' . $id);
}
$voted = JRequest::getVar($cookieName, '0', 'COOKIE', 'INT');
return $voted;
}
示例9: getName
static function getName()
{
$clientId = JRequest::getInt('client', 0, 'get');
$client = $clientId ? 'administrator' : 'site';
$hash = '';
if (method_exists('JUtility', 'getHash')) {
$hash = JUtility::getHash($client);
} else {
$hash = JApplication::getHash($client);
}
return $hash;
}
示例10: onUserLogout
/**
* This method should handle any logout logic and report back to the subject
*
* @param array $user Holds the user data.
* @param array $options Array holding options (client, ...).
*
* @return object True on success
* @since 1.5
*/
public function onUserLogout($user, $options = array())
{
if (JFactory::getApplication()->isSite()) {
// Create the cookie
$hash = JUtility::getHash('plgSystemLogout');
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('config.cookie_domain', '');
$cookie_path = $conf->get('config.cookie_path', '/');
setcookie($hash, true, time() + 86400, $cookie_path, $cookie_domain);
}
return true;
}
示例11: getToken
public function getToken()
{
$session = JFactory::getSession();
$user = JFactory::getUser();
$token = $session->get('session.token', null, 'wf');
//create a token
if ($token === null) {
$token = self::_createToken(12);
$session->set('session.token', $token, 'wf');
}
$hash = 'wf' . JUtility::getHash($user->get('id', 0) . $token);
return $hash;
}
示例12: getToken
public function getToken()
{
$session =& JFactory::getSession();
$user =& JFactory::getUser();
//$plugin = JRequest::getVar('plugin');
$token = $session->get('session.token', null, 'jce');
//create a token
if ($token === null) {
$token = self::_createToken(12);
$session->set('session.token', $token, 'jce');
}
$hash = 'jce' . JUtility::getHash($user->get('id', 0) . $token);
return $hash;
}
示例13: onAfterInitialise
function onAfterInitialise()
{
$app = JFactory::getApplication();
// No remember me for admin
if ($app->isAdmin()) {
return;
}
$user = JFactory::getUser();
if ($user->get('guest')) {
jimport('joomla.utilities.utility');
$hash = JUtility::getHash('JLOGIN_REMEMBER');
if ($str = JRequest::getString($hash, '', 'cookie', JREQUEST_ALLOWRAW | JREQUEST_NOTRIM)) {
jimport('joomla.utilities.simplecrypt');
// Create the encryption key, apply extra hardening using the user agent string.
// Since we're decoding, no UA validity check is required.
$key = JUtility::getHash(@$_SERVER['HTTP_USER_AGENT']);
$crypt = new JSimpleCrypt($key);
$str = $crypt->decrypt($str);
$cookieData = @unserialize($str);
// Deserialized cookie could be any object structure, so make sure the
// credentials are well structured and only have user and password.
$credentials = array();
$filter = JFilterInput::getInstance();
$goodCookie = true;
if (is_array($credentials)) {
if (isset($cookieData['username']) && is_string($cookieData['username'])) {
$credentials['username'] = $filter->clean($cookieData['username'], 'username');
} else {
$goodCookie = false;
}
if (isset($cookieData['password']) && is_string($cookieData['password'])) {
$credentials['password'] = $filter->clean($cookieData['password'], 'string');
} else {
$goodCookie = false;
}
} else {
$goodCookie = false;
}
if (!$goodCookie || !$app->login($credentials, array('silent' => true))) {
$config = JFactory::getConfig();
$cookie_domain = $config->get('cookie_domain', '');
$cookie_path = $config->get('cookie_path', '/');
// Clear the remember me cookie
setcookie(JUtility::getHash('JLOGIN_REMEMBER'), false, time() - 86400, $cookie_path, $cookie_domain);
}
}
}
}
示例14: vote
/**
* Add a vote to an option
*/
function vote()
{
global $mainframe;
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
// Captcha Controller Patch rev. 4.5.0 Stable
$dispatcher =& JDispatcher::getInstance();
$results = $dispatcher->trigger('onCaptchaRequired', array('user.poll'));
if ($results[0]) {
$captchaparams = array(JRequest::getVar('captchacode', '', 'post'), JRequest::getVar('captchasuffix', '', 'post'), JRequest::getVar('captchasessionid', '', 'post'));
$results = $dispatcher->trigger('onCaptchaVerify', $captchaparams);
if (!$results[0]) {
JError::raiseWarning('CAPTHCA', JText::_('CAPTCHACODE_DO_NOT_MATCH'));
$this->display();
return false;
}
}
$db =& JFactory::getDBO();
$poll_id = JRequest::getVar('id', 0, '', 'int');
$option_id = JRequest::getVar('voteid', 0, 'post', 'int');
$poll =& JTable::getInstance('poll', 'Table');
if (!$poll->load($poll_id) || $poll->published != 1) {
JError::raiseWarning(404, JText::_('ALERTNOTAUTH'));
return;
}
$cookieName = JUtility::getHash($mainframe->getName() . 'poll' . $poll_id);
// ToDo - may be adding those information to the session?
$voted = JRequest::getVar($cookieName, '0', 'COOKIE', 'INT');
if ($voted || !$option_id) {
if ($voted) {
$msg = JText::_('You already voted for this poll today!');
}
if (!$option_id) {
$msg = JText::_('WARNSELECT');
}
} else {
setcookie($cookieName, '1', time() + $poll->lag);
require_once JPATH_COMPONENT . DS . 'models' . DS . 'poll.php';
$model = new PollModelPoll();
$model->vote($poll_id, $option_id);
$msg = JText::_('Thanks for your vote!');
}
// set Itemid id for links
$menu =& JSite::getMenu();
$items = $menu->getItems('link', 'index.php?option=com_poll&view=poll');
$itemid = isset($items[0]) ? '&Itemid=' . $items[0]->id : '';
$this->setRedirect(JRoute::_('index.php?option=com_poll&id=' . $poll_id . ':' . $poll->alias . $itemid, false), $msg);
}
示例15: getToken
public static function getToken()
{
$session = JFactory::getSession();
$user = JFactory::getUser();
$token = $session->get('session.token', null, 'wf');
//create a token
if ($token === null) {
$token = self::_createToken(12);
$session->set('session.token', $token, 'wf');
}
if (method_exists('JApplication', 'getHash')) {
return 'wf' . JApplication::getHash($user->get('id', 0) . $token);
} else {
return 'wf' . JUtility::getHash($user->get('id', 0) . $token);
}
}