www.archline.hu — clean post-compromise baseline #2

Merged
imre.agent merged 88 commits from baseline/47 into main 2026-07-16 14:40:45 +02:00
5 changed files with 447 additions and 0 deletions
Showing only changes of commit 2d331103d7 - Show all commits

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

View File

@ -0,0 +1,14 @@
/*!
* jQuery Lazy - min - v0.3.8
* http://jquery.eisbehr.de/lazy/
* http://eisbehr.de/
*
* Copyright 2014, Daniel 'Eisbehr' Kern
*
* Dual licensed under the MIT and GPL-2.0 licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl-2.0.html
*
* jQuery("img.lazy").lazy();
*/
(function(e,t,n,r){e.fn.lazy=function(i){"use strict";function d(){l=t.devicePixelRatio>1;if(s.defaultImage!==null||s.placeholder!==null)for(var n=0;n<o.length;n++){var r=e(o[n]);if(s.defaultImage!==null&&!r.attr("src"))r.attr("src",s.defaultImage);if(s.placeholder!==null&&(!r.css("background-image")||r.css("background-image")=="none"))r.css("background-image","url("+s.placeholder+")")}if(s.delay>=0)setTimeout(function(){v(true)},s.delay);if(s.delay<0||s.combined){v(false);T(function(){e(s.appendScroll).bind("scroll",w(s.throttle,function(){T(function(){v(false)},this,true)}))},this);T(function(){e(s.appendScroll).bind("resize",w(s.throttle,function(){a=f=-1;T(function(){v(false)},this,true)}))},this)}}function v(t){if(!o.length)return;var n=false;for(var r=0;r<o.length;r++){(function(){var i=o[r],u=e(i);if(g(i)||t){var a=i.tagName.toLowerCase();if(u.attr(s.attribute)&&(a=="img"&&u.attr(s.attribute)!=u.attr("src")||a!="img"&&u.attr(s.attribute)!=u.css("background-image"))&&!u.data(s.handledName)&&(u.is(":visible")||!s.visibleOnly)){n=true;u.data(s.handledName,true);T(function(){m(u,a)},this)}}})()}if(n)T(function(){o=e(o).filter(function(){return!e(this).data(s.handledName)})},this)}function m(n,r){var i=e(new Image);++u;if(s.onError)i.error(function(){S(s.onError,n);E()});else i.error(function(){E()});var o=false;i.one("load",function(){var e=function(){if(!o){t.setTimeout(e,100);return}n.hide();if(r=="img")n.attr("src",i.attr("src"));else n.css("background-image","url("+i.attr("src")+")");n[s.effect](s.effectTime);if(s.removeAttribute){n.removeAttr(s.attribute);n.removeAttr(s.retinaAttribute)}S(s.afterLoad,n);i.unbind("load").remove();E()};e()});S(s.beforeLoad,n);i.attr("src",l&&n.attr(s.retinaAttribute)?n.attr(s.retinaAttribute):n.attr(s.attribute));S(s.onLoad,n);o=true;if(i.complete)i.load()}function g(e){var t=y(),n=b(),r=e.getBoundingClientRect(),i=n+s.threshold>r.top&&-s.threshold<r.bottom,o=t+s.threshold>r.left&&-s.threshold<r.right;if(s.scrollDirection=="vertical")return i;else if(s.scrollDirection=="horizontal")return o;return i&&o}function y(){if(a>=0)return a;a=t.innerWidth||n.documentElement.clientWidth||n.body.clientWidth||n.body.offsetWidth||s.fallbackWidth;return a}function b(){if(f>=0)return f;f=t.innerHeight||n.documentElement.clientHeight||n.body.clientHeight||n.body.offsetHeight||s.fallbackHeight;return f}function w(e,t){function o(){function u(){i=+(new Date);t.apply(r)}var o=+(new Date)-i;n&&clearTimeout(n);if(o>e||!s.enableThrottle)u();else n=setTimeout(u,e-o)}var n,i=0;return o}function E(){--u;if(!o.size()&&!u)S(s.onFinishedAll,null)}function S(e,t){if(e){if(t)T(function(){e(t)},this);else T(e,this)}}function x(){c=setTimeout(function(){T();if(h.length)x()},2)}function T(e,n,r){if(e){if(!s.enableQueueing){e.call(n||t);return}if(!r||r&&!p){h.push([e,n,r]);if(r)p=true}if(h.length==1)x();return}var i=h.shift();if(!i)return;if(i[2])p=false;i[0].call(i[1]||t)}var s={bind:"load",threshold:500,fallbackWidth:2e3,fallbackHeight:2e3,visibleOnly:false,appendScroll:t,scrollDirection:"both",defaultImage:"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",placeholder:null,delay:-1,combined:false,attribute:"data-src",retinaAttribute:"data-retina",removeAttribute:true,handledName:"handled",effect:"show",effectTime:0,enableThrottle:false,throttle:250,enableQueueing:true,beforeLoad:null,onLoad:null,afterLoad:null,onError:null,onFinishedAll:null},o=this,u=0,a=-1,f=-1,l=false,c=null,h=[],p=false;(function(){if(i)e.extend(s,i);if(s.onError)o.each(function(){var t=this;T(function(){e(t).bind("error",function(){S(s.onError,e(this))})},t)});if(s.bind=="load")e(t).load(d);else if(s.bind=="event")d()})();return this};e.fn.Lazy=e.fn.lazy})(jQuery,window,document);

View File

@ -0,0 +1,381 @@
<?php
/**
* @Copyright
* @package TM Lazy Load
* @author TemplateMonster
* @version 1.1.4
* @link http://www.templatemonster.com/
*
* @license GNU/GPL
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
defined('_JEXEC') or die('Restricted access');
class PlgSystemTmLazyLoad extends JPlugin
{
protected $_execute;
function __construct(&$subject, $config)
{
// First check whether version requirements are met for this specific version
if($this->checkVersionRequirements(false, '3.2', 'TM Lazy Load', 'plg_system_tmlazyload', JPATH_ADMINISTRATOR))
{
parent::__construct($subject, $config);
$this->loadLanguage('', JPATH_ADMINISTRATOR);
$this->_execute = true;
}
}
/**
* Do all checks whether the plugin has to be loaded and load needed JavaScript instructions
*/
public function onBeforeCompileHead()
{
if($this->params->get('exclude_editor'))
{
if(class_exists('JEditor', false))
{
$this->_execute = false;
}
}
if($this->params->get('exclude_bots') AND $this->_execute == true)
{
$this->excludeBots();
}
if($this->params->get('exclude_components') AND $this->_execute == true)
{
$this->excludeComponents();
}
if($this->params->get('exclude_urls') AND $this->_execute == true)
{
$this->excludeUrls();
}
if($this->_execute == true)
{
JHtml::_('jquery.framework');
$doc = JFactory::getDocument();
$document =& $doc;
$document->addScript(JURI::base() . 'plugins/system/tmlazyload/tmlazyload.js');
$document->addScriptDeclaration('
jQuery(function($) {
$("img.lazy").lazy({
threshold: 200,
visibleOnly: false,
effect: "fadeIn",
effectTime: 500,
throttle: 500,
afterLoad: function(element) {
if(typeof $.fn.BlackAndWhite_init == "function"){
jQuery(element).parent("a").BlackAndWhite_init();
}
setTimeout(function(){
element.addClass("lazyloaded");
},500)
}
});
});
');
}
}
/**
* Trigger onAfterRender executes the main plugin procedure
*/
public function onAfterRender()
{
if(JFactory::getApplication()->input->getWord('view')=='image'){
$this->_execute = false;
}
if($this->_execute == true)
{
$exclude_image_names = array_map('trim', explode("\n", $this->params->get('exclude_imagenames')));
$exclude_imagenames_toggle = $this->params->get('exclude_imagenames_toggle');
$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML(JFactory::getApplication()->getBody(false));
foreach($dom->getElementsByTagName('img') as $img)
{
$src = $img->getAttribute('src');
$img_name = parse_url($src);
$img_name = $img_name['path'];
$img_name = explode('/', $img_name);
$img_name = end($img_name);
if(count($exclude_image_names)){
$continue = false;
if($exclude_imagenames_toggle == 0){
foreach($exclude_image_names as $exclude_image_name){
if($exclude_image_name != '' && strpos($img_name, $exclude_image_name)===0){
$continue = true;
}
}
}
else{
$continue = true;
foreach($exclude_image_names as $exclude_image_name){
if($exclude_image_name != '' && strpos($img_name, $exclude_image_name)===0){
$continue = false;
}
}
}
if ($continue === true){
continue;
}
}
if(!array_key_exists('host',parse_url($src))){
$src = JURI::base().str_replace(JURI::base(true).'/', '', $src);
}
$size = @getimagesize($src);
$width = $size[0];
$height = $size[1];
$attributes = array();
foreach($img->attributes as $attribute_name => $attribute_node)
{
$attributes[$attribute_name] = $attribute_node->nodeValue;
}
if(!array_key_exists('width',$attributes) || $attributes['width']==0 || $attributes['width']==''){
$img->setAttribute('width',''.$width);
}
if(!array_key_exists('height',$attributes) || $attributes['height']==0 || $attributes['height']==''){
$img->setAttribute('height',''.$height);
}
if(array_key_exists('class',$attributes)){
$img->setAttribute('class', $attributes['class'].' lazy');
}
else{
$img->setAttribute('class','lazy');
}
$img->setAttribute('data-src',''.$src);
$img->setAttribute('src', JURI::base().'plugins/system/tmlazyload/blank.gif');
}
JFactory::getApplication()->setBody($dom->saveHTML());
$pattern = '/&amp;[lg]t;/';
$body = JFactory::getApplication()->getBody(false);
preg_match_all($pattern, $body, $matches);
if(!empty($matches))
{
foreach($matches[0] as $match)
{
$arg_1 = array('&amp;lt;','&amp;gt;');
$arg_2 = array('&lt;','&gt;');
$matchlazy = str_replace($arg_1, $arg_2, $match);
$body = str_replace($match, $matchlazy, $body);
}
JFactory::getApplication()->setBody($body);
}
$pattern = '/&amp;#160;/';
preg_match_all($pattern, $body, $matches);
if(!empty($matches))
{
foreach($matches[0] as $match)
{
$arg_1 = '&amp;#160;';
$arg_2 = ' ';
$matchlazy = str_replace($arg_1, $arg_2, $match);
$body = str_replace($match, $matchlazy, $body);
}
JFactory::getApplication()->setBody($body);
}
/*$pattern = "@<img[^>]*src=[\"\']([^\"\']*)[\"\'][^>]*>@";
preg_match_all($pattern, $body, $matches);
if($this->params->get('exclude_imagenames') AND !empty($matches))
{
$this->excludeImageNames($matches);
}
*/
}
}
/**
* Excludes the execution in specified components if option is selected
*/
private function excludeComponents()
{
$option = JFactory::getApplication()->input->getWord('option');
$exclude_components = array_map('trim', explode("\n", $this->params->get('exclude_components')));
$hit = false;
foreach($exclude_components as $exclude_component)
{
if($option == $exclude_component)
{
$hit = true;
break;
}
}
if($this->params->get('exclude_components_toggle'))
{
if($hit == false)
{
$this->_execute = false;
}
}
else
{
if($hit == true)
{
$this->_execute = false;
}
}
}
/**
* Excludes the execution in specified URLs if option is selected
*/
private function excludeUrls()
{
$url = JUri::getInstance()->toString();
$exclude_urls = array_map('trim', explode("\n", $this->params->get('exclude_urls')));
$hit = false;
foreach($exclude_urls as $exclude_url)
{
if($url == $exclude_url)
{
$hit = true;
break;
}
}
if($this->params->get('exclude_urls_toggle'))
{
if($hit == false)
{
$this->_execute = false;
}
}
else
{
if($hit == true)
{
$this->_execute = false;
}
}
}
/**
* Excludes the execution in specified image names if option is selected
*
* @param $matches
*/
private function excludeImageNames(&$matches)
{
$exclude_image_names = array_map('trim', explode("\n", $this->params->get('exclude_imagenames')));
$exclude_imagenames_toggle = $this->params->get('exclude_imagenames_toggle');
$matches_temp = array();
foreach($exclude_image_names as $exclude_image_name)
{
$count = 0;
foreach($matches[1] as $match)
{
if(preg_match('@'.preg_quote($exclude_image_name).'@', $match))
{
if(empty($exclude_imagenames_toggle))
{
unset($matches[0][$count]);
}
else
{
$matches_temp[] = $matches[0][$count];
}
}
$count++;
}
}
if($exclude_imagenames_toggle)
{
unset($matches[0]);
$matches[0] = $matches_temp;
}
}
/**
* Excludes the execution for specified bots if option is selected
*/
private function excludeBots()
{
$exclude_bots = array_map('trim', explode(",", $this->params->get('botslist')));
$agent = $_SERVER['HTTP_USER_AGENT'];
foreach($exclude_bots as $exclude_bot)
{
if(preg_match('@'.$exclude_bot.'@i', $agent))
{
$this->_execute = false;
break;
}
}
}
/**
* Checks whether all requirements are met for the execution
*
* @param $admin Allow backend execution - true or false
* @param $version_min Minimum required Joomla! version - e.g. 3.2
* @param $extension_name Name of the extension of the warning message
* @param $extension_system_name System name of the extension for the language file loading - e.g. plg_system_xxx
* @param $jpath Path of the language file - JPATH_ADMINISTRATOR or JPATH_SITE
*
* @return bool
*/
private function checkVersionRequirements($admin, $version_min, $extension_name, $extension_system_name, $jpath)
{
$execution = true;
$version = new JVersion();
if(!$version->isCompatible($version_min))
{
$execution = false;
$backend_message = true;
}
if(empty($admin))
{
if(JFactory::getApplication()->isAdmin())
{
$execution = false;
if(!empty($backend_message))
{
$this->loadLanguage($extension_system_name, $jpath);
JFactory::getApplication()->enqueueMessage(JText::sprintf('KR_JOOMLA_VERSION_REQUIREMENTS_NOT_MET', $extension_name, $version_min), 'warning');
}
}
}
return $execution;
}
}

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" version="3.2" group="system" method="upgrade">
<name>TM Lazy Load</name>
<version>1.2.1</version>
<creationDate>2014-07-04</creationDate>
<license>http://www.gnu.org/licenses/gpl-3.0</license>
<copyright>Copyright 2014 Template Monster. All rights reserved.</copyright>
<author>Template Monster</author>
<authorEmail></authorEmail>
<authorUrl></authorUrl>
<description>PLG_TMLAZYLOAD_XML_DESCRIPTION</description>
<files>
<filename plugin="tmlazyload">tmlazyload.php</filename>
<filename plugin="tmlazyload">tmlazyload.js</filename>
<filename plugin="tmlazyload">blank.gif</filename>
<filename plugin="tmlazyload">index.html</filename>
</files>
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.plg_system_tmlazyload.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_system_tmlazyload.sys.ini</language>
</languages>
<config>
<fields name="params" addfieldpath="/plugins/system/tmlazyload/fields">
<fieldset name="settings">
<field name="exclude_imagenames" type="textarea" default="" label="PLG_TMLAZYLOAD_EXCLUDEIMAGENAMES" description="PLG_TMLAZYLOAD_EXCLUDEIMAGENAMESDESC" rows="6" cols="60" />
<field name="exclude_imagenames_toggle" type="list" default="0" label="PLG_TMLAZYLOAD_EXCLUDEIMAGENAMES_TOGGLE" description="PLG_TMLAZYLOAD_EXCLUDEIMAGENAMES_TOGGLEDESC">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="exclude_components" type="textarea" default="" label="PLG_TMLAZYLOAD_EXCLUDECOMPONENTS" description="PLG_TMLAZYLOAD_EXCLUDECOMPONENTSDESC" rows="6" cols="60" />
<field name="exclude_components_toggle" type="list" default="0" label="PLG_TMLAZYLOAD_EXCLUDECOMPONENTS_TOGGLE" description="PLG_TMLAZYLOAD_EXCLUDECOMPONENTS_TOGGLEDESC">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="exclude_urls" type="textarea" default="" label="PLG_TMLAZYLOAD_EXCLUDEURLS" description="PLG_TMLAZYLOAD_EXCLUDEURLSDESC" rows="6" cols="60" />
<field name="exclude_urls_toggle" type="list" default="0" label="PLG_TMLAZYLOAD_EXCLUDEURLS_TOGGLE" description="PLG_TMLAZYLOAD_EXCLUDEURLS_TOGGLEDESC">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="exclude_editor" type="list" default="1" label="PLG_TMLAZYLOAD_EXCLUDEJOOMLAEDITOR" description="PLG_TMLAZYLOAD_EXCLUDEJOOMLAEDITORDESC">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="exclude_bots" type="list" default="1" label="PLG_TMLAZYLOAD_EXCLUDEBOTS" description="PLG_TMLAZYLOAD_EXCLUDEBOTSDESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="botslist" type="text" size="80" default="bot,spider,crawler,libwww,search,archive,slurp,teoma,facebook,twitter" label="PLG_TMLAZYLOAD_EXCLUDEBOTSLIST" description="PLG_TMLAZYLOAD_EXCLUDEBOTSLISTDESC" />
</fieldset>
</fields>
</config>
</extension>