<!--#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 addDownUrls()
{
	var div_urs=document.getElementById('Div_DownUrl');
	var url_num=parseInt(document.form1.DownUrlNum.value)+1;
	var w_str='';
	w_str=w_str+'<div id="DownDiv_"'+url_num+' style="display:block;">选择下载服务器：<select name="DownServer'+url_num+'" id="DownServer'+url_num+'"><%=getDownloadServerOptions(0)%></select>&nbsp;下载名称：<input type="text" name="DownTitle'+url_num+'" />&nbsp;文件名：<input type="text" name="FileName'+url_num+'" /></div>';
	document.form1.DownUrlNum.value=url_num;
	div_urs.innerHTML=div_urs.innerHTML+w_str;
}
function delDownUrls(){
	var url_num=parseInt(document.form1.DownUrlNum.value);
	var div_urs=document.getElementById('Div_DownUrl');
	if(url_num<=1){
		alert("下载地址不能少于1个!");
	}else{		
		if(document.getElementById('DownDiv_'+url_num)!=null){
			document.getElementById('DownDiv_'+url_num).style.display='none';			
			document.form1.DownUrlNum.value=url_num-1;
		}else{
			/*var ret='';
			var regS = new RegExp("<div.*?</div>","i");
			ret=div_urs.innerHTML.replace(regS,'');			
			div_urs.innerHTML=ret;			
			document.form1.DownUrlNum.value=url_num-1;*/
		}
	}
}
</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,id
act=trim(request.QueryString("act"))
if(request.QueryString("id")<>"") then
	id=Clng(request.QueryString("id"))
else
	response.Write("id not null!")
	response.End()
end if
if(act="modok") then
	call SoftServer_ModOk
else
	call SoftServer_Mod
end if
%>
<%
Sub SoftServer_Mod
	dim rs,sql,rs_soft,i
	set rs_soft=server.CreateObject("adodb.recordset")
	rs_soft.open "select * from t_download_soft where id="&id,conn,3,1
	if not rs_soft.eof then
