function check_dir_exists($dir, $create=false, $recursive=false) {
global $CFG;
- if (strstr($dir, $CFG->dataroot.'/') === false) {
+ if (strstr(cleardoubleslashes($dir), cleardoubleslashes($CFG->dataroot.'/')) === false) {
debugging('Warning. Wrong call to check_dir_exists(). $dir must be an absolute path under $CFG->dataroot ("' . $dir . '" is incorrect)', DEBUG_DEVELOPER);
}