diff --git a/Application/Controller/CacheWarmer.php b/Application/Controller/CacheWarmer.php
index a505a53..c94ebad 100644
--- a/Application/Controller/CacheWarmer.php
+++ b/Application/Controller/CacheWarmer.php
@@ -18,6 +18,13 @@ use OxidEsales\Eshop\Core\Controller\BaseController;
class CacheWarmer extends BaseController
{
+ protected $_sFileAndPathToExportFile = '';
+ protected $_handle = null;
+ protected $_sSeparator = ";";
+ protected $_sEnclosure = "'";
+
+ // todo: add to config
+ protected $_aHttpCodesIsOkay = array('200','302');
/**
* Executes cache warmer
*/
@@ -25,31 +32,18 @@ class CacheWarmer extends BaseController
{
$sMessage = "psCacheWarmer
".$this->_getSitemapUrl()."
---
";
+ $this->_sFileAndPathToExportFile = $this->_getPathWithFileName();
+ if(Registry::getConfig()->getShopConfVar('psCacheWarmerWriteCsv') == true)
+ {
+ $this->_handle = fopen( $this->_sFileAndPathToExportFile, "w+");;
+ }
+
if($this->_checkAuthentification()) {
$aUrls = $this->_getSitemapContent();
if(!empty(Registry::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 = Registry::getConfig()->getShopConfVar('psCacheWarmerUser');
- $sPassword = Registry::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 {
- if(trim($httpStatus) == '500')
- {
- $sMessage .= 'ERROR '.$httpStatus.': ' . $sUrl. '
';
- }
- else{
- $sMessage .= 'OK '.$httpStatus.': ' . $sUrl . '
';
- }
- }
+ $oCurl = $this->_runCurlConnect($sUrl);
+ $sMessage .= $this->_checkCurlResults($oCurl,$sUrl);
curl_close($oCurl);
}
} else {
@@ -59,10 +53,73 @@ class CacheWarmer extends BaseController
$sMessage .= 'Authentifizierung fehlgeschlagen!';
}
+ if(Registry::getConfig()->getShopConfVar('psCacheWarmerWriteCsv') == true)
+ {
+ fclose($this->_handle);
+ }
echo '
'.$sMessage.''; exit; } + /** + * @param $sUrl + * @return false|resource + */ + protected function _runCurlConnect($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 = Registry::getConfig()->getShopConfVar('psCacheWarmerUser'); + $sPassword = Registry::getConfig()->getShopConfVar('psCacheWarmerPass'); + curl_setopt($oCurl, CURLOPT_USERPWD, $sUsername . ":" . $sPassword); + curl_exec($oCurl); + return $oCurl; + } + + protected function _checkCurlResults($oCurl,$sUrl) + { + $sMessage = ''; + $httpStatus = curl_getinfo($oCurl, CURLINFO_HTTP_CODE); + if(curl_error($oCurl)) { + $sMessage .= 'ERROR '.$httpStatus.': ' . curl_error($oCurl) . '