⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 search.cgi

📁 绿叶网络小学校园网-完全适合小学的网站
💻 CGI
📖 第 1 页 / 共 2 页
字号:
#!/usr/bin/perl

#############################################################
# Ikonboard v2.1
# Copyright 2000 Ikondiscussion.com - All Rights Reserved
# Ikondiscussion is a trademark of Ikondiscussion.com
#
# Software Distributed by: Ikondiscussion.com
# Visit us online at http://www.ikondiscussion.com
# Email us on boards@ikondiscussion.com
#
# All files written by Matthew Mecham
#############################################################

#use CGI::Carp "fatalsToBrowser";          # Output errors to browser
use CGI qw(:standard);                    # Saves loads of work
$CGI::POST_MAX=1024 * 150;                # limit post data
$CGI::DISABLE_UPLOADS = 1;                # Disable uploads
$CGI::HEADERS_ONCE = 1;                   # Kill redundant headers

eval {
($0 =~ m,(.*)/[^/]+,)   && unshift (@INC, "$1");
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1");
require "ikon.lib";          # Require ikonboard ()
require "data/progs.cgi";    # Require prog names
require "data/boardinfo.cgi";# Require board info
require "data/styles.cgi";   # Require styles info
};
if ($@) {
    print header(-charset=>"gb2312"); print start_html(-title=>"ib2000 出错!");
    print "不能够找到文件:$@\n如果您使用的是 Windows 类操作系统,请在每一个程序中更改 require 的设置,填入绝对路径!";
    print end_html; exit;
}

$|++;                                     # Unbuffer the output

#################--- Begin the program ---###################

$thisprog = "search.cgi";

$query = new CGI;

## Patched by Peter

for ('TYPE_OF_SEARCH','NAME_SEARCH','POST_SEARCH','FORUMS_TO_SEARCH','action', 
	'SEARCH_STRING','REFINE_SEARCH','CUR_TIME','nextforum') {
    next unless defined $_;
    next if $_ eq 'SEND_MAIL';
    $tp = $query->param($_);
    $tp = &unHTML("$tp");
    ${$_} = $tp;
    }

$ipaddress        = $ENV{'REMOTE_ADDR'};
$inmembername     = cookie("amembernamecookie");
$filename = $inmembername;

if (!$filename) {
    $filename = "客人$ipaddress";
    $filename =~ s/\.//g;
    }
    
$filename =~ y/ /_/;
$filename = "$filename" . "_sch.txt";

$searchfilename = "$ikondir" . "search/$filename";

$dirtoopen = "$ikondir" . "search";
opendir(DIR, "$dirtoopen");
while ($file = readdir(DIR)) {
	if ((stat("$dirtoopen/$file"))[9] < (time - 30*60)) {  
    unlink("$dirtoopen/$file");
	}
}
closedir(DIR);

print header(-charset=>"gb2312");

&title;

    $output .= qq~
    <p>
    <table cellpadding=0 cellspacing=0 border=0 width=$tablewidth align=center>
        <tr>
            <td width=30% rowspan=2 valign=top>
            <img src="$imagesurl/images/$boardlogo" border=0>
            </td>
            <td valign=top align=left>
            <font face="$font" color=$fontcolormisc>
	           &nbsp;&nbsp;<img src="$imagesurl/images/closedfold.gif" border=0>&nbsp;&nbsp;<a href="$forumsummaryprog">$boardname</a>
	           <br>
            &nbsp;&nbsp;<img src="$imagesurl/images/bar.gif" border=0><img src="$imagesurl/images/openfold.gif" border=0>&nbsp;&nbsp;贴子搜索
            </td>
            </tr>
       </table>
    <p>
    <table cellpadding=0 cellspacing=0 border=0 width=$tablewidth bgcolor=$tablebordercolor align=center>
    <tr><td>
    <table cellpadding=8 cellspacing=1 border=0 width=100%>
    ~;




# Do we have a search folder?

if (!-d "$dirtoopen") {
    mkdir("$dirtoopen", 0777) or die "程序不能建立搜索目录,请使用 FTP 在 cgi-bin 中的 ib2000 下建立一个 search 目录!";
    chmod(0777, "$dirtoopen");
    }

&whosonline("$inmembername|搜索|none|搜索符合要求的贴子|");

if ($action eq "startsearch") {

    $SEARCH_STRING =~ s/\, /\,/g;

    if ($TYPE_OF_SEARCH eq "username_search") {
        $REFINE_SEARCH = "$NAME_SEARCH";
        }
        else {
            $REFINE_SEARCH = "$POST_SEARCH";
            }
        

    open (SEARCH, ">$searchfilename") or die "不能够保存到 search 目录,请设置此目录为 777 !";
    print SEARCH "$CUR_TIME\n";
    print SEARCH "$SEARCH_STRING\n";
    print SEARCH "$TYPE_OF_SEARCH\n";
    print SEARCH "$REFINE_SEARCH\n";
    print SEARCH "$FORUMS_TO_SEARCH\n";
    close (SEARCH);
    
    $relocurl = "$boardurl/$thisprog?action=continue";
        
        $output .= qq~
            <tr>
            <td bgcolor=$miscbacktwo valign=middle align=center><font face="$font" color=$fontcolormisc><b>搜索中....</b></font></td></tr>
            <tr>
            <td bgcolor=$miscbackone valign=middle><font face="$font" color=$fontcolormisc>
            请等待程序完成搜索。<br>
            <b>当前搜索情况:</b>
            <ul>
            <li>搜索情况....
            </ul>
            </tr>
            </td>
            </table></td></tr></table>
            <meta http-equiv="refresh" content="2; url=$relocurl">
            ~;
            
    }

    elsif ($action eq "display") {
         &displayresults;
         }

    elsif ($action eq "continue") {

        &getmember($inmembername);

        # Grab the params

        open (INSEARCH, "$searchfilename");
        @searchparam = <INSEARCH>;
        close (INSEARCH);

        my $SEARCH_STRING    = $searchparam[1];
        chomp $SEARCH_STRING;
        my $TYPE_OF_SEARCH   = $searchparam[2];
        chomp $TYPE_OF_SEARCH;
        my $REFINE_SEARCH    = $searchparam[3];
        chomp $REFINE_SEARCH;
        my $FORUMS_TO_SEARCH = $searchparam[4];
        chomp $FORUMS_TO_SEARCH;

        
        @KEYWORDS = split(/\,/,$SEARCH_STRING);

        $filetoopen = "$ikondir" . "data/allforums.cgi";
        open(FILE, "$filetoopen");
        flock(FILE, 2) if ($OS_USED eq "Unix");
        @forums = <FILE>;
        close(FILE);

        @checkforums = @forums;
        @checkforums = reverse(@checkforums);

        $search_in_forum = $FORUMS_TO_SEARCH;

        if ($FORUMS_TO_SEARCH eq "all") {
            $nextforum++;
            $search_in_forum = $nextforum;
            ($forumno, $trash) = split(/\|/,$checkforums[0]);
            
            if ("$search_in_forum" > "$forumno") { $nofile="true"; $FORUMS_TO_SEARCH = "done"; }
            }
            
       
        foreach $forum (@forums) { #start foreach @forums
            chomp $forum;
            ($tempforumno, $trash) = split(/\|/,$forum);
            if ($tempforumno eq $search_in_forum) { #1
                ($forumid, $category, $categoryplace, $forumname, $forumdescription, $forummoderator ,$htmlstate ,$idmbcodestate ,$privateforum) = split(/\|/,$forum);
                $nofile = "true" if (($privateforum eq "yes") && ($allowedentry{$forumid} ne "yes") &&($membercode ne "ad"));
                } #e1
               else { next; }   
            } # end foreach @allforums
            

            $filetoopen = "$ikondir" . "forum$forumid/list.cgi";
            open(FILE, "$filetoopen") or $nofile = "true";
            @topics = <FILE>;
            close(FILE);

            if ($nofile ne "true") { #start nofile
            foreach $topic (@topics) { # start topic foreach
                chomp $topic;
                ($topicid, $topictitle, $topicdescription, $threadstate, $threadposts, $threadviews, $startedby, $startedpostdate, $lastposter, $lastpostdate) = split(/\|/,$topic);
        
                if ($TYPE_OF_SEARCH eq "keyword_search") {

                    if ($REFINE_SEARCH eq "both_search" || $REFINE_SEARCH eq "topictitle_search") { #1
                        foreach (@KEYWORDS) { #new1
                            if (($topictitle =~ m|$_|gi)  and ("$lida" ne "$topicid")) { #2
                                $founditem = ("$forumid|$topicid|$topictitle|$topicdescription|$forumname|$startedpostdate|找到关键字: <B>$_</B>");
                                push (@founditems, $founditem);
                                $lida = $topicid;
                                } #e2
                             }
                        } #e1

                            if (($REFINE_SEARCH eq "both_search") or ($REFINE_SEARCH eq "post_search")) { # 1
                                $filetoopen = "$ikondir" . "forum$forumid/$topicid.thd";
                                open (THREAD, "$filetoopen") or next;
                                @thddata = <THREAD>;
                                close (THREAD);

                                foreach (@thddata) { # start foreach 'thd'
                                    ($membername, $topictitle, $postipaddress, $showemoticons, $showsignature, $postdate, $post, $posticon) = split(/\|/,$_);
                                    foreach (@KEYWORDS) { #new1
                                    if (($post =~ m|$_|gi) and ("$lida" ne "$topicid")) { # s 'if' n1
                                        $founditem = ("$forumid|$topicid|$topictitle|$topicdescription|$forumname|$postdate|找到 <B>$_</B> 处");
                                        push (@founditems, $founditem);
                                        $lida = $topicid;
                                        } # e 'if' n1
                                      }
                                    } # end foreach 'thd'
                            } # e1
                    } # END MAIN IF 'keyword_search'
                    
                    elsif ($TYPE_OF_SEARCH eq "username_search") {

                        if ($REFINE_SEARCH eq "both_search" || $REFINE_SEARCH eq "topictitle_search") { #1
                            foreach (@KEYWORDS) { #new1
                            if (($startedby =~ m|$_|gi) and ("$lidc" ne "$topicid")) { #2
                                $founditem = ("$forumid|$topicid|$topictitle|$topicdescription|$forumname|$startedpostdate|主题作者: <B>$membername</B>");
                                push (@founditems, $founditem);
                                $lidc = $topicid;
                                } #e2
                               }
                            } #e1

                                if ($REFINE_SEARCH eq "both_search" || $REFINE_SEARCH eq "post_search") { # 1
                                    $filetoopen = "$ikondir" . "forum$forumid/$topicid.thd";
                                    open (THREAD, "$filetoopen") or next;
                                    @thddata = <THREAD>;
                                    close (THREAD);

                                    foreach (@thddata) { # start foreach 'thd'
                                        ($membername, $topictitle, $postipaddress, $showemoticons, $showsignature, $postdate, $post, $posticon) = split(/\|/,$_);
                                        foreach (@KEYWORDS) { #new1
                                        if (($membername =~ m|$_|gi) and ($lidc != $topicid)) { # s 'if' n1
                                            $founditem = ("$forumid|$topicid|$topictitle|$topicdescription|$forumname|$postdate|回复人: <B>$membername</B>");
                                            push (@founditems, $founditem);
                                            $lidc = $topicid;
                                            } # e 'if' n1
                                          }
                                        } # end foreach 'thd'
                                } # e1
                        } # END MAIN ELSIF 'username_search'
                    
                     } # end main foreach list loop

                    # What do we do next? First push all the data to the text file

                        $matches_in_forum = @founditems;
                        $matches_so_far   = @searchparam - 5;

                        open (OUT, ">>$searchfilename") or die "不能够保存到 search 目录,请设置此目录为 777 !";
                        foreach (@founditems) {
                            chomp $_;
                            print OUT "$_\n";
                            }
                        close (OUT);
                    
                    undef @founditems;
                    undef @KEYWORDS;
                    } # end if no file
                    
                    # Then work out where to go

                    if ($FORUMS_TO_SEARCH eq "all") {
                        $relocurl = "$boardurl/$thisprog?action=continue&nextforum=$search_in_forum";
                        }
                        else {
                            $relocurl = "$boardurl/$thisprog?action=display";
                            }

                  if (!$matches_in_forum) {
                  	$matches_in_forum = "处理中...";
                  }
                  else {
                  	$matches_in_forums = " 次" if ($matches_in_forum);
                  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -