first commit

This commit is contained in:
2024-10-28 22:14:22 +01:00
commit b65352c452
40581 changed files with 5712079 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
drwxr-xr-x 3 30094 users 7 Oct 6 10:16 .
drwxr-xr-x 115 30094 users 117 Oct 6 10:16 ..
-rw-rw-r-- 1 30094 users 589 Apr 5 2022 config_pl.xml
-rw-r--r-- 1 30094 users 475 Mar 22 2022 index.php
-rw-r--r-- 1 30094 users 46107 Mar 22 2022 logo.png
-rw-r--r-- 1 30094 users 14236 Mar 22 2022 minifycode.php
drwxr-xr-x 3 30094 users 4 Oct 6 10:16 views

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>minifycode</name>
<displayName><![CDATA[Minify HTML CSS JS]]></displayName>
<version><![CDATA[2.1.2]]></version>
<description><![CDATA[Minify HTML CSS JS is a very small and efficient module]]></description>
<author><![CDATA[Keshva Thakur]]></author>
<tab><![CDATA[front_office_features]]></tab>
<confirmUninstall><![CDATA[Are you sure you want to uninstall?]]></confirmUninstall>
<is_configurable>1</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,17 @@
<?php
/**
* 2017 Keshva Thakur
* @author Keshva Thakur
* @copyright Keshva Thakur
* @license https://www.prestashop.com/en/osl-license
* @version 1.1.1
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

BIN
modules/minifycode/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@@ -0,0 +1,373 @@
<?php
/**
* 2017 Keshva Thakur
* @author Keshva Thakur
* @copyright Keshva Thakur
* @license https://www.prestashop.com/en/osl-license
* @version 1.1.2
*/
if (!defined('_PS_VERSION_'))
exit;
class MINIFYCODE extends Module {
public function __construct() {
$this->name = 'minifycode';
$this->description = 'Minify HTML CSS JS';
$this->tab = 'front_office_features';
$this->version = '2.1.2';
$this->author = 'Keshva Thakur';
$this->need_instance = 0;
$this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_);
$this->bootstrap = true;
$this->module_key = '600c149930fb6d0da957b6c9bc6fb288';
$this->author_address = '0xD04CFFC02eCb7ea7Aa8D92c47607fD79f2C5c901';
$this->_html = '';
$this->unique_string = '';
$this->valid = '';
$this->simple_content_files_location = $this->_path . 'views/';
$this->ignore_changes_content_changes = false;
parent::__construct();
$this->displayName = $this->l('Minify HTML CSS JS');
$this->description = $this->l('Minify HTML CSS JS is a very small and efficient module');
$this->confirmUninstall = $this->l('Are you sure you want to uninstall?');
if (Configuration::get('html_minify_ps')) {
if (!function_exists('smartyMinifyHTMLCustomCode')) {
$this->context->smarty->registerFilter(
'output', __CLASS__ . '::smartyMinifyHTMLCustomCode'
);
}
}
if (Configuration::get('js_minify_ps')) {
if (!function_exists('smartyPackJSinHTMLCustom')) {
$this->context->smarty->registerFilter(
'output', __CLASS__ . '::smartyPackJSinHTMLCustom'
);
}
}
}
public static function smartyMinifyHTMLCustomCode($tpl_output, Smarty_Internal_Template $template) {
$context = Context::getContext();
if (isset($context->controller) && in_array($context->controller->php_self, array('pdf-invoice', 'pdf-order-return', 'pdf-order-slip'))) {
return $tpl_output;
}
$class = new MINIFYCODE();
$tpl_output = $class->minifyHTML($tpl_output);
return $tpl_output;
}
public static function smartyPackJSinHTMLCustom($tpl_output, Smarty_Internal_Template $template) {
$context = Context::getContext();
if (isset($context->controller) && in_array($context->controller->php_self, array('pdf-invoice', 'pdf-order-return', 'pdf-order-slip'))) {
return $tpl_output;
}
$class = new MINIFYCODE();
$tpl_output = $class->minifyJS($tpl_output);
return $tpl_output;
}
public function minifyHTML($html_content) {
if (strlen($html_content) > 0) {
require_once('views/templates/tools/minify_html/minify_html.class.php');
$html_content = str_replace(chr(194) . chr(160), '&nbsp;', $html_content);
if (trim($minified_content = Minify_HTML::minify($html_content, array('cssMinifier', 'jsMinifier'))) != '') {
$html_content = $minified_content;
}
return $html_content;
}
return false;
}
public function minifyJS($tpl_output) {
$context = Context::getContext();
if (isset($context->controller) && in_array($context->controller->php_self, array('pdf-invoice', 'pdf-order-return', 'pdf-order-slip'))) {
return $tpl_output;
}
$class = new MINIFYCODE();
$tpl_output = $class->packJSinHTML($tpl_output);
return $tpl_output;
}
public static $pattern_js = '/(<\s*script(?:\s+[^>]*(?:javascript|src)[^>]*)?\s*>)(.*)(<\s*\/script\s*[^>]*>)/Uims';
protected static $pattern_keepinline = 'data-keepinline';
public static function packJSinHTML($html_content) {
if (strlen($html_content) > 0) {
$html_content_copy = $html_content;
$class = new MINIFYCODE();
if (!preg_match('/' . MINIFYCODE::$pattern_keepinline . '/', $html_content)) {
$html_content = preg_replace_callback(
MINIFYCODE::$pattern_js, array('MINIFYCODE', 'packJSinHTMLpregCallback'), $html_content, $class->getBackTrackLimit());
// If the string is too big preg_replace return an error
// In this case, we don't compress the content
if (function_exists('preg_last_error') && preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR) {
if (_PS_MODE_DEV_) {
Tools::error_log('ERROR: PREG_BACKTRACK_LIMIT_ERROR in function packJSinHTML');
}
return $html_content_copy;
}
}
return $html_content;
}
return false;
}
public static function getBackTrackLimit() {
static $limit = null;
if ($limit === null) {
$limit = @ini_get('pcre.backtrack_limit');
if (!$limit) {
$limit = -1;
}
}
return $limit;
}
public static function packJSinHTMLpregCallback($preg_matches) {
if (!(trim($preg_matches[2]))) {
return $preg_matches[0];
}
$preg_matches[1] = $preg_matches[1] . '/* <![CDATA[ */';
$class = new MINIFYCODE();
$preg_matches[2] = $class->packJS($preg_matches[2]);
$preg_matches[count($preg_matches) - 1] = '/* ]]> */' . $preg_matches[count($preg_matches) - 1];
unset($preg_matches[0]);
$output = implode('', $preg_matches);
return $output;
}
public static function packJS($js_content) {
if (!empty($js_content)) {
require_once('views/templates/tools/js_minify/jsmin.php');
try {
$js_content = JSMin::minify($js_content);
} catch (Exception $e) {
if (_PS_MODE_DEV_) {
echo $e->getMessage();
}
return ';' . trim($js_content, ';') . ';';
}
}
return ';' . trim($js_content, ';') . ';';
}
public function install() {
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
if (!parent::install() || !$this->registerHook('header') || !$this->EnableHTMLCompress()) {
Configuration::updateValue('html_minify_ps', 0);
Configuration::updateValue('js_minify_ps', 0);
return false;
}
return true;
}
public function uninstall() {
if (!parent::uninstall() || !$this->DisableHTMLCompress()) {
Configuration::deleteByName('html_minify_ps');
Configuration::deleteByName('js_minify_ps');
return false;
}
return true;
}
public function customCopy($source, $dest, $options = array('folderPermission' => '0755', 'filePermission' => '0644')) {
$result = false;
if (is_file($source)) {
if ($dest[strlen($dest) - 1] == '/') {
if (!file_exists($dest)) {
cmfcDirectory::makeAll($dest, $options['folderPermission'], true);
}
$__dest = $dest . "/" . basename($source);
} else {
$__dest = $dest;
}
$result = copy($source, $__dest);
@chmod($__dest, $options['filePermission']);
} elseif (is_dir($source)) {
if ($dest[strlen($dest) - 1] == '/') {
if ($source[strlen($source) - 1] == '/') {
//Copy only contents
} else {
//Change parent itself and its contents
$dest = $dest . basename($source);
if (!file_exists($dest))
mkdir($dest);
@chmod($dest, $options['filePermission']);
}
} else {
if ($source[strlen($source) - 1] == '/') {
//Copy parent directory with new name and all its content
if (!file_exists($dest))
mkdir($dest, $options['folderPermission']);
@chmod($dest, $options['filePermission']);
} else {
//Copy parent directory with new name and all its content
if (!file_exists($dest))
mkdir($dest, $options['folderPermission']);
@chmod($dest, $options['filePermission']);
}
}
$dirHandle = opendir($source);
while ($file = readdir($dirHandle)) {
if ($file != "." && $file != "..") {
if (!is_dir($source . "/" . $file)) {
$__dest = $dest . "/" . $file;
} else {
$__dest = $dest . "/" . $file;
}
//echo "$source/$file ||| $__dest<br />";
$result = $this->customCopy($source . "/" . $file, $__dest, $options);
}
}
closedir($dirHandle);
} else {
$result = false;
}
return $result;
}
function mycopy($s1, $s2) {
$path = pathinfo($s2);
if (!file_exists($path['dirname'])) {
mkdir($path['dirname'], 0777, true);
}
if (!copy($s1, $s2)) {
echo "copy failed \n";
}
}
public function DisableHTMLCompress() {
return true;
}
public function EnableHTMLCompress() {
if (!file_exists(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'tools' . DIRECTORY_SEPARATOR . 'minify_html' . DIRECTORY_SEPARATOR . 'minify_html.class.php')) {
// $code_files = _PS_MODULE_DIR_ . $this->name . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'tools' . DIRECTORY_SEPARATOR;
// $dest = _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'tools' . DIRECTORY_SEPARATOR;
// $this->customCopy($code_files, $dest);
}
return true;
}
public function DisableCSSCompress() {
return true;
}
public function EnableCSSCompress() {
return true;
}
public function DisableJSCompress() {
return true;
}
public function EnableJSCompress() {
if (!file_exists(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'tools' . DIRECTORY_SEPARATOR . 'minify_html' . DIRECTORY_SEPARATOR . 'jsmin.php')) {
// $code_files = _PS_MODULE_DIR_ . $this->name . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'tools' . DIRECTORY_SEPARATOR;
// $dest = _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'tools' . DIRECTORY_SEPARATOR;
// $this->customCopy($code_files, $dest);
}
return true;
}
public function getContent() {
$this->processSubmit();
return $this->displayForm();
}
public function processSubmit() {
if (Tools::isSubmit('submit' . $this->name)) {
$on_off_option = Tools::getValue('html_minify_ps');
if ($on_off_option == '1') {
$this->EnableHTMLCompress();
Configuration::updateValue('html_minify_ps', $on_off_option);
$this->_html .= $this->displayConfirmation("Minify HTML enable sucessfully");
}
if ($on_off_option == '0') {
$this->DisableHTMLCompress();
Configuration::updateValue('html_minify_ps', $on_off_option);
$this->_html .= $this->displayConfirmation("Minify HTML disable sucessfully");
}
$on_off_css = Tools::getValue('css_minify_ps');
if ($on_off_css == '1') {
$this->EnableCSSCompress();
Configuration::updateValue('PS_CSS_THEME_CACHE', $on_off_css);
$this->_html .= $this->displayConfirmation("Minify CSS enable sucessfully");
}
if ($on_off_css == '0') {
$this->DisableCSSCompress();
Configuration::updateValue('PS_CSS_THEME_CACHE', $on_off_css);
$this->_html .= $this->displayConfirmation("Minify CSS disable sucessfully");
}
$on_off_js = Tools::getValue('js_minify_ps');
if ($on_off_js == '1') {
$this->EnableJSCompress();
Configuration::updateValue('js_minify_ps', $on_off_js);
$this->_html .= $this->displayConfirmation("Minify JS enable sucessfully");
}
if ($on_off_js == '0') {
$this->DisableJSCompress();
Configuration::updateValue('js_minify_ps', $on_off_js);
$this->_html .= $this->displayConfirmation("Minify JS disable sucessfully");
}
}
}
public function displayForm() {
$fields_form = array();
$html_minify_ps = Configuration::get('html_minify_ps');
$css_minify_ps = Configuration::get('PS_CSS_THEME_CACHE');
$js_minify_ps = Configuration::get('js_minify_ps');
$fields_form[]['form'] = array(
'input' => array(
array(
'name' => 'topform',
'type' => 'topform',
'html_minify_ps' => $html_minify_ps,
'css_minify_ps' => $css_minify_ps,
'js_minify_ps' => $js_minify_ps,
),
),
);
$helper = new HelperForm();
$helper->module = $this;
$helper->name_controller = $this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
return $this->_html . $helper->generateForm($fields_form);
}
}

