@@ -2,7 +2,6 @@ |
||
| 2 | 2 | namespace core\admin; |
| 3 | 3 | |
| 4 | 4 | use core\App; |
| 5 | - use core\auth\Connexion; |
|
| 6 | 5 | use core\auth\Encrypt; |
| 7 | 6 | use core\auth\Membre; |
| 8 | 7 | use core\Configuration; |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * Pour récupérer la liste de tous les users afin d'activer un compte ou modifier des trucs dessus |
| 45 | 45 | * si archiver == null on récupère les utilisateurs actifs sur le site sinon on récupere les utilisateurs archives |
| 46 | 46 | */ |
| 47 | - public function getAllUser($archiver=null) { |
|
| 47 | + public function getAllUser($archiver = null) { |
|
| 48 | 48 | $dbc = \core\App::getDb(); |
| 49 | 49 | $this->setAllUser(null, null, null, null, null, null, null); |
| 50 | 50 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | |
| 230 | 230 | if ($oldimg_profil != "") { |
| 231 | 231 | $oldimg_profil = explode("/", $oldimg_profil); |
| 232 | - if($oldimg_profil[7] != "defaut.png") { |
|
| 232 | + if ($oldimg_profil[7] != "defaut.png") { |
|
| 233 | 233 | unlink("../../images/profil/".$oldimg_profil[7]); |
| 234 | 234 | } |
| 235 | 235 | } |
@@ -50,8 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | if ($archiver == null) { |
| 52 | 52 | $query = $dbc->query("SELECT * FROM identite WHERE archiver IS NULL AND ID_identite > 1"); |
| 53 | - } |
|
| 54 | - else { |
|
| 53 | + } else { |
|
| 55 | 54 | $query = $dbc->query("SELECT * FROM identite WHERE archiver IS NOT NULL AND ID_identite > 1"); |
| 56 | 55 | } |
| 57 | 56 | |
@@ -67,20 +66,17 @@ discard block |
||
| 67 | 66 | |
| 68 | 67 | if ($obj->img_profil == "") { |
| 69 | 68 | $img_profil[] = "profil/defaut.png"; |
| 70 | - } |
|
| 71 | - else { |
|
| 69 | + } else { |
|
| 72 | 70 | $img_profil[] = $obj->img_profil; |
| 73 | 71 | } |
| 74 | 72 | |
| 75 | 73 | if ($config->getValiderInscription() == 1) { |
| 76 | 74 | if ($obj->valide == 0) { |
| 77 | 75 | $valide[] = "<a href=".ADMWEBROOT."controller/core/admin/comptes/valider_compte?id_identite=$obj->ID_identite>Valider cet utilisateur</a>"; |
| 78 | - } |
|
| 79 | - else { |
|
| 76 | + } else { |
|
| 80 | 77 | $valide[] = "Utilisateur validé"; |
| 81 | 78 | } |
| 82 | - } |
|
| 83 | - else { |
|
| 79 | + } else { |
|
| 84 | 80 | $valide = ""; |
| 85 | 81 | } |
| 86 | 82 | } |
@@ -177,8 +173,7 @@ discard block |
||
| 177 | 173 | |
| 178 | 174 | $mail = new Mail($this->mail); |
| 179 | 175 | $mail->setEnvoyerMail("Réinitialisation de votre E-mail effectuée", "Votre mot de passe a été réinitialisé"); |
| 180 | - } |
|
| 181 | - else { |
|
| 176 | + } else { |
|
| 182 | 177 | FlashMessage::setFlash("le mot de passe de $this->pseudo ne peu pas être réinitialisé car il ne possède pas d'E-mail"); |
| 183 | 178 | $this->erreur = true; |
| 184 | 179 | } |
@@ -80,8 +80,8 @@ discard block |
||
| 80 | 80 | /** |
| 81 | 81 | * pour savoir si en fonction des droits d'accès de l'utilisateur il peu ou non accéder à cete page |
| 82 | 82 | * on passe outre les test si on est super admin |
| 83 | - * @param $page |
|
| 84 | - * @param null $id_page |
|
| 83 | + * @param string $page |
|
| 84 | + * @param string $page |
|
| 85 | 85 | * @return bool |
| 86 | 86 | */ |
| 87 | 87 | public function getDroitAccesPage($page) { |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * si on est super admin on passe outre tous les tests |
| 144 | 144 | * @param $droit |
| 145 | 145 | * @param $id_page |
| 146 | - * @return bool |
|
| 146 | + * @return boolean|null |
|
| 147 | 147 | */ |
| 148 | 148 | public function getDroitAccesContenu($droit, $id_page) { |
| 149 | 149 | $dbc = \core\App::getDb(); |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | - namespace core\admin\droitsacces; |
|
| 2 | + namespace core\admin\droitsacces; |
|
| 3 | 3 | |
| 4 | 4 | use core\App; |
| 5 | 5 | |
| 6 | 6 | class DroitAcces { |
| 7 | - private $logged; |
|
| 7 | + private $logged; |
|
| 8 | 8 | |
| 9 | 9 | //pour la table identite |
| 10 | 10 | private $id_identite; |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | |
| 23 | 23 | //-------------------------- CONSTRUCTEUR ----------------------------------------------------------------------------// |
| 24 | - public function __construct() { |
|
| 24 | + public function __construct() { |
|
| 25 | 25 | $dbc = \core\App::getDb(); |
| 26 | 26 | |
| 27 | - if (isset($_SESSION["idlogin".CLEF_SITE])) { |
|
| 27 | + if (isset($_SESSION["idlogin".CLEF_SITE])) { |
|
| 28 | 28 | $this->logged = true; |
| 29 | 29 | $this->id_identite = $_SESSION["idlogin".CLEF_SITE]; |
| 30 | 30 | |
@@ -44,36 +44,36 @@ discard block |
||
| 44 | 44 | else { |
| 45 | 45 | $this->logged = false; |
| 46 | 46 | } |
| 47 | - } |
|
| 48 | - //-------------------------- FIN CONSTRUCTEUR ----------------------------------------------------------------------------// |
|
| 47 | + } |
|
| 48 | + //-------------------------- FIN CONSTRUCTEUR ----------------------------------------------------------------------------// |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | |
| 52 | - //-------------------------- GETTER ----------------------------------------------------------------------------// |
|
| 52 | + //-------------------------- GETTER ----------------------------------------------------------------------------// |
|
| 53 | 53 | public function getLogged(){ |
| 54 | - return $this->logged; |
|
| 54 | + return $this->logged; |
|
| 55 | 55 | } |
| 56 | 56 | public function getSuperAdmin(){ |
| 57 | - return $this->super_admin; |
|
| 57 | + return $this->super_admin; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | //pour la table liste_droit_acces |
| 61 | 61 | public function getIdListeDroitAcces(){ |
| 62 | - return $this->id_liste_droit_acces; |
|
| 62 | + return $this->id_liste_droit_acces; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | //pour les droits sur la gestion des contenus |
| 66 | 66 | public function getModifSeo(){ |
| 67 | - return $this->modif_seo; |
|
| 67 | + return $this->modif_seo; |
|
| 68 | 68 | } |
| 69 | 69 | public function getModifContenu(){ |
| 70 | - return $this->modif_contenu; |
|
| 70 | + return $this->modif_contenu; |
|
| 71 | 71 | } |
| 72 | 72 | public function getModifNavigation(){ |
| 73 | - return $this->modif_navigation; |
|
| 73 | + return $this->modif_navigation; |
|
| 74 | 74 | } |
| 75 | 75 | public function getSupprimerPage(){ |
| 76 | - return $this->supprimer_page; |
|
| 76 | + return $this->supprimer_page; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | //autres getter |
@@ -240,11 +240,11 @@ discard block |
||
| 240 | 240 | return true; |
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | - //-------------------------- FIN GETTER ----------------------------------------------------------------------------// |
|
| 243 | + //-------------------------- FIN GETTER ----------------------------------------------------------------------------// |
|
| 244 | 244 | |
| 245 | 245 | |
| 246 | 246 | |
| 247 | - //-------------------------- SETTER ----------------------------------------------------------------------------// |
|
| 247 | + //-------------------------- SETTER ----------------------------------------------------------------------------// |
|
| 248 | 248 | |
| 249 | - //-------------------------- FIN SETTER ----------------------------------------------------------------------------// |
|
| 250 | - } |
|
| 251 | 249 | \ No newline at end of file |
| 250 | + //-------------------------- FIN SETTER ----------------------------------------------------------------------------// |
|
| 251 | + } |
|
| 252 | 252 | \ No newline at end of file |
@@ -50,29 +50,29 @@ |
||
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
| 53 | - public function getLogged(){ |
|
| 53 | + public function getLogged() { |
|
| 54 | 54 | return $this->logged; |
| 55 | 55 | } |
| 56 | - public function getSuperAdmin(){ |
|
| 56 | + public function getSuperAdmin() { |
|
| 57 | 57 | return $this->super_admin; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | //pour la table liste_droit_acces |
| 61 | - public function getIdListeDroitAcces(){ |
|
| 61 | + public function getIdListeDroitAcces() { |
|
| 62 | 62 | return $this->id_liste_droit_acces; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | //pour les droits sur la gestion des contenus |
| 66 | - public function getModifSeo(){ |
|
| 66 | + public function getModifSeo() { |
|
| 67 | 67 | return $this->modif_seo; |
| 68 | 68 | } |
| 69 | - public function getModifContenu(){ |
|
| 69 | + public function getModifContenu() { |
|
| 70 | 70 | return $this->modif_contenu; |
| 71 | 71 | } |
| 72 | - public function getModifNavigation(){ |
|
| 72 | + public function getModifNavigation() { |
|
| 73 | 73 | return $this->modif_navigation; |
| 74 | 74 | } |
| 75 | - public function getSupprimerPage(){ |
|
| 75 | + public function getSupprimerPage() { |
|
| 76 | 76 | return $this->supprimer_page; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -31,17 +31,17 @@ discard block |
||
| 31 | 31 | //on test voir si super admin |
| 32 | 32 | $query = $dbc->query("SELECT super_admin,liste_droit FROM identite WHERE ID_identite=".$this->id_identite); |
| 33 | 33 | foreach ($query as $obj) { |
| 34 | - if ($obj->super_admin == 1) $this->super_admin = 1; |
|
| 34 | + if ($obj->super_admin == 1) { |
|
| 35 | + $this->super_admin = 1; |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | if ($obj->liste_droit == 1) { |
| 37 | 39 | $this->id_liste_droit_acces = $obj->liste_droit; |
| 38 | - } |
|
| 39 | - else { |
|
| 40 | + } else { |
|
| 40 | 41 | $this->id_liste_droit_acces = 0; |
| 41 | 42 | } |
| 42 | 43 | } |
| 43 | - } |
|
| 44 | - else { |
|
| 44 | + } else { |
|
| 45 | 45 | $this->logged = false; |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -93,14 +93,15 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | if (!in_array($page, $all_access)) { |
| 95 | 95 | $query = $dbc->query("SELECT droit_acces FROM droit_acces WHERE page LIKE '%$page%'"); |
| 96 | - foreach ($query as $obj) $droit_acces = $obj->droit_acces; |
|
| 96 | + foreach ($query as $obj) { |
|
| 97 | + $droit_acces = $obj->droit_acces; |
|
| 98 | + } |
|
| 97 | 99 | } |
| 98 | 100 | |
| 99 | 101 | //si la page n'est pas trouvée dans les droit d'accès c'est qu'elle est obligatoirement accessible dans admin |
| 100 | 102 | if (!isset($droit_acces)) { |
| 101 | 103 | $acces = true; |
| 102 | - } |
|
| 103 | - else { |
|
| 104 | + } else { |
|
| 104 | 105 | $acces = false; |
| 105 | 106 | } |
| 106 | 107 | |
@@ -112,25 +113,23 @@ discard block |
||
| 112 | 113 | "); |
| 113 | 114 | |
| 114 | 115 | if (count($query) > 0) { |
| 115 | - foreach ($query as $obj) $liste_droit_acces[] = $obj->droit_acces; |
|
| 116 | + foreach ($query as $obj) { |
|
| 117 | + $liste_droit_acces[] = $obj->droit_acces; |
|
| 118 | + } |
|
| 116 | 119 | |
| 117 | 120 | if (($this->super_admin == 1) || ($acces == true) || (in_array($droit_acces, $liste_droit_acces)) || (($page == "") || ($page == null))) { |
| 118 | 121 | return true; |
| 119 | - } |
|
| 120 | - else { |
|
| 122 | + } else { |
|
| 121 | 123 | return false; |
| 122 | 124 | } |
| 123 | - } |
|
| 124 | - else { |
|
| 125 | + } else { |
|
| 125 | 126 | if ($acces == true) { |
| 126 | 127 | return true; |
| 127 | - } |
|
| 128 | - else { |
|
| 128 | + } else { |
|
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | - } |
|
| 133 | - else { |
|
| 132 | + } else { |
|
| 134 | 133 | return true; |
| 135 | 134 | } |
| 136 | 135 | } |
@@ -155,7 +154,9 @@ discard block |
||
| 155 | 154 | liste_droit_acces.ID_liste_droit_acces = liaison_liste_droit.ID_liste_droit_acces AND |
| 156 | 155 | liste_droit_acces.ID_liste_droit_acces = $this->id_liste_droit_acces |
| 157 | 156 | "); |
| 158 | - foreach ($query as $obj) $liste_droit_acces[] = $obj->droit_acces; |
|
| 157 | + foreach ($query as $obj) { |
|
| 158 | + $liste_droit_acces[] = $obj->droit_acces; |
|
| 159 | + } |
|
| 159 | 160 | |
| 160 | 161 | if (in_array($droit, $liste_droit_acces)) { |
| 161 | 162 | //on check si il a le droit de modifier ou supprimer cette page |
@@ -178,27 +179,21 @@ discard block |
||
| 178 | 179 | //si les trois sont différent de 0 on renvoit true soinon false |
| 179 | 180 | if (($this->modif_seo != 0) || ($this->modif_contenu != 0) || ($this->modif_navigation != 0) || ($this->supprimer_page != 0)) { |
| 180 | 181 | return true; |
| 181 | - } |
|
| 182 | - else { |
|
| 182 | + } else { |
|
| 183 | 183 | return false; |
| 184 | 184 | } |
| 185 | - } |
|
| 186 | - else { |
|
| 185 | + } else { |
|
| 187 | 186 | return false; |
| 188 | 187 | } |
| 189 | - } |
|
| 190 | - else if ($id_page == "creation_page") { |
|
| 188 | + } else if ($id_page == "creation_page") { |
|
| 191 | 189 | $this->getDroitAccesPage("gestion-contenus/index"); |
| 192 | - } |
|
| 193 | - else { |
|
| 190 | + } else { |
|
| 194 | 191 | return false; |
| 195 | 192 | } |
| 196 | - } |
|
| 197 | - else { |
|
| 193 | + } else { |
|
| 198 | 194 | return false; |
| 199 | 195 | } |
| 200 | - } |
|
| 201 | - else { |
|
| 196 | + } else { |
|
| 202 | 197 | $this->modif_seo = 1; |
| 203 | 198 | $this->modif_contenu = 1; |
| 204 | 199 | $this->modif_navigation = 1; |
@@ -223,20 +218,19 @@ discard block |
||
| 223 | 218 | liste_droit_acces.ID_liste_droit_acces = $this->id_liste_droit_acces |
| 224 | 219 | "); |
| 225 | 220 | if (count($query) > 0) { |
| 226 | - foreach ($query as $obj) $liste_droit_acces[] = $obj->droit_acces; |
|
| 221 | + foreach ($query as $obj) { |
|
| 222 | + $liste_droit_acces[] = $obj->droit_acces; |
|
| 223 | + } |
|
| 227 | 224 | |
| 228 | 225 | if (($this->super_admin == 1) || (in_array($droit_acces, $liste_droit_acces))) { |
| 229 | 226 | return true; |
| 230 | - } |
|
| 231 | - else { |
|
| 227 | + } else { |
|
| 232 | 228 | return false; |
| 233 | 229 | } |
| 234 | - } |
|
| 235 | - else { |
|
| 230 | + } else { |
|
| 236 | 231 | return false; |
| 237 | 232 | } |
| 238 | - } |
|
| 239 | - else { |
|
| 233 | + } else { |
|
| 240 | 234 | return true; |
| 241 | 235 | } |
| 242 | 236 | } |
@@ -13,6 +13,10 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
| 16 | + |
|
| 17 | + /** |
|
| 18 | + * @return string |
|
| 19 | + */ |
|
| 16 | 20 | public static function getParams($id_identite=null) { |
| 17 | 21 | if ($id_identite != null) { |
| 18 | 22 | $dbc = App::getDb(); |
@@ -101,7 +105,7 @@ discard block |
||
| 101 | 105 | |
| 102 | 106 | /** |
| 103 | 107 | * sauvegarde les parametres pour retrouver le mot de passe dans la bdd |
| 104 | - * @param $params |
|
| 108 | + * @param string $params |
|
| 105 | 109 | * @param $id_identite |
| 106 | 110 | */ |
| 107 | 111 | public static function setSaveParams($params, $id_identite) { |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
| 16 | - public static function getParams($id_identite=null) { |
|
| 16 | + public static function getParams($id_identite = null) { |
|
| 17 | 17 | if ($id_identite != null) { |
| 18 | 18 | $dbc = App::getDb(); |
| 19 | 19 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @param $id_identite |
| 39 | 39 | * @return string |
| 40 | 40 | */ |
| 41 | - public static function setEncryptMdp($mdp, $id_identite=null) { |
|
| 41 | + public static function setEncryptMdp($mdp, $id_identite = null) { |
|
| 42 | 42 | $encrypt_str = ChaineCaractere::random(154); |
| 43 | 43 | |
| 44 | 44 | //on cache le mdp |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | $longeur_mdp = strlen($mdp); |
| 49 | 49 | |
| 50 | 50 | //on va couper le mot de passe en 2 suivant un nombre aleatoire |
| 51 | - $nb_aleatoire_mdp = rand(3, $longeur_mdp-2); |
|
| 52 | - $bout1_mdp = mb_substr($mdp, 0, $longeur_mdp/2, "UTF-8"); |
|
| 53 | - $bout2_mdp = mb_substr($mdp, $longeur_mdp/2, $longeur_mdp, "UTF-8"); |
|
| 51 | + $nb_aleatoire_mdp = rand(3, $longeur_mdp - 2); |
|
| 52 | + $bout1_mdp = mb_substr($mdp, 0, $longeur_mdp / 2, "UTF-8"); |
|
| 53 | + $bout2_mdp = mb_substr($mdp, $longeur_mdp / 2, $longeur_mdp, "UTF-8"); |
|
| 54 | 54 | |
| 55 | 55 | //on stock la taille des bouts pour pouvoir les décrypter |
| 56 | 56 | $taille_bout1 = strlen($bout1_mdp); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | //on insere le premier bout aleatoirement dans le hashmdp |
| 60 | 60 | //on calcul sa longeur total (celle duhash + la logneur du mdp que l'on va rajouter dedans) |
| 61 | 61 | $longueur_hash = strlen($encrypt_str); |
| 62 | - $debut_bout1 = rand(0, $longueur_hash/2); |
|
| 62 | + $debut_bout1 = rand(0, $longueur_hash / 2); |
|
| 63 | 63 | |
| 64 | 64 | //on rajouter le premier bout dans le mot de passe + recalcule de la longeur du hash avec le mdp add |
| 65 | 65 | $encrypt_str = mb_substr($encrypt_str, 0, $debut_bout1).$bout1_mdp.mb_substr($encrypt_str, $debut_bout1, $longueur_hash); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | //on insere le second bout aleatoirement dans le hashmdp |
| 68 | 68 | //on calcul sa longeur total (celle duhash + la logneur premier bout du mdp que l'on va rajouter dedans) |
| 69 | 69 | $longueur_hash = strlen($encrypt_str); |
| 70 | - $debut_bout2 = rand($longueur_hash/2, $longueur_hash); |
|
| 70 | + $debut_bout2 = rand($longueur_hash / 2, $longueur_hash); |
|
| 71 | 71 | |
| 72 | 72 | //on rajoute le deuxieme |
| 73 | 73 | $mdp_encrypt = mb_substr($encrypt_str, 0, $debut_bout2).$bout2_mdp.mb_substr($encrypt_str, $debut_bout2, $longueur_hash); |
@@ -21,8 +21,7 @@ discard block |
||
| 21 | 21 | foreach ($query as $obj) { |
| 22 | 22 | $params = $obj->mdp_params; |
| 23 | 23 | } |
| 24 | - } |
|
| 25 | - else { |
|
| 24 | + } else { |
|
| 26 | 25 | $params = self::$params; |
| 27 | 26 | } |
| 28 | 27 | |
@@ -74,8 +73,7 @@ discard block |
||
| 74 | 73 | |
| 75 | 74 | if ($id_identite != null) { |
| 76 | 75 | self::setSaveParams("$taille_bout1, $debut_bout2, $nb_aleatoire_mdp, $taille_bout2, $debut_bout1, ".ChaineCaractere::random(20), $id_identite); |
| 77 | - } |
|
| 78 | - else { |
|
| 76 | + } else { |
|
| 79 | 77 | self::$params = "$taille_bout1, $debut_bout2, $nb_aleatoire_mdp, $taille_bout2, $debut_bout1, ".ChaineCaractere::random(20); |
| 80 | 78 | } |
| 81 | 79 | |
@@ -55,6 +55,9 @@ |
||
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | + /** |
|
| 59 | + * @param integer $longeur |
|
| 60 | + */ |
|
| 58 | 61 | protected function getTestLongueur($value, $longeur) { |
| 59 | 62 | if (strlen($value) > $longeur) { |
| 60 | 63 | return true; |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | //-------------------------- CONSTRUCTEUR ----------------------------------------------------------------------------// |
| 16 | 16 | public function __construct($datas) { |
| 17 | - for ($i=0 ; $i<count($datas) ; $i++) { |
|
| 17 | + for ($i = 0; $i < count($datas); $i++) { |
|
| 18 | 18 | $function = "setVerif".ucfirst($datas[$i][0]); |
| 19 | 19 | |
| 20 | 20 | if (isset($datas[$i][2])) { |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | return $this->mail; |
| 44 | 44 | } |
| 45 | 45 | public function getErreur() { |
| 46 | - return $this->erreur;; |
|
| 46 | + return $this->erreur; ; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | protected function getTestRequired($value) { |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param null $required |
| 84 | 84 | * @return bool |
| 85 | 85 | */ |
| 86 | - protected function setVerifNom($value, $required=null) { |
|
| 86 | + protected function setVerifNom($value, $required = null) { |
|
| 87 | 87 | //test avec le required, si le champe est vide et que le required est != null on return fa lse sinon on va tester |
| 88 | 88 | if (($required != null) && ($this->getTestRequired($value) == false)) { |
| 89 | 89 | $this->erreur .= "<li>Le champs nom ne peut pas être vide</li>"; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @param null $required |
| 111 | 111 | * @return bool |
| 112 | 112 | */ |
| 113 | - protected function setVerifPrenom($value, $required=null) { |
|
| 113 | + protected function setVerifPrenom($value, $required = null) { |
|
| 114 | 114 | //test avec le required, si le champe est vide et que le required est != null on return fa lse sinon on va tester |
| 115 | 115 | if (($required != null) && ($this->getTestRequired($value) == false)) { |
| 116 | 116 | $this->erreur .= "<li>Le champs prénom ne peut pas être vide</li>"; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param null $required |
| 138 | 138 | * @return bool |
| 139 | 139 | */ |
| 140 | - protected function setVerifMdp($value, $required=null) { |
|
| 140 | + protected function setVerifMdp($value, $required = null) { |
|
| 141 | 141 | //test avec le required, si le champe est vide et que le required est != null on return fa lse sinon on va tester |
| 142 | 142 | if (($required != null) && ($this->getTestRequired($value) == false)) { |
| 143 | 143 | $this->erreur .= "<li>Le champs mot de passe ne peut pas être vide</li>"; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * @param null $required |
| 165 | 165 | * @return bool |
| 166 | 166 | */ |
| 167 | - protected function setVerifRetapeMdp($value, $required=null) { |
|
| 167 | + protected function setVerifRetapeMdp($value, $required = null) { |
|
| 168 | 168 | if ($this->mdp == $value) { |
| 169 | 169 | return true; |
| 170 | 170 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @param null $required |
| 182 | 182 | * @return bool |
| 183 | 183 | */ |
| 184 | - protected function setVerifPseudo($value, $required=null) { |
|
| 184 | + protected function setVerifPseudo($value, $required = null) { |
|
| 185 | 185 | //test avec le required, si le champe est vide et que le required est != null on return fa lse sinon on va tester |
| 186 | 186 | if (($required != null) && ($this->getTestRequired($value) == false)) { |
| 187 | 187 | $this->erreur .= "<li>Le champs pseudo ne peut pas être vide</li>"; |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * @param null $required |
| 209 | 209 | * @return bool |
| 210 | 210 | */ |
| 211 | - protected function setVerifMail($value, $required=null) { |
|
| 211 | + protected function setVerifMail($value, $required = null) { |
|
| 212 | 212 | //test avec le required, si le champe est vide et que le required est != null on return fa lse sinon on va tester |
| 213 | 213 | if (($required != null) && ($this->getTestRequired($value) == false)) { |
| 214 | 214 | $this->erreur .= "<li>Le champs E-mail ne peut pas être vide</li>"; |
@@ -19,8 +19,7 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | if (isset($datas[$i][2])) { |
| 21 | 21 | $this->$function($datas[$i][1], $datas[$i][2]); |
| 22 | - } |
|
| 23 | - else { |
|
| 22 | + } else { |
|
| 24 | 23 | $this->$function($datas[$i][1]); |
| 25 | 24 | } |
| 26 | 25 | } |
@@ -49,8 +48,7 @@ discard block |
||
| 49 | 48 | protected function getTestRequired($value) { |
| 50 | 49 | if (($value == "") || ($value == null) || (strlen($value) == 0)) { |
| 51 | 50 | return false; |
| 52 | - } |
|
| 53 | - else { |
|
| 51 | + } else { |
|
| 54 | 52 | return true; |
| 55 | 53 | } |
| 56 | 54 | } |
@@ -58,8 +56,7 @@ discard block |
||
| 58 | 56 | protected function getTestLongueur($value, $longeur) { |
| 59 | 57 | if (strlen($value) > $longeur) { |
| 60 | 58 | return true; |
| 61 | - } |
|
| 62 | - else { |
|
| 59 | + } else { |
|
| 63 | 60 | return false; |
| 64 | 61 | } |
| 65 | 62 | } |
@@ -67,8 +64,7 @@ discard block |
||
| 67 | 64 | protected function getTestInt($value) { |
| 68 | 65 | if (is_numeric($value)) { |
| 69 | 66 | return true; |
| 70 | - } |
|
| 71 | - else { |
|
| 67 | + } else { |
|
| 72 | 68 | return false; |
| 73 | 69 | } |
| 74 | 70 | } |
@@ -88,17 +84,14 @@ discard block |
||
| 88 | 84 | if (($required != null) && ($this->getTestRequired($value) == false)) { |
| 89 | 85 | $this->erreur .= "<li>Le champs nom ne peut pas être vide</li>"; |
| 90 | 86 | return false; |
| 91 | - } |
|
| 92 | - else { |
|
| 87 | + } else { |
|
| 93 | 88 | if (($value != "") && ($this->getTestLongueur($value, 2) == true)) { |
| 94 | 89 | $this->nom = $value; |
| 95 | 90 | return true; |
| 96 | - } |
|
| 97 | - else if (($value != "") && ($this->getTestLongueur($value, 2) == false)) { |
|
| 91 | + } else if (($value != "") && ($this->getTestLongueur($value, 2) == false)) { |
|
| 98 | 92 | $this->erreur .= "<li>Le champs nom soit être supérieur à deux caractères</li>"; |
| 99 | 93 | return false; |
| 100 | - } |
|
| 101 | - else { |
|
| 94 | + } else { |
|
| 102 | 95 | return true; |
| 103 | 96 | } |
| 104 | 97 | } |
@@ -115,17 +108,14 @@ discard block |
||
| 115 | 108 | if (($required != null) && ($this->getTestRequired($value) == false)) { |
| 116 | 109 | $this->erreur .= "<li>Le champs prénom ne peut pas être vide</li>"; |
| 117 | 110 | return false; |
| 118 | - } |
|
| 119 | - else { |
|
| 111 | + } else { |
|
| 120 | 112 | if (($value != "") && ($this->getTestLongueur($value, 2) == true)) { |
| 121 | 113 | $this->prenom = $value; |
| 122 | 114 | return true; |
| 123 | - } |
|
| 124 | - else if (($value != "") && ($this->getTestLongueur($value, 2) == false)) { |
|
| 115 | + } else if (($value != "") && ($this->getTestLongueur($value, 2) == false)) { |
|
| 125 | 116 | $this->erreur .= "<li>Le champs prénom soit être supérieur à deux caractères</li>"; |
| 126 | 117 | return false; |
| 127 | - } |
|
| 128 | - else { |
|
| 118 | + } else { |
|
| 129 | 119 | return true; |
| 130 | 120 | } |
| 131 | 121 | } |
@@ -142,17 +132,14 @@ discard block |
||
| 142 | 132 | if (($required != null) && ($this->getTestRequired($value) == false)) { |
| 143 | 133 | $this->erreur .= "<li>Le champs mot de passe ne peut pas être vide</li>"; |
| 144 | 134 | return false; |
| 145 | - } |
|
| 146 | - else { |
|
| 135 | + } else { |
|
| 147 | 136 | if (($value != "") && ($this->getTestLongueur($value, 2) == true)) { |
| 148 | 137 | $this->mdp = $value; |
| 149 | 138 | return true; |
| 150 | - } |
|
| 151 | - else if (($value != "") && ($this->getTestLongueur($value, 2) == false)) { |
|
| 139 | + } else if (($value != "") && ($this->getTestLongueur($value, 2) == false)) { |
|
| 152 | 140 | $this->erreur .= "<li>Le champs mot de passe soit être supérieur à deux caractères</li>"; |
| 153 | 141 | return false; |
| 154 | - } |
|
| 155 | - else { |
|
| 142 | + } else { |
|
| 156 | 143 | return true; |
| 157 | 144 | } |
| 158 | 145 | } |
@@ -167,8 +154,7 @@ discard block |
||
| 167 | 154 | protected function setVerifRetapeMdp($value, $required=null) { |
| 168 | 155 | if ($this->mdp == $value) { |
| 169 | 156 | return true; |
| 170 | - } |
|
| 171 | - else { |
|
| 157 | + } else { |
|
| 172 | 158 | $this->erreur .= "<li>Les mots de passent ne correspondent pas</li>"; |
| 173 | 159 | $this->mdp = null; |
| 174 | 160 | return false; |
@@ -186,17 +172,14 @@ discard block |
||
| 186 | 172 | if (($required != null) && ($this->getTestRequired($value) == false)) { |
| 187 | 173 | $this->erreur .= "<li>Le champs pseudo ne peut pas être vide</li>"; |
| 188 | 174 | return false; |
| 189 | - } |
|
| 190 | - else { |
|
| 175 | + } else { |
|
| 191 | 176 | if (($value != "") && ($this->getTestLongueur($value, 2) == true)) { |
| 192 | 177 | $this->pseudo = $value; |
| 193 | 178 | return true; |
| 194 | - } |
|
| 195 | - else if (($value != "") && ($this->getTestLongueur($value, 2) == false)) { |
|
| 179 | + } else if (($value != "") && ($this->getTestLongueur($value, 2) == false)) { |
|
| 196 | 180 | $this->erreur .= "<li>Le champs pseudo soit être supérieur à deux caractères</li>"; |
| 197 | 181 | return false; |
| 198 | - } |
|
| 199 | - else { |
|
| 182 | + } else { |
|
| 200 | 183 | return true; |
| 201 | 184 | } |
| 202 | 185 | } |
@@ -213,17 +196,14 @@ discard block |
||
| 213 | 196 | if (($required != null) && ($this->getTestRequired($value) == false)) { |
| 214 | 197 | $this->erreur .= "<li>Le champs E-mail ne peut pas être vide</li>"; |
| 215 | 198 | return false; |
| 216 | - } |
|
| 217 | - else { |
|
| 199 | + } else { |
|
| 218 | 200 | if (($value != "") && (filter_var($value, FILTER_VALIDATE_EMAIL) != false)) { |
| 219 | 201 | $this->mail = $value; |
| 220 | 202 | return true; |
| 221 | - } |
|
| 222 | - else if (($value != "") && (filter_var($value, FILTER_VALIDATE_EMAIL) == false)) { |
|
| 203 | + } else if (($value != "") && (filter_var($value, FILTER_VALIDATE_EMAIL) == false)) { |
|
| 223 | 204 | $this->erreur .= "<li>Le champs E-mail doit être une adresse E-mail valide</li>"; |
| 224 | 205 | return false; |
| 225 | - } |
|
| 226 | - else { |
|
| 206 | + } else { |
|
| 227 | 207 | return true; |
| 228 | 208 | } |
| 229 | 209 | } |
@@ -136,6 +136,11 @@ discard block |
||
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | + /** |
|
| 140 | + * @param string $old_mdp |
|
| 141 | + * @param string $new_mdp |
|
| 142 | + * @param string $verif_new_mdp |
|
| 143 | + */ |
|
| 139 | 144 | public function setMdp($old_mdp, $new_mdp, $verif_new_mdp) { |
| 140 | 145 | $dbc = \core\App::getDb(); |
| 141 | 146 | |
@@ -271,7 +276,7 @@ discard block |
||
| 271 | 276 | /** |
| 272 | 277 | * Fonction qui permet de verifier la securite d'un mdp |
| 273 | 278 | * @param string $mdp |
| 274 | - * @return float |
|
| 279 | + * @return integer |
|
| 275 | 280 | */ |
| 276 | 281 | function testpassword($mdp) { |
| 277 | 282 | $longueur = strlen($mdp); |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | //------------------------------ constructeur----------------------------------- |
| 21 | 21 | //Récupérer en base de données les infos du membre |
| 22 | - public function __construct($id_identite=null){ |
|
| 22 | + public function __construct($id_identite = null) { |
|
| 23 | 23 | $dbc = \core\App::getDb(); |
| 24 | 24 | |
| 25 | 25 | $this->debut_lien = IMGROOT."profil/"; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | |
| 84 | 84 | //------------------------------ setter----------------------------------- |
| 85 | - public function setSupprimUser($id_identite=null) { |
|
| 85 | + public function setSupprimUser($id_identite = null) { |
|
| 86 | 86 | $dbc = \core\App::getDb(); |
| 87 | 87 | |
| 88 | 88 | if ($id_identite == null) { |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $oldimg_profil = $obj->img_profil; |
| 97 | 97 | if ($oldimg_profil != "") { |
| 98 | 98 | $oldimg_profil = explode("/", $oldimg_profil); |
| 99 | - if(end($oldimg_profil) == "defaut.png") { |
|
| 99 | + if (end($oldimg_profil) == "defaut.png") { |
|
| 100 | 100 | |
| 101 | 101 | } |
| 102 | 102 | else { |
@@ -211,26 +211,26 @@ discard block |
||
| 211 | 211 | //recuperation info sur img |
| 212 | 212 | $infos_img = getimagesize($_FILES['image']['tmp_name']); |
| 213 | 213 | |
| 214 | - if(substr($image, -3) == (!$extension || !$extension2 || !$extension3 || !$extension4)) { |
|
| 214 | + if (substr($image, -3) == (!$extension || !$extension2 || !$extension3 || !$extension4)) { |
|
| 215 | 215 | $err = "Votre image ne comporte pas l'extension .jpg"; |
| 216 | 216 | $this->erreur = $err; |
| 217 | 217 | } |
| 218 | - else if(($infos_img[0] >= $width_max) && ($infos_img[1] >= $height_max) && ($_FILES['image']['size'] >= $max_size)) { |
|
| 218 | + else if (($infos_img[0] >= $width_max) && ($infos_img[1] >= $height_max) && ($_FILES['image']['size'] >= $max_size)) { |
|
| 219 | 219 | $err = "Problème dans les dimensions ou taille de l\'image."; |
| 220 | 220 | $this->erreur = $err; |
| 221 | 221 | } |
| 222 | 222 | else { |
| 223 | 223 | $uniqid = uniqid(); |
| 224 | 224 | $chemin_destination = '../images/profil/'; |
| 225 | - if(substr($image, -3) == ($extension)) { |
|
| 225 | + if (substr($image, -3) == ($extension)) { |
|
| 226 | 226 | move_uploaded_file($_FILES['image']['tmp_name'], $chemin_destination.$uniqid.".jpg"); |
| 227 | 227 | $imageok = $uniqid.".jpg"; |
| 228 | 228 | } |
| 229 | - else if(substr($image, -3) == ($extension2)) { |
|
| 229 | + else if (substr($image, -3) == ($extension2)) { |
|
| 230 | 230 | move_uploaded_file($_FILES['image']['tmp_name'], $chemin_destination.$uniqid.".png"); |
| 231 | 231 | $imageok = $uniqid.".png"; |
| 232 | 232 | } |
| 233 | - else if(substr($image, -3) == ($extension3)) { |
|
| 233 | + else if (substr($image, -3) == ($extension3)) { |
|
| 234 | 234 | move_uploaded_file($_FILES['image']['tmp_name'], $chemin_destination.$uniqid.".jpeg"); |
| 235 | 235 | $imageok = $uniqid.".jpeg"; |
| 236 | 236 | } |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | if ($oldimg_profil != "") { |
| 257 | 257 | $oldimg_profil = explode("/", $oldimg_profil); |
| 258 | 258 | |
| 259 | - if($oldimg_profil[7] == "defaut.png") { |
|
| 259 | + if ($oldimg_profil[7] == "defaut.png") { |
|
| 260 | 260 | } |
| 261 | 261 | else { |
| 262 | 262 | unlink("../images/profil/".$oldimg_profil[7]); |
@@ -273,22 +273,22 @@ discard block |
||
| 273 | 273 | * @param string $mdp |
| 274 | 274 | * @return float |
| 275 | 275 | */ |
| 276 | - function testpassword($mdp) { |
|
| 276 | + function testpassword($mdp) { |
|
| 277 | 277 | $longueur = strlen($mdp); |
| 278 | 278 | $point = 0; |
| 279 | 279 | |
| 280 | - for ($i=0 ; $i<$longueur ; $i++) { |
|
| 280 | + for ($i = 0; $i < $longueur; $i++) { |
|
| 281 | 281 | $lettre = $mdp[$i]; |
| 282 | 282 | |
| 283 | 283 | if ($lettre >= 'a' && $lettre <= 'z') { |
| 284 | 284 | $point = $point + 1; |
| 285 | 285 | $point_min = 1; |
| 286 | 286 | } |
| 287 | - else if ($lettre >= 'A' && $lettre <= 'Z'){ |
|
| 287 | + else if ($lettre >= 'A' && $lettre <= 'Z') { |
|
| 288 | 288 | $point = $point + 2; |
| 289 | 289 | $point_maj = 2; |
| 290 | 290 | } |
| 291 | - else if ($lettre >= '0' && $lettre <= '9'){ |
|
| 291 | + else if ($lettre >= '0' && $lettre <= '9') { |
|
| 292 | 292 | $point = $point + 3; |
| 293 | 293 | $point_chiffre = 3; |
| 294 | 294 | } |
@@ -38,8 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | if ($obj->img_profil == "") { |
| 40 | 40 | $this->img = $this->debut_lien."defaut.png"; |
| 41 | - } |
|
| 42 | - else { |
|
| 41 | + } else { |
|
| 43 | 42 | $this->img = $obj->img_profil; |
| 44 | 43 | } |
| 45 | 44 | } |
@@ -98,8 +97,7 @@ discard block |
||
| 98 | 97 | $oldimg_profil = explode("/", $oldimg_profil); |
| 99 | 98 | if(end($oldimg_profil) == "defaut.png") { |
| 100 | 99 | |
| 101 | - } |
|
| 102 | - else { |
|
| 100 | + } else { |
|
| 103 | 101 | unlink("../../images/profil/".end($oldimg_profil)); |
| 104 | 102 | |
| 105 | 103 | } |
@@ -121,16 +119,13 @@ discard block |
||
| 121 | 119 | if (strlen($new_pseudo) < 5) { |
| 122 | 120 | $err = "Votre pseudo est trop court"; |
| 123 | 121 | $this->erreur = $err; |
| 124 | - } |
|
| 125 | - else if (strlen($new_pseudo) > 15) { |
|
| 122 | + } else if (strlen($new_pseudo) > 15) { |
|
| 126 | 123 | $err = "Votre pseudo est trop long"; |
| 127 | 124 | $this->erreur = $err; |
| 128 | - } |
|
| 129 | - else if ($new_pseudo == $pseudo_bdd) { |
|
| 125 | + } else if ($new_pseudo == $pseudo_bdd) { |
|
| 130 | 126 | $err = "Ce pseudo est déjà utilisé, veuillez en choisir un autre"; |
| 131 | 127 | $this->erreur = $err; |
| 132 | - } |
|
| 133 | - else { |
|
| 128 | + } else { |
|
| 134 | 129 | $dbc->query("UPDATE identite set pseudo=$new_pseudo WHERE ID_identite=".$_SESSION["idlogin".CLEF_SITE]); |
| 135 | 130 | $this->pseudo = $new_pseudo; |
| 136 | 131 | } |
@@ -146,24 +141,20 @@ discard block |
||
| 146 | 141 | if (md5($old_mdp) != $mdp) { |
| 147 | 142 | $err = "Votre mot de passe est incorrect"; |
| 148 | 143 | $this->erreur = $err; |
| 149 | - } |
|
| 150 | - else { |
|
| 144 | + } else { |
|
| 151 | 145 | if ($new_mdp != $verif_new_mdp) { |
| 152 | 146 | $err = "Vos mots de passe sont différents"; |
| 153 | 147 | $this->erreur = $err; |
| 154 | - } |
|
| 155 | - else { |
|
| 148 | + } else { |
|
| 156 | 149 | $testmdp = $this->testpassword($new_mdp); |
| 157 | 150 | |
| 158 | 151 | if (strlen($new_mdp) < 5) { |
| 159 | 152 | $err = "Votre mot de passe est trop court"; |
| 160 | 153 | $this->erreur = $err; |
| 161 | - } |
|
| 162 | - else if ($testmdp < 40) { |
|
| 154 | + } else if ($testmdp < 40) { |
|
| 163 | 155 | $err = "Votre mot de passe est trop simple"; |
| 164 | 156 | $this->erreur = $err; |
| 165 | - } |
|
| 166 | - else { |
|
| 157 | + } else { |
|
| 167 | 158 | $mdpok = Encrypt::setEncryptMdp($new_mdp, $this->id_identite); |
| 168 | 159 | //le nouveau mdp est bon on update |
| 169 | 160 | $dbc->query("UPDATE identite SET mdp='$mdpok' WHERE ID_identite=".$this->id_identite); |
@@ -199,8 +190,7 @@ discard block |
||
| 199 | 190 | |
| 200 | 191 | $urlimg = $this->debut_lien."profil/defaut.png"; |
| 201 | 192 | $dbc->query("UPDATE identite SET img_profil='$urlimg' WHERE ID_identite='$this->id_identite'"); |
| 202 | - } |
|
| 203 | - else { |
|
| 193 | + } else { |
|
| 204 | 194 | //test si il y a deja une img |
| 205 | 195 | $query = $dbc->query("SELECT img_profil FROM identite where ID_identite=$this->id_identite"); |
| 206 | 196 | |
@@ -214,27 +204,22 @@ discard block |
||
| 214 | 204 | if(substr($image, -3) == (!$extension || !$extension2 || !$extension3 || !$extension4)) { |
| 215 | 205 | $err = "Votre image ne comporte pas l'extension .jpg"; |
| 216 | 206 | $this->erreur = $err; |
| 217 | - } |
|
| 218 | - else if(($infos_img[0] >= $width_max) && ($infos_img[1] >= $height_max) && ($_FILES['image']['size'] >= $max_size)) { |
|
| 207 | + } else if(($infos_img[0] >= $width_max) && ($infos_img[1] >= $height_max) && ($_FILES['image']['size'] >= $max_size)) { |
|
| 219 | 208 | $err = "Problème dans les dimensions ou taille de l\'image."; |
| 220 | 209 | $this->erreur = $err; |
| 221 | - } |
|
| 222 | - else { |
|
| 210 | + } else { |
|
| 223 | 211 | $uniqid = uniqid(); |
| 224 | 212 | $chemin_destination = '../images/profil/'; |
| 225 | 213 | if(substr($image, -3) == ($extension)) { |
| 226 | 214 | move_uploaded_file($_FILES['image']['tmp_name'], $chemin_destination.$uniqid.".jpg"); |
| 227 | 215 | $imageok = $uniqid.".jpg"; |
| 228 | - } |
|
| 229 | - else if(substr($image, -3) == ($extension2)) { |
|
| 216 | + } else if(substr($image, -3) == ($extension2)) { |
|
| 230 | 217 | move_uploaded_file($_FILES['image']['tmp_name'], $chemin_destination.$uniqid.".png"); |
| 231 | 218 | $imageok = $uniqid.".png"; |
| 232 | - } |
|
| 233 | - else if(substr($image, -3) == ($extension3)) { |
|
| 219 | + } else if(substr($image, -3) == ($extension3)) { |
|
| 234 | 220 | move_uploaded_file($_FILES['image']['tmp_name'], $chemin_destination.$uniqid.".jpeg"); |
| 235 | 221 | $imageok = $uniqid.".jpeg"; |
| 236 | - } |
|
| 237 | - else { |
|
| 222 | + } else { |
|
| 238 | 223 | move_uploaded_file($_FILES['image']['tmp_name'], $chemin_destination.$uniqid.".gif"); |
| 239 | 224 | $imageok = $uniqid.".gif"; |
| 240 | 225 | } |
@@ -257,8 +242,7 @@ discard block |
||
| 257 | 242 | $oldimg_profil = explode("/", $oldimg_profil); |
| 258 | 243 | |
| 259 | 244 | if($oldimg_profil[7] == "defaut.png") { |
| 260 | - } |
|
| 261 | - else { |
|
| 245 | + } else { |
|
| 262 | 246 | unlink("../images/profil/".$oldimg_profil[7]); |
| 263 | 247 | } |
| 264 | 248 | } |
@@ -283,16 +267,13 @@ discard block |
||
| 283 | 267 | if ($lettre >= 'a' && $lettre <= 'z') { |
| 284 | 268 | $point = $point + 1; |
| 285 | 269 | $point_min = 1; |
| 286 | - } |
|
| 287 | - else if ($lettre >= 'A' && $lettre <= 'Z'){ |
|
| 270 | + } else if ($lettre >= 'A' && $lettre <= 'Z'){ |
|
| 288 | 271 | $point = $point + 2; |
| 289 | 272 | $point_maj = 2; |
| 290 | - } |
|
| 291 | - else if ($lettre >= '0' && $lettre <= '9'){ |
|
| 273 | + } else if ($lettre >= '0' && $lettre <= '9'){ |
|
| 292 | 274 | $point = $point + 3; |
| 293 | 275 | $point_chiffre = 3; |
| 294 | - } |
|
| 295 | - else { |
|
| 276 | + } else { |
|
| 296 | 277 | $point = $point + 5; |
| 297 | 278 | $point_caracteres = 5; |
| 298 | 279 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
| 55 | 55 | /** |
| 56 | - * @return bool |
|
| 56 | + * @return boolean|null |
|
| 57 | 57 | * fonction verifie en bdd si on a déjà enregistrer le fichier en cache |
| 58 | 58 | * si il ne l'est pas on le met, et si il y est et que reload cache == 0 on prend le fichier qui est en cache |
| 59 | 59 | * sinon soit on update la bdd et on refait un cache soit on crée tout |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | - * @param $contenu_fichier |
|
| 135 | + * @param string $contenu_fichier |
|
| 136 | 136 | * fonction qui met en cache le contenu du fichier enregistrer dans le ob |
| 137 | 137 | */ |
| 138 | 138 | private function setCache($contenu_fichier) { |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | //-------------------------- CONSTRUCTEUR ----------------------------------------------------------------------------// |
| 18 | - public function __construct($page, $admin=null) { |
|
| 18 | + public function __construct($page, $admin = null) { |
|
| 19 | 19 | $config = new Configuration(); |
| 20 | 20 | |
| 21 | 21 | //on test si le cache est bien active |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | if ($admin == null) { |
| 37 | - $this->dossier_cache = ROOT."cache/app/"; |
|
| 37 | + $this->dossier_cache = ROOT."cache/app/"; |
|
| 38 | 38 | } |
| 39 | 39 | else { |
| 40 | - $this->dossier_cache = ROOT."cache/admin/"; |
|
| 40 | + $this->dossier_cache = ROOT."cache/admin/"; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $page = ChaineCaractere::setUrl($page); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * fonction qui met en cache le contenu du fichier enregistrer dans le ob |
| 137 | 137 | */ |
| 138 | 138 | private function setCache($contenu_fichier) { |
| 139 | - $dbc= App::getDb(); |
|
| 139 | + $dbc = App::getDb(); |
|
| 140 | 140 | |
| 141 | 141 | $fichier_cache = $this->chemin_cache; |
| 142 | 142 | |
@@ -28,15 +28,13 @@ discard block |
||
| 28 | 28 | mkdir(ROOT."cache/admin"); |
| 29 | 29 | mkdir(ROOT."cache/app"); |
| 30 | 30 | } |
| 31 | - } |
|
| 32 | - else { |
|
| 31 | + } else { |
|
| 33 | 32 | $this->cache_active = 0; |
| 34 | 33 | } |
| 35 | 34 | |
| 36 | 35 | if ($admin == null) { |
| 37 | 36 | $this->dossier_cache = ROOT."cache/app/"; |
| 38 | - } |
|
| 39 | - else { |
|
| 37 | + } else { |
|
| 40 | 38 | $this->dossier_cache = ROOT."cache/admin/"; |
| 41 | 39 | } |
| 42 | 40 | |
@@ -69,8 +67,7 @@ discard block |
||
| 69 | 67 | $reload_cache = $obj->reload_cache; |
| 70 | 68 | $this->no_cache = $obj->no_cache; |
| 71 | 69 | } |
| 72 | - } |
|
| 73 | - else { |
|
| 70 | + } else { |
|
| 74 | 71 | $value = [ |
| 75 | 72 | "nom_fichier" => $this->page, |
| 76 | 73 | "reload_cache" => 0 |
@@ -101,16 +98,14 @@ discard block |
||
| 101 | 98 | require_once($this->chemin_cache); |
| 102 | 99 | |
| 103 | 100 | return true; |
| 104 | - } |
|
| 105 | - else { |
|
| 101 | + } else { |
|
| 106 | 102 | if ($this->no_cache == null) { |
| 107 | 103 | ob_start(); |
| 108 | 104 | } |
| 109 | 105 | |
| 110 | 106 | return false; |
| 111 | 107 | } |
| 112 | - } |
|
| 113 | - else { |
|
| 108 | + } else { |
|
| 114 | 109 | return false; |
| 115 | 110 | } |
| 116 | 111 | } |
@@ -59,6 +59,10 @@ |
||
| 59 | 59 | public function getNomSite(){ |
| 60 | 60 | return $this->nom_site; |
| 61 | 61 | } |
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * @return string|null |
|
| 65 | + */ |
|
| 62 | 66 | public function getMailSite(){ |
| 63 | 67 | return $this->mail_site; |
| 64 | 68 | } |
@@ -2,8 +2,6 @@ |
||
| 2 | 2 | namespace core; |
| 3 | 3 | |
| 4 | 4 | |
| 5 | - use core\HTML\flashmessage\FlashMessage; |
|
| 6 | - |
|
| 7 | 5 | class Configuration { |
| 8 | 6 | //pour la configuration générale du site |
| 9 | 7 | private $nom_site; //-> nom du site |
@@ -1,16 +1,16 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | - namespace core; |
|
| 2 | + namespace core; |
|
| 3 | 3 | |
| 4 | 4 | |
| 5 | - use core\HTML\flashmessage\FlashMessage; |
|
| 5 | + use core\HTML\flashmessage\FlashMessage; |
|
| 6 | 6 | |
| 7 | 7 | class Configuration { |
| 8 | 8 | //pour la configuration générale du site |
| 9 | - private $nom_site; //-> nom du site |
|
| 10 | - private $mail_site; //-> pour le gérant du site contact@nomdedomaine;com |
|
| 11 | - private $gerant_site; //->nom du gérant du site |
|
| 12 | - private $url_site; //-> url de site |
|
| 13 | - private $mail_administrateur; //-> mail de l'administrateur [email protected] |
|
| 9 | + private $nom_site; //-> nom du site |
|
| 10 | + private $mail_site; //-> pour le gérant du site contact@nomdedomaine;com |
|
| 11 | + private $gerant_site; //->nom du gérant du site |
|
| 12 | + private $url_site; //-> url de site |
|
| 13 | + private $mail_administrateur; //-> mail de l'administrateur [email protected] |
|
| 14 | 14 | private $last_save; //-> derniere sauvegarde de la bdd |
| 15 | 15 | private $acces_admin; //-> si == 1 on a acces à l'admin |
| 16 | 16 | private $contenu_dynamique; //->savoir si es contenus sont dynamique (stockés in DB) |
@@ -23,24 +23,24 @@ discard block |
||
| 23 | 23 | private $activer_connexion; |
| 24 | 24 | |
| 25 | 25 | |
| 26 | - //-------------------------- CONSTRUCTEUR ----------------------------------------------------------------------------// |
|
| 27 | - public function __construct() { |
|
| 28 | - $dbc = \core\App::getDb(); |
|
| 26 | + //-------------------------- CONSTRUCTEUR ----------------------------------------------------------------------------// |
|
| 27 | + public function __construct() { |
|
| 28 | + $dbc = \core\App::getDb(); |
|
| 29 | 29 | |
| 30 | 30 | //pour la configuration générale du site |
| 31 | - $query = $dbc->query("SELECT * FROM configuration WHERE ID_configuration=1"); |
|
| 32 | - foreach ($query as $obj) { |
|
| 33 | - $this->nom_site = $obj->nom_site; |
|
| 34 | - $this->mail_site = $obj->mail_site; |
|
| 35 | - $this->gerant_site = $obj->gerant_site; |
|
| 36 | - $this->url_site = $obj->url_site; |
|
| 37 | - $this->mail_administrateur = $obj->mail_administrateur; |
|
| 38 | - $this->last_save = $obj->last_save; |
|
| 31 | + $query = $dbc->query("SELECT * FROM configuration WHERE ID_configuration=1"); |
|
| 32 | + foreach ($query as $obj) { |
|
| 33 | + $this->nom_site = $obj->nom_site; |
|
| 34 | + $this->mail_site = $obj->mail_site; |
|
| 35 | + $this->gerant_site = $obj->gerant_site; |
|
| 36 | + $this->url_site = $obj->url_site; |
|
| 37 | + $this->mail_administrateur = $obj->mail_administrateur; |
|
| 38 | + $this->last_save = $obj->last_save; |
|
| 39 | 39 | $this->acces_admin = $obj->acces_admin; |
| 40 | 40 | $this->contenu_dynamique = $obj->contenu_dynamique; |
| 41 | 41 | $this->responsive = $obj->responsive; |
| 42 | 42 | $this->cache = $obj->cache; |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | //pour la configuration des comptes |
| 46 | 46 | $query = $dbc->query("SELECT * FROM configuration_compte WHERE ID_configuration_compte=1"); |
@@ -49,31 +49,31 @@ discard block |
||
| 49 | 49 | $this->activer_inscription = $obj->activer_inscription; |
| 50 | 50 | $this->activer_connexion = $obj->activer_connexion; |
| 51 | 51 | } |
| 52 | - } |
|
| 53 | - //-------------------------- FIN CONSTRUCTEUR ----------------------------------------------------------------------------// |
|
| 52 | + } |
|
| 53 | + //-------------------------- FIN CONSTRUCTEUR ----------------------------------------------------------------------------// |
|
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | |
| 57 | - //-------------------------- GETTER ----------------------------------------------------------------------------// |
|
| 57 | + //-------------------------- GETTER ----------------------------------------------------------------------------// |
|
| 58 | 58 | //pour la configuration générale du site |
| 59 | - public function getNomSite(){ |
|
| 60 | - return $this->nom_site; |
|
| 61 | - } |
|
| 62 | - public function getMailSite(){ |
|
| 63 | - return $this->mail_site; |
|
| 64 | - } |
|
| 65 | - public function getGerantSite(){ |
|
| 66 | - return $this->gerant_site; |
|
| 67 | - } |
|
| 68 | - public function getUrlSite(){ |
|
| 69 | - return $this->url_site; |
|
| 70 | - } |
|
| 71 | - public function getMailAdministrateur(){ |
|
| 72 | - return $this->mail_administrateur; |
|
| 73 | - } |
|
| 74 | - public function getLastSave(){ |
|
| 75 | - return $this->last_save; |
|
| 76 | - } |
|
| 59 | + public function getNomSite(){ |
|
| 60 | + return $this->nom_site; |
|
| 61 | + } |
|
| 62 | + public function getMailSite(){ |
|
| 63 | + return $this->mail_site; |
|
| 64 | + } |
|
| 65 | + public function getGerantSite(){ |
|
| 66 | + return $this->gerant_site; |
|
| 67 | + } |
|
| 68 | + public function getUrlSite(){ |
|
| 69 | + return $this->url_site; |
|
| 70 | + } |
|
| 71 | + public function getMailAdministrateur(){ |
|
| 72 | + return $this->mail_administrateur; |
|
| 73 | + } |
|
| 74 | + public function getLastSave(){ |
|
| 75 | + return $this->last_save; |
|
| 76 | + } |
|
| 77 | 77 | public function getAccesAdmin() { |
| 78 | 78 | return $this->acces_admin; |
| 79 | 79 | } |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | public function getActiverConnexion() { |
| 98 | 98 | return $this->activer_connexion; |
| 99 | 99 | } |
| 100 | - //-------------------------- FIN GETTER ----------------------------------------------------------------------------// |
|
| 100 | + //-------------------------- FIN GETTER ----------------------------------------------------------------------------// |
|
| 101 | 101 | |
| 102 | 102 | |
| 103 | 103 | |
| 104 | - //-------------------------- SETTER ----------------------------------------------------------------------------// |
|
| 104 | + //-------------------------- SETTER ----------------------------------------------------------------------------// |
|
| 105 | 105 | /** |
| 106 | 106 | * fonction qui permet de mettre à jour la date de la derniere save de la bdd |
| 107 | 107 | * + supprimer la sauverde ancienne d'il y a 1 mois |
@@ -125,5 +125,5 @@ discard block |
||
| 125 | 125 | unlink(ROOT."bdd_backup/".$nom_save); |
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | - //-------------------------- FIN SETTER ----------------------------------------------------------------------------// |
|
| 129 | - } |
|
| 130 | 128 | \ No newline at end of file |
| 129 | + //-------------------------- FIN SETTER ----------------------------------------------------------------------------// |
|
| 130 | + } |
|
| 131 | 131 | \ No newline at end of file |
@@ -56,22 +56,22 @@ |
||
| 56 | 56 | |
| 57 | 57 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
| 58 | 58 | //pour la configuration générale du site |
| 59 | - public function getNomSite(){ |
|
| 59 | + public function getNomSite() { |
|
| 60 | 60 | return $this->nom_site; |
| 61 | 61 | } |
| 62 | - public function getMailSite(){ |
|
| 62 | + public function getMailSite() { |
|
| 63 | 63 | return $this->mail_site; |
| 64 | 64 | } |
| 65 | - public function getGerantSite(){ |
|
| 65 | + public function getGerantSite() { |
|
| 66 | 66 | return $this->gerant_site; |
| 67 | 67 | } |
| 68 | - public function getUrlSite(){ |
|
| 68 | + public function getUrlSite() { |
|
| 69 | 69 | return $this->url_site; |
| 70 | 70 | } |
| 71 | - public function getMailAdministrateur(){ |
|
| 71 | + public function getMailAdministrateur() { |
|
| 72 | 72 | return $this->mail_administrateur; |
| 73 | 73 | } |
| 74 | - public function getLastSave(){ |
|
| 74 | + public function getLastSave() { |
|
| 75 | 75 | return $this->last_save; |
| 76 | 76 | } |
| 77 | 77 | public function getAccesAdmin() { |
@@ -1,7 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace core\contenus; |
| 3 | 3 | |
| 4 | - use core\functions\ChaineCaractere; |
|
| 5 | 4 | use core\RedirectError; |
| 6 | 5 | |
| 7 | 6 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | //-------------------------- CONSTRUCTEUR ----------------------------------------------------------------------------// |
| 21 | - public function __construct($init_all=0) { |
|
| 21 | + public function __construct($init_all = 0) { |
|
| 22 | 22 | $dbc = \core\App::getDb(); |
| 23 | 23 | |
| 24 | 24 | if ($init_all == 1) { |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * pour récupérer l'en tete d'une page (balise title ++ meta description) |
| 72 | 72 | * @param $id_page |
| 73 | 73 | */ |
| 74 | - public function getHeadPage($id_page, $url=null) { |
|
| 74 | + public function getHeadPage($id_page, $url = null) { |
|
| 75 | 75 | $dbc = \core\App::getDb(); |
| 76 | 76 | |
| 77 | 77 | if ($id_page != 0) { |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * pour récupérer une page en particulier |
| 95 | 95 | * @param $id_page |
| 96 | 96 | */ |
| 97 | - public function getContenuPage($id_page=null) { |
|
| 97 | + public function getContenuPage($id_page = null) { |
|
| 98 | 98 | $dbc = \core\App::getDb(); |
| 99 | 99 | |
| 100 | 100 | if ($id_page == null) { |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | |
| 122 | 122 | //-------------------------- SETTER ----------------------------------------------------------------------------// |
| 123 | - protected function setMenu($id_page, $titre, $balise_title, $url, $parent ){ |
|
| 123 | + protected function setMenu($id_page, $titre, $balise_title, $url, $parent) { |
|
| 124 | 124 | $this->id_page = $id_page; |
| 125 | 125 | $this->titre = $titre; |
| 126 | 126 | $this->balise_title = $balise_title; |
@@ -76,8 +76,7 @@ |
||
| 76 | 76 | |
| 77 | 77 | if ($id_page != 0) { |
| 78 | 78 | $query = $dbc->query("SELECT balise_title, meta_description, ID_page FROM page WHERE ID_page=".$id_page); |
| 79 | - } |
|
| 80 | - else { |
|
| 79 | + } else { |
|
| 81 | 80 | $query = $dbc->query("SELECT balise_title, meta_description, ID_page FROM page WHERE url LIKE '$url'"); |
| 82 | 81 | } |
| 83 | 82 | |
@@ -95,7 +95,7 @@ |
||
| 95 | 95 | * @param $table |
| 96 | 96 | * @param $champ |
| 97 | 97 | * @param $value |
| 98 | - * @return bool |
|
| 98 | + * @return boolean|null |
|
| 99 | 99 | */ |
| 100 | 100 | public function rechercherEgalite($table, $champ, $value, $id_table=null, $id=null) { |
| 101 | 101 | if ($id == null) { |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @param $req -> la req a executer |
| 63 | 63 | * @param $value -> le ou les tableaux de valeurs |
| 64 | 64 | */ |
| 65 | - public function prepare($req, $value=null) { |
|
| 65 | + public function prepare($req, $value = null) { |
|
| 66 | 66 | //si pas de donnees |
| 67 | 67 | if ($value === null) { |
| 68 | 68 | $this->getPdo()->query($req); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @param $value |
| 98 | 98 | * @return bool |
| 99 | 99 | */ |
| 100 | - public function rechercherEgalite($table, $champ, $value, $id_table=null, $id=null) { |
|
| 100 | + public function rechercherEgalite($table, $champ, $value, $id_table = null, $id = null) { |
|
| 101 | 101 | if ($id == null) { |
| 102 | 102 | $query = $this->getPdo()->query("SELECT COUNT($champ) as nb FROM $table WHERE $champ LIKE '$value'"); |
| 103 | 103 | } |
@@ -51,8 +51,7 @@ discard block |
||
| 51 | 51 | if ($query) { |
| 52 | 52 | $obj = $query->fetchAll(PDO::FETCH_OBJ); |
| 53 | 53 | return $obj; |
| 54 | - } |
|
| 55 | - else { |
|
| 54 | + } else { |
|
| 56 | 55 | FlashMessage::setFlash("Une erreur est survenue en executant cette requette : ".$req); |
| 57 | 56 | } |
| 58 | 57 | } |
@@ -66,8 +65,7 @@ discard block |
||
| 66 | 65 | //si pas de donnees |
| 67 | 66 | if ($value === null) { |
| 68 | 67 | $this->getPdo()->query($req); |
| 69 | - } |
|
| 70 | - else { |
|
| 68 | + } else { |
|
| 71 | 69 | $query = $this->getPdo()->prepare($req); |
| 72 | 70 | //si on a plusieurs tableaux |
| 73 | 71 | if (array_key_exists(0, $value)) { |
@@ -76,8 +74,7 @@ discard block |
||
| 76 | 74 | $err = true; |
| 77 | 75 | } |
| 78 | 76 | } |
| 79 | - } |
|
| 80 | - else { |
|
| 77 | + } else { |
|
| 81 | 78 | if (!$query->execute($value)) { |
| 82 | 79 | $err = true; |
| 83 | 80 | } |
@@ -100,8 +97,7 @@ discard block |
||
| 100 | 97 | public function rechercherEgalite($table, $champ, $value, $id_table=null, $id=null) { |
| 101 | 98 | if ($id == null) { |
| 102 | 99 | $query = $this->getPdo()->query("SELECT COUNT($champ) as nb FROM $table WHERE $champ LIKE '$value'"); |
| 103 | - } |
|
| 104 | - else { |
|
| 100 | + } else { |
|
| 105 | 101 | $query = $this->getPdo()->query("SELECT COUNT($champ) as nb FROM $table WHERE $champ LIKE '$value' AND $id_table != $id"); |
| 106 | 102 | } |
| 107 | 103 | |
@@ -109,7 +105,9 @@ discard block |
||
| 109 | 105 | $nb = $obj["nb"]; |
| 110 | 106 | } |
| 111 | 107 | |
| 112 | - if ($nb == 1) return true; |
|
| 108 | + if ($nb == 1) { |
|
| 109 | + return true; |
|
| 110 | + } |
|
| 113 | 111 | } |
| 114 | 112 | //-------------------------- FIN FUNCTION QUI FONT DES REQUETES SUR LA BDD --------------------------------------------// |
| 115 | 113 | |
@@ -124,8 +122,7 @@ discard block |
||
| 124 | 122 | |
| 125 | 123 | if ($query->rowCount() > 0) { |
| 126 | 124 | return true; |
| 127 | - } |
|
| 128 | - else { |
|
| 125 | + } else { |
|
| 129 | 126 | return false; |
| 130 | 127 | } |
| 131 | 128 | } |