Private blnError
Private strError
Private strHandle
Private MyIO

Private Sub Class_Initialize()
    strHandle = Request.QueryString("Handle")
    blnError = True
    strError = "޴"
End Sub

Public Sub main()
    If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
        Call doPost
    Else
        Call doGet
    End If
End Sub

Private Sub doGet()
    Select Case LCase(strHandle)
    Case "list"
        Set MyIO = Server.CreateObject("WMCore.IIO")
        Call doGetList
        Set MyIO = Nothing
    Case Else
        Call doGetMain
    End Select
End Sub

Private Sub doPost()
    Select Case LCase(strHandle)
    Case "remove"
        Call doPostRemove
    Case Else
        Echo "δ֪"
    End Select
End Sub

Private Sub doGetMain()
    Echo "<html>"
    Echo "<head>"
    Echo "<meta http-equiv=""cache-control"" content=""no-cache"" />"
    Echo "<meta http-equiv=""cache-control"" content=""max-age=0"" />"
    Echo "<meta http-equiv=""content-type"" content=""text/html; charset=gb2312"" />"
    Echo "<title>" & MyKernel.Env("ProVName") & " - ۹</title>"
    Echo "<link rel=""stylesheet"" href=""images/xw.css"" />"
    Echo "<script language=""javascript"" src=""jspp/jspp.js""></script>"
    Echo "<script language=""javascript"">"
    Echo "<!--"
    Echo "jspp.Caption = """ & MyKernel.Env("ProName") & """;"
    Echo "-->"
    Echo "</script>"
    Echo "<script language=""javascript"" src=""images/wm_remark.js""></script>"
    Echo "</head>"
    Echo "<body style=""padding:5;margin:0;overflow:auto;border:0"">"
    Echo "<table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"" style=""border:1px solid #000000"">"
    Echo "    <tr>"
    Echo "        <td align=""right"" bgcolor=""#A2ADC4"" style=""border-bottom:1px solid #000000;padding-right:1px;padding-top:1px"" height=""24""><img src=""images/xw_cls0.gif"" border=""0"" align=""absMiddle"" onMouseOver=""this.src='images/xw_cls1.gif'"" onMouseOut=""this.src='images/xw_cls0.gif'"" onMouseDown=""this.src='images/xw_cls2.gif'"" onMouseUp=""this.src='images/xw_cls1.gif'"" /></td>"
    Echo "    </tr>"
    Echo "    <tr>"
    Echo "        <td>"
    Echo "            <table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"">"
    Echo "                <tr>"
    Echo "                    <td height=""24"" style=""background-image:url(images/xw_back4.gif)"">&nbsp;</td>"
    Echo "                </tr>"
    Echo "                <tr>"
    Echo "                    <td>"
    Echo "                        <table width=""98%"" border=""0"" cellpadding=""0"" cellspacing=""0"" align=""center"">"
    Echo "                            <tr id=""child_0"" style=""display:none"">"
    Echo "                                <td>"
    Call setListForm
    Echo "                                </td>"
    Echo "                            </tr>"
    Echo "                        </table>"
    Echo "                    </td>"
    Echo "                </tr>"
    Echo "            </table>"
    Echo "        </td>"
    Echo "    </tr>"
    Echo "</table>"
    Echo "<iframe id=""console"" name=""console"" frameborder=""0"" scrolling=""no"" width=""0"" height=""0"" style=""display:none""></iframe>"
    Echo "</body>"
    Echo "</html>"
End Sub

Private Sub setListForm()
    Echo "<form id=""frmMain_0"" onsubmit=""return(false)"">"
    Echo "<table width=""100%"" border=""1"" cellpadding=""2"" cellspacing=""0"" align=""center"" style=""border-collapse:collapse"" bordercolor=""#000000"">"
    Echo "    <tr>"
    Echo "        <td colspan=""2"" class=""winT0"">"
    Echo "            <b></b>"
    Echo "            <a href=""javascript:void(0)"" class=""a1"" onclick=""jspp.Remark.doPage(jspp.Remark.page)"">ˢб</a>"
    Echo "        </td>"
    Echo "    </tr>"
    Echo "    <tr class=""winT1"">"
    Echo "        <td colspan=""2"" id=""_list_""></td>"
    Echo "    </tr>"
    Echo "</table>"
    Echo "</form>"
End Sub

Private Sub doGetList()
    Response.Charset = "utf-8"
    Response.ContentType = "text/xml"
    Dim objPage
    Dim rs
    Dim i
    Dim strKey
    Dim strWhere
    strKey = Trim(MyIO.QueryString("Keyword", 65001))
    Set objPage = Server.CreateObject("WMKernel.IPage")
    objPage.PageName = "Page"
    objPage.PageSize = 20
    objPage.dataType = WM_DataType
    objPage.Increment = "Intime"
    objPage.Column = "*"
    objPage.Table = T_REMARK
    strWhere = "1=1"
    If strKey <> "" Then
        strWhere = strWhere & Replace(" AND (Title LIKE '%$(Keyword)%' Or UserName LIKE '%$(Keyword)%' Or Content LIKE '%$(Keyword)%')", "$(Keyword)", SafeString(strKey))
    End If
    objPage.Where = strWhere
    objPage.Sort = "Intime DESC"
    objPage.SortType = True
    Set rs = objPage.Exec()
    Echo "<table width=""100%"" border=""1"" cellpadding=""2"" cellspacing=""0"" align=""center"" style=""border-collapse:collapse;word-break:break-all;word-wrap:break-word;"" bordercolor=""#000000"">"
    Echo "    <tr>"
    Echo "        <td width=""8%"" class=""winT0""><b>ѡ</b></td>"
    Echo "        <td width=""30%"" class=""winT0""><b><b/></td>"
    Echo "        <td width=""10%"" class=""winT0""><b><b/></td>"
    Echo "        <td width=""30%"" class=""winT0""><b><b/></td>"
    Echo "        <td width=""14%"" class=""winT0""><b>ʱ<b/></td>"
    Echo "        <td width=""8%"" class=""winT0""><b></b></td>"
    Echo "    </tr>"
    If objPage.TotalRow > 0 Then
        i = 0
        Dim objRemark
        Set objRemark = MyKernel.Table(T_REMARK)
        Do While rs.EOF = False And i < objPage.PageSize
            objRemark.Source = rs
            Echo "<tr class=""winT1"">"
            Echo "<td align=""center""><input type=""checkbox"" id=""SeqId"" name=""SeqId"" value=""" & objRemark.Item("SeqId") & """ /></td>"
            Echo "<td>" & Server.HTMLEncode(objRemark.Item("Title")) & "</td>"
            Echo "<td>" & Server.HTMLEncode(objRemark.Item("UserName")) & "</td>"
            Echo "<td>" & Server.HTMLEncode(objRemark.Item("Content")) & "</td>"
            Echo "<td align=""right"">" & FormatTime(getDate(objRemark.Item("Intime")), "YY-MM-DD HH24:MI") & "</td>"
            Echo "<td align=""center"">"
            Echo "<select class=""sel"" onchange=""jspp.Remark.control(this, " & objRemark.Item("SeqId") & ")"">"
            Echo "<option value=""0""></option>"
            Echo "<option value=""1"">ɾ</option>"
            Echo "</select>"
            Echo "</td>"
            Echo "</tr>"
            rs.MoveNext
            i = i + 1
        Loop
        Set objRemark = Nothing
        Call ShowControl
        Call ShowPage(objPage)
    Else
        Echo "    <tr class=""winT4"">"
        Echo "        <td colspan=""6"">κ</td>"
        Echo "    </tr>"
        Call ShowControl
    End If
    Echo "</table>"
    If TypeName(rs) <> "Nothing" Then rs.Close
    Set rs = Nothing
    Set objPage = Nothing
End Sub

Private Sub ShowControl()
    Echo "    <tr class=""winT4"">"
    Echo "        <td align=""center""><input type=""checkbox"" onclick=""chkAll(this)"" /></td>"
    Echo "        <td colspan=""5"">"
    Echo "            <input type=""button"" class=""btn"" value=""ɾ"" onclick=""jspp.Remark.removeAll(this.form)"" />"
    Echo "            <input type=""button"" class=""btn"" value="""" onclick=""jspp.Remark.query(this.form)"" />"
    Echo "            <input name=""Keyword"" type=""text"" class=""txt"" value=""" & Server.HTMLEncode(MyIO.QueryString("Keyword", 65001)) & """ />"
    Echo "        </td>"
    Echo "    </tr>"
End Sub

Private Sub ShowPage(objPage)
    Echo "    <tr class=""winT4"">"
    Echo "        <td colspan=""7"" align=""right"">"
    Echo "            " & objPage.TotalRow & "Ϣ"
    Echo "            " & objPage.PageSize & "/ҳ"
    Echo "            " & objPage.PageNum & "/" & objPage.TotalPage & "ҳ"
    If objPage.PageNum > 1 Then
        Echo "            <a href=""javascript:void(0)"" onclick=""jspp.Remark.doPage(1)"" class=""a1"" />  ҳ</a>"
        Echo "            <a href=""javascript:void(0)"" onclick=""jspp.Remark.doPage(" & (objPage.PageNum - 1) & ")"" class=""a1"" />һҳ</a>"
    Else
        Echo "            <a class=""a1"">  ҳ</a>"
        Echo "            <a class=""a1"">һҳ</a>"
    End If
    If objPage.PageNum < objPage.TotalPage Then
        Echo "            <a href=""javascript:void(0)"" onclick=""jspp.Remark.doPage(" & (objPage.PageNum + 1) & ")"" class=""a1"" />һҳ</a>"
        Echo "            <a href=""javascript:void(0)"" onclick=""jspp.Remark.doPage(" & objPage.TotalPage & ")"" class=""a1"" />β  ҳ</a>"
    Else
        Echo "            <a class=""a1"">һҳ</a>"
        Echo "            <a class=""a1"">β  ҳ</a>"
    End If
    Echo "        </td>"
    Echo "    </tr>"
End Sub

Private Sub doPostRemove()
    Response.Charset = "utf-8"
    Response.ContentType = "text/xml"
    If MyPower.Item("DeleteRemark") = 0 Then
        Push "ûɾ۵Ȩ"
    Else
        Dim arrSeq
        Dim lngSeq
        Dim objRemark
        Set objRemark = MyKernel.Table(T_REMARK)
        arrSeq = Split(Request.Form("SeqId"), ",")
        For Each lngSeq In arrSeq
            If objRemark.Exec("*", "SeqId=" & atol(lngSeq)) Then
                SafeExecute "DELETE FROM " & T_REMARK & " WHERE SeqId=" & objRemark.Item("SeqId")
                SafeExecute "UPDATE " & T_CONTENT & " SET RemarkTotal=RemarkTotal-1 WHERE SeqId=" & objRemark.Item("ContentId")
            End If
        Next
        Set objRemark = Nothing
        Push "OK"
    End If
End Sub
