📄 postings.cgi
字号:
#!/usr/bin/perl
#############################################################
# Ikonboard v2.1
# Copyright 2000 Ikondiscussion.com - All Rights Reserved
# Ikondiscussion is a trademark of Ikondiscussion.com
#
# Software Distributed by: Ikondiscussion.com
# Visit us online at http://www.ikondiscussion.com
# Email us on boards@ikondiscussion.com
#
# All files written by Matthew Mecham
#############################################################
#use CGI::Carp "fatalsToBrowser"; # Output errors to browser
use CGI qw(:standard); # Saves loads of work
$CGI::POST_MAX=1024 * 150; # limit post data
$CGI::DISABLE_UPLOADS = 1; # Disable uploads
eval {
($0 =~ m,(.*)/[^/]+,) and unshift (@INC, "$1");
($0 =~ m,(.*)\\[^\\]+,) and unshift (@INC, "$1");
require "data/progs.cgi"; # Require prog names
require "data/boardinfo.cgi";# Require board info
require "data/styles.cgi"; # Require styles info
require "ikon.lib"; # Require ikonboard ()
};
if ($@) {
print header(-charset=>"gb2312"); print start_html(-title=>"ib2000 出错!");
print "不能够找到文件:$@\n如果您使用的是 Windows 类操作系统,请在每一个程序中更改 require 的设置,填入绝对路径!";
print end_html; exit;
}
$|++; # Unbuffer the output
#################--- Begin the program ---###################
$thisprog = "postings.cgi";
$query = new CGI;
&checkVALIDITY;
$boardurltemp =$boardurl;
$boardurltemp =~ s/http\:\/\/(\S+?)\/(.*)/\/$2/;
$cookiepath = $boardurltemp;
$cookiepath =~ s/$thisprog//sg;
for ('forum','topic','membername','password','action','postno',
'notify','deletepost','previewfirst','intopictitle','intopicdescription',
'inpost','inshowemoticons','inshowsignature','checked','movetoid','leavemessage','posticon') {
next unless defined $_;
next if $_ eq 'SEND_MAIL';
$tp = $query->param($_);
$tp = &cleaninput("$tp");
${$_} = $tp;
}
$inforum = $forum;
$intopic = $topic;
$inmembername = $membername;
$inpassword = $password;
$inpostno = $postno;
$innotify = $notify;
$indeletepost = $deletepost;
$inleavemessage= $leavemessage;
$currenttime = time;
$inposticon = $posticon;
# Begin Program
if ($inshowemoticons ne "yes") { $inshowemoticons eq "no"; }
if ($innotify ne "yes") { $innotify eq "no"; }
print header(-charset=>"gb2312");
if (($inforum) && ($inforum !~ /^[0-9]+$/)) { &error("普通&请不要修改生成的 URL!"); }
if (($intopic ) && ($intopic !~ /^[0-9]+$/)) { &error("普通&请不要修改生成的 URL!"); }
if (($inpostno) && ($inpostno !~ /^[0-9]+$/)) { &error("普通&请不要修改生成的 URL!"); }
if (($movetoid) && ($movetoid !~ /^[0-9]+$/)) { &error("普通&请不要修改生成的 URL!"); }
if (! $inmembername) { $inmembername = cookie("amembernamecookie"); }
if (! $inpassword) { $inpassword = cookie("apasswordcookie"); }
if ($inmembername eq "") {
$inmembername = "客人";
}
else {
&getmemberstime("$inmembername");
}
if ($arrawpostpic eq "on") { $postpicstates = "允许";} else {$postpicstates = "禁止";}
if ($arrawpostfontsize eq "on") { $postfontsizestates = "允许";} else {$postfontsizestates = "禁止";}
if ($arrawpostsound eq "on") { $postsoundstates = "允许";} else {$postsoundstates = "禁止";}
# Begin Program
my %Mode = (
'edit' => \&editform,
'lock' => \&lockthread,
'unlock' => \&unlockthread,
'delete' => \&deletethread,
'movetopic' => \&movetopic
);
if($Mode{$action}) {
$Mode{$action}->();
}
elsif ($action eq "processedit" && $indeletepost eq "yes") { &deletepost; }
elsif ($action eq "processedit" && $previewfirst eq "no") { &processedit; }
elsif ($action eq "processedit" && $previewfirst eq "yes") { &editform; }
else { &error("常规&请以正常方式访问本程序!"); }
&output(
-Title => $boardname,
-ToPrint => $output,
-Version => $versionnumber
);
############# subs
sub movetopic {
&getmember("$inmembername");
&moderator;
$cleartomove = "no";
&mischeader("移动主题");
if (($membercode eq "ad") && ($inpassword eq $password)) { $cleartomove = "yes"; }
if (($inmembmod eq "yes") && ($inpassword eq $password)) { $cleartomove = "yes"; }
unless ($cleartomove eq "yes") { $cleartomove = "no"; }
if ($cleartomove eq "no" && $checked eq "yes") { &error("移动主题&您不是坛主或版主,或者您的密码错误!"); }
if (($cleartomove eq "yes") && ($checked eq "yes") && ($movetoid)) {
### Get a new thread number.
$dirtoopen = "$ikondir" . "forum$movetoid";
opendir (DIR, "$dirtoopen");
@numberdata = readdir(DIR);
closedir (DIR);
if ($movetoid == $inforum) { &error("移动主题&不允许在同个论坛上移动主题!"); }
@sorteddirdata = grep(/thd$/,@numberdata);
@sorteddirdata = sort numerically(@sorteddirdata);
@sorteddirdata = reverse(@sorteddirdata);
$highestno = @sorteddirdata[0];
$highestno =~ s/.thd//;
$newthreadnumber = $highestno + 1;
$currenttime = time;
### Get the old forum name
$filetoopen = "$ikondir" . "data/allforums.cgi";
open(FILE, "$filetoopen");
@forums = <FILE>;
close(FILE);
foreach $forumline (@forums) { #start foreach @forums
($tempno, $trash) = split(/\|/,$forumline);
if ($inforum eq $tempno) {
($trash, $trash, $trash, $oldforumname, $trash) = split(/\|/,$forumline);
}
}
### Get the new forum name
foreach $forumline (@forums) { #start foreach @forums
($tempno, $trash) = split(/\|/,$forumline);
if ($movetoid eq $tempno) {
($trash, $trash, $trash, $newforumname, $trash) = split(/\|/,$forumline);
}
}
unless ($inleavemessage eq "no") {
$inpostaddon = "<p>" if ($inpost ne "");
$inpost = qq~***** 版主模式 *****<p>$inpost$inpostaddon<a href="$threadprog?forum=$movetoid&topic=$newthreadnumber" target="_self">贴子由管理员移动到这里</a>~;
$filetoopen = "$ikondir" . "forum$inforum/$intopic.thd";
if (-e $filetoopen) {
open(FILE, "$filetoopen") or &error("移动主题&这个主题不存在!");
@allmessages = <FILE>;
close(FILE);
}
else { unlink ("$ikondir" . "forum$inforum/$intopic.pl"); &error("移动主题&这个主题不存在!可能已经被删除!"); }
$linetokeep = @allmessages[0];
chomp $linetokeep;
($trash, $topictitle, $trash) = split(/\|/,$linetokeep);
$inforumtemp = $inforum;
$filetomake = "$ikondir" . "forum$inforum/$intopic.thd";
open(FILE, ">$filetomake");
flock(FILE, 2) if ($OS_USED eq "Unix");
foreach $messages (@allmessages) {
chomp $messages;
print FILE "$messages\n";
}
print FILE "$inmembername|$topictitle|$ENV{'REMOTE_ADDR'}|yes|yes|$currenttime|$inpost|$inposticon|";
close(FILE);
$threadposts = @allmessages;
my $file = "$ikondir" . "forum$inforum/$intopic.pl";
open (ENT, $file);
$in = <ENT>;
close (ENT);
($topicid, $topictitle, $topicdescription, $threadstate, $threadposts ,$threadviews, $startedby, $startedpostdate, $lastposter, $lastpostdate, $lastinposticon) = split(/\|/,$in);
open(FILE, ">$file");
flock(FILE, 2) if ($OS_USED eq "Unix");
$threadposts++;
$topicdescription2 = $topicdescription;
print FILE "$intopic|$topictitle|此贴已被管理员$inmembername转移至: <a href=\"$forumsprog?forum=$movetoid\" target=\"_self\">$newforumname</a>|closed|$threadposts|$threadviews|$startedby|$startedpostdate|$inmembername|$currenttime|$lastinposticon|";
close(FILE);
} # end if inleavemessage eq yes
my $file = "$ikondir" . "forum$inforum/$intopic.pl";
open (ENT, $file);
$in = <ENT>;
close (ENT);
($topicid, $topictitle, $topicdescription1, $threadstate, $threadposts ,$threadviews, $startedby, $startedpostdate, $lastposter, $lastpostdate, $lastinposticon) = split(/\|/,$in);
my $file = "$ikondir" . "forum$movetoid/$newthreadnumber.pl";
open(FILE, ">$file");
flock(FILE, 2) if ($OS_USED eq "Unix");
print FILE "$newthreadnumber|$topictitle|此贴转移自: <a href=\"$boardurl/$forumsprog?forum=$inforum\" target=\"_self\">$oldforumname</a>|open|$threadposts|$threadviews|$startedby|$startedpostdate|$inmembername|$currenttime|$lastinposticon|";
close(FILE);
### Pick up old forum messages
$filetoopen = "$ikondir" . "forum$inforum/$intopic.thd";
open(FILE, "$filetoopen");
@oldforummessages = <FILE>;
close(FILE);
$oldthreadposts = @oldforummessages - 1;
### Print to new forum message file
$filetomake = "$ikondir" . "forum$movetoid/$newthreadnumber.thd";
open(FILE, ">$filetomake");
flock(FILE, 2) if ($OS_USED eq "Unix");
foreach $message (@oldforummessages) {
chomp $message;
print FILE "$message\n";
}
close(FILE);
### Update the post counts and lastposter details.
$filetoopen = "$ikondir" . "data/allforums.cgi";
open(FILE, "$filetoopen");
@allforums = <FILE>;
close(FILE);
$filetomake = "$ikondir" . "data/allforums.cgi";
open(FILE, ">$filetomake");
flock(FILE, 2) if ($OS_USED eq "Unix");
foreach $forum (@allforums) { #start foreach @forums
chomp($forum);
($tempno, $trash) = split(/\|/,$forum);
if ($inforum eq $tempno) {
($forumid, $category, $categoryplace, $forumname, $forumdescription, $forummoderator ,$htmlstate ,$idmbcodestate ,$privateforum, $startnewthreads ,$lastposter ,$lastposttime, $threads, $posts, $forumgraphic) = split(/\|/,$forum);
if ($inleavemessage eq "no") { #删除原贴
$threads--;
$posts = $posts - $threadposts;
}
else { $posts++; }
$currenttime = time;
print FILE "$forumid|$category|$categoryplace|$forumname|$forumdescription|$forummoderator|$htmlstate|$idmbcodestate|$privateforum|$startnewthreads|$inmembername|$currenttime|$threads|$posts|$forumgraphic|\n";
}
elsif ($movetoid eq $tempno) {
($forumid, $category, $categoryplace, $forumname, $forumdescription, $forummoderator ,$htmlstate ,$idmbcodestate ,$privateforum, $startnewthreads ,$lastposter ,$lastposttime, $threads, $posts, $forumgraphic) = split(/\|/,$forum);
$currenttime = time;
$threads++;
$posts = $posts + $threadposts;
print FILE "$forumid|$category|$categoryplace|$forumname|$forumdescription|$forummoderator|$htmlstate|$idmbcodestate|$privateforum|$startnewthreads|$inmembername|$currenttime|$threads|$posts|$forumgraphic|\n";
}
else { print FILE "$forum\n"; }
}
close(FILE);
if ($inleavemessage ne "no") { #不删除原贴
require "$ikondir" . "data/boardstats.cgi";
$filetomake = "$ikondir" . "data/boardstats.cgi";
$totalthreads++;
$totalposts = $totalposts + $threadposts + 1;
open(FILE, ">$filetomake");
flock(FILE, 2) if ($OS_USED eq "Unix");
print FILE "\$lastregisteredmember = \"$lastregisteredmember\"\;\n";
print FILE "\$totalmembers = \"$totalmembers\"\;\n";
print FILE "\$totalthreads = \"$totalthreads\"\;\n";
print FILE "\$totalposts = \"$totalposts\"\;\n";
print FILE "\n1\;";
close (FILE);
}
if ($inleavemessage ne "yes") {
### Delete the old listings first delete the old thread file
$filetounlink = "$ikondir" . "forum$inforum/$intopic.thd";
unlink $filetounlink;
### Now we have to trash it from the list.cgi
my $file = "$ikondir" . "forum$inforum/$intopic.pl";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -