首页 > 编程技术 > php

php 获取ip真实地址

发布时间:2016-11-25 15:59

<?php
function get_ip_place(){
$ip=file_get_contents("http://fw.qq.com/ipaddress");

$ip=str_replace('"',' ',$ip);

$ip2=explode("(",$ip);

$a=substr($ip2[1],0,-2);

$b=explode(",",$a);

return $b;
}


$ip=get_ip_place();


print_r($ip);
?>

<?php
function BigEndian2Int($byte_word, $signed = false) {
$int_value = 0;
$byte_wordlen = strlen($byte_word);
for ($i = 0; $i < $byte_wordlen; $i++) {
$int_value += ord($byte_word{$i}) * pow(256, ($byte_wordlen - 1 - $i));
}
if ($signed) {
$sign_mask_bit = 0x80 << (8 * ($byte_wordlen - 1));
if ($int_value & $sign_mask_bit) {
$int_value = 0 - ($int_value & ($sign_mask_bit - 1));
}
}
return $int_value;
}
function getTime($name){
if(!file_exists($name)){
echo "文件不存在";exit;
}
$flv_data_length=filesize($name);
$fp = @fopen($name, 'rb');
$flv_header = fread($fp, 5);
fseek($fp, 5, SEEK_SET);
$frame_size_data_length =BigEndian2Int(fread($fp, 4));
$flv_header_frame_length = 9;
if ($frame_size_data_length > $flv_header_frame_length) {
fseek($fp, $frame_size_data_length - $flv_header_frame_length, SEEK_CUR);
}
$duration = 0;
while ((ftell($fp) + 1) < $flv_data_length) {
$this_tag_header = fread($fp, 16);
$data_length = BigEndian2Int(substr($this_tag_header, 5, 3));
$timestamp = BigEndian2Int(substr($this_tag_header, 8, 3));
$next_offset = ftell($fp) - 1 + $data_length;
if ($timestamp > $duration) {
$duration = $timestamp;
}
fseek($fp, $next_offset, SEEK_SET);
}
fclose($fp);
return $duration;
}
if($_GET['submit'])
{
echo date('i分s秒',getTime($_GET['filepath'])/1000);
}
?>

<form action="" method="get">
<input type="text" size="40" value="" name="filepath">
<input type="submit" value="提交" name="submit">
</form>

<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript"" width=100% src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
<script type="text/javascript">
        function send_local(){
                var my_html=$("#test").html();
                $.ajax({
                        type:"POST",
                        url:"http://localhost/mycenter/test.php",
                        data:{my_html:my_html},
                        success:function(){alert("send ok")}
                });
        }
</script>
</head>
<body>
        <div id="test">test data</div>
        <div>
                <button onclick="send_local();">传到本地php</button>
        </div>
</body>
</html>

[/code]test.php 代码如下:[code]
<?php
        $my_html=$_POST['my_html'];
        ("test.txt",$my_html);
?>

PHP has encountered an Access Violation at 7C94BD02

php for windows的bug
参考:

第一种可能:

去掉 php中 eaccelerator 的扩展
这样做能够解决您的问题,不过可能会加重系统负担
因为eaccelerator主要是为了节省系统资源的东西

具体做法是找到php.ini
如果是我帮您配置的,一般在c:/php/php.ini或者 c:/winnt/php.ini 或者c:/windows/php.ini

去掉

zend_extension_ts="C:phpextensionseaccelerator_win_xxx.dll"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="c:temp"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

ea主要是在unix环境下开发的,但是作者忽略到windows实际上不像u主机那样,是没有u主机的那种内存共享机制的
这个bug已经提交给他们了,希望0.9.5能够解决

当然,如果您的机器这个问题不严重,建议还是保留,ea是一块非常优秀的Php缓存+加速软件
配合zo使用,将会降低系统负担 50%-80%左右,提高负载能力、速度和效率 200%左右

 


第二种可能

session_save_path 需要设定一个实际的物理路径,并且该目录需要everyone的所有权限,类似U主机的0777

 


第三种可能
c:/winnt/temp 或者 c:/windows/temp
也需要everyone的所有权限,类似U主机的0777

 


第四种可能
您的内存严重不足,查看一下,如果有问题,请加内存,最好是一次加两条
比如加1G内存,最好是加2条一模一样的512M。否则没有启用双通道,效果也很一般

 


第五种可能
ZendOptimizer和php的搭配不是很好
换个版本试试看
目前比较稳定的搭配是
php4.3.11+zo 2.5.10a
或者php4.4.1+zo 3.0 beta2

 


第六种可能

这种多属于用win2003的用户
他们在应用池中设定了限制
比如多长时间回收,最大使用内存多少等等
这些设置势必造成这个经典的php错误

很多人说,是php版本的问题,其实不然,可以从四个地方来看这个问题
1,是否zend所需的dll文件所在目录给的权限不够,必须有读取和运行的权限
2,是否使用的2003,设置过应用池,比如池中限制了什么什么,调整一下再试试看,是否好了,呵呵
3,php.ini有两个地方没有设置,而且一些程序必须用到的

