|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00040 if (defined('STDIN')) { 00041 fwrite(STDERR, "ERROR: This script no longer supports CLI, please use admin/cli/cron.php instead\n"); 00042 exit(1); 00043 } 00044 00045 // This is a fake CLI script, it is a really ugly hack which emulates 00046 // CLI via web interface, please do not use this hack elsewhere 00047 define('CLI_SCRIPT', true); 00048 define('WEB_CRON_EMULATED_CLI', 'defined'); // ugly ugly hack, do not use elsewhere please 00049 define('NO_OUTPUT_BUFFERING', true); 00050 00051 require('../config.php'); 00052 require_once($CFG->libdir.'/clilib.php'); 00053 require_once($CFG->libdir.'/cronlib.php'); 00054 00055 // extra safety 00056 session_get_instance()->write_close(); 00057 00058 // check if execution allowed 00059 if (!empty($CFG->cronclionly)) { 00060 // This script can only be run via the cli. 00061 print_error('cronerrorclionly', 'admin'); 00062 exit; 00063 } 00064 // This script is being called via the web, so check the password if there is one. 00065 if (!empty($CFG->cronremotepassword)) { 00066 $pass = optional_param('password', '', PARAM_RAW); 00067 if ($pass != $CFG->cronremotepassword) { 00068 // wrong password. 00069 print_error('cronerrorpassword', 'admin'); 00070 exit; 00071 } 00072 } 00073 00074 // send mime type and encoding 00075 if (check_browser_version('MSIE')) { 00076 //ugly IE hack to work around downloading instead of viewing 00077 @header('Content-Type: text/html; charset=utf-8'); 00078 echo "<xmp>"; //<pre> is not good enough for us here 00079 } else { 00080 //send proper plaintext header 00081 @header('Content-Type: text/plain; charset=utf-8'); 00082 } 00083 00084 // execute the cron 00085 cron_run(); 00086 00087 // finish the IE hack 00088 if (check_browser_version('MSIE')) { 00089 echo "</xmp>"; 00090 } 00091 00092