[FX.php List] Capturing IP for a choice calc

Vinnie P. Taranto vinniept at dso.ufl.edu
Wed Mar 1 09:40:51 MST 2006


This is the php I use. I did not write it but found it on the web.
 

<?php

/*

Gets the users ip address...Last Updated 7.13.04

Usage: Call the function

Return Type: IP

*/

$ip;

function getIP() {

if (getenv("HTTP_CLIENT_IP"))

$ip = getenv("HTTP_CLIENT_IP");

else if(getenv("HTTP_X_FORWARDED_FOR"))

$ip = getenv("HTTP_X_FORWARDED_FOR");

else if(getenv("REMOTE_ADDR"))

$ip = getenv("REMOTE_ADDR");

else

$ip = "UNKNOWN";

return $ip;

} 

?>

and I call this in a form by 

<input type="hidden" name="ipaddr" value="<?php /* gets ip */ echo getIP(); ?>">

 

hope this helps...

Vinnie Taranto
Technology Specialist & Database Engineer
Dean of Students Office
University of Florida
MAIN: (352) 392-1261
FAX: (352) 392-5566
TOLLFREE: (877) 9UF-DEAN
WEB: http://www.dso.ufl.edu
EMAIL: vinniept at dso.ufl.edu

________________________________

From: fx.php_list-bounces at mail.iviking.org on behalf of Peter Bates
Sent: Wed 3/1/2006 11:36 AM
To: andy at fmpug.com; FX.php Discussion List
Subject: Re: [FX.php List] Capturing IP for a choice calc



Thanks Andy and Dan,

This gives me the IP of my server, not the users IP. Is that the way 
it is supposed to be, or am I missing something?

Peter

On Mar 1, 2006, at 10:23 AM, Andy Gaunt wrote:

> You may also want to build an array of IP addresses, possibly from 
> a small
> table in FMPro or if a small number, you could just create an array 
> in a php
> file that you include in your page.
>
> Then you can query the IP (using the code below posted by Dan) and 
> see if it
> exists in the array. If it does, display the info, otherwise 
> display your
> message.
>
> Andy Gaunt
> T: 407.810.4722
> andy at fmpug.com
> http://www.fmpug.com
>
> Recipient of FileMaker's 2005 "Mad Dog" Public Relations Award
>
> For chapter locations, dates & times please visit the website at
> http://www.fmpug.com If you can make it to a meeting, please RSVP at
> http://www.fmpug.com/rsvp.php
>
> -----Original Message-----
> From: fx.php_list-bounces at mail.iviking.org
> [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of DC
> Sent: Wednesday, March 01, 2006 10:18 AM
> To: FX.php Discussion List
> Subject: Re: [FX.php List] Capturing IP for a choice calc
>
> check this for general information about PHP's predefined variables:
>
> http://us2.php.net/manual/en/
> reserved.variables.php#reserved.variables.serve
> r
>
> in short... you want to use this variable in PHP:
> <?php
> echo $_SERVER['REMOTE_ADDR'];
> ?>
>
> cheers,
> dan
>
> Peter Bates had written:
>> I'm building a solution that contains some copyrighted material on 
>> our
>> website. We have permission to share the copyrighted material with 
>> our
>> patrons while they are in one of our building, but not if they are
>> accessing the site from outside the building. I'm assuming that I 
>> need
>> to capture the requesting IP address before the data is displayed 
>> that
>> basically does the following:
>>
>> If IP = Our in-house IP range         <!-- We have our own in-house
>> network, inside and outside DNS servers, web server, etc. -->
>>    Show data from field "x"             <!-- This would be actually a
>> link that is stored in a FMP field. -->
>> Else
>>    Show "We're sorry, but due to copyright restrictions, this 
>> material
>> is only available in one of our library branches"   <!-- This 
>> would be
>> displayed in place of the data from  field "x" -->
>> End If
>>
>> As I am still floundering around using FileMaker Pro with FX.php, I
>> would deeply appreciate any help that could point me into the right
>> direction to code this.
>>
>> Mac OS X Server 10.4x, FileMaker Server Advanced 8x, PHP 4.x
>>
>> Thanks,
>> Peter
>>
>> Peter Bates
>> Microcomputer Network Specialist
>> Automated Services
>> St. Joseph County Public Library
>> 304 S. Main St.
>> South Bend, IN  46601
>> voice: (574) 282-4610
>> fax: (574) 282-4662
>> e-mail: p.bates at sjcpl.org <mailto:p.bates at sjcpl.org>
>> www:  http:/www.libraryforlife.org
>> library catalog:
>> http://www.libraryforlife.org/onlinecatalog/onlinecatalog.html
>>
>>
>>
>> ---------------------------------------------------------------------
>> ---
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list

_______________________________________________
FX.php_List mailing list
FX.php_List at mail.iviking.org
http://www.iviking.org/mailman/listinfo/fx.php_list


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 9825 bytes
Desc: not available
Url : http://www.iviking.org/pipermail/fx.php_list/attachments/20060301/8c9732a3/attachment.bin


More information about the FX.php_List mailing list