first commit

This commit is contained in:
alazhar
2020-01-02 22:20:31 +07:00
commit 10eb3340ad
5753 changed files with 631345 additions and 0 deletions

113
plugins/system/cache/cache.php vendored Normal file
View File

@ -0,0 +1,113 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage System.cache
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Joomla! Page Cache Plugin
*
* @package Joomla.Plugin
* @subpackage System.cache
*/
class PlgSystemCache extends JPlugin
{
var $_cache = null;
var $_cache_key = null;
/**
* Constructor
*
* @access protected
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.0
*/
function __construct(& $subject, $config)
{
parent::__construct($subject, $config);
//Set the language in the class
$options = array(
'defaultgroup' => 'page',
'browsercache' => $this->params->get('browsercache', false),
'caching' => false,
);
$this->_cache = JCache::getInstance('page', $options);
$this->_cache_key = JUri::getInstance()->toString();
}
/**
* Converting the site URL to fit to the HTTP request
*
*/
function onAfterInitialise()
{
global $_PROFILER;
$app = JFactory::getApplication();
$user = JFactory::getUser();
if ($app->isAdmin())
{
return;
}
if (count($app->getMessageQueue()))
{
return;
}
if ($user->get('guest') && $app->input->getMethod() == 'GET')
{
$this->_cache->setCaching(true);
}
$data = $this->_cache->get($this->_cache_key);
if ($data !== false)
{
// Set cached body
JResponse::setBody($data);
echo JResponse::toString($app->getCfg('gzip'));
if (JDEBUG)
{
$_PROFILER->mark('afterCache');
}
$app->close();
}
}
function onAfterRender()
{
$app = JFactory::getApplication();
if ($app->isAdmin())
{
return;
}
if (count($app->getMessageQueue()))
{
return;
}
$user = JFactory::getUser();
if ($user->get('guest'))
{
// We need to check again here, because auto-login plugins have not been fired before the first aid check
$this->_cache->store(null, $this->_cache_key);
}
}
}

39
plugins/system/cache/cache.xml vendored Normal file
View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="system">
<name>plg_system_cache</name>
<author>Joomla! Project</author>
<creationDate>February 2007</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_CACHE_XML_DESCRIPTION</description>
<files>
<filename plugin="cache">cache.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_system_cache.ini</language>
<language tag="en-GB">en-GB.plg_system_cache.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="browsercache" type="radio"
class="btn-group"
default="0"
description="PLG_CACHE_FIELD_BROWSERCACHE_DESC"
label="PLG_CACHE_FIELD_BROWSERCACHE_LABEL"
>
<option
value="0">JNO</option>
<option
value="1">JYES</option>
</field>
</fieldset>
</fields>
</config>
</extension>

1
plugins/system/cache/index.html vendored Normal file
View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,183 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="system">
<name>plg_system_debug</name>
<author>Joomla! Project</author>
<creationDate>December 2006</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_DEBUG_XML_DESCRIPTION</description>
<files>
<filename plugin="debug">debug.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_system_debug.ini</language>
<language tag="en-GB">en-GB.plg_system_debug.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="filter_groups" type="usergroup"
description="PLG_DEBUG_FIELD_ALLOWED_GROUPS_DESC"
label="PLG_DEBUG_FIELD_ALLOWED_GROUPS_LABEL"
multiple="true"
size="10"
/>
<field name="profile" type="radio"
class="btn-group"
default="1"
description="PLG_DEBUG_FIELD_PROFILING_DESC"
label="PLG_DEBUG_FIELD_PROFILING_LABEL"
>
<option value="1">JYes</option>
<option value="0">JNo</option>
</field>
<field name="queries" type="radio"
class="btn-group"
default="1"
description="PLG_DEBUG_FIELD_QUERIES_DESC"
label="PLG_DEBUG_FIELD_QUERIES_LABEL"
>
<option value="1">JYes</option>
<option value="0">JNo</option>
</field>
<field name="query_types" type="radio"
class="btn-group"
default="1"
description="PLG_DEBUG_FIELD_QUERY_TYPES_DESC"
label="PLG_DEBUG_FIELD_QUERY_TYPES_LABEL"
>
<option value="1">JYes</option>
<option value="0">JNo</option>
</field>
<field name="memory" type="radio"
class="btn-group"
default="1"
description="PLG_DEBUG_FIELD_MEMORY_DESC"
label="PLG_DEBUG_FIELD_MEMORY_LABEL"
>
<option value="1">JYes</option>
<option value="0">JNo</option>
</field>
<field name="logs" type="radio"
class="btn-group"
default="1"
description="PLG_DEBUG_FIELD_LOGS_DESC"
label="PLG_DEBUG_FIELD_LOGS_LABEL"
>
<option value="1">JYes</option>
<option value="0">JNo</option>
</field>
<field name="log_priorities" type="list" multiple="true" default="all"
label="PLG_DEBUG_FIELD_LOG_PRIORITIES_LABEL"
description="PLG_DEBUG_FIELD_LOG_PRIORITIES_DESC"
>
<option value="all">PLG_DEBUG_FIELD_LOG_PRIORITIES_ALL</option>
<option value="emergency">PLG_DEBUG_FIELD_LOG_PRIORITIES_EMERGENCY</option>
<option value="alert">PLG_DEBUG_FIELD_LOG_PRIORITIES_ALERT</option>
<option value="critical">PLG_DEBUG_FIELD_LOG_PRIORITIES_CRITICAL</option>
<option value="error">PLG_DEBUG_FIELD_LOG_PRIORITIES_ERROR</option>
<option value="warning">PLG_DEBUG_FIELD_LOG_PRIORITIES_WARNING</option>
<option value="notice">PLG_DEBUG_FIELD_LOG_PRIORITIES_NOTICE</option>
<option value="info">PLG_DEBUG_FIELD_LOG_PRIORITIES_INFO</option>
<option value="debug">PLG_DEBUG_FIELD_LOG_PRIORITIES_DEBUG</option>
</field>
<field name="log_categories" type="text" size="60" default=""
label="PLG_DEBUG_FIELD_LOG_CATEGORIES_LABEL"
description="PLG_DEBUG_FIELD_LOG_CATEGORIES_DESC"
/>
<field name="log_category_mode" type="hidden" default="0"
label="PLG_DEBUG_FIELD_LOG_CATEGORY_MODE_LABEL"
description="PLG_DEBUG_FIELD_LOG_CATEGORY_MODE_DESC"
>
<option value="0">PLG_DEBUG_FIELD_LOG_CATEGORY_MODE_INCLUDE</option>
<option value="1">PLG_DEBUG_FIELD_LOG_CATEGORY_MODE_EXCLUDE</option>
</field>
</fieldset>
<fieldset name="language"
label="PLG_DEBUG_LANGUAGE_FIELDSET_LABEL">
<field name="language_errorfiles" type="radio"
class="btn-group"
default="1"
description="PLG_DEBUG_FIELD_LANGUAGE_ERRORFILES_DESC"
label="PLG_DEBUG_FIELD_LANGUAGE_ERRORFILES_LABEL"
>
<option value="1">JYes</option>
<option value="0">JNo</option>
</field>
<field name="language_files" type="radio"
class="btn-group"
default="1"
description="PLG_DEBUG_FIELD_LANGUAGE_FILES_DESC"
label="PLG_DEBUG_FIELD_LANGUAGE_FILES_LABEL"
>
<option value="1">JYes</option>
<option value="0">JNo</option>
</field>
<field name="language_strings" type="radio"
class="btn-group"
default="1"
description="PLG_DEBUG_FIELD_LANGUAGE_STRING_DESC"
label="PLG_DEBUG_FIELD_LANGUAGE_STRING_LABEL"
>
<option value="1">JYes</option>
<option value="0">JNo</option>
</field>
<field name="strip-first" type="radio"
class="btn-group"
default="1"
description="PLG_DEBUG_FIELD_STRIP_FIRST_DESC"
label="PLG_DEBUG_FIELD_STRIP_FIRST_LABEL"
>
<option value="1">JYes</option>
<option value="0">JNo</option>
</field>
<field name="strip-prefix" type="textarea"
cols="30"
description="PLG_DEBUG_FIELD_STRIP_PREFIX_DESC"
label="PLG_DEBUG_FIELD_STRIP_PREFIX_LABEL"
rows="4"
/>
<field name="strip-suffix" type="textarea"
cols="30"
description="PLG_DEBUG_FIELD_STRIP_SUFFIX_DESC"
label="PLG_DEBUG_FIELD_STRIP_SUFFIX_LABEL"
rows="4"
/>
</fieldset>
<fieldset name="logging"
label="PLG_DEBUG_LOGGING_FIELDSET_LABEL">
<field name="log-deprecated" type="radio"
class="btn-group"
default="0"
description="PLG_DEBUG_FIELD_LOG_DEPRECATED_DESC"
label="PLG_DEBUG_FIELD_LOG_DEPRECATED_LABEL"
>
<option value="1">JYes</option>
<option value="0">JNo</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,86 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage System.Highlight
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_BASE') or die;
/**
* System plugin to highlight terms.
*
* @package Joomla.Plugin
* @subpackage System.Highlight
* @since 2.5
*/
class PlgSystemHighlight extends JPlugin
{
/**
* Method to catch the onAfterDispatch event.
*
* This is where we setup the click-through content highlighting for.
* The highlighting is done with JavaScript so we just
* need to check a few parameters and the JHtml behavior will do the rest.
*
* @return boolean True on success
*
* @since 2.5
*/
public function onAfterDispatch()
{
// Check that we are in the site application.
if (JFactory::getApplication()->isAdmin())
{
return true;
}
// Set the variables
$input = JFactory::getApplication()->input;
$extension = $input->get('option', '', 'cmd');
// Check if the highlighter is enabled.
if (!JComponentHelper::getParams($extension)->get('highlight_terms', 1))
{
return true;
}
// Check if the highlighter should be activated in this environment.
if (JFactory::getDocument()->getType() !== 'html' || $input->get('tmpl', '', 'cmd') === 'component')
{
return true;
}
// Get the terms to highlight from the request.
$terms = $input->request->get('highlight', null, 'base64');
$terms = $terms ? json_decode(base64_decode($terms)) : null;
// Check the terms.
if (empty($terms))
{
return true;
}
// Clean the terms array
$filter = JFilterInput::getInstance();
$cleanTerms = array();
foreach ($terms as $term)
{
$cleanTerms[] = htmlspecialchars($filter->clean($term, 'string'));
}
// Activate the highlighter.
JHtml::_('behavior.highlighter', $cleanTerms);
// Adjust the component buffer.
$doc = JFactory::getDocument();
$buf = $doc->getBuffer('component');
$buf = '<br id="highlighter-start" />' . $buf . '<br id="highlighter-end" />';
$doc->setBuffer($buf, 'component');
return true;
}
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="system" method="upgrade">
<name>plg_system_highlight</name>
<author>Joomla! Project</author>
<creationDate>August 2011</creationDate>
<copyright>(C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_SYSTEM_HIGHLIGHT_XML_DESCRIPTION</description>
<scriptfile>script.php</scriptfile>
<files>
<file plugin="highlight">highlight.php</file>
<filename>index.html</filename>
<folder>media</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/en-GB.plg_system_highlight.ini</language>
<language tag="en-GB">language/en-GB/en-GB.plg_system_highlight.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

1075
plugins/system/k2/k2.php Normal file

File diff suppressed because it is too large Load Diff

15
plugins/system/k2/k2.xml Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="system" method="upgrade">
<name>System - K2</name>
<author>JoomlaWorks</author>
<creationDate>July 8th, 2013</creationDate>
<copyright>Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.</copyright>
<authorEmail>please-use-the-contact-form@joomlaworks.net</authorEmail>
<authorUrl>www.joomlaworks.net</authorUrl>
<version>2.6.7</version>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<description>K2_THE_K2_SYSTEM_PLUGIN_IS_USED_TO_ASSIST_THE_PROPER_FUNCTIONALITY_OF_THE_K2_COMPONENT_SITE_WIDE_MAKE_SURE_ITS_ALWAYS_PUBLISHED_WHEN_THE_K2_COMPONENT_IS_INSTALLED</description>
<files>
<filename plugin="k2">k2.php</filename>
</files>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,10 @@
; Joomla! Project
; Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8
PLG_SYSTEM_LANGUAGECODE="System - Language Code"
PLG_SYSTEM_LANGUAGECODE_FIELD_DESC="Changes the language code used for the <em>%s</em> language"
PLG_SYSTEM_LANGUAGECODE_FIELDSET_DESC="Changes the language code for the generated HTML document. Example of use: One has installed the fr-FR language pack and wants the Search Engines to recognise the page as aimed at French-speaking Canada. Add the tag 'fr-CA' to the corresponding field for 'fr-FR' to resolve this."
PLG_SYSTEM_LANGUAGECODE_FIELDSET_LABEL="Language codes"
PLG_SYSTEM_LANGUAGECODE_XML_DESCRIPTION="Provides the ability to change the language code in the generated HTML document to improve SEO.<br />The fields will appear when the plugin is enabled and saved.<br />More information at <a href="_QQ_"http://www.w3.org/TR/xhtml1/#docconf"_QQ_">W3.org</a> "

View File

@ -0,0 +1,8 @@
; Joomla! Project
; Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8
PLG_SYSTEM_LANGUAGECODE="System - Language Code"
PLG_SYSTEM_LANGUAGECODE_XML_DESCRIPTION="Provides ability to change the language code in the generated HTML document to improve SEO"

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,149 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage System.languagecode
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Language Code plugin class.
*
* @package Joomla.Plugin
* @subpackage Content.languagecode
* @since 2.5
*/
class PlgSystemLanguagecode extends JPlugin
{
/**
* Plugin that change the language code used in the <html /> tag
*
* @since 2.5
*/
public function onAfterRender()
{
// Use this plugin only in site application
if (JFactory::getApplication()->isSite())
{
// Get the response body
$body = JResponse::getBody();
// Get the current language code
$code = JFactory::getDocument()->getLanguage();
// Get the new code
$new_code = $this->params->get($code);
// Replace the old code by the new code in the <html /> tag
if ($new_code)
{
// Replace the new code in the HTML document
$patterns = array(
chr(1) . '(<html.*\s+xml:lang=")(' . $code . ')(".*>)' . chr(1) . 'i',
chr(1) . '(<html.*\s+lang=")(' . $code . ')(".*>)' . chr(1) . 'i',
);
$replace = array(
'${1}' . strtolower($new_code) . '${3}',
'${1}' . strtolower($new_code) . '${3}'
);
}
else
{
$patterns = array();
$replace = array();
}
// Replace codes in <link hreflang="" /> attributes
preg_match_all(chr(1) . '(<link.*\s+hreflang=")([0-9a-z\-]*)(".*\s+rel="alternate".*/>)' . chr(1) . 'i', $body, $matches);
foreach ($matches[2] as $match)
{
$new_code = $this->params->get(strtolower($match));
if ($new_code)
{
$patterns[] = chr(1) . '(<link.*\s+hreflang=")(' . $match . ')(".*\s+rel="alternate".*/>)' . chr(1) . 'i';
$replace[] = '${1}' . $new_code . '${3}';
}
}
preg_match_all(chr(1) . '(<link.*\s+rel="alternate".*\s+hreflang=")([0-9A-Za-z\-]*)(".*/>)' . chr(1) . 'i', $body, $matches);
foreach ($matches[2] as $match)
{
$new_code = $this->params->get(strtolower($match));
if ($new_code)
{
$patterns[] = chr(1) . '(<link.*\s+rel="alternate".*\s+hreflang=")(' . $match . ')(".*/>)' . chr(1) . 'i';
$replace[] = '${1}' . $new_code . '${3}';
}
}
JResponse::setBody(preg_replace($patterns, $replace, $body));
}
}
/**
* @param JForm $form The form to be altered.
* @param array $data The associated data for the form.
*
* @return boolean
* @since 2.5
*/
public function onContentPrepareForm($form, $data)
{
// Ensure that data is an object
$data = (object) $data;
// Check we have a form
if (!($form instanceof JForm))
{
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
// Check we are manipulating a valid form.
$app = JFactory::getApplication();
if ($form->getName() != 'com_plugins.plugin'
|| isset($data->name) && $data->name != 'plg_system_languagecode'
|| empty($data) && !$app->getUserState('plg_system_language_code.edit')
)
{
return true;
}
// Mark the plugin as being edited
$app->setUserState('plg_system_language_code.edit', $data->name == 'plg_system_languagecode');
// Get site languages
if ($languages = JLanguage::getKnownLanguages(JPATH_SITE))
{
// Inject fields into the form
foreach ($languages as $tag => $language)
{
$form->load('
<form>
<fields name="params">
<fieldset
name="languagecode"
label="PLG_SYSTEM_LANGUAGECODE_FIELDSET_LABEL"
description="PLG_SYSTEM_LANGUAGECODE_FIELDSET_DESC"
>
<field
name="'.strtolower($tag).'"
type="text"
description="' . htmlspecialchars(JText::sprintf('PLG_SYSTEM_LANGUAGECODE_FIELD_DESC', $language['name']), ENT_COMPAT, 'UTF-8') . '"
translate_description="false"
label="' . $tag . '"
translate_label="false"
size="7"
filter="cmd"
/>
</fieldset>
</fields>
</form>
');
}
}
return true;
}
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="system">
<name>plg_system_languagecode</name>
<author>Joomla! Project</author>
<creationDate>November 2011</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_SYSTEM_LANGUAGECODE_XML_DESCRIPTION</description>
<files>
<filename plugin="languagecode">languagecode.php</filename>
<filename>index.html</filename>
<folder>language</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/en-GB.plg_system_languagecode.ini</language>
<language tag="en-GB">language/en-GB/en-GB.plg_system_languagecode.sys.ini</language>
</languages>
<config />
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,640 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage System.languagefilter
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');
JLoader::register('MultilangstatusHelper', JPATH_ADMINISTRATOR.'/components/com_languages/helpers/multilangstatus.php');
/**
* Joomla! Language Filter Plugin
*
* @package Joomla.Plugin
* @subpackage System.languagefilter
* @since 1.6
*/
class PlgSystemLanguageFilter extends JPlugin
{
protected static $mode_sef;
protected static $tag;
protected static $sefs;
protected static $lang_codes;
protected static $homes;
protected static $default_lang;
protected static $default_sef;
protected static $cookie;
private static $_user_lang_code;
public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
// Ensure that constructor is called one time
self::$cookie = SID == '';
if (!self::$default_lang)
{
$app = JFactory::getApplication();
$router = $app->getRouter();
if ($app->isSite())
{
// setup language data
self::$mode_sef = ($router->getMode() == JROUTER_MODE_SEF) ? true : false;
self::$sefs = JLanguageHelper::getLanguages('sef');
self::$lang_codes = JLanguageHelper::getLanguages('lang_code');
self::$default_lang = JComponentHelper::getParams('com_languages')->get('site', 'en-GB');
self::$default_sef = self::$lang_codes[self::$default_lang]->sef;
self::$homes = MultilangstatusHelper::getHomes();
$user = JFactory::getUser();
$levels = $user->getAuthorisedViewLevels();
foreach (self::$sefs as $sef => &$language)
{
if (isset($language->access) && $language->access && !in_array($language->access, $levels))
{
unset(self::$sefs[$sef]);
}
}
$app->setLanguageFilter(true);
jimport('joomla.environment.uri');
$uri = JUri::getInstance();
if (self::$mode_sef)
{
// Get the route path from the request.
$path = JString::substr($uri->toString(), JString::strlen($uri->base()));
// Apache mod_rewrite is Off
$path = JFactory::getConfig()->get('sef_rewrite') ? $path : JString::substr($path, 10);
// Trim any spaces or slashes from the ends of the path and explode into segments.
$path = JString::trim($path, '/ ');
$parts = explode('/', $path);
// The language segment is always at the beginning of the route path if it exists.
$sef = $uri->getVar('lang');
if (!empty($parts) && empty($sef))
{
$sef = reset($parts);
}
}
else
{
$sef = $uri->getVar('lang');
}
if (isset(self::$sefs[$sef]))
{
$lang_code = self::$sefs[$sef]->lang_code;
// Create a cookie
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('config.cookie_domain', '');
$cookie_path = $conf->get('config.cookie_path', '/');
setcookie(JApplication::getHash('language'), $lang_code, $this->getLangCookieTime(), $cookie_path, $cookie_domain);
$app->input->cookie->set(JApplication::getHash('language'), $lang_code);
// set the request var
$app->input->set('language', $lang_code);
}
}
parent::__construct($subject, $config);
// Detect browser feature
if ($app->isSite())
{
$app->setDetectBrowser($this->params->get('detect_browser', '1') == '1');
}
}
}
public function onAfterInitialise()
{
$app = JFactory::getApplication();
$app->item_associations = $this->params->get('item_associations', 0);
if ($app->isSite())
{
self::$tag = JFactory::getLanguage()->getTag();
$router = $app->getRouter();
// attach build rules for language SEF
$router->attachBuildRule(array($this, 'buildRule'));
// attach parse rules for language SEF
$router->attachParseRule(array($this, 'parseRule'));
// Adding custom site name
$languages = JLanguageHelper::getLanguages('lang_code');
if (isset($languages[self::$tag]) && $languages[self::$tag]->sitename)
{
JFactory::getConfig()->set('sitename', $languages[self::$tag]->sitename);
}
}
}
public function buildRule(&$router, &$uri)
{
$sef = $uri->getVar('lang');
if (empty($sef))
{
$sef = self::$lang_codes[self::$tag]->sef;
}
elseif (!isset(self::$sefs[$sef]))
{
$sef = self::$default_sef;
}
$Itemid = $uri->getVar('Itemid');
if (!is_null($Itemid))
{
if ($item = JFactory::getApplication()->getMenu()->getItem($Itemid))
{
if ($item->home && $uri->getVar('option') != 'com_search')
{
$link = $item->link;
$parts = JString::parse_url($link);
if (isset ($parts['query']) && strpos($parts['query'], '&amp;'))
{
$parts['query'] = str_replace('&amp;', '&', $parts['query']);
}
parse_str($parts['query'], $vars);
// test if the url contains same vars as in menu link
$test = true;
foreach ($uri->getQuery(true) as $key => $value)
{
if (!in_array($key, array('format', 'Itemid', 'lang')) && !(isset($vars[$key]) && $vars[$key] == $value))
{
$test = false;
break;
}
}
if ($test)
{
foreach ($vars as $key => $value)
{
$uri->delVar($key);
}
$uri->delVar('Itemid');
}
}
}
else
{
$uri->delVar('Itemid');
}
}
if (self::$mode_sef)
{
$uri->delVar('lang');
if (
$this->params->get('remove_default_prefix', 0) == 0
|| $sef != self::$default_sef
|| $sef != self::$lang_codes[self::$tag]->sef
|| $this->params->get('detect_browser', 1) && JLanguageHelper::detectLanguage() != self::$tag && !self::$cookie
)
{
$uri->setPath($uri->getPath().'/'.$sef.'/');
}
else
{
$uri->setPath($uri->getPath());
}
}
else
{
$uri->setVar('lang', $sef);
}
}
public function parseRule(&$router, &$uri)
{
$app = JFactory::getApplication();
$lang_code = $app->input->cookie->getString(JApplication::getHash('language'));
// No cookie - let's try to detect browser language or use site default
if (!$lang_code)
{
if ($this->params->get('detect_browser', 1))
{
$lang_code = JLanguageHelper::detectLanguage();
}
else
{
$lang_code = self::$default_lang;
}
}
if (self::$mode_sef)
{
$path = $uri->getPath();
$parts = explode('/', $path);
$sef = $parts[0];
// Redirect only if not in post
if (!empty($lang_code) && ($app->input->getMethod() != "POST" || count($app->input->post) == 0))
{
if ($this->params->get('remove_default_prefix', 0) == 0)
{
// redirect if sef does not exists
if (!isset(self::$sefs[$sef]))
{
// Use the current language sef or the default one
$sef = isset(self::$lang_codes[$lang_code]) ? self::$lang_codes[$lang_code]->sef : self::$default_sef;
$uri->setPath($sef . '/' . $path);
if ($app->getCfg('sef_rewrite'))
{
$app->redirect($uri->base().$uri->toString(array('path', 'query', 'fragment')));
}
else
{
$path = $uri->toString(array('path', 'query', 'fragment'));
$app->redirect($uri->base().'index.php'.($path ? ('/' . $path) : ''));
}
}
}
else
{
// redirect if sef does not exists and language is not the default one
if (!isset(self::$sefs[$sef]) && $lang_code != self::$default_lang)
{
$sef = isset(self::$lang_codes[$lang_code]) ? self::$lang_codes[$lang_code]->sef : self::$default_sef;
$uri->setPath($sef . '/' . $path);
if ($app->getCfg('sef_rewrite'))
{
$app->redirect($uri->base().$uri->toString(array('path', 'query', 'fragment')));
}
else
{
$path = $uri->toString(array('path', 'query', 'fragment'));
$app->redirect($uri->base().'index.php'.($path ? ('/' . $path) : ''));
}
}
// redirect if sef is the default one
elseif (isset(self::$sefs[$sef]) &&
self::$default_lang == self::$sefs[$sef]->lang_code &&
(!$this->params->get('detect_browser', 1) || JLanguageHelper::detectLanguage() == self::$tag || self::$cookie)
)
{
array_shift($parts);
$uri->setPath(implode('/', $parts));
if ($app->getCfg('sef_rewrite'))
{
$app->redirect($uri->base().$uri->toString(array('path', 'query', 'fragment')));
}
else
{
$path = $uri->toString(array('path', 'query', 'fragment'));
$app->redirect($uri->base().'index.php'.($path ? ('/' . $path) : ''));
}
}
}
}
$lang_code = isset(self::$sefs[$sef]) ? self::$sefs[$sef]->lang_code : '';
if ($lang_code && JLanguage::exists($lang_code))
{
array_shift($parts);
$uri->setPath(implode('/', $parts));
}
}
else
{
$sef = $uri->getVar('lang');
if (!isset(self::$sefs[$sef]))
{
$sef = isset(self::$lang_codes[$lang_code]) ? self::$lang_codes[$lang_code]->sef : self::$default_sef;
$uri->setVar('lang', $sef);
if ($app->input->getMethod() != "POST" || count($app->input->post) == 0)
{
$app->redirect(JUri::base(true).'/index.php?'.$uri->getQuery());
}
}
}
$array = array('lang' => $sef);
return $array;
}
/**
* before store user method
*
* Method is called before user data is stored in the database
*
* @param array $user Holds the old user data.
* @param boolean $isnew True if a new user is stored.
* @param array $new Holds the new user data.
*
* @return void
* @since 1.6
*/
public function onUserBeforeSave($user, $isnew, $new)
{
if ($this->params->get('automatic_change', '1') == '1' && key_exists('params', $user))
{
$registry = new JRegistry;
$registry->loadString($user['params']);
self::$_user_lang_code = $registry->get('language');
if (empty(self::$_user_lang_code))
{
self::$_user_lang_code = self::$default_lang;
}
}
}
/**
* after store user method
*
* Method is called after user data is stored in the database
*
* @param array $user Holds the new user data.
* @param boolean $isnew True if a new user is stored.
* @param boolean $success True if user was succesfully stored in the database.
* @param string $msg Message.
*
* @return void
* @since 1.6
*/
public function onUserAfterSave($user, $isnew, $success, $msg)
{
if ($this->params->get('automatic_change', '1') == '1' && key_exists('params', $user) && $success)
{
$registry = new JRegistry;
$registry->loadString($user['params']);
$lang_code = $registry->get('language');
if (empty($lang_code))
{
$lang_code = self::$default_lang;
}
$app = JFactory::getApplication();
if ($lang_code == self::$_user_lang_code || !isset(self::$lang_codes[$lang_code]))
{
if ($app->isSite())
{
$app->setUserState('com_users.edit.profile.redirect', null);
}
}
else
{
if ($app->isSite())
{
$app->setUserState('com_users.edit.profile.redirect', 'index.php?Itemid='.$app->getMenu()->getDefault($lang_code)->id.'&lang='.self::$lang_codes[$lang_code]->sef);
self::$tag = $lang_code;
// Create a cookie
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('config.cookie_domain', '');
$cookie_path = $conf->get('config.cookie_path', '/');
setcookie(JApplication::getHash('language'), $lang_code, $this->getLangCookieTime(), $cookie_path, $cookie_domain);
}
}
}
}
/**
* This method should handle any login logic and report back to the subject
*
* @param array $user Holds the user data
* @param array $options Array holding options (remember, autoregister, group)
*
* @return boolean True on success
* @since 1.5
*/
public function onUserLogin($user, $options = array())
{
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($app->isSite() && $this->params->get('automatic_change', 1))
{
// Load associations
$assoc = isset($app->item_associations) ? $app->item_associations : 0;
if ($assoc)
{
$active = $menu->getActive();
if ($active)
{
$associations = MenusHelper::getAssociations($active->id);
}
}
$lang_code = $user['language'];
if (empty($lang_code))
{
$lang_code = self::$default_lang;
}
if ($lang_code != self::$tag)
{
// Change language
self::$tag = $lang_code;
// Create a cookie
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('config.cookie_domain', '');
$cookie_path = $conf->get('config.cookie_path', '/');
setcookie(JApplication::getHash('language'), $lang_code, $this->getLangCookieTime(), $cookie_path, $cookie_domain);
// Change the language code
JFactory::getLanguage()->setLanguage($lang_code);
// Change the redirect (language have changed)
if (isset($associations[$lang_code]) && $menu->getItem($associations[$lang_code]))
{
$itemid = $associations[$lang_code];
$app->setUserState('users.login.form.return', 'index.php?&Itemid='.$itemid);
}
else
{
$itemid = isset(self::$homes[$lang_code]) ? self::$homes[$lang_code]->id : self::$homes['*']->id;
$app->setUserState('users.login.form.return', 'index.php?&Itemid='.$itemid);
}
}
}
}
/**
* This method adds alternate meta tags for associated menu items
*
* @return nothing
* @since 1.7
*/
public function onAfterDispatch()
{
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$menu = $app->getMenu();
$server = JUri::getInstance()->toString(array('scheme', 'host', 'port'));
$option = $app->input->get('option');
$eName = JString::ucfirst(JString::str_ireplace('com_', '', $option));
if ($app->isSite() && $this->params->get('alternate_meta') && $doc->getType() == 'html')
{
// Get active menu item
$active = $menu->getActive();
// load menu associations
if ($active)
{
// Get menu item link
if ($app->getCfg('sef'))
{
$active_link = JRoute::_('index.php?Itemid='.$active->id, false);
}
else
{
$active_link = JRoute::_($active->link.'&Itemid='.$active->id, false);
}
if ($active_link == JUri::base(true).'/')
{
$active_link .= 'index.php';
}
// Get current link
$current_link = JUri::getInstance()->toString(array('path', 'query'));
if ($current_link == JUri::base(true).'/')
{
$current_link .= 'index.php';
}
// Check the exact menu item's URL
if ($active_link == $current_link)
{
$associations = MenusHelper::getAssociations($active->id);
unset($associations[$active->language]);
}
}
// load component associations
$cName = JString::ucfirst($eName.'HelperAssociation');
JLoader::register($cName, JPath::clean(JPATH_COMPONENT_SITE . '/helpers/association.php'));
if (class_exists($cName) && is_callable(array($cName, 'getAssociations')))
{
$cassociations = call_user_func(array($cName, 'getAssociations'));
$lang_code = $app->input->cookie->getString(JApplication::getHash('language'));
// No cookie - let's try to detect browser language or use site default
if (!$lang_code)
{
if ($this->params->get('detect_browser', 1)){
$lang_code = JLanguageHelper::detectLanguage();
} else {
$lang_code = self::$default_lang;
}
}
unset($cassociations[$lang_code]);
}
// handle the default associations
if ((!empty($associations) || !empty($cassociations)) && $this->params->get('item_associations'))
{
foreach (JLanguageHelper::getLanguages() as $language)
{
if (!JLanguage::exists($language->lang_code))
{
continue;
}
if (isset($cassociations[$language->lang_code]))
{
$link = JRoute::_($cassociations[$language->lang_code].'&lang='.$language->sef);
$doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code));
}
elseif (isset($associations[$language->lang_code]))
{
$item = $menu->getItem($associations[$language->lang_code]);
if ($item)
{
if ($app->getCfg('sef'))
{
$link = JRoute::_('index.php?Itemid='.$item->id.'&lang='.$language->sef);
}
else
{
$link = JRoute::_($item->link.'&Itemid='.$item->id.'&lang='.$language->sef);
}
$doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code));
}
}
}
}
// link to the home page of each language
elseif ($active && $active->home)
{
foreach (JLanguageHelper::getLanguages() as $language)
{
if (!JLanguage::exists($language->lang_code))
{
continue;
}
$item = $menu->getDefault($language->lang_code);
if ($item && $item->language != $active->language && $item->language != '*')
{
if ($app->getCfg('sef'))
{
$link = JRoute::_('index.php?Itemid='.$item->id.'&lang='.$language->sef);
}
else
{
$link = JRoute::_($item->link.'&Itemid='.$item->id.'&lang='.$language->sef);
}
$doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code));
}
}
}
}
}
/**
* Getting the Language Cookie settings
*
* @return string The cookie time.
*
* @since 3.0.4
*/
private function getLangCookieTime()
{
if ($this->params->get('lang_cookie', 1) == 1)
{
$lang_cookie = time() + 365 * 86400;
}
else
{
$lang_cookie = 0;
}
return $lang_cookie;
}
}

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="system">
<name>plg_system_languagefilter</name>
<author>Joomla! Project</author>
<creationDate>July 2010</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_SYSTEM_LANGUAGEFILTER_XML_DESCRIPTION</description>
<files>
<filename plugin="languagefilter">languagefilter.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_system_languagefilter.ini</language>
<language tag="en-GB">en-GB.plg_system_languagefilter.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="detect_browser" type="list"
description="PLG_SYSTEM_LANGUAGEFILTER_FIELD_DETECT_BROWSER_DESC"
label="PLG_SYSTEM_LANGUAGEFILTER_FIELD_DETECT_BROWSER_LABEL"
default="1"
>
<option value="0">PLG_SYSTEM_LANGUAGEFILTER_SITE_LANGUAGE</option>
<option value="1">PLG_SYSTEM_LANGUAGEFILTER_BROWSER_SETTINGS</option>
</field>
<field name="automatic_change" type="radio"
description="PLG_SYSTEM_LANGUAGEFILTER_FIELD_AUTOMATIC_CHANGE_DESC"
label="PLG_SYSTEM_LANGUAGEFILTER_FIELD_AUTOMATIC_CHANGE_LABEL"
default="1"
class="btn-group"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="item_associations" type="radio"
description="PLG_SYSTEM_LANGUAGEFILTER_FIELD_ITEM_ASSOCIATIONS_DESC"
label="PLG_SYSTEM_LANGUAGEFILTER_FIELD_ITEM_ASSOCIATIONS_LABEL"
default="0"
class="btn-group"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="remove_default_prefix" type="radio"
description="PLG_SYSTEM_LANGUAGEFILTER_FIELD_REMOVE_DEFAULT_PREFIX_DESC"
label="PLG_SYSTEM_LANGUAGEFILTER_FIELD_REMOVE_DEFAULT_PREFIX_LABEL"
default="0"
class="btn-group"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="lang_cookie" type="radio"
description="PLG_SYSTEM_LANGUAGEFILTER_FIELD_COOKIE_DESC"
label="PLG_SYSTEM_LANGUAGEFILTER_FIELD_COOKIE_LABEL"
default="1"
class="btn-group"
>
<option value="0">PLG_SYSTEM_LANGUAGEFILTER_OPTION_SESSION</option>
<option value="1">PLG_SYSTEM_LANGUAGEFILTER_OPTION_YEAR</option>
</field>
<field name="alternate_meta" type="radio"
description="PLG_SYSTEM_LANGUAGEFILTER_FIELD_ALTERNATE_META_DESC"
label="PLG_SYSTEM_LANGUAGEFILTER_FIELD_ALTERNATE_META_LABEL"
default="0"
class="btn-group"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,52 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage System.log
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Joomla! System Logging Plugin
*
* @package Joomla.Plugin
* @subpackage System.log
* @since 1.5
*/
class PlgSystemLog extends JPlugin
{
public function onUserLoginFailure($response)
{
$errorlog = array();
switch($response['status'])
{
case JAuthentication::STATUS_SUCCESS:
$errorlog['status'] = $response['type'] . " CANCELED: ";
$errorlog['comment'] = $response['error_message'];
break;
case JAuthentication::STATUS_FAILURE:
$errorlog['status'] = $response['type'] . " FAILURE: ";
if ($this->params->get('log_username', 0))
{
$errorlog['comment'] = $response['error_message'] . ' ("' . $response['username'] . '")';
}
else
{
$errorlog['comment'] = $response['error_message'];
}
break;
default:
$errorlog['status'] = $response['type'] . " UNKNOWN ERROR: ";
$errorlog['comment'] = $response['error_message'];
break;
}
JLog::addLogger(array(), JLog::INFO);
JLog::add($errorlog['comment'], JLog::INFO, $errorlog['status']);
}
}

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="system">
<name>plg_system_log</name>
<author>Joomla! Project</author>
<creationDate>April 2007</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_LOG_XML_DESCRIPTION</description>
<files>
<filename plugin="log">log.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_system_log.ini</language>
<language tag="en-GB">en-GB.plg_system_log.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="log_username" type="radio"
description="PLG_SYSTEM_LOG_FIELD_LOG_USERNAME_DESC"
label="PLG_SYSTEM_LOG_FIELD_LOG_USERNAME_LABEL"
class="btn-group"
default="0"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,97 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage System.logout
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
/**
* Plugin class for logout redirect handling.
*
* @package Joomla.Plugin
* @subpackage System.logout
* @since 1-6
*/
class PlgSystemLogout extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Object Constructor.
*
* @access public
* @param object The object to observe -- event dispatcher.
* @param object The configuration object for the plugin.
* @return void
* @since 1.6
*/
public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
$input = JFactory::getApplication()->input;
$hash = JApplication::getHash('PlgSystemLogout');
if (JFactory::getApplication()->isSite() && $input->cookie->getString($hash))
{
// Destroy the cookie
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('config.cookie_domain', '');
$cookie_path = $conf->get('config.cookie_path', '/');
setcookie($hash, false, time() - 86400, $cookie_path, $cookie_domain);
// Set the error handler for E_ALL to be the class handleError method.
JError::setErrorHandling(E_ALL, 'callback', array('PlgSystemLogout', 'handleError'));
}
}
/**
* 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 boolean Always returns true
* @since 1.6
*/
public function onUserLogout($user, $options = array())
{
if (JFactory::getApplication()->isSite())
{
// Create the cookie
$hash = JApplication::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;
}
public static function handleError(&$error)
{
// Get the application object.
$app = JFactory::getApplication();
// Make sure the error is a 403 and we are in the frontend.
if ($error->getCode() == 403 and $app->isSite())
{
// Redirect to the home page
$app->redirect('index.php', JText::_('PLG_SYSTEM_LOGOUT_REDIRECT'), null, true, false);
}
else
{
// Render the error page.
JError::customErrorPage($error);
}
}
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="system">
<name>plg_system_logout</name>
<author>Joomla! Project</author>
<creationDate>April 2009</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_SYSTEM_LOGOUT_XML_DESCRIPTION</description>
<files>
<filename plugin="logout">logout.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_system_logout.ini</language>
<language tag="en-GB">en-GB.plg_system_logout.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,37 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage System.p3p
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Joomla! P3P Header Plugin
*
* @package Joomla.Plugin
* @subpackage System.p3p
* @since 1.6
*/
class PlgSystemP3p extends JPlugin
{
/*
* @since 1.6
*/
public function onAfterInitialise()
{
// Get the header
$header = $this->params->get('header', 'NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM');
$header = trim($header);
// Bail out on empty header (why would anyone do that?!)
if ( empty($header) )
{
return;
}
// Replace any existing P3P headers in the response
JResponse::setHeader('P3P', 'CP="'.$header.'"', true);
}
}

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="system">
<name>plg_system_p3p</name>
<author>Joomla! Project</author>
<creationDate>September 2010</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_P3P_XML_DESCRIPTION</description>
<files>
<filename plugin="p3p">p3p.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_system_p3p.ini</language>
<language tag="en-GB">en-GB.plg_system_p3p.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="header" type="text"
description="PLG_P3P_HEADER_DESCRIPTION"
label="PLG_P3P_HEADER_LABEL"
default="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
size="37"
/>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,124 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage System.redirect
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
/**
* Plugin class for redirect handling.
*
* @package Joomla.Plugin
* @subpackage System.redirect
* @since 1.6
*/
class PlgSystemRedirect extends JPlugin
{
/**
* Object Constructor.
*
* @access public
* @param object The object to observe -- event dispatcher.
* @param object The configuration object for the plugin.
* @return void
* @since 1.6
*/
public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
// Set the error handler for E_ERROR to be the class handleError method.
JError::setErrorHandling(E_ERROR, 'callback', array('PlgSystemRedirect', 'handleError'));
set_exception_handler(array('PlgSystemRedirect', 'handleError'));
}
public static function handleError(&$error)
{
// Get the application object.
$app = JFactory::getApplication();
// Make sure the error is a 404 and we are not in the administrator.
if (!$app->isAdmin() and ($error->getCode() == 404))
{
// Get the full current URI.
$uri = JUri::getInstance();
$current = $uri->toString(array('scheme', 'host', 'port', 'path', 'query', 'fragment'));
// Attempt to ignore idiots.
if ((strpos($current, 'mosConfig_') !== false) || (strpos($current, '=http://') !== false))
{
// Render the error page.
JError::customErrorPage($error);
}
// See if the current url exists in the database as a redirect.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('new_url'))
->select($db->quoteName('published'))
->from($db->quoteName('#__redirect_links'))
->where($db->quoteName('old_url') . ' = ' . $db->quote($current));
$db->setQuery($query, 0, 1);
$link = $db->loadObject();
// If a redirect exists and is published, permanently redirect.
if ($link and ($link->published == 1))
{
$app->redirect($link->new_url, null, null, true, false);
}
else
{
$referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
$db->setQuery('SELECT id FROM ' . $db->quoteName('#__redirect_links') . ' WHERE old_url= ' . $db->quote($current));
$res = $db->loadResult();
if (!$res)
{
// If not, add the new url to the database.
$columns = array(
$db->quoteName('old_url'),
$db->quoteName('new_url'),
$db->quoteName('referer'),
$db->quoteName('comment'),
$db->quoteName('hits'),
$db->quoteName('published'),
$db->quoteName('created_date')
);
$query->clear()
->insert($db->quoteName('#__redirect_links'), false)
->columns($columns)
->values(
$db->quote($current) . ', ' . $db->quote('') .
' ,' . $db->quote($referer) . ', ' . $db->quote('') . ',1,0, ' .
$db->quote(JFactory::getDate()->toSql())
);
$db->setQuery($query);
$db->execute();
}
else
{
// Existing error url, increase hit counter
$query->clear()
->update($db->quoteName('#__redirect_links'))
->set($db->quoteName('hits') . ' = ' . $db->quote('hits') . ' + 1')
->where('id = ' . (int) $res);
$db->setQuery($query);
$db->execute();
}
// Render the error page.
JError::customErrorPage($error);
}
}
else
{
// Render the error page.
JError::customErrorPage($error);
}
}
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="system">
<name>plg_system_redirect</name>
<author>Joomla! Project</author>
<creationDate>April 2009</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_REDIRECT_XML_DESCRIPTION</description>
<files>
<filename plugin="redirect">redirect.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_system_redirect.ini</language>
<language tag="en-GB">en-GB.plg_system_redirect.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,107 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage System.remember
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Joomla! System Remember Me Plugin
*
* @package Joomla.Plugin
* @subpackage System.remember
* @since 1.5
*/
class PlgSystemRemember extends JPlugin
{
public function onAfterInitialise()
{
$app = JFactory::getApplication();
// No remember me for admin
if ($app->isAdmin())
{
return;
}
$user = JFactory::getUser();
if ($user->get('guest'))
{
$hash = JApplication::getHash('JLOGIN_REMEMBER');
if ($str = JRequest::getString($hash, '', 'cookie', JREQUEST_ALLOWRAW | JREQUEST_NOTRIM))
{
$credentials = array();
$filter = JFilterInput::getInstance();
// Create the encryption key, apply extra hardening using the user agent string.
// Since we're decoding, no UA validity check is required.
$privateKey = JApplication::getHash(@$_SERVER['HTTP_USER_AGENT']);
$key = new JCryptKey('simple', $privateKey, $privateKey);
$crypt = new JCrypt(new JCryptCipherSimple, $key);
try
{
$str = $crypt->decrypt($str);
if (!is_string($str))
{
throw new Exception('Decoded cookie is not a string.');
}
$cookieData = json_decode($str);
if (null === $cookieData)
{
throw new Exception('JSON could not be docoded.');
}
if (!is_object($cookieData))
{
throw new Exception('Decoded JSON is not an object.');
}
// json_decoded cookie could be any object structure, so make sure the
// credentials are well structured and only have user and password.
if (isset($cookieData->username) && is_string($cookieData->username))
{
$credentials['username'] = $filter->clean($cookieData->username, 'username');
}
else
{
throw new Exception('Malformed username.');
}
if (isset($cookieData->password) && is_string($cookieData->password))
{
$credentials['password'] = $filter->clean($cookieData->password, 'string');
}
else
{
throw new Exception('Malformed password.');
}
$return = $app->login($credentials, array('silent' => true));
if (!$return)
{
throw new Exception('Log-in failed.');
}
}
catch (Exception $e)
{
$config = JFactory::getConfig();
$cookie_domain = $config->get('cookie_domain', '');
$cookie_path = $config->get('cookie_path', '/');
// Clear the remember me cookie
setcookie(
JApplication::getHash('JLOGIN_REMEMBER'), false, time() - 86400,
$cookie_path, $cookie_domain
);
JLog::add('A remember me cookie was unset for the following reason: ' . $e->getMessage(), JLog::WARNING, 'security');
}
}
}
}
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="system">
<name>plg_system_remember</name>
<author>Joomla! Project</author>
<creationDate>April 2007</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_REMEMBER_XML_DESCRIPTION</description>
<files>
<filename plugin="remember">remember.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_system_remember.ini</language>
<language tag="en-GB">en-GB.plg_system_remember.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,147 @@
<?php
/**
* @version 2.0.0 October 31, 2012
* @author RocketTheme http://www.rockettheme.com
* @copyright Copyright (C) 2007 - 2012 RocketTheme, LLC
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
*
* Gantry uses the Joomla Framework (http://www.joomla.org), a GNU/GPLv2 content management system
*
*/
defined('_JEXEC') or die('Restricted access');
jimport('joomla.plugin.plugin');
/**
* RokExtender Plugin
*/
class plgSystemRokExtender extends JPlugin
{
/**
* Loads all RokExtender plugins and fires onAfterInitialise if it needs to.
*
* @return void
*/
public function onAfterInitialise()
{
jimport('joomla.filesystem.file');
//get list of registered "files"
$registered_files = explode(',', $this->params->get('registered', ''));
foreach ($registered_files as $registered_file)
{
$dispatcher = JDispatcher::getInstance();
$className = basename(trim($registered_file), '.php');
$fullpath = JPATH_ROOT . $registered_file;
if (file_exists($fullpath) && is_file($fullpath))
{
require_once($fullpath);
}
if (class_exists($className))
{
// Instantiate and register the plugin.
$class = new $className($dispatcher);
$args = array('event' => 'onafterinitialise');
$class->update($args);
}
}
}
/**
* Function to register a RokExtender Plugin file
* @static
* @param string $path the path to the plugin file
* @return bool true if registered successfully false if there was an error
*/
public static function registerExtenderPlugin($path)
{
$db = JFactory::getDbo();
$table = JTable::getInstance('extension');
$id = $table->find(array('type' => 'plugin', 'element' => 'rokextender', 'folder' => 'system'));
if (!$table->load($id))
{
//$this->setError($table->getError());
return false;
}
$params = new JRegistry();
$params->loadString($table->params);
$registered_files = explode(',', $params->get('registered', ''));
if (!in_array($path, $registered_files))
{
$registered_files[] = $path;
}
// clean up files not there
$actually_there = $registered_files;
foreach($registered_files as $registered_loc => $registered_file)
{
$fullpath = JPATH_ROOT . $registered_file;
if (!file_exists($fullpath) || !is_file($fullpath)){
unset($actually_there[$registered_loc]);
}
}
$params->set('registered', implode(',', $actually_there));
$table->params = $params->toString();
// pre-save checks
if (!$table->check())
{
//$this->setError($table->getError());
return false;
}
// save the changes
if (!$table->store())
{
//$this->setError($table->getError());
return false;
}
}
/**
* Function to unregister a RokExtender Plugin file
* @static
* @param string $path the path to the plugin file
* @return bool true if unregistered successfully false if there was an error
*/
public static function unregisterExtenderPlugin($path)
{
$db = JFactory::getDbo();
$table = JTable::getInstance('extension');
$id = $table->find(array('type' => 'plugin', 'element' => 'rokextender', 'folder' => 'system'));
if (!$table->load($id))
{
//$this->setError($table->getError());
return false;
}
$params = new JRegistry();
$params->loadString($table->params);
$registered_files = explode(',', $params->get('registered', ''));
if (($loc = array_search($path, $registered_files)) !== false)
{
unset($registered_files[$loc]);
}
$params->set('registered', implode(',', $registered_files));
$table->params = $params->toString();
// pre-save checks
if (!$table->check())
{
//$this->setError($table->getError());
return false;
}
// save the changes
if (!$table->store())
{
//$this->setError($table->getError());
return false;
}
}
}

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="1.6" type="plugin" group="system" method="upgrade">
<name>System - RokExtender</name>
<author>RocketTheme, LLC</author>
<creationDate>October 31, 2012</creationDate>
<copyright>(C) 2005 - 2012 RocketTheme, LLC. All rights reserved.</copyright>
<license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
<authorEmail>support@rockettheme.com</authorEmail>
<authorUrl>http://www.rockettheme.com</authorUrl>
<version>2.0.0</version>
<description>System - Gantry</description>
<files>
<filename plugin="rokextender">rokextender.php</filename>
<filename>index.html</filename>
</files>
<config>
<fields name="params">
<fieldset name="advanced">
<field name="registered" type="text"
default=""
description=""
label=""
/>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

159
plugins/system/sef/sef.php Normal file
View File

@ -0,0 +1,159 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage System.sef
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Joomla! SEF Plugin
*
* @package Joomla.Plugin
* @subpackage System.sef
* @since 1.5
*/
class PlgSystemSef extends JPlugin
{
/**
* Add the canonical uri to the head
*
* @return void
*
* @since 3.0
*/
public function onAfterRoute()
{
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
if ($app->getName() != 'site' || $doc->getType() !== 'html')
{
return true;
}
$router = $app->getRouter();
$uri = JUri::getInstance();
$domain = $this->params->get('domain');
if ($domain === null || $domain === '')
{
$domain = $uri->toString(array('scheme', 'host', 'port'));
}
$parsed = $router->parse($uri);
$fakelink = 'index.php?' . http_build_query($parsed);
$link = $domain . JRoute::_($fakelink, false);
if ($uri !== $link)
{
$doc->addHeadLink(htmlspecialchars($link), 'canonical');
}
}
/**
* Converting the site URL to fit to the HTTP request
*
* @return void
*/
public function onAfterRender()
{
$app = JFactory::getApplication();
if ($app->getName() != 'site' || $app->getCfg('sef') == '0')
{
return true;
}
// Replace src links
$base = JUri::base(true).'/';
$buffer = JResponse::getBody();
$regex = '#href="index.php\?([^"]*)#m';
$buffer = preg_replace_callback($regex, array('PlgSystemSef', 'route'), $buffer);
$this->checkBuffer($buffer);
$protocols = '[a-zA-Z0-9]+:'; //To check for all unknown protocals (a protocol must contain at least one alpahnumeric fillowed by :
$regex = '#(src|href|poster)="(?!/|' . $protocols . '|\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, "$1=\"$base\$2\"", $buffer);
$this->checkBuffer($buffer);
$regex = '#(onclick="window.open\(\')(?!/|' . $protocols . '|\#)([^/]+[^\']*?\')#m';
$buffer = preg_replace($regex, '$1' . $base . '$2', $buffer);
$this->checkBuffer($buffer);
// ONMOUSEOVER / ONMOUSEOUT
$regex = '#(onmouseover|onmouseout)="this.src=([\']+)(?!/|' . $protocols . '|\#|\')([^"]+)"#m';
$buffer = preg_replace($regex, '$1="this.src=$2' . $base .'$3$4"', $buffer);
$this->checkBuffer($buffer);
// Background image
$regex = '#style\s*=\s*[\'\"](.*):\s*url\s*\([\'\"]?(?!/|' . $protocols . '|\#)([^\)\'\"]+)[\'\"]?\)#m';
$buffer = preg_replace($regex, 'style="$1: url(\'' . $base .'$2$3\')', $buffer);
$this->checkBuffer($buffer);
// OBJECT <param name="xx", value="yy"> -- fix it only inside the <param> tag
$regex = '#(<param\s+)name\s*=\s*"(movie|src|url)"[^>]\s*value\s*=\s*"(?!/|' . $protocols . '|\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, '$1name="$2" value="' . $base . '$3"', $buffer);
$this->checkBuffer($buffer);
// OBJECT <param value="xx", name="yy"> -- fix it only inside the <param> tag
$regex = '#(<param\s+[^>]*)value\s*=\s*"(?!/|' . $protocols . '|\#|\')([^"]*)"\s*name\s*=\s*"(movie|src|url)"#m';
$buffer = preg_replace($regex, '<param value="' . $base .'$2" name="$3"', $buffer);
$this->checkBuffer($buffer);
// OBJECT data="xx" attribute -- fix it only in the object tag
$regex = '#(<object\s+[^>]*)data\s*=\s*"(?!/|' . $protocols . '|\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, '$1data="' . $base . '$2"$3', $buffer);
$this->checkBuffer($buffer);
JResponse::setBody($buffer);
return true;
}
/**
* @param string $buffer
*
* @return void
*/
private function checkBuffer($buffer)
{
if ($buffer === null)
{
switch (preg_last_error())
{
case PREG_BACKTRACK_LIMIT_ERROR:
$message = "PHP regular expression limit reached (pcre.backtrack_limit)";
break;
case PREG_RECURSION_LIMIT_ERROR:
$message = "PHP regular expression limit reached (pcre.recursion_limit)";
break;
case PREG_BAD_UTF8_ERROR:
$message = "Bad UTF8 passed to PCRE function";
break;
default:
$message = "Unknown PCRE error calling PCRE function";
}
throw new RuntimeException($message);
}
}
/**
* Replaces the matched tags
*
* @param array &$matches An array of matches (see preg_match_all)
*
* @return string
*/
protected static function route(&$matches)
{
$url = $matches[1];
$url = str_replace('&amp;', '&', $url);
$route = JRoute::_('index.php?'.$url);
return 'href="' . $route;
}
}

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="system">
<name>plg_system_sef</name>
<author>Joomla! Project</author>
<creationDate>December 2007</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_SEF_XML_DESCRIPTION</description>
<files>
<filename plugin="sef">sef.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_system_sef.ini</language>
<language tag="en-GB">en-GB.plg_system_sef.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="domain" type="url"
description="PLG_SEF_DOMAIN_DESCRIPTION"
label="PLG_SEF_DOMAIN_LABEL"
filter="string"
validate="url"
/>
</fieldset>
</fields>
</config>
</extension>