Add IP whitelist turn off option (#1249)
parent
de831174c1
commit
607c2e1e82
|
@ -7,4 +7,6 @@ define('PSM_DB_HOST', 'localhost');
|
|||
define('PSM_DB_PORT', '3306'); //3306 is the default port for MySQL. If no specfic port is used, leave it empty.
|
||||
define('PSM_BASE_URL', '');
|
||||
define('PSM_WEBCRON_KEY', '');
|
||||
define('PSM_WEBCRON_ENABLE_IP_WHITELIST', 'true'); // Enable IP whitelisting for calling webcron
|
||||
define('PSM_PUBLIC', false);
|
||||
|
||||
|
|
|
@ -44,10 +44,16 @@ namespace {
|
|||
$data = (defined('PHP_MAJOR_VERSION') && PHP_MAJOR_VERSION >= 7) ? false : @unserialize(PSM_CRON_ALLOW);
|
||||
$allow = $data === false ? PSM_CRON_ALLOW : $data;
|
||||
|
||||
if (!in_array($_SERVER['REMOTE_ADDR'], $allow) && !in_array($_SERVER["HTTP_X_FORWARDED_FOR"], $allow)
|
||||
&& ! (array_key_exists ("webcron_key", $_GET) &&
|
||||
$_GET["webcron_key"]==PSM_WEBCRON_KEY && (PSM_WEBCRON_KEY != ""))
|
||||
) {
|
||||
$ipWhitelistCheckPassed = in_array($_SERVER['REMOTE_ADDR'], $allow)
|
||||
&& in_array($_SERVER["HTTP_X_FORWARDED_FOR"], $allow)
|
||||
&& PSM_WEBCRON_ENABLE_IP_WHITELIST;
|
||||
|
||||
$webCronKeyCheckPassed =
|
||||
array_key_exists ("webcron_key", $_GET)
|
||||
&& $_GET["webcron_key"] == PSM_WEBCRON_KEY
|
||||
&& (PSM_WEBCRON_KEY != "");
|
||||
|
||||
if (!$ipWhitelistCheckPassed && !$webCronKeyCheckPassed) {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
die('
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html>
|
||||
|
|
|
@ -7,4 +7,5 @@ define('PSM_DB_HOST', 'localhost');
|
|||
define('PSM_DB_PORT', '3306'); //3306 is the default port for MySQL. If no specfic port is used, leave it empty.
|
||||
define('PSM_BASE_URL', '');
|
||||
define('PSM_WEBCRON_KEY', '');
|
||||
define('PSM_WEBCRON_ENABLE_IP_WHITELIST', 'true');
|
||||
define('PSM_PUBLIC', false);
|
||||
|
|
Loading…
Reference in New Issue