Jump to content
Server Maintenance This Week. ×

Any idea how to show IP address of user?


This topic is 2474 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello - I'm looking for a fuction or some way of showing the IP address of the logged-in user on a page of the database they are in. I'm using the current user name and date to show that, but need a solution for the IP address as well.

Any ideas? No built-in functions for "GetUserIPAddress" that I'm aware of.

Link to comment
Share on other sites

  • 1 month later...

I'm looking for this same functionalty in FileMaker Pro 9 Advanced. Filemaker keeps track of IWP client IP#s in it's access.log file (if logging is enabled). But I've been unable to find a way to capture that within the database itself. There are a couple get functions:

Get(HostIPAddress)

Get(SystemIPAddress)

Normally--when using FMP network sharing--the HostIPAddress returns the IP# of the host and SystemIPAddress returns the IP# of the client FMP computer.

But when used with IWP, the HostIPAddress always returns 127.0.0.1 and the SystemIPAddress returns the IP number of the computer hosting the databse via IWP.

So, does anyone know of a trick for obtaining the IWP client IP? I wouldn't think it would be a good idea to try to extract this info from the access.log file on the fly, but I might have to try...

Link to comment
Share on other sites

  • 2 weeks later...

Nice suggestion to use PHP. Unfortunately it doesn't work. :

Or at least I can't get it to work. The problem is that you can't parse the displayed content of a web viewer using a calculate field while in IWP. It does work when using FMP client, but then so does the [color:blue]Get(SystemIPAddress) command.

The problem is that web viewer appears to be evaluated by the client browser, while any calculation within the database is evaluated by the host.

So to test this, I created a php document (named "[color:green]getIP.php") on my FMP server that included the command:

[color:blue]

<?php echo $_SERVER['REMOTE_ADDR']; ?>

I then named the web viewer object "IPview" in FMP, and created a calculated field containing the expression:

[color:blue]GetLayoutObjectAttribute ( "IPview" ; "content" )

Now, when I view this database using a FMP client, it reports the correct system IP number of my client.

But, when I view the same database via IWP using a brower, the web viewer displays the correct IP number, but the calculated field returns:

[color:blue]"http://(server_address)/php/getIP.php"

which is of course, the URL encoded in the web viewer, not the ip number it's displaying. And that is a documented limitation of the GetLayoutObjectAttribute command when used with IWP.

So I can see the correct result displayed on my screen, I just can't capture it in any useful way.

Another approach I tried--which also didn't work--was to use 360Works ScriptMaster plug-in to place the result of the php command in a variable.

[color:red]EvaluateGroovy ( "new URL("http://(server_address)/php/getip.php").getText();" )

That does return an IP number, but it's the IP address of the FMP Server. Because that's where Groovyscript is actually running (on the server itself) when the user activates that script.

So back to square one... Any other ideas?

I wonder if there's some way to do this by using custom web publishing PHP commands withing IWP?

Link to comment
Share on other sites

  • 3 weeks later...

FYI- I made a bit of progress for anyone who's interested, by creating a PHP document that writes the client info to a related table. So it can gather the IP# and DNS name of the client and create a record in a table that's related to the record being viewed in IWP.

Here's a simple example:

A database named "ITEMS" is shared via IWP. Each record has a primary key named "Item_Key". I've created a layout named "Item_Layout" that's published via IWP. I also have a separate table named "ITEM_LOG" that is related to the main table via the "Item_Key" field. It has two other fields: "IP" & "Name" for tracking the IP number & DNS name of the computer viewing the record in IWP.

Next, I placed a web viewer on the "Item_Layout" that addresses a PHP file shared on my FMP Server. It uses a calculation to include the key as a GET parameter. So when a user creates a new record via IWP (say the Item_Key equals 1234), the web viewer URL ends up looking something like this:

http://fmpserver/item_log.php?item_key=1234

The actual php code in the file "item_log.php" looks like this:

<?php 

$key = $_GET['item_key'] ; 

$ip = $_SERVER['REMOTE_ADDR'] ; 

$name = GetHostByAddr($ip); 

define( 'FM_HOST', '127.0.0.1' ); 

define( 'FM_FILE', 'ITEMS' ); 

define( 'FM_USER', 'GUEST' ); 

define( 'FM_PASS', '' ); 

require_once ( 'FileMaker.php' ); 

$fm = new FileMaker(FM_FILE, FM_HOST, FM_USER, FM_PASS); 

$request = $fm->newAddCommand('Item_Layout'); 

$request->setField('Item_Key',$key); 

$request->setField('IP',$ip); 

$request->setField('Name',$name); 

$request->execute(); 

??>>  

The end result is that the "ITEM_LOG" table contains entries that track the IP# & name of whomever created the related "ITEM" record.

Now the next issue to deal with is controlling how often these entries are made, and whether they include any other log information. I'm thinking it might be possible to create a rollback log this way, but there's still a lot of experimenting to do...

Anyway, I thought this might be of interest to others.

Link to comment
Share on other sites

  • 9 years later...

I realize this thread is 9 years old, but since I still have my FM Pro 11 databases hosted via IWP, I find it relevant.  Hopefully someone informed will reply.

I host my databases with a third party FM Pro hosting service in the USA on a shared server.  Because it is a shared server, there are no tweaks or mods I can make to that server.  I am based in Japan, so we need our login page to be in Japanese, but the 3rd parting hosting service won't do that for us because everyone else on the same shared server would then have a Japanese login.  So what I've done is create a <form action> on a page in our website which uses HTTPS to send ID and PSW data to the FM Pro database login page.  So long as there are no errors, it works seamlessly.

The reason I am posting in this thread is because we have assigned ID's and PSW's to various dealers around Japan, but some of them are sharing their LOGIN/PSW with others, breaking our terms of agreement.  The problem is, we don't know who is doing this but we want to find out.  I want to match an IP with each login to gain a better idea of what is going on.  How can I accomplish this?

Thank you.

Link to comment
Share on other sites

This topic is 2474 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.