<!--#include file="conn.asp"-->
<!--#include file="user_chkpass.asp"-->
<!--#include file="inc/usercode.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="inc/md5.asp"-->
<%
if CheckUserLogined()=False then
	response.Redirect "user_login.asp"
end if
dim needclassid
needclassid=trim(Application(cachename&"info")(3))
%>
<SCRIPT language=javascript>
function del_space(s)
{
	for(i=0;i<s.length;++i)
	{
	 if(s.charAt(i)!=" ")
		break;
	}

	for(j=s.length-1;j>=0;--j)
	{
	 if(s.charAt(j)!=" ")
		break;
	}

	return s.substring(i,++j);
}


function VerifySubmit()
{
	submits(); 
	topic = del_space(document.theForm.topic.value);
     if (topic.length == 0)
     {
        alert("您忘了填写题目!");
	return false;
     }
	 
	 var needclassid=<%=needclassid%>
	 if (needclassid==true) {
	 if (document.theForm.classid.value == 0)
     {
        alert("请选择日志的类别!");
	return false;
     }
	 }
	
	 showword = del_space(document.all("showword").value);
      for(i = 0; i < showword.length; i++){
	  if(showword.charAt(i) < "0" || showword.charAt(i) > "9"){
	  alert("请输入正确的显示字数！");
	  return false;  
		 }
     }
	if (document.theForm.edit.value == "")
     {
        alert("请输入日志内容!");
	return false;
     }	
	var date=document.theForm.selecty.value+"-"+document.theForm.selectm.value+"-"+document.theForm.selectd.value
	var datereg=/^(\d{4})-(\d{1,2})-(\d{1,2})$/
	var datareg=/^(\d){1,2}$/
	if (!datereg.test(date)){
	  alert("日志时间输入格式错误");
	   return false;
	 }
	var r=date.match(datereg)
	var d=new Date(r[1],r[2]-1,r[3])
	if (!(d.getFullYear()==r[1]&&d.getMonth()==r[2]-1&&d.getDate()==r[3])){
	  alert("日志时间输入格式错误");
	   return false;
	 }
	
  var FormLimit = 51100
  var TempVar = new String
  TempVar = document.theForm.edit.value
  if (TempVar.length > FormLimit)
	{
	if (confirm("您要发布的日志太长，建议您拆分为几部分分别发布。\n如果您坚持提交，注意需要较长时间才能提交成功。\n\n是否坚持提交？") == false)
	return false;
	}
	
	  if (TempVar.length > FormLimit)
  {
    document.theForm.edit.value = TempVar.substr(0, FormLimit)
    TempVar = TempVar.substr(FormLimit)
    while (TempVar.length > 0)
    {
      var objTEXTAREA = document.createElement("hidden")
      objTEXTAREA.name = "logtext"
      objTEXTAREA.value = TempVar.substr(0, FormLimit)
      document.theForm.appendChild(objTEXTAREA)
      
      TempVar = TempVar.substr(FormLimit)
    }
  }
	 
	 
	return true;
}
</SCRIPT>
<%

const MaxPerPage=20
dim strFileName
dim totalPut,CurrentPage,TotalPages
dim rs, sql
dim ID,UserSearch,Keyword,strField,uname
dim Action,FoundErr,ErrMsg
dim tmpDays,usersql
dim uppath
dim selectsub
keyword=trim(request("keyword"))
if keyword<>"" then 
	keyword=ReplaceBadChar(keyword)
end if
strField=trim(request("Field"))
UserSearch=trim(request("UserSearch"))
selectsub=trim(request("selectsub"))
Action=trim(request("Action"))
ID=trim(Request("ID"))
uname=trim(Request("uname"))
ComeUrl=Request.ServerVariables("HTTP_REFERER")
strFileName="user_blog.asp"
if UserSearch="" then
	UserSearch=0
else
	UserSearch=Clng(UserSearch)
	strFileName="user_blog.asp?UserSearch=" & UserSearch
end if
if selectsub<>"" then
	selectsub=Clng(selectsub)
	strFileName="user_blog.asp?UserSearch=10&selectsub="&selectsub
else
	selectsub=0
end if
if keyword<>"" then
	strFileName="user_blog.asp?UserSearch=10&keyword="&Keyword&"&strField="&strField
end if
if request("page")<>"" then
    currentPage=cint(request("page"))
else
	currentPage=1
end if

%>
<html>
<head>
<title>用户日志管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="Admin_STYLE.CSS" rel="stylesheet" type="text/css">
<SCRIPT language=javascript>
function unselectall()
{
    if(document.myform.chkAll.checked){
	document.myform.chkAll.checked = document.myform.chkAll.checked&0;
    } 	
}

function CheckAll(form)
{
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.Name != "chkAll")
       e.checked = form.chkAll.checked;
    }
}
</SCRIPT>
</head>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0" class="bgcolor">
<br>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" Class="border">
  <tr class="topbg"> 
    <td height="22" colspan=3 align=center><strong>用 户 日 志 管 理</strong></td>
  </tr>
  <form name="form1" action="User_blog.asp" method="get">
    <tr class="tdbg"> 
      <td width="34%" height="30"><strong>快速查找日志：</strong> <select size=1 name="UserSearch" onChange="javascript:submit()">
          <option value="10" selected>请选择查找类型</option>
		  <option value="0">列出所有日志</option>
          <option value="1">未通过审核的日志</option>
          <option value="2">已通过审核的日志</option>
          <option value="3">推荐日志</option>
          <%if userlevel=9 then%>
          <option value="4">我的日志</option>
          <%end if%>
        </select> &nbsp;&nbsp;&nbsp;</td>
      <td width="29%"> <strong>按专题查找：</strong>&nbsp;<a href="User_blog.asp"> 
        <select name="selectsub" id="selectsub" onChange="javascript:submit()">
          <%
			  response.Write "<option value=''>请选择专题</option>"
			  dim srs
			  set srs=conn.execute("select id,subjectname from subject where username='"&username&"'")
			  while not srs.eof
			  response.Write "<option value="&srs(0)&">"&srs(1)&"</option>"
			  srs.movenext
			  wend
			  %>
        </select>
        </a></td>
      <td width="37%"><div align="center"><a href="User_blog.asp"> 日志管理首页</a>&nbsp;|&nbsp;<a href="User_addblog.asp">添加新日志</a></div></td>
    </tr>
  </form>
</table>
<br>
<%
if Action="SaveAdd" then
	call SaveAdd()
elseif Action="Modify" then
	call Modify()
elseif Action="SaveModify" then
	call SaveModify()
elseif Action="Del" then
	call Delblog()
elseif Action="Lock" then
	call Lockblog()
elseif Action="UnLock" then
	call passblog()
elseif Action="isbest" then
	call isbest()
elseif Action="unisbest" then
	call unisbest()
elseif Action="Move" then
	call moveblog()
else
	call main()
end if
if FoundErr=True then
	call WriteErrMsg()
end if

sub main()
	dim strGuide
	strGuide="<table width='98%' align='center'><tr><td align='left'>您现在的位置：<a href='User_blog.asp'>用户日志管理</a>&nbsp;&gt;&gt;&nbsp;"
	select case UserSearch
		case 0
			if userlevel=9 then
				sql="select * from [blog] order by addtime desc"
			else
				sql="select * from [blog] where username='"&username&"' order by addtime desc"
			end if
			strGuide=strGuide & "所有日志"
		case 1
			if userlevel=9 then
				sql="select * from [blog] where passcheck='false' order by addtime desc"
			else
				sql="select * from [blog] where passcheck='false' and username='"&username&"' order by addtime desc"
			end if
			strGuide=strGuide & "未通过审核日志"
		case 2
			if userlevel=9 then
				sql="select * from [blog] where passcheck='true' order by addtime desc"
			else
				sql="select * from [blog] where passcheck='true' and username='"&username&"' order by addtime desc"
			end if
			strGuide=strGuide & "已通过审核日志"
		case 3
			if userlevel=9 then
				sql="select * from [blog] where isbest='true' order by addtime desc"
			else
				sql="select * from [blog] where isbest='true' and username='"&username&"' order by addtime desc"
			end if
			strGuide=strGuide & "推荐日志"
		case 4
			sql="select * from [blog] where username='"&username&"' order by addtime desc"
			strGuide=strGuide & "我的日志"
		case 10
			if Keyword="" then
				if selectsub>0 then
					sql="select * from [blog] where username='"&username&"' and subjectid="&selectsub&" order by addtime desc"
					strGuide=strGuide & "专题id为"&selectsub&"的日志"
				else
					if userlevel=9 then 
						sql="select * from [blog] order by addtime desc"
					else
						sql="select * from [blog] where username='"&username&"' order by addtime desc"
					end if
					strGuide=strGuide & "所有日志"
				end if
			else
				select case strField
				case "ID"
					if IsNumeric(Keyword)=False then
						FoundErr=True
						ErrMsg=ErrMsg & "<br><li>ID必须是整数！</li>"
					else
						if userlevel=9 then 
							sql="select * from [blog] where ID =" & Clng(Keyword)&" and username='"&username&"'"
						else
							sql="select * from [blog] where ID =" & Clng(Keyword)
						end if
						strGuide=strGuide & "日志ID等于<font color=red> " & Clng(Keyword) & " </font>的用户"
					end if
				case "topic"
					if userlevel=9 then
						sql="select * from [blog] where topic like '%" & Keyword & "%' order by addtime desc"
					else
						sql="select * from [blog] where topic like '%" & Keyword & "%' and username='"&username&"' order by addtime desc"
					end if
					strGuide=strGuide & "标题中含有“ <font color=red>" & Keyword & "</font> ”的日志"
				end select
			end if
		case else
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>错误的参数！</li>"&sql
	end select
	strGuide=strGuide & "</td><td align='right'>"
	if FoundErr=True then exit sub
	
	Set rs=Server.CreateObject("Adodb.RecordSet")
	'response.Write userlevel
	'response.Write(sql)
	rs.Open sql,Conn,1,1
  	if rs.eof and rs.bof then
		strGuide=strGuide & "共找到 <font color=red>0</font> 个日志</td></tr></table>"
		response.write strGuide
	else
    	totalPut=rs.recordcount
		strGuide=strGuide & "共找到 <font color=red>" & totalPut & "</font> 个日志</td></tr></table>"
		response.write strGuide
		if currentpage<1 then
       		currentpage=1
    	end if
    	if (currentpage-1)*MaxPerPage>totalput then
	   		if (totalPut mod MaxPerPage)=0 then
	     		currentpage= totalPut \ MaxPerPage
		  	else
		      	currentpage= totalPut \ MaxPerPage + 1
	   		end if

    	end if
	    if currentPage=1 then
        	showContent
        	showpage strFileName,totalput,MaxPerPage,true,true,"个日志"
   	 	else
   	     	if (currentPage-1)*MaxPerPage<totalPut then
         	   	rs.move  (currentPage-1)*MaxPerPage
         		dim bookmark
           		bookmark=rs.bookmark
            	showContent
            	showpage strFileName,totalput,MaxPerPage,true,true,"个日志"
        	else
	        	currentPage=1
           		showContent
           		showpage strFileName,totalput,MaxPerPage,true,true,"个日志"
	    	end if
		end if
	end if
	rs.Close
	set rs=Nothing
	call ShowSearch()
end sub

sub showContent()
   	dim i,rssubject
    i=0
