public function __construct() { # Limpiar cache expirada Sfphp_Cache::expirate(); # Aplicar la sesión Sfphp_Sesion::get(); $peticion = Sfphp_Peticion::get(); $clase = NULL; if (!is_null($peticion['_modulo'])) { $clase = ucwords($peticion['_modulo']) . "_"; } $clase .= "Controladores_" . ucwords($peticion['_control']); try { $objSeguridad = new Seguridad(); if ($objSeguridad->validarAcceso(ucwords($peticion['_control']))) { $objClase = new $clase(); if (is_callable(array($objClase, $peticion['_accion']))) { call_user_func(array($objClase, $peticion['_accion'])); } else { header("Location: " . BASE_URL . "Etc/Errors/process.php?code=401"); die; } } else { trigger_error("La accion {$peticion['_accion']} no esta definida en {$clase}", E_USER_ERROR); } } catch (Sfphp_Error $e) { Sfphp_Log::error($e); } }
public function query($consulta, $valores = array(), $cache = TRUE) { $resultado = FALSE; $query = $consulta; $cache = APP_CACHE; if (APP_CACHE) { if (strstr(strtoupper(trim($query)), "__SESIONES")) { $cache = FALSE; } } if ($statement = self::$conexion->prepare($consulta)) { if (preg_match_all("/(:\\w+)/", $consulta, $campo, PREG_PATTERN_ORDER)) { $campo = array_pop($campo); foreach ($campo as $parametro) { $statement->bindValue($parametro, $valores[substr($parametro, 1)]); $query = str_replace($parametro, $valores[substr($parametro, 1)], $query); } } if ($cache) { $cached = Sfphp_Cache::get("data_" . md5($query)); if ($cached) { return $cached; } } try { if (!$statement->execute()) { throw new PDOException("[SQLSTATE] " . $statement->errorInfo()[2], $statement->errorInfo()[1]); } $resultado = $statement->fetchAll(PDO::FETCH_ASSOC); $statement->closeCursor(); } catch (PDOException $e) { trigger_error($e->getMessage(), E_USER_ERROR); } if ($cache) { Sfphp_Cache::set("data_" . md5($query), $resultado); } if (DEV_QUERYLOG) { Sfphp_Log::query($query); } return $resultado; } }
?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Sfphp</title> <!-- Bootstrap Table --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <link rel="shortcut icon" href="{BASE_URL}favicon.ico"> </head> <body> <div class="panel panel-primary"> <div class="panel-heading"> <?php echo "<h2>Eliminando cache...</h2>"; Sfphp_Cache::clear(); ?> </div> <?php echo "<h3>...terminado!</h3>"; ?> </div> <nav> <ul class="pager"> <li class="previous"><a href="javascript:window.history.back()"><span aria-hidden="true">←</span> Regresar</a></li> </ul> </nav> </body> </html>