CGI 站内搜索

来源:网页教学基地 时间:2007-02-19 00:41:25  浏览次数:0

源代码:


#!/usr/bin/perl



# ___________



= '/home/httpd/elvis/public_html/';
#这里输入你的首页第一页index.htm档的绝对路径,到目录名即可
# The directory location of all your files. Remember the trailing
# slash.


= http://linux.cqi.com.cn/~elvis/;
#这里输入你的首页网址,後面不可加上index.htm
# The URL corresponding to the base directory.


@files = ('*.htm','*.html','forum/*.htm','mylinks/*.html','wwwboard/*.htm',
'bbs/*.htm','docs/*.htm','docs/*.html',
'guestbook/*.htm',
'guestbook/*.txt',
'friend/*.txt');
#这里输入你的所有档案形式,子目录内的也要
# These are all the files that will be listed. The asterisk is a
# wildcard - it will list all files and directories.


= '/home/httpd/elvis/public_html/search/summaries.htm';
#这里输入summaries.htm档的绝对路径
# Make this writable (chmod 777 summaries.htm) and hide it well!
# It holds the results of everybody's searches so you'll know what
# people are really looking for when they come to your site. We
# have placed our summary file in a non-web directory so others
# can't see it - you could put it in a hidden or secure directory.


= http://linux.cqi.com.cn/~elvis/';
#这里输入你的首页的网址


= '回到首页';
#这里是你首页名称,改不改无所谓
# Enter the URL and title of your main web page.


= 'on';
#如果担心你的访客有使用不支援Java的浏览器,请将on改成off
# If your visitors can't handle Java, better set this to 'off'.


= http://linux.cqi.com.cn/~elvis/search/search.gif';
#这里输入search.gif的连结路径(URL)
# The URL of the E3 picture.


= http://linux.cqi.com.cn/~elvis/search/search.cgi';
#这里输入search.cgi的执行路径
# Change this to the full URL only if your rename this script.


# This array holds info on all the directories and filetypes you'd like
# your visitors to search. Visit the readme file for more customizing
# information.



# Options for Weighted Search:
#
# All occurrences of a search term count as one point. The occurrence
# of a term in the filename, title, META keywords, or META description
# can have added weight (equivalent to a multiplier per hit). Enter
# the multipliers in the array below - the defaults are (2,2,4,2). If
# this makes no sense to you, just ignore it and leave the defaults as
# they are - they work pretty well. Note that this will give extra
# weight to those pages that have a properly formatted title and META
# tags, even if they contain the same basic information.


(, , , ) = (2,2,4,2);
# No further editing is necessary, but feel free to play around...
# Note that much of the code below is straight HTML, and very easy to
# modify if you know a little about HTML programming.
#
# __________________________________________________________________




read(STDIN,,{ 'CONTENT_LENGTH' });
@pairs = split(/&/,);
foreach (@pairs)
{
(,) = split(/=/,);
=~ tr/ / /;
=~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
{ } = ;
}



if ({ 'terms' })
{
&get_files;
&search;
&return_html;
}
else
{
&prompt;
}



sub prompt
{
print "Content-type: text/html\n\n";
print <

Oh Yeah Net 全文搜索





BORDER=1 ALT="Picture of Search Aircraft (trying to build a theme)">
请输入关键字在本站内搜寻您要的资料,或是阅读
搜寻秘诀







EOM


if ( eq 'on')
{
print "

推荐文章