Merge branch 'marijn-settings' into 'master'

Max file size for gifs.

See merge request !105
This commit was merged in pull request #109.
This commit is contained in:
Marijn Jansen
2017-01-24 14:49:02 +01:00
2 changed files with 18 additions and 8 deletions

View File

@@ -186,12 +186,21 @@ function doChangeEmail($email) {
function updateAvatar() { function updateAvatar() {
$profilePictureDir = "/var/www/html/public/"; $profilePictureDir = "/var/www/html/public/";
$relativePath = "uploads/profilepictures/" . $_SESSION["userID"] . "_avatar.png"; $tmpImg = $_FILES["pp"]["tmp_name"];
checkAvatarSize($_FILES["pp"]["tmp_name"]); checkAvatarSize($tmpImg);
$scaledImg = scaleAvatar($_FILES["pp"]["tmp_name"]);
removeOldAvatar(); removeOldAvatar();
if (getimagesize($tmpImg)["mime"] == "image/gif") {
if ($_FILES["pp"]["size"] > 4000000) {
throw new AngryAlert("Bestand is te groot, maximaal 4MB toegestaan.");
}
$relativePath = "uploads/profilepictures/" . $_SESSION["userID"] . "_avatar.gif";
move_uploaded_file($tmpImg, $profilePictureDir . $relativePath);
} else {
$relativePath = "uploads/profilepictures/" . $_SESSION["userID"] . "_avatar.png";
$scaledImg = scaleAvatar($tmpImg);
imagepng($scaledImg, $profilePictureDir . $relativePath); imagepng($scaledImg, $profilePictureDir . $relativePath);
}
setAvatarToDatabase("../" . $relativePath); setAvatarToDatabase("../" . $relativePath);
throw new HappyAlert("Profielfoto veranderd."); throw new HappyAlert("Profielfoto veranderd.");
} }

View File

@@ -6,9 +6,9 @@ $settings = getSettings();
<div class="settings"> <div class="settings">
<?php <?php
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
echo "<div class='platform settings-message ". $alertClass ."'>". echo "<div class='platform settings-message $alertClass '>
$alertMessage . $alertMessage
"</div>"; </div>";
} }
?> ?>
<form class="settings-profile platform" method="post"> <form class="settings-profile platform" method="post">
@@ -81,7 +81,8 @@ $settings = getSettings();
<label>Selecteer foto</label> <label>Selecteer foto</label>
<input type="file" <input type="file"
name="pp" name="pp"
accept="image/jpeg,image/gif,image/png" accept="image/*"
size="4000000"
> >
</li> </li>
<li> <li>