<!--#include file="../conn.asp" -->
<%

if request.QueryString("action")="deluser" then
set rs2=server.CreateObject("adodb.recordset")
userid=request.QueryString("userid")
sql2="select * from diaryuser where userid="&userid
rs2.open sql2,conn,1,3
rs2.delete
rs2.close
sql3="select * from diary where userid="&userid
rs2.open sql3,conn,1,3
rs2.delete
rs2.close
set rs2=nothing
end if
if session("username")="" or session("Password")="" Or session("userid")="" Or session("s0huuser")="" then
response.Redirect(diarydir&"index.asp")
response.End()
else
username=session("username")
userid=session("userid")
end if

action=request.QueryString("action")
dim strUrl,Item_Classid,id,FileName,FilePath,Do_Url,Html_Temp,objXmlHttp,binFileData,objAdoStream
select case action
case "logout"
session("username")=""
session("userid")=""
session("Password")=""
session("photouserid")=""
session("s0huuser")=""
okstring="<html><head><meta http-equiv=Content-Type content=text/html; charset=gb2312><title>成功退出</title><meta http-equiv=refresh content=0;URL="&diarydir&"index.asp><link href=blueyr2.css rel=stylesheet type=text/css></head>"
okstring=okstring+"<body><font color=#FF6600><div align=center>您已经成功退出日记本.如果IE没有自动返回,请点击<a href="&diarydir&"index.asp>这里</a>！</div></font></body></html>"
response.Write(okstring)

case "add"
user=Trim(Request.Form("user"))
title=Trim(Request.Form("title"))
content=Trim(Request.Form("Content"))
xq=Trim(Request.Form("xq"))
mtype=Trim(Request.Form("mtype"))
bg=Trim(Request.Form("bg"))
tq=Trim(Request.Form("tq"))
display=Trim(Request.Form("display"))
typeid=Trim(Request.Form("list"))
typeids=split(typeid,"$")
title=stripHTML(title)
'content=stripHTML(content)
set rs=server.CreateObject("adodb.recordset")
sql="select * from diary"
rs.open sql,conn,1,3
booktotal0=rs.recordcount
rs.addnew
rs("title")=title
rs("content")=content
rs("tq")=tq
rs("xq")=xq
rs("mtype")=mtype
rs("bg")=bg
rs("typeid")=typeids(0)
rs("diarytime")=now()
rs("userid")=userid
rs("display")=display
rs.update
did=rs("diaryid")
rs.close
booktotal=booktotal0+1
'HX_SetRSD.CursorLocation   =   3
Set rx = Server.CreateObject("ADODB.Recordset")
  sql="select * from xqlist where xqorder="&CInt(xq)
   rx.open sql,conn,3,2
   xq=rx("xqcontent")
   'rx.update
   rx.close

Set r = Server.CreateObject("ADODB.Recordset")
sql="select * from diaryuser where userid="&userid
r.open sql,conn,3,2
r("amount")=r("amount")+1
bookname=r("bookname")
user=r("username")
r.update
r.close

If ishtml="yes" Then

if mtype="5" then 
bg=replace(bg,"play/jd/5","")
bg=replace(bg,".jpg","")
mtype=mtype&bg
screenww=(Request.Cookies("screenw")-1024)/2
end if
File = diarydir&"m\riji"&mtype&".htm"
rijibody=LoadFile(File)
rijibody=rijire(rijibody)
if mtype="5" then rijibody=replace(rijibody,"{screenww}",screenww)
FileName = "riji"&did&".htm"
FilePath = diarydir&htmldir&"\"&FileName
SaveToFile rijibody,FilePath

rb=booktotal Mod diarylistno
rb0=booktotal0 Mod diarylistno
File = diarydir&"m\newlist.htm"
rijibody=LoadFile(File)
rijibody=newlistre(rijibody)
FileName = "newlist.htm"
FilePath = diarydir&sitelistdir&"\"&FileName
SaveToFile rijibody,FilePath
FilePath = diarydir&sitelistdir&"\"&"newlist_"&(Int(booktotal0/diarylistno)+1)&".htm"
SaveToFile rijibody,FilePath
If rb0=0 Then
File = diarydir&"m\newlist.htm"
rijibody=LoadFile(File)
rijibody=newlistre0(rijibody,booktotal)
FileName = "newlist_"&Int(booktotal0/diarylistno)&".htm"
FilePath = diarydir&sitelistdir&"\"&FileName
SaveToFile rijibody,FilePath
End if
End if

okstring="<html><head><meta http-equiv=Content-Type content=text/html; charset=gb2312><title>成功添加</title><meta http-equiv=refresh content=0;URL="&diarydir&"mybook.asp><link href=blueyr.css rel=stylesheet type=text/css></head>"
okstring=okstring+"<body><font color=#FF6600><div align=center>日记提交成功..!正在跳转至日记本首页...<br>如果IE没有自动返回,请点击<a href="&diarydir&"mybook.asp>这里</a>！</div></font></body></html>"
response.Write(okstring)

case "edit"
diaryid=Trim(Request.Form("diaryid"))
title=Trim(Request.Form("title"))
content=Trim(Request.Form("content"))
tq=Trim(Request.Form("tq"))
mtype=Trim(Request.Form("mtype"))
bg=Trim(Request.Form("bg"))
xq=Trim(Request.Form("xq"))
display=Trim(Request.Form("display"))
typeid=Trim(Request.Form("list"))
typeids=split(typeid,"$")
title=stripHTML(title)
'content=stripHTML(content)
set rs=server.CreateObject("adodb.recordset")
sql="select * from diary where diaryid="&diaryid
rs.open sql,conn,1,3
rs("title")=title
rs("content")=content
rs("xq")=xq
rs("mtype")=mtype
rs("bg")=bg
rs("tq")=tq
rs("typeid")=typeids(0)
rs("display")=display
rs.update
did=rs("diaryid")
rs.close

Set rx = Server.CreateObject("ADODB.Recordset")
  sql="select * from xqlist where xqorder="&CInt(xq)
   rx.open sql,conn,3,2
   xq=rx("xqcontent")
   rx.update
   rx.close

Set r = Server.CreateObject("ADODB.Recordset")
  sql="select * from diaryuser where userid="&userid
   r.open sql,conn,1,3
   bookname=r("bookname")
   user=r("username")
   r.close

if mtype="5" then 
bg=replace(bg,"play/jd/5","")
bg=replace(bg,".jpg","")
mtype=mtype&bg
screenww=(Request.Cookies("screenw")-1024)/2
end if
File = diarydir&"m\riji"&mtype&".htm"
rijibody=LoadFile(File)
rijibody=rijire(rijibody)
if mtype="5" then rijibody=replace(rijibody,"{screenww}",screenww)
FileName = "riji"&did&".htm"
FilePath = diarydir&htmldir&"\"&FileName
SaveToFile rijibody,FilePath

okstring="<html><head><meta http-equiv=Content-Type content=text/html; charset=gb2312><title>成功编辑</title><meta http-equiv=refresh content=0;URL="&diarydir&"mybook.asp><link href=mood8_diary.css rel=stylesheet type=text/css></head>"
okstring=okstring+"<body><font color=#FF6600><div align=center>日记修改成功..!正在跳转至日记本首页...<br>如果IE没有自动返回,请点击<a href="&diarydir&"mybook.asp>这里</a>！</div></font></body></html>"
response.Write(okstring)

case "del"
diaryid=Trim(Request.QueryString("diaryid"))
sql="select * from diary where diaryid="&diaryid
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,3
userid=rs("userid")

if session("userid")=userid then
else
%>
<script language='Javascript'>alert("您无权删除其他用户的信息!");history.back();</script>
<%
response.end
end if

rs.delete
rs.close
Set r = Server.CreateObject("ADODB.Recordset")
  sql="select * from diaryuser where userid="&userid
   r.open sql,conn,3,2
   
   if r("amount")<1 then
    r("amount")=0
	else
	r("amount")=r("amount")-1
	end if
   r.update
    r.close
    conn.close
set conn=nothing
%>
<script language='Javascript'>alert("您已经成功删除此日记");this.location.href='mdiary.asp';</script>
<%
case "delly"
id=Trim(Request.QueryString("id"))
sql="select * from book where id="&id
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,3
username=rs("bookuser")

if session("username")=username then
else
%>
<script language='Javascript'>alert("您无权删除其他用户的信息!");history.back();</script>
<%
response.end
end if

rs.delete
rs.close
conn.close
set conn=nothing
%>
<script language='Javascript'>alert("您已经成功删除此留言!");this.location.href='mybook006.asp';</script>
<%
end select
%>


