GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( e01879...7e1050 )
by Calima
08:53
created
Sistema/Ayudantes/CFPHPAyuda.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     }
44 44
     
45 45
     
46
-     // filtros Email
46
+        // filtros Email
47 47
     
48 48
     function filtroEmail($email){
49 49
         if (!filter_input(INPUT_POST, $email, FILTER_VALIDATE_EMAIL)){
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     //texto
110 110
     public function filtrarEntero($int){
111 111
         
112
-       return filter_var($int, FILTER_VALIDATE_INT);
112
+        return filter_var($int, FILTER_VALIDATE_INT);
113 113
        
114 114
     }
115 115
     
Please login to merge, or discard this patch.
Sistema/Ayudantes/CFPHPCache.php 1 patch
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -26,100 +26,100 @@
 block discarded – undo
26 26
 namespace Sistema\Ayudantes;
27 27
 
28 28
 class CFPHPCache {
29
-	/**
30
-	 * Configuracion
31
-	 *
32
-	 * @access public
33
-	 */
34
-	public static $configuracion = array(
35
-		'cache_dir' => 'cache',
36
-		// por defecto el tiempo expira en  *minutos*
37
-		'expires' => 180,
38
-	);
29
+    /**
30
+     * Configuracion
31
+     *
32
+     * @access public
33
+     */
34
+    public static $configuracion = array(
35
+        'cache_dir' => 'cache',
36
+        // por defecto el tiempo expira en  *minutos*
37
+        'expires' => 180,
38
+    );
39 39
 	
40
-	public static function configurar($clave, $valor = null) {
41
-		if( is_array($clave) ) {
42
-			foreach ($clave as $config_name => $config_value) {
43
-				self::$configuracion[$config_name] = $config_value;
44
-			}
45
-		} else {
46
-			self::$configuracion[$clave] = $valor;
47
-		}
48
-	}
49
-	/**
50
-	 * obtiene la ruta del archivo asociado a la clave.
51
-	 *
52
-	 * @access public
53
-	 * @param string $clave
54
-	 * @return string el nombre del archivo php
55
-	 */
56
-	public static function obtenerRuta($clave) {
57
-		return static::$configuracion['cache_path'] . '/' . md5($clave) . '.php';
58
-	}
59
-	/**
60
-	 * obtiene los datos asociados a la clave
61
-	 *
62
-	 * @access public
63
-	 * @param string $clave	 
64
-	 */
65
-	public static function obtener($clave, $raw = false, $tiempo_personalizado = null) {
66
-		if( ! self::file_expired($archivo = self::obtenerRuta($clave), $tiempo_personalizado)) {
67
-			$contenido = file_get_contents($archivo);
68
-			return $raw ? $contenido : unserialize($contenido);
69
-		}
70
-		return null;
71
-	}
72
-	/**
73
-	 * Envia el contenido dentro de la cache
74
-	 *
75
-	 * @access public
76
-	 * @param string $clave
77
-	 * @param mixed $content the the content you want to store
78
-	 * @param bool $raw whether if you want to store raw data or not. If it is true, $content *must* be a string
79
-	 *        It can be useful for static html caching.
80
-	 * @return bool whether if the operation was successful or not
81
-	 */
82
-	public static function enviar($clave, $contenido, $raw = false) {
83
-		return @file_put_contents(self::obtenerRuta($clave), $raw ? $contenido : serialize($contenido)) !== false;
84
-	}
85
-	/**
86
-	 * Delete data from cache
87
-	 *
88
-	 * @access public
89
-	 * @param string $clave
90
-	 * @return bool true if the data was removed successfully
91
-	 */
92
-	public static function eliminar($clave) {
93
-		if( ! file_exists($archivo = self::obtenerRuta($clave)) ) {
94
-			return true;
95
-		}
96
-		return @unlink($archivo);
97
-	}
98
-	/**
99
-	 * limpia la cache
100
-	 *
101
-	 * @access public
102
-	 * @return bool always true
103
-	 */
104
-	public static function limpiar() {
105
-		$cache_files = glob(self::$configuracion['cache_path'] . '/*.php', GLOB_NOSORT);
106
-		foreach ($cache_files as $archivo) {
107
-			@unlink($archivo);
108
-		}
109
-		return true;
110
-	}
111
-	/**
112
-	 * Check if a file has expired or not.
113
-	 *
114
-	 * @access public
115
-	 * @param $archivo the rout to the file
116
-	 * @param int $fecha the number of minutes it was set to expire
117
-	 * @return bool if the file has expired or not
118
-	 */
119
-	public static function file_expired($archivo, $fecha = null) {
120
-		if( ! file_exists($archivo) ) {
121
-			return true;
122
-		}
123
-		return (time() > (filemtime($archivo) + 60 * ($fecha ? $fecha : self::$configuracion['expires'])));
124
-	}
40
+    public static function configurar($clave, $valor = null) {
41
+        if( is_array($clave) ) {
42
+            foreach ($clave as $config_name => $config_value) {
43
+                self::$configuracion[$config_name] = $config_value;
44
+            }
45
+        } else {
46
+            self::$configuracion[$clave] = $valor;
47
+        }
48
+    }
49
+    /**
50
+     * obtiene la ruta del archivo asociado a la clave.
51
+     *
52
+     * @access public
53
+     * @param string $clave
54
+     * @return string el nombre del archivo php
55
+     */
56
+    public static function obtenerRuta($clave) {
57
+        return static::$configuracion['cache_path'] . '/' . md5($clave) . '.php';
58
+    }
59
+    /**
60
+     * obtiene los datos asociados a la clave
61
+     *
62
+     * @access public
63
+     * @param string $clave	 
64
+     */
65
+    public static function obtener($clave, $raw = false, $tiempo_personalizado = null) {
66
+        if( ! self::file_expired($archivo = self::obtenerRuta($clave), $tiempo_personalizado)) {
67
+            $contenido = file_get_contents($archivo);
68
+            return $raw ? $contenido : unserialize($contenido);
69
+        }
70
+        return null;
71
+    }
72
+    /**
73
+     * Envia el contenido dentro de la cache
74
+     *
75
+     * @access public
76
+     * @param string $clave
77
+     * @param mixed $content the the content you want to store
78
+     * @param bool $raw whether if you want to store raw data or not. If it is true, $content *must* be a string
79
+     *        It can be useful for static html caching.
80
+     * @return bool whether if the operation was successful or not
81
+     */
82
+    public static function enviar($clave, $contenido, $raw = false) {
83
+        return @file_put_contents(self::obtenerRuta($clave), $raw ? $contenido : serialize($contenido)) !== false;
84
+    }
85
+    /**
86
+     * Delete data from cache
87
+     *
88
+     * @access public
89
+     * @param string $clave
90
+     * @return bool true if the data was removed successfully
91
+     */
92
+    public static function eliminar($clave) {
93
+        if( ! file_exists($archivo = self::obtenerRuta($clave)) ) {
94
+            return true;
95
+        }
96
+        return @unlink($archivo);
97
+    }
98
+    /**
99
+     * limpia la cache
100
+     *
101
+     * @access public
102
+     * @return bool always true
103
+     */
104
+    public static function limpiar() {
105
+        $cache_files = glob(self::$configuracion['cache_path'] . '/*.php', GLOB_NOSORT);
106
+        foreach ($cache_files as $archivo) {
107
+            @unlink($archivo);
108
+        }
109
+        return true;
110
+    }
111
+    /**
112
+     * Check if a file has expired or not.
113
+     *
114
+     * @access public
115
+     * @param $archivo the rout to the file
116
+     * @param int $fecha the number of minutes it was set to expire
117
+     * @return bool if the file has expired or not
118
+     */
119
+    public static function file_expired($archivo, $fecha = null) {
120
+        if( ! file_exists($archivo) ) {
121
+            return true;
122
+        }
123
+        return (time() > (filemtime($archivo) + 60 * ($fecha ? $fecha : self::$configuracion['expires'])));
124
+    }
125 125
 }
Please login to merge, or discard this patch.
Sistema/Ayudantes/CFPHPFormularios.php 1 patch
Indentation   +823 added lines, -823 removed lines patch added patch discarded remove patch
@@ -25,26 +25,26 @@  discard block
 block discarded – undo
25 25
 
26 26
 // se agradece a ArrayZone por el aporte de esta clase
27 27
 
28
- /**
29
- * @name Form Generator for Kernel Web
30
- * @version A.1.0
31
- * @copyright ArrayZone 2014
32
- * @license AZPL or later; see License.txt or http://arrayzone.com/license
33
- * @category plugin
34
- * 
35
- * Description: This script write a FORM HTML automatically from array (it will be generated trhoug functions).
36
- * It write any type of items basics of HTML4 and some of HTML5.
37
- * Once user clic "submit", all information  will be validated via PHP
38
- * Some types like "required" and "email" validated trhough PHP to avoid problems with navigator compatibilities or hacker attacks
39
- *
40
- * NEXT VERSION: If you can use JavaScript and have JQuery implemented, the form can write JavaScript code to validate all
41
- * Read the documentation for all information in kernel.arrayzone.com
42
- * or all coments of all parameters and functions.
43
- * 
44
- * IMPORTANT: If you use a specific system to get POST and GET, you have to edit "private function getData()"
45
- * IMPORTANT 2: If you use DISABLE, control it manually when you save it
46
- * IMPORTANT 3: Currently aren't supported array names (name="MyField[]"), you can use: name="MyField_1"
47
- */
28
+    /**
29
+     * @name Form Generator for Kernel Web
30
+     * @version A.1.0
31
+     * @copyright ArrayZone 2014
32
+     * @license AZPL or later; see License.txt or http://arrayzone.com/license
33
+     * @category plugin
34
+     * 
35
+     * Description: This script write a FORM HTML automatically from array (it will be generated trhoug functions).
36
+     * It write any type of items basics of HTML4 and some of HTML5.
37
+     * Once user clic "submit", all information  will be validated via PHP
38
+     * Some types like "required" and "email" validated trhough PHP to avoid problems with navigator compatibilities or hacker attacks
39
+     *
40
+     * NEXT VERSION: If you can use JavaScript and have JQuery implemented, the form can write JavaScript code to validate all
41
+     * Read the documentation for all information in kernel.arrayzone.com
42
+     * or all coments of all parameters and functions.
43
+     * 
44
+     * IMPORTANT: If you use a specific system to get POST and GET, you have to edit "private function getData()"
45
+     * IMPORTANT 2: If you use DISABLE, control it manually when you save it
46
+     * IMPORTANT 3: Currently aren't supported array names (name="MyField[]"), you can use: name="MyField_1"
47
+     */
48 48
 
49 49
  
50 50
  
@@ -52,855 +52,855 @@  discard block
 block discarded – undo
52 52
 
53 53
 class CFPHPFormularios
54 54
 {
55
-	/*
55
+    /*
56 56
 	 * Form configuration. It don't need description
57 57
 	 */
58
-	public $method = 'post'; // post / get (CAUTION!!: Case sensitive)
59
-	public $action = '';
60
-	public $name = '';
61
-	public $on_submit = '';
62
-	public $id = '';
63
-	public $class = '';
64
-	
65
-	/**
66
-	 * Logging control
67
-	 * @logErrors boolean If is true, $errors will store errors
68
-	 * @errors string Contain al errors
69
-	 */
70
-	public $logErrors = true;
71
-	public $errors = '';
72
-	
73
-	/*
58
+    public $method = 'post'; // post / get (CAUTION!!: Case sensitive)
59
+    public $action = '';
60
+    public $name = '';
61
+    public $on_submit = '';
62
+    public $id = '';
63
+    public $class = '';
64
+	
65
+    /**
66
+     * Logging control
67
+     * @logErrors boolean If is true, $errors will store errors
68
+     * @errors string Contain al errors
69
+     */
70
+    public $logErrors = true;
71
+    public $errors = '';
72
+	
73
+    /*
74 74
 	 * Other configurations about form
75 75
 	 */
76 76
 	
77
-	/**
78
-	 * @show_labels boolean
79
-	 * @tutorial If is true, it show label text of some inputs before input tag
80
-	 */
81
-	public $show_labels = true;
77
+    /**
78
+     * @show_labels boolean
79
+     * @tutorial If is true, it show label text of some inputs before input tag
80
+     */
81
+    public $show_labels = true;
82 82
 	
83
-	/** IN DEVELOPMENT
84
-	 * @self_show boolean
85
-	 * @tutorial if is true, it show the input when function addX is called
86
-	 */
87
-	//public $self_show = false;
83
+    /** IN DEVELOPMENT
84
+     * @self_show boolean
85
+     * @tutorial if is true, it show the input when function addX is called
86
+     */
87
+    //public $self_show = false;
88 88
 	
89 89
 	
90
-	/** IN DEVELOPMENT
91
-	 * @only_show boolean
92
-	 * @tutorial If is true, it don't save the configuration to input (so showForm() and validateData() don't work)
93
-	 */
94
-	//public $only_show = false;
90
+    /** IN DEVELOPMENT
91
+     * @only_show boolean
92
+     * @tutorial If is true, it don't save the configuration to input (so showForm() and validateData() don't work)
93
+     */
94
+    //public $only_show = false;
95 95
 
96 96
 	
97
-	/*
97
+    /*
98 98
 	 * Content
99 99
 	 * It can be set manually or automatically trhough functions
100 100
 	 */
101
-	public $content = array();
101
+    public $content = array();
102 102
 	
103 103
 /*
104 104
  * Start functions
105 105
  */
106 106
 	
107
-	/**
108
-	 * @name showArray
109
-	 * @tutorial This function show array result, it can be copied and you can replace all generator functions to this array
110
-	 * @example $fg->showArray();
111
-	 */
112
-	public function showArray($array = false) {
113
-		print_r($this->content);
114
-	}
115
-	
116
-	
117
-	/**
118
-	 * @name showForm
119
-	 * @tutorial This function generate the form
120
-	 * @example $fg->showForm();
121
-	 */
122
-	public function showForm() {
123
-		// Loading all arrays
124
-		$toShow = $this->content;
125
-		
126
-		// Showing form
127
-		echo $this->showStartForm();
128
-		
129
-		
130
-		// Itearate all inputs
131
-		foreach ($toShow as $input) {
132
-			// Reading data
133
-			if (isset($input['data'])) $data = $input['data'];
107
+    /**
108
+     * @name showArray
109
+     * @tutorial This function show array result, it can be copied and you can replace all generator functions to this array
110
+     * @example $fg->showArray();
111
+     */
112
+    public function showArray($array = false) {
113
+        print_r($this->content);
114
+    }
115
+	
116
+	
117
+    /**
118
+     * @name showForm
119
+     * @tutorial This function generate the form
120
+     * @example $fg->showForm();
121
+     */
122
+    public function showForm() {
123
+        // Loading all arrays
124
+        $toShow = $this->content;
125
+		
126
+        // Showing form
127
+        echo $this->showStartForm();
128
+		
129
+		
130
+        // Itearate all inputs
131
+        foreach ($toShow as $input) {
132
+            // Reading data
133
+            if (isset($input['data'])) $data = $input['data'];
134 134
 			
135
-			// New row
136
-			echo '<div>';
137
-				// Showing labels
138
-				if ($this->show_labels) {
139
-					echo '<div>';
140
-						if (isset($input['label']) and $input['label'] != '') echo $input['label'];
141
-					echo '</div>';
142
-				}
135
+            // New row
136
+            echo '<div>';
137
+                // Showing labels
138
+                if ($this->show_labels) {
139
+                    echo '<div>';
140
+                        if (isset($input['label']) and $input['label'] != '') echo $input['label'];
141
+                    echo '</div>';
142
+                }
143 143
 				
144
-				// Showing content
145
-				echo '<div>';		
146
-					switch ($input['type']) {
147
-						case 'input':
148
-							echo $this->showInput($data);
149
-							break;
150
-						case 'radio':
151
-							echo $this->showRadio($data, $input['values'], $input['selected']);
152
-							break;
153
-						case 'select';
154
-							echo $this->showSelect($data, $input['values'], $input['selected']);
155
-							break;
156
-						case 'textarea':
157
-							echo $this->showTextArea($input['text'], $data);
158
-							break;
159
-						case 'separator';
160
-							echo '<br />';
161
-							break;
162
-					}
163
-				echo '</div>';
164
-			echo '</div>'.PHP_EOL;
165
-		}
166
-		
167
-		// Closing form
168
-		echo $this->showEndForm();
169
-	}
170
-	
171
-	
172
-	/* 
144
+                // Showing content
145
+                echo '<div>';		
146
+                    switch ($input['type']) {
147
+                        case 'input':
148
+                            echo $this->showInput($data);
149
+                            break;
150
+                        case 'radio':
151
+                            echo $this->showRadio($data, $input['values'], $input['selected']);
152
+                            break;
153
+                        case 'select';
154
+                            echo $this->showSelect($data, $input['values'], $input['selected']);
155
+                            break;
156
+                        case 'textarea':
157
+                            echo $this->showTextArea($input['text'], $data);
158
+                            break;
159
+                        case 'separator';
160
+                            echo '<br />';
161
+                            break;
162
+                    }
163
+                echo '</div>';
164
+            echo '</div>'.PHP_EOL;
165
+        }
166
+		
167
+        // Closing form
168
+        echo $this->showEndForm();
169
+    }
170
+	
171
+	
172
+    /* 
173 173
 	 * The following "showX" functions are autoloaded and show the different parts of form
174 174
 	 */ 
175 175
 	
176
-	/**
177
-	 * @name showInput
178
-	 * @tutorial This function show <input> tag with parameters specifics
179
-	 * @param array $data All data to show in the input
180
-	 * @return string
181
-	 */
182
-	private function showInput($data) {
183
-		$r = '';
184
-		// Number start if is range
185
-		if ($data['type'] == 'range' and isset($data['min'])) $r .= $data['min'] . ' '; 
176
+    /**
177
+     * @name showInput
178
+     * @tutorial This function show <input> tag with parameters specifics
179
+     * @param array $data All data to show in the input
180
+     * @return string
181
+     */
182
+    private function showInput($data) {
183
+        $r = '';
184
+        // Number start if is range
185
+        if ($data['type'] == 'range' and isset($data['min'])) $r .= $data['min'] . ' '; 
186 186
 		
187
-		$r .= '<input ';
187
+        $r .= '<input ';
188 188
 		
189
-		// Reading value sended by user, if are any, we load it temporaly to show in form
190
-		$data['value'] = $this->getData($data['name'], $data['value']);
189
+        // Reading value sended by user, if are any, we load it temporaly to show in form
190
+        $data['value'] = $this->getData($data['name'], $data['value']);
191 191
 		
192
-		// Asignamos las claves conviritiendo el array
193
-		foreach ($data as $attr=>$value) {
194
-			$r .= $attr.'="'.$value.'" ';
195
-		}
192
+        // Asignamos las claves conviritiendo el array
193
+        foreach ($data as $attr=>$value) {
194
+            $r .= $attr.'="'.$value.'" ';
195
+        }
196 196
 		
197
-		$r .= '/>';
197
+        $r .= '/>';
198 198
 		
199
-		// Number end if is range
200
-		if ($data['type'] == 'range' and isset($data['max'])) $r .= $data['max'] . ' ';
199
+        // Number end if is range
200
+        if ($data['type'] == 'range' and isset($data['max'])) $r .= $data['max'] . ' ';
201 201
 		
202
-		// Return
203
-		return $r;
204
-	}
202
+        // Return
203
+        return $r;
204
+    }
205 205
 	
206
-	private function showRadio($data, $values, $selected) {		
207
-		// Primero generamos un esquema
208
-		$base = '<label><input type="radio"';
206
+    private function showRadio($data, $values, $selected) {		
207
+        // Primero generamos un esquema
208
+        $base = '<label><input type="radio"';
209 209
 		
210
-		// Asignamos las claves conviritiendo el array
211
-		foreach ($data as $attr=>$value) {
212
-			$base .= $attr.'="'.$value.'" ';
213
-		}
210
+        // Asignamos las claves conviritiendo el array
211
+        foreach ($data as $attr=>$value) {
212
+            $base .= $attr.'="'.$value.'" ';
213
+        }
214 214
 		
215 215
 		
216
-		// Leemos el valor enviado por el usuario (si lo hay) y si hay, reemplazamos $select por el valor 
217
-		$selected = $this->getData($data['name'], $selected);
216
+        // Leemos el valor enviado por el usuario (si lo hay) y si hay, reemplazamos $select por el valor 
217
+        $selected = $this->getData($data['name'], $selected);
218 218
 
219
-		//echo $sendValue;
220
-		// Si no tiene m�ltiples valores (es un string), lo retornamos de golpe 
221
-		if (!is_array($values)) {
222
-			// Comprobamos el value, es posible que el usuario este intentando crear los Radio (option) de forma separada
223
-			if (!is_array($values) and $selected == $values) $base .= ' checked="checked" ';
224
-			return $base . ' value="'.$values.'" />';
225
-		} 
219
+        //echo $sendValue;
220
+        // Si no tiene m�ltiples valores (es un string), lo retornamos de golpe 
221
+        if (!is_array($values)) {
222
+            // Comprobamos el value, es posible que el usuario este intentando crear los Radio (option) de forma separada
223
+            if (!is_array($values) and $selected == $values) $base .= ' checked="checked" ';
224
+            return $base . ' value="'.$values.'" />';
225
+        } 
226 226
 
227
-		// Por el contrario, tenemos 1 o m�s value con lo que es un posible texto
228
-		// Ahora preparamos todos los input
229
-		$r = '';
230
-		foreach ($values as $id=>$text) {
231
-			$r .= $base;
232
-			if ($selected !== null and $id == $selected) $r .= ' checked="checked" ';
233
-			$r .= ' value="'. $id .'" />'.$text.'</label>';
234
-		}
235
-		
236
-		return $r;
237
-		
238
-	}
239
-	
240
-	/**
241
-	 * @name showSelect
242
-	 * @tutorial This function show <select> tag with all values
243
-	 * @param array $data All data to show in the input
244
-	 * @param array $values Values to show in select
245
-	 * @param string $selected Specify selected option
246
-	 * @return string
247
-	 */
248
-	private function showSelect($data, $values, $selected = null) {
249
-		$r = '<select ';
250
-			// Convert array to input string
251
-			foreach ($data as $attr=>$value) {
252
-				$r .= $attr.'="'.$value.'" ';
253
-			}
254
-			// Return end input
255
-		$r .= '>';
256
-		
257
-		// Leemos el valor enviado por el usuario (si lo hay) y si hay, reemplazamos $select por el valor
258
-		$selected = $this->getData($data['name'], $selected);
259
-		
260
-		
261
-		// Loading options
262
-		// To speed up processes, we have two whiles depending if are any selected value
263
-		if ($selected != '') {
264
-			foreach ($values as $val=>$txt) {
265
-				$r .= '<option value="' . $val . '"';
266
-					if ($val == $selected) $r .= ' selected ';
267
-				$r .= '>' . $txt . '</option>';
268
-			}
269
-		} else {
270
-			foreach ($values as $val=>$txt) {
271
-				$r .= '<option value="' . $val . '">' . $txt . '</option>';
272
-			}	
273
-		}
274
-		
275
-		return $r . '</select>';
276
-	}
277
-	
278
-	/**
279
-	 * @name showTextArea
280
-	 * @tutorial This function show <textarea> tag with all values
281
-	 * @param array $data All data to show in the input
282
-	 * @return string
283
-	 */
284
-	private function showTextArea($text, $data) {
285
-		$r = '';
286
-		$r .= '<textarea ';
287
-		
288
-		// Asignamos las claves conviritiendo el array
289
-		foreach ($data as $attr=>$value) {
290
-			$r .= $attr.'="'.$value.'" ';
291
-		}
292
-		
293
-		$r .= '>';
294
-		// Reading value sended by user, if are any, we load it temporaly to show in form
295
-		$r .= $this->getData($data['name'], $text) . '</textarea>';
227
+        // Por el contrario, tenemos 1 o m�s value con lo que es un posible texto
228
+        // Ahora preparamos todos los input
229
+        $r = '';
230
+        foreach ($values as $id=>$text) {
231
+            $r .= $base;
232
+            if ($selected !== null and $id == $selected) $r .= ' checked="checked" ';
233
+            $r .= ' value="'. $id .'" />'.$text.'</label>';
234
+        }
235
+		
236
+        return $r;
237
+		
238
+    }
239
+	
240
+    /**
241
+     * @name showSelect
242
+     * @tutorial This function show <select> tag with all values
243
+     * @param array $data All data to show in the input
244
+     * @param array $values Values to show in select
245
+     * @param string $selected Specify selected option
246
+     * @return string
247
+     */
248
+    private function showSelect($data, $values, $selected = null) {
249
+        $r = '<select ';
250
+            // Convert array to input string
251
+            foreach ($data as $attr=>$value) {
252
+                $r .= $attr.'="'.$value.'" ';
253
+            }
254
+            // Return end input
255
+        $r .= '>';
256
+		
257
+        // Leemos el valor enviado por el usuario (si lo hay) y si hay, reemplazamos $select por el valor
258
+        $selected = $this->getData($data['name'], $selected);
259
+		
260
+		
261
+        // Loading options
262
+        // To speed up processes, we have two whiles depending if are any selected value
263
+        if ($selected != '') {
264
+            foreach ($values as $val=>$txt) {
265
+                $r .= '<option value="' . $val . '"';
266
+                    if ($val == $selected) $r .= ' selected ';
267
+                $r .= '>' . $txt . '</option>';
268
+            }
269
+        } else {
270
+            foreach ($values as $val=>$txt) {
271
+                $r .= '<option value="' . $val . '">' . $txt . '</option>';
272
+            }	
273
+        }
274
+		
275
+        return $r . '</select>';
276
+    }
277
+	
278
+    /**
279
+     * @name showTextArea
280
+     * @tutorial This function show <textarea> tag with all values
281
+     * @param array $data All data to show in the input
282
+     * @return string
283
+     */
284
+    private function showTextArea($text, $data) {
285
+        $r = '';
286
+        $r .= '<textarea ';
287
+		
288
+        // Asignamos las claves conviritiendo el array
289
+        foreach ($data as $attr=>$value) {
290
+            $r .= $attr.'="'.$value.'" ';
291
+        }
292
+		
293
+        $r .= '>';
294
+        // Reading value sended by user, if are any, we load it temporaly to show in form
295
+        $r .= $this->getData($data['name'], $text) . '</textarea>';
296 296
 
297
-		// Return
298
-		return $r;
299
-	}
300
-	
301
-	/**
302
-	 * @name showStartForm This function return the start part of the form
303
-	 * @return string
304
-	 */
305
-	private function showStartForm() {
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;
315
-	}
316
-	
317
-	/**
318
-	 * @name showEndForm This show the end of the form
319
-	 * @return string
320
-	 */
321
-	private function showEndForm() {
322
-		return '</form>';
323
-	}
324
-	
325
-	
326
-	/*
297
+        // Return
298
+        return $r;
299
+    }
300
+	
301
+    /**
302
+     * @name showStartForm This function return the start part of the form
303
+     * @return string
304
+     */
305
+    private function showStartForm() {
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;
315
+    }
316
+	
317
+    /**
318
+     * @name showEndForm This show the end of the form
319
+     * @return string
320
+     */
321
+    private function showEndForm() {
322
+        return '</form>';
323
+    }
324
+	
325
+	
326
+    /*
327 327
 	 * VALIDATORS
328 328
 	 */
329
-	/**
330
-	 * @name validate
331
-	 * @tutorial this function validate items sends trhough form. It DON'T FILTER
332
-	 * 	Basically simulate HTML5 trhoguh PHP for full compatibility
333
-	 * @param boolean $error_list If is true, it generate in $this->error_list a list with data required 
334
-	 */
335
-	public function validate() {
336
-		$this->error_list = ''; // Clean error list
337
-		$total = 0; // Total counted params
338
-		$success = 0; // Total correct
339
-		
340
-		// load all inputs
341
-		$params = $this->content;
342
-		
343
-		// reading all inputs
344
-		foreach ($params as $param) {
345
-			++$total;
329
+    /**
330
+     * @name validate
331
+     * @tutorial this function validate items sends trhough form. It DON'T FILTER
332
+     * 	Basically simulate HTML5 trhoguh PHP for full compatibility
333
+     * @param boolean $error_list If is true, it generate in $this->error_list a list with data required 
334
+     */
335
+    public function validate() {
336
+        $this->error_list = ''; // Clean error list
337
+        $total = 0; // Total counted params
338
+        $success = 0; // Total correct
339
+		
340
+        // load all inputs
341
+        $params = $this->content;
342
+		
343
+        // reading all inputs
344
+        foreach ($params as $param) {
345
+            ++$total;
346 346
 			
347
-			// Skip separators and bad generated arrays
348
-			if (!isset($param['data'])) {
349
-				++$success;
350
-				continue;
351
-			}
347
+            // Skip separators and bad generated arrays
348
+            if (!isset($param['data'])) {
349
+                ++$success;
350
+                continue;
351
+            }
352 352
 			
353
-			// Start validation
354
-			$data = $param['data'];
353
+            // Start validation
354
+            $data = $param['data'];
355 355
 			
356
-			// Checking type input
357
-			switch ($param['type']) {
356
+            // Checking type input
357
+            switch ($param['type']) {
358 358
 				
359
-				case 'input':
360
-					$success += $this->validateInput($param['data']);
361
-					break;
362
-				case 'radio':
363
-					$success += $this->validateRadio($param);
364
-					break;
365
-				case 'select':
366
-					$success += $this->validateSelect($param);
367
-					break;
368
-				default:
369
-					$success++;
370
-			}
371
-		}
372
-		
373
-		if ($success >= $total) return true;
374
-		return false;
375
-	}
376
-	
377
-	/**
378
-	 * @name validateInput
379
-	 * @tutorial This function test if an input (text, password, checkbox, ...) is valid depending assigned values
380
-	 * If you need other that is not invented, you can use "pattern" for example
381
-	 * It checks:
382
-	 * 	- required
383
-	 *  - date
384
-	 *  - min
385
-	 *  - max
386
-	 *  - number
387
-	 * @param array $data Contains all information about input
388
-	 * @return boolean If return true, its okay
389
-	 */
390
-	private function validateInput($data) {
391
-		// Obtaining value send by user
392
-		$readValue = $this->getData($data['name']);
359
+                case 'input':
360
+                    $success += $this->validateInput($param['data']);
361
+                    break;
362
+                case 'radio':
363
+                    $success += $this->validateRadio($param);
364
+                    break;
365
+                case 'select':
366
+                    $success += $this->validateSelect($param);
367
+                    break;
368
+                default:
369
+                    $success++;
370
+            }
371
+        }
372
+		
373
+        if ($success >= $total) return true;
374
+        return false;
375
+    }
376
+	
377
+    /**
378
+     * @name validateInput
379
+     * @tutorial This function test if an input (text, password, checkbox, ...) is valid depending assigned values
380
+     * If you need other that is not invented, you can use "pattern" for example
381
+     * It checks:
382
+     * 	- required
383
+     *  - date
384
+     *  - min
385
+     *  - max
386
+     *  - number
387
+     * @param array $data Contains all information about input
388
+     * @return boolean If return true, its okay
389
+     */
390
+    private function validateInput($data) {
391
+        // Obtaining value send by user
392
+        $readValue = $this->getData($data['name']);
393 393
 
394
-		// Empty/not send and required?
395
-		// TODO: Add require --> file (uses $_FILE)
396
-		
397
-		if (isset($data['required']) and ($readValue === null or $readValue == '')) {
398
-			$this->log('is required', $data);
399
-			return false;
400
-		} elseif ($readValue == '') {
401
-			return true;
402
-		}
403
-		
404
-		// Checking type input
405
-		switch ($data['type']) {
406
-			case 'text':
407
-				// Maxlenght fail
408
-				if (isset($data['maxlength']) and is_numeric($data['maxlength']) and $data['maxlength'] > -1 
409
-					and strlen($readValue) > $data['maxlength']) {
394
+        // Empty/not send and required?
395
+        // TODO: Add require --> file (uses $_FILE)
396
+		
397
+        if (isset($data['required']) and ($readValue === null or $readValue == '')) {
398
+            $this->log('is required', $data);
399
+            return false;
400
+        } elseif ($readValue == '') {
401
+            return true;
402
+        }
403
+		
404
+        // Checking type input
405
+        switch ($data['type']) {
406
+            case 'text':
407
+                // Maxlenght fail
408
+                if (isset($data['maxlength']) and is_numeric($data['maxlength']) and $data['maxlength'] > -1 
409
+                    and strlen($readValue) > $data['maxlength']) {
410 410
 					
411
-					$this->log('is too long. Maximum' . ' ' . $data['maxlength'] . ' ' . 'characters', $data );
412
-					return false;
413
-				}
411
+                    $this->log('is too long. Maximum' . ' ' . $data['maxlength'] . ' ' . 'characters', $data );
412
+                    return false;
413
+                }
414 414
 				
415
-				if (isset($data['pattern']) and is_numeric($data['pattern']) and $data['maxlength'] != '' 
416
-					and preg_match($data['pattern'], $readValue) === FALSE) {
415
+                if (isset($data['pattern']) and is_numeric($data['pattern']) and $data['maxlength'] != '' 
416
+                    and preg_match($data['pattern'], $readValue) === FALSE) {
417 417
 					
418
-					$this->log('pattern error' . ' (' . $data['pattern'] . ')' , $data);
419
-					return false;
420
-				}
421
-				break;
422
-			case 'number':
423
-			case 'range':
424
-				// IS NUMERIC
425
-				if ($readValue != '' and !is_numeric($readValue)) {
426
-					$this->log('Not numeric', $data);
427
-					return false;
428
-				}
418
+                    $this->log('pattern error' . ' (' . $data['pattern'] . ')' , $data);
419
+                    return false;
420
+                }
421
+                break;
422
+            case 'number':
423
+            case 'range':
424
+                // IS NUMERIC
425
+                if ($readValue != '' and !is_numeric($readValue)) {
426
+                    $this->log('Not numeric', $data);
427
+                    return false;
428
+                }
429 429
 				
430
-				// MIN
431
-				if (isset($data['min']) and $readValue < $data['min']) {
432
-					$this->log('The number have to be greather than' . ' ' . $data['min'].'.', $data);
433
-					return false;
434
-				}
430
+                // MIN
431
+                if (isset($data['min']) and $readValue < $data['min']) {
432
+                    $this->log('The number have to be greather than' . ' ' . $data['min'].'.', $data);
433
+                    return false;
434
+                }
435 435
 				
436
-				// MAX
437
-				if (isset($data['max']) and $readValue > $data['max']) {
438
-					$this->log('The number have to be less than' . ' ' . $data['max'].'.', $data);
439
-					return false;
440
-				}
436
+                // MAX
437
+                if (isset($data['max']) and $readValue > $data['max']) {
438
+                    $this->log('The number have to be less than' . ' ' . $data['max'].'.', $data);
439
+                    return false;
440
+                }
441 441
 				
442
-				// STEP http://www.w3schools.com/tags/att_input_step.asp
443
-				// Value 0 ever is valid (and if you try Divide to Zero, it will take error because the result is inifinite
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);
446
-					return false;
447
-				}
442
+                // STEP http://www.w3schools.com/tags/att_input_step.asp
443
+                // Value 0 ever is valid (and if you try Divide to Zero, it will take error because the result is inifinite
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);
446
+                    return false;
447
+                }
448 448
 				
449
-				break;
450
-			case 'date';
451
-				//min | max
452
-				echo $readValue;
453
-				if (!is_date($readValue)) {
454
-					$this->log('The date' . ' ' .$readValue.' '. 'must have format' . ' mm/dd/yyyy '.'.', $data);
455
-					return false;
456
-				}
457
-				break;
449
+                break;
450
+            case 'date';
451
+                //min | max
452
+                echo $readValue;
453
+                if (!is_date($readValue)) {
454
+                    $this->log('The date' . ' ' .$readValue.' '. 'must have format' . ' mm/dd/yyyy '.'.', $data);
455
+                    return false;
456
+                }
457
+                break;
458 458
 				
459
-			case 'email':
460
-				if (!filter_var($readValue, FILTER_VALIDATE_EMAIL)) {
461
-					$this->log('Email invalid', $data);
462
-					return false;
463
-				}
464
-			case 'file':
465
-				//accept="image/*" (http://www.w3schools.com/tags/att_input_accept.asp)
466
-				break;
459
+            case 'email':
460
+                if (!filter_var($readValue, FILTER_VALIDATE_EMAIL)) {
461
+                    $this->log('Email invalid', $data);
462
+                    return false;
463
+                }
464
+            case 'file':
465
+                //accept="image/*" (http://www.w3schools.com/tags/att_input_accept.asp)
466
+                break;
467 467
 			
468
-			case 'url':
469
-				if (!filter_var($readValue, FILTER_VALIDATE_URL)) {
470
-					$this->log('Invalid url', $data);
471
-					return false;
472
-				}
473
-				break;	
474
-		}
475
-		// Validamos el resto como cierto (no podemos parametrizar el 100 % de cosas nuevas que salgan de HTML)
476
-		return true;
477
-	}
478
-	
479
-	/**
480
-	 * @name validateArray
481
-	 * This functions validate an Array, is a complement to validateRadio, select...
482
-	 * @param array/string $values List of values to validate
483
-	 * @param array/string $value/s selecteds by user 
484
-	 */
485
-	private function validateArray($values, $value, $data = array()) {
486
-		if (is_array($values)) {
487
-			// Is array (serach all "$value" in "$values"
488
-			if (!array_key_exists($value, $values)) {
489
-				if (is_array($value)) {
490
-					$this->log('Values don\'t match.', $data);
491
-				} else {
492
-					$this->log('ID ' .$value.' ' . 'don\'t match', $data);
493
-				}
494
-				return false;
495
-			}
496
-		} else {
497
-			// Is string
498
-			if ($readValue == $values) {
499
-				$this->log('The value' . ' ' . $value.' ' . 'is not available', $data);
500
-				return false;
501
-			}
502
-		}
503
-		
504
-		return true;
505
-	}
506
-	
507
-	
508
-	/**
509
-	 * @name validateRadio
510
-	 * @tutorial This function test if an radio is valid depending assigned values
511
-	 * @param array $data Contains all information about input
512
-	 * @return boolean If return true, its okay
513
-	 */
514
-	private function validateRadio($params) {
515
-		$data = $params['data'];
516
-		// Obtaining value send by user
517
-		$readValue = $this->getData($data['name']);
518
-		
519
-		// Is required?
520
-		if (isset($data['required']) and ($readValue === null or $readValue == '')) {
521
-			$this->log('is required', $data);
522
-			return false;
523
-		} elseif ($readValue == '') {
524
-			return true;
525
-		}
526
-		
527
-		
528
-		// Seleccionamos que tipo de analisis (dependiendo si se ha creado como input o como radio)
529
-		// Esto no deberia estar aqui porque no es necesario, pero esta hecho por posibles despistes de usuarios finales
530
-		if (isset($params['values'])) {
531
-			return $this->validateArray($params['values'], $readValue, $data);
532
-		} elseif ($data['value']) {
533
-			// If user try to add radio like normal input... (into 'value' in index data)
534
-			return $this->validateArray($params['value'], $readValue, $data);
535
-		}
536
-		
537
-		return false;
538
-	}
539
-	
540
-	/**
541
-	 * @name validateSelect
542
-	 * @tutorial This function test if an select is valid depending assigned values
543
-	 * @param array $data Contains all information about input
544
-	 * @return boolean If return true, its okay
545
-	 */
546
-	private function validateSelect($param) {
547
-		$data = $param['data'];
548
-		// Obtaining value send by user
549
-		$readValue = $this->getData($data['name']);
550
-	
551
-		// Is required?
552
-		if (isset($data['required']) and ($readValue === null or $readValue == '')) {
553
-			$this->log('is required', $data);
554
-			return false;
555
-		} elseif ($readValue == '') {
556
-			return true;
557
-		}
558
-	
559
-		// Seleccionamos que tipo de analisis (dependiendo si se ha creado como input o como radio)
560
-		// Esto no deberia estar aqui porque no es necesario, pero esta hecho por posibles despistes de usuarios finales
561
-		return $this->validateArray($param['values'], $readValue, $data);
562
-	}
563
-	
564
-	
565
-	/**
566
-	 * @name getData This function get value from POST/GET trhough ID ($key)
567
-	 * 	If you use other system to load GET and POST, you have to edit this
568
-	 * @param string $key Object Index
569
-	 * @param string $default Default item if not data
570
-	 * @return string/null Return the value, if don't exist, return null
571
-	 */
572
-	private function getData($key, $default = null) {
573
-		if ($this->method == "post") return isset($_POST[$key]) ? $_POST[$key] : $default;
574
-		else return isset($_GET[$key]) ? $_GET[$key] : $default;
575
-	}
576
-	
577
-	/*
468
+            case 'url':
469
+                if (!filter_var($readValue, FILTER_VALIDATE_URL)) {
470
+                    $this->log('Invalid url', $data);
471
+                    return false;
472
+                }
473
+                break;	
474
+        }
475
+        // Validamos el resto como cierto (no podemos parametrizar el 100 % de cosas nuevas que salgan de HTML)
476
+        return true;
477
+    }
478
+	
479
+    /**
480
+     * @name validateArray
481
+     * This functions validate an Array, is a complement to validateRadio, select...
482
+     * @param array/string $values List of values to validate
483
+     * @param array/string $value/s selecteds by user 
484
+     */
485
+    private function validateArray($values, $value, $data = array()) {
486
+        if (is_array($values)) {
487
+            // Is array (serach all "$value" in "$values"
488
+            if (!array_key_exists($value, $values)) {
489
+                if (is_array($value)) {
490
+                    $this->log('Values don\'t match.', $data);
491
+                } else {
492
+                    $this->log('ID ' .$value.' ' . 'don\'t match', $data);
493
+                }
494
+                return false;
495
+            }
496
+        } else {
497
+            // Is string
498
+            if ($readValue == $values) {
499
+                $this->log('The value' . ' ' . $value.' ' . 'is not available', $data);
500
+                return false;
501
+            }
502
+        }
503
+		
504
+        return true;
505
+    }
506
+	
507
+	
508
+    /**
509
+     * @name validateRadio
510
+     * @tutorial This function test if an radio is valid depending assigned values
511
+     * @param array $data Contains all information about input
512
+     * @return boolean If return true, its okay
513
+     */
514
+    private function validateRadio($params) {
515
+        $data = $params['data'];
516
+        // Obtaining value send by user
517
+        $readValue = $this->getData($data['name']);
518
+		
519
+        // Is required?
520
+        if (isset($data['required']) and ($readValue === null or $readValue == '')) {
521
+            $this->log('is required', $data);
522
+            return false;
523
+        } elseif ($readValue == '') {
524
+            return true;
525
+        }
526
+		
527
+		
528
+        // Seleccionamos que tipo de analisis (dependiendo si se ha creado como input o como radio)
529
+        // Esto no deberia estar aqui porque no es necesario, pero esta hecho por posibles despistes de usuarios finales
530
+        if (isset($params['values'])) {
531
+            return $this->validateArray($params['values'], $readValue, $data);
532
+        } elseif ($data['value']) {
533
+            // If user try to add radio like normal input... (into 'value' in index data)
534
+            return $this->validateArray($params['value'], $readValue, $data);
535
+        }
536
+		
537
+        return false;
538
+    }
539
+	
540
+    /**
541
+     * @name validateSelect
542
+     * @tutorial This function test if an select is valid depending assigned values
543
+     * @param array $data Contains all information about input
544
+     * @return boolean If return true, its okay
545
+     */
546
+    private function validateSelect($param) {
547
+        $data = $param['data'];
548
+        // Obtaining value send by user
549
+        $readValue = $this->getData($data['name']);
550
+	
551
+        // Is required?
552
+        if (isset($data['required']) and ($readValue === null or $readValue == '')) {
553
+            $this->log('is required', $data);
554
+            return false;
555
+        } elseif ($readValue == '') {
556
+            return true;
557
+        }
558
+	
559
+        // Seleccionamos que tipo de analisis (dependiendo si se ha creado como input o como radio)
560
+        // Esto no deberia estar aqui porque no es necesario, pero esta hecho por posibles despistes de usuarios finales
561
+        return $this->validateArray($param['values'], $readValue, $data);
562
+    }
563
+	
564
+	
565
+    /**
566
+     * @name getData This function get value from POST/GET trhough ID ($key)
567
+     * 	If you use other system to load GET and POST, you have to edit this
568
+     * @param string $key Object Index
569
+     * @param string $default Default item if not data
570
+     * @return string/null Return the value, if don't exist, return null
571
+     */
572
+    private function getData($key, $default = null) {
573
+        if ($this->method == "post") return isset($_POST[$key]) ? $_POST[$key] : $default;
574
+        else return isset($_GET[$key]) ? $_GET[$key] : $default;
575
+    }
576
+	
577
+    /*
578 578
 	 * Array constructors
579 579
 	 * This functions will be called to self construct array easy
580 580
 	 */
581 581
 	
582
-	/**
583
-	 * @name separator
584
-	 * @tutorial This function add separation (<hr/>) between parts
585
-	 */
586
-	public function addSeparator() {
587
-		$this->content[] = array('type' => 'separator');
588
-	}
589
-	
590
-	/**
591
-	 * @name addInput
592
-	 * @tutorial This class generate a generic INPUT
593
-	 * @param string $label If is not empty, it show a text "label" with the text
594
-	 * @param string $type Specify input type. It will be validated once use validate();
595
-	 * Types that are current supported to validate:
596
-	 * 		text, password, hidden, file
597
-	 * 		Its supported use ALL type supported (http://www.w3schools.com/tags/att_input_type.asp), 
598
-	 * 	Some type input you can declare directly via functions (afther this function are more)
599
-	 * @param string $name Element name
600
-	 * @param string $value Element value
601
-	 * @param string $required Element required?
602
-	 * @param array $attributes Optional atributes not listened (in array).
603
-	 * 		EX: You like use "date", then you can put array('min' => '1979-12-31', 'max' => '2000-01-02')
604
-	 * 		All parameters currently working: min, max (date and number), pattern,   
605
-	 * 
606
-	 * @example $fr->addInput('text', 'Username', '', true, 'Type here your username', array('class'=>'text red', id => 'text1'), array())
607
-	 */
608
-	public function addInput($label = '', $type = 'text', $name = '', $value = '', $required = false, $placeholder = '',  $attributes = array()) {
609
-		// Creating main data
610
-		$data = array(
611
-			'type' => $type,
612
-			'name' => $name,
613
-			'value' => $value,
614
-		);
615
-		
616
-		
617
-		if ($required) $data['required'] = 'required';
618
-		if ($placeholder != '') $data['placeholder'] = $placeholder;
619
-		if (!empty($attributes)) array_merge($data, $attributes);
620
-		
621
-		
622
-		// Saving data to object
623
-		$content = array(
624
-			'type' => 'input',
625
-			'data' => $data	
626
-		);
627
-		if ($label != '') $content['label'] = $label;
582
+    /**
583
+     * @name separator
584
+     * @tutorial This function add separation (<hr/>) between parts
585
+     */
586
+    public function addSeparator() {
587
+        $this->content[] = array('type' => 'separator');
588
+    }
589
+	
590
+    /**
591
+     * @name addInput
592
+     * @tutorial This class generate a generic INPUT
593
+     * @param string $label If is not empty, it show a text "label" with the text
594
+     * @param string $type Specify input type. It will be validated once use validate();
595
+     * Types that are current supported to validate:
596
+     * 		text, password, hidden, file
597
+     * 		Its supported use ALL type supported (http://www.w3schools.com/tags/att_input_type.asp), 
598
+     * 	Some type input you can declare directly via functions (afther this function are more)
599
+     * @param string $name Element name
600
+     * @param string $value Element value
601
+     * @param string $required Element required?
602
+     * @param array $attributes Optional atributes not listened (in array).
603
+     * 		EX: You like use "date", then you can put array('min' => '1979-12-31', 'max' => '2000-01-02')
604
+     * 		All parameters currently working: min, max (date and number), pattern,   
605
+     * 
606
+     * @example $fr->addInput('text', 'Username', '', true, 'Type here your username', array('class'=>'text red', id => 'text1'), array())
607
+     */
608
+    public function addInput($label = '', $type = 'text', $name = '', $value = '', $required = false, $placeholder = '',  $attributes = array()) {
609
+        // Creating main data
610
+        $data = array(
611
+            'type' => $type,
612
+            'name' => $name,
613
+            'value' => $value,
614
+        );
615
+		
616
+		
617
+        if ($required) $data['required'] = 'required';
618
+        if ($placeholder != '') $data['placeholder'] = $placeholder;
619
+        if (!empty($attributes)) array_merge($data, $attributes);
620
+		
621
+		
622
+        // Saving data to object
623
+        $content = array(
624
+            'type' => 'input',
625
+            'data' => $data	
626
+        );
627
+        if ($label != '') $content['label'] = $label;
628 628
 		 
629
-		$this->content[] = $content;
630
-	}
631
-	
632
-	/**
633
-	 * @name addNumber This function add input "number" and "date" with min, max and step (if you like)
634
-	 * @param string $label If is not empty, it show a text "label" with the text
635
-	 * @param string $name Element name
636
-	 * @param string $value Default value
637
-	 * @param boolen $range If is true, then show "range" instead of text with number
638
-	 * @param boolen $required Is required?
639
-	 * @param number $min Minium value. Empty nothing
640
-	 * @param number $max Max value. Empty nothing
641
-	 * @param number $step Step (multiply). Empty nothing (ex: step 2: -2, 0, 2, 4 ...)
642
-	 * @param string $placeholder Default text to show if box is empty
643
-	 * @param unknown $attributes Additional attributes
644
-	 */
645
-	public function addNumber($label = '', $name = '', $value = '', $range = false, $required = false, $min = '', $max = '', $step = '',  $placeholder = '',  $attributes = array()) {
646
-		// Creating main data
647
-		$data = array(
648
-			'type' => (! $range) ? 'number' : 'range',
649
-			'name' => $name,
650
-			'value' => $value,
651
-		);
652
-	
653
-		
654
-		if ($required) $data['required'] = 'required';
655
-		if ($min) $data['min'] = $min;
656
-		if ($max) $data['max'] = $max;
657
-		if ($step) $data['step'] = $step;
658
-		if ($placeholder != '') $data['placeholder'] = $placeholder;
659
-		if (!empty($attributes)) array_merge($data, $attributes);
660
-	
661
-		// Saving data to object
662
-		$content = array(
663
-			'type' => 'input',
664
-			'data' => $data
665
-		);
666
-		if ($label != '') $content['label'] = $label;
667
-		
668
-		$this->content[] = $content;
669
-	}
629
+        $this->content[] = $content;
630
+    }
631
+	
632
+    /**
633
+     * @name addNumber This function add input "number" and "date" with min, max and step (if you like)
634
+     * @param string $label If is not empty, it show a text "label" with the text
635
+     * @param string $name Element name
636
+     * @param string $value Default value
637
+     * @param boolen $range If is true, then show "range" instead of text with number
638
+     * @param boolen $required Is required?
639
+     * @param number $min Minium value. Empty nothing
640
+     * @param number $max Max value. Empty nothing
641
+     * @param number $step Step (multiply). Empty nothing (ex: step 2: -2, 0, 2, 4 ...)
642
+     * @param string $placeholder Default text to show if box is empty
643
+     * @param unknown $attributes Additional attributes
644
+     */
645
+    public function addNumber($label = '', $name = '', $value = '', $range = false, $required = false, $min = '', $max = '', $step = '',  $placeholder = '',  $attributes = array()) {
646
+        // Creating main data
647
+        $data = array(
648
+            'type' => (! $range) ? 'number' : 'range',
649
+            'name' => $name,
650
+            'value' => $value,
651
+        );
652
+	
653
+		
654
+        if ($required) $data['required'] = 'required';
655
+        if ($min) $data['min'] = $min;
656
+        if ($max) $data['max'] = $max;
657
+        if ($step) $data['step'] = $step;
658
+        if ($placeholder != '') $data['placeholder'] = $placeholder;
659
+        if (!empty($attributes)) array_merge($data, $attributes);
660
+	
661
+        // Saving data to object
662
+        $content = array(
663
+            'type' => 'input',
664
+            'data' => $data
665
+        );
666
+        if ($label != '') $content['label'] = $label;
667
+		
668
+        $this->content[] = $content;
669
+    }
670 670
 
671
-	/**
672
-	 * @name addDate This function add input "number" with min, max and step (if you like)
673
-	 * @param string $label If is not empty, it show a text "label" with the text
674
-	 * @param string $name Element name
675
-	 * @param string $value Default value
676
-	 * @param string $required Is required?
677
-	 * @param string $min Minium value. Empty nothing
678
-	 * @param string $max Max value. Empty nothing
679
-	 * @param string $step Step (multiply). Empty nothing (ex: step 2: -2, 0, 2, 4 ...)
680
-	 * @param string $placeholder Default text to show if box is empty
681
-	 * @param unknown $attributes Additional attributes
682
-	 */
683
-	public function addDate($label = '', $name = '', $value = '', $required = false, $min = '', $max = '', $step = '',  $placeholder = '',  $attributes = array()) {
684
-		// Creating main data
685
-		$data = array(
686
-			'type' => 'date',
687
-			'name' => $name,
688
-			'value' => $value,
689
-		);
690
-	
691
-		if ($required) $data['required'] = 'required';
692
-		if ($min) $data['min'] = $min;
693
-		if ($max) $data['max'] = $max;
694
-		if ($step) $data['step'] = $step;
695
-		if ($placeholder != '') $data['placeholder'] = $placeholder;
696
-		if (!empty($attributes)) array_merge($data, $attributes);
697
-	
698
-		// Saving data to object
699
-		$content = array(
700
-			'type' => 'input',
701
-			'data' => $data
702
-		);
703
-		if ($label != '') $content['label'] = $label;
704
-		
705
-		$this->content[] = $content;
706
-	}
707
-	
708
-	
709
-	/**
710
-	 * @name addCheck
711
-	 * @tutorial Use this function to add a checkBox
712
-	 * @param string $label If is not empty, it show a text "label" with the text
713
-	 * @param string $name Check name
714
-	 * @param string $value Check value
715
-	 * @param boolean $required Specify if check is required
716
-	 * @param array $attributes Optional atributes not listened (in array).
717
-	 */
718
-	public function addCheck($label = '', $name = '', $value = '', $required = false, $attributes = array()) {
719
-		$data = array(
720
-			'type' => 'checkbox',
721
-			'name' => $name,
722
-			'value' => $value
723
-		);
724
-		if ($required) $data['required'] = 'required';
725
-		if (!empty($attributes)) array_merge($data, $attributes);
726
-		
727
-		$content = array(
728
-			'type' => 'input',
729
-			'data' => $data 
730
-		);
731
-		if ($label != '') $content['label'] = $label;
732
-		
733
-		$this->content[] = $content;
734
-	}
735
-	
736
-	
737
-	/**
738
-	 * @name addRadio
739
-	 * @tutorial Use this function to add a radio button
740
-	 * @param string $label If is not empty, it show a text "label" with the text
741
-	 * @param string $name Radio button name
742
-	 * @param array $values Contain all radio with values and text to show 
743
-	 * 	EX: array('val1'=>'text1', 'val2'=>'text2'); 
744
-	 * @param string $selected Specify wich option (ID) will be checked by default 
745
-	 * @param boolean $required Specify if radio is required
746
-	 * @param array $attributes Optional atributes not listened (in array). This will be applicated to all radioButton
747
-	 */
748
-	public function addRadio($label = '', $name = '', $values = array(), $selected = null, $required = false, $attributes = array()) {
749
-		if (!is_array($values)) die('FATAL ERROR: Trying to create "RadioButton" with string VALUE, is requried use ARRAY()');
750
-		$data = array(
751
-			'name' => $name,
752
-		);
753
-		
754
-		if ($required) $data['required'] = 'required';		
755
-		if (!empty($attributes)) array_merge($data, $attributes);
756
-		
757
-		
758
-		
759
-		$content = array(
760
-			'type' => 'radio',
761
-			'data' => $data,
762
-			'values' => $values,
763
-			'selected' => $selected
764
-		);
765
-		if ($label != '') $content['label'] = $label;
766
-		
767
-		$this->content[] = $content;
768
-	}
769
-	
770
-	
771
-	/**
772
-	 * @name addSelect
773
-	 * @tutorial Use this function to add a radio button
774
-	 * @param string $label Text to show before input
775
-	 * @param string $name Select name
776
-	 * @param array $values Array('value'=>'text to show')
777
-	 * @param boolean $required Specify if select is required
778
-	 * @param string $id ID Specify ID to manipulate via javascript or CSS
779
-	 * @param array $attributes Optional atributes not listened (in array).
780
-	 */
781
-	public function addSelect($label = '', $name = '', $values = '', $selected = null, $required = false, $multiple = false, $attributes = array()) {
782
-		$data = array(
783
-			'name' => $name,
784
-			'required' => $required,
785
-		);
786
-		if ($required) $data['required'] = 'required';
787
-		if ($multiple) $data['multiple'] = 'multiple';
788
-		if (!empty($attributes)) array_merge($data, $attributes);
789
-		
790
-		
791
-		// In this case, the values are saved in the main of array to speed up select loader
792
-		$content = array(
793
-			'type' => 'select',
794
-			'data' => $data,
795
-			'values' => $values,
796
-			'selected' => $selected
797
-		);
798
-		if ($label != '') $content['label'] = $label;
799
-		
800
-		$this->content[] = $content;
801
-	}
802
-	
803
-	/**
804
-	 * @name addSubmit
805
-	 * @tutorial Use this function to add a submit button
806
-	 * @param string $name Select name (optional, if leav blank it will not send in POST / GET)
807
-	 * @param string $value Text to show in button and ID
808
-	 * @param array $attributes Optional atributes not listened (in array).
809
-	 */
810
-	public function addSubmit($name = '', $value = '', $attributes = array()) {
811
-		$data = array(
812
-			'type' => 'submit',
813
-			'name' => $name,
814
-			'value' => $value
815
-		);
816
-		if (!empty($attributes)) array_merge($data, $attributes);
817
-		
818
-		$this->content[] = array(
819
-			'type' => 'input',
820
-			'data' => $data
821
-		);
822
-		
823
-		
824
-	}
825
-	
826
-	/**
827
-	 * @name addButton
828
-	 * @tutorial Use this function to add a button with "onclick" action (or id/class to call via jquery) 
829
-	 * @param string $value Name to show in button and ID
830
-	 * @param string $onClick Action to load when button is clicked 
831
-	 * @param array $attributes Optional atributes not listened (in array).
832
-	 */
833
-	public function addButton($value = '', $onClick = '', $attributes = array()) {
834
-		$data = array(
835
-			'type' => 'button',
836
-			'value' => $value,
837
-			'onClick' => $onClick
838
-		);
839
-		if (!empty($attributes)) array_merge($data, $attributes);
840
-		
841
-		$this->content[] = array(
842
-			'type' => 'input',
843
-			'data' => $data
844
-		);
845
-	}
846
-	
847
-	
848
-	/**
849
-	 * @name addButton
850
-	 * @tutorial Use this function to add a button with "onclick" action (or id/class to call via jquery)
851
-	 * @param string $value Name to show in button and ID
852
-	 * @param string $onClick Action to load when button is clicked
853
-	 * @param array $attributes Optional atributes not listened (in array).
854
-	 */
855
-	public function addTextArea($label = '', $name = '', $value = '', $required = false, $attributes = array()) {
856
-		// Creating main data
857
-		$data = array(
858
-			'name' => $name,
859
-		);
860
-		
861
-		if ($required) $data['required'] = 'required';
862
-		if (!empty($attributes)) array_merge($data, $attributes);
863
-		
864
-		// Saving data to object
865
-		$content = array(
866
-			'type' => 'textarea',
867
-			'text' => $value,
868
-			'data' => $data	
869
-		);
870
-		if ($label != '') $content['label'] = $label;
671
+    /**
672
+     * @name addDate This function add input "number" with min, max and step (if you like)
673
+     * @param string $label If is not empty, it show a text "label" with the text
674
+     * @param string $name Element name
675
+     * @param string $value Default value
676
+     * @param string $required Is required?
677
+     * @param string $min Minium value. Empty nothing
678
+     * @param string $max Max value. Empty nothing
679
+     * @param string $step Step (multiply). Empty nothing (ex: step 2: -2, 0, 2, 4 ...)
680
+     * @param string $placeholder Default text to show if box is empty
681
+     * @param unknown $attributes Additional attributes
682
+     */
683
+    public function addDate($label = '', $name = '', $value = '', $required = false, $min = '', $max = '', $step = '',  $placeholder = '',  $attributes = array()) {
684
+        // Creating main data
685
+        $data = array(
686
+            'type' => 'date',
687
+            'name' => $name,
688
+            'value' => $value,
689
+        );
690
+	
691
+        if ($required) $data['required'] = 'required';
692
+        if ($min) $data['min'] = $min;
693
+        if ($max) $data['max'] = $max;
694
+        if ($step) $data['step'] = $step;
695
+        if ($placeholder != '') $data['placeholder'] = $placeholder;
696
+        if (!empty($attributes)) array_merge($data, $attributes);
697
+	
698
+        // Saving data to object
699
+        $content = array(
700
+            'type' => 'input',
701
+            'data' => $data
702
+        );
703
+        if ($label != '') $content['label'] = $label;
704
+		
705
+        $this->content[] = $content;
706
+    }
707
+	
708
+	
709
+    /**
710
+     * @name addCheck
711
+     * @tutorial Use this function to add a checkBox
712
+     * @param string $label If is not empty, it show a text "label" with the text
713
+     * @param string $name Check name
714
+     * @param string $value Check value
715
+     * @param boolean $required Specify if check is required
716
+     * @param array $attributes Optional atributes not listened (in array).
717
+     */
718
+    public function addCheck($label = '', $name = '', $value = '', $required = false, $attributes = array()) {
719
+        $data = array(
720
+            'type' => 'checkbox',
721
+            'name' => $name,
722
+            'value' => $value
723
+        );
724
+        if ($required) $data['required'] = 'required';
725
+        if (!empty($attributes)) array_merge($data, $attributes);
726
+		
727
+        $content = array(
728
+            'type' => 'input',
729
+            'data' => $data 
730
+        );
731
+        if ($label != '') $content['label'] = $label;
732
+		
733
+        $this->content[] = $content;
734
+    }
735
+	
736
+	
737
+    /**
738
+     * @name addRadio
739
+     * @tutorial Use this function to add a radio button
740
+     * @param string $label If is not empty, it show a text "label" with the text
741
+     * @param string $name Radio button name
742
+     * @param array $values Contain all radio with values and text to show 
743
+     * 	EX: array('val1'=>'text1', 'val2'=>'text2'); 
744
+     * @param string $selected Specify wich option (ID) will be checked by default 
745
+     * @param boolean $required Specify if radio is required
746
+     * @param array $attributes Optional atributes not listened (in array). This will be applicated to all radioButton
747
+     */
748
+    public function addRadio($label = '', $name = '', $values = array(), $selected = null, $required = false, $attributes = array()) {
749
+        if (!is_array($values)) die('FATAL ERROR: Trying to create "RadioButton" with string VALUE, is requried use ARRAY()');
750
+        $data = array(
751
+            'name' => $name,
752
+        );
753
+		
754
+        if ($required) $data['required'] = 'required';		
755
+        if (!empty($attributes)) array_merge($data, $attributes);
756
+		
757
+		
758
+		
759
+        $content = array(
760
+            'type' => 'radio',
761
+            'data' => $data,
762
+            'values' => $values,
763
+            'selected' => $selected
764
+        );
765
+        if ($label != '') $content['label'] = $label;
766
+		
767
+        $this->content[] = $content;
768
+    }
769
+	
770
+	
771
+    /**
772
+     * @name addSelect
773
+     * @tutorial Use this function to add a radio button
774
+     * @param string $label Text to show before input
775
+     * @param string $name Select name
776
+     * @param array $values Array('value'=>'text to show')
777
+     * @param boolean $required Specify if select is required
778
+     * @param string $id ID Specify ID to manipulate via javascript or CSS
779
+     * @param array $attributes Optional atributes not listened (in array).
780
+     */
781
+    public function addSelect($label = '', $name = '', $values = '', $selected = null, $required = false, $multiple = false, $attributes = array()) {
782
+        $data = array(
783
+            'name' => $name,
784
+            'required' => $required,
785
+        );
786
+        if ($required) $data['required'] = 'required';
787
+        if ($multiple) $data['multiple'] = 'multiple';
788
+        if (!empty($attributes)) array_merge($data, $attributes);
789
+		
790
+		
791
+        // In this case, the values are saved in the main of array to speed up select loader
792
+        $content = array(
793
+            'type' => 'select',
794
+            'data' => $data,
795
+            'values' => $values,
796
+            'selected' => $selected
797
+        );
798
+        if ($label != '') $content['label'] = $label;
799
+		
800
+        $this->content[] = $content;
801
+    }
802
+	
803
+    /**
804
+     * @name addSubmit
805
+     * @tutorial Use this function to add a submit button
806
+     * @param string $name Select name (optional, if leav blank it will not send in POST / GET)
807
+     * @param string $value Text to show in button and ID
808
+     * @param array $attributes Optional atributes not listened (in array).
809
+     */
810
+    public function addSubmit($name = '', $value = '', $attributes = array()) {
811
+        $data = array(
812
+            'type' => 'submit',
813
+            'name' => $name,
814
+            'value' => $value
815
+        );
816
+        if (!empty($attributes)) array_merge($data, $attributes);
817
+		
818
+        $this->content[] = array(
819
+            'type' => 'input',
820
+            'data' => $data
821
+        );
822
+		
823
+		
824
+    }
825
+	
826
+    /**
827
+     * @name addButton
828
+     * @tutorial Use this function to add a button with "onclick" action (or id/class to call via jquery) 
829
+     * @param string $value Name to show in button and ID
830
+     * @param string $onClick Action to load when button is clicked 
831
+     * @param array $attributes Optional atributes not listened (in array).
832
+     */
833
+    public function addButton($value = '', $onClick = '', $attributes = array()) {
834
+        $data = array(
835
+            'type' => 'button',
836
+            'value' => $value,
837
+            'onClick' => $onClick
838
+        );
839
+        if (!empty($attributes)) array_merge($data, $attributes);
840
+		
841
+        $this->content[] = array(
842
+            'type' => 'input',
843
+            'data' => $data
844
+        );
845
+    }
846
+	
847
+	
848
+    /**
849
+     * @name addButton
850
+     * @tutorial Use this function to add a button with "onclick" action (or id/class to call via jquery)
851
+     * @param string $value Name to show in button and ID
852
+     * @param string $onClick Action to load when button is clicked
853
+     * @param array $attributes Optional atributes not listened (in array).
854
+     */
855
+    public function addTextArea($label = '', $name = '', $value = '', $required = false, $attributes = array()) {
856
+        // Creating main data
857
+        $data = array(
858
+            'name' => $name,
859
+        );
860
+		
861
+        if ($required) $data['required'] = 'required';
862
+        if (!empty($attributes)) array_merge($data, $attributes);
863
+		
864
+        // Saving data to object
865
+        $content = array(
866
+            'type' => 'textarea',
867
+            'text' => $value,
868
+            'data' => $data	
869
+        );
870
+        if ($label != '') $content['label'] = $label;
871 871
 		 
872
-		$this->content[] = $content;
873
-	}
872
+        $this->content[] = $content;
873
+    }
874 874
 	
875
-	/*
875
+    /*
876 876
 	 * OTHER
877 877
 	 */
878
-	/**
879
-	 * @name log
880
-	 * @tutorial Save a log if is enabled logging
881
-	 * @param boolean $save If is true, save the log
882
-	 * @param string $message Message to log
883
-	 */
884
-	private function log($message, $data = array()) {
885
-		if ($this->logErrors) {
886
-			// Try to get a name (label or name)
887
-			if (class_exists('kw')) {
888
-				if (isset($data['label'])) $this->errors .= 'Found an error in field' . ': "' . $data['label'] . '": ';
889
-				elseif (isset($data['name'])) $this->errors .= 'Found an error in field' . ': "' . $data['name'] . '": ';
890
-			} else {
891
-				if (isset($data['label'])) $this->errors .= 'Found an error in field' . $data['label'] . '": ';
892
-				elseif (isset($data['name'])) $this->errors .= 'Found an error in field' . ': "' . $data['name'] . '": ';
893
-			}
878
+    /**
879
+     * @name log
880
+     * @tutorial Save a log if is enabled logging
881
+     * @param boolean $save If is true, save the log
882
+     * @param string $message Message to log
883
+     */
884
+    private function log($message, $data = array()) {
885
+        if ($this->logErrors) {
886
+            // Try to get a name (label or name)
887
+            if (class_exists('kw')) {
888
+                if (isset($data['label'])) $this->errors .= 'Found an error in field' . ': "' . $data['label'] . '": ';
889
+                elseif (isset($data['name'])) $this->errors .= 'Found an error in field' . ': "' . $data['name'] . '": ';
890
+            } else {
891
+                if (isset($data['label'])) $this->errors .= 'Found an error in field' . $data['label'] . '": ';
892
+                elseif (isset($data['name'])) $this->errors .= 'Found an error in field' . ': "' . $data['name'] . '": ';
893
+            }
894 894
 			
895
-			// preparing message
896
-			$this->errors .= ' ' . $message . '.';
895
+            // preparing message
896
+            $this->errors .= ' ' . $message . '.';
897 897
 			
898
-			// Extra message (title attribute)
899
-			if (isset($data['title']) and $data['title'] != '') $this->errors .= ' | '. 'MESSAGE' .': ' . $data['title'];
898
+            // Extra message (title attribute)
899
+            if (isset($data['title']) and $data['title'] != '') $this->errors .= ' | '. 'MESSAGE' .': ' . $data['title'];
900 900
 			
901
-			$this->errors .= '<br />';
902
-		}
903
-	}
901
+            $this->errors .= '<br />';
902
+        }
903
+    }
904 904
 }
905 905
 
906 906
 
@@ -914,23 +914,23 @@  discard block
 block discarded – undo
914 914
 // More examples:
915 915
 // http://us2.php.net/manual/es/function.checkdate.php
916 916
 function is_date( $str ) {
917
-	// Try to execute date creator
918
-	try {
919
-		$dt = new DateTime( trim($str) );
920
-	} catch( Exception $e ) {
921
-		// If fails, it return false, date is incorrect
922
-		return false;
923
-	}
924
-	
925
-	// Checking date
926
-	$month = $dt->format('m');
927
-	$day = $dt->format('d');
928
-	$year = $dt->format('Y');
929
-	
930
-	// Date is ok
931
-	if (checkdate($month, $day, $year)) {
932
-		return true;
933
-	} else {
934
-		return false;
935
-	}
917
+    // Try to execute date creator
918
+    try {
919
+        $dt = new DateTime( trim($str) );
920
+    } catch( Exception $e ) {
921
+        // If fails, it return false, date is incorrect
922
+        return false;
923
+    }
924
+	
925
+    // Checking date
926
+    $month = $dt->format('m');
927
+    $day = $dt->format('d');
928
+    $year = $dt->format('Y');
929
+	
930
+    // Date is ok
931
+    if (checkdate($month, $day, $year)) {
932
+        return true;
933
+    } else {
934
+        return false;
935
+    }
936 936
 }
937 937
\ No newline at end of file
Please login to merge, or discard this patch.
Sistema/Ayudantes/CFPHPMenu.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     
31 31
     
32 32
     function menu_ul($sel = 'inicio')
33
-   {
33
+    {
34 34
         $items = array(
35 35
             'inicio' => array(
36 36
                 'id'     => 'inicio',
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     }
66 66
     
67 67
     function menu_p($sel = 'inicio', $separador = '')
68
-   {
68
+    {
69 69
         //$CI =& get_instance();
70 70
         $items = array(
71 71
             'inicio' => array(
Please login to merge, or discard this patch.
Sistema/Ayudantes/CFPHPPaginador.php 1 patch
Indentation   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -39,311 +39,311 @@
 block discarded – undo
39 39
  * (you can pass the most critical GETs manually if you like)
40 40
  */
41 41
  
42
- //Esta clase fue editada por programadores de Cf con la aprobacion de Ruben Arroyo
42
+    //Esta clase fue editada por programadores de Cf con la aprobacion de Ruben Arroyo
43 43
 
44 44
 namespace Sistema\Ayudantes;
45 45
 
46 46
 class Cf_PHPPaginator {
47
-	/*
47
+    /*
48 48
 	 * MAIN Settings (required)
49 49
 	 */
50 50
 	
51
-	/**
52
-	 * 
53
-	 * @total_records string Total of records to paginate (specify manually)
54
-	 */
55
-	public $total_records = 0;
51
+    /**
52
+     * 
53
+     * @total_records string Total of records to paginate (specify manually)
54
+     */
55
+    public $total_records = 0;
56 56
 	
57 57
 	
58
-	/*
58
+    /*
59 59
 	 * MAIN Settings (optional)
60 60
 	 */
61 61
 	
62
-	/**
63
-	 * @style string  Specify Class to define
64
-	 * @tutorial If is specified, it would create <div class="style"> otherwise it not create div
65
-	 */
66
-	public $style = '';
62
+    /**
63
+     * @style string  Specify Class to define
64
+     * @tutorial If is specified, it would create <div class="style"> otherwise it not create div
65
+     */
66
+    public $style = '';
67 67
 	
68
-	/**
69
-	 * @records number Max records to show on every page
70
-	 */
71
-	public $records = 20;
68
+    /**
69
+     * @records number Max records to show on every page
70
+     */
71
+    public $records = 20;
72 72
 	
73
-	/** 
74
-	 * @max_links number Maxium quantity of links to show before and after actual page
75
-	 * @example If current page is 4 and MAX is 2, it show "2 3 4 5 6"
76
-	 */
77
-	public $max_links = 3;
73
+    /** 
74
+     * @max_links number Maxium quantity of links to show before and after actual page
75
+     * @example If current page is 4 and MAX is 2, it show "2 3 4 5 6"
76
+     */
77
+    public $max_links = 3;
78 78
 	
79
-	/**
80
-	 * @get_name string Specify INDEX of GET that is used
81
-	 * 
82
-	 * It will load automatically the current page. 
83
-	 * If you like, you can specify manually in "$cur_page" 
84
-	 * (if you like filter previously or the script will not load directly from URL)  
85
-	 */
86
-	public $get_name = 'pag';
79
+    /**
80
+     * @get_name string Specify INDEX of GET that is used
81
+     * 
82
+     * It will load automatically the current page. 
83
+     * If you like, you can specify manually in "$cur_page" 
84
+     * (if you like filter previously or the script will not load directly from URL)  
85
+     */
86
+    public $get_name = 'pag';
87 87
 	
88
-	/**
89
-	 * @max_records number Specify maxium quantity of registers will be loaded. "0" disable this
90
-	 */
91
-	public $max_records = 0;
88
+    /**
89
+     * @max_records number Specify maxium quantity of registers will be loaded. "0" disable this
90
+     */
91
+    public $max_records = 0;
92 92
 	
93 93
 	
94
-	/**
95
-	 * @recicle_url boolean If is true, modify directly tue current URL to put the pagination (if not exist any, add &pag= to the end)
96
-	 * If is true, $url_start and $url_end will be ignored
97
-	 */
98
-	public $recicle_url = true;
94
+    /**
95
+     * @recicle_url boolean If is true, modify directly tue current URL to put the pagination (if not exist any, add &pag= to the end)
96
+     * If is true, $url_start and $url_end will be ignored
97
+     */
98
+    public $recicle_url = true;
99 99
 	
100
-	/**
101
-	 * @specific_get array Specify what GETs (and order) you like recicle.
102
-	 * Set array() to ALL (not recomended to avoid atacks DoS)  
103
-	 * Set '' for any
104
-	 * @example array('section', 'pag', 'subsection');
105
-	 * If you don't need 'pag' in the midle, you can ignore it.
106
-	 * WARNING: If the order is very important, use the pag at THE END of url   
107
-	 */
108
-	public $specific_get = '';
100
+    /**
101
+     * @specific_get array Specify what GETs (and order) you like recicle.
102
+     * Set array() to ALL (not recomended to avoid atacks DoS)  
103
+     * Set '' for any
104
+     * @example array('section', 'pag', 'subsection');
105
+     * If you don't need 'pag' in the midle, you can ignore it.
106
+     * WARNING: If the order is very important, use the pag at THE END of url   
107
+     */
108
+    public $specific_get = '';
109 109
 	
110
-	/**
111
-	 * @url_start string specify how the URL of every link start. IF $recicle_url is TRUE, this will be ignored 
112
-	 * @example If you use MOD_REWRITE or JAVASCRIPT, you can put "http://mywebsite.com/subdir/pag-" or "javascript:paginate("
113
-	 * 
114
-	 * This value will auto completed if you leave empty 
115
-	 */
116
-	public $url_start = '';
110
+    /**
111
+     * @url_start string specify how the URL of every link start. IF $recicle_url is TRUE, this will be ignored 
112
+     * @example If you use MOD_REWRITE or JAVASCRIPT, you can put "http://mywebsite.com/subdir/pag-" or "javascript:paginate("
113
+     * 
114
+     * This value will auto completed if you leave empty 
115
+     */
116
+    public $url_start = '';
117 117
 	
118
-	/**
119
-	 * @url_end string specify how the URL of every link ends. IF $recicle_url is TRUE, this will be ignored
120
-	 * @example If you use MOD_REWRITE or JAVASCRIPT, you can put "/" or ");"
121
-	 * 
122
-	 * This value will auto completed if you leave empty
123
-	 */
124
-	public $url_end = '';
118
+    /**
119
+     * @url_end string specify how the URL of every link ends. IF $recicle_url is TRUE, this will be ignored
120
+     * @example If you use MOD_REWRITE or JAVASCRIPT, you can put "/" or ");"
121
+     * 
122
+     * This value will auto completed if you leave empty
123
+     */
124
+    public $url_end = '';
125 125
 	
126 126
 	
127 127
 	
128
-	/*
128
+    /*
129 129
 	 * Design settings
130 130
 	 */
131 131
 	
132
-	// Icons to show "First | Previous | Next | Last"
133
-	//& laquo; = � | & lt; = <
132
+    // Icons to show "First | Previous | Next | Last"
133
+    //& laquo; = � | & lt; = <
134 134
     //& raquo; = � | & gt; = >
135 135
     // Leave empty '' to not show or ' ' to show empty
136
-	public $first = '[&lt;&lt;]';
137
-	public $previous = '[&lt;]';
138
-	public $next = '[&gt;]';
139
-	public $last = '[&gt;&gt;]';
136
+    public $first = '[&lt;&lt;]';
137
+    public $previous = '[&lt;]';
138
+    public $next = '[&gt;]';
139
+    public $last = '[&gt;&gt;]';
140 140
 	
141 141
 	
142
-	/*
142
+    /*
143 143
 	 * RETURNS FROM PAGINATOR and internal use
144 144
 	 */
145
-	// Return current page (auto loaded)
146
-	public $cur_page;
145
+    // Return current page (auto loaded)
146
+    public $cur_page;
147 147
 	
148
-	// original page loaded
149
-	// it contains the real value in GET (ex: -1, 5...) to compare later
150
-	public $original_page;
148
+    // original page loaded
149
+    // it contains the real value in GET (ex: -1, 5...) to compare later
150
+    public $original_page;
151 151
 	
152
-	// Return total pages
153
-	public $total_pages;
152
+    // Return total pages
153
+    public $total_pages;
154 154
 	
155
-	// LIMIT_START / Specify the first record of the page (ex, in page 3 and 20 records is record num 40)
156
-	// Limit max is $records
157
-	public $first_record;
155
+    // LIMIT_START / Specify the first record of the page (ex, in page 3 and 20 records is record num 40)
156
+    // Limit max is $records
157
+    public $first_record;
158 158
 	
159
-	// Specify limit to put directly in mysql query ( LIMIT 0,20 )
160
-	public $limit;
159
+    // Specify limit to put directly in mysql query ( LIMIT 0,20 )
160
+    public $limit;
161 161
 	
162 162
 	
163 163
 /*
164 164
  * Functions
165 165
  */
166
-	/**
167
-	 * @name paginate
168
-	 * @tutorial This function is called directly to load all params
169
-	 * @example $pag->paginate();
170
-	 */
171
-	public function paginate() {
172
-		$this->get(); // Filtering and obtaining variables
173
-		$this->calculate(); // Calc current page
174
-		$this->prepareUrl(); // Preparing URL to show
175
-	}
166
+    /**
167
+     * @name paginate
168
+     * @tutorial This function is called directly to load all params
169
+     * @example $pag->paginate();
170
+     */
171
+    public function paginate() {
172
+        $this->get(); // Filtering and obtaining variables
173
+        $this->calculate(); // Calc current page
174
+        $this->prepareUrl(); // Preparing URL to show
175
+    }
176 176
 	
177
-	/**
178
-	 * @name show
179
-	 * @tutorial Show links of pagination
180
-	 * @example $pag->show();
181
-	 */
182
-	public function show() {
183
-		// Prepare string with links
184
-		// Reading here variables is faster than "$this->var"
185
-		$cur_page = $this->cur_page; 
186
-		$url_start = $this->url_start;
187
-		$url_end = $this->url_end;
177
+    /**
178
+     * @name show
179
+     * @tutorial Show links of pagination
180
+     * @example $pag->show();
181
+     */
182
+    public function show() {
183
+        // Prepare string with links
184
+        // Reading here variables is faster than "$this->var"
185
+        $cur_page = $this->cur_page; 
186
+        $url_start = $this->url_start;
187
+        $url_end = $this->url_end;
188 188
 		
189
-		$start = $cur_page - $this->max_links;
190
-		$end = $cur_page + $this->max_links;
189
+        $start = $cur_page - $this->max_links;
190
+        $end = $cur_page + $this->max_links;
191 191
 		
192
-		if ($start < 1) $start = 1;
193
-		if ($end > $this->total_pages) $end = $this->total_pages;
192
+        if ($start < 1) $start = 1;
193
+        if ($end > $this->total_pages) $end = $this->total_pages;
194 194
 		
195
-		// Showing all clickable pages (create div if class is defined)
196
-		if ($this->style != '') $r = '<div class="'.$this->style.'">';
197
-		else $r = '';
195
+        // Showing all clickable pages (create div if class is defined)
196
+        if ($this->style != '') $r = '<div class="'.$this->style.'">';
197
+        else $r = '';
198 198
 		
199 199
 		
200
-		// First / previous
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> ';
204
-		}
200
+        // First / previous
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> ';
204
+        }
205 205
 		
206
-		// You can optimize this separating BEFORE and AFTER current page in two for (to avoid load "if" in each loop)
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> ';
211
-		}
206
+        // You can optimize this separating BEFORE and AFTER current page in two for (to avoid load "if" in each loop)
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> ';
211
+        }
212 212
 		
213
-		// next / last
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> ';
217
-		}
213
+        // next / last
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> ';
217
+        }
218 218
 		
219
-		// End div (if exist)
220
-		if ($this->style != '') $r .= '</div>';
219
+        // End div (if exist)
220
+        if ($this->style != '') $r .= '</div>';
221 221
 		
222
-		return $r;
223
-	}
222
+        return $r;
223
+    }
224 224
 	
225 225
 	
226
-	/**
227
-	 * @name get
228
-	 * @tutorial This function is autoloaded, it get the current page and filter number to avoid hackers
229
-	 */	 
230
-	private function get() {
231
-		if (!is_numeric($this->cur_page)) {
232
-			// First get the actual page, by default 1
233
-			$cur_page = isset($_GET[$this->get_name]) ? $_GET[$this->get_name] : 1;
234
-			$this->original_page = $cur_page;
226
+    /**
227
+     * @name get
228
+     * @tutorial This function is autoloaded, it get the current page and filter number to avoid hackers
229
+     */	 
230
+    private function get() {
231
+        if (!is_numeric($this->cur_page)) {
232
+            // First get the actual page, by default 1
233
+            $cur_page = isset($_GET[$this->get_name]) ? $_GET[$this->get_name] : 1;
234
+            $this->original_page = $cur_page;
235 235
 			
236
-			// Filter values
237
-			if (!is_numeric($cur_page) or $cur_page < 1) $cur_page = 1;
236
+            // Filter values
237
+            if (!is_numeric($cur_page) or $cur_page < 1) $cur_page = 1;
238 238
 			
239
-			// Set new filtered values (is faster this method)
240
-			$this->cur_page = $cur_page;
241
-		} else {
242
-			$this->original_page = $cur_page;
243
-		}
244
-	}
239
+            // Set new filtered values (is faster this method)
240
+            $this->cur_page = $cur_page;
241
+        } else {
242
+            $this->original_page = $cur_page;
243
+        }
244
+    }
245 245
 	
246
-	/**
247
-	 * @name calculate
248
-	 * @tutorial Do all calcs about current and last page
249
-	 */
250
-	private function calculate() {
251
-		// This vars are very used, so is faster do this
252
-		$max_records = $this->max_records;
253
-		$records = $this->records;
246
+    /**
247
+     * @name calculate
248
+     * @tutorial Do all calcs about current and last page
249
+     */
250
+    private function calculate() {
251
+        // This vars are very used, so is faster do this
252
+        $max_records = $this->max_records;
253
+        $records = $this->records;
254 254
 		
255
-		// Force maxium records loaded (only if is specified by user)
256
-		if ($max_records  > 0 and $max_records  > $total_records) 
257
-			$this->total_records = $max_records;
255
+        // Force maxium records loaded (only if is specified by user)
256
+        if ($max_records  > 0 and $max_records  > $total_records) 
257
+            $this->total_records = $max_records;
258 258
 		
259
-		// Calculate total pages that have
260
-		$total_pages = ceil($this->total_records / $records);
259
+        // Calculate total pages that have
260
+        $total_pages = ceil($this->total_records / $records);
261 261
 		
262
-		// Is correct current page?
263
-		if ($this->cur_page > $total_pages) $this->cur_page = $total_pages;
264
-		$this->total_pages = $total_pages;
262
+        // Is correct current page?
263
+        if ($this->cur_page > $total_pages) $this->cur_page = $total_pages;
264
+        $this->total_pages = $total_pages;
265 265
 		
266
-		// Specify LIMIT to do a query
267
-		$start = ($this->cur_page - 1) * $records;
266
+        // Specify LIMIT to do a query
267
+        $start = ($this->cur_page - 1) * $records;
268 268
 		
269
-		// Forcing maixum records to show (only if is specified by user)
270
-		if ($max_records > 0 and $records > $max_records) {
271
-			$records = $max_records;
272
-			$this->records = $records;
273
-		}
269
+        // Forcing maixum records to show (only if is specified by user)
270
+        if ($max_records > 0 and $records > $max_records) {
271
+            $records = $max_records;
272
+            $this->records = $records;
273
+        }
274 274
 			
275 275
 		
276
-		// Saving changes
277
-		$this->first_record = $start;
278
-		$this->limit = ' LIMIT '.$start.','.$records.' ';
279
-	}
276
+        // Saving changes
277
+        $this->first_record = $start;
278
+        $this->limit = ' LIMIT '.$start.','.$records.' ';
279
+    }
280 280
 	
281
-	/**
282
-	 * @name prepareUrl
283
-	 * @tutorial It prepare the url to show in each link, specified by user
284
-	 * If recicle URL is false, it will auto load $url_start and $url_end
285
-	 */
286
-	private function prepareUrl() {
287
-		// This script use three methods to recicle GET depending user selection
288
-		if ($this->recicle_url) {
289
-			// gonna to recicle the URL
290
-			$gets = $this->specific_get;
291
-			$get_name = $this->get_name;
281
+    /**
282
+     * @name prepareUrl
283
+     * @tutorial It prepare the url to show in each link, specified by user
284
+     * If recicle URL is false, it will auto load $url_start and $url_end
285
+     */
286
+    private function prepareUrl() {
287
+        // This script use three methods to recicle GET depending user selection
288
+        if ($this->recicle_url) {
289
+            // gonna to recicle the URL
290
+            $gets = $this->specific_get;
291
+            $get_name = $this->get_name;
292 292
 			
293
-			// If user specified an array
294
-			if (is_array($gets)) {
295
-				if (empty($gets)) {
296
-					// And is empty, we have to Recicle ALL GET
297
-					// To know that page needs to be replaced we will use the "original_page" (the real get)
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']);
293
+            // If user specified an array
294
+            if (is_array($gets)) {
295
+                if (empty($gets)) {
296
+                    // And is empty, we have to Recicle ALL GET
297
+                    // To know that page needs to be replaced we will use the "original_page" (the real get)
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']);
300 300
 					
301
-					// How start the new URL? To know it, we need to see the last character from current string
302
-					if (!in_array(substr($query_string[0], -1), array('?', '&'))) {
303
-						// Current string haven't any at end and it isn't "&" or "?" ?
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];
307
-					} else {
308
-						// Current string already have ? or &,
309
-						$this->url_start = '?'.$query_string[0];
310
-					}
301
+                    // How start the new URL? To know it, we need to see the last character from current string
302
+                    if (!in_array(substr($query_string[0], -1), array('?', '&'))) {
303
+                        // Current string haven't any at end and it isn't "&" or "?" ?
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];
307
+                    } else {
308
+                        // Current string already have ? or &,
309
+                        $this->url_start = '?'.$query_string[0];
310
+                    }
311 311
 					
312
-					$this->url_end = isset($query_string[1]) ? $query_string[1] : '';
313
-				} else {
314
-					// Only specifics GET, reading all and finally leave in the same order
315
-					// With this we can clean all GET that we don't need (like hacker attempts)
316
-					$tmp = '';
317
-					$tmp_start = ''; // If we found the current page, we move here all $tmp
318
-					foreach ($gets as $get) {
319
-						if ($get != $get_name) {
320
-							// Trying to get the GET
321
-							if (isset($_GET[$get])) $tmp .= $get.'='.$_GET[$get].'&';
322
-						} else {
323
-							// Pour the $tmp content to $tmp_start
324
-							if ($tmp_start == '') $tmp_start .= '?';
325
-							$tmp_start .= $tmp;
326
-							$tmp = '';
327
-						}
328
-					}
312
+                    $this->url_end = isset($query_string[1]) ? $query_string[1] : '';
313
+                } else {
314
+                    // Only specifics GET, reading all and finally leave in the same order
315
+                    // With this we can clean all GET that we don't need (like hacker attempts)
316
+                    $tmp = '';
317
+                    $tmp_start = ''; // If we found the current page, we move here all $tmp
318
+                    foreach ($gets as $get) {
319
+                        if ($get != $get_name) {
320
+                            // Trying to get the GET
321
+                            if (isset($_GET[$get])) $tmp .= $get.'='.$_GET[$get].'&';
322
+                        } else {
323
+                            // Pour the $tmp content to $tmp_start
324
+                            if ($tmp_start == '') $tmp_start .= '?';
325
+                            $tmp_start .= $tmp;
326
+                            $tmp = '';
327
+                        }
328
+                    }
329 329
 					
330
-					// Finally, write the changes in the object
331
-					if ($tmp_start != '') {
332
-						// If have start and end
333
-						$this->url_start = $tmp_start;
334
-						$this->url_end = $tmp;
335
-					}
336
-					else $this->url_start = '?'.$tmp;
337
-				}
338
-			} else{
339
-				// Non recicle
340
-				$this->url_start = '?';
341
-				$this->url_end = ''; 
342
-			}
330
+                    // Finally, write the changes in the object
331
+                    if ($tmp_start != '') {
332
+                        // If have start and end
333
+                        $this->url_start = $tmp_start;
334
+                        $this->url_end = $tmp;
335
+                    }
336
+                    else $this->url_start = '?'.$tmp;
337
+                }
338
+            } else{
339
+                // Non recicle
340
+                $this->url_start = '?';
341
+                $this->url_end = ''; 
342
+            }
343 343
 			
344
-			// Add the pagination
345
-			$this->url_start .= $this->get_name.'=';
346
-		}
347
-	}
344
+            // Add the pagination
345
+            $this->url_start .= $this->get_name.'=';
346
+        }
347
+    }
348 348
 }
349 349
 ?>
350 350
\ No newline at end of file
Please login to merge, or discard this patch.
Sistema/Ayudantes/CFPHPSeguridad.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
     
32 32
     //xss funciones de mitigacion
33 33
     function xsseguro($texto,$encoding='UTF-8'){
34
-       return htmlspecialchars($texto,ENT_QUOTES | ENT_HTML401,$encoding);
34
+        return htmlspecialchars($texto,ENT_QUOTES | ENT_HTML401,$encoding);
35 35
     }
36 36
     function xecho($texto){
37
-       echo xsseguro($texto);
37
+        echo xsseguro($texto);
38 38
     }
39 39
     
40 40
     public function filtrarTexto($texto){
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         $longitudCaracteres = strlen($caracteres);
55 55
         $cadenaAleatoria = '';
56 56
         for ($i = 0; $i < $length; $i++) {
57
-             $cadenaAleatoria .= $caracteres[rand(0, $longitudCaracteres - 1)];
57
+                $cadenaAleatoria .= $caracteres[rand(0, $longitudCaracteres - 1)];
58 58
         }
59 59
         return $cadenaAleatoria;
60 60
     }
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
     
81 81
     function obtenerDireccionIP(){
82 82
     if (!empty($_SERVER ['HTTP_CLIENT_IP'] ))
83
-      $ip=$_SERVER ['HTTP_CLIENT_IP'];
83
+        $ip=$_SERVER ['HTTP_CLIENT_IP'];
84 84
     elseif (!empty($_SERVER ['HTTP_X_FORWARDED_FOR'] ))
85
-      $ip=$_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 92
     function restringirIp($ip){
93 93
         $ipCliente = $this->obtenerDireccionIP();
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         }
102 102
     }
103 103
 	
104
-	function restringirConjuntoIps($ips){
104
+    function restringirConjuntoIps($ips){
105 105
     $ipCliente = obtenerDireccionIP();
106 106
 
107 107
     if (in_array($ipCliente,$ips)){
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
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 119
     if(substr($ipCliente, 0, 8 ) == "150.214."){
@@ -123,20 +123,20 @@  discard block
 block discarded – undo
123 123
         header('location: http://direccion_envio_salida');
124 124
         exit;
125 125
     }
126
-	}
126
+    }
127 127
         
128 128
         
129 129
     /**
130
- *
131
- * @strip injection chars from email headers
132
- *
133
- * @param string $string
134
- *
135
- * return string
136
- *
137
- */
130
+     *
131
+     * @strip injection chars from email headers
132
+     *
133
+     * @param string $string
134
+     *
135
+     * return string
136
+     *
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 
Please login to merge, or discard this patch.
Sistema/Ayudantes/CFPHPVinculos.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,5 +31,5 @@
 block discarded – undo
31 31
     
32 32
     $dominio = "http://www.my-site-domain.com/";
33 33
     return $dominio;
34
-   }
34
+    }
35 35
 }
