oops j'ai oublié de push

This commit is contained in:
Yasder5 2026-02-23 19:43:44 +01:00
parent 4f41366010
commit fed88a764b
15 changed files with 130 additions and 35 deletions

View file

@ -217,9 +217,81 @@ class UserCtrl extends MotherCtrl {
}else{
$objUser->hydrate($_POST);
$objUser->setId($_SESSION['user']['user_id']);
// Vérification de l'image
$arrTypeAllowed = array('image/jpeg', 'image/png', 'image/webp');
$boolImageOk = true;
if ($_FILES['image']['error'] != 4) {
if (!in_array($_FILES['image']['type'], $arrTypeAllowed)) {
$arrError['image'] = "Le type de fichier n'est pas autorisé";
} else {
switch ($_FILES['image']['error']) {
case 0:
$strImageName = uniqid() . ".webp";
$strOldImg = $objUser->getImage();
$objUser->setImage($strImageName);
break;
case 1:
case 2:
$arrError['image'] = "Le fichier est trop volumineux";
break;
case 3:
$arrError['image'] = "Le fichier a été partiellement téléchargé";
break;
case 6:
$arrError['image'] = "Le répertoire temporaire est manquant";
break;
default:
$arrError['image'] = "Erreur sur l'image";
break;
}
}
}
// Traitement de l'image si pas d'erreur
if (count($arrError) == 0 && isset($strImageName)) {
$strDest = $_ENV['IMG_USER_PATH'] . $strImageName;
$strSource = $_FILES['image']['tmp_name'];
list($intWidth, $intHeight) = getimagesize($strSource);
$intDestWidth = 200; $intDestHeight = 200;
$fltDestRatio = $intDestWidth / $intDestHeight;
$fltSourceRatio = $intWidth / $intHeight;
if ($fltSourceRatio > $fltDestRatio) {
$intCropHeight = $intHeight;
$intCropWidth = (int)round($intHeight * $fltDestRatio);
$intCropX = (int)(($intWidth - $intCropWidth) / 2);
$intCropY = 0;
} else {
$intCropWidth = $intWidth;
$intCropHeight = (int)round($intWidth / $fltDestRatio);
$intCropX = 0;
$intCropY = (int)(($intHeight - $intCropHeight) / 2);
}
$objDest = imagecreatetruecolor($intDestWidth, $intDestHeight);
switch ($_FILES['image']['type']) {
case 'image/jpeg': $objSource = imagecreatefromjpeg($strSource); break;
case 'image/png': $objSource = imagecreatefrompng($strSource); break;
case 'image/webp': $objSource = imagecreatefromwebp($strSource); break;
}
imagecopyresampled($objDest, $objSource, 0, 0, $intCropX, $intCropY, $intDestWidth, $intDestHeight, $intCropWidth, $intCropHeight);
$boolImageOk = imagewebp($objDest, $strDest);
imagedestroy($objDest);
imagedestroy($objSource);
}
$boolInsert = $objUserModel->update($objUser);
if ($boolInsert === true) {
if (isset($strOldImg) && !empty($strOldImg) && isset($strImageName)) {
$strOldFile = $_ENV['IMG_USER_PATH'] . $strOldImg;
if (file_exists($strOldFile)) unlink($strOldFile);
}
$arrNewInfo = $objUserModel->findUserByPseudo($objUser->getPseudo());
$_SESSION['user'] = $arrNewInfo;
$_SESSION['success'] = "Compte modifier avec succès";

View file

@ -79,7 +79,8 @@
user_phone = :phone,
user_work = :work,
user_location = :location,
user_description = :description
user_description = :description,
user_image = :image
WHERE user_id = :id";
@ -94,6 +95,7 @@
$rqPrep->bindValue(':work', $objUser->getWork() ?? "", PDO::PARAM_STR);
$rqPrep->bindValue(':location', $objUser->getLocation() ?? "", PDO::PARAM_STR);
$rqPrep->bindValue(':description', $objUser->getDescription() ?? "", PDO::PARAM_STR);
$rqPrep->bindValue(':image', $objUser->getImage() ?? "", PDO::PARAM_STR);
return $rqPrep->execute();

View file

@ -1,18 +1,18 @@
<?php
/* Smarty version 5.7.0, created on 2026-02-19 22:33:10
/* Smarty version 5.7.0, created on 2026-02-22 17:49:48
from 'file:views/home.tpl' */
/* @var \Smarty\Template $_smarty_tpl */
if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array (
'version' => '5.7.0',
'unifunc' => 'content_69978fa60745f2_12751511',
'unifunc' => 'content_699b41bcd91c72_02975929',
'has_nocache_code' => false,
'file_dependency' =>
array (
'0f54e8b5c9bcafd01d94486bfa02ee91c2c5fe68' =>
array (
0 => 'views/home.tpl',
1 => 1771519241,
1 => 1771764865,
2 => 'file',
),
),
@ -21,20 +21,20 @@ if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array (
'file:views/_partial/preview.tpl' => 1,
),
))) {
function content_69978fa60745f2_12751511 (\Smarty\Template $_smarty_tpl) {
function content_699b41bcd91c72_02975929 (\Smarty\Template $_smarty_tpl) {
$_smarty_current_dir = 'D:\\projetphp\\views';
$_smarty_tpl->getInheritance()->init($_smarty_tpl, true);
?>
<?php
$_smarty_tpl->getInheritance()->instanceBlock($_smarty_tpl, 'Block_71856491269978fa6070479_42524298', "content");
$_smarty_tpl->getInheritance()->instanceBlock($_smarty_tpl, 'Block_1323497504699b41bcd807a2_70028595', "content");
?>
<?php $_smarty_tpl->getInheritance()->endChild($_smarty_tpl, "views/layout.tpl", $_smarty_current_dir);
}
/* {block "content"} */
class Block_71856491269978fa6070479_42524298 extends \Smarty\Runtime\Block
class Block_1323497504699b41bcd807a2_70028595 extends \Smarty\Runtime\Block
{
public function callBlock(\Smarty\Template $_smarty_tpl) {
$_smarty_current_dir = 'D:\\projetphp\\views';

View file

@ -1,18 +1,18 @@
<?php
/* Smarty version 5.7.0, created on 2026-02-19 22:40:54
/* Smarty version 5.7.0, created on 2026-02-22 17:49:48
from 'file:views/layout.tpl' */
/* @var \Smarty\Template $_smarty_tpl */
if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array (
'version' => '5.7.0',
'unifunc' => 'content_69979176184d29_24146176',
'unifunc' => 'content_699b41bce4c480_92970054',
'has_nocache_code' => false,
'file_dependency' =>
array (
'1c51ad9f5c349145220f82584009ce981aa35e0b' =>
array (
0 => 'views/layout.tpl',
1 => 1771520226,
1 => 1771764865,
2 => 'file',
),
),
@ -22,21 +22,21 @@ if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array (
'file:views/_partial/footer.tpl' => 1,
),
))) {
function content_69979176184d29_24146176 (\Smarty\Template $_smarty_tpl) {
function content_699b41bce4c480_92970054 (\Smarty\Template $_smarty_tpl) {
$_smarty_current_dir = 'D:\\projetphp\\views';
$_smarty_tpl->getInheritance()->init($_smarty_tpl, false);
$_smarty_tpl->renderSubTemplate("file:views/_partial/header.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), (int) 0, $_smarty_current_dir);
?>
<?php
$_smarty_tpl->getInheritance()->instanceBlock($_smarty_tpl, 'Block_109821553569979176183258_93965722', "content");
$_smarty_tpl->getInheritance()->instanceBlock($_smarty_tpl, 'Block_734818017699b41bce4aba1_89981806', "content");
?>
<?php $_smarty_tpl->renderSubTemplate("file:views/_partial/footer.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), (int) 0, $_smarty_current_dir);
}
/* {block "content"} */
class Block_109821553569979176183258_93965722 extends \Smarty\Runtime\Block
class Block_734818017699b41bce4aba1_89981806 extends \Smarty\Runtime\Block
{
public function callBlock(\Smarty\Template $_smarty_tpl) {
$_smarty_current_dir = 'D:\\projetphp\\views';

View file

@ -1,18 +1,18 @@
<?php
/* Smarty version 5.7.0, created on 2026-02-19 22:40:54
/* Smarty version 5.7.0, created on 2026-02-22 17:49:49
from 'file:views/_partial/footer.tpl' */
/* @var \Smarty\Template $_smarty_tpl */
if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array (
'version' => '5.7.0',
'unifunc' => 'content_69979176449a68_71315247',
'unifunc' => 'content_699b41bd21fcf8_20527700',
'has_nocache_code' => false,
'file_dependency' =>
array (
'264314e384c04e79c5fa56e3cf6837f9df55d7fb' =>
array (
0 => 'views/_partial/footer.tpl',
1 => 1771519241,
1 => 1771764865,
2 => 'file',
),
),
@ -20,7 +20,7 @@ if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array (
array (
),
))) {
function content_69979176449a68_71315247 (\Smarty\Template $_smarty_tpl) {
function content_699b41bd21fcf8_20527700 (\Smarty\Template $_smarty_tpl) {
$_smarty_current_dir = 'D:\\projetphp\\views\\_partial';
?>
<footer class="footer container-fluid d-flex justify-content-around mt-auto">

View file

@ -1,18 +1,18 @@
<?php
/* Smarty version 5.7.0, created on 2026-02-19 22:33:52
/* Smarty version 5.7.0, created on 2026-02-22 17:49:49
from 'file:views/_partial/preview.tpl' */
/* @var \Smarty\Template $_smarty_tpl */
if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array (
'version' => '5.7.0',
'unifunc' => 'content_69978fd0688ff3_83236343',
'unifunc' => 'content_699b41bd0e6f98_46719655',
'has_nocache_code' => false,
'file_dependency' =>
array (
'67e1ae3a210fc2d1bf8782993687bad91a1cf0f6' =>
array (
0 => 'views/_partial/preview.tpl',
1 => 1771531758,
1 => 1771765950,
2 => 'file',
),
),
@ -20,13 +20,14 @@ if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array (
array (
),
))) {
function content_69978fd0688ff3_83236343 (\Smarty\Template $_smarty_tpl) {
function content_699b41bd0e6f98_46719655 (\Smarty\Template $_smarty_tpl) {
$_smarty_current_dir = 'D:\\projetphp\\views\\_partial';
?><article class="col-md-3 mb-5 <?php if ((true && (true && null !== ($_SESSION['user'] ?? null))) && $_SESSION['user']['user_status'] == 2) {?> pb-5 <?php }?>" style="border-radius: 100px ;">
<div class="card h-100 shadow article-card rounded-4" style="border-width: 2px; overflow: hidden;">
<div class="ratio ratio-4x3">
<img src=".<?php echo $_smarty_tpl->getValue('objProject')->getThumbnail();?>
<img src="<?php echo $_ENV['IMG_PROJECT_PATH'];
echo $_smarty_tpl->getValue('objProject')->getThumbnail();?>
"
class="w-100 h-100 object-fit-cover"
alt=""
@ -35,7 +36,8 @@ $_smarty_current_dir = 'D:\\projetphp\\views\\_partial';
<div class="card-body p-3 bg-light">
<div class="d-flex align-items-start gap-3">
<img src="<?php echo $_smarty_tpl->getValue('objProject')->getUser_image();?>
<img src="<?php echo $_ENV['IMG_USER_PATH'];
echo $_smarty_tpl->getValue('objProject')->getUser_image();?>
"
class="rounded-circle flex-shrink-0 border border-2 border-white"
style="width: 64px; height: 64px; object-fit: cover; margin-top: 8px;"

View file

@ -1,18 +1,18 @@
<?php
/* Smarty version 5.7.0, created on 2026-02-19 22:40:54
/* Smarty version 5.7.0, created on 2026-02-22 17:49:48
from 'file:views/_partial/header.tpl' */
/* @var \Smarty\Template $_smarty_tpl */
if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array (
'version' => '5.7.0',
'unifunc' => 'content_699791762209a2_04044349',
'unifunc' => 'content_699b41bcec6d64_92614803',
'has_nocache_code' => false,
'file_dependency' =>
array (
'8056b95e7f6b28be5e36947735d13c8d176ec944' =>
array (
0 => 'views/_partial/header.tpl',
1 => 1771532429,
1 => 1771767067,
2 => 'file',
),
),
@ -21,7 +21,7 @@ if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array (
'file:views/_partial/messages.tpl' => 1,
),
))) {
function content_699791762209a2_04044349 (\Smarty\Template $_smarty_tpl) {
function content_699b41bcec6d64_92614803 (\Smarty\Template $_smarty_tpl) {
$_smarty_current_dir = 'D:\\projetphp\\views\\_partial';
?><!DOCTYPE html>
<html lang="fr">
@ -88,7 +88,8 @@ $_smarty_current_dir = 'D:\\projetphp\\views\\_partial';
<li class="nav-item">
<a class="nav-link" href="index.php?ctrl=user&action=user&pseudo=<?php echo $_SESSION['user']['user_pseudo'];?>
" title="Modifier mon compte" aria-label="Modifier mon compte">
<img src="<?php echo $_SESSION['user']['user_image'];?>
<img src="<?php echo $_ENV['IMG_USER_PATH'];
echo $_SESSION['user']['user_image'];?>
"
class="rounded-circle flex-shrink-0 mt-2 ml-5"
style="width: 36px; height: 36px; object-fit: cover;"
@ -96,7 +97,7 @@ $_smarty_current_dir = 'D:\\projetphp\\views\\_partial';
</a>
</li>
<li class="nav-item">
<li>
<a class="nav-link" href="index.php?ctrl=user&action=logout" title="Se déconnecter" aria-label="Se déconnecter">
Se déconnecter
</a>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

View file

@ -66,14 +66,14 @@
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="index.php?ctrl=user&action=user&pseudo={$smarty.session.user.user_pseudo}" title="Modifier mon compte" aria-label="Modifier mon compte">
<img src="{$smarty.session.user.user_image}"
<img src="{$smarty.env.IMG_USER_PATH}{$smarty.session.user.user_image}"
class="rounded-circle flex-shrink-0 mt-2 ml-5"
style="width: 36px; height: 36px; object-fit: cover;"
alt="Photo de profil">
</a>
</li>
<li class="nav-item">
<li>
<a class="nav-link" href="index.php?ctrl=user&action=logout" title="Se déconnecter" aria-label="Se déconnecter">
Se déconnecter
</a>

View file

@ -3,7 +3,7 @@
{* IMAGE (partie supérieure - plus grande) *}
<div class="ratio ratio-4x3">
<img src=".{$objProject->getThumbnail()}"
<img src="{$smarty.env.IMG_PROJECT_PATH}{$objProject->getThumbnail()}"
class="w-100 h-100 object-fit-cover"
alt=""
loading="lazy">
@ -13,7 +13,7 @@
<div class="card-body p-3 bg-light">
<div class="d-flex align-items-start gap-3">
{* PHOTO DE PROFIL (cercle à gauche - plus grand) *}
<img src="{$objProject->getUser_image()}"
<img src="{$smarty.env.IMG_USER_PATH}{$objProject->getUser_image()}"
class="rounded-circle flex-shrink-0 border border-2 border-white"
style="width: 64px; height: 64px; object-fit: cover; margin-top: 8px;"
alt="Photo de profil">

View file

@ -5,7 +5,7 @@
<section class="user-profile mb-5 mt-5/*vh /*">
<div class="row">
<div class="col-md-4 text-center">
<img src="{$user->getImage()}" alt="Avatar de {$user->getPseudo()}" class="rounded-circle flex-shrink-0 border border-2 border-white"
<img src="{$smarty.env.IMG_USER_PATH}{$user->getImage()}" alt="Avatar de {$user->getPseudo()}" class="rounded-circle flex-shrink-0 border border-2 border-white"
style="width: 256px; height: 256px; object-fit: cover; margin-top: 8px;"
>
</div>

View file

@ -25,7 +25,7 @@
{/if}
<!-- Formulaire d'inscription -->
<!-- Les données seront traitées côté serveur en PHP via la méthode POST -->
<form method="POST">
<form method="POST" enctype="multipart/form-data">
<div class="row g-3">
<div class="col-md-6">
@ -71,6 +71,24 @@
>
</div>
</div>
<div class="col-12">
<label class="form-label" for="image">
Photo de profil
</label>
{if $objUser->getImage()}
<div class="mb-2">
<img src="{$smarty.env.IMG_USER_PATH}{$objUser->getImage()}" alt="image actuel" class="rounded-circle" width="80" height="80">
</div>
{/if}
<input
class="form-control"
type="file"
id="image"
name="image"
accept="image/jpeg, image/png, image/webp"
>
<div class="form-text">Formats acceptés : JPG, PNG, WEBP. Laisser vide pour ne pas changer.</div>
</div>
<div class="col-12">
<label class="form-label" for="user_mail">
Adresse e-mail