%
server.Execute "/NoHACK1.asp"
dim Keyword, NewsType, Y, M, strCondition, T1, Y1, M1
dim strSQL, rs, rs1, Hp, MaxPage, O, P, Q, R, S, Ipage, ToPage
dim strLink, strTarget, NewsTypePic, TitlePic
dim rsTOP
Keyword = ReqTxt(request("Keyword"))
NewsType = ReqTxt(request("Type"))
Y = ReqNum(request("Y"))
M = ReqNum(request("M"))
strCondition = ""
' 前往頁數
ToPage = ReqNum(Request.QueryString("ToPage"))
'---- 搜尋關鍵字
If Keyword<>"" Then
strCondition = " NewsHuy = 'N' AND NewsTitle LIKE '%" & Replace(Keyword,"'","''") & "%'"
TitlePic = "new1.gif"
Else
'---- 驗證 NewsType : A 熱門 B 重要 C 活動 D 儲值 E系統 S立即移至系統類別
If (NewsType<>"") Then
If ((Len(NewsType) <> 1) or (Asc(NewsType) < 65) or (Asc(NewsType) > 69)) then
Response.Redirect "/Main.asp"
Response.End
Else
strCondition = " NewsHuy = 'N' AND NewsType = '" & NewsType & "'"
select case NewsType
case "A"
TitlePic = "new2.gif"
case "B"
TitlePic = "new3.gif"
case "C"
TitlePic = "new4.gif"
case "D"
TitlePic = "new6.gif"
case "E"
TitlePic = "new5.gif"
strCondition = " NewsHuy = 'N' AND (NewsType = '" & NewsType & "' OR NewsType = 'S')"
case else
TitlePic = "new1.gif"
end select
End If
Else
strCondition = " NewsHuy='N' and (NewsType <> 'E' and NewsType <> 'S' or NewsType = 'E' AND AddTime > DATE_ADD(SYSDATE(), INTERVAL -5 DAY))"
TitlePic = "new1.gif"
End If
'---- 驗證日期
If (Y<>"" and M<>"") Then
If (CInt(Y) > 2100 or CInt(Y) < 1911 or CInt(M) > 12 or CInt(M)) < 1 Then
Response.Redirect "/Main.asp"
Response.End
Else
strCondition = strCondition & " AND Year(AddTime) = '" & Y & "' AND Month(AddTime) = '" & M & "'"
End If
else
strCondition = strCondition & " AND Addtime >= DATE_ADD(SYSDATE(), INTERVAL -3 MONTH) - Day(DATE_ADD(SYSDATE(), INTERVAL -3 MONTH)) + 1"
End If
End If
strSQL = "SELECT NewsID, NewsTitle, DATE_FORMAT(AddTime, '%Y.%m.%d') AS NewsAddTime, NewsData, NewsType, NewsUrl FROM TOP_Notice WHERE Newsshow = 'Y' AND NewsTop = 'N' AND " & strCondition & " ORDER BY AddTime DESC, NewsID DESC"
set rs = GetRecordset(strSQL)
'撈置頂三則
strSQL = "SELECT NewsID, NewsTitle, DATE_FORMAT(AddTime, '%Y.%m.%d') AS NewsAddTime, NewsData, NewsType, NewsUrl FROM TOP_Notice WHERE Newsshow = 'Y' AND NewsTop = 'Y' ORDER BY AddTime DESC, NewsID DESC LIMIT 3"
set rsTOP = GetRecordset(strSQL)
rs.pagesize = 20 - rsTOP.recordcount
Hp = "news_all.asp"
if ToPage = "" or ToPage = empty then
ToPage = 1
else
ToPage = CInt(ToPage)
end if
MaxPage = rs.PageCount
if ToPage > MaxPage then
ToPage = MaxPage
elseif ToPage < 1 then
ToPage = 1
end if
If not(rs.EOF and rs.BOF) Then rs.AbsolutePage = ToPage
%>
<%
'置頂三則
Do Until rsTOP.EOF
select case rsTOP("NewsType").value
case "A"
NewsTypePic = "h.gif"
case "B"
NewsTypePic = "i.gif"
case "C"
NewsTypePic = "a.gif"
case "D"
NewsTypePic = "b.gif"
case "E"
NewsTypePic = "s.gif"
case "S"
NewsTypePic = "s.gif"
case else
NewsTypePic = "i.gif"
end select
If Trim(rsTOP("NewsUrl").value) = "" Or Escape(rs("NewsUrl")) = "%00" then
strLink = "/news/news_in.asp?ID=" & rsTOP("NewsID").value
strTarget = "_top"
Else
strLink = "/news/news_Url.asp?ID=" & rsTOP("NewsID").value
strTarget = "_blank"
End If
%>
<%
rsTOP.movenext
Loop
rsTOP.close : set rsTOP = nothing
For ipage = 1 to rs.PageSize
If rs.EOF Then Exit For
select case rs("NewsType").value
case "A"
NewsTypePic = "h.gif"
case "B"
NewsTypePic = "i.gif"
case "C"
NewsTypePic = "a.gif"
case "D"
NewsTypePic = "b.gif"
case "E"
NewsTypePic = "s.gif"
case "S"
NewsTypePic = "s.gif"
case else
NewsTypePic = "i.gif"
end select
If Trim(rs("NewsUrl").value) = "" Or Escape(rs("NewsUrl")) = "%00" then
strLink = "/news/news_in.asp?ID=" & rs("NewsID").value
strTarget = "_top"
Else
strLink = "/news/news_Url.asp?ID=" & rs("NewsID").value
strTarget = "_blank"
End If
%>
<%
P = ToPage
O = P + 5
R = O + 1
Q = P - 5
S = Q - 1
If O > RS.PageCount Then O = RS.PageCount
If R > RS.PageCount Then R = RS.PageCount
If Q < 1 Then Q = 1
If S < 1 Then S = 1
Keyword = server.URLEncode(Keyword)
%>