<!--#include file="../inc/conn.asp"-->
<%
If Is_sql=0 Then SqlNowString="Now()" else SqlNowString="Getdate()"
set sdcms=new Sdcms_Function
id=sdcms.Requestint(id)
if id=0 then
echo id:Died
end if
select case action
	case "1":info_hits
	case "2":comment_num
	case else:notice_hits
end select
set sdcms=nothing
sub info_hits
	set rs=conn.execute("select hits,dayhits,weekhits,monthhits,lasthitsdate from sd_info where id="&id&"")
	if rs.eof then
	echo "0"
	else
	conn.execute("update sd_info set hits=hits+1 where id="&id&"")
	  if DateDiff("D",rs(4),now())<=0 then
	  conn.execute("update sd_info set dayhits=dayhits+1 where id="&id&"")
	  else
	  conn.execute("update sd_info set dayhits=1 where id="&id&"")  
	  end if
	  
	  if DateDiff("ww",rs(4),now())<=0 then
		conn.execute("update sd_info set weekhits=weekhits+1 where id="&id&"")
	  else
		conn.execute("update sd_info set weekhits=1 where id="&id&"")
	  end if
	  
	  if DateDiff("m",rs(4),now())<=0 then
		conn.execute("update sd_info set monthhits=monthhits+1 where id="&id&"")
	  else
		conn.execute("update sd_info set monthhits=1 where id="&id&"")
	  end if
	  conn.execute("update sd_info set lasthitsdate="&SqlNowString&" where id="&id&"")
	select case t
	case "1" 
	echo rs(1)
	case "2" 
	echo rs(2)
	case "3" 
	echo rs(3)
	case else 
	echo rs(0)
	end select
	rs.close
	set rs=nothing
	end if
End sub

Sub notice_hits
	set rs=conn.execute("select hits from sd_notice where id="&id&"")
	if rs.eof then
	echo "0"
	else
	conn.execute("update sd_notice set hits=hits+1 where id="&id&"")
	echo rs(0)
	end if
End Sub

Sub comment_num
	set rs=conn.execute("select comment_num,id from sd_info where id="&id&"")
	if rs.eof then
	echo "0"
	else
	echo "<a>"&rs(0)&"</a>"
	end if
End Sub
%>