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

📄 news.cgi

📁 一个linux论坛
💻 CGI
字号:
#!/usr/bin/perl
###############################################################################################################################################
# LB5000 分论坛新贴子 ver 1.9
# 程序编制: 山鹰糊  webmaster@cgier.com
# 版权所有: CGI 编程者之家  http://www.CGIer.com  http://www.LeoBoard.com
###############################################################################################################################################
# 使用办法: news.cgi?forum=分论坛号&max=显示几条贴子&maxlength=标题长度&display=1&link=颜色16进制代码&vlink=颜色16进制代码&alink=颜色16进制代码
# 例: 在你主页的适当位置加入以下语句
#      <script src="news.cgi?forum=1&max=10&maxlength=20&link=0000ff&vlink=7f007f&alink=ff0000&mode=topic"></script>
#      这样就可以在相应位置显示1号论坛的最新10个贴子,标题长度为 20,显示发贴时间,用帖子模式查看
#                                                   (display=0 表示不显示发贴时间)
#                                                   (mode=view 表示用新闻模式查看)
# link是自定义超链接的颜色,vlink是自定义已访问的超链接的颜色,alink是自定义当前超链接的颜色
#
# 所有参数均可以省略,默认为查看第1个论坛的前10个帖子,标题最多20个字符、显示时间、用帖子模式
###############################################################################################################################################
BEGIN {
    $LBPATH = '.';
    my $pgm = $0;
    $pgm =~s/\\/\//g;
    $pgm =~s/^.*\/([^\/]+)$/$1/g;
    unless (-e $LBPATH.'/'.$pgm) {
        foreach ($0, $ENV{'SCRIPT_FILENAME'}, $ENV{'PATH_TRANSLATED'}) {
            s!\\!/!g; s/^(.*)\/[^\/]+$/$1/g;
            if (-e $_ . '/' .$pgm) { $LBPATH = $_; last; }
        }
    }
    unshift (@INC, "$LBPATH");
}
#unless ($ENV{'HTTP_REFERER'} =~ /$ENV{'HTTP_HOST'}/) {
#print "Content-Type:text/html\n\n";
#print "document.write('<font color=red> 对不起,不允许非本论坛主机调用!</font>');";
#exit;
#}
use LBCGI;
$LBCGI::POST_MAX=2000;
$LBCGI::DISABLE_UPLOADS = 1;
$LBCGI::HEADERS_ONCE = 1;
require "data/boardinfo.cgi";
require "data/styles.cgi";
require "lb.lib.pl";

$|++;
$query = new LBCGI;
$number        = $query -> param('forum');
$number        = &stripMETA("$number");
$max	       = $query -> param('max');
$max           = &stripMETA("$max");
$display       = $query -> param('display');
$display       = &stripMETA("$display");
$maxlengths    = $query -> param('maxlength');
$maxlengths    = &stripMETA("$maxlengths");
$link	       = $query -> param('link');
$link          = &stripMETA("$link");
$alink	       = $query -> param('alink');
$alink         = &stripMETA("$alink");
$vlink	       = $query -> param('vlink');
$vlink         = &stripMETA("$vlink");
$mode       = $query -> param('mode');
$mode       = &stripMETA("$mode");
$mode = "" if (($mode ne "topic")&&($mode ne "view"));
$mode      = "topic" if ($mode eq "");  # 默认帖子方式查看
$number    = 1  if ($number eq "");     # 默认查看第一个论坛
$display   = 1  if ($display eq "");    # 默认显示贴子时间
$max	   = 10 if ($max eq "");        # 默认显示 10 个帖子
$maxlengths= 30 if ($maxlengths eq "");  # 默认标题最多 30 个字符
print header(-charset=>gb2312);
if ($number !~ /^[0-9]+$/) {
   print "document.write('普通&老大,别乱黑我的程序呀!')\n";
   exit;
}
    my $filetoopen = "${lbdir}forum$number/foruminfo.cgi";
    open(FILE, "$filetoopen");
    my $forums = <FILE>;
    close(FILE);
    (my $no, $no, $no, $no, $no, $no ,$no ,$no ,$privateforum, $no) = split(/\t/,$forums);

