proto = $dest['proto']; $this->host = str_replace("\\", "/", $dest['host']); $this->anon = ($dest['anon'] == 1); $this->user = $this->anon ? "anonymous" : str_replace("\\", "/", $dest['user']); $this->pass = $this->anon ? "" : $dest['pass']; $this->dir = $this->VerBarraPath(str_replace("\\", "/", $dest['dir'])); if ($dest['port'] && $this->proto != 4) { $this->port = $dest['port']; } if ($dest['timeout']) { $this->timeout = $dest['timeout']; } $this->backupHandler = $backupHandler; } public function connect() { if (is_null($this->proto) || empty($this->proto)) { $this->Except("Nenhum protocolo informado para a realização do backup"); } /* * Tenta se conectar ao servidor destino de acordo com o protocolo */ $this->backupHandler->Connect($this); return !$this->hasError; } public function GetMessage() { return $this->messge; } public function GetRealMessage() { return $this->realMessge; } public function Except($msg, $realMessage = '') { $this->hasError = true; $this->messge = $msg; $error = error_get_last(); $this->realMessge = $realMessage . "[" . $error['message'] . "]\n"; } public function VerBarraPath($path) { if (substr($path, -1) != '/') { return $path . '/'; } return $path; } public function GetMode($file) { return (StringClass::ContemTexto($file, '.txt')) || (StringClass::ContemTexto($file, '.sql')) ? FTP_ASCII : FTP_BINARY; } function getBackupHandler() { return $this->backupHandler; } /** * Retorna o último erro lançado pelo $backupHandler * @return null|string */ public function GetLastHandlerException() { return $this->backupHandler->getExceptionMessage(); } }