View File

View File

@@ -0,0 +1,4 @@
drwxr-xr-x 3 30094 users 4 Oct 6 10:16 .
drwxr-xr-x 3 30094 users 7 Oct 6 10:16 ..
-rw-r--r-- 1 30094 users 477 Mar 22 2022 index.php
drwxr-xr-x 4 30094 users 5 Oct 6 10:16 templates

View File

@@ -0,0 +1,18 @@
<?php
/**
* 2017 Keshva Thakur
* @author Keshva Thakur
* @copyright Keshva Thakur
* @license https://www.prestashop.com/en/osl-license
* @version 1.1.1
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,5 @@
drwxr-xr-x 4 30094 users 5 Oct 6 10:16 .
drwxr-xr-x 3 30094 users 4 Oct 6 10:16 ..
drwxr-xr-x 3 30094 users 4 Oct 6 10:16 admin
-rw-r--r-- 1 30094 users 477 Mar 22 2022 index.php
drwxr-xr-x 4 30094 users 5 Oct 6 10:16 tools

View File

@@ -0,0 +1,4 @@
drwxr-xr-x 3 30094 users 4 Oct 6 10:16 .
drwxr-xr-x 4 30094 users 5 Oct 6 10:16 ..
drwxr-xr-x 3 30094 users 4 Oct 6 10:16 _configure
-rw-r--r-- 1 30094 users 478 Mar 22 2022 index.php

View File

@@ -0,0 +1,4 @@
drwxr-xr-x 3 30094 users 4 Oct 6 10:16 .
drwxr-xr-x 3 30094 users 4 Oct 6 10:16 ..
drwxr-xr-x 3 30094 users 4 Oct 6 10:16 helpers
-rw-r--r-- 1 30094 users 477 Mar 22 2022 index.php

View File

@@ -0,0 +1,4 @@
drwxr-xr-x 3 30094 users 4 Oct 6 10:16 .
drwxr-xr-x 3 30094 users 4 Oct 6 10:16 ..
drwxr-xr-x 2 30094 users 4 Oct 6 10:16 form
-rw-r--r-- 1 30094 users 476 Mar 22 2022 index.php

View File

@@ -0,0 +1,4 @@
drwxr-xr-x 2 30094 users 4 Oct 6 10:16 .
drwxr-xr-x 3 30094 users 4 Oct 6 10:16 ..
-rw-r--r-- 1 30094 users 5833 Mar 22 2022 form.tpl
-rw-r--r-- 1 30094 users 477 Mar 22 2022 index.php

View File

@@ -0,0 +1,113 @@
{*
* @author keshva
* @copyright 2017
*}
{extends file="helpers/form/form.tpl"}
{block name="label"}
{if $input.type == 'topform'}
<div class="panel ">
<div class="panel-heading">
<i class="icon-cogs"></i>
{l s='Setting ' mod='minifycode'}
</div>
<div class="form-wrapper">
<div class="row" style="background-color: transparent;" >
<div id="tab-description" class="plugin-description section ">
<form action="" method="post" id="orderreferenceform">
<div class="form-wrapper">
<div class="form-group">
<label class="control-label col-lg-3">{l s='Minify HTML' mod='minifycode'}</label>
<div class="col-lg-9 ">
<span class="switch prestashop-switch fixed-width-lg">
<input type="radio" name="html_minify_ps" id="ref_on" value="1" {if $input.html_minify_ps == '1'} checked="checked" {/if}>
<label for="ref_on">Yes</label>
<input type="radio" name="html_minify_ps" id="ref_off" value="0" {if $input.html_minify_ps == '0'} checked="checked" {/if}>
<label for="ref_off">No</label>
<a class="slide-button btn"></a>
</span>
<p class="help-block"></p>
</div>
</div>
</div>
<div class="form-wrapper">
<div class="form-group">
<label class="control-label col-lg-3">{l s='Minify CSS' mod='minifycode'}</label>
<div class="col-lg-9 ">
<span class="switch prestashop-switch fixed-width-lg">
<input type="radio" name="css_minify_ps" id="ref_on1" value="1" {if $input.css_minify_ps == '1'} checked="checked" {/if}>
<label for="ref_on1">Yes</label>
<input type="radio" name="css_minify_ps" id="ref_off1" value="0" {if $input.css_minify_ps == '0'} checked="checked" {/if}>
<label for="ref_off1">No</label>
<a class="slide-button btn"></a>
</span>
<p class="help-block"></p>
</div>
</div>
</div>
<div class="form-wrapper">
<div class="form-group">
<label class="control-label col-lg-3">{l s='Minify JS' mod='minifycode'}</label>
<div class="col-lg-9 ">
<span class="switch prestashop-switch fixed-width-lg">
<input type="radio" name="js_minify_ps" id="ref_on12" value="1" {if $input.js_minify_ps == '1'} checked="checked" {/if}>
<label for="ref_on12">Yes</label>
<input type="radio" name="js_minify_ps" id="ref_off12" value="0" {if $input.js_minify_ps == '0'} checked="checked" {/if}>
<label for="ref_off12">No</label>
<a class="slide-button btn"></a>
</span>
<p class="help-block"></p>
</div>
</div>
</div>
<div class="col-lg-12 ">
<div class="panel-footer">
<button type="submit" value="1" id="module_form_submit_btn" name="submitminifycode" class="btn btn-default pull-right">
<i class="process-icon-save"></i> {l s='Save' mod='minifycode'}
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="panel ">
<div class="panel-heading">
<i class="icon-info"></i>
{l s='Minify HTML CSS JS' mod='minifycode'}
</div>
<div class="form-wrapper">
<div class="row" style="background-color: transparent;" >
<div id="tab-description" class="plugin-description section ">
<div id="tab-description" class="plugin-description section ">
<h4 id="description-header">Description</h4>
<div id="tab-description" class="plugin-description section ">
<p><b> Note</b> : Minify HTML CSS JS Module will compress your HTML CSS JS by shortening URLs and removing standard comments and whitespace; including new lines .<br>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
{/if}
{/block}

View File

@@ -0,0 +1,18 @@
<?php
/**
* 2017 Keshva Thakur
* @author Keshva Thakur
* @copyright Keshva Thakur
* @license https://www.prestashop.com/en/osl-license
* @version 1.1.1
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,17 @@
<?php
/**
* 2017 Keshva Thakur
* @author Keshva Thakur
* @copyright Keshva Thakur
* @license https://www.prestashop.com/en/osl-license
* @version 1.1.2
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,18 @@
<?php
/**
* 2017 Keshva Thakur
* @author Keshva Thakur
* @copyright Keshva Thakur
* @license https://www.prestashop.com/en/osl-license
* @version 1.1.2
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,18 @@
<?php
/**
* 2017 Keshva Thakur
* @author Keshva Thakur
* @copyright Keshva Thakur
* @license https://www.prestashop.com/en/osl-license
* @version 1.1.1
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,17 @@
<?php
/**
* 2017 Keshva Thakur
* @author Keshva Thakur
* @copyright Keshva Thakur
* @license https://www.prestashop.com/en/osl-license
* @version 1.1.1
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,5 @@
drwxr-xr-x 4 30094 users 5 Oct 6 10:16 .
drwxr-xr-x 4 30094 users 5 Oct 6 10:16 ..
-rw-r--r-- 1 30094 users 1288 Mar 22 2022 index.php
drwxr-xr-x 2 30094 users 4 Oct 6 10:16 js_minify
drwxr-xr-x 2 30094 users 4 Oct 6 10:16 minify_html

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2016 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,4 @@
drwxr-xr-x 2 30094 users 4 Oct 6 10:16 .
drwxr-xr-x 4 30094 users 5 Oct 6 10:16 ..
-rw-r--r-- 1 30094 users 1288 Mar 22 2022 index.php
-rw-r--r-- 1 30094 users 13386 Mar 22 2022 jsmin.php

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2016 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,385 @@
<?php
/**
* JSMin.php - modified PHP implementation of Douglas Crockford's JSMin.
*
* <code>
* $minifiedJs = JSMin::minify($js);
* </code>
*
* This is a modified port of jsmin.c. Improvements:
*
* Does not choke on some regexp literals containing quote characters. E.g. /'/
*
* Spaces are preserved after some add/sub operators, so they are not mistakenly
* converted to post-inc/dec. E.g. a + ++b -> a+ ++b
*
* Preserves multi-line comments that begin with /*!
*
* PHP 5 or higher is required.
*
* Permission is hereby granted to use this version of the library under the
* same terms as jsmin.c, which has the following license:
*
* --
* Copyright (c) 2002 Douglas Crockford (www.crockford.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* The Software shall be used for Good, not Evil.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* --
*
* @package JSMin
* @author Ryan Grove <ryan@wonko.com> (PHP port)
* @author Steve Clay <steve@mrclay.org> (modifications + cleanup)
* @author Andrea Giammarchi <http://www.3site.eu> (spaceBeforeRegExp)
* @copyright 2002 Douglas Crockford <douglas@crockford.com> (jsmin.c)
* @copyright 2008 Ryan Grove <ryan@wonko.com> (PHP port)
* @license http://opensource.org/licenses/mit-license.php MIT License
* @link http://code.google.com/p/jsmin-php/
*/
class JSMin {
const ORD_LF = 10;
const ORD_SPACE = 32;
const ACTION_KEEP_A = 1;
const ACTION_DELETE_A = 2;
const ACTION_DELETE_A_B = 3;
protected $a = "\n";
protected $b = '';
protected $input = '';
protected $inputIndex = 0;
protected $inputLength = 0;
protected $lookAhead = null;
protected $output = '';
protected $lastByteOut = '';
/**
* Minify Javascript.
*
* @param string $js Javascript to be minified
*
* @return string
*/
public static function minify($js)
{
$jsmin = new JSMin($js);
return $jsmin->min();
}
/**
* @param string $input
*/
public function __construct($input)
{
$this->input = $input;
}
/**
* Perform minification, return result
*
* @return string
*/
public function min()
{
if ($this->output !== '') { // min already run
return $this->output;
}
$mbIntEnc = null;
if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) {
$mbIntEnc = mb_internal_encoding();
mb_internal_encoding('8bit');
}
$this->input = str_replace("\r\n", "\n", $this->input);
$this->inputLength = strlen($this->input);
$this->action(self::ACTION_DELETE_A_B);
while ($this->a !== null) {
// determine next command
$command = self::ACTION_KEEP_A; // default
if ($this->a === ' ') {
if (($this->lastByteOut === '+' || $this->lastByteOut === '-')
&& ($this->b === $this->lastByteOut)) {
// Don't delete this space. If we do, the addition/subtraction
// could be parsed as a post-increment
} elseif (! $this->isAlphaNum($this->b)) {
$command = self::ACTION_DELETE_A;
}
} elseif ($this->a === "\n") {
if ($this->b === ' ') {
$command = self::ACTION_DELETE_A_B;
// in case of mbstring.func_overload & 2, must check for null b,
// otherwise mb_strpos will give WARNING
} elseif ($this->b === null
|| (false === strpos('{[(+-', $this->b)
&& ! $this->isAlphaNum($this->b))) {
$command = self::ACTION_DELETE_A;
}
} elseif (! $this->isAlphaNum($this->a)) {
if ($this->b === ' '
|| ($this->b === "\n"
&& (false === strpos('}])+-"\'', $this->a)))) {
$command = self::ACTION_DELETE_A_B;
}
}
$this->action($command);
}
$this->output = trim($this->output);
if ($mbIntEnc !== null) {
mb_internal_encoding($mbIntEnc);
}
return $this->output;
}
/**
* ACTION_KEEP_A = Output A. Copy B to A. Get the next B.
* ACTION_DELETE_A = Copy B to A. Get the next B.
* ACTION_DELETE_A_B = Get the next B.
*
* @param int $command
* @throws JSMin_UnterminatedRegExpException|JSMin_UnterminatedStringException
*/
protected function action($command)
{
if ($command === self::ACTION_DELETE_A_B
&& $this->b === ' '
&& ($this->a === '+' || $this->a === '-')) {
// Note: we're at an addition/substraction operator; the inputIndex
// will certainly be a valid index
if ($this->input[$this->inputIndex] === $this->a) {
// This is "+ +" or "- -". Don't delete the space.
$command = self::ACTION_KEEP_A;
}
}
switch ($command) {
case self::ACTION_KEEP_A:
$this->output .= $this->a;
$this->lastByteOut = $this->a;
// fallthrough
case self::ACTION_DELETE_A:
$this->a = $this->b;
if ($this->a === "'" || $this->a === '"') { // string literal
$str = $this->a; // in case needed for exception
while (true) {
$this->output .= $this->a;
$this->lastByteOut = $this->a;
$this->a = $this->get();
if ($this->a === $this->b) { // end quote
break;
}
if (ord($this->a) <= self::ORD_LF) {
throw new JSMin_UnterminatedStringException(
"JSMin: Unterminated String at byte "
. $this->inputIndex . ": {$str}");
}
$str .= $this->a;
if ($this->a === '\\') {
$this->output .= $this->a;
$this->lastByteOut = $this->a;
$this->a = $this->get();
$str .= $this->a;
}
}
}
// fallthrough
case self::ACTION_DELETE_A_B:
$this->b = $this->next();
if ($this->b === '/' && $this->isRegexpLiteral()) { // RegExp literal
$this->output .= $this->a . $this->b;
$pattern = '/'; // in case needed for exception
while (true) {
$this->a = $this->get();
$pattern .= $this->a;
if ($this->a === '/') { // end pattern
break; // while (true)
} elseif ($this->a === '\\') {
$this->output .= $this->a;
$this->a = $this->get();
$pattern .= $this->a;
} elseif (ord($this->a) <= self::ORD_LF) {
throw new JSMin_UnterminatedRegExpException(
"JSMin: Unterminated RegExp at byte "
. $this->inputIndex .": {$pattern}");
}
$this->output .= $this->a;
$this->lastByteOut = $this->a;
}
$this->b = $this->next();
}
// end case ACTION_DELETE_A_B
}
}
/**
* @return bool
*/
protected function isRegexpLiteral()
{
if (false !== strpos("\n{;(,=:[!&|?", $this->a)) { // we aren't dividing
return true;
}
if (' ' === $this->a) {
$length = strlen($this->output);
if ($length < 2) { // weird edge case
return true;
}
// you can't divide a keyword
if (preg_match('/(?:case|else|in|return|typeof)$/', $this->output, $m)) {
if ($this->output === $m[0]) { // odd but could happen
return true;
}
// make sure it's a keyword, not end of an identifier
$charBeforeKeyword = substr($this->output, $length - strlen($m[0]) - 1, 1);
if (! $this->isAlphaNum($charBeforeKeyword)) {
return true;
}
}
}
return false;
}
/**
* Get next char. Convert ctrl char to space.
*
* @return string
*/
protected function get()
{
$c = $this->lookAhead;
$this->lookAhead = null;
if ($c === null) {
if ($this->inputIndex < $this->inputLength) {
$c = $this->input[$this->inputIndex];
$this->inputIndex += 1;
} else {
return null;
}
}
if ($c === "\r" || $c === "\n") {
return "\n";
}
if (ord($c) < self::ORD_SPACE) { // control char
return ' ';
}
return $c;
}
/**
* Get next char. If is ctrl character, translate to a space or newline.
*
* @return string
*/
protected function peek()
{
$this->lookAhead = $this->get();
return $this->lookAhead;
}
/**
* Is $c a letter, digit, underscore, dollar sign, escape, or non-ASCII?
*
* @param string $c
*
* @return bool
*/
protected function isAlphaNum($c)
{
return (preg_match('/^[0-9a-zA-Z_\\$\\\\]$/', $c) || ord($c) > 126);
}
/**
* @return string
*/
protected function singleLineComment()
{
$comment = '';
while (true) {
$get = $this->get();
$comment .= $get;
if (ord($get) <= self::ORD_LF) { // EOL reached
// if IE conditional comment
if (preg_match('/^\\/@(?:cc_on|if|elif|else|end)\\b/', $comment)) {
return "/{$comment}";
}
return $get;
}
}
}
/**
* @return string
* @throws JSMin_UnterminatedCommentException
*/
protected function multipleLineComment()
{
$this->get();
$comment = '';
while (true) {
$get = $this->get();
if ($get === '*') {
if ($this->peek() === '/') { // end of comment reached
$this->get();
// if comment preserved by YUI Compressor
if (0 === strpos($comment, '!')) {
return "\n/*!" . substr($comment, 1) . "*/\n";
}
// if IE conditional comment
if (preg_match('/^@(?:cc_on|if|elif|else|end)\\b/', $comment)) {
return "/*{$comment}*/";
}
return ' ';
}
} elseif ($get === null) {
throw new JSMin_UnterminatedCommentException(
"JSMin: Unterminated comment at byte "
. $this->inputIndex . ": /*{$comment}");
}
$comment .= $get;
}
}
/**
* Get the next character, skipping over comments.
* Some comments may be preserved.
*
* @return string
*/
protected function next()
{
$get = $this->get();
if ($get !== '/') {
return $get;
}
switch ($this->peek()) {
case '/': return $this->singleLineComment();
case '*': return $this->multipleLineComment();
default: return $get;
}
}
}
class JSMin_UnterminatedStringException extends Exception {}
class JSMin_UnterminatedCommentException extends Exception {}
class JSMin_UnterminatedRegExpException extends Exception {}

