public function __construct() { Configure::load('auth'); $this->session = new Session(); }
/** * Função de auto execução ao startar a classe. */ public function __construct() { Configure::load('database'); $this->log = (bool) Configure::read('database.log'); $class = explode('\\', get_class($this)); $class = end($class); $this->classe = substr($class, 0, -5) . 'Entity'; $this->alias = substr($class, 0, -5); $this->classe = '\\App\\Model\\Entity\\' . $this->classe; $this->pdo = Conection::db(); $this->_cache = new Cache('model' . DS . $this->tabela); $this->_cache->setTime(Configure::read('database.cacheTime')); $this->cache = (bool) Configure::read('database.cache'); $this->schema = $this->schema()->columnsTypes(); $this->_conditions = new Conditions($this->tabela, $this->alias, $this->schema()); }
/** * Função de auto execução ao startar a classe. */ public function __construct() { Configure::load('database'); }
private function _create() { if ($this->is_session_started()) { Configure::load('session'); foreach (Configure::read('session') as $key => $value) { ini_set($key, $value); } } @session_start(); }
/** * * Faz o tratamento das url para definar os dados de rotas a ser usados. * * @param string $uriPath */ public function match($uriPath) { $uriPath = '/' . trim($uriPath, '/'); Configure::load('rotas'); $rotas = Configure::read('rotas'); if (count($rotas) > 0) { foreach ($rotas as $route => $actualPage) { $route_regex = preg_replace('@:[^/]+@', '([^/]+)', $route); if (!preg_match('@' . $route_regex . '@', $uriPath, $matches)) { continue; } $r = preg_match('@' . $route_regex . '@', $route, $identifiers); if ($r > 0) { if ($identifiers[0] === $uriPath) { $this->uri = []; foreach (explode('.', $actualPage) as $k => $v) { $this->uri[$k] = $v; } } } } } }
} exit(1); // EXIT_ERROR } } // ------------------------------------------------------------------------ if (!function_exists('_shutdown_handler')) { /** * Shutdown Handler * * This is the shutdown handler that is declared at the top * of CodeIgniter.php. The main reason we use this is to simulate * a complete custom exception handler. * * E_STRICT is purposively neglected because such events may have * been caught. Duplication or none? None is preferred for now. * * @link http://insomanic.me.uk/post/229851073/php-trick-catching-fatal-errors-e-error-with-a * @return void */ function _shutdown_handler() { $last_error = error_get_last(); if (isset($last_error) && $last_error['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING)) { _error_handler($last_error['type'], $last_error['message'], $last_error['file'], $last_error['line']); } } } \Core\Configure::load('app'); $router = new Core\Router(new \Core\Request()); $router->run();
public function send($options, $type = 'default') { Configure::load('mail'); $config = Configure::read('mail'); if (!empty(Configure::read('Parametros.Email'))) { $config = array_merge($config, Configure::read('Parametros.Email')); } $config = $config[$type]; $mail = new PHPMailer((bool) Configure::read('app.debug')); $mail->SMTPDebug = (int) $config['Debug']; $mail->isSMTP(); $mail->Host = $config['Host']; $mail->SMTPAuth = (bool) $config['Auth']; $mail->Username = $config['Username']; $mail->Password = $config['Password']; $mail->SMTPAutoTLS = false; if ($config['AutoTls'] > 0) { $mail->SMTPSecure = $config['Secure']; $mail->SMTPAutoTLS = true; } $mail->Port = (int) $config['Port']; $mail->CharSet = $config['Charset']; //$mail->isSMTP(); // Set mailer to use SMTP //$mail->Host = 'smtp.appettosa.com.br'; // Specify main and backup server //$mail->SMTPAuth = true; // Enable SMTP authentication //$mail->Port = 587; //$mail->Username = '******'; // SMTP username //$mail->Password = '******'; // SMTP password //$mail->From = ('*****@*****.**'); //$mail->FromName = $_POST['nome']; $default = ['from' => ['mail' => '', 'title' => ''], 'add' => [], 'replyto' => [], 'cc' => [], 'bcc' => [], 'file' => [], 'html' => true, 'title' => '', 'data' => [], 'alt' => '', 'layout' => 'default', 'view' => 'default']; $options = Hash::merge($default, $options); $options['add'] = Hash::merge([-1 => [$options['from']['mail'] => $options['from']['title']]], $options['add']); $mail->setFrom($config['Username'], $config['Name']); if (count($options['add'])) { foreach ($options['add'] as $key => $value) { if (is_array($value)) { foreach ($value as $k => $v) { $mail->addAddress($k, $v); } } else { $mail->addAddress($value); } } } if (count($options['replyto'])) { foreach ($options['replyto'] as $key => $value) { if (is_array($value)) { foreach ($value as $k => $v) { $mail->addReplyTo($k, $v); } } else { $mail->addReplyTo($value); } } } if (count($options['cc'])) { foreach ($options['cc'] as $key => $value) { if (is_array($value)) { foreach ($value as $k => $v) { $mail->addCC($k, $v); } } else { $mail->addCC($value); } } } if (count($options['bcc'])) { foreach ($options['bcc'] as $key => $value) { if (is_array($value)) { foreach ($value as $k => $v) { $mail->addBCC($k, $v); } } else { $mail->addBCC($value); } } } if (count($options['file'])) { foreach ($options['file'] as $key => $value) { if (is_array($value)) { foreach ($value as $k => $v) { $mail->addAttachment($k, $v); } } else { $mail->addAttachment($value); } } } $mail->isHTML($options['html']); $this->data = $options['data']; //debug($this->data); $this->data['title'] = $options['title']; $this->loads(); $this->render($options['view']); $options['body'] = $this->renderlayout($options['layout']); $mail->Subject = $options['title']; $mail->Body = $options['body']; $mail->AltBody = $options['alt']; try { if (!$mail->send()) { return false; } else { return true; } } catch (\Exception $exception) { $this->error = $exception; $ex = new \Core\MyException(); $ex->show_exception($exception); return false; } }