$_SERVER['DOCUMENT_ROOT'].'/gen-inc', ); // Loop through $directories . . . $i=1; foreach($directories as $dir) { // . . . build constant names . . . $dirName = 'GINC_DIR'.$i; // . . . and set constants. We use constants to preclude // accidental reset, however unlikely it may be. define($dirName,$dir); } // The one you'll use the most. It's basically shorthand for // ninclude($fn,1), and the fallback in case ninclude can't // find a file. function ginclude($fn) { // Check if the file exists . . . if(file_exists(GINC_DIR1."/$fn")) { // . . .and if it does, include it. include(GINC_DIR1."/$fn"); } // If it doesn't . . . else { // . . . spit out a comment. gincUnAvail($fn,'ginclude','1'); } } // The Swiss Army Include() . . . function ninclude($fn,$dirID) { // Build the constant name . . . $dirName = 'GINC_DIR'.$dirID; // . . . and get the constant value . . . // . . . if, of course, it exists. if(defined($dirName)) { $dir = constant($dirName); } // If not . . . else { // . . . give a warning . . . echo("\n\n\n\n"); // . . . and quit. return TRUE; } // If the file exists . . . if(file_exists($dir."/$fn")) { // . . . include it. include($dir."/$fn"); } else { // Otherwise, slip a comment . . . gincUnAvail($fn,'ninclude',$dirID); // . . . and try ginclude(). ginclude($fn); } } // Boring warn function: function gincUnAvail($fn,$func,$id) { // Just warn in HTML with $fn, which function, and which // directory key (not whole directory, for security's sake. echo("\n\n\n\n"); } ?>