diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 1be36ae2ed0..ef0f357a1a3 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -3988,52 +3988,6 @@ function email_is_not_allowed($email) { /// FILE HANDLING ///////////////////////////////////////////// -/** - * Create a directory. - * - * @uses $CFG - * @param string $directory a string of directory names under $CFG->dataroot eg stuff/assignment/1 - * param bool $shownotices If true then notification messages will be printed out on error. - * @return string|false Returns full path to directory if successful, false if not - */ -function make_upload_directory($directory, $shownotices=true) { - - global $CFG; - - $currdir = $CFG->dataroot; - - umask(0000); - - if (!file_exists($currdir)) { - if (! mkdir($currdir, $CFG->directorypermissions)) { - if ($shownotices) { - notify('ERROR: You need to create the directory '. $currdir .' with web server write access'); - } - return false; - } - if ($handle = fopen($currdir.'/.htaccess', 'w')) { // For safety - @fwrite($handle, "deny from all\r\n"); - @fclose($handle); - } - } - - $dirarray = explode('/', $directory); - - foreach ($dirarray as $dir) { - $currdir = $currdir .'/'. $dir; - if (! file_exists($currdir)) { - if (! mkdir($currdir, $CFG->directorypermissions)) { - if ($shownotices) { - notify('ERROR: Could not find or create a directory ('. $currdir .')'); - } - return false; - } - //@chmod($currdir, $CFG->directorypermissions); // Just in case mkdir didn't do it - } - } - - return $currdir; -} /** * Makes an upload directory for a particular module. diff --git a/lib/setup.php b/lib/setup.php index 76338e4645f..3ab3c67472f 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -87,7 +87,11 @@ global $HTTPSPAGEREQUIRED; /// Set httpswwwroot default value (this variable will replace $CFG->wwwroot /// inside some URLs used in HTTPSPAGEREQUIRED pages. -$CFG->httpswwwroot = $CFG->wwwroot; + $CFG->httpswwwroot = $CFG->wwwroot; + + $CFG->libdir = $CFG->dirroot .'/lib'; + + require_once($CFG->libdir .'/setuplib.php'); // Functions that MUST be loaded first /// Time to start counting init_performance_info(); @@ -106,7 +110,6 @@ $CFG->httpswwwroot = $CFG->wwwroot; /// Connect to the database using adodb - $CFG->libdir = $CFG->dirroot .'/lib'; require_once($CFG->libdir .'/adodb/adodb.inc.php'); // Database access functions @@ -526,31 +529,4 @@ $CFG->httpswwwroot = $CFG->wwwroot; } -/** - * Initializes our performance info early. - * - * Pairs up with get_performance_info() which is actually - * in moodlelib.php. This function is here so that we can - * call it before all the libs are pulled in. - * - * @uses $PERF - */ -function init_performance_info() { - - global $PERF; - - $PERF = new Object; - $PERF->dbqueries = 0; - $PERF->logwrites = 0; - if (function_exists('microtime')) { - $PERF->starttime = microtime(); - } - if (function_exists('memory_get_usage')) { - $PERF->startmemory = memory_get_usage(); - } - if (function_exists('posix_times')) { - $PERF->startposixtimes = posix_times(); - } -} - -?> \ No newline at end of file +?> diff --git a/lib/setuplib.php b/lib/setuplib.php new file mode 100644 index 00000000000..7de8bc4892e --- /dev/null +++ b/lib/setuplib.php @@ -0,0 +1,83 @@ +dbqueries = 0; + $PERF->logwrites = 0; + if (function_exists('microtime')) { + $PERF->starttime = microtime(); + } + if (function_exists('memory_get_usage')) { + $PERF->startmemory = memory_get_usage(); + } + if (function_exists('posix_times')) { + $PERF->startposixtimes = posix_times(); + } +} + +/** + * Create a directory. + * + * @uses $CFG + * @param string $directory a string of directory names under $CFG->dataroot eg stuff/assignment/1 + * param bool $shownotices If true then notification messages will be printed out on error. + * @return string|false Returns full path to directory if successful, false if not + */ +function make_upload_directory($directory, $shownotices=true) { + + global $CFG; + + $currdir = $CFG->dataroot; + + umask(0000); + + if (!file_exists($currdir)) { + if (! mkdir($currdir, $CFG->directorypermissions)) { + if ($shownotices) { + echo '
ERROR: You need to create the directory '. + $currdir .' with web server write access
'."
\n"; + } + return false; + } + if ($handle = fopen($currdir.'/.htaccess', 'w')) { // For safety + @fwrite($handle, "deny from all\r\n"); + @fclose($handle); + } + } + + $dirarray = explode('/', $directory); + + foreach ($dirarray as $dir) { + $currdir = $currdir .'/'. $dir; + if (! file_exists($currdir)) { + if (! mkdir($currdir, $CFG->directorypermissions)) { + if ($shownotices) { + echo '
ERROR: Could not find or create a directory ('. + $currdir .')
'."
\n"; + } + return false; + } + //@chmod($currdir, $CFG->directorypermissions); // Just in case mkdir didn't do it + } + } + + return $currdir; +} + +?> diff --git a/lib/weblib.php b/lib/weblib.php index f3dbba923c3..a09f42eddde 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -3958,10 +3958,10 @@ function notice_yesno ($message, $linkyes, $linkno) { function redirect($url, $message='', $delay='0') { global $CFG; + //$url = clean_text($url); - if (!empty($CFG->usesid) && !isset($_COOKIE[session_name()])) - { - $url=sid_process_url($url); + if (!empty($CFG->usesid) && !isset($_COOKIE[session_name()])) { + $url = sid_process_url($url); } $message = clean_text($message);