PHP版本 D-Link 动态域名客户端
来源:互联网 发布:快压解压缩软件 编辑:程序博客网 时间:2024/06/05 19:22
<?php /* * D-Link 动态域名客户端.主域名www.dlinkddns.com 和 www.dlinkddns.com.cn * 首先获取外网IP,若IP没有变化,则结束运行;否则更行域名的IP,若执行错误,则发送EMAIL. * 用到了 CURL 扩展 * 2013.5.28 */// 获取外网 IP $ipurl = 'http://iframe.ip138.com/ic.asp'; $ip = get_onlineip($ipurl); //$ip = '14.134.204.99'; $iplog = dirname(__FILE__) . '\ip.txt'; // 域名账号设定 $domain = 'dlinkddns.com.cn'; $host = 'lpszy'; $user = 'tom112'; $pw = 'PASSWORD'; // 邮件账号设定 $smtp = array( 'url' => 'smtp.sina.com', //发件箱服务器 'port' => '25', 'username' => 'safeboat@sina.com', //发件箱账号 'password' => 'PASSWORD', //发件箱密码 'from' => 'safeboat@sina.com', 'to' => '395636344@qq.com', //接收信箱 'subject' => '请更新 '.$host.'.'.$domain.' 的IP', 'body' => $ip, ); if(file_exists($iplog) == false) file_put_contents($iplog, ''); $oldip = file_get_contents($iplog); if($oldip == $ip){ echo "IP 没有变化"; exit(); } file_put_contents($iplog, $ip); $cookie_file = dirname(__FILE__) . "/cookie_" . md5(basename(__FILE__)) . ".txt"; vlogin('http://www.'.$domain.'/login', 'username=' . $user . '&pw=' . $pw); $response_body = vlogin('http://www.'.$domain.'/host/'.$host.'.'.$domain, 'modify='.$host.'&host='.$host.'&domain='.$domain.'&ip='.$ip.'&commit=%E4%BF%9D+++%E5%AD%98'); header("Content-type: text/html; charset=gb2312"); if(stristr($response_body, 'updated')){ @unlink($cookie_file); echo "域名IP已更新."; exit(); } @unlink($cookie_file); echo "提交的账号、域名或IP错误,或者是服务器更新了参数等原因。\r\n"; echo '<br>稍后将发送IP到你的邮箱,请手动更新<br><br> '; echo '一下是发邮件过程:<br>'; echo '<pre>' . smtp($smtp) . '</pre>'; //下面为函数部分 function get_onlineip($ipurl){ $ch = curl_init($ipurl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $a = curl_exec($ch); preg_match('/\[(.*)\]/', $a, $ip); return @$ip[1]; } function vlogin($url, $data){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1); curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_AUTOREFERER, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, @$data); curl_setopt($curl, CURLOPT_COOKIEJAR, $GLOBALS['cookie_file']); curl_setopt($curl, CURLOPT_COOKIEFILE, $GLOBALS['cookie_file']); curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $tmpInfo = curl_exec($curl); if (curl_errno($curl)){ echo 'Errno' . curl_error($curl); } curl_close($curl); return $tmpInfo; } function smtp($smtp){ $CRLF = "\r\n"; $header = array( 'Return-path' => '<' . $smtp['from'] . '>', 'Date' => date('r'), 'From' => '<' . $smtp['from'] . '>', 'MIME-Version' => '1.0', 'Subject' => trim($smtp['subject']), 'To' => $smtp['to'], 'Content-Type' => 'text/plain; charset=gb2312', 'Content-Transfer-Encoding' => 'base64' ); $ret = ''; foreach($header as $k => $v){ $ret .= $k . ': ' . $v . "\n"; } $data = $ret . $CRLF . chunk_split(base64_encode($smtp['body'])); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $smtp['url']); curl_setopt($curl, CURLOPT_PORT, $smtp['port']); curl_setopt($curl, CURLOPT_TIMEOUT, 10); $content = "EHLO " . $smtp["url"] . $CRLF; $content .= "AUTH LOGIN" . $CRLF . base64_encode($smtp["username"]) . $CRLF . base64_encode($smtp["password"]) . $CRLF; $content .= "MAIL FROM:" . $smtp["from"] . $CRLF; $content .= "RCPT TO:" . $smtp["to"] . $CRLF; $content .= "DATA" . $CRLF . $data . $CRLF . "." . $CRLF; $content .= "QUIT" . $CRLF; curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $content); curl_exec($curl); curl_close($curl); return $content; } ?>
0 0
- PHP版本 D-Link 动态域名客户端
- 花生壳 + D-Link + Tomcat 设置动态域名内网访问
- 花生壳动态域名软件3重大版本:客户端支持微信远程管理
- 金万维动态域名gnhost客户端 免费
- CentOS 安装动态域名解析客户端
- 希网动态域名 客户端(系统服务)
- dnspod 动态域名更新客户端 in python
- PHP 获取客户端操作系统版本和浏览器版本
- 3D Link
- D-Link路由器设置
- 动态域名ddns客户端(有程序和源代码)下载
- 请大家试用我开发的动态域名解析客户端软件
- 动态域名ddns开源客户端inadyn的移植
- OpenWrt(busybox版)配置dnspod动态域名客户端
- 版本控制(link)
- PHP获取客户端IP地址、浏览器类型版本、操作系统
- D-Link 路由 PCAnyWhere 端口映射
- D-link路由器设置详解
- 卷积神经网络CNN(5)—— Dilated Convolution
- gRPC 实现多线程异步服务端
- nginx配置与常见错误解决方法
- PDF文件格式的特点
- win7电脑远程桌面,出现凭据不工作解决方案
- PHP版本 D-Link 动态域名客户端
- undefined reference to `pthread_create' collect2: ld returned 1 exit status
- ubuntu14.04 Samba服务无法访问 可能没有权限 指定的网络名不再可用的问题
- ?Implement strStr()
- ROS常用命令
- 2016-12-29 DNS简介下
- Python的 range()函数解析
- MySQL(7):CRUD语句(3)——子查询和多表查询
- LeetCode 92. Reverse Linked List II