profile pictures implemented & poc for active user feautre

This commit is contained in:
thies 2021-01-10 20:51:45 +01:00
parent 13ceba1e23
commit 5d2dd2a6d5
3 changed files with 87 additions and 2 deletions

View File

@ -13,3 +13,20 @@ if($_SESSION['activated'] == 0) {
} }
echo "heres the fun world"; echo "heres the fun world";
?> ?>
<br /> <br />
<div class="jumbotron jumbotron-fluid">
<div class="container">
<?php
echo "Hi ".$_SESSION['username']."!";
if(isset($_GET['notimplemented'])) {
echo '<div class="alert alert-danger" role="alert">Feature not yet implemented!</div>';
}
?>
<br /><br />
<a href="changeprofilepicture.php"><button class="btn btn-primary">Change Profile Picture</button>
<br /><br />
<a href="?notimplemented=1"><button class="btn btn-primary disabled">Change Description</button></a>
<br /> <br /><br />
<a href="start.php"><button class="btn btn-info">Back</button></a>
</div>
</div>

68
changeprofilepicture.php Normal file
View File

@ -0,0 +1,68 @@
<html>
<head>
<title>Activated Area</title>
<link rel="stylesheet" href="ressources/css/bootstrap.min.css" crossorigin="anonymous">
</head>
<body>
<script src="ressources/js/bootstrap.min.js"></script>
<?php
session_start();
include 'db.inc.php';
if($_SESSION['activated'] == 0) {
die ("Not activated yet");
}
echo "heres the fun world";
?>
<?php
//regex to parse file extensions here:
//function to insert url into table here:
if(isset($_GET['new'])) {
$imageurl = $_POST['imageurl'];
$userid = $_SESSION['userid'];
if($imageurl == "https://web.td00.de/woddle.gif") {
echo "<br> returning to default picture";
$statement = $pdo->prepare("UPDATE users SET profilepicture = :imageurl WHERE id = :userid");
$result = $statement->execute(array('imageurl' => $imageurl, 'userid'=> $userid ));
if($result) {
die('<br>Changed Profile Picture. Going to <a href="update.php?page=profile.php">profile</a> now.<meta http-equiv="refresh" content="1; URL=update.php?page=profile.php">');
}
}
else {
$statement = $pdo->prepare("UPDATE users SET profilepicture = :imageurl WHERE id = :userid");
$result = $statement->execute(array('imageurl' => $imageurl, 'userid'=> $userid ));
if($result) {
die('<br>Changed Profile Picture. Going to <a href="update.php?page=profile.php">profile</a> now.<meta http-equiv="refresh" content="1; URL=update.php?page=profile.php">');
}
}
}
?>
<br /> <br />
<div class="jumbotron jumbotron-fluid">
<div class="container">
<i>Right now you need to upload the picture somewhere and input the URL here.</i><br />
<b>Please be aware that only the following filetypes will work!</b>
<li>jpg</li>
<li>gif</li>
<li>png</li>
<br /><br /><br />
<script src="ressources/js/bootstrap.min.js"></script>
<form action="?new=1&amp;userid=<?php echo htmlentities($userid); ?>&amp;code=<?php echo htmlentities($code); ?>" method="post">
<div class="form-group">
<label for="imageurl">URL to new image</label>
<input type="url" pattern="https://.*" id="imageurl" class="form-control" name="imageurl"><br><br>
</div>
<button type="submit" class="btn btn-primary">Submit new Image</button>
</form>
<br /> <br /><br />
<a href="activatedarea.php"><button class="btn btn-info">Back</button></a>
</div>
</div>

View File

@ -12,7 +12,7 @@ $usergn = $_SESSION['givenName'];
$userln = $_SESSION['lastName']; $userln = $_SESSION['lastName'];
$activated = $_SESSION['activated']; $activated = $_SESSION['activated'];
$isadmin = $_SESSION['isadmin']; $isadmin = $_SESSION['isadmin'];
$profilepicture = "https://web.td00.de/woddle.gif"; $profilepicture = $_SESSION['profilepicture'];
?> ?>
<html> <html>
<head> <head>