<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/function.asp" -->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p19")
'''''''''''''''''''''''''''''''''''''''''''''''
%>
<html>
<head>
<title>软件管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #FFFFFF;
}
-->
</style>
<link href="style/global.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #FF0000}
.style3 {color: #FFFFFF;
	font-weight: bold;
}
.style4 {color: #003300}
-->
</style>
<script language="javascript">
function check(obj){
	if(obj.SoftName.value==""){
		alert("名称不能为空!");
		obj.SoftName.focus();
		obj.SoftName.select();
		return false;
	}
	
	return true;
}
function addParentOption()
{
	var arr = showModalDialog("tree_container.asp", "", "dialogWidth:410px; dialogHeight:420px; status:0");
  	if (arr != null){  
   		document.form1.catalogid.options[0]=new Option(arr[1],arr[0]);
  	}
	
}
function charOptions(c){
	var sele="";
	var fonts = new Array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');

	for(var i=0;i<fonts.length;i++){
		if(c==fonts[i])
			sele=" selected=selected";
		else
			sele="";		
		document.write('<option value="'+fonts[i]+'"'+sele+'>'+fonts[i]+'</option>');
	}
}
function getDownServerOptins(sid){
	var sele=""
	var optionItems =<%=getDownloadServerOptionsJS%>
	for(var i=0;i<optionItems.length;i++){
		if(sid==optionItems[i][0])
			sele=" selected=selected";
		else
			sele="";		
		document.write('<option value="'+optionItems[i][0]+'"'+sele+'>'+optionItems[i][1]+'</option>');
	}
}
function setDownUrls(elem)
{
  var checkOK = ".0123456789";
  var checkStr = elem.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
		ch = checkStr.charAt(i);
    	for (j = 0;  j < checkOK.length;  j++)
      	if (ch == checkOK.charAt(j))
        break;
    	if (j == checkOK.length)
    	{
      		allValid = false;
      		break;
    	}
  }
  if (!allValid)
  {
    	alert("只能输入数字。");
    	elem.focus();
		elem.select();
    	return (false);
  }else{
  	var div_urs=document.getElementById('Div_DownUrl');
	var w_str='';
	var d_options='';	
	for(var i=1;i<=parseInt(checkStr);i++){
		//if(document.getElementById('DownServer'+i)==null){
			w_str=w_str+'选择下载服务器：<select name="DownServer'+i+'" id="DownServer'+i+'"><%=getDownloadServerOptions(0)%></select>&nbsp;下载名称：<input type="text" name="DownTitle'+i+'" />&nbsp;文件名：<input type="text" name="FileName'+i+'" /><br />';
		//}
	}
	div_urs.innerHTML=w_str;
  }
  return (true);
}
</script>
</head>

<body>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><iframe src="right_top.htm" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" height="30" width="100%"></iframe></td>
  </tr>
</table>
<%
dim act
act=trim(request.QueryString("act"))
if(act="addok") then
	call SoftServer_AddOk
else
	call SoftServer_Add
end if
%>
<%
Sub SoftServer_Add
	dim rs,sql
%>
<FORM method="POST" name="form1" action="?act=addok" style="margin:0 0 0 0;" onSubmit="return check(this)">
  <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
<TR bgcolor="#FF9900">
  <TD height="24" colspan="2"><div align="center" class="style3">添加软件</div></TD>
  </TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="right">选择类别：</div></TD>
  <TD>
  <select name="catalogid" >
  	<%
	set rs=server.CreateObject("adodb.recordset")
	sql="select id,title from catalogs where parentid="&PlugIn_DownloadId&" order by id asc"
	rs.open sql,conn,3,1
	if not rs.eof then
		first=rs.GetRows()
	else
		response.Write("<option>点击右边＋号选择栏目</option>")
	end if
	rs.close
	set rs=nothing
	if(isarray(first)) then
  		for i=0 to ubound(first,2)
			response.Write("<option value="&first(0,i)&">├"&first(1,i)&"</option>"&Chr(10))	    	
		next	
	end if
%>
	%>	  	     
 </select>&nbsp;&nbsp;<a href="#" onClick="addParentOption();">＋</a>  </TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD width="19%"><div align="right">软件名称：</div></TD>
  <TD width="81%"><input name="SoftName" type="text" id="SoftName" size="35"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="right">字母索引：</div></TD>
  <TD>
  <select name="SoftChar" id="SoftChar">
  <script>charOptions('');</script>
  </select>  </TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="right">关键字：</div></TD>
  <TD><input name="SoftKey" type="text" id="SoftKey">
    根据此关键字查询相关软件</TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD width="19%"><div align="right">版本：</div></TD>
  <TD width="81%"><input name="SoftVersion" type="text" id="SoftVersion" size="35"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>软件语言：</TD>
  <TD align=right><div align="left">
    <input name="SoftLanguage" type="radio" value="简体中文" checked>
  简体中文
  <input name="SoftLanguage" type="radio" value="繁体中文">
繁体中文
<input name="SoftLanguage" type="radio" value="英文">
英文
<input name="SoftLanguage" type="radio" value="多国语言">
多国语言</div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>软件授权：</TD>
  <TD align=right><div align="left">
    <input type='radio' name='SoftLicense' value='共享版' checked>
    共享版&nbsp;
    <input type='radio' name='SoftLicense' value='免费版'>
    免费版&nbsp;
    <input type='radio' name='SoftLicense' value='商业版'>
    商业版&nbsp;
    <input type='radio' name='SoftLicense' value='试用版'>
    试用版&nbsp;</div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>软件属性：</TD>
  <TD align=right><div align="left">
    <input type='radio' name='SoftAttr' value='国产软件' checked>
    国产软件&nbsp;
      <input type='radio' name='SoftAttr' value='国外软件'>
    国外软件&nbsp;
      <input type='radio' name='SoftAttr' value='汉化补丁'>
    汉化补丁&nbsp;
      <input type='radio' name='SoftAttr' value='破解补丁'>
    破解补丁&nbsp; </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>软件大小：</TD>
  <TD align=right><div align="left">
    <input name="SoftSize" type="text" id="SoftSize">
  </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>星级：</TD>
  <TD align=right><div align="left">
  <select name="SoftStars">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
          </select></div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>运行环境：</TD>
  <TD align=right><div align="left">
    <input name="SoftOs" type="checkbox" id="SoftOs" value="Win9x">
  Win9x
  <input name="SoftOs" type="checkbox" id="SoftOs" value="Me">
ME
<input name="SoftOs" type="checkbox" id="SoftOs" value="2000">
2000
<input name="SoftOs" type="checkbox" id="SoftOs" value="NT">
NT
<input name="SoftOs" type="checkbox" id="SoftOs" value="2003">
2003
<input name="SoftOs" type="checkbox" id="SoftOs" value="Unix">
Unix
<input name="SoftOs" type="checkbox" id="SoftOs" value="Linux">
Linux</div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>软件作者：</TD>
  <TD align=right>
    <div align="left">
      <input name="SoftAuthor" type="text" id="SoftAuthor" size="22">
      </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>作者网址：</TD>
  <TD align=right><div align="left">
    <input name="SoftAuthorUrl" type="text" id="SoftAuthorUrl" value="http://www." size="33">
  </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>演示地址：</TD>
  <TD align=right><div align="left">
    <input name="SoftDemoUrl" type="text" id="SoftDemoUrl" value="http://www." size="33">
  </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>缩略图：</TD>
  <TD align=right><div align="left">
    <input name="SoftPhoto" type="text" id="SoftPhoto" size="50">
    <input type="button" name="Button" value="上传->" onClick="javascript:document.form1.SoftPhoto.value=window.showModalDialog('upimg.htm','','dialogHeight:130px;dialogWidth:410px;help:no;status:no;scroll:no')">
  </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>描述：</TD>
  <TD align=right><div align="left">
    <INPUT type="hidden" name="content1" value="">
	    <IFRAME ID="eWebEditor1" src="webedit/editor.html" frameborder="0" scrolling="no" width="98%" height="350"></IFRAME>
  </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>下载地址：</TD>
  <TD align=right>
  <div align="left">设置下载地址数目
    <input name="DownUrlNum" type="text" value="2" size="6" onBlur="setDownUrls(this)">
  </div>
  <div align="left" id="Div_DownUrl"></div>
  <script>setDownUrls(document.form1.DownUrlNum);</script>  </TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right><div align="right">是否限制会员下载：</div></TD>
  <TD align=right><div align="left">
    <select name="IsNeedLogin" id="IsNeedLogin">
      <option value="1">是</option>
      <option value="0">否</option>
    </select>
  </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
	<TD align=right>&nbsp;	  </TD>
    <TD align=right><div align="left"> 
        <input type=submit name=b1 value="提 交">&nbsp;&nbsp;
        <input type=reset name=b2 value="重 填">       
    </div></TD>
</TR>
</TABLE>
</FORM>
<%
end Sub
Sub SoftServer_AddOk
	dim CatalogId,SoftName,SoftChar,SoftKey,SoftVersion,SoftLanguage,SoftLicense,SoftAttr,SoftSize,SoftStars,SoftOs,SoftAuthor,SoftAuthorUrl,SoftDemoUrl,SoftPhoto,SoftDesc,SoftDemons,SoftRecommend,SoftTop,InsertDate,ModifyDate,SoftHits,SoftSort,IsCheck,LastId,DownUrlNum,j,IsNeedLogin
	CatalogId=Clng(request.Form("catalogid"))
	SoftName=request.Form("SoftName")
	SoftChar=request.Form("SoftChar")
	SoftKey=request.Form("SoftKey")
	SoftVersion=request.Form("SoftVersion")
	SoftLanguage=request.Form("SoftLanguage")
	SoftLicense=request.Form("SoftLicense")
	SoftAttr=request.Form("SoftAttr")
	SoftSize=request.Form("SoftSize")
	SoftStars=Cint(request.Form("SoftStars"))
	SoftOs=request.Form("SoftOs")
	SoftAuthor=request.Form("SoftAuthor")
	SoftAuthorUrl=request.Form("SoftAuthorUrl")
	SoftDemoUrl=request.Form("SoftDemoUrl")
	SoftPhoto=request.Form("SoftPhoto")
	SoftDesc=request.Form("content1")
	SoftDemons=SoftDesc
	SoftDemons=gotTopic(RemoveHTML(SoftDemons),230)
	DownUrlNum=Cint(request.form("DownUrlNum"))
	IsNeedLogin=Cint(request.Form("IsNeedLogin"))
	set rs=server.createobject("adodb.recordset")
	rs.open "select top 1 id from t_download_soft order by id desc",conn,3,3
	if not rs.eof then
		LastId=rs(0)+1
	else
		LastId=1
	end if
	rs.close
	set rs=nothing
	'入库
	set rs=server.createobject("adodb.recordset")
	rs.open "select * from t_download_soft where 1=0",conn,3,3
	rs.addnew
	rs("id")=LastId
	rs("CatalogId")=CatalogId		
	rs("SoftName")=SoftName
	rs("SoftChar")=SoftChar
	rs("SoftKey")=SoftKey
	rs("SoftVersion")=SoftVersion		
	rs("SoftLanguage")=SoftLanguage
	rs("SoftLicense")=SoftLicense
	rs("SoftAttr")=SoftAttr
	rs("SoftSize")=SoftSize
	rs("SoftStars")=SoftStars
	rs("SoftOs")=SoftOs
	rs("SoftAuthor")=SoftAuthor		
	rs("SoftAuthorUrl")=SoftAuthorUrl
	rs("SoftDemoUrl")=SoftDemoUrl
	rs("SoftPhoto")=SoftPhoto
	rs("SoftDesc")=SoftDesc
	rs("SoftDemons")=SoftDemons
	rs("SoftRecommend")=0
	rs("SoftTop")=0
	rs("InsertDate")=now()
	rs("ModifyDate")=now()
	rs("SoftHits")=1
	rs("SoftSort")=LastId
	rs("IsCheck")=1
	rs("IsNeedLogin")=IsNeedLogin
	rs.update
	rs.close
	set rs=nothing
	'下载地址
	for j=1 to DownUrlNum
		conn.execute("insert into t_download_file(SoftId,Title,FileUrl,ServerId) values("&LastId&",'"&request.form("DownTitle"&j)&"','"&request.form("FileName"&j)&"',"&request.form("DownServer"&j)&")")
	next
	response.Write("<p align=""center"">添加软件成功~!")
	response.Write("<br><a href=""javascript:history.back()"">继续添加</a>&nbsp;&nbsp;<a href=""soft_manage.asp"">管理软件</a></p>")
	response.Write("<iframe src=""soft_reset_htm.asp?id="&(LastId)&""" height=""0"" width=""0""></iframe>")
end Sub
%>
</body>
</html>
<%
call connclose()
%>