File: D:/web/expressmusic/inc-pages.asp
<%
' called for every request, calls the appropriate routine, page holds the page name, defaults to products'
' (SS,17/4/12) modified to allow pages directly from sitedetails table without needing separate templates for customer info, about, how to order, links etc.
' (SS,22/5/12) added reviews
' (SS,17/1/13) added hook to CustomShowPageContent for content from third party SEO company
' (SS,2/9/15) improved CustomPagesEnabled and CustomPageExists so CustomPageExists function doesn't need to exist in customutils.asp, only needs to exist if CustomPagesEnabled
' (SS,12/12/18) Added HTMLEncode to render of page name (FPageName) chosen to prevent XSS
' (SS,9/11/23) added FPageName = "sellyourguitar" for new template file (inc-template-upload.asp)
Dim FPageName, FPageHandled
FPageName = LCase(Request.QueryString("page"))
FPageHandled = True ' (SS,2/9/15)
' (SS,1/7/11) added Request.QueryString("search") <> ""
' (SS,14/5/15) added Request.QueryString("grp") <> ""
' (SS,7/10/15) on Google Search Console, discovered duplicates being mentioned, this was happening for products2.asp, a page that doesn't exist, even products99.asp, only if a querystring
' parameter precedes the code= e.g. ?name=test&code=1, or ?a=b&code=1,
' It was because IIS page adds original URL to added to the query string passed on to this page, from which the code gets picked up as a separate query string value when another querystring precedes it
' debug code: If FPageName = "404" Then Response.Write "##QUERY_STRING: " & Request.ServerVariables("QUERY_STRING") & "##<br>"
' e.g. 1 ##QUERY_STRING: page=404&404;http://www.expressmusicstore.co.uk:80/products2.asp?a=b&code=208536##
' e.g. 2 ##QUERY_STRING: page=404&404;http://www.expressmusicstore.co.uk:80/products99.asp?n=2&code=208536##
' e.g. 3 ##QUERY_STRING: page=404&404;http://www.expressmusicstore.co.uk:80/products2.asp?code=99097&name=123##
' discovered a bug below which allowed it, missing brackets after the And, which I now added
If FPageName = "products" Or (FPageName = "" And (Request.QueryString("cmd") <> "" Or Request.QueryString("code") <> "" Or Request.QueryString("cat") <> "" Or Request.QueryString("grp") <> "" Or Request.QueryString("search") <> "")) Then
ShowPage_products
ElseIf FPageName = "contact" Then
DoContactForm
' (SS,22/5/12)
' (SS,26/2/20) renmoved old reviews page (as requested by them via email)
'ElseIf FPageName = "reviews" Then
'DoReviewsPage
ElseIf FPageName = "account" Then
DoAccount ' (SS,22/6/09) replaced DoCreateAccountForm, DoAccountLogout, DoAccountLogin and DoForgotPassword with just DoAccount
ElseIf FPageName = "sellyourguitar" Then ' (SS,9/11/23) for EM
DoUploadForm
ElseIf FPageName = "" Or FPageName = "home" Then
ShowPage_home
ElseIf PageExists(FPageName) Then
ShowPageContent(FPageName)
' if IIS has redirect to 404 error page (i.e. page=404) then set the status to 404
If FPageName = "404" Then
Response.Status = "404 Not Found" ' tells the browser that page was not found
End If
' (SS,17/1/13) added CustomPage for integration with content from SEO company
' (SS,2/9/15) modified by removing And CustomPageExists which always gets called even if CustomPagesEnabled is False
ElseIf CustomPagesEnabled Then
If CustomPageExists(FPageName) Then
CustomShowPageContent(FPageName)
Else
FPageHandled = False
End If
Else
FPageHandled = False
End If
' page doesn't exist so return 404 error, and display page does not exist message
' (SS,2/9/15) moved here from above if
If Not FPageHandled Then
' (SS,12/12/18) Added HTMLEncode to FPageName to prevent XSS
Response.Write "<strong>Sorry, page '" & HTMLEncode(FPageName) & "' does not exist.</strong>"
Response.Status = "404 Not Found" ' tells the browser that page was not found
End If
%>