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( '`<italique>(.+)</italique>`isU',
'`<souligne>(.+)</souligne>`isU',
'`<gras>(.+)</gras>`isU',
'`<barre>(.+)</barre>`isU',
'`<lien>(.+)</lien>`isU',
'`<lien url="(.+)">(.+)</lien>`isU',
'`<taille valeur="(.+)">(.+)</taille>`isU',
'`<police valeur="(.+)">(.+)</police>`isU',
'`<jaune>(.+)</jaune>`isU', '`<bleu-c>(.+)</bleu-c>`isU',
'`<bleu-f>(.+)</bleu-f>`isU', '`<vert-p>(.+)</vert-p>`isU',
'`<vert-f>(.+)</vert-f>`isU', '`<rose>(.+)</rose>`isU',
'`<rouge>(.+)</rouge>`isU', '`<marron>(.+)</marron>`isU',
'`<noir>(.+)</noir>`isU', '`<blanc>(.+)</blanc>`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:', ':\\(', '>\'<', 'cool', 'x_x', '\\(d\\)', ':go:', 'tcool', 'fuck', 'light', 'jap', 'lol', ':love:', '<3', ':slove:', 'mdr', ':na:', ':/', ':out:', 'ptdr', ':ssmile:', 'T_T', '</3', 'warn', ';\\)', ';D', ':oui:', ':non:', ':yipi:', 'zzz', ':cam:', ':bravo:', 'bisoux', ':beurk:', '=O', ':\'\\(', ':cadeau:', ':\\)', '\\(a\\)', 'o:\\)', '><', ':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 } ?> |
Partager