<?php // TPLINK WR882N/TL-WR842N管理脚本 function getContent($url){ $temp = parse_url($url); $query = isset($temp['query']) ? $temp['query'] : ''; $path = isset($temp['path']) ? $temp['path'] : '/'; $header = array ( "POST {$path}?{$query} HTTP/1.1", "Host: {$temp['host']}", "Content-Type: text/xml; charset=utf-8", 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Cookie: Authorization=Basic ' . base64_encode("admin:264059790"), // 注意这里的cookie认证字符串 "Referer: http://{$temp['host']}/", 'User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1)', "Content-length: 380", "Connection: Close" ); $curl = curl_init(); // 启动一个CURL会话 curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址 curl_setopt($curl, CURLOPT_HTTPHEADER, $header); //设置头信息的地方 curl_setopt($curl, CURLOPT_TIMEOUT, 60); // 设置超时限制防止死循环 curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回 $content = curl_exec($curl); // 执行操作 curl_close($curl); return $content; } function getIp(){ $content = getContent("http://192.168.188.254:8081/userRpm/StatusRpm.htm"); preg_match('/wanPara=new Array((.+?)</script>/s',$content,$all); $ip = "0"; if(!empty($all[1])){ $data = trim($all[1]); $data = str_replace(" ","",$data); $data = explode(",",$data); $ip = str_replace('"','',$data[2]); $ip = trim($ip); } return $ip; } function reboot(){ $url = "http://192.168.188.254:8081/userRpm/SysRebootRpm.htm?Reboot=%D6%D8%C6%F4%C2%B7%D3%C9%C6%F7"; getContent($url); } function gudingip(){ $url = "http://192.168.188.254:8081/userRpm/WanStaticIpCfgRpm.htm?wantype=1&ip=10.1.1.185&mask=255.255.255.0&gateway=10.1.1.1&mtu=1500&dnsserver=223.5.5.5&dnsserver2=223.6.6.6&downBandwidth=100&upBandwidth=100&Save=%B1%A3+%B4%E6"; getContent($url); } function pppoe(){ $url = "http://192.168.188.254:8081/userRpm/PPPoECfgRpm.htm?wan=0&wantype=2&acc=0571xxxxxxxxxxxx&psw=Hello123World&confirm=Hello123World&specialDial=100&SecType=0&sta_ip=0.0.0.0&sta_mask=0.0.0.0&linktype=2&Save=%B1%A3+%B4%E6"; getContent($url); } $info = getIp(); echo "WAN口IP:".$info; //$pppoe=pppoe(); //修改WAN口为PPPOE拨号 function Wifimima(){ $content = getContent("http://192.168.188.254:8081/userRpm/WlanSecurityRpm.htm"); preg_match('/wlanPara=new Array((.+?)</script>/s',$content,$all); $ip = "0"; //var_dump($content); if(!empty($all[1])){ $data = trim($all[1]); //var_dump($data); $data = str_replace(" ","",$data); $data = explode(",",$data); //var_dump($data[9]); $mima = str_replace('"','',$data[9]); $mima = trim($mima); } echo "<br>"; echo "无线WIFI密码为:".$mima; return $mima; } $wifimima=Wifimima();