Files
homepage/admin/inhalte/fotos/10er.php

85 lines
3.3 KiB
PHP
Raw Blame History

<?php
if ('will' == $_GET['t']) {
$path = "../img/will/";
echo "<h2>Fotos auf der Seite Willkommen</h2>\n";
} elseif ('haus' == $_GET['t']) {
$path = "../img/haus/";
echo "<h2>Fotos auf der Seite Unser Haus</h2>\n";
} elseif ('lage' == $_GET['t']) {
$path = "../img/haus/lage/";
echo "<h2>Fotos auf der Seite Unser Haus - Lage</h2>\n";
} elseif ('geschichte' == $_GET['t']) {
$path = "../img/haus/geschichte/";
echo "<h2>Fotos auf der Seite Unser Haus - Geschichte</h2>\n";
} elseif ('gaby' == $_GET['t']) {
$path = "../img/gaby/";
echo "<h2>Fotos auf der Seite Wohnung Gaby</h2>\n";
} elseif ('amelie' == $_GET['t']) {
$path = "../img/amelie/";
echo "<h2>Fotos auf der Seite Wohnung Amelie</h2>\n";
} else {
die();
}
$ref = "index.php?section=fotos&t=" . $_GET['t'];
if (!isset($_GET['action'])) {
echo "<p>Auf ein vorhandenes Bild klicken um es zu l<>schen<br />";
echo "Auf einen Platzhalter klicken um ein neues Bild hochzuladen</p>";
for ($i = 0; $i < 10; $i++) {
$pic = $path . $i . ".jpg";
if (file_exists($pic)) {
$link = $ref . "&action=del&pic=" . $i;
echo "<a href=\"$link\">";
echo "<img style=\"margin: 20px 20px 20px 20px; border: 2px solid red;\" src=\"$pic\" width=\"100px\" height=\"100px\"/>";
} else {
$link = $ref . "&action=add&pic=" . $i;
echo "<a href=\"$link\">";
echo "<img style=\"margin: 20px 20px 20px 20px; border: 2px solid red;\" src=\"../img/no.jpg\" />";
}
echo "</a>\n";
}
} else {
if ('del' == $_GET['action']) {
$delfile = $path . $_GET['pic'] . ".jpg";
if (unlink($delfile)) {
echo "<p>Bild gel<65>scht</p>";
} else {
echo "<p>Fehler beim L<>schen</p>";
}
echo "<a href=\"index.php?section=fotos&t=$_GET[t]\">Zur<75>ck zur <20>bersicht</a>\n";
} elseif ('add' == $_GET['action']) {
$ref .= "&action=speichern&pic=" . $_GET['pic']
?>
<form action="<?php echo $ref; ?>" method="post" enctype="multipart/form-data">
<label>Foto ausw&auml;hlen</label>
<input type="file" name="Foto"/>
<br/>
<input type="submit" name="Speichern" value="Speichern"/>
</form>
<?php
} elseif ('speichern' == $_GET['action']) {
$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['pic'] . ".jpg";
imagejpeg($tmp, $filename, 80);
imagedestroy($src);
imagedestroy($tmp);
unlink($path . $_FILES['Foto']['name']);
echo "<p>Bild hochgeladen</p>";
echo "<a href=\"index.php?section=fotos&t=" . $_GET['t'] . "\">Zur<75>ck zur <20>bersicht</a>\n";
}
}