PHP Classes

File: PHP_toolbucket/SoftMoon/include_modules.php

Recommend this page to a friend!
  Classes of Joseph   Rainbow Maker   PHP_toolbucket/SoftMoon/include_modules.php   Download  
File: PHP_toolbucket/SoftMoon/include_modules.php
Role: Auxiliary script
Content type: text/plain
Description: PHP utility function
Class: Rainbow Maker
Create transparent gradient images
Author: By
Last change: updated to allow ignoring specific files to upload - needed for PHP 5.2 support.
Date: 12 years ago
Size: 1,091 bytes
 

Contents

Class file image Download
<?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); }
?>