📄 announcements.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
$CGI::HEADERS_ONCE = 1; # Kill redundant headers
eval {
($0 =~ m,(.*)/[^/]+,) and unshift (@INC, "$1");
($0 =~ m,(.*)\\[^\\]+,) and unshift (@INC, "$1");
require "ikon.lib"; # Require ikonboard ()
require "data/progs.cgi"; # Require prog names
require "data/boardinfo.cgi";# Require board info
require "data/styles.cgi"; # Require styles info
};
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 = "announcements.cgi";
$query = new CGI;
$boardurltemp =$boardurl;
$boardurltemp =~ s/http\:\/\/(\S+?)\/(.*)/\/$2/;
$cookiepath = $boardurltemp;
$cookiepath =~ s/$thisprog//sg;
for ('membername','password','announcementtitle','announcementpost','action','checked','number') {
next unless defined $_;
next if $_ eq 'SEND_MAIL';
$tp = $query->param($_);
$tp = &cleaninput($tp);
${$_} = $tp;
}
$inmembername = $membername;
$inpassword = $password;
$inannouncementtitle = $announcementtitle;
$inannouncementpost = $announcementpost;
if (! $inmembername) { $inmembername = cookie("amembernamecookie"); }
if (! $inpassword) { $inpassword = cookie("apasswordcookie"); }
if ($inmembername eq "") {
$inmembername = "客人";
}
else {
&getmemberstime("$inmembername");
}
### Print Header for the page.
print header(-charset=>"gb2312");
&title;
$output .= qq~
<table cellpadding=0 cellspacing=0 border=0 width=$tablewidth align=center>
<tr>
<td width=30% rowspan=2 valign=top>
<img src="$imagesurl/images/$boardlogo" border=0>
</td>
<td valign=top align=left>
<font face="$font" color=$fontcolormisc>
<img src="$imagesurl/images/closedfold.gif" border=0> <a href="$forumsummaryprog">$boardname</a>
<br>
<img src="$imagesurl/images/bar.gif" border=0><img src="$imagesurl/images/openfold.gif" border=0> 论坛公告
</tr>
</table>
<p>
<table cellpadding=0 cellspacing=0 border=0 width=$tablewidth bgcolor=$tablebordercolor align=center>
<tr>
<td>
<table cellpadding=3 cellspacing=1 border=0 width=100%>
~;
### Startactions
if ($action eq "delete") {
if ($checked eq "yes") {
# Validate user
&getmember("$inmembername");
if ($membercode ne "ad") { print header(-charset=>"gb2312"); &error("使用公告&您不是管理员!"); }
elsif ($inpassword ne $password) { print header(-charset=>"gb2312"); &error("使用公告&您的密码错误!"); }
# Get the announcement to delete
$filetoopen = "$ikondir" . "data/news.cgi";
$filetoopen = &stripMETA($filetoopen);
open(FILE, "$filetoopen") or die "无法定位公告文件!";
@announcements = <FILE>;
close(FILE);
# Write it back minus the one to delete.
$count = 0;
$filetoopen = "$ikondir" . "data/news.cgi";
$filetoopen = &stripMETA($filetoopen);
open(FILE, ">$filetoopen") or die "无法定位公告文件!";
flock (FILE, 2) if ($OS_USED eq "Unix");
foreach $line (@announcements) {
chomp $line;
if ($count ne $number) {
print FILE "$line\n";
}
$count++;
}
close(FILE);
&doend("论坛公告已经被删除");
exit;
} # end checked delete
else {
&login("$thisprog?action=delete&number=$number&checked=yes");
} # end else
} # end action
elsif ($action eq "add") {
&whosonline("$inmembername|公告栏|none|添加公告|");
# Present the form
$output .= qq~
<tr>
<td bgcolor=$miscbacktwo colspan=2 align=center>
<form action="$thisprog" method=post>
<input type=hidden name="action" value="addannouncement">
<font face="$font" color=$fontcolormisc><b>发表论坛公告</b></td>
</tr>
<tr>
<td bgcolor=$miscbackone valign=middle><font face="$font" color=$fontcolormisc>请输入您的名称</font></td>
<td bgcolor=$miscbackone valign=middle><input type=text name="membername" value="$inmembername"0></a></td></tr>
<tr>
<td bgcolor=$miscbackone valign=middle><font face="$font" color=$fontcolormisc>请输入您的密码</font></td>
<td bgcolor=$miscbackone valign=middle><input type=password name="password" value="$inpassword"0></td></tr>
<tr>
<td bgcolor=$miscbackone valign=top width=30%><font face="$font" color=$fontcolormisc><b>论坛公告标题</b></font></td>
<td bgcolor=$miscbackone valign=middle><input type=text name="announcementtitle" size=60 maxlength=100></td>
</tr>
<tr>
<td bgcolor=$miscbackone valign=top width=30%><font face="$font" color=$fontcolormisc><b>论坛公告内容</b><br>请输入您的论坛公告内容。<p>如果使用了表情字符转换,ib2000 将自动在公告中转换表情字符。</font></td>
<td bgcolor=$miscbackone valign=middle><textarea cols=60 rows=10 name="announcementpost"></textarea></td>
</tr>
<tr>
<td bgcolor=$miscbacktwo valign=middle colspan=2 align=center>
<input type=Submit value="递交" name=Submit onClick="return clckcntr();"> <input type="reset" name="Clear"></form>
</td></tr>
~;
} # end action
elsif ($action eq "addannouncement") {
$currenttime = time;
# Validate user
&getmember("$inmembername");
if ($membercode ne "ad") { print header(-charset=>"gb2312"); &error("使用公告&您不是管理员!"); }
elsif ($inpassword ne $password) { print header(-charset=>"gb2312"); &error("使用公告&您的密码错误!"); }
# Check for blanks.
if ($inannouncementpost eq "") { print header(-charset=>"gb2312"); &error("使用公告&请输入论坛公告内容!"); }
if ($inannouncementtitle eq "") { print header(-charset=>"gb2312"); &error("使用公告&请输入论坛公告标题!"); }
# Get the announcement file
$filetoopen = "$ikondir" . "data/news.cgi";
$filetoopen = &stripMETA($filetoopen);
open(FILE, "$filetoopen");
@announcements = <FILE>;
close(FILE);
# Write it back with the new announcement at the top
$newline = "$inannouncementtitle|$currenttime|$inannouncementpost|$inmembername";
chomp $newline;
$filetoopen = "$ikondir" . "data/news.cgi";
$filetoopen = &stripMETA($filetoopen);
open(FILE, ">$filetoopen");
flock(FILE, 2) if ($OS_USED eq "Unix");
print FILE "$newline\n";
foreach $line (@announcements) {
chomp $line;
print FILE "$line\n";
}
close(FILE);
&doend("论坛公告已经发表。");
} # end add announcement
elsif ($action eq "edit") {
&whosonline("$inmembername|公告栏|none|编辑公告|");
# Get the announcement file
$filetoopen = "$ikondir" . "data/news.cgi";
$filetoopen = &stripMETA($filetoopen);
open(FILE, "$filetoopen") or die "无法定位公告文件!";
@announcements = <FILE>;
close(FILE);
# Get the announcement to edit
$count = 0;
foreach (@announcements) {
if ($count eq $number) {
($announcementtitle, $notneeded, $announcementpost,$notneeded) = split(/\|/,$_);
}
$count++;
}
# Clean the text area
$announcementpost =~ s/\<p\>/\n\n/g;
$announcementpost =~ s/\<br\>/\n/g;
# Present the form
if ($badwords) {
@pairs = split(/\&/,$badwords);
foreach (@pairs) {
($bad, $good) = split(/=/,$_);
chop $good;
$announcementtitle =~ s/$bad/$good/isg;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -