<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="../Task/TaskConfig.asp"-->
<!--#include file="../HSK_Cls/HSK.MemberCls.asp"-->
<!--#include file="../HSK_Cls/HSK.Label.CommonCls.asp"-->
<%
Dim KSCls
Set KSCls = New User_Friend
KSCls.HSK_Run()
Set KSCls = Nothing

Class User_Friend
        Private KS,KSUser
		Private CurrentPage,totalPut
		Private RS,MaxPerPage,SQL,tablebody,strErr,action,boxName,smscount,smstype,readaction,turl
		Private ArticleStatus,ComeUrl
		Private Sub Class_Initialize()
			MaxPerPage =20
		  Set KS=New PublicCls
		  Set KSUser = New UserCls
		End Sub
        Private Sub Class_Terminate()
		 Set KS=Nothing
		 Set KSUser=Nothing
		End Sub
		%>
		<!--#include file="../HSK_Cls/UserFunction.asp"-->
		<%
       Public Sub loadMain()
		ComeUrl=Request.ServerVariables("HTTP_REFERER")
		IF Cbool(KSUser.UserLoginChecked)=false Then
		  Response.Write "<script>top.location.href='Login';</script>"
		  Exit Sub
		End If
		action=KS.S("Action")
		Call KSUser.Head()
		Call KSUser.InnerLocation("我的好友")
		KSUser.CheckPowerAndDie("s03")
		%>
		<div class="tabs">	
			<ul>
				<li<%If action="" And KS.S("listtype")="" then KS.Echo " class='select'"%>><a href="?">我的好友</a>
<!--				<span class="rl bl" onMouseover="$('#f').show();"><a href="?">我的好友 <img src="images/menu_icon.gif" align="absmiddle"/></a>-->
				
                <li<%If KS.S("listtype")="3" then KS.Echo " class='select'"%>><a href="?listtype=3">黑名单</a></li>
<!--				 <div id="f" class='abs' onMouseOut="$('#f').hide();">
				 <dl><a href='?listtype=1'> 好 朋 友 </a>&nbsp;&nbsp;</dl>
				 <dl><a href='?listtype=2'> 陌 生 人 </a>&nbsp;&nbsp;</dl>
				 <dl><a href='?listtype=3'> 黑 名 单 </a>&nbsp;&nbsp;</dl>
				 </div>
				</span>-->
				</li>
