source: spip-zone/_plugins_/comments_phpbb/comments_phpbb_fonctions.php @ 59625

Last change on this file since 59625 was 59625, checked in by crichard@…, 9 years ago

Corrige le problème sur les dates des posts dans le forum phpbb

File size: 3.2 KB
Line 
1<?php
2if (!defined("_ECRIRE_INC_VERSION")) return;
3
4
5function datetime_mysql2unix($str) {
6        /// convert from MySQL to UNIX timestamp       
7        list($date, $time) = explode(' ', $str);
8        list($year, $month, $day) = explode('-', $date);
9        list($hour, $minute, $second) = explode(':', $time);
10
11        $timestamp = mktime((int)$hour, (int)$minute, (int)$second, (int)$month, (int)$day, (int)$year);
12
13        return $timestamp;
14}
15
16function datetime_unix2mysql($timestamp) {
17        /// convert from UNIX to MySQL timestamp
18        return date('Y-m-d H:i:s', $timestamp);
19}
20
21function bbcode($chaine) {
22/*
23 * Source originale : Plugin "Du BBCode dans SPIP
24 * http://plugins.spip.net/Du-BBcode-dans-SPIP
25 * Modifiée par David Dorchies http://dorch.fr 13/07/2009
26 */
27  $chaine = stripslashes($chaine);
28  $chaine = str_replace("[code]","<html><code>",$chaine);       
29  $chaine = str_replace("[/code]","</code></html>",$chaine);
30  $chaine = preg_replace("!\\[url\\]\\[img\\](.+)\\[/img\\]\\[/url\\]!Umi","<html><a href=\"\\1\" title=\"img\"><img src=\"\\1\" alt=\"img\"/></a></html>",$chaine);
31  $chaine = preg_replace("!\\[url=(.+)\\]\\[img\\](.+)\\[/img\\]\\[/url\\]!Umi","<html><a href=\"\\1\" title=\"img\"><img src=\"\\2\" alt=\"img\"/></a></html>",$chaine);
32  $chaine = preg_replace("!\\[url\\](.+)\\[/url\\]!Umi","<html><a href=\"\\1\" title=\"\\1\">\\1</a></html>",$chaine);
33  $chaine = preg_replace("!\\[url=(.+)\\](.+)\\[/url\\]!Umi","<html><a href=\"\\1\" title=\"\\2\">\\2</a></html>",$chaine);
34  $chaine = preg_replace("!\\[email\\](.+)\\[/email\\]!Umi","<html><a href=mailto:\"\\1\">\\1</a></html>",$chaine);
35  $chaine = preg_replace("!\\[email=(.+)\\](.+)\\[/email\\]!Umi","<html><a href=mailto:\"\\1\">\\2</a></html>",$chaine);
36  $chaine = preg_replace("!\\[color=(.+)\\](.+)\\[/color\\]!Umi","<html><span style=\"color:\\1\">\\2</span></html>",$chaine);
37  $chaine = preg_replace("!\\[size=(.+)\\](.+)\\[/size\\]!Umi","<html><span style=\"font-size:\\1px\">\\2</span></html>",$chaine);
38  $chaine = preg_replace("!\[list\](.+)\[/list\]!Umi","<html><ul> \\1 </ul></html>",$chaine);
39  $chaine = preg_replace("!\[list=1\](.+)\[/list\]!Umi","<html><ol> \\1 </ol></html>",$chaine); 
40  $chaine = preg_replace("!\[list=a\](.+)\[/list\]!Umi","<html><ol type='a'> \\1 </ol></html>",$chaine);
41  $chaine = preg_replace("!\[\*\](.+)(?=(\[\*\]|</ul>))!Umi","<li>\\1</li>",$chaine);
42  $chaine = preg_replace("!\\[b.*\\](.*)\\[/b.*\\]!Umi","{{\\1}}",$chaine);
43  $chaine = preg_replace("!\\[i.*\\](.*)\\[/i.*\\]!Umi","{\\1}",$chaine);
44  $chaine = preg_replace("!\\[u.*\\](.*)\\[/u.*\\]!Umi","<html><span style='text-decoration:underline;'>\\1</span></html>",$chaine);
45  $chaine = preg_replace("!\\[center.*\\](.*)\\[/center.*\\]!Umi","<html><center>\\1</center></html>",$chaine);
46  $chaine = preg_replace("!\\[img.*\\](.*)\\[/img.*\\]!Umi","<html><img src=\"\\1\" alt=\"img\" /></html>",$chaine);
47  $chaine = preg_replace("!\\[quote=\"(.*)\\\".*\\](.*)\\[/quote.*\\]!Umi","<html><quote>\\1 a &eacute;crit<br/>\\2</quote></html>",$chaine);
48  $chaine = preg_replace("!\\[quote.*\\](.*)\\[/quote.*\\]!Umi","<html><quote>\\1</quote></html>",$chaine);
49  $chaine = str_replace("[scroll]","<cadre>",$chaine); 
50  $chaine = str_replace("[/scroll]","</cadre>",$chaine);
51  $chaine = str_replace("\n","\n\n",$chaine);
52 
53  return propre($chaine);
54}
55
56?>
Note: See TracBrowser for help on using the repository browser.