示例#1
0
		public function GetStat($ipaddr)
		{
			$res = $this->SSH2->Exec("{$this->VentriloPath}/bin/ventrilo_status -c2 -t{$ipaddr}:{$this->Port}", "\004");
			if ($res)
			{
				$chunks = explode("\n", $res);
				foreach ((array)$chunks as $chunk)
				{
					$chunk = trim($chunk);
					$line = explode(":", $chunk);
					
					$key = trim($line[0]);
					$value = trim($line[1]);
					
					if (!empty($key))
						$retval[$key][] = urldecode($value);
				}
				
				// Parse channels
				if ($retval["CHANNELCOUNT"][0] > 0)
				{
					
					foreach ((array)$retval["CHANNEL"] as $chan)
					{
						$chunks = explode(",", $chan);
						foreach ((array)$chunks as $chunk)
						{
							$tmp = explode("=",$chunk);
							$channel[trim($tmp[0])] = trim($tmp[1]);
						}
						
						$retval["CHANNELS"][] = $channel;
					}
				}
				
				// Parse Users
				if ($retval["CLIENTCOUNT"] > 0)
				{
					foreach ((array)$retval["CLIENT"] as $cl)
					{
						$chunks = explode(",", $cl);
						foreach ((array)$chunks as $chunk)
						{
							$tmp = explode("=",$chunk);
							$client[trim($tmp[0])] = trim($tmp[1]);
						}
						
						$retval["CLIENTS"][] = $client;
					}
				}
			}
			else 
				$retval = false;
			
			return $retval;
		}
		/**
		 * Reastart apache
		 *
		 * @return bool
		 */
		public function RestartApache()
		{
			$retval = $this->SSH2->Exec(CF_HTTPD_APACHECTL." restart 2>&1");
			
			$retval = !(bool)strstr($retval, "error") && !(bool)strstr($retval, "Usage");
			
			if (!$retval)
                Core::RaiseWarning("Cannot restart apache: {$retval}");
			
			return $retval;
		}
示例#3
0
		public function GetRunningServers()
		{
		    $res = $this->SSH2->Exec("{$this->ShoutcastDir}/sc.sh get_running_ports");
		    if ($res)
			{
				$running_servers = explode("\n", $res);
				return $running_servers;
			}
			else
				return false;
		}
示例#4
0
	    /**
	     * Execute command
	     *
	     * @param string $command
	     * @return bool
	     */
	    public function Execute($command)
	    {
	        if (!$this->SSHConnection->IsConnected())
                $this->Connect();
                
            $res = $this->SSHConnection->Exec($command);
            if ($res === true)
                $res = $this->SSHConnection->StdErr;
                
            return $res;
	    }
示例#5
0
 /**
  * Disconnect
  *
  * @param int $reason
  * @return bool
  * @access private
  */
 function _disconnect($reason)
 {
     $this->pwd = false;
     parent::_disconnect($reason);
 }
示例#6
0
<?php

/**
 * SSH2 libs
 * 
 * @author Radek Hřebeček <*****@*****.**>
 * @copyright  Copyright (c) 2012 Radek Hřebeček (https://github.com/rhrebecek)
 * @license New BSD License
 * @link https://github.com/rhrebecek/SSH2
 *
 * @example
 * 	Working with an object is very simple
 * 		
 * ////////////////////////////////////////////////
 * 
 * 		include 'SSH2.php';
 * 
 * 		$ssh = new \SSH2;
 * 		$ssh->login('root', 'password', 'example.com');
 * 		$ssh->exec('ls --all');
 * 
 * 		echo $ssh->getOutput();
 * 
 * /////////////////////////////////////////////////
 */
include "libs/SSH2.php";
$ssh = new SSH2();
$ssh->login('root', 'password', 'example.com')->exec('ls -all')->getOutputBlackScreen();
示例#7
0
		public function ListServers2()
		{
			$res = $this->SSH2->Exec("/bin/ls -al {$this->VentriloPath}/etc | grep .ini", "\004");
			$res2 = $this->SSH2->Exec("ps -ax -o pid,command | grep 'etc/4496' | grep -v grep | head -n 1 | awk '{print \$1}'");
			
			var_dump($res2);
			exit();
			
			if ($res)
			{
				preg_match_all("/([0-9]+)\.ini/msi", $res, $servers);
				preg_match_all("/([0-9]+)\.pid/msi", $res2, $servers2);
				$started = array_flip($servers2[1]);
		
				$retval = array();
				foreach ($servers[1] as $v)
				{
					if (isset($started[$v]))
						$retval[$v] = 1;
					else
						$retval[$v] = 0;
				}
				
				return $retval;
			}
			else
				return false;
		}
示例#8
0
 /**
  * Execute command on remote shell
  * @param string $cmd Command ex:pwd
  * @return string $output Command output
  */
 function execCmd($cmd)
 {
     $output = $this->objSsh->exec($cmd);
     return $output;
 }