Skip to content

Commit

Permalink
#3488 Composer: source code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Trofimov committed Sep 5, 2021
1 parent cb24c76 commit 559a1ef
Show file tree
Hide file tree
Showing 26 changed files with 1,674 additions and 57 deletions.
1,479 changes: 1,479 additions & 0 deletions composer.lock

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions inc/classes/BxDolHTMLPurifierFilterAddBxLinksClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

class BxDolHTMLPurifierFilterAddBxLinksClass extends HTMLPurifier_Filter
{
public $name = 'AddBxLinksClass';
protected $class = BX_DOL_LINK_CLASS;

public function preFilter($sHtml, $config, $context)
{
if (false === strstr($sHtml, '<a '))
return $sHtml;

$sId = 'bx-links-' . md5(microtime());
$dom = new DOMDocument();
@$dom->loadHTML('<?xml encoding="UTF-8"><div id="' . $sId . '">' . $sHtml . '</div>');
$xpath = new DOMXpath($dom);

$oLinks = $xpath->evaluate('//a');
for ($i = 0; $i < $oLinks->length; $i++) {
$oLink = $oLinks->item($i);

$sClasses = $oLink->getAttribute('class');
if (!$sClasses || false === strpos($sClasses, $this->class))
$sClasses = ($sClasses ? $sClasses . ' ' : '') . $this->class;

$oLink->removeAttribute('class');
$oLink->setAttribute("class", $sClasses);
}

if (false === ($s = $dom->saveXML($dom->getElementById($sId)))) // in case of error return original string
return $sHtml;

return mb_substr($s, 52, -6); // strip added tags
}
}

43 changes: 43 additions & 0 deletions inc/classes/BxDolHTMLPurifierFilterLocalIframe.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

class BxDolHTMLPurifierFilterLocalIframe extends HTMLPurifier_Filter
{
public $name = 'LocalIframe';

public function preFilter($sHtml, $config, $context)
{
if (strstr($sHtml, '<iframe')) {
$sHtml = str_ireplace("</iframe>", "", $sHtml);
if (preg_match_all("/<iframe(.*?)>/si", $sHtml, $aResult)) {
foreach ($aResult[1] as $key => $sItem) {
preg_match('/width="([0-9]+)"/', $sItem, $width);
$iWidth = $width[1];
preg_match('/height="([0-9]+)"/', $sItem, $height);
$iHeight = $height[1];
$sDolUrl = preg_quote(BX_DOL_URL_ROOT);
$sIframeUrl = '';
if (preg_match("#({$sDolUrl}[a-zA-Z0-9_=\-\?\&\/]+)#", $sItem, $aMatches))
$sIframeUrl = $aMatches[1];
if (preg_match("#src=\"(((?!//)(?![a-z]+://)(?![a-z]+://))[a-zA-Z0-9_=\-\?\&\/]+)#", $sItem, $aMatches))
$sIframeUrl = $aMatches[1];
if ($sIframeUrl)
$sHtml = str_replace($aResult[0][$key], '<img class="LocalIframe" width="' . $iWidth . '" height="' . $iHeight . '" src="' . $sIframeUrl . '">', $sHtml);
}
}
}
return $sHtml;
}

public function postFilter($sHtml, $config, $context)
{
$sPostRegex = '#<img class="LocalIframe" ([^>]+)>#';
$sHtml = preg_replace_callback($sPostRegex, array($this, 'postFilterCallback'), $sHtml);
return $sHtml;
}

protected function postFilterCallback($aMatches)
{
return '<iframe frameborder="0" allowfullscreen ' . $aMatches[1] . '></iframe>';
}
}

65 changes: 65 additions & 0 deletions inc/classes/BxDolHTMLPurifierFilterYouTube.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

class BxDolHTMLPurifierFilterYouTube extends HTMLPurifier_Filter
{

/**
* @type string
*/
public $name = 'YouTube';

/**
* @param string $html
* @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context
* @return string
*/
public function preFilter($html, $config, $context)
{
$pre_regex = '#<object[^>]+>.+?' .
'(?:http:)?//www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s';
$pre_replace = '<span class="youtube-embed">\1</span>';
return preg_replace($pre_regex, $pre_replace, $html);
}

/**
* @param string $html
* @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context
* @return string
*/
public function postFilter($html, $config, $context)
{
$post_regex = '#<span class="youtube-embed">((?:v|cp)/[A-Za-z0-9\-_=]+)</span>#';
return preg_replace_callback($post_regex, array($this, 'postFilterCallback'), $html);
}

/**
* @param $url
* @return string
*/
protected function armorUrl($url)
{
return str_replace('--', '-&#45;', $url);
}

/**
* @param array $matches
* @return string
*/
protected function postFilterCallback($matches)
{
$url = $this->armorUrl($matches[1]);
return '<object width="425" height="350" type="application/x-shockwave-flash" ' .
'data="//www.youtube.com/' . $url . '">' .
'<param name="movie" value="//www.youtube.com/' . $url . '"></param>' .
'<!--[if IE]>' .
'<embed src="//www.youtube.com/' . $url . '"' .
'type="application/x-shockwave-flash"' .
'wmode="transparent" width="425" height="350" />' .
'<![endif]-->' .
'</object>';
}
}

