user_blog.asp

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

ASP
862 行
字号
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="form2" 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>
日
<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
	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")=trim(request("topic"))
	rs("logtext")=request("edit")
	rs("face")=trim(request("face"))
	'rs("username")=username
	rs("addtime")=request("selecty")&"-"&request("selectm")&"-"&request("selectd")&" "&time()
	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
		rs("passcheck")="true"
		set rsblogchk=nothing
	end if
	rs.update
	rs.close
	set rs=nothing
	call CloseConn()
	Response.Write"<script language=JavaScript>"
	Response.Write"alert(""修改日志成功!"");"
	Response.Write"window.location='user_blog.asp'"
	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 '日志数-1
		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&"'"
		end if
		conn.execute("delete from comment where mainid="& Clng(ID))
		conn.execute("update [user] set logcount=logcount-1 where username='"&uname&"'")
	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 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 


%>

⌨️ 快捷键说明

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