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

📄 search.cgi

📁 一个linux论坛
💻 CGI
📖 第 1 页 / 共 3 页
字号:
       $nextforum++; 
       if ($nextforum >= $checkforums) { $FORUMS_TO_SEARCH = "done"; } 
   }else{
       $search_in_forum = $FORUMS_TO_SEARCH;$FORUMS_TO_SEARCH = "done";
   }
   my $filetoopen = "${lbdir}forum$search_in_forum/foruminfo.cgi";
   if(-e $filetoopen){
   &getoneforum($search_in_forum);
   $nofile = "true" if (($privateforum eq "yes") && ($allowedentry{$search_in_forum} ne "yes") &&($membercode ne "ad")&&($membercode ne 'smo'));
   }else{
   $nofile = "true";
   }

    open(FILE, "${lbdir}boarddata/list$forumid.cgi") or $nofile = "true";
    @topics = <FILE>;
    close(FILE);

    if ($JH_SEARCH eq "jinghua") {
	@check=@topics;@topics=();
        open(FILE, "${lbdir}boarddata/jinghua$forumid.cgi") or $nofile = "true";
        @jinghuas = <FILE>;
        close(FILE);
        $jhdata = join("\_",@jinghuas);
        $jhdata = "\_$jhdata\_";
        $jhdata =~ s/\W//isg;
        if ($nofile ne "true") {
            foreach (@check) {
                chomp $_;
                my ($topicid, $slash) = split(/\t/,$_);
       		push(@topics,$_) if ($jhdata =~ /\_$topicid\_/);
            }
        }
    }

    elsif ($JH_SEARCH eq "recycle") {
	@check=@topics;@topics=();
        open(FILE, "${lbdir}boarddata/recycletopic$forumid.cgi") or $nofile = "true";
        @recycles = <FILE>;
        close(FILE);
        $recycledata = join("\_",@recycles);
        $recycledata = "\_$recycledata\_";
        $recycledata =~ s/\W//isg;
        if ($nofile ne "true") {
            foreach (@check) {
                chomp $_;
                my ($topicid, $slash) = split(/\t/,$_);
	        push(@topics,$_) if ($recycledata =~ /\_$topicid\_/);
            }
	}
    }

    elsif ($JH_SEARCH eq "poll") {
	@check=@topics;@topics=();
        $filetoopen = "$lbdir" . "boarddata/list$forumid.cgi";
        if (-e $filetoopen) {
    	    &winlock($filetoopen) if (($OS_USED eq "Nt")||($OS_USED eq "Unix"));
            open(FILE, "$filetoopen");
            flock(FILE, 1) if ($OS_USED eq "Unix");
            @jinghuas = <FILE>;
            close(FILE);
            &winunlock($filetoopen) if (($OS_USED eq "Nt")||($OS_USED eq "Unix"));
        }
        foreach $topic (@check) {
	    chomp $topic;
            ($topicid,$no,$no, $threadstate,$no,$no,$no,$no, $no,$no, $no, $no, $no, $no) = split(/\t/,$topic);
	    next if (($topicid eq "")||($topicid !~ /^[0-9]+$/));
	    push(@topics,$topic) if (($threadstate eq "poll")||($threadstate eq "pollclosed"));
	}
    }

    elsif($JH_SEARCH eq "lock") {
	@check=@topics;@topics=();
        $filetoopen = "$lbdir" . "boarddata/list$forumid.cgi";
        if (-e $filetoopen) {
    	    &winlock($filetoopen) if (($OS_USED eq "Nt")||($OS_USED eq "Unix"));
            open(FILE, "$filetoopen");
            flock(FILE, 1) if ($OS_USED eq "Unix");
            @jinghuas = <FILE>;
            close(FILE);
            &winunlock($filetoopen) if (($OS_USED eq "Nt")||($OS_USED eq "Unix"));
        }
        foreach $topic (@check) {
	    chomp $topic;
            ($topicid,$no,$no, $threadstate,$no,$no,$no,$no, $no,$no, $no, $no, $no, $no) = split(/\t/,$topic);
	    next if (($topicid eq "")||($topicid !~ /^[0-9]+$/));
	    push(@topics,$topic) if (($threadstate eq "closed")||($threadstate eq "pollclosed"));
	}
    }

    elsif ($JH_SEARCH eq "hot") {
	@check=@topics;@topics=();

        $filetoopen = "$lbdir" . "boarddata/list$forumid.cgi";
        if (-e $filetoopen) {
    	    &winlock($filetoopen) if (($OS_USED eq "Nt")||($OS_USED eq "Unix"));
            open(FILE, "$filetoopen");
            flock(FILE, 1) if ($OS_USED eq "Unix");
            @jinghuas = <FILE>;
            close(FILE);
            &winunlock($filetoopen) if (($OS_USED eq "Nt")||($OS_USED eq "Unix"));
        }
        foreach $topic (@check) {
	    chomp $topic;
            ($topicid,$no,$no,$threadstate,$threadposts,$no,$no,$no, $no,$no, $no, $no, $no, $no) = split(/\t/,$topic);
	    next if (($topicid eq "")||($topicid !~ /^[0-9]+$/));
	    if (($threadstate eq "poll")||($threadstate eq "pollclosed")) {
       	        $size = 0;
		if (open(FILE, "${lbdir}forum$inforum/$topicid.poll.cgi")) {
	    	    my @allpoll = <FILE>;
              	    close(FILE);
	            $size = @allpoll;
                }
	    	if ($size > 18) { push(@topics,$topic); }
	    }
	    elsif ($threadposts > 20) { push(@topics,$topic); }
	}
    }

    elsif ($JH_SEARCH eq "top") {
	@check=@topics;@topics=();
        $filetoopen = "$lbdir" . "boarddata/ontop$forumid.cgi";
        open(FILE, "$filetoopen") or $nofile = "true";
        @ontops = <FILE>;
        close(FILE);
        $ontopdata = join("\_",@ontops);
        $ontopdata = "\_$ontopdata\_";
        $ontopdata =~ s/\W//isg;
        if ($nofile ne "true") {
            foreach (@check) {
                chomp $_;
                ($topicid, $slash) = split(/\t/,$_);
	        push(@topics,$_) if ($ontopdata =~ /\_$topicid\_/);
            }
        }
    }

    if ($nofile ne "true") { #start nofile
	foreach $topic (@topics) { # start topic foreach
            chomp $topic;
            ($topicid, $topictitle, $topicdescription, $threadstate, $threadposts, $threadviews, $startedby, $startedpostdate, $lastposter, $lastpostdate,$lastposticon,$lastposttemp,$topicvalue,$water) = split(/\t/,$topic);
	    $topictitle =~ s/^*#!&*//;
if($DAY_TO_SEARCH ne "any"){
if($TIME_TO_SEARCH eq "b"){
next if(time-$lastpostdate < (86400*$DAY_TO_SEARCH));
}elsif($TIME_TO_SEARCH eq "f"){
next if(time-$lastpostdate > (86400*$DAY_TO_SEARCH));
}
}

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

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

                    foreach (@thddata) {
                        ($membername, $topictitle, $postipaddress, $showemoticons, $showsignature, $postdate, $post, $posticon,$topicvalue,$water) = split(/\t/,$_);
                        foreach (@KEYWORDS) {
                            if (($post =~ m|$_|gi) and ("$lida" ne "$topicid")) {
                                $founditem = ("$forumid\t$topicid\t$topictitle\t$topicdescription\t$forumname\t$postdate\t找到 <B>$_</B> 处");
                                push (@founditems, $founditem);
                                $lida = $topicid;
                            }
                        }
                    }
                }
            } # END MAIN IF 'keyword_search'
            elsif ($TYPE_OF_SEARCH eq "username_search") {
                if ($REFINE_SEARCH eq "both_search" || $REFINE_SEARCH eq "topictitle_search") {
                    foreach (@KEYWORDS) {
                        if (($startedby =~ m|$_|gi) and ("$lidc" ne "$topicid")) {
                            $founditem = ("$forumid\t$topicid\t$topictitle\t$topicdescription\t$forumname\t$startedpostdate\t主题作者: <B>$_</B>");
                            push (@founditems, $founditem);
                            $lidc = $topicid;
                        }
                    }
                }

                if ($REFINE_SEARCH eq "both_search" || $REFINE_SEARCH eq "post_search") {
                    $filetoopen = "$lbdir" . "forum$forumid/$topicid.thd.cgi";
                    open (THREAD, "$filetoopen") or next;
                    @thddata = <THREAD>;
                    close (THREAD);
		    $toptttt = 0;
                    foreach (@thddata) {
			$toptttt++;
			next if ($toptttt == 1);
                        ($membername, $topictitle, $postipaddress, $showemoticons, $showsignature, $postdate, $post, $posticon,$topicvalue,$water) = split(/\t/,$_);
                        foreach (@KEYWORDS) {
                            if (($membername =~ m|$_|gi) and ($lidc != $topicid)) { # s 'if' n1
                                $founditem = ("$forumid\t$topicid\t$topictitle\t$topicdescription\t$forumname\t$postdate\t回复人: <B>$membername</B>");
                                push (@founditems, $founditem);
                                $lidc = $topicid;
                            }
                        }
			$toptttt++;
                    }
                }
            } # 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");
        foreach (@founditems) {
            chomp $_;
            print OUT "$_\n";
        }
        close (OUT);
        undef @founditems;
        undef @KEYWORDS;
    } # end if no file

    if ($FORUMS_TO_SEARCH ne "done") { 
        $relocurl = "$thisprog?action=continue&nextforum=$nextforum"; 
    } 
    else {
        $relocurl = "$thisprog?action=display";
    }

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

    $matches_so_far   = "处理中..." if (!$matches_so_far);
    $forumname        = "处理中..." if (!$forumname);

    $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>详细情况....<BR>
<li>搜索论坛: <b>$forumname</b>
<li>搜索结果: <b>$matches_so_far</b>
<li>匹配符合: <b>$matches_in_forum</b>$matches_in_forums

⌨️ 快捷键说明

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