<?php
session_start();
$pdo = new PDO('mysql:host=rdbms.strato.de;dbname=DB3116701', 'U3116701', 'FruchTzwerG5Tische');

$site = str_replace("/smartshipcloud/","",$_SERVER["PHP_SELF"]);
$site = str_replace("/","",$site);

if($_SESSION["smartshipcloud-login-id"]!=""){
	$sql = 'SELECT * FROM smartshipcloud_login WHERE id="'.$_SESSION["smartshipcloud-login-id"].'"';
	foreach ($pdo->query($sql) as $ausgabe) {
		foreach($ausgabe as $spalte => $wert){
			$ausgabelogin[$spalte] = $wert;
		}
	}
}
?>
<html>
<head>
<title>Smartshipcloud - Versand&uuml;berwachung</title>
<link rel="shortcut icon" href="data/logo-icon.png" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="animate.css" />

<link href="https://fonts.googleapis.com/css?family=Roboto+Slab" rel="stylesheet">

<style>
a{
	color:black;
	text-decoration:none;
}
a:hover{
	ZZcolor:#ffb500;
}
a.site{
	border-bottom:solid #ffb500 3px;
}
a.link{
	text-decoration:underline
}
a.link:hover{
	text-decoration:none;
}
body{
	background-color:#eeeeee;
	margin:0px;
	font-size:100%;
	font-family: 'Roboto Slab', serif;
	overflow-y:scroll;
}
input.button{
	background-color:#008369;
	color:white;
	border:solid white 1px;
	padding:2px;
}
div.content{
	text-align:center;
	background-color:#eeeeee;
}
div.header{
	ZZbackground-color:#351c15;
	background-image:url('data/logo.png');
	background-size:30%;
	background-repeat:no-repeat;
	background-position:10%;
	width:100%;
	height:15%;
}
div.headerGesamt{
	background-image:url('data/header.jpg');
	background-size:100% 100%;
}
div.headermenu{
	ZZbackground-color:#351c15;
	width:98%;
	min-height:30px;
	font-size:0.8em;
	text-align:right;
	padding-right:2%;
	color:black;
}
div.index-slideshow{
	float:left;
	width:500px;
	height:300px;
	margin:20px;
	margin-top:0px;
	margin-bottom:10px;
}
div.navigation{
	padding:1%;
	ZZbackground-color:#351c15;
	width:98%;
	max-height:5%;
	font-size:0.9em;
	text-align:center;
	font-weight:bold;
	font-family:arial;
}
@keyframes height{
	0%{height:0px;}
	100%{}
}

@media (orientation: portrait) {
	div.index-slideshow{
		width:100%;
	}
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	var textAreas = document.getElementsByTagName('textarea');

	Array.prototype.forEach.call(textAreas, function(elem) {
		elem.placeholder = elem.placeholder.replace(/\\n/g, '\n');
	});
});
function klappen(id){
	if(document.getElementById(id).hidden==true){
		document.getElementById(id).hidden = false;
	} else {
		document.getElementById(id).hidden = true;
	}
}
</script>
</head>
<body>
	<div class="headerGesamt">
		<div class="headermenu">
			<div class="animated fadeInDown" style="position:absolute;top:0px;right:10px;overflow-y:hidden;" <?php if($_SESSION["smartshipcloud-login-id"]!=""){echo'hidden';} ?>>
				<form method="post" action="<?php echo $site; ?>">
				<input type="hidden" name="func" value="login">
				<?php
					if($_POST[func]=="login"){
						$salt = '983je7usl923nslk890233jdiskdj9e';
						$passwort = sha1(md5($_POST["smartshipcloud-login-pw"]) . $salt . sha1($salt . $_POST["smartshipcloud-login-pw"]));
						$loginsuccess = "";
						$sql = 'SELECT * FROM smartshipcloud_login WHERE BINARY nutzername="'.htmlentities($_POST["smartshipcloud-login-nn"]).'" AND BINARY passwort = "'.$passwort.'" AND aktiviert = "1"';
						foreach ($pdo->query($sql) as $ausgabe) {
							$loginsuccess = "true";
							$_SESSION["smartshipcloud-login-id"] = $ausgabe[id];
							die('<meta http-equiv="refresh" content="0; url='.$site.'">');
						}
						if($loginsuccess!="true"){
							echo'<b style="color:red;">Fehler! Logindaten ung&uuml;ltig</b>';
						}
					}
				?>
				<input type="text" name="smartshipcloud-login-nn" style="border:none;" placeholder="Nutzername"><input type="password" name="smartshipcloud-login-pw" style="border:none;" placeholder="Passwort"><input type="submit" value=">" style="background-color:#008369;border:solid white 1px;">
				</form>
			</div>
			<div class="animated fadeInDown" style="" <?php if($_SESSION["smartshipcloud-login-id"]==""){echo'hidden';} ?>>
				Willkommen, <b><?php echo $ausgabelogin[vorname]; ?></b>
				<?php
				if($_GET[func]=="logout"){
					$_SESSION["smartshipcloud-login-id"]="";
					session_destroy();
					die('<meta http-equiv="refresh" content="0; url='.$site.'">');
				}
				if($ausgabelogin[admin]=="1"){
					echo'
						| <a class="link" href="admin_nutzer.php" style="color:#ffb500;">Kundendaten</a>
					';
				}
				?>
				| <a class="link" href="login_konto.php"><b><?php echo $ausgabelogin[nutzername]; ?></b></a>
				| <a class="link" href="login_tn.php">Trackingnummern</a>
				<input type="button" class="button" value="ausloggen" style="font-weight:bold;" onclick="window.location.href='?func=logout'">
			</div>
		</div>
		<div class="header">
			
		</div>
		<div class="navigation">
			<a <?php if($site=="index.php"){echo'class="site"';} ?> href="index.php" style="margin:8px;">&Uuml;ber Uns</a>
			<a <?php if($site=="track.php"){echo'class="site"';} ?> href="track.php" style="margin:8px;">Sendungsverfolgung</a>
			<a <?php if($site=="kontakt.php"){echo'class="site"';} ?> href="kontakt.php" style="margin:8px;">Partner werden</a>
			<?php
				if($_SESSION["smartshipcloud-login-id"]!=""){
					echo'<a '; if($site=="login_service.php"){echo'class="site"';} echo'style="color:#ffb500;" href="login_service.php" style="margin:8px;">Service</a>';
				}
			?>
			<a <?php if($site=="impressum.php"){echo'class="site"';} ?> href="impressum.php" style="margin:8px;">Impressum</a>
		</div>
	</div>
	<div class="content">