@@ -31,7 +31,7 @@ |
||
| 31 | 31 | public static function resolveDriver(string $motor) : Driver { |
| 32 | 32 | global $config; |
| 33 | 33 | |
| 34 | - if($motor == 'mysql') { |
|
| 34 | + if ($motor == 'mysql') { |
|
| 35 | 35 | return new Mysql; |
| 36 | 36 | } |
| 37 | 37 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $sqlite3 = $config['database']['drivers']['sqlite3']; |
| 31 | 31 | |
| 32 | 32 | # Establecer conexión, si la base de datos no existe, es creada |
| 33 | - parent::__construct('sqlite:' . str_replace('___ROOT___',___ROOT___,$sqlite3['file'])); |
|
| 33 | + parent::__construct('sqlite:' . str_replace('___ROOT___', ___ROOT___, $sqlite3['file'])); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | . (null !== $limit ? "LIMIT $limit" : '') |
| 73 | 73 | ); |
| 74 | 74 | |
| 75 | - if(false != $result && sizeof($result)) { |
|
| 75 | + if (false != $result && sizeof($result)) { |
|
| 76 | 76 | $matriz = (array) $result->fetchAll(PDO::FETCH_ASSOC); |
| 77 | 77 | $result->closeCursor(); |
| 78 | 78 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | ); |
| 45 | 45 | |
| 46 | 46 | # Verificar conexión |
| 47 | - if($this->connect_errno) { |
|
| 47 | + if ($this->connect_errno) { |
|
| 48 | 48 | throw new \RuntimeException('ERROR :' . $this->connect_errno . ' conectando con la base de datos' . $this->connect_error); |
| 49 | 49 | } |
| 50 | 50 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | . (null !== $limit ? "LIMIT $limit" : '') |
| 83 | 83 | ); |
| 84 | 84 | |
| 85 | - if(false != $result && $result->num_rows) { |
|
| 85 | + if (false != $result && $result->num_rows) { |
|
| 86 | 86 | $matriz = (array) $result->fetch_all(MYSQLI_ASSOC); |
| 87 | 87 | $result->free(); |
| 88 | 88 | |
@@ -80,22 +80,22 @@ |
||
| 80 | 80 | global $session, $config; |
| 81 | 81 | |
| 82 | 82 | # Verificar si está habilitada la opción de sesión de usuario con cookie |
| 83 | - if($config['sessions']['user_cookie']['enable']) { |
|
| 83 | + if ($config['sessions']['user_cookie']['enable']) { |
|
| 84 | 84 | # Obtener |
| 85 | 85 | $user_session = $session->get($this->get('session_hash') . '__user_id'); |
| 86 | 86 | $salt = $this->get('appsalt'); |
| 87 | 87 | $encrypt = $this->get('appencrypt'); |
| 88 | 88 | |
| 89 | 89 | # Verificar que no estén vacías y coincidan |
| 90 | - if(null == $user_session && null != $salt && null != $encrypt && Helper\Strings::chash($salt ?? '_', $encrypt ?? '/$')) { |
|
| 90 | + if (null == $user_session && null != $salt && null != $encrypt && Helper\Strings::chash($salt ?? '_', $encrypt ?? '/$')) { |
|
| 91 | 91 | # Generar un nuevo session hash |
| 92 | - $this->set('session_hash', md5(time()) , $config['sessions']['user_cookie']['lifetime']); |
|
| 92 | + $this->set('session_hash', md5(time()), $config['sessions']['user_cookie']['lifetime']); |
|
| 93 | 93 | |
| 94 | 94 | # Desencriptar el id del usuario |
| 95 | 95 | $id_user = Helper\Strings::ocrend_decode($encrypt, $config['sessions']['user_cookie']['key_encrypt']); |
| 96 | 96 | |
| 97 | 97 | # Reestablecer la sesión |
| 98 | - $session->set($this->get('session_hash') . '__user_id',(int) $id_user); |
|
| 98 | + $session->set($this->get('session_hash') . '__user_id', (int) $id_user); |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -38,15 +38,15 @@ |
||
| 38 | 38 | if ($__TWIG_READABLE_AND_WRITABLE) { |
| 39 | 39 | |
| 40 | 40 | # Intentar solucionarlo |
| 41 | - if(!is_dir($__TWIG_CACHE_PATH)) { |
|
| 41 | + if (!is_dir($__TWIG_CACHE_PATH)) { |
|
| 42 | 42 | mkdir($__TWIG_CACHE_PATH, 0644, true); |
| 43 | 43 | } else { |
| 44 | 44 | chmod($__TWIG_CACHE_PATH, 0644); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | # Revisar la lecutra para twig |
| 48 | - if($__TWIG_READABLE_AND_WRITABLE) { |
|
| 49 | - throw new \RuntimeException('Debe conceder permisos de escritura y lectura a la ruta '. $__TWIG_CACHE_PATH .' ó crearla si no existe.'); |
|
| 48 | + if ($__TWIG_READABLE_AND_WRITABLE) { |
|
| 49 | + throw new \RuntimeException('Debe conceder permisos de escritura y lectura a la ruta ' . $__TWIG_CACHE_PATH . ' ó crearla si no existe.'); |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | |
| 53 | 53 | # Verificar sesión del usuario |
| 54 | 54 | $session_name = $cookie->get('session_hash') . '__user_id'; |
| 55 | - if(null !== $session->get($session_name)) { |
|
| 55 | + if (null !== $session->get($session_name)) { |
|
| 56 | 56 | $this->id_user = $session->get($session_name); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | * |
| 37 | 37 | * @return void |
| 38 | 38 | */ |
| 39 | - protected function startDBConexion($driver = null) { |
|
| 39 | + protected function startDBConexion($driver = null) { |
|
| 40 | 40 | global $config; |
| 41 | 41 | $this->db = Database::resolveDriver($driver ?? $config['database']['default_driver']); |
| 42 | 42 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public static function loadTemplate(array $content, int $template) : string { |
| 48 | 48 | # Verificar que existe la plantilla |
| 49 | - if(!array_key_exists($template,self::TEMPLATES)) { |
|
| 49 | + if (!array_key_exists($template, self::TEMPLATES)) { |
|
| 50 | 50 | throw new \RuntimeException('La plantilla seleccionada no se encuentra.'); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | $tpl = Files::read_file(self::TEMPLATES_ROUTE . self::TEMPLATES[$template]); |
| 55 | 55 | |
| 56 | 56 | # Reempalzar contenido |
| 57 | - foreach($content as $index => $html) { |
|
| 58 | - $tpl = str_replace($index,$html,$tpl); |
|
| 57 | + foreach ($content as $index => $html) { |
|
| 58 | + $tpl = str_replace($index, $html, $tpl); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | return $tpl; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $https['ssl']['verify_peer_name'] = false; |
| 91 | 91 | |
| 92 | 92 | # Verificar si están llenos los campos |
| 93 | - if(!$config['build']['production'] && Functions::emp($config['mailer']['host'])) { |
|
| 93 | + if (!$config['build']['production'] && Functions::emp($config['mailer']['host'])) { |
|
| 94 | 94 | throw new \RuntimeException('Los datos de mailer, en Ocrend.ini.yml están vacíos.'); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | # El mensaje |
| 107 | 107 | $message = new \Swift_Message(); |
| 108 | - $message->setSubject(array_key_exists('{{title}}',$content) ? $content['{{title}}'] : $config['build']['name']); |
|
| 109 | - $message->setBody(self::loadTemplate($content,$template), 'text/html'); |
|
| 110 | - $message->setFrom([ $config['mailer']['user'] => $config['build']['name']]); |
|
| 108 | + $message->setSubject(array_key_exists('{{title}}', $content) ? $content['{{title}}'] : $config['build']['name']); |
|
| 109 | + $message->setBody(self::loadTemplate($content, $template), 'text/html'); |
|
| 110 | + $message->setFrom([$config['mailer']['user'] => $config['build']['name']]); |
|
| 111 | 111 | $message->setTo($dest); |
| 112 | 112 | |
| 113 | 113 | # Adjuntos |
@@ -119,7 +119,7 @@ |
||
| 119 | 119 | $this->template->addExtension(new Helper\Functions); |
| 120 | 120 | |
| 121 | 121 | # Debug disponible en twig |
| 122 | - if(!$config['build']['production']) { |
|
| 122 | + if (!$config['build']['production']) { |
|
| 123 | 123 | $this->template->addExtension(new \Twig_Extension_Debug()); |
| 124 | 124 | } |
| 125 | 125 | |