View File

@@ -0,0 +1,4 @@
drwxr-xr-x 2 30094 users 4 Oct 6 10:16 .
drwxr-xr-x 4 30094 users 5 Oct 6 10:16 ..
-rw-r--r-- 1 30094 users 1288 Mar 22 2022 index.php
-rw-r--r-- 1 30094 users 8273 Mar 22 2022 minify_html.class.php

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2016 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,247 @@
<?php
/**
* Class Minify_HTML
* @package Minify
*/
/**
* Compress HTML
*
* This is a heavy regex-based removal of whitespace, unnecessary comments and
* tokens. IE conditional comments are preserved. There are also options to have
* STYLE and SCRIPT blocks compressed by callback functions.
*
* A test suite is available.
*
* @package Minify
* @author Stephen Clay <steve@mrclay.org>
*/
class Minify_HTML {
/**
* @var boolean
*/
protected $_jsCleanComments = true;
/**
* "Minify" an HTML page
*
* @param string $html
*
* @param array $options
*
* 'cssMinifier' : (optional) callback function to process content of STYLE
* elements.
*
* 'jsMinifier' : (optional) callback function to process content of SCRIPT
* elements. Note: the type attribute is ignored.
*
* 'xhtml' : (optional boolean) should content be treated as XHTML1.0? If
* unset, minify will sniff for an XHTML doctype.
*
* @return string
*/
/* PrestaShop
* added a limit for all preg_replace_callback
*/
public static function minify($html, $options = array()) {
$min = new self($html, $options);
return $min->process();
}
/**
* Create a minifier object
*
* @param string $html
*
* @param array $options
*
* 'cssMinifier' : (optional) callback function to process content of STYLE
* elements.
*
* 'jsMinifier' : (optional) callback function to process content of SCRIPT
* elements. Note: the type attribute is ignored.
*
* 'jsCleanComments' : (optional) whether to remove HTML comments beginning and end of script block
*
* 'xhtml' : (optional boolean) should content be treated as XHTML1.0? If
* unset, minify will sniff for an XHTML doctype.
*
* @return null
*/
public function __construct($html, $options = array())
{
$this->_html = str_replace("\r\n", "\n", trim($html));
if (isset($options['xhtml'])) {
$this->_isXhtml = (bool)$options['xhtml'];
}
if (isset($options['cssMinifier'])) {
$this->_cssMinifier = $options['cssMinifier'];
}
if (isset($options['jsMinifier'])) {
$this->_jsMinifier = $options['jsMinifier'];
}
if (isset($options['jsCleanComments'])) {
$this->_jsCleanComments = (bool)$options['jsCleanComments'];
}
}
/**
* Minify the markeup given in the constructor
*
* @return string
*/
public function process()
{
if ($this->_isXhtml === null) {
$this->_isXhtml = (false !== strpos($this->_html, '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML'));
}
$this->_replacementHash = 'MINIFYHTML' . md5($_SERVER['REQUEST_TIME']);
$this->_placeholders = array();
// replace SCRIPTs (and minify) with placeholders
$this->_html = preg_replace_callback(
'/(\\s*)<script(\\b[^>]*?>)([\\s\\S]*?)<\\/script>(\\s*)/i', array($this, '_removeScriptCB'), $this->_html, Media::getBackTrackLimit());
// replace STYLEs (and minify) with placeholders
$this->_html = preg_replace_callback(
'/\\s*<style(\\b[^>]*>)([\\s\\S]*?)<\\/style>\\s*/i', array($this, '_removeStyleCB'), $this->_html, Media::getBackTrackLimit());
// remove HTML comments (not containing IE conditional comments).
$this->_html = preg_replace_callback(
'/<!--([\\s\\S]*?)-->/', array($this, '_commentCB'), $this->_html, Media::getBackTrackLimit());
// replace PREs with placeholders
$this->_html = preg_replace_callback('/\\s*<pre(\\b[^>]*?>[\\s\\S]*?<\\/pre>)\\s*/i', array($this, '_removePreCB'), $this->_html, Media::getBackTrackLimit());
// replace TEXTAREAs with placeholders
$this->_html = preg_replace_callback(
'/\\s*<textarea(\\b[^>]*?>[\\s\\S]*?<\\/textarea>)\\s*/i', array($this, '_removeTextareaCB'), $this->_html, Media::getBackTrackLimit());
// trim each line.
// @todo take into account attribute values that span multiple lines.
$this->_html = preg_replace(Tools::cleanNonUnicodeSupport('/^\\s+|\\s+$/mu'), '', $this->_html);
// remove ws around block/undisplayed elements
$this->_html = preg_replace('/\\s+(<\\/?(?:area|base(?:font)?|blockquote|body'
.'|caption|center|cite|col(?:group)?|dd|dir|div|dl|dt|fieldset|form'
.'|frame(?:set)?|h[1-6]|head|hr|html|legend|li|link|map|menu|meta'
.'|ol|opt(?:group|ion)|p|param|t(?:able|body|head|d|h||r|foot|itle)'
.'|ul)\\b[^>]*>)/i', '$1', $this->_html);
// remove ws outside of all elements
$this->_html = preg_replace(
'/>(\\s(?:\\s*))?([^<]+)(\\s(?:\s*))?</', '>$1$2$3<', $this->_html);
// use newlines before 1st attribute in open tags (to limit line lengths)
// $this->_html = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/i', "$1\n$2", $this->_html);
$this->_html = preg_replace(Tools::cleanNonUnicodeSupport('/\s+/mu'), ' ', $this->_html);
// fill placeholders
$this->_html = str_replace(
array_keys($this->_placeholders), array_values($this->_placeholders), $this->_html
);
// issue 229: multi-pass to catch scripts that didn't get replaced in textareas
$this->_html = str_replace(
array_keys($this->_placeholders), array_values($this->_placeholders), $this->_html
);
return $this->_html;
}
protected function _commentCB($m)
{
return (0 === strpos($m[1], '[') || false !== strpos($m[1], '<!['))
? $m[0]
: '';
}
protected function _reservePlace($content)
{
$placeholder = '%' . $this->_replacementHash . count($this->_placeholders) . '%';
$this->_placeholders[$placeholder] = $content;
return $placeholder;
}
protected $_isXhtml = null;
protected $_replacementHash = null;
protected $_placeholders = array();
protected $_cssMinifier = null;
protected $_jsMinifier = null;
protected function _removePreCB($m)
{
return $this->_reservePlace("<pre{$m[1]}");
}
protected function _removeTextareaCB($m)
{
return $this->_reservePlace("<textarea{$m[1]}");
}
protected function _removeStyleCB($m)
{
$openStyle = "<style{$m[1]}";
$css = $m[2];
// remove HTML comments
$css = preg_replace('/(?:^\\s*<!--|-->\\s*$)/', '', $css);
// remove CDATA section markers
$css = $this->_removeCdata($css);
// minify
$minifier = $this->_cssMinifier
? $this->_cssMinifier
: 'trim';
$css = call_user_func($minifier, $css);
return $this->_reservePlace($this->_needsCdata($css)
? "{$openStyle}/*<![CDATA[*/{$css}/*]]>*/</style>"
: "{$openStyle}{$css}</style>"
);
}
protected function _removeScriptCB($m)
{
$openScript = "<script{$m[2]}";
$js = $m[3];
// whitespace surrounding? preserve at least one space
$ws1 = ($m[1] === '') ? '' : ' ';
$ws2 = ($m[4] === '') ? '' : ' ';
// remove HTML comments (and ending "//" if present)
if ($this->_jsCleanComments) {
$js = preg_replace('/(?:^\\s*<!--\\s*|\\s*(?:\\/\\/)?\\s*-->\\s*$)/', '', $js);
}
// remove CDATA section markers
$js = $this->_removeCdata($js);
// minify
$minifier = $this->_jsMinifier
? $this->_jsMinifier
: 'trim';
$js = call_user_func($minifier, $js);
return $this->_reservePlace($this->_needsCdata($js)
? "{$ws1}{$openScript}/*<![CDATA[*/{$js}/*]]>*/</script>{$ws2}"
: "{$ws1}{$openScript}{$js}</script>{$ws2}"
);
}
protected function _removeCdata($str)
{
return (false !== strpos($str, '<![CDATA['))
? str_replace(array('<![CDATA[', ']]>'), '', $str)
: $str;
}
protected function _needsCdata($str)
{
return ($this->_isXhtml && preg_match('/(?:[<&]|\\-\\-|\\]\\]>)/', $str));
}
}