<edited to correct field name> <edited to update the code - 3/17/2003>
Several members have been reporting the problems related to HTTP_REFERER causing users visiting their sites being redirected to same page again and again. The reasons being some security softwares installed on their machines, which blocks the HTTP_REFERER or send some wrong information. Norton Anti Virus, Zone Alarm etc does this. Though there are settings for these software programs which can be changed by the users. However, many times users will not understand this problem and leave the site thinking the soite has problems. I encountered the same problem on my site when I tried to register from one of my computers.
To solve this problem I did the following:
inc_func_common.asp
Added the following function and procedure
function GetReferer()
Dim strReferer
strReferer = lcase(Request.ServerVariables("HTTP_REFERER"))
if strReferer = "" then
strReferer = "default.asp"
elseif (Left(strReferer, len(strForumURL)) <> lcase(strForumURL)) then
strReferer = "default.asp"
end if
GetReferer = strReferer
end function
sub CheckReferer(strMatchReferer, strRedirectTo)
dim strReferer
strReferer = lcase(Request.ServerVariables("HTTP_REFERER"))
if InStr(strReferer, lcase(strMatchReferer)) = 0 then
if Instr(lcase(Request.Form("REFERER_PATH")), lcase(strMatchReferer)) = 0 then
Response.Redirect(strRedirectTo)
Response.End
end if
end if
end sub
policy.asp
Modified Line 103 as shown below (in red) and added a new hidden field just below Line 103 highlighted in blue (strScriptname is defined and populated in inc_header.asp)
Just a few suggested changes, removed variables from first function and made the second function case insesitive
function GetReferer()
if Request.ServerVariables("HTTP_REFERER") = "" then
GetReferer = "default.asp"
else
GetReferer = Request.ServerVariables("HTTP_REFERER")
end if
end function
sub CheckReferer(strMatchReferer, strRedirectTo)
if InStr(lcase(Request.ServerVariables("HTTP_REFERER")), lcase(strMatchReferer)) = 0 then
if Instr(lcase(Request.Form("REFERER_PATH")), lcase(strMatchReferer)) = 0 then
Response.Redirect(strRedirectTo)
Response.End
end if
end if
end sub
I have seen some posts where it was mentioned that HTTP_REFERER returned some strange values. For that situation I modified the function GetReferer. Also applied the changes suggested by pweighill
<Edited: Posted the updated code in First Post. Removed from here to avoid confusion.>
Sorry, I should have been clearer: when I click "agree" on policy.asp, I go to an error page that tells me I need to read the agreement (BTW, I saw a typo in your menu tree: "Registeration Form")
Just tried it again, same thing. Of course, I could try disabling my NIS firewall to register, but that would defeat the purpose, right?
It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Prayer Of Forgiveness
"I forgive all living beings. May all living beings forgive me! I cherish the friendliness towards all and harbour enmity towards none." -- Aavashyaka Sutra(Translated)
First of all... i like what you guys created here, very nice!
I'm a starting member with programming knowledge next to none and just starting of with Snitz. I've downloaded a completely modified forum (the one from serverhacker) and installed it on my localhost with IIS5 on my WinXP machine, just to learn more about Snitz before starting up a real forum.
I stumbled upon the above problem since i have Zone Alarm pro installed. I already had privacy control disabled but i still couldnt log on an kept being redirected. I was glad to find this solution but after follow the directions of GauravBhabu i still couldt log on without having to disable ZA pro. Where did i go wrong?
I pasted the function and procedure into inc_func_common.asp I replaced the Request.ServerVariables("HTTP_REFERER") with GetRefer() in policy.asp and pasted this line "<input name=""REFERER_PATH"" type=""hidden"" value=""" & strScriptName & """>" & vbNewLine & _ under it. And at last i replaced: if InStr(Request.ServerVariables("HTTP_REFERER"), "policy.asp") = 0 then Response.Redirect("policy.asp") end if
with
Rem - Argument1 = Path to Match, Argument2 = Redirect Path Call CheckReferer("policy.asp", "default.asp")