Basic surfer information variables (from HTTP_SERVER_VARS)
<?php
$surfer_info[ip]=$HTTP_SERVER_VARS["REMOTE_ADDR"];
// $surfer_info[real_ip] will only contain something if the surfer used a transparent proxy
$surfer_info[real_ip]=$HTTP_SERVER_VARS["X_FORWARDED_FOR"];
$surfer_info[port]=$HTTP_SERVER_VARS["REMOTE_PORT"];
$surfer_info[browser_lang]=$HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"];
$surfer_info[user_agent]=$HTTP_SERVER_VARS["HTTP_USER_AGENT"];
$surfer_info[request_path]=$HTTP_SERVER_VARS["PATH_INFO"];
$surfer_info[request_query]=$HTTP_SERVER_VARS["QUERY_STRING"];
$surfer_info[request_method]=$HTTP_SERVER_VARS["REQUEST_METHOD"];
$surfer_info[http_referrer]=$HTTP_SERVER_VARS["HTTP_REFERER"];
?>
stalemate
202.***.***.***
I tried these codes in my site but to my surprise they didn't work. Plz help me.
stalemate;70:
I tried these codes in my site but to my surprise they didn't work. Plz help me.
It is just a row of variables, - it is up to you to decide how they are useful to your script and how to integrate them.
But if you want to see something happening any way, add
print_r($surfer_info);
to the bottom of the script (but before the closing
?>). Doing so will cause the script to show you what information the variables picked up.
stalemate
202.***.***.***
Good idea.This is working very well for me.It was so simple.No real coding.Its really showing the information for my likings.
penguinmama
12.***.***.***
Very cool! One can also stick phpinfo() into the bottom of the file (temporarily, and only for one's self, preferably!) to see ALL the variables.
Darkneoboi
68.***.***.***
One question, what does the print_r() command do? I know the print() command but not that one.
Darkneoboi;164:
One question, what does the print_r() command do? I know the print() command but not that one.
print_r() visualizes the given array in a neat format which supports multiple dimensions.
Example output:
Array
(
[phpcentral_com] => Array
(
[users] => Array
(
[0] => Bill
[1] => Darkneboi
[2] => stalemate
[3] => penguinmama
[4] => etc
[5] => etc
)
[facts] => Array
(
[0] => PHPCentral.com saves cats from trees.
[1] => Chuck Norris approves of PHPCentral.com.
)
)
)
Welcome to the forum, by the way!
penguinmama
12.***.***.***
Oh, that's nifty! I'll have to fiddle with that print_r (and arrays!) a little more!
Dismounted
59.***.***.***
Wow, print_r is very neat! I can't believe I never knew about it.
Darkneoboi
68.***.***.***
Yeah, it is pretty cool, i have know PHP for a while but this is the first time i have encountered that command. I may try to use it more often.
the variable "$HTTP_SERVER_VARS" did not work for me. I had to use "$_SERVER"
<?php
$surfer_info[ip]=$_SERVER["REMOTE_ADDR"];
// $surfer_info[real_ip] will only contain something if the surfer used a transparent proxy
$surfer_info[real_ip]=$_SERVER["X_FORWARDED_FOR"];
$surfer_info[port]=$_SERVER["REMOTE_PORT"];
$surfer_info[browser_lang]=$_SERVER["HTTP_ACCEPT_LANGUAGE"];
$surfer_info[user_agent]=$_SERVER["HTTP_USER_AGENT"];
$surfer_info[request_path]=$_SERVER["PATH_INFO"];
$surfer_info[request_query]=$_SERVER["QUERY_STRING"];
$surfer_info[request_method]=$_SERVER["REQUEST_METHOD"];
$surfer_info[http_referrer]=$_SERVER["HTTP_REFERER"];
print_r($surfer_info);
?>