Example #1
0
 public function __construct()
 {
     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 {
                 throw new Sfphp_Error("La accion {$peticion['_accion']} no esta definida en {$clase}", 1);
             }
         } else {
             throw new Sfphp_Error("No tienes privilegios para acceder a {$clase}::{$peticion['_accion']}", 1);
         }
     } catch (Sfphp_Error $e) {
         Sfphp_Logs::procesa($e);
     }
 }
Example #2
0
File: Logs.php Project: sincco/devs
 public static function procesa($e)
 {
     if (DEV_LOG) {
         Sfphp_Logs::escribe($e);
     }
     #Escribir el log de errores
     if (DEV_SHOWERRORS) {
         if (stripos($e->getMessage(), "SQLSTATE") > -1) {
             Sfphp_Logs::pantallaBD($e);
         } else {
             Sfphp_Logs::pantalla($e);
         }
     } else {
         header('HTTP/1.1 500 Internal Server Error');
         echo "Error interno pide al administrador que revise el log " . str_replace("./Etc/Logs/", "", DEV_LOGFILE);
     }
 }
Example #3
0
 public function insert($consulta, $valores = array())
 {
     $resultado = false;
     if ($statement = self::$default->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)]);
             }
         }
         try {
             if (!$statement->execute()) {
                 throw new PDOException("[SQLSTATE] " . $statement->errorInfo()[2], $statement->errorInfo()[1]);
             }
             $resultado = self::$default->lastInsertId();
         } catch (PDOException $e) {
             Sfphp_Logs::procesa($e);
             return false;
         }
         return $resultado;
     }
 }