Exemplo n.º 1
0
/**
 * Given one full path, return one array with all the files to check
 */
function files_to_check($path)
{
    $results = array();
    $pending = array();
    $dir = opendir($path);
    while (false !== ($file = readdir($dir))) {
        $fullpath = $path . '/' . $file;
        if (substr($file, 0, 1) == '.' || $file == 'CVS' || $file == 'm19tom20.php') {
            /// Exclude some dirs
            continue;
        }
        if (is_dir($fullpath)) {
            /// Process dirs later
            $pending[] = $fullpath;
            continue;
        }
        if (is_file($fullpath) && strpos($file, basename(__FILE__)) !== false) {
            /// Exclude me
            continue;
        }
        if (is_file($fullpath) && strpos($file, '.php') === false && strpos($file, '.html') === false && strpos($file, '.xml') === false) {
            /// Exclude some files
            continue;
        }
        if (!in_array($fullpath, $results)) {
            /// Add file if doesn't exists
            $results[$fullpath] = $fullpath;
        }
    }
    closedir($dir);
    foreach ($pending as $pend) {
        $results = array_merge($results, files_to_check($pend));
    }
    return $results;
}
/**
 * Given one full path, return one array with all the files to check
 */
function files_to_check($path)
{
    $results = array();
    $pending = array();
    $dir = opendir($path);
    while (false !== ($file = readdir($dir))) {
        $fullpath = $path . '/' . $file;
        if (substr($file, 0, 1) == '.' || $file == 'CVS') {
            // Exclude some dirs.
            continue;
        }
        if (is_dir($fullpath)) {
            // Process dirs later.
            $pending[] = $fullpath;
            continue;
        }
        if (is_file($fullpath) && strpos($file, basename(__FILE__)) !== false) {
            // Exclude me.
            continue;
        }
        if (is_file($fullpath) && (strpos($fullpath, 'lib/adodb') !== false || strpos($fullpath, 'lib/pear') !== false || strpos($fullpath, 'lib/simpletest') !== false || strpos($fullpath, 'lib/htmlpurifier') !== false || strpos($fullpath, 'lib/memcached.class.php') !== false || strpos($fullpath, 'lib/eaccelerator.class.php') !== false || strpos($fullpath, 'lib/phpmailer') !== false || strpos($fullpath, 'lib/simplepie/simplepie.class.php') !== false || strpos($fullpath, 'lib/soap') !== false || strpos($fullpath, 'lib/zend/Zend/Amf/Adobe/DbInspector.php') !== false || strpos($fullpath, 'search/Zend/Search') !== false || strpos($fullpath, 'lang/') !== false || strpos($fullpath, 'config.php') !== false || strpos($fullpath, 'config-dist.php') != false)) {
            // Exclude adodb, pear, simpletest, htmlpurifier, memcached, phpmailer, soap and lucene libs, lang and config files.
            continue;
        }
        if (is_file($fullpath) && strpos($file, '.php') === false && strpos($file, '.html') === false && strpos($file, '.xml') === false) {
            // Exclude some files.
            continue;
        }
        if (!in_array($fullpath, $results)) {
            // Add file if doesn't exists.
            $results[$fullpath] = $fullpath;
        }
    }
    closedir($dir);
    foreach ($pending as $pend) {
        $results = array_merge($results, files_to_check($pend));
    }
    return $results;
}