📄 search.php
字号:
<?php
include_once( "inc/auth.php" );
require( "config.php" );
require( "nusoap.php" );
require( "code.php" );
$langCHK = array( "", "", "" );
$search = $_GET['keywords'];
$lang = $_GET['lang'];
$start = $_GET['start'];
if ( !is_numeric( $start ) )
{
$start = 0;
}
$start = abs( $start );
if ( $search != "" )
{
switch ( $lang )
{
case "lang_zh-CN" :
$langCHK[2] = " checked";
break;
case "lang_zh-CN|lang_zh-TW" :
$langCHK[1] = " checked";
break;
default :
$langCHK[0] = " checked";
}
$BadWords = split( "\\|", $BadWords );
foreach ( $BadWords as $aBadWords )
{
if ( stristr( $search, $aBadWords ) )
{
exit( "这么敏感的内容还是不要搜了,想别的办法吧 :P" );
}
}
$soap = new soapclient( $googleWSDL, true );
$soap->decodeutf8( false );
$params = array(
"key" => $googleAPIKey,
"q" => $search,
"start" => $start,
"maxResults" => 10,
"filter" => true,
"restrict" => "",
"safeSearch" => false,
"lr" => $lang,
"ie" => "UTF-8",
"oe" => "UTF-8"
);
$res = $soap->call( "doGoogleSearch", $params, "urn:GoogleSearch", "urn:GoogleSearch" );
$totalCount = $res['estimatedTotalResultsCount'];
$searchTime = $res['searchTime'];
$startIndex = $res['startIndex'];
$endIndex = $res['endIndex'];
if ( $totalCount == 0 )
{
$output = "<font size=-1><hr color=\"#3366cc\">对不起,找不到您要查找的 <b>{$search}</b></font>";
}
else
{
$output = "<font size=-1><hr color=\"#3366cc\">总共为您搜到了 <b>{$totalCount}</b> 条信息,这是第 <b>{$startIndex}</b> - <b>{$endIndex}</b> 条,共用时 <b>{$searchTime}</b> 秒。<br><br></font>";
}
if ( is_array( $res['resultElements'] ) )
{
foreach ( $res['resultElements'] as $item )
{
$DocSize = $item['cachedSize'];
$DocSnippet = u2g( $item['snippet'] );
$DocURL = u2g( $item['URL'] );
$DocTitle = u2g( $item['title'] );
$DocTitle = $DocTitle == "" ? "无标题" : $DocTitle;
if ( $DocSnippet != "" )
{
$DocSnippet .= "<br>";
}
$output .= "<a href=\"{$DocURL}\" target='_blank'>{$DocTitle}</a><br>";
$output .= "<font size=-1>{$DocSnippet}<span class=g>{$DocURL} - {$DocSize} </span>";
$output .= " <span snap='{$DocURL}' class=hand>[快照预览]</span><br><br></font>";
}
}
}
else
{
$langCHK[2] = " checked";
}
$output = preg_replace( "/<B>\\.\\.\\.<\\/B>/is", "...", $output );
$output .= "<div align=center>";
$theUrl = "<a href=\"".$_SERVER['PHP_SELF']."?keywords={$search}&lang={$lang}&start=";
if ( 9 < $start )
{
$output .= ( $theUrl.( $start - 10 ) )."\">上一页</a> ";
}
if ( $endIndex - $startIndex == 9 )
{
$output .= ( $theUrl.( $start + 10 ) )."\">下一页</a> ";
}
$output .= "</div>";
echo "\r\n<html>\r\n<head>\r\n<title>google 搜索引擎</title>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\r\n";
echo "<s";
echo "tyle type=\"text/css\">\r\n<!--\r\nb {color:#f66}\r\n.g{color:green}\r\n.h {color: #333}\r\n.h a {color: #333;text-decoration:none}\r\n.h a:visited {color: #666;text-decoration:none}\r\n.h a:hover {color: #f33;text-decoration:underline overline}\r\n.hand {cursor:hand;color:#00f}\r\n-->\r\n</style>\r\n</head>\r\n<body leftmargin=\"50\" topmargin=\"0\" onload=\"document.frmSearch.keywords.focus();document.frmSearch.keywords.select()\"";
echo ">\r\n<CENTER>\r\n<form method=\"GET\" action=\"";
echo $_SERVER['PHP_SELF'];
echo "\" name=frmSearch>\r\n<a href=\"http://google.soff.net\"><img src=\"img/logo_sm.gif\" border=\"0\" alt=\"Google\" align=\"absmiddle\"></a>\r\n<input type=text name=\"keywords\" maxLength=256 size=30 value=\"";
echo rawurldecode( $search );
echo "\" class=\"BigInput\"> <input type=\"submit\" value=\"重新搜索\" class=\"BigButton\"> <input type=submit value=\"在结果中搜索\" onClick=\"document.frmSearch.keywords.value+=' '+KWD\" class=\"BigButton\"><br>\r\n<input type=radio name=\"lang\" value=\"\"";
echo $langCHK[0];
echo "><font size=-1>搜索所有网站 </font><input type=radio name=\"lang\" value=\"lang_zh-CN|lang_zh-TW\"";
echo $langCHK[1];
echo "><font size=-1>搜索所有中文网页 </font><input type=radio name=\"lang\" value=\"lang_zh-CN\"";
echo $langCHK[2];
echo "><font size=-1>搜索中文(简体)网页</font><input type=hidden name=\"start\" value=0></form>\r\n</CENTER>\r\n";
echo "<s";
echo "cript src=\"showcache.js\"></script>\r\n";
echo $output;
echo "</body>\r\n</html>";
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -