欢迎看看这个无聊的我的博客,可能真的很无聊的
3月
20
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
看看结果.
新件文件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
看看结果.




