<% const DefaultCleanupInterval=1 '****************************************************************************** ' VP-ASP 6.50 ' Cleanup any sessionfiles ' Clean up Wish lists ' Sept 12, 2004 line 63 should be shopclosedatabase '***************************************************************************** shopcheckadmin "" dim cleanupinterval dim debugflag If getsess("cleanupdone")<>"" then ProcessContinue end if debugflag=getconfig("xdebug") SessionDeletefiles CleanupWishlist ProcessContinue Sub ProcessContinue Setsess "Cleanupdone","Yes" responseredirect "shopadmin1.asp" end sub '************************************************************************ ' With Database sessions we need to cleanup records ' look for all session not reference in session interval in hours '************************************************************************ sub Sessiondeletefiles dim deleteids, conn, rs, sql, sessionnow, mytime dim diff, hours 'VP-ASP 6.50 - advanced session handling 'If xusefilesession<>"Yes" then exit sub If xsavesession<>"Yes" then exit sub on error resume next mytime=now() deleteids="" 'VP-ASP 6.50 - advanced session handling 'shopopendatabase conn cookieopendatabase conn hours=getconfig("xsessioncleanupinterval") If not isnumeric(hours) then exit sub hours=clng(hours) sql="select * from sitesessions order by sessiondate desc" set rs=conn.execute(sql) do while not rs.eof sessionnow=rs("sessionnow") sessionid=rs("id") diff=datediff("h",sessionnow, mytime) ' Debugwrite "hours=" & hours & "diff=" & diff & " mytime=" & mytime & " record=" & sessionnow If diff>hours then if deleteids<>"" then deleteids=deleteids & "," end if ' debugwrite "adding deleteid " & sessionid deleteids=deleteids & sessionid end if rs.movenext loop closerecordset rs if deleteids<>"" then sql="delete from sitesessions where id in (" & deleteids & ")" conn.execute sql end if shopclosedatabase conn End sub Function MakeDate(byval filestring) MakeDate = date() End Function '*********************************************************************** ' delete items in wish list after so many days ' Set value in xwishlistdays '*********************************************************************** Sub Cleanupwishlist If getconfig("Xwishlist")<>"Yes" then exit sub If getconfig("Xwishlistdays")="" then exit sub dim days, diff, sql, dbc days=getconfig("xwishlistdays") If not isnumeric(days) then exit sub on error resume next days=-clng(days) olddate=dateadd("d",days,date()) olddate=datenormalize(Olddate) olddate=datedelimit(olddate) sql="delete from savedcarts where savedate<=" & olddate If getconfig("Xdebug")="Yes" then debugwrite sql end if shopopendatabase dbc dbc.execute(sql) shopclosedatabase dbc end sub '**************************************************************** ' get real address of staging directory ' May be disk addrsss or relative address ' result is in stagingdir '******************************************************************* Sub GetstagingDirectory (stagingdirectory) dim drivechar, fso, stagingdir stagingdirectory=xsessionfolder drivechar=mid(stagingdirectory,2,1) If drivechar=":" then stagingdir=stagingdirectory else stagingdir = Server.Mappath(stagingdirectory) end if stagingdirectory=stagingdir end sub %>