diff --git a/common/debug.php b/common/debug.php index 4c8f0db89..0e56fac0b 100644 --- a/common/debug.php +++ b/common/debug.php @@ -109,6 +109,25 @@ if(!defined('__LOG_SLOW_WIDGET__')) define('__LOG_SLOW_WIDGET__', 0); } +/** + * output comments of the slowlog files + * + * 0: No limit (not recommended) + * 1: Allow only specified IP addresses + */ +if(!defined('__LOG_SLOW_PROTECT__')) +{ + define('__LOG_SLOW_PROTECT__', 1); +} + +/** + * Set a ip address to allow slowlog + */ +if(!defined('__LOG_SLOW_PROTECT_IP__')) +{ + define('__LOG_SLOW_PROTECT_IP__', '127.0.0.1'); +} + /** * Leave DB query information * diff --git a/common/legacy.php b/common/legacy.php index b2739bf07..82ddabc8b 100644 --- a/common/legacy.php +++ b/common/legacy.php @@ -822,6 +822,7 @@ function debugPrint($debug_output = NULL, $display_option = TRUE, $file = '_debu function writeSlowlog($type, $elapsed_time, $obj) { if(!__LOG_SLOW_TRIGGER__ && !__LOG_SLOW_ADDON__ && !__LOG_SLOW_WIDGET__ && !__LOG_SLOW_QUERY__) return; + if(__LOG_SLOW_PROTECT__ === 1 && __LOG_SLOW_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) return; static $log_filename = array( 'query' => 'files/_slowlog_query.php',