/**
		 * Save vhost config
		 *
		 * @param string $fields
		 * @return bool
		 */
		public function SaveConfig($fields, $restart = false)
		{
			// Stop server
			if ($restart)
				$this->Stop();
		
			$config = $this->ConfigTemplate;
			
			foreach ($fields as $k=>$v)
				$config = str_replace('{$'.$k.'}', $v, $config);
			
			$remote_path = "{$this->VentriloPath}/etc/{$this->Port}.ini";
			
			$tempfn = tempnam("","");
			$temp = fopen($tempfn, "w+");
			fwrite($temp, $config);
			fclose($temp);
			
			// Try to save config. If success try to Start server else return false
			$retval = $this->SSH2->SendFile($remote_path, $tempfn);
			@unlink($tempfn);
			
			if ($restart)
				$this->Start();
			
			if (!$retval)
				return false;
			else
				return true;
		}
        /**
         * Write file
         *
         * @param string $filename
         * @param string $content
         * @param bool $overwrite
         * @return bool
         */
	    public function Write($filename, $content, $overwrite = true)
	    {
	        if (!$this->SSHConnection->IsConnected())
                $this->Connect();
            
            $tp = ($overwrite) ? "w+" : "a+";
            return $this->SSHConnection->SendFile($filename, $content, $tp, false);
	    }
		/**
		 * Save apache config
		 *
		 * @return bool
		 */
		private function SaveConf()
		{
			$this->ConfCleanup();
			//
			$tempfn = tempnam("","");
			$temp = fopen($tempfn, "w+");
			fwrite($temp, $this->conf);
			fclose($temp);
		
			$this->SSH2->Exec("/bin/mv {$this->ConfPath} {$this->ConfPath}.".time());
			$retval = $this->SSH2->SendFile("{$this->ConfPath}", $tempfn);
			
			@unlink($tempfn);
			
			$retval &= $this->RestartApache();
			
			return($retval);
		}
Beispiel #4
0
		/**
		 * Create ventrilo server
		 *
		 * @param array $fields
		 * @return VentriloVhost
		 */
		public function AddServer($fields)
		{
			$port = $fields["port"];
			
			$config = $this->ConfigTemplate;
			
			foreach ($fields as $k=>$v)
				$config = str_replace('{$'.$k.'}', $v, $config);
			
			$remote_path = "{$this->VentriloPath}/etc/{$port}.ini";
			
			$tempfn = tempnam("","");
			$temp = fopen($tempfn, "w+");
			fwrite($temp, $config);
			fclose($temp);
			
			$retval = $this->SSH2->SendFile($remote_path, $tempfn);
			
			@unlink($tempfn);
			if (!$retval)
				return false;
			else
				return new VentriloVhost($this->SSHHost, $this->SSHPort, $this->SSHLogin, $this->SSHPassword, $this->VentriloPath, $this->ConfigTemplate, $port);
		}