Пример #1
0
    <head>
        <title>Videoclub</title>
        <meta charset="utf-8" />
    </head>
    <body><?php 
require '../comunes/auxiliar.php';
require 'auxiliar.php';
conectar();
comprobar_usuario_conectado();
$numero = $_SESSION['socio_numero'];
$codigo = isset($_GET['codigo']) ? trim($_GET['codigo']) : "";
if (isset($_POST['socio_id'], $_POST['copia_id'])) {
    try {
        $socio_id = trim($_POST['socio_id']);
        $copia_id = trim($_POST['copia_id']);
        alquilar($socio_id, $copia_id);
        $res = pg_query_params("select precio_alq\n                                          from v_copias\n                                         where id = \$1", array($copia_id));
        $fila = pg_fetch_assoc($res, 0);
        $precio_alq = (double) $fila['precio_alq'];
        $cookie = isset($_COOKIE['subtotal']) ? trim($_COOKIE['subtotal']) : 0.0;
        $cookie += $precio_alq;
        setcookie('subtotal', "{$cookie}");
    } catch (Exception $e) {
        ?>
                <h3>Error: <?php 
        echo $e->getMessage();
        ?>
</h3><?php 
    }
} elseif (isset($_POST['alquiler_id'])) {
    $alquiler_id = trim($_POST['alquiler_id']);
try {
    //         HttpSession sesion = request.getSession();
    //         UsuarioLogica
    //$ul = (UsuarioLogica) sesion.getAttribute("usuario");
    //verificar que pueda alquilar o redirigir
    //         String
    $id = (string) request . getParameter("id");
    //         int
    $id_contenido = intval($id);
    $cont = ContenidoLogica::Buscar($id_contenido);
    if (is_null($cont)) {
        // contenido no encontrado
        throw new \Exception();
    }
    try {
        $ul . alquilar($cont);
    } catch (\Exception $ex) {
        //no puedo alquilar por falta de alquileres
        $puede_alquilar = false;
        if (is_null($ul)) {
            $logueado = false;
        }
    }
} catch (\Exception $e) {
    header("Location: http://localhost/ECinemaFinal/Pages/index.php");
    exit;
}
?>
<!DOCTYPE html>
<html>
    <head>