<!--#include file="conn.asp" -->
<!--#include file="inc/const.asp"-->
<%
Const allow = 1
Dim Rs1
Dim Rs2
Dim i
Dim founderr
Dim errmsg
Dim sortname
Dim strSortid
Dim GroupSet
Dim GroupName
Dim Rs
Dim SQL
Dim DownloadClass_Ads
Dim NowStats
Dim HtmlTitle
Dim Style_CSS
Dim HtmlTempStr
Dim TempTopStr
Dim TempFootStr
PublishSoft
If IsObject(DownloadClass_Ads) Then
	Set DownloadClass_Ads = Nothing
End If
CloseConn
Public Sub PublishSoft()
	Set Rs = Server.CreateObject("adodb.recordset")
	Set Rs1 = Server.CreateObject("adodb.recordset")
	Set Rs2 = Server.CreateObject("adodb.recordset")
	founderr = False
	If allow <> 0 Then
	 If DownsysClass.memberName = Empty Then
		Response.Write "<script>alert('对不起!你还没有登陆 \n\n如果你是本站会员请先登陆!');location.replace('user.asp')</script>"
		Response.End
	 End If
	 Set Rs = conn.Execute("select * from NC_UserGroup where grades=" & CInt(DownsysClass.membergrade) & "")
	 GroupSet = Split(Rs("GroupSet"), ",")
	 GroupName = Rs("GroupName")
	 Rs.Close
	 If CInt(GroupSet(0)) = 0 Then
		 Response.Write "<script>alert('对不起!" & GroupName & "不能发布软件。');history.go(-1)</script>"
		 Response.End
	 End If
	End If
	DownsysClass.LoadTemplates ("")
	If CInt(DownsysClass.setting(39)) = 0 Then
		Response.Write "<script>alert('" & DownsysClass.mainset(40) & "');javascript:history.back(1)</script>"
		Response.End
	End If
	Set DownloadClass_Ads = New Adcolumn_Cls
	NowStats = "软件发布"
	HtmlTitle = "软件发布"
	TempTopStr = DownsysClass.mainhtml(0) & DownsysClass.mainhtml(1) & DownsysClass.mainhtml(2) & DownsysClass.mainhtml(3)
	TempFootStr = DownsysClass.mainhtml(4)
	Style_CSS = Replace(Replace(DownsysClass.Style_CSS, "{$SetupDir}", DownsysClass.SetupDir), "{$PicUrl}", DownsysClass.TempDir)
	HtmlTempStr = TempTopStr
	HtmlTempStr = Replace(HtmlTempStr, "{$NavMenu}", DownsysClass.SortingMenu)
	HtmlTempStr = Replace(HtmlTempStr, "{$Width}", DownsysClass.mainset(0))
	HtmlTempStr = Replace(HtmlTempStr, "{$Style_CSS}", Style_CSS)
	If CInt(DownsysClass.setting(5)) = 0 Then
		HtmlTempStr = Replace(HtmlTempStr, "{$TopMeun}", DownsysClass.mainset(9))
	Else
		HtmlTempStr = Replace(HtmlTempStr, "{$TopMeun}", DownsysClass.mainset(10))
	End If
	HtmlTempStr = Replace(HtmlTempStr, "{$NowStats}", NowStats)
	HtmlTempStr = Replace(HtmlTempStr, "{$Title}", HtmlTitle)
	HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(0)}", DownloadClass_Ads.RunScriptAds(7))
	HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(1)}", DownloadClass_Ads.BannerAds(7))
	HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(2)}", DownloadClass_Ads.AdsColumn(7, 2))
	HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(3)}", DownloadClass_Ads.AdsColumn(7, 3))
	Response.Write HtmlTempStr
	If CInt(DownsysClass.Setting(5)) = 1 Then
		TempFootStr = Replace(TempFootStr, "{$FootMeun}", DownsysClass.mainset(11))
	Else 
		TempFootStr = Replace(TempFootStr, "{$FootMeun}", DownsysClass.mainset(44))
	End If
	TempFootStr = Replace(TempFootStr, "{$Width}", DownsysClass.mainset(0))
	TempFootStr = Replace(TempFootStr, "{$Adcolumn(4)}", DownloadClass_Ads.ScriptFloatAds(7))
	TempFootStr = Replace(TempFootStr, "{$Adcolumn(5)}", DownloadClass_Ads.ScriptFixedAds(7))
	Select Case Trim(Request("Action"))
		Case "save"
			Call saveAdd
		Case Else
			Call main
	End Select
	If founderr = True Then
		Response.Write "<script>alert('" & errmsg & "');javascript:history.back(1)</script>"
		Response.End
	End If
	Response.Write TempFootStr