// vim: et sw=4 sts=4
40 changes: 40 additions & 0 deletions inc/classes/BxDolHTMLPurifierFilterYoutubeIframe.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

class BxDolHTMLPurifierFilterYoutubeIframe extends HTMLPurifier_Filter
{
public $name = 'YouTubeIframe';

public function preFilter($html, $config, $context)
{
if (strstr($html, '<iframe') && (strstr($html, 'youtube.com') || strstr($html, 'youtu.be') || strstr($html, 'youtube-nocookie.com'))) {
$html = str_ireplace("</iframe>", "", $html);
if (preg_match_all("/<iframe(.*?)>/si", $html, $result)) {
foreach ($result[1] as $key => $item) {
preg_match('/width="([0-9]+)"/', $item, $width);
$width = $width[1];
preg_match('/height="([0-9]+)"/', $item, $height);
$height = $height[1];
if (preg_match('/((\/\/www\.youtube\.com\/embed\/)|(\/\/www\.youtube-nocookie\.com\/embed\/)|(\/\/www.youtube.com\/v\/))([a-zA-Z0-9_-]+)/', $item, $id)) {
$id = $id[5];
$sProto = 0 == strncmp('https', BX_DOL_URL_ROOT, 5) ? 'https' : 'http';
$html = str_replace($result[0][$key], '<img class="YouTubeIframe" width="' . $width . '" height="' . $height . '" src="' . $sProto . '://www.youtube-nocookie.com/embed/' . $id . '?rel=0">', $html);
}
}
}
}
return $html;
}

public function postFilter($html, $config, $context)
{
$post_regex = '#<img class="YouTubeIframe" ([^>]+)>#';
$html = preg_replace_callback($post_regex, array($this, 'postFilterCallback'), $html);
return $html;
}

protected function postFilterCallback($matches)
{
return '<iframe frameborder="0" allowfullscreen ' . $matches[1] . '></iframe>';
}
}

10 changes: 0 additions & 10 deletions inc/classes/BxDolImageResize.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@
* @{
*/

spl_autoload_register(function ($sClass) {
// autoload Intervention Image files
$sClass = trim($sClass, '\\');
if (0 === strncmp('Intervention', $sClass, 12)) {
$sFile = BX_DIRECTORY_PATH_PLUGINS . 'intervention-image/' . str_replace('\\', '/', $sClass) . '.php';
if (file_exists($sFile))
require_once($sFile);
}
});

define('IMAGE_ERROR_SUCCESS', 0); ///< operation was successfull
define('IMAGE_ERROR_WRONG_TYPE', 2); ///< operation failed, most probably because incorrect image format(or not image file) was provided

Expand Down
6 changes: 0 additions & 6 deletions inc/classes/BxDolMinify.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@

use MatthiasMullie\Minify;

require_once(BX_DIRECTORY_PATH_PLUGINS . 'matthiasmullie/path-converter/ConverterInterface.php');
require_once(BX_DIRECTORY_PATH_PLUGINS . 'matthiasmullie/path-converter/Converter.php');
require_once(BX_DIRECTORY_PATH_PLUGINS . 'matthiasmullie/minify/Minify.php');
require_once(BX_DIRECTORY_PATH_PLUGINS . 'matthiasmullie/minify/CSS.php');
require_once(BX_DIRECTORY_PATH_PLUGINS . 'matthiasmullie/minify/JS.php');

class BxDolMinify extends BxDolFactory implements iBxDolSingleton
{
protected function __construct()
Expand Down
2 changes: 1 addition & 1 deletion inc/classes/BxDolStorageS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct($aObject)

protected function init ($aObject)
{
require_once(BX_DIRECTORY_PATH_PLUGINS . 'amazon-s3/S3.php');
require_once(BX_DIRECTORY_PATH_PLUGINS . 'unaio/amazon-s3-php-class-hmac-v2/S3.php');
$this->_s3 = new S3(
getParam('sys_storage_s3_access_key'),
getParam('sys_storage_s3_secret_key'),
Expand Down
4 changes: 2 additions & 2 deletions inc/classes/BxDolStorageS3v4.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class BxDolStorageS3v4 extends BxDolStorageS3
{
protected function init ($aObject)
{
require_once(BX_DIRECTORY_PATH_PLUGINS . 'amazon-s3/S3.php');
require_once(BX_DIRECTORY_PATH_PLUGINS . 'amazon-s3/S3v4.php');
require_once(BX_DIRECTORY_PATH_PLUGINS . 'unaio/amazon-s3-php-class-hmac-v2/S3.php');
require_once(BX_DIRECTORY_PATH_PLUGINS . 'tpyo/amazon-s3-php-class/S3.php'); // HMAC v4
$this->_s3 = new S3v4\S3(
getParam('sys_storage_s3_access_key'),
getParam('sys_storage_s3_secret_key'),
Expand Down
3 changes: 0 additions & 3 deletions inc/classes/BxDolTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2178,15 +2178,12 @@ function _compileCss($sAbsolutePath, &$aIncluded)
*/
function _lessCss($mixed)
{
require_once(BX_DIRECTORY_PATH_PLUGINS . 'lessphp/Less.php');

if(is_array($mixed) && isset($mixed['url']) && isset($mixed['path'])) {
$sPathFile = realpath($mixed['path']);
$aInfoFile = pathinfo($sPathFile);
if (!isset($aInfoFile['extension']) || $aInfoFile['extension'] != 'less')
return $mixed;

require_once(BX_DIRECTORY_PATH_PLUGINS . 'lessphp/Cache.php');
$aFiles = array($mixed['path'] => $mixed['url']);
$aOptions = array('cache_dir' => $this->_sCachePublicFolderPath, 'prefix' => $this->_sCssLessPrefix);
$sFile = Less_Cache::Get($aFiles, $aOptions, $this->_oTemplateConfig->aLessConfig);
Expand Down
1 change: 1 addition & 0 deletions inc/params.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
require_once(BX_DIRECTORY_PATH_INC . 'version.inc.php');

spl_autoload_register('bx_autoload');
require BX_DIRECTORY_PATH_PLUGINS . 'autoload.php';

BxDolDb::getInstance()->cacheParams();

Expand Down
11 changes: 2 additions & 9 deletions inc/utils.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,6 @@ function clear_xss($val)
global $oHtmlPurifier;
if (!isset($oHtmlPurifier) && !$GLOBALS['logged']['admin']) {

require_once( BX_DIRECTORY_PATH_PLUGINS . 'htmlpurifier/HTMLPurifier.standalone.php' );

HTMLPurifier_Bootstrap::registerAutoload();

$oConfig = HTMLPurifier_Config::createDefault();
Expand All @@ -593,7 +591,7 @@ function clear_xss($val)
$oConfig->set('HTML.Nofollow', 'true');
}

$oConfig->set('Filter.Custom', array (new HTMLPurifier_Filter_YouTube(), new HTMLPurifier_Filter_YoutubeIframe(), new HTMLPurifier_Filter_AddBxLinksClass(), new HTMLPurifier_Filter_LocalIframe()));
$oConfig->set('Filter.Custom', array (new BxDolHTMLPurifierFilterYouTube(), new BxDolHTMLPurifierFilterYoutubeIframe(), new BxDolHTMLPurifierFilterAddBxLinksClass(), new BxDolHTMLPurifierFilterLocalIframe()));

$oConfig->set('HTML.DefinitionID', 'html5-definitions');
$oConfig->set('HTML.DefinitionRev', 1);
Expand Down Expand Up @@ -781,11 +779,6 @@ function bx_autoload($sClassName)
{
if (0 === strncmp($sClassName, 'BxDol', 5) || 0 === strncmp($sClassName, 'BxBase', 6) || 0 === strncmp($sClassName, 'BxTempl', 7))
bx_import($sClassName);
else {
if (0 === strpos($sClassName, 'Akeeba\Engine\Postproc\Connector\S3v4')) {
require_once(BX_DIRECTORY_PATH_PLUGINS . 'akeeba-s3/src' . str_replace('\\', '/', substr($sClassName, 37)) . '.php');
}
}
}

/**
Expand Down Expand Up @@ -953,7 +946,7 @@ function bx_file_get_contents($sFileUrl, $aParams = array(), $sMethod = 'get', $
$sResult = curl_exec($rConnect);

if (curl_errno($rConnect) == 60) { // CURLE_SSL_CACERT
curl_setopt($rConnect, CURLOPT_CAINFO, BX_DIRECTORY_PATH_PLUGINS . 'curl/cacert.pem');
curl_setopt($rConnect, CURLOPT_CAINFO, BX_DIRECTORY_PATH_PLUGINS . 'curl/cacert/cacert.pem');
$sResult = curl_exec($rConnect);
}

Expand Down
1 change: 0 additions & 1 deletion install/classes/BxDolInstallView.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ protected function _getFilesJS()

protected function _getInlineCSS()
{
require_once($this->_sDirPlugins . 'lessphp/Less.php');
$oLessParser = new Less_Parser();

$oConfigBase = new BxBaseConfig();
Expand Down
2 changes: 2 additions & 0 deletions install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
require_once(BX_INSTALL_DIR_CLASSES . 'BxDolInstallLang.php');
require_once(BX_INSTALL_DIR_CLASSES . 'BxDolInstallSiteConfig.php');

require BX_INSTALL_DIR_PLUGINS . 'autoload.php';

$oController = new BxDolInstallController ();
$oController->run(isset($_REQUEST['action']) ? $_REQUEST['action'] : '');

Expand Down
2 changes: 1 addition & 1 deletion modules/boonex/antispam/classes/BxAntispamAkismet.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct($iAccoutId = 0)
parent::__construct();
$sKey = getParam('bx_antispam_akismet_api_key');
if ($sKey && $oAccount = BxDolAccount::getInstance((int)$iAccoutId)) {
require_once (BX_DIRECTORY_PATH_PLUGINS . 'akismet/Akismet.class.php');
require_once (BX_DIRECTORY_PATH_PLUGINS . 'achingbrain/php5-akismet/src/main/php/net/achingbrain/Akismet.class.php');
$this->oAkismet = new Akismet(BX_DOL_URL_ROOT, $sKey);

$oProfile = BxDolProfile::getInstanceByAccount((int)$iAccoutId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
class BxAntispamProfanityFilter extends BxDol
{
protected $oProfanityFilter = null;
protected $sPluginPath = BX_DIRECTORY_PATH_PLUGINS . 'banbuilder/src/';
protected $sPluginPath = BX_DIRECTORY_PATH_PLUGINS . 'snipe/banbuilder/src/';

public function __construct()
{
parent::__construct();

require_once ($this->sPluginPath .'CensorWords.php');
$sClassName = 'Snipe\BanBuilder\CensorWords';
$this->oProfanityFilter = new $sClassName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ function __construct(&$aModule)
{
parent::__construct($aModule);

require_once(BX_DIRECTORY_PATH_PLUGINS . 'facebook-php-sdk/src/Facebook/autoload.php');

// Create our Application instance.
$this -> oFacebook = null;

Expand Down
2 changes: 0 additions & 2 deletions modules/boonex/payment/classes/BxPaymentProviderChargebee.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
* @{
*/

require_once(BX_DIRECTORY_PATH_PLUGINS . 'chargebee/ChargeBee.php');

define('CBEE_MODE_LIVE', 1);
define('CBEE_MODE_TEST', 2);

Expand Down
2 changes: 1 addition & 1 deletion modules/boonex/payment/classes/BxPaymentProviderPayPal.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ protected function _readValidationData($sConnectionUrl, $sRequest)

$sResponse = curl_exec($rConnect);
if(curl_errno($rConnect) == 60) { // CURLE_SSL_CACERT
curl_setopt($rConnect, CURLOPT_CAINFO, BX_DIRECTORY_PATH_PLUGINS . 'curl/cacert.pem');
curl_setopt($rConnect, CURLOPT_CAINFO, BX_DIRECTORY_PATH_PLUGINS . 'curl/cacert/cacert.pem');
$sResponse = curl_exec($rConnect);
}

Expand Down
2 changes: 0 additions & 2 deletions modules/boonex/payment/classes/BxPaymentProviderPayPalApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
*
*/

require_once(BX_DIRECTORY_PATH_PLUGINS . 'paypal/autoload.php');

use PayPalCheckoutSdk\Core\PayPalHttpClient;
use PayPalCheckoutSdk\Core\SandboxEnvironment;
use PayPalCheckoutSdk\Core\ProductionEnvironment;
Expand Down
2 changes: 0 additions & 2 deletions modules/boonex/payment/classes/BxPaymentProviderRecurly.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
* @{
*/

require_once(BX_DIRECTORY_PATH_PLUGINS . 'recurly/recurly.php');

define('RCRL_MODE_LIVE', 1);
define('RCRL_MODE_TEST', 2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
* @{
*/

require_once(BX_DIRECTORY_PATH_PLUGINS . 'stripe/init.php');

define('STRP_MODE_LIVE', 1);
define('STRP_MODE_TEST', 2);

Expand Down
Loading

0 comments on commit 559a1ef

Please sign in to comment.