@@ -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 |
@@ -29,25 +29,25 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public static function amigable_time(int $from, $to = null) : string { |
31 | 31 | $intervalos = ['segundo', 'minuto', 'hora', 'día', 'semana', 'mes', 'año']; |
32 | - $duraciones = ['60','60','24','7','4.35','12']; |
|
32 | + $duraciones = ['60', '60', '24', '7', '4.35', '12']; |
|
33 | 33 | $to = $to ?? time(); |
34 | 34 | |
35 | 35 | $diferencia = $from - $to; |
36 | 36 | $tiempo = 'Dentro de'; |
37 | - if($to > $from) { |
|
37 | + if ($to > $from) { |
|
38 | 38 | $diferencia = $to - $from; |
39 | 39 | $tiempo = 'Hace'; |
40 | 40 | } |
41 | 41 | |
42 | - for($j = 0; $diferencia >= $duraciones[$j] && $j < sizeof($duraciones) - 1 ; $j++) { |
|
42 | + for ($j = 0; $diferencia >= $duraciones[$j] && $j < sizeof($duraciones) - 1; $j++) { |
|
43 | 43 | $diferencia /= $duraciones[$j]; |
44 | 44 | } |
45 | 45 | |
46 | 46 | $diferencia = round($diferencia); |
47 | 47 | |
48 | - if($diferencia != 1) { |
|
49 | - $intervalos[5].= 'e'; //MESES |
|
50 | - $intervalos[$j].= 's'; |
|
48 | + if ($diferencia != 1) { |
|
49 | + $intervalos[5] .= 'e'; //MESES |
|
50 | + $intervalos[$j] .= 's'; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | return $tiempo . ' ' . $diferencia . ' ' . $intervalos[$j]; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | * @return string : Texto desencriptado |
103 | 103 | */ |
104 | 104 | public static function ocrend_decode(string $str, string $key) : string { |
105 | - $data = base64_decode($str ); |
|
106 | - $___s___ = substr($data, 0, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC)); |
|
105 | + $data = base64_decode($str); |
|
106 | + $___s___ = substr($data, 0, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC)); |
|
107 | 107 | return rtrim( |
108 | 108 | mcrypt_decrypt( |
109 | 109 | MCRYPT_RIJNDAEL_128, |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | * |
138 | 138 | */ |
139 | 139 | public static function date_difference(string $ini, string $fin) : int { |
140 | - $ini_i = explode('-',str_replace('/','-',$ini)); |
|
141 | - $fin_i = explode('-',str_replace('/','-',$fin)); |
|
142 | - return (int) floor((mktime(0, 0, 0, $fin_i[1], $fin_i[0], $fin_i[2]) - mktime(0, 0, 0, $ini_i[1], $ini_i[0], $ini_i[2])) / 86400); |
|
140 | + $ini_i = explode('-', str_replace('/', '-', $ini)); |
|
141 | + $fin_i = explode('-', str_replace('/', '-', $fin)); |
|
142 | + return (int) floor((mktime(0, 0, 0, $fin_i[1], $fin_i[0], $fin_i[2]) - mktime(0, 0, 0, $ini_i[1], $ini_i[0], $ini_i[2]))/86400); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * |
163 | 163 | */ |
164 | 164 | public static function days_of_month() : int { |
165 | - return cal_days_in_month(CAL_GREGORIAN, (int) date('m',time()), (int) date('Y',time())); |
|
165 | + return cal_days_in_month(CAL_GREGORIAN, (int) date('m', time()), (int) date('Y', time())); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | * @return int Cantidad de palabras |
336 | 336 | */ |
337 | 337 | public static function count_words(string $s) : int { |
338 | - return (int) str_word_count($s,0,'0..9_'); |
|
338 | + return (int) str_word_count($s, 0, '0..9_'); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |