📄 lb.lib.pl
字号:
if ($temppoll >1) {
$posticon1 = "<br>";
}
else {
$posticon1 = "";
}
}
$inposttemp = &lbhz($inposttemp,$maxsavepost);
$posticon = $posticon1 if ($sortposticonshow eq "yes");
$rr = ("$postdate1\t$id\t$topictitle\t$topicdescription\t$threadstate\t$tmp\t$threadviews\t$membername\t$postdate\t$membername1\t$posticon\t$inposttemp\t");
}else{
$threadviews = ($tmp+1) * 8 if ($threadviews eq "");
$threadviews = 8000 if ($threadviews > 10000);
$rr = ("$lastpostdate\t$id\t$topictitle\t$topicdescription\t$threadstate\t$threadposts\t$threadviews\t$startedby\t$startedpostdate\t$lastposter\t$posticon1\t$inposttemp\t");
}
if ($topictitle ne "") {push (@dat, $rr);}
}
@sortdat = sort(@dat); undef @dat;
@sortdat = reverse(@sortdat);
my $file = "$lbdir" . "forum$IN{-Forum}/list.cgi";
&winlock($file) if ($OS_USED eq "Nt");
open (LIST, ">$file");
flock (LIST, 2) if ($OS_USED eq "Unix");
foreach (@sortdat) {
chomp $_;
$_ =~ s/\n//isg;
next if ($_ eq "");
($lastpostdate, $topicid, $topictitle, $topicdescription, $threadstate, $threadposts, $threadviews, $startedby, $startedpostdate, $lastposter, $posticon, $posttemp) = split (/\t/,$_);
next if ($topicid eq "");
next if ($topicid !~ /^[0-9]+$/);
$threadstate = "poll" if (($posticon =~ m/<br>/i)&&($threadstate ne "poll")&&($threadstate ne "pollclosed"));
if ($threadstate eq "") {$threadstate="open";}
$posticon = "<BR>" if (($threadstate eq "poll")||($threadstate eq "pollclosed"));
print LIST "$topicid\t$topictitle\t$topicdescription\t$threadstate\t$threadposts\t$threadviews\t$startedby\t$startedpostdate\t$lastposter\t$lastpostdate\t$posticon\t$posttemp\t\n" unless (!$topictitle);
undef $posticon; undef $threadstate;
}
close (LIST);
&winunlock($file) if ($OS_USED eq "Nt");
}
sub ipwhere {
my $fromwhere = shift;
my $datapath="$lbdir"."data";
(my $ip1,my $ip2,my $ip3,my $ip4)=split(/\./,$fromwhere);
my $ips=$ip1*1000000000+$ip2*1000000+$ip3*1000+$ip4;
$ip1=int($ip1);
if (-f "$datapath/$ip1.txt") {
$datafile=$datapath."/".$ip1.".txt";
}
else {
$datafile=$datapath."/other.txt";
}
my $from1='';
my $from2='';
open(IPF,"$datafile");
my @ipdata=<IPF>;
close(IPF);
for ($i=0;$i<@ipdata;$i++){
($ip1,$ip2,$from1,$from2)=split(/__/,$ipdata[$i]);
(my $ipa1,my $ipa2,my $ipa3,my $ipa4)=split(/\./,$ip1);
(my $ipb1,my $ipb2,my $ipb3,my $ipb4)=split(/\./,$ip2);
my $ipbegin =$ipa1*1000000000+$ipa2*1000000+$ipa3*1000+$ipa4;
my $ipend =$ipb1*1000000000+$ipb2*1000000+$ipb3*1000+$ipb4;
if (($ips<=$ipend)&&($ips>=$ipbegin)) {
last;
}
}
if ($from1 eq "") { $fromwhere="未知地区"; }
else {$fromwhere="$from1$from2";}
$fromwhere =~ s/\n//isg;
$fromwhere =~ s/\)//isg;
$fromwhere =~ s/\(//isg;
return $fromwhere;
}
sub osinfo {
local $os="",$Agent;
$Agent = $ENV{'HTTP_USER_AGENT'};
if (($Agent =~ /win/i)&&($Agent =~ /95/i)) {
$os="Windows 95";
}
elsif (($Agent =~ /win 9x/i)&&($Agent =~ /4.90/i)) {
$os="Windows ME";
}
elsif (($Agent =~ /win/i)&&($Agent =~ /98/i)) {
$os="Windows 98";
}
elsif (($Agent =~ /win/i)&&($Agent =~ /nt 5\.0/i)) {
$os="Windows 2000";
}
elsif (($Agent =~ /win/i)&&($Agent =~ /nt 5\.1/i)) {
$os="Windows XP";
}
elsif (($Agent =~ /win/i)&&($Agent =~ /nt/i)) {
$os="Windows NT";
}
elsif (($Agent =~ /win/i)&&($Agent =~ /32/i)) {
$os="Windows 32";
}
elsif ($Agent =~ /linux/i) {
$os="Linux";
}
elsif ($Agent =~ /unix/i) {
$os="Unix";
}
elsif (($Agent =~ /sun/i)&&($Agent =~ /os/i)) {
$os="SunOS";
}
elsif (($Agent =~ /ibm/isg)&&($Agent =~ /os/isg)) {
$os="IBM OS/2";
}
elsif (($Agent =~ /Mac/i)&&($Agent =~ /PC/i)) {
$os="Macintosh";
}
elsif ($Agent =~ /FreeBSD/i) {
$os="FreeBSD";
}
elsif ($Agent =~ /PowerPC/i) {
$os="PowerPC";
}
elsif ($Agent =~ /AIX/i) {
$os="AIX";
}
elsif ($Agent =~ /HPUX/i) {
$os="HPUX";
}
elsif ($Agent =~ /NetBSD/i) {
$os="NetBSD";
}
elsif ($Agent =~ /BSD/i) {
$os="BSD";
}
elsif ($Agent =~ /OSF1/i) {
$os="OSF1";
}
elsif ($Agent =~ /IRIX/i) {
$os="IRIX";
}
$os = "Unknown" if ($os eq '');
$os =~ s/\n//isg;
$os =~ s/\)//isg;
$os =~ s/\(//isg;
return $os;
}
sub browseinfo {
local $browser="",$browserver="",@Browsers = ("Lynx","MOSAIC","AOL","Opera","JAVA","MacWeb","WebExplorer","OmniWeb"),$Agent,$Part;
$Agent = $ENV{'HTTP_USER_AGENT'};
foreach (@Browsers) {
if ($Agent =~/$_/i) {
$browser = $_;
$browserver ="";
}
}
if (($Agent =~ "Mozilla")&&($Agent !~ "MSIE")) {
$Part =(split(/\(/, $Agent))[0];
$browserver = (split(/\//, $Part))[1];
$browserver = (split(/ /,$browserver))[0];
$browserver =~ s/([\d\.]+)/$1/isg;
$browserver = " $browserver";
$browser = "Netscape Navigator";
}
if (($Agent =~ "Mozilla")&&($Agent =~ "Opera")) {
$Part =(split(/\(/, $Agent))[1];
$browserver = (split(/\)/, $Part))[1];
$browserver = (split(/ /,$browserver))[2];
$browserver =~ s/([\d\.]+)/$1/isg;
$browserver = " $browserver";
$browser = "Opera";
}
if (($Agent =~ "Mozilla")&&($Agent =~ "MSIE")) {
$Part = (split(/\(/, $Agent))[1];
$Part = (split(/\;/,$Part))[1];
$browserver = (split(/ /,$Part))[2];
$browserver =~ s/([\d\.]+)/$1/isg;
$browserver = " $browserver";
$browser = "Internet Explorer";
}
if ($browser ne '') {
$browserver = substr($browserver,0,4) if (length($browserver) > 10);
$browseinfo = "$browser$browserver";
}
else {
$browseinfo = "Unknown";
}
$browseinfo =~ s/\n//isg;
$browseinfo =~ s/\)//isg;
$browseinfo =~ s/\(//isg;
return $browseinfo;
}
sub doemoticons {
my $post = shift;
open (FILE, "${lbdir}data/lbemot.cgi");
my @emoticondata = <FILE>;
close (FILE);
chomp @emoticondata;
foreach $picture (@emoticondata) {
$smileyname = $picture;
$smileyname =~ s/\.gif$//g;
for (my $i=1;$i<=$maxsmail;$i++) {
$post =~ s/\:$smileyname\:/\<img src=$imagesurl\/emot\/$picture>/is;
}
$post =~ s/ \:$smileyname\://isg;
$post =~ s/\:$smileyname\://isg;
$post =~ s/\ \:$smileyname\://isg;
}
return $post;
}
sub winlock{
my ($lockfile) = shift;
my $i = 0;
while (-e "$lockfile.lck") {
last if ($i >= 100);
select(undef,undef,undef,0.1);
$i++;
}
open (LOCKFILE, ">$lockfile.lck");
close (LOCKFILE);
}
sub winunlock{
my ($lockfile) = shift;
chmod(0777,"$lockfile.lck");
unlink("$lockfile.lck");
}
sub InMaintenance
{
if ($@) {
print header(-charset=>gb2312); print start_html(-title=>"LB5000 出错!");
print "不能够找到文件:$@\n如果您使用的是 Windows 类操作系统,请在每一个程序中更改 require 的设置,填入绝对路径!";
print end_html; exit;
}
$|++;
# Unbuffer the output
$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/images/$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 lbagent {
my $out="";
my $url=shift;
$url =~ m@http://(.*?)/(.*)@;
my ($host,$path) = ($1,$2);
my $port = 80;
if ($host =~ /(.*):(\d+)/) {
$host = $1;
$port = $2;
}
my $file;
if ($path =~ m@.*/(.*)@) {
$file = $1;
} else {
$file = $path;
}
my ($name,$aliases,$addrtype,$len,@addrs) = gethostbyname($host);
my ($a,$b,$c,$d) = unpack("C4",$addrs[0]);
my $that = pack('S n C4 x8',2,$port,$a,$b,$c,$d);
select (sock);
$|=1;
select (STDOUT);
socket(sock,2,1,0) || die "不能建立套接字,$!!\n";
my $result = connect(sock,$that);
if ($result != 1) {
$out="连接远程服务器错误,请检查网络!";
} else {
print sock "GET /$path HTTP/1.1\r\n";
print sock "Host: $host\r\n";
print sock "Accept: */*\r\n";
print sock "User-Agent: Leoboard Agent 1.0 By hanwei\r\n";
print sock "Pragma: no-cache\r\n";
print sock "Cache-Control: no-cache\r\n";
print sock "Connection: close\r\n";
print sock "\r\n";
recv(sock,$out,4096,0);
recv(sock,$out1,4096,0);
$out=$out.$out1;
close(sock);
}
return $out;
}
sub getoicq {
my $oicq=shift;
if ($oicqshow == 0){
return "$imagesurl/images/oicq.gif";
}else{
my $geturl="http://search.tencent.com/cgi-bin/friend/oicq_find?oicq_no=$oicq";
my $out=&lbagent($geturl);
if ($out eq "连接远程服务器错误,请检查网络!"){
return "$imagesurl/images/oicq.gif";
}else{
@str_ary = split(/ShowResult/,$out);
@str_ary =split(/<\/script>/,$str_ary[2]);
@str_ary = split(/\"\,\"/,$str_ary[0]);
if ($str_ary[1] !~ /\.gif$/isg){
return "$imagesurl/images/oicq.gif";
}else{
return "$str_ary[1]";
}
}
}
}
1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -