- md5
- 3799058d19e35e9f99fc0ea27e97c1e4
- sha1
- 0bd38f52a29a57f93af0c0cdd310bc69f0039e67
- sha256
- 4485cb972ce42b1ba8ce363d0a01be68ec459fc400077e548f72f0cc58c39ac0
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
<?php
/**
* @version $Id: sef.php 20196 2011-01-09 02:40:25Z ian $
* @package Joomla
* @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.plugin.plugin');
/**
* Joomla! SEF Plugin
*
* @package Joomla
* @subpackage System
*/
class plgSystemSef extends JPlugin
{
/**
* Converting the site URL to fit to the HTTP request
*/
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);
$protocols = '[a-zA-Z0-9]+:'; //To check for all unknown protocals (a protocol must contain at least one alpahnumeric fillowed by :
$regex = '#(src|href)="(?!/|'.$protocols.'|\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, "$1=\"$base\$2\"", $buffer);
$regex = '#(onclick="window.open\(\')(?!/|'.$protocols.'|\#)([^/]+[^\']*?\')#m';
$buffer = preg_replace($regex, '$1'.$base.'$2', $buffer);
// ONMOUSEOVER / ONMOUSEOUT
$regex = '#(onmouseover|onmouseout)="this.src=([\']+)(?!/|'.$protocols.'|\#|\')([^"]+)"#m';
$buffer = preg_replace($regex, '$1="this.src=$2'. $base .'$3$4"', $buffer);
// Background image
$regex = '#style\s*=\s*[\'\"](.*):\s*url\s*\([\'\"]?(?!/|'.$protocols.'|\#)([^\)\'\"]+)[\'\"]?\)#m';
$buffer = preg_replace($regex, 'style="$1: url(\''. $base .'$2$3\')', $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);
// 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);
// 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);
JResponse::setBody($buffer);
return true;
}
/**
* Replaces the matched tags
*
* @param array An array of matches (see preg_match_all)
* @return string
*/
protected static function route(&$matches)
{
$original = $matches[0];
$url = $matches[1];
$url = str_replace('&','&',$url);
$route = JRoute::_('index.php?'.$url);
return 'href="'.$route;
}
}
No other release has this exact content. See every version of this file.