<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<!--#include file="../sub.asp"-->
<%
if session("flag")>0 then
   Response.Write("<br><br><br><center>对不起。你没有权限进入此页面！！！</center>")
   Response.end 
end if

style=request.QueryString("style")
title=trim(request.form("title"))
desc=request.Form("txtcontent")
classid1=request.Form("classid")
if style="add" then
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from news where title='"&title&"'",conn,1,3
	if rs.eof or rs.bof then
		rs.addnew
		rs("title")=title
		rs("desc")=desc
		rs("time")=now
                RS("encode")="ubb"
		RS("classid")=classid1
		rs.update
		rsclose
		Response.Write("<script language=javascript>alert('添加成功．请返回！');window.location.replace('setnews.asp')</script>")
	else
		Response.Write("<script language=javascript>alert('已经存在这样的新闻．请返回！');window.location.replace('setnews.asp')</script>")
		rsclose
	end if
elseif style="del" then
	ID=cint(request.querystring("ID"))
	conn.execute("delete from news where id="&ID)
	Response.Write("<script language=javascript>alert('删除成功．请返回！');window.location.replace('setnews.asp')</script>")
end if
%>
<html>
<head>
<title>系统设置</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/bbs.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          min=test.substring(8,p); max=test.substr;
	    if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
		ing(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' 不能为空！\n'; }
  } if (errors) alert('出现错误的可能原因：\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->
</script>
<script language=javascript>
<!--
	function zipwindow() {
		var ref = "img_upload.asp";
			window.open(ref, "zipwin", 'width=350, height=220');
	}	
	function rightStr(str,n)
	{
		if(str.length<=n)
		{
			return(str);
		}
		{
			return(str.substr(str.length-n,n));
		}
	}
	function addcontent(str1,str2)
	{
		myform.txtcontent.focus();
		if ((document.selection)&&(document.selection.type== "Text"))
		{
			var range= document.selection.createRange();
			var ch_text=range.text;
			range.text= str1 + ch_text + str2;
		} 
		else
		{
			document.myform.txtcontent.value=document.myform.txtcontent.value+str1+str2;
			myform.txtcontent.focus();
		}
	}
	function submitonce(theform)
	{
		if (document.all||document.getElementById)
		{
			for (i=0;i<theform.length;i++)
			{
				var tempobj=theform.elements[i];
				if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
				tempobj.disabled=true;
			}
		}
	}

	function storeCaret (textEl)
	{
		if (textEl.createTextRange) 
		textEl.caretPos = document.selection.createRange().duplicate(); 
	}
	
	function checklength(){alert("帖子内容长度: "+document.myform.txtcontent.value.length+" 个字，\n最多允许<%=DEF_MaxTextLength%>字节。");}
//-->
</script>
<script src="ubbcode.js"></script>
</head>
<body topmargin="0">
<%
if session("flag")>0 then
   Response.Write("<br><br><br><center>对不起。你没有权限进入此页面！！！</center>")
   Response.end 
end if
%>
<table width=636 height="323" border="1" align="center" cellpadding="3" cellspacing="0" bordercolorlight="#DFEEDB" bordercolordark="#FFFFFF">
  <tr> 
    <td colspan="2" height="305" align="center"><br>
      <form action="?style=add" method="post" name="myform" onSubmit="MM_validateForm('title','','R');return document.MM_returnValue">
        <table width="609" height="255" border="0" cellpadding="0" cellspacing="0">
          <tr align="center"> 
            <td height="25" colspan="3"><strong>文章管理</strong></td>
          </tr>
          <tr> 
            <td height="20" align="center" width="65">ID</td>
            <td height="20" width="380">文章标题</td>
            <td height="20" width="82">操作</td>
          </tr>
          <%
		Set Rs=Server.Createobject("ADODB.Recordset")
		sql="select ID,title from News order by ID desc"
rs.open sql,conn,3,1
rcount=rs.recordcount
if pmcount="" or isempty(pmcount) or pmcount<1 then
        pmcount=8
end if
rs.pagesize=pmcount   	'设置每页数
mpage=rs.pagecount    	'得到总页数
pageno=Request("pageno")
if rcount mod pmcount=0 then
     		n= rcount \ pmcount
else
     		n= rcount \ pmcount+1
end if
if cint(pageno)<1 or cint(pageno)>mpage then
	pageno=1
end if


if rs.bof and rs.eof then
	response.write "<tr><td colspan='5'><div align='center'>没有内容</div></td></tr>"
else

rs.absolutepage=pageno	'将指针移至指定页的第一条记录
loopno=pmcount

do while not rs.eof and loopno>0
		  %>
          <tr> 
            <td height="20" width="65"> 
              <div align="center"><%=rs(0)%></div>
            </td>
            <td width="380" height="20"><a href="../news.asp?ID=<%=rs(0)%>&title=<%=rs(1)%>" target="_blank"><%=rs(1)%></a></td>
            <td width="82"><a href="?style=del&ID=<%=rs(0)%>">删除</a></td>
          </tr>
                            <%
						rs.movenext
						loopno=loopno-1
						loop
						end if
						rs.close
						set rs=Nothing
						%>
          <tr> 
            <td height="14" colspan="3">
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr align="right"> 
                  <td height="18"> 
                    <div align="center"><a href="newsadd1.asp">添加文章</a> | 共 <%=cstr(rcount)%> 
                      条信息 当前第 <%=cstr(pageno)&"/"&cstr(mpage)%> 页 每页 <%=pmcount%> 
                      条 
                      <%
							if cint(pageno)>1 then%>
                      [ <a href='setnews.asp?type1=<%=type1%>&pageno=<%=pageno-1%>&s_keyword=<%=s_keyword%>' class="tt1">上一页</a> 
                      ] 
                      <%
							end if
							if cint(pageno)<cint(mpage) then
							%>
                      [ <a href='setnews.asp?type1=<%=type1%>&pageno=<%=pageno+1%>&s_keyword=<%=s_keyword%>' class="tt1">下一页</a> 
                      ] 
                      <%end if%>
                      &nbsp;&nbsp;</div>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
          <tr> 
            <td width="65" height="14"> 
              <div align="center">标题</div>
            </td>
            <td height="25" colspan="2" valign="top"> 
              <input name="title" type="text" id="title" size="52" style="font-family:宋体; font-size:9pt; color:#000000; width:368px; height:19px; border:1px solid #000000; background-color:#F0F0F0;">
            </td>
          </tr>
          <tr> 
            <td width="65" height="4" valign="top"> 
              <div align="center">分类</div>
            </td>
            <td height="4" colspan="2" valign="top">
              <%ShowClass1(ClassID)%>
              　</td>
          </tr>
          <tr> 
            <td colspan="3" height="5" valign="top"> 
              <table width="100%" border="1" align="center" cellpadding="3" cellspacing="0" bordercolorlight="#DFEEDB" bordercolordark="#FFFFFF">
                <tr> 
                  <td rowspan="2" align="left" height="15" valign="middle" width="13%">UBB&nbsp;标签： 
                  </td>
                  <td height="2" width="87%"> <a href="javascript:addcontent('[B]','[/B]');" title=粗体><img src="../images/ubb//bold.GIF" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[I]','[/I]');" title=斜体><img src="../images/ubb//italicize.GIF" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[U]','[/U]');" title=下划线><img src="../images/ubb//underline.GIF" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[ALIGN=CENTER]','[/ALIGN]');" title=居中><img src="../images/ubb//center.GIF" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[URL]','[/URL]');" title=链接><img src="../images/ubb//url1.GIF" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[EMAIL]','[/EMAIL]');" title=邮件><img src="../images/ubb//email1.GIF" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[IMGA]','[/IMGA]');" title=图片><img src="../images/ubb//image.GIF" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:zipwindow()" title=上传图片><img src="../images/ubb//images1.GIF" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[FLASH]','[/FLASH]');" title=Flash><img src="../images/ubb//swf.GIF" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[CODE]','[/CODE]');" title=代码><img src="../images/ubb//code.GIF" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[QUOTE]','[/QUOTE]');" title=引用><img src="../images/ubb//quote1.GIF" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[FLY]','[/FLY]');" title=飞行><img src="../images/ubb//fly.GIF" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[MOVE]','[/MOVE]');" title=移动><img src="../images/ubb//move.GIF" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[GLOW=255,RED,2]','[/GLOW]');" title=发光><img src="../images/ubb//glow.GIF" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[SHADOW=255,RED,2]','[/SHADOW]');" title=阴影><img src="../images/ubb//shadow.GIF" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[SIZE=3]','[/SIZE]');" title=3号字><img src="../images/ubb//size3.GIF" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[COLOR=blue]','[/COLOR]');" title=蓝色字><img src="../images/ubb//blue.gif" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[COLOR=red]','[/COLOR]');" title=红色字><img src="../images/ubb//red.GIF" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[MP=320,240]','[/MP]');" title=插入Media文件><img src="../images/ubb//media.gif" width="20" height="20" align="absmiddle" border=0></a> 
                    <a href="javascript:addcontent('[RM=320,240]','[/RM]');" title=插入RealPlay文件><img src="../images/ubb//real.gif" width="20" height="20" align="absmiddle" border=0></a> 
                  </td>
                </tr>
                <tr> 
                  <td width="87%"> <a href="javascript:var d; d=new Date();addcontent(d.getYear()+'-'+rightStr('0'+(d.getMonth()+1),2)+'-'+rightStr('0'+d.getDate(),2)+' '+rightStr('0'+d.getHours(),2)+':'+rightStr('0'+d.getMinutes(),2)+':'+rightStr('0'+d.getSeconds(),2),'');" title=插入时间><b>T</b></a> 
                    <a href="javascript:checklength();">长度</a> </td>
                </tr>
              </table>
            </td>
          </tr>
          <tr> 
            <td width="65" height="7" valign="top"> 
              <div align="center">内容</div>
            </td>
            <td height="7" colspan="2" valign="top"> 
              <textarea name="txtcontent" cols="70" rows="15" id="desc"></textarea>
            </td>
          </tr>
          <tr> 
            <td height="28" width="65">&nbsp;</td>
            <td colspan="2"> 
              <input type="submit" name="Submit" value="添加" style="font-family:宋体; font-size:9pt; color:#000000; width:60px; height:19px; border:1px solid #000000; background-color:#F0F0F0;">
              &nbsp;&nbsp;&nbsp; 
              <input type="button" name="Submit2" value="取消" style="font-family:宋体; font-size:9pt; color:#000000; width:60px; height:19px; border:1px solid #000000; background-color:#F0F0F0;" onClick="javascript:history.back();">
            </td>
          </tr>
          <tr> 
            <td colspan="3">&nbsp;</td>
          </tr>
        </table>
      </form>
    </td>
  </tr>
  <tr> 
    <td>&nbsp;</td>
    <td> 
      <div align="center"></div>
    </td>
  </tr>
</table>
</body>
</html>
