16
16
// You should have received a copy of the GNU Lesser General Public License
17
17
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
21
require_once("../inc/db.inc");
22
require_once("../inc/util.inc");
23
require_once('../inc/sanitize_html.inc');
20
require_once("../inc/util_ops.inc");
21
require_once('../inc/bbcode_convert.inc');
28
function image_as_bb($text){
29
// This function depends on sanitized HTML
31
$pattern = '@<img(.*) src=\"([^>^"]+)\"([^>]*)>@si';
32
$replacement = '[img]$2[/img]';
33
$text = preg_replace($pattern, $replacement, $text);
35
$pattern = "@<img(.*) src='([^>^']+)'([^>]*)>@si";
36
$replacement = '[img]$2[/img]';
37
$text = preg_replace($pattern, $replacement, $text);
42
function link_as_bb($text){
43
/* This function depends on sanitized HTML */
44
// Build some regex (should be a *lot* faster)
45
$pattern = '@<a href=\"([^>]+)\">@si'; // Gives us the URL in $1...
46
$replacement = '[url=$1]'; // Turns that URL into a hyperlink
47
$text = preg_replace($pattern, $replacement, $text);
48
$pattern = "@<a href='([^>]+)'>@si"; // Gives us the URL in $1...
49
$replacement = '[url=$1]'; // Turns that URL into a hyperlink
50
$text = preg_replace($pattern, $replacement, $text);
52
$pattern = "@</a>@si";
53
$replacement = '[/url]';
54
$text = preg_replace($pattern, $replacement, $text);
58
function formatting_as_bb($text){
59
/* This function depends on sanitized HTML */
60
$in[]="<b>";$out[]="[b]";
61
$in[]="</b>";$out[]="[/b]";
63
$in[]="<i>";$out[]="[i]";
64
$in[]="</i>";$out[]="[/i]";
66
$in[]="<u>";$out[]="[u]";
67
$in[]="</u>";$out[]="[/u]";
69
$in[]="<b>";$out[]="[b]";
70
$in[]="</b>";$out[]="[/b]";
72
$in[]="<ul>";$out[]="[list]";
73
$in[]="</ul>";$out[]="[/list]";
75
$in[]="<ol>";$out[]="[list=1]";
76
$in[]="</ol>";$out[]="[/list]";
78
$in[]="<pre>";$out[]="[pre]";
79
$in[]="</pre>";$out[]="[/pre]";
81
$in[]="</br>";$out[]="\n";
82
$in[]="<br/>";$out[]="\n";
83
$in[]="<br>";$out[]="\n";
84
$in[]=">";$out[]=">";
85
$in[]="<";$out[]="<";
86
$in[]="&";$out[]="&";
88
return str_replace($in, $out, $text);
91
function fix_text($text) {
92
$text = sanitize_html($text);
93
$text = image_as_bb($text);
94
$text = link_as_bb($text);
95
$text = formatting_as_bb($text);
99
27
function fix_forum_preferences($forum_preferences) {
100
$text = fix_text($forum_preferences->signature);
28
$text = html_to_bbcode($forum_preferences->signature);
101
29
if ($text != $forum_preferences->signature) {
102
30
$query = "update forum_preferences set signature = '".mysql_escape_string($text)."' where userid=".$forum_preferences->userid;
103
31
//echo "$forum_preferences->signature\n\n";