<?php 
 
if (!defined('DIR_SEP'))  { 
    if (stripos(php_uname('s'), 'Win')===FALSE)    // Mac OS/LINUX/UNIX directory separator 
        define('DIR_SEP', "/"); 
    else    // MS Windows directory separator 
        define('DIR_SEP', "\\");  } 
 
 
function include_modules($dir, $ignore=array(), $filetype='.php', $¿require=FALSE)  { 
    if (substr($dir, strlen($dir)-1)!==DIR_SEP)  $dir.=DIR_SEP; 
    if (!is_dir($path=$dir))  { 
        $paths=explode(PATH_SEPARATOR, get_include_path()); 
        foreach ($paths as &$p)  {if (substr($p, strlen($p)-1)!==DIR_SEP)  $p.=DIR_SEP;} 
        $i=0;  $m=count($paths); 
        do {$path=$paths[$i++].$dir;} 
        while (!is_dir($path)  and  $i<$m);  } 
    $D=opendir($path); 
    while ( $f=readdir($D) )  { 
        if ($f=="." or $f==".."  or  in_array($f, $ignore))  continue; 
        if (is_dir($path.$f))  include_modules($path.$f.DIR_SEP, $ignore, $filetype, $¿require); 
        else 
        if ( (is_string($filetype)  and  strrchr($f, '.')==$filetype) 
        or  (is_array($filetype)  and  in_array(strrchr($f, '.'), $filetype)) )  { 
            if ($¿require)  require_once $path.$f; 
            else  include_once $path.$f;  }  } 
    closedir($D);  } 
?>
 
 |