<?php
require("mysql.php");
require_once 'filter.php';

if(!$_SESSION[foto]) {
	header("location:photo.php?login");
}else{
if($_GET[msgid] == 'ERRORONLYJPG') {
	$inhalt .= '<div class="servermessage">Es sind nur JPG Files zum Upload erlaubt.</div>';
}

$inhalt .= '<div class="photo"><div class="noh1"></div><div class="box small"><div class="hd"><div class="tl"></div><div class="tr"></div><div class="tm"></div><div class="m"><div class="mi"><div class="h h3"><div class="hbegin"></div><h3>Profilfoto komfortabel hochladen</h3></div></div></div></div><div class="bd fade bd-fade"><div class="m"><div class="mi">';

if ($_POST[upload] != '') {
	if (!empty($_FILES['photo']['name'])) {
		$time = md5(time());
		$zahl = rand(0,100);
		$size = @getimagesize($_FILES['photo']['tmp_name']);
		$ex = strtolower(end(explode('.', $_FILES['photo']['name'])));
		$newfile = $time.$zahl.'.'.$ex;

		if (!in_array($_FILES['photo']['type'], array('image/jpg', 'image/jpeg', 'image/pjpeg'))) {
			header("location:photos-upload.php?msgid=ERRORONLYJPG");
		} else {
			resize($_FILES['photo']['tmp_name'], 'pics/photos/l/' .  $newfile, 280, 280, false);
			resize($_FILES['photo']['tmp_name'], 'pics/photos/m/' .  $newfile, 100, 100, false);
			resize($_FILES['photo']['tmp_name'], 'pics/photos/s/' .  $newfile, 100, 100, false);

			if($low[photo] != '') {
				unlink("pics/photos/l/$low[photo].jpg");
				unlink("pics/photos/m/$low[photo].jpg");
				unlink("pics/photos/s/$low[photo].jpg");
			}

			$datum = date("d.m.Y", time());
			mysql_query("update accounts set priviMessage='1',photo='".$time.$zahl."', photoUpload='".$datum."' where name = '".$_SESSION[foto]."'");

			if($low[photoNew] == 0 && $low[photo] != '') {
				mysql_query("update accounts set photoNew = '1' where name = '".$_SESSION[foto]."'");
			}

			header("location:photos-profile.php?id=$_SESSION[foto]");
		}
	}
}





$inhalt .= '<div class="uploader">
<div>
<div class="h h3"><div class="hbegin"></div><h3>Fotoupload</h3></div>
<ul class="bullet">

<li>Wähle eine Datei zum Upload.</li>

<li><strong>Bist du fertig, klicke auf "Hochladen"</strong></li>
</ul>
Es gibt keine Fortschrittsanzeige. Habe daher viel Geduld. Der Upload kann je nach Größe der Bilder <strong>sehr lange dauern</strong>.
<form action="photos-upload.php" method="POST" accept-charset="UTF-8"
enctype="multipart/form-data"
id="form-alternate"
name="form-alternate">
<ol id="alternate_file_list">

<li>
<span id="formline-alternate-file0" class="formline formline-plain formline-alternate-file0 formres-no formres-noresult-alternate-file0 ">
<input type="file" class="file type-String"
name="photo" id="alternate-file0"
accept="*/*" /><div class="formerror hidden" id="err-alternate-file0">
$inhalt .= $meldung;

</div>

</span>
</li>

</ol>
<div class="buttons">
<div class="bbutton submit" id="submit-button-alternate-nojava"><div class="bttl corner"></div><div class="bttr corner"></div><div class="bttm"></div><div class="btm"><img src="/sf/m/buttons/bt-nm.png" id="submit-button-alternate-nojava-img" class="jsFixHeight" style="" height="22" width="" /><input type="submit" name="upload" class="image-submit" /><div class="btmi"><span class="text">Hochladen</span></div></div><div class="btbl corner"></div><div class="btbr corner"></div><div class="btbm"></div></div>
<div class="bbutton"><a href="photo?n='.$_SESSION[foto].'"><div class="bttl corner"></div><div class="bttr corner"></div><div class="bttm"></div><div class="btm"><img src="/sf/m/buttons/bt-nm.png" id="button-870873937-img" class="jsFixHeight" style="" height="22" width="" /><div class="btmi"><span class="text">Abbrechen</span></div></div><div class="btbl corner"></div><div class="btbr corner"></div><div class="btbm"></div></a></div>
<div class="clear"></div></div></div></div>
</div></div>';
}

$inhalt .= '<div class="bl"></div><div class="br"></div><div class="bm"></div></div></div></div></div>';

$styles = '<link href="/sf/f/registration/registration.css" rel="stylesheet" type="text/css">
<link href="/sf/m/buttons/buttons.css" rel="stylesheet" type="text/css"><link href="/sf/f/index/index.css" rel="stylesheet" type="text/css"><link href="/sf/m/boxes/boxes.css" rel="stylesheet" type="text/css"><link href="/sf/f/photos/photos.css" rel="stylesheet" type="text/css"><link href="/sf/m/forms/forms.css" rel="stylesheet" type="text/css"><link href="/sf/m/tables/tables.css" rel="stylesheet" type="text/css"><link href="/sf/m/uploader/uploader.css" rel="stylesheet" type="text/css">';

echo str_replace(array('<?url?>','<?inhalt?>', '<?titel?>', '<?fotonavi?>', '<?registrieren?>', '<?styles?>', '<?fotos?>'),array($_SERVER[SERVER_NAME], $inhalt, "Profilfoto komfortabel hochladen - Fotos", $fotonavi, $registrieren, $styles, $fotos),implode("",file("sf/b/style.tpl")));
?>  