Alpha 0.0.1 profile picture upload shizzle!
This commit is contained in:
@@ -22,12 +22,13 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$result = updateSettings();
|
||||
break;
|
||||
case "password":
|
||||
$result = updatePassword();
|
||||
$result = changePassword();
|
||||
break;
|
||||
case "email":
|
||||
$result = changeEmail();
|
||||
break;
|
||||
case "picture":
|
||||
updateProfilePicture();
|
||||
$result = $notImplemented;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -99,11 +99,11 @@ function updateSettings() {
|
||||
return new settingsMessage("happy", "Instellingen zijn opgeslagen.");
|
||||
}
|
||||
|
||||
function updatePassword() {
|
||||
function changePassword() {
|
||||
$user = getPasswordHash();
|
||||
if (password_verify($_POST["password-old"], $user["password"])) {
|
||||
if ($_POST["password-new"] == $_POST["password-confirm"] && (strlen($_POST["password-new"]) >= 8)) {
|
||||
if (changePassword()) {
|
||||
if (doChangePassword()) {
|
||||
return new settingsMessage("happy", "Wachtwoord gewijzigd.");
|
||||
} else {
|
||||
return new settingsMessage("angry", "Er is iets mis gegaan.");
|
||||
@@ -116,7 +116,7 @@ function updatePassword() {
|
||||
}
|
||||
}
|
||||
|
||||
function changePassword() {
|
||||
function doChangePassword() {
|
||||
$stmt = $GLOBALS["db"]->prepare("
|
||||
UPDATE
|
||||
`user`
|
||||
@@ -184,4 +184,26 @@ function doChangeEmail($email) {
|
||||
$stmt->bindParam(":userID", $_SESSION["userID"]);
|
||||
$stmt->execute();
|
||||
return $stmt->rowCount();
|
||||
}
|
||||
|
||||
function updateProfilePicture() {
|
||||
$profilePictureDir = "/var/www/html/public/";
|
||||
$relativePath = "uploads/" . $_SESSION["userID"] . "_" . basename($_FILES["pp"]["name"]);
|
||||
move_uploaded_file($_FILES['pp']['tmp_name'], $profilePictureDir . $relativePath);
|
||||
setProfilePictureToDatabase("../" . $relativePath);
|
||||
}
|
||||
|
||||
function setProfilePictureToDatabase($url) {
|
||||
$stmt = $GLOBALS["db"]->prepare("
|
||||
UPDATE
|
||||
`user`
|
||||
SET
|
||||
`profilepicture` = :profilepicture
|
||||
WHERE
|
||||
`userID` = :userID
|
||||
");
|
||||
|
||||
$stmt->bindParam(":profilepicture", $url);
|
||||
$stmt->bindParam(":userID", $_SESSION["userID"]);
|
||||
$stmt->execute();
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
$settings = getSettings();
|
||||
//phpinfo();
|
||||
?>
|
||||
|
||||
<div class="content">
|
||||
@@ -68,7 +69,7 @@ $settings = getSettings();
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
<form class="settings-profilepictue platform" method="post">
|
||||
<form class="settings-profilepictue platform" method="post" enctype="multipart/form-data">
|
||||
<h5>Verander profielfoto</h5>
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
Reference in New Issue
Block a user