} if (!isset($CFG->sessioncookiepath)) { $CFG->sessioncookiepath = '/'; } /// Configure ampersands in URLs @ini_set('arg_separator.output', '&'); /// Work around for a PHP bug see MDL-11237 @ini_set('pcre.backtrack_limit', 20971520); // 20 MB /// Location of standard files $CFG->wordlist = $CFG->libdir . '/wordlist.txt'; $CFG->javascript = $CFG->libdir . '/javascript.php'; $CFG->moddata = 'moddata'; // Alas, in some cases we cannot deal with magic_quotes. if (defined('MOODLE_SANE_INPUT') && ini_get_bool('magic_quotes_gpc')) { mdie("Facilities that require MOODLE_SANE_INPUT " . "cannot work with magic_quotes_gpc. Please disable " . "magic_quotes_gpc."); } /// A hack to get around magic_quotes_gpc being turned off /// It is strongly recommended to enable "magic_quotes_gpc"! if (!ini_get_bool('magic_quotes_gpc') && !defined('MOODLE_SANE_INPUT')) { function addslashes_deep($value) { $value = is_array($value) ? array_map('addslashes_deep', $value) : addslashes($value); return $value; } $_POST = array_map('addslashes_deep', $_POST); $_GET = array_map('addslashes_deep', $_GET); $_COOKIE = array_map('addslashes_deep', $_COOKIE); $_REQUEST = array_map('addslashes_deep', $_REQUEST); if (!empty($_SERVER['REQUEST_URI'])) { $_SERVER['REQUEST_URI'] = addslashes($_SERVER['REQUEST_URI']);
* On windows, use php -r 'print sys_get_temp_dir()' to see where the file is saved. */ // Security check. if (!file_exists(__DIR__ . '/mailout-debugger.enable')) { mdie("Disabled."); } $tmpdir = sys_get_temp_dir(); // default if (isset($_SERVER['REMOTE_ADDR'])) { mdie("should not be called from web server!"); } if (isset($_ENV['TMPDIR']) && is_dir($_ENV['TMPDIR'])) { $tmpdir = $_ENV['TMPDIR']; } $tmpfile = $tmpdir . '/moodle-mailout.log'; $fh = fopen($tmpfile, 'a+', false) or mdie("Error openning {$tmpfile} on append\n"); fwrite($fh, "==== " . strftime("%a %b %e %H:%M:%S %Y", time()) . " ====\n"); fwrite($fh, "==== Commandline: " . implode(' ', $argv) . "\n"); $stdin = fopen('php://stdin', 'r'); while ($line = fgets($stdin)) { fwrite($fh, $line); } fwrite($fh, "\n"); fclose($fh); fclose($stdin); /** * Print an error to STDOUT and exit with a non-zero code. For commandline scripts. * Default errorcode is 1. * * Very useful for perl-like error-handling: *