%>
<table width='100%' border="0" cellpadding="0" cellspacing="0">
  <tr>
  <form name="myform" method="Post" action="User_blog.asp" onsubmit="return confirm('确定要执行选定的操作吗？');">
     <td>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
          <tr class="title"> 
            <td width="38" align="center"><font color="#FFFFFF">选中</font></td>
            <td width="82" align="center"><font color="#FFFFFF">专题</font></td>
            <td width="57" height="22" align="center"><span class="style1">发表人</span> </td>
            <td width="205" height="22" align="center"><font color="#FFFFFF">文章标题</font></td>
            <td width="93" align="center"><font color="#FFFFFF">发表时间</font></td>
            <td width="35" height="22" align="center"><font color="#FFFFFF">推荐</font></td>
            <td width="38" height="22" align="center"><font color="#FFFFFF"> 状态</font></td>
            <td width="179" height="22" align="center"><font color="#FFFFFF"> 
              操作</font></td>
          </tr>
          <%do while not rs.EOF %>
          <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
            <td align="center"><input name='ID' type='checkbox' onclick="unselectall()" id="ID" value='<%=cstr(rs("ID"))%>'>
            <input name='uname' type="hidden"  id="uname" value='<%=trim(rs("username"))%>'></td>
            <td  align="center"><%
			set rssubject=conn.execute("select subjectname from subject where id="&rs("subjectid"))
			if not rssubject.eof then
				response.Write(rssubject(0))
			end if
			%></td>
            <td align="center"><%if rs("author")<>"" then response.Write(htmlencode(rs("author"))) else response.Write(rs("username"))%>
		    </td>
            <td align="center"> <a href=more.asp?name=<%=rs("username")%>&id=<%=rs("id")%> target=_blank><%=htmlencode(rs("topic"))%>  </a> </td>
            <td align="center"> <%
	if rs("addtime")<>"" then
		response.write rs("addtime")
	else
		response.write "&nbsp;"
	end if
	%> </td>
            <td align="center"> <%
	 if rs("isbest")="true" then
	  	response.write "<font color=red>推荐</font>"
	  else
	  	response.write " "
	  end if
			%> </td>
            <td align="center"><%
	  if rs("passcheck")="false" then
	  	response.write "<font color=red>未审</font>"
	  else
	  	response.write "已审"
	  end if
	  %></td>
            <td align="center"> 
              <%
		response.write "<a href='User_blog.asp?Action=Modify&ID=" & rs("ID") & "'>修改</a>&nbsp;"
		if userlevel=9 then
			if rs("passcheck")="true" then
				response.write "<a href='User_blog.asp?Action=Lock&ID=" & rs("ID") & "'>设为未审</a>&nbsp;"
			else
    	        response.write "<a href='User_blog.asp?Action=UnLock&ID=" & rs("ID") & "'>通过审核</a>&nbsp;"
			end if
		end if
		if userlevel=9 then
			if rs("isbest")="true" then
				response.write "<a href='User_blog.asp?Action=unisbest&ID=" & rs("ID") & "'>取消推荐</a>&nbsp;"
			else
				response.write "<a href='User_blog.asp?Action=isbest&ID=" & rs("ID") & "'>设为推荐</a>&nbsp;"
			end if
		end if
        response.write "<a href='User_blog.asp?Action=Del&ID=" & rs("ID") & "&username="&rs("username")&"' onClick='return confirm(""确定要删除此日志吗？"");'>删除</a>"
		%> </td>
          </tr>
          <%
	i=i+1
	if i>=MaxPerPage then exit do
	rs.movenext
loop
%>
        </table>  
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="200" height="30"><input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">
              选中本页显示的所有日志</td>
            <td> <strong>操作：</strong> 
              <input name="Action" type="radio" value="Del" checked onClick="document.myform.subject.disabled=true">删除&nbsp;&nbsp;&nbsp;&nbsp;
			                <input name="Action" type="radio" value="Move" onClick="document.myform.subject.disabled=false">移动到
              <select name="subject" id="subject" disabled>
			  <%
			  set srs=conn.execute("select id,subjectname from subject where username='"&username&"'")
			  while not srs.eof
			  response.Write "<option value="&srs(0)&">"&srs(1)&"</option>"
			  srs.movenext
			  wend
			  set srs=nothing
			  %>
              </select>&nbsp;&nbsp;&nbsp;&nbsp;
              <% if userlevel=9 then %>
			  <input name="Action" type="radio" value="Lock" onClick="document.myform.UserLevel.disabled=true"> 
              设为未审核&nbsp;&nbsp;&nbsp;
              <input name="Action" type="radio" value="UnLock" onClick="document.myform.UserLevel.disabled=true">              
              通过审核&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <%end if%>
              <input type="submit" name="Submit" value=" 执 行 "></td>
  </tr>
</table>
</td>
</form></tr></table>
<%
set rssubject=nothing
end sub

sub ShowSearch()
%>
<form name="theForm" method="post" action="User_blog.asp">
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="border">
  <tr class="tdbg">
    <td width="120"><strong>日志高级查询：</strong></td>
    <td width="300">
      <select name="Field" id="Field">
        <option value="ID">日志ID</option>
        <option value="topic" selected>日志标题</option>
      </select>
      <input name="Keyword" type="text" id="Keyword" size="20" maxlength="30">
      <input type="submit" name="Submit2" value=" 查 询 ">
      <input name="UserSearch" type="hidden" id="UserSearch" value="10">
	</td>
    <td>若为空，则查询所有日志</td>
  </tr>
</table>
</form>
<%
end sub

sub Modify()
	dim ID
	dim rsblog,sqlblog
	ID=trim(request("ID"))
	if ID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>参数不足！</li>"
		exit sub
	else
		ID=Clng(ID)
	end if
	Set rsblog=Server.CreateObject("Adodb.RecordSet")
	if userlevel=9 then
		sqlblog="select * from [blog] where ID=" & ID
	else
		sqlblog="select * from [blog] where ID=" & ID&" and username='"&username&"'"
	end if
	rsblog.Open sqlblog,Conn,1,3
	if rsblog.bof and rsblog.eof then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>找不到指定的日志！</li>"
		rsUser.close
		set rsUser=nothing
		exit sub
	end if
%>
<FORM action="user_blog.asp?action=SaveModify" method="post" name="theForm" onSubmit="return VerifySubmit()">
  <table width="98%" border="0" align=center cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
    <tr align="center"> 
    <td height=25 colspan=5 class="topbg"><strong>修 改  日 志</strong> 
  <tr> 
    <td width="11%"  class="tdbg" height=23>日志标题：</td>
    <td width="89%" colspan="4" class="tdbg"><input name="topic" type=text class="cont" id="topic" value="<%=rsblog("topic")%>" size="50" maxlength="50"> 
      <font color="#FF0000"> *</font></td>
  </tr>
  <tr> 
    <td width="11%" class="tdbg" height=23>日志心情：</td>
    <td colspan="4" class="tdbg"><FONT COLOR="#FF0000"> 
      <input type="radio" name="face" value="1" checked>
      <img src="images/face/1.gif" width="20" height="20"> 
      <input type="radio" name="face" value="2">
      <img src="images/face/2.gif" width="20" height="20"> 
      <input type="radio" name="face" value="3">
      <img src="images/face/3.gif" width="20" height="20"> 
      <input type="radio" name="face" value="4">
      <img src="images/face/4.gif" width="20" height="20"> 
      <input type="radio" name="face" value="5">
      <img src="images/face/5.gif" width="20" height="20"> 
      <input type="radio" name="face" value="6">
      <img src="images/face/6.gif" width="18" height="20"> 
      <input type="radio" name="face" value="7">
      <img src="images/face/7.gif" width="20" height="20"> 
      <input type="radio" name="face" value="8">
      <img src="images/face/8.gif" width="20" height="20"> 
      <input type="radio" name="face" value="9">
      <img src="images/face/9.gif" width="20" height="20"> </FONT></td>
  </tr>
  <tr> 
    <td height=23 colspan="5" class="tdbg">系统分类： 
      <select name="classid" id="classid">
          <option value="<%=rsblog("classid")%>" selected><%
	  set rs=conn.execute("select classname from classname where id="&rsblog("classid"))
	  if not rs.eof then
	  response.Write rs(0)
	  else
	  response.Write "  "
	  end if
		
	  %></option>
        <%
		set rs=conn.execute("select id,classname from classname")
		do while not rs.eof  %>
	        <option value=<%=rs(0)%>><%=rs(1)%></option>
        <%
			rs.movenext
		loop
		set rs=nothing  
	    %>
        </select>       　　
      我的专题(分类)：
        <select name="subjectid" id="subjectid">
	  <option value="<%=rsblog("subjectid")%>" selected><%
	  set rs=conn.execute("select subjectname from subject where id="&rsblog("subjectid"))
	  if not rs.eof then
	  response.Write rs(0)
	  else
	  response.Write "  "
	  end if
		
	  %></option>
         <%
		set rs=conn.execute("select id,subjectname from subject where username='"&username&"'")
		do while not rs.eof  %>
	        <option value=<%=rs(0)%>><%=rs(1)%></option>
        <%
			rs.movenext
		loop
		set rs=nothing  
	    %>
        </select>
      　　 是否隐藏这篇日志： 
      <select name="ishide" id="ishide">
          <option value="true" <%if rsblog("ishide")="true" then response.Write "selected"%>>是</option>
          <option value="false" <%if rsblog("ishide")<>"true" then response.Write "selected"%>>否</option>
        </select></td>
  </tr>
  <tr> 
    <td height=23 colspan="5" class="tdbg">日志密码：
      <input name="ispassword" type="password" id="ispassword" size="10" maxlength="10" value="<%=rsblog("ispassword")%>">
      (无密码请留空 )　　部分显示字数： 
        <input name="showword" type="text" id="showword" value="<%=rsblog("showword")%>" size="10" maxlength="10">
      (全部显示请留空或为零)</td>
  </tr>
  <tr> 
    <td height=23 colspan="5" class="tdbg"><INPUT type="hidden" name="edit" id="edit" value="<%
				if rsblog("logtext")<>"" then
					response.Write Server.HtmlEncode(rsblog("logtext"))
				else
					response.Write ""
				end if
				%>""> 
      <!--#include file="edit.asp"-->
      &nbsp;</td>
  </tr>
  <tr> 
    <td colspan="5" class="tdbg">设置发表时间：
      <select name="selecty" id="selecty">
          <%
	  dim y
	  y=2000
	  while y<=2008
	  	if year(rsblog("addtime"))=y then
		  	response.Write "<option value="&y&" selected>"&y&"</option>"
		else
		  	response.Write "<option value="&y&">"&y&"</option>"
		end if
		y=y+1
	  wend
		%>
      </select>
年
<select name="selectm" id="selectm">
    <%
	  dim m
	  m=1
	  while m<=12
	  	if month(rsblog("addtime"))=m then
		  	response.Write "<option value="&m&" selected>"&m&"</option>"
		else
		  	response.Write "<option value="&m&">"&m&"</option>"
		end if
		m=m+1
	  wend
		%>
</select>
月
<select name="selectd" id="selectd">
    <%
	  dim d
	  d=1
	  while d<=31
	  	if day(rsblog("addtime"))=d then
		  	response.Write "<option value="&d&" selected>"&d&"</option>"
		else
		  	response.Write "<option value="&d&">"&d&"</option>"
		end if
		d=d+1
	  wend
		%>
</select>
        日 
        <select name="selecth" id="selecth">
          <%
	  dim h
	  h=0	  
	  while h<=23
	  	if hour(rsblog("addtime"))=h then
		  	response.Write "<option value="&h&" selected>"&h&"</option>"
		else
		  	response.Write "<option value="&h&">"&h&"</option>"
		end if
		h=h+1
	  wend
		%>
        </select>
        时 
        <select name="selectmi" id="selectmi">
          <%
	  dim mi
	  mi=0 
	  while mi<=59
	  	if minute(rsblog("addtime"))=mi then
		  	response.Write "<option value="&mi&" selected>"&mi&"</option>"
		else
		  	response.Write "<option value="&mi&">"&mi&"</option>"
		end if
		mi=mi+1
	  wend
		%>
        </select>
        分 
        <select name="selects" id="selects">
          <%
	  dim s
	  s=0
	  while s<=59
	  	if second(rsblog("addtime"))=s then
		  	response.Write "<option value="&s&" selected>"&s&"</option>"
		else
		  	response.Write "<option value="&s&">"&s&"</option>"
		end if
		s=s+1
	  wend
		%>
        </select>
        秒 
        <input name="upfiles"  type="hidden" id="upfiles" >
<input name="serverdate"  type="hidden" id="serverdate" value=<%=date()%> ></td>
  </tr>
  <tr> 
      <td height=23 colspan="5" class="tdbg"> <INPUT type="hidden" name="id" value="<%=rsblog("id")%>">
        <input type="submit" name="Submit2" value="提交修改">
        　　　　 
        <input type="reset" name="Submit" value="清除重写">
     </td>
  </tr>
</table> 
</form>
<%
	rsblog.close
	set rsblog=nothing
end sub

