Bonjour à tous
Alors après mainte tentative avec un membre sur un forum, nous avons tenter de créé un éditeur de texte (comme sur ce site d'ailleurs) et je dois avouer que je bloque
Alors voici d'abord mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 
<?php function parseCode($content){$zcode = array( '`&lt;italique&gt;(.+)&lt;/italique&gt;`isU',
                                                 '`&lt;souligne&gt;(.+)&lt;/souligne&gt;`isU',		
		                                         '`&lt;gras&gt;(.+)&lt;/gras&gt;`isU',
		                                         '`&lt;barre&gt;(.+)&lt;/barre&gt;`isU',
		                                         '`&lt;lien&gt;(.+)&lt;/lien&gt;`isU',
		                                         '`&lt;lien url=&quot;(.+)&quot;&gt;(.+)&lt;/lien&gt;`isU',
		                                         '`&lt;taille valeur=&quot;(.+)&quot;&gt;(.+)&lt;/taille&gt;`isU',
		                                         '`&lt;police valeur=&quot;(.+)&quot;&gt;(.+)&lt;/police&gt;`isU',
		                                         '`&lt;jaune&gt;(.+)&lt;/jaune&gt;`isU', '`&lt;bleu-c&gt;(.+)&lt;/bleu-c&gt;`isU',
		                                         '`&lt;bleu-f&gt;(.+)&lt;/bleu-f&gt;`isU', '`&lt;vert-p&gt;(.+)&lt;/vert-p&gt;`isU',
		                                         '`&lt;vert-f&gt;(.+)&lt;/vert-f&gt;`isU', '`&lt;rose&gt;(.+)&lt;/rose&gt;`isU',
		                                         '`&lt;rouge&gt;(.+)&lt;/rouge&gt;`isU', '`&lt;marron&gt;(.+)&lt;/marron&gt;`isU',
		                                         '`&lt;noir&gt;(.+)&lt;/noir&gt;`isU', '`&lt;blanc&gt;(.+)&lt;/blanc&gt;`isU',);  
 
	                              $html = array( '<em>$1</em>', 
					'<U>$1</U>',		
					'<strong>$1</strong>',
					'<del>$1</del>', 
					'<a href="$1">$1</a>',
					'<a href="$1">$2</a>',
					'<span style="font-size:$1;">$2</span>',
					'<span style="font-family:$1;">$2</span>',
					'<span style="color:yellow;">$1</span>',
					'<span style="color:Cyan;">$1</span>',
					'<span style="color:Blue;">$1</span>',
					'<span style="color:#00FF00;">$1</span>',
					'<span style="color:#228B22;">$1</span>',
					'<span style="color:Magenta;">$1</span>',
					'<span style="color:red;">$1</span>',
					'<span style="color:#8B4513;">$1</span>',
					'<span style="color:Black;">$1</span>',
					'<span style="color:white;">$1</span>',); 
 
	$content = htmlspecialchars($content, ENT_QUOTES);
	$content = preg_replace($zcode, $html, $content);
	$content = preg_replace('`\<image>(.+(?<!\.php|\.php3|\.phtml)\.(?:png|jpg|jpeg|gif))\</image>`isU', '<img src="$1" alt="image" />', $content);
 
	$smiliesName = array('\\^\\^', ':oups:', ':D', ':P', '8-\\)', 'o_o', ':bad:', ':clown:', ':\\(', '&gt;\'&lt;', 'cool', 'x_x', '\\(d\\)', ':go:', 'tcool', 'fuck', 'light', 'jap', 'lol', ':love:', '&lt;3', ':slove:', 'mdr', ':na:', ':/', ':out:', 'ptdr', ':ssmile:', 'T_T', '&lt;/3', 'warn', ';\\)', ';D', ':oui:', ':non:', ':yipi:', 'zzz', ':cam:', ':bravo:', 'bisoux', ':beurk:', '=O', ':\'\\(', ':cadeau:', ':\\)', '\\(a\\)', 'o:\\)', '&gt;&lt;', ':boulet:', ':fouet:');
	$smiliesUrl  = array('ct.gif', 'oups.gif', 'souriant.gif', 'langue.gif', 'ttcool.gif', 'imp.gif', 'bad.gif', 'clown.gif', 'pct.gif', 'supernerf.gif', 'cool.gif', 'out.gif', 'diable1.gif', 'go.gif', 'tcool.gif', 'fuck1.gif', 'light.gif', 'jap.gif', 'lol.gif', 'love.gif', 'coeur.gif', 'slove.gif', 'mdr.gif', 'na.gif', 'contra.gif', 'out2.gif', 'ptdr.gif', 'ssmile.gif', 'pleure.gif', 'ncoeur.gif', 'warn.gif', 'clo.gif', 'sclo.gif', 'oui.gif', 'non.gif', 'yipi.gif', 'zzz.gif', 'cam.gif', 'bravo.gif', 'bisoux.gif', 'beurk.gif', 'Han.gif', 'snif.gif', 'cadeau.gif', 'ct2.gif', 'ange.gif', 'ange2.gif', 'nerf.gif', 'boulet.gif', 'fouet.gif');
	$smiliesPath = "http://localhost/Lifenet/Image/smiley/";
 
	for ($i = 0, $c = count($smiliesName); $i < $c; $i++) { $content = preg_replace('`' . $smiliesName[$i] . '`isU', '<img src="' . $smiliesPath . $smiliesUrl[$i] . '" />', $content);}
	$content = preg_replace('`\n`isU', '<br />', $content);
	return $content;
} ?>
		<?php try { $bdd = new PDO('mysql:host=localhost;dbname=lifenet','root',''); }
                   catch(Exception $e){die('Erreur :'.$e->getMessage());}
	       if(empty($_GET['page'])){$id = 0;}
		   else{$id = ($_GET['page'] - 1)*3;}
	            $reponse = $bdd->query('SELECT id,contenu,DATE_FORMAT(date_creation,\'Le %d/%m/%Y Ã* %Hh%imin%ss\') AS date_creation_fr FROM billets ORDER BY id  DESC LIMIT '.$id.',5');
		   while($donnees = $reponse->fetch()) { ?>
           <div class="news">
           <p> <?php echo parseCode($donnees['contenu']);?>
				   <br/></br>
                   <a class="actu" href = "commentaires.php?billet_1=<?php echo htmlspecialchars($donnees['id']);?>"><em>Commentaires</em></a>
                   <em style="font-size:10px; float:right;"><?php echo htmlspecialchars($donnees['date_creation_fr']);?></em>
                </p></div></br>
        <?php } ?>
C'est au moment d'enregistrer le code puis de l'afficher qui pose problème...
Dans ma news test sur mon forum je devrais tomber sur ça : Test numéro 10 (de police impact aussi).
Malheureusement, je tombe sur ça : <rouge><police valeur="Impact">Test numéro 10</police></rouge>