%Option Explicit%> <% '****************************************************************** ' Version 5.00 ' filtering two sort fields and no display fields ' Main program logic for displaying products. ' actual formatting is done in shopproductformat or shopproductformat_withhtml ' May 20, 2003 '****************************************************************** dim search Dim dbc Dim PRODUCTNAME, CATALOGID Dim ProductFields ' fields being displayed in order Dim ProductCaptions ' Product column captions Dim ProductFieldCount ' count of fields Dim ProductSelect Dim Colcount, totalcolcount dim ProductMaxColumns, Productwithhtml ' Mod dim yfieldnames,Sortnames, yfieldcount, sortcount dim displayfields, displayfieldcount, displaycaptions dim sortcaptions, yfieldcaptions dim sortupdownnames(3),sortupdownvalues(3), sortupdowncount dim sortfield, sortupdown, selectfield, i dim sortfield2, sortupdown2 dim rc ' end mod '***************************************************** ' open database and see if we are doing with html or not ' See if this is a next page request or first time '****************************************************** shopopendatabase dbc ProductmaxColumns=Getconfig("xproductcolumns") ProductwithHtml=Getconfig("xProductwithhtml") If productmaxcolumns="" then productmaxcolumns=1 end if productmaxcolumns=clng(productmaxcolumns) If Productmaxcolumns>1 then Productwithhtml="Yes" end if ProductSelect=getconfig("xProductSelect") SetSess "CurrentUrl","shopdisplayproducts.asp" mypage=request.querystring("page") mypagesize=getconfig("xProductsPerPage") If getconfig("xproductfiltering")="Yes" then GetFilteringfields SetupFiltering end if ' If there is no page, then we must generate sql otherwise sqlis in Session(sqlQuery) if mypage= "" then mypage=1 ' first time through ProcessFirst ' get input variables CreateSql ' generate sql else sql=GetSess("sqlquery") ' on recursive calls we stored sql in sessikon variable Category=GetSess("Category") ' see what previous one was Subcat=getsess("Subcat") cat_id=getsess("Cat_id") ' GetFilteringfields end if setsess "pagenumber",mypage ' for languae switch ShopPageHeader ' normal page header DisplayProducts ' display products ShopPageTrailer ' normal trailer shopclosedatabase dbc ' Process first time Sub ProcessFirst() CAT_ID = Request("id") ' category id If not isnumeric(CAT_ID) then CAT_ID="" ' hacker fix CATEGORY = Request("cat") ' category name CleanseMessage category, rc if rc> 0 then category="" ' cannot trust it hacker may be trying someting end if SUBCAT=Request("subcat") ' subcategory id PRODUCTNAME=Request("PRODUCT") ' product name CleanseMessage productname, rc if rc>0 then productname="" end if CATALOGID=Request("CATALOGID") ' catalogid SetSess "Category",CATEGORY 'remember category see what previous one was setsess "Subcat",subcat setsess "cat_id",cat_id end sub ' '******************************************************* ' product loop logic is here ' Put out headers, category image, open recordset ' SQL already exists so we simply loop through the products '******************************************************** Sub DisplayProducts() Dim header Dim recordcount dim words dim wordcount dim i dim msg dim rc, url, stayonpage dim objrs1 Header="" If category <> "" Then header = header & Category else header= header & getlang("langProduct01") End If response.write prodheaderfont & header & prodheaderfontend ShowCategoryImage 'debugwrite sql ShopOpenRecordSet SQL,objRS1, mypagesize, mypage if objRS1.eof then objRS1.Close set objRS1=nothing shopwriteerror getlang("langProductSearch") exit sub end if recordcount=0 response.write "
" & smallinfofont & getlang("langCommonPage") & " " & mypage & getlang("langCommonOf") & " " & maxpages & smallinfoend If ProductSelect="Yes" then Response.Write("
" end if response.write("") end if if getconfig("xproductpagingnextprevious")="Yes" then PageNavBarNext SQL else PageNavBar SQL end if objRS1.Close set objRS1=nothing If getconfig("xproductfiltering")="Yes" then DisplayFiltering end if end sub '****************************** ' Sub ShowCategoryImage ' ===================== ' If DisplayCategoryImages is set to Yes ' Displays the CatImage if there are not subcategories ' Display file associates with actegory ' Displays the SubCatImage if there is '****************************** Sub ShowCategoryImage Dim ImageFileName, description, i Dim rs Dim query imagefilename="" If cat_id="" then exit sub If getconfig("xDisplayCategoryImages")="Yes" or getconfig("xdisplaycategoryfiles")="Yes" Then query = "select * from categories where categoryid = " & cat_id set rs = dbc.execute(query) If not rs.EOF Then imagefilename = rs("catimage") description=rs("catextra") if isnull(imagefilename) then imagefilename="" end if if isnull(description) then description="" end if end if closerecordset rs else exit sub end if If getconfig("xDisplayCategoryImages")="Yes" and imagefilename<>"" then response.write "