Version Notes
Added cache support for FishPig WordPress Integration. WordPress pages will be auto purged by the LiteSpeed Cache for WordPress plugin.
Added support for LiteSpeed Load Balancer (LSLB). LiteMage cache will be located on your LSLB, no need to change your local web server setup.
Added support to purge by store ID.
Added a command line tool to purge LiteMage cache. This tool is located under the shell subdirectory under the Magento root directory.
Improved crawler and added delta crawler logging.
Improved new visitor detection when visitor log is disabled.
Allow users to specify what saving a product form the admin panel automatically purges.
Fixed a bug caused by specifying a different theme for different categories.
Download this release
Release Info
Developer | LiteSpeed Technologies |
Extension | LiteSpeed_LiteMage |
Version | 1.2.1 |
Comparing to | |
See all releases |
Code changes from version 1.2.0 to 1.2.1
- app/code/community/Litespeed/Litemage/Block/Adminhtml/ItemSave.php +83 -0
- app/code/community/Litespeed/Litemage/Helper/Data.php +47 -8
- app/code/community/Litespeed/Litemage/Helper/Esi.php +95 -51
- app/code/community/Litespeed/Litemage/Model/EsiData.php +2 -2
- app/code/community/Litespeed/Litemage/Model/Layout/Master.php +13 -5
- app/code/community/Litespeed/Litemage/Model/Layout/Update.php +7 -0
- app/code/community/Litespeed/Litemage/Model/Observer/Cron.php +52 -19
- app/code/community/Litespeed/Litemage/Model/Observer/Esi.php +9 -1
- app/code/community/Litespeed/Litemage/Model/Observer/Purge.php +62 -13
- app/code/community/Litespeed/Litemage/controllers/AdminController.php +39 -4
- app/code/community/Litespeed/Litemage/controllers/Adminhtml/LitemageCacheController.php +23 -0
- app/code/community/Litespeed/Litemage/controllers/EsiController.php +29 -6
- app/code/community/Litespeed/Litemage/etc/config.xml +24 -5
- app/code/community/Litespeed/Litemage/etc/system.xml +54 -4
- app/design/adminhtml/default/default/layout/litemage.xml +12 -0
- app/design/adminhtml/default/default/template/litemage/cache_management.phtml +3 -2
- app/design/adminhtml/default/default/template/litemage/category_save.phtml +38 -0
- app/design/adminhtml/default/default/template/litemage/product_save.phtml +50 -0
- package.xml +12 -10
- shell/litemage_purge.php +179 -0
app/code/community/Litespeed/Litemage/Block/Adminhtml/ItemSave.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* LiteMage
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This program is free software: you can redistribute it and/or modify
|
9 |
+
* it under the terms of the GNU General Public License as published by
|
10 |
+
* the Free Software Foundation, either version 3 of the License, or
|
11 |
+
* (at your option) any later version.
|
12 |
+
*
|
13 |
+
* This program is distributed in the hope that it will be useful,
|
14 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
+
* GNU General Public License for more details.
|
17 |
+
*
|
18 |
+
* You should have received a copy of the GNU General Public License
|
19 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
20 |
+
*
|
21 |
+
* @package LiteSpeed_LiteMage
|
22 |
+
* @copyright Copyright (c) 2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
23 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
24 |
+
*/
|
25 |
+
|
26 |
+
|
27 |
+
class Litespeed_Litemage_Block_Adminhtml_ItemSave extends Mage_Adminhtml_Block_Template
|
28 |
+
{
|
29 |
+
const SAVE_PROD_SESSION_KEY = 'litemage_admin_saveprod';
|
30 |
+
|
31 |
+
public function getProductSaveOptionUrl()
|
32 |
+
{
|
33 |
+
if (($product = Mage::registry('product')) == null) {
|
34 |
+
$product = Mage::registry('current_product');
|
35 |
+
}
|
36 |
+
|
37 |
+
if ($product && $product->getId() > 0) {
|
38 |
+
return $this->getUrl('*/litemageCache/productSaveOption', array('id' => $product->getId()));
|
39 |
+
}
|
40 |
+
return null;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function getCurrentProdSaveOptions()
|
44 |
+
{
|
45 |
+
$session = Mage::getSingleton('admin/session');
|
46 |
+
if (!$session->getData(self::SAVE_PROD_SESSION_KEY)) {
|
47 |
+
$session->setData(self::SAVE_PROD_SESSION_KEY, 'c');
|
48 |
+
}
|
49 |
+
$cur = $session->getData(self::SAVE_PROD_SESSION_KEY);
|
50 |
+
|
51 |
+
$lmhelper = Mage::helper('litemage/data');
|
52 |
+
$options = array('c' => $lmhelper->__('For This Product and Related Parent Categories'),
|
53 |
+
'p' => $lmhelper->__('For This Product Only'),
|
54 |
+
'n' => $lmhelper->__('Do Not Purge'));
|
55 |
+
$buf = '';
|
56 |
+
foreach($options as $k => $v) {
|
57 |
+
$buf .= '<option value="' . $k . '"';
|
58 |
+
if ($k == $cur) {
|
59 |
+
$buf .= ' selected';
|
60 |
+
}
|
61 |
+
$buf .= '>' . $v . '</option>';
|
62 |
+
}
|
63 |
+
return $buf;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Check if block can be displayed
|
68 |
+
*
|
69 |
+
* @return bool
|
70 |
+
*/
|
71 |
+
public function canShowButton()
|
72 |
+
{
|
73 |
+
return Mage::helper('litemage/data')->moduleEnabled();
|
74 |
+
}
|
75 |
+
|
76 |
+
public function isCacheAvailable()
|
77 |
+
{
|
78 |
+
return Mage::app()->useCache('layout') && Mage::app()->useCache('config');
|
79 |
+
}
|
80 |
+
|
81 |
+
|
82 |
+
|
83 |
+
}
|
app/code/community/Litespeed/Litemage/Helper/Data.php
CHANGED
@@ -33,6 +33,8 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
|
|
33 |
const STOREXML_TRACKLASTVIEWED = 'litemage/general/track_viewed' ;
|
34 |
const STOREXML_DIFFCUSTGRP = 'litemage/general/diff_customergroup' ;
|
35 |
const STOREXML_WARMUP_ENABLED = 'litemage/warmup/enable_warmup' ;
|
|
|
|
|
36 |
const CFG_ENABLED = 'enabled' ;
|
37 |
const CFG_DEBUGON = 'debug' ;
|
38 |
const CFG_WARMUP = 'warmup' ;
|
@@ -40,6 +42,7 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
|
|
40 |
const CFG_WARMUP_LOAD_LIMIT = 'load_limit' ;
|
41 |
const CFG_WARMUP_MAXTIME = 'max_time' ;
|
42 |
const CFG_WARMUP_THREAD_LIMIT = 'thread_limit' ;
|
|
|
43 |
const CFG_AUTOCOLLECT = 'collect' ;
|
44 |
const CFG_TRACKLASTVIEWED = 'track_viewed' ;
|
45 |
const CFG_DIFFCUSTGRP = 'diff_customergroup' ;
|
@@ -55,6 +58,9 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
|
|
55 |
const CFG_NOCACHE_URL = 'nocache_urls' ;
|
56 |
const CFG_ALLOWEDIPS = 'allow_ips' ;
|
57 |
const CFG_ADMINIPS = 'admin_ips' ;
|
|
|
|
|
|
|
58 |
const CFG_FLUSH_PRODCAT = 'flush_prodcat' ;
|
59 |
const CFG_NEED_ADD_DELTA = 'add_delta' ;
|
60 |
const LITEMAGE_GENERAL_CACHE_TAG = 'LITESPEED_LITEMAGE' ;
|
@@ -63,21 +69,36 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
|
|
63 |
// config items
|
64 |
protected $_conf = array() ;
|
65 |
protected $_userModuleEnabled = -2 ; // -2: not set, true, false
|
|
|
66 |
protected $_esiTag ;
|
67 |
-
protected $_isDebug ;
|
68 |
protected $_translateParams = null ;
|
69 |
protected $_debugTag = 'LiteMage' ;
|
70 |
|
71 |
-
public function
|
72 |
{
|
73 |
-
if ( isset($_SERVER['X-LITEMAGE']) && $_SERVER['X-LITEMAGE']
|
74 |
-
|
|
|
75 |
}
|
76 |
else {
|
77 |
return false ;
|
78 |
}
|
79 |
}
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
public function moduleEnabledForUser()
|
82 |
{
|
83 |
if ( $this->_userModuleEnabled === -2 ) {
|
@@ -678,6 +699,9 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
|
|
678 |
if ( ! isset($cust['fullcache_routes']) ) {
|
679 |
$cust['fullcache_routes'] = '' ;
|
680 |
}
|
|
|
|
|
|
|
681 |
|
682 |
$this->_conf[self::CFG_NOCACHE][self::CFG_CACHE_ROUTE] = array_merge(preg_split($pattern, $default['cache_routes'], null, PREG_SPLIT_NO_EMPTY), preg_split($pattern, $cust['cache_routes'], null, PREG_SPLIT_NO_EMPTY)) ;
|
683 |
$this->_conf[self::CFG_NOCACHE][self::CFG_NOCACHE_ROUTE] = array_merge(preg_split($pattern, $default['nocache_subroutes'], null, PREG_SPLIT_NO_EMPTY), preg_split($pattern, $default['nocache_subroutes'], null, PREG_SPLIT_NO_EMPTY)) ;
|
@@ -688,15 +712,17 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
|
|
688 |
|
689 |
case self::CFG_WARMUP:
|
690 |
$warmup = $this->_conf['defaultlm']['warmup'] ;
|
691 |
-
$server_ip = $warmup[self::CFG_WARMUP_SERVER_IP] ;
|
692 |
-
if (
|
693 |
-
$server_ip = '' ;
|
694 |
}
|
|
|
695 |
$this->_conf[self::CFG_WARMUP] = array(
|
696 |
self::CFG_WARMUP_LOAD_LIMIT => $warmup[self::CFG_WARMUP_LOAD_LIMIT],
|
697 |
self::CFG_WARMUP_THREAD_LIMIT => $warmup[self::CFG_WARMUP_THREAD_LIMIT],
|
698 |
self::CFG_WARMUP_MAXTIME => $warmup[self::CFG_WARMUP_MAXTIME],
|
699 |
-
self::CFG_WARMUP_SERVER_IP => $server_ip
|
|
|
700 |
break ;
|
701 |
|
702 |
default:
|
@@ -731,6 +757,16 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
|
|
731 |
$allowedIps = trim($test[self::CFG_ALLOWEDIPS]) ;
|
732 |
$this->_conf[self::CFG_ALLOWEDIPS] = $allowedIps ? preg_split($pattern, $allowedIps, null, PREG_SPLIT_NO_EMPTY) : '' ;
|
733 |
$this->_conf[self::CFG_FLUSH_PRODCAT] = isset($general[self::CFG_FLUSH_PRODCAT]) ? $general[self::CFG_FLUSH_PRODCAT] : 0 ; // for upgrade, maynot save in config
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
734 |
}
|
735 |
}
|
736 |
|
@@ -758,6 +794,9 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
|
|
758 |
|
759 |
public function debugMesg( $mesg )
|
760 |
{
|
|
|
|
|
|
|
761 |
if ( $this->_isDebug ) {
|
762 |
$mesg = str_replace("\n", ("\n" . $this->_debugTag . ' '), $mesg) ;
|
763 |
Mage::log($this->_debugTag . ' ' . $mesg) ;
|
33 |
const STOREXML_TRACKLASTVIEWED = 'litemage/general/track_viewed' ;
|
34 |
const STOREXML_DIFFCUSTGRP = 'litemage/general/diff_customergroup' ;
|
35 |
const STOREXML_WARMUP_ENABLED = 'litemage/warmup/enable_warmup' ;
|
36 |
+
const STOREXML_FPWP_ENABLED = 'litemage/fishpigwp/fpwp_cache';
|
37 |
+
const STOREXML_FPWP_TTL = 'litemage/fishpigwp/fpwp_ttl';
|
38 |
const CFG_ENABLED = 'enabled' ;
|
39 |
const CFG_DEBUGON = 'debug' ;
|
40 |
const CFG_WARMUP = 'warmup' ;
|
42 |
const CFG_WARMUP_LOAD_LIMIT = 'load_limit' ;
|
43 |
const CFG_WARMUP_MAXTIME = 'max_time' ;
|
44 |
const CFG_WARMUP_THREAD_LIMIT = 'thread_limit' ;
|
45 |
+
const CFG_WARMUP_DELTA_LOG = 'delta_log';
|
46 |
const CFG_AUTOCOLLECT = 'collect' ;
|
47 |
const CFG_TRACKLASTVIEWED = 'track_viewed' ;
|
48 |
const CFG_DIFFCUSTGRP = 'diff_customergroup' ;
|
58 |
const CFG_NOCACHE_URL = 'nocache_urls' ;
|
59 |
const CFG_ALLOWEDIPS = 'allow_ips' ;
|
60 |
const CFG_ADMINIPS = 'admin_ips' ;
|
61 |
+
const CFG_FPWP_ENABLED = 'fpwp_cache';
|
62 |
+
const CFG_FPWP_TTL = 'fpwp_ttl';
|
63 |
+
const CFG_FPWP_PREFIX = 'fpwp_prefix';
|
64 |
const CFG_FLUSH_PRODCAT = 'flush_prodcat' ;
|
65 |
const CFG_NEED_ADD_DELTA = 'add_delta' ;
|
66 |
const LITEMAGE_GENERAL_CACHE_TAG = 'LITESPEED_LITEMAGE' ;
|
69 |
// config items
|
70 |
protected $_conf = array() ;
|
71 |
protected $_userModuleEnabled = -2 ; // -2: not set, true, false
|
72 |
+
protected $_moduleEnabled = -2 ; // -2: not set, true, false
|
73 |
protected $_esiTag ;
|
74 |
+
protected $_isDebug = null;
|
75 |
protected $_translateParams = null ;
|
76 |
protected $_debugTag = 'LiteMage' ;
|
77 |
|
78 |
+
public function licenseEnabled()
|
79 |
{
|
80 |
+
if ( (isset($_SERVER['X-LITEMAGE']) && $_SERVER['X-LITEMAGE']) // for lsws
|
81 |
+
|| (isset($_SERVER['HTTP_X_LITEMAGE']) && $_SERVER['HTTP_X_LITEMAGE'])) { // lslb
|
82 |
+
return true;
|
83 |
}
|
84 |
else {
|
85 |
return false ;
|
86 |
}
|
87 |
}
|
88 |
|
89 |
+
public function moduleEnabled()
|
90 |
+
{
|
91 |
+
if ( $this->_moduleEnabled === -2 ) {
|
92 |
+
if ($this->licenseEnabled()) {
|
93 |
+
$this->_moduleEnabled = $this->getConf(self::CFG_ENABLED);
|
94 |
+
}
|
95 |
+
else {
|
96 |
+
$this->_moduleEnabled = false;
|
97 |
+
}
|
98 |
+
}
|
99 |
+
return $this->_moduleEnabled;
|
100 |
+
}
|
101 |
+
|
102 |
public function moduleEnabledForUser()
|
103 |
{
|
104 |
if ( $this->_userModuleEnabled === -2 ) {
|
699 |
if ( ! isset($cust['fullcache_routes']) ) {
|
700 |
$cust['fullcache_routes'] = '' ;
|
701 |
}
|
702 |
+
if ($this->_conf[self::CFG_FPWP_ENABLED]) {
|
703 |
+
$cust['cache_routes'] .= ' wordpress_' ;
|
704 |
+
}
|
705 |
|
706 |
$this->_conf[self::CFG_NOCACHE][self::CFG_CACHE_ROUTE] = array_merge(preg_split($pattern, $default['cache_routes'], null, PREG_SPLIT_NO_EMPTY), preg_split($pattern, $cust['cache_routes'], null, PREG_SPLIT_NO_EMPTY)) ;
|
707 |
$this->_conf[self::CFG_NOCACHE][self::CFG_NOCACHE_ROUTE] = array_merge(preg_split($pattern, $default['nocache_subroutes'], null, PREG_SPLIT_NO_EMPTY), preg_split($pattern, $default['nocache_subroutes'], null, PREG_SPLIT_NO_EMPTY)) ;
|
712 |
|
713 |
case self::CFG_WARMUP:
|
714 |
$warmup = $this->_conf['defaultlm']['warmup'] ;
|
715 |
+
$server_ip = trim($warmup[self::CFG_WARMUP_SERVER_IP]) ;
|
716 |
+
if ( !$server_ip || ! Mage::helper('core/http')->validateIpAddr($server_ip) ) {
|
717 |
+
$server_ip = '127.0.0.1' ; //default
|
718 |
}
|
719 |
+
$delta_log = isset($this->_conf['defaultlm']['test']['delta_log']) && ($this->_conf['defaultlm']['test']['delta_log'] == 1);
|
720 |
$this->_conf[self::CFG_WARMUP] = array(
|
721 |
self::CFG_WARMUP_LOAD_LIMIT => $warmup[self::CFG_WARMUP_LOAD_LIMIT],
|
722 |
self::CFG_WARMUP_THREAD_LIMIT => $warmup[self::CFG_WARMUP_THREAD_LIMIT],
|
723 |
self::CFG_WARMUP_MAXTIME => $warmup[self::CFG_WARMUP_MAXTIME],
|
724 |
+
self::CFG_WARMUP_SERVER_IP => $server_ip,
|
725 |
+
self::CFG_WARMUP_DELTA_LOG => $delta_log) ;
|
726 |
break ;
|
727 |
|
728 |
default:
|
757 |
$allowedIps = trim($test[self::CFG_ALLOWEDIPS]) ;
|
758 |
$this->_conf[self::CFG_ALLOWEDIPS] = $allowedIps ? preg_split($pattern, $allowedIps, null, PREG_SPLIT_NO_EMPTY) : '' ;
|
759 |
$this->_conf[self::CFG_FLUSH_PRODCAT] = isset($general[self::CFG_FLUSH_PRODCAT]) ? $general[self::CFG_FLUSH_PRODCAT] : 0 ; // for upgrade, maynot save in config
|
760 |
+
|
761 |
+
if (isset($this->_conf['defaultlm']['fishpigwp'])) {
|
762 |
+
$fpwp = $this->_conf['defaultlm']['fishpigwp'];
|
763 |
+
$this->_conf[self::CFG_FPWP_PREFIX] = $fpwp[self::CFG_FPWP_PREFIX];
|
764 |
+
$this->_conf[self::CFG_FPWP_TTL] = Mage::getStoreConfig(self::STOREXML_FPWP_TTL, $storeId) ;
|
765 |
+
$this->_conf[self::CFG_FPWP_ENABLED] = Mage::getStoreConfig(self::STOREXML_FPWP_ENABLED, $storeId) ;
|
766 |
+
}
|
767 |
+
else {
|
768 |
+
$this->_conf[self::CFG_FPWP_ENABLED] = 0;
|
769 |
+
}
|
770 |
}
|
771 |
}
|
772 |
|
794 |
|
795 |
public function debugMesg( $mesg )
|
796 |
{
|
797 |
+
if ($this->_isDebug === null) {
|
798 |
+
$this->_initConf();
|
799 |
+
}
|
800 |
if ( $this->_isDebug ) {
|
801 |
$mesg = str_replace("\n", ("\n" . $this->_debugTag . ' '), $mesg) ;
|
802 |
Mage::log($this->_debugTag . ' ' . $mesg) ;
|
app/code/community/Litespeed/Litemage/Helper/Esi.php
CHANGED
@@ -182,19 +182,7 @@ class Litespeed_Litemage_Helper_Esi
|
|
182 |
return;
|
183 |
|
184 |
$this->_esiPurgeEvents[$eventName] = $eventName ;
|
185 |
-
|
186 |
-
$purgeHeader = $this->_getPurgeHeaderValue($cachePurgeTags, true);
|
187 |
-
header(self::LSHEADER_PURGE . ': ' . $purgeHeader, true);
|
188 |
-
if ($this->_isDebug)
|
189 |
-
$this->_config->debugMesg("SetPurgeHeader: " . $purgeHeader . ' (triggered by event ' . $eventName . ')') ;
|
190 |
-
}
|
191 |
-
}
|
192 |
-
|
193 |
-
protected function _getEsiPurgeTags()
|
194 |
-
{
|
195 |
-
if ( count($this->_esiPurgeEvents) == 0 )
|
196 |
-
return null ;
|
197 |
-
|
198 |
$events = $this->_config->getEsiConf('event');
|
199 |
$tags = array() ;
|
200 |
foreach ( $this->_esiPurgeEvents as $e ) {
|
@@ -207,43 +195,49 @@ class Litespeed_Litemage_Helper_Esi
|
|
207 |
}
|
208 |
}
|
209 |
|
210 |
-
if ($
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
}
|
216 |
|
217 |
-
protected function
|
218 |
{
|
219 |
-
|
|
|
|
|
|
|
|
|
220 |
$t = '';
|
221 |
foreach ($tags as $tag) {
|
222 |
-
$t .=
|
223 |
}
|
224 |
-
$purgeHeader
|
225 |
-
|
226 |
-
if (!$isPrivate ) {
|
227 |
-
$this->_addDeltaByTags($tags);
|
228 |
-
}
|
229 |
-
|
230 |
return $purgeHeader;
|
231 |
}
|
232 |
-
|
233 |
-
public function setPurgeHeader( $tags, $by, $response = null
|
234 |
{
|
235 |
-
$purgeHeader = $this->
|
236 |
|
237 |
if ( $response == null ) {
|
238 |
$response = Mage::app()->getResponse() ;
|
239 |
}
|
240 |
$response->setHeader(self::LSHEADER_PURGE, $purgeHeader, true) ;
|
241 |
-
|
242 |
if ($this->_isDebug) {
|
243 |
$this->_config->debugMesg("SetPurgeHeader: " . $purgeHeader . ' (triggered by ' . $by . ')') ;
|
244 |
}
|
245 |
}
|
246 |
-
|
247 |
public function setPurgeURLHeader( $url, $by )
|
248 |
{
|
249 |
$response = Mage::app()->getResponse() ;
|
@@ -440,6 +434,39 @@ class Litespeed_Litemage_Helper_Esi
|
|
440 |
}
|
441 |
}
|
442 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
443 |
public function beforeResponseSend( $response )
|
444 |
{
|
445 |
$this->_refreshEsiBlockCache();
|
@@ -462,11 +489,20 @@ class Litespeed_Litemage_Helper_Esi
|
|
462 |
$cacheable = false;
|
463 |
}
|
464 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
if ( $cacheable ) {
|
466 |
-
if (
|
467 |
-
$cacheControlHeader = 'private,max-age=' . (($this->_cacheVars['ttl'] > 0) ? $this->_cacheVars['ttl'] : $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_PRIVATETTL)) ;
|
468 |
-
else
|
469 |
$cacheControlHeader = 'public,max-age=' . (($this->_cacheVars['ttl'] > 0) ? $this->_cacheVars['ttl'] : $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_PUBLICTTL)) ;
|
|
|
|
|
|
|
|
|
470 |
|
471 |
$notEsiReq = (($flag & self::CHBM_ESI_REQ) == 0);
|
472 |
if ($notEsiReq) {
|
@@ -481,7 +517,7 @@ class Litespeed_Litemage_Helper_Esi
|
|
481 |
$cacheControlHeader .= ',set-blank';
|
482 |
}
|
483 |
|
484 |
-
if ( ($cacheTagHeader = $this->_getCacheTagHeader($notEsiReq)) ) {
|
485 |
$extraHeaders[self::LSHEADER_CACHE_TAG] = $cacheTagHeader;
|
486 |
}
|
487 |
}
|
@@ -556,7 +592,7 @@ class Litespeed_Litemage_Helper_Esi
|
|
556 |
// no need to use comment, will be removed by minify extensions
|
557 |
// if response coming from backend, no need to send separate log request
|
558 |
$tracker = '<' . $esiIncludeTag . ' src="' . $this->_getSubReqUrl('litemage/esi/log', $logOptions)
|
559 |
-
. '" test="$(RESP_HEADER{X-LITESPEED-CACHE})!=\'\'" cache-control="no-cache" combine="sub"/>' ;
|
560 |
if ($this->_isDebug) {
|
561 |
$this->_config->debugMesg('Track recently viewed as ' . $tracker);
|
562 |
}
|
@@ -593,9 +629,11 @@ class Litespeed_Litemage_Helper_Esi
|
|
593 |
|
594 |
}
|
595 |
|
596 |
-
protected function _getCacheTagHeader($notEsiReq)
|
597 |
{
|
598 |
$tags = $this->_cacheVars['tag'] ;
|
|
|
|
|
599 |
if ($notEsiReq) {
|
600 |
if ( count($tags) == 0 ) {
|
601 |
// set tag for product id, cid, and pageid
|
@@ -607,16 +645,18 @@ class Litespeed_Litemage_Helper_Esi
|
|
607 |
}
|
608 |
}
|
609 |
|
610 |
-
$curStore = Mage::app()->getStore() ;
|
611 |
if ($curStore->getCurrentCurrencyCode() != $curStore->getBaseCurrencyCode()) {
|
612 |
$tags[] = 'CURR'; // will be purged by currency rate update event
|
613 |
}
|
614 |
|
615 |
-
$debugMesg = $this->_autoCollectUrls($
|
616 |
if ($this->_isDebug && $debugMesg) {
|
617 |
$this->_config->debugMesg('_autoCollectUrls: ' . $debugMesg);
|
618 |
}
|
619 |
}
|
|
|
|
|
|
|
620 |
|
621 |
$tag = count($tags) ? implode(',', $tags) : '' ;
|
622 |
return $tag ;
|
@@ -684,7 +724,10 @@ class Litespeed_Litemage_Helper_Esi
|
|
684 |
}
|
685 |
|
686 |
if (!$tag) {
|
687 |
-
|
|
|
|
|
|
|
688 |
}
|
689 |
|
690 |
$attr = 0; // BitMask 1: user, 2: robot, 4: cron_store, 8: cron_cust, 16: cron_auto, 32: is_ajax,
|
@@ -920,7 +963,9 @@ class Litespeed_Litemage_Helper_Esi
|
|
920 |
|
921 |
protected function _getPurgeCacheTags()
|
922 |
{
|
|
|
923 |
$tags = $this->_cacheVars['tag'] ;
|
|
|
924 |
if (empty($tags)) {
|
925 |
// set tag for product id, cid, and pageid
|
926 |
if ( ($curProduct = Mage::registry('current_product')) != null ) {
|
@@ -929,16 +974,15 @@ class Litespeed_Litemage_Helper_Esi
|
|
929 |
elseif ( ($curCategory = Mage::registry('current_category')) != null ) {
|
930 |
$tags[] = self::TAG_PREFIX_CATEGORY . $curCategory->getId() ;
|
931 |
}
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
$this->_addDeltaByTags($tags);
|
943 |
|
944 |
$tag = count($tags) ? implode(',', $tags) : '' ;
|
182 |
return;
|
183 |
|
184 |
$this->_esiPurgeEvents[$eventName] = $eventName ;
|
185 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
$events = $this->_config->getEsiConf('event');
|
187 |
$tags = array() ;
|
188 |
foreach ( $this->_esiPurgeEvents as $e ) {
|
195 |
}
|
196 |
}
|
197 |
|
198 |
+
if (count($tags)) {
|
199 |
+
$purgeHeader = 'private,' ;
|
200 |
+
$t = '';
|
201 |
+
foreach ($tags as $tag) {
|
202 |
+
$t .= ( $tag == '*' ) ? '*' : 'tag=' . $tag . ',' ;
|
203 |
+
}
|
204 |
+
$purgeHeader .= trim($t, ',');
|
205 |
+
|
206 |
+
header(self::LSHEADER_PURGE . ': ' . $purgeHeader, true);
|
207 |
+
if ($this->_isDebug) {
|
208 |
+
$this->_config->debugMesg("SetPurgeHeader: " . $purgeHeader . ' (triggered by event ' . $eventName . ')') ;
|
209 |
+
}
|
210 |
+
}
|
211 |
}
|
212 |
|
213 |
+
protected function _getPurgeHeaderValueByPublicTags($tags)
|
214 |
{
|
215 |
+
$this->_addDeltaByTags($tags);
|
216 |
+
if (in_array('*', $tags)) {
|
217 |
+
return '*';
|
218 |
+
}
|
219 |
+
|
220 |
$t = '';
|
221 |
foreach ($tags as $tag) {
|
222 |
+
$t .= 'tag=' . $tag . ',' ;
|
223 |
}
|
224 |
+
$purgeHeader = trim($t, ',');
|
|
|
|
|
|
|
|
|
|
|
225 |
return $purgeHeader;
|
226 |
}
|
227 |
+
|
228 |
+
public function setPurgeHeader( $tags, $by, $response = null )
|
229 |
{
|
230 |
+
$purgeHeader = $this->_getPurgeHeaderValueByPublicTags($tags);
|
231 |
|
232 |
if ( $response == null ) {
|
233 |
$response = Mage::app()->getResponse() ;
|
234 |
}
|
235 |
$response->setHeader(self::LSHEADER_PURGE, $purgeHeader, true) ;
|
|
|
236 |
if ($this->_isDebug) {
|
237 |
$this->_config->debugMesg("SetPurgeHeader: " . $purgeHeader . ' (triggered by ' . $by . ')') ;
|
238 |
}
|
239 |
}
|
240 |
+
|
241 |
public function setPurgeURLHeader( $url, $by )
|
242 |
{
|
243 |
$response = Mage::app()->getResponse() ;
|
434 |
}
|
435 |
}
|
436 |
|
437 |
+
protected function _integrateFishpigWP()
|
438 |
+
{
|
439 |
+
$h = Mage::helper('wordpress/app');
|
440 |
+
if ($h) {
|
441 |
+
$blogId = $h->getBlogId();
|
442 |
+
if ($blogId > 0) {
|
443 |
+
$this->_cacheVars['ttl'] = $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_FPWP_TTL);
|
444 |
+
$prefix = $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_FPWP_PREFIX);
|
445 |
+
$this->_cacheVars['wptag'] = $prefix . 'B' . $blogId . '_';
|
446 |
+
if (empty($this->_cacheVars['tag'])) {
|
447 |
+
if ( ($curProduct = Mage::registry('product')) != null ) {
|
448 |
+
$this->_cacheVars['tag'][] = self::TAG_PREFIX_PRODUCT . $curProduct->getId() ;
|
449 |
+
}
|
450 |
+
elseif ( ($curCategory = Mage::registry('category')) != null ) {
|
451 |
+
$this->_cacheVars['tag'][] = self::TAG_PREFIX_CATEGORY . $curCategory->getId() ;
|
452 |
+
}
|
453 |
+
}
|
454 |
+
$this->_cacheVars['tag'][] = $this->_cacheVars['wptag'];
|
455 |
+
return true;
|
456 |
+
}
|
457 |
+
else {
|
458 |
+
$msg = 'cannot find blog Id';
|
459 |
+
}
|
460 |
+
}
|
461 |
+
else {
|
462 |
+
$msg = 'cannot find Fishpig helper';
|
463 |
+
}
|
464 |
+
if ($this->_isDebug) {
|
465 |
+
$this->_config->debugMesg('Fishpig WP - ' . $msg);
|
466 |
+
}
|
467 |
+
|
468 |
+
}
|
469 |
+
|
470 |
public function beforeResponseSend( $response )
|
471 |
{
|
472 |
$this->_refreshEsiBlockCache();
|
489 |
$cacheable = false;
|
490 |
}
|
491 |
|
492 |
+
$isPublic = (($flag & self::CHBM_PRIVATE) == 0);
|
493 |
+
if ($cacheable && $isPublic
|
494 |
+
&& (strpos($this->_cacheVars['internal']['route_info'], 'wordpress_') !== false)
|
495 |
+
&& $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_FPWP_ENABLED)) {
|
496 |
+
$cacheable = $this->_integrateFishpigWP();
|
497 |
+
}
|
498 |
+
|
499 |
if ( $cacheable ) {
|
500 |
+
if ( $isPublic ) {
|
|
|
|
|
501 |
$cacheControlHeader = 'public,max-age=' . (($this->_cacheVars['ttl'] > 0) ? $this->_cacheVars['ttl'] : $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_PUBLICTTL)) ;
|
502 |
+
}
|
503 |
+
else {
|
504 |
+
$cacheControlHeader = 'private,max-age=' . (($this->_cacheVars['ttl'] > 0) ? $this->_cacheVars['ttl'] : $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_PRIVATETTL)) ;
|
505 |
+
}
|
506 |
|
507 |
$notEsiReq = (($flag & self::CHBM_ESI_REQ) == 0);
|
508 |
if ($notEsiReq) {
|
517 |
$cacheControlHeader .= ',set-blank';
|
518 |
}
|
519 |
|
520 |
+
if ( ($cacheTagHeader = $this->_getCacheTagHeader($notEsiReq, $isPublic)) ) {
|
521 |
$extraHeaders[self::LSHEADER_CACHE_TAG] = $cacheTagHeader;
|
522 |
}
|
523 |
}
|
592 |
// no need to use comment, will be removed by minify extensions
|
593 |
// if response coming from backend, no need to send separate log request
|
594 |
$tracker = '<' . $esiIncludeTag . ' src="' . $this->_getSubReqUrl('litemage/esi/log', $logOptions)
|
595 |
+
. '" test="$(RESP_HEADER{X-LITESPEED-CACHE})!=\'hit,litemage\'" cache-control="no-cache" combine="sub"/>' ;
|
596 |
if ($this->_isDebug) {
|
597 |
$this->_config->debugMesg('Track recently viewed as ' . $tracker);
|
598 |
}
|
629 |
|
630 |
}
|
631 |
|
632 |
+
protected function _getCacheTagHeader($notEsiReq, $isPublic)
|
633 |
{
|
634 |
$tags = $this->_cacheVars['tag'] ;
|
635 |
+
$curStore = Mage::app()->getStore() ;
|
636 |
+
$curStoreId = $curStore->getId();
|
637 |
if ($notEsiReq) {
|
638 |
if ( count($tags) == 0 ) {
|
639 |
// set tag for product id, cid, and pageid
|
645 |
}
|
646 |
}
|
647 |
|
|
|
648 |
if ($curStore->getCurrentCurrencyCode() != $curStore->getBaseCurrencyCode()) {
|
649 |
$tags[] = 'CURR'; // will be purged by currency rate update event
|
650 |
}
|
651 |
|
652 |
+
$debugMesg = $this->_autoCollectUrls($curStoreId, $tags);
|
653 |
if ($this->_isDebug && $debugMesg) {
|
654 |
$this->_config->debugMesg('_autoCollectUrls: ' . $debugMesg);
|
655 |
}
|
656 |
}
|
657 |
+
if ($isPublic) {
|
658 |
+
$tags[] = 'S.' . $curStoreId;
|
659 |
+
}
|
660 |
|
661 |
$tag = count($tags) ? implode(',', $tags) : '' ;
|
662 |
return $tag ;
|
724 |
}
|
725 |
|
726 |
if (!$tag) {
|
727 |
+
if (isset($this->_cacheVars['wptag']))
|
728 |
+
$tag = $this->_cacheVars['wptag'];
|
729 |
+
else
|
730 |
+
$tag = $this->_cacheVars['internal']['route_info'];
|
731 |
}
|
732 |
|
733 |
$attr = 0; // BitMask 1: user, 2: robot, 4: cron_store, 8: cron_cust, 16: cron_auto, 32: is_ajax,
|
963 |
|
964 |
protected function _getPurgeCacheTags()
|
965 |
{
|
966 |
+
// only for LITEMAGE_CTRL=PURGE
|
967 |
$tags = $this->_cacheVars['tag'] ;
|
968 |
+
|
969 |
if (empty($tags)) {
|
970 |
// set tag for product id, cid, and pageid
|
971 |
if ( ($curProduct = Mage::registry('current_product')) != null ) {
|
974 |
elseif ( ($curCategory = Mage::registry('current_category')) != null ) {
|
975 |
$tags[] = self::TAG_PREFIX_CATEGORY . $curCategory->getId() ;
|
976 |
}
|
977 |
+
}
|
978 |
+
if (empty($tags)) {
|
979 |
+
// go by url
|
980 |
+
$uri = str_replace('LITEMAGE_CTRL=PURGE', '', $_SERVER['REQUEST_URI']);
|
981 |
+
if (substr($uri, -1) == '?') {
|
982 |
+
$uri = rtrim($uri, '?');
|
983 |
+
}
|
984 |
+
return $uri;
|
985 |
+
}
|
|
|
986 |
$this->_addDeltaByTags($tags);
|
987 |
|
988 |
$tag = count($tags) ? implode(',', $tags) : '' ;
|
app/code/community/Litespeed/Litemage/Model/EsiData.php
CHANGED
@@ -174,10 +174,10 @@ class Litespeed_Litemage_Model_EsiData
|
|
174 |
$buf .= $this->_cacheAttr['access'] . ',max-age=' . $ttl . ',no-vary' ;
|
175 |
if ( $this->_cacheAttr['cacheIfEmpty'] )
|
176 |
$buf .= ',set-blank' ;
|
177 |
-
elseif ( $shared ) {
|
178 |
$buf .= ',shared' ;
|
179 |
}
|
180 |
-
|
181 |
$buf .= '" cache-tag="' . $this->_cacheAttr['tag'] ;
|
182 |
}
|
183 |
|
174 |
$buf .= $this->_cacheAttr['access'] . ',max-age=' . $ttl . ',no-vary' ;
|
175 |
if ( $this->_cacheAttr['cacheIfEmpty'] )
|
176 |
$buf .= ',set-blank' ;
|
177 |
+
elseif ( $shared && ($this->_action != self::ACTION_GET_FORMKEY) ) {
|
178 |
$buf .= ',shared' ;
|
179 |
}
|
180 |
+
|
181 |
$buf .= '" cache-tag="' . $this->_cacheAttr['tag'] ;
|
182 |
}
|
183 |
|
app/code/community/Litespeed/Litemage/Model/Layout/Master.php
CHANGED
@@ -40,12 +40,20 @@ class Litespeed_Litemage_Model_Layout_Master
|
|
40 |
throw Mage::exception('Litespeed_Litemage_Model_Layout_Master should only be used for frontend') ;
|
41 |
}
|
42 |
|
43 |
-
$
|
|
|
44 |
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
47 |
|
48 |
-
|
|
|
|
|
|
|
|
|
49 |
}
|
50 |
|
51 |
public function getHandleUpdates( $handle )
|
@@ -53,7 +61,7 @@ class Litespeed_Litemage_Model_Layout_Master
|
|
53 |
if ( ! isset($this->_handleUpdates[$handle]) ) {
|
54 |
$result = false ;
|
55 |
if ( Mage::app()->useCache('layout') ) {
|
56 |
-
$cacheId = $this->
|
57 |
$result = Mage::app()->loadCache($cacheId) ;
|
58 |
}
|
59 |
$this->_handleUpdates[$handle] = $result ;
|
40 |
throw Mage::exception('Litespeed_Litemage_Model_Layout_Master should only be used for frontend') ;
|
41 |
}
|
42 |
|
43 |
+
$this->_cacheTags = array( Mage_Core_Model_Layout_Update::LAYOUT_GENERAL_CACHE_TAG ) ;
|
44 |
+
}
|
45 |
|
46 |
+
public function getCachePrefix()
|
47 |
+
{
|
48 |
+
if (!$this->_cachePrefix) {
|
49 |
+
$design = Mage::getSingleton('core/design_package');
|
50 |
+
$storeId = Mage::app()->getStore()->getId();
|
51 |
|
52 |
+
//dp & dt may change dynamically, so only set when calling it
|
53 |
+
$this->_cachePrefix = 'LAYOUT_MASTER_' . $storeId . '_' . $design->getPackageName() . '_'
|
54 |
+
. $design->getTheme('layout') . '_';
|
55 |
+
}
|
56 |
+
return $this->_cachePrefix;
|
57 |
}
|
58 |
|
59 |
public function getHandleUpdates( $handle )
|
61 |
if ( ! isset($this->_handleUpdates[$handle]) ) {
|
62 |
$result = false ;
|
63 |
if ( Mage::app()->useCache('layout') ) {
|
64 |
+
$cacheId = $this->getCachePrefix() . $handle ;
|
65 |
$result = Mage::app()->loadCache($cacheId) ;
|
66 |
}
|
67 |
$this->_handleUpdates[$handle] = $result ;
|
app/code/community/Litespeed/Litemage/Model/Layout/Update.php
CHANGED
@@ -134,6 +134,9 @@ class Litespeed_Litemage_Model_Layout_Update extends Mage_Core_Model_Layout_Upda
|
|
134 |
$this->_resetInternals() ;
|
135 |
$this->_layoutHandles = $this->getHandles() ;
|
136 |
$tags = $this->_layoutHandles ;
|
|
|
|
|
|
|
137 |
$tags[] = 'LITEMAGE_MODIFY' ;
|
138 |
$this->_cacheId = 'LAYOUT_' . Mage::app()->getStore()->getId() . md5(join('__', $tags)) ;
|
139 |
}
|
@@ -162,6 +165,7 @@ class Litespeed_Litemage_Model_Layout_Update extends Mage_Core_Model_Layout_Upda
|
|
162 |
if ( isset($this->_handleUpdates['LITEMAGE_SHARED']) ) {
|
163 |
$this->_sharedCacheId = $this->_handleUpdates['LITEMAGE_SHARED'] ;
|
164 |
if ( ! $result = Mage::app()->loadCache($this->_sharedCacheId) ) {
|
|
|
165 |
return false ;
|
166 |
}
|
167 |
|
@@ -196,6 +200,9 @@ class Litespeed_Litemage_Model_Layout_Update extends Mage_Core_Model_Layout_Upda
|
|
196 |
|
197 |
if ( count($this->_layoutHandles) > count($usedHandles) ) {
|
198 |
$shared = $usedHandles ;
|
|
|
|
|
|
|
199 |
$shared[] = 'LITEMAGE_SHARED' ;
|
200 |
$sharedTags = $usedHandles ;
|
201 |
$sharedTags[] = self::LAYOUT_GENERAL_CACHE_TAG ;
|
134 |
$this->_resetInternals() ;
|
135 |
$this->_layoutHandles = $this->getHandles() ;
|
136 |
$tags = $this->_layoutHandles ;
|
137 |
+
$design = Mage::getSingleton('core/design_package') ;
|
138 |
+
$tags[] = $design->getPackageName();
|
139 |
+
$tags[] = $design->getTheme('layout');
|
140 |
$tags[] = 'LITEMAGE_MODIFY' ;
|
141 |
$this->_cacheId = 'LAYOUT_' . Mage::app()->getStore()->getId() . md5(join('__', $tags)) ;
|
142 |
}
|
165 |
if ( isset($this->_handleUpdates['LITEMAGE_SHARED']) ) {
|
166 |
$this->_sharedCacheId = $this->_handleUpdates['LITEMAGE_SHARED'] ;
|
167 |
if ( ! $result = Mage::app()->loadCache($this->_sharedCacheId) ) {
|
168 |
+
unset($this->_handleUpdates['LITEMAGE_SHARED']) ;
|
169 |
return false ;
|
170 |
}
|
171 |
|
200 |
|
201 |
if ( count($this->_layoutHandles) > count($usedHandles) ) {
|
202 |
$shared = $usedHandles ;
|
203 |
+
$design = Mage::getSingleton('core/design_package') ;
|
204 |
+
$shared[] = $design->getPackageName();
|
205 |
+
$shared[] = $design->getTheme('layout');
|
206 |
$shared[] = 'LITEMAGE_SHARED' ;
|
207 |
$sharedTags = $usedHandles ;
|
208 |
$sharedTags[] = self::LAYOUT_GENERAL_CACHE_TAG ;
|
app/code/community/Litespeed/Litemage/Model/Observer/Cron.php
CHANGED
@@ -50,6 +50,12 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
|
|
50 |
{
|
51 |
$this->_helper = Mage::helper('litemage/data') ;
|
52 |
$this->_isDebug = $this->_helper->isDebug() ;
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
if ( $this->_isDebug ) {
|
54 |
$this->_debugTag = 'LiteMage [cron:' ;
|
55 |
if ( isset($_SERVER['USER']) )
|
@@ -58,9 +64,6 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
|
|
58 |
$this->_debugTag .= $_SERVER['HTTP_X_FORWARDED_FOR'] ;
|
59 |
$this->_debugTag .= ':' . $_SERVER['REQUEST_TIME'] . '] ' ;
|
60 |
}
|
61 |
-
$this->_listDir = $this->_helper->getCrawlerListDir() ;
|
62 |
-
|
63 |
-
$this->_conf = $this->_helper->getWarmUpConf() ;
|
64 |
}
|
65 |
|
66 |
public function resetCrawlerList( $listId )
|
@@ -196,13 +199,11 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
|
|
196 |
) ;
|
197 |
|
198 |
$server_ip = $this->_conf[Litespeed_Litemage_Helper_Data::CFG_WARMUP_SERVER_IP] ;
|
199 |
-
if ($server_ip) {
|
200 |
-
$options[CURLOPT_INTERFACE] = $server_ip;
|
201 |
-
}
|
202 |
|
203 |
$client = new Varien_Http_Adapter_Curl() ;
|
204 |
$curCookie = '' ;
|
205 |
$endReason = '' ;
|
|
|
206 |
|
207 |
while ( $urls = $this->_getNextUrls($curCookie) ) {
|
208 |
$curlOptions = $options ;
|
@@ -220,10 +221,24 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
|
|
220 |
$regular = array();
|
221 |
$ajax = array();
|
222 |
foreach ($urls as $url) {
|
223 |
-
|
224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
else
|
226 |
-
$regular[] = $
|
227 |
}
|
228 |
|
229 |
try {
|
@@ -231,7 +246,7 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
|
|
231 |
$client->multiRequest($regular, $curlOptions) ;
|
232 |
}
|
233 |
if (count($ajax)) {
|
234 |
-
$curlOptions[CURLOPT_HTTPHEADER] =
|
235 |
$client->multiRequest($ajax, $curlOptions) ;
|
236 |
}
|
237 |
} catch ( Exception $e ) {
|
@@ -253,7 +268,7 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
|
|
253 |
break ;
|
254 |
}
|
255 |
}
|
256 |
-
|
257 |
}
|
258 |
$this->_meta['endreason'] = $endReason ;
|
259 |
|
@@ -404,11 +419,19 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
|
|
404 |
array_shift($this->_curDelta['ids']) ;
|
405 |
}
|
406 |
|
407 |
-
$urls
|
408 |
-
$depth
|
409 |
foreach ($this->_curDelta['storeurls'][$m['curlist']] as $level => $ud) {
|
410 |
if (is_int($level) && $level <= $depth) {
|
411 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
412 |
}
|
413 |
}
|
414 |
|
@@ -910,18 +933,22 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
|
|
910 |
|
911 |
$this->_priority = $this->_isDelta ? $this->_initDeltaMeta() : $this->_initMeta() ;
|
912 |
if ( empty($this->_priority) ) {
|
913 |
-
return 'no
|
914 |
}
|
915 |
|
916 |
$maxTime = (int) ini_get('max_execution_time') ;
|
917 |
if ( $maxTime == 0 )
|
918 |
-
$maxTime = 300 ; // hardlimit
|
919 |
else
|
920 |
$maxTime -= 5 ;
|
921 |
|
922 |
$configed = $this->_conf[Litespeed_Litemage_Helper_Data::CFG_WARMUP_MAXTIME] ;
|
923 |
-
if ( $maxTime
|
924 |
$maxTime = $configed ;
|
|
|
|
|
|
|
|
|
925 |
$this->_maxRunTime = $maxTime + time() ;
|
926 |
|
927 |
$this->_adjustCurThreads() ;
|
@@ -1265,8 +1292,14 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
|
|
1265 |
protected function _debugLog( $message, $level = 0 )
|
1266 |
{
|
1267 |
if ( $this->_isDebug ) {
|
1268 |
-
$message = str_replace("\n", ("\n" . $this->_debugTag . ' '), $message) ;
|
1269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1270 |
}
|
1271 |
}
|
1272 |
|
50 |
{
|
51 |
$this->_helper = Mage::helper('litemage/data') ;
|
52 |
$this->_isDebug = $this->_helper->isDebug() ;
|
53 |
+
$this->_listDir = $this->_helper->getCrawlerListDir() ;
|
54 |
+
|
55 |
+
$this->_conf = $this->_helper->getWarmUpConf() ;
|
56 |
+
if ($this->_conf[Litespeed_Litemage_Helper_Data::CFG_WARMUP_DELTA_LOG]) {
|
57 |
+
$this->_isDebug |= 2;
|
58 |
+
}
|
59 |
if ( $this->_isDebug ) {
|
60 |
$this->_debugTag = 'LiteMage [cron:' ;
|
61 |
if ( isset($_SERVER['USER']) )
|
64 |
$this->_debugTag .= $_SERVER['HTTP_X_FORWARDED_FOR'] ;
|
65 |
$this->_debugTag .= ':' . $_SERVER['REQUEST_TIME'] . '] ' ;
|
66 |
}
|
|
|
|
|
|
|
67 |
}
|
68 |
|
69 |
public function resetCrawlerList( $listId )
|
199 |
) ;
|
200 |
|
201 |
$server_ip = $this->_conf[Litespeed_Litemage_Helper_Data::CFG_WARMUP_SERVER_IP] ;
|
|
|
|
|
|
|
202 |
|
203 |
$client = new Varien_Http_Adapter_Curl() ;
|
204 |
$curCookie = '' ;
|
205 |
$endReason = '' ;
|
206 |
+
$pattern = "/:\/\/([^\/^:]+)(\/|:)?/";
|
207 |
|
208 |
while ( $urls = $this->_getNextUrls($curCookie) ) {
|
209 |
$curlOptions = $options ;
|
221 |
$regular = array();
|
222 |
$ajax = array();
|
223 |
foreach ($urls as $url) {
|
224 |
+
// replace domain with direct IP
|
225 |
+
if (preg_match($pattern, $url, $m)) {
|
226 |
+
$domain = $m[1];
|
227 |
+
$pos = strpos($url, $domain);
|
228 |
+
$url2 = substr($url, 0, $pos) . $server_ip . substr($url, $pos + strlen($domain));
|
229 |
+
$curlOptions[CURLOPT_HTTPHEADER] = array("Host: $domain");
|
230 |
+
}
|
231 |
+
else {
|
232 |
+
if ( $this->_isDebug ) {
|
233 |
+
$this->_debugLog('invalid url ' . $url);
|
234 |
+
}
|
235 |
+
continue;
|
236 |
+
}
|
237 |
+
|
238 |
+
if ($url2{0} == ':')
|
239 |
+
$ajax[] = substr($url2, 1);
|
240 |
else
|
241 |
+
$regular[] = $url2;
|
242 |
}
|
243 |
|
244 |
try {
|
246 |
$client->multiRequest($regular, $curlOptions) ;
|
247 |
}
|
248 |
if (count($ajax)) {
|
249 |
+
$curlOptions[CURLOPT_HTTPHEADER][] = 'X-Requested-With: XMLHttpRequest';
|
250 |
$client->multiRequest($ajax, $curlOptions) ;
|
251 |
}
|
252 |
} catch ( Exception $e ) {
|
268 |
break ;
|
269 |
}
|
270 |
}
|
271 |
+
usleep(500) ;
|
272 |
}
|
273 |
$this->_meta['endreason'] = $endReason ;
|
274 |
|
419 |
array_shift($this->_curDelta['ids']) ;
|
420 |
}
|
421 |
|
422 |
+
$urls = array();
|
423 |
+
$depth = $this->_meta['deltaDepth'][$m['curlist']];
|
424 |
foreach ($this->_curDelta['storeurls'][$m['curlist']] as $level => $ud) {
|
425 |
if (is_int($level) && $level <= $depth) {
|
426 |
+
$u = array();
|
427 |
+
foreach ($ud as $url => $data) {
|
428 |
+
if (($level == 0 && count($u) == 0) // always include first one
|
429 |
+
|| (($data[1] & 28) > 0 ) // auto+cust+store = 16+8+4 = 28, from crawler list
|
430 |
+
|| ($data[0] > 1)) { // or visitor count > 1
|
431 |
+
$u[] = $url;
|
432 |
+
}
|
433 |
+
}
|
434 |
+
$urls = array_merge($urls, $u);
|
435 |
}
|
436 |
}
|
437 |
|
933 |
|
934 |
$this->_priority = $this->_isDelta ? $this->_initDeltaMeta() : $this->_initMeta() ;
|
935 |
if ( empty($this->_priority) ) {
|
936 |
+
return 'no URL list scheduled for warm up' ;
|
937 |
}
|
938 |
|
939 |
$maxTime = (int) ini_get('max_execution_time') ;
|
940 |
if ( $maxTime == 0 )
|
941 |
+
$maxTime = 300 ; // hardlimit
|
942 |
else
|
943 |
$maxTime -= 5 ;
|
944 |
|
945 |
$configed = $this->_conf[Litespeed_Litemage_Helper_Data::CFG_WARMUP_MAXTIME] ;
|
946 |
+
if ( $maxTime >= $configed ) {
|
947 |
$maxTime = $configed ;
|
948 |
+
}
|
949 |
+
else if (ini_set('max_execution_time', $configed + 15 ) !== false) {
|
950 |
+
$maxTime = $configed;
|
951 |
+
}
|
952 |
$this->_maxRunTime = $maxTime + time() ;
|
953 |
|
954 |
$this->_adjustCurThreads() ;
|
1292 |
protected function _debugLog( $message, $level = 0 )
|
1293 |
{
|
1294 |
if ( $this->_isDebug ) {
|
1295 |
+
$message = $this->_debugTag . ' ' . str_replace("\n", ("\n" . $this->_debugTag . ' '), $message) ;
|
1296 |
+
if (($this->_isDebug & 1) == 1) {
|
1297 |
+
Mage::log($message) ;
|
1298 |
+
}
|
1299 |
+
if ($this->_isDelta && (($this->_isDebug & 2) == 2)) {
|
1300 |
+
//($message, $level = null, $file = '', $forceLog = false)
|
1301 |
+
Mage::log($message, null, 'lmdelta.log', true) ;
|
1302 |
+
}
|
1303 |
}
|
1304 |
}
|
1305 |
|
app/code/community/Litespeed/Litemage/Model/Observer/Esi.php
CHANGED
@@ -106,6 +106,14 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
|
|
106 |
$controller = $eventObj->getControllerAction();
|
107 |
$curActionName = $controller->getFullActionName() ;
|
108 |
$reqUrl = $req->getRequestString() ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
$this->_helper->setInternal(array('route_info' => $curActionName,
|
111 |
'is_ajax' => $req->isXmlHttpRequest())); // here do not use isAjax()
|
@@ -412,7 +420,7 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
|
|
412 |
$this->_helper->addCacheEntryTag(Litespeed_Litemage_Helper_Esi::TAG_PREFIX_PRODUCT . $productId) ;
|
413 |
|
414 |
if ( $this->_config->trackLastViewed() ) {
|
415 |
-
$this->_helper->addPrivatePurgeEvent($eventObj->getEvent()->getName())
|
416 |
$this->_helper->trackProduct($productId) ;
|
417 |
}
|
418 |
}
|
106 |
$controller = $eventObj->getControllerAction();
|
107 |
$curActionName = $controller->getFullActionName() ;
|
108 |
$reqUrl = $req->getRequestString() ;
|
109 |
+
$session = Mage::getSingleton('core/session');
|
110 |
+
$lmuser = $session->getData('_litemage_user');
|
111 |
+
if ($lmuser == null) {
|
112 |
+
$session->setData('_litemage_user', 1); // new visitor
|
113 |
+
}
|
114 |
+
else if ($lmuser == 1) {
|
115 |
+
$session->setData('_litemage_user', 2); // existing visitor
|
116 |
+
}
|
117 |
|
118 |
$this->_helper->setInternal(array('route_info' => $curActionName,
|
119 |
'is_ajax' => $req->isXmlHttpRequest())); // here do not use isAjax()
|
420 |
$this->_helper->addCacheEntryTag(Litespeed_Litemage_Helper_Esi::TAG_PREFIX_PRODUCT . $productId) ;
|
421 |
|
422 |
if ( $this->_config->trackLastViewed() ) {
|
423 |
+
$this->_helper->addPrivatePurgeEvent($eventObj->getEvent()->getName()) ;// for T:Mage_Reports_Block_Product_Viewed
|
424 |
$this->_helper->trackProduct($productId) ;
|
425 |
}
|
426 |
}
|
app/code/community/Litespeed/Litemage/Model/Observer/Purge.php
CHANGED
@@ -64,7 +64,7 @@ class Litespeed_Litemage_Model_Observer_Purge extends Varien_Event_Observer
|
|
64 |
if ($ids == '') {
|
65 |
$adminSession->addError($config->__('Missing input value.'));
|
66 |
}
|
67 |
-
elseif (in_array($type, array('P','C','G'))) {
|
68 |
$tags = preg_split("/[\s,]+/", $ids, null, PREG_SPLIT_NO_EMPTY);
|
69 |
if (count($tags) == 0) {
|
70 |
$adminSession->addError($config->__('Missing ID values.'));
|
@@ -101,17 +101,18 @@ class Litespeed_Litemage_Model_Observer_Purge extends Varien_Event_Observer
|
|
101 |
{
|
102 |
$config = Mage::helper('litemage/data') ;
|
103 |
$moduleEnabled = $config->getConf(Litespeed_Litemage_Helper_Data::CFG_ENABLED) ;
|
104 |
-
$serverEnabled =
|
105 |
$adminSession = $this->_getAdminSession() ;
|
106 |
if ( ! $serverEnabled ) {
|
107 |
-
|
108 |
-
|
109 |
if ( $moduleEnabled ) {
|
110 |
if ( $serverEnabled ) {
|
111 |
$adminSession->addNotice($config->__('To make your changes take effect immediately, purge LiteSpeed Cache (System -> Cache Management).')) ;
|
112 |
}
|
113 |
}
|
114 |
else {
|
|
|
115 |
$this->_purgeAllByAdmin($adminSession, $config) ;
|
116 |
}
|
117 |
}
|
@@ -120,13 +121,43 @@ class Litespeed_Litemage_Model_Observer_Purge extends Varien_Event_Observer
|
|
120 |
{
|
121 |
$sectionCode = Mage::app()->getRequest()->getParam('section') ;
|
122 |
if ( $sectionCode == 'litemage' ) {
|
123 |
-
|
124 |
-
if (
|
125 |
-
$config
|
126 |
-
$this->_getAdminSession()->addError($config->__('Your installation of LiteSpeed Web Server does not have LiteMage Cache enabled.')) ;
|
127 |
}
|
128 |
}
|
129 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
protected function _purgeAllByAdmin( $adminSession, $config )
|
132 |
{
|
@@ -181,10 +212,26 @@ class Litespeed_Litemage_Model_Observer_Purge extends Varien_Event_Observer
|
|
181 |
{
|
182 |
try {
|
183 |
if ( Mage::helper('litemage/data')->moduleEnabled() ) {
|
|
|
|
|
|
|
|
|
|
|
184 |
$product = $eventObj->getEvent()->getProduct() ;
|
185 |
-
if (
|
186 |
-
|
187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
}
|
189 |
}
|
190 |
} catch ( Exception $e ) {
|
@@ -313,9 +360,11 @@ class Litespeed_Litemage_Model_Observer_Purge extends Varien_Event_Observer
|
|
313 |
|
314 |
$pcids = array_diff(array_unique($pcids), $cids) ;
|
315 |
foreach ( $pcids as $cid ) {
|
|
|
|
|
316 |
$cat = Mage::getModel('catalog/category')->load($cid) ;
|
317 |
-
$dispmode = $cat->getDisplayMode() ;
|
318 |
-
if ( $dispmode
|
319 |
$tags[] = Litespeed_Litemage_Helper_Esi::TAG_PREFIX_CATEGORY . $cid ;
|
320 |
}
|
321 |
}
|
64 |
if ($ids == '') {
|
65 |
$adminSession->addError($config->__('Missing input value.'));
|
66 |
}
|
67 |
+
elseif (in_array($type, array('P','C','G','S'))) {
|
68 |
$tags = preg_split("/[\s,]+/", $ids, null, PREG_SPLIT_NO_EMPTY);
|
69 |
if (count($tags) == 0) {
|
70 |
$adminSession->addError($config->__('Missing ID values.'));
|
101 |
{
|
102 |
$config = Mage::helper('litemage/data') ;
|
103 |
$moduleEnabled = $config->getConf(Litespeed_Litemage_Helper_Data::CFG_ENABLED) ;
|
104 |
+
$serverEnabled = $config->licenseEnabled();
|
105 |
$adminSession = $this->_getAdminSession() ;
|
106 |
if ( ! $serverEnabled ) {
|
107 |
+
$adminSession()->addError($config->__('Your installation of LiteSpeed Web Server does not have LiteMage Cache enabled. Please make sure your LiteSpeed license includes the LiteMage cache module, and LiteMage is turned on in the .htaccess file in the root directory of your Magento installation.')) ;
|
108 |
+
}
|
109 |
if ( $moduleEnabled ) {
|
110 |
if ( $serverEnabled ) {
|
111 |
$adminSession->addNotice($config->__('To make your changes take effect immediately, purge LiteSpeed Cache (System -> Cache Management).')) ;
|
112 |
}
|
113 |
}
|
114 |
else {
|
115 |
+
// when litemage disabled, purge all.
|
116 |
$this->_purgeAllByAdmin($adminSession, $config) ;
|
117 |
}
|
118 |
}
|
121 |
{
|
122 |
$sectionCode = Mage::app()->getRequest()->getParam('section') ;
|
123 |
if ( $sectionCode == 'litemage' ) {
|
124 |
+
$config = Mage::helper('litemage/data') ;
|
125 |
+
if (!$config->licenseEnabled()) {
|
126 |
+
$this->_getAdminSession()->addError($config->__('Your installation of LiteSpeed Web Server does not have LiteMage Cache enabled. Please make sure your LiteSpeed license includes the LiteMage cache module, and LiteMage is turned on in the .htaccess file in the root directory of your Magento installation.')) ;
|
|
|
127 |
}
|
128 |
}
|
129 |
}
|
130 |
+
|
131 |
+
public function purgeTrigger($eventObj)
|
132 |
+
{
|
133 |
+
// array('action'=>'admin_prod_save', 'option'=>$curOption, 'id'=>$id)
|
134 |
+
$action = $eventObj->getAction();
|
135 |
+
$option = $eventObj->getOption();
|
136 |
+
$id = $eventObj->getId();
|
137 |
+
$tags = array();
|
138 |
+
$reason = 'litemage_purge_trigger - ' . $action . ' opt=' . $option . ' id=' . $id;
|
139 |
+
|
140 |
+
if ($action == 'admin_prod_save') {
|
141 |
+
$message = 'product ' . $id;
|
142 |
+
if ($option != 'c') {
|
143 |
+
$tags[] = Litespeed_Litemage_Helper_Esi::TAG_PREFIX_PRODUCT . $id ;
|
144 |
+
}
|
145 |
+
else {
|
146 |
+
$product = Mage::getModel('catalog/product')->load($id);
|
147 |
+
if ($product) {
|
148 |
+
$tags = $this->_getPurgeProductTags($product, true);
|
149 |
+
$message .= ' and its parent categories';
|
150 |
+
}
|
151 |
+
|
152 |
+
}
|
153 |
+
$this->_getAdminSession()->addSuccess(Mage::helper('litemage/data')->__('Notified LiteSpeed web server to purge ' . $message)) ;
|
154 |
+
}
|
155 |
+
|
156 |
+
Mage::helper('litemage/data')->debugMesg($reason);
|
157 |
+
if (!empty($tags)) {
|
158 |
+
Mage::helper('litemage/esi')->setPurgeHeader($tags, $reason) ;
|
159 |
+
}
|
160 |
+
}
|
161 |
|
162 |
protected function _purgeAllByAdmin( $adminSession, $config )
|
163 |
{
|
212 |
{
|
213 |
try {
|
214 |
if ( Mage::helper('litemage/data')->moduleEnabled() ) {
|
215 |
+
$curOption = Mage::getSingleton('admin/session')->getData(Litespeed_Litemage_Block_Adminhtml_ItemSave::SAVE_PROD_SESSION_KEY);
|
216 |
+
if ($curOption == 'n') { // no purge
|
217 |
+
return;
|
218 |
+
}
|
219 |
+
|
220 |
$product = $eventObj->getEvent()->getProduct() ;
|
221 |
+
if ($product == null)
|
222 |
+
return;
|
223 |
+
|
224 |
+
$tags = array();
|
225 |
+
$mesg = $product->getName();
|
226 |
+
if ($curOption == 'p') {
|
227 |
+
$tags[] = Litespeed_Litemage_Helper_Esi::TAG_PREFIX_PRODUCT . $product->getId() ;
|
228 |
+
}
|
229 |
+
else { // default 'c'
|
230 |
+
$tags = $this->_getPurgeProductTags($product, true);
|
231 |
+
$mesg .= ' and related parent categories';
|
232 |
+
}
|
233 |
+
if (!empty($tags)) {
|
234 |
+
$this->_purgeTagByAdmin($tags, $mesg, 'adminPurgeCatalogProduct - catalog_product_save_commit_after') ;
|
235 |
}
|
236 |
}
|
237 |
} catch ( Exception $e ) {
|
360 |
|
361 |
$pcids = array_diff(array_unique($pcids), $cids) ;
|
362 |
foreach ( $pcids as $cid ) {
|
363 |
+
if ($cid == Mage_Catalog_Model_Category::TREE_ROOT_ID)
|
364 |
+
continue;
|
365 |
$cat = Mage::getModel('catalog/category')->load($cid) ;
|
366 |
+
$dispmode = $cat->getDisplayMode() ; // maybe empty, not saved in db
|
367 |
+
if ( $dispmode != Mage_Catalog_Model_Category::DM_PAGE) // is DM_PRODUCT or DM_MIXED, maybe empty, so use !=
|
368 |
$tags[] = Litespeed_Litemage_Helper_Esi::TAG_PREFIX_CATEGORY . $cid ;
|
369 |
}
|
370 |
}
|
app/code/community/Litespeed/Litemage/controllers/AdminController.php
CHANGED
@@ -36,6 +36,8 @@ class Litespeed_Litemage_AdminController extends Mage_Core_Controller_Front_Acti
|
|
36 |
$this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_START_SESSION, 1) ; // Do not start standart session
|
37 |
$this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_PRE_DISPATCH, true) ;
|
38 |
$this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_POST_DISPATCH, true) ;
|
|
|
|
|
39 |
}
|
40 |
|
41 |
/**
|
@@ -47,7 +49,7 @@ class Litespeed_Litemage_AdminController extends Mage_Core_Controller_Front_Acti
|
|
47 |
public function indexAction()
|
48 |
{
|
49 |
Mage::log('Err: litemage/admin/ come to indexaction') ;
|
50 |
-
|
51 |
}
|
52 |
|
53 |
protected function _errorExit($errorMesg)
|
@@ -76,11 +78,44 @@ class Litespeed_Litemage_AdminController extends Mage_Core_Controller_Front_Acti
|
|
76 |
}
|
77 |
}
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
protected function _accessAllowed()
|
81 |
{
|
82 |
-
$this->_config = Mage::helper('litemage/data') ;
|
83 |
-
$this->_isDebug = $this->_config->isDebug() ;
|
84 |
if ( $this->_config->moduleEnabledForUser() && $this->_config->isAdminIP() ) {
|
85 |
$this->_helper = Mage::helper('litemage/esi') ;
|
86 |
return true ;
|
@@ -98,7 +133,7 @@ class Litespeed_Litemage_AdminController extends Mage_Core_Controller_Front_Acti
|
|
98 |
}
|
99 |
$data = explode(',', $tags);
|
100 |
foreach ($data as $d) {
|
101 |
-
if ( !preg_match("/^[
|
102 |
return 'Invalid Format';
|
103 |
}
|
104 |
}
|
36 |
$this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_START_SESSION, 1) ; // Do not start standart session
|
37 |
$this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_PRE_DISPATCH, true) ;
|
38 |
$this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_POST_DISPATCH, true) ;
|
39 |
+
$this->_config = Mage::helper('litemage/data') ;
|
40 |
+
$this->_isDebug = $this->_config->isDebug() ;
|
41 |
}
|
42 |
|
43 |
/**
|
49 |
public function indexAction()
|
50 |
{
|
51 |
Mage::log('Err: litemage/admin/ come to indexaction') ;
|
52 |
+
//$this->getResponse()->setRedirect(Mage::getBaseUrl()) ;
|
53 |
}
|
54 |
|
55 |
protected function _errorExit($errorMesg)
|
78 |
}
|
79 |
}
|
80 |
|
81 |
+
public function shellAction()
|
82 |
+
{
|
83 |
+
if (Mage::helper('core/http')->getHttpUserAgent() !== 'litemage_walker'
|
84 |
+
|| ! $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_ENABLED)) {
|
85 |
+
$this->_errorExit('Access denied');
|
86 |
+
}
|
87 |
+
|
88 |
+
$tags = array();
|
89 |
+
$req = $this->getRequest();
|
90 |
+
if ($req->getParam('all')) {
|
91 |
+
$tags[] = '*';
|
92 |
+
}
|
93 |
+
else {
|
94 |
+
if ($t = $req->getParam('tags')) {
|
95 |
+
$tags = explode(',', $t);
|
96 |
+
}
|
97 |
+
$types = array('P.' => 'products', 'C.' => 'cats', 'S.' => 'stores');
|
98 |
+
foreach ($types as $prefix => $type) {
|
99 |
+
if ($ids = $req->getParam($type)) {
|
100 |
+
$tids = explode(',', $ids);
|
101 |
+
foreach ($tids as $id) {
|
102 |
+
$tags[] = $prefix . $id;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
106 |
+
$tags = array_unique($tags);
|
107 |
+
}
|
108 |
+
if (empty($tags)) {
|
109 |
+
$this->_errorExit('Invalid url');
|
110 |
+
}
|
111 |
+
else {
|
112 |
+
Mage::helper('litemage/esi')->setPurgeHeader($tags, 'litemage/shell/purge');
|
113 |
+
$this->getResponse()->setBody('purged tags ' . implode(',', $tags));
|
114 |
+
}
|
115 |
+
}
|
116 |
|
117 |
protected function _accessAllowed()
|
118 |
{
|
|
|
|
|
119 |
if ( $this->_config->moduleEnabledForUser() && $this->_config->isAdminIP() ) {
|
120 |
$this->_helper = Mage::helper('litemage/esi') ;
|
121 |
return true ;
|
133 |
}
|
134 |
$data = explode(',', $tags);
|
135 |
foreach ($data as $d) {
|
136 |
+
if ( !preg_match("/^[GCPS]\.\d+$/", $d)) {
|
137 |
return 'Invalid Format';
|
138 |
}
|
139 |
}
|
app/code/community/Litespeed/Litemage/controllers/Adminhtml/LitemageCacheController.php
CHANGED
@@ -58,6 +58,29 @@ class Litespeed_Litemage_Adminhtml_LitemageCacheController extends Mage_Adminhtm
|
|
58 |
$output = Mage::getModel( 'litemage/observer_cron' )->getCrawlerList($req->getParam('list'));
|
59 |
$this->getResponse()->setBody($output);
|
60 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
protected function _isAllowed()
|
63 |
{
|
58 |
$output = Mage::getModel( 'litemage/observer_cron' )->getCrawlerList($req->getParam('list'));
|
59 |
$this->getResponse()->setBody($output);
|
60 |
}
|
61 |
+
|
62 |
+
public function productSaveOptionAction()
|
63 |
+
{
|
64 |
+
$req = $this->getRequest();
|
65 |
+
$session = Mage::getSingleton('admin/session');
|
66 |
+
$id = $req->getParam('id');
|
67 |
+
|
68 |
+
if ($req->getParam('litemage_purgeprod')) {
|
69 |
+
Mage::dispatchEvent('litemage_purge_trigger',
|
70 |
+
array('action'=>'admin_prod_save', 'option'=>'p', 'id'=>$id));
|
71 |
+
}
|
72 |
+
elseif ($req->getParam('litemage_purgepcats')) {
|
73 |
+
Mage::dispatchEvent('litemage_purge_trigger',
|
74 |
+
array('action'=>'admin_prod_save', 'option'=>'c', 'id'=>$id));
|
75 |
+
}
|
76 |
+
elseif ($req->getParam('prodpurgeoption')) {
|
77 |
+
$option = $req->getParam('prodpurgeoption');
|
78 |
+
if (in_array($option, array('c','p','n'))) {
|
79 |
+
$session->setData(Litespeed_Litemage_Block_Adminhtml_ItemSave::SAVE_PROD_SESSION_KEY, $option);
|
80 |
+
}
|
81 |
+
}
|
82 |
+
$this->_redirect('*/catalog_product/edit', array('id'=>$id));
|
83 |
+
}
|
84 |
|
85 |
protected function _isAllowed()
|
86 |
{
|
app/code/community/Litespeed/Litemage/controllers/EsiController.php
CHANGED
@@ -183,11 +183,12 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
|
|
183 |
{
|
184 |
$blockIndex = $esiData->getLayoutAttribute('bi') ;
|
185 |
$block = $this->_layout->getEsiBlock($blockIndex) ;
|
|
|
186 |
if ( ! $block ) {
|
187 |
if ( $this->_isDebug ) {
|
188 |
$this->_config->debugMesg('cannot get esi block ' . $blockIndex) ;
|
189 |
}
|
190 |
-
return
|
191 |
}
|
192 |
try {
|
193 |
$out = $block->toHtml() ;
|
@@ -209,8 +210,14 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
|
|
209 |
$origEsiUrl = $_SERVER['REQUEST_URI'] ;
|
210 |
$req = $this->getRequest() ;
|
211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
//set original host url
|
213 |
-
if ( $refererUrl
|
214 |
$_SERVER['REQUEST_URI'] = $refererUrl ;
|
215 |
$req->setRequestUri($refererUrl) ;
|
216 |
$req->setPathInfo() ;
|
@@ -244,10 +251,7 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
|
|
244 |
|
245 |
protected function _processIncoming( $esiUrls )
|
246 |
{
|
247 |
-
if (
|
248 |
-
|
249 |
-
$this->_env['shared'] = true ;
|
250 |
-
|
251 |
$list = array() ;
|
252 |
foreach ( $esiUrls as $url ) {
|
253 |
if ( $html = $this->_getShared($url) ) {
|
@@ -493,6 +497,25 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
|
|
493 |
|
494 |
protected function _initEnv( $esiData )
|
495 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
496 |
$action = $esiData->getAction() ;
|
497 |
if ( $action == Litespeed_Litemage_Model_EsiData::ACTION_GET_FORMKEY ) {
|
498 |
return ;
|
183 |
{
|
184 |
$blockIndex = $esiData->getLayoutAttribute('bi') ;
|
185 |
$block = $this->_layout->getEsiBlock($blockIndex) ;
|
186 |
+
$out = '';
|
187 |
if ( ! $block ) {
|
188 |
if ( $this->_isDebug ) {
|
189 |
$this->_config->debugMesg('cannot get esi block ' . $blockIndex) ;
|
190 |
}
|
191 |
+
return $out ;
|
192 |
}
|
193 |
try {
|
194 |
$out = $block->toHtml() ;
|
210 |
$origEsiUrl = $_SERVER['REQUEST_URI'] ;
|
211 |
$req = $this->getRequest() ;
|
212 |
|
213 |
+
// for lsws
|
214 |
+
$refererUrl = $req->getServer('ESI_REFERER');
|
215 |
+
if (!$refererUrl) {
|
216 |
+
//lslb
|
217 |
+
$refererUrl = $req->getServer('HTTP_ESI_REFERER');
|
218 |
+
}
|
219 |
//set original host url
|
220 |
+
if ( $refererUrl ) {
|
221 |
$_SERVER['REQUEST_URI'] = $refererUrl ;
|
222 |
$req->setRequestUri($refererUrl) ;
|
223 |
$req->setPathInfo() ;
|
251 |
|
252 |
protected function _processIncoming( $esiUrls )
|
253 |
{
|
254 |
+
if ($this->_env['shared']) {
|
|
|
|
|
|
|
255 |
$list = array() ;
|
256 |
foreach ( $esiUrls as $url ) {
|
257 |
if ( $html = $this->_getShared($url) ) {
|
497 |
|
498 |
protected function _initEnv( $esiData )
|
499 |
{
|
500 |
+
$session = Mage::getSingleton('core/session');
|
501 |
+
if (($session->getData('_litemage_user') == 1) && (Mage::registry('current_customer') == null)) {
|
502 |
+
if (Mage::registry('LITEMAGE_NEWVISITOR')) {
|
503 |
+
$this->_env['shared'] = true ;
|
504 |
+
}
|
505 |
+
else {
|
506 |
+
$loghelper = Mage::helper('log');
|
507 |
+
if ( method_exists($loghelper, 'isLogDisabled') ) { // new for 1.9
|
508 |
+
if (Mage::helper('log')->isLogDisabled()) {
|
509 |
+
$this->_env['shared'] = true ;
|
510 |
+
}
|
511 |
+
}
|
512 |
+
else { // prior to 1.9
|
513 |
+
$this->_env['shared'] = true ;
|
514 |
+
}
|
515 |
+
}
|
516 |
+
}
|
517 |
+
$session->setData('_litemage_user', 3);
|
518 |
+
|
519 |
$action = $esiData->getAction() ;
|
520 |
if ( $action == Litespeed_Litemage_Model_EsiData::ACTION_GET_FORMKEY ) {
|
521 |
return ;
|
app/code/community/Litespeed/Litemage/etc/config.xml
CHANGED
@@ -26,10 +26,14 @@
|
|
26 |
<config>
|
27 |
<modules>
|
28 |
<Litespeed_Litemage>
|
29 |
-
<version>1.2.
|
30 |
</Litespeed_Litemage>
|
31 |
</modules>
|
32 |
<global>
|
|
|
|
|
|
|
|
|
33 |
<blocks>
|
34 |
<litemage>
|
35 |
<class>Litespeed_Litemage_Block</class>
|
@@ -52,7 +56,6 @@
|
|
52 |
</core>
|
53 |
</models>
|
54 |
<events>
|
55 |
-
<!-- purge product cache after stock update -->
|
56 |
<cataloginventory_stock_item_save_after>
|
57 |
<observers>
|
58 |
<litemage_purge>
|
@@ -61,6 +64,15 @@
|
|
61 |
</litemage_purge>
|
62 |
</observers>
|
63 |
</cataloginventory_stock_item_save_after>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
</events>
|
65 |
</global>
|
66 |
<admin>
|
@@ -456,10 +468,11 @@
|
|
456 |
<diff_customergroup>0</diff_customergroup>
|
457 |
<flush_prodcat>0</flush_prodcat>
|
458 |
<alt_esi_syntax>0</alt_esi_syntax>
|
|
|
459 |
</general>
|
460 |
<warmup>
|
461 |
<enable_warmup>0</enable_warmup>
|
462 |
-
<server_ip
|
463 |
<load_limit>5</load_limit>
|
464 |
<thread_limit>6</thread_limit>
|
465 |
<max_time>360</max_time>
|
@@ -479,7 +492,7 @@
|
|
479 |
</warmup>
|
480 |
<default>
|
481 |
<!-- Full or partial match on controller full action name for cacheable routes. Space, return, and comma separated -->
|
482 |
-
<cache_routes><![CDATA[catalog cms
|
483 |
<!-- Full or partial match on controller full action name for non-cacheable routes within cacheable routes. Space, return, and comma separated -->
|
484 |
<nocache_subroutes><![CDATA[catalog_product_compare catalogsearch]]></nocache_subroutes>
|
485 |
</default>
|
@@ -496,9 +509,15 @@
|
|
496 |
<toplinkstag/>
|
497 |
<messages/>
|
498 |
</donotcache>
|
|
|
|
|
|
|
|
|
|
|
499 |
<test>
|
500 |
-
<debug>0</debug>
|
501 |
<allow_ips/>
|
|
|
|
|
502 |
</test>
|
503 |
</litemage>
|
504 |
</default>
|
26 |
<config>
|
27 |
<modules>
|
28 |
<Litespeed_Litemage>
|
29 |
+
<version>1.2.1</version>
|
30 |
</Litespeed_Litemage>
|
31 |
</modules>
|
32 |
<global>
|
33 |
+
<ignore_user_agents>
|
34 |
+
<litemage1>litemage_walker</litemage1>
|
35 |
+
<litemage2>litemage_runner</litemage2>
|
36 |
+
</ignore_user_agents>
|
37 |
<blocks>
|
38 |
<litemage>
|
39 |
<class>Litespeed_Litemage_Block</class>
|
56 |
</core>
|
57 |
</models>
|
58 |
<events>
|
|
|
59 |
<cataloginventory_stock_item_save_after>
|
60 |
<observers>
|
61 |
<litemage_purge>
|
64 |
</litemage_purge>
|
65 |
</observers>
|
66 |
</cataloginventory_stock_item_save_after>
|
67 |
+
<!-- litemage own events -->
|
68 |
+
<litemage_purge_trigger>
|
69 |
+
<observers>
|
70 |
+
<litemage_purge>
|
71 |
+
<class>litemage/observer_purge</class>
|
72 |
+
<method>purgeTrigger</method>
|
73 |
+
</litemage_purge>
|
74 |
+
</observers>
|
75 |
+
</litemage_purge_trigger>
|
76 |
</events>
|
77 |
</global>
|
78 |
<admin>
|
468 |
<diff_customergroup>0</diff_customergroup>
|
469 |
<flush_prodcat>0</flush_prodcat>
|
470 |
<alt_esi_syntax>0</alt_esi_syntax>
|
471 |
+
<cache_tag_prefix>M</cache_tag_prefix>
|
472 |
</general>
|
473 |
<warmup>
|
474 |
<enable_warmup>0</enable_warmup>
|
475 |
+
<server_ip>127.0.0.1</server_ip>
|
476 |
<load_limit>5</load_limit>
|
477 |
<thread_limit>6</thread_limit>
|
478 |
<max_time>360</max_time>
|
492 |
</warmup>
|
493 |
<default>
|
494 |
<!-- Full or partial match on controller full action name for cacheable routes. Space, return, and comma separated -->
|
495 |
+
<cache_routes><![CDATA[catalog cms]]></cache_routes>
|
496 |
<!-- Full or partial match on controller full action name for non-cacheable routes within cacheable routes. Space, return, and comma separated -->
|
497 |
<nocache_subroutes><![CDATA[catalog_product_compare catalogsearch]]></nocache_subroutes>
|
498 |
</default>
|
509 |
<toplinkstag/>
|
510 |
<messages/>
|
511 |
</donotcache>
|
512 |
+
<fishpigwp>
|
513 |
+
<fpwp_cache>0</fpwp_cache>
|
514 |
+
<fpwp_ttl>28800</fpwp_ttl>
|
515 |
+
<fpwp_prefix/>
|
516 |
+
</fishpigwp>
|
517 |
<test>
|
|
|
518 |
<allow_ips/>
|
519 |
+
<debug>0</debug>
|
520 |
+
<delta_log>0</delta_log>
|
521 |
</test>
|
522 |
</litemage>
|
523 |
</default>
|
app/code/community/Litespeed/Litemage/etc/system.xml
CHANGED
@@ -27,7 +27,7 @@
|
|
27 |
<config>
|
28 |
<tabs>
|
29 |
<Litespeed_Litemage translate="label">
|
30 |
-
<label>LiteMage Cache 1.2.
|
31 |
<sort_order>5000</sort_order>
|
32 |
</Litespeed_Litemage>
|
33 |
</tabs>
|
@@ -279,7 +279,7 @@
|
|
279 |
<fields>
|
280 |
<enable_warmup translate="label,comment">
|
281 |
<label>Enable Cache Warm Up</label>
|
282 |
-
<comment>Allow LiteMage to automatically warm
|
283 |
<frontend_type>multiselect</frontend_type>
|
284 |
<source_model>litemage/config_source_enableWarmUp</source_model>
|
285 |
<sort_order>10</sort_order>
|
@@ -488,12 +488,51 @@ Each file listed should contain a list of custom-defined URLs (one per line). Th
|
|
488 |
</fields>
|
489 |
</warmup>
|
490 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
491 |
<test translate="label" module="litemage">
|
492 |
<label>Developer Testing</label>
|
493 |
<show_in_default>1</show_in_default>
|
494 |
<show_in_website>0</show_in_website>
|
495 |
<show_in_store>0</show_in_store>
|
496 |
-
<sort_order>
|
497 |
<fields>
|
498 |
<allow_ips translate="label,comment">
|
499 |
<label>Enable LiteMage Cache Only for Listed IPs</label>
|
@@ -506,7 +545,7 @@ Each file listed should contain a list of custom-defined URLs (one per line). Th
|
|
506 |
</allow_ips>
|
507 |
<debug translate="label,comment">
|
508 |
<label>Enable Debug Log</label>
|
509 |
-
<comment>Prints additional information to
|
510 |
<![CDATA[<span class="notice">Turn off for production use.</span>]]></comment>
|
511 |
<frontend_type>select</frontend_type>
|
512 |
<source_model>litemage/config_source_enableDebugLog</source_model>
|
@@ -515,6 +554,17 @@ Each file listed should contain a list of custom-defined URLs (one per line). Th
|
|
515 |
<show_in_website>0</show_in_website>
|
516 |
<show_in_store>0</show_in_store>
|
517 |
</debug>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
</fields>
|
519 |
</test>
|
520 |
|
27 |
<config>
|
28 |
<tabs>
|
29 |
<Litespeed_Litemage translate="label">
|
30 |
+
<label>LiteMage Cache 1.2.1</label>
|
31 |
<sort_order>5000</sort_order>
|
32 |
</Litespeed_Litemage>
|
33 |
</tabs>
|
279 |
<fields>
|
280 |
<enable_warmup translate="label,comment">
|
281 |
<label>Enable Cache Warm Up</label>
|
282 |
+
<comment>Allow LiteMage to automatically warm the cache. Select all that apply. It is always recommended that you enable the Store site map, Auto collected (deep crawling) URL list, and Delta list after tag purge options. Magento cron job must be enabled to use this setting.</comment>
|
283 |
<frontend_type>multiselect</frontend_type>
|
284 |
<source_model>litemage/config_source_enableWarmUp</source_model>
|
285 |
<sort_order>10</sort_order>
|
488 |
</fields>
|
489 |
</warmup>
|
490 |
|
491 |
+
<fishpigwp translate="label" module="litemage">
|
492 |
+
<label>FishPig WordPress Integration</label>
|
493 |
+
<show_in_default>1</show_in_default>
|
494 |
+
<show_in_website>1</show_in_website>
|
495 |
+
<show_in_store>1</show_in_store>
|
496 |
+
<sort_order>50</sort_order>
|
497 |
+
<fields>
|
498 |
+
<fpwp_cache translate="label,comment">
|
499 |
+
<label>Enable Cache for FishPig WP Integration</label>
|
500 |
+
<comment>Enable LiteMage Cache for FishPig WP integration. WP pages will be served from Magento and purged by WP backend edits. The LiteSpeed Cache plugin for WP needs to be installed from the WP backend and "Auto Purge All pages on Update" box needs to be checked in the LiteSpeed Cache > Settings > Purge Rules page in the LiteSpeed Cache for WordPress plugin backend.</comment>
|
501 |
+
<frontend_type>select</frontend_type>
|
502 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
503 |
+
<sort_order>10</sort_order>
|
504 |
+
<show_in_default>1</show_in_default>
|
505 |
+
<show_in_website>1</show_in_website>
|
506 |
+
<show_in_store>1</show_in_store>
|
507 |
+
</fpwp_cache>
|
508 |
+
<fpwp_ttl translate="label,comment">
|
509 |
+
<label>WP Pages Public Cache TTL (seconds)</label>
|
510 |
+
<comment>Timeout for publicly cached WordPress pages. Recommended value is 28800. This value will override the Public Cache TTL setting in the LiteSpeed Cache for WordPress plugin.</comment>
|
511 |
+
<frontend_type>text</frontend_type>
|
512 |
+
<validate>validate-digits validate-digits-range digits-range-600-</validate>
|
513 |
+
<sort_order>20</sort_order>
|
514 |
+
<show_in_default>1</show_in_default>
|
515 |
+
<show_in_website>1</show_in_website>
|
516 |
+
<show_in_store>1</show_in_store>
|
517 |
+
</fpwp_ttl>
|
518 |
+
<fpwp_prefix translate="label,comment">
|
519 |
+
<label>Cache Tag Prefix for WP LiteSpeed Cache Plugin</label>
|
520 |
+
<comment>If you set the cache tag prefix in the LiteSpeed cache plugin for WP, please copy the same value into this setting in order for cache purging to work properly.</comment>
|
521 |
+
<frontend_type>text</frontend_type>
|
522 |
+
<sort_order>20</sort_order>
|
523 |
+
<show_in_default>1</show_in_default>
|
524 |
+
<show_in_website>0</show_in_website>
|
525 |
+
<show_in_store>0</show_in_store>
|
526 |
+
</fpwp_prefix>
|
527 |
+
</fields>
|
528 |
+
</fishpigwp>
|
529 |
+
|
530 |
<test translate="label" module="litemage">
|
531 |
<label>Developer Testing</label>
|
532 |
<show_in_default>1</show_in_default>
|
533 |
<show_in_website>0</show_in_website>
|
534 |
<show_in_store>0</show_in_store>
|
535 |
+
<sort_order>60</sort_order>
|
536 |
<fields>
|
537 |
<allow_ips translate="label,comment">
|
538 |
<label>Enable LiteMage Cache Only for Listed IPs</label>
|
545 |
</allow_ips>
|
546 |
<debug translate="label,comment">
|
547 |
<label>Enable Debug Log</label>
|
548 |
+
<comment>Prints additional information to var/log/system.log for debugging purposes. (Ensure developer log is enabled.)
|
549 |
<![CDATA[<span class="notice">Turn off for production use.</span>]]></comment>
|
550 |
<frontend_type>select</frontend_type>
|
551 |
<source_model>litemage/config_source_enableDebugLog</source_model>
|
554 |
<show_in_website>0</show_in_website>
|
555 |
<show_in_store>0</show_in_store>
|
556 |
</debug>
|
557 |
+
<delta_log translate="label,comment">
|
558 |
+
<label>Enable Log for Delta crawler</label>
|
559 |
+
<comment>Prints delta crawler activities to var/log/lmdelta.log.</comment>
|
560 |
+
<frontend_type>select</frontend_type>
|
561 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
562 |
+
<sort_order>30</sort_order>
|
563 |
+
<show_in_default>1</show_in_default>
|
564 |
+
<show_in_website>0</show_in_website>
|
565 |
+
<show_in_store>0</show_in_store>
|
566 |
+
</delta_log>
|
567 |
+
|
568 |
</fields>
|
569 |
</test>
|
570 |
|
app/design/adminhtml/default/default/layout/litemage.xml
CHANGED
@@ -30,4 +30,16 @@
|
|
30 |
<block type="litemage/adminhtml_cache_management" name="litemage.cache.management" template="litemage/cache_management.phtml" after="cache.additional" />
|
31 |
</reference>
|
32 |
</adminhtml_cache_index>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
</layout>
|
30 |
<block type="litemage/adminhtml_cache_management" name="litemage.cache.management" template="litemage/cache_management.phtml" after="cache.additional" />
|
31 |
</reference>
|
32 |
</adminhtml_cache_index>
|
33 |
+
<adminhtml_catalog_product_edit>
|
34 |
+
<reference name="content">
|
35 |
+
<block type="litemage/adminhtml_itemSave" name="litemage_prodsave" template="litemage/product_save.phtml" before="-"></block>
|
36 |
+
</reference>
|
37 |
+
</adminhtml_catalog_product_edit>
|
38 |
+
<adminhtml_catalog_category_edit>
|
39 |
+
<reference name="content">
|
40 |
+
<block type="litemage/adminhtml_itemSave" name="litemage_catsave" template="litemage/category_save.phtml" before="-"></block>
|
41 |
+
</reference>
|
42 |
+
</adminhtml_catalog_category_edit>
|
43 |
+
|
44 |
+
|
45 |
</layout>
|
app/design/adminhtml/default/default/template/litemage/cache_management.phtml
CHANGED
@@ -101,14 +101,15 @@ if ($stats = $this->getCacheStatistics()) {
|
|
101 |
<select name="tag_types" class="required-entry select local-validation">
|
102 |
<option value="P"><?php echo $lmhelper->__('Product IDs')?></option>
|
103 |
<option value="C"><?php echo $lmhelper->__('Category IDs')?></option>
|
104 |
-
<option value="G"><?php echo $lmhelper->__('CMS IDs')?></option>
|
|
|
105 |
</select>
|
106 |
</td>
|
107 |
<td class="scope-label">
|
108 |
<input type="text" name="purge_tag" class="input-text required-entry" style="width:150px"/>
|
109 |
</td>
|
110 |
<td class="scope-label">
|
111 |
-
<?php echo $lmhelper->__('Specify one or more IDs separated by spaces. (Under normal operation, related pages will automatically be purged when saving changes to an item through the Admin Panel.)')?>
|
112 |
</td>
|
113 |
</tr>
|
114 |
</table>
|
101 |
<select name="tag_types" class="required-entry select local-validation">
|
102 |
<option value="P"><?php echo $lmhelper->__('Product IDs')?></option>
|
103 |
<option value="C"><?php echo $lmhelper->__('Category IDs')?></option>
|
104 |
+
<option value="G"><?php echo $lmhelper->__('CMS Page IDs')?></option>
|
105 |
+
<option value="S"><?php echo $lmhelper->__('Store IDs')?></option>
|
106 |
</select>
|
107 |
</td>
|
108 |
<td class="scope-label">
|
109 |
<input type="text" name="purge_tag" class="input-text required-entry" style="width:150px"/>
|
110 |
</td>
|
111 |
<td class="scope-label">
|
112 |
+
<?php echo $lmhelper->__('Specify one or more IDs (integer numbers) separated by spaces. (Under normal operation, related pages will automatically be purged when saving changes to an item through the Admin Panel.)')?>
|
113 |
</td>
|
114 |
</tr>
|
115 |
</table>
|
app/design/adminhtml/default/default/template/litemage/category_save.phtml
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
+
*/
|
24 |
+
|
25 |
+
if ($this->canShowButton()):
|
26 |
+
//$lmhelper = Mage::helper('litemage/data');
|
27 |
+
?>
|
28 |
+
<br/>
|
29 |
+
|
30 |
+
<div><ul class="messages">
|
31 |
+
<li class="notice-msg">
|
32 |
+
LiteMage Cache: Clicking the Save Button Will Automatically Purge Cache For This Category.
|
33 |
+
</li>
|
34 |
+
</ul></div>
|
35 |
+
|
36 |
+
<?php
|
37 |
+
endif;
|
38 |
+
?>
|
app/design/adminhtml/default/default/template/litemage/product_save.phtml
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
+
*/
|
24 |
+
|
25 |
+
if ($this->canShowButton()):
|
26 |
+
if ($url = $this->getProductSaveOptionUrl()) :
|
27 |
+
//$lmhelper = Mage::helper('litemage/data');
|
28 |
+
?>
|
29 |
+
<br/>
|
30 |
+
|
31 |
+
<div class="entry-edit"><ul class="messages">
|
32 |
+
<li class="notice-msg">
|
33 |
+
<form action="<?php echo $this->getProductSaveOptionUrl()?>" method="post" id="litemage_prodsave">
|
34 |
+
<?php echo $this->getBlockHtml('formkey')?>
|
35 |
+
LiteMage Cache: Clicking the Save Button Will Automatically Purge Cache
|
36 |
+
<select name="prodpurgeoption" onchange="submit()">
|
37 |
+
<?php echo $this->getCurrentProdSaveOptions(); ?>
|
38 |
+
</select>
|
39 |
+
<div class="form-buttons">
|
40 |
+
<input type="submit" class="form-button" name="litemage_purgeprod" value="Purge This Product" id="litemage_purgeprod" />
|
41 |
+
<input type="submit" class="form-button" name="litemage_purgepcats" value="Purge This Product and Parent Categories" id="litemage_purgepcats" />
|
42 |
+
</div>
|
43 |
+
</form>
|
44 |
+
</li>
|
45 |
+
</ul></div>
|
46 |
+
|
47 |
+
<?php
|
48 |
+
endif;
|
49 |
+
endif;
|
50 |
+
?>
|
package.xml
CHANGED
@@ -1,24 +1,26 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>LiteSpeed_LiteMage</name>
|
4 |
-
<version>1.2.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="https://opensource.org/licenses/GPL-3.0 ">GPL v3</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>LiteMage Cache speeds up Magento by automatically integrating Magento with LiteSpeed's superior ESI implementation.</summary>
|
10 |
<description>LiteMage Cache is a powerful Magento page caching utility built into LiteSpeed Web Server. It combines superior ESI implementation with easy set up. LiteMage Cache contains a number of optimizations, including combined subrequests, that give it faster, more efficient performance than other page caching utilities. In addition, because it is part of the web server, LiteMage Cache does away with the communication problems and overhead other page caching solutions suffer from. The LiteMage Magento extension then automatically integrates Magento installations with LiteSpeed's top-of-the-line ESI implementation, combining the greatest Magento performance enhancement possible with a painless set up.</description>
|
11 |
-
<notes>
|
12 |
-
Added
|
13 |
-
Added
|
14 |
-
Added
|
15 |
-
|
16 |
-
Improved
|
|
|
|
|
17 |
</notes>
|
18 |
<authors><author><name>LiteSpeed Technologies</name><user>LiteSpeedTech</user><email>lsong@litespeedtech.com</email></author></authors>
|
19 |
-
<date>2016-
|
20 |
-
<time>
|
21 |
-
<contents><target name="magecommunity"><dir name="Litespeed"><dir name="Litemage"><dir name="Block"><dir name="Adminhtml"><dir name="Cache"><file name="Management.php" hash="126c636bebf6a1933f45781d6e95863d"/></dir
|
22 |
<compatible/>
|
23 |
<dependencies><required><php><min>5.3.0</min><max>7.1.0</max></php></required></dependencies>
|
24 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>LiteSpeed_LiteMage</name>
|
4 |
+
<version>1.2.1</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="https://opensource.org/licenses/GPL-3.0 ">GPL v3</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>LiteMage Cache speeds up Magento by automatically integrating Magento with LiteSpeed's superior ESI implementation.</summary>
|
10 |
<description>LiteMage Cache is a powerful Magento page caching utility built into LiteSpeed Web Server. It combines superior ESI implementation with easy set up. LiteMage Cache contains a number of optimizations, including combined subrequests, that give it faster, more efficient performance than other page caching utilities. In addition, because it is part of the web server, LiteMage Cache does away with the communication problems and overhead other page caching solutions suffer from. The LiteMage Magento extension then automatically integrates Magento installations with LiteSpeed's top-of-the-line ESI implementation, combining the greatest Magento performance enhancement possible with a painless set up.</description>
|
11 |
+
<notes>Added cache support for FishPig WordPress Integration. WordPress pages will be auto purged by the LiteSpeed Cache for WordPress plugin.
|
12 |
+
Added support for LiteSpeed Load Balancer (LSLB). LiteMage cache will be located on your LSLB, no need to change your local web server setup.
|
13 |
+
Added support to purge by store ID.
|
14 |
+
Added a command line tool to purge LiteMage cache. This tool is located under the shell subdirectory under the Magento root directory.
|
15 |
+
Improved crawler and added delta crawler logging.
|
16 |
+
Improved new visitor detection when visitor log is disabled.
|
17 |
+
Allow users to specify what saving a product form the admin panel automatically purges.
|
18 |
+
Fixed a bug caused by specifying a different theme for different categories.
|
19 |
</notes>
|
20 |
<authors><author><name>LiteSpeed Technologies</name><user>LiteSpeedTech</user><email>lsong@litespeedtech.com</email></author></authors>
|
21 |
+
<date>2016-09-13</date>
|
22 |
+
<time>16:28:57</time>
|
23 |
+
<contents><target name="magecommunity"><dir name="Litespeed"><dir name="Litemage"><dir name="Block"><dir name="Adminhtml"><dir name="Cache"><file name="Management.php" hash="126c636bebf6a1933f45781d6e95863d"/></dir><file name="ItemSave.php" hash="70a8adbbc723c4134957f549333122c9"/></dir><dir name="Core"><file name="Dummy.php" hash="ae50751905056dd3eb34c3222d17a310"/><file name="Esi.php" hash="32da90253e38aedf67a8c4619bfc983b"/><file name="Messages.php" hash="da581eb4adaa1ac4e2d4b86ff30f08d4"/><file name="Xml.php" hash="6c7d088368f06151be14609dde9afade"/></dir><dir name="Inject"><file name="Jsvar.php" hash="cc0590fe211c81d6d29de570503fe8fd"/><file name="Nickname.php" hash="deba1efffd6449b6492bb13aaca4658b"/></dir></dir><dir name="Helper"><file name="Data.php" hash="ba9b5664ec8304419025a44c6d4ded2a"/><file name="Esi.php" hash="775ffb0d2c0e9de0e8eff9f0ff13dfb3"/><file name="Viewvary.php" hash="04f39f2d726a3c92f83ff53abdf4cffe"/></dir><dir name="Model"><dir name="Config"><dir name="Backend"><file name="WarmUp.php" hash="663ecf7689115059eb94898f37adeb6f"/></dir><dir name="Source"><file name="CustomerGroup.php" hash="2aa52d9a1614a545035267958be0656f"/><file name="EnableDebugLog.php" hash="27d4b6030f564dfae8c89a84264b1175"/><file name="EnableWarmUp.php" hash="f44aafa2f6ba65a0e4926b7635ff264d"/><file name="FlushCategory.php" hash="b8017a1859b320f05af272f4d4e442e2"/></dir></dir><file name="EsiData.php" hash="98b1ce4bf07d2b795e1efeb5f5b030a9"/><file name="EsiLayout.php" hash="26bef4ee2a873ecb26ba7f292cfe0fd6"/><dir name="Layout"><file name="EsiUpdate.php" hash="3c98a2961b08f0acb3d334ab932eb397"/><file name="Master.php" hash="5eb57ba3677b76468ccf6f74741dcc63"/><file name="Update.php" hash="a72d4beb502803532af5d1ac2a06a06e"/></dir><dir name="Observer"><file name="Cron.php" hash="0e9b3a9966e42dc4702b94f8b047a6e9"/><file name="Esi.php" hash="c8f15321aa9cdb1f62603482f69dae79"/><file name="Purge.php" hash="1443771fa96b59cf7934d0c79ea8e38e"/></dir><file name="Session.php" hash="558a80fb45a532af59727ae5657cd380"/><file name="Translate.php" hash="35326b8d2214f516d7dba82519902529"/></dir><dir name="controllers"><file name="AdminController.php" hash="549098ba10e19b066a6d52eab0f7bbb6"/><dir name="Adminhtml"><file name="LitemageCacheController.php" hash="86bf427c2b53788cdb5f5fae964eb4ff"/></dir><file name="EsiController.php" hash="80bee25260f28cd3e14f3cdf252b9308"/></dir><dir name="etc"><file name="config.xml" hash="fbcc065174d7e42e6861f1d1a7749d84"/><file name="system.xml" hash="47e200b3635b11c607daa87660c4bafe"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="litemage.xml" hash="f4dd1848120e353da9a84a7fd5565093"/></dir><dir name="template"><dir name="litemage"><file name="cache_management.phtml" hash="64c252b79223fe85a071fa9806939575"/><file name="category_save.phtml" hash="fa4b3e5d70cdba64fca41fbe7446052b"/><file name="product_save.phtml" hash="17e2b188a7008a1c2964cf12b596cd3a"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="litemage.xml" hash="4c840b12cc6246f68b1b028f0ef1056d"/></dir><dir name="template"><dir name="litemage"><dir name="inject"><file name="jsvar.phtml" hash="5bbd9992e7ba5925d09f21cf03237676"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Litespeed_Litemage.xml" hash="ba0c8904bc89219c6829e37cc14d9bdd"/></dir></target><target name="mage"><dir name="shell"><file name="litemage_purge.php" hash="144e7aeba7895515cf28cd0e2a6a9903"/></dir></target></contents>
|
24 |
<compatible/>
|
25 |
<dependencies><required><php><min>5.3.0</min><max>7.1.0</max></php></required></dependencies>
|
26 |
</package>
|
shell/litemage_purge.php
ADDED
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* LiteMage
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This program is free software: you can redistribute it and/or modify
|
9 |
+
* it under the terms of the GNU General Public License as published by
|
10 |
+
* the Free Software Foundation, either version 3 of the License, or
|
11 |
+
* (at your option) any later version.
|
12 |
+
*
|
13 |
+
* This program is distributed in the hope that it will be useful,
|
14 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
+
* GNU General Public License for more details.
|
17 |
+
*
|
18 |
+
* You should have received a copy of the GNU General Public License
|
19 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
20 |
+
*
|
21 |
+
* @package LiteSpeed_LiteMage
|
22 |
+
* @copyright Copyright (c) 2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
23 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
24 |
+
*/
|
25 |
+
|
26 |
+
require_once 'abstract.php';
|
27 |
+
|
28 |
+
class Litespeed_Litemage_Shell_Purge extends Mage_Shell_Abstract
|
29 |
+
{
|
30 |
+
protected $_modules;
|
31 |
+
protected $_modifiedFiles = array();
|
32 |
+
protected $_fileReplacePatterns = array();
|
33 |
+
public static $_errors = array();
|
34 |
+
|
35 |
+
|
36 |
+
public function run()
|
37 |
+
{
|
38 |
+
$helper = Mage::helper('litemage/data');
|
39 |
+
if (!$helper->getConf($helper::CFG_ENABLED)) {
|
40 |
+
static::log("Abort - litemage module is not enabled.");
|
41 |
+
return;
|
42 |
+
}
|
43 |
+
$params = $this->_inputParams();
|
44 |
+
if ($params == null) {
|
45 |
+
return;
|
46 |
+
}
|
47 |
+
|
48 |
+
$options = array(
|
49 |
+
CURLOPT_SSL_VERIFYPEER => 0,
|
50 |
+
CURLOPT_TIMEOUT => 180,
|
51 |
+
CURLOPT_USERAGENT => 'litemage_walker'
|
52 |
+
) ;
|
53 |
+
|
54 |
+
$server_ip = $helper->getConf($helper::CFG_WARMUP_SERVER_IP, $helper::CFG_WARMUP);
|
55 |
+
|
56 |
+
$base = Mage::getBaseUrl() ;
|
57 |
+
if ($pos = strpos($base, 'litemage_purge')) {
|
58 |
+
$base = substr($base, 0, $pos);
|
59 |
+
}
|
60 |
+
$pattern = "/:\/\/([^\/^:]+)(\/|:)?/";
|
61 |
+
if (preg_match($pattern, $base, $m)) {
|
62 |
+
$domain = $m[1];
|
63 |
+
$pos = strpos($base, $domain);
|
64 |
+
$base = substr($base, 0, $pos) . $server_ip . substr($base, $pos + strlen($domain));
|
65 |
+
$options[CURLOPT_HTTPHEADER] = array("Host: $domain");
|
66 |
+
}
|
67 |
+
|
68 |
+
$url = $base . 'litemage/admin/shell/' . implode('/', $params);
|
69 |
+
|
70 |
+
try {
|
71 |
+
static::log("purge url is " . $url);
|
72 |
+
$client = new Varien_Http_Adapter_Curl() ;
|
73 |
+
$urls = array($url);
|
74 |
+
$result = $client->multiRequest($urls, $options) ;
|
75 |
+
static::log('result back is ' . print_r($result, true));
|
76 |
+
} catch ( Exception $e ) {
|
77 |
+
static::log('Error when send purge url : ' . $e->getMessage()) ;
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
protected function _cleanInput($type, $ids)
|
82 |
+
{
|
83 |
+
$clean = array();
|
84 |
+
if ($ids !== true) {
|
85 |
+
$pattern = "/[\s,]+/";
|
86 |
+
$check = preg_split($pattern, $ids, null, PREG_SPLIT_NO_EMPTY);
|
87 |
+
foreach ($check as $id) {
|
88 |
+
if ($type == 'tags' || strval(intval($id)) === $id) {
|
89 |
+
$clean[] = $id;
|
90 |
+
}
|
91 |
+
else {
|
92 |
+
static::log("found invalid parameters $id for $type", true);
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
return $clean;
|
97 |
+
}
|
98 |
+
|
99 |
+
protected function _inputParams()
|
100 |
+
{
|
101 |
+
$params = array();
|
102 |
+
if ($this->getArg('all')) {
|
103 |
+
$params[] = 'all';
|
104 |
+
$params[] = 1;
|
105 |
+
}
|
106 |
+
else {
|
107 |
+
$types = array('products', 'cats', 'stores', 'tags');
|
108 |
+
foreach ($types as $type) {
|
109 |
+
if ($value = $this->getArg($type)) {
|
110 |
+
$ids = $this->_cleanInput($type, $value);
|
111 |
+
if (empty($ids)) {
|
112 |
+
static::log("No value provided for param $type", true);
|
113 |
+
}
|
114 |
+
else {
|
115 |
+
$params[] = $type;
|
116 |
+
$params[] = implode(',', $ids);
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
120 |
+
}
|
121 |
+
if (empty($params)) {
|
122 |
+
echo "Abort - No valid parameters found.\n\n";
|
123 |
+
echo $this->usageHelp();
|
124 |
+
return null;
|
125 |
+
}
|
126 |
+
return $params;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Retrieve Usage Help Message
|
131 |
+
*
|
132 |
+
* @return void
|
133 |
+
*/
|
134 |
+
public function usageHelp()
|
135 |
+
{
|
136 |
+
return <<<USAGE
|
137 |
+
Usage: php litemage_purge.php -- [options]
|
138 |
+
|
139 |
+
--products <product IDs> Comma delimited product IDs
|
140 |
+
--cats <category_IDs> Comma delimited category IDs
|
141 |
+
--stores <store_IDs> Comma delimited store IDs
|
142 |
+
--tags <raw tags> Comma delimited raw tags. You need to understand LiteMage internals to use this.
|
143 |
+
--all Flush all cached files in LiteSpeed Web Server.
|
144 |
+
|
145 |
+
You can use this tool to flush LiteMage cache from the command line.
|
146 |
+
|
147 |
+
USAGE;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Write the given message to a log file and to screen.
|
152 |
+
*
|
153 |
+
* @param mixed $message Message to log
|
154 |
+
* @param boolean $isError If true, log the error for summary.
|
155 |
+
* @return void
|
156 |
+
*/
|
157 |
+
public static function log( $message, $isError=false )
|
158 |
+
{
|
159 |
+
// Record errors to repeat in the summary.
|
160 |
+
if( $isError === true ) {
|
161 |
+
static::$_errors[] = $message;
|
162 |
+
|
163 |
+
$message = 'ERROR: ' . $message;
|
164 |
+
}
|
165 |
+
|
166 |
+
Mage::log( $message, null, 'litemage_shell.log', true );
|
167 |
+
|
168 |
+
if( !is_string( $message ) ) {
|
169 |
+
$message = print_r( $message, 1 );
|
170 |
+
}
|
171 |
+
|
172 |
+
echo $message . "\n";
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
$litemageShell = new Litespeed_Litemage_Shell_Purge();
|
177 |
+
$litemageShell->run();
|
178 |
+
|
179 |
+
|