diff --git a/classes/local/outagelib.php b/classes/local/outagelib.php index a514b68..e579523 100644 --- a/classes/local/outagelib.php +++ b/classes/local/outagelib.php @@ -250,7 +250,7 @@ class outagelib { $code = <<<'EOT' = {{STARTTIME}}) { +if ((time() >= {{STARTTIME}}) && (time() < {{STOPTIME}})) { define('MOODLE_INTERNAL', true); require_once($CFG->dirroot.'/lib/moodlelib.php'); if (!remoteip_in_list('{{ALLOWEDIPS}}')) { @@ -278,8 +278,8 @@ if (time() >= {{STARTTIME}}) { } } EOT; - $search = ['{{STARTTIME}}', '{{ALLOWEDIPS}}', '{{YOURIP}}']; - $replace = [$starttime, $allowedips, getremoteaddr('n/a')]; + $search = ['{{STARTTIME}}', '{{STOPTIME}}', '{{ALLOWEDIPS}}', '{{YOURIP}}']; + $replace = [$starttime, $stoptime, $allowedips, getremoteaddr('n/a')]; return str_replace($search, $replace, $code); } diff --git a/tests/phpunit/local/outagelib_test.php b/tests/phpunit/local/outagelib_test.php index f7e380a..ba39c42 100644 --- a/tests/phpunit/local/outagelib_test.php +++ b/tests/phpunit/local/outagelib_test.php @@ -290,7 +290,7 @@ class outagelib_test extends advanced_testcase { public function test_createmaintenancephpcode() { $expected = <<<'EOT' = 123) { +if ((time() >= 123) && (time() < 456)) { define('MOODLE_INTERNAL', true); require_once($CFG->dirroot.'/lib/moodlelib.php'); if (!remoteip_in_list('heyyou @@ -330,7 +330,7 @@ EOT; $expected = <<<'EOT' = 123) { +if ((time() >= 123) && (time() < 456)) { define('MOODLE_INTERNAL', true); require_once($CFG->dirroot.'/lib/moodlelib.php'); if (!remoteip_in_list('127.0.0.1')) {