<!--				<li<%If action="addF" then KS.Echo " class='select'"%>><a href="?action=addF">寻找好友</a></li>
				<li<%If action="online" then KS.Echo " class='select'"%>><a href="user_friend.asp?action=online">在线用户</a></li>-->
				<li<%if action="add" then KS.Echo " class='select'"%>><a href="?Action=add">添加好友</a></li>
				<li<%if action="mail" then KS.Echo " class='select'"%>><a href="?Action=mail">邮件邀请好友</a></li>
			</ul>
	 </div>
	 
	 	<script src="../HSK_JS/HSK.box.js"></script>
		<script type="text/javascript">
		 function checkmsg()
		 {
		     var message=escape($("#message").val());
			 var username=escape($("#username").val());
			 if (username==''){
			  alert('参数传递出错!');
			  closeWindow();
			 }
			 if (message==''){
			   alert('请输入消息内容!');
			   $("#message").focus();
			   return false;
			 }
			 $.get("../plus/ajaxs.asp",{action:"SendMsg",username:username,message:message},function(r){
			   r=unescape(r);
			   if (r!='success'){
				alert(r);
			   }else{
				 alert('恭喜，您的消息已发送!');
				 closeWindow();
			   }
			 });
         }
		 function sendMsg(ev,username)
		 {
		  new KesionPopup().mousepopup("<img src='../images/user/mail.gif' align='absmiddle'>发送消息","对方登录后可以看到您的消息(可输入255个字符)<br /><textarea name='message' id='message' style='width:340px;height:80px'></textarea><div style='text-align:center;margin:10px'><input type='button' onclick='return(checkmsg())' value=' 确 定 ' class='button'><input type='hidden' value="+username+" name='username' id='username'> <input type='button' value=' 取 消 ' onclick='closeWindow()' class='button'></div>",350)
		 }
        function check()
		{
		
		 var message=escape($("#message").val());
		 var username=escape($("#username").val());
		 if (username==''){
		  alert('参数传递出错!');
		  closeWindow();
		 }
		 if (message==''){
		   alert('请输入附言!');
		   $("#message").focus();
		   return false;
		 }
		 $.get("../plus/ajaxs.asp",{action:"AddFriend",username:username,message:message},function(r){
		   r=unescape(r);
		   if (r!='success'){
		    alert(r);
		   }else{
		     alert('您的请求已发送,请等待对方的确认!');
			 closeWindow();
		   }
		 });
		}
		function addF(ev,username)
		{ 
		 show(ev,username);
		 var isMyFriend=false;
		 $.get("../plus/ajaxs.asp",{action:"CheckMyFriend",username:escape(username)},function(b){
			  if (b=='true'){
			  closeWindow();
			  alert('用户['+username+']已经是您的好友了！');
			  return false;
			 }else if(b=='verify'){
			  closeWindow();
			  alert('您已邀请过['+username+'],请等待对方的认证!');
			  return false;
			 }else{
			   show(ev,username);
			 }
		 });
		 
		}
		function show(ev,username)
		{
		 new KesionPopup().mousepopup("<img src='../images/user/log/106.gif'>添加好友","通过对方验证才能成为好友(可输入255个字符)<br /><textarea name='message' id='message' style='width:340px;height:80px'></textarea><div style='text-align:center;margin:10px'><input type='button' onclick='return(check())' value=' 确 定 ' class='button'><input type='hidden' value="+username+" name='username' id='username'> <input type='button' value=' 取 消 ' onclick='closeWindow()' class='button'></div>",350);
		}		 
		</script>
		
		<%
		action=lcase(Trim(request("action")))
		CurrentPage=Trim(request("page"))
		if Isnumeric(CurrentPage) then
			CurrentPage=Clng(CurrentPage)
		else
			CurrentPage=1
		end if
		select case action
		case "add"
		    Call AddFriend()
			Call KSUser.InnerLocation("添加好友")
	    case "edit"
		    Call AddFriend()
			Call KSUser.InnerLocation("修改好友资料")
		case "addsave"
		    call addsave()
		case "del"
		    call DelFriend()
		case "info"
			call info()
			Call KSUser.InnerLocation("我的好友")
'		case "savef" call saveF()
		case "move" call moveF()
		case "shielddt" call ShieldDT()
		case "mail" call mail()
		case "mailsave" call mailsave()
		case "black" call DoBlack()
		case else
			call info()
		end select
		  	%>
		</TD>    
		 </TR>
</TABLE>
		</div> <%
	  End Sub
	   
		'添加好友
		Sub AddFriend()
		  dim flag,username,realname,phone,mobile,qq,msn,email,note
		  dim id:id=KS.chkclng(KS.S("id"))
		 if KS.S("action")="edit" then
		   dim rs:set rs=server.createobject("adodb.recordset")
		   rs.open "select * from ks_friend where id=" & id,conn,1,1
		   if rs.eof and rs.bof then
		    rs.close:set rs=nothing
		    call KS.alerthistory("参数传递出错!",-1):exit sub
		   else
		     username=rs("friend")
			 flag=rs("flag")
			 realname=rs("realname")
			 phone=rs("phone")
			 mobile=rs("mobile")
			 qq=rs("qq")
			 msn=rs("msn")
			 email=rs("email")
			 note=rs("note")
		   end if
		   rs.close:set rs=nothing
		 else
		  flag=KS.S("flag")
		 end if%>
		<script>
		 function checkform()
		 {
		   if (document.myform.username.value=='')
		   {
		     alert('请输入好友的用户名!');
			 document.myform.username.focus();
			 return false;
		   }
		   
		  var message=escape($("#message").val());
		 var username=escape($("#username").val());
		 if (username==''){
		  alert('参数传递出错!');
		 }
		 if (message==''){
		   alert('请输入附言!');
		   $("#message").focus();
		   return false;
		 }
		 $.get("../plus/ajaxs.asp",{action:"AddFriend",username:username,message:message},function(r){
		   r=unescape(r);
		   if (r!='success'){
		    alert(r);
		   }else{
		     if (confirm('您的请求已发送,请等待对方的确认,确定添加吗？')){
			 $("#username").val('');
			 $("#message").val('');
			 }else{
			  location.href='user_friend.asp';
			 }
		   }
		 });
		   return true;
		 }
		 
		 
		</script>
		<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1"  class="border">
		<form action="?action=addsave" method="post" name="myform">
			<tr height="23" class="title">
				<td width="25%" height="25" align="center">添加好友<span style='font-weight:normal'>(通过对方验证才能成为好友)</span></td>
			</tr>
			<tr> 
			  <td>
			    <table border="0" cellpadding="0" cellspacing="1" width="100%">
				 <tr class='tdbg'>
				  <td width="344"><b>用户名</b><br>
			       登录会员中心的用户名，必须填写。</td>
				  <td width="607"><input type="text" class="textbox" name="username" id="username" value="<%=username%>" size="20" maxlength="30" style="width:150"> <font color=red>*</font></td>
				 </tr>
				 <tr class='tdbg'>
				  <td><b>附 言</b><br>只有通过对方验证才能成为好友。</td>
				  <td><textarea class="textbox" name="message" id="message" style="width:350px;height:80px"></textarea></td>
				 </tr>
				
				 <tr class='tdbg'>
				  <td height="30" colspan=2 align="center">
				  <input type="hidden" name="id" value="<%=id%>">
				  <input type="button" onClick="checkform()" class="button" value=" OK,保存 ">&nbsp;<input type="button" class="button" value=" 取 消 " onClick="javascript:history.back()"></td>
				 </tr>
				 </table>
			  </td>
			</tr>
			</form>
		</table>
		<%
		End Sub
		
		'邮件邀请好友
		Sub Mail()
		if KS.Setting(143)<>"1" Then
		  Call KS.ShowError("对不起,本站没有开启邮件邀请功能!")
		  Exit Sub
		End If
		Call KSUser.InnerLocation("邮件邀请好友")
		 %>
		<script>
		 function checkform()
		 {
		   if (document.myform.realname.value=='')
		   {
		     alert('请输入您的姓名!');
			 document.myform.realname.focus();
			 return false;
		   }
		   if (document.myform.email.value=='')
		   {
		     alert('请输入您的好友邮箱!');
			 document.myform.email.focus();
			 return false;
		   }
		   return true;
		 }
		</script>
		<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1"  class="border">
		<form action="?action=mailsave" method="post" name="myform">
			<tr height="23" class="title">
				<td width="25%" height="25" align="center">通过邮件邀请好友</span></td>
			</tr>
			<tr> 
			  <td>
			    <table border="0" cellpadding="0" cellspacing="1" width="100%">
				 <tr class='tdbg'>
				  <td width="344"><b>您的姓名</b><br>
			       显示在对方邮箱的发件人中。</td>
				  <td width="607"><input type="text" class="textbox" name="realname" id="realname" value="<%=KSUser.GetUserInfo("RealName")%>" size="20" maxlength="30" style="width:150"> <font color=red>*</font></td>
				 </tr>
				 <tr class='tdbg'>
				  <td><b>好友的邮箱</b><br></td>
				  <td><textarea class="textbox" name="email" id="email" style="width:350px;height:80px"></textarea>
				  <br><font color=#999999>填写多个Email时：请用换行分割(一行一个,最多可一次性输入20个邮箱地址)。</font> 
				  </td>
				 </tr>
				
				 <tr class='tdbg'>
				  <td height="30" colspan=2 align="center">
				  <input type="submit" onClick="checkform()" class="button" value=" OK,发送 ">&nbsp;<input type="button" class="button" value=" 取 消 " onClick="javascript:history.back()"></td>
				 </tr>
				 </table>
			  </td>
			</tr>
			</form>
		</table>
		<br/>
		<%if KS.Setting(144)>0 then%>
		<div align="center"><font color=green>奖励说明：成功推荐一个好友注册,您还可以增加 <font color=red><%=KS.Setting(144)%></font> 个积分。赶快行动吧！</font></div>
		<%
		end if
		End Sub
		
		Sub mailsave()
		 dim realname:realname=ks.s("realname")
		 dim email:email=replace(request("email"),"'","")
		 if realname="" then call ks.alerthistory("请输入您的姓名!",-1)
		 if email="" then call ks.alerthistory("请输入好友邮箱!",-1)
		 email=split(email,vbcrlf)
		 If ubound(email)>20 Then call KS.AlertHistory("一次最多只能发送给20个好友!",-1)
		 dim i,content,ReturnInfo,N
		 for i=0 to ubound(email)
		   dim user_face:user_face=KSUser.GetUserInfo("UserFace")
		   If Left(User_Face,1)<>"/" And lcase(left(user_face,4))<>"http" then user_face=KS.GetDomain & user_face
			content="<style type=""text/css"">A:visited {	TEXT-DECORATION: none	}"
			content=content &"A:active  {	TEXT-DECORATION: none	}"
			content=content &"A:hover   {	TEXT-DECORATION: underline overline	}"
			content=content &"A:link 	  {	text-decoration: none;}"
			content=content &"A:visited {	text-decoration: none;}"
			content=content &"A:active  {	TEXT-DECORATION: none;}"
			content=content &"A:hover   {	TEXT-DECORATION: underline overline}"
			content=content &"body   {	FONT-FAMILY: 宋体; FONT-SIZE: 9pt;}"
			content=content &"td  {	FONT-FAMILY: 宋体; FONT-SIZE: 9pt	}</style>"

		   content=content & "<table border=""0"" width=""100%"">"
		   content=content & "<tr><td width=""150"" align=""center""><a style=""border:1px solid #ccc;padding:1px"" href=""" & KS.GetDomain & "space?" & KSUser.UserName & """ target=""_blank""><img width=""82"" height=""82"" src=""" & user_face & """ border=""0"" /></a><br/>" & KSUser.GetUserInfo("RealName") & "</td>"
		   content=content & "<td><p>Hi,最近又在做些什么活动,我发现一个叫做" & KS.Setting(1) & "的网站,这里有很多好玩的东西,在这里我发现了好多相识的老朋友和刚认识的新朋友,我们都有共同的兴趣爱好,你也一起加入吧!</p><p>点击这个链接，把我加为好友吧！<br /><a href=""" & KS.GetDomain & "?do=reg&uid=" & server.urlencode(KSUser.UserName) & "&f=r&u=" & server.urlencode(email(i)) &""" target=""_blank"">" & KS.GetDomain & "?do=reg&uid=" & server.urlencode(KSUser.UserName) & "&f=r&u=" & server.urlencode(email(i)) &"</a></p>"
		   content=content & "注明：本邮件是您的好友<a href=""" & KS.GetDomain & "space?" & KSUser.UserName & """ target=""_blank"">" & KSUser.GetUserInfo("RealName") & "</a>通过" & KS.Setting(1) & "发送，无需回复。"
		   content=content &"</td></tr></table>"
		   
		   ReturnInfo=KS.SendMail(KS.Setting(12), KS.Setting(13), KS.Setting(14), realname & "邀请您加入" & KS.Setting(0), Email(i),realname, content,KS.Setting(11))
		   IF ReturnInfo="OK" Then
			 N=N+1
		    End If
		 next
		 response.write "<script>alert('成功发送了 " & N & " 位好友的邀请!');location.href='" & Request.ServerVariables("http_referer") & "';</script>"
		End Sub
		
		
		sub info()
		 
		%>
		<style type="text/css">
		 .friendlist{font-size:12px}
		 .friendlist .t a{font-size:14px;color:#ff6600;height:30px;line-height:30px}
		 .friendlist li{float:left;width:350px;margin:5px;height:100px;background:#FAFAFA}
		 .friendlist li div{height:22px;line-height:22px}
		 .friendlist .l{height:100px;width:70px;float:left;text-align:center;padding-top:10px;padding-left:4px}
		 .friendlist .l a{border:1px solid #ccc;padding:1px;display:block}
		 .rriendlist .r{float:left}
		 .friendlist .r .zl span{color:#999999}
		</style>
        
   <%  If KS.S("listtype")="3" then %>
   <br>
     <table border="0" width="98%" align=center cellpadding=0 cellspacing=0 style="border:1px solid #CCC; background-color:#F7F7F7">
			<form action="?action=black" method="post" name="myform">
              <tr class="title"> 
                <td height="25" colspan="2" align="left">&nbsp; 把不信任的用户拉入黑名单：
                </td>
                </tr>
                <tr height="30"> 
                <td>
				    <table class="border" width="100%" border="0" cellspacing="0" cellpadding="6">
                    <tr>
                      <td align="right">用户名：</td>
                      <td><input name="username" type="text" class="textbox" id="username" maxlength="30" value="" /></td>
                    </tr>
                    <tr>
                    <td align="right">拉入天数：</td>
                    <td><label><input name='blackDays' type='radio' value='7' id='blackDays' checked='checked' />7天</label>&nbsp;&nbsp;<label><input name='blackDays' type='radio' value='15' id='blackDays' />15天</label>&nbsp;&nbsp;<label><input name='blackDays' type='radio' value='30' id='blackDays' />30天</label>&nbsp;&nbsp;<label><input name='blackDays' type='radio' value='365' id='blackDays' />永久</label>&nbsp;&nbsp;</td>
                    </tr>

                    <tr>
                      <td align="right">&nbsp;</td>
                      <td><input name="BlackSave" type="submit" class="button" id="BlackSave" value="拉入黑名单" /></td>
                    </tr>
                    <tr>
                      <td colspan="2" align="left">&nbsp; &nbsp; &nbsp; <strong>提示：</strong>如果您不想收到某个用户的消息或不想某个用户接手您发布的任务，您可以将他（她）移到黑名单。<br />
                      &nbsp; &nbsp; &nbsp; <strong>说明：</strong>普通会员只可以拉<span class="orange"><%=BlackList_CommonNum%></span>个用户进黑名单，VIP可拉<span class="orange"><%=BlackList_VIPNum%></span>个，超额每个用户收取<span class="orange"><%=formatnumber(BlackList_ExcessPoint,1,-1)%></span>个发布点。<br />
                        &nbsp; &nbsp; &nbsp; <strong>统计：</strong>您主动拉入黑名单人数为： <span class="orange"><%=KS.ChkClng(Conn.Execute("Select Count(ID) From KS_Friend Where UserName='" & KSUser.UserName & "' And Flag=3")(0))%></span> 人； 您被拉入黑名单人数为： <span class="orange"><%=KS.ChkClng(Conn.Execute("Select Count(ID) From KS_Friend Where Friend='" & KSUser.UserName & "' And Flag=3")(0))%></span> 人（注：被拉入黑名单达到<span class="orange"><%=BlackList_LockMaxNum %></span>人自动禁止接手任务）<br />
                      </td>
                    </tr>
                  </table>
            </td>
          </tr>
		  </form>
</table>
<br>
<% End IF %>

		<form action="User_Friend.asp?listtype=<%=KS.S("listtype")%>&action=move" method=post name=inbox>
		<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" class="border">
					<tr class=titlename align=middle>
                      <td width=30>选择</td>
					  <td width=64 height="25">头像</td>
					  <td width=80>用户账号</td>
					  <td width=60>用户姓名</td>
					  <td width=60>性别</td>
					  <td width=120>来自地区</td>
					  <% if KS.chkclng(KS.S("listtype"))<>3 then %>
                      <td width=70>关系</td>
                      <%else%>
                      <td width=80>拉黑天数</td>
                      <%end if%>
					  <td width=50>状态</td>
					  <td>操作</td>
					</tr>
		<%  dim param,i
		    if KS.chkclng(KS.S("listtype"))<>0 then
				param=param & " and flag=" & KS.chkclng(KS.S("listtype"))
			else
				param=param & " and flag=1"
			end if
			set rs=server.createobject("adodb.recordset")
			MaxPerPage=15
			if action="online" then
			sql="select userid as id,userid,RealName,Username,userface,sex,birthday,province,city,isonline from KS_user where isonline=1 order by userid desc"
			else
			sql="select f.id,u.userid,U.RealName,U.Username,u.userface,u.sex,u.birthday,u.province,u.city,u.isonline,f.flag,f.ShieldDT,f.BlackDays,f.Addtime from KS_Friend F inner join KS_User U on F.Friend=U.UserName where F.accepted=1 and F.Username='"&KSUser.UserName&"' " & param & " order by F.addtime desc"
			end if
			rs.open sql,Conn,1,1
			if rs.eof and rs.bof then
		         select case KS.S("listtype")
						    case "2"
							 response.write "你没有添加陌生人。"
							case "3"
							 response.write "你黑名单还没有用户。"
							case else
							 response.write "你还没有添加好朋友。"
						   end select
				else
		         totalPut = RS.RecordCount
				 If CurrentPage < 1 Then	CurrentPage = 1
			    If CurrentPage > 1  and (CurrentPage - 1) * MaxPerPage < totalPut Then
							RS.Move (CurrentPage - 1) * MaxPerPage
				Else
							CurrentPage = 1
				End If
		     i=0					       
			do while not rs.eof
			%>
      <tr class=tdbg onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
      <td  class="splittd" align=middle><input type='checkbox' name='id' value='<%=rs("id") %>"'></td>
      <td  class="splittd" align=middle height="54"><%
								dim user_face:user_face=rs("userface")
								If user_face="" or isnull(user_face) then 
								if rs("sex")="男" then  user_face="images/face/0.gif" else user_face="images/face/girl.gif"
							    End If
								If Left(User_Face,1)<>"/" And lcase(left(user_face,4))<>"http" then user_face=KS.Setting(2) & "/" & user_face
								response.write "<a href='" & KS.GetSpaceUrl(rs("userid")) & "' target='_blank'><img src='" & user_face & "' width='50' height='50'/></a>"
	%></td>
	  <td  class="splittd" align=middle><a href="/task/userinfo.asp?username=<%=rs("username")%>" target="_blank"><%=rs("username")%></a></td>
      <td  class="splittd" align=middle><%=rs("realname")%></td>
      <td  class="splittd" align=center><%=rs("sex")%>&nbsp;</td>
      <td  class="splittd" align=center><%=rs("province")%><%=rs("city")%></td>
      <% if KS.chkclng(KS.S("listtype"))<>3 then %>
      <td  class="splittd" align=center><%if rs("flag")="1" then
								  response.write "好朋友 "
								  elseif rs("flag")="2" then
								  response.write "陌生人 "
								  else
								  response.write "黑名单 "
								  end if%>
	  </td>
      <% else %>
      <td  class="splittd" align=center><% IF DateDiff("d",rs("Addtime"),Now)>rs("BlackDays") then KS.echo rs("BlackDays") Else KS.Echo DateDiff("d",rs("Addtime"),Now) %>/<%=rs("BlackDays")%></td>
      <% end if %>
      <td  class="splittd" align=center><% if rs("isonline")="1" then response.write "<font color=red>在线</font>" else response.write "离线" %></td>
      <td  class="splittd" align=middle><%if rs("flag")<>"3" then%><a href="javascript:void(0)" onClick="sendMsg(event,'<%=rs("username")%>')">发送消息</a> <% end if:  If action="online" then%>
								 <img src="../images/user/log/106.gif" border="0"><a href="javascript:void(0)" onClick="addF(event,'<%=rs("username")%>')">加为好友</a>
								 <%else%>
								 <a href="?action=del&id=<%=rs(0)%>" onClick="return(confirm('确定要删除这位好友吗？'))">删除好友</a>
								 <% if rs("flag")<>"3" then
								 if rs("ShieldDT")="0"  then
								  response.write "<a href='?action=ShieldDT&v=1&id=" & rs("id") & "'>屏蔽动态</a>"
								  else
								  response.write "<a href='?action=ShieldDT&v=0&id=" & rs("id") & "'>显示动态</a>"
								  end if
								 end if
								 end if%></td>
    </tr>
			<%
				rs.movenext
			  i=i+1 : if i>=maxperpage then exit do
		  loop
		end if
		rs.close
		set rs=Nothing
		%>
	</table>		

	 
	 <%if action="" then%>
	 <div class="clear"></div>	
		  &nbsp; <label><input id="chkAll" onClick="CheckAll(this.form)" type="checkbox" value="checkbox"  name="chkAll">&nbsp;选中所有</label> 将选中的好友移动到
		  <select name="grouptype" id="grouptype" onchange="if(this.options[this.selectedIndex].value==3){$('#days').toggle();}">
		   <option value="1">好朋友</option>
		   <%if action="" And KS.S("listtype")<>"3" then%>
           <option value="3">黑名单</option>
           <% end if %>
		  </select>&nbsp;
          <span id="days" style="display:none;">拉入天数：
          <label><input name='blackDays' type='radio' value='7' id='blackDays' checked='checked' />7天</label>&nbsp;&nbsp;<label><input name='blackDays' type='radio' value='15' id='blackDays' />15天</label>&nbsp;&nbsp;<label><input name='blackDays' type='radio' value='30' id='blackDays' />30天</label>&nbsp;&nbsp;<label><input name='blackDays' type='radio' value='365' id='blackDays' />永久</label></span>
		   <button id="b1" type="submit" class="button"><strong>确定操作</strong></button>
	
		
	 <br/>
	 <%end if%>
		  </form>
	 <div style="text-align:right;margin-right:50px">
	 <%Call KS.ShowPage(totalput, MaxPerPage, "", CurrentPage,true,true)%>
	 </div>
	 
	 <br/>
	 <%if action="" And KS.S("listtype")<>"3" then%>
	 	 <br/> <br/> <strong>提示：</strong>
	 如果您不想收到某个用户的消息或不想某个用户接手您发布的任务，您可以将他（她）移到黑名单

	 <%end if%>
	 <br/><br/>
	 <br/><br/>
	 <br/><br/>
	 <br/><br/>
	 <br/><br/>
		<%
		end sub
		
		sub DoBlack()		' 加入黑名单
		dim rs,sql
		dim blackDays,T_Count,username
		blackDays = KS.ChkClng(KS.S("blackDays"))
		username = KS.R(KS.S("username"))
		if ks.IsNul(username) then KS.AlertHistory "用户名不能为空!","-1"
		if KSUser.UserName=Trim(username) then KS.AlertHistory "不能拉自己入黑名单!","-1"
		IF KS.ChkClng(KSUser.GetUserInfo("KS_IDAuthentication")) <> 1 And SMS_IDAuthentication_Enabled = 1 Then KS.Alert "尚未通过手机认证的用户，不能拉入黑名单!","User_IDAuthentication.asp"
		
		set rs=server.createobject("adodb.recordset")
		sql="select top 1 UserName from KS_User where UserName='"& username &"'"
		set rs=Conn.Execute(sql)
		if rs.eof and rs.bof then
		    Call KSUser.InnerLocation("错误提示")
			KS.AlertHistory "系统没有（"& UserName &"）这个用户!","-1"
			exit sub
		end if
		rs.close
		set rs=Nothing
		
		IF Not Conn.Execute("Select ID From KS_Friend Where UserName='" & KSUser.UserName & "' And Friend='" & username & "' And Flag=3").Eof Then KS.AlertHistory "该用户已经在你的黑名单里面了","-1"
		
		IF KS.ChkClng(KSUser.GroupID) <> AdminGroupID Then
				T_Count = KS.ChkClng(Conn.Execute("Select Count(ID) From KS_Friend Where UserName='" & KSUser.UserName & "' And Flag=3")(0))
			IF KS.ChkClng(KSUser.GroupID) = UserGroupVipID Then
				IF T_Count + 1 > BlackList_VIPNum Then
				'VIp会员超额扣费
					Call KS.PointInOrOut(0,0,KSUser.UserName,2,BlackList_ExcessPoint,"系统","黑名单超额",1)
				End iF
			ElseIF KS.ChkClng(KSUser.GroupID) <> UserGroupVipID Then
				IF T_Count + 1 > BlackList_CommonNum Then
				'普通会员超额扣费
					Call KS.PointInOrOut(0,0,KSUser.UserName,2,BlackList_ExcessPoint,"系统","黑名单超额",1)
				End iF					
			End if
		End if
		
		Conn.Execute("insert into KS_Friend (username,friend,addtime,flag,accepted,blackDays) values ('"& KSUser.UserName &"','"& Trim(username) &"',"& SqlNowString &",3,1," & blackDays & ")")

		Call KSUser.InnerLocation("操作成功")
		Call KS.Alert("拉入黑名单成功！",Request.ServerVariables("http_referer"))
		
		end sub
		
		sub moveF()
		 DIm Point,T_Count,IDNum,blackDays
		 Dim ID:ID=KS.S("id")
		 Dim flag:flag=KS.ChkClng(KS.S("grouptype"))
		 If ID="" Then KS.AlertHintScript "请选择要移到的好友!"
		 ID=KS.FilterIDS(ID)
		 IF Instr(ID,",")>0 Then
		 	IDNum=Ubound(Split(ID,",")) + 1
		 Else
		 	IDNum = 1
		 End IF
		 blackDays = 0
		 If Flag=0 Then Flag=1
		 If flag=3 then
		 	IF KS.ChkClng(KSUser.GetUserInfo("KS_IDAuthentication")) <> 1 And SMS_IDAuthentication_Enabled = 1 Then KS.Alert "尚未通过手机认证的用户，不能拉入黑名单!","User_IDAuthentication.asp"
		 	blackDays = KS.ChkClng(KS.S("blackDays"))
			 IF KS.ChkClng(KSUser.GroupID) <> AdminGroupID Then
				T_Count = KS.ChkClng(Conn.Execute("Select Count(ID) From KS_Friend Where UserName='" & KSUser.UserName & "' And Flag=3")(0))
				IF KS.ChkClng(KSUser.GroupID) = UserGroupVipID Then
					IF T_Count + IDNum > BlackList_VIPNum Then
					'VIp会员超额扣费
						Point = (T_Count + IDNum - BlackList_VIPNum) * BlackList_ExcessPoint
						Call KS.PointInOrOut(0,0,KSUser.UserName,2,Point,"系统","黑名单超额",1)
					End iF
				ElseIF KS.ChkClng(KSUser.GroupID) <> UserGroupVipID Then
					IF T_Count + IDNum > BlackList_CommonNum Then
					'普通会员超额扣费
						Point = (T_Count + IDNum - BlackList_CommonNum) * BlackList_ExcessPoint
						Call KS.PointInOrOut(0,0,KSUser.UserName,2,Point,"系统","黑名单超额",1)
					End iF					
				End if
			 End if
		 end if
		 Conn.Execute("Update KS_Friend Set Flag=" & Flag & ",Addtime=" & SqlNowString & ",BlackDays="& blackDays &" where UserName='" & KSUser.UserName & "' And id in(" & ID & ")")
		 Response.Redirect Request.ServerVariables("http_referer")
		end sub
		
		sub ShieldDT()
		 Conn.Execute("Update KS_Friend Set ShieldDT=" & KS.ChkClng(request("v")) & " where id=" & KS.ChkClng(Request("ID")))
		 Response.Redirect Request.ServerVariables("http_referer")
		end sub
		
		sub delFriend()
		dim delid
		delid=replace(request("id"),"'","")
		DelID=KS.FilterIDs(DelID)
		if delid="" or isnull(delid) then
		    Call KSUser.InnerLocation("错误提示")
			Call KS.AlertHistory("您没有选择要删除好友名单。",-1)
			exit sub
		else
		    dim rs:set rs=server.createobject("adodb.recordset")
			rs.open "select friend from KS_Friend where username='"&KSUser.UserName&"' and id in ("&delid&")",conn,1,3
			do while not rs.eof
			 Call KSUser.AddLog(KSUser.UserName,"与<a href=""{$GetSiteUrl}space/?" & rs(0) & """ target=""_blank"">" & rs(0) & "</a>解除好友关系!",106)
			 rs.delete
			 rs.movenext
			loop
			rs.close
			set rs=nothing
			Call KSUser.InnerLocation("成功提示")
			Call KS.Alert("您已经与选定的好友解除关系。","User_Friend.asp")
		end if
		end sub
		
		sub AllDelFriend()
			Conn.Execute("delete from KS_Friend where username='"&KSUser.UserName&"'")
			Call KSUser.InnerLocation("成功提示")
			Call KS.Alert("您已经删除了所有好友列表。","User_Friend.asp")
		end sub
				
'		sub saveF()
'		dim incept,i
'		if request("touser")="" then
'		    Call KSUser.InnerLocation("错误提示")
'			Call KS.AlertHistory("请填写对象。",-1)
'			exit sub
'		else
'			incept=KS.R(KS.S("touser"))
'			incept=split(incept,",")
'		end if
'		
'		for i=0 to ubound(incept)
'		set rs=server.createobject("adodb.recordset")
'		sql="select UserName from KS_User where UserName='"&incept(i)&"'"
'		set rs=Conn.Execute(sql)
'		if rs.eof and rs.bof then
'		    Call KSUser.InnerLocation("错误提示")
'			Call KS.ShowError("系统没有（"&incept(i)&"）这个用户，操作未成功。")
'			exit sub
'		end if
'		set rs=Nothing
'		
'		if KSUser.UserName=Trim(incept(i)) then
'		    Call KSUser.InnerLocation("错误提示")
'			Call KS.ShowError("不能把自已添加为好友。")
'		end if
'		
'		sql="select friend from KS_Friend where username='"&KSUser.UserName&"' and  friend='"&incept(i)&"'"
'		set rs=Conn.Execute(sql)
'		if rs.eof and rs.bof then
'			sql="insert into KS_Friend (username,friend,addtime,flag) values ('"&KSUser.UserName&"','"&Trim(incept(i))&"',"&SqlNowString&",1)"
'			set rs=Conn.Execute(sql)
'		end if
'		
'		if i>5 then
'			Call KS.ShowError("每次最多只能添加5位用户，您的名单5位以后的请重新填写。")
'			exit sub
'			exit for
'		end if
'		
'		next
'		Call KSUser.InnerLocation("成功信息")
'		Call KS.Alert("恭喜您，好友添加成功。","User_Friend.asp")
'		end sub
		
End Class
%> 
