⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 upload.pl

📁 这个社区是虚拟社区使用的程序
💻 PL
字号:
#!/usr/bin/perl

###############################################################################
# upload.pl                                                                   #
###############################################################################
# UltraBoard Ver. 1.61 modified by LastSun                                    #
# --------------------------------------------------------------------------- #
# PROGRAM NAME : Image Attachment                                             #
# VERSION : 0.99                                                              #
# LAST MODIFIED : 01/06/2000                                                  #
# Used for UltraBoard v1.61    Info available below                           #
#                                                                             #
# PROGRAM NAME : UltraBoard                                                   #
# VERSION : 1.61                                                              #
# LAST MODIFIED : 01/06/2000                                                  #
###############################################################################

eval {
	($0 =~ m,(.*)/[^/]+,)   && unshift (@INC, "$1"); # Get the script location: UNIX / or Windows /
	($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \
	require "/cgi-bin/vrbbs/Variables/System.cfg";
	require "/cgi-bin/vrbbs/Variables/Style.cfg";
};
$SAVE_DIRECTORY = "/vrcdata/UserImages";	# This is the path to the location where images should be saved.
$SAVE_HTTP = "http://www.yourweb.com/vrcdata/UserImages";		# This is the HTTP location of the saved files directory. Both this line, and the above line should work fine if you installed UltraBoard in its default location.
$MAXIMUM_UPLOAD = 15360;			# File size limit, in BYTES. Default is 20k. Set to 0 for no limit.
#### Don't configure below this line ######################################################################

$| = 1;
# chop $SAVE_DIRECTORY if ($SAVE_DIRECTORY =~ /\/$/);
use CGI qw(:standard);
$query = new CGI;

$Mark=0;
foreach $key1 (sort {$a <=> $b} $query->param()) {
	next if ($key1 =~ /^\s*$/);
	next if ($query->param($key1) =~ /^\s*$/);
	next if ($key1 !~ /^uref$/);
	$Number = $1;

	if ($query->param($key1) =~ /([^\/\\]+)$/) {
		$user_ref = $1;
		$user_ref =~ s/^\.+//;
		if (-e "/cgi-bin/vrc/UBData/Sessions/$user_ref"){
			$Mark=1;
			($UserName)=split(/\./,$user_ref);
		}
	}
}

if($Mark == 0){
	print "Content-type: text/html\n\n";
	print "<html><head>\n";
	print "Ref Error<P>对不起,请先登陆笑傲江湖社区!\n";
	print "<script Language=\"JavaScript\">\n";
	print "  alert(\"对不起,请先登陆笑傲江湖社区!\");\n";
	print "</script></head></html>\n";
	exit;
}

foreach $key (sort {$a <=> $b} $query->param()) {
	next if ($key =~ /^\s*$/);
	next if ($query->param($key) =~ /^\s*$/);
	next if ($key !~ /^file-to-upload-(\d+)$/);
	$Number = $1;
		
	if ($query->param($key) =~ /([^\/\\]+)$/) {
		$Filename = $1;
		$Filename =~ s/^\.+//;
		($PictureName,$NameExt)=split(/\./,$Filename);
		$NameExt=lc($NameExt);
		$Filename=$PictureName."\.".$NameExt;
		$File_Handle = $query->param($key);
			
		unless ($Filename =~ /\.jpg$/i){
			print header;
			print <<__END_OF_HTML_CODE__;
			<HTML>
			<HEAD>
			<TITLE>文件名出错!</TITLE>
			<body text="$TextColor">
			<CENTER><P>
			对不起,你的肖像图片文件后缀名必须是jpg,<A HREF="javascript:history.go(-1)">请选择正确的图片文件</A>。
			</CENTER>
			<BR><BR><BR><BR><BR><BR>
			<!--VirtualAvenueBanner-->
			</BODY>
			</HTML>
__END_OF_HTML_CODE__

			exit;
			}
		} else {
			$FILENAME_IN_QUESTION = $query->param($key);
			print header;
			print <<__END_OF_HTML_CODE__;
			<HTML>
			<HEAD>
			<TITLE>文件名出错!</TITLE>
			<body text="$TextColor">
			<CENTER><P>
			You attempted to upload a file that isn't properly formatted.  Please rename the file on your computer, and
			<A HREF="javascript:history.go(-1)">attempt to upload it again</A>. Files may not have forward or backward slashes in their 
			names. Also, they may not be prefixed with one (or more) periods.
			</CENTER>
			<BR><BR><BR><BR><BR><BR>
			<!--VirtualAvenueBanner-->
			</BODY>
			</HTML>
__END_OF_HTML_CODE__

			exit;
		}

		if($PictureName ne $UserName){
			print "Content-type: text/html\n\n";
			print "<html><head>\n";
			print "UserName Error<P>对不起,你上传的文件名和你的用户名不相同!\n";
			exit;
		}

		if (-e "$SAVE_DIRECTORY/$Filename") {
			print header;
			print <<__END_OF_HTML_CODE__;
			<HTML>
			<HEAD>
			<TITLE>文件已经存在!</TITLE>
			<body text="$TextColor">
			<CENTER><P>
			$PictureName
			你欲上传的肖像图片 "$Filename" 文件已经存在!请确定这个文件名是你在社区时注册的ID!</CENTER>
			<BR><BR><BR><BR><BR><BR>
			<!--VirtualAvenueBanner-->
			</BODY>
			</HTML>
__END_OF_HTML_CODE__
			exit;
		}
		open(OUTFILE, ">$SAVE_DIRECTORY\/$Filename");	
		undef $BytesRead;
		undef $Buffer;

		while ($Bytes = read($File_Handle,$Buffer,2096)) {
			$BytesRead += $Bytes;
	        binmode OUTFILE;
			print OUTFILE $Buffer;
        }
		
		push(@Files_Written, "$SAVE_DIRECTORY\/$Filename");
		$TOTAL_BYTES += $BytesRead;
		$Confirmation{$File_Handle} = $BytesRead;

        close($File_Handle);
		close(OUTFILE);
		chmod 0666,"$SAVE_DIRECTORY\/$Filename";
    }

	$FILES_UPLOADED = scalar(keys(%Confirmation));

	if ($TOTAL_BYTES > $MAXIMUM_UPLOAD && $MAXIMUM_UPLOAD > 0) {
		foreach $File (@Files_Written) {
			unlink $File;
		}
		
		print header;
		print <<__END_OF_HTML_CODE__;
		<HTML>
		<HEAD>
		<TITLE>错误!</TITLE>
		<body text="$TextColor">
		<CENTER><P>
		对不起,你准备上传的肖像图片文件 "$Filename" 太大了!足足有 <font color=red>$TOTAL_BYTES</font> 个字节<br>
		<b>请确认:</b>文件不得超过 $MAXIMUM_UPLOAD 个字节。<br>
		<A HREF="javascript:history.go(-1)">请重新上传规则大小的图片文件!</A>
		</CENTER>
		<BR><BR><BR><BR><BR><BR>
		<!--VirtualAvenueBanner-->
		</BODY>
		</HTML>
__END_OF_HTML_CODE__
		exit;
	}

if (($TOTAL_BYTES eq $null) || ($TOTAL_BYTES == 0)) {
	print header;
	print <<__END_OF_HTML_CODE__;
	<HTML>
	<HEAD>
	<TITLE>有没有搞错?</TITLE>
	<body text="$TextColor">
	<CENTER><P>
	有没有搞错?你根本就没有选择你的肖像图片!<br>
	虽然我是一个系统精灵,可您也别拿我开涮呀!<br>
	<A HREF="javascript:history.go(-1)">请重新上传</A></CENTER>
	<BR><BR><BR><BR><BR><BR>
	<!--VirtualAvenueBanner-->
	</BODY>
	</HTML>
__END_OF_HTML_CODE__
exit;
}

print header;
print qq(
<html>
<head>
<title>上传完毕!</title>
</head>
<body text="$TextColor">
<div align="center"><center>
<table border="0" cellpadding="0" cellspacing="0" width="$TableWidth" bgcolor="$TableBorderColor">
<tr>
<td><table border="0" cellpadding="$TableCellPadding" cellspacing="$TableCellSpacing" width="100%">
<tr>
<td valign="top" colspan="2" bgcolor="$HeaderBGColor"><font color="$HeaderTextColor" size="2" face="$FontFace"><b>
恭喜!恭喜!
</b></font></td>
</tr>
<tr>
<td align="center" colspan="2" bgcolor="$CategoryBGColor"><table border="0" cellpadding="10" cellspacing="10" width="100%">
<tr>
<td align="center">
<FONT FACE="$FontFace" SIZE="2">
你的肖像$Filename已经成功上传完毕,效果如下:
</FONT>
<P>
<FONT FACE="$FontFace" SIZE="2"><img src=$SAVE_HTTP/$Filename></FONT><P>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" colspan="2" bgcolor="$HeaderBGColor"><table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="center"><font color="$HeaderTextColor" size="2" face="$FontFace"></font><a href="http://www.yourweb.com/cgi-bin/vrc/UltraBoard.pl?Action=UploadImage&Post=$in{'Post'}&Board=$in{'Board'}&ID=0&Idle=$in{'Idle'}&Sort=$in{'Sort'}&Order=$in{'Order'}&Page=$in{'Page'}&Session=$user_ref" target="_blank" title="我很喜欢这个肖像,我确定就使用它了!"><font size="2" face="$FontFace">看看效果!</font></a></td>
</tr>
<tr>
<td align="right"><font color="$HeaderTextColor" size="1" face="$FontFace">Copyright by </font><a href="http://www.ultrascripts.com/" target="_blank" title="UltraBoard v1.61"><font size="1" face="$FontFace">www.ultrascripts.com</font></a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center></div>
</BODY>
<!--VirtualaveAvenueBanner-->
</HTML>
);
exit;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -