153 lines
4.9 KiB
PHP
153 lines
4.9 KiB
PHP
<?php
|
|
require "../include/variables.php";
|
|
require "../include/functions.php";
|
|
|
|
if(isset($_SESSION['userid']) == false) {
|
|
header("Location: index.php");
|
|
http_response_code(404);
|
|
die();
|
|
}
|
|
|
|
if(isset($_POST['delete_account'])) {
|
|
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
|
|
|
$req = $bdd->prepare("DELETE FROM users WHERE ID = :id");
|
|
$req->bindParam(':id', $_SESSION['userid']);
|
|
if($req->execute()) {
|
|
header("Location: logout.php");
|
|
exit();
|
|
} else {
|
|
die("Erreur SQL");
|
|
}
|
|
} else if (isset($_POST['display_name']) && isset($_POST['email'])){
|
|
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
|
|
|
$req = $bdd->prepare("UPDATE users SET display_name = :display_name, email = :email WHERE ID = :userid");
|
|
$req->bindParam(':display_name', $_SESSION['display_name']);
|
|
$req->bindParam(':email', $_SESSION['email']);
|
|
$req->bindParam(':userid', $_SESSION['userid']);
|
|
if($req->execute()) {
|
|
$status = "Informations mises à jour";
|
|
} else {
|
|
$status = "Erreur SQL";
|
|
}
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="stylesheet" href="./src/css/style.css">
|
|
<style>
|
|
@media (prefers-color-scheme: dark) {
|
|
.body {
|
|
<?=$theme_dark?>
|
|
}
|
|
<?php
|
|
for ($i = 0; $i < count($themes_dark); $i++) {
|
|
echo "#palette" . $i . " { ";
|
|
echo $themes_dark[$i];
|
|
echo " } ";
|
|
}
|
|
?>
|
|
}
|
|
@media (prefers-color-scheme: light) {
|
|
.body {
|
|
<?=$theme_light?>
|
|
}
|
|
<?php
|
|
for ($i = 0; $i < count($themes_light); $i++) {
|
|
echo "#palette" . $i . " { ";
|
|
echo $themes_light[$i];
|
|
echo " } ";
|
|
}
|
|
?>
|
|
}
|
|
|
|
.userinfo {
|
|
margin: 5em auto;
|
|
}
|
|
|
|
.palettes {
|
|
display: flex;
|
|
}
|
|
|
|
.delaccount {
|
|
margin-top: 15em;
|
|
}
|
|
|
|
</style>
|
|
<link rel="icon" href="src/img/favicon.ico">
|
|
<title><?=$title?></title>
|
|
</head>
|
|
<body class="body">
|
|
<header>
|
|
<div class="pancontent">
|
|
<div class="athena-container">
|
|
<a href="/" class="athena-link">
|
|
<img src="./src/img/athena-mono.png" class="athena">
|
|
</a>
|
|
</div>
|
|
<div class="content">
|
|
<div>
|
|
<div class="main-title">
|
|
<div class="title"><?=$header_title?></div>
|
|
<div class="subtitle"><?=$header_subtitle?></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
<nav>
|
|
<div class="pancontent">
|
|
<?php nav($nav);?>
|
|
</div>
|
|
</nav>
|
|
<main>
|
|
<div class="content">
|
|
<div>
|
|
<div class="userinfo">
|
|
<form action='' method='post'>
|
|
<?php
|
|
echo "<div><input type='text' name='display_name' value='" . $_SESSION['display_name'] . "' required></div>";
|
|
echo "<div><input type='email' name='email' value='" . $_SESSION['email'] . "' required></div>";
|
|
echo "<div><input type='submit' value='Mettre à jour'></div>";
|
|
?>
|
|
<div><?=$status?></div>
|
|
</form>
|
|
</div>
|
|
<div class="palettes">
|
|
<?php
|
|
|
|
$height = 4;
|
|
$width = 6;
|
|
|
|
for ($i = 0; $i < count($themes_dark); $i++) {
|
|
echo "<a href='?theme=" . $i . "'><div id='palette" . $i . "'style='display: flex; margin: 0 1em; border: 1px solid var(--text)'>";
|
|
echo "<div style='display: inline; background-color: var(--text); padding: " . $height/2 . "em ". $width/8 ."em'></div>";
|
|
echo "<div style='display: inline; background-color: var(--background); padding: " . $height/2 . "em ". $width/8 ."em'></div>";
|
|
echo "<div style='display: inline; background-color: var(--banner-background); padding: " . $height/2 . "em ". $width/8 ."em'></div>";
|
|
echo "<div style='display: inline; background-color: var(--buttons); padding: " . $height/2 . "em ". $width/8 ."em'></div>";
|
|
echo "</div></a>";
|
|
}
|
|
?>
|
|
</div>
|
|
<div class="delaccount">
|
|
<form action="" method="post">
|
|
<input type="submit" name="delete_account" value="Supprimer le compte (irréversible)" style="font-size: 1em;">
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
<footer>
|
|
<div class="content">
|
|
<div>
|
|
<div><?=$copyright?></div>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
</body>
|
|
</html>
|