function getPHPFiles($root)
{
    $phpFiles = array();
    foreach (scandir($root) as $file) {
        if ($file == '.' || $file == '..') {
            continue;
        }
        $file = $root . "/" . $file;
        if (is_dir($file)) {
            $phpFiles = array_merge($phpFiles, getPHPFiles($file));
        } elseif (strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'php') {
            $phpFiles[] = $file;
        }
    }
    return $phpFiles;
}
Example #2
0
function getPHPFiles($folder, $exclude, &$files = array())
{
    $dir = opendir($folder);
    while (($file = readdir($dir)) !== false) {
        $file = str_replace('\\', '/', $file);
        if (strpos($file, '.') !== 0) {
            if (is_dir($folder . '/' . $file) && !in_array($file, $exclude)) {
                getPHPFiles($folder . '/' . $file, $exclude, $files);
            } else {
                if (getSuffix($file) == 'php') {
                    $entry = $folder . '/' . $file;
                    $files[] = $entry;
                }
            }
        }
    }
    closedir($dir);
    return $files;
}
            }
            $userfiles = array();
            foreach ($paths as $path) {
                $userfiles[] = stripSuffix(basename($path));
            }
            $path = SERVERPATH . '/' . ZENFOLDER;
            echo "<em>" . ZENFOLDER . "</em><br />\n";
            listUses(getPHPFiles($path, array()), $path, $pattern);
            $path = SERVERPATH . '/' . USER_PLUGIN_FOLDER;
            echo "<em>" . USER_PLUGIN_FOLDER . "</em><br />\n";
            listUses(getPHPFiles($path, $userfiles), $path, $pattern);
            echo "<em>" . THEMEFOLDER . "</em><br /><br />\n";
            foreach ($zplist as $theme) {
                $path = SERVERPATH . '/' . THEMEFOLDER . '/' . $theme;
                echo "<em>" . $theme . "</em><br />\n";
                listUses(getPHPFiles($path, array()), $path, $pattern);
            }
            break;
        case 4:
            listDBUses($pattern);
            break;
    }
    ?>
					</div>
					<?php 
}
?>
			</div>
		</div>
	</div>
</body>
function &getPHPFiles($dir)
{
    $Directory = new RecursiveDirectoryIterator($dir);
    $Iterator = new RecursiveIteratorIterator($Directory);
    $Regex = new RegexIterator($Iterator, '/^.+\\.(php|inc)$/i', RecursiveRegexIterator::GET_MATCH);
    $files = array();
    foreach ($Regex as $file) {
        $files[] = $file[0];
    }
    return $files;
}
if (!isset($argv[1])) {
    echo "Usage: {$argv[0]} path/to/dir" . PHP_EOL;
    exit;
}
$files_to_parse = getPHPFiles($argv[1]);
foreach ($files_to_parse as $file) {
    //echo "Parsing $file ....".PHP_EOL;
    ParsePHPFile($file);
}
function ParsePHPFile($file, $prepend_out = '')
{
    $contents = file_get_contents($file);
    $contents = strip_comments($contents);
    if (preg_match_all("/<\\?(php)?(.*?)(\\?>|\$\$)/s", $contents, $matchs)) {
        foreach ($matchs[2] as $match) {
            $match = strip_comments($match);
            $results = lookForPaths($match);
            if ($results) {
                for ($i = 0; $i < count($results[0]); $i++) {
                    $file_param = get_file_path($results[1][$i], $results[2][$i]);
Example #5
0
						<?php 
    switch ($selected) {
        case '1':
            $path = SERVERPATH . '/' . THEMEFOLDER;
            listUses(getPHPFiles($path, $zplist), $path, $pattern);
            break;
        case '2':
            $path = SERVERPATH . '/' . USER_PLUGIN_FOLDER;
            listUses(getPHPFiles($path, array()), $path, $pattern);
            break;
        case '3':
            $path = SERVERPATH . '/' . ZENFOLDER;
            listUses(getPHPFiles($path, array()), $path, $pattern);
            foreach ($zplist as $theme) {
                $path = SERVERPATH . '/' . THEMEFOLDER . '/' . $theme;
                $output || listUses(getPHPFiles($path, array()), SERVERPATH, $pattern);
            }
            break;
        case 4:
            listDBUses($pattern);
            break;
    }
    ?>
					</div>
					<?php 
}
?>
			</div>
		</div>
	</div>
</body>