Linux server.edchosting.com 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
LiteSpeed
Server IP : 75.98.162.185 & Your IP : 216.73.216.163
Domains :
Cant Read [ /etc/named.conf ]
User : goons4good
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
opt /
a2-optimized /
app /
classes /
Delete
Unzip
Name
Size
Permission
Date
Action
class.A2OptAction.php
16.53
KB
-rw-r--r--
2025-04-29 15:40
class.A2OptBase.php
34.32
KB
-rw-r--r--
2025-04-29 15:40
class.A2OptDrupal.php
27.68
KB
-rw-r--r--
2025-04-29 15:40
class.A2OptDrupal8.php
23.09
KB
-rw-r--r--
2025-04-29 15:40
class.A2OptJoomla.php
28.43
KB
-rw-r--r--
2025-04-29 15:40
class.A2OptJoomla25.php
178
B
-rw-r--r--
2025-04-29 15:40
class.A2OptJoomla3.php
182
B
-rw-r--r--
2025-04-29 15:40
class.A2OptMagento.php
16.07
KB
-rw-r--r--
2025-04-29 15:40
class.A2OptMemcache.php
7.77
KB
-rw-r--r--
2025-04-29 15:40
class.A2OptOpenCart.php
25.74
KB
-rw-r--r--
2025-04-29 15:40
class.A2OptPDO.php
683
B
-rw-r--r--
2025-04-29 15:40
class.A2OptPrestaShop.php
21.11
KB
-rw-r--r--
2025-04-29 15:40
class.A2OptStaging.php
1.87
KB
-rw-r--r--
2025-04-29 15:40
class.A2OptTest.php
5.06
KB
-rw-r--r--
2025-04-29 15:40
class.A2OptTurboCache.php
14.24
KB
-rw-r--r--
2025-04-29 15:40
class.A2OptWordPress.php
48.93
KB
-rw-r--r--
2025-04-29 15:40
class.A2Optimize.php
5.25
KB
-rw-r--r--
2025-04-29 15:40
class.MemcacheLite.php
5.22
KB
-rw-r--r--
2025-04-29 15:40
class.MemcachedInstance.php
3.82
KB
-rw-r--r--
2025-04-29 15:40
Save
Rename
<?php class A2OptOpenCart extends A2OptBase { public $app; public $db_connection; public $db_server; public $db_prefix; public $db_port; public $db_name; public $db_user; public $db_passwd; public $memcached_socket; public $title; public $domain; public $path; public $type; public $cookie_key; public $pdo; public $htaccess; public $memcached_instance; public function __construct($app) { $this->exit_on_error = false; try { $this->pdo = new PDO(''); } catch (Exception $e) { } $this->db_connection = new MySQLi(); $this->app = $app; $this->path = $app->path; $this->domain = $app->domain; $this->type = 'OpenCart'; $this->get_settings(); if (is_null($this->type)) { $this->log_action('Unable to get_settings ' . $this->path); return; } $this->app->version = $this->get_version(); if (version_compare('2.0', $this->app->version) >= 0) { $this->log_action('Version less than 2.0 ' . $this->path); unset($this->type); unset($this->app->type); return; } //echo $this->app->version; $this->db_connect(true); if ( is_null($this->type) || is_null($this->db_connection) ) { $this->log_action('Unable to connect to DB ' . $this->path); $this->type = null; return; } $this->get_shop_name(); $this->exit_on_error = true; $thisclass = $this; } private function get_settings() { if (!($this->db_server = $this->get_config_setting('DB_HOSTNAME'))) { $this->db_server = 'localhost'; } if (!($this->db_name = $this->get_config_setting('DB_DATABASE'))) { $this->type = null; $this->error("There is no database name defined for OpenCart in {$this->path}/config.php"); } if (!($this->db_user = $this->get_config_setting('DB_USERNAME'))) { $this->type = null; $this->error("There is no database user defined for OpenCart in {$this->path}/config.php"); } if (!($this->db_passwd = $this->get_config_setting('DB_PASSWORD'))) { $this->type = null; $this->error("There is no database password defined for OpenCart in {$this->path}/config.php"); } if (!($this->db_post = $this->get_config_setting('DB_PORT'))) { $this->db_port = '3306'; } if (!($this->db_prefix = $this->get_config_setting('DB_PREFIX'))) { $this->db_prefix = 'ps_'; } } public function db_connect($testing) { if ( isset($this->db_server) && isset($this->db_user) && isset($this->db_passwd) && isset($this->db_name) && $this->db_server != '' && $this->db_user != '' && $this->db_passwd != '' && $this->db_name ) { $this->db_connection = new MySQLi($this->db_server, $this->db_user, $this->db_passwd, $this->db_name); if ($this->db_connection->connect_errno) { if ($testing === true) { $this->type = null; } $this->error('Could not connect to the OpenCart database.'); return; } $this->db_connection->autocommit(true); try { $this->pdo = new A2OptPDO($this->db_server, $this->db_user, $this->db_passwd, $this->db_name); } catch (PDOException $e) { if ($testing === true) { $this->type = null; } $this->error('Could not connect to the OpenCart database.'); return; } } else { if ($testing === true) { $this->type = null; } $this->error('Could not connect to the OpenCart database.'); } } public function get_config_setting($name, $required = true) { if (file_exists("{$this->path}/config.php")) { $settings = file_get_contents("{$this->path}/config.php"); if ( !(preg_match('/define\(\s*[\'"]' . $name . '[\'"]\s*,\s*[\'"](.*)[\'"]\s*\)\s*;/iU', $settings, $matches) === false) ) { return $matches[1]; } } if ($required) { $this->type = null; } return null; } public function get_db_setting($key, $store_id = 0) { $table = $this->get_table('setting'); if (!is_null($this->pdo)) { $stmt = $this->pdo->prepare("select value from {$table} where {$table}.key = :key and {$table}.store_id = :store_id"); $stmt->execute(['key' => $key, 'store_id' => $store_id]); if ($stmt->rowCount() == 1) { $row = $stmt->fetch(PDO::FETCH_ASSOC); return $row['value']; } } return false; } public function update_db_setting($key, $value, $serialized = 0, $code = 'config', $store_id = 0) { $table = $this->get_table('setting'); if (!is_null($this->pdo)) { $curr_value = $this->get_db_setting($key, $store_id); if ($curr_value === false) { $stmt = $this->pdo->prepare("insert into {$table} set {$table}.value = :value, {$table}.key = :key, '{$table}.code' = :code, {$table}.serialized = :serialized ;"); $stmt->execute(['value' => $value,'key' => $key, 'code' => $code, 'serialized' => $serialized]); if ($stmt->rowCount() == 1) { return true; } } elseif ($curr_value == $value) { return true; } else { $stmt = $this->pdo->prepare("update {$table} set {$table}.value = :value where {$table}.key = :key;"); $stmt->execute(['value' => $value,'key' => $key]); if ($stmt->rowCount() == 1) { return true; } } return false; } } public function get_table($name = 'setting') { if ($name == '') { return ''; } $var = "{$this->db_prefix}{$name}"; $table = ''; $stmt = $this->pdo->prepare('SHOW Tables LIKE ?'); $stmt->execute([$var]); if ($res = $stmt->fetchAll()) { $table = $res[0][0]; } else { $var = "%{$name}"; $stmt = $this->pdo->prepare('SHOW Tables LIKE ?'); $stmt->execute([$var]); if ($res = $stmt->fetchAll()) { $table = $res[0][0]; } } return $table; } public function get_shop_name() { $table = $this->get_table('setting'); $result = $this->db_connection->query("select value from {$table} where {$table}.key='config_name'"); if (isset($result->num_rows) && $result->num_rows >= 1) { $title = ($row = $result->fetch_object()) ? $row->value : $this->domain; $this->title = $this->check_app_title($title, $this->app); } else { $this->title = $this->domain; } } public function move_htaccess() { if (!file_exists("{$this->path}/.htaccess") && file_exists("{$this->path}/.htaccess.txt")) { copy("{$this->path}/.htaccess.txt", "{$this->path}/.htaccess"); } //Rewrite the RewriteBase if (file_exists("{$this->path}/.htaccess") && isset($this->app->folder) && $this->app->folder != '') { $htaccess = file_get_contents("{$this->path}/.htaccess"); $htaccess = str_replace("RewriteBase /\n", "RewriteBase {$this->app->folder}/\n", $htaccess); $fp = fopen("{$this->path}/.htaccess", 'w'); flock($fp, LOCK_EX); fwrite($fp, $htaccess); flock($fp, LOCK_UN); fclose($fp); } } public function get_optimizations() { $thisclass = $this; $turbo_cache_enabled = false; if (isset($this->app->swiftcache->turbocache->enabled)) { $turbo_cache_enabled = $this->app->swiftcache->turbocache->enabled; } $optimizations = [ 'Use URL Alias' => [ 'optimized' => ($this->get_db_setting('config_seo_url') == 1 && file_exists("{$this->path}/.htaccess")), 'description' => 'Use URL rewrites', 'enable' => function () use ($thisclass) { $this->update_db_setting('config_seo_url', 1); $this->move_htaccess(); }, 'disable' => function () use ($thisclass) { $this->update_db_setting('config_seo_url', 0); }, 'type' => 'setting' ], 'Turn Off Product Counters For Categories' => [ 'optimized' => ( $this->get_db_setting('config_product_count') == 0 ), 'description' => 'Turn Off Product Counters For Categories to save processing time.', 'enable' => function () use ($thisclass) { $this->update_db_setting('config_product_count', 0); }, 'disable' => function () use ($thisclass) { $this->update_db_setting('config_product_count', 1); }, 'type' => 'setting' ], 'Turn on Output Compression' => [ 'optimized' => ( $this->get_db_setting('config_compression') >= 6 ), 'description' => "Set OpenCart's Output Compression Level to a fast and efficient setting.", 'enable' => function () use ($thisclass) { $this->update_db_setting('config_compression', 6); $this->move_htaccess(); $this->add_htaccess_rules("{$this->path}/.htaccess", [ 'AddOutputFilterByType DEFLATE text/plain', 'AddOutputFilterByType DEFLATE text/html', 'AddOutputFilterByType DEFLATE text/xml', 'AddOutputFilterByType DEFLATE text/css', 'AddOutputFilterByType DEFLATE application/xml', 'AddOutputFilterByType DEFLATE application/xhtml+xml', 'AddOutputFilterByType DEFLATE application/rss+xml', 'AddOutputFilterByType DEFLATE application/javascript', 'AddOutputFilterByType DEFLATE application/x-javascript', 'BrowserMatch ^Mozilla/4 gzip-only-text/html', "BrowserMatch ^Mozilla/4\.0[678] no-gzip", "BrowserMatch \bMSIE !no-gzip !gzip-only-text/html", 'Header append Vary User-Agent' ], 'mod_deflate.c'); }, 'disable' => function () use ($thisclass) { $this->update_db_setting('config_compression', 0); if (file_exists("{$this->path}/.htaccess")) { $this->comment_htaccess_rules("{$this->path}/.htaccess", [ 'AddOutputFilterByType DEFLATE text/plain', 'AddOutputFilterByType DEFLATE text/html', 'AddOutputFilterByType DEFLATE text/xml', 'AddOutputFilterByType DEFLATE text/css', 'AddOutputFilterByType DEFLATE application/xml', 'AddOutputFilterByType DEFLATE application/xhtml+xml', 'AddOutputFilterByType DEFLATE application/rss+xml', 'AddOutputFilterByType DEFLATE application/javascript', 'AddOutputFilterByType DEFLATE application/x-javascript', 'BrowserMatch ^Mozilla/4 gzip-only-text/html', "BrowserMatch ^Mozilla/4\.0[678] no-gzip", "BrowserMatch \bMSIE !no-gzip !gzip-only-text/html", 'Header append Vary User-Agent' ]); } }, 'type' => 'setting' ], 'Enable Browser Caching' => [ 'optimized' => ($this->is_browser_cache() === true), 'description' => 'Enable rules in .htaccess to tell browsers to cache static content.', 'enable' => function () use ($thisclass) { $this->move_htaccess(); $this->add_htaccess_rules("{$this->path}/.htaccess", [ 'ExpiresActive On', 'ExpiresByType image/jpg "access plus 1 week"', 'ExpiresByType image/jpeg "access plus 1 week"', 'ExpiresByType image/gif "access plus 1 week"', 'ExpiresByType image/png "access plus 1 week"', 'ExpiresByType text/css "access plus 1 week"', 'ExpiresByType application/pdf "access plus 1 week"', 'ExpiresByType text/x-javascript "access plus 1 week"', 'ExpiresByType application/x-shockwave-flash "access plus 1 week"', 'ExpiresByType image/x-icon "access plus 1 week"', 'ExpiresDefault "access plus 1 week"' ], 'mod_expires.c'); }, 'disable' => function () use ($thisclass) { if (file_exists("{$this->path}/.htaccess")) { $this->comment_htaccess_rules("{$this->path}/.htaccess", [ 'ExpiresActive On', 'ExpiresByType image/jpg "access plus 1 week"', 'ExpiresByType image/jpeg "access plus 1 week"', 'ExpiresByType image/gif "access plus 1 week"', 'ExpiresByType image/png "access plus 1 week"', 'ExpiresByType text/css "access plus 1 week"', 'ExpiresByType application/pdf "access plus 1 week"', 'ExpiresByType text/x-javascript "access plus 1 week"', 'ExpiresByType application/x-shockwave-flash "access plus 1 week"', 'ExpiresByType image/x-icon "access plus 1 week"', 'ExpiresDefault "access plus 1 week"' ]); } }, 'type' => 'setting' ], 'Fix the Extension Installer' => [ 'optimized' => ($this->is_extension_enabled('isensealabs_quickfix_ocmod') === true), 'description' => 'Allow the extension installer to function without FTP access by installing a modification by iSenseLabs.', 'enable' => function () use ($thisclass) { $thisclass->install_extension(__DIR__ . '/../../opencart/QuickFix.xml'); }, 'disable' => function () use ($thisclass) { $this->disable_extension('isensealabs_quickfix_ocmod'); }, 'type' => 'mod' ], 'Enable Cookies for TurboCache' => [ 'optimized' => ($this->is_extension_enabled('a2hosting_cookies_ocmod') === true), 'description' => 'Set cookies that the web server can see when there are items in the cart', 'enable' => function () use ($thisclass) { $thisclass->install_extension(__DIR__ . '/../../opencart/Cookies.xml'); }, 'disable' => function () use ($thisclass) { $this->disable_extension('a2hosting_cookies_ocmod'); }, 'type' => 'mod' ], 'Make JavaScript Asynchronous' => [ 'optimized' => ($this->is_extension_enabled('a2hosting_async_ocmod') === true), 'description' => 'add the async attribute to all script tags in the common template files. This optimization must be enabled individually.', 'enable' => function () use ($thisclass) { $thisclass->install_extension(__DIR__ . '/../../opencart/Async.xml'); }, 'disable' => function () use ($thisclass) { $this->disable_extension('a2hosting_async_ocmod'); }, 'type' => 'mod', 'auto' => false ], /*"Maintenance Mode"=>array( "optimized"=> ($this->get_db_setting('config_maintenance') == 0), "description"=>"Take the Store out of maintenance mode when development is complete.", "enable"=> function () use ($thisclass){ $this->update_db_setting('config_maintenance',0); }, "disable"=> function () use ($thisclass){ $this->update_db_setting('config_maintenance',1); }, "enabled_text"=>"Off", "disabled_text"=>"On", "type"=>"setting", "auto"=>false ),*/ 'Memcached' => [ 'optimized' => $this->is_memcached_enabled(), 'description' => 'Caching of database query results in memory', 'controller' => 'Memcached', 'advanced' => true ], 'TurboCache' => [ 'optimized' => $turbo_cache_enabled, 'description' => 'Static file caching by the web Server', 'controller' => 'TurboCache', 'advanced' => true ] ]; if (version_compare($this->app->version, '4.0', '>=')) { // Opencart 4.x unset($optimizations['Enable Cookies for TurboCache']); unset($optimizations['Fix the Extension Installer']); unset($optimizations['Make JavaScript Asynchronous']); } return $optimizations; } public function get_version() { $index = file_get_contents("{$this->path}/index.php"); preg_match("/define\s*\(\s*['\"]VERSION['\"]\s*,\s*['\"](.*)['\"]\s*\)/Ui", $index, $matches); if (count($matches) > 0) { $version = array_pop($matches); return $version; } } public function is_memcached_enabled() { $driver = $this->get_config_setting('CACHE_DRIVER'); $hostname = $this->get_config_setting('CACHE_HOSTNAME'); $port = $this->get_config_setting('CACHE_PORT'); $prefix = $this->get_config_setting('CACHE_PREFIX'); if ( is_null($driver) || is_null($hostname) || is_null($port) || is_null($prefix) ) { return false; } if ( $driver != 'mem' ) { return false; } return true; } public function enable_memcached() { if ( !isset($this->app->swiftcache ) || !isset($this->app->swiftcache->memcached) || !isset($this->app->swiftcache->memcached->id) || !isset($this->app->swiftcache->memcached->user) ) { $this->error('The memcached info was missing'); } $memcached = new MemcachedInstance($this->app->swiftcache->memcached->id, $this->app->swiftcache->memcached->user); $this->memcached_instance = $memcached->get_instance(); $this->memcached_socket = $this->memcached_instance->socket; $this->update_config_setting('CACHE_DRIVER', 'mem'); $this->update_config_setting('CACHE_HOSTNAME', $this->memcached_socket); $this->update_config_setting('CACHE_PORT', '0'); $this->update_config_setting('CACHE_PREFIX', $this->get_random_prefix()); $this->system_config_memcached_enable(true); $this->app->swiftcache->memcached->enabled = true; return true; } public function disable_memcached() { $this->update_config_setting('CACHE_DRIVER', 'file'); $this->system_config_memcached_enable(false); $this->app->swiftcache->memcached->enabled = false; return true; } /** * @param bool $memcached_active * @param bool $backup * @return void */ public function system_config_memcached_enable($memcached_active = true, $backup = true) { //$_['cache_engine'] = 'memcached'; // apc, file, mem or memcached $config_file = 'system/config/default.php'; if (file_exists($this->path . '/' . $config_file)) { $prev_settings = file_get_contents("{$this->path}/{$config_file}"); $lines = explode(PHP_EOL, $prev_settings); $file_dirty = false; foreach ($lines as &$line) { if (strpos($line, '$_[\'cache_engine\']') !== false) { if ($memcached_active) { $line = '$_[\'cache_engine\'] = \'memcached\'; // apc, file, mem or memcached'; $file_dirty = true; } else { $line = '$_[\'cache_engine\'] = \'file\'; // apc, file, mem or memcached'; $file_dirty = true; } } } if ($file_dirty) { $new_settings = implode(PHP_EOL, $lines); if ( $backup ) { copy("{$this->path}/{$config_file}", "{$this->path}/system/config/default-bak.php"); } if ( $fp = fopen("{$this->path}/{$config_file}", 'w') ) { fwrite($fp, $new_settings); fclose($fp); } else { $this->error("{$this->path}/{$config_file} is not writable by the web server.", true); } } } } private function find_admin_path() { $paths = []; $iti = new RecursiveDirectoryIterator($this->path); foreach (new RecursiveIteratorIterator($iti) as $file) { if (strpos($file, 'config.php') !== false) { if ($file != $this->path . '/config.php' && $file != $this->path . 'system/engine/config.php') { // This file is NOT the root folder config.php or the unrelated system/engine/config.php. It must be the $admin_folder/config.php // We only need the folder name, so trim off /config.php from the end of the string return substr($file, 0, -11); } } } } public function update_config_setting($name, $value, $backup = true) { $admin_path = $this->path . '/admin'; if (version_compare($this->app->version, '4.0', '>=')) { $admin_path = $this->find_admin_path(); } $config_file_locations = [ $this->path, $admin_path, ]; foreach ($config_file_locations as $path) { if (!file_exists("{$path}/config.php")) { continue; } $prev_settings = file_get_contents("{$path}/config.php"); $new_settings = preg_replace("/define\(['\"]{$name}['\"][^;]+;/Ui", "define('{$name}', '{$value}');", $prev_settings); if ($new_settings === $prev_settings && preg_match("/define\('{$name}'[^;]+;/Ui", $new_settings) === 0) { // Remove closing PHP tag to make sure new setting goes in above it. $new_settings = str_replace('?>', '', $new_settings); $new_settings = <<<CODE {$new_settings} define('{$name}', '{$value}'); ?> CODE; } if ( !($new_settings === $prev_settings) ) { if ( $backup ) { copy("{$path}/config.php", "{$path}/config-bak.php"); } if ( $fp = fopen("{$path}/config.php", 'w') ) { fwrite($fp, $new_settings); fclose($fp); } else { $this->error("{$path}/config.php is not writable by the web server.", true); } } } } public function get_random_prefix() { $prefix = ''; for ($i = 0;$i < 4;$i++) { $prefix .= chr(rand(97, 122)); } return "{$prefix}_"; } public function is_extension_enabled($code) { if ( !is_null($this->pdo) ) { $table = $this->get_table('modification'); if (!$table) { return false; } $stmt = $this->pdo->prepare("select status from {$table} where 'code' = :code;"); $stmt->execute(['code' => $code]); if ($stmt->rowCount() >= 1) { $row = $stmt->fetch(PDO::FETCH_ASSOC); if ($row['status'] == 1 ) { return true; } } } return false; } public function is_extension_installed($code) { if ( !is_null($this->pdo) ) { $table = $this->get_table('modification'); if (!$table) { return false; } $stmt = $this->pdo->prepare("select status from {$table} where 'code' = :code;"); $stmt->execute(['code' => $code]); if ($stmt->rowCount() >= 1) { return true; } } return false; } public function disable_extension($code) { if (!is_null($this->pdo)) { $table = $this->get_table('modification'); if (!$table) { return false; } $stmt = $this->pdo->prepare("update {$table} set status=0 where 'code' = :code;"); $stmt->execute(['code' => $code]); $this->refresh_modifications(); } } public function enable_extension($code) { if (!is_null($this->pdo)) { $table = $this->get_table('modification'); if (!$table) { return false; } $stmt = $this->pdo->prepare("update {$table} set status=1 where 'code' = :code;"); $stmt->execute(['code' => $code]); $this->refresh_modifications(); } } public function refresh_modifications() { copy(__DIR__ . '/../../opencart/admin-cli.php', "{$this->path}/admin-cli.php"); if (file_exists("{$this->path}/admin-cli.php")) { chmod("{$this->path}/admin-cli.php", 0770); chdir($this->app->path); $this->su_exec('php-cli admin-cli.php --route=extension/modification/refresh', $this->app->path); $this->update_db_setting('config_maintenance', 0); } } public function install_extension($path) { $xml_path = ''; $php_path = ''; $sql_path = ''; if (strpos($path, '.xml') === false) { if (file_exists("$path/install.xml")) { $xml_path = "$path/install.xml"; } if (file_exists("$path/install.xml")) { $xml_path = "$path/install.xml"; } else { return false; } } else { $xml_path = $path; } if ($xml_path != '') { $xml = file_get_contents($xml_path); $dom = new DOMDocument(); $dom->loadXML($xml); $name = $this->get_xml_value($dom, 'name'); $version = $this->get_xml_value($dom, 'version'); $link = $this->get_xml_value($dom, 'link'); $author = $this->get_xml_value($dom, 'author'); $code = $this->get_xml_value($dom, 'code'); if (!is_null($this->pdo)) { $table = $this->get_table('modification'); $stmt = $this->pdo->prepare("select code from {$table} where 'code' = :code;"); $stmt->execute(['code' => $code]); if ($stmt->rowCount() > 0) { $stmt = $this->pdo->prepare("update {$table} set name = :name, version = :version, link = :link, author = :author, 'code' = :code, xml = :xml, status=1 where 'code' = :code;"); $stmt->execute([ 'name' => $name, 'version' => $version, 'link' => $link, 'author' => $author, 'code' => $code, 'xml' => $xml ]); $this->refresh_modifications(); return true; } else { $stmt = $this->pdo->prepare("insert into {$table} set name = :name, version = :version, link = :link, author = :author, code = :code, xml = :xml, status=1, date_added=now();"); $stmt->execute([ 'name' => $name, 'version' => $version, 'link' => $link, 'author' => $author, 'code' => $code, 'xml' => $xml ]); if ($stmt->rowCount() == 1) { $this->refresh_modifications(); return true; } } return false; } } } /** * @param DOMDocument $dom * @param string $name * @return string|false */ public function get_xml_value(&$dom, $name) { $nodes = $dom->getElementsByTagName($name); $node = $nodes->length > 0 ? $nodes->item(0) : null; if ( !is_null($node) ) { return $node->nodeValue; } return false; } public function is_browser_cache() { $rules = [ 'ExpiresActive On', 'ExpiresByType image/jpg "access plus 1 week"', 'ExpiresByType image/jpeg "access plus 1 week"', 'ExpiresByType image/gif "access plus 1 week"', 'ExpiresByType image/png "access plus 1 week"', 'ExpiresByType text/css "access plus 1 week"', 'ExpiresByType application/pdf "access plus 1 week"', 'ExpiresByType text/x-javascript "access plus 1 week"', 'ExpiresByType application/x-shockwave-flash "access plus 1 week"', 'ExpiresByType image/x-icon "access plus 1 week"', 'ExpiresDefault "access plus 1 week"' ]; return $this->check_htaccess_rules($this->get_htaccess(), $rules); } /* * "ExpiresActive On", 'ExpiresByType image/jpg "access plus 1 week"', 'ExpiresByType image/jpeg "access plus 1 week"', 'ExpiresByType image/gif "access plus 1 week"', 'ExpiresByType image/png "access plus 1 week"', 'ExpiresByType text/css "access plus 1 week"', 'ExpiresByType application/pdf "access plus 1 week"', 'ExpiresByType text/x-javascript "access plus 1 week"', 'ExpiresByType application/x-shockwave-flash "access plus 1 week"', 'ExpiresByType image/x-icon "access plus 1 week"', 'ExpiresDefault "access plus 1 week"' */ public function set_optimization($name, $optimize, $refresh_w3tc = true) { $optimizations = $this->get_optimizations(); if (array_key_exists($name, $optimizations)) { if (isset($optimizations[$name]['type'])) { switch ($optimizations[$name]['type']) { case 'setting': case 'mod': if ($optimize) { $optimizations[$name]['enable'](); } else { $optimizations[$name]['disable'](); } break; } } } return $this->get_optimizations(); } public function optimize() { $optimizations = $this->get_optimizations(); foreach ($optimizations as $name => $optimization) { if (!$optimization['optimized'] && ( !isset($optimization['auto']) || $optimization['auto'] === true ) ) { $this->set_optimization($name, true); } } } public function get_percent_optimized() { $optimizations = $this->get_optimizations(); $count = 0; foreach ($optimizations as $name => $optimization) { if ($optimization['optimized']) { $count ++; } } return round(($count / (count($optimizations))) * 100); } public function get_turbocache_defaults() { return [ 'reject_urls' => [ 'admin', 'account', 'checkout', 'cart' ], 'reject_cookies' => [ 'logged_in', 'cust_logged_in', 'cart', 'compare', 'wishlist' ], 'time' => '15 Minutes', 'ttl' => 900, 'enabled' => true ]; } }