Would like to add client IP plus more
Krait
Status: New User - Welcome
Joined: 26 Oct 2004
Posts: 1
Reply Quote
Firstly would like to thank you for a great set of scripts, working well on my dev server.
However I would like to include the client IP address in the informatioin I can do this using <!--#echo var="REMOTE_ADDR" --> on a standard web page but it doesnot work on php page from your computer script. Have modified .htaccess to allow html extensions for php.
Also as I am looking to develop this further as demonstration of good security practices I would like to know what other information can be gleened using simple scripts and or cookies.
Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 3905
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
Glad the script is useful to you.

To add IP recognition, do this:

Add the second line of code to the script right above the line:
:: Code ::
switch ( $which_test )
:: Code ::

// this is what you add, don't use the deprecated method you used
// or it might not work suddenly one day, this is the correct syntax:
$ip = $_SERVER["REMOTE_ADDR"];

Go the last switch statement:
:: Code ::
case 'math_number':// returns numerical version number, for number comparisons
         return $math_version_number;
         break;

and add this switch:
:: Code ::
case 'ip':
return $ip;
break;

right before the default
so it looks like this:
:: Code ::
case 'math_number':// returns numerical version number, for number comparisons
   return $math_version_number;
   break;
case 'ip':
return $ip;
break;
      default:
         break;


In the static variable declarations add $ip to the list of static variables.

Now when you want to check or verify IP addresses, you can simply do this, after the include of the browser detection script:

:: Code ::
$ip = browser_detection('ip');


then do what you need to do with the IP in terms of checking.

Personally, if I want to block an IP or IP range, I'm going to use mod_rewrite in .htaccess or apache httpd.conf, that's a better place to do that in general, since they user never even accesses the site code at all, blocked at the gate.

I'm not quite clear on what you're trying to do however, so it depends what your goal is when deciding which method(s) to use.
Back to top
Display posts from previous:   

All times are GMT - 8 Hours