@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @param string $table |
90 | 90 | * @return boolean |
91 | 91 | */ |
92 | - public function table_exists($table, $schema='') |
|
92 | + public function table_exists($table, $schema = '') |
|
93 | 93 | { |
94 | 94 | /** |
95 | 95 | * Informix no soporta schemas |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | { |
110 | 110 | $params = Util::getParams(func_get_args()); |
111 | 111 | |
112 | - $limit =''; |
|
113 | - if(isset($params['offset'])){ |
|
112 | + $limit = ''; |
|
113 | + if (isset($params['offset'])) { |
|
114 | 114 | $limit .= " SKIP $params[offset]"; |
115 | 115 | } |
116 | - if(isset($params['limit'])){ |
|
116 | + if (isset($params['limit'])) { |
|
117 | 117 | $limit .= " FIRST $params[limit]"; |
118 | 118 | } |
119 | 119 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param string $table |
127 | 127 | * @return boolean |
128 | 128 | */ |
129 | - public function drop_table($table, $if_exists=true) |
|
129 | + public function drop_table($table, $if_exists = true) |
|
130 | 130 | { |
131 | 131 | if ($if_exists) { |
132 | 132 | if ($this->table_exists($table)) { |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param array $definition |
154 | 154 | * @return boolean |
155 | 155 | */ |
156 | - public function create_table($table, $definition, $index=array()) |
|
156 | + public function create_table($table, $definition, $index = array()) |
|
157 | 157 | { |
158 | 158 | $create_sql = "CREATE TABLE $table ("; |
159 | 159 | if (!is_array($definition)) { |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | } |
204 | 204 | $create_lines[] = "$field " . $field_def['type'] . $size . ' ' . $not_null . ' ' . $extra; |
205 | 205 | } |
206 | - $create_sql.= join(',', $create_lines); |
|
206 | + $create_sql .= join(',', $create_lines); |
|
207 | 207 | $last_lines = array(); |
208 | 208 | if (count($primary)) { |
209 | 209 | $last_lines[] = 'PRIMARY KEY(' . join(",", $primary) . ')'; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $last_lines[] = join(',', $unique_index); |
216 | 216 | } |
217 | 217 | if (count($last_lines)) { |
218 | - $create_sql.= ',' . join(',', $last_lines) . ')'; |
|
218 | + $create_sql .= ',' . join(',', $last_lines) . ')'; |
|
219 | 219 | } |
220 | 220 | return $this->query($create_sql); |
221 | 221 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @param string $table |
237 | 237 | * @return array |
238 | 238 | */ |
239 | - public function describe_table($table, $schema='') |
|
239 | + public function describe_table($table, $schema = '') |
|
240 | 240 | { |
241 | 241 | /** |
242 | 242 | * Informix no soporta schemas |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param int $opt |
178 | 178 | * @return array |
179 | 179 | */ |
180 | - public function fetch_array($result_query='', $opt=MYSQL_BOTH) |
|
180 | + public function fetch_array($result_query = '', $opt = MYSQL_BOTH) |
|
181 | 181 | { |
182 | 182 | |
183 | 183 | if (!$result_query) { |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | /** |
203 | 203 | * Devuelve el numero de filas de un select |
204 | 204 | */ |
205 | - public function num_rows($result_query='') |
|
205 | + public function num_rows($result_query = '') |
|
206 | 206 | { |
207 | 207 | |
208 | 208 | if (!$result_query) { |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param resource $result_query |
226 | 226 | * @return string |
227 | 227 | */ |
228 | - public function field_name($number, $result_query='') |
|
228 | + public function field_name($number, $result_query = '') |
|
229 | 229 | { |
230 | 230 | |
231 | 231 | if (!$result_query) { |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * @param resource $result_query |
249 | 249 | * @return boolean |
250 | 250 | */ |
251 | - public function data_seek($number, $result_query='') |
|
251 | + public function data_seek($number, $result_query = '') |
|
252 | 252 | { |
253 | 253 | if (!$result_query) { |
254 | 254 | $result_query = $this->last_result_query; |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @param resource $result_query |
270 | 270 | * @return int |
271 | 271 | */ |
272 | - public function affected_rows($result_query='') |
|
272 | + public function affected_rows($result_query = '') |
|
273 | 273 | { |
274 | 274 | if (($numberRows = mysql_affected_rows()) !== false) { |
275 | 275 | return $numberRows; |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * |
284 | 284 | * @return string |
285 | 285 | */ |
286 | - public function error($err='') |
|
286 | + public function error($err = '') |
|
287 | 287 | { |
288 | 288 | if (!$this->id_connection) { |
289 | 289 | $this->last_error = mysql_error() ? mysql_error() : "[Error Desconocido en MySQL: $err]"; |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | return $this->last_error; |
294 | 294 | } |
295 | 295 | $this->last_error = mysql_error() ? mysql_error() : "[Error Desconocido en MySQL: $err]"; |
296 | - $this->last_error.= $err; |
|
296 | + $this->last_error .= $err; |
|
297 | 297 | if ($this->logger) { |
298 | 298 | Logger::error($this->last_error); |
299 | 299 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return int |
317 | 317 | */ |
318 | - public function last_insert_id($table='', $primary_key='') |
|
318 | + public function last_insert_id($table = '', $primary_key = '') |
|
319 | 319 | { |
320 | 320 | return mysql_insert_id($this->id_connection); |
321 | 321 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * @param string $table |
327 | 327 | * @return boolean |
328 | 328 | */ |
329 | - public function table_exists($table, $schema='') |
|
329 | + public function table_exists($table, $schema = '') |
|
330 | 330 | { |
331 | 331 | $table = addslashes("$table"); |
332 | 332 | if ($schema == '') { |
@@ -350,11 +350,11 @@ discard block |
||
350 | 350 | $sql_new = $sql; |
351 | 351 | |
352 | 352 | if (isset($params['limit']) && is_numeric($params['limit'])) { |
353 | - $sql_new.=" LIMIT $params[limit]"; |
|
353 | + $sql_new .= " LIMIT $params[limit]"; |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | if (isset($params['offset']) && is_numeric($params['offset'])) { |
357 | - $sql_new.=" OFFSET $params[offset]"; |
|
357 | + $sql_new .= " OFFSET $params[offset]"; |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | return $sql_new; |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * @param string $table |
367 | 367 | * @return boolean |
368 | 368 | */ |
369 | - public function drop_table($table, $if_exists=true) |
|
369 | + public function drop_table($table, $if_exists = true) |
|
370 | 370 | { |
371 | 371 | if ($if_exists) { |
372 | 372 | return $this->query("DROP TABLE IF EXISTS $table"); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * @param array $definition |
389 | 389 | * @return boolean |
390 | 390 | */ |
391 | - public function create_table($table, $definition, $index=array()) |
|
391 | + public function create_table($table, $definition, $index = array()) |
|
392 | 392 | { |
393 | 393 | $create_sql = "CREATE TABLE $table ("; |
394 | 394 | if (!is_array($definition)) { |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | } |
439 | 439 | $create_lines[] = "`$field` " . $field_def['type'] . $size . ' ' . $not_null . ' ' . $extra; |
440 | 440 | } |
441 | - $create_sql.= join(',', $create_lines); |
|
441 | + $create_sql .= join(',', $create_lines); |
|
442 | 442 | $last_lines = array(); |
443 | 443 | if (count($primary)) { |
444 | 444 | $last_lines[] = 'PRIMARY KEY(' . join(",", $primary) . ')'; |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | $last_lines[] = join(',', $unique_index); |
451 | 451 | } |
452 | 452 | if (count($last_lines)) { |
453 | - $create_sql.= ',' . join(',', $last_lines) . ')'; |
|
453 | + $create_sql .= ',' . join(',', $last_lines) . ')'; |
|
454 | 454 | } |
455 | 455 | return $this->query($create_sql); |
456 | 456 | } |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | * @param string $table |
472 | 472 | * @return array |
473 | 473 | */ |
474 | - public function describe_table($table, $schema='') |
|
474 | + public function describe_table($table, $schema = '') |
|
475 | 475 | { |
476 | 476 | if ($schema == '') { |
477 | 477 | return $this->fetch_all("DESCRIBE `$table`"); |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | * @param string $class clase de objeto |
488 | 488 | * @return object |
489 | 489 | */ |
490 | - public function fetch_object($result_query=null, $class='stdClass') |
|
490 | + public function fetch_object($result_query = null, $class = 'stdClass') |
|
491 | 491 | { |
492 | 492 | if (!$result_query) { |
493 | 493 | $result_query = $this->last_result_query; |
@@ -120,7 +120,9 @@ discard block |
||
120 | 120 | if (!extension_loaded('mysql')) { |
121 | 121 | throw new KumbiaException('Debe cargar la extensión de PHP llamada php_mysql'); |
122 | 122 | } |
123 | - if (!isset($config['port']) || !$config['port']) $config['port'] = 3306; |
|
123 | + if (!isset($config['port']) || !$config['port']) { |
|
124 | + $config['port'] = 3306; |
|
125 | + } |
|
124 | 126 | |
125 | 127 | if ($this->id_connection = mysql_connect("{$config['host']}:{$config['port']}", $config['username'], $config['password'], true)) { |
126 | 128 | if ($config['name'] !== '') { |
@@ -129,7 +131,9 @@ discard block |
||
129 | 131 | } |
130 | 132 | } |
131 | 133 | //Selecciona charset |
132 | - if (isset($config['charset'])) mysql_query("SET NAMES {$config['charset']}"); |
|
134 | + if (isset($config['charset'])) { |
|
135 | + mysql_query("SET NAMES {$config['charset']}"); |
|
136 | + } |
|
133 | 137 | //mysql_set_charset($config['charset'],$this->id_connection); //Necesita mysql > 5.0.7 |
134 | 138 | return true; |
135 | 139 | } else { |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param int $opt |
170 | 170 | * @return array |
171 | 171 | */ |
172 | - function fetch_array($resultQuery='', $opt=SQLITE_BOTH) |
|
172 | + function fetch_array($resultQuery = '', $opt = SQLITE_BOTH) |
|
173 | 173 | { |
174 | 174 | |
175 | 175 | if (!$resultQuery) { |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | /** |
196 | 196 | * Devuelve el numero de filas de un select |
197 | 197 | */ |
198 | - function num_rows($resultQuery='') |
|
198 | + function num_rows($resultQuery = '') |
|
199 | 199 | { |
200 | 200 | if (!$resultQuery) { |
201 | 201 | $resultQuery = $this->last_result_query; |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @param resource $resultQuery |
218 | 218 | * @return string |
219 | 219 | */ |
220 | - function field_name($number, $resultQuery='') |
|
220 | + function field_name($number, $resultQuery = '') |
|
221 | 221 | { |
222 | 222 | |
223 | 223 | if (!$resultQuery) { |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @param resource $resultQuery |
241 | 241 | * @return boolean |
242 | 242 | */ |
243 | - function data_seek($number, $resultQuery='') |
|
243 | + function data_seek($number, $resultQuery = '') |
|
244 | 244 | { |
245 | 245 | if (!$resultQuery) { |
246 | 246 | $resultQuery = $this->last_result_query; |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * @param resource $resultQuery |
262 | 262 | * @return int |
263 | 263 | */ |
264 | - function affected_rows($resultQuery='') |
|
264 | + function affected_rows($resultQuery = '') |
|
265 | 265 | { |
266 | 266 | |
267 | 267 | if (!$resultQuery) { |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return string |
284 | 284 | */ |
285 | - function error($err='') |
|
285 | + function error($err = '') |
|
286 | 286 | { |
287 | 287 | if (!$this->id_connection) { |
288 | 288 | $this->last_error = sqlite_last_error($this->id_connection) ? sqlite_last_error($this->id_connection) . $err : "[Error Desconocido en SQLite \"$err\"]"; |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | return $this->last_error; |
293 | 293 | } |
294 | 294 | $this->last_error = 'SQLite error: ' . sqlite_error_string(sqlite_last_error($this->id_connection)); |
295 | - $this->last_error.= $err; |
|
295 | + $this->last_error .= $err; |
|
296 | 296 | if ($this->logger) { |
297 | 297 | Logger::error($this->last_error); |
298 | 298 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * |
315 | 315 | * @return int |
316 | 316 | */ |
317 | - public function last_insert_id($table='', $primary_key='') |
|
317 | + public function last_insert_id($table = '', $primary_key = '') |
|
318 | 318 | { |
319 | 319 | $last_id = $this->fetch_one("SELECT COUNT(*) FROM $table"); |
320 | 320 | return $last_id[0]; |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * @param string $table |
327 | 327 | * @return boolean |
328 | 328 | */ |
329 | - function table_exists($table, $schema='') |
|
329 | + function table_exists($table, $schema = '') |
|
330 | 330 | { |
331 | 331 | $table = addslashes(strtolower($table)); |
332 | 332 | if (strpos($table, ".")) { |
@@ -348,11 +348,11 @@ discard block |
||
348 | 348 | $sql_new = $sql; |
349 | 349 | |
350 | 350 | if (isset($params['limit']) && is_numeric($params['limit'])) { |
351 | - $sql_new.=" LIMIT $params[limit]"; |
|
351 | + $sql_new .= " LIMIT $params[limit]"; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | if (isset($params['offset']) && is_numeric($params['offset'])) { |
355 | - $sql_new.=" OFFSET $params[offset]"; |
|
355 | + $sql_new .= " OFFSET $params[offset]"; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | return $sql_new; |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * @param string $table |
365 | 365 | * @return boolean |
366 | 366 | */ |
367 | - public function drop_table($table, $if_exists=true) |
|
367 | + public function drop_table($table, $if_exists = true) |
|
368 | 368 | { |
369 | 369 | if ($if_exists) { |
370 | 370 | if ($this->table_exists($table)) { |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @param array $definition |
385 | 385 | * @return boolean|null |
386 | 386 | */ |
387 | - public function create_table($table, $definition, $index=array()) |
|
387 | + public function create_table($table, $definition, $index = array()) |
|
388 | 388 | { |
389 | 389 | |
390 | 390 | } |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | * @param string $table |
408 | 408 | * @return array |
409 | 409 | */ |
410 | - public function describe_table($table, $schema='') |
|
410 | + public function describe_table($table, $schema = '') |
|
411 | 411 | { |
412 | 412 | $fields = array(); |
413 | 413 | $results = $this->fetch_all("PRAGMA table_info($table)"); |
@@ -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 | } |