A
将;upload_tmp_dir该行的注释符,即前面的分号“;”去掉,使该行在php.ini文档中起作用。upload_tmp_dir是用来定义上传文件存放的临时路径,在这里你还可以给其定义一个绝对路径,例如:upload_tmp_dir = d:upload  当然,此时你的d:upload目录必须有读写权限。 
这里我设置为 
upload_tmp_dir = "c:windowstemp"

B
出现这样的错误语句一般是因为你的php.ini中关于session.save_path一项没有设置好,解决的方法是将session.save_path和session.cookie_path 设置置为 
session.save_path = "c:windowstemp" 
session.cookie_path = "c:windowstemp" 
(这个设置不知道是否正确.没试过.)
   也可以在c:目录下建立一个temp目录,即可(前面我们的eaccelerarot正好用到,建立过这么一个文件夹)

 


PHP has encountered an Access Violation解决方法总结
这个问题不是很好处理,困惑了很多站长非常时间了
主要出现在windows主机的服务器上。
在php官方,.net/">http://bugs.php.net/
也能够查到两三千页的报告,他们官方也是束手无策,经过了11个小版本后,还是没有彻底解决
http://bugs.php.net/search.php?c ... ess&x=8&y=9

目前我提供一下这几年我维护经验,我的一些民间解决办法

本贴不断更新,请关注!!! 引用:
第一种可能:

去掉 php中 eaccelerator 的扩展
这样做能够解决您的问题,不过可能会加重系统负担
因为eaccelerator主要是为了节省系统资源的东西

具体做法是找到php.ini
如果是我帮您配置的,一般在c:/php/php.ini或者 c:/winnt/php.ini 或者c:/windows/php.ini

去掉

zend_extension_ts="C:phpextensionseaccelerator_win_xxx.dll"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="c:temp"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

ea主要是在unix环境下开发的,但是作者忽略到windows实际上不像u主机那样,是没有u主机的那种内存共享机制的
这个bug已经提交给他们了,希望0.9.5能够解决

当然,如果您的机器这个问题不严重,建议还是保留,ea是一块非常优秀的Php缓存+加速软件
配合zo使用,将会降低系统负担 50%-80%左右,提高负载能力、速度和效率 200%左右引用:
第二种可能

session_save_path 需要设定一个实际的物理路径,并且该目录需要everyone的所有权限,类似U主机的0777引用:
第三种可能
c:/winnt/temp 或者 c:/windows/temp
也需要everyone的所有权限,类似U主机的0777引用:
第四种可能
您的内存严重不足,查看一下,如果有问题,请加内存,最好是一次加两条
比如加1G内存,最好是加2条一模一样的512M。否则没有启用双通道,效果也很一般引用:
第五种可能
ZendOptimizer和php的搭配不是很好
换个版本试试看
目前比较稳定的搭配是
php4.3.11+zo 2.5.10a
或者php4.4.1+zo 3.0 beta2引用:
第六种可能

这种多属于用win2003的用户
他们在应用池中设定了限制
比如多长时间回收,最大使用内存多少等等
这些设置势必造成这个经典的php错误
木头经过数以百计的测试,敢担保问题会出现在这里。引用:
第七种解决办法
2003用户,可以通过修改正在运行的应用池的, “性能”-“WEB园”“最大工作进程数”来解决.
曾经有个用户,直到加为10,才彻底解决了这个问题。

<?php
include "config.php";
if(isset($_POST['d'])&&isset($_POST['d'])&&$_POST['d']&&$_POST['d']){
$aa=$_POST['d'];
$url = "http://61.172.202.146:800/webquery/index.asp?wen=$aa";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$out = curl_exec($ch);
$out=cut($out,'<div align="center">','<script type="text/JavaScript">');
$out = preg_replace("/(?<=href=)([^>]*)(?=>)/i","",$out);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>天天快递----快件跟踪</title>
<link href='images/Style.css' rel='stylesheet' type='text/css'>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style>
H1{FONT-size:14px;margin-top:10px;}
</style>
</head>
<body>
<DIV id="lg">
<IMG " width=100% src="images/logo.gif" >
</DIV>
 
<div id="s">
  <div id="tit">快递查询及快递网点查询</div>
  <DIV id="sn">
    <UL>
      <LI><a href="./">EMS</a> </LI>
      <LI><a href="./">圆通</a></LI>
      <LI><a href="./">申通</a></LI>
      <LI class="selected">天天</LI>
      <LI><a href="./">中通</a></LI>
      <LI><a href="./">韵达</a></LI>
      <LI><a href="./">顺丰</a></LI>
      <LI><a href="./">汇通</a></LI>
      <LI><a href="./">亚风</a></LI>
      <LI class="m"><A href="./" target="_blank">更多</A>>></LI>
    </UL>
  </DIV>
</DIV>
<h1>天天快递查询</h1><form action="tt.php" method="post">
<p>运单号
    <input type="text" name="d" value="<? echo $_POST['d'] ?>">
<input type="submit" value="查询"></p>
</form>
<p align="center">

</p>
<table align="center">
  <? echo $out; ?>
</table>
<p align="center">

</p>
 
<?
function cut($file,$from,$end){

        $message=explode($from,$file);
        $message=explode($end,$message[2]);
return        $message[0];
}
include "foot.php";
?>
</body>
</html>

标签:[!--infotagslink--]

您可能感兴趣的文章: