<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/function.asp"-->
<!--#include file="../inc/md5.asp"-->
<%
call adminpassword()

t=checksql(request("t"))
if t="" then t=0
if request("action")="add" then

	if request("title")="" or request("content1")="" then
	response.write("<script>alert('标题和内容都不能为空！');history.go(-1)</script>")
	response.end
	end if

	set rs=Server.CreateObject("ADODB.Recordset")
	sql="select * from D_News"
	rs.open sql,conn,3,3


	rs.addnew
	rs("Title")=checksql(request("title"))
    rs("Classid")=checksql(request("classid"))
	rs("Tag")=checksql(request("tag"))
	rs("Hot")=checksql(request("hot"))
	rs("Introduction")=checksql(request("introduction"))
	rs("Color")=checksql(request("color"))
	rs("Content")=checksql(request("content1"))
	rs("NewsType")=t
	if request("Recommend")="" then
	rs("Recommend")=0
	else
	rs("Recommend")=checksql(request("recommend"))
	end if
	rs("AddDate")=now()
	rs.update

	rs.close
	set rs=nothing
	response.write"<SCRIPT language=JavaScript>alert('恭喜您，添加成功！');"
	response.write"this.location.href='News.asp?action=News&t="&t&"';</SCRIPT>" 
	response.end

	
end if

if request("action")="save" then
if Not isChkInteger(request.QueryString("id")) then
	%>
	<script language=javascript>
		alert("参数错误！");
		window.close();
	</script>
	<%
	response.end
end if

	if request("title")="" or request("content1")="" then
	response.write("<script>alert('标题和内容都不能为空！');history.go(-1)</script>")
	response.end
	end if

	set rs=Server.CreateObject("ADODB.Recordset")
	sql="select * from D_News where id="&request.QueryString("id")&""
	rs.open sql,conn,3,3

	rs("Title")=checksql(request("title"))
    rs("Classid")=checksql(request("classid"))
	rs("Tag")=checksql(request("tag"))
	rs("Hot")=checksql(request("hot"))
	rs("Introduction")=checksql(request("introduction"))
	rs("Color")=checksql(request("color"))
	rs("Content")=checksql(request("content1"))
	if request("Recommend")="" then
	rs("Recommend")=0
	else
	rs("Recommend")=checksql(request("recommend"))
	end if
	rs.update

	rs.close
	set rs=nothing
	response.write"<SCRIPT language=JavaScript>alert('恭喜您，修改成功！');"
	response.write"this.location.href='News.asp?action=News&t="&t&"';</SCRIPT>" 
	response.end

	
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<META   HTTP-EQUIV="Pragma"   CONTENT="no-cache">
<META   HTTP-EQUIV="Cache-Control"   CONTENT="no-cache">
<META   HTTP-EQUIV="Expires"   CONTENT="0">
<title><%=Dshop_webname%>后台管理登陆</title>
<link rel="stylesheet" href="style.css">
<style type="text/css">
<!--
body {
	margin: 20px;
}
body,td,th {
	color: #999999;
}
-->
</style>
<script charset="utf-8" src="/editor/kindeditor.js"></script>
<script charset="utf-8" src="/editor/lang/zh_CN.js"></script>
<script>
		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="content1"]', {
				cssPath : '/Editor/plugins/code/prettify.css',
				uploadJson : '/Editor/upload_json.asp',
				fileManagerJson : '/Editor/file_manager_json.asp',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
				}
			});
			prettyPrint();
		});
	</script>
<link rel="stylesheet" href="/Editor/themes/default/default.css" />
		<script src="/Editor/kindeditor-min.js"></script>
		<script>
			KindEditor.ready(function(K) {
				var uploadbutton = K.uploadbutton({
					button : K('#uploadButton')[0],
					fieldName : 'imgFile',
					url : '/Editor/upload_json.asp?',
					afterUpload : function(data) {
						if (data.error === 0) {
							var url = K.formatUrl(data.url, 'absolute');
							K('#url').val(url);
						} else {
							alert(data.message);
						}
					},
					afterError : function(str) {
						alert('自定义错误信息: ' + str);
					}
				});
				uploadbutton.fileBox.change(function(e) {
					uploadbutton.submit();
				});
			});
		
		</script>
