htaccess c'est vraiment de la merde

This commit is contained in:
Yass 2026-03-03 11:16:14 +01:00
parent 5638c0712d
commit 04d7d564f1
5 changed files with 15 additions and 14 deletions

View file

@ -1,9 +1,8 @@
Options -Indexes Options -Indexes
# Rediriger les erreurs serveur vers ton contrôleur
# 1. On définit des URLs propres pour les erreurs # On force le passage par index.php pour que ton routeur reçoive les paramètres
ErrorDocument 403 /error/error_403 ErrorDocument 404 /index.php?ctrl=error&action=error_404
ErrorDocument 404 /error/error_404 ErrorDocument 403 /index.php?ctrl=error&action=error_403
# --- Sécurité --- # --- Sécurité ---
<FilesMatch ".env"> <FilesMatch ".env">
Require all denied Require all denied

View file

@ -21,8 +21,8 @@
public function admin(){ public function admin(){
if (!isset($_SESSION['user']) && ($_SESSION['user']['user_status'] != 1 )){ if (!isset($_SESSION['user']) && ($_SESSION['user']['user_status'] != 1 )){
header("Location:index.php?ctrl=error&action=error_403"); $error = new \Controllers\ErrorCtrl();
exit; return $error->error_403();
} }
$objCategoryModel = new CategoryModel; $objCategoryModel = new CategoryModel;

View file

@ -13,6 +13,7 @@
public function error_404(){ public function error_404(){
http_response_code(404); http_response_code(404);
$this->_display("error_404"); $this->_display("error_404");
exit;
} }
/** /**
@ -21,6 +22,7 @@
public function error_403(){ public function error_403(){
http_response_code(403); http_response_code(403);
$this->_display("error_403"); $this->_display("error_403");
exit;
} }
} }

View file

@ -124,8 +124,8 @@
*/ */
public function addedit_project() { public function addedit_project() {
if (!isset($_SESSION['user'])){ if (!isset($_SESSION['user'])){
header("Location:index.php?ctrl=error&action=error_403"); $error = new \Controllers\ErrorCtrl();
exit; return $error->error_403();
} }
$objProject = new Project; $objProject = new Project;
@ -135,8 +135,8 @@
if (isset($_GET['id'])){ if (isset($_GET['id'])){
$arrProject = $objProjectModel->findOne($_GET['id']); $arrProject = $objProjectModel->findOne($_GET['id']);
if($_SESSION['user']['user_id'] != $arrProject['project_user_id']){ if($_SESSION['user']['user_id'] != $arrProject['project_user_id']){
header("Location:index.php?ctrl=error&action=error_403"); $error = new \Controllers\ErrorCtrl();
exit; return $error->error_403();
} }
$objProject->hydrate($arrProject); $objProject->hydrate($arrProject);
$this->_arrData['arrImages'] = $objProjectModel->getImagesByProjectId($objProject->getId()); $this->_arrData['arrImages'] = $objProjectModel->getImagesByProjectId($objProject->getId());

View file

@ -11,8 +11,8 @@
try{ try{
$this->_db = new PDO( $this->_db = new PDO(
"mysql:host=localhost;dbname=projet_folliow", "mysql:host=localhost;dbname=projet_folliow",
"projet_user", "root",
"F0lliowRules!", "",
array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC) array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC)
); );
$this->_db->exec("SET CHARACTER SET utf8"); $this->_db->exec("SET CHARACTER SET utf8");