Get IP address using Action Script?

一世执手 提交于 2019-12-05 07:51:29

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

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

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

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..

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.

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'])?> };

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

Despite what most are saying - there is a difference somehow. I used to run a rather large forum (200k+) and most banned members were eventually caught again once they entered our chat (Flash). While the VB software (using php) would give one IP (Usually through a Proxy/Network) , the Chat (Flash) would in fact give us their True IP. Don't ask me to explain it - I barely get by with PHP myself ...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!