@@ -36,17 +36,17 @@ discard block |
||
36 | 36 | public function __construct() { |
37 | 37 | //parent::__construct(); |
38 | 38 | |
39 | - $this->_sesion=new \Sistema\Nucleo\CFSesion(); |
|
39 | + $this->_sesion = new \Sistema\Nucleo\CFSesion(); |
|
40 | 40 | } |
41 | - public function enviarCorreo($para, $titulo= 'Asunto', $mensaje= 'cuerpo del correo'){ |
|
41 | + public function enviarCorreo($para, $titulo = 'Asunto', $mensaje = 'cuerpo del correo') { |
|
42 | 42 | return mail($para, $titulo, $mensaje); |
43 | 43 | } |
44 | 44 | |
45 | 45 | |
46 | 46 | // filtros Email |
47 | 47 | |
48 | - function filtroEmail($email){ |
|
49 | - if (!filter_input(INPUT_POST, $email, FILTER_VALIDATE_EMAIL)){ |
|
48 | + function filtroEmail($email) { |
|
49 | + if (!filter_input(INPUT_POST, $email, FILTER_VALIDATE_EMAIL)) { |
|
50 | 50 | echo "E-Mail no es valido"; |
51 | 51 | } |
52 | 52 | else |
@@ -58,44 +58,44 @@ discard block |
||
58 | 58 | |
59 | 59 | //cadenas |
60 | 60 | |
61 | - function rangoTexto($texto, $inicio, $cantidad){ |
|
61 | + function rangoTexto($texto, $inicio, $cantidad) { |
|
62 | 62 | |
63 | - return $limite= substr($texto, $inicio, $cantidad); |
|
63 | + return $limite = substr($texto, $inicio, $cantidad); |
|
64 | 64 | |
65 | 65 | } |
66 | 66 | |
67 | 67 | //Redirecionar |
68 | 68 | |
69 | - function Redireccion($url, $permanent = false){ |
|
69 | + function Redireccion($url, $permanent = false) { |
|
70 | 70 | header('Location: ' . $url, true, $permanent ? 301 : 302); |
71 | 71 | |
72 | 72 | exit(); |
73 | 73 | } |
74 | 74 | |
75 | - function redireccionUrl($url){ |
|
76 | - $url=Cf_BASE_URL.$url; |
|
75 | + function redireccionUrl($url) { |
|
76 | + $url = Cf_BASE_URL . $url; |
|
77 | 77 | header('Location: ' . $url); |
78 | 78 | exit(); |
79 | 79 | } |
80 | 80 | |
81 | - function redireccionUrlMsj($controlador){ |
|
81 | + function redireccionUrlMsj($controlador) { |
|
82 | 82 | $this->_sesion->iniciarSesion('_s', false); |
83 | - $_SESSION[error_ingreso]='Error en el intento de ingreso'; |
|
84 | - $controlador=Cf_BASE_URL.$controlador; |
|
83 | + $_SESSION[error_ingreso] = 'Error en el intento de ingreso'; |
|
84 | + $controlador = Cf_BASE_URL . $controlador; |
|
85 | 85 | header('Location: ' . $controlador); |
86 | 86 | exit(); |
87 | 87 | } |
88 | 88 | |
89 | - function redireccion_($url, $statusCode = 303){ |
|
89 | + function redireccion_($url, $statusCode = 303) { |
|
90 | 90 | header('Location: ' . $url, true, $statusCode); |
91 | 91 | die(); |
92 | 92 | } |
93 | 93 | |
94 | - function redirect($controller,$method = "index",$args = array()) |
|
94 | + function redirect($controller, $method = "index", $args = array()) |
|
95 | 95 | { |
96 | 96 | global $core; /* Guess Obviously */ |
97 | 97 | |
98 | - $location = $core->Cf_BASE_URL . "/" . $controller . "/" . $method . "/" . implode("/",$args); |
|
98 | + $location = $core->Cf_BASE_URL . "/" . $controller . "/" . $method . "/" . implode("/", $args); |
|
99 | 99 | |
100 | 100 | /* |
101 | 101 | * Use @header to redirect the page: |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | |
109 | 109 | //texto |
110 | - public function filtrarEntero($int){ |
|
110 | + public function filtrarEntero($int) { |
|
111 | 111 | |
112 | 112 | return filter_var($int, FILTER_VALIDATE_INT); |
113 | 113 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | ); |
39 | 39 | |
40 | 40 | public static function configurar($clave, $valor = null) { |
41 | - if( is_array($clave) ) { |
|
41 | + if (is_array($clave)) { |
|
42 | 42 | foreach ($clave as $config_name => $config_value) { |
43 | 43 | self::$configuracion[$config_name] = $config_value; |
44 | 44 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param string $clave |
64 | 64 | */ |
65 | 65 | public static function obtener($clave, $raw = false, $tiempo_personalizado = null) { |
66 | - if( ! self::file_expired($archivo = self::obtenerRuta($clave), $tiempo_personalizado)) { |
|
66 | + if (!self::file_expired($archivo = self::obtenerRuta($clave), $tiempo_personalizado)) { |
|
67 | 67 | $contenido = file_get_contents($archivo); |
68 | 68 | return $raw ? $contenido : unserialize($contenido); |
69 | 69 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @return bool true if the data was removed successfully |
91 | 91 | */ |
92 | 92 | public static function eliminar($clave) { |
93 | - if( ! file_exists($archivo = self::obtenerRuta($clave)) ) { |
|
93 | + if (!file_exists($archivo = self::obtenerRuta($clave))) { |
|
94 | 94 | return true; |
95 | 95 | } |
96 | 96 | return @unlink($archivo); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @return bool if the file has expired or not |
118 | 118 | */ |
119 | 119 | public static function file_expired($archivo, $fecha = null) { |
120 | - if( ! file_exists($archivo) ) { |
|
120 | + if (!file_exists($archivo)) { |
|
121 | 121 | return true; |
122 | 122 | } |
123 | 123 | return (time() > (filemtime($archivo) + 60 * ($fecha ? $fecha : self::$configuracion['expires']))); |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | break; |
162 | 162 | } |
163 | 163 | echo '</div>'; |
164 | - echo '</div>'.PHP_EOL; |
|
164 | + echo '</div>' . PHP_EOL; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | // Closing form |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | // Asignamos las claves conviritiendo el array |
193 | 193 | foreach ($data as $attr=>$value) { |
194 | - $r .= $attr.'="'.$value.'" '; |
|
194 | + $r .= $attr . '="' . $value . '" '; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | $r .= '/>'; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | // Asignamos las claves conviritiendo el array |
211 | 211 | foreach ($data as $attr=>$value) { |
212 | - $base .= $attr.'="'.$value.'" '; |
|
212 | + $base .= $attr . '="' . $value . '" '; |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | if (!is_array($values)) { |
222 | 222 | // Comprobamos el value, es posible que el usuario este intentando crear los Radio (option) de forma separada |
223 | 223 | if (!is_array($values) and $selected == $values) $base .= ' checked="checked" '; |
224 | - return $base . ' value="'.$values.'" />'; |
|
224 | + return $base . ' value="' . $values . '" />'; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | // Por el contrario, tenemos 1 o m�s value con lo que es un posible texto |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | foreach ($values as $id=>$text) { |
231 | 231 | $r .= $base; |
232 | 232 | if ($selected !== null and $id == $selected) $r .= ' checked="checked" '; |
233 | - $r .= ' value="'. $id .'" />'.$text.'</label>'; |
|
233 | + $r .= ' value="' . $id . '" />' . $text . '</label>'; |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | return $r; |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $r = '<select '; |
250 | 250 | // Convert array to input string |
251 | 251 | foreach ($data as $attr=>$value) { |
252 | - $r .= $attr.'="'.$value.'" '; |
|
252 | + $r .= $attr . '="' . $value . '" '; |
|
253 | 253 | } |
254 | 254 | // Return end input |
255 | 255 | $r .= '>'; |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | |
288 | 288 | // Asignamos las claves conviritiendo el array |
289 | 289 | foreach ($data as $attr=>$value) { |
290 | - $r .= $attr.'="'.$value.'" '; |
|
290 | + $r .= $attr . '="' . $value . '" '; |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | $r .= '>'; |
@@ -304,14 +304,14 @@ discard block |
||
304 | 304 | */ |
305 | 305 | private function showStartForm() { |
306 | 306 | $r = '<form '; |
307 | - if ($this->action!= '') $r .= 'action="'.$this->action.'" '; |
|
308 | - if ($this->method != '') $r .= 'method="'.$this->method .'" '; |
|
309 | - if ($this->name != '') $r .= 'name="'.$this->name .'" '; |
|
310 | - if ($this->on_submit != '') $r .= 'onSubmit="'.$this->on_submit .'" '; |
|
311 | - if ($this->id != '') $r .= 'id="'.$this->id .'" '; |
|
312 | - if ($this->class != '') $r .= 'class="'.$this->class .'" '; |
|
313 | - |
|
314 | - return $r . '>'.PHP_EOL; |
|
307 | + if ($this->action != '') $r .= 'action="' . $this->action . '" '; |
|
308 | + if ($this->method != '') $r .= 'method="' . $this->method . '" '; |
|
309 | + if ($this->name != '') $r .= 'name="' . $this->name . '" '; |
|
310 | + if ($this->on_submit != '') $r .= 'onSubmit="' . $this->on_submit . '" '; |
|
311 | + if ($this->id != '') $r .= 'id="' . $this->id . '" '; |
|
312 | + if ($this->class != '') $r .= 'class="' . $this->class . '" '; |
|
313 | + |
|
314 | + return $r . '>' . PHP_EOL; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -408,14 +408,14 @@ discard block |
||
408 | 408 | if (isset($data['maxlength']) and is_numeric($data['maxlength']) and $data['maxlength'] > -1 |
409 | 409 | and strlen($readValue) > $data['maxlength']) { |
410 | 410 | |
411 | - $this->log('is too long. Maximum' . ' ' . $data['maxlength'] . ' ' . 'characters', $data ); |
|
411 | + $this->log('is too long. Maximum' . ' ' . $data['maxlength'] . ' ' . 'characters', $data); |
|
412 | 412 | return false; |
413 | 413 | } |
414 | 414 | |
415 | 415 | if (isset($data['pattern']) and is_numeric($data['pattern']) and $data['maxlength'] != '' |
416 | 416 | and preg_match($data['pattern'], $readValue) === FALSE) { |
417 | 417 | |
418 | - $this->log('pattern error' . ' (' . $data['pattern'] . ')' , $data); |
|
418 | + $this->log('pattern error' . ' (' . $data['pattern'] . ')', $data); |
|
419 | 419 | return false; |
420 | 420 | } |
421 | 421 | break; |
@@ -429,20 +429,20 @@ discard block |
||
429 | 429 | |
430 | 430 | // MIN |
431 | 431 | if (isset($data['min']) and $readValue < $data['min']) { |
432 | - $this->log('The number have to be greather than' . ' ' . $data['min'].'.', $data); |
|
432 | + $this->log('The number have to be greather than' . ' ' . $data['min'] . '.', $data); |
|
433 | 433 | return false; |
434 | 434 | } |
435 | 435 | |
436 | 436 | // MAX |
437 | 437 | if (isset($data['max']) and $readValue > $data['max']) { |
438 | - $this->log('The number have to be less than' . ' ' . $data['max'].'.', $data); |
|
438 | + $this->log('The number have to be less than' . ' ' . $data['max'] . '.', $data); |
|
439 | 439 | return false; |
440 | 440 | } |
441 | 441 | |
442 | 442 | // STEP http://www.w3schools.com/tags/att_input_step.asp |
443 | 443 | // Value 0 ever is valid (and if you try Divide to Zero, it will take error because the result is inifinite |
444 | 444 | if (isset($data['step']) and $readValue != 0 and $readValue % $data['step'] !== 0) { |
445 | - $this->log('The number have to be multiple of' . ' ' . $data['step'].'.', $data); |
|
445 | + $this->log('The number have to be multiple of' . ' ' . $data['step'] . '.', $data); |
|
446 | 446 | return false; |
447 | 447 | } |
448 | 448 | |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | //min | max |
452 | 452 | echo $readValue; |
453 | 453 | if (!is_date($readValue)) { |
454 | - $this->log('The date' . ' ' .$readValue.' '. 'must have format' . ' mm/dd/yyyy '.'.', $data); |
|
454 | + $this->log('The date' . ' ' . $readValue . ' ' . 'must have format' . ' mm/dd/yyyy ' . '.', $data); |
|
455 | 455 | return false; |
456 | 456 | } |
457 | 457 | break; |
@@ -489,14 +489,14 @@ discard block |
||
489 | 489 | if (is_array($value)) { |
490 | 490 | $this->log('Values don\'t match.', $data); |
491 | 491 | } else { |
492 | - $this->log('ID ' .$value.' ' . 'don\'t match', $data); |
|
492 | + $this->log('ID ' . $value . ' ' . 'don\'t match', $data); |
|
493 | 493 | } |
494 | 494 | return false; |
495 | 495 | } |
496 | 496 | } else { |
497 | 497 | // Is string |
498 | 498 | if ($readValue == $values) { |
499 | - $this->log('The value' . ' ' . $value.' ' . 'is not available', $data); |
|
499 | + $this->log('The value' . ' ' . $value . ' ' . 'is not available', $data); |
|
500 | 500 | return false; |
501 | 501 | } |
502 | 502 | } |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | * |
606 | 606 | * @example $fr->addInput('text', 'Username', '', true, 'Type here your username', array('class'=>'text red', id => 'text1'), array()) |
607 | 607 | */ |
608 | - public function addInput($label = '', $type = 'text', $name = '', $value = '', $required = false, $placeholder = '', $attributes = array()) { |
|
608 | + public function addInput($label = '', $type = 'text', $name = '', $value = '', $required = false, $placeholder = '', $attributes = array()) { |
|
609 | 609 | // Creating main data |
610 | 610 | $data = array( |
611 | 611 | 'type' => $type, |
@@ -642,10 +642,10 @@ discard block |
||
642 | 642 | * @param string $placeholder Default text to show if box is empty |
643 | 643 | * @param unknown $attributes Additional attributes |
644 | 644 | */ |
645 | - public function addNumber($label = '', $name = '', $value = '', $range = false, $required = false, $min = '', $max = '', $step = '', $placeholder = '', $attributes = array()) { |
|
645 | + public function addNumber($label = '', $name = '', $value = '', $range = false, $required = false, $min = '', $max = '', $step = '', $placeholder = '', $attributes = array()) { |
|
646 | 646 | // Creating main data |
647 | 647 | $data = array( |
648 | - 'type' => (! $range) ? 'number' : 'range', |
|
648 | + 'type' => (!$range) ? 'number' : 'range', |
|
649 | 649 | 'name' => $name, |
650 | 650 | 'value' => $value, |
651 | 651 | ); |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | * @param string $placeholder Default text to show if box is empty |
681 | 681 | * @param unknown $attributes Additional attributes |
682 | 682 | */ |
683 | - public function addDate($label = '', $name = '', $value = '', $required = false, $min = '', $max = '', $step = '', $placeholder = '', $attributes = array()) { |
|
683 | + public function addDate($label = '', $name = '', $value = '', $required = false, $min = '', $max = '', $step = '', $placeholder = '', $attributes = array()) { |
|
684 | 684 | // Creating main data |
685 | 685 | $data = array( |
686 | 686 | 'type' => 'date', |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | $this->errors .= ' ' . $message . '.'; |
897 | 897 | |
898 | 898 | // Extra message (title attribute) |
899 | - if (isset($data['title']) and $data['title'] != '') $this->errors .= ' | '. 'MESSAGE' .': ' . $data['title']; |
|
899 | + if (isset($data['title']) and $data['title'] != '') $this->errors .= ' | ' . 'MESSAGE' . ': ' . $data['title']; |
|
900 | 900 | |
901 | 901 | $this->errors .= '<br />'; |
902 | 902 | } |
@@ -913,11 +913,11 @@ discard block |
||
913 | 913 | */ |
914 | 914 | // More examples: |
915 | 915 | // http://us2.php.net/manual/es/function.checkdate.php |
916 | -function is_date( $str ) { |
|
916 | +function is_date($str) { |
|
917 | 917 | // Try to execute date creator |
918 | 918 | try { |
919 | - $dt = new DateTime( trim($str) ); |
|
920 | - } catch( Exception $e ) { |
|
919 | + $dt = new DateTime(trim($str)); |
|
920 | + } catch (Exception $e) { |
|
921 | 921 | // If fails, it return false, date is incorrect |
922 | 922 | return false; |
923 | 923 | } |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | ) |
54 | 54 | ); |
55 | 55 | |
56 | - $menu = '<ul class="inline" >'. PHP_EOL; |
|
57 | - foreach($items as $item) |
|
56 | + $menu = '<ul class="inline" >' . PHP_EOL; |
|
57 | + foreach ($items as $item) |
|
58 | 58 | { |
59 | 59 | $current = (in_array($sel, $item)) ? ' class="current"' : ''; |
60 | - $id = (!empty($item['id'])) ? ' id="'.$item['id'].'"' : ''; |
|
61 | - $menu .= '<li'.$current.'><a href="'.$item['link'].'"'.$id.'>'.$item['title'].'</a></li>'."\n"; |
|
60 | + $id = (!empty($item['id'])) ? ' id="' . $item['id'] . '"' : ''; |
|
61 | + $menu .= '<li' . $current . '><a href="' . $item['link'] . '"' . $id . '>' . $item['title'] . '</a></li>' . "\n"; |
|
62 | 62 | } |
63 | - $menu .= '</ul>'. PHP_EOL . PHP_EOL; |
|
63 | + $menu .= '</ul>' . PHP_EOL . PHP_EOL; |
|
64 | 64 | return $menu; |
65 | 65 | } |
66 | 66 | |
@@ -91,19 +91,19 @@ discard block |
||
91 | 91 | |
92 | 92 | $count = count($items); |
93 | 93 | $i = 0; |
94 | - $menu = PHP_EOL .'<p class="bottom_nav">'; |
|
95 | - foreach($items as $item) |
|
94 | + $menu = PHP_EOL . '<p class="bottom_nav">'; |
|
95 | + foreach ($items as $item) |
|
96 | 96 | { |
97 | 97 | $current = (in_array($sel, $item)) ? ' class="current"' : ''; |
98 | - $id = (!empty($item['id'])) ? ' id="'.$item['id'].'"' : ''; |
|
99 | - $menu .= '<a'.$current.' href="'.$item['link'].'"'.$id.'>'.$item['title'].'</a>'; |
|
98 | + $id = (!empty($item['id'])) ? ' id="' . $item['id'] . '"' : ''; |
|
99 | + $menu .= '<a' . $current . ' href="' . $item['link'] . '"' . $id . '>' . $item['title'] . '</a>'; |
|
100 | 100 | $i++; |
101 | - if($count != $i) |
|
101 | + if ($count != $i) |
|
102 | 102 | { |
103 | - $menu .= ' '.$separador.' '; |
|
103 | + $menu .= ' ' . $separador . ' '; |
|
104 | 104 | } |
105 | 105 | } |
106 | - $menu .= '</p>'. PHP_EOL ; |
|
106 | + $menu .= '</p>' . PHP_EOL; |
|
107 | 107 | return $menu; |
108 | 108 | } |
109 | 109 |
@@ -193,27 +193,27 @@ discard block |
||
193 | 193 | if ($end > $this->total_pages) $end = $this->total_pages; |
194 | 194 | |
195 | 195 | // Showing all clickable pages (create div if class is defined) |
196 | - if ($this->style != '') $r = '<div class="'.$this->style.'">'; |
|
196 | + if ($this->style != '') $r = '<div class="' . $this->style . '">'; |
|
197 | 197 | else $r = ''; |
198 | 198 | |
199 | 199 | |
200 | 200 | // First / previous |
201 | 201 | if ($this->cur_page > 1) { |
202 | - if ($this->first != '') $r .= '<a class="first" href="' . $url_start . '1' . $url_end . '">'.$this->first.'</a> '; |
|
203 | - if ($this->previous != '') $r .= '<a class="previous" href="' . $url_start . ($cur_page - 1) . $url_end . '">'.$this->previous.'</a> '; |
|
202 | + if ($this->first != '') $r .= '<a class="first" href="' . $url_start . '1' . $url_end . '">' . $this->first . '</a> '; |
|
203 | + if ($this->previous != '') $r .= '<a class="previous" href="' . $url_start . ($cur_page - 1) . $url_end . '">' . $this->previous . '</a> '; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | // You can optimize this separating BEFORE and AFTER current page in two for (to avoid load "if" in each loop) |
207 | 207 | // but it would be difficult on changes |
208 | - for ($n=$start; $n<=$end; $n++) { |
|
209 | - if ($n != $cur_page) $r .= '<a class="link" href="'. $url_start . $n . $url_end . '">'.$n.'</a> '; |
|
210 | - else $r .= '<a class="current">'.$n.'</a> '; |
|
208 | + for ($n = $start; $n <= $end; $n++) { |
|
209 | + if ($n != $cur_page) $r .= '<a class="link" href="' . $url_start . $n . $url_end . '">' . $n . '</a> '; |
|
210 | + else $r .= '<a class="current">' . $n . '</a> '; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | // next / last |
214 | 214 | if ($this->cur_page < $this->total_pages) { |
215 | - if ($this->next != '') $r .= '<a class="next" href="' . $url_start . ($cur_page + 1) . $url_end . '">'.$this->next.'</a> '; |
|
216 | - if ($this->last != '') $r .= '<a class="last" href="' . $url_start . $this->total_pages . $url_end .'">'.$this->last.'</a> '; |
|
215 | + if ($this->next != '') $r .= '<a class="next" href="' . $url_start . ($cur_page + 1) . $url_end . '">' . $this->next . '</a> '; |
|
216 | + if ($this->last != '') $r .= '<a class="last" href="' . $url_start . $this->total_pages . $url_end . '">' . $this->last . '</a> '; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | // End div (if exist) |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $records = $this->records; |
254 | 254 | |
255 | 255 | // Force maxium records loaded (only if is specified by user) |
256 | - if ($max_records > 0 and $max_records > $total_records) |
|
256 | + if ($max_records > 0 and $max_records > $total_records) |
|
257 | 257 | $this->total_records = $max_records; |
258 | 258 | |
259 | 259 | // Calculate total pages that have |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | // Saving changes |
277 | 277 | $this->first_record = $start; |
278 | - $this->limit = ' LIMIT '.$start.','.$records.' '; |
|
278 | + $this->limit = ' LIMIT ' . $start . ',' . $records . ' '; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -296,17 +296,17 @@ discard block |
||
296 | 296 | // And is empty, we have to Recicle ALL GET |
297 | 297 | // To know that page needs to be replaced we will use the "original_page" (the real get) |
298 | 298 | // Cortamos "pag=2" para obtener lo que va antes y despues, as� poder modificar directamente ese pag=2 por la pagina actual |
299 | - $query_string = explode($this->get_name.'='.$this->original_page, $_SERVER['QUERY_STRING']); |
|
299 | + $query_string = explode($this->get_name . '=' . $this->original_page, $_SERVER['QUERY_STRING']); |
|
300 | 300 | |
301 | 301 | // How start the new URL? To know it, we need to see the last character from current string |
302 | 302 | if (!in_array(substr($query_string[0], -1), array('?', '&'))) { |
303 | 303 | // Current string haven't any at end and it isn't "&" or "?" ? |
304 | 304 | // If initial string have one character at least it means that not is the first index |
305 | - if (isset($query_string[0][0])) $this->url_start = '?'.$query_string[0].'&'; |
|
306 | - else $this->url_start = '?'.$query_string[0]; |
|
305 | + if (isset($query_string[0][0])) $this->url_start = '?' . $query_string[0] . '&'; |
|
306 | + else $this->url_start = '?' . $query_string[0]; |
|
307 | 307 | } else { |
308 | 308 | // Current string already have ? or &, |
309 | - $this->url_start = '?'.$query_string[0]; |
|
309 | + $this->url_start = '?' . $query_string[0]; |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | $this->url_end = isset($query_string[1]) ? $query_string[1] : ''; |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | foreach ($gets as $get) { |
319 | 319 | if ($get != $get_name) { |
320 | 320 | // Trying to get the GET |
321 | - if (isset($_GET[$get])) $tmp .= $get.'='.$_GET[$get].'&'; |
|
321 | + if (isset($_GET[$get])) $tmp .= $get . '=' . $_GET[$get] . '&'; |
|
322 | 322 | } else { |
323 | 323 | // Pour the $tmp content to $tmp_start |
324 | 324 | if ($tmp_start == '') $tmp_start .= '?'; |
@@ -333,16 +333,16 @@ discard block |
||
333 | 333 | $this->url_start = $tmp_start; |
334 | 334 | $this->url_end = $tmp; |
335 | 335 | } |
336 | - else $this->url_start = '?'.$tmp; |
|
336 | + else $this->url_start = '?' . $tmp; |
|
337 | 337 | } |
338 | - } else{ |
|
338 | + } else { |
|
339 | 339 | // Non recicle |
340 | 340 | $this->url_start = '?'; |
341 | 341 | $this->url_end = ''; |
342 | 342 | } |
343 | 343 | |
344 | 344 | // Add the pagination |
345 | - $this->url_start .= $this->get_name.'='; |
|
345 | + $this->url_start .= $this->get_name . '='; |
|
346 | 346 | } |
347 | 347 | } |
348 | 348 | } |
@@ -30,20 +30,20 @@ discard block |
||
30 | 30 | //Seguridad |
31 | 31 | |
32 | 32 | //xss funciones de mitigacion |
33 | - function xsseguro($texto,$encoding='UTF-8'){ |
|
34 | - return htmlspecialchars($texto,ENT_QUOTES | ENT_HTML401,$encoding); |
|
33 | + function xsseguro($texto, $encoding = 'UTF-8') { |
|
34 | + return htmlspecialchars($texto, ENT_QUOTES | ENT_HTML401, $encoding); |
|
35 | 35 | } |
36 | - function xecho($texto){ |
|
36 | + function xecho($texto) { |
|
37 | 37 | echo xsseguro($texto); |
38 | 38 | } |
39 | 39 | |
40 | - public function filtrarTexto($texto){ |
|
40 | + public function filtrarTexto($texto) { |
|
41 | 41 | return strip_tags($texto); |
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | 45 | |
46 | - public function filtrarCaracteresEspeciales($texto){ |
|
46 | + public function filtrarCaracteresEspeciales($texto) { |
|
47 | 47 | return htmlspecialchars($texto, ENT_QUOTES); |
48 | 48 | } |
49 | 49 | |
@@ -59,67 +59,67 @@ discard block |
||
59 | 59 | return $cadenaAleatoria; |
60 | 60 | } |
61 | 61 | // encriptacion |
62 | - function cifrado($clave){ |
|
63 | - $cfi=sha1(md5($clave)); |
|
64 | - return $clave=Cf_KEY_MD5.$cfi; |
|
62 | + function cifrado($clave) { |
|
63 | + $cfi = sha1(md5($clave)); |
|
64 | + return $clave = Cf_KEY_MD5 . $cfi; |
|
65 | 65 | } |
66 | 66 | // Protecion CSRF |
67 | 67 | public function generoTokenDeFormulario($formulario) { |
68 | - $secreta = Cf_CSRF_SECRET.$this->generarCadenaAleatoria(); |
|
68 | + $secreta = Cf_CSRF_SECRET . $this->generarCadenaAleatoria(); |
|
69 | 69 | $sid = session_id(); |
70 | - $token = md5($secreta.$sid.$formulario); |
|
70 | + $token = md5($secreta . $sid . $formulario); |
|
71 | 71 | return $token; |
72 | 72 | } |
73 | 73 | |
74 | 74 | public function verificoTokenDeFormulario($formulario, $token) { |
75 | - $secreta = Cf_CSRF_SECRET.$this->generarCadenaAleatoria(); |
|
75 | + $secreta = Cf_CSRF_SECRET . $this->generarCadenaAleatoria(); |
|
76 | 76 | $sid = session_id(); |
77 | - $correcta = md5($secreta.$sid.$formulario); |
|
77 | + $correcta = md5($secreta . $sid . $formulario); |
|
78 | 78 | return ($token == $correcta); |
79 | 79 | } |
80 | 80 | |
81 | - function obtenerDireccionIP(){ |
|
82 | - if (!empty($_SERVER ['HTTP_CLIENT_IP'] )) |
|
83 | - $ip=$_SERVER ['HTTP_CLIENT_IP']; |
|
84 | - elseif (!empty($_SERVER ['HTTP_X_FORWARDED_FOR'] )) |
|
85 | - $ip=$_SERVER ['HTTP_X_FORWARDED_FOR']; |
|
81 | + function obtenerDireccionIP() { |
|
82 | + if (!empty($_SERVER ['HTTP_CLIENT_IP'])) |
|
83 | + $ip = $_SERVER ['HTTP_CLIENT_IP']; |
|
84 | + elseif (!empty($_SERVER ['HTTP_X_FORWARDED_FOR'])) |
|
85 | + $ip = $_SERVER ['HTTP_X_FORWARDED_FOR']; |
|
86 | 86 | else |
87 | - $ip=$_SERVER ['REMOTE_ADDR']; |
|
87 | + $ip = $_SERVER ['REMOTE_ADDR']; |
|
88 | 88 | |
89 | 89 | return $ip; |
90 | 90 | } |
91 | 91 | |
92 | - function restringirIp($ip){ |
|
92 | + function restringirIp($ip) { |
|
93 | 93 | $ipCliente = $this->obtenerDireccionIP(); |
94 | 94 | |
95 | - if($ipCliente == $ip){ |
|
95 | + if ($ipCliente == $ip) { |
|
96 | 96 | return true; |
97 | 97 | } |
98 | - else{ |
|
98 | + else { |
|
99 | 99 | header('location: http://www.tusitioweb/redireccion'); |
100 | 100 | exit; |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | - function restringirConjuntoIps($ips){ |
|
104 | + function restringirConjuntoIps($ips) { |
|
105 | 105 | $ipCliente = obtenerDireccionIP(); |
106 | 106 | |
107 | - if (in_array($ipCliente,$ips)){ |
|
107 | + if (in_array($ipCliente, $ips)) { |
|
108 | 108 | return true; |
109 | 109 | } |
110 | - else{ |
|
110 | + else { |
|
111 | 111 | header('location: http://direccion_envio_salida'); |
112 | 112 | exit; |
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | - function restringirRango(){ |
|
116 | + function restringirRango() { |
|
117 | 117 | $ipCliente = obtenerDireccionIP(); |
118 | 118 | |
119 | - if(substr($ipCliente, 0, 8 ) == "150.214."){ |
|
119 | + if (substr($ipCliente, 0, 8) == "150.214.") { |
|
120 | 120 | return true; |
121 | 121 | } |
122 | - else{ |
|
122 | + else { |
|
123 | 123 | header('location: http://direccion_envio_salida'); |
124 | 124 | exit; |
125 | 125 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * |
137 | 137 | */ |
138 | 138 | function emailSeguro($cadena) { |
139 | - return preg_replace( '((?:\n|\r|\t|%0A|%0D|%08|%09)+)i' , '', $cadena ); |
|
139 | + return preg_replace('((?:\n|\r|\t|%0A|%0D|%08|%09)+)i', '', $cadena); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /*** example usage |
@@ -27,7 +27,7 @@ |
||
27 | 27 | |
28 | 28 | class CFPHPVinculos { |
29 | 29 | |
30 | - function get_dominio(){ |
|
30 | + function get_dominio() { |
|
31 | 31 | |
32 | 32 | $dominio = "http://www.my-site-domain.com/"; |
33 | 33 | return $dominio; |
@@ -32,31 +32,31 @@ |
||
32 | 32 | { |
33 | 33 | $controlador = $peticion->getControlador() . 'Controlador'; |
34 | 34 | //definimos la ruta al controlador |
35 | - $rutaControlador = SITE_ROOT . 'mvc' . DS .'controladores' . DS . $controlador . '.php'; |
|
35 | + $rutaControlador = SITE_ROOT . 'mvc' . DS . 'controladores' . DS . $controlador . '.php'; |
|
36 | 36 | $metodo = $peticion->getMetodo(); |
37 | 37 | $args = $peticion->getArgumentos(); |
38 | 38 | |
39 | 39 | //verifcamos que el archivo existe con la funcion de PHP is_readable |
40 | - if(is_readable($rutaControlador)){ |
|
40 | + if (is_readable($rutaControlador)) { |
|
41 | 41 | require_once $rutaControlador; |
42 | 42 | $controlador = new $controlador; |
43 | 43 | |
44 | - if(is_callable(array($controlador, $metodo))){ |
|
44 | + if (is_callable(array($controlador, $metodo))) { |
|
45 | 45 | $metodo = $peticion->getMetodo(); |
46 | 46 | } |
47 | - else{ |
|
47 | + else { |
|
48 | 48 | $metodo = 'index'; |
49 | 49 | } |
50 | 50 | |
51 | - if(isset($args)){ |
|
51 | + if (isset($args)) { |
|
52 | 52 | call_user_func_array(array($controlador, $metodo), $args); |
53 | 53 | } |
54 | - else{ |
|
54 | + else { |
|
55 | 55 | call_user_func(array($controlador, $metodo)); |
56 | 56 | } |
57 | 57 | |
58 | 58 | } else { |
59 | - header('Location: '. Cf_BASE_URL.'error/'); |
|
59 | + header('Location: ' . Cf_BASE_URL . 'error/'); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | } |
63 | 63 | \ No newline at end of file |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | $this->_vista = new CFVista(new CFSolicitud); |
35 | 35 | } |
36 | 36 | |
37 | - protected function cargaLib($libreria){ |
|
37 | + protected function cargaLib($libreria) { |
|
38 | 38 | $rutaLib = RUTA_LIBS . $libreria . '.php'; |
39 | - if(is_readable($rutaLib)){ |
|
39 | + if (is_readable($rutaLib)) { |
|
40 | 40 | require_once $rutaLib; |
41 | 41 | //echo 'libreria cargada'; |
42 | 42 | } |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | - protected function cargaModelo($modelo){ |
|
49 | - $modelo=$modelo.'Modelo'; |
|
48 | + protected function cargaModelo($modelo) { |
|
49 | + $modelo = $modelo . 'Modelo'; |
|
50 | 50 | $rutaMod = RUTA_MOD . $modelo . '.php'; |
51 | - if(is_readable($rutaMod)){ |
|
51 | + if (is_readable($rutaMod)) { |
|
52 | 52 | require_once $rutaMod; |
53 | 53 | $modelo = new $modelo; |
54 | 54 | return $modelo; |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | - protected function cargaAyudante($ayudante){ |
|
66 | + protected function cargaAyudante($ayudante) { |
|
67 | 67 | $rutaAyudante = RUTA_AYUDANTES . $ayudante . '.php'; |
68 | - if(is_readable($rutaAyudante)){ |
|
68 | + if (is_readable($rutaAyudante)) { |
|
69 | 69 | require_once $rutaAyudante; |
70 | 70 | //echo 'libreria cargada'; |
71 | 71 | } |