36 36
\ No newline at end of file
Please login to merge, or discard this patch.
Sistema/Nucleo/CFControlador.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         $rutaLib = RUTA_LIBS . $libreria . '.php';
39 39
         if(is_readable($rutaLib)){
40 40
             require_once $rutaLib;
41
-           //echo 'libreria cargada';
41
+            //echo 'libreria cargada';
42 42
         }
43 43
         else {
44 44
             throw new Exception("houston tenemos un problema! al cargar libreria");
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
     
48 48
     protected function cargaModelo($modelo){
49 49
         $modelo=$modelo.'Modelo';
50
-       $rutaMod = RUTA_MOD . $modelo . '.php';
50
+        $rutaMod = RUTA_MOD . $modelo . '.php';
51 51
         if(is_readable($rutaMod)){
52 52
             require_once $rutaMod;
53 53
             $modelo = new $modelo;
54 54
             return $modelo;
55
-           //echo 'modelo cargado';
55
+            //echo 'modelo cargado';
56 56
         }
57 57
         else {
58 58
             //echo $rutaMod;
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
     }
65 65
     
66 66
     protected function cargaAyudante($ayudante){
67
-       $rutaAyudante = RUTA_AYUDANTES . $ayudante . '.php';
67
+        $rutaAyudante = RUTA_AYUDANTES . $ayudante . '.php';
68 68
         if(is_readable($rutaAyudante)){
69 69
             require_once $rutaAyudante;
70
-           //echo 'libreria cargada';
70
+            //echo 'libreria cargada';
71 71
         }
72 72
         else {
73 73
             throw new Exception("houston tenemos un problema! al cargar ayudante");
Please login to merge, or discard this patch.
Sistema/Nucleo/CFSesion.php 1 patch
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -33,155 +33,155 @@
 block discarded – undo
33 33
 namespace Sistema\Nucleo;
34 34
 class CFSesion
35 35
 {   
36
-   public function __construct() {
37
-       session_regenerate_id(true);
38
-         // set our custom session functions.
39
-      session_set_save_handler(array($this, 'abrir'), array($this, 'cerrar'), array($this, 'leer'), array($this, 'escribir'), array($this, 'destruir'), array($this, 'gc'));
40
-      // This line prevents unexpected effects when using objects as save handlers.
41
-      register_shutdown_function('session_write_close');      
42
-   }   
43
-  /* public function __destruct() {
36
+    public function __construct() {
37
+        session_regenerate_id(true);
38
+            // set our custom session functions.
39
+        session_set_save_handler(array($this, 'abrir'), array($this, 'cerrar'), array($this, 'leer'), array($this, 'escribir'), array($this, 'destruir'), array($this, 'gc'));
40
+        // This line prevents unexpected effects when using objects as save handlers.
41
+        register_shutdown_function('session_write_close');      
42
+    }   
43
+    /* public function __destruct() {
44 44
       session_regenerate_id(true);
45 45
    }*/
46
-           function iniciarSesion($session_name, $secure) {
47
-      // Make sure the session cookie is not accessable via javascript.
48
-      $httpunico = true;
46
+            function iniciarSesion($session_name, $secure) {
47
+        // Make sure the session cookie is not accessable via javascript.
48
+        $httpunico = true;
49 49
 
50
-      // Hash algorithm to use for the sessionid. (use hash_algos() to get a list of available hashes.)
51
-      $sesion_hash = 'sha512';
50
+        // Hash algorithm to use for the sessionid. (use hash_algos() to get a list of available hashes.)
51
+        $sesion_hash = 'sha512';
52 52
 
53
-      // Check if hash is available
54
-      if (in_array($sesion_hash, hash_algos())) {
53
+        // Check if hash is available
54
+        if (in_array($sesion_hash, hash_algos())) {
55 55
         // Set the has function.
56 56
         ini_set('session.hash_function', $sesion_hash);
57
-      }
58
-      // How many bits per character of the hash.
59
-      // The possible values are '4' (0-9, a-f), '5' (0-9, a-v), and '6' (0-9, a-z, A-Z, "-", ",").
60
-      ini_set('session.hash_bits_per_character', 5);
61
-
62
-      // Force the session to only use cookies, not URL variables.
63
-      ini_set('session.use_only_cookies', 1);
64
-
65
-      // Get session cookie parameters 
66
-      $cookieParams = session_get_cookie_params(); 
67
-      // Set the parameters
68
-      session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httpunico); 
69
-      // Change the session name 
70
-      session_name($session_name);
71
-      // Now we cat start the session
72
-      session_start();
57
+        }
58
+        // How many bits per character of the hash.
59
+        // The possible values are '4' (0-9, a-f), '5' (0-9, a-v), and '6' (0-9, a-z, A-Z, "-", ",").
60
+        ini_set('session.hash_bits_per_character', 5);
61
+
62
+        // Force the session to only use cookies, not URL variables.
63
+        ini_set('session.use_only_cookies', 1);
64
+
65
+        // Get session cookie parameters 
66
+        $cookieParams = session_get_cookie_params(); 
67
+        // Set the parameters
68
+        session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httpunico); 
69
+        // Change the session name 
70
+        session_name($session_name);
71
+        // Now we cat start the session
72
+        session_start();
73 73
      
74
-      // This line regenerates the session and delete the old one. 
75
-      // It also generates a new encryption key in the database. 
74
+        // This line regenerates the session and delete the old one. 
75
+        // It also generates a new encryption key in the database. 
76 76
        
77
-   }
77
+    }
78 78
 
79 79
 // ingrese la informacion de conexion a su base de datos, debe ser igual a la que esta en CFConfiguracion.php
80
-   function abrir() {
81
-   $host = "localhost";
82
-   $user = "";
83
-   $pass = "";
84
-   $name = "";
80
+    function abrir() {
81
+    $host = "localhost";
82
+    $user = "";
83
+    $pass = "";
84
+    $name = "";
85 85
    
86
-   $mysqli = new \mysqli($host, $user, $pass, $name);
87
-   $this->db = $mysqli;
88
-   return true;
89
-   }
86
+    $mysqli = new \mysqli($host, $user, $pass, $name);
87
+    $this->db = $mysqli;
88
+    return true;
89
+    }
90 90
 
91
-   function cerrar() {
92
-      $this->db->close();
93
-      return true;
94
-   }
91
+    function cerrar() {
92
+        $this->db->close();
93
+        return true;
94
+    }
95 95
 
96 96
 
97
-   function leer($id) {
98
-      if(!isset($this->read_stmt)) {
99
-      $this->read_stmt = $this->db->prepare("SELECT data FROM sesiones WHERE id = ? LIMIT 1");
100
-   }
101
-   $this->read_stmt->bind_param('s', $id);
102
-   $this->read_stmt->execute();
103
-   $this->read_stmt->store_result();
104
-   $this->read_stmt->bind_result($data);
105
-   $this->read_stmt->fetch();
106
-   $key = $this->getkey($id);
107
-   $data = $this->decrypt($data, $key);
108
-   return $data;
109
-   }
97
+    function leer($id) {
98
+        if(!isset($this->read_stmt)) {
99
+        $this->read_stmt = $this->db->prepare("SELECT data FROM sesiones WHERE id = ? LIMIT 1");
100
+    }
101
+    $this->read_stmt->bind_param('s', $id);
102
+    $this->read_stmt->execute();
103
+    $this->read_stmt->store_result();
104
+    $this->read_stmt->bind_result($data);
105
+    $this->read_stmt->fetch();
106
+    $key = $this->getkey($id);
107
+    $data = $this->decrypt($data, $key);
108
+    return $data;
109
+    }
110 110
 
111 111
 
112 112
 
113 113
 
114 114
 
115
-   function escribir($id, $data) {
116
-      // Get unique key
117
-   $key = $this->getkey($id);
118
-   // Encrypt the data
119
-   $data = $this->encrypt($data, $key);
115
+    function escribir($id, $data) {
116
+        // Get unique key
117
+    $key = $this->getkey($id);
118
+    // Encrypt the data
119
+    $data = $this->encrypt($data, $key);
120 120
  
121
-   $time = time();
122
-   if(!isset($this->w_stmt)) {
123
-      $this->w_stmt = $this->db->prepare("REPLACE INTO sesiones (id, set_time, data, session_key) VALUES (?, ?, ?, ?)");
124
-   }
121
+    $time = time();
122
+    if(!isset($this->w_stmt)) {
123
+        $this->w_stmt = $this->db->prepare("REPLACE INTO sesiones (id, set_time, data, session_key) VALUES (?, ?, ?, ?)");
124
+    }
125 125
  
126
-   $this->w_stmt->bind_param('siss', $id, $time, $data, $key);
127
-   $this->w_stmt->execute();
128
-   return true;
129
-   }
130
-
131
-   function destruir($id) {
132
-      if(!isset($this->delete_stmt)) {
133
-      $this->delete_stmt = $this->db->prepare("DELETE FROM sesiones WHERE id = ?");
134
-   }
135
-   $this->delete_stmt->bind_param('s', $id);
136
-   $this->delete_stmt->execute();
137
-   return true;
138
-   }
139
-
140
-   function gc($max) {
141
-      if(!isset($this->gc_stmt)) {
142
-      $this->gc_stmt = $this->db->prepare("DELETE FROM sesiones WHERE set_time < ?");
143
-   }
144
-   $old = time() - $max;
145
-   $this->gc_stmt->bind_param('s', $old);
146
-   $this->gc_stmt->execute();
147
-   return true;
148
-   }
149
-
150
-   private function getkey($id) {
126
+    $this->w_stmt->bind_param('siss', $id, $time, $data, $key);
127
+    $this->w_stmt->execute();
128
+    return true;
129
+    }
130
+
131
+    function destruir($id) {
132
+        if(!isset($this->delete_stmt)) {
133
+        $this->delete_stmt = $this->db->prepare("DELETE FROM sesiones WHERE id = ?");
134
+    }
135
+    $this->delete_stmt->bind_param('s', $id);
136
+    $this->delete_stmt->execute();
137
+    return true;
138
+    }
139
+
140
+    function gc($max) {
141
+        if(!isset($this->gc_stmt)) {
142
+        $this->gc_stmt = $this->db->prepare("DELETE FROM sesiones WHERE set_time < ?");
143
+    }
144
+    $old = time() - $max;
145
+    $this->gc_stmt->bind_param('s', $old);
146
+    $this->gc_stmt->execute();
147
+    return true;
148
+    }
149
+
150
+    private function getkey($id) {
151 151
            
152 152
       
153
-      if(!isset($this->key_stmt)) {
154
-      $this->key_stmt = $this->db->prepare("SELECT session_key FROM sesiones WHERE id = ? LIMIT 1");
155
-   }
156
-   $this->key_stmt->bind_param('s', $id);
157
-   $this->key_stmt->execute();
158
-   $this->key_stmt->store_result();
159
-   if($this->key_stmt->num_rows == 1) { 
160
-      $this->key_stmt->bind_result($key);
161
-      $this->key_stmt->fetch();
162
-      return $key;
163
-   } else {
164
-      $random_key = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true));
165
-      return $random_key;
166
-   }
167
-   }
168
-
169
-   private function encrypt($data, $key) {
170
-      $salt = 'cH!swe!retReGu7W6bEDRup7usuDUh9THeD2CHeGE*ewr4n39=E@rAsp7c-Ph@pH';
171
-      $key = substr(hash('sha256', $salt.$key.$salt), 0, 32);
172
-      $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
173
-      $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
174
-      $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB, $iv));
175
-      return $encrypted;
176
-   }
177
-   private function decrypt($data, $key) {
178
-      $salt = 'cH!swe!retReGu7W6bEDRup7usuDUh9THeD2CHeGE*ewr4n39=E@rAsp7c-Ph@pH';
179
-      $key = substr(hash('sha256', $salt.$key.$salt), 0, 32);
180
-      $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
181
-      $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
182
-      $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($data), MCRYPT_MODE_ECB, $iv);
183
-      return $decrypted;
184
-   }
153
+        if(!isset($this->key_stmt)) {
154
+        $this->key_stmt = $this->db->prepare("SELECT session_key FROM sesiones WHERE id = ? LIMIT 1");
155
+    }
156
+    $this->key_stmt->bind_param('s', $id);
157
+    $this->key_stmt->execute();
158
+    $this->key_stmt->store_result();
159
+    if($this->key_stmt->num_rows == 1) { 
160
+        $this->key_stmt->bind_result($key);
161
+        $this->key_stmt->fetch();
162
+        return $key;
163
+    } else {
164
+        $random_key = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true));
165
+        return $random_key;
166
+    }
167
+    }
168
+
169
+    private function encrypt($data, $key) {
170
+        $salt = 'cH!swe!retReGu7W6bEDRup7usuDUh9THeD2CHeGE*ewr4n39=E@rAsp7c-Ph@pH';
171
+        $key = substr(hash('sha256', $salt.$key.$salt), 0, 32);
172
+        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
173
+        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
174
+        $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB, $iv));
175
+        return $encrypted;
176
+    }
177
+    private function decrypt($data, $key) {
178
+        $salt = 'cH!swe!retReGu7W6bEDRup7usuDUh9THeD2CHeGE*ewr4n39=E@rAsp7c-Ph@pH';
179
+        $key = substr(hash('sha256', $salt.$key.$salt), 0, 32);
180
+        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
181
+        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
182
+        $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($data), MCRYPT_MODE_ECB, $iv);
183
+        return $decrypted;
184
+    }
185 185
     
186 186
 }
187 187
 
Please login to merge, or discard this patch.