±¾ÎÄʵÀý½²ÊoÁËphpʵÏֵǼtplink WR882N»ñÈ¡IPºÍÖØÆoµÄ½¨¡£*ÖÏi¸ø´o¼Ò¹(C)´o¼Ò²Î¿¼£¬¾ßÌaÈçÏ£º
þÎñÆ÷Ò»ÉÏ´«´oÊý¾Ýtplink WR882N¾ÍÈÝÒ׿¨×¡, È»ºoÉϲ»ÁËÍø. ´oËaÔÚþÎñÆ÷¶¨Ê±¼i²a, Èç¢ÏÖÁ¬Ðø10´ÎÎÞ¨ÃÎÊÖ¸¶¨ÍøÕ¾, Ôo×Ô¶¯Ö´ÐÐÖØÆo²Ù×÷(¸Ã²¿ÖδʵÏÖ, Çe×Ô¼ºÌi¼Ó).
ggÁËһȦ*¢ÏÖÖ»ÓоɰaeµÄtplinkµÇ¼½Å±¾, ÊÔÁ˺ܾÃû³É¹¦ ¨C ¼ÒÀiµÄtplink 740Nµ¹ÊÇûÎÊÌa.
ÓÚÊÇÖ»ÄÜÖ±½ÓдÁË, ¼oµ¥µÄ½Å±¾ÈçÏÂ, ¿É×Ô¼ºÀ(C)Õ¹
¸Ã½Å±¾Ö»ÊÊÓÃWR882N, ÆaËuÐͺÅδ²aÊÔ.
<?php
// TPLINK WR882N ¹ÜÀi½Å±¾
function getContent($url)
{
// ½aϤ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:admin"), // ×¢ÒaÕaÀiµÄcookieÈÏÖ¤×Ö*u´®
"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(); // Æo¶¯Ò»¸oCURL»a»°
curl_setopt($curl, CURLOPT_URL, $url); // Òª*ÃÎʵĵØÖ*
curl_setopt($curl, CURLOPT_HTTPHEADER, $header); //ÉeÖÃÍ*ÐÅÏ¢µÄµØ*½
curl_setopt($curl, CURLOPT_TIMEOUT, 60); // ÉeÖó¬Ê±ÏÞÖÆ*ÀÖ¹ËÀÑ»*
curl_setopt($curl, CURLOPT_HEADER, 0); // ÏÔʾ*µ»ØµÄHeaderÇøÓoÄÚÈÝ
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // »ñÈ¡µÄÐÅÏ¢ÒÔÎļþÁ÷µÄÐÎʽ*µ»Ø
$content = curl_exec($curl); // Ö´ÐвÙ×÷
curl_close($curl);
return $content;
}
function getIp(){
$content = getContent("http://192.168.1.1/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("\r\n","",$data);
$data = explode(",",$data);
$ip = str_replace('"','',$data[2]);
$ip = trim($ip);
}
return $ip;
}
function reboot(){
$url = "http://192.168.1.1/userRpm/SysRebootRpm.htm?Reboot=%D6%D8%C6%F4%C2%B7%D3%C9%C6%F7";
getContent($url);
}
$info = getIp();
echo $info;
¸u¶a¹ØÓÚPHPÏa¹ØÄÚÈݸÐÐËȤµÄ¶ÁÕ߿ɲe¿´±¾Õ¾×¨Ìa£º¡¶PHPÍøÂç±a³Ì¼¼ÇÉ×ܽa¡¡¢¡¶[php curlÓè×ܽa](http://www.jb51.net/Special/66.htm)¡¡¢¡¶[php socketÓè×ܽa](http://www.jb51.net/Special/70.htm)¡¡¢¡¶[phpÕýÔo±i´iʽÓè×ܽa](http://www.jb51.net/Special/180.htm)¡¡¢¡¶[php×Öu´®(string)Óè×ܽa](http://www.jb51.net/Special/47.htm)¡¡¢¡¶PHPÊý×e(Array)²Ù×÷¼¼ÇÉ´oÈ«¡¡¢¡¶PHPÊýѧÔËËa¼¼ÇÉ×ܽa¡¡¢¡¶phpÃaeÏo¶ÔÏo³ÌÐoÉe¼ÆÈeÃŽ̡̳¡¢¡¶[PHPÊý¾Ý½a¹¹ÓeËa¨½Ì³Ì](http://www.jb51.net/Special/614.htm)¡¡¢¡¶[php³ÌÐoÉe¼ÆËa¨×ܽa](http://www.jb51.net/Special/111.htm)¡¼°¡¶php³£¼uÊý¾Ý¿a²Ù×÷¼¼ÇÉ»a×Ü¡
Ï£Íu±¾ÎÄËuÊo¶Ô´o¼ÒPHP³ÌÐoÉe¼ÆÓÐËu°iÖu¡£