Vous êtes connecté en tant que anonymous Se Deconnecter
Browse code

ajout de la lib Encoding et mise en place de la class caracter du projet VLAN

FIXME: appel curl ou fopen d'une methode http depuis une action ou un controlleur.

TODO: sécuriser les accès HTTP1.1 par un fichier config similaire a l'applet Discourse faite pour Tinternet

TODO: ajouter un plug-in symfony permettant de charger un utilisateur dans les apps a partir de l'authentification multiple

TODO: lire les documentation officielles provenant des 4 plate-formes tranquillement afin de comprendre commet doit on tester ces type d'auth quitte a créé un sous domaine particulier directement hebergé sur gittea
-->Sécuriser le serveur de dev

Emmanuel ROY authored on 04/12/2019 15:52:04
Showing 6 changed files
... ...
@@ -11,6 +11,7 @@
11 11
       <excludeFolder url="file://$MODULE_DIR$/vendor/illuminate/filesystem" />
12 12
       <excludeFolder url="file://$MODULE_DIR$/vendor/illuminate/support" />
13 13
       <excludeFolder url="file://$MODULE_DIR$/vendor/illuminate/view" />
14
+      <excludeFolder url="file://$MODULE_DIR$/vendor/neitanod/forceutf8" />
14 15
       <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/finder" />
15 16
       <excludeFolder url="file://$MODULE_DIR$/vendor/windwalker/renderer" />
16 17
       <excludeFolder url="file://$MODULE_DIR$/vendor/windwalker/structure" />
... ...
@@ -12,6 +12,7 @@
12 12
       <path value="$PROJECT_DIR$/vendor/symfony/finder" />
13 13
       <path value="$PROJECT_DIR$/vendor/windwalker/structure" />
14 14
       <path value="$PROJECT_DIR$/vendor/hybridauth/hybridauth" />
15
+      <path value="$PROJECT_DIR$/vendor/neitanod/forceutf8" />
15 16
     </include_path>
16 17
   </component>
17 18
   <component name="PhpProjectSharedConfiguration" php_language_level="7.1" />
... ...
@@ -11,12 +11,12 @@ class Bdd
11 11
         switch($bdd) {
12 12
             case 'bdd1':
13 13
                 $this->bdd = new PDO(DSN_BDD1, USER_BDD1, PASS_BDD1);
14
-            break;
14
+                break;
15 15
             case 'bdd2':
16 16
                 $this->bdd = new PDO(DSN_BDD2, USER_BDD2, PASS_BDD2);
17
-            break;
17
+                break;
18 18
             default:
19
-                $this->bdd = new PDO(DSN_FICHES, USER_FICHES, PASS_FICHES);
19
+                $this->bdd = new PDO(DSN_BDD_DEFAULT, USER_BDD_DEFAULT, PASS_BDD_DEFAULT);
20 20
         }
21 21
     }
22 22
 
... ...
@@ -30,6 +30,9 @@ class Bdd
30 30
 
31 31
         $tab = array();
32 32
         foreach($res as $key => $row){
33
+            if (is_string($row)) {
34
+                $row = Caracter::normalise_ChaineDeCaracteresDownload($row);
35
+            }
33 36
             $tab[$key] = $row;
34 37
         }
35 38
         return $tab;
36 39
new file mode 100644
... ...
@@ -0,0 +1,80 @@
1
+<?php
2
+
3
+
4
+namespace MVC\Classe;
5
+
6
+
7
+use ForceUTF8\Encoding;
8
+
9
+class Caracter
10
+{
11
+
12
+    public static function normalise_ChaineDeCaracteresDownload($chaine)
13
+    {
14
+        //return Caracter::remplacerAccents($chaine);
15
+        return Encoding::fixUTF8(Caracter::fp_stripslashes($chaine));
16
+    }
17
+
18
+    public static function fp_stripslashes($str)
19
+    {
20
+        if (get_magic_quotes_gpc() == 1) {
21
+            return stripslashes($str);
22
+        } else {
23
+            return $str;
24
+        }
25
+    }
26
+
27
+    public static function normalise_ChaineDeCaracteresUpload($chaine)
28
+    {
29
+        return Caracter::fp_addslashes(Encoding::fixUTF8($chaine));
30
+    }
31
+
32
+    public static function fp_addslashes($str)
33
+    {
34
+        if (get_magic_quotes_gpc() == 1) {
35
+            return $str;
36
+        } else {
37
+            return addslashes($str);
38
+        }
39
+    }
40
+
41
+    public static function remplacerAccents($chaine)
42
+    {
43
+        $chaine = str_replace('é', '&eacute;', $chaine);
44
+        $chaine = str_replace('è', '&egrave;', $chaine);
45
+        $chaine = str_replace('ë', '&euml;', $chaine);
46
+        $chaine = str_replace('ê', '&ecirc;', $chaine);
47
+        $chaine = str_replace('ç', '&ccedil;', $chaine);
48
+        $chaine = str_replace('Ç', '&Ccedil;', $chaine);
49
+        $chaine = str_replace('à', '&agrave;', $chaine);
50
+        // $chaine = str_replace('','&aeacute;',$chaine);
51
+        $chaine = str_replace('â', '&circ;', $chaine);
52
+        $chaine = str_replace('ä', '&uml;', $chaine);
53
+        $chaine = str_replace('î', '&icirc;', $chaine);
54
+        $chaine = str_replace('ï', '&iuml;', $chaine);
55
+        $chaine = str_replace('ù', '&ugrave;', $chaine);
56
+        $chaine = str_replace('û', '&ucirc;', $chaine);
57
+        $chaine = str_replace('ü', '&uuml;', $chaine);
58
+        $chaine = str_replace('É', '&Eacute;', $chaine);
59
+        $chaine = str_replace('Ê', '&Ecirc;', $chaine);
60
+        $chaine = str_replace('È', '&Egrave;', $chaine);
61
+        $chaine = str_replace('Ë', '&Euml;', $chaine);
62
+        $chaine = str_replace('À', '&Agrave;', $chaine);
63
+        // $chaine = str_replace('','&Aeacute;',$chaine);
64
+        $chaine = str_replace('Â', '&Acirc;', $chaine);
65
+        $chaine = str_replace('Ä', '&Auml;', $chaine);
66
+        $chaine = str_replace('Î', '&Icirc;', $chaine);
67
+        $chaine = str_replace('Ï', '&Iuml;', $chaine);
68
+        $chaine = str_replace('Ù', '&Ugrave;', $chaine);
69
+        $chaine = str_replace('Û', '&Ucirc;', $chaine);
70
+        $chaine = str_replace('Ü', '&Uuml;', $chaine);
71
+        return Caracter::remplacerGuillemets($chaine);
72
+    }
73
+
74
+    public static function remplacerGuillemets($chaine)
75
+    {
76
+        $chaine = str_replace("'", "&#39;", $chaine);
77
+        $chaine = str_replace('"', '&#34;', $chaine);
78
+        return $chaine;
79
+    }
80
+}
0 81
\ No newline at end of file
... ...
@@ -1,5 +1,10 @@
1 1
 <?php
2 2
 
3
+
4
+define('DSN_BDD_DEFAULT', "mysql:host=localhost;dbname=default");
5
+define('USER_BDD_DEFAULT', "user_default");
6
+define('PASS_BDD_DEFAULT', "pass_default");
7
+
3 8
 define('DSN_BDD1',"mysql:host=localhost;dbname=db1");
4 9
 define('USER_BDD1',"user1");
5 10
 define('PASS_BDD1',"pass1");
... ...
@@ -8,4 +13,4 @@ define('DSN_BDD2',"mysql:host=localhost;dbname=db2");
8 13
 define('USER_BDD2',"user2");
9 14
 define('PASS_BDD2',"pass2");
10 15
 
11
-define('PATH_URL',"http://vlan.localhost/");
12 16
\ No newline at end of file
17
+//define('PATH_URL',"http://localhost/");
13 18
\ No newline at end of file
... ...
@@ -16,6 +16,7 @@
16 16
       "ext-curl": "*",
17 17
         "windwalker/renderer": "3.*",
18 18
         "illuminate/view": "4.*",
19
-        "hybridauth/hybridauth": "~3.0"
19
+      "hybridauth/hybridauth": "~3.0",
20
+      "neitanod/forceutf8": "^2.0"
20 21
     }
21 22
 }