Advertisement
Guest User

Untitled

a guest
Jul 1st, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.90 KB | None | 0 0
  1. <?php
  2. $ip='109.230.234.170';
  3. $port=8080;
  4. $admin_pass='';
  5. $bcast_pass='';
  6. $ssh_username='shoutcast';
  7. $ssh_password='';
  8. $web_port=801;
  9. $ssh_port=22;
  10. if(!isset($ip,$port,$admin_pass,$bcast_pass,$web_port,$ssh_port)) die("missing one or more required variables to execute.");
  11. function executeCheck($ip,$port,$web=false,$resp1=false)
  12. {
  13.     if(!$web)
  14.     {
  15.        
  16.     $f=@fsockopen($ip,$port,$errno,$errstr,1);
  17.     if(!$f) return false;
  18.     elseif($f) return true;
  19.     else return false;
  20.    
  21.     }
  22.     elseif($web)
  23.     {
  24.         $g=@file_get_contents($web);
  25.         if($g)
  26.         {
  27.             return $g;
  28.         }
  29.         else
  30.         {
  31.             if($resp1) return $resp1;
  32.             else return true;
  33.         }
  34.     }
  35. }
  36. function RestartShoutcast($meth,$ip,$port,$content)
  37. {
  38.    
  39. }
  40. function outputRestart($ip,$web_port,$ssh_port,$meth="",$server="")
  41. {
  42. if(executeCheck($ip,$port)==false)
  43.       {
  44.          if(executeCheck($ip,$web_port)==false)
  45.          {
  46.              if(executeCheck($ip,$ssh_port)==false)
  47.              {
  48.                  die("could not connect to httpd, sshd or shoutcast.\r\n<br />Can not execute server.");
  49.              }
  50.              else
  51.              {
  52.                  echo "Port {$ssh_port} (SSHd) appears to be open, could not connect to HTTPd or Shoutcast.\r\n<br />Will now restart client using SSHd on port {$ssh_port}.";
  53.              }
  54.          }
  55.          else
  56.          {
  57.              if(executeCheck($ip,$web_port,"/scripts/execute_sc.php") === "restarted")
  58.              {
  59.                  echo "Server claims to have restarted the Shoutcast server. Checking...\r\n<br />";
  60.                  if(executeCheck($ip,$port) ==true)
  61.                  {
  62.                      die("Server has been restarted");
  63.                  }
  64.                  else
  65.                  {
  66.                      die("Could not restart server.");
  67.                  }
  68.              }
  69.              else
  70.              {
  71.                  echo "Server seems to have not restarted the Shoutcast server.\r\n<br />We will now try it via SSHd.\r\n<br />";
  72.                  if(!function_exists("RestartShoutcast"))
  73.                  {
  74.                      die("Seem to have a problem trying to restart.\r\n<br />");
  75.                  }
  76.                  else
  77.                  {
  78.                      RestartShoutcast($meth,$ip,$server);
  79.                  }
  80.              }
  81.          }
  82.       }
  83. }
  84. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement