user_blog.asp

来自「个人博客」· ASP 代码 · 共 862 行 · 第 1/2 页

ASP
862 行
字号
<!--#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.form2.topic.value);
     if (topic.length == 0)
     {
        alert("您忘了填写题目!");
	return false;
     }
	 
	 var needclassid=<%=needclassid%>
	 if (needclassid==true) {
	 if (document.form2.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.form2.edit.value == "")
     {
        alert("请输入日志内容!");
	return false;
     }	
	var date=document.form2.selecty.value+"-"+document.form2.selectm.value+"-"+document.form2.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 sdate=document.form2.serverdate.value
	date = date.replace(/\-/g,"\/");
	sdate = sdate.replace(/\-/g,"\/");	
	if ((new Date(date) > new Date(sdate))){
		alert("日志日期不能大于今天!");
	return false;
	}
	 
	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
keyword=trim(request("keyword"))
if keyword<>"" then 
	keyword=ReplaceBadChar(keyword)
end if
strField=trim(request("Field"))
UserSearch=trim(request("UserSearch"))
Action=trim(request("Action"))
ID=trim(Request("ID"))
uname=trim(Request("uname"))
ComeUrl=Request.ServerVariables("HTTP_REFERER")

if UserSearch="" then
	UserSearch=0
else
	UserSearch=Clng(UserSearch)
end if
strFileName="user_blog.asp?UserSearch=" & UserSearch
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>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</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=2 align=center><strong>用 户 日 志 管 理</strong></td>
  </tr>
  <form name="form1" action="User_blog.asp" method="get">
    <tr class="tdbg"> 
      <td width="100" height="30"><strong>快速查找日志:</strong></td>
      <td width="687" height="30"><select size=1 name="UserSearch" onChange="javascript:submit()">
          <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%>
          <option value="10" selected> </option>
         
        </select>
        &nbsp;&nbsp;&nbsp;&nbsp;<a href="User_blog.asp">日志管理首页</a>&nbsp;|&nbsp;<a href="User_addblog.asp">添加新日志</a></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()
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 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 & "所有日志"
			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
    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="29" align="center"><font color="#FFFFFF">选中</font></td>
            <td width="29" align="center"><font color="#FFFFFF">ID</font></td>
            <td width="56" height="22" align="center"><span class="style1">发表人</span> </td>
            <td width="251" height="22" align="center"><font color="#FFFFFF">文章标题</font></td>
            <td width="104" align="center"><font color="#FFFFFF">发表时间</font></td>
            <td width="35" height="22" align="center"><font color="#FFFFFF">推荐</font></td>
            <td width="35" height="22" align="center"><font color="#FFFFFF"> 状态</font></td>
            <td width="185" 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 width="29" 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 width="29" align="center"><%=rs("ID")%></td>
            <td width="56" align="center"><%=rs("username")%>
		    </td>
            <td align="center"> <a href=more.asp?name=<%=rs("username")%>&id=<%=rs("id")%> target=_blank><%=rs("topic")%>  </a> </td>
            <td align="center"> <%
	if rs("addtime")<>"" then
		response.write rs("addtime")
	else
		response.write "&nbsp;"
	end if
	%> </td>
            <td width="35" align="center"> <%
			 if rs("isbest")="true" then
	  	response.write "<font color=red>推荐</font>"
	  else
	  	response.write " "
	  end if
			%> </td>
            <td width="36" align="center"><%
	  if rs("passcheck")="false" then
	  	response.write "<font color=red>未审</font>"
	  else
	  	response.write "已审"
	  end if
	  %></td>
            <td width="185" 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.UserLevel.disabled=true">删除&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>
<%
end sub

sub ShowSearch()
%>
<form name="form2" 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

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?