【发布时间】:2011-04-25 17:37:28
【问题描述】:
我正在尝试将嵌入在 html 中的 flash 文件部署到 google 应用引擎。 Flash(action script 2.0) 使用“post”方法发送主机名并通过 php 函数 gethostbyname() 获取其 IP 地址。 事实上,我知道 google app engine 不支持 php。 所以我尝试使用另一种方式将 ipPHP.php 部署在其他免费的网络服务器中,并且只在谷歌应用引擎中部署 flash 文件。 但它不起作用,我不知道为什么。 你能给我一个关于这个问题的提示吗?
-------------domaintoip.fla ---------
result_lv = new LoadVars();
result_lv.byname = _root.domainnm;
trace("Sending... " + result_lv.byname);
result_lv.onLoad = function (success)
{
if (success)
{
_root.ip = unescape(this.result);
trace("Return value from the PHP : " + unescape(this));
if(_root.ip.length==5){
_root.flag=1;
}
else{
var mystring=_root.ip;
arr=mystring.split(".");
_root.ipby1=arr[0];
_root.ipby2=arr[1];
_root.ipby3=arr[2];
if(arr[3].length==15)
{
_root.ipby4=arr[3].substr(0,3);
}
if(arr[3].length==14)
{
_root.ipby4=arr[3].substr(0,2);
}
if(arr[3].length==13)
{
_root.ipby4=arr[3].substr(0,1);
}
_root.flag=0;
}
}
else
{
trace("Cannot call the PHP file...");
_root.flag=1;
}
}
result_lv.sendAndLoad("http://anotherserver../ipPHP.php", result_lv, "POST");
------------- ipPHP.php ---------
<?php
$Var1 = $_POST['byname'];
$rtnValue = gethostbyname(trim($Var1));
if(ip2long($rtnValue) == -1 || $rtnValue == $Var1 ) {
$rtnValue =0;
echo (result=$rtnValue");
}
else {
echo("result=$rtnValue");
}
?>
【问题讨论】:
-
为什么需要获取客户端的IP地址?
标签: php google-app-engine