Advertisement
plas71k

@Rislo => ioncube file => decoded

Apr 19th, 2013
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.04 KB | None | 0 0
  1. <?php
  2. /*
  3. * @ Pirate-Sky Crew :: PHP Decoder v2
  4. * @ Author: pLa$71k
  5. * @ Web: http://pirate-sky.com
  6. * @ Pirate-Sky Crew © 2008 - 2013
  7. */
  8.  
  9. require_once( MAINDIR."includes".DS."libs".DS."phpquery".DS."phpQuery.php" );
  10. class Nagios extends HostingModule
  11. {
  12.  
  13.     protected $modname = "Nagios monitoring module";
  14.     protected $description = "Use with dedicated servers manager plugin to monitor services";
  15.     protected $version = "1.0";
  16.     protected $serverFields = array
  17.     (
  18.         "ssl" => false,
  19.         "nameservers" => false,
  20.         "maxaccounts" => false,
  21.         "status_url" => false,
  22.         "ip" => false,
  23.         "hostname" => true,
  24.         "field1" => false,
  25.         "field2" => false
  26.     );
  27.     protected $serverFieldsDescription = array
  28.     (
  29.         "hostname" => "Nagios URL"
  30.     );
  31.     private $url = NULL;
  32.     private $username = NULL;
  33.     private $password = NULL;
  34.     private static $columns = array
  35.     (
  36.         1 => "service",
  37.         2 => "status",
  38.         3 => "lastcheck",
  39.         4 => "duration",
  40.         5 => "attempt",
  41.         6 => "info"
  42.     );
  43.     private static $severity = array
  44.     (
  45.         "OK" => 1,
  46.         "WARNING" => 2,
  47.         "UNKNOWN" => 3,
  48.         "CRITICAL" => 4
  49.     );
  50.  
  51.     public function connect( $connect )
  52.     {
  53.         if ( !preg_match( "/http[s]?:/", $connect['host'] ) )
  54.         {
  55.             $connect['host'] = "http://".$connect['host'];
  56.         }
  57.         if ( stripos( $connect['host'], ".cgi" ) !== false )
  58.         {
  59.             $connect['host'] = substr( $connect['host'], 0, strrpos( $connect['host'], "/" ) );
  60.         }
  61.         $connect['host'] = rtrim( $connect['host'], "/" );
  62.         $this->url = $connect['host']."/status.cgi?limit=0";
  63.         $this->username = $connect['username'];
  64.         $this->password = $connect['password'];
  65.     }
  66.  
  67.     public function testConnection( )
  68.     {
  69.         return $this->loadStatuses( );
  70.     }
  71.  
  72.     public function Create( )
  73.     {
  74.         return true;
  75.     }
  76.  
  77.     public function loadStatuses( )
  78.     {
  79.         $curl = curl_init( );
  80.         curl_setopt( $curl, CURLOPT_URL, $this->url );
  81.         curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
  82.         curl_setopt( $curl, CURLOPT_TIMEOUT, 30 );
  83.         curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, false );
  84.         curl_setopt( $curl, CURLOPT_SSL_VERIFYHOST, false );
  85.         curl_setopt( $curl, CURLOPT_USERPWD, $this->username.":".$this->password );
  86.         $out = curl_exec( $curl );
  87.         if ( $out === false )
  88.         {
  89.             $this->addError( ucwords( curl_error( $curl ) ) );
  90.         }
  91.         $dom = phpQuery::newdocument( $out, "text/html" );
  92.         $return = array( );
  93.         if ( !phpQuery::pq( "table.status" ) )
  94.         {
  95.             $this->addError( "Unable to parse nagios response, check login details" );
  96.             return false;
  97.         }
  98.         $trs = phpQuery::pq( "table.status", $dom )->children( "tr" )->next( );
  99.         $hostname = "";
  100.         $i = $j = 0;
  101.         foreach ( $trs as $row )
  102.         {
  103.             $tds = pq( $row )->children( );
  104.             foreach ( $tds as $td )
  105.             {
  106.                 $td = pq( $td );
  107.                 $t = trim( $col = $td->text( ) );
  108.                 if ( !$i )
  109.                 {
  110.                     if ( $t )
  111.                     {
  112.                         $hostname = $t;
  113.                         $j = 0;
  114.                     }
  115.                 }
  116.                 else
  117.                 {
  118.                     $return[$hostname]['services'][$j][self::$columns[$i]] = $t;
  119.                 }
  120.                 ++$i;
  121.                 $last = $return[$hostname]['services'][$j]['status'];
  122.             }
  123.             if ( !$return[$hostname]['status'] )
  124.             {
  125.                 $return[$hostname]['status'] = $last;
  126.             }
  127.             if ( self::$severity[$return[$hostname]['status']] < self::$severity[$last] )
  128.             {
  129.                 $return[$hostname]['status'] = $last;
  130.             }
  131.             $i = 0;
  132.             ++$j;
  133.         }
  134.         return $return;
  135.     }
  136.  
  137. }
  138.  
  139. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement