📄 searcher.cgi
字号:
#!/usr/bin/perl
#------------------------------------------------------#
# 本程序为Yuzi工作室提供 #
# Yuzi搜索引擎2000 v1.00版 #
# #
# 本程序版权归Yuzi工作室所有!任何人皆可自由 #
# 使用本程序于非商业用途,商业用途必须付费人 #
# 民币500元! #
# #
# 谢谢您使用本程序 yuzi #
# E-mail: huangzhiyu@163.net #
# http://www.yuzi.net #
# #
# 本程序为免费程序,您可以使用本程序,但必须 #
# 保留Yuzi工作室(http://www.yuzi.net)的链接! #
#------------------------------------------------------#
######################## 设定部分 ########################
$password= "abcd"; # 管理员密码
$title = "Yuzi搜索引擎2000"; # 搜索引擎名称
$wzname = "中文CGI专门店"; # 主页名称
$wzurl = "http://www.yuzi.net"; # 主页地址
$BaseDir = "."; # CGI程序文件的绝对路径(后面不要加"/")
######################## 设定结束 ########################
## 以下部分不需修改 ##
######################
mkdir("$BaseDir",0777);
mkdir("$BaseDir/data",0777);
unless(-f "$BaseDir/data/new"){
open(TMP,">$BaseDir/data/new")||die $!;
close(TMP);
chmod(0666,"$BaseDir/data/new");
}
unless(-f "$BaseDir/data/ip"){
open(TMP,">$BaseDir/data/ip")||die $!;
close(TMP);
chmod(0666,"$BaseDir/data/ip");
}
$ip = $ENV{'REMOTE_ADDR'};
##########
$yuzicgi="searcher.cgi";
@Categories = ('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30');
$FileFlag = 0;
$MatchFlag = 0;
$MatchFlag2 = 0;
$allow_html = 0;
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
}
else {
$buffer = $ENV{'QUERY_STRING'};
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$value =~ s/\|//g;
$value =~ s/>/>/g;
$value =~ s/</</g;
$in{$name} = $value;
}
$menu = $in{'menu'};
$psd = $in{'psd'};
$yuzi = $in{'yuzi'};
$url = $in{'url'};
$action = $in{'action'};
$delnr = $in{'delnr'};
$lb = $in{'lb'};
$page =$in{'page'};
if($menu eq "add"){&add; exit;}
if($menu eq "del"){&del; exit;}
if($menu eq "dj"){&dj; exit;}
if($menu eq "glms"){&glms; exit;}
if($menu eq "index"){&index; exit;}
if(($menu eq "")&&($yuzi eq "")&&($action eq "")){&index; exit;}
$Header = <<'EOT';
<html>
<head>
<style>
<!--
A:link {text-decoration: none; color:005AB5}
A:visited {text-decoration: none; color: 005AB5}
A:active {text-decoration: none; color: 005AB5}
A:hover {text-decoration: none; color: ff0000}
-->
</style>
<style type=text/css>A {
TEXT-DECORATION: none
}
A:hover {
COLOR: #ee9c00; TEXT-DECORATION: underline
}
TD {
FONT-SIZE: 9pt
}
</style>
<title>Yuzi搜索引擎2000</title>
</head>
<body>
<center><b><font face="华文行楷" size="5" color="#FFBB9D">Yuzi搜索引擎2000</font></b>
<form method="post" action="searcher.cgi">
<hr width="550" size="0">
<input type="hidden" name="action" value="search"><input type="text" size="20" name="Keywords"> <input type="submit" value="搜索">
</center>
<hr width="550" size="0">
</form>
EOT
$Footer = <<'EOT';
<p align=center><font size=1>版权所有 2000 <a href=http://www.yuzi.net target=_blank>Yuzi工作室</a>.
</body>
</html>
EOT
if ($ENV{'QUERY_STRING'} ne "") {
@TempCheck = split (/=/, $ENV{'QUERY_STRING'});
$yuzi = $TempCheck[1];
open(GUEST,"$BaseDir/menu.txt")||die $!;
@lines=<GUEST>;
close(GUEST);
foreach $line (@lines){
$line =~ s/\n//g;
if ($line ne "") {
($no,$mc,$jie) = split(/\|/,$line);
if($yuzi eq $no){$lll=$mc};
}
}
if (-e "$BaseDir/data/$yuzi.dat") {
open (DB, "$BaseDir/data/$yuzi.dat");
@Data = <DB>;
close DB;
$size=@Data;
$ii=0;
$j=$size;
while ($j>0) {
$j=$j-20;
$ii++;
}
sub tp{
$ta=$a;
$ta=~s/.*\|(\d*)\n/$1/g;
$tb=$b;
$tb=~s/.*\|(\d*)\n/$1/g;
$tb <=> $ta;
}
open(FILE,"$BaseDir/data/$yuzi.dat")||die $!;
@lines=<FILE>;
close(FILE);
@MEMTIMES=sort tp @lines;
for($inti=1;$inti<11;$inti++){
$line=@MEMTIMES[$inti-1];
$line=~s/\n//g;
($t1,$t20,$jj,$dj)=split(/\|/,$line);
$top="$top<tr><td align=center><a href=searcher.cgi?menu=dj&yuzi=$yuzi&url=$t20 target=_blank>$t1</a></td><td><font color=#FF0000>$dj</font></td></tr>";
}
&PrintHeader;
print <<EOF;
<html>
$Header
<body>
<center>
<table border=0 cellpadding=0 cellspacing=0 width=600 height=59><span style=FONT-SIZE:9pt>◎ <a href=$wzurl>$wzname</a> —〉<a href="searcher.cgi?psd=$psd">$title</a> —〉$lll <a href=searcher.cgi?menu=add>登录网站</a>
<tr>
<td width=33% height=59 valign=top bgcolor=#FFF9F7><div align=center><table
border=0 cellpadding=0 width=100% height=84>
<tr>
<td width=100% height=84 style=line-height: 10px><table width=454 cellspacing=3
cellpadding=3>
EOF
if($page eq ""){$page=$ii;}
$pages=$page-1;
$pages=$page*20-20;
for($i=$pages; $i<$pages+20; $i++) {
$Match=@Data[$i];
$Match=~ s/\n//g;
if ($Match ne "") {
@TempData = split (/\|/, $Match);
if ($psd eq "$password"){$ppp="<a href=searcher.cgi?menu=del&yuzi=$yuzi&psd=$psd&delnr=$TempData[0]>删除</a>"};
if ($NO_count <2) {
$NO_count ++;
} else {
$NO_count =1;
}
print "<tr><td bgColor=#FFF9F7 width=454>$ppp<li><a href=\"searcher.cgi?menu=dj&yuzi=$yuzi&url=$TempData[1]\" target=\"_blank\">$TempData[0]</a> - $TempData[2]</td></tr>" if ($NO_count==1);
print "<tr><td bgColor=#FFEDE6 width=454>$ppp<li><a href=\"searcher.cgi?menu=dj&yuzi=$yuzi&url=$TempData[1]\" target=\"_blank\">$TempData[0]</a> - $TempData[2]</td></tr>" if ($NO_count==2);
}
}
print <<EOF;
</table>
</td>
</tr>
</table>
</div></td>
<td width=34% height=59 valign=top bgcolor=#FFF4F0><div align=center><table border=0 cellpadding=0 width=94% style=border: 1px solid rgb(255,185,155)><tr><td width=100% bgcolor=#FFCEB9><p align=center><font color="#FFFFFF">TOP前</font><font color=#FFFFFF>10名网站</font></td></tr>
<table>$top
</table>
</div></td>
</tr>
</table>
</body>
EOF
$j=$size;
while ($j>0) {
print "<a href=searcher.cgi?yuzi=$yuzi=&page=$ii&psd=$psd>" if ($page != $ii);
print "[$ii]";
print "</a>" if ($page != $ii);
$j=$j-20;
$ii--;
}
print "<p align=center><font size=1>版权所有 2000 <a href=http://www.yuzi.net target=_blank>Yuzi工作室</a>.\n";
exit;
}
else {
&PrintHeader;
print "<html>\n <head>\n <title>Matches</title>\n </head>\n";
print "$Header\n";
print "<center><table border=0 cellpadding=0 cellspacing=0 width=600 height=59><span style=FONT-SIZE:9pt>◎ <a href=$wzurl>$wzname</a> —〉<a href=searcher.cgi>$title</a> —〉$lll<tr><td width=33% height=59 valign=top bgcolor=#FFF9F7><div align=center><table border=0 cellpadding=0 width=100% height=84><tr><td width=100% height=84 10px align=center>非常抱歉,这个类型尚未有任何网站登录。</td></tr></table></div></td></tr></table>\n";
print "$Footer</font>\n";
exit;
}
}
if ($in{'action'} eq "add") {
if (($in{'Title'} eq "") || ($in{'URL'} eq "") || ($in{'yuzi'} eq "") || ($in{'Description'} eq "")) {&errorview("您登录的资料不完整,请重新填写。");exit;}
open (GUEST,"$BaseDir/data/new")||die $!;
@lines=<GUEST>;
close(GUEST);
foreach $line1 (@lines) {
$line1=~ s/\n//g;
($ww,$zz)=split(/\|/,$line1);
if($in{'URL'} eq $zz){&errorview("您的网站已经在我们的搜索引擎中了,不需要再重复登陆!");exit;}
}
$CheckURL = substr ($in{'URL'}, 0, 7);
if ($CheckURL ne "http://") {&errorview("您输入的网址错误。");exit;}
@DescArray = split (/ /, $in{'Description'});
$ArrayCount = @DescArray;
if (length($in{'Description'}) > 200) {&errorview("您的网站简介不能大于100个字,请重新修改您的简介。");exit;}
foreach $yuzi (@Categories) {
if ($yuzi eq "$in{'yuzi'}") {
$CatFlag = 1;
}
}
if ($CatFlag != 1) {&errorview("您没有选择网站类别,请重新选择。");exit;}
$in{'Description'} =~ s/[ \n\t\r\f]/ /go;
if (-e "$BaseDir/data/$in{'yuzi'}.dat") {
open (DB, ">>$BaseDir/data/$in{'yuzi'}.dat");
print DB "$in{'Title'}|$in{'URL'}|$in{'Description'}\n";
close DB;
}
else {
open (DB, ">$BaseDir/data/$in{'yuzi'}.dat");
print DB "$in{'Title'}|$in{'URL'}|$in{'Description'}\n";
close DB;
}
open (GUEST,"$BaseDir/data/new");
@lines=<GUEST>;
close(GUEST);
$size=@lines;
open (GUEST,">$BaseDir/data/new");
print GUEST "$in{'Title'}|$in{'URL'}|$in{'yuzi'}\n";
for($i=0;$i<=8;$i++){
$_=@lines[$i];
print GUEST $_;
}
close(GUEST);
&PrintHeader;
print "<html>\n <head>\n <title>URL Added</title>\n </head>\n";
print "$Header\n";
print "<center><table border=0 cellpadding=0 cellspacing=0 width=600 height=59><span style=FONT-SIZE:9pt>◎ <a href=$wzurl>$wzname</a> —〉<a href=searcher.cgi>$title</a><tr><td width=33% height=59 valign=top bgcolor=#FFF9F7><div align=center><table border=0 cellpadding=0 width=100% height=84><tr><td width=100% height=84 10px align=center>谢谢您的登录,您的网站已经顺利地登录了我们的搜索系统,您可以使用我们的搜索引擎查找。</td></tr></table></div></td></tr></table>\n";
print "$Footer</font>\n";
exit;
}
if ($in{'action'} eq "search") {
$Counter = 0;
foreach $yuzi (@Categories) {
if (-e "$BaseDir/data/$yuzi.dat") {
open (DB, "$BaseDir/data/$yuzi.dat");
$FileFlag = 0;
@KeyData = <DB>;
foreach $TempLine (@KeyData) {
@Keywords = split (/ /, $in{'Keywords'});
foreach $Keyword (@Keywords) {
if (($TempLine =~ /$Keyword/i) && ($MatchFlag2 == 0)) {
$MatchFlag = 1;
$MatchFlag2 = 1;
$URL[$Counter] = $TempLine;
$Counter++;
}
}
$MatchFlag2 = 0;
}
$FileFlag = 0;
$MatchFlag2 = 0;
}
}
if ($MatchFlag == 0) {
&PrintHeader;
print "$Header\n";
print "<center><table border=0 cellpadding=0 cellspacing=0 width=600 height=59><span style=FONT-SIZE:9pt>◎ <a href=$wzurl>$wzname</a> —〉<a href=searcher.cgi>$title</a><tr><td width=33% height=59 valign=top bgcolor=#FFF9F7><div align=center><table border=0 cellpadding=0 width=100% height=84><tr><td width=100% height=84 10px align=center>很抱歉,根据您提供的关键字进行搜索,未找到任何相关的结果。</td></tr></table></div></td></tr></table>\n";
print "$Footer</font>\n";
exit;
}
else {
&PrintHeader;
print "<html>\n <head>\n <title>Matches</title>\n </head>\n";
print "$Header\n";
print "<span style=FONT-SIZE:9pt><p align=center>根据你的关键字 <font color=#FF0000><b>$in{'Keywords'}</b></font> 搜索出以下结果:</p>\n";
print "<center><table width=454 cellspacing=3 cellpadding=3><tr><td bgColor=#FFEDE6 width=454 height=17>◎ <a href=$wzurl>$wzname</a> —〉<a href=searcher.cgi>$title</a></td></tr>\n";
foreach $Match (@URL) {
@TempData = split (/\|/, $Match);
print "<tr><td bgColor=#FFF9F7 width=454 height=17><a href=$TempData[1] target=_blank>$TempData[0]</a> - $TempData[2]</td></tr>\n";
}
print "</table></center>$Footer</font>\n";
exit;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -