📄 bbs2lbt_online.cgi
字号:
#!/usr/bin/perl #
#
# YZBBS3000->LB5000在线转换程序 #
# #
# 编制:hleil(hleil@163.com) #
# http://www.hleil.cn.gs/cgi-bin/LeoBoard/leoboard.cgi #
# http://hleil.126.com #
# #
#适用于原来申请了别人的免费的Yuzi论坛3000(BBS3000),现在又建设了自己的LB5000论坛 #
#的情况。也就是说,你无法直接控制Yuzi论坛的数据,只可以浏览。这样就无法使用清凉编制的 #
#两个转换程序(bbs2lbt,ys2lbt)和山鹰编制的bbs2lb5000。 #
# #
#因为我有自己的需要,所以就写了这么个小东西,呵呵,这可是我第一次写perl脚本,请大家多 #
#提意见! #
# #
#使用了清凉的t2t,如果有错误,修改成#111那样。 #
#使用了libwww-perl,如果你的虚拟主机不支持,可以在本机运行。我就是这样的。 #
#(平台:NT+ActivePerl)。然后把生成的文件打包上载,用webunzip解开,这样不会出现权 #
#限问题,webunzip从此处下载: #
#http://www.tapor.com/webunzip/ #
# #
# #
#测试平台:NT+ActivePerl-5.6.0.623(没办法,主机不支持libwww-perl) #
# #
#完成日期:2001-12-3 #
#########################################################################
#
#推荐使用方法:用lb5000建一个论坛,类别:精华区。
#执行此脚本。
#如果你的BBS已经有了很多用户,为了避免重名,可以给$rusername变量加上适当的前缀或者后缀,
#此名称不受LB5000的用户名长度限制。
#如果你想在现有论坛执行转化,首先关闭lb5000,然后,手工给$j赋一个值,大小是你现有主贴子
#号+1。
#
#做完之后,重新整理论坛就行。
#
#此论坛:http://www.hleil.cn.gs/cgi-bin/LeoBoard/forums.cgi?forum=5
#就是用这个脚本转换的。
#当然,用户资料是无法转化的。
#假设你申请的免费Yuzi论坛的
#URL=http://www.test.com/cgi-bin/bbs3000/bbs.cgi?id=200112022043
#
#则:$base="http://www.test.com/cgi-bin/bbs3000/list/200112022043/
#
$base="http://www.test.com/cgi-bin/bbs3000/list/200112022043/";
#这就不用说了吧?你的LB5000论坛的绝对目录,注意设置 777 属性
$lbpath="/web/htdoc/hleil/cgi-bin/LeoBoard/forum5/";
#$lbpath=""; #NT用此
##############################################################
####以下不需修改
####
use Time::Local;
require "data/styles.cgi";
$bbsdata="bbs";
####GET 主贴
$tmp="$base$bbsdata";
$data=&gethtml("$tmp");
$num=length($data)/16;
#
&save;
sub save{
for($i=0,$j=1;$i<$num;$i++,$j++){
$bbsdata=substr($data,$i*16,16);
$tmp="$base$bbsdata";
$data2=&gethtml("$tmp");
($rtitles,$rthistime,$rusername,$nr,$rfrom,$rhasreply,$emote,$lastname,$rlasttime,$re,$rhassee)=split(/\t/,$data2);
$ctime=&t2t($rthistime);
# print FILE "$newthreadnumber\t$intopictitle\t$intopicdescription\topen\t0\t0\t$inmembername\t$currenttime\t\t$currenttime\t$inposticon\t$inposttemp\t";
# print FILE "$inmembername\t$intopictitle\t$postipaddress\t$inshowemoticons\t$inshowsignature\t$currenttime\t$inpost\t$inposticon\t";
$inposttemp = &lbhz($nr,24);#$maxsavepost);
open (FILE,">$lbpath$j.pl");
print FILE "$j\t$rtitles\t\topen\t$rhasreply\t$rhassee\t$rusername\t$ctime\t\t$ctime\t\t$inposttemp\t";
close FILe;
open (FILE,">$lbpath$j.thd.cgi");
print FILE "$rusername\t$rtitles\t$rfrom\tyes\tyes\t$ctime\t$nr\t\t";
close FILe;
if ($rhasreply > 0)
{
&save2($j,$re);
}
}}
sub save2{
$mainid=$_[0];
$nextid=$_[1];
$tmp="$base$nextid";
@data2=&gethtml("$tmp");
foreach $m (@data2){
chomp($m);
if($m ne ""){
($rtime,$rthistime,$rusername,$rcomment,$rfrom,$remote,$retitles,$rerhassee)=split(/\t/,$m);
$ctime=&t2t($rthistime);
open (FILE,">>$lbpath$mainid.thd.cgi");
print FILE "\n$rusername\t$retitles\t$rfrom\tyes\tyes\t$ctime\t$rcomment\t\t";
close FILe;
}}
open (FILE,"$lbpath$mainid.pl");
$data3 = <FILE>;
close FILE;
($topicid, $topictitle, $topicdescription, $threadstate, $threadposts ,$threadviews, $startedby, $startedpostdate, $lastposter, $lastpostdate, $posticon, $inposttemp) = split(/\t/,$data3);
$lastposter=$rusername;
$lastpostdate=$ctime;
$inposttemp = &lbhz($nr,24);
open (FILE,">$lbpath$mainid.pl");
print FILE "$topicid\t$topictitle\t$topicdescription\t$threadstate\t$threadposts\t$threadviews\t$startedby\t$startedpostdate\t$lastposter\t$lastpostdate\t$posticon\t$inposttemp\t";
close FILE;
}
sub gethtml {
$url=$_[0];
require LWP::UserAgent;
$ua = new LWP::UserAgent;
$request = new HTTP::Request('GET', "$url");
$response = $ua->request($request);
my $html = $response->{_content};
return $html;
}
sub lbhz{
my($str,$maxlen) = @_;
if (length($str) <= $maxlen){ return $str; }
if (substr($str,0,$maxlen-4) =~ /^([\000-\177]|[\200-\377][\200-\377])*([\000-\177]|[\200-\377][\200-\377])$/ ){
return substr($str,0,$maxlen-4)." ...";
}else{
return substr($str,0,$maxlen-5)." ...";
}
}
sub t2t{
#转换之前的日期格式为2001/04/28(13:04:04),
#我的是:2001-08-10.19:00:54,一样,呵呵~~
#其他的日期如果具备这几项内容,按照格式对下面时间的定位做一些修改,就可以用这个函数
my $ntime=shift;
my($secn,$minn,$hourn,$dayn,$monn,$yearn);
$yearn=substr($ntime,0,4); $monn=substr($ntime,5,2); $dayn=substr($ntime,8,2);
$hourn=substr($ntime,11,2); $minn=substr($ntime,14,2); $secn=substr($ntime,17,2);
$yearn=int($yearn)-1900;
# $yearn=int($yearn)-1900;
$monn=dotime($monn)-1;
$dayn=dotime($dayn);
$hourn=dotime($hourn);
$minn=dotime($minn);
$secn=dotime($secn);
$time = timelocal($secn,$minn,$hourn,$dayn,$monn,$yearn);
#111 $time = timelocal($secn,$minn,$hourn,$dayn,$monn,101);
return $time;
}
sub dotime {
my $dtime=shift;
$dtime=substr($dtime,1,1) if(substr($dtime,0,1) eq "0");
$dtime=int($dtime);
$dtime=1 if($dtime<1);
return $dtime;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -