/** * Cria um dump das tabelas do banco de dados. * * @param string $file_prefix Perfixo do arquivo a ser usado (SEM .INI) * @param string $section OPCIONAL section a ser usanda, se não informada será usado o que está definido em APPLICATION_ENV * * @return Zend_Config_Ini */ public static function getIni($file_prefix, $section = null) { // Verifica se uma das opções foi localizada if (!defined('APPLICATION_PATH') || realpath(APPLICATION_PATH) === false) { throw new Exception("constante APPLICATION_PATH não está definida em RW_Config::getApplicationIni()"); } // Opções de localização do application.ini $configs = array(APPLICATION_PATH . "/../configs/{$file_prefix}.ini", APPLICATION_PATH . "/configs/{$file_prefix}.ini"); // Verifica se a constante da marca (BFFC) esta definida if (defined('MARCA')) { if (is_numeric(MARCA)) { $configs[] = APPLICATION_PATH . "/../configs/{$file_prefix}." . BFFC_Marca::getCssClass(MARCA) . ".ini"; $configs[] = APPLICATION_PATH . "/configs/{$file_prefix}." . BFFC_Marca::getCssClass(MARCA) . ".ini"; } else { $configs[] = APPLICATION_PATH . "/../configs/{$file_prefix}." . MARCA . ".ini"; $configs[] = APPLICATION_PATH . "/configs/{$file_prefix}." . MARCA . ".ini"; } } // Carrega as configurações do config $configpath = false; foreach ($configs as $c) { if (file_exists($c)) { $configpath = $c; } } // Verifica se uma das opções foi localizada if ($configpath === false) { $marca = defined('MARCA') ? '(marca=' . BFFC_Marca::getCssClass(MARCA) . ')' : ''; throw new Exception("Nenhum arquivo de configuração {$file_prefix}.ini encontrado do diretório '/configs' {$marca} em RW_Config::getApplicationIni()"); } // Verifica o ambiente $section = empty($section) ? APPLICATION_ENV : $section; // Instância o arquivo aplication.ini return new Zend_Config_Ini($configpath, $section); }
public function __construct($isException = false) { // Verifica se a constante da marca esta definida // @todo remover referencia a BBFC $marca = defined('MARCA') ? '.' . BFFC_Marca::getCssClass(MARCA) : ''; // Carrega as configurações do config $configpath = APPLICATION_ROOT . "/../configs/application{$marca}.ini"; if (!file_exists($configpath)) { // procura dentro do application $configpath = APPLICATION_ROOT . "/configs/application{$marca}.ini"; if (!file_exists($configpath)) { throw new \Exception("Arquivo de configuração application{$marca}.ini não encontrado do diretório /configs"); } } $config = new Zend_Config_Ini($configpath, APPLICATION_ENV); $this->_name = $config->cms->email->name; $this->_email = $config->cms->email->email; $this->_returnPath = $config->cms->email->returnPath; $this->_type = $isException ? 'exception' : $config->cms->email->type; $this->_username = isset($config->cms->email->smtp) ? $config->cms->email->smtp->username : ''; $this->_password = isset($config->cms->email->smtp) ? $config->cms->email->smtp->password : ''; // Configura o método de envio if ($this->_type == 'exception') { $transport = new Zend_Mail_Transport_Sendmail('-f' . $this->_returnPath); // Envio do servidor local. Deve impedir que o cliente receba sem // querer } elseif (APPLICATION_ENV != 'production') { $this->_name .= ' (teste local)'; $this->_email = '*****@*****.**'; $transport = new Zend_Mail_Transport_Sendmail("*****@*****.**"); // Configurações da Locaweb } elseif ($this->_type == 'locaweb') { /* * Return-Path padrão da Locaweb sendmail_path = /usr/sbin/sendmail -t -i -r'*****@*****.**' */ $transport = new Zend_Mail_Transport_Sendmail("-f{$this->_returnPath}"); // Configurações do GMail } elseif ($this->_type == 'gmail') { $serverconfig = array('auth' => 'login', 'username' => $this->_username, 'password' => $this->_password, 'ssl' => 'ssl', 'port' => 465); $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $serverconfig); // Configuração genérica de SMTP } elseif ($this->_type == 'smtp') { $serverconfig = array('auth' => 'login', 'username' => $this->_username, 'password' => $this->_password); // Verifica se há SSL if (isset($config->cms->email->smtp->ssl) && $config->cms->email->smtp->ssl != '') { $config['ssl'] = $config->cms->email->smtp->ssl; } // veriufica se há uma porta definida if (isset($config->cms->email->smtp->port) && $config->cms->email->smtp->port != '') { $config['port'] = $config->cms->email->smtp->port; } // Configura o transport $transport = new Zend_Mail_Transport_Smtp($config->cms->email->smtp->host, $serverconfig); } else { throw new \Exception('Tipo de envio <b>' . $this->_type . '</b> não definido em RW_Mail'); } Zend_Mail::setDefaultTransport($transport); }