public function __construct() { if (isset($_GET['url'])) { #Obtener la URL solicitada $url = filter_input(INPUT_GET, 'url', FILTER_SANITIZE_URL); $url = explode('/', $url); $url = array_filter($url); #Convertir la URL a nombres de objetos del sistema $this->_controlador = strtolower(array_shift($url)); if ($this->_controlador == "ejecuta") { $url = str_replace(substr($_GET['url'], strpos($_GET['url'], "/ejecuta/") + 8), Framework::Decrypt(substr($_GET['url'], strpos($_GET['url'], "/ejecuta/") + 8)), $_GET['url']); $url = explode('/', $url); $url = array_filter($url); $this->_controlador = strtolower(array_shift($url)); $this->_metodo = strtolower(array_shift($url)); $this->_argumentos = $url; } else { $this->_metodo = strtolower(array_shift($url)); $this->_argumentos = $url; } } #Limpiar parametros recibidos $this->_argumentos = Framework::limpiarEntrada($this->_argumentos); $_POST = Framework::limpiarEntrada($_POST); $_GET = Framework::limpiarEntrada($_GET); #Inicializar los atributos no recibidos en la URL if (!$this->_controlador) { $this->_controlador = DEFAULT_CONTROLLER; } if (!$this->_metodo) { $this->_metodo = 'index'; } if (!$this->_argumentos) { $this->_argumentos = array(); } }
public static function limpiarEntrada($valor) { $_busquedas = array('@<script[^>]*?>.*?</script>@si', '@<[\\/\\!]*?[^<>]*?>@si', '@<style[^>]*?>.*?</style>@siU', '@<![\\s\\S]*?--[ \\t\\n\\r]*>@'); if (is_array($valor)) { foreach ($valor as $_key => $_value) { $valor[$_key] = Framework::limpiarEntrada($_value); #Recursivo para arreglos } } else { $valor = preg_replace($_busquedas, '', $valor); $valor = filter_var($valor, FILTER_SANITIZE_STRING); if (get_magic_quotes_gpc()) { $valor = stripslashes($valor); } } return $valor; }