detect WAN IP in webclient

HI,

we need to detect in a Servoy webclient (3.5.10) the WAN IP-address.
In a smart client this is not that difficult, we use a php script on an other server, which returns the client WAN-IP
but in a webclient this is not working, it returns (ofcourse) the WAN-IP of the servoy-server, because the webclient is really a client ON the server.

Anyone have any ideas, on how to do this in a servoy web-client?

You need to use the web client utils plugin to run the JavaScript for browser detection client side

http://code.google.com/p/web-client-utils/

yes I saw that, but does that plugin also work in servoy 3.5.10?

I believe it does work in 3.5 as well, but you can check with Sean Devlin if you want to be sure…or just give it a try. Also, if it doesn’t work, you can always do it manually. Just make a Global, and set the global with some HTML. Place the global 1x1 pixel on your form, display type HTML_AREA, and not editable. Lets call that one “g_custom_html”. Then just hide it behind something.
Then create a global Servoy method to handle the callback, lets call it “servoyCallbackScript”

The html code to set in the global would be something like…

<html>
<head>
<script type=text/javascript>
function browserDetect(){
   var elem = document.getElementById('jsBridge');
   if (typeof elem.onclick == "function") {
       elem.onclick.apply(elem);
   }
   //old stuff not browser compat
   //document.getElementById(’jsBridge').onClick();
}
</script>
</head>
<body onLoad="browserDetect()">
<a href=\"javascript:globals.servoyCallbackScript(navigator.appName)\" id=\"jsBridge\">Hidden</a>
</html>

This is partially from memory, so it may need some tweaking. Basically you have a link in the html with an ID set. The link runs a Servoy method. On show, when it renders, Wicket converts the link to make it run the real Servoy method. Then with the body onLoad, it runs the javascript, which gets the link element and calls the onClick, simulating like as if the user clicked the link. Like i said, it may need a few tweaks.

Scott, MANY thanks!! :D
I did’nt knew this,

this will get me going!

Why don’t you just use application.getIPAddress()?

Paul

Paul, we are in a webclient??

so this function returns the ip addres of the server right??
thats not what we want, want need the WAN IP of the client, that has the webclient open.!

we need this for european rules for opt-in opt-out of mailinglists.

Have you tried? It works! It returns the ip of the client!

Paul

oke Paul thanks!

I have tested it, and it wasn’t clear for me.
with the function: application.getIPAddress()

a smartClient returns it’s own LAN IP-address
and indeed
a webclient returns it’s WAN IP-address