zl程序教程

您现在的位置是:首页 >  后端

当前栏目

利用php来自动调用不同服务器上的flash

PHP服务器自动 利用 调用 不同 Flash
2023-06-13 09:13:43 时间
近期,学校校庆,做了一个flash动画的网站,但体积比较庞大。如果上传到学校的服务器,从公众信息网访问就比较慢,而放到教育网外从校园网访问就比较不流畅,还好,我们有php,解决了这一问题!
   代码如下:
<html>
<head>
<title>庆校庆</title>
</head>
<bodybgcolor="#f2d560"topmargin=0leftmargin=0>
<?php
$remote_addr=getenv("REMOTE_ADDR");  
$testip="202.117.6";
$realip=substr($remote_addr,0,9);
if($testip==$realip){
$url="http://202.117.68.12/~flyhawk/cau.swf";
$word="长大校园网";
}else{
$url="http://webnow.oso.com.cn/cau.swf";
$word="公众信息网";
}
?>
<scriptlanguage="JavaScript">
functionInfo()
{

if(!confirm("欢迎光临长安校庆专题网"+"\n\n您的IP:<?echo$remote_addr?>\n\n您来自<?echo$word?>\n\n请稍候.....\n\n正在引导网页以提供最快的网络传输"+"\n\n\n请按确定进入本页浏览\n"+"\n按取消将离开本站\n"+"\n\n\n【我爱长安大学】"))

history.go(-1);return""

}

document.writeln(Info())</script>

</SCRIPT>

<embedsrc="<?echo$url?>"quality=highpluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"type="application/x-shockwave-flash"width="100%"height="98%">
</embed>  

</body>
</html>
简单提示:
$remote_addr=getenv("REMOTE_ADDR");是获得客户机的ip.
$realip=substr($remote_addr,0,9);获得ip的前9个字节,因为我们学校的ip地址是202.117.6*.*,所以,通过判断$realip与$testip的值的不同来确定$url的值,即flash的文件位置。
   本程序的演示请见:http://www.caunet.com