diff --git a/controllers/UserCtrl.php b/controllers/UserCtrl.php index a9fee94..cd0b3e2 100644 --- a/controllers/UserCtrl.php +++ b/controllers/UserCtrl.php @@ -243,9 +243,6 @@ class UserCtrl extends MotherCtrl { } } } - if ($_POST['delete_image'] === '1') { - $objUser->setImage('images.jpg'); - } if (count($arrError) == 0 && isset($strImageName)) { @@ -283,12 +280,20 @@ class UserCtrl extends MotherCtrl { } + if ($_POST['delete_image'] === '1') { + $strOldImg = $objUser->getImage(); + if (!empty($strOldImg) && $strOldImg !== 'images.jpg') { + $strOldFile = $_ENV['IMG_USER_PATH'] . $strOldImg; + if (file_exists($strOldFile)) unlink($strOldFile); + } + $objUser->setImage('images.jpg'); + } $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); + if (isset($strOldImg) && !empty($strOldImg) && $strOldImg !== 'images.jpg' && isset($strImageName)) { + $strOldFile = $_ENV['IMG_USER_PATH'] . $strOldImg; + if (file_exists($strOldFile)) unlink($strOldFile); } $arrNewInfo = $objUserModel->findUserByPseudo($objUser->getPseudo()); $_SESSION['user'] = $arrNewInfo; diff --git a/models/MotherModel.php b/models/MotherModel.php index df9f2f7..d63bcfd 100644 --- a/models/MotherModel.php +++ b/models/MotherModel.php @@ -11,8 +11,8 @@ try{ $this->_db = new PDO( "mysql:host=localhost;dbname=projet_folliow", - "projet_user", - "F0lliowRules!", + "root", + "", array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC) ); $this->_db->exec("SET CHARACTER SET utf8"); diff --git a/uploads/profiles/69a5f23fe150e.webp b/uploads/profiles/69a5f23fe150e.webp deleted file mode 100644 index 2a2361e..0000000 Binary files a/uploads/profiles/69a5f23fe150e.webp and /dev/null differ diff --git a/uploads/profiles/images.jpg b/uploads/profiles/images.jpg new file mode 100644 index 0000000..44949df Binary files /dev/null and b/uploads/profiles/images.jpg differ