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; }
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; }
/** * 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; }
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; }