Location: PHPKode > scripts > GoogleCrawler > googlecrawler/SearchEngine.php
<?
/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * (C) Jonathan Schmidt-Dominé 2008-2009 < hide@address.com >
 */
header('content-type:text/html;charset="utf-8"');
?>
<form action="">
<div>
<input type="text" name="searchquery" size="25" value="<?=htmlspecialchars($_GET['searchquery']);?>"/>
<input type="submit" value="Suchen"/>
</div>
</form>
<?
if(!empty($_GET['searchquery']))
{
    require_once "googleCrawler.class.php";
    $resultsperpage = (intval($_GET['resultsperpage']) > 0 ? intval($_GET['resultsperpage']) : 10);
    $gC = new googleCrawler($_GET['searchquery'], intval($_GET['site']), $resultsperpage);
    $gC->parseGoogle();
    foreach($gC->results as $result)
    {
        echo '<div class="ergebnis">
    ';
        echo '<a href="' . $result['link'] . '"><img src="http://www.mythumbshot.com/get?url=' . urlencode($result['link']) . '"/>
    ';
        echo '<h3>' . $result['title'] . '</h3></a>
    ';
        echo '<div>' . $result['description'] . '</div>
    </div>
    ';
    }
    if($gC->maxnum)
    {
        echo '<div class="seiten">
';
        $start = $gC->maxnum - 19;
        if(true)
        {
            $pages = array();
            $pages[1] = '<a href="?searchquery=' . urlencode($_GET['searchquery']) . '&amp;site=1&amp;resultsperpage=' .$resultsperpage . '">1</a>';
            $pages[2] = '...';
            for($i = ((intval($_GET['site']) > 8 ? intval($_GET['site']) : 9) - 8); $i < intval($_GET['site']); ++$i)
                $pages[$i] = '<a href="?searchquery=' . urlencode($_GET['searchquery']) . '&amp;site=' . $i . '&amp;resultsperpage=' . $resultsperpage .'">' . $i . '</a> ';
            $pages[$i] = '<span class="actual">' . $i . '</span>';
            for(++$i; $i < $gC->maxnum; ++$i)
                $pages[$i] = '<a href="?searchquery=' . urlencode($_GET['searchquery']) . '&amp;site=' . $i . '&amp;resultsperpage=' . $resultsperpage .'">' . $i . '</a>';
            echo implode(",\n", $pages);
        }
        echo '</div>
';
    }
}
?>
Return current item: GoogleCrawler