initial commit
Dieser Commit ist enthalten in:
Commit
512e4c9641
46
README.md
Normale Datei
46
README.md
Normale Datei
@ -0,0 +1,46 @@
|
|||||||
|
psCacheWarmer
|
||||||
|
============
|
||||||
|
|
||||||
|
Automatically calling urls using the xml-sitemap, eg. for cache warming.
|
||||||
|
Free Module for OXID eShop.
|
||||||
|
|
||||||
|
|
||||||
|
Features
|
||||||
|
|
||||||
|
- admin setting sitemap url
|
||||||
|
- admin setting security key (cronjob)
|
||||||
|
- admin setting basic auth user/password
|
||||||
|
|
||||||
|
|
||||||
|
Installation
|
||||||
|
|
||||||
|
1. copy content from copy_this folder into your shop root
|
||||||
|
2. activate module psCacheWarmer in shop admin
|
||||||
|
|
||||||
|
|
||||||
|
Changelog
|
||||||
|
|
||||||
|
25.08.2016 1.0.0 module release
|
||||||
|
|
||||||
|
|
||||||
|
License
|
||||||
|
|
||||||
|
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/>.
|
||||||
|
|
||||||
|
|
||||||
|
Copyright
|
||||||
|
|
||||||
|
Proud Sourcing GmbH 2016
|
||||||
|
www.proudcommerce.com
|
||||||
|
www.proudsourcing.de
|
113
copy_this/modules/proudsourcing/psCacheWarmer/application/controllers/pscachewarmer.php
Ausführbare Datei
113
copy_this/modules/proudsourcing/psCacheWarmer/application/controllers/pscachewarmer.php
Ausführbare Datei
@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @copyright (c) Proud Sourcing GmbH | 2016
|
||||||
|
* @link www.proudcommerce.com
|
||||||
|
* @package psCacheWarmer
|
||||||
|
* @version 1.0.0
|
||||||
|
**/
|
||||||
|
class psCacheWarmer extends oxUBase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Executes cache warmer
|
||||||
|
*/
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
$sMessage = "<b>psCacheWarmer</b><br>".$this->_getSitemapUrl()."<br>---<br>";
|
||||||
|
|
||||||
|
if($this->_checkAuthentification()) {
|
||||||
|
$aUrls = $this->_getSitemapContent();
|
||||||
|
if(!empty(oxRegistry::getConfig()->getShopConfVar('psCacheWarmerSitemapUrl')) && count($aUrls) > 0) {
|
||||||
|
foreach($aUrls as $sUrl) {
|
||||||
|
$oCurl = curl_init();
|
||||||
|
curl_setopt($oCurl, CURLOPT_URL, $sUrl);
|
||||||
|
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($oCurl, CURLOPT_CONNECTTIMEOUT, 25);
|
||||||
|
curl_setopt($oCurl, CURLOPT_HEADER, true);
|
||||||
|
$sUsername = oxRegistry::getConfig()->getShopConfVar('psCacheWarmerUser');
|
||||||
|
$sPassword = oxRegistry::getConfig()->getShopConfVar('psCacheWarmerPass');
|
||||||
|
curl_setopt($oCurl, CURLOPT_USERPWD, $sUsername . ":" . $sPassword);
|
||||||
|
curl_exec($oCurl);
|
||||||
|
$httpStatus = curl_getinfo($oCurl, CURLINFO_HTTP_CODE);
|
||||||
|
if(curl_error($oCurl)) {
|
||||||
|
$sMessage .= '<span style="color: orange;">ERROR '.$httpStatus.': ' . curl_error($oCurl) . '</span><br>';
|
||||||
|
} else {
|
||||||
|
$sMessage .= '<span style="color: green;">OK '.$httpStatus.': ' . $sUrl . '</span><br>';
|
||||||
|
}
|
||||||
|
curl_close($oCurl);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$sMessage .= '<span style="color: red;">Keine Daten vorhanden!</span>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$sMessage .= '<span style="color: red;">Authentifizierung fehlgeschlagen!</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<pre>'.$sMessage.'</pre>';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returens urls from sitemap
|
||||||
|
*
|
||||||
|
* @return array urls
|
||||||
|
*/
|
||||||
|
protected function _getSitemapContent($sSitemapUrl = "")
|
||||||
|
{
|
||||||
|
$aUrls = array();
|
||||||
|
if(empty($sSitemapUrl)) {
|
||||||
|
$sSitemapUrl = $this->_getSitemapUrl();
|
||||||
|
#$sSitemapUrl = "https://www.likoerfactory.de/sitemaps/sitemap-index.xml";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sSitemapXmlData = @file_get_contents($sSitemapUrl);
|
||||||
|
if(($oSitemap = @simplexml_load_string($sSitemapXmlData)) != false) {
|
||||||
|
if (count($oSitemap->sitemap) > 0) {
|
||||||
|
foreach ($oSitemap->sitemap as $oSubSitemap) {
|
||||||
|
$sNextSitemapUrl = (string)$oSubSitemap->loc;
|
||||||
|
$aUrls = array_merge($aUrls, $this->_getSitemapContent($sNextSitemapUrl));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count($oSitemap->url) > 0) {
|
||||||
|
foreach($oSitemap->url as $oSitemapUrl) {
|
||||||
|
$aUrls[] = (string)$oSitemapUrl->loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#print_r($aUrls);
|
||||||
|
return $aUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returens sitemap url
|
||||||
|
*
|
||||||
|
* @return string sitemap url
|
||||||
|
*/
|
||||||
|
protected function _getSitemapUrl()
|
||||||
|
{
|
||||||
|
$sSitemapUrl = oxRegistry::getConfig()->getConfigParam('sShopURL');
|
||||||
|
$sSitemapUrl .= oxRegistry::getConfig()->getShopConfVar('psCacheWarmerSitemapUrl');
|
||||||
|
return $sSitemapUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks authentification
|
||||||
|
*
|
||||||
|
* @return bool true|false
|
||||||
|
*/
|
||||||
|
protected function _checkAuthentification()
|
||||||
|
{
|
||||||
|
$oConfig = oxRegistry::getConfig();
|
||||||
|
$sKey = oxRegistry::getConfig()->getRequestParameter("key");
|
||||||
|
$sSavedKey = $oConfig->getShopConfVar('psCacheWarmerKey', $oConfig->getShopId());
|
||||||
|
if($sSavedKey == $sKey) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @copyright (c) Proud Sourcing GmbH | 2016
|
||||||
|
* @link www.proudcommerce.com
|
||||||
|
* @package psCacheWarmer
|
||||||
|
* @version 1.0.0
|
||||||
|
**/
|
||||||
|
$sLangName = "Deutsch";
|
||||||
|
// -------------------------------
|
||||||
|
// RESOURCE IDENTITFIER = STRING
|
||||||
|
// -------------------------------
|
||||||
|
$aLang = array(
|
||||||
|
'charset' => 'UTF-8',
|
||||||
|
|
||||||
|
'SHOP_MODULE_GROUP_psCacheWarmerConfig' => 'Einstellungen',
|
||||||
|
'SHOP_MODULE_psCacheWarmerSitemapUrl' => 'XML-Sitemap URL',
|
||||||
|
'SHOP_MODULE_psCacheWarmerKey' => 'Cronjob-Key',
|
||||||
|
'SHOP_MODULE_psCacheWarmerUser' => 'Basic-Auth Benutzer',
|
||||||
|
'SHOP_MODULE_psCacheWarmerPass' => 'Basic-Auth Kennwort',
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
[{ oxmultilang ident="GENERAL_YOUWANTTODELETE" }]
|
||||||
|
*/
|
BIN
copy_this/modules/proudsourcing/psCacheWarmer/logo.jpg
Normale Datei
BIN
copy_this/modules/proudsourcing/psCacheWarmer/logo.jpg
Normale Datei
Binäre Datei nicht angezeigt.
Nachher Breite: | Höhe: | Größe: 10 KiB |
71
copy_this/modules/proudsourcing/psCacheWarmer/metadata.php
Normale Datei
71
copy_this/modules/proudsourcing/psCacheWarmer/metadata.php
Normale Datei
@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @copyright (c) Proud Sourcing GmbH | 2016
|
||||||
|
* @link www.proudcommerce.com
|
||||||
|
* @package psCacheWarmer
|
||||||
|
* @version 1.0.0
|
||||||
|
**/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Metadata version
|
||||||
|
*/
|
||||||
|
$sMetadataVersion = '1.1';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module information
|
||||||
|
*/
|
||||||
|
$aModule = array(
|
||||||
|
'id' => 'psCacheWarmer',
|
||||||
|
'title' => 'psCacheWarmer',
|
||||||
|
'description' => array(
|
||||||
|
'de' => 'Website anhand der XML-Sitemap automatisch aufrufen, z. B. zum "Aufwärmen" eines Caches.<br>
|
||||||
|
<b>URL:</b> <a href="'.oxRegistry::getConfig()->getConfigParam('sShopURL').'?cl=psCacheWarmer&key='.oxRegistry::getConfig()->getShopConfVar('psCacheWarmerKey', oxRegistry::getConfig()->getShopId()).'" target="_blank">'.oxRegistry::getConfig()->getConfigParam('sShopURL').'?cl=psCacheWarmer&key='.oxRegistry::getConfig()->getShopConfVar('psCacheWarmerKey', oxRegistry::getConfig()->getShopId()).'</a>',
|
||||||
|
'en' => 'Automatically calling urls using the xml-sitemap, eg. for cache warming.
|
||||||
|
<b>URL:</b> <a href="'.oxRegistry::getConfig()->getConfigParam('sShopURL').'?cl=psCacheWarmer&key='.oxRegistry::getConfig()->getShopConfVar('psCacheWarmerKey', oxRegistry::getConfig()->getShopId()).'" target="_blank">'.oxRegistry::getConfig()->getConfigParam('sShopURL').'?cl=psCacheWarmer&key='.oxRegistry::getConfig()->getShopConfVar('psCacheWarmerKey', oxRegistry::getConfig()->getShopId()).'</a>',
|
||||||
|
),
|
||||||
|
'thumbnail' => 'logo.jpg',
|
||||||
|
'version' => '1.0.0',
|
||||||
|
'author' => 'Proud Sourcing GmbH',
|
||||||
|
'url' => 'http://www.proudcommerce.com/',
|
||||||
|
'email' => 'support@proudcommerce.com',
|
||||||
|
'extend' => array(
|
||||||
|
),
|
||||||
|
'files' => array(
|
||||||
|
'pscachewarmer' => 'proudsourcing/psCacheWarmer/application/controllers/pscachewarmer.php',
|
||||||
|
),
|
||||||
|
'templates' => array(
|
||||||
|
),
|
||||||
|
'blocks' => array(
|
||||||
|
),
|
||||||
|
'settings' => array(
|
||||||
|
array(
|
||||||
|
'group' => 'psCacheWarmerConfig',
|
||||||
|
'name' => 'psCacheWarmerSitemapUrl',
|
||||||
|
'type' => 'str',
|
||||||
|
'value' => 'sitemap.xml',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'group' => 'psCacheWarmerConfig',
|
||||||
|
'name' => 'psCacheWarmerKey',
|
||||||
|
'type' => 'str',
|
||||||
|
'value' => md5(time()),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'group' => 'psCacheWarmerConfig',
|
||||||
|
'name' => 'psCacheWarmerUser',
|
||||||
|
'type' => 'str',
|
||||||
|
'value' => '',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'group' => 'psCacheWarmerConfig',
|
||||||
|
'name' => 'psCacheWarmerPass',
|
||||||
|
'type' => 'str',
|
||||||
|
'value' => '',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @copyright (c) Proud Sourcing GmbH | 2016
|
||||||
|
* @link www.proudcommerce.com
|
||||||
|
* @package psCacheWarmer
|
||||||
|
* @version 1.0.0
|
||||||
|
**/
|
||||||
|
$sLangName = "Deutsch";
|
||||||
|
// -------------------------------
|
||||||
|
// RESOURCE IDENTITFIER = STRING
|
||||||
|
// -------------------------------
|
||||||
|
$aLang = array(
|
||||||
|
'charset' => 'UTF-8',
|
||||||
|
|
||||||
|
'SHOP_MODULE_GROUP_psCacheWarmerConfig' => 'Einstellungen',
|
||||||
|
'SHOP_MODULE_psCacheWarmerSitemapUrl' => 'XML-Sitemap URL',
|
||||||
|
'SHOP_MODULE_psCacheWarmerKey' => 'Cronjob-Key',
|
||||||
|
'SHOP_MODULE_psCacheWarmerUser' => 'Basic-Auth Benutzer',
|
||||||
|
'SHOP_MODULE_psCacheWarmerPass' => 'Basic-Auth Kennwort',
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
[{ oxmultilang ident="GENERAL_YOUWANTTODELETE" }]
|
||||||
|
*/
|
6
copy_this/modules/proudsourcing/vendormetadata.php
Ausführbare Datei
6
copy_this/modules/proudsourcing/vendormetadata.php
Ausführbare Datei
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Metadata version
|
||||||
|
*/
|
||||||
|
$sVendorMetadataVersion = '1.0';
|
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren