From cecef7b209d674272b373d77058188d4f769094f Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Fri, 11 Aug 2017 16:59:40 -0400 Subject: [PATCH] Updated check for all common plugin PHP files being called directly and now sending user to /assets/404.html --- activate.php | 3 ++- deactivate.php | 3 ++- defines.php | 6 ++++++ index.php | 6 +++--- uninstall.php | 3 ++- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/activate.php b/activate.php index b7c7de3..237a1fc 100644 --- a/activate.php +++ b/activate.php @@ -16,7 +16,8 @@ // Check that we're being called by WordPress. if (!defined('ABSPATH')) { - die("Please do not call this code directly!"); + header("Location: http://".$_SERVER['SERVER_NAME']."/error/404.html"); + die(); } /* diff --git a/deactivate.php b/deactivate.php index 08d00b1..e73d494 100644 --- a/deactivate.php +++ b/deactivate.php @@ -15,7 +15,8 @@ // Check that we're being called by WordPress. if (!defined('ABSPATH')) { - die("Please do not call this code directly!"); + header("Location: http://".$_SERVER['SERVER_NAME']."/error/404.html"); + die(); } /* diff --git a/defines.php b/defines.php index edee637..c72f370 100644 --- a/defines.php +++ b/defines.php @@ -5,6 +5,12 @@ * Set standard defined parameters */ +// Check that we're being called by WordPress. +if (!defined('ABSPATH')) { + header("Location: http://".$_SERVER['SERVER_NAME']."/error/404.html"); + die(); +} + define('GLM_SERVERSTATS_SITE_TITLE', get_bloginfo( 'name' )); define('GLM_SERVERSTATS_PLUGIN_NAME', 'Gaslight Media ServerStats (serverstats)'); define('GLM_SERVERSTATS_PLUGIN_SHORT_NAME', 'ServerStats'); diff --git a/index.php b/index.php index e24086c..69b18d7 100644 --- a/index.php +++ b/index.php @@ -22,13 +22,13 @@ * @version 1.1.1 */ -define('GLM_SERVERSTATS_PLUGIN_VERSION', '1.1.1'); - // Check that we're being called by WordPress. if (!defined('ABSPATH')) { - die("Please do not call this code directly!"); + header("Location: http://".$_SERVER['SERVER_NAME']."/error/404.html"); + die(); } +define('GLM_SERVERSTATS_PLUGIN_VERSION', '1.1.1'); // Required to be able to get user capabilities when being called as a filter from the main plugin require_once ABSPATH . 'wp-includes/pluggable.php'; diff --git a/uninstall.php b/uninstall.php index 7f2a84e..92fda27 100644 --- a/uninstall.php +++ b/uninstall.php @@ -18,7 +18,8 @@ die('uninstall not configured - See plugin uninstall.php script!'); // Check that we're being called by WordPress. if (!defined('ABSPATH')) { - die("Please do not call this code directly!"); + header("Location: http://".$_SERVER['SERVER_NAME']."/error/404.html"); + die(); } //if uninstall not called from WordPress exit -- 2.17.1