3月 20

3322.org动态域名用php的脚本解决 不指定

adminleon , 18:33 , php , 评论(0) , 引用(0) , 阅读(242) , Via 本站原创 | |
3322.org动态域名用php的脚本解决

新件文件getip.php  , 以下内容

getip.php
----------------------------------------------------------------------------------------------
#!/usr/local/bin/php -q

function openfile($file){
                  
                        $theget="";
                      if($open=file($file)){
                                        $count=count($open);
                                        for($i=0;$i<$count;$i++){
                                                $theget.=$open[$i];

                                        }
                                      
                                }else{
                                        die('读取数据错误');
                                }
              
              
        return $theget;

}


function writelog($str)
{
$tmp="";
if($str !="")
  {


     //  日志文件路径 /usr/workhome/3322.org/getip.txt      
      $fp = @fopen("/usr/workhome/3322.org/getip.txt", "a+");
      if($fp)
    {
       fwrite($fp, date("Y-m-d H:i:s").": ".$str."\n");
         fclose($fp);
     $tmp="ok";
    }
  }
  return $tmp;
}



$str=openfile("http://用户名:密码@members.3322.org/dyndns/update?system=dyndns&hostname=域名");

//调试时使用
echo $str;

//写日志, 当然也可以不用,注释掉.
writelog($str)
?>



然后命令:
#  chmod 755 getip.php

在定时任务里加上 getip.php的任务,设定十分钟一次.


可以在命令行里:

# ./getip.php

看看结果.
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]