friend.asp
来自「一个不错的论坛原代码」· ASP 代码 · 共 579 行 · 第 1/2 页
ASP
579 行
<!--#include file="Connections.asp" -->
<!--#include file="inc_admenu.asp"-->
<!--#include file="top.asp" -->
<%cpbtitle="好友中心"
call toptitle(l_title,cpbtitle)
call head(0,cpbusername&"的控制面板首页","userindex.asp",cpbtitle)
if isuser=false then
errormsg="<Li>你还没有登陆,不能操作您的好友表,请先<a href=login.asp target=_blank>登陆</a></li>"
call error(errormsg)
call login()
else
dim h_friend
sql="select h_friend,h_badfriend from home"
set rsconn1=conn.execute(sql)
if not rsconn1.eof then
h_friend=rsconn1("h_friend")
h_badfriend=rsconn1("h_badfriend")
end if
set rsconn1=nothing
%>
<center>
<table border=1 borderColor=<%=tdc2%> cellPadding=0 cellSpacing=0 width=<%=tdc3%> style="border-collapse: collapse">
<tr>
<td class=tdc1 align="center" height="23" <%=tcolor%> width="12%">
<a href="userindex.asp" class=nav1>用户控制面板</a></td>
<td class=tdc1 align="center" height="23" <%=tcolor%> width="12%">
<a href="edituser.asp?action=editbasic" class=nav1>基本资料修改</a></td>
<td class=tdc1 align="center" height="23" <%=tcolor%> width="12%">
<a href="edituser.asp?action=editlink" class=nav1>联系资料修改</a></td>
<td class=tdc1 align="center" height="23" <%=tcolor%> width="12%">
<a href="edituser.asp?action=editpw" class=nav1>用户密码修改</a></td>
<td class=tdc1 align="center" height="23" <%=tcolor%> width="12%">
<a href="friend.asp" class=nav1>编辑好友列表</a></td>
<td class=tdc1 align="center" height="23" <%=tcolor%> width="12%">
<a href="friend.asp?action=badfriend" class=nav1>编辑忽略列表</a></td>
<td class=tdc1 align="center" height="23" <%=tcolor%> width="12%">
<a href="fav.asp" class=nav1>用户收藏管理</a></td>
<td class=tdc1 align="center" height="23" <%=tcolor%> width="12%">
<a href="pm.asp" class=nav1>用户短信服务</a></td>
</tr>
</table>
<font size="1"> </font><br> </center>
<%select case request("action")
case ""
call showfriend()
case "addf"
call addf()
case "add"
call add()
case "删除好友"
call dellfriend()
case "清空好友"
call dellallfriend()
case "badfriend"
call badfriend()
case "addh"
call addh()
case "add1"
call add1()
case "删除忽略用户"
call dellfriend1()
case "清空忽略用户"
call dellallfriend1()
end select
sub showfriend()
%>
<center>
<table border=1 borderColor=<%=tdc2%> cellPadding=4 cellSpacing=1 width=<%=tdc3%> style="border-collapse: collapse" align=center>
<tr>
<td height="21" width="100%" align="center" <%=hColor%> class=tdc1 colspan="5" >
<%=cpbusername%> 好友列表</td>
</tr>
<tr>
<td height="21" width="10%" align="center" <%=tColor%> class=tdc1>用户名</td>
<td height="21" width="50%" align="center" <%=tColor%> class=tdc1>主页</td>
<td height="21" width="20%" align="center" <%=tColor%> class=tdc1>邮件</td>
<td height="21" width="15%" align="center" <%=tColor%> class=tdc1>发短信</td>
<td height="21" width="15%" align="center" <%=tColor%> class=tdc1> 操作</td>
</tr>
<form action="?" method=post>
<% sql="select u_friend from user where username='"&cpbusername&"'"
set rs=conn.execute(sql)
if not rs.eof then u_friend=rs("u_friend")
if not isnull(u_friend) and u_friend<>"" then
u_friendname=split(u_friend,",")
fmaxcount=ubound(u_friendname)
fpage=20'每个用户数
page=request("page")'
c=0
cmax=0
if page="" then page=1
if fmaxcount mod cint(fpage)=0 then
fmaxpage=fmaxcount \ cint(fpage)
else
fmaxpage=fmaxcount \ cint(fpage)+1
end if
for i=0 to (ubound(u_friendname)-1)
sql="select email,home from user where username='"&u_friendname(i)&"'"
set rs=conn.execute(sql)
if not rs.eof then
u_home=rs("home")
u_email=rs("email")
else
u_home="该用户已经不存在,请删除"
u_email="该用户已经不存在,请删除"
end if
c=c+1
if cmax>=fpage then
exit for
elseif c>(page-1)*fpage then
cmax=cmax+1
%>
<tr>
<td height="21" width="10%" align="center" bgcolor=<%=tColor2%> class=tdc><a href="viewuser.asp?username=<%=u_friendname(i)%>" target=_blank><%=u_friendname(i)%></a></td>
<td height="21" width="50%" bgcolor=<%=tColor2%> class=tdc><a href="<%=u_home%>" target=_blank><%=u_home%></a></td>
<td height="21" width="20%" align="center" bgcolor=<%=tColor2%> class=tdc1><a href="mailto:<%=u_email%>"><%=u_email%></a></td>
<td height="21" width="15%" align="center" bgcolor=<%=tColor2%> class=tdc><a href="pm.asp?mode=add&action=add&username=<%=u_friendname(i)%>">发送</a></td>
<td height="21" width="15%" align="center" bgcolor=<%=tColor2%> class=tdc1><INPUT type=radio value=<%=u_friendname(i)%> name=u_username></td> </tr>
<% end if
next%>
<tr align="left" height=23>
<td colspan="6" bgcolor=<%=tColor2%> class=tdc >
<%
if fmaxpage="" then maxpagecount=1
pagestart=page-5
pageend=page+5
if pagestart<1 then pagestart=1
if pageend>fmaxpage then pageend=fmaxpage
response.write(" [ ")
if fmaxpage > 6 then Response.Write ("<a href=?page=1>1</a> ... ")
for i=pagestart to pageend
if i<>int(page) then
Response.Write (" <a href=?page="&i&">" & i & "</a> ")
else
Response.Write ("<b>"&i&"</b> ")
end if
next
if fmaxpage > page +5 then Response.Write( " ... <a href=?page="&fmaxpage&">"&fmaxpage&"</a>")
response.write(" ] ")
response.write("..页次:"&page&"/"&fmaxpage&"页 每页:"&fpage&" 用户数:"&fmaxcount&" </td> ")%>
</tr>
<% else%>
<tr>
<td height="21" width="100%" align="center" bgcolor=<%=tColor2%> class=tdc colspan="5" >
您的好友列表中没有好友</td>
</tr>
<% end if%>
</form>
<tr>
<td height="21" width="100%" align="right" bgcolor=<%=tColor2%> class=tdc colspan="5" >
<input type=button name=action onclick="location.href='?action=addf'" value="添加好友" class=bdtj> <input type=submit name=action onclick="{if(confirm('确定删除选定的纪录吗?')){this.document.inbox.submit();return true;}return false;}" value="删除好友" class=bdtj> <input type=submit name=action onclick="{if(confirm('确定清除所有的纪录吗?')){this.document.inbox.submit();return true;}return false;}" value="清空好友" class=bdtj></td>
</tr>
</table>
</center>
<%
end sub
sub addf()%>
<center>
<table border=1 borderColor=<%=tdc2%> cellPadding=4 cellSpacing=1 width=<%=tdc3%> style="border-collapse: collapse" align=center>
<tr>
<td height="21" width="100%" align="center" <%=hColor%> class=tdc1 colspan="5" >
添加好友</td>
</tr>
<form action="?action=add" method=post>
<tr>
<td align="right" width="25%" bgcolor=<%=tColor2%> class=tdc>好友名称:</td>
<td bgcolor=<%=tColor2%> class=tdc colspan="4">
<input type="text" size="40" name="u_friendname" class="bdtj" value=""> 多位好友请用逗号(,)分开,最多4位用户
</td>
</tr>
<tr>
<td bgcolor=<%=tColor2%> class=tdc width="15%"> </td>
<td bgcolor=<%=tColor2%> class=tdc colspan="4">
<input type="submit" name="Submit" value="保存" class="bdtj" >
<input type="button" value="返回" onClick="JavaScript:history.go(-1)" name="Button" class="bdtj">
</td>
</tr>
</form>
</table>
</center>
<%
end sub
sub add()
u_friendname1=chktopic(request("u_friendname"))
if u_friendname1="" then
errormsg=errormsg&"<li>您没有输入好友名称</li>"
else
u_friendname=split(u_friendname1,",")
if ubound(u_friendname)>3 then errormsg=errormsg&"<li>您输入的好友名称超过了4个,请减少重新输入</li>"
end if
if errormsg<>"" then
call error(errormsg)
call bq()
response.end
end if
u_monyfriend=0
sql="select u_friend from user where username='"&cpbusername&"'"
set rs=conn.execute(sql)
if not rs.eof then
u_friend1=rs("u_friend")
if not isnull(u_friend1) then
u_friend=split(u_friend1,",")
u_monyfriend=ubound(u_friend)
end if
else
errormsg=errormsg&"<li>参数错误,非法登陆</li>"
end if
for i=0 to ubound(u_friendname)
if cpbusername=u_friendname(i) then
errormsg=errormsg&"<li>很抱歉,您不可以自己添加自己</li>"
exit for
end if
if instr(u_friend1,u_friendname(i))>0 then
errormsg=errormsg&"<li>用户<B>"&u_friendname(i)&"</b>已经在您的好友表中</li>"
exit for
end if
if u_monyfriend+ubound(u_friendname)>=int(h_friend) then
errormsg=errormsg&"<li>您的好友表只能存在"&h_friend&"位好友,现在已经有"&u_monyfriend&"位好友</li>"
exit for
end if
sql="select username from user where username='"&u_friendname(i)&"'"
set rs=conn.execute(sql)
if rs.eof then
errormsg=errormsg&"<li>用户<B>"&u_friendname(i)&"</b>不存在</li>"
exit for
end if
next
if errormsg<>"" then
call error(errormsg)
call bq()
response.end
else
sql="update user set u_friend=u_friend&'"&u_friendname1&","&"' where username='"&cpbusername&"'"
conn.execute(sql)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?