Exemple #1
0
function get_links($page, $domain, &$links)
{
    global $ignoredir;
    global $getext;
    global $offset;
    global $max_results;
    if (sizeof($links) >= $offset + $max_results && $max_results) {
        return true;
    }
    $href_pos = -5;
    $file = strrchr($page, "/");
    if (!strlen($file)) {
        $page__ = find_page("http://" . $domain . $page);
        if ($page__ == false) {
            return;
        }
        $path = substr($page, -1, 1);
        $page = $page . $page__;
    } else {
        $path = str_replace($file, "", $page);
    }
    $links[] = "http://{$domain}{$path}{$file}";
    if (($page_ = @file("http://" . $domain . $path . $file)) == false) {
        return;
    }
    $page_ = implode("", $page_);
    $_page = strtolower($page_);
    while (1) {
        set_time_limit(1);
        if (sizeof($links) >= $offset + $max_results && $max_results) {
            return true;
        }
        $href_pos = @strpos($_page, "href=", $href_pos + 5);
        if (@is_string($href_pos) && !$href_pos) {
            return;
        }
        $nc = substr($page_, $href_pos + 5, 1);
        if ($nc == '"') {
            $np = @strpos($page_, '"', $href_pos + 6);
        } else {
            if ($nc == "'") {
                $np = @strpos($page_, "'", $href_pos + 6);
            } else {
                $np = @strpos($page_, " ", $href_pos + 5);
                $nd = @strpos($page_, ">", $href_pos + 5);
                if ($np > $nd) {
                    $np = $nd;
                }
            }
        }
        if (@is_string($np) && !$np) {
            continue;
        }
        if ($nc == "'" || $nc == '"') {
            $link = @str_replace("'", " ", @str_replace('"', " ", @substr($page_, $href_pos + 6, $np - $href_pos - 6)));
        } else {
            $link = @str_replace("'", " ", @str_replace('"', " ", @substr($page_, $href_pos + 5, $np - $href_pos - 5)));
        }
        if (ereg("\\?+", $link)) {
            $link = @substr($link, 0, strpos($link, "?"));
        }
        if (ereg("^((javascript:)|(ftp://)|(mailto:))", $link)) {
            continue;
        }
        if (($link_ = @stristr($link, $domain)) == false) {
            if (($link_ = apply_correction($link, $path, $domain)) == false) {
                continue;
            }
        }
        $link_ = eregi_replace("^(www\\.)?({$domain})", "", $link_);
        if (@my_in_array("http://{$domain}{$link_}", $links) == true) {
            continue;
        }
        if (ereg("((\\.)({$getext}))\$", $link_) && !ereg("(/)({$ignoredir})(/)", $link_)) {
            get_links($link_, $domain, $links);
        }
    }
}
<?php

function my_in_array($wt, $Array)
{
    $Array = array('a', 'b', 'c', 'd');
    $arrLength = count($Array);
    $element = 'a';
    for ($i = 0; $i < $arrLength; $i++) {
        if ($element == $Array[$i]) {
            return true;
        }
        return false;
    }
}
$result = my_in_array($wt, $Array);
echo $result;
include "C:/xampp/htdocs/Training/PHP/functions.php";
$str1 = "acct";
$str2 = "act";
$strlen1 = strlen($str1);
$strlen2 = strlen($str2);
$arrString = array();
if ($strlen1 == $strlen2) {
    // $strArray = " ";
    for ($i = 0; $i < $strlen1; $i++) {
        // echo $str1[$i];
        for ($j = 0; $j < $strlen2; $j++) {
            // $strArray =  $str2[$j];
            // echo $strArray;
            if ($str1[$i] == $str2[$j]) {
                if (my_in_array($j, $arrString)) {
                    continue;
                } else {
                    array_push($arrString, $j);
                }
                if ($i == $strlen1 - 1) {
                    echo "True";
                }
                break;
            }
        }
        if ($j == $strlen2) {
            echo "False";
            break;
        }
    }
Exemple #4
0
            return true;
        }
    }
    return false;
}
if (isset($_GET["string1"]) && $_GET["string2"]) {
    $string1 = $_GET['string1'];
    $string2 = $_GET['string2'];
    $length1 = strlen($string1);
    $length2 = strlen($string2);
    $arr = array();
    if ($length1 == $length2) {
        for ($i = 0; $i < $length1; $i++) {
            for ($j = 0; $j < $length2; $j++) {
                if ($string1[$i] == $string2[$j]) {
                    if (my_in_array($j, $arr)) {
                        continue;
                    } else {
                        array_push($arr, $j);
                    }
                    if ($i == $length1 - 1) {
                        echo "true";
                    }
                    break;
                }
            }
            if ($j == $length2) {
                echo "false";
                break;
            }
        }