<!-- #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.
'****************************************************
dim url,types,nname,ndim,nnum
index_url="upload"
'data_name="upload"
'tit_fir="上传文件"
'tit="上传管理"
call admin_master(0,0)
types=trim(request.querystring("types"))
if not(isnumeric(types)) then types=-1
select case int(types)
case 0
  nname="无效"
case 1
  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=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><%call admin_read("","上传文件管理说明","本上传系统中文件的<font class=red>“有效”</font>、<font class=red>“无效”</font>指的是该<u>上传文件所在的栏目是否显示正常，并不能完全决定该上传文件是否正常使用，而是由上传文件状态显示来决定的</u>，具体描述如下：<br>当上传文件状态为<font class=red>“○”</font>表示此文件在服务器空间中还存在，可以正常使用，无需及时删除；<br>当上传文件状态为<font class=red>“Ｘ”</font>表示此文件在服务器空间中已不存在，不能正常使用，可及时删除，以便节省数据库空间。")%></td>
  </tr>
  </table>
</td></tr>
<tr><td colspan=2 align=center>
  <table border=0 cellspacing=0 cellpadding=2>
  <form action='?' method=get>
  <tr>
  <td>搜索（<%response.write tit_fir%>） 关键字：</td>
  <td><input type=text name=keyword value='<%response.write trim(request.querystring("keyword"))%>' size=15 maxlength=20></td>
  <td><select name=sea_type size=1>
<option value='url'>按文件名</option>
<option value='username'>按发布人</option>
</select></td>
  <td><select name=sea_term sizs=1><option value='all'>满足所有条件</option><option value='only'>满足一个条件</option></seelct></td>
  <td><input type=submit value='搜索'></td>
  </tr>
  </form>
  </table>
</td></tr>
</table>
<%
call admin_table(1)

if action="handle" then call joekoe_chk_handle()
call joekoe_chk_main()

call msort_end()
call admin_ender(1)

sub joekoe_chk_handle()
  dim sel_type,seltype,sel_id,hdim,hnum,hid,hi,htype,hintegral,file_name
  htype=1
  sel_type=trim(request.form("sel_type"))
  select case sel_type
  case "删除"
    seltype="delete"
  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)
      file_name=""
      if isnumeric(hid) then
        sql="select top 1 url from "&data_name&" where id="&hid
        set rs=joekoe_cms.exec(sql,1)
        if not rs.eof then
          file_name=rs("url")
        end if
        rs.close
      end if
      if file_name<>"" then
        call joekoe_cms.exec("delete from "&data_name&" where id="&hid,0)
        call del_file(file_name,1)
      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,upload_path,nnsort,tim,genre
%>
<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='31%'>文件名</td>
<td class=td width='6%'>类型</td>
<td class=td width='9%'>大小(B)</td>
<td class=td width='12%'>栏目、ID</td>
<td class=td width='15%'>作者</td>
<td class=td width='11%'>时间</td>
<td class=td width='5%'>状态</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 types="&types
  end if
  call format_search("url","url,username",2,1)
  sql="select count(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 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
    url=rs("url")
    ntypes=rs("types")
    nnsort=rs("nsort")
    tim=rs("tim")
	genre=rs("genre")
%>
  <tr align=center>
  <td class=tims><%response.write (viewpage-1)*nummer+i%></td>
  <td align=left>
  <%if genre="gif" or genre="jpg" then%>
     <a href='<%response.write joekoe_cms.url_true("",url)%>' target=_blank title='<img src=<%response.write joekoe_cms.url_true("",url)%> border=0>' ><%response.write url%></a>
  <%else%>
    <a href='<%response.write joekoe_cms.url_true("",url)%>' target=_blank><%response.write url%></a>
  <%end if%>
  </td>
  <td><%response.write rs("genre")%></td>
  <td align=left class=tims><%response.write rs("sizes")%></td>
  <td><%
    if int(ntypes)<>0 then
      response.write "<font alt='ID："&rs("iid")&"'>"&upload_sort_name(nnsort)&"</font>"
    else
      response.write "<font class=red2>无效</font>"
    end if
%></td>
  <td><%response.write format_user_view(rs("username"),1,0)%></td>
  <td><font class=tims alt='<%response.write joekoe_cms.time_type(tim,2)%>'><%response.write joekoe_cms.time_type(tim,3)%></font></td>
  <td><%
    dim filename,fs
    filename= request.ServerVariables("APPL_PHYSICAL_PATH")&joekoe_cms.url_true("",url)
    set fs = CreateObject ("Scripting.FileSystemObject")
    if fs.FileExists (filename) then
    response.write "○"
    else
    response.write "Ｘ"
    end if
    set fs = nothing
   %></td>
  <td><input type=checkbox name=sel_id value='<%response.write rs("id")%>'></td>
  </tr>
<%
    rs.movenext
  next
  rs.close
%>
<tr class=tr1>
<td colspan=6>
现有<font class=red><%response.write rssum%></font>个<%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=3 align=center>
<select name=sel_type size=1>
<option value='删除'>删除</option>
</select>
<input type=submit value='操作' onclick="return sel_click(this.form);">
</td>
</tr>
</form>
<%
end sub

function upload_sort_name(mvar)
  dim si
  for si=0 to m_num
    if mvar=m_dim(0,si) or mvar=m_dim(1,si) then
      upload_sort_name=m_dim(4,si)
      if var_null(upload_sort_name)="" then upload_sort_name=m_dim(3,si)
      exit for
    end if
  next
  if mvar="uface" then upload_sort_name="用户头像"
  if upload_sort_name="" then upload_sort_name=mvar
end function
'****************************************************
' 阳光情缘 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.
'****************************************************
%>