</head>

<body >
<table width="860" height="32" border="0">
  <tr>
    <td colspan="3" align="right">添加新商品</td>
  </tr>
</table>
<%if request("action")="" then%>
<form name="myform" method="post" action="?action=add&t=<%=t%>">
<table width="860" border="0" cellpadding="5" cellspacing="1" bgcolor="#EFEFEF" class="nr">
            <tr>
              <td width="100" height="25" align="right" bgcolor="#FAFAFA"><strong>标题：　</strong></td>
              <td bgcolor="#FFFFFF" style="padding-top: 5px; padding-bottom: 5px">
                <table border="0" style="margin-left:10px;">
                  <tr>
                    <td><input name="title" type="text" id="title" size="80" /></td>
                    <td><input type='hidden' name='color' id='color' value="#666666"  />
				<script language="javascript" type="text/javascript">

function closeiconDiv() {
	document.getElementById('div_icon').style.visibility = 'hidden';
}


function showiconDiv() {
	document.getElementById('div_icon').style.visibility = 'visible';
}
function chicon(iconid, color) {
	document.getElementById('icon_change').style.background = color;
	document.getElementById('color').value = iconid;
	closeiconDiv();
}
</script>
				  <div id='icon_change' style="cursor:hand;background:#666666;width:20px;height:20px;" onClick="showiconDiv()" title="标题颜色"><img src="/Images/change.gif" /></div>   <div id='div_icon' style='background:#fafafa;width:78px;margin-top:-21px;margin-left:10px;border:1px solid #cccccc;position:absolute;display:inline;visibility:hidden;'>
<div>
<table border="0" cellpadding="2" cellspacing="3" bgcolor="#FFFFFF" >
  <tr>
    <td width="15" height="14" bgcolor="#666666" onClick="chicon('#666666','#333333')" style='margin:0px;cursor:hand;' ></td>
    <td width="15" height="14" bgcolor="#0099CC" onClick="chicon('#0099CC','#0099CC')" style='margin:0px;cursor:hand;' ></td>
    <td width="15" height="14" bgcolor="#999900" onClick="chicon('#999900','#999900')" style='margin:0px;cursor:hand;' ></td>
	<td width="15" height="14" bgcolor="#993399" onClick="chicon('#993399','#993399')" style='margin:0px;cursor:hand;' ></td>
  </tr>
  <tr>
    <td width="15" height="14" bgcolor="#FF3300" onClick="chicon('#FF3300','#FF3300')" style='margin:0px;cursor:hand;' ></td>
    <td width="15" height="14" bgcolor="#FF3399" onClick="chicon('#FF3399','#FF3399')" style='margin:0px;cursor:hand;' ></td>
    <td width="15" height="14" bgcolor="#003399" onClick="chicon('#003399','#003399')" style='margin:0px;cursor:hand;' ></td>
	<td width="15" height="14" bgcolor="#669900" onClick="chicon('#669900','#669900')" style='margin:0px;cursor:hand;' ></td>
  </tr>
</table>
</div>
</div></td>
                  </tr>
                </table>                </td>
            </tr>
            <tr>
              <td bgcolor="#FAFAFA" height="25" align="right">类别：　</td>
              <td bgcolor="#FFFFFF">　 
                <select name="classid" size="1" id="classid">
              <%
		Set rs1 = Server.CreateObject("ADODB.Recordset")
		rs1.open "select * from  D_NewsClass where NewsType="&t,conn,1,1
if not(rs1.eof and rs1.bof) then

do while not rs1.eof
  response.write  "<option value="&rs1("id")
  if nclassid=rs1("id") then response.write " selected "
  response.write ">"&trim(rs1("ClassName"))&"</option>"  
rs1.movenext
loop
end if
        rs1.close
        set rs1 = nothing     
%>
            </select></td>
            </tr>
            <tr>
			  <td bgcolor="#FAFAFA" height="25" align="right">标签：　</td>
              <td bgcolor="#FFFFFF">　 
                <input name="tag" type="text" id="tag" size="80"> 
                请用,号分开 如：新闻,公告</td>
            </tr>
            <tr>
              <td bgcolor="#FAFAFA" height="25" align="right">浏览量：　</td>
              <td bgcolor="#FFFFFF">　
              <input name="hot" type="text" id="hot" value="0" size="10" /></td>
            </tr>
            <tr>
              <td bgcolor="#FAFAFA" height="25" align="right">简评：　</td>
              <td bgcolor="#FFFFFF" style="padding-left: 20px"><textarea name="introduction" cols="75" rows="5" id="introduction"></textarea></td>
            </tr>
            <tr>
              <td bgcolor="#FAFAFA" height="25" align="right">内容：　</td>
              <td bgcolor="#FFFFFF" style="padding-left: 20px"><textarea name="content1" style="width:700px;height:500px;visibility:hidden;"><%=htmlspecialchars(htmlData)%></textarea></td>
            </tr>
            <tr>
              <td bgcolor="#FAFAFA" height="25" align="right">选项：　</td>
              <td bgcolor="#FFFFFF"><label>　
                  <input name="recommend" type="checkbox" id="recommend" value="1" />
推荐</label></td>
            </tr>
            <tr>
              <td height="30" colspan="2" align="center" bgcolor="#FFFFFF"><input name="B22" type="submit" class="ian" onClick="return addsc()" value=" 添加发布 ">
                <script language="javascript">		
        function addsc()
		{
			
		if(checkkk())
		{
		myform.submit()
		}
		
		}
		</script> 
                <label></label></td>
            </tr>
  </table>
</form>
<%elseif request("action")="edit" and request("id")<>"" then
if Not isChkInteger(request.QueryString("id")) then
	%>
	<script language=javascript>
		alert("参数错误！");
		window.close();
	</script>
	<%
	response.end
end if
	set rs=Server.CreateObject("ADODB.Recordset")
	sql="select * from D_News where id="&abs(request("id"))
	rs.open sql,conn,1,1%>
<form name="myform" method="post" action="?action=save&t=<%=t%>&id=<%=request("id")%>">
<table width="860" border="0" cellpadding="5" cellspacing="1" bgcolor="#EFEFEF" class="nr">
            <tr>
              <td width="100" height="25" align="right" bgcolor="#FAFAFA"><strong>标题：　</strong></td>
              <td bgcolor="#FFFFFF" style="padding-top: 5px; padding-bottom: 5px">
                <table border="0" style="margin-left:10px;">
                  <tr>
                    <td><input name="title" type="text" id="title" value="<%=rs("title")%>" size="80" /></td>
                    <td><input type='hidden' name='color' id='color' value="<%=rs("color")%>"  />
				<script language="javascript" type="text/javascript">

function closeiconDiv() {
	document.getElementById('div_icon').style.visibility = 'hidden';
}


function showiconDiv() {
	document.getElementById('div_icon').style.visibility = 'visible';
}
function chicon(iconid, color) {
	document.getElementById('icon_change').style.background = color;
	document.getElementById('color').value = iconid;
	closeiconDiv();
}
</script>
				  <div id='icon_change' style="cursor:hand;background:<%=rs("color")%>;width:20px;height:20px;" onClick="showiconDiv()" title="标题颜色"><img src="/Images/change.gif" /></div>   <div id='div_icon' style='background:#fafafa;width:78px;margin-top:-21px;margin-left:10px;border:1px solid #cccccc;position:absolute;display:inline;visibility:hidden;'>
<div>
<table border="0" cellpadding="2" cellspacing="3" bgcolor="#FFFFFF" >
  <tr>
    <td width="15" height="14" bgcolor="#666666" onClick="chicon('#666666','#333333')" style='margin:0px;cursor:hand;' ></td>
    <td width="15" height="14" bgcolor="#0099CC" onClick="chicon('#0099CC','#0099CC')" style='margin:0px;cursor:hand;' ></td>
    <td width="15" height="14" bgcolor="#999900" onClick="chicon('#999900','#999900')" style='margin:0px;cursor:hand;' ></td>
	<td width="15" height="14" bgcolor="#993399" onClick="chicon('#993399','#993399')" style='margin:0px;cursor:hand;' ></td>
  </tr>
  <tr>
    <td width="15" height="14" bgcolor="#FF3300" onClick="chicon('#FF3300','#FF3300')" style='margin:0px;cursor:hand;' ></td>
    <td width="15" height="14" bgcolor="#FF3399" onClick="chicon('#FF3399','#FF3399')" style='margin:0px;cursor:hand;' ></td>
    <td width="15" height="14" bgcolor="#003399" onClick="chicon('#003399','#003399')" style='margin:0px;cursor:hand;' ></td>
	<td width="15" height="14" bgcolor="#669900" onClick="chicon('#669900','#669900')" style='margin:0px;cursor:hand;' ></td>
  </tr>
</table>
</div>
</div></td>
                  </tr>
                </table>                </td>
            </tr>
            <tr>
              <td bgcolor="#FAFAFA" height="25" align="right">类别：　</td>
              <td bgcolor="#FFFFFF">　 
                <select name="classid" size="1" id="classid">
              <%
		Set rs1 = Server.CreateObject("ADODB.Recordset")
		rs1.open "select * from  D_NewsClass where NewsType="&t,conn,1,1
if not(rs1.eof and rs1.bof) then

do while not rs1.eof
  response.write  "<option value="&rs1("id")
  if rs("Classid")=rs1("id") then response.write " selected "
  response.write ">"&trim(rs1("ClassName"))&"</option>"  
rs1.movenext
loop
end if
        rs1.close
        set rs1 = nothing     
%>
            </select></td>
            </tr>
            <tr>
			  <td bgcolor="#FAFAFA" height="25" align="right">标签：　</td>
              <td bgcolor="#FFFFFF">　 
                <input name="tag" type="text" id="tag" size="80" value="<%=rs("tag")%>"> 
                请用,号分开 如：新闻,公告</td>
            </tr>
            <tr>
              <td bgcolor="#FAFAFA" height="25" align="right">浏览量：　</td>
              <td bgcolor="#FFFFFF">　
              <input name="hot" type="text" id="hot" size="10" value="<%=rs("hot")%>" /></td>
            </tr>
            <tr>
              <td bgcolor="#FAFAFA" height="25" align="right">简评：　</td>
              <td bgcolor="#FFFFFF" style="padding-left: 20px"><textarea name="introduction" cols="75" rows="5" id="introduction"><%=rs("introduction")%></textarea></td>
            </tr>
            <tr>
              <td bgcolor="#FAFAFA" height="25" align="right">内容：　</td>
              <td bgcolor="#FFFFFF" style="padding-left: 20px"><textarea name="content1" style="width:700px;height:500px;visibility:hidden;"><%=htmlspecialchars(rs("content"))%></textarea></td>
            </tr>
            <tr>
              <td bgcolor="#FAFAFA" height="25" align="right">选项：　</td>
              <td bgcolor="#FFFFFF"><label>　
                  <input name="recommend" type="checkbox" id="recommend" value="1" <%if rs("recommend")=1 then%>checked="checked"<%end if%> />
推荐</label></td>
            </tr>
            <tr>
              <td height="30" colspan="2" align="center" bgcolor="#FFFFFF"><input name="B22" type="submit" class="ian" onClick="return addsc()" value=" 修改发布 ">
                <script language="javascript">		
        function addsc()
		{
			
		if(checkkk())
		{
		myform.submit()
		}
		
		}
		</script> 
                <label></label></td>
            </tr>
  </table>
</form>
<%end if%>
</body>
</html>
