April 17, 2012
No Comments
if(!function_exists('requireDir')){
function requireDir($dir){
$dh = @opendir($dir);
if (!$dh) {
throw new Exception("Cannot open directory $dir");
} else {
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..') {
$requiredFile = $dir . DIRECTORY_SEPARATOR . $file;
if ('.php' === substr($file, strlen($file) - 4)) {
require_once $requiredFile;
} elseif (is_dir($requiredFile)) {
requireDir($requiredFile);
}
}
}
closedir($dh);
}
unset($dh, $dir, $file, $requiredFile);
}
}