<!--#include file="../../Inc/Cls_Main.Asp"-->
<%
'=======================================================
Dim Action
'=======================================================
Action = LCase(Trim(Easp.Get("action:s")))
'=======================================================
Select Case Action
    Case "hits"
        Call GetHits()
    Case Else
        Easp.RR "/"
End Select
Set Cms = Nothing
Set Easp = Nothing

Sub GetHits()
    Dim ChannelId, DataId, ResultType, ArrayChannel, TabName
    ChannelId = Easp.Get("ChannelId:n:0")
    DataId = Easp.Get("id:n:0")
    ResultType = Easp.Get("r:n:0")
    If (ChannelId = 0 Or DataId = 0) Then
        ShowJs "参数错误!"
    Else
        ArrayChannel = GetCaCheChannelInfo("Channel", ChannelId, ChannelField)
        If Easp.IsN(ArrayChannel) Then
            ShowJs "不存在的频道"
        Else
            TabName = ArrayChannel(2)
            '===============================================================
            Dim oRs, Hits, DayHits, WeekHits, MonthHits, HitsTime, Result, CountNum
            Set oRs = Easp.db.GRS("Select Top 1 Hits,DayHits,WeekHits,MonthHits,HitsTime From ["& TabName &"] Where Id = "& DataId &" ")
            If Not Easp.IsN(oRs) Then
                If DateDiff("Ww", oRs("HitsTime"), Now()) <= 0 Then
                    WeekHits = oRs("WeekHits").Value + 1
                Else
                    WeekHits = 1
                End If
                If DateDiff("M", oRs("HitsTime"), Now()) <= 0 Then
                    MonthHits = oRs("MonthHits").Value + 1
                Else
                    MonthHits = 1
                End If
                If DateDiff("D", oRs("HitsTime"), Now()) <= 0 Then
                    DayHits = oRs("DayHits").Value + 1
                Else
                    DayHits = 1
                    HitsTime = Now()
                End If
                If DayHits = 1 Then
                    Result = Easp.db.UR(TabName, " Id = "& DataId &" ", Array("Hits:Hits+1", "DayHits:" & DayHits, "MonthHits:" & MonthHits, "WeekHits:" & WeekHits, "HitsTime:" & Now()))
                Else
                    Result = Easp.db.UR(TabName, " Id = "& DataId &" ", Array("Hits:Hits+1", "DayHits:" & DayHits, "MonthHits:" & MonthHits, "WeekHits:" & WeekHits))
                End If
                If Result <> 0 Then
                    CountNum = CmsFun.ChkNumEric(Easp.db.RT(TabName, " Id = "& DataId &" ", "Hits"))
                    If ResultType = 1 Then
                        ShowJson Easp.IIf(CountNum > 0, CountNum, 1), DayHits, MonthHits, WeekHits
                    Else
                        ShowJs Easp.IIf(CountNum > 0, CountNum, 1)
                    End If
                Else
                    If ResultType = 1 Then
                        ShowJson 1, 1, 1, 1
                    Else
                        ShowJs 1
                    End If
                End If
            End If
        End If
    End If
End Sub

Sub ShowJs(ByVal Tip)
    Easp.WE "document.writeln('"& Tip &"');"
End Sub

Sub ShowJson(ByVal Hits, ByVal DayHits, ByVal WeekHits, ByVal MonthHits)
    Easp.WE "{""Hits"":"""& Hits &""",""DayHits"":"""& DayHits &""",""WeekHits"":"""& WeekHits &""",""MonthHits"":"""& MonthHits &"""}"
End Sub
%>