| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Seeing $_SERVER variables in home.php | |||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() I successfully include the following in via home.tpl in home.php:
print $_SERVER['REFERER']; print $_SERVER['REQUEST_URI']; print $_SERVER['REMOTE_ADDR']; print "hello!!\n<br>"; But this only prints "hello!!" and does not print the $_SERVER variables. This is in 4.0.13, but I think it applies to all versions? Can you point me in the right direction? Thanks, -Michael
__________________
X-Cart 4.1.9 PHP 4.4.1 MySQL 4.0.27 Linux Apache |
|||||||
#2
|
|||||||||
|
|||||||||
![]() Try the $HTTP_SERVER_VARS variable.
__________________
Eugene Kaznacheev, Evangelist/Product Manager at Ecwid: http://www.ecwid.com/ (since Sept 2009) ex-Head of X-Cart Tech Support Department ex- X-Cart Hosting Manager - X-Cart hosting ex-X-Cart Technical Support Engineer Note: For the official guaranteed tech support services please turn to the Customers HelpDesk. |
|||||||||
#3
|
|||||||
|
|||||||
![]() Quote:
Thanks Ene, but it didn't work. I tried print $HTTP_SERVER_VARS["REMOTE_ADDR"]; print $HTTP_SERVER_VARS["HTTP_REFERER"]; print $HTTP_SERVER_VARS["HTTP_USER_AGENT"]; print "hello again\n<br>"; and still got... "hello again" Is X-cart doing something strange here?
__________________
X-Cart 4.1.9 PHP 4.4.1 MySQL 4.0.27 Linux Apache |
|||||||
#4
|
|||||||
|
|||||||
![]() X-Cart definitely does something strange for HTTP_REFERER and stuffs it into $HTTP_REFERER then unsetting $HTTP_SERVER_VARS["HTTP_REFERER"]. This is done in prepare.php and checks to see if its loaded in an iframe and uses iframe_referer instead of HTTP_REFERER if so. REMOTE_ADDR is stuffed into $REMOTE_ADDR. Its also stuffed into $CLIENT_IP if not accessed through a proxy and tries to get the real client IP if accessed through a proxy. X-Cart also stuffs all of the elements of $HTTP_SERVER_VARS into individual variables with the same name as the element key (e.g. $HTTP_SERVER_VARS['HTTP_USER_AGENT'] is stuffed into $HTTP_USER_AGENT). You can use either (except yout must use $HTTP_REFERER) but using the individual variables will give you the advantage of any special logic X-Cart applies as in the above variables.
But your real problem is probably not declaring $HTTP_SERVER_VARS as global. Try adding this before your print statements. global $HTTP_SERVER_VARS; Or use the individual variable names if you want to use them.
__________________
Manuka Bay Company X-Cart Version 4.0.19 [Linux] UGG Boots and other fine sheepskin products http://www.snowriver.com |
|||||||
#5
|
|||||||
|
|||||||
![]() Declaring it global did the trick (in both cases). Thank you Ralph!
It seems that by the time my code snippet is loaded (via home.tpl) the referrer is always my own domain. I'm trying to capture the 'original' referrer (search engine, affiliate, etc) on the first entry page entry and, ideally, make it available as a session variable throughout the system. Any tricks that you know of to achieve this? -Michael
__________________
X-Cart 4.1.9 PHP 4.4.1 MySQL 4.0.27 Linux Apache |
|||||||
#6
|
|||||||
|
|||||||
![]() Try this:
Code:
__________________
Manuka Bay Company X-Cart Version 4.0.19 [Linux] UGG Boots and other fine sheepskin products http://www.snowriver.com |
|||||||
#7
|
|||||||
|
|||||||
![]() Quote:
Ahhh. You just beat me to it!!! ![]() I ended up using the cookie set in referer.php: $HTTP_COOKIE_VARS["RefererCookie"]; Now to figure how to get the original REQUEST. I'll post later. -Michael
__________________
X-Cart 4.1.9 PHP 4.4.1 MySQL 4.0.27 Linux Apache |
|||||||
#8
|
|||||||
|
|||||||
![]() OK, to use access the original Request URI via a cookie, I modified referer.php by adding the following code at the end. It worked for my 4.0.13 edition. Hope it helps someone.
Code:
-Michael
__________________
X-Cart 4.1.9 PHP 4.4.1 MySQL 4.0.27 Linux Apache |
|||||||
|
|||
X-Cart forums © 2001-2020
|