views:

4868

answers:

8

Is it possible to get client IP address through Flash (swf) Action Script 3 and then pass it to php file to store it in database?

A: 

As I know YES!! But I am wondering about the reason of doing that. You can just use PHP for get the IP Address..

EDIT : Had a research.. Changing my answer. I think there is less possibility to do it with Flash..

Chathuranga Chandrasekara
I have a screen which whole thing must in flash, hence i must use flash to get the ip and then pass it to php. Since you say YES, can show me how to do that?
roa3
(Dissappointed). I did research. So far, do not have positive results..
roa3
+1  A: 

No, the client IP address is not available in ActionScript 3. The recommended approach is to have it reflected by server-side code.

See http://www.actionscript.org/forums/showthread.php3?s=&threadid=20123

Chris W. Rea
+3  A: 

No need to do it in flash, just do it on your server in php "$ip=@$REMOTE_ADDR;"

Alex Mac
A: 

Like the above answer, use PHP (or other scripting language) to pass the IP address as a param value into your flash movie and you'll have it available at runtime.

Another option is to use the ExternalInterface to make a call to a server-side PHP script or something of the like to return the IP address.

jerebear
A: 

As Alex says, pass it in via flashvars, but that PHP should really be:

$_SERVER['REMOTE_ADDR']

The json extension is handy for wrIting out flash vars, e.g. for passing to swfobject:

var flashvars = { IP : <?=json_encode($_SERVER['REMOTE_ADDR'])?> };
Tim Whitlock
+1  A: 

function GetUserIP() { var js="function get_userIP(){return java.net.InetAddress.getLocalHost().getHostAddress();}"; var userIPInfo:String=ExternalInterface.call(js).toString(); return userIPInfo; }

A: 

well i think im in the same situation, where i want to restrict my swf to run only in a specific IP. if i get the ip in php and pass it as flash vars then it would not protect my swf. in that case, we really have to get IP using actionscript alone.

meraldo
A: 

It is possible to grab the real IP address via Flash Actionscript.

You'll believe it after you visited this site (click on Flash tab):

http://AnalyzeMy.net

Proxylist