Exemplo n.º 1
0
<?php

require_once 'minilibreria.php';
$id = $_POST["id"];
$usuario = unserialize($_SESSION["usuario"]);
$foto = is_numeric($id) ? ENFoto::obtenerPorId($id) : null;
if ($usuario != null && $foto != null) {
    if ($usuario->getNombre() == $foto->getUsuario()) {
        $album = $foto->getIdAlbum();
        $foto->borrarFoto();
        $foto->borrar();
        if ($_POST["ajax"] == "no") {
            header("location: album.php?id={$album}&exito=La foto ha sido eliminada correctamente.");
            exit;
        } else {
            echo "OK";
            exit;
        }
    }
}
if ($_POST["ajax"] == "no") {
    header("location: index.php?exito=No se ha podido eliminar la foto.");
    exit;
} else {
    echo "ERROR";
    exit;
}
Exemplo n.º 2
0
<?php

include_once "base.php";
$id = is_numeric($_GET["id"]) ? $_GET["id"] : -1;
$foto = ENFoto::obtenerPorId($id);
if ($foto == null) {
    header("location: index.php?error=La foto no existe.");
    exit;
}
$album = ENAlbum::obtenerPorId($foto->getIdAlbum());
$usuario = ENUsuario::obtenerPorNombre($foto->getUsuario());
$propio = false;
if (isset($_SESSION["usuario"])) {
    if (unserialize($_SESSION["usuario"])->getNombre() == $usuario->getNombre()) {
        $propio = true;
    }
}
baseSuperior("Foto #" . $foto->getId());
?>
					<div id="foto">
						<h3><span>Foto: <?php 
echo $foto->getTitulo();
?>
</span></h3>
						<table>
							<tr>
								<td colspan="2"><a href="fotos/<?php 
echo $foto->getId();
?>
.jpg"><img src="fotos/m5<?php 
echo $foto->getId();
Exemplo n.º 3
0
// Calculamos una foto aleatoria para mostrarla.
$foto = null;
// Leemos el fichero y guardamos los identificadores en un vector.
$id_fotos = array();
$fichero = fopen("seleccionadas.txt", "r");
while (!feof($fichero)) {
    $leido = trim(fgets($fichero, 4096));
    if (is_numeric($leido)) {
        $id_fotos[] = $leido;
    }
}
fclose($fichero);
// Elegimos al azar uno de los identificadores.
$id_foto = $id_fotos[rand(0, count($id_fotos) - 1)];
// Obtenemos la foto y la mostramos si realmente existe la foto con ese identificador.
$foto = ENFoto::obtenerPorId($id_foto);
if ($foto != null) {
    ?>
							<h3><span>Foto aleatoria seleccionada por el administrador</span></h3>
							<div class="foto">
								<div class="imagen"><a href="fotos/<?php 
    echo $foto->getId();
    ?>
.jpg"><img src="fotos/m1<?php 
    echo $foto->getId();
    ?>
.jpg" alt="<?php 
    echo $foto->getTitulo();
    ?>
" title="<?php 
    echo $foto->getTitulo();