From b25603680e8141a80a7618b15f0814edb012e305 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Mon, 14 Nov 2011 10:09:10 +0800 Subject: [PATCH] MDL-29396 core: ip blocking will be bypassed for cli scripts - Thanks Petr --- lib/setup.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/setup.php b/lib/setup.php index de6f9fff90b..305f150db2c 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -788,12 +788,14 @@ if (!empty($CFG->customscripts)) { } } -// in the first case, ip in allowed list will be performed first -// for example, client IP is 192.168.1.1 -// 192.168 subnet is an entry in allowed list -// 192.168.1.1 is banned in blocked list -// This ip will be banned finally -if (!empty($CFG->allowbeforeblock)) { // allowed list processed before blocked list? +if (CLI_SCRIPT and !defined('WEB_CRON_EMULATED_CLI') and !PHPUNIT_SCRIPT) { + // no ip blocking +} else if (!empty($CFG->allowbeforeblock)) { // allowed list processed before blocked list? + // in this case, ip in allowed list will be performed first + // for example, client IP is 192.168.1.1 + // 192.168 subnet is an entry in allowed list + // 192.168.1.1 is banned in blocked list + // This ip will be banned finally if (!empty($CFG->allowedip)) { if (!remoteip_in_list($CFG->allowedip)) { die(get_string('ipblocked', 'admin'));