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 /
wordpress /
Delete
Unzip
Name
Size
Permission
Date
Action
A2ReCaptcha
[ DIR ]
drwxr-xr-x
2025-04-30 04:08
bin
[ DIR ]
drwxr-xr-x
2025-04-30 04:08
LSCWP_Default_Configuration.data
7.4
KB
-rw-r--r--
2025-04-29 15:41
Optimizations.php
241
B
-rw-r--r--
2025-04-29 15:41
am-bundle.php
1010
B
-rw-r--r--
2025-04-29 15:41
class.A2_Optimized_Private_Optimizations.php
36.09
KB
-rw-r--r--
2025-04-29 15:41
class.A2_Optimized_Private_Optimizations_v3.php
35.31
KB
-rw-r--r--
2025-04-29 15:41
cron-job.php
2.39
KB
-rw-r--r--
2025-04-29 15:41
fix-w3tc.php
2.02
KB
-rw-r--r--
2025-04-29 15:41
hcaptcha_lib.php
2.1
KB
-rw-r--r--
2025-04-29 15:41
managedwp_functions.php
3.78
KB
-rw-r--r--
2025-04-29 15:41
opt-init-variables.txt
797
B
-rw-r--r--
2025-04-29 15:41
optimize.sh
12.29
KB
-rw-r--r--
2025-04-29 15:41
p2-wp-opt-v1.data
7.39
KB
-rw-r--r--
2025-04-29 15:41
p2-wp-opt-v1.sh
20.48
KB
-rwxr-xr-x
2025-04-29 15:41
pagespeed.php
3.2
KB
-rw-r--r--
2025-04-29 15:41
privkey
0
B
-rw-r--r--
2025-04-29 15:41
pubkey
0
B
-rw-r--r--
2025-04-29 15:41
recaptcha_autoload.php
1.14
KB
-rw-r--r--
2025-04-29 15:41
recaptchalib.php
9.36
KB
-rw-r--r--
2025-04-29 15:41
recaptchalib_v2.php
2.95
KB
-rw-r--r--
2025-04-29 15:41
turbo-default.txt
7.39
KB
-rw-r--r--
2025-04-29 15:41
warp-imagick.json
940
B
-rw-r--r--
2025-04-29 15:41
wp-opt-v1.sh
41.12
KB
-rwxr-xr-x
2025-04-29 15:41
Save
Rename
<?php /* Workaround for Easy Hide Login Password Reset */ add_action('lostpassword_form', 'easy_hide_login_hidden_field'); function a2_easy_hide_login_lostpassword_redirect($lostpassword_redirect) { if (!function_exists('easy_hide_login_lostpassword_redirect')) { $EHL_slug = get_option('wpseh_l01gnhdlwp'); return 'wp-login.php?checkemail=confirm&redirect=false&' . $EHL_slug; } } add_filter( 'lostpassword_redirect', 'a2_easy_hide_login_lostpassword_redirect', 100, 1 ); /* Grab RWL generated URLs and send them to Easy Hide Login */ function a2_grab_rwl_url_init() { if (get_option('wpseh_l01gnhdlwp')) { $EHL_slug = get_option('wpseh_l01gnhdlwp'); if (parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) == '/' . $EHL_slug) { wp_safe_redirect(home_url("wp-login.php?$EHL_slug&redirect=false")); exit(); } } } add_action( 'init', 'a2_grab_rwl_url_init'); /* Workarounds for Elementor / Easy Hide Login issues. This needs to run ASAP. When classes are instantiated is too late. During install we choose to not enable Easy Hide Login and set a flag. Right now, we check for that flag and re-enable that plugin and unset the flag. This should fix our new redirect issue as elementor has done what it needs to do and is no longer hijacking the login process. */ add_action( 'admin_init', function () { if (get_option('a2_enable_easyhidelogin') == 1) { $login_page = get_option('a2_login_page'); if (!$login_page) { $login_page = getRandomString(4); update_option('a2_login_page', $login_page); } update_option('wpseh_l01gnhdlwp', $login_page); activate_plugin('easy-hide-login/wp-hide-login.php'); delete_option('a2_enable_easyhidelogin'); } // Removes A2 Optimized menu item if we're on Managed WordPress product if (get_option('a2_is_managedv2') == '1') { remove_menu_page( 'A2_Optimized_Plugin_admin' ); } $private_opt = new A2_Optimized_Private_Optimizations; if ($private_opt->is_redis_supported() && !get_option('a2_declined_redis') && get_option('litespeed.conf.object-kind') != 1) { add_action('admin_notices', array('A2_Optimized_Private_Optimizations', 'prompt_user_for_redis_caching')); } if (!$private_opt->is_redis_supported() && is_plugin_active('litespeed-cache/litespeed-cache.php') && !get_option('a2_declined_memcached') && get_option('a2_object_cache_enabled') != 0 && get_option('litespeed.confg.object-kind') != 0) { add_action('admin_notices', array('A2_Optimized_Private_Optimizations', 'prompt_user_for_memcached_caching')); } if ($private_opt->maybe_display_recaptcha_notice()) { // Set the captcha provider to hcaptcha, we're past the deadline for users to choose to migrate update_option('a2_captcha_provider', 'hcaptcha'); } if (isset($_REQUEST['a2_action']) && isset($_REQUEST['_wpnonce'])) { switch ($_REQUEST['a2_action']) { case 'enable_redis_caching': if (wp_verify_nonce( $_REQUEST['_wpnonce'], 'a2opt-redis-enable' )) { $private_opt->enable_redis_object_cache(); } break; case 'decline_redis_caching': if (wp_verify_nonce( $_REQUEST['_wpnonce'], 'a2opt-redis-enable' )) { //set option so we don't see prompt again update_option('a2_declined_redis', 1); } break; case 'enable_memcached_caching': if (wp_verify_nonce( $_REQUEST['_wpnonce'], 'a2opt-memcached-enable' )) { $private_opt->enable_memcached(); } break; case 'decline_memcached_caching': if (wp_verify_nonce( $_REQUEST['_wpnonce'], 'a2opt-memcached-enable' )) { //set option so we don't see prompt again update_option('a2_declined_memcached', 1); } break; case 'hcaptcha_migrate': if (wp_verify_nonce( $_REQUEST['_wpnonce'], 'a2opt-hcaptcha' )) { //set option so we don't see prompt again update_option('a2_captcha_provider', 'hcaptcha'); } break; } } }, 1 ); function a2_admin_notice_incompatible_cache_plugins() { if (is_plugin_active( 'litespeed-cache/litespeed-cache.php' )) { $active_plugins = array(); if (is_plugin_active( 'autoptimize/autoptimize.php' )) { $active_plugins[] = 'Autoptimize'; } if (is_plugin_active( 'w3-total-cache/w3-total-cache.php' )) { $active_plugins[] = 'W3 Total Cache'; } if (is_plugin_active( 'wp-smushit/wp-smushit.php' )) { $active_plugins[] = 'Smush'; } if (is_plugin_active( 'wp-optimize/wp-optimize.php' )) { $active_plugins[] = 'WP-Optimize'; } if (is_plugin_active( 'sg-cachepress/sg-cachepress.php' )) { $active_plugins[] = 'SG Optimizer'; } if ($active_plugins) { ?> <div class="notice notice-error is-dismissible"> <p>We have detected another active caching plugin that could interfere with TurboCache. We recommend disabling it to ensure your site runs as expected.</p> <p><?php echo implode(', ', $active_plugins); ?></p> </div> <?php } } } add_action( 'admin_notices', 'a2_admin_notice_incompatible_cache_plugins' ); function getRandomString($length) { $output = ''; $valid_chars = 'abcdefghijklmnopqrstuvwxyz'; $num_valid_chars = strlen($valid_chars); for ($i = 0; $i < $length; $i++) { $random_pick = mt_rand(1, $num_valid_chars); $random_char = $valid_chars[$random_pick - 1]; $output .= $random_char; } return $output; } class A2_Optimized_Private_Optimizations { private $thisclass; public function __construct() { $this->disable_elementor_redirect(); } private function disable_elementor_redirect() { add_action( 'admin_init', function () { if ( did_action( 'elementor/loaded' ) ) { remove_action( 'admin_init', array( \Elementor\Plugin::$instance->admin, 'maybe_redirect_to_getting_started' ) ); } }, 1 ); } public function get_optimizations(&$thisclass) { $recaptcha_name = 'CAPTCHA on comments and login'; $recaptcha_desc = 'Decreases spam and increases site security by adding a CAPTCHA to comment forms and the login screen. Without a CAPTCHA, bots will easily be able to post comments to you blog or brute force login to your admin panel.'; if ($this->is_a2_managed()) { $recaptcha_name = 'CAPTCHA on comments'; $recaptcha_desc = 'Decreases spam and increases site security by adding a CAPTCHA to comment forms. Without a CAPTCHA, bots will easily be able to post comments to your blog.'; } $recaptcha_custom = get_option('a2_recaptcha_usecustom'); $recaptcha_site_key = get_option('a2_recaptcha_sitekey'); $recaptcha_secret_key = get_option('a2_recaptcha_secretkey'); if ($recaptcha_custom == '1' && (!$recaptcha_site_key || !$recaptcha_secret_key)) { $recaptcha_desc .= "<br /><strong>Please generate reCaptcha keys for this site.</strong> <a href='https://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/obtaining-google-recaptcha-site-key-and-secret-key' target='_blank'>Google ReCAPTCHA | How To Get Site Key & Secret Key</a>"; } $hcaptcha_custom = get_option('a2_hcaptcha_usecustom'); $hcaptcha_site_key = get_option('a2_hcaptcha_sitekey'); $hcaptcha_secret_key = get_option('a2_hcaptcha_secretkey'); if ($hcaptcha_custom == '1' && (!$hcaptcha_site_key || !$rhcaptcha_secret_key)) { $recaptcha_desc .= '<br /><strong>Please generate hCaptcha keys for this site.</strong>'; } $wp_cron_desc = 'CRON jobs are used to schedule tasks at periodic fixed times, dates, or intervals on your WordPress site. Some examples of a WordPress cron job might involve scheduling a post to publish, checking for updates, or a backup plugin running on a predefined schedule. This normally happens when a user visits your site and can impact front-end performance. This feature will move the WordPress cron tasks to the system cron.'; if ($this->get_cron_command('doing_wp_cron')) { $wp_cron_desc .= '<br /><br />If you would like to further customize when your cron task runs please refer to our KB article on <a href="https://www.a2hosting.com/kb/cpanel/advanced-features/cron-jobs" target="_blank">Cron Jobs</a>'; } if ($this->wp_config_cron_disabled() && !$this->get_cron_command('doing_wp_cron')) { $wp_cron_desc .= '<br /><br /><strong>WARNING:</strong> You have disabled the WordPress cron in your wp-config.php file, but do not currently have a system cron job setup. You can create one automatically by enabling this feature.'; } $optimizations = array( 'captcha' => array('name' => $recaptcha_name, 'plugin' => 'A2 Optimized', 'slug' => 'captcha', 'configured' => false, 'configured_links' => array( 'Settings' => 'admin.php?page=A2_Optimized_Plugin_admin&a2-page=recaptcha_settings', ), 'description' => $recaptcha_desc, 'is_configured' => function (&$item) use (&$thisclass) { if ($thisclass->getOption('recaptcha') == 1) { $captcha_provider = get_option('a2_captcha_provider'); if (!$captcha_provider) { update_option('a2_captcha_provider', 'recaptcha'); } $item['configured'] = true; $thisclass->set_install_status('captcha', true); } else { $thisclass->set_install_status('captcha', false); } }, 'enable' => function () use (&$thisclass) { $captcha_provider = get_option('a2_captcha_provider'); if (!$captcha_provider) { update_option('a2_captcha_provider', 'hcaptcha'); } update_option('A2_Optimized_Plugin_recaptcha', 1); }, 'disable' => function () use (&$thisclass) { $thisclass->updateOption('recaptcha', 0); } ), 'cron_disable' => array( 'name' => 'Use System Cron Instead of WordPress Cron', 'slug' => 'cron_disable', 'configured' => false, 'premium' => true, 'description' => $wp_cron_desc, 'is_configured' => function (&$item) use (&$thisclass) { $item['configured'] = $this->is_wp_cron_disabled(); return $item['configured']; }, 'enable' => function () use (&$thisclass) { $minute = rand(0, 59); // random minute so all sites aren't going off at the same time $this->update_wp_config('wp_cron', 'enable'); $this->enable_cron($minute, '*', '*', '*', '*', 'wget -q -O - ' . get_site_url() . '/wp-cron.php?doing_wp_cron >/dev/null 2>&1'); }, 'disable' => function () use (&$thisclass) { $this->update_wp_config('wp_cron', 'disable'); $this->disable_cron('doing_wp_cron'); } ), 'images' => array( 'name' => 'Compress Images on Upload', 'plugin' => 'EWWW Image Optimizer', 'slug' => 'images', 'configured' => false, 'description' => 'Makes your site faster by compressing images to make them smaller.', 'is_configured' => function (&$item) use (&$thisclass) { if (is_plugin_active('warp-imagick/index.php') || is_plugin_active('ewww-image-optimizer/ewww-image-optimizer.php')) { $item['configured'] = true; $thisclass->set_install_status('compress-images', true); } else { $thisclass->set_install_status('compress-images', false); } }, 'enable' => function () use (&$thisclass) { $thisclass->install_plugin('ewww-image-optimizer'); $thisclass->activate_plugin('ewww-image-optimizer/ewww-image-optimizer.php'); }, 'disable' => function () use (&$thisclass) { if (is_plugin_active('warp-imagick/index.php')) { $thisclass->uninstall_plugin('warp-imagick/index.php', false); } if (is_plugin_active('ewww-image-optimizer/ewww-image-optimizer.php')) { $thisclass->uninstall_plugin('ewww-image-optimizer/ewww-image-optimizer.php', false); } } ), 'wp-login' => array( 'name' => 'Login URL Change', 'slug' => 'wp-login', 'plugin' => 'Rename wp-login.php', 'configured' => false, 'kb' => 'http://www.a2hosting.com/kb/security/application-security/wordpress-security#a-namemethodRenameLoginPageaMethod-3.3A-Change-the-WordPress-login-URL', 'description' => '', 'is_configured' => function (&$item) use (&$thisclass) { $plugins = $thisclass->get_plugins(); $active_plugins = get_option('active_plugins'); if (in_array('easy-hide-login/wp-hide-login.php', $active_plugins)) { if ($rwl_page = get_option('wpseh_l01gnhdlwp')) { if ($rwl_page == '') { if ($rwl_page = get_option('a2_login_page')) { update_option('wpseh_l01gnhdlwp', $rwl_page); } else { $length = 4; $rwl_page = $thisclass->getRandomString($length); update_option('a2_login_page', $rwl_page); update_option('wpseh_l01gnhdlwp', $rwl_page); } } else {//sync rwl_page and a2_login_page if ($a2_login_page = get_option('a2_login_page')) { if ($a2_login_page != $rwl_page) { delete_option('hide_login_url'); update_option('a2_login_page', $rwl_page); } } else { update_option('a2_login_page', $rwl_page); } } } elseif ($rwl_page = get_option('a2_login_page')) { update_option('wpseh_l01gnhdlwp', $rwl_page); } else { return false; } if (class_exists('W3_ConfigWriter')) { $w3tc = $thisclass->get_w3tc_config(); if (!array_search($rwl_page, $w3tc['pgcache.reject.uri'])) { array_push($w3tc['pgcache.reject.uri'], $rwl_page); $thisclass->update_w3tc(array('pgcache.reject.uri' => $w3tc['pgcache.reject.uri'])); } } $item['configured'] = true; $thisclass->set_install_status('wp-login', true); } else { $thisclass->set_install_status('wp-login', false); return false; } return $item['configured']; }, 'disable' => function () use (&$thisclass) { $thisclass->uninstall_plugin('easy-hide-login/wp-hide-login.php'); delete_option('wpseh_l01gnhdlwp'); }, 'enable' => function () use (&$thisclass) { if (!isset($thisclass->plugin_list['easy-hide-login/wp-hide-login.php'])) { $thisclass->install_plugin('easy-hide-login'); } $thisclass->activate_plugin('easy-hide-login/wp-hide-login.php'); if (get_option('a2_login_page') === false) { if (get_option('wpseh_l01gnhdlwp') === false || get_option('wpseh_l01gnhdlwp') == 'root') { // 'root' is set as the login page by default when 'easy-hide-login' is installed, we want to change that $length = 4; $rwl_page = $thisclass->getRandomString($length); update_option('a2_login_page', $rwl_page); update_option('wpseh_l01gnhdlwp', $rwl_page); } else { update_option('a2_login_page', get_option('wpseh_l01gnhdlwp')); } } else { update_option('wpseh_l01gnhdlwp', get_option('a2_login_page')); } delete_option('rwl_redirect'); //Send Email with new login address $email_to = get_bloginfo('admin_email'); $site_url = get_site_url(); $new_admin_url = get_option('a2_login_page'); $subject = 'WordPress Login URL Changed'; $message = "You have changed your login for:\n\n" . $site_url . "\n\nYou can now log in to the administrator account at the following URL:\n\n" . $site_url . '?' . $new_admin_url . "\n\nA2 Optimized"; wp_mail( $email_to, $subject, $message); } ), 'turbo' => array( 'name' => 'Turbo Web Hosting', 'slug' => 'turbo', 'configured' => false, 'compatibility' => array('caching'), 'premium' => true, 'description' => ' <ul> <li>Turbo Web Hosting servers compile .htaccess files to make speed improvements. Any changes to .htaccess files are immediately re-compiled.</li> <li>Turbo Web Hosting servers have their own PHP API that provides speed improvements over FastCGI and PHP-FPM (FastCGI Process Manager). </li> <li>To serve static files, Turbo Web Hosting servers do not need to create a worker process as the user. Servers only create a worker process for PHP scripts, which results in faster performance.</li> <li>PHP OpCode Caching is enabled by default. Accounts are allocated 256 MB of memory toward OpCode caching.</li> <li>Turbo Web Hosting servers have a built-in caching engine for Full Page Cache and Edge Side Includes.</li> </ul> ', 'is_configured' => function (&$item) use (&$thisclass) { if (php_sapi_name() == 'litespeed' || is_plugin_active('litespeed-cache/litespeed-cache.php')) { $item['configured'] = true; } return $item['configured']; } ), 'memcached' => array( 'name' => 'Memcached Database and Object Cache', 'slug' => 'memcached', 'configured' => false, 'partially_configured' => function (&$item) use (&$thisclass) { if (is_dir('/opt/a2-optimized')) { $w3tc = $thisclass->get_w3tc_config(); if ( ( isset($w3tc['dbcache.engine']) && $w3tc['dbcache.engine'] == 'memcached' ) || ( isset($w3tc['objectcache.engine']) && $w3tc['objectcache.engine'] == 'memcached' ) || ( isset($w3tc['minify.engine']) && $w3tc['minify.engine'] == 'memcached' ) ) { $item['partially_configured'] = true; } } return $item['partially_configured']; }, 'premium' => true, 'description' => ' <ul> <li>Extremely fast and powerful caching system.</li> <li>Store frequently used database queries and WordPress objects in Memcached.</li> <li>Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.</li> <li>Take advantage of A2 Hosting's one-click memcached configuration for WordPress.</li> </ul> ', 'is_configured' => function (&$item) use (&$thisclass) { if (is_dir('/opt/a2-optimized')) { $w3tc = $thisclass->get_w3tc_config(); if ( ( isset($w3tc['dbcache.engine']) && $w3tc['dbcache.engine'] == 'memcached' ) && ( isset($w3tc['objectcache.engine']) && $w3tc['objectcache.engine'] == 'memcached' ) && ( isset($w3tc['minify.engine']) && $w3tc['minify.engine'] == 'memcached' ) ) { $item['configured'] = true; } } return $item['configured']; } ) ); if (is_plugin_active( 'litespeed-cache/litespeed-cache.php' )) { $optimizations['a2_page_cache'] = array( 'slug' => 'a2_page_cache', 'name' => 'Page Caching with TurboCache', 'plugin' => 'A2 Optimized', 'configured' => true, 'compatibility' => array('caching'), 'description' => 'TurboCache is a caching system at the web server level.<br />The first time a page is requested: a static copy of the html to display the page is stored on the server. Subsequent requests to pages that have been cached are served from the copy instead of running the scripts and database queries over and over again.<br />Running a static cache like TurboCache is one of the best ways to boost the performance of your site.<br /><strong>This feature is provided by the LiteSpeed Cache plugin.</strong>', 'is_configured' => function (&$item) use (&$thisclass) { $item['configured'] = true; } ); $optimizations['a2_page_cache_gzip'] = array( 'slug' => 'a2_page_cache_gzip', 'name' => 'Gzip Compression Enabled', 'plugin' => 'A2 Optimized', 'configured' => true, 'description' => 'Makes your site significantly faster by compressing all text files to make them smaller<br /><strong>This feature is provided by the LiteSpeed Cache plugin.</strong>', 'is_configured' => function (&$item) use (&$thisclass) { $item['configured'] = true; } ); $optimizations['a2_page_cache_minify_html'] = array( 'slug' => 'a2_page_cache_minify_html', 'name' => 'Minify HTML Pages', 'plugin' => 'A2 Optimized', 'configured' => true, 'description' => 'Removes extra spaces, tabs and line breaks in the HTML to reduce the size of the files sent to the user.<br /><strong>This feature is provided by the LiteSpeed Cache plugin.</strong>', 'is_configured' => function (&$item) use (&$thisclass) { $item['configured'] = true; } ); $optimizations['a2_page_cache_minify_jscss'] = array( 'slug' => 'a2_page_cache_minify_jscss', 'name' => 'Minify CSS and Javascript', 'plugin' => 'A2 Optimized', 'configured' => true, 'description' => 'Removes extra spaces, tabs and line breaks in inline CSS and Javascript to reduce the size of the files sent to the user.<br /><strong>This feature is provided by the LiteSpeed Cache plugin.</strong>', 'is_configured' => function (&$item) use (&$thisclass) { $item['configured'] = true; } ); $optimizations['a2_object_cache'] = array( 'name' => 'Memcached Object Cache', 'slug' => 'memcached', 'configured' => false, 'premium' => true, 'description' => ' <ul> <li>Extremely fast and powerful caching system.</li> <li>Store frequently used database queries and WordPress objects in Memcached.</li> <li>Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.</li> <li>Take advantage of A2 Hosting's one-click memcached configuration for WordPress.</li> </ul> ', 'is_configured' => function (&$item) use (&$thisclass) { if(wp_using_ext_object_cache() || get_option('litespeed.conf.object') == 1){ $item['configured'] = true; } } ); } /* If the webserver is nginx, we want to recommend that the Nginx Helper plugin is active */ if ($this->is_nginx()) { $optimizations['a2_nginx'] = array( 'slug' => 'a2_nginx', 'name' => 'Nginx Helper', 'plugin' => 'A2 Optimized', 'configured' => false, 'description' => 'Purge the Nginx cache (FastCGI, Proxy, uWSGI) automatically when content changes or manually within WordPress.', 'is_configured' => function (&$item) use (&$thisclass) { $item['configured'] = false; if (is_plugin_active('nginx-helper/nginx-helper.php')) { $nginx_helper_settings = get_option('rt_wp_nginx_helper_options'); if ($nginx_helper_settings['enable_purge'] == '1') { $item['configured'] = true; } } return $item['configured']; }, 'disable' => function () use (&$thisclass) { $nginx_helper_settings = get_option('rt_wp_nginx_helper_options'); $nginx_helper_settings['enable_purge'] = 0; update_option('rt_wp_nginx_helper_options', $nginx_helper_settings); }, 'enable' => function () use (&$thisclass) { if (!isset($thisclass->plugin_list['nginx-helper/nginx-helper.php'])) { $thisclass->install_plugin('nginx-helper'); } $thisclass->activate_plugin('nginx-helper/nginx-helper.php'); update_option('rt_wp_nginx_helper_options', $this->get_default_nginx_settings()); } ); } return $optimizations; } public function get_advanced(&$thisclass) { return array( 'cloudflare' => array( 'slug' => 'cloudflare', 'name' => 'CloudFlare', 'description' => ' <p> CloudFlare is a free global CDN and DNS provider that can speed up and protect any site online. </p> <dl style="padding-left:20px"> <dt>CloudFlare CDN</dt> <dd>Distribute your content around the world so it’s closer to your visitors (speeding up your site).</dd> <dt>CloudFlare optimizer</dt> <dd>Web pages with ad servers and third party widgets load snappy on both mobile and computers.</dd> <dt>CloudFlare security</dt> <dd>Protect your website from a range of online threats from spammers to SQL injection to DDOS.</dd> <dt>CloudFlare analytics</dt> <dd>Get insight into all of your website’s traffic including threats and search engine crawlers.</dd> </dl> <p> Use cPanel to activate CloudFlare. </p> ', 'plugin' => 'CloudFlare', 'plugin_slug' => 'cloudflare', 'configured' => false, 'kb' => 'http://www.a2hosting.com/kb/security/application-security/wordpress-security#a-namemethodCloudFlareaMethod-4.3A-Enable-CloudFlare-for-your-site', 'configured_links' => array( 'Dectivating CloudFlare' => array('http://www.a2hosting.com/kb/add-on-services/cloudflare/how-to-activate-cloudflare', '_blank'), 'Configure CloudFlare' => array('http://www.a2hosting.com/kb/add-on-services/cloudflare/configuring-cloudflare', '_blank'), 'About CloudFlare' => array('http://www.cloudflare.com', '_blank'), ), 'not_configured_links' => array( 'Activating Cloudflare' => array('http://www.a2hosting.com/kb/add-on-services/cloudflare/how-to-activate-cloudflare', '_blank'), 'About CloudFlare' => array('http://www.cloudflare.com', '_blank') ), 'file' => 'cloudflare/cloudflare.php', 'is_configured' => function (&$item) use (&$thisclass) { //curl to homepage $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, home_url()); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_NETRC, 1); // omit if you know no urls are FTP links... curl_setopt($ch, CURLOPT_TIMEOUT, 300); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'); curl_setopt($ch, CURLOPT_ENCODING, 'gzip'); ob_start(); $header = get_transient( 'a2-server_resp2-gzip' ); if (false === $header) { $header = curl_exec($ch); set_transient( 'a2-server_resp2-gzip', $header, WEEK_IN_SECONDS ); } $temp_headers = explode("\n", $header); foreach ($temp_headers as $i => $header) { $header = explode(':', $header, 2); if (isset($header[1])) { $headers[strtolower($header[0])] = $header[1]; } else { $headers[strtolower($header[0])] = ''; } } if (isset($headers['server']) && (strpos(strtolower($headers['server']), 'cloudflare') !== false)) { $item['configured'] = true; $thisclass->set_install_status('cloudflare', true); } else { $thisclass->set_install_status('cloudflare', false); } curl_close($ch); } ) ); } public function get_warnings(&$thisclass) { return array(); } /* Should the notice for recaptcha be displayed? */ public function maybe_display_recaptcha_notice() { $current_captcha = get_option('a2_captcha_provider'); $recaptcha_custom = get_option('a2_recaptcha_usecustom'); $recaptcha_site_key = get_option('a2_recaptcha_sitekey'); $recaptcha_secret_key = get_option('a2_recaptcha_secretkey'); $current_page = ''; $current_action = ''; if (isset($_GET['page'])) { $current_page = $_GET['page']; } if (isset($_GET['a2_action'])) { $current_action = $_GET['a2_action']; } if ( current_user_can('manage_options') && // user is an admin get_option('A2_Optimized_Plugin_recaptcha') == '1' && // captcha optimization is enabled $current_captcha != 'hcaptcha' && // captcha provider is not hcaptcha (!$recaptcha_custom || $recaptcha_custom == '') && // User has not set up custom recaptcha keys (!$recaptcha_site_key || $recaptcha_site_key == '') && (!$recaptcha_secret_key || $recaptcha_secret_key == '') && $current_action != 'hcaptcha_migrate') { // Not just tried to fix the issue return true; } } /* Is this a (plesk) MWP server? */ protected function is_a2_managed() { return file_exists('/opt/a2-optimized/wordpress/a2managed'); } /* Is this an nginx server? */ protected function is_nginx() { $webserver = strtolower($_SERVER['SERVER_SOFTWARE']); if (strpos($webserver, 'nginx') === false) { return false; } else { return true; } } /* Default settings for purging nginx cache */ protected function get_default_nginx_settings() { $settings_json = '{"enable_purge":"1","cache_method":"enable_fastcgi","purge_method":"get_request","enable_map":null,"enable_log":null,"log_level":"INFO","log_filesize":"5","enable_stamp":null,"purge_homepage_on_edit":"1","purge_homepage_on_del":"1","purge_archive_on_edit":"1","purge_archive_on_del":"1","purge_archive_on_new_comment":null,"purge_archive_on_deleted_comment":null,"purge_page_on_mod":"1","purge_page_on_new_comment":"1","purge_page_on_deleted_comment":"1","redis_hostname":"127.0.0.1","redis_port":"6379","redis_prefix":"nginx-cache:","purge_url":"","redis_enabled_by_constant":0,"smart_http_expire_form_nonce":"f2de3ffc41"}'; return json_decode($settings_json, true); } /** * is wp cron disabled * * check if everything is setup for this site to use system cron * */ protected function is_wp_cron_disabled() { if (is_dir('/opt/a2-optimized')) { // Check wp-config.php if ($this->wp_config_cron_disabled() === false) { return false; } // Check user cron if ($this->get_cron_command('doing_wp_cron') === false) { return false; } return true; } return false; } /** * enable cron * * use the cpanel live API v2 to create a cron if called from within * cpanel or use crontab if called from command line. * command is not sanitized, make sure it is well written and * sanitized if it uses variables from an external source. * * @param int|string $minute * @param int|string $hour * @param int|string $day * @param int|string $month * @param int|string $weekday * @param string $command */ private function enable_cron($minute, $hour, $day, $month, $weekday, $command) { $jobs = $this->get_cron_jobs(); $jobs[] = "{$minute} {$hour} {$day} {$month} {$weekday} $command"; $this->save_cron_jobs($jobs); } /** * wp config cron disabled * * check if the disable wp cron constant is present in wp-config.php * */ private function wp_config_cron_disabled() { $wpconfig = file_get_contents(ABSPATH . 'wp-config.php'); if (strpos($wpconfig, "define('DISABLE_WP_CRON', true)")) { return true; } return false; } /** * disable cron * * search the crontab and remove a cron * * @param string $search */ private function disable_cron($search) { $jobs = $this->get_cron_jobs(); foreach ($jobs as $line) { if (strpos($line, $search) && strpos($line, get_site_url() . '/wp-cron.php?')) { unset($jobs[array_search($line, $jobs)]); } } $this->save_cron_jobs($jobs); } /** * save cronjobs * * save cronjobs passed in from jobs array * * @param array $jobs */ private function save_cron_jobs($jobs) { $job_string = implode("\n", $jobs); $hash = md5(rand() . time()); $file_name = '/tmp/cron-' . $hash . '.txt'; if (file_exists($file_name)) { unlink($file_name); } file_put_contents($file_name, $job_string . "\n"); shell_exec('cat ' . $file_name . ' | crontab -'); unlink($file_name); } /** * get cron tabs * * get all the cron jobs for this user */ private function get_cron_jobs() { exec('crontab -l', $jobs); return $jobs; } /** * get cron command * * search for a cron that has been set and return the string representing it. * this pulls from the users crontab * * @param string $search * @return string */ private function get_cron_command($search) { $jobs = $this->get_cron_jobs(); foreach ($jobs as $i => $line) { if (!(strpos($line, $search) === false) && strpos($line, get_site_url() . '/wp-cron.php?')) { return $line; } } return false; } /** * update wp config * * utility function to add and remove items from wp-config.php * * @param string $option_name * @param string $action */ private function update_wp_config($option_name, $action = 'disable') { copy(ABSPATH . 'wp-config.php', ABSPATH . 'wp-config.bak-a2.php'); $wpconfig = file_get_contents(ABSPATH . 'wp-config.php'); $a2_config = ''; if ($option_name == 'wp_cron') { if ($action == 'enable') { // add line to wp-config $a2_config = <<<PHP // BEGIN A2 CRON DISABLE define('DISABLE_WP_CRON', true); // END A2 CRON DISABLE PHP; } if ($action == 'disable') { $a2_config = <<<PHP // BEGIN A2 CRON DISABLE define('DISABLE_WP_CRON', false); // END A2 CRON DISABLE PHP; } } $wpconfig = file_get_contents(ABSPATH . 'wp-config.php'); $pattern = "/[\r\n]*[\/][\/] BEGIN A2 CRON DISABLE.*[\/][\/] END A2 CRON DISABLE[\r\n]*/msU"; $wpconfig = preg_replace($pattern, '', $wpconfig); $wpconfig = str_replace('<?php', "<?php{$a2_config}", $wpconfig); //Write the rules to wp-config $fh = fopen(ABSPATH . 'wp-config.php', 'w+'); fwrite($fh, $wpconfig); fclose($fh); } /* Determine if this site can use Redis */ public function is_redis_supported() { if (file_exists('/opt/redis/conf/example.conf') && class_exists('Redis')) { return true; } update_option('a2_optimized_objectcache_type', 'memcached'); // Change our type to Memcached to avoid issues if Redis is set return false; } /* Steps to enable Redis object caching */ public function enable_redis_object_cache() { $options_manager = new A2_Optimized_OptionsManager; // Create .redis.on file touch('/home/' . $this->get_username() . '/.redis.on'); // install plugin if (!is_plugin_active('litespeed-cache/litespeed-cache.php')) { $options_manager->install_plugin('litespeed-cache', true); } // configure plugin $socket_path = $this->get_redis_socket(); update_option('a2_optimized_objectcache_type', 'redis'); update_option('a2_optimized_redis_server', $socket_path); update_option('litespeed.conf.object', 1); // Enable object cache update_option('litespeed.conf.object-kind', 1); // Kind is redis update_option('litespeed.conf.object-host', $socket_path); // Server host update_option('litespeed.conf.object-port', '0'); // Port is 0 for socket connections update_option('a2_object_cache_enabled', 1); // Flag that we have this enabled for A2 Optimized } public function enable_memcached() { $options_manager = new A2_Optimized_OptionsManager; // Create .redis.on file touch('/home/' . $this->get_username() . '/.memcached.on'); // install plugin if (!is_plugin_active('litespeed-cache/litespeed-cache.php')) { $options_manager->install_plugin('litespeed-cache', true); } // configure plugin $socket_path = $this->get_memcached_socket(); update_option('a2_optimized_objectcache_type', 'memcached'); update_option('a2_optimized_memcached_server', $socket_path); update_option('litespeed.conf.object', 1); // Enable object cache update_option('litespeed.conf.object-kind', 0); // Kind is redis update_option('litespeed.conf.object-host', $socket_path); // Server host update_option('litespeed.conf.object-port', '0'); // Port is 0 for socket connections update_option('a2_object_cache_enabled', 1); // Flag that we have this enabled for A2 Optimized } /* Hopefully get the username of this account */ public function get_username() { $file_path = get_home_path(); $path_parts = explode('/', $file_path); $username = $path_parts[2]; return $username; } /* Get the redis socket path */ public function get_redis_socket() { $user = $this->get_username(); return "/home/$user/.redis/redis.sock"; } public function get_memcached_socket() { $user = $this->get_username(); return "/opt/memcached/run/$user/memcached-1.sock"; } /* Display alert to user if Redis caching is available */ public static function prompt_user_for_redis_caching() { $nonce = wp_create_nonce('a2opt-redis-enable'); ?> <div class="notice notice-info"> <p>Hey, we've detected that Redis Object Caching is supported for your site. Would you like to set it up?</p> <p><a href="<?php echo get_admin_url(); ?>/admin.php?page=A2_Optimized_Plugin_admin&_wpnonce=<?php echo esc_attr( $nonce ); ?>&a2_action=enable_redis_caching" class="button button-primary">Yes, please!</a> <a href="<?php echo get_admin_url(); ?>/admin.php?page=A2_Optimized_Plugin_admin&_wpnonce=<?php echo esc_attr( $nonce ); ?>&a2_action=decline_redis_caching" class="button button-secondary">No, thank you</a></p> </div> <?php } /* Display alert to user if Redis caching is available */ public static function prompt_user_for_memcached() { $nonce = wp_create_nonce('a2opt-memcached-enable'); ?> <div class="notice notice-info"> <p>Hey, we've detected that Memcached is supported for your site. Would you like to set it up?</p> <p><a href="<?php echo get_admin_url(); ?>/admin.php?page=A2_Optimized_Plugin_admin&_wpnonce=<?php echo esc_attr( $nonce ); ?>&a2_action=enable_memcached_caching" class="button button-primary">Yes, please!</a> <a href="<?php echo get_admin_url(); ?>/admin.php?page=A2_Optimized_Plugin_admin&_wpnonce=<?php echo esc_attr( $nonce ); ?>&a2_action=decline_memcached_caching" class="button button-secondary">No, thank you</a></p> </div> <?php } }