commit 512e4c964119717d9e749cb9498910394c403a83 Author: Tobias Merkl Date: Thu Aug 25 15:26:37 2016 +0200 initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..666f4e3 --- /dev/null +++ b/README.md @@ -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 . + + +Copyright + + Proud Sourcing GmbH 2016 + www.proudcommerce.com + www.proudsourcing.de diff --git a/copy_this/modules/proudsourcing/psCacheWarmer/application/controllers/pscachewarmer.php b/copy_this/modules/proudsourcing/psCacheWarmer/application/controllers/pscachewarmer.php new file mode 100755 index 0000000..8530ced --- /dev/null +++ b/copy_this/modules/proudsourcing/psCacheWarmer/application/controllers/pscachewarmer.php @@ -0,0 +1,113 @@ +psCacheWarmer
".$this->_getSitemapUrl()."
---
"; + + 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 .= 'ERROR '.$httpStatus.': ' . curl_error($oCurl) . '
'; + } else { + $sMessage .= 'OK '.$httpStatus.': ' . $sUrl . '
'; + } + curl_close($oCurl); + } + } else { + $sMessage .= 'Keine Daten vorhanden!'; + } + } else { + $sMessage .= 'Authentifizierung fehlgeschlagen!'; + } + + echo '
'.$sMessage.'
'; + 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; + } +} diff --git a/copy_this/modules/proudsourcing/psCacheWarmer/application/views/admin/de/pscachewarmer_lang.php b/copy_this/modules/proudsourcing/psCacheWarmer/application/views/admin/de/pscachewarmer_lang.php new file mode 100644 index 0000000..cb5a397 --- /dev/null +++ b/copy_this/modules/proudsourcing/psCacheWarmer/application/views/admin/de/pscachewarmer_lang.php @@ -0,0 +1,30 @@ + '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" }] +*/ diff --git a/copy_this/modules/proudsourcing/psCacheWarmer/logo.jpg b/copy_this/modules/proudsourcing/psCacheWarmer/logo.jpg new file mode 100644 index 0000000..2565082 Binary files /dev/null and b/copy_this/modules/proudsourcing/psCacheWarmer/logo.jpg differ diff --git a/copy_this/modules/proudsourcing/psCacheWarmer/metadata.php b/copy_this/modules/proudsourcing/psCacheWarmer/metadata.php new file mode 100644 index 0000000..722c688 --- /dev/null +++ b/copy_this/modules/proudsourcing/psCacheWarmer/metadata.php @@ -0,0 +1,71 @@ + 'psCacheWarmer', + 'title' => 'psCacheWarmer', + 'description' => array( + 'de' => 'Website anhand der XML-Sitemap automatisch aufrufen, z. B. zum "Aufwärmen" eines Caches.
+ URL: '.oxRegistry::getConfig()->getConfigParam('sShopURL').'?cl=psCacheWarmer&key='.oxRegistry::getConfig()->getShopConfVar('psCacheWarmerKey', oxRegistry::getConfig()->getShopId()).'', + 'en' => 'Automatically calling urls using the xml-sitemap, eg. for cache warming. + URL: '.oxRegistry::getConfig()->getConfigParam('sShopURL').'?cl=psCacheWarmer&key='.oxRegistry::getConfig()->getShopConfVar('psCacheWarmerKey', oxRegistry::getConfig()->getShopId()).'', + ), + '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' => '', + ), + ), +); \ No newline at end of file diff --git a/copy_this/modules/proudsourcing/psCacheWarmer/views/admin/de/pscachewarmer_lang.php b/copy_this/modules/proudsourcing/psCacheWarmer/views/admin/de/pscachewarmer_lang.php new file mode 100644 index 0000000..cb5a397 --- /dev/null +++ b/copy_this/modules/proudsourcing/psCacheWarmer/views/admin/de/pscachewarmer_lang.php @@ -0,0 +1,30 @@ + '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" }] +*/ diff --git a/copy_this/modules/proudsourcing/vendormetadata.php b/copy_this/modules/proudsourcing/vendormetadata.php new file mode 100755 index 0000000..69b7025 --- /dev/null +++ b/copy_this/modules/proudsourcing/vendormetadata.php @@ -0,0 +1,6 @@ +