PDA

View Full Version : SSI question (passing HTTP_REFERER info on)


Paul-Ecchi
07-11-2003, 11:19 PM
I have a perl counter that I call via SSI, and I want to pass the URL of the referring page to the counter, something like :

<!--#set var="refer" value="$ENV{HTTP_REFERER}" -->
<!--#include virtual="/cgi-bin/test.cgi?$refer"-->

Obviously this does not work, but I cannot find anything that will, does anyone have any ideas.

Thanks

ACJavascript
07-12-2003, 03:59 AM
Try this

<!--#include virtual="/cgi-bin/test.cgi?$ENV{HTTP_REFERER}"-->

Paul-Ecchi
07-12-2003, 02:14 PM
Thanks for your help, but I have tried that and it does not work. What the perl script receives is the text "{HTTP_REFERER}", which made sense to me when I first tried it, as I assumed it was ignoring the operation and just passing it as text, but looking at it now, if that is what it is doing I would have expected it to pass on "$ENV{HTTP_REFERER}" and not just "{HTTP_REFERER}", so I am assuming it thinks $ENV is a string (treating this as "$ENV={HTTP_REFERER}"). I also tried "#ENV{HTTP_REFERER}", and it appeared to pass nothing, so I tried the # with other EVs (DATE_LOCAL etc) and still it passed nothing. I have also tried a few other things, and I think it treats the # as a perl program would, and ignores anything after the #.

Any other ideas ?

ACJavascript
07-12-2003, 04:21 PM
Try this one

-----

<!--#exec cgi="text.cgi/$ENV{'HTTP-REFERER'}"-->

Paul-Ecchi
07-14-2003, 02:27 PM
Thanks again, but this still does not work, I get the "an error has occured..." message. If I remember correctly, "#exec cgi" cannot carry any information (I usually use "#exec cgi", the reason I am using "#include virtual" is that I could not convince "#exec cgi" to carry any info across and I had a nagging thought in the back of my mind that it is not supposed to).

SpeedFreak
07-24-2003, 08:45 PM
wait, nvm - thought this was PHP

Paul-Ecchi
07-24-2003, 11:07 PM
RE: "wait, nvm - thought this was PHP" nope, I am trying to run a perl script via ssi, PHP is the next board down in the index.

Pearl
07-28-2003, 07:21 PM
Okay I'll take a stab at this. I'm guessing the reason why you want to do this is because you can't get the true "Referer" pulled from your SSI call. If I can remember you're probably getting your *.cgi script as the referer if you tried hard coding in the HTTP_REFERER within your script. If I'm guessing right, and you want to use strictly server code not Javascript or anything else, try this:

In your test.cgi script (counter script) create a new variable like:
$myREFERER = '<!--#echo var="HTTP_REFERER"-->';
You should now get the true referer from your .shtml page(s) where you placed your include tags, without passing any additional info in your ssi call (?refer= ...). You can use $myREFERER now to write into your database or whichever you're using it for.

Depending on your script and server, I hope that works for you.