PHP Implementation Login Tplink wr882n access to IP and restart methods _php skills

Source: Internet
Author: User
Tags curl php programming php regular expression

This article describes the PHP implementation login Tplink wr882n access to IP and restart the method. Share to everyone for your reference, specific as follows:

Server upload large data tplink wr882n easily jammed, and then on the net. Intend to detect on the server, if found 10 consecutive times can not access the specified Web site, then the automatic restart operation (this part is not implemented, please add yourself).

GG A lap found only the old version of the Tplink login script, tried for a long time did not succeed – the home of the Tplink 740N is no problem.

So you can only write directly, the simple script is as follows, you can expand

The script only applies to wr882n and other models are not tested.

<?php//Tplink wr882n admin script function getcontent ($url) {//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:aut Horization=basic '. Base64_encode ("Admin:admin"),//Note Here the cookie authentication string "referer:http://{$temp [' Host ']}/', ' user-agent:mozilla/4.0 (c ompatible; MSIE 7.0; Windows NT 5.1;
  SV1) ', "content-length:380", "connection:close"); $curl = Curl_init (); Start a Curl session curl_setopt ($curl, Curlopt_url, $url); Address curl_setopt ($curl, Curlopt_httpheader, $header) to be accessed; Set header information to the place curl_setopt ($curl, curlopt_timeout, 60); Set timeout limit to prevent dead loop curl_setopt ($curl, Curlopt_header, 0); Displays the contents of the header area returned curl_setopt ($curl, Curlopt_returntransfer, 1); The information obtained is returned in the form of a file stream $content = curl_exec ($curl);
  Perform operation 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;

More interested in PHP related content readers can view the site topics: "PHP Network Programming Skills Summary", "Php Curl Usage Summary", "PHP Socket Usage Summary", "PHP Regular Expression Usage summary", "PHP string (String) Usage Summary", " PHP array Operation techniques Encyclopedia, "PHP Mathematical Calculation Skills Summary", "PHP object-oriented Programming Introductory Course", "PHP Data structure and algorithm tutorial", "PHP Programming algorithm Summary" and "PHP common database Operation Skills Summary"

I hope this article will help you with the PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.