📄 diary.asp
字号:
<!--#include file="head.asp"-->
<SCRIPT language=javascript>
<!--
function selectpage_onchange()
{
location.href = "diary.asp?user=<%=username%>&page=" + form1.page2.value;
}
//-->
</SCRIPT>
<script language="javascript">
function yesok(){
if (confirm("确认要执行此操作吗?"))
return true;
else
return false;
}
</script>
<%
'=========================================================
' 随然日记本(多用户版) Version:3.0
' Date: 2004-11-15
' Script Written by 随然(dampure)
' 随然日记本演示地址:http://www.suiran.cn
'=========================================================
' Copyright (C) 2003,2004 真露无香. All rights reserved.
' Web: www.yongzi.com
' Diary:http://www.suiran.cn
'=========================================================
set rs=server.createobject("adodb.recordset")
sql="select * from admin where user='"& username &"'"
rs.open sql,conn,1,1
if rs.eof then
%>
<script language=vbscript>
MsgBox "系统中没有该用户,请返回首页注册!"
location.href = "login.asp"
</script>
<%
end if
id=rs("userid")
rs.close
set rs=server.createobject("adodb.recordset")
sql="select * from diary where userid="& id &" order by id desc"
rs.open sql,conn,1,1
const MaxPerPage=12
page=request("page")
if page<>empty and page<>"" then
'检测输入页数是否合法
pagestrlong=len(page)
chOK="0123456789"
chvalid=true
j=1
do while j<=pagestrlong
ch=mid(page,j,1)
If instr(chOK,ch)=0 then
chvalid=false
exit do
end if
j=j+1
loop
'检测完毕
if not chvalid then '如果不合法
currentPage=1 '默认为第1页
else
currentPage=int(page) '如果合法则取整数
if currentpage=0 then '如果是0页取1
currentpage=1
end if
end if
else
currentPage=1 '如果空白测取第1页
end if
if rs.eof and rs.bof then
showadd
else
totalPut=rs.recordcount '记录总数
'判断最大显示页数
if totalput<=maxperpage then
maxpagenum=1
else
pageys=totalput/maxperpage
if pageys > int(pageys) then
maxpagenum=int(pageys)+1
else
maxpagenum=int(pageys)
end if
end if
if currentPage=1 then
j = 1
showContent
else
if (currentPage-1)*MaxPerPage>=totalPut then
currentPage=maxpagenum
end if
rs.move (currentPage-1)*MaxPerPage
j = (currentPage-1)*MaxPerPage+1
showContent
end if
rs.close
end if
set rs=nothing
conn.close
set conn=nothing
sub showContent
%>
<FORM id=form1 name=form1 action=diary.asp method=post>
<TABLE cellSpacing=0 cellPadding=0 width=609 align=center border=0
dwcopytype="CopyTableRow">
<TBODY>
<TR>
<TD><IMG height=2 src="images/top01.gif"
width=609></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=609 align=center
border=0><TBODY>
<TR>
<TD height=17><A
href="login.asp?user=<%=username%>"><IMG height=204
alt="返回<%=rs2("nickname")%>的日记本封面" src="pic/diy0<%=k%>.jpg" width=609
border=0></A></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=609 align=center
border=0><TBODY>
<TR>
<TD><IMG height=2 src="images/top01.gif"
width=609></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=609 align=center
bgColor=#636562 border=0>
<TBODY>
<TR height=40>
<TD height=36>
<TABLE cellSpacing=0 cellPadding=4 width="100%"
bgColor=#ffffff border=0>
<TBODY>
<TR>
<TD bgColor=#636562>
<% if rs("userid")=session("userid") then %>
<DIV align=center><FONT color=#ffffff><A
href="index.asp"><FONT
color=#ffffff>日记首页</FONT></A><FONT
color=#ffffff> </FONT><A
href="cover.asp"><FONT
color=#ffffff>日记封面</FONT></A><FONT
color=#ffffff> </FONT><A
href="write_diary.asp"><FONT
color=#ffffff>签写日记</FONT></A> <A
href="admin.asp"><FONT
color=#ffffff>日记管理</FONT></A>
<%
set rsbest=server.createobject("adodb.recordset")
sql="select * from admin where userid="&session("userid")
rsbest.open sql,conn,1,1
mybest=rsbest("mybest")
rsbest.close
if mybest=0 then
%>
<A href="mybest.asp?best=1" target="_blank" onclick='return yesok()'><FONT color=#ffffff>日记自荐</FONT></A>
<%else%>
<A href="mybest.asp?best=0" target="_blank" onclick='return yesok()'><FONT color=#ffffff>取消自荐</FONT></A>
<%end if%>
<A
href="logout.asp"><FONT
color=#ffffff>退出登陆</FONT></A></DIV>
<% end if %></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff>
<TABLE borderColor=#e3e3e3 cellSpacing=0 borderColorDark=#e3e3e3
cellPadding=0 width=609 align=center bgColor=#ffffff border=1
bordercolorlight="#E3E3E3">
<TBODY>
<TR bgColor=#e6e6e6>
<TD width="45%" bgColor=#e6e6e6>
<DIV align=center>主 题</DIV></TD>
<TD width="10%">
<DIV align=center>字数</DIV></TD>
<TD width="7%">
<DIV align=center>阅读</DIV></TD>
<TD width="7%">
<DIV align=center>评论</DIV></TD>
<TD width="11%">
<DIV align=center>天气</DIV></TD>
<TD width="20%">
<DIV align=center>时间</DIV></TD></TR>
<%
i=1
do while not (rs.eof or err)
if len(rs("title"))>12 then
title=left(rs("title"),12)&"......"
elseif rs("title")="" then
title=left(rs("content"),12)&"......"
else
title=rs("title")
end if
nowtime=rs("date")
writeday=cstr(year(nowtime))+"-"+cstr(month(nowtime))+"-"+cstr(day(nowtime))
%>
<TR>
<TD width="45%"> <A
href=show_diary.asp?id=<%=rs("id")%> target=_blank><FONT color=#666666><%=title%></FONT></A><%if rs("lock")=0 then response.Write "<IMG src=images/lock.gif border=0>"
grade=Int(rs("hits")/200)
if grade>5 then grade=5
for n=1 to grade
response.Write "<IMG src=images/star.gif border=0>"
next
%>
</TD>
<TD width="10%"> <DIV align=center><FONT color=#999999
size=2><%=rs.fields("content").actualsize/2%></FONT></DIV></TD>
<TD width="8%"> <DIV align=center><FONT color=#666666
size=2><%=rs("hits")%></FONT></DIV></TD>
<TD width="8%"> <DIV align=center><FONT color=#666666
size=2><%=rs("saynum")%></FONT></DIV></TD>
<TD width="11%">
<DIV align=center><FONT color=#666666><%=rs("weather")%></FONT></DIV></TD>
<TD width="20%">
<DIV align=center><FONT color=#666666><%=writeday%></FONT></DIV></TD></TR>
<%
j=j+1
i=i+1
if i>MaxPerPage then exit do '循环时如果到尾部则先退出,如果记录达到页最大显示数,也退出
rs.movenext
loop
%>
</TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=2 width=609 align=center border=0>
<TBODY>
<TR bgColor=#e6e6e6>
<TD width="10%"></TD>
<TD width="50%"><%
If currentPage <> 1 Then
Response.Write "<FONT color=#666666>|<a href=diary.asp?user=" & username & ">首页</a></FONT>"
Response.Write "<FONT color=#666666>|<a href=diary.asp?user=" & username & "&Page=" & (currentPage-1) & ">上页</a></FONT>"
else
Response.Write "<FONT color=#666666>|首页</FONT></FONT>"
Response.Write "<FONT color=#666666>|上页</FONT>"
End If
If currentPage <> maxpagenum Then
Response.Write "<FONT color=#666666>|<a href=diary.asp?user=" & username & "&Page=" & (currentPage+1) & ">下页</a></FONT>"
Response.Write "|<a href=diary.asp?user="&username&"&Page=" & maxpagenum & ">末页</a>|"
else
Response.Write "<FONT color=#666666>|下页</FONT>"
Response.Write "<FONT color=#666666>|末页|</FONT>"
End If
%>
<FONT color=#666666>页数: </FONT><SELECT
language=javascript class=drpdwn onchange=selectpage_onchange() size=1
name=page2>
<% for i = 1 to maxpagenum %>
<OPTION value="<%=i%>" <% if currentpage=i then response.write " selected"%> ><%=i%></OPTION>
<%
next
%>
</SELECT>
<TD width="40%">
共有日记:<font color=#990000> <%=totalPut%> </font>则|
<FONT class=s><B>当前: (<%=currentPage%>/<%=maxpagenum%>页)</B></FONT>
</TD>
</TR></TBODY></TABLE></TD></TR>
<TR>
<TD bgColor=#ffffff height=16>
<TABLE cellSpacing=0 cellPadding=3 width=609 align=center bgColor=#9c9a9d
border=0>
<TBODY>
<!--#include file="foot.asp"-->
</TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
</FORM></BODY></HTML>
<% end sub %>
<%
sub showadd
%>
<FORM id=form1 name=form1 action=diary.asp method=post>
<TABLE cellSpacing=0 cellPadding=0 width=609 align=center border=0
dwcopytype="CopyTableRow">
<TBODY>
<TR>
<TD><IMG height=2 src="images/top01.gif"
width=609></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=609 align=center
border=0><TBODY>
<TR>
<TD height=17><A
href="login.asp?user=<%=username%>"><IMG height=204
alt="返回<%=rs2("nickname")%>的日记本封面" src="pic/diy0<%=k%>.jpg" width=609
border=0></A></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=609 align=center
border=0><TBODY>
<TR>
<TD><IMG height=2 src="images/top01.gif"
width=609></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=609 align=center
bgColor=#636562 border=0>
<TBODY>
<TR height=40>
<TD height=36>
<TABLE cellSpacing=0 cellPadding=4 width="100%"
bgColor=#ffffff border=0>
<TBODY>
<TR>
<TD bgColor=#636562>
<% if request("user")=session("username") then %>
<DIV align=center><FONT color=#ffffff><A
href="index.asp"><FONT
color=#ffffff>日记首页</FONT></A><FONT
color=#ffffff> </FONT><A
href="write_diary.asp"><FONT
color=#ffffff>签写日记</FONT></A> <A
href="admin.asp"><FONT
color=#ffffff>日记管理</FONT></A> <A
href="logout.asp"><FONT
color=#ffffff>退出登陆</FONT></A></DIV>
<% end if %>
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff>
<TABLE borderColor=#e3e3e3 cellSpacing=0 borderColorDark=#e3e3e3
cellPadding=0 width=609 align=center bgColor=#ffffff border=1
bordercolorlight="#E3E3E3">
<TBODY>
<TR bgColor=#e6e6e6>
<TD width="42%" bgColor=#e6e6e6>
<DIV align=center>主 题</DIV></TD>
<TD width="17%">
<DIV align=center>天气</DIV></TD>
<TD width="14%">
<DIV align=center>时间</DIV></TD></TR>
<TR>
<TD colspan="3" width="42%" align="center"><FONT color=#666666>对不起,你还没有写日记</FONT>
</TD></TR>
</TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=2 width=609 align=center border=0>
<TBODY>
<TR bgColor=#e6e6e6>
<TD width="10%"></TD>
<TD width="50%"><%
If currentPage <> 1 Then
Response.Write "<FONT color=#666666>|首页</FONT>"
Response.Write "<FONT color=#666666>|上页</FONT>"
else
Response.Write "<FONT color=#666666>|首页</FONT></FONT>"
Response.Write "<FONT color=#666666>|上页</FONT>"
End If
If currentPage <> maxpagenum Then
Response.Write "<FONT color=#666666>|下页</FONT>"
Response.Write "<FONT color=#666666>|末页|</FONT>"
else
Response.Write "<FONT color=#666666>|下页</FONT>"
Response.Write "<FONT color=#666666>|末页|</FONT>"
End If
%>
<FONT color=#666666>页数: </FONT><SELECT
language=javascript class=drpdwn onchange=selectpage_onchange() size=1
name=page2>
<OPTION value="1">1</OPTION>
</SELECT>
<TD width="40%">
共有日记:<font color=#990000> 0 </font>则|
<FONT class=s><B>当前: (1/1页)</B></FONT>
</TD>
</TR></TBODY></TABLE></TD></TR>
<TR>
<TD bgColor=#ffffff height=16>
<TABLE cellSpacing=0 cellPadding=3 width=609 align=center bgColor=#9c9a9d
border=0>
<TBODY>
<!--#include file="foot.asp"-->
</TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
</FORM></BODY></HTML>
<% end sub %>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -