function search_packages($base_path, $suffix, $depth)
{
    $dir = opendir($base_path);
    $actions = array();
    while (false !== ($file = readdir($dir))) {
        $path_depth = str_replace("\t", "   ", $depth);
        // Select package
        if (filetype("{$base_path}/{$file}") != "dir") {
            $selected = "";
            if (substr($file, -strlen($suffix)) != $suffix) {
                continue;
            }
            $file_data = file("{$base_path}/{$file}");
            if ($_GET['suite'] == "{$base_path}/{$file}") {
                $selected = 'selected="true"';
            }
            echo "{$depth}\t<option value='{$base_path}/{$file}' {$selected}>{$path_depth}" . substr($file_data[0], 3) . "</option>\n";
        }
        // Nested package directory
        if (filetype("{$base_path}/{$file}") == "dir" && substr($file, 0, 1) != ".") {
            echo "{$depth}<optgroup label='{$path_depth}" . $file . "'>\n";
            search_packages("{$base_path}/{$file}", $suffix, $depth . "\t");
            echo "{$depth}</optgroup>\n";
        }
    }
}
function search_packages($base_path, $suffix)
{
    $dir = opendir($base_path);
    $actions = array();
    while (false !== ($file = readdir($dir))) {
        // Select package
        if (filetype("{$base_path}/{$file}") != "dir") {
            if (substr($file, -(strlen($suffix) + 1)) != "." . $suffix) {
                continue;
            }
            echo "\t<script type='text/javascript' charset='UTF-8' src='./{$base_path}/{$file}'></script>\n";
        }
        // Nested package directory
        if (filetype("{$base_path}/{$file}") == "dir" && substr($file, 0, 1) != ".") {
            search_packages("{$base_path}/{$file}", $suffix);
        }
    }
}