<?php
$url
= "http://sagool.jp/openapi?clientUrl=http%3A%2F%2Ftatamilab.jp%2F&query=";
$url .= $_SERVER["QUERY_STRING"];
$res = file_get_contents($url);

if((
$count = preg_match_all("|<item>.*?<title>(.*?)</title>.*?<description>(.*?)</description>.*?<link>(.*?)</link>.*?</item>|s",$res, $match)) == 0){
    echo
"だめっぽい";
    exit;
}
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="Cache-Control" content="no-cache">
<title>Sagool検索結果</title>
</head>
<body>
<?php for ($i = 0; $i<$count;$i++){
    echo
'<a href="http://www.google.co.jp/gwt/n?u=' . urlencode($match[3][$i]) .  '">'. unhtmlspecialchars($match[1][$i]) . "</a><br>";
    echo
'<blockquote><small><font size="-1">' . unhtmlspecialchars($match[2][$i]) .  '</font></small></blockquote><p/>';
}
?>
<hr>
<center><small><font size="-1">
powered by <a href="http://sagool.jp/k/">オモロ検索エンジンSAGOOL</a>
</font></small></center>
</body>
<?
function unhtmlspecialchars( $str )
{
    
$entry = array_flip( get_html_translation_table( HTML_SPECIALCHARS ) );
    return
strtr( $str, $entry );
}
?>