<!-- #include file=../../inc/BBSsetup.asp -->
<!-- #include file=../../inc/Upload_Setup.asp -->
<!-- #include file=../../inc/Board_popfun.asp -->
<!-- #include file=../inc/bbsmanage_Fun.asp -->
<%
DEF_BBS_HomeUrl = "../../"
Const MaxLinkNum = 100
Dim GBL_ID
initDatabase
GBL_CHK_TempStr = ""
GBL_ID = CheckSupervisorPass

Dim ReqN,WriteN
Dim Form_DEF_BBS_UploadPhotoUrl,Form_DEF_EnableDotNetUpload,Form_DEF_UploadFileType
Dim Form_DEF_FileMaxBytes,Form_DEF_FaceMaxBytes
Dim Form_DEF_UploadSpendPoints,Form_DEF_UploadOneDayMaxNum,Form_DEF_UploadFaceNeedPoints
Dim Form_DEF_UploadVersionString

GetDefaultValue

SiteHead(DEF_SiteNameString & " - 管理员")
UserTopicTopInfo
DisplayUserNavigate("论坛上传参数设置")
If GBL_CHK_Flag=1 Then
	SiteLink
Else%>
	<table width=96%>
	<tr>
	<td>
	<%
	If Request("submitflag")="" Then
		Response.Write "<br><b>请先登录</b>"
	Else
		Response.Write "<br><p align=left><font color=ff0000 class=RedFont><b>" & GBL_CHK_TempStr & "</b></font>"
	End If
	DisplayLoginForm
	Response.Write "</p>"%>
	</td>
	</tr>
	</table>
<%End If
UserTopicBottomInfo
closeDataBase
SiteBottom
If GBL_ShowBottomSure = 1 Then Response.Write GBL_SiteBottomString

Function SiteLink

ReqN = 0
WriteN = 0
%>
<form name="pollform3sdx" method="post" action="UploadSetup.asp">
<input type="hidden" name="SubmitFlag" value=yes>
<p>
	<b>
		<a href=SiteSetup.asp>论坛常用参数设置</a> <font color=gray class=GrayFont>上传参数设置</font>
		<a href=../User/UserSetup.asp>用户注册参数设置</a>
		<a href=UbbcodeSetup.asp>UBB编码参数设置</a>
		</b>
		<br><font color=8888888 class=GrayFont>(下面为网站参数，请注意修改，错误的设置将会发生严重错误)<br><br>
		如果在设置后发现网站不能正常运行，请将LeadBBS最新版的inc/Upload_Setup.asp覆盖回去</font>
</p>
<%If Request.Form("SubmitFlag") <> "" Then
	CheckLinkValue
End If%>
<b><font color=ff0000 class=RedFont><%=GBL_CHK_TempStr%></font></b>
<p>
<%
If Request.Form("SubmitFlag") <> "" Then
	If GBL_CHK_TempStr <> "" Then
		DisplayDatabaseLink
	Else
		MakeDataBaseLinkFile
		Exit Function
	End If
Else
	DisplayDatabaseLink
End If
%>
<br>
<input type=submit name=提交 value=提交 class=fmbtn>
<input type=reset name=取消 value=取消 class=fmbtn>
</form>
<%

End Function

Function CheckLinkValue

	GetFormValue

End Function

Function DisplayDatabaseLink

		%>
		<table border=0 cellpadding=5 cellspacing=1 width="100%" bgcolor="<%=DEF_BBS_LightColor%>" class=TBBG1>
		<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
			<td width=50>上传目录</td>
			<td><input class=fminpt type="text" name="Form_DEF_BBS_UploadPhotoUrl" maxlength="50" size="30" value="<%=htmlencode(Form_DEF_BBS_UploadPhotoUrl)%>"><font color=gray> 默认为images/upload/，相对于论坛根目录而言</font></td>
		</tr>
		<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
			<td>上传方式</td>
			<td><table border=0 cellpadding=0 cellspacing=0><tr>
				<td><input class=fmchkbox type=radio name=Form_DEF_EnableDotNetUpload value=0<%If Form_DEF_EnableDotNetUpload = 0 Then%> checked<%End If%>></td><td>FileUp组件上传</td>
          		<td><input class=fmchkbox type=radio name=Form_DEF_EnableDotNetUpload value=1<%If Form_DEF_EnableDotNetUpload = 1 Then%> checked<%End If%>></td><td>使用.Net上传</td>
          		<td><input class=fmchkbox type=radio name=Form_DEF_EnableDotNetUpload value=2<%If Form_DEF_EnableDotNetUpload = 2 Then%> checked<%End If%>></td><td>使用无组件</td>
          		</tr></table></td>
		</tr>
		<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
			<td width=50>上传类型</td>
			<td><input class=fminpt type="text" name="Form_DEF_UploadFileType" maxlength="1024" size="50" value="<%=htmlencode(Form_DEF_UploadFileType)%>"><font color=gray><br>定义上传所允许的文件类型，扩展名必须小写，用冒号分隔</font></td>
		</tr>
		<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
			<td>文件大小</td>
			<td><input class=fminpt type="text" name="Form_DEF_FileMaxBytes" maxlength="8" size="10" value="<%=htmlencode(Form_DEF_FileMaxBytes)%>"><font color=gray>(自定义允许上传文件的最大值，单位字节)</font></td>
		</tr>
		<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
			<td>头像大小</td>
			<td><input class=fminpt type="text" name="Form_DEF_FaceMaxBytes" maxlength="8" size="10" value="<%=htmlencode(Form_DEF_FaceMaxBytes)%>"><font color=gray>(自定义允许上传头像的最大值，单位字节，设为零表示禁止)</font></td>
		</tr>
		<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
			<td width=50>上传花费积分</td>
			<td><input class=fminpt type="text" name="Form_DEF_UploadSpendPoints" maxlength="14" size="10" value="<%=htmlencode(Form_DEF_UploadSpendPoints)%>"><font color=gray><br>用户每上传一个附件所消耗的积分值，正数为加，负数为减，零为不变</font></td>
		</tr>
		<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
			<td width=50>每日上传数量</td>
			<td><input class=fminpt type="text" name="Form_DEF_UploadOneDayMaxNum" maxlength="14" size="10" value="<%=htmlencode(Form_DEF_UploadOneDayMaxNum)%>"><font color=gray><br>限制用户每天允许上传的最多附件个数，不能设置得大于100，设置为0表示无限制</font></td>
		</tr>
		<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
			<td width=50>上传头像需要积分</td>
			<td><input class=fminpt type="text" name="Form_DEF_UploadFaceNeedPoints" maxlength="14" size="10" value="<%=htmlencode(Form_DEF_UploadFaceNeedPoints)%>"><font color=gray><br>限制用户只有积分值大于此值才能上传论坛头像</font></td>
		</tr>
		<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
			<td width=50>水印生成</td>
			<td><input class=fminpt type="text" name="Form_DEF_UploadVersionString" maxlength="50" size="30" value="<%=htmlencode(Form_DEF_UploadVersionString)%>"><font color=gray> 在上传的图片附件上面自动生成水印文字</font></td>
		</tr>
		</table>
		<%

End Function

Function GetDefaultValue

	Form_DEF_BBS_UploadPhotoUrl = DEF_BBS_UploadPhotoUrl
	Form_DEF_EnableDotNetUpload = DEF_EnableDotNetUpload
	Form_DEF_UploadFileType = DEF_UploadFileType	
	Form_DEF_FileMaxBytes = DEF_FileMaxBytes
	Form_DEF_FaceMaxBytes = DEF_FaceMaxBytes
	Form_DEF_UploadSpendPoints = DEF_UploadSpendPoints
	Form_DEF_UploadOneDayMaxNum = DEF_UploadOneDayMaxNum
	Form_DEF_UploadFaceNeedPoints = DEF_UploadFaceNeedPoints
	Form_DEF_UploadVersionString = DEF_UploadVersionString

End Function

