Inscription
- - -- Créez votre compte utilisateur. -
- - - -From 6ed4394ddac6a023bf20e5f9f3ca4fec2c085273 Mon Sep 17 00:00:00 2001 From: Yasder5 <102179445+Yasder5@users.noreply.github.com> Date: Mon, 9 Feb 2026 11:19:00 +0100 Subject: [PATCH] =?UTF-8?q?smarty=20et=20merge=20de=20tout=20fini=20(=20?= =?UTF-8?q?=E0=B4=A6=E0=B5=8D=E0=B4=A6=E0=B4=BF=20=CB=99=E1=97=9C=CB=99=20?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 3 +- composer.lock | 84 +- config/.gitkeep | 0 controllers/admin_controller.php | 41 +- controllers/mother_controller.php | 1 + controllers/project_controller.php | 114 +- controllers/user_controller.php | 22 +- entities/category_entity.php | 28 +- index.php | 7 +- models/category_model.php | 2 +- models/image_model.php | 3 +- .../database.php => models/mother_model.php | 0 models/project_model.php | 20 +- models/user_model.php | 19 +- ...94486bfa02ee91c2c5fe68_0.file_home.tpl.php | 10 +- ...5df178eaf9a1be4_0.file_inscription.tpl.php | 218 - ...82584009ce981aa35e0b_0.file_layout.tpl.php | 10 +- ...56e3cf6837f9df55d7fb_0.file_footer.tpl.php | 6 +- ...2993687bad91a1cf0f6_0.file_preview.tpl.php | 10 +- ...dad4b27dd58fe64_0.file_inscription.tpl.php | 218 - ...db1687a6d7b7b3c501bb_0.file_search.tpl.php | 10 +- ...dfc9d5f8ae68eb5c308ba_0.file_login.tpl.php | 83 - ...947735d13c8d176ec944_0.file_header.tpl.php | 21 +- ...67988eba5ded_0.file_projet_display.tpl.php | 128 + ...9ecf544040a414ed627_0.file_preview.tpl.php | 69 - ...eaa5fc81e6e357127f49_0.file_footer.tpl.php | 63 - ...bbeae871506874cefd9d6_0.file_login.tpl.php | 129 +- ...c811496cf0ce7d4ac25_0.file_project.tpl.php | 110 - ...53056a7c17f1dc50fcde_0.file_layout.tpl.php | 50 - ...d7bc28a51149e2e63b3bf1_0.file_home.tpl.php | 71 - ...ad4f73c431db5dba4722b_0.file_admin.tpl.php | 140 +- ...f80cb970eb1abb3c21fb_0.file_header.tpl.php | 108 - vendor/composer/autoload_psr4.php | 1 + vendor/composer/autoload_static.php | 8 + vendor/composer/installed.json | 85 + vendor/composer/installed.php | 13 +- vendor/phpmailer/phpmailer/COMMITMENT | 46 + vendor/phpmailer/phpmailer/LICENSE | 502 ++ vendor/phpmailer/phpmailer/README.md | 232 + vendor/phpmailer/phpmailer/SECURITY.md | 37 + vendor/phpmailer/phpmailer/SMTPUTF8.md | 48 + vendor/phpmailer/phpmailer/VERSION | 1 + vendor/phpmailer/phpmailer/composer.json | 84 + .../phpmailer/phpmailer/get_oauth_token.php | 182 + .../phpmailer/language/phpmailer.lang-af.php | 26 + .../phpmailer/language/phpmailer.lang-ar.php | 27 + .../phpmailer/language/phpmailer.lang-as.php | 35 + .../phpmailer/language/phpmailer.lang-az.php | 27 + .../phpmailer/language/phpmailer.lang-ba.php | 27 + .../phpmailer/language/phpmailer.lang-be.php | 27 + .../phpmailer/language/phpmailer.lang-bg.php | 27 + .../phpmailer/language/phpmailer.lang-bn.php | 35 + .../phpmailer/language/phpmailer.lang-ca.php | 27 + .../phpmailer/language/phpmailer.lang-cs.php | 28 + .../phpmailer/language/phpmailer.lang-da.php | 39 + .../phpmailer/language/phpmailer.lang-de.php | 28 + .../phpmailer/language/phpmailer.lang-el.php | 33 + .../phpmailer/language/phpmailer.lang-eo.php | 37 + .../phpmailer/language/phpmailer.lang-es.php | 38 + .../phpmailer/language/phpmailer.lang-et.php | 28 + .../phpmailer/language/phpmailer.lang-fa.php | 28 + .../phpmailer/language/phpmailer.lang-fi.php | 27 + .../phpmailer/language/phpmailer.lang-fo.php | 27 + .../phpmailer/language/phpmailer.lang-fr.php | 36 + .../phpmailer/language/phpmailer.lang-gl.php | 27 + .../phpmailer/language/phpmailer.lang-he.php | 27 + .../phpmailer/language/phpmailer.lang-hi.php | 35 + .../phpmailer/language/phpmailer.lang-hr.php | 27 + .../phpmailer/language/phpmailer.lang-hu.php | 27 + .../phpmailer/language/phpmailer.lang-hy.php | 27 + .../phpmailer/language/phpmailer.lang-id.php | 31 + .../phpmailer/language/phpmailer.lang-it.php | 28 + .../phpmailer/language/phpmailer.lang-ja.php | 37 + .../phpmailer/language/phpmailer.lang-ka.php | 27 + .../phpmailer/language/phpmailer.lang-ko.php | 27 + .../phpmailer/language/phpmailer.lang-ku.php | 27 + .../phpmailer/language/phpmailer.lang-lt.php | 27 + .../phpmailer/language/phpmailer.lang-lv.php | 27 + .../phpmailer/language/phpmailer.lang-mg.php | 27 + .../phpmailer/language/phpmailer.lang-mn.php | 27 + .../phpmailer/language/phpmailer.lang-ms.php | 27 + .../phpmailer/language/phpmailer.lang-nb.php | 37 + .../phpmailer/language/phpmailer.lang-nl.php | 38 + .../phpmailer/language/phpmailer.lang-pl.php | 33 + .../phpmailer/language/phpmailer.lang-pt.php | 34 + .../language/phpmailer.lang-pt_br.php | 38 + .../phpmailer/language/phpmailer.lang-ro.php | 33 + .../phpmailer/language/phpmailer.lang-ru.php | 36 + .../phpmailer/language/phpmailer.lang-si.php | 34 + .../phpmailer/language/phpmailer.lang-sk.php | 30 + .../phpmailer/language/phpmailer.lang-sl.php | 36 + .../phpmailer/language/phpmailer.lang-sr.php | 28 + .../language/phpmailer.lang-sr_latn.php | 28 + .../phpmailer/language/phpmailer.lang-sv.php | 27 + .../phpmailer/language/phpmailer.lang-tl.php | 28 + .../phpmailer/language/phpmailer.lang-tr.php | 38 + .../phpmailer/language/phpmailer.lang-uk.php | 28 + .../phpmailer/language/phpmailer.lang-ur.php | 30 + .../phpmailer/language/phpmailer.lang-vi.php | 27 + .../phpmailer/language/phpmailer.lang-zh.php | 29 + .../language/phpmailer.lang-zh_cn.php | 36 + .../phpmailer/src/DSNConfigurator.php | 245 + vendor/phpmailer/phpmailer/src/Exception.php | 40 + vendor/phpmailer/phpmailer/src/OAuth.php | 139 + .../phpmailer/src/OAuthTokenProvider.php | 44 + vendor/phpmailer/phpmailer/src/PHPMailer.php | 5525 +++++++++++++++++ vendor/phpmailer/phpmailer/src/POP3.php | 470 ++ vendor/phpmailer/phpmailer/src/SMTP.php | 1617 +++++ views/_partial/header.tpl | 13 +- views/_partial/preview.tpl | 2 +- views/admin.tpl | 91 +- views/login.tpl | 117 +- views/projet_display.tpl | 79 + 113 files changed, 11964 insertions(+), 1192 deletions(-) delete mode 100644 config/.gitkeep rename config/database.php => models/mother_model.php (100%) delete mode 100644 templates_c/184f81453f2b8e9c87b8f61bf5df178eaf9a1be4_0.file_inscription.tpl.php delete mode 100644 templates_c/6a0422fe7dc4be4b812fa3545dad4b27dd58fe64_0.file_inscription.tpl.php delete mode 100644 templates_c/7a5d14230a80bcfb142dfc9d5f8ae68eb5c308ba_0.file_login.tpl.php create mode 100644 templates_c/858273afeea443d46db5cb9b3c1c67988eba5ded_0.file_projet_display.tpl.php delete mode 100644 templates_c/8a75168f6980e04270d359ecf544040a414ed627_0.file_preview.tpl.php delete mode 100644 templates_c/98cc8c099e0c6b2a1fe1eaa5fc81e6e357127f49_0.file_footer.tpl.php delete mode 100644 templates_c/cf8cd41232f90f60b8532c811496cf0ce7d4ac25_0.file_project.tpl.php delete mode 100644 templates_c/e18412d61db50ad0096e53056a7c17f1dc50fcde_0.file_layout.tpl.php delete mode 100644 templates_c/ec3d3ee358d0cb60e3d7bc28a51149e2e63b3bf1_0.file_home.tpl.php delete mode 100644 templates_c/fa32ecfd2db3b295fbf8f80cb970eb1abb3c21fb_0.file_header.tpl.php create mode 100644 vendor/phpmailer/phpmailer/COMMITMENT create mode 100644 vendor/phpmailer/phpmailer/LICENSE create mode 100644 vendor/phpmailer/phpmailer/README.md create mode 100644 vendor/phpmailer/phpmailer/SECURITY.md create mode 100644 vendor/phpmailer/phpmailer/SMTPUTF8.md create mode 100644 vendor/phpmailer/phpmailer/VERSION create mode 100644 vendor/phpmailer/phpmailer/composer.json create mode 100644 vendor/phpmailer/phpmailer/get_oauth_token.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-af.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-ar.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-as.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-az.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-ba.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-be.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-bg.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-bn.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-ca.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-cs.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-da.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-de.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-el.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-eo.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-es.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-et.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-fa.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-fi.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-fo.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-fr.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-gl.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-he.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-hi.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-hr.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-hu.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-hy.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-id.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-it.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-ja.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-ka.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-ko.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-ku.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-lt.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-lv.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-mg.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-mn.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-ms.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-nb.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-nl.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-pl.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-pt.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-pt_br.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-ro.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-ru.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-si.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-sk.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-sl.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-sr.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-sr_latn.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-sv.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-tl.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-tr.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-uk.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-ur.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-vi.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-zh.php create mode 100644 vendor/phpmailer/phpmailer/language/phpmailer.lang-zh_cn.php create mode 100644 vendor/phpmailer/phpmailer/src/DSNConfigurator.php create mode 100644 vendor/phpmailer/phpmailer/src/Exception.php create mode 100644 vendor/phpmailer/phpmailer/src/OAuth.php create mode 100644 vendor/phpmailer/phpmailer/src/OAuthTokenProvider.php create mode 100644 vendor/phpmailer/phpmailer/src/PHPMailer.php create mode 100644 vendor/phpmailer/phpmailer/src/POP3.php create mode 100644 vendor/phpmailer/phpmailer/src/SMTP.php create mode 100644 views/projet_display.tpl diff --git a/composer.json b/composer.json index f2a1a02..60ba30e 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,8 @@ "name": "yasse/projetphp", "description": "le projet php de ces mort", "require": { - "smarty/smarty": "^5.7" + "smarty/smarty": "^5.7", + "phpmailer/phpmailer": "^7.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 57a15c5..5dad180 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,90 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "68f8d029d347b4c0c8cdbe33eeb96101", + "content-hash": "97f3233a5e69021ef84a92c5454bdb64", "packages": [ + { + "name": "phpmailer/phpmailer", + "version": "v7.0.2", + "source": { + "type": "git", + "url": "https://github.com/PHPMailer/PHPMailer.git", + "reference": "ebf1655bd5b99b3f97e1a3ec0a69e5f4cd7ea088" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/ebf1655bd5b99b3f97e1a3ec0a69e5f4cd7ea088", + "reference": "ebf1655bd5b99b3f97e1a3ec0a69e5f4cd7ea088", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-filter": "*", + "ext-hash": "*", + "php": ">=5.5.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "doctrine/annotations": "^1.2.6 || ^1.13.3", + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcompatibility/php-compatibility": "^10.0.0@dev", + "squizlabs/php_codesniffer": "^3.13.5", + "yoast/phpunit-polyfills": "^1.0.4" + }, + "suggest": { + "decomplexity/SendOauth2": "Adapter for using XOAUTH2 authentication", + "directorytree/imapengine": "For uploading sent messages via IMAP, see gmail example", + "ext-imap": "Needed to support advanced email address parsing according to RFC822", + "ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses", + "ext-openssl": "Needed for secure SMTP sending and DKIM signing", + "greew/oauth2-azure-provider": "Needed for Microsoft Azure XOAUTH2 authentication", + "hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication", + "league/oauth2-google": "Needed for Google XOAUTH2 authentication", + "psr/log": "For optional PSR-3 debug logging", + "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)", + "thenetworg/oauth2-azure": "Needed for Microsoft XOAUTH2 authentication" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPMailer\\PHPMailer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-only" + ], + "authors": [ + { + "name": "Marcus Bointon", + "email": "phpmailer@synchromedia.co.uk" + }, + { + "name": "Jim Jagielski", + "email": "jimjag@gmail.com" + }, + { + "name": "Andy Prevost", + "email": "codeworxtech@users.sourceforge.net" + }, + { + "name": "Brent R. Matzelle" + } + ], + "description": "PHPMailer is a full-featured email creation and transfer class for PHP", + "support": { + "issues": "https://github.com/PHPMailer/PHPMailer/issues", + "source": "https://github.com/PHPMailer/PHPMailer/tree/v7.0.2" + }, + "funding": [ + { + "url": "https://github.com/Synchro", + "type": "github" + } + ], + "time": "2026-01-09T18:02:33+00:00" + }, { "name": "smarty/smarty", "version": "v5.7.0", diff --git a/config/.gitkeep b/config/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/controllers/admin_controller.php b/controllers/admin_controller.php index dd4c1cf..63e92a1 100644 --- a/controllers/admin_controller.php +++ b/controllers/admin_controller.php @@ -18,8 +18,45 @@ class AdminCtrl extends MotherCtrl{ public function admin(){ + /*accès à la page admin + if (!isset($_SESSION['user']) && ($_SESSION['user']['user_status'] != 1 )){ + header("Location:index.php?ctrl=error&action=error_403"); + exit; + }*/ + $objCategoryModel = new CategoryModel; + + if (!empty($_POST['new_category'])) { + $objNewCategory = new Category; + if (!empty($objNewCategory->getName())) { + $objNewCategory = $_POST['new_category']; + $objCategoryModel->insertCategory($objNewCategory); + header("Location:index.php?ctrl=admin&action=admin"); + exit; + } + } + + if (!empty($_POST['edit_category'])) { + $objEditCategory = new Category; + if ($objEditCategory->getId() > 0) { + $objEditCategory = $_POST['edit_category']; + $objCategoryModel->editCategory($objEditCategory); + header("Location:index.php?ctrl=admin&action=admin"); + exit; + } + } + + $arrCategory = $objCategoryModel->findAllCategory(); + $arrCategoryToDisplay = array(); + + foreach($arrCategory as $arrDetCategory){ + $objCategory = new Category; + $objCategory->hydrate($arrDetCategory); + $arrCategoryToDisplay[] = $objCategory; + } - $this->_display("admin"); - + // Il faudra donner à maman et gérer l'affichage quand Smarty sera prêt + $this->_arrData['arrCategoryToDisplay'] = $arrCategoryToDisplay; + //$this->_arrData['intCategory'] = $objCategoryModel->; + $this->_display("admin"); } } diff --git a/controllers/mother_controller.php b/controllers/mother_controller.php index a5284f2..953a1ef 100644 --- a/controllers/mother_controller.php +++ b/controllers/mother_controller.php @@ -2,6 +2,7 @@ use Smarty\Smarty; + class MotherCtrl { protected array $_arrData = array(); // ou = [] diff --git a/controllers/project_controller.php b/controllers/project_controller.php index 216b1b9..af2e9fa 100644 --- a/controllers/project_controller.php +++ b/controllers/project_controller.php @@ -8,6 +8,9 @@ require("./models/user_model.php"); require("./entities/user_entity.php"); require("mother_controller.php"); + use PHPMailer\PHPMailer\PHPMailer; + use PHPMailer\PHPMailer\Exception; + use PHPMailer\PHPMailer\SMTP; /** * Le controler des Project @@ -50,25 +53,24 @@ $strStartDate = $_POST['startdate']??''; $strEndDate = $_POST['enddate']??''; $intCategory = $_POST['category']??0; - // Récupération des projetc + + // Récupération des projets $objProjectModel = new ProjectModel; $arrProject = $objProjectModel->findAll(intAuthor:$intAuthor, intPeriod:$intPeriod, strDate:$strDate, strKeywords:$strKeywords, strStartDate:$strStartDate, strEndDate:$strEndDate, intCategory:$intCategory); - - // Initialisation d'un tableau => objets $arrProjectToDisplay = array(); - // Boucle de transformation du tableau de tableau en tableau d'objets + foreach($arrProject as $arrDetProject){ $objProject = new Project; $objProject->hydrate($arrDetProject); - $arrProjectToDisplay[] = $objProject; } + // Récupération des utilisateurs $objUserModel = new UserModel; $arrUser = $objUserModel->findAllUsers(); - + // Récupération des catégories $objCategoryModel = new CategoryModel; $arrCategory = $objCategoryModel->findAllCategory(); @@ -159,9 +161,99 @@ } - public function admin(){ - - $this->_display("admin"); - - } + + public function display() { + $intId = $_GET['id'] ?? null; + + if ($intId) { + $objProjectModel = new ProjectModel(); + $arrProject = $objProjectModel->findOne((int)$intId); + + if ($arrProject) { + $objProject = new Project(); + $objProject->hydrate($arrProject); + + $this->_arrData["objProject"] = $objProject; + $this->_display("projet_display"); + } else { + header("Location: index.php?ctrl=project&action=home"); + exit; + } + } else { + header("Location: index.php?ctrl=project&action=home"); + exit; + } + } + + public function sendEmail() + { + if (count($_POST) > 0) { + + $projectId = (int)($_POST['project_id'] ?? 0); + $toEmail = trim($_POST['to_email'] ?? ''); + + if ($projectId <= 0 || !filter_var($toEmail, FILTER_VALIDATE_EMAIL)) { + header("Location: index.php?ctrl=project&action=display&id=".$projectId."&mail=fail"); + exit; + } + + $objProjectModel = new ProjectModel(); + $arrProject = $objProjectModel->findOne($projectId); + + if (!$arrProject) { + header("Location: index.php?ctrl=project&action=home"); + exit; + } + + $objProject = new Project(); + $objProject->hydrate($arrProject); + + + + $objMail = new PHPMailer(); // Nouvel objet Mail + $objMail->IsSMTP(); + $objMail->Mailer = "smtp"; + $objMail->CharSet = PHPMailer::CHARSET_UTF8; + + $objMail->SMTPDebug = 0; + + $objMail->SMTPAuth = TRUE; + $objMail->SMTPSecure = "tls"; + $objMail->Port = 587; + $objMail->Host = "smtp.gmail.com"; + $objMail->Username = "projet.folliow@gmail.com"; + $objMail->Password = "dqnw mqbu cwvg enbp"; + + $objMail->IsHTML(true); + + + $objMail->setFrom('projet.folliow@gmail.com', 'Projet Folliow'); + + + // Destinataire + $objMail->addAddress($toEmail); + + // Mail + $objMail->Subject = "Projet : " . $objProject->getTitle(); + + $url = "http://localhost/projet_php/public/index.php?ctrl=project&action=display&id=" . $projectId; + + $objMail->Body = + "
" . $objProject->getDescription() . "
" . + ""; + + // Envoi + redirection + if ($objMail->Send()) { + header("Location: index.php?ctrl=project&action=display&id=".$projectId."&mail=ok"); + } else { + // Pour debug si besoin: echo $objMail->ErrorInfo; exit; + header("Location: index.php?ctrl=project&action=display&id=".$projectId."&mail=fail"); + } + exit; + } + + header("Location: index.php?ctrl=project&action=home"); + exit; + } } \ No newline at end of file diff --git a/controllers/user_controller.php b/controllers/user_controller.php index 3a34aa7..70e2599 100644 --- a/controllers/user_controller.php +++ b/controllers/user_controller.php @@ -8,8 +8,8 @@ class UserCtrl extends MotherCtrl { public function login(){ - $strMail = $_POST['mail']??""; - $strPwd = $_POST['pwd']??""; + $strMail = $_POST['user_mail']??""; + $strPwd = $_POST['user_password']??""; // Tester le formulaire $arrError = []; @@ -127,13 +127,19 @@ class UserCtrl extends MotherCtrl { $objUserModel = new UserModel(); $boolInsert = $objUserModel->insert($objUser); - if ($boolInsert === true) { - $_SESSION['success'] = "Compte créé avec succès"; - header("Location:index.php?ctrl=user&action=login"); - exit; + if ($objUserModel->mailExists($objUser->getMail())) { + + $arrError['user_mail'] = "Ce mail existe déjà"; } else { - // Erreur globale (pas liée à un champ) - $arrError['global'] = "Erreur lors de l'ajout"; + $boolInsert = $objUserModel->insert($objUser); + + if ($boolInsert === true) { + $_SESSION['success'] = "Compte créé avec succès"; + header("Location:index.php?ctrl=user&action=login"); + exit; + } else { + $arrError['global'] = "Erreur lors de l'ajout"; + } } } } diff --git a/entities/category_entity.php b/entities/category_entity.php index 3b51e5b..c614541 100644 --- a/entities/category_entity.php +++ b/entities/category_entity.php @@ -9,11 +9,11 @@ require_once("mother_entity.php"); class Category extends Entity{ - private int $_id; - protected string $_name = ''; - protected string $_parent = ''; + private ?int $_id = null; + protected string $_name = ''; + protected ?int $_parent = null; - /** + /** * Constructeur (j'ai toujours pas compris à quoi ça sert) */ public function __construct(){ @@ -26,7 +26,7 @@ class Category extends Entity{ * Récuperation de l'id de la catégorie * @return int l'id de la catégorie */ - public function getId():int{ + public function getId(): ?int{ return $this->_id; } @@ -35,7 +35,11 @@ class Category extends Entity{ * @param int le nouvelle id */ public function setId($id){ - $this->_id = $id; + if (empty($id)) { + $this->_id = null; + } else { + $this->_id = (int) $id; + } } /** @@ -56,18 +60,22 @@ class Category extends Entity{ /** * Récuperation du nom du parent de la catégorie - * @return string nom de la catégorie + * @return int nom de la catégorie */ - public function getParent(){ + public function getParent():?int{ return $this->_parent; } /** * Mise à jour du nom du parent de la catégorie - * @param string le nouveau nom de la catégorie + * @param int le nouveau nom de la catégorie */ public function setParent($parent){ - $this->_parent = $parent; + if (empty($parent)) { + $this->_parent = null; + } else { + $this->_parent = (int) $parent; + } } } \ No newline at end of file diff --git a/index.php b/index.php index 8c958bd..f7890b4 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,5 @@ $strMethod(); + $objController->$strMethod (); }else{ $boolError = true; } diff --git a/models/category_model.php b/models/category_model.php index 0301c29..6432a9a 100644 --- a/models/category_model.php +++ b/models/category_model.php @@ -1,5 +1,5 @@ exec($strRq); return $rqPrep->execute(); } + + public function findOne(int $intId) { + $strRq = "SELECT project.*, + CONCAT(users.user_firstname, ' ', users.user_name) AS 'project_creatorname', + users.user_image, + category.category_name + FROM project + INNER JOIN users ON users.user_id = project.project_user + LEFT JOIN category ON category.category_id = project.project_category + WHERE project.project_id = :id"; + + $rqPrep = $this->_db->prepare($strRq); + $rqPrep->bindValue(":id", $intId, PDO::PARAM_INT); + $rqPrep->execute(); + + return $rqPrep->fetch(); + } } \ No newline at end of file diff --git a/models/user_model.php b/models/user_model.php index 83debc8..72f1ada 100644 --- a/models/user_model.php +++ b/models/user_model.php @@ -1,5 +1,6 @@ _db->query($strRq)->fetchAll(); } @@ -33,8 +34,8 @@ */ public function verifUser(string $strMail, string $strPwd):array|bool{ // 2. Construire la requête - $strRq = "SELECT user_id, user_name, user_firstname, user_password, user_image - FROM users + $strRq = "SELECT user_id, user_name, user_firstname, user_password, user_image, user_status, authorisation_name + FROM users INNER JOIN authorisation ON authorisation.authorisation_id = users.user_status WHERE user_mail = '".$strMail."'"; // Récupère mon utilisateur // Executer la requête et récupérer les résultats @@ -81,4 +82,12 @@ //return $db->exec($strRq); return $rqPrep->execute(); } + public function mailExists(string $mail): bool + { + $rq = $this->_db->prepare("SELECT 1 FROM users WHERE user_mail = :mail LIMIT 1"); + $rq->bindValue(":mail", $mail); + $rq->execute(); + + return (bool)$rq->fetchColumn(); + } } diff --git a/templates_c/0f54e8b5c9bcafd01d94486bfa02ee91c2c5fe68_0.file_home.tpl.php b/templates_c/0f54e8b5c9bcafd01d94486bfa02ee91c2c5fe68_0.file_home.tpl.php index 720dec7..76d88b5 100644 --- a/templates_c/0f54e8b5c9bcafd01d94486bfa02ee91c2c5fe68_0.file_home.tpl.php +++ b/templates_c/0f54e8b5c9bcafd01d94486bfa02ee91c2c5fe68_0.file_home.tpl.php @@ -1,11 +1,11 @@ getCompiled()->isFresh($_smarty_tpl, array ( 'version' => '5.7.0', - 'unifunc' => 'content_6988e6e030cfc2_17810205', + 'unifunc' => 'content_6989b403135214_06797903', 'has_nocache_code' => false, 'file_dependency' => array ( @@ -21,20 +21,20 @@ if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array ( 'file:views/_partial/preview.tpl' => 1, ), ))) { -function content_6988e6e030cfc2_17810205 (\Smarty\Template $_smarty_tpl) { +function content_6989b403135214_06797903 (\Smarty\Template $_smarty_tpl) { $_smarty_current_dir = 'D:\\projetphp\\views'; $_smarty_tpl->getInheritance()->init($_smarty_tpl, true); ?> getInheritance()->instanceBlock($_smarty_tpl, 'Block_14883993436988e6e03087b1_93283416', "content"); +$_smarty_tpl->getInheritance()->instanceBlock($_smarty_tpl, 'Block_8519413186989b403131000_39935260', "content"); ?> getInheritance()->endChild($_smarty_tpl, "views/layout.tpl", $_smarty_current_dir); } /* {block "content"} */ -class Block_14883993436988e6e03087b1_93283416 extends \Smarty\Runtime\Block +class Block_8519413186989b403131000_39935260 extends \Smarty\Runtime\Block { public function callBlock(\Smarty\Template $_smarty_tpl) { $_smarty_current_dir = 'D:\\projetphp\\views'; diff --git a/templates_c/184f81453f2b8e9c87b8f61bf5df178eaf9a1be4_0.file_inscription.tpl.php b/templates_c/184f81453f2b8e9c87b8f61bf5df178eaf9a1be4_0.file_inscription.tpl.php deleted file mode 100644 index 67893a4..0000000 --- a/templates_c/184f81453f2b8e9c87b8f61bf5df178eaf9a1be4_0.file_inscription.tpl.php +++ /dev/null @@ -1,218 +0,0 @@ -getCompiled()->isFresh($_smarty_tpl, array ( - 'version' => '5.7.0', - 'unifunc' => 'content_6988e6eb196d91_26203411', - 'has_nocache_code' => false, - 'file_dependency' => - array ( - '184f81453f2b8e9c87b8f61bf5df178eaf9a1be4' => - array ( - 0 => 'views/inscription.tpl', - 1 => 1770579251, - 2 => 'file', - ), - ), - 'includes' => - array ( - ), -))) { -function content_6988e6eb196d91_26203411 (\Smarty\Template $_smarty_tpl) { -$_smarty_current_dir = 'D:\\projetphp\\views'; -$_smarty_tpl->getInheritance()->init($_smarty_tpl, true); -?> - - -getInheritance()->instanceBlock($_smarty_tpl, 'Block_10194680646988e6eb195117_68573569', "content"); -$_smarty_tpl->getInheritance()->endChild($_smarty_tpl, "views/layout.tpl", $_smarty_current_dir); -} -/* {block "content"} */ -class Block_10194680646988e6eb195117_68573569 extends \Smarty\Runtime\Block -{ -public function callBlock(\Smarty\Template $_smarty_tpl) { -$_smarty_current_dir = 'D:\\projetphp\\views'; -?> - - - - -- Créez votre compte utilisateur. -
- - - -