]> git.mjollnir.org Git - moodle.git/commitdiff
A fix from boman in bug 1421 that allows the script to be
authormoodler <moodler>
Tue, 18 May 2004 13:38:58 +0000 (13:38 +0000)
committermoodler <moodler>
Tue, 18 May 2004 13:38:58 +0000 (13:38 +0000)
run from anywhere on the command line in PHP > 4.3.0.

ie:

   php /some/dir/moodle/admin/php.php

   ... now works again

admin/cron.php

index 5a16fd5598af51238ae6ce8767df773e2c90cb98..5f307ba63df5161f0b2e891e43f4577ffa05b6b0 100644 (file)
     $FULLME = "cron";
 
     $starttime = microtime();
+    
+/// The current directory in PHP version 4.3.0 and above isn't necessarily the
+/// directory of the script when run from the command line. The require_once()
+/// would fail, so we'll have to chdir()
+
+    if (!isset($_SERVER['REMOTE_ADDR']) && isset($_SERVER['argv'][0])) {
+        chdir(dirname($_SERVER['argv'][0]));
+    }
 
     require_once("../config.php");