Function GetFormValue

	Form_DEF_BBS_UploadPhotoUrl = Trim(Request.Form("Form_DEF_BBS_UploadPhotoUrl"))
	Form_DEF_EnableDotNetUpload = Trim(Request.Form("Form_DEF_EnableDotNetUpload"))
	Form_DEF_UploadFileType = Trim(Request.Form("Form_DEF_UploadFileType"))
	Form_DEF_FileMaxBytes = Trim(Request.Form("Form_DEF_FileMaxBytes"))
	Form_DEF_FaceMaxBytes = Trim(Request.Form("Form_DEF_FaceMaxBytes"))
	Form_DEF_UploadSpendPoints = Trim(Request.Form("Form_DEF_UploadSpendPoints"))
	Form_DEF_UploadOneDayMaxNum = Trim(Request.Form("Form_DEF_UploadOneDayMaxNum"))
	Form_DEF_UploadFaceNeedPoints = Trim(Request.Form("Form_DEF_UploadFaceNeedPoints"))
	Form_DEF_UploadVersionString = Trim(Request.Form("Form_DEF_UploadVersionString"))

	If inStr(Form_DEF_BBS_UploadPhotoUrl,"""") Then GBL_CHK_TempStr = "上传目录不能包含有引号<br>" & VbCrLf
	If isNumeric(Form_DEF_EnableDotNetUpload) = 0 Then GBL_CHK_TempStr = "上传方式必须为数字<br>" & VbCrLf
	If inStr(Form_DEF_UploadFileType,"""") Then GBL_CHK_TempStr = "上传类型不能包含有引号<br>" & VbCrLf
	Form_DEF_UploadFileType = LCase(Form_DEF_UploadFileType)
	
	Dim FobType,N
	FobType = Array("htw","ida","asp","asa","idq","cer","cdx","htr","idc","shtm","shtml","stm","printer","asax","ascx","ashx","asmx","aspx","axd","vsdisco","rem","soap","config","cs","csproj","vb","vbproj","webinfo","licx","resx","resources")
	For N = 0 to Ubound(FobType)
		If inStr(Form_DEF_UploadFileType,":." & FobType(N) & ":") Then
			GBL_CHK_TempStr = "为了安全，上传类型不能使用扩展名 " & FobType(N) & " ！<br>" & VbCrLf
			Exit Function
		End If
	Next
	If isNumeric(Form_DEF_FileMaxBytes) = 0 Then GBL_CHK_TempStr = "上传文件大小必须为数字<br>" & VbCrLf
	If isNumeric(Form_DEF_FaceMaxBytes) = 0 Then GBL_CHK_TempStr = "上传头像大小必须为数字<br>" & VbCrLf
	If isNumeric(Form_DEF_UploadSpendPoints) = 0 Then GBL_CHK_TempStr = "上传花费积分值必须为数字<br>" & VbCrLf
	If isNumeric(Form_DEF_UploadOneDayMaxNum) = 0 Then GBL_CHK_TempStr = "每日上传附件数量必须为数字<br>" & VbCrLf
	If isNumeric(Form_DEF_UploadFaceNeedPoints) = 0 Then GBL_CHK_TempStr = "上传头像需要积分必须为数字<br>" & VbCrLf
	If inStr(Form_DEF_UploadVersionString,"""") Then GBL_CHK_TempStr = "上传文件水印标识不能包含有引号<br>" & VbCrLf

End Function

Function MakeDataBaseLinkFile

	Dim n,TempStr
	TempStr = ""
	TempStr = TempStr & chr(60) & "%" & VbCrLf
	TempStr = TempStr & "const DEF_BBS_UploadPhotoUrl=" & Chr(34) & Replace(Form_DEF_BBS_UploadPhotoUrl,Chr(34),Chr(34) & Chr(34)) & Chr(34) & VbCrLf
	TempStr = TempStr & "const DEF_EnableDotNetUpload = " & Form_DEF_EnableDotNetUpload & VbCrLf
	TempStr = TempStr & "const DEF_UploadFileType=" & Chr(34) & Replace(Form_DEF_UploadFileType,Chr(34),Chr(34) & Chr(34)) & Chr(34) & VbCrLf
	TempStr = TempStr & "Const DEF_FileMaxBytes = " & Form_DEF_FileMaxBytes & VbCrLf
	TempStr = TempStr & "Const DEF_FaceMaxBytes = " & Form_DEF_FaceMaxBytes & VbCrLf
	TempStr = TempStr & "Const DEF_UploadSpendPoints = " & Form_DEF_UploadSpendPoints & VbCrLf
	TempStr = TempStr & "Const DEF_UploadOneDayMaxNum = " & Form_DEF_UploadOneDayMaxNum & VbCrLf
	TempStr = TempStr & "Const DEF_UploadFaceNeedPoints = " & Form_DEF_UploadFaceNeedPoints & VbCrLf
	TempStr = TempStr & "const DEF_UploadVersionString=" & Chr(34) & Replace(Form_DEF_UploadVersionString,Chr(34),Chr(34) & Chr(34)) & Chr(34) & VbCrLf

	TempStr = TempStr & "%" & chr(62) & VbCrLf

	ADODB_SaveToFile TempStr,"../../inc/Upload_Setup.asp"
	If GBL_CHK_TempStr = "" Then
		Response.Write "<br><font color=Green class=GreenFont>2.成功完成设置！</font>"
	Else
		%><%=GBL_CHK_TempStr%><br>服务器不支持在线写入文件功能，请使用FTP等功能，将<font color=Red Class=RedFont>../../inc/Upload_Setup.asp</font>文件替换成框中内容(注意备份)<p>
		<textarea name="fileContent" cols="80" rows="30" class=fmtxtra><%=Server.htmlencode(TempStr)%></textarea><%
		GBL_CHK_TempStr = ""
	End If

End Function%>