<% On Error Resume Next If session("user_logged_moderator" & strSUnique) = True Or session("admin_loggedin" & strSUnique) = Session.SessionID then moderator = True setLocale server_locale as_ALL_Cats = False Dim as_catOpt(3, 20), as_catOptValues(20), as_catOptValues1(20), as_userOptValues(6), as_userOptValues1(6), commonWordsArray Dim totalPage, totalRecords, displayRecords '*** Add 3+ letter common words separated by a single space if nessesary. '*** Words in this list will be EXCLUDED from search (except for "Exact Phrase" search). commonWordsArray = Split("the for and where who that this then that from does will yes") '*** ------------------------------------------------------------------------------ msgHalt = "


" & strText_Advanced & " " & strText_SearchRules & ":

" msgHalt = msgHalt & "
  • " & strText_SearchCriteria & "

  • " msgHalt = msgHalt & "
  • " & strText_SearchKeywords & "

  • " msgHalt = msgHalt & "
  • " & strText_SearchKeywordsLength & "

  • " msgHalt = msgHalt & "
  • " & strText_SearchSpeedUp & "

  • " msgHalt = msgHalt & "
  • " & strText_SearchCommomWords & "

  • " msgHalt = msgHalt & "

    " & strText_SearchInvalid & "

" msgResult = "
" & strText_SearchResult & "[""" as_ALL_ID = CStr(Request("D1")) If Len(as_ALL_ID) > 0 then update = True If Request.Querystring.Count > 0 then as_dosearch = Request("dosearch") as_keys = Trim(lCase(CStr(Request("T1")))) as_keys = sqbl(as_keys) as_keysformat = CLng(Request("D2")) as_date = CLng(Request("D3")) as_city = sqbl(Trim(CStr(Request("T2")))) as_image = CStr(Request("C1")) as_sort = CLng(Request("D4")) as_keystarget = CLng(Request("D5")) as_ALL_Cats = Cbool(CInt(Request("advcat"))) If Len(as_keys) > 0 AND Len(as_keys) < 3 then haltSearch = true Elseif Len(as_keys) > 2 Then as_queryKeys = formatKeywords(as_keys, as_keysformat, as_keystarget) If Len(as_queryKeys) = 0 then haltSearch = true End If catname = Replace(CStr(catname), "-", "", 1, 1) catname = Trim(Request("catname")) If Len(as_ALL_ID) > 0 then as_IDArray = Split(as_ALL_ID, "|") Select Case UBound(as_IDArray) Case 0 as_1ID = as_IDArray(0) If isNumeric(as_1ID) then as_URLLink = "viewscat.asp?id=" & as_1ID Case 1 as_1ID = as_IDArray(0) as_2ID = as_IDArray(1) as_1Name = Server.URLEncode(Trim(Split(catname, ">")(0))) as_2Name = Server.URLEncode(Trim(Split(catname, ">")(1))) If isNumeric(as_2ID) then as_URLLink = "viewlist.asp?cid=" & as_1ID & "&sid=" & as_2ID Case 2 as_1ID = as_IDArray(0) as_2ID = as_IDArray(1) as_3ID = as_IDArray(2) as_1Name = Server.URLEncode(Trim(Split(catname, ">")(0))) as_2Name = Server.URLEncode(Trim(Split(catname, ">")(1))) as_3Name = Server.URLEncode(Trim(Split(catname, ">")(2))) If isNumeric(as_3ID) then as_URLLink = "viewsublist.asp?cid=" & as_1ID & "&sid=" & as_2ID & "3id=" & as_3ID End Select If Len(as_URLLink) > 0 then as_link = "" & catname & "" Else: as_link = catname End If End If For I = 0 to 6 as_userOptValues(I) = sqbl(Trim(CStr(Request("uO" & I)))) If Len(as_userOptValues(I)) = 0 then as_userOptValues(I) = sqbl(Trim(CStr(Request("uCOF" & I)))) chkString = chkString & as_userOptValues(I) as_userOptValues1(I) = sqbl(Trim(CStr(Request("uO" & I & "1")))) Next For I = 1 to 20 as_catOptValues(I) = sqbl(Trim(CStr(Request("O" & I)))) If Len(as_catOptValues(I)) = 0 then as_catOptValues(I) = sqbl(Trim(CStr(Request("COF" & I)))) chkString = chkString & as_catOptValues(I) as_catOptValues1(I) = sqbl(Trim(CStr(Request("O" & I & "01")))) Next chkString = Replace(chkString, "0", "") isswap = Request("catswap") Else as_link = strText_Advanced & " " & strText_Search End If %>
<%= strText_Home %>::<%= as_link %>
<% If as_dosearch = "dosearch" then as_refine = Replace(Request.Querystring, "&dosearch=dosearch", "") as_links = "

" Response.Write as_links If as_keys = Empty AND as_date = 0 AND as_city = Empty AND as_image = Empty AND as_ALL_ID = "0" AND chkString = Empty then haltSearch = true If haltSearch then Response.Write msgHalt Else sdd = dd(objConn) If not as_date = 0 then baseDate = DateAdd("d", -as_date, Date) as_queryDate = " AND pdate > " & sdd & ConvDateShort(baseDate) & sdd End If If Len(as_city) > 0 then as_queryCity = " AND city LIKE '%" & as_city & "%'" If as_image = "1" then as_queryImage = " AND images <> ''" If IsNumeric(as_3ID) And as_3ID > 0 Then as_category = " AND cat3rdID = " & as_3ID ElseIf IsNumeric(as_2ID) And as_2ID > 0 Then as_category = " AND scatID = " & as_2ID ElseIf IsNumeric(as_1ID) And as_1ID > 0 Then as_category = " AND catID = " & as_1ID End If Select Case as_sort Case 1: as_sortorder = ") ORDER BY pdate DESC" Case 2: as_sortorder = ") ORDER BY pdate ASC" Case 3: as_sortorder = ") ORDER BY subject DESC" Case 4: as_sortorder = ") ORDER BY nick DESC" Case 5: as_sortorder = ") ORDER BY images DESC" Case 6: as_sortorder = ") ORDER BY hotlist DESC" End Select For I = 0 to 6 If Len(as_userOptValues1(I)) > 0 AND isNumeric(as_userOptValues1(I)) then Select Case databaseType Case "msaccess" If Not as_userOptValues(I) = "00" then as_useropt = as_useropt & " AND CLng(Val(uopt" & I+1 & "))>=" & CLng(as_userOptValues(I)) If Not as_userOptValues1(I) = "00" then as_useropt = as_useropt & " AND CLng(Val(uopt" & I+1 & "))<=" & CLng(as_userOptValues1(I)) Case "mssql" If Not as_userOptValues(I) = "00" then as_useropt = as_useropt & " AND CAST(uopt" & I+1 & " AS int)>=" & CLng(as_userOptValues(I)) If Not as_userOptValues1(I) = "00" then as_useropt = as_useropt & " AND CAST(uopt" & I+1 & " AS int)<=" & CLng(as_userOptValues1(I)) Case "mysql" If Not as_userOptValues(I) = "00" then as_useropt = as_useropt & " AND ROUND(uopt" & I+1 & ")>=" & CLng(as_userOptValues(I)) If Not as_userOptValues1(I) = "00" then as_useropt = as_useropt & " AND ROUND(uopt" & I+1 & ")<=" & CLng(as_userOptValues1(I)) End Select ElseIf Len(as_userOptValues(I)) > 0 AND Not as_userOptValues(I) = "00" then as_useropt = as_useropt & " AND uopt" & I+1 & " LIKE '%" & as_userOptValues(I) & "%'" End If Next For I = 0 to 20 If Len(CStr(as_catOptValues1(I))) > 0 AND isNumeric(as_catOptValues1(I)) then Select Case databaseType Case "msaccess" If Not as_catOptValues(I) = "00" then as_useropt = as_useropt & " AND CLng(Val(opt" & I & "))>=" & CLng(as_catOptValues(I)) If Not as_catOptValues1(I) = "00" then as_useropt = as_useropt & " AND CLng(Val(opt" & I & "))<=" & CLng(as_catOptValues1(I)) Case "mssql" If Not as_catOptValues(I) = "00" then as_useropt = as_useropt & " AND CAST(opt" & I & " AS int)>=" & CLng(as_catOptValues(I)) If Not as_catOptValues1(I) = "00" then as_useropt = as_useropt & " AND CAST(opt" & I & " AS int)<=" & CLng(as_catOptValues1(I)) Case "mysql" If Not as_catOptValues(I) = "00" then as_useropt = as_useropt & " AND ROUND(opt" & I & ")>=" & CLng(as_catOptValues(I)) If Not as_catOptValues1(I) = "00" then as_useropt = as_useropt & " AND ROUND(opt" & I & ")<=" & CLng(as_catOptValues1(I)) End Select ElseIf Len(as_catOptValues(I)) > 0 AND Not as_catOptValues(I) = "00" then as_useropt = as_useropt & " AND opt" & I & " LIKE '%" & as_catOptValues(I) & "%'" End If Next strSQLSearch = "SELECT adID,pdate,nick,city,subject,images,status,adcounter,hotlist,userID,webimage FROM " & tablPfx & "Ads WHERE " strSQLSearch = strSQLSearch & "(status = 1 " & as_queryKeys & as_queryDate & as_queryCity & as_queryImage & as_category & as_useropt & as_sortorder & ";" '*** DEBUG SQL QUERY STRING 'Response.Write strSQLSearch 'Response.End '*** DEBUG SQL QUERY STRING rs.PageSize = pp rs.CacheSize = 60 rs.CursorLocation = 3 rs.Open strSQLSearch, strConn, 0, 1 If rs.EOF OR err.number <> 0 then Response.Write "
" & strText_SearchNoMatch2 & "

" Else If isNumeric(Request("page")) and Len(Request("page")) > 0 then nPage = Request("page") Else: nPage = 1 End If URLlink = "advsearch.asp?" & Server.URLEncode(Request.Querystring) pageType = 11 strPaging = buildPages(nPage, URLlink, pageType) '## paging built in libraries.asp Response.Write msgResult & as_link & """]
" Response.Write strPaging Response.Write "
" & strText_TotalPages & ": " & totalPage & "
" Response.Write strText_SearchMatchAd & ": " & totalRecords & "
" %>
<% setLocale resetLocale For J = 1 to displayRecords If rs.EOF Then Exit For Else adID = rs(0) active = CLng(rs(6)) iDate = FormatDateTime(rs(1), 2) subject = rs(4) subject = "" & subject & "" If rs(8) then subject = "   " & subject userID = rs(9) If CStr(session("user_logged_ID" & strSUnique)) = CStr(userID) then adOwner = True nick = rs(2) city = rs(3) webImage = rs(10) If len(webImage) > 0 then imgStr = "" & strText_Yes & "" Else: imgStr = "" & strText_NA & "" End If views = rs(7) If len(rs(5)) > 0 then imgTempArray = Split(rs(5), sf) img = Split(imgTempArray(0), "|")(0) size = Split(imgTempArray(0), "|")(1) w = CLng(Split(size, "x")(0)) + 50 h = CLng(Split(size, "x")(1)) + 70 imgStr = "" imgStr = imgStr & "" Else: imgStr = "N/A" End If If J mod 2 = 0 then cellColor = "class='evencell'": Else: cellColor = "class='oddcell'" %> <% rs.MoveNext End If Next %>
<%= strText_PostedOn %>: <%= strText_Subject %>: <%= strText_Location %>: <%= strText_Picture %>: <%= strText_Views %>: <%= strText_Action %>:
align="center"><%= iDate %> ><%= subject %> align="center"><%= city %> align="center"><%= imgStr %> align="center"><%= views %> align="center"> <% If adOwner Or moderator then If active = 2 then Response.Write "" & strText_Repost & "" ElseIf active = 1 then Response.Write "" & strText_Edit & "" End If If moderator then Response.Write " Delete" If active = 0 then Response.Write " Activate" End If End If Else: Response.Write "=" End If %>

<% Session("adlist_show_page" & strSUnique) = Empty End If rs.close End If Response.Write as_links Else %>
<%= strText_Advanced %> <%= strText_Search %>
<% For ruo = 0 to 6 If Not uOpt(ruo) = Empty AND CLng(uOptSearch(ruo)) = 1 Then If update then userValue = as_userOptValues(ruo): userValue1 = as_userOptValues1(ruo) If CStr(uOptType(ruo)) = "0" then strInput = "" Else set rsOpt = objConn.Execute("SELECT * FROM " & tablPfx & "OptTypes WHERE optionName = '" & uOptType(ruo) & "';") If rsOpt.EOF then strInput = "" Else inputMatch = False noMatchDisable = Empty ccheckBox = Empty ctextBox = "disabled" nextOptString = Empty nextOptString1 = Empty strCustom = Empty nextOptValues = CStr(rsOpt(2)) nextAllowCustom = CBool(rsOpt(3)) nextCustomName = CStr(rsOpt(4)) nextOptBlank = CStr(rsOpt(5)) nextIsRange = CBool(rsOpt(7)) nextOptValuesA = Split(nextOptValues, sf) For bo = 0 to Ubound(nextOptValuesA) optValue = CStr(nextOptValuesA(bo)) optText = optValue If update AND optText = userValue then sel = "selected": inputMatch = True: Else sel = "": End If If nextOptBlank = optValue then optValue = Empty nextOptString = nextOptString & "" & vbcrlf Next If nextIsRange then For bo = Ubound(nextOptValuesA) to 0 Step -1 optValue = CStr(nextOptValuesA(bo)) optText = optValue If update AND optText = userValue1 then sel = "selected": Else sel = "": End If If nextOptBlank = optValue then optValue = Empty nextOptString1 = nextOptString1 & "" & vbcrlf Next If Not update OR userValue1 = "00" then selAll1 = "selected": Else: selAll1 = "": End If nextOptString1 = "" & vbcrlf & nextOptString1 End If If Not update OR userValue = "00" then selAll = "selected": Else: selAll = "": End If nextOptString = "" & vbcrlf & nextOptString If nextAllowCustom AND Not nextIsRange then If Not inputMatch AND update AND Not userValue = "00" AND not isswap then noMatchDisable = "disabled" ccheckBox = "checked" ctextBox = Empty Else: userValue = Empty End If strCustom = "  " & nextCustomName & " " strCustom = strCustom & " " End If If nextIsRange then strInput = vbcrlf & "" & vbcrlf strInput = strInput & vbcrlf & " To: " & vbcrlf Else strInput = vbcrlf & "" & vbcrlf & strCustom End If End If rsOpt.close End If %> <% End If Next %> <% If Len(as_ALL_ID) > 2 then catID = Split(CStr(as_ALL_ID), "|")(0) If isNumeric(catID) then set rsOpt = objConn.Execute("SELECT * FROM " & tablPfx & "Cat WHERE catID = " & catID & ";") If Not rsOpt.EOF then For I = 1 to 20 as_catOpt(0, I) = rsOpt("catOpt" & I) as_catOpt(1, I) = rsOpt("catOptType" & I) as_catOpt(2, I) = CInt(rsOpt("catOptSearch" & I)) Next End If rsOpt.close End If Else set rsGlobal = objConn.Execute("SELECT * FROM " & tablPfx & "Opt ORDER BY optorder ASC;") For I = 1 to 20 If CBool(CInt(rsGlobal("isglobal"))) then as_catOpt(3, I) = 1 rsGlobal.MoveNext Next rsGlobal.close If mysql then set rsOpt = objConn.Execute("SELECT * FROM " & tablPfx & "Cat LIMIT 0,1;") Else: set rsOpt = objConn.Execute("SELECT TOP 1 * FROM " & tablPfx & "Cat;") End If If Not rsOpt.EOF then For I = 1 to 20 If as_catOpt(3, I) = 1 AND CInt(rsOpt("catOptSearch" & I)) = 1 then as_catOpt(0, I) = rsOpt("catOpt" & I) as_catOpt(1, I) = rsOpt("catOptType" & I) as_catOpt(2, I) = 1 End If Next End If rsOpt.close End If For op = 1 to 20 nextOptFieldName = as_catOpt(0, op) nextOptType = as_catOpt(1, op) If Not isNull(nextOptFieldName) AND as_catOpt(2, op) = 1 then If len(nextOptFieldName) > 0 then If update then userValue = Replace(as_catOptValues(op), sg, ""): userValue1 = Replace(as_catOptValues1(op), sg, "") If CStr(nextOptType) = "0" then strInput = "" Else set rsOpt = objConn.Execute("SELECT * FROM " & tablPfx & "OptTypes WHERE optionName = '" & nextOptType & "';") If rsOpt.EOF then strInput = "" Else inputMatch = False noMatchDisable = Empty ccheckBox = Empty ctextBox = "disabled" nextOptString = Empty nextOptString1 = Empty strCustom = Empty nextOptValues = CStr(rsOpt(2)) nextAllowCustom = CBool(rsOpt(3)) nextCustomName = CStr(rsOpt(4)) nextOptBlank = CStr(rsOpt(5)) nextIsHidden = CBool(rsOpt(6)) nextIsRange = CBool(rsOpt(7)) nextOptValuesA = Split(nextOptValues, sf) For bo = 0 to Ubound(nextOptValuesA) optValue = nextOptValuesA(bo) optText = Replace(optValue, sg, "") If update AND optText = userValue then sel = "selected": inputMatch = True: Else sel = "": End If If nextOptBlank = optValue then If nextIsHidden then optValue = sg Else: optValue = Empty End If End If nextOptString = nextOptString & "" & vbcrlf Next If nextIsRange then For bo = Ubound(nextOptValuesA) to 0 Step -1 optValue = nextOptValuesA(bo) optText = Replace(optValue, sg, "") If update AND optText = userValue1 then sel = "selected" Else sel = "": End If If nextOptBlank = optValue then If nextIsHidden then optValue = sg Else: optValue = Empty End If End If nextOptString1 = nextOptString1 & "" & vbcrlf Next If Not update OR userValue1 = "00" then selAll1 = "selected": Else: selAll1 = "": End If nextOptString1 = "" & vbcrlf & nextOptString1 End If If Not update OR userValue = "00" then selAll = "selected": Else: selAll = "": End If nextOptString = "" & vbcrlf & nextOptString If nextAllowCustom AND Not nextIsRange then If Not inputMatch AND update AND Not userValue = "00" AND Not isswap then noMatchDisable = "disabled" ccheckBox = "checked" ctextBox = Empty Else: userValue = Empty End If strCustom = "  " & nextCustomName & " " strCustom = strCustom & " " End If If nextIsRange then strInput = vbcrlf & "" strInput = strInput & " To: " Else strInput = vbcrlf & "" & vbcrlf & strCustom End If End If rsOpt.close End If %> <% End If End If Next %>
   
<%= strText_Searchforkeywords %>:
<%= strText_KeywordsTarget %>:
<%= strText_KeywordsFormat %>:
<%= strText_Sortby %>:
<%= strText_CategorytoSearch %>: <% If as_ALL_Cats then displayCategories = buildALLCategories(as_ALL_ID) Else displayCategories = buildCategories(as_ALL_ID) End If %> value=1 onclick="catname.value=D1.options[D1.selectedIndex].text;catswap.value=true;submit();">- <%= strText_DisplayCategoriesTree %>
<%= displayCategories %>
<%= strText_DateRange %>:
<%= strText_City %>:
<%= uOpt(ruo) %>: <%= strInput %>
<%= strText_WithPhotoOnly %>: >
<%= nextOptFieldName %>: <%= strInput %>
   
      <%= strText_Reset %>
   
   
<% End If %>
<% Function buildCategories(selected) buildOptionList as_temp = Replace(Application("Cat_List" & strUnique), strText_ALLCATEGORIES, strText_SearchAllCategories) If Len(CStr(selected)) > 0 then as_temp = Replace(as_temp, "value='" & selected & "'", "selected value='" & selected & "'") End If buildCategories = "" End Function Function buildALLCategories(selected) If mysql then strsql = "SELECT tbCat.catID AS ID1st, tbCat.catName AS Name1st, tbCat.ads AS Ads1st, tbscat.sCatID AS ID2nd, tbscat.scatName AS Name2nd, tbscat.ads AS Ads2nd, tb3ID.sCatID AS ID3rd, tb3ID.scatName AS Name3rd, tb3ID.ads AS Ads3rd " strsql = strsql & "FROM " & tablPfx & "Cat AS tbCat " strsql = strsql & "LEFT JOIN " & tablPfx & "Scat AS tbscat ON tbscat.catID = tbCat.catID " strsql = strsql & "LEFT JOIN " & tablPfx & "Scat AS tb3ID ON tb3ID.catID = tbscat.scatID " strsql = strsql & "ORDER BY tbCat.catName, tbscat.scatName, tb3ID.scatName;" Else strsql = "SELECT tbCat.catID AS ID1st, tbCat.catName AS Name1st, tbCat.ads AS Ads1st, tbscat.sCatID AS ID2nd, tbscat.scatName AS Name2nd, tbscat.ads AS Ads2nd, tb3ID.sCatID AS ID3rd, tb3ID.scatName AS Name3rd, tb3ID.ads AS Ads3rd " strsql = strsql & "FROM " & tablPfx & "Cat AS tbCat " strsql = strsql & "LEFT JOIN (" & tablPfx & "Scat AS tbscat LEFT JOIN " & tablPfx & "Scat AS tb3ID ON tb3ID.catID = tbscat.scatID) " strsql = strsql & "ON tbscat.catID = tbCat.catID " strsql = strsql & "ORDER BY tbCat.catName, tbscat.scatName, tb3ID.scatName;" End If catname = "" scatname = "" Set rsCat = objConn.Execute(strsql) Do while not rsCat.EOF currcatName = rsCat("Name1st") currscatName = rsCat("Name2nd") currcat3rdName = rsCat("Name3rd") If currcatName <> catName then catName = currcatName catID = rsCat("ID1st") If CStr(selected) = CStr(catID) then sel = "selected": Else: sel = Empty strCats = strCats & "" & vbcrLf End If If currscatName <> scatName then scatName = currscatName sCatID = rsCat("ID2nd") If CStr(selected) = catID & "|" & sCatID then sel = "selected": Else: sel = Empty strCats = strCats & "" & vbcrLf End If If Len(currcat3rdName) > 0 then cat3rdID = rsCat("ID3rd") If CStr(selected) = catID & "|" & sCatID & "|" & cat3rdID then sel = "selected": Else: sel = Empty strCats = strCats & "" & vbcrLf End If rsCat.MoveNext Loop rsCat.close strCats = "" & strCats buildALLCategories = "" End Function Function formatKeywords(keywords, kFormat, kTarget) Select Case kFormat Case 3 Select Case kTarget Case 1: formatKeywords = " subject LIKE '%" & keywords & "%'" Case 2: formatKeywords = " body LIKE '%" & keywords & "%'" Case 3: formatKeywords = " (body LIKE '%" & keywords & "%' OR subject LIKE '%" & keywords & "%')" End Select formatKeywords = "AND " & formatKeywords Case Else keywordsArray = Split(keywords) For I = 0 to UBound(keywordsArray) validkey = True If Len(keywordsArray(I)) > 2 then For each cword in commonWordsArray If keywordsArray(I) = cword then validkey = False Exit For End If Next Else: validkey = False End If If validkey then newkeywords = newkeywords & " " & keywordsArray(I) Next If Trim(newkeywords) = Empty then formatKeywords = Empty: Exit Function newkArray = Split(Trim(newkeywords)) Select Case kTarget Case 1, 2 If kTarget = 1 then adTarget = "subject": Else: adTarget = "body": End If For each r in newkArray If kFormat = 2 then formatKeywords = "AND " & adTarget & " LIKE '%" & r & "%' " & formatKeywords Elseif kFormat = 1 then formatKeywords = "OR " & adTarget & " LIKE '%" & r & "%' " & formatKeywords End If Next Case 3 For each r in newkArray If kFormat = 2 then formatKeywords = " AND (body LIKE '%" & r & "%' OR subject LIKE '%" & r & "%')" & formatKeywords Elseif kFormat = 1 then formatKeywords = " OR body LIKE '%" & r & "%' OR subject LIKE '%" & r & "%'" & formatKeywords End If Next End Select If kFormat = 1 then formatKeywords = Replace(formatKeywords, "OR ", "", 1, 1) If UBound(newkArray) > 0 Or kTarget = 3 then formatKeywords = "AND (" & formatKeywords & ") " Else: formatKeywords = "AND " & formatKeywords End If End If End Select End Function On Error Goto 0 %>