Esempio n. 1
0
 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);
     }
 }
Esempio n. 2
0
 public function procesa($errno, $errstr, $errfile, $errline)
 {
     if (!(error_reporting() & $errno)) {
         // Este código de error no está incluido en error_reporting
         return;
     }
     switch ($errno) {
         case E_USER_ERROR:
             $data = "[ERROR {$errno}]\n\rDesc::{$errstr}\n\rFile::{$errfile}\n\rLine::{$errline}\n\r";
             Sfphp_Log::set($data, "err");
             $data = str_replace("\n\r", "<br>", $data);
             $data = str_replace("[", "<b>[", $data);
             $data = str_replace("]", "]</b>", $data);
             self::fatal($data);
             break;
         case E_USER_WARNING:
             $data = "[WARNING {$errno}]\n\rDesc::{$errstr}\n\rFile::{$errfile}\n\rLine::{$errline}\n\r";
             Sfphp_Log::set($data, "err");
             break;
         case E_USER_NOTICE:
             $data = "[NOTICE {$errno}]\n\rDesc::{$errstr}\n\rFile::{$errfile}\n\rLine::{$errline}\n\r";
             Sfphp_Log::set($data, "err");
             break;
         default:
             $data = "[minor {$errno}]\n\rDesc::{$errstr}\n\rFile::{$errfile}\n\rLine::{$errline}\n\r";
             Sfphp_Log::set($data, "err");
             break;
     }
     $data = str_replace("\n\r", "<br>", $data);
     $data = str_replace("[", "<b>[", $data);
     $data = str_replace("]", "]</b>", $data);
     if (DEV_SHOWERRORS) {
         self::draw($data);
     }
     return true;
 }
Esempio n. 3
0
 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;
     }
 }