Exemplo n.º 1
0
Arquivo: 404.php Projeto: boost01/caan
function scan_site()
{
    global $do_debug, $exact_match, $extentions, $fuzzy_match, $ignore, $insert, $insert_no_ext, $level, $partial_match, $scan_path;
    if (!$exact_match) {
        $insert = $insert_no_ext;
    }
    for ($search = 0, $search_path = ''; $search <= $level; $search++) {
        $search_path .= $scan_path[$search];
        $search_path = str_replace($ignore, '', $search_path);
    }
    $dirhandle = opendir($search_path);
    while ($file = readdir($dirhandle)) {
        if ($file[0] != '.') {
            if (is_file($search_path . $file)) {
                $fext = substr($file, strrpos($file, '.'));
                $itsname = basename($file);
                $short_name = substr($itsname, 0, 0 - strlen($fext));
                if ($partial_match and (in_array($fext, $extentions) and @stristr($file, $insert))) {
                    do_result($search_path . $file);
                } elseif ($fuzzy_match) {
                    if (in_array($fext, $extentions) and similar_text($short_name, $insert) == strlen($short_name) - 1 and levenshtein($short_name, $insert) == 1) {
                        // using two tests allows us to match for dodgy, non letter
                        // characters and makes things more accurate.
                        do_result($search_path . $file);
                    }
                } else {
                    // non-fuzzy or partial match..
                    if (in_array($fext, $extentions) and @stristr($itsname, $insert)) {
                        do_result($search_path . $file);
                    }
                }
            } elseif (is_dir($search_path . $file)) {
                $scan_path[++$level] = $file . '/';
                scan_site();
                $level--;
            }
        }
    }
}
Exemplo n.º 2
0
function scan_site()
{
    global $active_errors, $insert, $insert_no_ext, $level;
    if (!$active_errors['exact_match']) {
        $insert = $insert_no_ext;
    }
    for ($search = 0, $search_path = ''; $search <= $level; $search++) {
        $search_path .= $active_errors['scan_path'][$search];
        $search_path = str_replace($active_errors['ignore_folders'], '', $search_path);
    }
    $dirhandle = opendir($search_path);
    while ($file = readdir($dirhandle)) {
        if ($file[0] != '.') {
            if (is_file($search_path . $file)) {
                $fext = substr($file, strrpos($file, '.'));
                $itsname = basename($file);
                $short_name = substr($itsname, 0, 0 - strlen($fext));
                if ($active_errors['partial_match'] and (in_array($fext, $active_errors['allowed_extensions']) and @stristr($file, $insert))) {
                    do_result($search_path . $file);
                } elseif ($active_errors['fuzzy_match']) {
                    if (in_array($fext, $active_errors['allowed_extensions']) and similar_text($short_name, $insert) == strlen($short_name) - 1 and levenshtein($short_name, $insert) <= $active_errors['fuzziness_level']) {
                        // using two tests allows us to match for dodgy, non-letter
                        // characters and makes things more accurate.
                        do_result($search_path . $file);
                    }
                } else {
                    // non-fuzzy or partial match..
                    if (in_array($fext, $active_errors['allowed_extensions']) and @stristr($itsname, $insert)) {
                        do_result($search_path . $file);
                    }
                }
            } elseif (is_dir($search_path . $file)) {
                if ($active_errors['match_dirs'] and !in_array($search_path . $file, $active_errors['ignore_folders']) and @stristr($search_path . $file, $insert)) {
                    do_result($search_path . $file);
                }
                $active_errors['scan_path'][++$level] = $file . '/';
                scan_site();
                $level--;
            }
        }
    }
}