110 lines
4.1 KiB
PHP
110 lines
4.1 KiB
PHP
<?php
|
|
|
|
$path = "../img/objekte/";
|
|
$tmp_path = "../img/temp/";
|
|
$ref = "index.php?section=objekte&t=fotos&o=".$_GET['o'];
|
|
if ( !isset ( $_SESSION['ID'] ) )
|
|
{
|
|
}
|
|
else
|
|
{
|
|
echo "<h1>Bildergalerie zu Objekt-Nummer ".$_GET['o']."</h1>\n";
|
|
if ( isset ( $_POST['Speichern'] ) AND 'Speichern' == $_POST['Speichern'] )
|
|
{
|
|
$uploadfile = $path. $_FILES['Foto']['name'];
|
|
move_uploaded_file ( $_FILES['Foto']['tmp_name'], $uploadfile );
|
|
$src = imagecreatefromjpeg ( $uploadfile );
|
|
list( $width, $height ) = getimagesize ( $uploadfile );
|
|
if ( $height > $width )
|
|
{
|
|
$newheight = 480;
|
|
$newwidth = ( $width / $height ) * 480;
|
|
}
|
|
else
|
|
{
|
|
$newwidth = 480;
|
|
$newheight = ( $height / $width ) * 480;
|
|
}
|
|
$tmp = imagecreatetruecolor ( $newwidth, $newheight );
|
|
imagecopyresampled ( $tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height );
|
|
$filename = $path . $_GET['o'] . "_" . $_POST['pic'] . ".jpg";
|
|
imagejpeg ( $tmp, $filename, 80);
|
|
imagedestroy ( $src );
|
|
imagedestroy ( $tmp );
|
|
unlink ( $path. $_FILES['Foto']['name'] );
|
|
echo "<h2 class=\"hinweis\">Das Bild wurde hochgeladen und gespeichert!</h2>\n";
|
|
}
|
|
if ( !isset ( $_GET['action'] ) OR "add" != $_GET['action'])
|
|
{
|
|
if ( isset ( $_GET['action'] ) AND 'del' == $_GET['action'])
|
|
{
|
|
$delfile = $path . $_GET['o'] . "_" . $_GET['pic'] . ".jpg";
|
|
if (unlink($delfile))
|
|
{
|
|
echo "<h2 class=\"hinweis\">Bild wurde gelöscht!</h2>";
|
|
}
|
|
else
|
|
{
|
|
echo "<h2 class=\"hinweis\">Fehler beim Löschen des Bildes!</h2>";
|
|
}
|
|
}
|
|
echo "<h2 class=\"hinweis\">Achtung: Beim Löschen gibt es keine weitere Abfrage mehr!</h2>\n";
|
|
echo "<p>Auf das rote X klicken um ein Bild zu löschen.<br />";
|
|
echo "Auf einen Platzhalter klicken um ein neues Bild hochzuladen.</p>\n";
|
|
echo "<ul id=\"sortable\">\n";
|
|
for ($i=1; $i<11; $i++)
|
|
{
|
|
echo " <li id=\"element_" . $i . "\" class=\"ui-state-default\">\n";
|
|
$pic = $path.$_GET['o']."_".$i.".jpg";
|
|
if (file_exists($pic))
|
|
{
|
|
$link = $ref."&action=del&pic=".$i;
|
|
echo "<img style=\"margin:0px;border:1px solid gray;float:left;\" src=\"$pic?ts=" . date ( 'YmdHis' ) . "\" width=\"100px\" height=\"100px\"/>";
|
|
echo "<a href=\"$link\">";
|
|
echo "<img width=\"20\" height=\"20\" style=\"margin: 0px;border: 2px solid red;\" src=\"../img/no.jpg\" />";
|
|
echo "</a>\n";
|
|
}
|
|
else
|
|
{
|
|
$link = $ref."&action=add&pic=".$i;
|
|
echo "<a href=\"$link\">";
|
|
echo "<img style=\"margin:0px; border:1px solid gray;\" src=\"../img/no_img.gif\" />";
|
|
echo "</a>\n";
|
|
}
|
|
echo " </li>\n";
|
|
}
|
|
echo "</ul>\n";
|
|
?>
|
|
<script>
|
|
$(function() {
|
|
$("#sortable").sortable({
|
|
update: function() {
|
|
var test = $("#sortable").sortable("serialize", { attribute: 'id' } );
|
|
document.FBesch.sorting.value = test;
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
<?php
|
|
echo "<br style=\"clear:both;\"/>";
|
|
echo "<form name=\"FBesch\" action=\"index.php?section=objekte&t=FBesch\" method=\"post\" >\n";
|
|
echo " <input type=\"hidden\" name=\"OBJ\" value=\"".$_GET['o']."\" />\n";
|
|
echo " <input type=\"hidden\" name=\"sorting\" value=\"\" />\n";
|
|
echo " <input class=\"lang\" type=\"submit\" name=\"FBesch\" value=\"Weiter zu den Bild-Beschreibungen\" />\n";
|
|
echo "</form>\n";
|
|
}
|
|
elseif ('add' == $_GET['action']) {
|
|
$timestamp = time();
|
|
$timestamp .= rand();
|
|
echo "<form action=\"".$ref."\" method=\"post\" enctype=\"multipart/form-data\">\n";
|
|
echo " <label>Foto auswählen</label>\n";
|
|
echo " <input type=\"file\" name=\"Foto\" />\n";
|
|
echo " <input type=\"hidden\" name=\"egal\" value=\"".$timestamp."\" />\n";
|
|
echo " <input type=\"hidden\" name=\"pic\" value=\"".$_GET['pic']."\" />\n";
|
|
echo " <img src=\"../img/help.gif\" title=\"Es kann immer nur ein Bild ausgewählt werden!\" />\n";
|
|
echo " <br />\n";
|
|
echo " <input type=\"submit\" name=\"Speichern\" value=\"Speichern\" />\n";
|
|
echo "</form>\n";
|
|
}
|
|
}
|
|
?>
|