End Sub

Private Sub main()
	Dim srtSortingList
	Dim RunSystem
	Dim SoftType
	Response.Write "<script language=""javascript"">" & vbCrLf
	Response.Write "<!--//" & vbCrLf
	Response.Write "function ToRunSystem(addTitle) { " & vbCrLf
	Response.Write "var revisedTitle; " & vbCrLf
	Response.Write "var currentTitle;" & vbCrLf
	Response.Write "currentTitle = document.myform.RunSystem.value; " & vbCrLf
	Response.Write "revisedTitle = currentTitle+addTitle; " & vbCrLf
	Response.Write "document.myform.RunSystem.value=revisedTitle; " & vbCrLf
	Response.Write "document.myform.RunSystem.focus(); " & vbCrLf
	Response.Write "return; }" & vbCrLf
	Response.Write "//-->"
	Response.Write "</script>" & vbCrLf
	Response.Write "<SCRIPT LANGUAGE=javascript>" & vbCrLf
	Response.Write "<!--" & vbCrLf
	Response.Write "function Juge(myform)" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write "if (myform.softname.value == """")" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write "alert(""软件名称不能为空！"");" & vbCrLf
	Response.Write "myform.softname.focus();" & vbCrLf
	Response.Write "return (false);" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "if (myform.RunSystem.value == """")" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write "alert(""软件运行环境不能为空！"");" & vbCrLf
	Response.Write "myform.RunSystem.focus();" & vbCrLf
	Response.Write " return (false);" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "if (myform.SoftSize.value == """")" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write "alert(""软件大小不能为空！"");" & vbCrLf
	Response.Write "myform.SoftSize.focus();" & vbCrLf
	Response.Write " return (false);" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "if (checktext(myform.SoftSize.value))" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write "alert(""软件大小要求输入数字即可 !"");" & vbCrLf
	Response.Write "myform.SoftSize.select();" & vbCrLf
	Response.Write " myform.SoftSize.focus();" & vbCrLf
	Response.Write "myform.SoftSize.value="""";" & vbCrLf
	Response.Write "return (false);" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "if (myform.SoftType.value == """")" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write "alert(""软件授权类型不能为空！"");" & vbCrLf
	Response.Write "myform.SoftType.focus();" & vbCrLf
	Response.Write " return (false);" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "if (myform.Homepage.value == """")" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write "alert(""软件作者网址不能为空！"");" & vbCrLf
	Response.Write "myform.Homepage.focus();" & vbCrLf
	Response.Write " return (false);" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "if (myform.SoftType.value == """")" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write "alert(""软件类型不能为空！"");" & vbCrLf
	Response.Write "myform.SoftType.focus();" & vbCrLf
	Response.Write " return (false);" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "if (myform.Language.value == """")" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write "alert(""软件语言不能为空！"");" & vbCrLf
	Response.Write "myform.Language.focus();" & vbCrLf
	Response.Write " return (false);" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "if (myform.content.value == """")" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write "alert(""软件简介内容不能为空！"");" & vbCrLf
	Response.Write "myform.content.focus();" & vbCrLf
	Response.Write " return (false);" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "function checktext(text)" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write "allValid = false;" & vbCrLf
	Response.Write "var checkOK = ""0123456789"";" & vbCrLf
	Response.Write "for (i = 0; i < text.length; i++)" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write "ch = text.charAt(i);" & vbCrLf
	Response.Write "for (j = 0; j < checkOK.length; j++)" & vbCrLf
	Response.Write "if (ch == checkOK.charAt(j))" & vbCrLf
	Response.Write "break;" & vbCrLf
	Response.Write "if (j == checkOK.length)" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write " " & "allValid = true;" & vbCrLf
	Response.Write "break;" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "return allValid;" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "//-->"
	Response.Write "</script>" & vbCrLf
	Response.Write "<table width="""
	Response.Write DownsysClass.mainset(0)
	Response.Write """ class=TableBorder align=""center"" border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbCrLf
	Response.Write " <tr> " & vbCrLf
	Response.Write " <th width=""25%"">软件发布协议</th> <TD width=""1""><img src="""" width=1 height=1></TD><th>软件发布</th>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr valign=""top""> " & vbCrLf
	Response.Write " <td width=""25%"" style=""LINE-HEIGHT: 150%"" class=Border1 align=""center""> <div align=""Left"">软件作者在此发布软件，就表明授权该作品给于["
	Response.Write DownsysClass.setting(0)
	Response.Write "]网络传播权。软件作者必须保障所提供的软件中不含有可能损害他人利益的附加程序（如病毒、木马等）。["
	Response.Write DownsysClass.setting(0)
	Response.Write "]保证对作者所提供的软件作品不做任何改动，保持“原样”提供；但["
	Response.Write DownsysClass.setting(0)
	Response.Write "]不保证本站提供的下载资源的准确性、安全性和完整性，也不提供任何有关软件安装、使用方面的服务；同时["
	Response.Write DownsysClass.setting(0)
	Response.Write "]也不承担用户因使用这些下载软件对自己和他人造成任何形式的损失或伤害。<br>" & vbCrLf
	Response.Write " <font color=""#FF0000"">如果同意上述协议请点击“发布软件”按钮</font> </div></td>" & vbCrLf
	Response.Write " <TD width=""0""><img src="""" width=1 height=1></TD>" & vbCrLf
	Response.Write " <td width=""75%"" class=Border1>" & vbCrLf
	Response.Write "<table width=""98%"" border=""0"" align=""center"" cellpadding=""0"" bgcolor=""#CECECE"" cellspacing=""1"">" & vbCrLf
	Response.Write "<form name=""myform"" method=""post"" action=""publish.asp"" onSubmit=""return Juge(this)"">" & vbCrLf
	Response.Write "<input type=""Hidden"" name=""action"" value='save'>" & vbCrLf
	Response.Write " <tr class=Border1> " & vbCrLf
	Response.Write " <td width=""15%"" height=""22"" align=""center"" nowrap>软件分类：</td>" & vbCrLf
	Response.Write " <td width=""85%"" >" & vbCrLf
	srtSortingList = DownsysClass.SortingJumpList
	srtSortingList = Replace(srtSortingList, "{SortID=" & Request("sortid") & "}", "selected")
	Response.Write srtSortingList
	Response.Write " </td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr class=Border1> " & vbCrLf
	Response.Write " <td height=""22"" align=""center"">软件名称：</td>" & vbCrLf
	Response.Write " <td ><input name=""softname"" type=""text"" size=""25""> 版本: <input name=""softver"" type=""text"" size=""20""></td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr class=Border1> " & vbCrLf
	Response.Write " <td height=""22"" align=""center"">运行环境：</td>" & vbCrLf
	Response.Write " <td><input name=""RunSystem"" type=""text"" size=""50"" value="""&DownsysClass.setting(45)&"""><BR>" & vbCrLf
	RunSystem = Split(DownsysClass.setting(34), ",")
	For i = 0 To UBound(RunSystem)
		Response.Write "<a href='javascript:ToRunSystem(""" & Trim(RunSystem(i)) & """)'><u>" & Trim(RunSystem(i)) & "</u></a> | "
		If i = 7 Then Response.Write "<br>"
	Next
	Response.Write "</td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr class=Border1> " & vbCrLf
	Response.Write " <td height=""22"" align=""center"">软件类型：</td>" & vbCrLf
	Response.Write " <td >" & vbCrLf
	SoftType = Split(DownsysClass.setting(35), ",")
	For i = 0 To UBound(SoftType)
		Response.Write "<input type=""radio"" name=""SoftType"" value=""" & Trim(SoftType(i)) & """ "
		If i = 0 Then Response.Write " checked"
		Response.Write ">" & Trim(SoftType(i)) & " "
		If i = 6 Then Response.Write "<br>"
	Next
	Response.Write "</td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr class=Border1> " & vbCrLf
	Response.Write " <td height=""22"" align=""center"">界面预览：</td>" & vbCrLf
	Response.Write " <td ><input name=""PreviewImg"" type=""text"" size=""40"" ><font color=""#808080""> 软件界面预览图片，大小不定</font></td>" & vbCrLf
	Response.Write " </tr" & vbCrLf
	Response.Write " <tr class=Border1> " & vbCrLf
	Response.Write " <td height=""22"" class=Border1 align=""center"">软件大小：</td>" & vbCrLf
	Response.Write " <td class=Border1> <input type=""text"" name=""SoftSize"" size=""14"" maxlength=""10""> <input name=""SizeUnit"" type=""radio"" value=""KB"" checked>" & vbCrLf
	Response.Write " KB " & vbCrLf
	Response.Write " <input type=""radio"" name=""SizeUnit"" value=""MB"">" & vbCrLf
	Response.Write " MB <font color=""#FF0000"">！</font>" & vbCrLf
	Response.Write " 解压密码:<input type=""text"" name=""Decode"" size=""15"" maxlength=""100""> <font color=""#808080"">没有请留空</font> </td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr class=Border1> " & vbCrLf
	Response.Write " <td height=""22"" align=""center"" nowrap>授权方式：</td>" & vbCrLf
	Response.Write " <td nowrap> <select name=""impower"">" & vbCrLf
	Dim ImpowerStr
	ImpowerStr = Split(DownsysClass.Setting(46), ",")
	For i = 0 To UBound(ImpowerStr)
		Response.Write " <option value=""" & ImpowerStr(i) & """>" & ImpowerStr(i) & "</option>"
	Next
	Response.Write " </select>" & vbCrLf
	Response.Write " 软件语言: <select name=""Language"">" & vbCrLf
	Dim LanguageStr
	LanguageStr = Split(DownsysClass.Setting(47), ",")
	For i = 0 To UBound(LanguageStr)
		Response.Write " <option value=""" & LanguageStr(i) & """>" & LanguageStr(i) & "</option>"
	Next
	Response.Write " </select>" & vbCrLf
	Response.Write " 软件等级: <select name=""Grades"" size=""1"">" & vbCrLf
	Response.Write " <option value=""1"">一星级</option>" & vbCrLf
	Response.Write " <option value=""2"">二星级</option>" & vbCrLf
	Response.Write " <option value=""3"" selected>三星级</option>" & vbCrLf
	Response.Write " <option value=""4"">四星级</option>" & vbCrLf
	Response.Write " <option value=""5"">五星级</option>" & vbCrLf
	Response.Write " </select>" & vbCrLf
	Response.Write "</td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr class=Border1> " & vbCrLf
	Response.Write " <td height=""22"" align=""center"">联系作者：</td>" & vbCrLf
	Response.Write " <td ><input name=""Contact"" type=""text"" size=""25"" value="""">" & vbCrLf
	Response.Write " 作者主页: <input name=""Homepage"" type=""text"" size=""30"" value="""">" & vbCrLf
	Response.Write "</td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr class=Border1>" & vbCrLf
	Response.Write " <td height=""22"" align=""center"">软件简介：<br> <font color=""#FF0000"">"
	Response.Write CLng(DownsysClass.setting(43))
	Response.Write "字符内</font></td> " & vbCrLf
	Response.Write " <td align=""center""><textarea name=""content"" cols=""76"" rows=""10"" wrap=""VIRTUAL""></textarea> </td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr class=Border1> " & vbCrLf
	Response.Write " <td height=""22"" align=""center"">下载地址1：</td>" & vbCrLf
	Response.Write " <td ><input name=""Site_1"" type=""text"" size=""60""></td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr class=Border1> " & vbCrLf
	Response.Write " <td height=""22"" align=""center"">下载地址2：</td>" & vbCrLf
	Response.Write " <td ><input name=""Site_2"" type=""text"" size=""60""></td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr class=Border1> " & vbCrLf
	Response.Write " <td height=""22"" align=""center"">下载地址3：</td>" & vbCrLf
	Response.Write " <td ><input name=""Site_3"" type=""text"" size=""60""></td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr class=Border1> " & vbCrLf
	Response.Write " <td height=""22"" align=""center""></td>" & vbCrLf
	Response.Write " <td align=""center""> <input type=Submit class=button value=""发布软件"" name=Submit>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <input type=reset name=Submit2 class=button value=""重新填写""></td>" & vbCrLf
	Response.Write " </tr></form>" & vbCrLf
	Response.Write "</TABLE>" & vbCrLf
	Response.Write "<BR style=""OVERFLOW: hidden; LINE-HEIGHT: 3px"">" & vbCrLf
	Response.Write "</TD>" & vbCrLf
	Response.Write " </TR></TABLE>" & vbCrLf

End Sub

Private Sub checksave()
	If CInt(DownsysClass.setting(39)) = 0 Then
		founderr = True
		errmsg = DownsysClass.mainset(40)
		Exit Sub
	End If
	If Trim(Request.Form("softname")) = "" Then
		founderr = True
		errmsg = errmsg + "软件名称不能为空！"
		Exit Sub
	End If
	If Trim(Request.Form("sortid")) = "" Then
		founderr = True
		errmsg = errmsg + "软件分类有误！"
		Exit Sub
	Else
		strSortid = Split(Trim(Request.Form("sortid")), ",")
	End If
	If Trim(Request.Form("content")) = "" Then
		founderr = True
		errmsg = errmsg + "软件简介不能为空！"
		Exit Sub
	End If
	If Len(Request.Form("content")) > CLng(DownsysClass.setting(43)) Then
		founderr = True
		errmsg = errmsg + "软件简介超过了" & CLng(DownsysClass.setting(43)) & "个字符！"
		Exit Sub
	End If
	If Trim(Request.Form("RunSystem")) = "" Then
		founderr = True
		errmsg = errmsg + "运行环境不能为空！"
		Exit Sub
	End If
	If Trim(Request.Form("SoftSize")) = "" Then
		founderr = True
		errmsg = errmsg + "大小不能为空！"
		Exit Sub
	End If
	If Trim(Request.Form("Site_1")) = "" Then
		founderr = True
		errmsg = errmsg + "下载地址还没有填！"
		Exit Sub
	End If

End Sub

Private Sub saveAdd()
	Call checksave
	If founderr = False Then
		SQL = "select * from NC_SoftPublish where (softid is null)"
		Rs.Open SQL, conn, 1, 3
		Rs.addnew
		Rs("softname") = DownsysClass.HtmlEncodes(Request.Form("softname"))
		Rs("softver") = DownsysClass.HtmlEncodes(Request.Form("softver"))
		Rs("rootid") = strSortid(0)
		Rs("sortid") = strSortid(1)
		Rs("sortname") = strSortid(2)
		Rs("content") = DownsysClass.HtmlEncodes(Request.Form("content"))
		Rs("Language") = Request.Form("Language")
		Rs("SoftType") = Request.Form("SoftType")
		Rs("RunSystem") = Request.Form("RunSystem")
		Rs("Grades") = Request.Form("Grades")
		Rs("impower") = Request.Form("impower")
		If Trim(Request.Form("SizeUnit")) = "MB" Then
			Rs("SoftSize") = CLng(Request.Form("SoftSize")) * 1024
		Else
			Rs("SoftSize") = CLng(Request.Form("SoftSize"))
		End If
		Rs("RunSystem") = Request.Form("RunSystem")
		Rs("Decode") = Request.Form("Decode")
		Rs("Homepage") = Request.Form("Homepage")
		Rs("Contact") = Request.Form("Contact")
		Rs("PreviewImg") = Request.Form("PreviewImg")
		Rs("Site_1") = Request.Form("Site_1")
		Rs("Site_2") = Request.Form("Site_2")
		Rs("Site_3") = Request.Form("Site_3")
		If allow <> 0 Then
		 Rs("username") = DownsysClass.memberName
		Else
		 Rs("username") = "anoymous"
		End If
		Rs.Update
		Rs.Close
		If allow <> 0 Then
		 SQL = "select * from [NC_User] where userid=" & CLng(DownsysClass.memberid) & ""
		 Rs.Open SQL, conn, 1, 3
		 Rs("money") = Rs("money") + CInt(GroupSet(1))
		 Rs.Update
		 Rs.Close
		End If
		Set Rs = Nothing
		If allow <> 0 Then
		 Response.Write "<script>alert('恭喜你 " & DownsysClass.memberName & " !\n 添加软件 " & Request.Form("softname") & " 成功!');location.replace('publish.asp')</script>"
		Else
		 Response.Write "<script>alert('恭喜你!\n 添加软件 " & Request.Form("softname") & " 成功!');location.replace('publish.asp')</script>"
		End If
	End If
End Sub
%>
