📄 lb.lib.pl
字号:
return $text;
}
sub unclean {
my $text = shift;
$text =~ s/\&/\&/g;
$text =~ s/\"/"/g;
$text =~ s/ \ / /g;
return $text;
}
sub unHTML {
my $text = shift;
$text =~ s/<!--(.|\n)*-->//g;
$text =~ s/\&/\&/g;
$text =~ s/<script>/\<script\>/ig;
$text =~ s/"/\"/g;
$text =~ s/ / \ /g;
$text =~ s/</\</g;
$text =~ s/>/\>/g;
$text =~ s/[\a\f\e\0\r\t]//isg;
$text =~ s/document.cookie/documents\&\#46\;cookie/isg;
return $text;
}
sub HTML {
my $text = shift;
$text =~ s/\&/\&/g;
$text =~ s/\"/"/g;
$text =~ s/ \ / /g;
$text =~ s/\</</g;
$text =~ s/\>/>/g;
$text =~ s/documents\&\#46\;cookie/document.cookie/isg;
return $text;
}
sub cleanarea {
my $text = shift;
study($text);
$text =~ s/\ / /g;
$text =~ s/\@ARGV/\&\#64\;ARGV/isg;
$text =~ s/\;/\&\#59\;/isg;
$text =~ s/\&/\&/g;
$text =~ s/\&\#/\&\#/isg;
$text =~ s/\&\;(.{1,6})\&\#59\;/\&$1\;/isg;
$text =~ s/\&\#([0-9]{1,6})\&\#59\;/\&\#$1\;/isg;
$text =~ s/"/\"/g;
$text =~ s/ / \ /g;
$text =~ s/</\</g;
$text =~ s/>/\>/g;
$text =~ s/[\a\f\e\0\r\t]//isg;
$text =~ s/ / /g;
$text =~ s/\n\n/<p>/g;
$text =~ s/\n/<br>/g;
$text =~ s/<script>/\<script\>/ig;
$text =~ s/document.cookie/documents\&\#46\;cookie/isg;
return $text;
# my $text = shift;
# study($text);
# $text =~ s/<!--(.|\n)*-->//g;
# $text =~ s/\&/\&/g;
# $text =~ s/<script>/\<script\>/ig;
# $text =~ s/"/\"/g;
# $text =~ s/ / \ /g;
# $text =~ s/</\</g;
# $text =~ s/>/\>/g;
# $text =~ s/[\a\f\e\0\r\t]//g;
# $text =~ s/ / /g;
# $text =~ s/\n\n/<p>/g;
# $text =~ s/\n/<br>/g;
# $text =~ s/document.cookie/documents\&\#46\;cookie/isg;
# return $text;
}
sub stripMETA {
my $file = shift;
$file =~ s/[<>\^\(\)\{\}\a\f\n\e\0\r\"\`\&\;\|\*\?]//g;
return $file;
}
sub dateformat {
my $time = shift;
(my $sec,my $min,my $hour,my $mday,my $mon,my $year,my $wday,my $yday,my $isdst) = localtime($time);
my @months = ('01','02','03','04','05','06','07','08','09','10','11','12');
$mon = $months[$mon];
my $ampm = "am";
if ($hour > 11) { $ampm = "pm"; }
if ($hour > 12) { $hour = $hour - 12; }
if ($hour < 10) { $hour = "0$hour"; }
if ($min < 10) { $min = "0$min"; }
if ($sec < 10) { $sec = "0$sec"; }
if ($mday < 10) { $mday = "0$mday"; }
$year = $year + 1900;
return "$year/$mon/$mday $hour:$min$ampm";
}
sub dateformatshort {
my $time = shift;
(my $sec,my $min,my $hour,my $mday,my $mon,my $year,my $wday,my $yday,my $isdst) = localtime($time);
my @months = ('01','02','03','04','05','06','07','08','09','10','11','12');
$mon = $months[$mon];
if ($hour < 10) { $hour = "0$hour"; }
if ($mday < 10) { $mday = "0$mday"; }
if ($min < 10) { $min = "0$min"; }
if ($sec < 10) { $sec = "0$sec"; }
$year = $year + 1900;
return "$year/$mon/$mday $hour:$min";
}
sub fulldatetime {
my $time = shift;
(my $sec,my $min,my $hour,my $mday,my $mon,my $year,my $wday,my $yday,my $isdst) = localtime($time);
my @months = ('01','02','03','04','05','06','07','08','09','10','11','12');
$year = $year + 1900;
if ($mday < 10) { $mday = "0$mday"; }
my $ampm = "am";
if ($hour > 11) { $ampm = "pm"; }
if ($hour > 12) { $hour = $hour - 12; }
if ($hour < 10) { $hour = "0$hour"; }
if ($min < 10) { $min = "0$min"; }
if ($sec < 10) { $sec = "0$sec"; }
return "$year年$months[$mon]月$mday日 $hour:$min$ampm";
}
sub longdate {
my $time = shift;
(my $sec,my $min,my $hour,my $mday,my $mon,my $year,my $wday,my $yday,my $isdst) = localtime($time);
my @months = ('01','02','03','04','05','06','07','08','09','10','11','12');
$year = $year + 1900;
if ($mday < 10) { $mday = "0$mday"; }
return "$year年$months[$mon]月$mday日";
}
sub shortdate {
my $time = shift;
(my $sec,my $min,my $hour,my $mday,my $mon,my $year,my $wday,my $yday,my $isdst) = localtime($time);
$mon++;
if ($mon < 10) { $mon = "0$mon"; }
if ($mday < 10) { $mday = "0$mday"; }
$year = $year + 1900;
return "$year/$mon/$mday";
}
sub shorttime {
my $time = shift;
(my $sec,my $min,my $hour,my $mday,my $mon,my $year,my $wday,my $yday,my $isdst) = localtime($time);
my $ampm = "am";
if ($hour > 11) { $ampm = "pm"; }
if ($hour > 12) { $hour = $hour - 12; }
if ($hour < 10) { $hour = "0$hour"; }
if ($min < 10) { $min = "0$min"; }
if ($sec < 10) { $sec = "0$sec"; }
return "$hour:$min$ampm";
}
sub output {
my %args = ( -Title => "", -ToPrint => "", -Version => "", @_, );
my $title = $args{-Title};
$title =~ s/\$/\&\#036\;/sg;
my $output = $args{-ToPrint};
my $versionnumber = $args{-Version};
my $filetoopen = "$lbdir" . "data/template.cgi";
open(FILE,"$filetoopen");
my $templatedata=join('',<FILE>);
close(FILE);
study($templatedata);
my $boardcopyright;
my $copyright;
if ($versionnumber ne "msg") {
$boardcopyright = qq(©\; $copyrightinfo) if $copyrightinfo;
$boardcopyright =~ s/</</g; $boardcopyright =~ s/>/>/g; $boardcopyright =~ s/"/\"/g;
$copyright = qq~<center>~;
if (($thisprog eq "topic.cgi")||($thisprog eq "forums.cgi")) {
if ($useadfoot ne 0) {
$adfoot = &HTML("$adfoot");
$adfoot =~ s/\$imagesurl/$imagesurl/isg;
}
else { $adfoot =""; }
$copyright .= $adfoot;
}
$copyright .= qq~<hr width=380 size=1><table width=80% align=center cellpadding=0 cellspacing=0><tr><td align=center>~;
$boardlastinfo =qq~<BR>本论坛言论纯属发表者个人意见,与<font color=$fonthighlight><b> $boardname </b></font>立场无关<br>~ if ($dispboardsm ne "no");
$copyright .= qq~<font color=$fontcolormisc>$boardcopyright 版本: <a href="http://www.leoboard.com/cgi-bin/lbdown.cgi" title="按此可以下载最新版本的雷傲超级论坛">$versionnumber</a><BR><font color=$postfontcolorone>程序版权所有: <a href="http://www.cgier.com" target=_blank>CGI 编程者之家</a> 程序编制: <a href="mailto:htc\@263.net">山鹰(糊)</a>、 <a href="mailto:info\@cgier.net">花无缺</a></font><BR><img src=$imagesurl/images/none.gif width=0 height=3>$boardlastinfo</font></td></tr></table></center>\n~;
}
else { undef $copyright; }
$templatedata=~ s/\$lbbody/$lbbody/;
$templatedata=~ s/\$page_title/$title/;
$templatedata=~ s/\$imagesurl/$imagesurl\/images/isg;
$templatedata=~ s/\$lbboard_main/$output\n\n$copyright\n/;
print $templatedata;
exit;
}
sub helpfiles {
my $helptype = shift;
$helptype = uri_escape($helptype) if ($uri_escape ne "no");
my $helpurl = qq~<span style="cursor: help" onClick="openScript('help.cgi?helpon=$helptype', 500, 400)">~;
return $helpurl;
}
sub lockfilename{
my ($lockfilename) = shift;
$lockfilename =~ s/\\/\//isg;
$lockfilename =~ s/\://isg;
$lockfilename =~ s/\//\_/isg;
$lockfilename = "$lbdir" . "lock/$lockfilename";
}
sub winlock{
my ($lockfile) = shift;
my $i = 0;
$lockfile =~ s/\\/\//isg;
$lockfile =~ s/\://isg;
$lockfile =~ s/\//\_/isg;
$lockfile = "$lbdir" . "lock/$lockfile";
while (-e "$lockfile.lck") {
last if ($i >= 120);
select(undef,undef,undef,0.1);
$i++;
}
open (LOCKFILE, ">$lockfile.lck");
close (LOCKFILE);
}
sub winunlock{
my ($lockfile) = shift;
$lockfile =~ s/\\/\//isg;
$lockfile =~ s/\://isg;
$lockfile =~ s/\//\_/isg;
$lockfile = "$lbdir" . "lock/$lockfile";
unlink("$lockfile.lck");
}
sub InMaintenance {
$title = "论坛暂时关闭!";
$line1 = &HTML($line1);
$line1 =~ s/\n/<BR>/isg;
$output .= qq~<table cellpadding=0 cellspacing=0 border=0 width=$tablewidth align=center>
<tr><td width=30% rowspan=2><img src="$imagesurl/myimages/$boardlogo" border=0></td><td valign=middle align=left><font face="$font" color=$fontcolormisc size=2>
<img src="$imagesurl/images/closedfold.gif" border=0>$boardname -- 论坛维护中</td><div align="center"><center><br>
<table border="0" cellpadding="0" cellspacing="0" width="80%" bgcolor="#fdfdfd"><tr><td width="100%">
<p align="center"><b><font color="#FF0000" size="4"><br>论坛暂时关闭<br><br>现在正在维护,请稍后访问!<br><br><br>
</font><font face="宋体" color="#FF0000">$line1<br></tr></table></center></div><tr><td valign=bottom align=right> $helpurl</td></tr></table><br>
~;
print header(-charset=>gb2312);
&output( -Title => "$boardname", -ToPrint => $output, -Version => $versionnumber );
exit;
}
sub myip {
my $ipaddress = $ENV{'REMOTE_ADDR'};
my $trueipaddress = $ENV{'HTTP_X_FORWARDED_FOR'};
$trueipaddress = $ipaddress if (($trueipaddress eq "")||($trueipaddress eq "unknown"));
my $trueipaddress1 = $ENV{'HTTP_CLIENT_IP'};
$trueipaddress = $trueipaddress1 if (($trueipaddress1 ne "")&&($trueipaddress1 ne "unknown"));
return "$ipaddress=$trueipaddress";
}
sub uri_escape {
my $text = shift;
return if ($text =~ /\%/);
unless (defined(%escapes)) {
for (0..255) {
$escapes{chr($_)} = sprintf("%%%02X", $_);
}
}
$text =~ s/([^;\/?:@&=+\$,A-Za-z0-9\-_.!~*'()])/$escapes{$1}/g;
return $text;
}
1;
#发言处理(有出错信息)
# if (($dofilter eq "yes")||($dofilter eq "all")) {
# my $temp = &dofilter("$inpost\t$message");
# ($inpost,$message) = split(/\t/,$temp);
# }
#发言处理(无出错信息,直接过滤写入)
# if (($dofilter eq "yes")||($dofilter eq "all")) {
# my $temp = &postwordfilter("$inpost\t$message");
# ($inpost,$message) = split(/\t/,$temp);
# }
#显示处理
# if (($dofilter eq "no")||($dofilter eq "all")) {
# my $temp = &postwordfilter("$title\t$msg");
# ($title,$msg) = split(/\t/,$temp);
# }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -