@@ -135,7 +135,7 @@ |
||
135 | 135 | /** |
136 | 136 | * Asigna las extensiones de archivos permitidas |
137 | 137 | * |
138 | - * @param array|string $value lista de extensiones para archivos, si es string separado por | |
|
138 | + * @param string[] $value lista de extensiones para archivos, si es string separado por | |
|
139 | 139 | */ |
140 | 140 | public function setExtensions($value) { |
141 | 141 | if (!is_array($value)) { |
@@ -141,7 +141,7 @@ |
||
141 | 141 | |
142 | 142 | private static function sprintf($sentence, $args, $offset) |
143 | 143 | { |
144 | - return vsprintf( $sentence, array_slice( $args, $offset)); |
|
144 | + return vsprintf($sentence, array_slice($args, $offset)); |
|
145 | 145 | |
146 | 146 | } |
147 | 147 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @param string $name |
92 | 92 | */ |
93 | - public static function initialize($name='') |
|
93 | + public static function initialize($name = '') |
|
94 | 94 | { |
95 | 95 | self::$log_path = APP_PATH . 'temp/logs/'; //TODO poder cambiar el path |
96 | 96 | if ($name === '') { |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | * @param string $msg |
130 | 130 | * @param string $name_log |
131 | 131 | */ |
132 | - public static function log($type='DEBUG', $msg, $name_log) |
|
132 | + public static function log($type = 'DEBUG', $msg, $name_log) |
|
133 | 133 | { |
134 | 134 | if (is_array($msg)) { |
135 | 135 | $msg = print_r($msg, true); |
136 | 136 | } |
137 | 137 | //TODO poder añadir otros formatos de log |
138 | 138 | $date = date(DATE_RFC1036); |
139 | - $msg = "[$date][$type] " . $msg ; |
|
139 | + $msg = "[$date][$type] " . $msg; |
|
140 | 140 | if (self::$transaction) { |
141 | 141 | self::$queue[] = $msg; |
142 | 142 | return; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | protected static function write($msg, $name_log) |
153 | 153 | { |
154 | - self::initialize($name_log); //TODO dejarlo abierto cuando es un commit |
|
154 | + self::initialize($name_log); //TODO dejarlo abierto cuando es un commit |
|
155 | 155 | fputs(self::$fileLogger, $msg . PHP_EOL); |
156 | 156 | self::close(); |
157 | 157 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param string $msg |
210 | 210 | * @param string $name_log |
211 | 211 | */ |
212 | - public static function warning($msg, $name_log='') |
|
212 | + public static function warning($msg, $name_log = '') |
|
213 | 213 | { |
214 | 214 | self::log('WARNING', $msg, $name_log); |
215 | 215 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @param string $msg |
222 | 222 | * @param string $name_log |
223 | 223 | */ |
224 | - public static function error($msg, $name_log='') |
|
224 | + public static function error($msg, $name_log = '') |
|
225 | 225 | { |
226 | 226 | self::log('ERROR', $msg, $name_log); |
227 | 227 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @param string $msg |
234 | 234 | * @param string $name_log |
235 | 235 | */ |
236 | - public static function debug($msg, $name_log='') |
|
236 | + public static function debug($msg, $name_log = '') |
|
237 | 237 | { |
238 | 238 | self::log('DEBUG', $msg, $name_log); |
239 | 239 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @param string $msg |
246 | 246 | * @param string $name_log |
247 | 247 | */ |
248 | - public static function alert($msg, $name_log='') |
|
248 | + public static function alert($msg, $name_log = '') |
|
249 | 249 | { |
250 | 250 | self::log('ALERT', $msg, $name_log); |
251 | 251 | } |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @param string $msg |
258 | 258 | * @param string $name_log |
259 | 259 | */ |
260 | - public static function critical($msg, $name_log='') |
|
260 | + public static function critical($msg, $name_log = '') |
|
261 | 261 | { |
262 | 262 | self::log('CRITICAL', $msg, $name_log); |
263 | 263 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @param string $msg |
270 | 270 | * @param string $name_log |
271 | 271 | */ |
272 | - public static function notice($msg, $name_log='') |
|
272 | + public static function notice($msg, $name_log = '') |
|
273 | 273 | { |
274 | 274 | self::log('NOTICE', $msg, $name_log); |
275 | 275 | } |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * @param string $msg |
282 | 282 | * @param string $name_log |
283 | 283 | */ |
284 | - public static function info($msg, $name_log='') |
|
284 | + public static function info($msg, $name_log = '') |
|
285 | 285 | { |
286 | 286 | self::log('INFO', $msg, $name_log); |
287 | 287 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @param string $msg |
294 | 294 | * @param string $name_log |
295 | 295 | */ |
296 | - public static function emergence($msg, $name_log='') |
|
296 | + public static function emergence($msg, $name_log = '') |
|
297 | 297 | { |
298 | 298 | self::log('EMERGENCE', $msg, $name_log); |
299 | 299 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * @param string $msg |
306 | 306 | * @param string $name_log |
307 | 307 | */ |
308 | - public static function custom($type='CUSTOM', $msg, $name_log='') |
|
308 | + public static function custom($type = 'CUSTOM', $msg, $name_log = '') |
|
309 | 309 | { |
310 | 310 | self::log($type, $msg, $name_log); |
311 | 311 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $this->month = date("m"); |
76 | 76 | $this->day = date("d"); |
77 | 77 | $this->timestamp = time(); |
78 | - $this->date = $this->year."-".sprintf("%02s", $this->month)."-".sprintf("%02s", $this->day); |
|
78 | + $this->date = $this->year . "-" . sprintf("%02s", $this->month) . "-" . sprintf("%02s", $this->day); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | * |
147 | 147 | */ |
148 | 148 | public function addMonths($month) { |
149 | - if ($this->month+$month > 12) { |
|
150 | - $this->month = ($month%12)+1; |
|
149 | + if ($this->month + $month > 12) { |
|
150 | + $this->month = ($month%12) + 1; |
|
151 | 151 | $this->year += ((int) ($month/12)); |
152 | 152 | } else { |
153 | 153 | $this->month++; |
154 | 154 | } |
155 | - $this->date = $this->year."-".sprintf("%02s", $this->month)."-".sprintf("%02s", $this->day); |
|
155 | + $this->date = $this->year . "-" . sprintf("%02s", $this->month) . "-" . sprintf("%02s", $this->day); |
|
156 | 156 | $this->consolideDate(); |
157 | 157 | return $this->date; |
158 | 158 | } |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | * |
163 | 163 | */ |
164 | 164 | public function diffMonths($month) { |
165 | - if ($this->month-$month < 1) { |
|
166 | - $this->month = 12-(($month%12)+1); |
|
165 | + if ($this->month - $month < 1) { |
|
166 | + $this->month = 12 - (($month%12) + 1); |
|
167 | 167 | $this->year -= ((int) ($month/12)); |
168 | 168 | } else { |
169 | 169 | $this->month--; |
170 | 170 | } |
171 | - $this->date = $this->year."-".sprintf("%02s", $this->month)."-".sprintf("%02s", $this->day); |
|
171 | + $this->date = $this->year . "-" . sprintf("%02s", $this->month) . "-" . sprintf("%02s", $this->day); |
|
172 | 172 | $this->consolideDate(); |
173 | 173 | return $this->date; |
174 | 174 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @return string |
181 | 181 | */ |
182 | 182 | public function addDays($days) { |
183 | - $this->date = date("Y-m-d", $this->timestamp+$days*86400); |
|
183 | + $this->date = date("Y-m-d", $this->timestamp + $days*86400); |
|
184 | 184 | $this->consolideDate(); |
185 | 185 | return $this->date; |
186 | 186 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @return string |
193 | 193 | */ |
194 | 194 | public function diffDays($days) { |
195 | - $this->date = date("Y-m-d", $this->timestamp-$days*86400); |
|
195 | + $this->date = date("Y-m-d", $this->timestamp - $days*86400); |
|
196 | 196 | $this->consolideDate(); |
197 | 197 | return $this->date; |
198 | 198 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function addYears($years) { |
207 | 207 | $this->year += $years; |
208 | - $this->date = $this->year."-".sprintf("%02s", $this->month)."-".sprintf("%02s", $this->day); |
|
208 | + $this->date = $this->year . "-" . sprintf("%02s", $this->month) . "-" . sprintf("%02s", $this->day); |
|
209 | 209 | $this->consolideDate(); |
210 | 210 | return $this->date; |
211 | 211 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | */ |
219 | 219 | public function diffYears($years) { |
220 | 220 | $this->year -= $years; |
221 | - $this->date = $this->year."-".sprintf("%02s", $this->month)."-".sprintf("%02s", $this->day); |
|
221 | + $this->date = $this->year . "-" . sprintf("%02s", $this->month) . "-" . sprintf("%02s", $this->day); |
|
222 | 222 | $this->consolideDate(); |
223 | 223 | return $this->date; |
224 | 224 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $month = (int) $date_parts[1]; |
254 | 254 | $day = (int) $date_parts[2]; |
255 | 255 | $timestamp = mktime(0, 0, 0, $month, $day, $year); |
256 | - return (int) (($this->timestamp-$timestamp)/86400); |
|
256 | + return (int) (($this->timestamp - $timestamp)/86400); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * @return boolean |
276 | 276 | */ |
277 | 277 | public function isYesterday() { |
278 | - $time = mktime(0, 0, 0, date("m"), date("d"), date("Y"))-86400; |
|
278 | + $time = mktime(0, 0, 0, date("m"), date("d"), date("Y")) - 86400; |
|
279 | 279 | |
280 | 280 | if ($this->timestamp == $time) { |
281 | 281 | return true; |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @return boolean |
291 | 291 | */ |
292 | 292 | public function isTomorrow() { |
293 | - $time = mktime(0, 0, 0, date("m"), date("d"), date("Y"))+86400; |
|
293 | + $time = mktime(0, 0, 0, date("m"), date("d"), date("Y")) + 86400; |
|
294 | 294 | |
295 | 295 | if ($this->timestamp == $time) { |
296 | 296 | return true; |
@@ -138,7 +138,7 @@ |
||
138 | 138 | |
139 | 139 | $image = $this->_imgInfo; |
140 | 140 | // Verifica que sea un archivo de imagen |
141 | - if (!$image){ |
|
141 | + if (!$image) { |
|
142 | 142 | Flash::error('Error: el archivo debe ser una imagen'); |
143 | 143 | return FALSE; |
144 | 144 | } |
@@ -187,10 +187,14 @@ |
||
187 | 187 | protected function _validatesTypes() |
188 | 188 | { |
189 | 189 | // Verifica que sea un archivo de imagen |
190 | - if (!$this->_imgInfo) return FALSE; |
|
190 | + if (!$this->_imgInfo) { |
|
191 | + return FALSE; |
|
192 | + } |
|
191 | 193 | |
192 | 194 | foreach ($this->_types as $type) { |
193 | - if ($this->_imgInfo['mime'] == "image/$type") return TRUE; |
|
195 | + if ($this->_imgInfo['mime'] == "image/$type") { |
|
196 | + return TRUE; |
|
197 | + } |
|
194 | 198 | } |
195 | 199 | |
196 | 200 | return FALSE; |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * @see AuthInterface |
22 | 22 | */ |
23 | -require_once __DIR__ .'/auth_interface.php'; |
|
23 | +require_once __DIR__ . '/auth_interface.php'; |
|
24 | 24 | |
25 | 25 | // Evita problemas al actualizar de la beta2 |
26 | -if (session_status() !== PHP_SESSION_ACTIVE) {session_start();} |
|
26 | +if (session_status() !== PHP_SESSION_ACTIVE) {session_start(); } |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Esta clase permite autenticar usuarios |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | throw new kumbiaException("Adaptador de autenticación '$adapter' no soportado"); |
107 | 107 | } |
108 | 108 | $this->adapter = Util::camelcase($adapter); |
109 | - require_once __DIR__ ."/adapters/{$adapter}_auth.php"; |
|
110 | - $adapter_class = $this->adapter.'Auth'; |
|
109 | + require_once __DIR__ . "/adapters/{$adapter}_auth.php"; |
|
110 | + $adapter_class = $this->adapter . 'Auth'; |
|
111 | 111 | $this->extra_args = $extra_args; |
112 | 112 | $this->adapter_object = new $adapter_class($auth, $extra_args); |
113 | 113 | } |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | */ |
133 | 133 | if ($result && $this->active_session) { |
134 | 134 | $user_hash = md5(serialize($this->extra_args)); |
135 | - $filename = APP_PATH.'temp/cache/'.base64_encode('auth'); |
|
135 | + $filename = APP_PATH . 'temp/cache/' . base64_encode('auth'); |
|
136 | 136 | if (file_exists($filename)) { |
137 | 137 | $fp = fopen($filename, 'r'); |
138 | 138 | while (!feof($fp)) { |
139 | 139 | $line = fgets($fp); |
140 | 140 | $user = explode(':', $line); |
141 | 141 | if ($user_hash == $user[0]) { |
142 | - if ($user[1]+$user[2] > time()) { |
|
142 | + if ($user[1] + $user[2] > time()) { |
|
143 | 143 | if ($this->sleep_time) { |
144 | 144 | sleep($this->sleep_time); |
145 | 145 | } |
@@ -149,16 +149,16 @@ discard block |
||
149 | 149 | } else { |
150 | 150 | fclose($fp); |
151 | 151 | $this->destroy_active_session(); |
152 | - file_put_contents($filename, $user_hash.':'.time().':'.$this->expire_time."\n"); |
|
152 | + file_put_contents($filename, $user_hash . ':' . time() . ':' . $this->expire_time . "\n"); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | } |
156 | 156 | fclose($fp); |
157 | 157 | $fp = fopen($filename, 'a'); |
158 | - fputs($fp, $user_hash.':'.time().':'.$this->expire_time."\n"); |
|
158 | + fputs($fp, $user_hash . ':' . time() . ':' . $this->expire_time . "\n"); |
|
159 | 159 | fclose($fp); |
160 | 160 | } else { |
161 | - file_put_contents($filename, $user_hash.':'.time().':'.$this->expire_time."\n"); |
|
161 | + file_put_contents($filename, $user_hash . ':' . time() . ':' . $this->expire_time . "\n"); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | if (!$result) { |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function destroy_active_session() { |
217 | 217 | $user_hash = md5(serialize($this->extra_args)); |
218 | - $filename = APP_PATH.'temp/cache/'.base64_encode('auth'); |
|
218 | + $filename = APP_PATH . 'temp/cache/' . base64_encode('auth'); |
|
219 | 219 | $lines = file($filename); |
220 | 220 | $lines_out = array(); |
221 | 221 | foreach ($lines as $line) { |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | if (!is_null(self::$is_valid)) { |
263 | 263 | return self::$is_valid; |
264 | 264 | } else { |
265 | - self::$is_valid = isset($_SESSION['KUMBIA_AUTH_VALID'][Config::get('config.application.namespace_auth')])?$_SESSION['KUMBIA_AUTH_VALID'][Config::get('config.application.namespace_auth')]:null; |
|
265 | + self::$is_valid = isset($_SESSION['KUMBIA_AUTH_VALID'][Config::get('config.application.namespace_auth')]) ? $_SESSION['KUMBIA_AUTH_VALID'][Config::get('config.application.namespace_auth')] : null; |
|
266 | 266 | return self::$is_valid; |
267 | 267 | } |
268 | 268 | } |
@@ -18,8 +18,8 @@ |
||
18 | 18 | * @license http://wiki.kumbiaphp.com/Licencia New BSD License |
19 | 19 | */ |
20 | 20 | |
21 | -class KumbiaAuth extends KumbiaFacade{ |
|
22 | - protected static function getAlias(){ |
|
21 | +class KumbiaAuth extends KumbiaFacade { |
|
22 | + protected static function getAlias() { |
|
23 | 23 | return 'auth'; |
24 | 24 | } |
25 | 25 | } |
@@ -44,7 +44,7 @@ |
||
44 | 44 | if ($seconds) { |
45 | 45 | header("Refresh: $seconds; url=$route"); |
46 | 46 | } else { |
47 | - header('Location: '.$route, TRUE, $statusCode); |
|
47 | + header('Location: ' . $route, TRUE, $statusCode); |
|
48 | 48 | $_SESSION['KUMBIA.CONTENT'] = ob_get_clean(); |
49 | 49 | View::select(null, null); |
50 | 50 | } |
@@ -86,8 +86,9 @@ |
||
86 | 86 | $vars = $url; |
87 | 87 | } |
88 | 88 | |
89 | - if (++$cyclic > 1000) |
|
90 | - throw new KumbiaException('Se ha detectado un enrutamiento cíclico. Esto puede causar problemas de estabilidad'); |
|
89 | + if (++$cyclic > 1000) { |
|
90 | + throw new KumbiaException('Se ha detectado un enrutamiento cíclico. Esto puede causar problemas de estabilidad'); |
|
91 | + } |
|
91 | 92 | |
92 | 93 | Router::to($vars, TRUE); |
93 | 94 | } |
@@ -42,12 +42,12 @@ |
||
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | - public static function createSecureRSAKey($kumbia=true) |
|
45 | + public static function createSecureRSAKey($kumbia = true) |
|
46 | 46 | { |
47 | 47 | $config = Config::read('config'); |
48 | 48 | if ($config->kumbia->secure_ajax) { |
49 | 49 | if ($_SESSION['rsa_key']) { |
50 | - if ((time() % 8) == 0) { |
|
50 | + if ((time()%8) == 0) { |
|
51 | 51 | return self::generateRSAKey($kumbia); |
52 | 52 | } else { |
53 | 53 | echo "<input type='hidden' id='rsa32_key' value=\"{$_SESSION['rsa_key']}\"/>"; |