草草整理一下思路,如果现在再不整理,估计就遥遥无期了。
第一:Hack思路。
1。本Hack彻底改变原LB的附件方式,所有的附件都在帖子里面以[ uploadfile=***]方式存在。
2。上传机制是在$usrfile目录下面建立tmp目录,在此目录下面以用户name分目录存临时上传的文件,可以限制每个人一次上传的个数。(目录程序自动处理)
3,在帖子提交时候,[b]选择插入[/b]的附件被处理。Copy到$usr/$foumid/XX目录下面,并且在帖子里面更新文件名字。
4。改革了附件都放在$usr/$foumid/根目录下面的习惯,在这个目录下面参考用户库再次分目录,使贴图区不在慢如蜗牛。(来自bbser老大的建议)
5。由于存储方式改变,所以和原来上传的旧格式完全兼容(牺牲了点速度)
6。全部转化中文,不建议出现中文目录和中文文件。
7。js实现插入。
8。没有插入帖子的存在与tmp目录下面的临时文件会在15分钟后自动删除。
第二:新建文件简单介绍
upfile.cgi 上传主界面,会被post.cgi等文件自动用iframe方式调用的。
其中函数:
sub uppic #界面函数
sub doupfile #处理上传函数
sub delup #删除已经上传的文件。
dopost.pl 函数模块,处理获取文件/copy数据/处理帖子cache/删除帖子/移动帖子等等的文件附件处理。
其中函数:
sub upfileonpost #提交的时候处理临时文件到合适的地方:)更新帖子
sub delupfiles #删除当前帖子全部附件(遍历帖子方式)---删除回复时候用
sub delallupfiles #删除当前主贴全部附件,全部删除的时候调用(cache方式)
sub moveallupfiles #移动/copy当前主贴全部附件,移动/copy的时候调用(cache方式)
sub getusrdir #获取临时文件夹,基本函数,上面的函数多调用他,获取$usr/tmp/等等。也负责创建目录,删除超时临时文件。加文件上传数目限制等等,中文处理等等
sub gettmpname #获取临时文件名字,也是基本函数,亦有中文处理等等
第三:修改办法(废话那么多,终于正题了)
1.界面修改,修改文件:fastreplay.pl,forumfastpost.pl,post.cgi,editpost.cgi
打开这些文件,找到:
$addtypedisp = $addtype;
$addtypedisp =~ s/\, /\,/gi;
$addtypedisp =~ s/ \,/\,/gi;
$addtypedisp =~ tr/A-Z/a-z/;
my @addtypedisp = split(/\,/, $addtypedisp);
$addtypedisp = "<select><option value=#>支持类型:</option><option value=#>----------</option>";
foreach (@addtypedisp) {
chomp $_;
next if ($_ eq "");
$addtypedisp .= qq~<option>$_</option>~;
}
$addtypedisp .= qq~</select>~;
$uploadreqire = "" if ($uploadreqire <= 0);
$uploadreqire = "<BR>发帖数要大于 <B>$uploadreqire</B> 篇(认证用户不限)" if ($uploadreqire ne "");
$output .= qq~<tr><td bgcolor=$miscbackone><b>上传附件或图片</b> (最大容量 <B>$maxupload</B>KB)$uploadreqire</td><td bgcolor=$miscbackone colspan=2><input type="file" size=45 name="addme"> $addtypedisp</td></tr>~;
改成
$uploadreqire = "" if ($uploadreqire <= 0);
$uploadreqire = "<BR>发帖数要大于 <B>$uploadreqire</B> 篇(认证用户不限)" if ($uploadreqire ne "");
###路杨add start
$output .= qq~<script language="javascript">function jsupfile(upname) {upname='[UploadFile='+upname+']';if (document.FORM.inpost.createTextRange && document.FORM.inpost.caretPos) {var caretPos = document.FORM.inpost.caretPos;caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? upname + ' ' : upname;document.FORM.inpost.focus();} else {document.FORM.inpost.value+=upname;document.FORM.inpost.focus();}}</script>~;
###路杨add end
$output .= qq~</td></tr><tr><td bgcolor=$miscbackone><b>上传附件或图片</b> (最大容量 <B>$maxupload</B>KB)$uploadreqire</td><td bgcolor=$miscbackone> <iframe id="upframe" name="upframe" src="upfile.cgi?action=uppic&forum=$inforum&topic=$intopic" width=100% height=40 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=NO></iframe><br><font color=$fonthighlight>目前附件:</font><SPAN id=showupfile></SPAN>~;
2。上传处理:
打开post.cgi
找到
require "bbs.lib.pl";
改成
require "bbs.lib.pl";
require "dopost.pl"; #add by 路杨
找到
$addme = $query->param('addme');
删除或者屏障掉这句。
打开doaddnewtopic.pl
找到
删除或者屏障掉这句。
&error("发表新主题&此区新主题必须带附件,请返回重试!") if (($addme eq "")&&($mastpostatt eq "yes")&&($membercode ne "ad")&&($membercode ne 'smo')&&($inmembmod ne "yes"));
找到
if (($addme)&&(($arrowupload ne "off")||($membercode eq "ad")||($membercode eq 'smo')||($inmembmod eq "yes"))) {
$uploadreqire = 0 if ($uploadreqire < 0);
if (($membercode ne "ad")&&($membercode ne 'smo')&&($membercode ne 'amo')&&($membercode ne 'cmo')&&($membercode ne 'mo')&&($membercode !~ /^rz/)&&($inmembmod ne "yes")&&(($numberofposts+$numberofreplys) < $uploadreqire)) {
&error("上传出错&你必须发帖总数达到 <B>$uploadreqire</B> 才能在本区上传!");
}
my $up_filename =$query->uploadInfo($addme);
($up_name,$up_ext) = split(/.*\./,$up_filename);
$up_ext = lc($up_ext);
my $checkadd=0;
for (split(/\,\s*/,$addtype)){
$checkadd=1,last if ($up_ext eq lc($_));
}
&error("上传出错&为了安全,不支持你所上传的附件,请重新选择!") if ($up_ext eq "exe"||$up_ext eq "com"||$up_ext eq "pl"||$up_ext eq "cgi"||$up_ext eq "pm"||$up_ext eq "php4"||$up_ext eq "asp"||$up_ext eq "php"||$up_ext eq "php3"||$up_ext eq "phtml"||$up_ext eq "jsp"||$up_ext eq "cfml"||$up_ext eq "dll");
&error("上传出错&不支持你所上传的附件或者图片,请重新选择!") if ($checkadd==0);
my $filesize=0;
my $bufferall;
open (FILE,">${imagesdir}$usrdir/$inforum/$inforum\_${newthreadnumber}.$up_ext");
binmode (FILE);
while ((($buffer=$query->readUploadFile($addme,4096)))&&!(($filesize>$maxupload)&&($membercode ne "ad"))) {
print FILE $buffer;
$bufferall .= $buffer;
$filesize=$filesize+4;
}
close (FILE);
if ($up_ext eq "torrent") {
if (($bufferall !~ /\/announce/i)||($bufferall !~ /length/i)||($bufferall !~ /info/i)||($bufferall !~ /^d/i)) {
unlink ("${imagesdir}$usrdir/$inforum/$inforum\_${newthreadnumber}.$up_ext");
&error("上传出错&你上传的这个文件不是 .torrent 文件格式,请查实后重新上传!");
}
else {
eval("use BTINFO;");
if ($@ eq "") {
my $btfileinfo = process_file($bufferall);
my (undef, $hash, $announce) = split(/\n/, $btfileinfo);
if ($hash eq "" || $announce eq "") {
unlink ("${imagesdir}$usrdir/$inforum/$inforum\_${newthreadnumber}.$up_ext");
&error("上传出错&你上传的这个文件不是 .torrent 文件格式,请查实后重新上传!");
}
my $seedinfo = output_torrent_data($hash, $announce);
open(FILE, ">${imagesdir}$usrdir/$inforum/$inforum\_$newthreadnumber.$up_ext.btfile");
print FILE "$btfileinfo\|$seedinfo";
close(FILE);
}
}
}
if ($up_ext eq "gif"||$up_ext eq "jpg"||$up_ext eq "bmp"||$up_ext eq "jpeg"||$up_ext eq "png"||$up_ext eq "ppm"||$up_ext eq "svg"||$up_ext eq "xbm"||$up_ext eq "xpm") {
eval("use Image::Info qw(image_info);");
if ($@ eq "") {
my $info = image_info("${imagesdir}$usrdir/$inforum/$inforum\_${newthreadnumber}.$up_ext");
if ($info->{error} eq "Unrecognized file format"){
unlink ("${imagesdir}$usrdir/$inforum/$inforum\_${newthreadnumber}.$up_ext");
&error("上传出错&上传文件不是图片文件,请上传标准的图片文件!");
}
undef $info;
}
}
if (($filesize>$maxupload)&&($membercode ne "ad")) {
unlink ("${imagesdir}$usrdir/$inforum/$inforum\_${newthreadnumber}.$up_ext");
&error("上传出错&上传文件大小超过$maxupload,请重新选择!");
}
if ($dispshowcount eq "yes"){
$filetomake = "${lbdir}FileCount/$inforum/$inforum\_${newthreadnumber}.cgi";
if (open(FILE, ">$filetomake")) {
print FILE "$inforum\_${newthreadnumber}\_\=$inforum\_${newthreadnumber}.$up_ext\=0\n";
close(FILE);
}
}
open (FILE, ">${lbdir}FileCount/$inforum/$inforum\_${newthreadnumber}.pl");
print FILE "$inforum\_${newthreadnumber}.$up_ext\n";
close(FILE);
}
改成
$addme= &upfileonpost(\$inpost,$inforum,$newthreadnumber);#处理上传,返回数值给BT区做判断
&error("发表新主题&此区新主题必须带附件,请返回重试!") if (($addme eq "0")&&($mastpostatt eq "yes")&&($membercode ne "ad")&&($membercode ne 'smo')&&($inmembmod ne "yes"));
打开dotopicreplay.pl
找到
if (($addme)&&(($allowattachment ne "no")||($membercode eq "ad")||($membercode eq 'smo')||($inmembmod eq "yes"))) {
my $filesize=0;
$uploadreqire = 0 if ($uploadreqire < 0);
if (($membercode ne "ad")&&($membercode ne 'smo')&&($membercode ne 'amo')&&($membercode ne 'cmo')&&($membercode ne 'mo')&&($membercode !~ /^rz/)&&($inmembmod ne "yes")&&(($numberofposts+$numberofreplys) < $uploadreqire)) {
&error("上传出错&你必须发帖总数达到 <B>$uploadreqire</B> 才能在本区上传!");
}
my $up_filename =$query->uploadInfo($addme);
($up_name,$up_ext) = split(/\./,$up_filename);
$up_ext = lc($up_ext);
my $checkadd=0;
for (split(/\,\s*/,$addtype)){
$checkadd=1,last if ($up_ext eq lc($_));
}
if ($up_ext eq "exe"||$up_ext eq "com"||$up_ext eq "pl"||$up_ext eq "cgi"||$up_ext eq "asp"||$up_ext eq "pm"||$up_ext eq "php4"||$up_ext eq "php"||$up_ext eq "php3"||$up_ext eq "phtml"||$up_ext eq "jsp"||$up_ext eq "cfml"||$up_ext eq "dll") {
&error("上传出错&为了安全,不支持你所上传的附件,请重新选择!");
}
if ($checkadd==0) { &error("上传出错&不支持你所上传的附件或者图片,请重新选择!"); }
my $bufferall;
$replynumber=$#allmessages+1;
open (FILE,">${imagesdir}$usrdir/$inforum/$inforum\_$intopic\_$replynumber.$up_ext");
binmode (FILE);
while ((($buffer=$query->readUploadFile($addme,4096)))&&!(($filesize>$maxupload)&&($membercode ne "ad"))){
print FILE $buffer;
$bufferall .= $buffer;
$filesize=$filesize+4;
}
close (FILE);
if ($up_ext eq "gif"||$up_ext eq "jpg"||$up_ext eq "bmp"||$up_ext eq "jpeg"||$up_ext eq "png"||$up_ext eq "ppm"||$up_ext eq "svg"||$up_ext eq "xbm"||$up_ext eq "xpm") {
eval("use Image::Info qw(image_info);");
if ($@ eq "") {
my $info = image_info("${imagesdir}$usrdir/$inforum/$inforum\_$intopic\_$replynumber.$up_ext");
if ($info->{error} eq "Unrecognized file format"){
unlink ("${imagesdir}$usrdir/$inforum/$inforum\_$intopic\_$replynumber.$up_ext");
&error("上传出错&上传文件不是图片文件,请上传标准的图片文件!");
}
undef $info;
}
}
if (($filesize>$maxupload)&&($membercode ne "ad")) {
unlink ("${imagesdir}$usrdir/$inforum/$inforum\_$intopic\_$replynumber.$up_ext");
&error("上传出错&上传文件大小超过$maxupload,请重新选择! ");
}
if ($dispshowcount eq "yes"){
open(FILE, ">>${lbdir}FileCount/$inforum/$inforum\_$intopic.cgi");
print FILE "$inforum\_$intopic\_$replynumber\=$inforum\_$intopic\_$replynumber.$up_ext\=0\n";
close(FILE);
}
open (FILE, ">>${lbdir}FileCount/$inforum/$inforum\_$intopic.pl");
print FILE "$inforum\_$intopic\_$replynumber.$up_ext\n";
close(FILE);
}
全部删除。
找到
unlink ("${imagesdir}$usrdir/$inforum/inforum\_$intopic\_$replynumber.$up_ext") if ($addme);
删除。
找到
if ($moneyhidden eq "yes") { $inposttemp = "(保密)"; $inpost="LBSALE[$moneypost]LBSALE".$inpost;}
改成
$addme= &upfileonpost(\$inpost,$inforum,$intopic);#处理上传,返回数值给BT区做判断
#&error("发表新主题&此区新主题必须带附件,请返回重试!") if (($addme eq "0")&&($mastpostatt eq "yes")&&($membercode ne "ad")&&($membercode ne 'smo')&&($inmembmod ne "yes"));
if ($moneyhidden eq "yes") { $inposttemp = "(保密)"; $inpost="LBSALE[$moneypost]LBSALE".$inpost;}
3.修改帖子处理(有新上传)
打开editpost.cgi
找到
require "bbs.lib.pl";
改成
require "bbs.lib.pl";
require "dopost.pl"; #add by 路杨
找到
$addme = $query->param('addme');
删除或者屏障掉这句。
找到
my $p1=$inpostno-1;
$dirtoopen2 = "$imagesdir" . "$usrdir/$inforum";
opendir (DIR, "$dirtoopen2");
@files = readdir(DIR);
closedir (DIR);
@files = grep(/^$inforum\_$intopic/,@files);
if ($p1>0) { @files = grep(/^$inforum\_$intopic\_$p1\./,@files); } else { @files = grep(/^$inforum\_$intopic\./,@files); }
if ( $#files >= 0 ) { $delimg="<BR><input type=checkbox name='delimg' value='no'>删除所有的原图像或附件</input>"; }
改成
#######旧方式的附件,为了兼容,保留,如果想彻底取消旧方式,可以删除###########################
my $p1=$inpostno-1;
$dirtoopen2 = "$imagesdir" . "$usrdir/$inforum";
opendir (DIR, "$dirtoopen2");
@files = readdir(DIR);
closedir (DIR);
@files = grep(/^$inforum\_$intopic/,@files);
if ($p1>0) { @files = grep(/^$inforum\_$intopic\_$p1\./,@files); } else { @files = grep(/^$inforum\_$intopic\./,@files); }
if ( $#files >= 0 ) { $delimg="<BR><input type=checkbox name='delimg' value='no'>删除所有的原图像或附件</input>"; }
########################################################
if ( $rawpost =~/\[UploadFile=([^\]]+?)\]/is) {$delimg="<BR><input type=checkbox name='delimg' value='no'>删除所有的原图像或附件</input>" if ($delimg eq "");} #新的方式
找到
$dirtoopen2 = "$imagesdir" . "$usrdir/$inforum";
opendir (DIR, "$dirtoopen2");
@files = readdir(DIR);
closedir (DIR);
@files = grep(/^$inforum\_$intopic/,@files);
if ($p1>0) { @files = grep(/^$inforum\_$intopic\_$p1\./,@files);} else { @files = grep(/^$inforum\_$intopic\./,@files);}
foreach (@files) {
if (($addme ne "")||($delimg ne "")) {
unlink ("$imagesdir/$usrdir/$inforum/$_");
}
}
my $filesize=0;
if (($addme)&&((($inpostno eq "1")&&($arrowupload ne "off"))||(($inpostno ne "1")&&($allowattachment ne "no"))||($membercode eq "ad")||($membercode eq 'smo')||($inmembmod eq "yes"))) {
$uploadreqire = 0 if ($uploadreqire < 0);
if (($membercode ne "ad")&&($membercode ne 'smo')&&($membercode ne 'amo')&&($membercode ne 'mo')&&($membercode !~ /^rz/)&&($inmembmod ne "yes")&&(($numberofposts+$numberofreplys) < $uploadreqire)) {
&error("上传出错&你必须发贴总数达到 <B>$uploadreqire</B> 才能在本区上传!");
}
my $up_filename =$query->uploadInfo($addme);
my ($up_name,$up_ext) = split(/\./,$up_filename);
$up_ext = lc($up_ext);
my $checkadd=0;
for (split(/\,\s*/,$addtype)){
$checkadd=1,last if ($up_ext eq lc($_));
}
&error("上传出错&为了安全,不支持你所上传的附件,请重新选择!") if ($up_ext eq "exe"||$up_ext eq "com"||$up_ext eq "pl"||$up_ext eq "cgi"||$up_ext eq "asp"||$up_ext eq "php"||$up_ext eq "php3"||$up_ext eq "phtml"||$up_ext eq "jsp"||$up_ext eq "cfml"||$up_ext eq "dll");
&error("上传出错&不支持你所上传的附件或者图片,请重新选择!") if ($checkadd==0);
my $bufferall;
if ($p1==0) {
$dofile = "$imagesdir/$usrdir/$forum/$forum\_$topic.$up_ext";
$HackDetail = "$forum\_$topic\_\=$forum\_$topic.$up_ext\=0";
open (FILE,">$dofile")
} else {
my $replynum=$postno-1;
$dofile = "$imagesdir/$usrdir/$forum/$forum\_$topic\_$p1.$up_ext";
$HackDetail = "$forum\_$topic\_$p1\=$forum\_$topic\_$p1.$up_ext\=0";
open (FILE,">$dofile");
}
binmode (FILE);
while ((($buffer=$query->readUploadFile($addme,4096)))&&!(($filesize>$maxupload)&&($membercode ne "ad"))) {
$filesize = $filesize + 4;
print FILE $buffer;
$bufferall .= $buffer;
}
close (FILE);
if ($up_ext eq "torrent") {
if (($bufferall !~ /\/announce/i)||($bufferall !~ /length/i)||($bufferall !~ /info/i)||($bufferall !~ /^d/i)) {
unlink ("$dofile");
&error("上传出错&你上传的这个文件不是 .torrent 文件格式,请查实后重新上传!");
}
else {
eval("use BTINFO;");
if ($@ eq "") {
my $btfileinfo = process_file($bufferall);
my (undef, $hash, $announce) = split(/\n/, $btfileinfo);
if ($hash eq "" || $announce eq "") {
unlink ("$dofile");
&error("上传出错&你上传的这个文件不是 .torrent 文件格式,请查实后重新上传!");
}
my $seedinfo = output_torrent_data($hash, $announce);
open(FILE, ">${imagesdir}$usrdir/$inforum/$inforum\_$newthreadnumber.$up_ext.btfile");
print FILE "$btfileinfo\|$seedinfo";
close(FILE);
}
}
}
if ($up_ext eq "gif"||$up_ext eq "jpg"||$up_ext eq "bmp"||$up_ext eq "jpeg"||$up_ext eq "png"||$up_ext eq "ppm"||$up_ext eq "svg"||$up_ext eq "xbm"||$up_ext eq "xpm") {
eval("use Image::Info qw(image_info);");
if ($@ eq "") {
my $info = image_info("$dofile");
if ($info->{error} eq "Unrecognized file format"){
unlink ("$dofile");
&error("上传出错&上传文件不是图片文件,请上传标准的图片文件!");
}
undef $info;
}
}
if ($dispshowcount eq "yes") {
$filetomake = "${lbdir}FileCount/$forum/$forum\_$topic.cgi";
open(HACK, "$filetomake");
@AllHackDetail = <HACK>;
close(HACK);
open(NHACK, ">$filetomake");
foreach $HackDetail(@AllHackDetail){
chomp $HackDetail;
my ($ThisHackName,$ThisFileName,$ThisHackDT)=split(/\=/,$HackDetail);
if ($ThisHackName eq "$forum\_$topic\_$p1") {
$ThisHackDT++;
print NHACK "$ThisHackName\=$forum\_$topic\_$p1.$up_ext\=$ThisHackDT\n";
} else {
print NHACK "$HackDetail\n";
}
}
close(NHACK);
}
}
opendir (USRDIR, "${imagesdir}$usrdir/$inforum");
@usruploaddata = readdir(USRDIR);
closedir (USRDIR);
@usruploaddata = grep(/^$inforum\_$intopic(\.|\_)/,@usruploaddata);
chomp @usruploaddata;
open (FILE, ">${lbdir}FileCount/$inforum/$inforum\_$intopic.pl");
print FILE join("\n",@usruploaddata);
print FILE "\n" if ($#usruploaddata > 0);
close(FILE);
if (($filesize>$maxupload)&&($membercode ne "ad")) {
if ($postno==1) {
unlink ("$imagesdir/$usrdir/$forum/$forum\_$topic.$up_ext");
} else {
my $replynum=$postno-1;
unlink ("$imagesdir/$usrdir/$forum/$forum\_$topic\_$replynum.$up_ext");
}
&error("上传出错&上传文件大小超过$maxupload,请重新选择! ");
}
改成
########删除旧方式的附件,兼容的话保留####
$dirtoopen2 = "$imagesdir" . "$usrdir/$inforum";
opendir (DIR, "$dirtoopen2");
@files = readdir(DIR);
closedir (DIR);
@files = grep(/^$inforum\_$intopic/,@files);
if ($p1>0) { @files = grep(/^$inforum\_$intopic\_$p1\./,@files);} else { @files = grep(/^$inforum\_$intopic\./,@files);}
foreach (@files) {
if (($addme ne "")||($delimg ne "")) {
unlink ("$imagesdir/$usrdir/$inforum/$_");
}
}
#######删除全部原来的附件 START###(BY 路杨)
if ($delimg ne "") {$showerr = &delupfiles(\$inpost,$inforum,$intopic);}; #新方式
#######删除全部原来的附件 END
my $filesize=0;
$addme= &upfileonpost(\$inpost,$inforum,$intopic);#处理上传,返回数值给BT区做判断
4。处理删除回复,删除帖子/移动帖子。
打开delpost.cgi
找到
require "bbs.lib.pl";
改成
require "bbs.lib.pl";
require "dopost.pl"; #add by 路杨
找到
opendir (DIRS, "${imagesdir}$usrdir/$inforum");
my @files = readdir(DIRS);
closedir (DIRS);
@files = grep(/^$inforum\_$intopic(\.|\_)/i, @files);
foreach (@files) {
chomp $_;
unlink ("${imagesdir}$usrdir/$inforum/$_");
}
改成
###原来的方式开始,保持兼容的话保留,不然删除###
opendir (DIRS, "${imagesdir}$usrdir/$inforum");
my @files = readdir(DIRS);
closedir (DIRS);
@files = grep(/^$inforum\_$intopic(\.|\_)/i, @files);
foreach (@files) {
chomp $_;
unlink ("${imagesdir}$usrdir/$inforum/$_");
}
###原来的方式完 ###
&delallupfiles($inforum,$intopic); ##新的帖子附件删除(cache方式)
找到
unlink ("${lbdir}FileCount/$inforum/$inforum\_$intopic.pl");
$filetoopen = "${lbdir}FileCount/$inforum/$inforum\_$intopic.cgi";
if (-e $filetoopen && $dispshowcount eq "yes") {
&winlock($filetoopen) if ($OS_USED eq "Nt");
open(FILE, "$filetoopen");
flock(FILE, 1) if ($OS_USED eq "Unix");
@DTHack = <FILE>;
close(FILE);
chomp @DTHack;
$DTHack=join("\n",@DTHack);
&winunlock($filetoopen) if ($OS_USED eq "Nt");
}
my $dirtoopen2 = "$imagesdir" . "$usrdir/$inforum";
opendir (DIR, "$dirtoopen2");
@dirdata = readdir(DIR);
closedir (DIR);
@oldinpostno=reverse sort @oldinpostno;
@oldinpostnobak = @oldinpostno;
foreach $pno(@oldinpostno){
$pno--;
@files=grep(/^$inforum\_$intopic\_$pno/,@dirdata);
chomp @files;
if($#files >= 0){
$DTHack=~s/$inforum\_$intopic\_$pno\=$inforum\_$intopic\_$pno.(.+?)\=Ύ-9]+\n//s if (-e $filetoopen && $dispshowcount eq "yes" && $DTHack=~m/$inforum\_$intopic\_$pno/);
foreach $file(@files){
unlink ("$dirtoopen2/$file");
}
}
for(my $i=$pno+1;$i<$tt;$i++){
@filetorename=grep(/^$inforum\_$intopic\_$i/,@dirdata);
if($#filetorename >= 0){
($filename,$fileext)=split(/\./,$filetorenameΎ]);
$ii=$i-1;
rename ("${imagesdir}$usrdir/$inforum/$inforum\_$intopic\_$i.$fileext","${imagesdir}$usrdir/$inforum/$inforum\_$intopic\_$ii.$fileext");
$DTHack=~s/$inforum\_$intopic\_$i/$inforum\_$intopic\_$ii/isg if (-e $filetoopen && $dispshowcount eq "yes" && $DTHack=~m/$inforum\_$intopic\_$i/);
}
}
}
改成
##########老的附件删除 保留,为了兼容,不兼容就del##
# unlink ("${lbdir}FileCount/$inforum/$inforum\_$intopic.pl"); #现在不能删除他(注意这一句!!!)
$filetoopen = "${lbdir}FileCount/$inforum/$inforum\_$intopic.cgi";
if (-e $filetoopen && $dispshowcount eq "yes") {
&winlock($filetoopen) if ($OS_USED eq "Nt");
open(FILE, "$filetoopen");
flock(FILE, 1) if ($OS_USED eq "Unix");
@DTHack = <FILE>;
close(FILE);
chomp @DTHack;
$DTHack=join("\n",@DTHack);
&winunlock($filetoopen) if ($OS_USED eq "Nt");
}
#########很怪的重命名:)为了兼容,保留(路杨)
my $dirtoopen2 = "$imagesdir" . "$usrdir/$inforum";
opendir (DIR, "$dirtoopen2");
@dirdata = readdir(DIR);
closedir (DIR);
@oldinpostno=reverse sort @oldinpostno;
@oldinpostnobak = @oldinpostno;
foreach $pno(@oldinpostno){
$pno--;
@files=grep(/^$inforum\_$intopic\_$pno/,@dirdata);
chomp @files;
if($#files >= 0){
$DTHack=~s/$inforum\_$intopic\_$pno\=$inforum\_$intopic\_$pno.(.+?)\=Ύ-9]+\n//s if (-e $filetoopen && $dispshowcount eq "yes" && $DTHack=~m/$inforum\_$intopic\_$pno/);
foreach $file(@files){
unlink ("$dirtoopen2/$file");
}
}
for(my $i=$pno+1;$i<$tt;$i++){
@filetorename=grep(/^$inforum\_$intopic\_$i/,@dirdata);
if($#filetorename >= 0){
($filename,$fileext)=split(/\./,$filetorenameΎ]);
$ii=$i-1;
rename ("${imagesdir}$usrdir/$inforum/$inforum\_$intopic\_$i.$fileext","${imagesdir}$usrdir/$inforum/$inforum\_$intopic\_$ii.$fileext");
$DTHack=~s/$inforum\_$intopic\_$i/$inforum\_$intopic\_$ii/isg if (-e $filetoopen && $dispshowcount eq "yes" && $DTHack=~m/$inforum\_$intopic\_$i/);
}
}
}
###############老的附件删除END
&delupfiles(\$delpostES,$inforum,$intopic); ###新的方法BY路杨
找到
@files1 = grep(/^$inforum\_$intopic\./,@files);
$files1 = @files1;
if ($files1 > 0) {
foreach (@files1) {
(my $name,my $ext) = split(/\./,$_);
copy("${imagesdir}$usrdir/$inforum/$name.$ext","${imagesdir}$usrdir/$movetoid/$movetoid\_$newthreadnumber\.$ext");
}
}
@files1 = grep(/^$inforum\_$intopic\_/,@files);
$files1 = @files1;
if ($files1 > 0) {
foreach (@files1) {
(my $name,my $ext) = split(/\./,$_);
(my $name1,my $name2,my $name3) = split(/\_/,$name);
copy("${imagesdir}$usrdir/$inforum/$name.$ext","${imagesdir}$usrdir/$movetoid/$movetoid\_$newthreadnumber\_$name3\.$ext");
}
}
改成
####旧的方式,不需要兼容的话,可以删除
@files1 = grep(/^$inforum\_$intopic\./,@files);
$files1 = @files1;
if ($files1 > 0) {
foreach (@files1) {
(my $name,my $ext) = split(/\./,$_);
copy("${imagesdir}$usrdir/$inforum/$name.$ext","${imagesdir}$usrdir/$movetoid/$movetoid\_$newthreadnumber\.$ext");
}
}
@files1 = grep(/^$inforum\_$intopic\_/,@files);
$files1 = @files1;
if ($files1 > 0) {
foreach (@files1) {
(my $name,my $ext) = split(/\./,$_);
(my $name1,my $name2,my $name3) = split(/\_/,$name);
copy("${imagesdir}$usrdir/$inforum/$name.$ext","${imagesdir}$usrdir/$movetoid/$movetoid\_$newthreadnumber\_$name3\.$ext");
}
}
#####旧的方式
&moveallupfiles($inforum,$intopic,$movetoid,$newthreadnumber,$inleavemessage); #新的方式
打开jinghua.cgi
找到
@files1 = grep(/^$inforum\_$intopic\./,@files);
$files1 = @files1;
if ($files1 > 0) {
foreach (@files1) {
(my $name,my $ext) = split(/\./,$_);
copy("${imagesdir}$usrdir/$inforum/$name.$ext","${imagesdir}$usrdir/$movetoid/$movetoid\_$newthreadnumber\.$ext");
}
}
@files1 = grep(/^$inforum\_$intopic\_/,@files);
$files1 = @files1;
if ($files1 > 0) {
foreach (@files1) {
(my $name,my $ext) = split(/\./,$_);
(my $name1,my $name2,my $name3) = split(/\_/,$name);
copy("${imagesdir}$usrdir/$inforum/$name.$ext","${imagesdir}$usrdir/$movetoid/$movetoid\_$newthreadnumber\_$name3\.$ext");
}
}
改成
#########旧的附件copy,为了兼容,保留 路杨
@files1 = grep(/^$inforum\_$intopic\./,@files);
$files1 = @files1;
if ($files1 > 0) {
foreach (@files1) {
(my $name,my $ext) = split(/\./,$_);
copy("${imagesdir}$usrdir/$inforum/$name.$ext","${imagesdir}$usrdir/$movetoid/$movetoid\_$newthreadnumber\.$ext");
}
}
@files1 = grep(/^$inforum\_$intopic\_/,@files);
$files1 = @files1;
if ($files1 > 0) {
foreach (@files1) {
(my $name,my $ext) = split(/\./,$_);
(my $name1,my $name2,my $name3) = split(/\_/,$name);
copy("${imagesdir}$usrdir/$inforum/$name.$ext","${imagesdir}$usrdir/$movetoid/$movetoid\_$newthreadnumber\_$name3\.$ext");
}
}
###########
require "dopost.pl"; #路杨
&moveallupfiles($inforum,$intopic,$movetoid,$newthreadnumber,"yes"); #新的附件copy 路杨
5。分论坛显示处理 打开 forums.cgi
找到
opendir (DIR, "${imagesdir}$usrdir/$inforum");
@usruploadfile = readdir(DIR);
closedir (DIR);
删除这些。
找到
if (($topiccount >= $abstopcount + $cattopcount)||($startarray ne 0)||($forumid eq $inforum)) {
my @usruploadfile = grep(/^$inforum\_$topicid(\.|\_)/,@usruploadfile);
if ($#usruploadfile >= 0) {
my @files = grep(/^$inforum\_$topicid\./,@usruploadfile);
if ($#files >= 0) {
my $usrfilename = $filesΎ]; chomp $usrfilename;
($up_name, $up_ext) = split(/\./,$usrfilename);
$up_ext =~ tr/A-Z/a-z/;
$filetype = "unknow";
$filetype = $up_ext if (-e "${imagesdir}icon/$up_ext.gif");
$addmelink=qq~<a href=attachment.cgi?forum=$inforum&topic=$topicid&postno=1&type=.$up_ext target=_blank>~;
if (($up_ext eq 'jpg')||($up_ext eq 'gif')||($up_ext eq 'bmp')||($up_ext eq 'png')) { $topictitle ="$addmelink<img src=$imagesurl/icon/$filetype.gif width=16 alt=\"该主题有一张 $filetype 格式图片\" border=0 align=absmiddle></a> ".$topictitle; }
elsif ($up_ext eq "swf") { $topictitle ="$addmelink<img src=$imagesurl/icon/$filetype.gif width=16 alt=\"该主题有一张 $filetype 格式动画\" border=0 align=absmiddle></a> ".$topictitle; }
else {
if ($dispshowcount eq "yes") { $addmelink=qq~<a href="javascript:Download('$inforum','$topicid','')">~; }
$topictitle ="$addmelink<img src=$imagesurl/icon/$filetype.gif width=16 align=absmiddle alt=\"该主题有一个“$filetype”类型附件\" border=0></a> ".$topictitle;
}
$addonlength += 4;
}
my @files = grep(/^$inforum\_$topicid\_/,@usruploadfile);
if ($#files >= 0) {
my $filesnum= $#files + 1;
$topictitle=$topictitle." <img src=$imagesurl/icon/replyattachment.gif width=16 align=absmiddle alt=\"该主题内的回复中含有 $filesnum 个图形或附件\">";
$addonlength += 3;
}
}
}
改成
if (($topiccount >= $abstopcount + $cattopcount)||($startarray ne 0)||($forumid eq $inforum)) {
my $usruploadfile = "${lbdir}FileCount/$inforum/${inforum}\_${topicid}.pl";
if (-e "$usruploadfile")
{
my @fileinfo = stat("$usruploadfile"); my $filelength = $fileinfoΕ];
if ($filelength != 0)
{
if (open(FILEUP,"$usruploadfile"))
{
undef $/;
$files = <FILEUP>;
close(FILEUP);
$/="\n";
my @files=split(/\n/,$files);
$filesnumber=@files;
if ($filesnumber >= 1)
{
my $usrfilename = $filesΎ];
chomp $usrfilename;
($up_name, $up_ext) = split(/\./,$usrfilename);
$up_ext =~ tr/A-Z/a-z/;
$filetype = "unknow";
$filetype = $up_ext if (-e "${imagesdir}icon/$up_ext.gif");
## $addmelink=qq~<a href=attachment.cgi?forum=$inforum&topic=$topicid&postno=1&type=.$up_ext target=_blank>~;
if (($up_ext eq 'jpg')||($up_ext eq 'gif')||($up_ext eq 'bmp')||($up_ext eq 'png')) { $topictitle ="$addmelink<img src=$imagesurl/icon/$filetype.gif width=16 alt=\"该主题有一张 $filetype 格式图片\" border=0 align=absmiddle></a> ".$topictitle; }
elsif ($up_ext eq "swf") { $topictitle ="$addmelink<img src=$imagesurl/icon/$filetype.gif width=16 alt=\"该主题有一张 $filetype 格式动画\" border=0 align=absmiddle></a> ".$topictitle; }
else {
# if ($dispshowcount eq "yes") { $addmelink=qq~<a href="javascript:Download('$inforum','$topicid','')">~; }
$topictitle ="$addmelink<img src=$imagesurl/icon/$filetype.gif width=16 align=absmiddle alt=\"该主题有一个“$filetype”类型附件\" border=0></a> ".$topictitle;
}
$addonlength += 4;
}
if ($filesnumber >= 2) {
$topictitle=$topictitle." <img src=$imagesurl/icon/replyattachment.gif width=16 align=absmiddle alt=\"该主题内的回复中含有 $filesnumber 个图形或附件\">";
$addonlength += 3;
}
}
}
}
}
6.帖子显示处理
打开toptic.cgi
找到
if (open (FILE, "${lbdir}FileCount/$inforum/$inforum\_$intopic.pl")) {
@usruploaddata =<FILE>;
close(FILE);
chomp @usruploaddata;
} else {
opendir (USRDIR, "${imagesdir}$usrdir/$inforum");
@usruploaddata = readdir(USRDIR);
closedir (USRDIR);
@usruploaddata = grep(/^$inforum\_$intopic(\.|\_)/,@usruploaddata);
chomp @usruploaddata;
open (FILE, ">${lbdir}FileCount/$inforum/$inforum\_$intopic.pl");
print FILE join("\n",@usruploaddata);
print FILE "\n" if ($#usruploaddata > 0);
close(FILE);
}
$usruploaddata = @usruploaddata;
if ($usruploaddata > 0) {
@usruploaddatareply = grep(/^$inforum\_$intopic\_/,@usruploaddata);
$usruploaddatareply = @usruploaddatareply;
}
改成
##兼容代码,请注意修改了一部分
if (open (FILE, "${lbdir}FileCount/$inforum/$inforum\_$intopic.pl")) {
@usruploaddata =<FILE>;
close(FILE);
chomp @usruploaddata;
}
##老格式的目录遍例
else {
opendir (USRDIR, "${imagesdir}$usrdir/$inforum");
@usruploaddata = readdir(USRDIR);
closedir (USRDIR);
@usruploaddata = grep(/^$inforum\_$intopic(\.|\_)/,@usruploaddata);
chomp @usruploaddata;
# open (FILE, ">${lbdir}FileCount/$inforum/$inforum\_$intopic.pl");
# print FILE join("\n",@usruploaddata);
# print FILE "\n" if ($#usruploaddata > 0);
# close(FILE);
}
$usruploaddata = @usruploaddata;
if ($usruploaddata > 0) {
@usruploaddatareply = grep(/^$inforum\_$intopic\_/,@usruploaddata);
$usruploaddatareply = @usruploaddatareply;
}
后面的代码
foreach (@threads[$startarray .. $endarray]) {
chomp $_;
# next if ($_ eq "");
if ($usruploaddata > 0) {
my $addmefile =0;
if ($rn>0) {
if ($usruploaddatareply > 0) {
$rrn = $rn;
my @usruploaddata1 = grep(/^$inforum\_$intopic\_$rrn\./,@usruploaddatareply);
my @downcount = grep(/$inforum\_$intopic\_$rrn\./,@filedowncount);
if ($#usruploaddata1 >= 0) {
my $usruploadfile = $usruploaddata1Ύ]; chomp $usruploadfile;
($up_name, $up_ext) = split(/\./,$usruploadfile);
$up_ext =~ tr/A-Z/a-z/;
$addmefile =1;
$usruploaddatareply --;
}
if ($#downcount>=0 && $dispshowcount eq "yes") {
my $DownDetail = $downcountΎ]; chomp $DownDetail;
my ($ThisHackName,$ThisFileName,$ThisHackDT)=split(/\=/,$DownDetail);
$DownTime=",<font color=$fonthighlight>共被下载</font>: $ThisHackDT 次";
}
}
}
else {
my @usruploaddata2 = grep(/^$inforum\_$intopic\./,@usruploaddata);
my @downcount = grep(/$inforum\_$intopic\./,@filedowncount);
if ($#usruploaddata2 >= 0) {
my $usruploadfile = $usruploaddata2Ύ]; chomp $usruploadfile;
($up_name, $up_ext) = split(/\./,$usruploadfile);
$up_ext =~ tr/A-Z/a-z/;
$addmefile =1;
}
if ($#downcount>=0 && $dispshowcount eq "yes") {
my $DownDetail = $downcountΎ]; chomp $DownDetail;
my ($ThisHackName,$ThisFileName,$ThisHackDT)=split(/\=/,$DownDetail);
$DownTime=",<font color=$fonthighlight>共被下载</font>: $ThisHackDT 次";
}
}
if (!(-e "${imagesdir}$usrdir/$inforum/$up_name.$up_ext")) {
unlink ("${lbdir}FileCount/$inforum/$inforum\_$intopic.pl");
print "页面已经更新,程序自动刷新,如果没有自动刷新,请手工刷新一次!<BR><BR><meta http-equiv='refresh' content='0;'>";
exit;
}
if ($addmefile == 1) {
@fileinfo = stat("${imagesdir}$usrdir/$inforum/$up_name.$up_ext");
$filetype = "unknow";
$filetype = $up_ext if (-e "${imagesdir}icon/$up_ext.gif");
if (($up_ext eq "gif")||($up_ext eq "jpg")||($up_ext eq "jpe")||($up_ext eq "jpeg")||($up_ext eq "tif")||($up_ext eq "png")||($up_ext eq "bmp")) {
if (($nodispphoto eq 'yes')||($arrawpostpic eq 'off')) {
$addme = qq(<a href=attachment.cgi?forum=$inforum&topic=$intopic&postno=$editpostnumber&type=.$up_ext target=_blank><img src=$imagesurl/icon/$filetype.gif border=0 width=16></a> <a href=attachment.cgi?forum=$inforum&topic=$intopic&postno=$editpostnumber&type=.$up_ext target=_blank>点击显示此主题相关图片</a><br>);
} else{
$addme = qq(<img src=$imagesurl/icon/$filetype.gif border=0 width=16> 此主题相关图片如下:<br><a href=attachment.cgi?forum=$inforum&topic=$intopic&postno=$editpostnumber&type=.$up_ext target=_blank><img src=attachment.cgi?forum=$inforum&topic=$intopic&postno=$editpostnumber&type=.$up_ext border=0 alt=按此在新窗口浏览图片 onload="javascript:if(this.width>screen.width-333)this.width=screen.width-333" onmousewheel="return bbimg(this)"></a><br>);
}
$addme .= qq(<img src=$imagesurl/images/none.gif whidth=0 height=5><BR><span style=CURSOR:hand onclick=loadThreadFollow($forumid,$topicid,$editpostnumber,'$up_ext')><img id=followImg$editpostnumber src=$imagesurl/images/cat.gif width=9 loaded=no nofollow="cat.gif" valign=absmiddle> 按此查看图片详细信息<table cellpadding=0 class=ts1 cellspacing=0 width=50% id=follow$editpostnumber style=DISPLAY:none><tr><td id=followTd$editpostnumber><DIV class=ts onclick=loadThreadFollow($forumid,$topicid,$editpostnumber,'$up_ext')>正在读取此图片的详细信息,请稍候 ...</DIV></td></tr></table></span><BR><BR>);
}
elsif ($up_ext eq "swf") {
if ($arrawpostflash eq "on") {
$addme = qq(<img src=$imagesurl/icon/$filetype.gif border=0 width=16> 该主题有一个 $up_ext 格式 Flash 动画 (共 $fileinfoΕ] 字节)<br><br><PARAM NAME=PLAY VALUE=TRUE><PARAM NAME=LOOP VALUE=TRUE><PARAM NAME=QUALITY VALUE=HIGH><embed src=attachment.cgi?forum=$inforum&topic=$intopic&postno=$editpostnumber&type=.$up_ext quality=high width=$defaultflashwidth height=$defaultflashheight pluginspage="http:\/\/www.macromedia.com\/shockwave\/download\/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application\/x-shockwave-flash"><\/embed><br> <img src=$imagesurl/images/fav.gif width=16> <a href=attachment.cgi?forum=$inforum&topic=$intopic&postno=$editpostnumber&type=.$up_ext target=_blank>全屏观看</a> (按右键下载)<br><br>)
} else {
$addme=qq(<a href=attachment.cgi?forum=$inforum&topic=$intopic&postno=$editpostnumber&type=.$up_ext target=_blank><img src=$imagesurl/icon/$filetype.gif border=0 width=16 height=16>点击欣赏 Flash 动画</a>);
}
}
elsif (($up_ext eq "torrent")&&(($rn eq 0)||($rn eq ""))) {
require "dobtinfo.pl";
}
else {
if ($dispshowcount eq "yes") {
my ($forumno,$topicno,$replyno)=split(/\_/,$up_name);
$addme = qq(<font color=$fonthighlight>相关附件</font>:<a href="javascript:Download('$forumno','$topicno','$replyno')"><img src=$imagesurl/icon/$filetype.gif border=0 width=16 alt="该主题有一个“$filetype”类型附件,点击下载"></a> (共 $fileinfoΕ] 字节)$DownTime<br><br>);
} else {
$addme = qq(<font color=$fonthighlight>相关附件</font>:<a href=attachment.cgi?forum=$inforum&topic=$intopic&postno=$editpostnumber&type=.$up_ext target=_blank><img src=$imagesurl/icon/$filetype.gif border=0 width=16 alt="该主题有一个“$filetype”类型附件,点击下载"></a> (共 $fileinfoΕ] 字节)<br><br>);
}
}
} else { $addme = ""; }
} else { $addme = ""; }
为大量的兼容代码。不与理会了。
7.标签转化。
打开code.cgi
找到
if ($wwjf ne "no") {
if ($$post=~/LBHIDDEN\[(.*?)\]LBHIDDEN/sg) {
前面加上
###处理上传 By 路杨(Easun Studio) start 等待完善###
$tmptopic = $intopic%100;
$$post =~ s/\[UploadFile=([^\]]+?\.(gif|jpg|png|bmp|jpeg))\]/<br><img src=$imagesurl\/icon\/$2.gif border=0 width=16> <b>这个为上传图片文件<\/b><br> \[img\]$imagesurl\/$usrdir\/$inforum\/$tmptopic\/$1\[\/img\]<br>/isg;
$$post =~ s/\[UploadFile=([^\]]+?\.swf)\]/<br><img src=$imagesurl\/icon\/swf.gif border=0 width=16> <b>这个为上传Flash文件<\/b><br> \[swf\]$imagesurl\/$usrdir\/$inforum\/$tmptopic\/$1\[\/swf\]<br>/isg;
$$post =~ s/\[UploadFile=([^\]]+?)(\.(.*?))\]/<br><img src=$imagesurl\/icon\/$3.gif border=0 width=16> <b>这个为上传$3文件<\/b><br><a href=$imagesurl\/$usrdir\/$inforum\/$tmptopic\/$1$2> 点击查看 <\/a><br>/isg;
$$post =~ s/\[UploadFile=([^\]]+?)\]/<br><img src=$imagesurl\/icon\/unknow.gif border=0 width=16> <b>这个为上传未知文件<\/b><br><a href=$imagesurl\/$usrdir\/$inforum\/$tmptopic\/$1> 点击查看 <\/a><br>/isg;
### 处理上传 By 路杨(Easun Studio) end ###
完成。
可以看的出来,为了保持原来的兼容,保留了大量的代码。
草率之作,很多地方都可以完善,只是路杨精力不足了。
JS部分我今天测试时候,发现删除的js更新不会进行(难道又是IE5兼容)?其他的都是在IE5下正常运行。请Anthony老弟高手看看解决的问题。
注意事项
1。本功能适合XP/MX,改法相似。
2。本功能和LeoBBS的加密附件功能没有柔和,期待高手
3。本功能对显示下载功能有冲突,似乎我的改法已经破坏了这个功能?但是这个功能我是从来没有开放过。期待高手完善。
4。还是那句话,跟进官方升级的人不要用喔,有兼容问题
5。路杨的程序一般都会在每个程序段上加上功能注释,欢迎指教。
6。欠扁的话,路杨近来很忙……所以免责版本,请先备份。
-----
EXCERPT: