<% 'declaring variables, arrays Dim x Dim int Dim DisplayCount Dim ThisPage Dim ShortPageName Dim FSObject Dim GetTotals Dim WriteTotals Dim PageHits() Dim PageName() Dim PageEntry Dim RedirURL RedirURL=Request.QueryString("url") ThisPage = Request.QueryString("bID") 'Grabs page path/name from root 'ThisPage = lcase(ThisPage) 'changes URL to lower case DisplayCount = 0 'Will use later to determine if new page areaS=Request.QueryString("area") opcao=Request.QueryString("opcao") if areaS = empty then else RedirURL = RedirURL&"&area="&areaS end if if opcao <> empty then RedirURL = RedirURL&"&opcao="&opcao end if id_artigo = Request.QueryString("id_artigo") if id_artigo = empty then else RedirURL = RedirURL&"&id_artigo="&id_artigo end if tipo = Request.QueryString("tipo") if tipo = empty then else RedirURL = RedirURL&"&tipo="&tipo end if raca = Request.QueryString("raca") if raca = empty then else RedirURL = RedirURL&"&raca="&raca end if id_animal = Request.QueryString("id_animal") if id_animal = empty then else RedirURL = RedirURL&"&id_animal="&id_animal end if idProduto = Request.QueryString("idProduto") if idProduto = empty then else RedirURL = RedirURL&"&idProduto="&idProduto end if idPatrocinador = Request.QueryString("idPatrocinador") if idPatrocinador = empty then else RedirURL = RedirURL&"&idPatrocinador="&idPatrocinador end if 'Open a FileSystemObject and fetch data from the text file containing our page counts Set FSObject = CreateObject("Scripting.FileSystemObject") 'True creates file if none exists dim caminho caminho = "e:\home\beefpoint\dados\BannerTotals.txt" Set GetTotals = FSObject.OpenTextFile(caminho,1,True,0) 'Now read each line in our text file and load the data into the PageName and PageHits arrays x=0 While Not GetTotals.AtEndOfStream 'Loop until last line ReDim preserve PageName(x) 'Append PageName array PageName(x) = GetTotals.ReadLine 'Put first named page into PageName array If PageName(x) = ThisPage Then 'Check to see if this page name is current page ReDim preserve PageHits(x) 'Append PageHit array PageHits(x) = GetTotals.ReadLine + 1 'If current page, add 1 to total and put into PageHits array DisplayCount = PageHits(x) 'DisplayCount now contains this page's counter total x = x + 1 'Increment the index number for our arrays Else ReDim preserve PageHits(x) 'If this page is NOT the current page... PageHits(x) = GetTotals.ReadLine 'we still load it into our array, but do not adjust total x = x + 1 'Increment the index number for our arrays End If Wend 'Loop through rest of PageTotals.txt GetTotals.Close 'Clean up Set GetTotals = Nothing 'Routine for new site or newly added pages If x = 0 then '.txt file empty...1st site hit Redim preserve PageName(x) 'Create PageName array item and, PageName(x) = ThisPage 'Array item = this Page's Name. Redim preserve PageHits(x) 'Create PageHit array item PageHits(x) = 1 'Set page's hit total to 1 DisplayCount = 1 'Count to be displayed on page elseif DisplayCount = 0 then 'Or if this page is newly added x = x + 1 'Bump up the array index ReDim preserve PageHits(x) 'Create PageHits array item PageHits(x) = 1 'Set new page's hit total to 1 DisplayCount = 1 'Count to be displayed on page ReDim Preserve PageName(x) 'Create PageName array item and, PageName(x) = ThisPage 'Array item = this Page's name. End If 'Now that we have our arrays loaded, we write a "new" PageTotals.txt file Set WriteTotals = FSObject.CreateTextFile(caminho) x = 0 'Reset our array index to 0 For Each PageEntry In PageName 'Looping through our PageName array WriteTotals.WriteLine PageName(x) 'Write the PageName to the text file WriteTotals.WriteLine PageHits(x) 'Next line is the page's hits total x = x + 1 'Increment our array index number Next WriteTotals.Close 'Clean up Set WriteTotals = Nothing Set FSObject = Nothing Response.Redirect RedirURL %>