public function getFotos() { $fotosUsuario = ENFoto::obtenerTodos($this->usuario); $fotosAlbum = array(); $contador = 0; foreach ($fotosUsuario as $i) { if ($i->getIdAlbum() == $this->id) { $fotosAlbum[$contador++] = $i; } } return $fotosAlbum; }
include_once "base.php"; baseSuperior("Resultados de la búsqueda"); ?> <div id="resultados"> <h3><span>Resultados de la búsqueda</span></h3> <div> <?php $titulo = $_GET["titulo"]; $dia = $_GET["dia"]; $mes = $_GET["mes"]; $ano = $_GET["ano"]; $fecha = checkdate($mes, $dia, $ano) ? "{$ano}-" . rellenar($mes, "0", 2) . "-" . rellenar($dia, "0", 2) . "" : ""; $segmento = $_GET["segmento"]; $antes = $segmento == "antes" ? true : false; $pais = $_GET["pais"]; $fotos = ENFoto::obtenerBusqueda($titulo, $fecha, $antes, $pais); ?> <p> Se han encontrado <?php echo count($fotos); ?> resultados que contienen la secuencia <em>"<?php echo $titulo; ?> "</em>. <?php // Calculamos la cadena según si se especificó el país. if ($pais != null) { if (is_numeric($pais)) { $pais = ENPais::obtenerPorId($pais); if ($pais != null) {
<?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();
<?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; }
header("location: anadirfoto.php?id={$id}&error=El país introducido no es válido."); exit; } else { if (!isset($_FILES["foto"])) { header("location: anadirfoto.php?id={$id}&error=No se ha introducido una imagen."); exit; } else { if ($_FILES["foto"]["tmp_name"] == "") { header("location: anadirfoto.php?id={$id}&error=No se ha introducido una imagen."); exit; } } } } } } } $nuevo = new ENFoto(); $nuevo->setTitulo($titulo); $nuevo->setDescripcion($descripcion); $nuevo->setFecha($fecha); $nuevo->setPais(ENPais::obtenerPorId($pais)->getNombre()); $nuevo->setIdAlbum($album->getId()); $nuevo->guardar(); if (!$nuevo->setFoto($_FILES["foto"])) { $nuevo->borrarFoto(); $nuevo->borrar(); header("location: anadirfoto.php?id=" . $album->getId() . "&error=No se pudo crear la foto porque tiene un formato incorrecto. Debe ser JPG."); exit; } header("location: album.php?id=" . $album->getId() . "&exito=Foto subida correctamente.");
// 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();