www.pudn.com > bbs3000afree.zip > newtopic.cgi
#!/usr/bin/perl
#------------------------------------------------------#
# 本程序为Yuzi工作室提供 #
# Yuzi论坛3000(BBS3000)v4.00 #
#------------------------------------------------------#
$cgipa="."; # CGI程序文件的绝对路径
######################
## 以下部分不需修改 ##
######################
require "$cgipa/setup.cgi";
&GetCookies;
#########
if($ENV{'QUERY_STRING'}) {
@pairs = split(/&/,$ENV{'QUERY_STRING'});
foreach $pair (@pairs) {
($name, $value) = split(/=/,$pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$value =~ s///g;
$value =~ s/\t/--/g;
$value =~ s/>/>/g;
$value =~ s/</g;
$FORM{$name} = $value;
}
}else{
binmode STDIN;
read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
($boundary=$ENV{'CONTENT_TYPE'}) =~ s/^.*boundary=(.*)$/$1/;
@pairs=split(/--$boundary/, $buffer);
for $pair (@pairs) {
($dump,$line,$value) = split(/\r\n/,$pair,3);
if($line =~ /filename/) {
$real_file = $line;
}
next if $line =~ /filename=\"\"/;
$line =~ s/^Content-Disposition: form-data; //;
(@column) = split(/;\s+/, $line);
($name = $column[0]) =~ s/^name="([^"]+)"$/$1/g;
if($#column > 0) {
($dump,$dump,$value) = split(/\r\n/,$value,3);
}else {
($dump,$value) = split(/\r\n/,$value,2);
next if $value =~ /^\s*$/;
$FORM{$name} = $value;
chop($FORM{$name});
chop($FORM{$name});
next;
}
$FORM{$name} = $value;
}
}
##################
$menu= $FORM{'menu'};
$id=$FORM{'id'};
$username=$FORM{'username'};
$userpsd=$FORM{'userpsd'};
$titles=$FORM{'titles'};
$emote=$FORM{'emote'};
$comment=$FORM{'comment'};
$titles=~s/>/>/g;
$titles=~s/</g;
$titles=~s/\t/ /g;
$titles=~s/\n/\
/g;
$titles=~s///g;
$comment=~s///g;
$comment=~s/\t/ /g;
$comment=~s/>/>/g;
$comment=~s/</g;
$comment=~s/\n/\
/g;
if ($menu eq "upfile"){&upfile;exit;}
if($ybbcodeAllow ne "on"){$ybbestate="不";}
if($Cookies{xuansave}){$savechecked=checked;}
$maxkk=$maxfj/1024;
&css;
print <function HighlightAll(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
therange=tempval.createTextRange()
therange.execCommand("Copy")}
function DoTitle(addTitle) {
var currentTitle = document.form.titles.value;
revisedTitle = currentTitle+addTitle;
document.form.titles.value=revisedTitle;
return; }
var MessageMax="$restrictbyte";
var Override="";
function CheckLength(){
MessageLength=document.form.comment.value.length;
message="";
if(MessageMax !=0) {
message="最大字符为 "+MessageMax+ " 字节";
}else{
messag ="";
}
alert(message+"\\n您的内容已有 "+MessageLength+" 字节");
}
function ValidateForm(){
usernameLength=document.form.username.value.length;
if(usernameLength<1){alert("请输入用户名称!");return false;}
userpsdLength=document.form.userpsd.value.length;
if(userpsdLength<1){alert("请输入用户密码!");return false;}
titlesLength=document.form.titles.value.length;
if(titlesLength<2){alert("文章标题不能小于2个字符!");return false;}
MessageLength =document.form.comment.value.length;
errors="";
if(MessageLength<2){
errors="文章内容不能小于2个字符!";
}
if(MessageMax !=0){
if(MessageLength > MessageMax){
errors="本论坛限制文章长度不得超过 "+MessageMax+" 字节\\n目前您的文章字节: "+MessageLength;
}
}
if(errors != "" && Override == ""){
alert(errors);
return false;
}else{
document.form.submit1.disabled = true;
return true;
}
}
function emoticon(theSmilie){
document.form.comment.value += theSmilie + ' ';
document.form.comment.focus();
}
var i=0;
function presskey(eventobject){if(event.ctrlKey && window.event.keyCode==13){i++;if (i>1) {alert('帖子正在发出,请耐心等待!');return false;}this.document.form.submit();}}
您当前的位置:$FORM{'bbsname'} >> 发表文章 $outurl
EOF
exit;
sub upfile {
&origin;
if(length($username) > 20){&errorview("您的名字不能大于20个字符!");}
open (FILE, "$filepath/data/prison");
@ips = ;
close(FILE);
foreach $prison(@ips) {
($prison)=split(/\t/,$prison);
if ($prison eq $username) {&errorview("您被抓进监狱,无法发表文章!");}}
if($id eq "" || $id eq "."){&monitor;}
$yhzlurl ="$filepath/yhzl/$username.cgi";
if($regok eq "0"){unless(-f $yhzlurl){
open(PSD,">$yhzlurl");
print PSD $userpsd."\t".$username."\t\t\t".$lasttime;
close(PSD);
chmod(0666,$yhzlurl);}}
open(PSD,"$yhzlurl")||&errorview("对不起,此用户名还没有注册!");
$liness=;
close(PSD);
($rdpassword,$rdname,$rdmail,$rdhome,$rlast,$rdqm,$rdsex,$rdwork,$rdcity,$rdlove,$rfy,$rhf,$tu,$jiao,$iewin,$QQ,$photo,$savecookie)=split(/\t/,$liness);
if($rdpassword ne $userpsd){&errorview("对不起,您的密码错误!");}
$upfile = $FORM{'file_name'};
$filelen=length($upfile);
if($filelen > 0){
@a=split(/\"/,$real_file);
@b=split(/\\/,$a[3]);
$t=@b;
$org_name=($b[$t-1]);
$org_name=~ tr/ /_/;
($filenameleft,$filenameright)= split(/\./,$org_name);
if ($filelen > $maxfj){&errorview("上传附件超长!您上传的附件长度是 $filelen byte, 本站接受的附件最大长度是 $maxfj byte!");exit;}
$filenameright=~tr/A-Z/a-z/;
unless(-e "$ImgDir/genre/$filenameright.gif"){&errorview("本系统不支持这种格式的文件!");}
$filename = "$ImgDir/affix/$ftime.$filenameright";
open(FILE,">$filename")||&errorview("系统无法建立文件,请检查 $ImgDir/affix 目录属性是否为“777”");
binmode FILE;
print FILE $upfile;
close FILE;
chmod("$filename",0777);
$sizek=$filelen/1024;
($sizek)=split(/\./,$sizek);
if($sizek eq "0"){$sizek=1};
$comment.="
与此主题相关的附件(大小:$sizek K)";
if($filenameright eq "gif" || $filenameright eq "bmp" || $filenameright eq "jpeg" || $filenameright eq "jpg"){$comment.="
";}
elsif($filenameright eq "mid" || $filenameright eq "wav"){$comment.="