%Option Explicit%>
<%
'declare and set variables
'arrays used to display proper sorting method
'also sets column widths
Dim fieldDescriptions, fieldNames, fieldWidths
fieldDescriptions = Array("Θέματα", "Αποστολέας", "Ημερομηνία", "Απαντήσεις")
fieldNames = Array("topic", "author", "date_posted", "replies")
fieldWidths = Array("290", "155", "100", "85")
Dim curPage, pageCount, topicCount
Dim sortBy, sortDir, sortDirOpp
Dim strSearch
Dim strSQL
Dim dbRS
Dim stateQS
Dim i, x, c
x = 0
'get the new current page if available - otherwise set to 1
curPage = CInt(Request("curPage"))
If curPage = "" Or IsNumeric(curPage) = False Then
curPage = 1
Else
If curPage < 1 Then
curPage = 1
End If
End If
'get sort settings
If Request("sortBy") = "" Then
sortBy = Session("sortBy")
Else
sortBy = Request("sortBy")
End If
If Request("sortDir") = "" Then
sortDir = Session("sortDir")
Else
sortDir = Request("sortDir")
End If
If sortBy = "" Then
sortBy = "orderit"
End If
If sortDir = "" Then
sortDir = "DESC"
End If
'get the opposite of the current sort direction in case of change
If sortDir = "DESC" Then
sortDirOpp = "ASC"
ElseIf sortDir = "ASC" Then
sortDirOpp = "DESC"
End If
'get the search string and build the SQL statement
strSearch = Request("search")
strSQL = "SELECT ID,parentID,topic,author,date_posted,replies,orderit FROM board1 "
If Not strSearch = "" Then
strSQL = strSQL & "WHERE (topic LIKE '%" & web2db(strSearch) & "%' OR"
strSQL = strSQL & " body LIKE '%" & web2db(strSearch) & "%' OR"
strSQL = strSQL & " author LIKE '%" & web2db(strSearch) & "%') "
Else
strSQL = strSQL & "WHERE parentID = 0 "
End If
strSQL = strSQL & "ORDER BY " & sortBy & " " & sortDir
'connect to the database
Set dbRS = Server.CreateObject("ADODB.Recordset")
With dbRS
.CursorLocation = 3
.CacheSize = C_dbPageSize
.Open strSQL, C_dbConnect
End With
If dbRS.EOF = False Then
With dbRS
.MoveFirst
topicCount = CInt(.RecordCount)
.PageSize = C_dbPageSize
pageCount = CInt(.PageCount)
.AbsolutePage = curPage
End With
Else
topicCount = 0
pageCount = 1
End If
'preconstruct query strings to keep things simple
stateQS = "curPage=" & curPage & "&"
stateQS = stateQS & "search=" & Server.URLEncode(strSearch)
%>
Konstantinos Kenteris, the world champion!


<%
'clear recordset from memory
Set dbRS = Nothing
'store sort settings in session variables
Session("sortBy") = sortBy
Session("sortDir") = sortDir
%>