• User

    google in php

    ciao a tutti, questo è una specie di motore di ricerca che funziona tramite google e salva i siti trovati in un txt. Ma vedo che è limitato..cioè non mi cerca molti siti come fa sul browser, si può modificare?

    <?
    ########################

    google v2.0

    Versione in php

    ########################

    if (!empty($_GET['q']))
    {
    $hora = date("H:i:s"); $dia = date("m-d-y");
    $ip = $_SERVER['REMOTE_ADDR'];
    $SITEs = $ip.'-'.str_replace(":", "", $hora).str_replace("-", "", $dia).'.txt';

    echo "<body onload="window.location='page.php?id=0&sites={$SITEs}';">\n";
    echo "Attendere qualche minuto!<br>\n";
    @set_time_limit(0);

    function allstring($SITE) {
    $ALL[0] = parse_url($SITE);
    if (!empty($ALL[0]['query'])) {
    $ALL[1] = explode("=", $ALL[0]['query']);
    $ALL[2] = 1;
    $ALL[3] = '';
    $RESULTS = '';
    while ($ALL[2] <= count($ALL[1])-1) {
    if (!empty($ALL[1][$ALL[2]])) {
    if (@eregi("&", $ALL[1][$ALL[2]])) {
    $ALL[4] = explode("&", $ALL[1][$ALL[2]]);
    $ALL[4] = $ALL[4][0];
    } else {
    $ALL[4] = $ALL[1][$ALL[2]];
    }
    $ALL[3] = str_replace($ALL[4], "[CMD]", $ALL[0]['query']);
    $RESULTS .= str_replace($ALL[0]['query'], $ALL[3], $SITE)."\n";
    }
    $ALL[2]++;
    }
    return $RESULTS;
    }
    }

    function filter($TEXT)
    {
    $CHAVE[1] = "<a class=l href="";
    $CHAVE[2] = """;
    $SITE = explode($CHAVE[1], $TEXT);
    $cSITE = count($SITE)-1;
    $rSITES = '';
    for ($x = 1;$x <= $cSITE;$x++)
    {
    $rSITE = explode($CHAVE[2], $SITE[$x]);
    $aSITE = str_replace("", "", $rSITE[0]);
    $rSITES .= allstring(strip_tags($aSITE));
    }
    return $rSITES;
    }
    function write($A, $B) {
    @touch($A);
    $C = fopen($A, 'a');
    fwrite($C, $B);
    fclose($C);
    }
    for ($n = 0;$n < 900;$n+=10)
    {

    $URL = "www.google.com";
    $PORT = "80";
    $TIMEOUT = 30; // Padrão
    /* Não modifique isso */
    $Q = $_GET['q'];
    $GET = '/custom?q='.urlencode($Q).'+&hl=en&lr=&ie=UTF-8&cof=BGC:%23FFFFFF%3BT:%23000000%3BLC:%230000CC%3BVLC:%230000CC%3BALC:%230000CC%3BGALT:%23008000%3BGFNT:%23000000%3BGIMP:%23000000%3BDIV:%230000CC%3BLBGC:%23FFFFFF%3B&start='.$n.'&sa=N';
    $fp = fsockopen($URL, $PORT, $errno, $errstr, $TIMEOUT);

    if (!$fp)
    {
    echo "Errore nella connessione al sito {$URL}<br>\n";
    } else
    {
    $out = "GET $GET HTTP/1.1\r\n";
    $out .= "Host: $URL\r\n";
    $out .= "Connection: Close\r\n\r\n";
    fwrite($fp, $out);
    $buffer = '';
    while (!feof($fp))
    {
    $buffer .= fgets($fp, 128);
    }
    fclose($fp);
    write($SITEs, filter($buffer));

    }
    }
    } else
    {
    exit;
    }
    ?>