<!--#include file="../conn/conn.asp" -->
<!--#include file="admin_check.asp" -->
<%
action=Request.QueryString("action")
N_id=Request.QueryString("N_id")

if N_id<>"" then
aa="edit&N_id="&N_id
sql="Select * from news Where N_id="&N_id
		set rs=Server.CreateObject("ADODB.RecordSet")
		rs.open sql,conn,1,1
		if not rs.eof then
		N_title=rs("N_title")
		N_content=rs("N_content")
		N_pic=rs("N_pic")
		N_thumb=rs("N_thumb")
		N_sort=rs("N_sort")
		end if
		rs.close
set rs=nothing
else
aa="add"
end if
		
if action="add" then


set xmlhttp=server.createobject("Microsoft.XMLHTTP")
xmlhttp.open "get","http://www.flash-soul.com/domain/xml.asp?D_domain="&host&"&D_v=v10.1",false
xmlhttp.send
xmlpass=xmlhttp.responsetext
set xmlhttp=nothing

if xmlpass="no" then
Response.Write"<script>alert('温馨提示：您使用的为免费版，有部分功能限制，请升级为VIP版!');window.location='photo_list.asp';</script>"
end if

if xmlpass="yse" then
N_title=Request.Form("N_title")
N_content=Request.Form("N_content")
N_pic=Request.Form("N_pic")

if left(N_pic,4)="http" then
N_pic=N_pic
else
N_pic="media/"&N_pic
end if

N_thumb=Request.Form("N_thumb")

if left(N_thumb,4)="http" then
N_thumb=N_thumb
else
N_thumb="media/"&N_thumb
end if
N_sort=Request.Form("N_sort")
sql="Insert into news(N_title,N_content,N_pic,N_thumb,N_sort) values('"&N_title&"','"&N_content&"','"&N_pic&"','"&N_thumb&"',"&N_sort&")"
conn.execute(sql)
Response.Write"<script>alert('添加新闻成功!');window.location='news_list.asp';</script>"
end if
end if

if action="edit" then
N_title=Request.Form("N_title")
N_content=Request.Form("N_content")
N_pic=Request.Form("N_pic")
N_thumb=Request.Form("N_thumb")
N_sort=Request.Form("N_sort")

if left(N_pic,5)="media" then
N_pic=N_pic
end if

if left(N_pic,4)="http" then
N_pic=N_pic
end if

if left(N_pic,1)="2" then
N_pic="media/"&N_pic
end if

if left(N_thumb,5)="media" then
N_thumb=N_thumb
end if

if left(N_thumb,4)="http" then
N_thumb=N_thumb
end if

if left(N_thumb,1)="2" then
N_thumb="media/"&N_thumb
end if

sql="Select * from news Where N_id="&N_id
		set rs=Server.CreateObject("ADODB.RecordSet")
		rs.open sql,conn,1,3
		if not rs.eof then
		rs("N_title")=N_title
		rs("N_content")=N_content
		rs("N_pic")=N_pic
		rs("N_thumb")=N_thumb
		rs("N_sort")=N_sort
		rs.update
		rs.close
		end if
Response.Write"<script>alert('修改新闻成功!');window.location='news_list.asp';</script>"
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" />
<title>Flash后台管理</title>
<style>
html,body,div,span,p,a,img,ul,li,dl,dt,dd,ol,form,label,form{ margin:0; padding:0; border:0; outline:0; font-size:100%;}
body{ font-size:12px;font-family:微软雅黑; line-height:150%; background-color:#eeeeee}
a{ font-size:12px; color:#000000; text-decoration:none;}
a:link{ color:#000000;}
a:visited{ color:#000000;}
a:hover{ text-decoration:underline; color:#FF6600;}
a:active{ color:#FF6600;}

a img {
	border:none;
}
.container{ width:1000px; margin:0 auto;}
.title{width:1010px; height:30px; margin-top:10px; background-image:url(img/untitled.png);}
.content{width:990px; background-color:#FFFFFF; padding-left:10px; padding-top:10px;padding-bottom:10px;padding-right:10px; line-height:200%}
.input1 {border-top:1px solid #ABADB3;border-left:1px solid #ABADB3;border-right:1px solid #ddd;border-bottom:1px solid #ddd;height:24px;width:400px;padding:0 5px;}
.input2 {border:1px solid #FFB334;outline:2px solid #ffdc97;*border:2px solid #FFB334;*padding:2px 5px;height:24px;width:400px;padding:0 5px;}
.right{width:150px;float:left}
.left{width:800px; padding-right:10px; float:left}
.submit{ width:131px;height:34px; border:hidden; font-family:"微软雅黑";color:#FFFFFF;background-image:url(img/btn.png);cursor:hand;font-size:15px}
.submit2{ width:131px;height:34px; border:hidden; font-family:"微软雅黑";color:#FFFFFF;background-image:url(img/btn2.png);cursor:hand;font-size:15px}
/********光标说明**************/
#pltsTipLayer
{
	FILTER: alpha(opacity=100);
	opacity: 1;
	background: #ffffff;
	color: #ff6600;
	border: 1px solid #dddddd;
	width:500px;
}
.Bttd
{
	font-size:12px;
	width:500px;
	border:0;
	padding-top:5px;
	padding-left:5px;
	padding-bottom:5px;
}



</style>
<script language="javascript" src="news.js"></script>
<SCRIPT LANGUAGE="JavaScript" src="js/help.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
 function check() {
if(document.form1.N_title.value==""||document.form1.N_content.value==""||document.form1.N_pic.value==""||document.form1.N_thumb.value==""){
alert("请把信息填全，不要有留空!");
return false;
}
}
</SCRIPT> 
</head>
<body>
<!--#include file="left.asp" -->
<div class="container">
<div class="title"><img src="img/orange.png" style="margin-left:10px; margin-top:5px; margin-right:10px;"><b>新闻管理</b> >>  <a href="news_list.asp">新闻列表</a> | <font color="#FF6600"><u>新增新闻</u></font> | <a href="Nsort_list.asp">新闻分类列表</a> | <a href="Nsort_add.asp">新增新闻分类</a></div>
<div class="content">
<h2>添加新闻</h2><hr>
<form id="form" name="form1" method="post" action="news_add.asp?action=<%=aa%>" onsubmit="return check();">
<table width="100%">
<tr><td width="12%">新闻标题：</td><td><input type="text" name="N_title" value="<%=N_title%>" class="input1" onFocus="this.className='input2'" onBlur="this.className='input1'"/></td></tr>
<tr><td width="12%">新闻描述：</td><td><textarea name='N_content' cols='80' rows='10' ><%=N_content%></textarea> <img src="img/q.png" alt="如需换行可插入换行符‘<img src='img/br.png'>’"></td></tr>
<tr><td width="12%">新闻小图：</td><td><input type="text" name="N_thumb" value="<%=N_thumb%>" class="input1" onFocus="this.className='input2'" onBlur="this.className='input1'"/> <input name="upfile" type="button" class="submit1" onClick="javascript:opw('../inc/picup.asp?fromForm=form1&fromEdit=N_thumb&saveTo=../media/&showPath=','N_thumb',420,165)" value="上传图片">  <img src="img/q.png" alt="最佳尺寸260*160"></td></tr>
<tr><td width="12%">新闻图片：</td><td><input type="text" name="N_pic" value="<%=N_pic%>" class="input1" onFocus="this.className='input2'" onBlur="this.className='input1'"/> <input name="upfile" type="button" class="submit1" onClick="javascript:opw('../inc/picup.asp?fromForm=form1&fromEdit=N_pic&saveTo=../media/&showPath=','N_pic',420,165)" value="上传图片">  <img src="img/q.png" alt="最佳尺寸600*230"></td></tr>
<tr><td width="12%">新闻分类：</td><td><select name="N_sort">
			<%
				sql1="Select S_title,S_id from NSort"
				set rs1=Server.CreateObject("ADODB.RecordSet")
				rs1.open sql1,conn,1,1
				if not rs1.eof then
				for i=1 to rs1.recordcount
			%>
				<option value="<%=rs1("S_id")%>" <%if cstr(rs1("S_id"))=cstr(N_sort) then%>selected="selected"<%end if%>><%=rs1("S_title")%></option>
			<%
				rs1.movenext
				next
				end if
				rs1.close
				set rs1=nothing
			%>
			  </select></td></tr>
<tr><td width="12%"></td><td><input name="Submit" type="submit" class="submit" onmouseover="this.className='submit2'" onmouseout="this.className='submit'"  value="确 认" /></td></tr></table>
</form>
</div>

</div>
</body>
</html>