Subida del módulo y tema de PrestaShop

This commit is contained in:
Kaloyan
2026-04-09 18:31:51 +02:00
parent 12c253296f
commit 16b3ff9424
39262 changed files with 7418797 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
<?php
$config = new PrestaShop\CodingStandards\CsFixer\Config();
$config
->setUsingCache(true)
->getFinder()
->in(__DIR__)
->exclude('vendor');
return $config;

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

2426
modules/pagesnotfound/composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>pagesnotfound</name>
<displayName><![CDATA[Pages not found]]></displayName>
<version><![CDATA[3.0.0]]></version>
<description><![CDATA[Displays the pages requested by your visitors that have not been found.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[analytics_stats]]></tab>
<is_configurable>0</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 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/afl-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/afl-3.0.php Academic Free License (AFL 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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -0,0 +1,233 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
if (!defined('_PS_VERSION_')) {
exit;
}
class PagesNotFound extends Module
{
private $html = '';
public function __construct()
{
$this->name = 'pagesnotfound';
$this->tab = 'administration';
$this->version = '3.0.0';
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->trans('Pages not found', [], 'Modules.Pagesnotfound.Admin');
$this->description = $this->trans('Enrich your stats, display the pages requested by your visitors that could not be found.', [], 'Modules.Pagesnotfound.Admin');
$this->ps_versions_compliancy = ['min' => '1.7.7', 'max' => _PS_VERSION_];
}
public function install()
{
if (!parent::install()
|| !$this->registerHook('displayTop')
|| !$this->registerHook('displayAdminStatsModules')
) {
return false;
}
return Db::getInstance()->execute(
'CREATE TABLE `' . _DB_PREFIX_ . 'pagenotfound` (
id_pagenotfound INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
id_shop INTEGER UNSIGNED NOT NULL DEFAULT \'1\',
id_shop_group INTEGER UNSIGNED NOT NULL DEFAULT \'1\',
request_uri VARCHAR(256) NOT NULL,
http_referer VARCHAR(256) NOT NULL,
date_add DATETIME NOT NULL,
PRIMARY KEY(id_pagenotfound),
INDEX (`date_add`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;'
);
}
public function uninstall()
{
return parent::uninstall() && Db::getInstance()->execute('DROP TABLE `' . _DB_PREFIX_ . 'pagenotfound`');
}
private function getPages()
{
$sql = 'SELECT http_referer, request_uri, COUNT(*) as nb
FROM `' . _DB_PREFIX_ . 'pagenotfound`
WHERE date_add BETWEEN ' . ModuleGraph::getDateBetween()
. Shop::addSqlRestriction() .
'GROUP BY http_referer, request_uri';
$result = Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->executeS($sql);
$pages = [];
foreach ($result as $row) {
$row['http_referer'] = parse_url($row['http_referer'], PHP_URL_HOST) . parse_url($row['http_referer'], PHP_URL_PATH);
if (!isset($row['http_referer']) || empty($row['http_referer'])) {
$row['http_referer'] = '--';
}
if (!isset($pages[$row['request_uri']])) {
$pages[$row['request_uri']] = ['nb' => 0];
}
$pages[$row['request_uri']][$row['http_referer']] = $row['nb'];
$pages[$row['request_uri']]['nb'] += $row['nb'];
}
uasort($pages, 'pnfSort');
return $pages;
}
public function hookDisplayAdminStatsModules()
{
$this->context->controller->addCSS($this->_path . 'views/css/stacking_responsive.css');
if (Tools::isSubmit('submitTruncatePNF')) {
Db::getInstance()->execute('TRUNCATE `' . _DB_PREFIX_ . 'pagenotfound`');
$this->html .= '<div class="alert alert-warning"> ' . $this->trans('The "pages not found" cache has been emptied.', [], 'Modules.Pagesnotfound.Admin') . '</div>';
} elseif (Tools::isSubmit('submitDeletePNF')) {
Db::getInstance()->execute(
'DELETE FROM `' . _DB_PREFIX_ . 'pagenotfound`
WHERE date_add BETWEEN ' . ModuleGraph::getDateBetween()
);
$this->html .= '<div class="alert alert-warning"> ' . $this->trans('The "pages not found" cache has been deleted.', [], 'Modules.Pagesnotfound.Admin') . '</div>';
}
$this->html .= '
<div class="panel-heading">
' . $this->displayName . '
</div>
<h4>' . $this->trans('Guide', [], 'Modules.Pagesnotfound.Admin') . '</h4>
<div class="alert alert-warning">
<h4>' . $this->trans('404 errors', [], 'Modules.Pagesnotfound.Admin') . '</h4>
<p>'
. $this->trans('A 404 error is an HTTP error code which means that the file requested by the user cannot be found. In your case it means that one of your visitors entered a wrong URL in the address bar, or that you or another website has a dead link. When possible, the referrer is shown so you can find the page/site which contains the dead link. If not, it generally means that it is a direct access, so someone may have bookmarked a link which doesn\'t exist anymore.', [], 'Modules.Pagesnotfound.Admin') . '
</p>
<p>&nbsp;</p>
<h4>' . $this->trans('How to catch these errors?', [], 'Modules.Pagesnotfound.Admin') . '</h4>
<p>'
. sprintf($this->trans('If your webhost supports .htaccess files, you can create one in the root directory of PrestaShop and insert the following line inside: "%s".', [], 'Modules.Pagesnotfound.Admin'), 'ErrorDocument 404 ' . __PS_BASE_URI__ . '404.php') . '<br />' .
sprintf($this->trans('A user requesting a page which doesn\'t exist will be redirected to the following page: %s. This module logs access to this page.', [], 'Modules.Pagesnotfound.Admin'), __PS_BASE_URI__ . '404.php') . '
</p>
</div>';
if (!file_exists($this->_normalizeDirectory(_PS_ROOT_DIR_) . '.htaccess')) {
$this->html .= '<div class="alert alert-warning">' . $this->trans('You must use a .htaccess file to redirect 404 errors to the "404.php" page.', [], 'Modules.Pagesnotfound.Admin') . '</div>';
}
$pages = $this->getPages();
if (count($pages)) {
$titlePage = $this->trans('Page', [], 'Modules.Pagesnotfound.Admin');
$titleReferer = $this->trans('Referrer', [], 'Modules.Pagesnotfound.Admin');
$titleCounter = $this->trans('Counter', [], 'Modules.Pagesnotfound.Admin');
$this->html .= '
<div class="stacking__wrapper">
<table class="table">
<thead>
<tr>
<th scope="row"></th>
<th scope="col"><span class="title_box active">' . $titlePage . '</span></th>
<th scope="col"><span class="title_box active">' . $titleReferer . '</span></th>
<th scope="col"><span class="title_box active">' . $titleCounter . '</span></th>
</tr>
</thead>
<tbody>';
foreach ($pages as $ru => $hrs) {
foreach ($hrs as $hr => $counter) {
if ($hr != 'nb') {
$this->html .= '
<tr>
<th scope="row"></th>
<td data-header="' . $titlePage . '"><a href="' . $ru . '-admin404">' . wordwrap($ru, 30, '<br />', true) . '</a></td>
<td data-header="' . $titleReferer . '"><a href="' . Tools::getProtocol() . $hr . '">' . wordwrap($hr, 40, '<br />', true) . '</a></td>
<td data-header="' . $titleCounter . '"><span>' . $counter . '</span></td>
</tr>';
}
}
}
$this->html .= '
</tbody>
</table>
</div>';
} else {
$this->html .= '<div class="alert alert-warning"> ' . $this->trans('No "page not found" issue registered for now.', [], 'Modules.Pagesnotfound.Admin') . '</div>';
}
if (count($pages)) {
$this->html .= '
<h4>' . $this->trans('Empty database', [], 'Modules.Pagesnotfound.Admin') . '</h4>
<form action="' . Tools::htmlEntitiesUtf8($_SERVER['REQUEST_URI']) . '" method="post">
<button type="submit" class="btn btn-default" name="submitDeletePNF">
<i class="icon-remove"></i> ' . $this->trans('Empty ALL "pages not found" notices for this period', [], 'Modules.Pagesnotfound.Admin') . '
</button>
<button type="submit" class="btn btn-default" name="submitTruncatePNF">
<i class="icon-remove"></i> ' . $this->trans('Empty ALL "pages not found" notices', [], 'Modules.Pagesnotfound.Admin') . '
</button>
</form>';
}
return $this->html;
}
public function hookDisplayTop($params)
{
if (strstr($_SERVER['REQUEST_URI'], '404.php') && isset($_SERVER['REDIRECT_URL'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['REDIRECT_URL'];
}
if (!Validate::isUrl($request_uri = $_SERVER['REQUEST_URI']) || strstr($_SERVER['REQUEST_URI'], '-admin404')) {
return;
}
if (get_class(Context::getContext()->controller) == 'PageNotFoundController') {
$http_referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
if (empty($http_referer) || Validate::isAbsoluteUrl($http_referer)) {
Db::getInstance()->execute(
'
INSERT INTO `' . _DB_PREFIX_ . 'pagenotfound` (`request_uri`, `http_referer`, `date_add`, `id_shop`, `id_shop_group`)
VALUES (\'' . pSQL($request_uri) . '\', \'' . pSQL($http_referer) . '\', NOW(), ' . (int) $this->context->shop->id . ', ' . (int) $this->context->shop->id_shop_group . ')
'
);
}
}
}
private function _normalizeDirectory($directory)
{
$last = $directory[strlen($directory) - 1];
if (in_array($last, ['/', '\\'])) {
$directory[strlen($directory) - 1] = DIRECTORY_SEPARATOR;
return $directory;
}
$directory .= DIRECTORY_SEPARATOR;
return $directory;
}
}
function pnfSort($a, $b)
{
if ($a['nb'] == $b['nb']) {
return 0;
}
return ($a['nb'] > $b['nb']) ? -1 : 1;
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 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/afl-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/afl-3.0.php Academic Free License (AFL 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,32 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
/**
* @param Module $module
*
* @return bool
*/
function upgrade_module_2_0_1($module)
{
$module->unregisterHook('top');
$module->registerHook('displayTop');
return true;
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
/**
* @param Module $module
*
* @return bool
*/
function upgrade_module_2_0_2($module)
{
$module->unregisterHook('AdminStatsModules');
$module->registerHook('displayAdminStatsModules');
return true;
}

View File

@@ -0,0 +1,106 @@
.stacking__wrapper {
width: 100%;
}
.stacking__wrapper .table {
width: 100%;
max-width: 100%;
}
/* ------- Presentational Formatting --------- */
.stacking__wrapper .table {
border: 1px solid #f0f0f0;
border-collapse: collapse;
}
.stacking__wrapper .table tr {
border-bottom: 1px solid #f0f0f0;
}
.stacking__wrapper .table thead tr {
border-bottom: 2px solid #f0f0f0;
}
.stacking__wrapper .table td,
.stacking__wrapper .table th {
padding: .5em;
}
.stacking__wrapper .table th {
text-align: left;
}
@media screen and (max-width:768px) {
.stacking__wrapper .table {
margin: 0 auto;
width: 100%;
border-spacing: 0;
}
.stacking__wrapper .table thead {
position: absolute;
clip: rect(1px, 1px, 1px, 1px);
padding: 0;
border: 0;
height: 1px;
width: 1px;
overflow: hidden;
}
.stacking__wrapper .table tbody,
.stacking__wrapper .table tr,
.stacking__wrapper .table th,
.stacking__wrapper .table td {
display: block;
padding: 0;
text-align: left;
white-space: normal;
}
.stacking__wrapper .table tr td,
.stacking__wrapper .table tr th {
padding: 2em 1em;
vertical-align: middle;
overflow: hidden;
position: relative;
vertical-align: top;
border: 1px solid #EDF0F1;
border-top: none;
width: 100%;
white-space: normal;
}
.stacking__wrapper .table th[scope="row"] {
width: 100%;
height: 0.5em;
text-align: center;
display: block;
background-color: #B3BFC6;
margin: 0 auto;
padding: 0;
}
.stacking__wrapper .table td[data-header]:before {
content: attr(data-header);
display: block;
float: left;
width: 20%;
color: #000000;
font-weight: bold;
text-align: left;
}
.stacking__wrapper .table td[data-header] > * {
display: block;
width: 80%;
float: right;
clear: right;
padding-left: 1em;
margin-top: 0;
}
.stacking__wrapper .table td[data-header]:after {
content: "";
position: absolute;
left: 0;
top: 0;
width: 20%;
padding-bottom: 200%;
display: block;
}
}