<!-- #include file="include/admin_onlogin.asp" -->
<%
index_url="data"
call admin_master(0,0)
call admin_header(0,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='?action=update'>网站统计数据更新</a></td>
  <td width=10></td>
  <td><a href='?action=cache'>网站缓存清理</a></td>
  </tr>
  </table>
</td></tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
<%
call admin_table(1,1)

select case action
case "update"
  call joekoe_chk_update()
case "cache"
  call joekoe_chk_cache()
case else
  call joekoe_chk_main()
end select

call admin_ender(1)

sub joekoe_chk_update()

  if trim(request.querystring("chk"))<>"yes" then
    call admin_td("网站统计数据更新")
%>
<tr>
<td>操作注意事项：</td>
<td height=60 class=htd>重新计算整个网站的统计信息，包括产品、新闻、文章、软件、论坛等！<br>建议在数据显示错乱时执行本次操作。</td>
</tr>
<tr><td height=40 colspan=2 align=center><input type=button value='网站统计数据更新' onclick="javascript:location.href='?action=<%response.write action%>&chk=yes';"></td></tr>
<%
    exit sub
  end if
  'sql="insert into configs(id,num_topic,num_data,num_reg,new_username,num_news,num_article,num_down,num_product,counter,max_online,max_tim,start_tim,num_new,today_tim) " & _
  '    "values(1,0,0,0,'',0,0,0,0,0,0,'"&joekoe_cms.now_time&"','"&joekoe_cms.time_type(joekoe_cms.now_time,5)&"',0,'"&joekoe_cms.time_type(joekoe_cms.now_time,4)&"')"
  dim num_topic,num_data,num_reg,new_username,num_news,num_article,num_down,num_product,counter,max_online,max_tim,start_tim,num_new,today_tim
  num_topic=0
  num_data=0
  num_reg=0
  new_username=""
  num_news=0
  num_article=0
  num_down=0
  num_product=0
  num_new=0
  set rs=joekoe_cms.exec("select count(id) from bbs_topic",1)
  if not rs.eof then num_topic=rs(0)
  rs.close
  set rs=joekoe_cms.exec("select count(id) from bbs_data",1)
  if not rs.eof then num_data=rs(0)
  rs.close
  set rs=joekoe_cms.exec("select count(id) from user_data",1)
  if not rs.eof then num_reg=rs(0)
  rs.close
  set rs=joekoe_cms.exec("select top 1 username from user_data order by id desc",1)
  if not rs.eof then new_username=rs(0)
  rs.close
  set rs=joekoe_cms.exec("select count(id) from news where hidden=1",1)
  if not rs.eof then num_news=rs(0)
  rs.close
  set rs=joekoe_cms.exec("select count(id) from article where hidden=1",1)
  if not rs.eof then num_article=rs(0)
  rs.close
  set rs=joekoe_cms.exec("select count(id) from down where hidden=1",1)
  if not rs.eof then num_down=rs(0)
  rs.close
  set rs=joekoe_cms.exec("select count(id) from shop_product where hidden=1",1)
  if not rs.eof then num_product=rs(0)
  rs.close
  set rs=joekoe_cms.exec("select sum(forum_new_num) from bbs_forum where forum_star=0",1)
  if not rs.eof then num_new=rs(0)
  rs.close
  if not int_true(num_new) then num_new=0
  sql="update configs set num_topic="&num_topic&",num_data="&num_data&",num_reg="&num_reg&",new_username='"&new_username&"',num_news="&num_news&",num_article="&num_article&",num_down="&num_down&",num_product="&num_product&",num_new="&num_new&",today_tim='"&joekoe_cms.time_type(joekoe_cms.now_time,4)&"'"
  call joekoe_cms.exec(sql,0)
  call admin_msg("成功重新计算了整个网站的统计信息，包括产品、新闻、文章、软件、论坛等！","?action="&action,1)
end sub

sub joekoe_chk_cache()
  dim aaa

  if trim(request.querystring("chk"))<>"yes" then
    call admin_td("网站缓存清理")
%>
<tr>
<td>操作注意事项：</td>
<td height=60 class=htd>现在正在执行清理网站当前正在使用的所有缓存！<br>建议在数据显示错乱时执行本次操作。</td>
</tr>
<tr><td height=40 colspan=2 align=center><input type=button value='执行网站缓存清理' onclick="javascript:location.href='?action=<%response.write action%>&chk=yes';"></td></tr>
<%
    exit sub
  end if
  sql="select sum(forum_new_num) from bbs_forum where forum_star=0"
  set rs=joekoe_cms.exec(sql,1)
  aaa=rs(0)
  rs.close
  if not int_true(aaa) then aaa=0
  call joekoe_cms.exec("update configs set num_new="&aaa,0)
  application.contents.removeall()
  call admin_msg("成功对网站现在所使用的所有缓存进行了清理！","?action="&action,1)
end sub

sub joekoe_chk_main()
  call admin_td(tit)
%>
<tr>
<td></td>
<td>
  <table border=0>
  <tr><td><%response.write img_admin("","")%>&nbsp;<a href='?action=update'>网站统计数据更新</a></td></tr>
  <tr><td>重新计算整个网站的统计信息，包括产品、新闻、文章、软件、论坛等。</td></tr>
  </table>
</td>
</tr>
<tr>
<td></td>
<td>
  <table border=0>
  <tr><td><%response.write img_admin("","")%>&nbsp;<a href='?action=cache'>网站缓存清理</a></td></tr>
  <tr><td>清理网站当前正在使用的所有缓存！建议在数据显示错乱时执行本次操作。</td></tr>
  </table>
</td>
</tr>
<%
end sub
%>