Advertisement
luishenriique

Reboot TS-9000 if no connection

Feb 11th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <?php
  2.  
  3. function exec_curl($ch, $url, $post = null) {
  4.     curl_setopt($ch, CURLOPT_URL, $url);
  5.     curl_setopt($ch, CURLOPT_POST, true);
  6.     curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  7.     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  8.  
  9.     return curl_exec($ch);
  10. }
  11.  
  12. function ping($ip) {
  13.     exec("ping $ip -l 0 -n 1", $outcome, $status);
  14.    
  15.     return $status == 0;
  16. }
  17.  
  18. if (!ping("www.google.com")) {
  19.     $ch = curl_init();
  20.  
  21.     $url = "http://192.168.1.1";
  22.     $post = "username=admin&password=admin";
  23.     exec_curl($ch, $url, $post);
  24.  
  25.     $url = "http://192.168.1.1/form2Reboot.cgi";
  26.     $post = "rebootMode=0&reboot=Reiniciar&submit.htm%3Freboot.htm=Send";
  27.     exec_curl($ch, $url, $post);
  28.  
  29.     exit(1);
  30. }
  31.  
  32. exit(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement