<h1>Logoverwaltung</h1>
<p>
	Hier können Sie Ihr Firmenlogo ändern!
</p>

<?php

	if ("Hochladen" == $_POST['Send']) {
		$uploaddir = '../img/';
		if ('' != $_FILES[Bild][name]) {
			$uploadfile = $uploaddir. $_FILES['Bild']['name'];
			move_uploaded_file($_FILES['Bild']['tmp_name'], $uploadfile);
			$src = imagecreatefromjpeg($uploadfile);
			list($width,$height)=getimagesize($uploadfile);
			$aspect = $width/$height;
			if ($aspect < 2.3) {
				$newheight=100;
				$newwidth=($width/$height)*100;
			}
			else {
				$newwidth=230;
				$newheight=($height/$width)*230;
			}
			$tmp=imagecreatetruecolor($newwidth,$newheight);
			imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
			$filename = $uploaddir. "h_logo.jpg";
			imagejpeg($tmp,$filename,80);
			imagedestroy($src);
			imagedestroy($tmp);
			unlink($uploaddir. $_FILES['Bild']['name']);
		}
	}
	elseif ("Entfernen" == $_POST['Send']) {
		$file = "../img/h_logo.jpg";
		unlink($file);
	}

	if (file_exists("../img/h_logo.jpg")) {
		echo "<img src=\"../img/h_logo.jpg\" />\n";
	}
	else {
		echo "<p>Es wurde noch kein Firmenlogo hochgeladen!</p>\n";
	}
	
	
	echo "<form action=\"index.php?section=Stammdaten&t=lv\" method=\"post\" enctype=\"multipart/form-data\">\n";
	if (file_exists("../img/h_logo.jpg")) {
		echo "    <input type=\"submit\" name=\"Send\" value=\"Entfernen\" /><br />\n";
	}
	else {
		echo "    <label>Bild ausw&auml;hlen</label><br />\n";
		echo "    <input type=\"file\" name=\"Bild\" /><br />\n";
		echo "    <input type=\"submit\" name=\"Send\" value=\"Hochladen\" /><br />\n";
	}
	echo "</form>\n";

?>