]> git.mxchange.org Git - friendica.git/blob - include/html2bbcode.php
pass vars via javascript, not html. Also fix broken pause img on IE
[friendica.git] / include / html2bbcode.php
1 <?php
2
3
4 function html2bbcode($s) {
5
6
7 // Tags to Find
8 $htmltags = array(
9                         '/\<b\>(.*?)\<\/b\>/is',
10                         '/\<i\>(.*?)\<\/i\>/is',
11                         '/\<u\>(.*?)\<\/u\>/is',
12                         '/\<ul\>(.*?)\<\/ul\>/is',
13                         '/\<li\>(.*?)\<\/li\>/is',
14                         '/\<img(.*?) src=\"(.*?)\" (.*?)\>/is',
15                         '/\<div(.*?)\>(.*?)\<\/div\>/is',
16                         '/\<br(.*?)\>/is',
17                         '/\<strong\>(.*?)\<\/strong\>/is',
18                         '/\<a href=\"(.*?)\"(.*?)\>(.*?)\<\/a\>/is',
19                         '/\<code\>(.*?)\<\/code\>/is',
20                         '/\<font color=(.*?)\>(.*?)\<\/font\>/is',
21                         '/\<font color=\"(.*?)\"\>(.*?)\<\/font\>/is',
22                         '/\<blockquote\>(.*?)\<\/blockquote\>/is',
23
24                         );
25
26 // Replace with
27 $bbtags = array(
28                         '[b]$1[/b]',
29                         '[i]$1[/i]',
30                         '[u]$1[/u]',
31                         '[list]$1[/list]',
32                         '[*]$1',
33                         '[img]$2[/img]',
34                         '$2',
35                         '\n',
36                         '[b]$1[/b]',
37                         '[url=$1]$3[/url]',
38                         '[code]$1[/code]',
39                         '[color="$1"]$2[/color]',
40                         '[color="$1"]$2[/color]',
41                         '[quote]$1[/quote]',
42                         );
43
44 // Replace $htmltags in $text with $bbtags
45 $text = preg_replace ($htmltags, $bbtags, $s);
46
47 // Strip all other HTML tags
48 $text = strip_tags($text);
49 return $text;
50 }