<?
?>
<link rel="stylesheet" type="text/css" href="../css/menu.css" />
<?php
include ("config.php");
include ("functions.php");
$select = mysql_query ("SELECT * FROM `wnp_nickname` where nickname='".$_SESSION['nickname']."'");
CheckLogin();
//Instellingen
$forms = 1; //Standaard aantal file uploads
$user = TRUE; //User kan aangeven dat hij meer files wil uploaden
$max_size = 0; //Maximale bestands grootte, 0 voor ongelimiteerd
$max_thumb = 50; //Maximale hoogte dan wel breedte van de thumb.
$ext = "jpg jpeg gif png"; // Welke extensies kunnen er worden geupload ( als alles mag dan niks invullen )
//Script
// Toegestaande extensies opvragen
if($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['submit'])){ $aantal=count($_FILES['image']['type']); $i=0;
for($i=0;$i<$aantal;$i++){
if(!empty($_FILES['image']['tmp_name'][$i])){ $type= $_FILES['image']['type'][$i];
// Bestands naam opvragen
$bestand2 = explode("\\", $_FILES['image']['name'][$i]); $laatste = count($bestand2) - 1;
$bestand2 = "$bestand2[$laatste]";
// Extensie van bestand opvragen
$bestand3 = explode(".", $bestand2);
$laatste = count($bestand3) - 1;
$bestand3 = "$bestand3[$laatste]";
$bestand3 = strtolower($bestand3);
for ($tel = 0;$tel < $aantal; $tel++){
if ($bestand3 == $ext[$tel]){
$extfout = "nee";
}
}
if($type == "image/gif" OR $type == "image/pjpeg" OR $type == "image/x-png" OR $type == "image/jpeg"){
if(!empty($max_size) && $_FILES['image']['size'][$i] > $max_size){
echo"Bestand is te groot: ".$_FILES['image']['size'][$i]." / ".$max_size."<br>\n";
}elseif(!isset($extfout)){
}else{
if(move_uploaded_file($_FILES['image']['tmp_name'][$i], "./img/".$foto_name.".".$bestand3)){
echo $foto_name.".".$bestand3." is succesvol geupload.<br \>\n<img src=\"./img/".$foto_name.".".$bestand3."\" \><br \>\n";
if($type == "image/gif"){
$photo = imagecreatefromgif("./img/".$foto_name.".".$bestand3);
}elseif($type == "image/pjpeg" OR $type == "image/jpeg"){
$photo = imagecreatefromjpeg ("./img/".$foto_name.".".$bestand3);
}elseif($type == "image/x-png"){
$photo = imagecreatefrompng("./img/".$foto_name.".".$bestand3);
}
$photo_dimensions_width = imagesx ($photo);
$photo_dimensions_height = imagesy ($photo);
if ($photo_dimensions_width > $max_thumb OR $photo_dimensoons_height > $max_thumb) {
if ($photo_dimensions_width == $photo_dimensions_height) {
$thumb_dimensions_width = $max_thumb;
$thumb_dimensions_height = $max_thumb;
}
elseif ($photo_dimensions_width > $photo_dimensions_height) {
$value = $photo_dimensions_width / $max_thumb;
$thumb_dimensions_width = $max_thumb;
$thumb_dimensions_height = round ($photo_dimensions_height / $value); }
else {
$value = $photo_dimensions_height / $max_thumb;
$thumb_dimensions_height = $max_thumb;
$thumb_dimensions_width = round ($photo_dimensions_width / $value); }
}
else {
$thumb_dimensions_width = $photo_dimensions_width;
$thumb_dimensions_height = $photo_dimensions_height;
}
$create_thumb = imagecreatetruecolor ($thumb_dimensions_width, $thumb_dimensions_height);
imagecopyresampled ($create_thumb, $photo, 0, 0, 0, 0, $thumb_dimensions_width, $thumb_dimensions_height, $photo_dimensions_width, $photo_dimensions_height);
ImageJpeg($create_thumb,'./img/thumb/'.$foto_name.".jpg",90);
Imagedestroy($photo);
echo"Thumb, ./img/thumb/".$foto_name.".jpg, is gemaakt.<br>\n<img src=\"./img/thumb/".$foto_name.".jpg\" \><br \>\n"; }else{
echo $_FILES['image']['name'][$i]." kon niet geupload worden.<br \>\n"; }
}
}else{
echo "Ongeldig type: ".$type."<br>\n"; }
}else{
echo "Geen file geselecteerd.<br>\n"; }
}
}
?>
<?
$insert = mysql_query ("UPDATE `WNP_nickname` SET `avatar` = '$avatar', `ex_avatar` = '$ex_avatar' WHERE `nickname` = '".$_SESSION['nickname']."'") or
die (mysql_error());
if(!isset($_POST['avatar'])) {
?>
<? echo "<table><tr><td bgcolor=\"993300\" width=\"478\" align=\"center\"><font color=\"ffffff\">Jouw foto:</font></td></tr><tr><td valign=top width=100% align=\"center\" bgcolor=\"ffffff\"><img src='avatar/".$data['avatar']."' align=\"center\"></td></tr></table>"; ?> <table cellpading='0' cellspacing='0' width='478'>
<tr><td bgcolor="993300" width="490"><font color="ffffff">Bewerken:</font>
</td><td bgcolor="993300">
</td></tr>
<input type="hidden" name="<? $id ?>" VALUE="Image">
<tr>
<form enctype="multipart/form-data" method="post" action="edit_avatar.php">
<td width="150">Avatar <br><u>Alleen .gif, .jpeg of .png!</u>
</td>
<td width="150">
<input type="file" name="image">
</td>
<tr>
<td width="60">Externe avatar
</td>
<td width="150">
<input name="ex_avatar" type="text">
</td>
</tr>
<tr>
<td>
<input name="avatar" type="submit" value="Toevoegen">
</td>
</tr>
</p>
</form>
</body>
</html>
<?
}
?>