<!-- #include file="../../include/skin.asp" -->
<!-- #include file="../../include/jk_nsort.asp" -->
<!-- #include file="../../style/data_sort_down.asp" -->
<%

cid=0
sid=0
n_sort="down"
index_url="down"
tit_fir=format_menu(index_url)
m_channel=index_url
web_img_m="m_"&m_channel
web_img_h="h_"&m_channel

'================================================
'作    用：清除变量
'================================================
sub down_end()
  if isarray(sort_dim) then erase sort_dim
end sub

'================================================
'作    用：下载说明信息功能模块
'================================================
sub down_remark(t_title)
  dim tmp
  tmp=CMS_Skin.GetDB("down_remark")
  tmp=Replace(tmp,"{$web_url}",joekoe_cms.web_url)
  tmp=Replace(tmp,"{$web_name}",joekoe_cms.web_name)
  call down_center_table(t_title,tmp,3,0)
end sub

'================================================
'作    用：下载搜索功能模块
'================================================
sub down_search(t_title)
  dim tmp
  tmp=CMS_Skin.GetDB("down_more")
  tmp=Replace(tmp,"{$img}",img_skin("new"))
  tmp=Replace(tmp,"{$select}",select_type("软件",0,0))
  tmp=Replace(tmp,"{$stit}","软件")
  call down_center_table(t_title,tmp,2,0)
end sub

'================================================
'作    用：下载分类显示信息功能模块
'================================================
sub down_sort(t_url,t1,t2,t_title)
  call down_center_table(t_title,sort_type(t_url,t1,t2),1,0)
end sub

'================================================
'作    用：常用下载工具显示信息功能模块
'================================================
sub down_tool(t_title)
  dim tmp
  tmp=CMS_Skin.GetDB("down_tool")
  call down_left_table(t_title,tmp,3,0)
end sub

'================================================
'作    用：下载左边部分功能模块
'参    数：
'  nt        ：判断软件的类型，如热门软件、推荐软件等
'  n_num     ：每个模块显示软件标题数
'  c_num     ：软件标题字数
'  n_title   ：模块名称
'================================================
sub down_left(nt,n_num,c_num,n_title)
  dim n_username,n_topic,n_tim,bar_num,tmp
  bar_num=1
  sql="select top "&n_num&" id,username,name,tim,counter from down where hidden=1"
  select case nt
  case "hot"
    sql=sql&" order by counter desc,id desc"
    bar_num=3
  case "good"
    sql=sql&" and types=5 order by id desc"
    bar_num=2
  case else
    sql=sql&" order by id desc"
  end select
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    n_username=rs("username")
    n_topic=rs("name")
    n_tim=rs("tim")
    n_tim=joekoe_cms.time_type(n_tim,1)
    tmp=tmp&down_topic_type(c_num,rs("id"),n_username,n_topic,n_tim,rs("counter"),false,0)
    rs.movenext
  loop
  rs.close
  call down_left_table(n_title,tmp,bar_num,1)
end sub

sub down_left2(nt,c_id,s_id,n_num,c_num,n_title)
  dim n_username,n_topic,n_tim,bar_num,tmp
  bar_num=1
  sql="select top "&n_num&" id,username,name,tim,counter from down where hidden=1"
   if s_id<1 then
  sql=sql&" and c_id="&c_id
  else
  sql=sql&" and c_id="&c_id&" and s_id="&s_id
  end if
  select case nt
  case "hot"
    sql=sql&" order by counter desc,id desc"
    bar_num=3
  case "good"
    sql=sql&" and types=5 order by id desc"
    bar_num=2
  case else
    sql=sql&" order by id desc"
  end select
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    n_username=rs("username")
    n_topic=rs("name")
    n_tim=rs("tim")
    n_tim=joekoe_cms.time_type(n_tim,1)
    tmp=tmp&down_topic_type(c_num,rs("id"),n_username,n_topic,n_tim,rs("counter"),false,0)
    rs.movenext
  loop
  rs.close
  call down_left_table(n_title,tmp,bar_num,1)
end sub

'================================================
'作    用：下载各模块上部分显示模式功能模块
'参    数：
'  n_title   ：模块名称
'  body      ：模块内容
'  ttype     ：下载部分图片风格显示标记
'  tt        ：判断模块内容显示方式
'================================================
sub down_left_table(n_title,body,ttype,tt)
  dim temp1
  if tt=1 then body="<table border=0 width='98%'>"&body&"</table>"
  temp1=CMS_Skin.GetDB("down_left")
  temp1=Replace(temp1,"{$web_skin}",joekoe_cms.web_dir_skin)
  temp1=Replace(temp1,"{$type}",ttype)
  temp1=Replace(temp1,"{$img}",img_skin(web_img_m))
  temp1=Replace(temp1,"{$tit}",n_title)
  temp1=Replace(temp1,"{$body}",body)
  temp1=Replace(temp1,"{$ukong}",CMS_Skin.skukong)
  Response.Write(temp1)
end sub

sub down_center_table(n_title,body,ttype,tt)
  dim temp1
  if tt=1 then body="<table border=0 width='98%'>"&body&"</table>"
  temp1=CMS_Skin.GetDB("down_center")
  temp1=Replace(temp1,"{$web_skin}",joekoe_cms.web_dir_skin)
  temp1=Replace(temp1,"{$type}",ttype)
  temp1=Replace(temp1,"{$img}",img_skin(web_img_m))
  temp1=Replace(temp1,"{$tit}",n_title)
  temp1=Replace(temp1,"{$body}",body)
  temp1=Replace(temp1,"{$ukong}",CMS_Skin.skukong)
  Response.Write(temp1)
end sub

sub down_left_sort(nsn,ntt)
  dim tmp1,surl,body
  surl="list.asp?action=more&"
  tmp1=vbcrlf&nsort_left_type(surl,ntt)
  call down_left_table(nsn,tmp1,0,2) 
end sub
'================================================
'作    用：下载各模块下部分显示模式功能模块
'参    数：
'  mvar   ：模块下部分显示类似“更多”这样标记的具体内容
'  tt     ：判断模块内容显示方式
'================================================
function down_bar_end(mvar,tt)
  dim temp1
  if tt=1 then temp1=temp1&vbcrlf&"  </table>"
  temp1=temp1&vbcrlf&"</td></tr>"
  if mvar<>"" and var_null(mvar)<>"" then temp1=temp1&vbcrlf&"<tr><td align=right>"&mvar&"&nbsp;&nbsp;</td></tr>"
  temp1=temp1&vbcrlf&"</table>"
  down_bar_end=temp1&ukong
end function

'================================================
'作    用：下载标题显示功能模块
'================================================
function down_topic_main(b_cid,b_cname,b_c_num,b_id,b_username,b_topic,b_tim,b_counter,b_tim_type)
  dim b_url,tim_type
  b_url="view.asp?id="&b_id
  if b_tim_type>0 then
    if b_tim_type=2 then tim_type=tim_type&"</td><td align=right>"
    tim_type=tim_type&"&nbsp;<font class=tims>"&mid(b_tim,6,5)&"</font>"
  end if
  down_topic_main="<tr><td class=gray>[<a href='list.asp?c_id="&b_cid&"'>"&b_cname&"</a>] <a href='"&b_url&"' alt='软件标题："&joekoe_cms.code_html(b_topic,1,0)&"<br>发 布 人："&b_username&"<br>整理时间："&b_tim&"'>"&joekoe_cms.code_html(b_topic,1,b_c_num)&"</a></td><td class=tims align=right><font class=blue>"&b_counter&"</font>"&tim_type&"</td></tr>"
end function

function down_topic_type(b_c_num,b_id,b_username,b_topic,b_tim,b_counter,b_ispic,b_tim_type)
  dim n_url,n_jt
  n_url="view.asp?id="&b_id
  n_jt=img_skin(web_img_h)
  down_topic_type=format_topic_type(n_jt,b_username,b_topic,b_c_num,n_url,b_tim,b_counter,b_ispic,"软件标题","下载人次",b_tim_type)
end function

function down_label_list()
  dim temp1
  temp1=temp1&vbcrlf&"<table border=0 cellspacing=0 cellpadding=4>" & _
              vbcrlf&"<tr><td><a href='list.asp?action=good'"
  if action="good" then temp1=temp1&" class=red_3"
  temp1=temp1&">推荐下载</a></td></tr>" & _
       vbcrlf&"<tr><td><a href='list.asp?action=hot'"
  if action="hot" then temp1=temp1&" class=red_3"
  temp1=temp1&">热门下载</a></td></tr>" & _
       vbcrlf&"</table>"
  down_label_list=temp1
end function

function down_list_top(nurl)
  dim temp1
  temp1=temp1&vbcrlf&"<tr>" & _
              vbcrlf&"<td width='54%'></td>" & _
              vbcrlf&"<td width='11%'><a href='"&nurl&"taxis=tim'><img src='../images/down/down_tim.gif' title='按整理时间排序' border=0></a></td>" & _
              vbcrlf&"<td width='11%'><img src='../images/down/down_size.gif' border=0></td>" & _
              vbcrlf&"<td width='11%'><a href='"&nurl&"taxis=counter'><img src='../images/down/down_counter.gif' title='按下载次数排序' border=0></a></td>" & _
              vbcrlf&"<td width='13%'><a href='"&nurl&"taxis=types'><img src='../images/down/down_types.gif' title='按推荐等级排序' border=0></a></td>" & _
              vbcrlf&"</tr>"
  down_list_top=temp1
end function

function down_list_body(n_ii,n_id,n_name,n_tim,n_counter,n_sizes,n_types,n_remark)
  dim temp1
  temp1=temp1&vbcrlf&"<tr>" & _
              vbcrlf&"<td height=20>"&n_ii&"、<b><a href='view.asp?id="&n_id&"' title='"&joekoe_cms.code_html(n_name,1,0)&"'  >"&joekoe_cms.code_html(n_name,1,20)&"</a></b></td>" & _
              vbcrlf&"<td class=tims align=center>"&mid(n_tim,6,5)&"</td>" & _
              vbcrlf&"<td class=tims align=right>"&n_sizes&"</td>" & _
              vbcrlf&"<td align=center class=red>"&n_counter&"</td>" & _
              vbcrlf&"<td><img src='../images/down/star"&n_types&".gif' border=0></td>" & _
              vbcrlf&"</tr>" & _
              vbcrlf&"<tr><td colspan=5>软件介绍："&n_remark&"</td></tr>" & _
              vbcrlf&"<tr><td colspan=5><table border=0 cellpadding=0 cellspacing=0 width='98%'><tr><td background='"&joekoe_cms.web_dir_skin&"bg_dian.gif'></td></tr></table></td></tr>"
  down_list_body=temp1
end function

function down_list_pagecute(p_nummer,p_rssum,p_viewpage,p_thepages,p_pageurl)
  dim temp1
  temp1=temp1&vbcrlf&"<tr><td colspan=5 align=center>" & _
              vbcrlf&"<table border=0 width='98%' cellspacing=0 cellpadding=2>" & _
              vbcrlf&"<tr>" & _
              vbcrlf&"<td height=25>" & _
              vbcrlf&"&nbsp;本栏共有 <font class=red>"&p_rssum&"</font> 个软件" & _
              vbcrlf&"页次：<font class=red>"&p_viewpage&"</font>/<font class=red>"&p_thepages&"</font>&nbsp;" & _
              vbcrlf&"&nbsp;分页："&jk_pagecute(p_nummer,p_thepages,p_viewpage,p_pageurl,5,"#ff0000") & _
              vbcrlf&"</td>" & _
              vbcrlf&"</table>" & _
              vbcrlf&"</td></tr>"
  down_list_pagecute=temp1
end function

sub down_main_top(n_num,c_num,n_title)
  dim n_username,n_topic,n_tim,n_cname,num_num,num_down,num_today,tmp
  dim down_head,ta
  ta="#"
  sql="select count(id) from down where hidden=1 and tim>="&ta&formatdatetime(formatdatetime(joekoe_cms.now_time,2))&ta
  set rs=joekoe_cms.exec(sql,1)
  num_today=rs(0)
  rs.close
  if not int_true(num_today) then num_today=0
  sql="select top 1 num_down from configs"
  'sql="select count(id) from down where hidden=1"
  set rs=joekoe_cms.exec(sql,1)
  num_num=rs(0)
  rs.close
  if not int_true(num_num) then num_num=0
  sql="select sum(counter) from down where hidden=1"
  set rs=joekoe_cms.exec(sql,1)
  num_down=rs(0)
  rs.close
  sql="select top "&n_num&" d.id,d.username,d.name,d.tim,d.counter,c.c_id,c.c_name " & _
      "from jk_class c inner join down d on c.c_id=d.c_id where d.hidden=1 order by d.id desc"
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    n_username=rs("username")
    n_topic=rs("name")
    n_tim=rs("tim")
    n_tim=joekoe_cms.time_type(n_tim,1)
    n_cname=rs("c_name")
    n_cname=joekoe_cms.code_html(n_cname,1,0)
    tmp=tmp&down_topic_main(rs("c_id"),n_cname,c_num,rs("id"),n_username,n_topic,n_tim,rs("counter"),2)
    rs.movenext
  loop
  rs.close
  tmp=vbcrlf&"<tr><td width='70%'>" & _
	vbcrlf&"<table border=0 width='100%'>" & _
    vbcrlf&tmp&"</table>" & _
	vbcrlf&"</td>" & _
    vbcrlf&"<td width='30%' align=center>" & _
	vbcrlf&"<table border=0>" & _
	vbcrlf&"<tr><td>软件总数：<font class=red>"&num_num&"</font>个软件</td></tr>" & _
	vbcrlf&"<tr><td>今日更新：<font class=red>"&num_today&"</font>个软件</td></tr>" & _
	vbcrlf&"<tr><td>下载总数：<font class=red>"&num_down&"</font>人次</td></tr>" & _
	vbcrlf&"<tr><td class=gray>[ "&img_skin(web_img_h)&"<a href='list.asp'>浏览软件详细列表</a> ]</td></tr>" & _
	vbcrlf&"<tr><td class=gray>[ "&img_skin(web_img_h)&"<a href='../common/gbook.asp?action=write'>下载链接地址报错</a> ]</td></tr>" & _
	vbcrlf&"<tr><td class=gray>[ "&img_skin(web_img_h)&"<a href='../user/put.asp?action=down'>我要发布软件下载</a> ]</td></tr>" & _
	vbcrlf&"</table>" & _
	vbcrlf&"</td>" & _
	vbcrlf&"</tr>"
  call down_center_table(n_title,tmp,1,1)
end sub

sub down_pic(nt,n_num,c_num,n_title)
  dim temp1,nid,per_num,n_pic,n_topic,tmp
  per_num=100\n_num
  sql="select top "&n_num&" id,name,pic from down where hidden=1"
  select case nt
  case "hot"
    sql=sql&" order by counter desc,id desc"
  case "good"
    sql=sql&" and types=5 order by id desc"
  case else
    sql=sql&" order by id desc"
  end select
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    n_topic=rs("name")
    tmp=tmp&"<td width='"&per_num&"%'>"&format_pic_type(rs("pic"),n_topic,c_num,"view.asp?id="&rs("id"))&"</td>"
    rs.movenext
  loop
  rs.close
  tmp="<tr align=center>"&tmp&"</tr>"
  call down_center_table(n_title,tmp,1,1)
end sub

function down_server(snum,vurl)
  if snum=0 or snum="" then
    d_url=vurl
    exit function
  end if
  dim vdim,vserver,sserver
  if left(vurl,1)="/" then vurl=left(vurl,len(vurl)-1)
  joekoe_cms.chk_down_server()
  vdim=split(web_dim(53),"$")
  sserver=split(vdim(snum-1),"|")
  down_server=sserver(0)
  if right(down_server,1)<>"/" then down_server=down_server&"/"
  d_url=down_server&vurl
end function

sub down_list()
  dim mhead,n_name,n_tim,n_remark,sqladd,sql_tmp,cname,sname,sea_type,keyword,sea_term,taxis,tmp
  mhead=tit
  sqladd=""
  cname=""
  sname=""
  taxis=trim(request.querystring("taxis"))
  if cint(cid)>0 then
    sqladd=" and c_id="&cid
    sql="select c_name from jk_class where c_id="&cid
    if cint(sid)>0 then 
      sqladd=" and s_id="&sid
      sql="select jk_class.c_name,jk_sort.s_name from jk_sort inner join jk_class on jk_sort.c_id=jk_class.c_id where jk_sort.c_id="&cid&" and jk_sort.s_id="&sid
    end if
    set rs=conn.execute(sql)
    if not(rs.eof) then
      cname=rs("c_name")
      if cint(sid)>0 then sname=rs("s_name")
    end if
    rs.close
    mhead=mhead&"&nbsp;→&nbsp;"&cname
    if sid>0 and sname<>"" then mhead=mhead&"&nbsp;→&nbsp;"&sname
  end if
  keyword=joekoe_cms.code_form(request.querystring("keyword"))
  if action="search" and keyword<>"" then
    sea_type=trim(request.querystring("sea_type"))
    sea_term=trim(request.querystring("sea_term"))
    if sea_type<>"username" then sea_type="name"
    if sea_term<>"only" then sea_term="all"
    sql_tmp=sql_key(keyword,sea_type,2,sea_term)
    if sql_tmp<>"" then
      sqladd=sqladd&" and "&sql_tmp
      sql_tmp=""
      pageurl=pageurl&"sea_type="&sea_type&"&keyword="&server.urlencode(keyword)&"&"
      mhead=mhead&"&nbsp;→&nbsp;关键字："&keyword
    end if
  end if
  tmp=tmp&down_list_top(pageurl&"page="&viewpage&"&")
  sql="select count(id) from down where hidden=1"&sqladd
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&viewpage*nummer&" id,name,tim,counter,sizes,types,remark from down where hidden=1"&sqladd
  select case taxis
  case "tim"
    sql=sql&" order by tim desc,id desc"
  case "counter"
    sql=sql&" order by counter desc,id desc"
  case "types"
    sql=sql&" order by types desc,id desc"
  case else
    sql=sql&" order by id desc"
    taxis=""
  end select
  pageurl=pageurl&"taxis="&taxis&"&"
  call joekoe_cms.exec("",-1)
  rs.open sql,conn,1,1
  if cint(viewpage)>1 then rs.move (viewpage-1)*nummer
  if int(viewpage*nummer)>int(rssum) then nums=nummer-(viewpage*nummer-rssum)
  for i=1 to nums
    n_name=rs("name")
    n_tim=rs("tim")
    n_tim=joekoe_cms.time_type(n_tim,1)
    n_remark=rs("remark")
    n_remark=joekoe_cms.cuted(n_remark,70)
    n_remark=joekoe_cms.code_html(n_remark,2,0)
    tmp=tmp&down_list_body(((viewpage-1)*nummer+i),rs("id"),n_name,n_tim,rs("counter"),rs("sizes"),rs("types"),n_remark)
    rs.movenext
  next
  rs.close
  if action<>"hot" then tmp=tmp&down_list_pagecute(nummer,rssum,viewpage,thepages,pageurl)
  call down_center_table(mhead,tmp,1,1)
end sub
%>