sub SaveModify()
	dim id,rsblogchk
	dim logtext
	dim i
	id=clng(trim(request("id")))
	'call chkenaddlog()
	if userlevel=9 then
		sql="select * from blog where id="&id
	else
		sql="select * from blog where id="&id&" and username='"&username&"'"
	end if	
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,1,3
	rs("topic")=debadstr(trim(request("topic")))
	for i = 1 to Request.Form("logtext").Count 
  		logtext = logtext & Request.Form("logtext")(i)
	Next
	if logtext="" then
		logtext=trim(request.form("edit"))
	end if
	rs("logtext")=debadstr(logtext)
	rs("face")=trim(request("face"))
	'rs("username")=username
	rs("addtime")=request("selecty")&"-"&request("selectm")&"-"&request("selectd")&" "&request("selecth")&":"&request("selectmi")&":"&request("selects")
	rs("classid")=clng(trim(request("classid")))
	rs("subjectid")=clng(trim(request("subjectid")))
	if request("showword")<>"" then
		rs("showword")=clng(trim(request("showword")))
	else
		rs("showword")=0
	end if
	rs("ishide")=trim(request("ishide"))
	if request("upfiles")<>"" then
		if rs("upfiles")<>"" then
			rs("upfiles")=rs("upfiles")&"|"&request("upfiles")
		else
			rs("upfiles")=request("upfiles")
		end if
	end if
	if trim(request("ispassword"))<>trim(rs("ispassword")) then
		if trim(request("ispassword"))<>"" then
			rs("ispassword")=md5(trim(request("ispassword")))
		else
			rs("ispassword")=""
		end if
	else
		if trim(request("ispassword"))<>"" then
			rs("ispassword")=md5(trim(request("ispassword")))
		end if
	end if
	set rsblogchk=conn.execute("select blogcheck from bloginfo") '判断是否需要审核
	if rsblogchk("blogcheck")="true" then
		rs("passcheck")="false"
		set rsblogchk=nothing
	else
		if findbadstr(logtext) then '检查敏感字出现次数
			rs("passcheck")="false"
		else
			rs("passcheck")="true"
		end if		
	end if
	set rsblogchk=nothing
	rs.update
	rs.close
	set rs=nothing
	call CloseConn()
	Response.Write"<script language=JavaScript>"
	Response.Write"alert(""修改日志成功！"");"
	Response.Write"window.history.go(-2);"
	Response.Write"</script>"
	'response.redirect "User_blog.asp"
end sub


sub Delblog()
	dim rsfile
	set rsfile=conn.execute("select upfile_path from bloginfo")
	uppath=rsfile(0)
	set rsfile=nothing
	if ID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请指定要删除的日志</li>"
		exit sub
	end if
	if instr(ID,",")>0 then
		ID=replace(ID," ","")
		if userlevel=9 then
			set rsfile=conn.execute("select upfiles from blog where ID  in (" & ID & ")")
			while not rsfile.eof
				if rsfile(0)<>"" then					
					deletefile(rsfile(0))
				end if
			rsfile.movenext
			wend
			set rsfile=nothing
			sql="delete from [blog] where ID  in (" & ID & ")"
		else
			set rsfile=conn.execute("select upfiles from blog where ID  in (" & ID & ") and username='"&username&"'")
			while not rsfile.eof
				if rsfile(0)<>"" then					
					deletefile(rsfile(0))
				end if
			rsfile.movenext
			wend
			set rsfile=nothing
			sql="delete from [blog] where ID  in (" & ID & ")"&" and username='"&username&"'"			
		end if
		conn.execute("delete from comment where mainid in (" & ID & ")")
		dim n,i,u '日志数-１
		n=split(id,",")
		u=split(uname,",")
		for i=0 to ubound(n)
			conn.execute("update [user] set logcount=logcount-1 where username='"&trim(u(i))&"'")
		next		
	else
		if userlevel=9 then
			set rsfile=conn.execute("select upfiles from blog where ID=" & Clng(ID))
			if rsfile(0)<>"" then					
				deletefile(rsfile(0))
			end if
			set rsfile=nothing
			sql="delete from [blog] where ID=" & Clng(ID)

		else
			set rsfile=conn.execute("select upfiles from blog where ID=" & Clng(ID)&" and username='"&username&"'")
			if rsfile(0)<>"" then					
				deletefile(rsfile(0))
			end if
			set rsfile=nothing
			sql="delete from [blog] where ID=" & Clng(ID)&" and username='"&username&"'"
			conn.execute("update [user] set logcount=logcount-1 where username='"&username&"'")
		end if
		conn.execute("delete from comment where mainid="& Clng(ID))		
	end if
	Conn.Execute sql
	call CloseConn()      
	response.redirect ComeUrl
end sub