%>
<FORM method="POST" name="form1" action="?act=modok&id=<%=id%>" 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
	dim ifselect
	if(isarray(first)) then
  		for i=0 to ubound(first,2)
			if(rs_soft("CatalogId")=first(0,i)) then
				ifselect=" selected"
			else
				ifselect=""
			end if
			response.Write("<option value="""&first(0,i)&""""&ifselect&">├"&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" value="<%=rs_soft("SoftName")%>"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="right">字母索引：</div></TD>
  <TD>
  <select name="SoftChar" id="SoftChar">
  
  <script>charOptions('<%=rs_soft("SoftChar")%>');</script>
  </select>  </TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="right">关键字：</div></TD>
  <TD><input name="SoftKey" type="text" id="SoftKey" value="<%=rs_soft("SoftKey")%>">
    根据此关键字查询相关软件</TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD width="19%"><div align="right">版本：</div></TD>
  <TD width="81%"><input name="SoftVersion" type="text" id="SoftVersion" value="<%=rs_soft("SoftVersion")%>" size="35"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>软件语言：</TD>
  <TD align=right><div align="left">
    <input name="SoftLanguage" type="text" id="SoftLanguage" value="<%=rs_soft("SoftLanguage")%>" size="35">
  </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>软件授权：</TD>
  <TD align=right><div align="left">
    <input name="SoftLicense" type="text" id="SoftLicense" value="<%=rs_soft("SoftLicense")%>" size="35">
  </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>软件属性：</TD>
  <TD align=right><div align="left">
    <input name="SoftAttr" type="text" id="SoftAttr" value="<%=rs_soft("SoftAttr")%>" size="35">
  </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>软件大小：</TD>
  <TD align=right><div align="left">
    <input name="SoftSize" type="text" id="SoftSize" value="<%=rs_soft("SoftSize")%>">
  </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>星级：</TD>
  <TD align=right><div align="left">
  <select name="SoftStars">
            <option value="1" <%if(rs_soft("SoftStars")=1) then response.Write("selected=""selected""") end if%>>1</option>
            <option value="2" <%if(rs_soft("SoftStars")=2) then response.Write("selected=""selected""") end if%>>2</option>
            <option value="3" <%if(rs_soft("SoftStars")=3) then response.Write("selected=""selected""") end if%>>3</option>
            <option value="4" <%if(rs_soft("SoftStars")=4) then response.Write("selected=""selected""") end if%>>4</option>
            <option value="5" <%if(rs_soft("SoftStars")=5) then response.Write("selected=""selected""") end if%>>5</option>
          </select></div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>运行环境：</TD>
  <TD align=right><div align="left">
    <input name="SoftOs" type="text" id="SoftOs" value="<%=rs_soft("SoftOs")%>" size="35">
  </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>软件作者：</TD>
  <TD align=right>
    <div align="left">
      <input name="SoftAuthor" type="text" id="SoftAuthor" value="<%=rs_soft("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="<%=rs_soft("SoftAuthorUrl")%>" 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="<%=rs_soft("SoftDemoUrl")%>" 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" value="<%=rs_soft("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"><textarea name="SoftDemons" cols="56" rows="6"><%=rs_soft("SoftDemons")%></textarea>
  </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>描述：</TD>
  <TD align=right><div align="left">
    	<textarea name="content1" style="display:none; "><%=rs_soft("SoftDesc")%></textarea>
	    <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"><a href="javascript:addDownUrls()">[+]增加下载地址-&gt;</a>&nbsp;&nbsp;<a href="javascript:delDownUrls()">[-]减少下载地址-&gt;</a></div>
  <div align="left" id="Div_DownUrl">
  <%
  i=1
  set rs=server.CreateObject("adodb.recordset")
  rs.open "select id,SoftId,Title,FileUrl,ServerId from t_download_file where SoftId="&id,conn,3,1
  while not rs.eof
  	response.write("<div id=""DownDiv_"&i&""" style=""display:block;"">选择下载服务器：<select name=""DownServer"&i&""" id=""DownServer"&i&"""><script>getDownServerOptins("&rs(4)&");</script></select>&nbsp;下载名称：<input type=""text"" name=""DownTitle"&i&""" value="""&rs(2)&""" />&nbsp;文件名：<input type=""text"" name=""FileName"&i&""" value="""&rs(3)&""" /></div>")
  	rs.movenext
	i=i+1
  wend
  rs.close
  set rs=nothing
  %>
  <input name="DownUrlNum" type="hidden" value="<%=i-1%>" size="6" >
  </div>  </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="0" <%if(rs_soft("IsNeedLogin")=0) then response.Write("selected=""selected""") end if%>>否</option>
	  <option value="1" <%if(rs_soft("IsNeedLogin")=1) then response.Write("selected=""selected""") end if%>>是</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>
<%
	else
		response.Write("没有找到记录ID:"&id)
	end if
	rs_soft.close
	set rs_soft=nothing
end Sub
Sub SoftServer_ModOk
	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,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=gotTopic(request.Form("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 id="&id,conn,3,3
	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
	'下载地址
	conn.execute("delete from t_download_file where SoftId="&id)
	for j=1 to DownUrlNum
		conn.execute("insert into t_download_file(SoftId,Title,FileUrl,ServerId) values("&id&",'"&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.go(-2)"">继续修改</a>&nbsp;&nbsp;<a href=""soft_add.asp"">添加新软件</a>&nbsp;&nbsp;<a href=""send_soft.asp?currentid="&CatalogId&""">发布软件栏目</a></p>")
	response.Write("<iframe src=""soft_reset_htm.asp?id="&(id)&""" height=""0"" width=""0""></iframe>")
end Sub
%>
</body>
</html>
<%
call connclose()
%>