@@ -31,5 +31,5 @@ |
||
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 |
@@ -27,7 +27,7 @@ |
||
27 | 27 | |
28 | 28 | class CFPHPVinculos { |
29 | 29 | |
30 | - function get_dominio(){ |
|
30 | + function get_dominio() { |
|
31 | 31 | |
32 | 32 | $dominio = "http://www.my-site-domain.com/"; |
33 | 33 | return $dominio; |
@@ -32,31 +32,31 @@ |
||
32 | 32 | { |
33 | 33 | $controlador = $peticion->getControlador() . 'Controlador'; |
34 | 34 | //definimos la ruta al controlador |
35 | - $rutaControlador = SITE_ROOT . 'mvc' . DS .'controladores' . DS . $controlador . '.php'; |
|
35 | + $rutaControlador = SITE_ROOT . 'mvc' . DS . 'controladores' . DS . $controlador . '.php'; |
|
36 | 36 | $metodo = $peticion->getMetodo(); |
37 | 37 | $args = $peticion->getArgumentos(); |
38 | 38 | |
39 | 39 | //verifcamos que el archivo existe con la funcion de PHP is_readable |
40 | - if(is_readable($rutaControlador)){ |
|
40 | + if (is_readable($rutaControlador)) { |
|
41 | 41 | require_once $rutaControlador; |
42 | 42 | $controlador = new $controlador; |
43 | 43 | |
44 | - if(is_callable(array($controlador, $metodo))){ |
|
44 | + if (is_callable(array($controlador, $metodo))) { |
|
45 | 45 | $metodo = $peticion->getMetodo(); |
46 | 46 | } |
47 | - else{ |
|
47 | + else { |
|
48 | 48 | $metodo = 'index'; |
49 | 49 | } |
50 | 50 | |
51 | - if(isset($args)){ |
|
51 | + if (isset($args)) { |
|
52 | 52 | call_user_func_array(array($controlador, $metodo), $args); |
53 | 53 | } |
54 | - else{ |
|
54 | + else { |
|
55 | 55 | call_user_func(array($controlador, $metodo)); |
56 | 56 | } |
57 | 57 | |
58 | 58 | } else { |
59 | - header('Location: '. Cf_BASE_URL.'error/'); |
|
59 | + header('Location: ' . Cf_BASE_URL . 'error/'); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | } |
63 | 63 | \ No newline at end of file |
@@ -43,15 +43,13 @@ |
||
43 | 43 | |
44 | 44 | if(is_callable(array($controlador, $metodo))){ |
45 | 45 | $metodo = $peticion->getMetodo(); |
46 | - } |
|
47 | - else{ |
|
46 | + } else{ |
|
48 | 47 | $metodo = 'index'; |
49 | 48 | } |
50 | 49 | |
51 | 50 | if(isset($args)){ |
52 | 51 | call_user_func_array(array($controlador, $metodo), $args); |
53 | - } |
|
54 | - else{ |
|
52 | + } else{ |
|
55 | 53 | call_user_func(array($controlador, $metodo)); |
56 | 54 | } |
57 | 55 |
@@ -38,7 +38,7 @@ discard block |
||
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 |
||
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 |
||
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"); |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | $this->_vista = new CFVista(new CFSolicitud); |
35 | 35 | } |
36 | 36 | |
37 | - protected function cargaLib($libreria){ |
|
37 | + protected function cargaLib($libreria) { |
|
38 | 38 | $rutaLib = RUTA_LIBS . $libreria . '.php'; |
39 | - if(is_readable($rutaLib)){ |
|
39 | + if (is_readable($rutaLib)) { |
|
40 | 40 | require_once $rutaLib; |
41 | 41 | //echo 'libreria cargada'; |
42 | 42 | } |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | - protected function cargaModelo($modelo){ |
|
49 | - $modelo=$modelo.'Modelo'; |
|
48 | + protected function cargaModelo($modelo) { |
|
49 | + $modelo = $modelo . 'Modelo'; |
|
50 | 50 | $rutaMod = RUTA_MOD . $modelo . '.php'; |
51 | - if(is_readable($rutaMod)){ |
|
51 | + if (is_readable($rutaMod)) { |
|
52 | 52 | require_once $rutaMod; |
53 | 53 | $modelo = new $modelo; |
54 | 54 | return $modelo; |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | - protected function cargaAyudante($ayudante){ |
|
66 | + protected function cargaAyudante($ayudante) { |
|
67 | 67 | $rutaAyudante = RUTA_AYUDANTES . $ayudante . '.php'; |
68 | - if(is_readable($rutaAyudante)){ |
|
68 | + if (is_readable($rutaAyudante)) { |
|
69 | 69 | require_once $rutaAyudante; |
70 | 70 | //echo 'libreria cargada'; |
71 | 71 | } |
@@ -39,8 +39,7 @@ discard block |
||
39 | 39 | if(is_readable($rutaLib)){ |
40 | 40 | require_once $rutaLib; |
41 | 41 | //echo 'libreria cargada'; |
42 | - } |
|
43 | - else { |
|
42 | + } else { |
|
44 | 43 | throw new Exception("houston tenemos un problema! al cargar libreria"); |
45 | 44 | } |
46 | 45 | } |
@@ -53,8 +52,7 @@ discard block |
||
53 | 52 | $modelo = new $modelo; |
54 | 53 | return $modelo; |
55 | 54 | //echo 'modelo cargado'; |
56 | - } |
|
57 | - else { |
|
55 | + } else { |
|
58 | 56 | //echo $rutaMod; |
59 | 57 | |
60 | 58 | |
@@ -68,8 +66,7 @@ discard block |
||
68 | 66 | if(is_readable($rutaAyudante)){ |
69 | 67 | require_once $rutaAyudante; |
70 | 68 | //echo 'libreria cargada'; |
71 | - } |
|
72 | - else { |
|
69 | + } else { |
|
73 | 70 | throw new Exception("houston tenemos un problema! al cargar ayudante"); |
74 | 71 | } |
75 | 72 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | |
97 | 97 | function leer($id) { |
98 | - if(!isset($this->read_stmt)) { |
|
98 | + if (!isset($this->read_stmt)) { |
|
99 | 99 | $this->read_stmt = $this->db->prepare("SELECT data FROM sesiones WHERE id = ? LIMIT 1"); |
100 | 100 | } |
101 | 101 | $this->read_stmt->bind_param('s', $id); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $data = $this->encrypt($data, $key); |
120 | 120 | |
121 | 121 | $time = time(); |
122 | - if(!isset($this->w_stmt)) { |
|
122 | + if (!isset($this->w_stmt)) { |
|
123 | 123 | $this->w_stmt = $this->db->prepare("REPLACE INTO sesiones (id, set_time, data, session_key) VALUES (?, ?, ?, ?)"); |
124 | 124 | } |
125 | 125 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | function destruir($id) { |
132 | - if(!isset($this->delete_stmt)) { |
|
132 | + if (!isset($this->delete_stmt)) { |
|
133 | 133 | $this->delete_stmt = $this->db->prepare("DELETE FROM sesiones WHERE id = ?"); |
134 | 134 | } |
135 | 135 | $this->delete_stmt->bind_param('s', $id); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | } |
139 | 139 | |
140 | 140 | function gc($max) { |
141 | - if(!isset($this->gc_stmt)) { |
|
141 | + if (!isset($this->gc_stmt)) { |
|
142 | 142 | $this->gc_stmt = $this->db->prepare("DELETE FROM sesiones WHERE set_time < ?"); |
143 | 143 | } |
144 | 144 | $old = time() - $max; |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | private function getkey($id) { |
151 | 151 | |
152 | 152 | |
153 | - if(!isset($this->key_stmt)) { |
|
153 | + if (!isset($this->key_stmt)) { |
|
154 | 154 | $this->key_stmt = $this->db->prepare("SELECT session_key FROM sesiones WHERE id = ? LIMIT 1"); |
155 | 155 | } |
156 | 156 | $this->key_stmt->bind_param('s', $id); |
157 | 157 | $this->key_stmt->execute(); |
158 | 158 | $this->key_stmt->store_result(); |
159 | - if($this->key_stmt->num_rows == 1) { |
|
159 | + if ($this->key_stmt->num_rows == 1) { |
|
160 | 160 | $this->key_stmt->bind_result($key); |
161 | 161 | $this->key_stmt->fetch(); |
162 | 162 | return $key; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | private function encrypt($data, $key) { |
170 | 170 | $salt = 'cH!swe!retReGu7W6bEDRup7usuDUh9THeD2CHeGE*ewr4n39=E@rAsp7c-Ph@pH'; |
171 | - $key = substr(hash('sha256', $salt.$key.$salt), 0, 32); |
|
171 | + $key = substr(hash('sha256', $salt . $key . $salt), 0, 32); |
|
172 | 172 | $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); |
173 | 173 | $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); |
174 | 174 | $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB, $iv)); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | } |
177 | 177 | private function decrypt($data, $key) { |
178 | 178 | $salt = 'cH!swe!retReGu7W6bEDRup7usuDUh9THeD2CHeGE*ewr4n39=E@rAsp7c-Ph@pH'; |
179 | - $key = substr(hash('sha256', $salt.$key.$salt), 0, 32); |
|
179 | + $key = substr(hash('sha256', $salt . $key . $salt), 0, 32); |
|
180 | 180 | $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); |
181 | 181 | $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); |
182 | 182 | $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($data), MCRYPT_MODE_ECB, $iv); |
@@ -41,155 +41,155 @@ |
||
41 | 41 | private $bdchar = CF_BD_CHAR; |
42 | 42 | private $bdconector = CF_BD_CONECTOR; |
43 | 43 | |
44 | - public function __construct() { |
|
45 | - session_regenerate_id(true); |
|
46 | - // set our custom session functions. |
|
47 | - session_set_save_handler(array($this, 'abrir'), array($this, 'cerrar'), array($this, 'leer'), array($this, 'escribir'), array($this, 'destruir'), array($this, 'gc')); |
|
48 | - // This line prevents unexpected effects when using objects as save handlers. |
|
49 | - register_shutdown_function('session_write_close'); |
|
50 | - } |
|
51 | - /* public function __destruct() { |
|
44 | + public function __construct() { |
|
45 | + session_regenerate_id(true); |
|
46 | + // set our custom session functions. |
|
47 | + session_set_save_handler(array($this, 'abrir'), array($this, 'cerrar'), array($this, 'leer'), array($this, 'escribir'), array($this, 'destruir'), array($this, 'gc')); |
|
48 | + // This line prevents unexpected effects when using objects as save handlers. |
|
49 | + register_shutdown_function('session_write_close'); |
|
50 | + } |
|
51 | + /* public function __destruct() { |
|
52 | 52 | session_regenerate_id(true); |
53 | 53 | }*/ |
54 | - function iniciarSesion($session_name, $secure) { |
|
55 | - // Make sure the session cookie is not accessable via javascript. |
|
56 | - $httpunico = true; |
|
54 | + function iniciarSesion($session_name, $secure) { |
|
55 | + // Make sure the session cookie is not accessable via javascript. |
|
56 | + $httpunico = true; |
|
57 | 57 | |
58 | - // Hash algorithm to use for the sessionid. (use hash_algos() to get a list of available hashes.) |
|
59 | - $sesion_hash = 'sha512'; |
|
58 | + // Hash algorithm to use for the sessionid. (use hash_algos() to get a list of available hashes.) |
|
59 | + $sesion_hash = 'sha512'; |
|
60 | 60 | |
61 | - // Check if hash is available |
|
62 | - if (in_array($sesion_hash, hash_algos())) { |
|
61 | + // Check if hash is available |
|
62 | + if (in_array($sesion_hash, hash_algos())) { |
|
63 | 63 | // Set the has function. |
64 | 64 | ini_set('session.hash_function', $sesion_hash); |
65 | - } |
|
66 | - // How many bits per character of the hash. |
|
67 | - // The possible values are '4' (0-9, a-f), '5' (0-9, a-v), and '6' (0-9, a-z, A-Z, "-", ","). |
|
68 | - ini_set('session.hash_bits_per_character', 5); |
|
69 | - |
|
70 | - // Force the session to only use cookies, not URL variables. |
|
71 | - ini_set('session.use_only_cookies', 1); |
|
72 | - |
|
73 | - // Get session cookie parameters |
|
74 | - $cookieParams = session_get_cookie_params(); |
|
75 | - // Set the parameters |
|
76 | - session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httpunico); |
|
77 | - // Change the session name |
|
78 | - session_name($session_name); |
|
79 | - // Now we cat start the session |
|
80 | - session_start(); |
|
65 | + } |
|
66 | + // How many bits per character of the hash. |
|
67 | + // The possible values are '4' (0-9, a-f), '5' (0-9, a-v), and '6' (0-9, a-z, A-Z, "-", ","). |
|
68 | + ini_set('session.hash_bits_per_character', 5); |
|
69 | + |
|
70 | + // Force the session to only use cookies, not URL variables. |
|
71 | + ini_set('session.use_only_cookies', 1); |
|
72 | + |
|
73 | + // Get session cookie parameters |
|
74 | + $cookieParams = session_get_cookie_params(); |
|
75 | + // Set the parameters |
|
76 | + session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httpunico); |
|
77 | + // Change the session name |
|
78 | + session_name($session_name); |
|
79 | + // Now we cat start the session |
|
80 | + session_start(); |
|
81 | 81 | |
82 | - // This line regenerates the session and delete the old one. |
|
83 | - // It also generates a new encryption key in the database. |
|
82 | + // This line regenerates the session and delete the old one. |
|
83 | + // It also generates a new encryption key in the database. |
|
84 | 84 | |
85 | - } |
|
85 | + } |
|
86 | 86 | |
87 | 87 | // ingrese la informacion de conexion a su base de datos, debe ser igual a la que esta en CFConfiguracion.php |
88 | - function abrir() { |
|
89 | - $host = $this->host; |
|
90 | - $user = $this->usuario; |
|
91 | - $pass = $this->clave; |
|
92 | - $name = $this->bdnombree; |
|
88 | + function abrir() { |
|
89 | + $host = $this->host; |
|
90 | + $user = $this->usuario; |
|
91 | + $pass = $this->clave; |
|
92 | + $name = $this->bdnombree; |
|
93 | 93 | |
94 | - $mysqli = new \mysqli($host, $user, $pass, $name); |
|
95 | - $this->db = $mysqli; |
|
96 | - return true; |
|
97 | - } |
|
94 | + $mysqli = new \mysqli($host, $user, $pass, $name); |
|
95 | + $this->db = $mysqli; |
|
96 | + return true; |
|
97 | + } |
|
98 | 98 | |
99 | - function cerrar() { |
|
100 | - $this->db->close(); |
|
101 | - return true; |
|
102 | - } |
|
99 | + function cerrar() { |
|
100 | + $this->db->close(); |
|
101 | + return true; |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | - function leer($id) { |
|
106 | - if(!isset($this->read_stmt)) { |
|
107 | - $this->read_stmt = $this->db->prepare("SELECT data FROM sesiones WHERE id = ? LIMIT 1"); |
|
108 | - } |
|
109 | - $this->read_stmt->bind_param('s', $id); |
|
110 | - $this->read_stmt->execute(); |
|
111 | - $this->read_stmt->store_result(); |
|
112 | - $this->read_stmt->bind_result($data); |
|
113 | - $this->read_stmt->fetch(); |
|
114 | - $key = $this->getkey($id); |
|
115 | - $data = $this->decrypt($data, $key); |
|
116 | - return $data; |
|
117 | - } |
|
105 | + function leer($id) { |
|
106 | + if(!isset($this->read_stmt)) { |
|
107 | + $this->read_stmt = $this->db->prepare("SELECT data FROM sesiones WHERE id = ? LIMIT 1"); |
|
108 | + } |
|
109 | + $this->read_stmt->bind_param('s', $id); |
|
110 | + $this->read_stmt->execute(); |
|
111 | + $this->read_stmt->store_result(); |
|
112 | + $this->read_stmt->bind_result($data); |
|
113 | + $this->read_stmt->fetch(); |
|
114 | + $key = $this->getkey($id); |
|
115 | + $data = $this->decrypt($data, $key); |
|
116 | + return $data; |
|
117 | + } |
|
118 | 118 | |
119 | 119 | |
120 | 120 | |
121 | 121 | |
122 | 122 | |
123 | - function escribir($id, $data) { |
|
124 | - // Get unique key |
|
125 | - $key = $this->getkey($id); |
|
126 | - // Encrypt the data |
|
127 | - $data = $this->encrypt($data, $key); |
|
123 | + function escribir($id, $data) { |
|
124 | + // Get unique key |
|
125 | + $key = $this->getkey($id); |
|
126 | + // Encrypt the data |
|
127 | + $data = $this->encrypt($data, $key); |
|
128 | 128 | |
129 | - $time = time(); |
|
130 | - if(!isset($this->w_stmt)) { |
|
131 | - $this->w_stmt = $this->db->prepare("REPLACE INTO sesiones (id, set_time, data, session_key) VALUES (?, ?, ?, ?)"); |
|
132 | - } |
|
129 | + $time = time(); |
|
130 | + if(!isset($this->w_stmt)) { |
|
131 | + $this->w_stmt = $this->db->prepare("REPLACE INTO sesiones (id, set_time, data, session_key) VALUES (?, ?, ?, ?)"); |
|
132 | + } |
|
133 | 133 | |
134 | - $this->w_stmt->bind_param('siss', $id, $time, $data, $key); |
|
135 | - $this->w_stmt->execute(); |
|
136 | - return true; |
|
137 | - } |
|
138 | - |
|
139 | - function destruir($id) { |
|
140 | - if(!isset($this->delete_stmt)) { |
|
141 | - $this->delete_stmt = $this->db->prepare("DELETE FROM sesiones WHERE id = ?"); |
|
142 | - } |
|
143 | - $this->delete_stmt->bind_param('s', $id); |
|
144 | - $this->delete_stmt->execute(); |
|
145 | - return true; |
|
146 | - } |
|
147 | - |
|
148 | - function gc($max) { |
|
149 | - if(!isset($this->gc_stmt)) { |
|
150 | - $this->gc_stmt = $this->db->prepare("DELETE FROM sesiones WHERE set_time < ?"); |
|
151 | - } |
|
152 | - $old = time() - $max; |
|
153 | - $this->gc_stmt->bind_param('s', $old); |
|
154 | - $this->gc_stmt->execute(); |
|
155 | - return true; |
|
156 | - } |
|
157 | - |
|
158 | - private function getkey($id) { |
|
134 | + $this->w_stmt->bind_param('siss', $id, $time, $data, $key); |
|
135 | + $this->w_stmt->execute(); |
|
136 | + return true; |
|
137 | + } |
|
138 | + |
|
139 | + function destruir($id) { |
|
140 | + if(!isset($this->delete_stmt)) { |
|
141 | + $this->delete_stmt = $this->db->prepare("DELETE FROM sesiones WHERE id = ?"); |
|
142 | + } |
|
143 | + $this->delete_stmt->bind_param('s', $id); |
|
144 | + $this->delete_stmt->execute(); |
|
145 | + return true; |
|
146 | + } |
|
147 | + |
|
148 | + function gc($max) { |
|
149 | + if(!isset($this->gc_stmt)) { |
|
150 | + $this->gc_stmt = $this->db->prepare("DELETE FROM sesiones WHERE set_time < ?"); |
|
151 | + } |
|
152 | + $old = time() - $max; |
|
153 | + $this->gc_stmt->bind_param('s', $old); |
|
154 | + $this->gc_stmt->execute(); |
|
155 | + return true; |
|
156 | + } |
|
157 | + |
|
158 | + private function getkey($id) { |
|
159 | 159 | |
160 | 160 | |
161 | - if(!isset($this->key_stmt)) { |
|
162 | - $this->key_stmt = $this->db->prepare("SELECT session_key FROM sesiones WHERE id = ? LIMIT 1"); |
|
163 | - } |
|
164 | - $this->key_stmt->bind_param('s', $id); |
|
165 | - $this->key_stmt->execute(); |
|
166 | - $this->key_stmt->store_result(); |
|
167 | - if($this->key_stmt->num_rows == 1) { |
|
168 | - $this->key_stmt->bind_result($key); |
|
169 | - $this->key_stmt->fetch(); |
|
170 | - return $key; |
|
171 | - } else { |
|
172 | - $random_key = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true)); |
|
173 | - return $random_key; |
|
174 | - } |
|
175 | - } |
|
176 | - |
|
177 | - private function encrypt($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 | - $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB, $iv)); |
|
183 | - return $encrypted; |
|
184 | - } |
|
185 | - private function decrypt($data, $key) { |
|
186 | - $salt = 'cH!swe!retReGu7W6bEDRup7usuDUh9THeD2CHeGE*ewr4n39=E@rAsp7c-Ph@pH'; |
|
187 | - $key = substr(hash('sha256', $salt.$key.$salt), 0, 32); |
|
188 | - $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); |
|
189 | - $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); |
|
190 | - $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($data), MCRYPT_MODE_ECB, $iv); |
|
191 | - return $decrypted; |
|
192 | - } |
|
161 | + if(!isset($this->key_stmt)) { |
|
162 | + $this->key_stmt = $this->db->prepare("SELECT session_key FROM sesiones WHERE id = ? LIMIT 1"); |
|
163 | + } |
|
164 | + $this->key_stmt->bind_param('s', $id); |
|
165 | + $this->key_stmt->execute(); |
|
166 | + $this->key_stmt->store_result(); |
|
167 | + if($this->key_stmt->num_rows == 1) { |
|
168 | + $this->key_stmt->bind_result($key); |
|
169 | + $this->key_stmt->fetch(); |
|
170 | + return $key; |
|
171 | + } else { |
|
172 | + $random_key = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true)); |
|
173 | + return $random_key; |
|
174 | + } |
|
175 | + } |
|
176 | + |
|
177 | + private function encrypt($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 | + $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB, $iv)); |
|
183 | + return $encrypted; |
|
184 | + } |
|
185 | + private function decrypt($data, $key) { |
|
186 | + $salt = 'cH!swe!retReGu7W6bEDRup7usuDUh9THeD2CHeGE*ewr4n39=E@rAsp7c-Ph@pH'; |
|
187 | + $key = substr(hash('sha256', $salt.$key.$salt), 0, 32); |
|
188 | + $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); |
|
189 | + $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); |
|
190 | + $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($data), MCRYPT_MODE_ECB, $iv); |
|
191 | + return $decrypted; |
|
192 | + } |
|
193 | 193 | |
194 | 194 | } |
195 | 195 |
@@ -51,6 +51,11 @@ discard block |
||
51 | 51 | /* public function __destruct() { |
52 | 52 | session_regenerate_id(true); |
53 | 53 | }*/ |
54 | + |
|
55 | + /** |
|
56 | + * @param string $session_name |
|
57 | + * @param false|string $secure |
|
58 | + */ |
|
54 | 59 | function iniciarSesion($session_name, $secure) { |
55 | 60 | // Make sure the session cookie is not accessable via javascript. |
56 | 61 | $httpunico = true; |
@@ -136,6 +141,9 @@ discard block |
||
136 | 141 | return true; |
137 | 142 | } |
138 | 143 | |
144 | + /** |
|
145 | + * @param string $id |
|
146 | + */ |
|
139 | 147 | function destruir($id) { |
140 | 148 | if(!isset($this->delete_stmt)) { |
141 | 149 | $this->delete_stmt = $this->db->prepare("DELETE FROM sesiones WHERE id = ?"); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | private $_argumentos; |
33 | 33 | |
34 | 34 | public function __construct() { |
35 | - if(isset($_GET['url'])){ |
|
35 | + if (isset($_GET['url'])) { |
|
36 | 36 | $url = filter_input(INPUT_GET, 'url', FILTER_SANITIZE_URL); |
37 | 37 | $url = explode('/', $url); |
38 | 38 | $url = array_filter($url); |
@@ -42,15 +42,15 @@ discard block |
||
42 | 42 | $this->_argumentos = $url; |
43 | 43 | } |
44 | 44 | |
45 | - if(!$this->_controlador){ |
|
45 | + if (!$this->_controlador) { |
|
46 | 46 | $this->_controlador = CONTROLADOR_INICIAL; |
47 | 47 | } |
48 | 48 | |
49 | - if(!$this->_metodo){ |
|
49 | + if (!$this->_metodo) { |
|
50 | 50 | $this->_metodo = 'index'; |
51 | 51 | } |
52 | 52 | |
53 | - if(!isset($this->_argumentos)){ |
|
53 | + if (!isset($this->_argumentos)) { |
|
54 | 54 | $this->_argumentos = array(); |
55 | 55 | } |
56 | 56 | } |
@@ -38,14 +38,14 @@ |
||
38 | 38 | |
39 | 39 | $ver_ruta = VIEW_PATH . $this->_controlador . DS . $vista . '.phtml'; |
40 | 40 | |
41 | - if(is_readable($ver_ruta)){ |
|
41 | + if (is_readable($ver_ruta)) { |
|
42 | 42 | include_once SITE_ROOT . 'mvc/vistas' . DS . ADICIONALES_VISTA . DS . 'encabezado.php'; |
43 | 43 | include_once $ver_ruta; |
44 | 44 | include_once SITE_ROOT . 'mvc/vistas' . DS . ADICIONALES_VISTA . DS . 'pie_de_pagina.php'; |
45 | 45 | } |
46 | 46 | else { |
47 | 47 | |
48 | - header('Location: '. Cf_BASE_URL.'error/index'.'?error='.'vista' ); |
|
48 | + header('Location: ' . Cf_BASE_URL . 'error/index' . '?error=' . 'vista'); |
|
49 | 49 | |
50 | 50 | } |
51 | 51 | } |
@@ -42,8 +42,7 @@ |
||
42 | 42 | include_once SITE_ROOT . 'mvc/vistas' . DS . ADICIONALES_VISTA . DS . 'encabezado.php'; |
43 | 43 | include_once $ver_ruta; |
44 | 44 | include_once SITE_ROOT . 'mvc/vistas' . DS . ADICIONALES_VISTA . DS . 'pie_de_pagina.php'; |
45 | - } |
|
46 | - else { |
|
45 | + } else { |
|
47 | 46 | |
48 | 47 | header('Location: '. Cf_BASE_URL.'error/index'.'?error='.'vista' ); |
49 | 48 |
@@ -102,31 +102,31 @@ |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | switch ($lang) { |
105 | - case 'en': |
|
105 | + case 'en': |
|
106 | 106 | $lang_file = 'lang.en.php'; |
107 | - break; |
|
107 | + break; |
|
108 | 108 | |
109 | - case 'de': |
|
109 | + case 'de': |
|
110 | 110 | $lang_file = 'lang.de.php'; |
111 | - break; |
|
111 | + break; |
|
112 | 112 | |
113 | - case 'zh': |
|
113 | + case 'zh': |
|
114 | 114 | $lang_file = 'lang.zh.php'; |
115 | - break; |
|
115 | + break; |
|
116 | 116 | |
117 | - case 'pt': |
|
117 | + case 'pt': |
|
118 | 118 | $lang_file = 'lang.pt.php'; |
119 | - break; |
|
119 | + break; |
|
120 | 120 | |
121 | - case 'pt': |
|
121 | + case 'pt': |
|
122 | 122 | $lang_file = 'lang.pt.php'; |
123 | - break; |
|
123 | + break; |
|
124 | 124 | |
125 | - case 'es': |
|
125 | + case 'es': |
|
126 | 126 | $lang_file = 'lang.es.php'; |
127 | - break; |
|
127 | + break; |
|
128 | 128 | |
129 | - default: |
|
129 | + default: |
|
130 | 130 | $lang_file = 'lang.en.php'; |
131 | 131 | |
132 | 132 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * <http://www.calimaframework.com>. |
24 | 24 | */ |
25 | 25 | |
26 | -require_once __DIR__.'/vendor/autoload.php'; |
|
26 | +require_once __DIR__ . '/vendor/autoload.php'; |
|
27 | 27 | |
28 | 28 | use Sistema\Nucleo; |
29 | 29 | use Sistema\Ayudantes; |
@@ -42,44 +42,44 @@ discard block |
||
42 | 42 | /** Cf directorio separador */ |
43 | 43 | defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); |
44 | 44 | /** Cf raiz del sitio */ |
45 | -defined('SITE_ROOT')? null: define('SITE_ROOT', realpath(dirname(__FILE__)).DS); |
|
45 | +defined('SITE_ROOT') ? null : define('SITE_ROOT', realpath(dirname(__FILE__)) . DS); |
|
46 | 46 | /** Cf PATH del sitio */ |
47 | -defined('SITE_PATH') ? NULL : define ('SITE_PATH', realpath(dirname(__FILE__) . DS . '..' . DS) . DS); |
|
47 | +defined('SITE_PATH') ? NULL : define('SITE_PATH', realpath(dirname(__FILE__) . DS . '..' . DS) . DS); |
|
48 | 48 | |
49 | 49 | /** Cf definimos constante Ruta directa al nucleo de framework */ |
50 | -define('RUTA_NUCLEO', SITE_ROOT . 'Sistema'.DS.'Nucleo' . DS); |
|
50 | +define('RUTA_NUCLEO', SITE_ROOT . 'Sistema' . DS . 'Nucleo' . DS); |
|
51 | 51 | |
52 | 52 | # define para mvc erp |
53 | 53 | |
54 | 54 | /** Cf definimos constante directa a la vista del framework */ |
55 | -define('VIEW_PATH', SITE_ROOT . 'mvc'.DS.'vistas' . DS); |
|
55 | +define('VIEW_PATH', SITE_ROOT . 'mvc' . DS . 'vistas' . DS); |
|
56 | 56 | /** Cf definimos constante directa a los controladores del framework */ |
57 | -define('CONTR_PATH', SITE_ROOT . 'mvc'.DS.'controladores' . DS); |
|
57 | +define('CONTR_PATH', SITE_ROOT . 'mvc' . DS . 'controladores' . DS); |
|
58 | 58 | /** Cf definimos constante directa a los modelos del framework */ |
59 | -define('RUTA_MOD', SITE_ROOT . 'mvc'.DS.'modelos' . DS); |
|
59 | +define('RUTA_MOD', SITE_ROOT . 'mvc' . DS . 'modelos' . DS); |
|
60 | 60 | |
61 | 61 | # define ruta a los stilos del public |
62 | 62 | |
63 | 63 | /** Cf definimos constante directa a los css dentro del directorio public_ del framework */ |
64 | -define('CSS_PATH', SITE_ROOT . 'public_'.DS.'css' . DS); |
|
64 | +define('CSS_PATH', SITE_ROOT . 'public_' . DS . 'css' . DS); |
|
65 | 65 | /** Cf definimos constante directa a los css dentro del directorio public_ del framework */ |
66 | -define('IMG_PATH', SITE_ROOT . 'public_'.DS.'img' . DS); |
|
66 | +define('IMG_PATH', SITE_ROOT . 'public_' . DS . 'img' . DS); |
|
67 | 67 | /** Cf definimos constante directa a los js dentro del directorio public_ del framework */ |
68 | -define('JS_PATH', SITE_ROOT . 'public_'.DS.'js' . DS); |
|
68 | +define('JS_PATH', SITE_ROOT . 'public_' . DS . 'js' . DS); |
|
69 | 69 | /** Cf definimos constante directa a las librerias dentro del framework */ |
70 | -define('RUTA_LIBS', SITE_ROOT . 'Sistema'.DS.'librerias' . DS); |
|
70 | +define('RUTA_LIBS', SITE_ROOT . 'Sistema' . DS . 'librerias' . DS); |
|
71 | 71 | /** Cf definimos constante directa a los ayudantes del framework */ |
72 | -define('RUTA_AYUDANTES', SITE_ROOT . 'Sistema'.DS.'ayudantes' . DS); |
|
72 | +define('RUTA_AYUDANTES', SITE_ROOT . 'Sistema' . DS . 'ayudantes' . DS); |
|
73 | 73 | |
74 | 74 | /** Cf definimos constante directa a los lenguajes del framework */ |
75 | -define('RUTA_LENGUAJES', SITE_ROOT . 'Sistema'.DS.'lenguajes' . DS); |
|
75 | +define('RUTA_LENGUAJES', SITE_ROOT . 'Sistema' . DS . 'lenguajes' . DS); |
|
76 | 76 | |
77 | 77 | |
78 | 78 | //LENGUAJES |
79 | 79 | //En el directorio sistema lenguajes hay varios archivos php cada uno para crear las constantes en el idioma especifico |
80 | 80 | //luego por get capturamos la variable lan al inicio de la aplicacion asi: www.tuapp.com/?lang=de |
81 | 81 | |
82 | -if(isSet($_GET['lang'])) |
|
82 | +if (isSet($_GET['lang'])) |
|
83 | 83 | { |
84 | 84 | $lang = $_GET['lang']; |
85 | 85 | |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | |
89 | 89 | setcookie('lang', $lang, time() + (3600 * 24 * 30)); |
90 | 90 | } |
91 | -else if(isSet($_SESSION['lang'])) |
|
91 | +else if (isSet($_SESSION['lang'])) |
|
92 | 92 | { |
93 | 93 | $lang = $_SESSION['lang']; |
94 | 94 | } |
95 | -else if(isSet($_COOKIE['lang'])) |
|
95 | +else if (isSet($_COOKIE['lang'])) |
|
96 | 96 | { |
97 | 97 | $lang = $_COOKIE['lang']; |
98 | 98 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | //require_once RUTA_NUCLEO . 'Cf_Autocarga.php'; |
149 | 149 | require_once RUTA_NUCLEO . 'CFConfiguracion.php'; |
150 | 150 | |
151 | -try{ |
|
151 | +try { |
|
152 | 152 | |
153 | 153 | Nucleo\CFBootstrap::actuar(new Nucleo\CFSolicitud); |
154 | 154 | //CFBootstrap::actuar(new CFSolicitud); |
@@ -87,16 +87,13 @@ |
||
87 | 87 | $_SESSION['lang'] = $lang; |
88 | 88 | |
89 | 89 | setcookie('lang', $lang, time() + (3600 * 24 * 30)); |
90 | -} |
|
91 | -else if(isSet($_SESSION['lang'])) |
|
90 | +} else if(isSet($_SESSION['lang'])) |
|
92 | 91 | { |
93 | 92 | $lang = $_SESSION['lang']; |
94 | -} |
|
95 | -else if(isSet($_COOKIE['lang'])) |
|
93 | +} else if(isSet($_COOKIE['lang'])) |
|
96 | 94 | { |
97 | 95 | $lang = $_COOKIE['lang']; |
98 | -} |
|
99 | -else |
|
96 | +} else |
|
100 | 97 | { |
101 | 98 | $lang = 'es'; // por defecto el idioma para el app es español puede ser en, bt, de, zh |
102 | 99 | } |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | if (isset($_POST['enviar'])&& isset($_POST['option1']) ) { |
62 | 62 | |
63 | 63 | $datas->insertarDatos( |
64 | - $this->_ayuda->filtrarEntero($_POST['id']), |
|
65 | - $this->_ayuda->filtrarTexto($_POST['nombre']), |
|
66 | - $this->_ayuda->filtrarTexto($_POST['email']), |
|
67 | - $this->_ayuda->filtrarTexto($_POST['comentario']) |
|
64 | + $this->_ayuda->filtrarEntero($_POST['id']), |
|
65 | + $this->_ayuda->filtrarTexto($_POST['nombre']), |
|
66 | + $this->_ayuda->filtrarTexto($_POST['email']), |
|
67 | + $this->_ayuda->filtrarTexto($_POST['comentario']) |
|
68 | 68 | ); |
69 | 69 | echo $this->_ayuda->filtrarEntero('id'); |
70 | 70 | $_POST['option1']=false; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | public function insertarComentario(){ |
77 | 77 | |
78 | - /*$this->_vista->titulo = 'Registro CalimaFramework'; |
|
78 | + /*$this->_vista->titulo = 'Registro CalimaFramework'; |
|
79 | 79 | if(isset($_GET['titulo'])){ |
80 | 80 | $this->_vista->salida_campo = $_GET['titulo']; |
81 | 81 | } |
@@ -19,46 +19,46 @@ discard block |
||
19 | 19 | $this->_ayuda = new Sistema\Ayudantes\CFPHPAyuda(); |
20 | 20 | } |
21 | 21 | |
22 | - public function index(){ |
|
22 | + public function index() { |
|
23 | 23 | $datas = $this->cargaModelo('blog'); |
24 | 24 | |
25 | - $this->_vista->postear= $datas->llamarDatosBlog(); |
|
26 | - $this->_vista->categorias= $datas->llamarDatosCategoria(); |
|
27 | - $this->_vista->tags= $datas->llamarDatosTags(); |
|
25 | + $this->_vista->postear = $datas->llamarDatosBlog(); |
|
26 | + $this->_vista->categorias = $datas->llamarDatosCategoria(); |
|
27 | + $this->_vista->tags = $datas->llamarDatosTags(); |
|
28 | 28 | $this->_vista->titulo = 'Blog Calima Framework'; |
29 | 29 | $this->_vista->imprimirVista('index', 'blog'); |
30 | 30 | |
31 | 31 | } |
32 | - public function crearpost(){ |
|
32 | + public function crearpost() { |
|
33 | 33 | $datas = $this->cargaModelo('blog'); |
34 | 34 | |
35 | - $this->_vista->postear= $datas->llamarDatosBlog(); |
|
35 | + $this->_vista->postear = $datas->llamarDatosBlog(); |
|
36 | 36 | $this->_vista->titulo = 'Blog Calima Framework crear post'; |
37 | 37 | $this->_vista->imprimirVista('crearpost', 'blog'); |
38 | 38 | |
39 | 39 | } |
40 | 40 | |
41 | - public function wikipost(){ |
|
41 | + public function wikipost() { |
|
42 | 42 | $datas = $this->cargaModelo('blog'); |
43 | 43 | |
44 | - $this->_vista->postear= $datas->llamarDatosBlog(); |
|
45 | - $this->_vista->tags= $datas->llamarDatosTags(); |
|
46 | - $this->_vista->comentarios= $datas->llamarComentarios(); |
|
47 | - $this->_vista->categorias= $datas->llamarDatosCategoria(); |
|
48 | - $this->_vista->contar= $datas->contarComentarios($_GET['id']); |
|
49 | - $this->_vista->video= $datas->llamarDatosBlogId($_GET['id']); |
|
44 | + $this->_vista->postear = $datas->llamarDatosBlog(); |
|
45 | + $this->_vista->tags = $datas->llamarDatosTags(); |
|
46 | + $this->_vista->comentarios = $datas->llamarComentarios(); |
|
47 | + $this->_vista->categorias = $datas->llamarDatosCategoria(); |
|
48 | + $this->_vista->contar = $datas->contarComentarios($_GET['id']); |
|
49 | + $this->_vista->video = $datas->llamarDatosBlogId($_GET['id']); |
|
50 | 50 | $this->_vista->titulo = 'Blog 1 Calima Framework'; |
51 | 51 | $this->_vista->imprimirVista('wikipost', 'blog'); |
52 | 52 | |
53 | 53 | |
54 | 54 | $this->_vista->titulo = 'Registro CalimaFramework'; |
55 | - if(isset($_GET['titulo'])){ |
|
55 | + if (isset($_GET['titulo'])) { |
|
56 | 56 | $this->_vista->salida_campo = $_GET['titulo']; |
57 | 57 | } |
58 | 58 | |
59 | 59 | $this->_vista->imprimirVista('wikipost', 'blog'); |
60 | 60 | //$datas = $this->cargaModelo('blog'); |
61 | - if (isset($_POST['enviar'])&& isset($_POST['option1']) ) { |
|
61 | + if (isset($_POST['enviar']) && isset($_POST['option1'])) { |
|
62 | 62 | |
63 | 63 | $datas->insertarDatos( |
64 | 64 | $this->_ayuda->filtrarEntero($_POST['id']), |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | $this->_ayuda->filtrarTexto($_POST['comentario']) |
68 | 68 | ); |
69 | 69 | echo $this->_ayuda->filtrarEntero('id'); |
70 | - $_POST['option1']=false; |
|
70 | + $_POST['option1'] = false; |
|
71 | 71 | |
72 | 72 | } |
73 | 73 | |
74 | 74 | } |
75 | 75 | |
76 | - public function insertarComentario(){ |
|
76 | + public function insertarComentario() { |
|
77 | 77 | |
78 | 78 | /*$this->_vista->titulo = 'Registro CalimaFramework'; |
79 | 79 | if(isset($_GET['titulo'])){ |
@@ -37,7 +37,7 @@ |
||
37 | 37 | |
38 | 38 | |
39 | 39 | |
40 | - if (isset($_POST['email'])) { |
|
40 | + if (isset($_POST['email'])) { |
|
41 | 41 | $para="[email protected]"; |
42 | 42 | $this->_ayuda->enviarCorreo( |
43 | 43 | $_POST['email'], |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | // cargamos la clase ayudantes para usar sus metodos de ayuda |
12 | 12 | |
13 | - $this->_ayuda= new Sistema\Ayudantes\CFPHPAyuda(); |
|
13 | + $this->_ayuda = new Sistema\Ayudantes\CFPHPAyuda(); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | public function index() |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | $this->_vista->imprimirVista('index', 'inicio'); |
20 | 20 | |
21 | 21 | if (isset($_POST['email'])) { |
22 | - $this->_vista->validar=1; |
|
23 | - $para="[email protected]"; |
|
22 | + $this->_vista->validar = 1; |
|
23 | + $para = "[email protected]"; |
|
24 | 24 | $this->_ayuda->enviarCorreo( |
25 | 25 | $_POST['email'], |
26 | 26 | $this->_ayuda->filtrarTexto($_POST['asunto']), |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | |
40 | 40 | if (isset($_POST['email'])) { |
41 | - $para="[email protected]"; |
|
41 | + $para = "[email protected]"; |
|
42 | 42 | $this->_ayuda->enviarCorreo( |
43 | 43 | $_POST['email'], |
44 | 44 | $this->_ayuda->filtrarTexto($_POST['asunto']), |