本文整理汇总了PHP中JUserHelper::getShortHashedUserAgent方法的典型用法代码示例。如果您正苦于以下问题:PHP JUserHelper::getShortHashedUserAgent方法的具体用法?PHP JUserHelper::getShortHashedUserAgent怎么用?PHP JUserHelper::getShortHashedUserAgent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUserHelper
的用法示例。
在下文中一共展示了JUserHelper::getShortHashedUserAgent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onUserLogout
public function onUserLogout($options)
{
// No remember me for admin
if ($this->app->isAdmin()) {
return false;
}
$cookieName = JUserHelper::getShortHashedUserAgent();
// Check for the cookie
if ($this->app->input->cookie->get($cookieName)) {
// Make sure authentication group is loaded to process onUserAfterLogout event
JPluginHelper::importPlugin('authentication');
}
}
示例2: onUserLogout
function onUserLogout($user, $options = array())
{
$mainframe = JFactory::getApplication('site');
if (array_key_exists('skip_joomdlehooks', $options)) {
return true;
}
if ($mainframe->isAdmin()) {
return true;
}
$comp_params = JComponentHelper::getParams('com_joomdle');
$redirectless_logout = $comp_params->get('redirectless_logout');
if (!$redirectless_logout) {
// Delete "remember me" cookie if present
$cookieName = JUserHelper::getShortHashedUserAgent();
$cookieValue = $this->app->input->cookie->get($cookieName);
if ($cookieValue) {
$cookieArray = explode('.', $cookieValue);
// Filter series since we're going to use it in the query
$filter = new JFilterInput();
$series = $filter->clean($cookieArray[1], 'ALNUM');
// Remove the record from the database
$query = $this->db->getQuery(true);
$query->delete('#__user_keys')->where($this->db->quoteName('series') . ' = ' . $this->db->quote($series));
$this->db->setQuery($query)->execute();
// Destroy the cookie
$this->app->input->cookie->set($cookieName, false, time() - 42000, $this->app->get('cookie_path', '/'), $this->app->get('cookie_domain'));
}
$moodle_url = $comp_params->get('MOODLE_URL');
$app = JFactory::getApplication();
$app->redirect($moodle_url . "/auth/joomdle/land_logout.php");
return;
}
// if (!array_key_exists ('MoodleSession', $_COOKIE))
// return;
$cookie_path = $comp_params->get('cookie_path', "/");
$old_session = session_id();
session_name("MoodleSession");
session_id("");
@session_destroy();
// session_unregister("USER");
// session_unregister("SESSION");
unset($_SESSION['USER']);
unset($_SESSION['SESSION']);
setcookie('MoodleSession', '', time() - 3600, $cookie_path, '', '', 0);
unset($_SESSION);
return true;
}
示例3: onUserAfterLogin
public function onUserAfterLogin($options)
{
$jcookie = JFactory::getApplication()->input->cookie;
$jcookie->set('fc_uid', JUserHelper::getShortHashedUserAgent(), 0);
}
示例4: onUserAfterLogout
/**
* This is where we delete any authentication cookie when a user logs out
*
* @param array $options Array holding options (length, timeToExpiration)
*
* @return boolean True on success
*
* @since 3.2
*/
public function onUserAfterLogout($options)
{
// No remember me for admin
if ($this->app->isAdmin()) {
return false;
}
$cookieName = JUserHelper::getShortHashedUserAgent();
$cookieValue = $this->app->input->cookie->get($cookieName);
// There are no cookies to delete.
if (!$cookieValue) {
return true;
}
$cookieArray = explode('.', $cookieValue);
// Filter series since we're going to use it in the query
$filter = new JFilterInput();
$series = $filter->clean($cookieArray[1], 'ALNUM');
// Remove the record from the database
$query = $this->db->getQuery(true);
$query->delete('#__user_keys')->where($this->db->quoteName('series') . ' = ' . $this->db->quote($series));
$this->db->setQuery($query)->execute();
// Destroy the cookie
$this->app->input->cookie->set($cookieName, false, time() - 42000, $this->app->get('cookie_path', '/'), $this->app->get('cookie_domain'));
return true;
}
示例5: loadFramework
//.........这里部分代码省略.........
break;
case 'imagesLoaded':
$framework_path = JURI::root(true) . $lib_path . '/imagesLoaded';
$document->addScript($framework_path . '/imagesloaded.pkgd.min.js');
break;
case 'noobSlide':
// Make sure mootools are loaded
FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
$framework_path = JURI::root(true) . $lib_path . '/noobSlide';
//$document->addScript($framework_path.'/_class.noobSlide.js');
$document->addScript($framework_path . '/_class.noobSlide.packed.js');
break;
case 'zTree':
if ($load_jquery) {
flexicontent_html::loadJQuery();
}
$framework_path = JURI::root(true) . $lib_path . '/zTree';
$document->addStyleSheet($framework_path . '/css/flexi_ztree.css');
$document->addStyleSheet($framework_path . '/css/zTreeStyle/zTreeStyle.css');
$document->addScript($framework_path . '/js/jquery.ztree.all-3.5.min.js');
//$document->addScript($framework_path.'/js/jquery.ztree.core-3.5.js');
//$document->addScript($framework_path.'/js/jquery.ztree.excheck-3.5.js');
//$document->addScript($framework_path.'/js/jquery.ztree.exedit-3.5.js');
break;
case 'plupload':
if ($load_jquery) {
flexicontent_html::loadJQuery();
}
$framework_path = JURI::root(true) . $lib_path . '/plupload';
$document->addScript($framework_path . '/js/plupload.full.min.js');
if ($mode == 'ui') {
$document->addStyleSheet($framework_path . '/js/jquery.ui.plupload/css/jquery.ui.plupload.css');
$document->addScript($framework_path . '/js/jquery.ui.plupload/jquery.ui.plupload.min.js');
$document->addScript($framework_path . '/js/themeswitcher.js');
} else {
$document->addStyleSheet($framework_path . '/js/jquery.plupload.queue/css/jquery.plupload.queue.css');
$document->addScript($framework_path . '/js/jquery.plupload.queue/jquery.plupload.queue.js');
}
$lang_code = flexicontent_html::getUserCurrentLang();
if ($lang_code && $lang_code != 'en') {
// Try language shortcode
if (file_exists($framework_folder . DS . 'js' . DS . $lang_code . '.js')) {
$document->addScript($framework_path . '/js/' . $lang_code . '.js');
} else {
$country_code = flexicontent_html::getUserCurrentLang($short_tag = false);
if ($country_code && file_exists($framework_folder . DS . 'js' . DS . $country_code . '.js')) {
$document->addScript($framework_path . '/js/' . $country_code . '.js');
}
}
}
// For debugging
//$document->addScript($framework_path.'/js/moxie.min.js');
//$document->addScript($framework_path.'/js/plupload.dev.js');
break;
case 'nouislider':
$framework_path = JURI::root(true) . $lib_path . '/nouislider';
$document->addStyleSheet($framework_path . '/nouislider.min.css');
$document->addScript($framework_path . '/nouislider.min.js');
break;
case 'flexi_tmpl_common':
if ($load_jquery) {
flexicontent_html::loadJQuery();
}
flexicontent_html::loadFramework('select2');
// make sure select2 is loaded
// Make sure user cookie is set
$jcookie = $app->input->cookie;
$fc_uid = $jcookie->get('fc_uid', null);
$hashedUA = JFactory::getUser()->id ? JUserHelper::getShortHashedUserAgent() : 'p';
if ($fc_uid != $hashedUA) {
$jcookie->set('fc_uid', $hashedUA, 0);
}
$js .= "\n\t\t\t\t\tvar _FC_GET = " . json_encode($_GET) . ";\n\t\t\t\t";
$document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/tmpl-common.js', FLEXI_VERSION);
$document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/jquery-easing.js', FLEXI_VERSION);
JText::script("FLEXI_APPLYING_FILTERING", true);
JText::script("FLEXI_TYPE_TO_LIST", true);
JText::script("FLEXI_TYPE_TO_FILTER", true);
JText::script("FLEXI_UPDATING_CONTENTS", true);
break;
case 'flexi-lib':
if ($load_jquery) {
flexicontent_html::loadJQuery();
}
$document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/flexi-lib.js', FLEXI_VERSION);
JText::script("FLEXI_NOT_AN_IMAGE_FILE", true);
break;
default:
JFactory::getApplication()->enqueueMessage(__FUNCTION__ . ' Cannot load unknown Framework: ' . $framework, 'error');
break;
}
// Add custom JS & CSS code
if ($js) {
$document->addScriptDeclaration($js);
}
if ($css) {
$document->addStyleDeclaration($css);
}
return $_loaded[$framework];
}
示例6: getShortHashedUserAgent
/**
* Helper wrapper method for getShortHashedUserAgent
*
* @return string A hashed user agent string with version replaced by 'abcd'
*
* @see JUserHelper::getShortHashedUserAgent()
* @since 3.4
*/
public function getShortHashedUserAgent()
{
return JUserHelper::getShortHashedUserAgent();
}
示例7: onUserAuthenticate
/**
* This method should handle any authentication and report back to the subject
*
* @param array $credentials Array holding the user credentials
* @param array $options Array of extra options
* @param object &$response Authentication response object
*
* @return boolean
*
* @since 3.2
*/
public function onUserAuthenticate($credentials, $options, &$response)
{
// No remember me for admin
if ($this->app->isAdmin()) {
return false;
}
JLoader::register('JAuthentication', JPATH_LIBRARIES . '/joomla/user/authentication.php');
$response->type = 'Cookie';
// We need to validate the cookie data because there may be no Remember Me plugin to do it.
// Create the cookie name and data.
$rememberArray = JUserHelper::getRememberCookieData();
if ($rememberArray == false) {
return false;
}
list($privateKey, $series, $uastring) = $rememberArray;
// Find the matching record if it exists.
$query = $this->db->getQuery(true)->select($this->db->quoteName(array('user_id', 'token', 'series', 'time', 'invalid')))->from($this->db->quoteName('#__user_keys'))->where($this->db->quoteName('series') . ' = ' . $this->db->quote(base64_encode($series)))->where($this->db->quoteName('uastring') . ' = ' . $this->db->quote($uastring))->order($this->db->quoteName('time') . ' DESC');
$results = $this->db->setQuery($query)->loadObjectList();
$countResults = count($results);
if ($countResults !== 1) {
$response->status = JAuthentication::STATUS_FAILURE;
return;
} else {
if (substr($results[0]->token, 0, 4) === '$2y$') {
if (JCrypt::hasStrongPasswordSupport()) {
$match = password_verify($privateKey, $results[0]->token);
}
} else {
if (JCrypt::timingSafeCompare($results[0]->token, $privateKey)) {
$match = true;
}
}
if (empty($match)) {
JUserHelper::invalidateCookie($results[0]->user_id, $uastring);
JLog::add(JText::sprintf('PLG_SYSTEM_REMEMBER_ERROR_LOG_LOGIN_FAILED', $user->username), JLog::WARNING, 'security');
$response->status = JAuthentication::STATUS_FAILURE;
return false;
}
}
// Set cookie params.
if (!empty($options['lifetime']) && !empty($options['length']) && !empty($options['secure'])) {
$response->lifetime = $options['lifetime'];
$response->length = $options['length'];
$response->secure = $options['secure'];
}
// Make sure there really is a user with this name and get the data for the session.
$query = $this->db->getQuery(true)->select($this->db->quoteName(array('id', 'username', 'password')))->from($this->db->quoteName('#__users'))->where($this->db->quoteName('username') . ' = ' . $this->db->quote($credentials['username']));
$result = $this->db->setQuery($query)->loadObject();
if ($result) {
// Bring this in line with the rest of the system
$user = JUser::getInstance($result->id);
$cookieName = JUserHelper::getShortHashedUserAgent();
// If there is no cookie, bail out
if (!$this->app->input->cookie->get($cookieName)) {
return;
}
// Set response data.
$response->username = $result->username;
$response->email = $user->email;
$response->fullname = $user->name;
$response->password = $result->password;
$response->language = $user->getParam('language');
// Set response status.
$response->status = JAuthentication::STATUS_SUCCESS;
$response->error_message = '';
} else {
$response->status = JAuthentication::STATUS_FAILURE;
$response->error_message = JText::_('JGLOBAL_AUTH_NO_USER');
}
}
示例8: onUserAfterLogin
/**
* We set the authentication cookie only after login is successfullly finished.
* We set a new cookie either for a user with no cookies or one
* where the user used a cookie to authenticate.
*
* @param array $options Array holding options
*
* @return boolean True on success
*
* @since 3.2
*/
public function onUserAfterLogin($options)
{
// Currently this portion of the method only applies to Cookie based login.
if (!isset($options['responseType']) || $options['responseType'] != 'Cookie' && empty($options['remember'])) {
return true;
}
// We get the parameter values differently for cookie and non-cookie logins.
$cookieLifetime = empty($options['lifetime']) ? $this->app->rememberCookieLifetime : $options['lifetime'];
$length = empty($options['length']) ? $this->app->rememberCookieLength : $options['length'];
$secure = empty($options['secure']) ? $this->app->rememberCookieSecure : $options['secure'];
// We need the old data to match against the current database
$rememberArray = JUserHelper::getRememberCookieData();
$privateKey = JUserHelper::genRandomPassword($length);
// We are going to concatenate with . so we need to remove it from the strings.
$privateKey = str_replace('.', '', $privateKey);
$cryptedKey = JUserHelper::getCryptedPassword($privateKey, '', 'bcrypt', false);
$cookieName = JUserHelper::getShortHashedUserAgent();
// Create an identifier and make sure that it is unique.
$unique = false;
do {
// Unique identifier for the device-user
$series = JUserHelper::genRandomPassword(20);
// We are going to concatenate with . so we need to remove it from the strings.
$series = str_replace('.', '', $series);
$query = $this->db->getQuery(true)->select($this->db->quoteName('series'))->from($this->db->quoteName('#__user_keys'))->where($this->db->quoteName('series') . ' = ' . $this->db->quote(base64_encode($series)));
$results = $this->db->setQuery($query)->loadResult();
if (is_null($results)) {
$unique = true;
}
} while ($unique === false);
// If a user logs in with non cookie login and remember me checked we will
// delete any invalid entries so that he or she can use remember once again.
if ($options['responseType'] !== 'Cookie') {
$query = $this->db->getQuery(true)->delete('#__user_keys')->where($this->db->quoteName('uastring') . ' = ' . $this->db->quote($cookieName))->where($this->db->quoteName('user_id') . ' = ' . $this->db->quote($options['user']->username));
$this->db->setQuery($query)->execute();
}
$cookieValue = $cryptedKey . '.' . $series . '.' . $cookieName;
// Destroy the old cookie.
$this->app->input->cookie->set($cookieName, false, time() - 42000, $this->app->get('cookie_path'), $this->app->get('cookie_domain'));
// And make a new one.
$this->app->input->cookie->set($cookieName, $cookieValue, $cookieLifetime, $this->app->get('cookie_path'), $this->app->get('cookie_domain'), $secure);
$query = $this->db->getQuery(true);
if (empty($options['user']->cookieLogin) || $options['responseType'] != 'Cookie') {
// For users doing login from Joomla or other systems
$query->insert($this->db->quoteName('#__user_keys'));
} else {
$query->update($this->db->quoteName('#__user_keys'))->where($this->db->quoteName('user_id') . ' = ' . $this->db->quote($options['user']->username))->where($this->db->quoteName('series') . ' = ' . $this->db->quote(base64_encode($rememberArray[1])))->where($this->db->quoteName('uastring') . ' = ' . $this->db->quote($cookieName));
}
$query->set($this->db->quoteName('user_id') . ' = ' . $this->db->quote($options['user']->username))->set($this->db->quoteName('time') . ' = ' . $cookieLifetime)->set($this->db->quoteName('token') . ' = ' . $this->db->quote($cryptedKey))->set($this->db->quoteName('series') . ' = ' . $this->db->quote(base64_encode($series)))->set($this->db->quoteName('invalid') . ' = 0')->set($this->db->quoteName('uastring') . ' = ' . $this->db->quote($cookieName));
$this->db->setQuery($query)->execute();
return true;
}