if ($privateforum ne "yes") {
    $filetoopen = "$lbdir" . "boarddata/list$number.cgi";
    if (-e $filetoopen) {
	&winlock($filetoopen) if (($OS_USED eq "Unix")||($OS_USED eq "Nt"));
        open(FILE, "$filetoopen");
	flock (FILE, 1) if ($OS_USED eq "Unix");
        @topics = <FILE>;
        close(FILE);
	&winunlock($filetoopen) if (($OS_USED eq "Unix")||($OS_USED eq "Nt"));
        $topics = @topics;
        $max = $topics if ($topics<$max);
    
        $max--;
        undef $str;
        $addtime = $timedifferencevalue*3600 + $timezone*3600;
        foreach $topic (@topics[0 ... $max]) {
	    chomp $topic;
            $maxlength = $maxlengths;
            ($topicid, $topictitle, $topicdescription, $threadstate, $threadposts, $threadviews, $startedby, $startedpostdate, $lastposter, $lastpostdate, $posticon1) = split(/\t/,$topic);
            next if ($topicid !~ /^[0-9]+$/);
            $lastpostdate = &longdate($lastpostdate + $addtime);
 	    $topictitle =~ s/^*#!&*//;
 	    
            if (($posticon1 eq "")||($posticon1 !~ /^[0-9]+$/)) {
		$posticon1 = int(rand(23));
		if ($posticon1 <10 ) {$posticon1="0$posticon1.gif"};
                if ($posticon1 > 9 ) {$posticon1="$posticon1.gif"};
            }

	    if (($dofilter eq "no")||($dofilter eq "all")) {
	        $topictitle = &postwordfilter("$topictitle");
	    }
	    $topictitle = &cleanarea("$topictitle");
 	    $topictitle =~ s/\'/\`/g;
            $topictitle =~ s/\&amp;/\&/g;
	    $topictitle =~ s/\&quot;/\"/g;
#	    $topictitle =~ s/\&lt;/</g;
#	    $topictitle =~ s/\&gt;/>/g;
	    $topictitle =~ s/ \&nbsp;/ /g;
	    $topictitle =~ s/  / /g;
	    if  ($display eq 1) {
	        $disptime= " $lastpostdate";
	    }
	    else { undef $disptime; }
	    if (length($topictitle)>$maxlength) {
	        $topictitletemp=&lbhz("$topictitle",$maxlength); 
                $topictitletemp =~ s/\&/\&amp;/g;
	        $topictitletemp =~ s/\"/\&quot;/g;
                $topictitletemp =~ s/</\&lt;/g;
	        $topictitletemp =~ s/>/\&gt;/g;
	        $topictitletemp =~ s/ /\&nbsp;/g;
	        $topictitletemp = $topictitletemp ."&nbsp;" if (length($topictitletemp) < $maxlength);
	        $str.="<img src=$imagesurl/posticons/$posticon1 border=0> <a href=$boardurl/$mode.cgi?forum=$number&topic=$topicid target=_blank><ACRONYM TITLE=\"主题: $topictitle\">$topictitletemp</ACRONYM></a>$disptime<br>";
	    }
	    else {
	        $topicspace=$maxlength-length($topictitle);
	        $topictitle =~ s/ /\&nbsp;/g;
	        $addspace = "";
	        for ($i=0;$i<$topicspace;$i++) {
	     	    $addspace = $addspace ."&nbsp;";
	        }
	        $str.="<img src=$imagesurl/posticons/$posticon1 border=0> <a href=$boardurl/$mode.cgi?forum=$number&topic=$topicid target=_blank>$topictitle</a>$addspace$disptime<br>";
	    }
        }
    }
    else {
        $str="-* 没有找到相应的论坛 *-";
    }
}
else {
    $str="-* 这是保密论坛 *-";
}
print "document.write('<span LINK=#$link VLINK=#$vlink ALINK=#$alink>$str')\n";
exit;

⌨️ 快捷键说明

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