sub Lockblog()
	if userlevel<>9 then
		exit sub
	end if
	if ID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请选择要设为未审核的日志</li>"
		exit sub
	end if
	if instr(ID,",")>0 then
		ID=replace(ID," ","")
			sql="Update [blog] set passcheck ='false' where ID  in (" & ID & ")"
	else
			sql="Update [blog] set passcheck='false' where ID =" & CLng(ID)
	end if
	Conn.Execute sql
	call CloseConn()      
	response.Redirect "User_blog.asp"
end sub

sub passblog()
	if userlevel<>9 then
		exit sub
	end if
	if ID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请指定要通过审核的日志</li>"
		exit sub
	end if
	if instr(ID,",")>0 then
		ID=replace(ID," ","")
		sql="Update [blog] set passcheck='true' where ID in (" &ID& ")"
	else
		sql="Update [blog] set passcheck='true' where ID=" & CLng(ID)
	end if
	Conn.Execute sql
	call CloseConn()      
	response.Redirect "User_blog.asp"
end sub

sub isbest()
	if userlevel<>9 then
		exit sub
	end if
	if ID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请选择要推荐日志</li>"
		exit sub
	end if
	if instr(ID,",")>0 then
		ID=replace(ID," ","")
		sql="Update [blog] set isbest ='true' where ID  in (" & ID & ")"
	else
		sql="Update [blog] set isbest='true' where ID =" & CLng(ID)
	end if
	Conn.Execute sql
	call CloseConn()      
	response.Redirect "user_blog.asp"
end sub

sub moveblog()
	if id="" then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>请选择要移动的日志</li>"
		exit sub
	end if
	dim subjectid
	subjectid=trim(request("subject"))
	if subjectid="" then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>请指定目标专题</li>"
		exit sub
	else
		subjectid=Clng(subjectid)
	end if
	if instr(id,",")>0 then
		id=replace(id," ","")
		sql="Update [blog] set subjectid="&subjectid&" where id in (" & id & ")"
	else
		sql="Update [blog] set subjectid="&subjectid&" where id=" & id 
	end if
	Conn.Execute sql
	response.Redirect "user_blog.asp"
end sub

sub unisbest()
	if userlevel<>9 then
		exit sub
	end if
	if ID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请选择要取消推荐日志</li>"
		exit sub
	end if
	if instr(ID,",")>0 then
		ID=replace(ID," ","")
		sql="Update [blog] set isbest ='false' where ID  in (" & ID & ")"
	else
		sql="Update [blog] set isbest='false' where ID =" & CLng(ID)
	end if
	Conn.Execute sql
	call CloseConn()      
	response.Redirect "User_blog.asp"
end sub

sub WriteErrMsg()
	dim strErr
	strErr=strErr & "<html><head><title>错误信息</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbcrlf
	strErr=strErr & "<link href='style.css' rel='stylesheet' type='text/css'></head><body><br><br>" & vbcrlf
	strErr=strErr & "<table cellpadding=2 cellspacing=1 border=0 width=400 class='border' align=center>" & vbcrlf
	strErr=strErr & "  <tr align='center' class='title'><td height='22'><strong>错误信息</strong></td></tr>" & vbcrlf
	strErr=strErr & "  <tr class='tdbg'><td height='100' valign='top'><b>产生错误的可能原因：</b>" & errmsg &"</td></tr>" & vbcrlf
	strErr=strErr & "  <tr align='center' class='tdbg'><td><a href='javascript:history.go(-1)'>&lt;&lt; 返回上一页</a></td></tr>" & vbcrlf
	strErr=strErr & "</table>" & vbcrlf
	strErr=strErr & "</body></html>" & vbcrlf
	response.write strErr
end sub

function DeleteFile(Filename) '删除文件 
	dim fso,delname,i,rs

	if Filename<>"" then 
		Set fso = server.CreateObject("Scripting.FileSystemObject")
		if instr(filename,"|")<>0 then
			delname=split(filename,"|")
			for i=0 to ubound(delname)			
				if fso.FileExists(Server.MapPath(uppath&"/"&delname(i))) then 
					fso.DeleteFile Server.MapPath(uppath&"/"&delname(i))
				end if 
			next
		else
			if fso.FileExists(Server.MapPath(uppath&"/"&filename)) then 
				fso.DeleteFile Server.MapPath(uppath&"/"&filename)
			end if 	
		end if
	set fso = nothing 
	end if 
end function 


%>