This commit is contained in:
Jakub Bivoj Kubień 2023-09-01 20:21:12 -06:00 committed by GitHub
commit e3661a66ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View File

@ -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);

View File

@ -44,10 +44,16 @@ namespace {
$data = @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>

View File

@ -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);