87 lines
3.4 KiB
PHP
87 lines
3.4 KiB
PHP
<?php
|
|
|
|
$imgPath = __DIR__ . '/../../../public/img';
|
|
|
|
if ('will' == $_GET['t']) {
|
|
$path = $imgPath . '/will/';
|
|
echo "<h2>Fotos auf der Seite Willkommen</h2>\n";
|
|
} elseif ('haus' == $_GET['t']) {
|
|
$path = $imgPath . '/haus/';
|
|
echo "<h2>Fotos auf der Seite Unser Haus</h2>\n";
|
|
} elseif ('lage' == $_GET['t']) {
|
|
$path = $imgPath . '/haus/lage/';
|
|
echo "<h2>Fotos auf der Seite Unser Haus - Lage</h2>\n";
|
|
} elseif ('geschichte' == $_GET['t']) {
|
|
$path = $imgPath . '/haus/geschichte/';
|
|
echo "<h2>Fotos auf der Seite Unser Haus - Geschichte</h2>\n";
|
|
} elseif ('gaby' == $_GET['t']) {
|
|
$path = $imgPath . '/gaby/';
|
|
echo "<h2>Fotos auf der Seite Wohnung Gaby</h2>\n";
|
|
} elseif ('amelie' == $_GET['t']) {
|
|
$path = $imgPath . '/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=\"" . str_replace(__DIR__ . '/../../../public', '', $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öscht</p>";
|
|
} else {
|
|
echo "<p>Fehler beim Löschen</p>";
|
|
}
|
|
echo "<a href=\"index.php?section=fotos&t=$_GET[t]\">Zurück zur Ü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ä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ück zur Übersicht</a>\n";
|
|
}
|
|
}
|