<!-- #include file="include/admin_onlogin.asp" -->
<%
'****************************************************
' 阳光情缘 2006V3.0      Power by sdsun.com.cn
' Email: 27072320@qq.com  , sdsun163@163.com
' Web: http://www.sdsun.com.cn
' Copyright (C) 2006 sdsun.com.cn All Rights Reserved.
'****************************************************
admins=true
nsort="stopip"
index_url="stopip"
data_name="jk_stopip"
tit_fir="IP锁定"
tit="IP锁定管理"

dim s_ip,types,nname,ndim,nnum,tim_ips
tim_ips=int(dim_num(32))

types=trim(request.querystring("types"))
if not(isnumeric(types)) then types=-1
select case int(types)
case 0
  nname="解除的"
case 1
  nname="临时的"
case 2
  nname="永久的"
case else
  types=-1
  nname="所有的"
end select
pageurl=pageurl&"types="&types&"&"

call admin_header(0,0)
call msort_start(0)
%>
<tr><td align=center colspan=2 height=30>
  <table border=0>
  <tr>
  <td><a href='?'><%response.write tit%></a></td>
  <td width=10></td>
  <td><a href='?types=2'<%if types=2 then response.write " class=red"%>>永久的<%response.write tit_fir%></a></td>
  <td width=10></td>
  <td><a href='?types=1'<%if types=1 then response.write " class=red"%>>临时的<%response.write tit_fir%></a></td>
  <td width=10></td>
  <td><a href='?types=0'<%if types=0 then response.write " class=red"%>>解除的<%response.write tit_fir%></a></td>
  <td width=10></td>
  <td><a href='?action=add'<%if action="add" then response.write " class=red"%>>添加新<%response.write tit_fir%></a></td>
  </tr>
  </table>
</td></tr>
</table>
<%
call admin_table(1)

if action="handle" then 
   call joekoe_chk_handle()

   else if action="add" then
      call joekoe_ip_add()
        else 
         call joekoe_chk_main()
       end if
end if

call msort_end()
call admin_ender(1)

sub joekoe_chk_handle()
  dim sel_type,seltype,sel_id,hdim,hnum,hid,hi,htype,hintegral,newdata,olddata
  olddata=joekoe_cms.now_time
  newdata=DateAdd("s",tim_ips,olddata)
  htype=1
  sel_type=trim(request.form("sel_type"))
  select case sel_type
  case "删除"
    seltype="delete"
  case "解锁"
    seltype="ipjs"
  case "永久"
    seltype="yjsd"
  case "锁定"
    seltype="ipsd"
  case else
    sel_type=""
    seltype=""
  end select
  if joekoe_cms.post_chk()=false or seltype="" then
    exit sub
  end if
  hintegral=mp_integral()
  sel_id=trim(request.form("sel_id"))
  sel_id=replace(sel_id," ","")
  hdim=split(sel_id,",")
  hnum=ubound(hdim)
  select case seltype
  case "delete"
    for hi=0 to hnum
      hid=hdim(hi)
        call joekoe_cms.exec("delete from "&data_name&" where s_id="&hid,0)
    next
	case "ipjs"
    for hi=0 to hnum
      hid=hdim(hi)
      if isnumeric(hid) then	   
	   sql="update "&data_name&" set s_dl_num=0,s_style=0,s_yj_stop=0,s_tim_end='"&olddata&"' where s_id="&hid
       call joekoe_cms.exec(sql,0)
	   end if      
    next
	case "ipsd"
    for hi=0 to hnum
      hid=hdim(hi)
      if isnumeric(hid) then
        sql="update "&data_name&" set s_style=1,s_tim_star='"&olddata&"',s_tim_end='"&newdata&"' where s_id="&hid
       call joekoe_cms.exec(sql,0) 
	   end if
    next
	case "yjsd"
    for hi=0 to hnum
      hid=hdim(hi)
      if isnumeric(hid) then
        sql="update "&data_name&" set s_style=1,s_yj_stop=1,s_tim_star='"&olddata&"',s_tim_end='"&newdata&"' where s_id="&hid
       call joekoe_cms.exec(sql,0) 
	   end if
    next
  end select
  erase hdim
  action=""
  'call admin_event(sel_type&" "&(hnum+1)&"条（"&tit_fir&"）记录",0,0)
  call admin_msg("已成功（"&sel_type&"）操作了"&(hnum+1)&"条记录！","?types="&types,1)
end sub

sub joekoe_chk_main()
  dim ntypes,stopip_path,sd_tim_end,sd_tim_star
%>
<form name=sel_form action='?jk_mod=<%response.write jk_mod%>&types=<%response.write types%>&action=handle' method=post>
<tr align=center>
<td class=td width='6%'>序号</td>
<td class=td width='39%'>IP 地 址</td>
<td class=td width='7%'>次数</td>
<td class=td width='16%'>登 陆 者</td>
<td class=td width='10%'>锁定类型</td>
<td class=td width='17%'>锁定时间</td>
<td class=td width='5%'><input type=checkbox name=sel_all value='yes' onclick="javascript:select_all(this.form);"></td>
</tr>
<%
  if int(types)=0 then
    sql_add=" where s_style=0 and s_yj_stop=0"
	else 
	if int(types)=1 then
     sql_add=" where s_style=1 and s_yj_stop=0"
	 else
	 if int(types)=2 then
	   sql_add=" where s_style=1 and s_yj_stop=1"
	 else
	   sql_add=""
     end if
	end if
  end if	 
  sql="select count(s_id) from "&data_name&sql_add
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&nummer*viewpage&" * from "&data_name&sql_add&" order by s_id desc"
  call joekoe_cms.exec("",-1)
  rs.open sql,conn,1,1
  if int(viewpage)>1 then
    rs.move (viewpage-1)*nummer
  end if
  if int(viewpage*nummer)>int(rssum) then
    nums=nummer-(viewpage*nummer-rssum)
  end if
  for i=1 to nums
    s_ip=rs("s_ip")
    ntypes=rs("s_style")
    sd_tim_end=rs("s_tim_end")
    sd_tim_star=rs("s_tim_star")
%>
  <tr align=center>
  <td class=tims><%response.write (viewpage-1)*nummer+i%></td>
  <td><%response.write s_ip%></a></td>
  <td class=tims><%response.write rs("s_dl_num")%></td>
  <td><%response.write format_user_view(rs("s_username"),1,0)%></td>
  <td>
  <%
  if rs("s_yj_stop")<>0 then 
   response.write "永久锁定"
  else
   if rs("s_style")<>0 then
     response.Write "临时锁定"
	 else
	 response.write "锁定解除"
   end if
  end if   
  %>
  </td>
  <td><font class=tims alt='<%response.write joekoe_cms.time_type(sd_tim_star,2)%>'><%response.write sd_tim_star%></font></td>
  <td><input type=checkbox name=sel_id value='<%response.write rs("s_id")%>'></td>
  </tr>
<%
    rs.movenext
  next
  rs.close
%>
<tr class=tr1>
<td colspan=5>
现有<font class=red><%response.write rssum%></font>个<%if int(types)=0 then response.write "解除的"%><%if int(types)=1 then response.write "临时的"%><%if int(types)=2 then response.write "永久的"%><%if int(types)=-1 then response.write "记录的"%><%response.write tit_fir%>，
页次：<font class=red><%response.write viewpage%></font>/<font class=red><%response.write thepages%></font>
分页：<%response.write jk_pagecute(nummer,thepages,viewpage,pageurl,5,"#ff0000")%>
</td>
<td colspan=2 align=center>
<select name=sel_type size=1>
<option value='删除'>删除</option>
<option value='解锁'>解锁</option>
<option value='锁定'>锁定</option>
<option value='永久'>永久</option>
</select>
<input type=submit value='操作' onclick="return sel_click(this.form);">
</td>
</tr>
</form>
<%
end sub

sub joekoe_ip_add()
  dim vname,newdata,olddata,sdms
  call admin_td("添加"&tit_fir)
  olddata=joekoe_cms.now_time
  if chk() then
    vname=trim(request.form("s_ip"))
	sdms=request.form("sdms")
	newdata=request.form("newdata")
    if vname="" then
      call admin_error(tit_fir&"地址 不能为空！")
      exit sub
    end if
    sql="select top 1 s_ip from "&data_name&" where s_ip='"&vname&"'"
    set rs=joekoe_cms.exec(sql,1)
   if not rs.eof then
      rs.close
      call admin_error(tit_fir&"IP或端口号 已存在！该IP地址已经锁定")
      exit sub
    end if
    rs.close
	if sdms=2 then
      call joekoe_cms.exec("insert into "&data_name&"(s_ip,s_username,s_tim_star,s_tim_end,s_dl_num,s_style,s_yj_stop) values('"&vname&"','后台增加','"&olddata&"','"&olddata&"',0,1,1)",0)
	else 
	 if newdata="" then
	   call admin_error(tit_fir&"选择“临时锁定”，解锁时间必须输入")
	   exit sub
	 else
	   call joekoe_cms.exec("insert into "&data_name&"(s_ip,s_username,s_tim_star,s_tim_end,s_dl_num,s_style,s_yj_stop) values('"&vname&"','后台增加','"&olddata&"','"&newdata&"',0,1,0)",0)
	end if
	end if
    call admin_msg("成功添加一项新的"&tit_fir,"?",1)
    exit sub
  end if
 call form_first()  
%>
<form name=write_frm action='?action=add' method=post>
<input type=hidden name=chk value='yes'>
<tr>
<td align="center"><%response.write tit_fir%>：</td>
<td><input type=text name=s_ip value='' size=30 maxlength=15><%response.write redx%>不可重复（ＩＰ和端口号可以任填其一或都填）</td>
</tr>
<tr>
<td align="center">锁定模式：</td>
<td><input type=radio name=sdms  value='1' onclick="cmp_displayg.style.display=''">&nbsp;临时锁定&nbsp;<input type=radio name=sdms value='2' checked onclick="cmp_displayg.style.display='none'">&nbsp;永久锁定
</tr>
<tr id=cmp_displayg style="display:none">
<td align="center">解锁时间：</td>
<td><input type=text name=newdata value='' size=20 maxlength=10 onFocus="this.blur()">&nbsp;<input type=button name=st_btn value="选择" onclick="javascript:select_time(newdata);return false;">
</td>
</tr>
<%
 call submit_add()
end sub

'****************************************************
' 阳光情缘 2006V3.0      Power by sdsun.com.cn
' Email: 27072320@qq.com  , sdsun163@163.com
' Web: http://www.sdsun.com.cn
' Copyright (C) 2006 sdsun.com.cn All Rights Reserved.
'****************************************************
%>
