author | Dan |
Sun, 06 Apr 2008 00:28:50 -0400 | |
changeset 7 | 98bbc533541c |
child 10 | 98d80b672f3c |
permissions | -rw-r--r-- |
7
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
1 |
<?php |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
2 |
/*********************************************************************** |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
3 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
4 |
Copyright (C) 2002-2008 PunBB.org |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
5 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
6 |
This file is part of PunBB. |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
7 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
8 |
PunBB is free software; you can redistribute it and/or modify it |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
9 |
under the terms of the GNU General Public License as published |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
10 |
by the Free Software Foundation; either version 2 of the License, |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
11 |
or (at your option) any later version. |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
12 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
13 |
PunBB is distributed in the hope that it will be useful, but |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
14 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
16 |
GNU General Public License for more details. |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
17 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
18 |
You should have received a copy of the GNU General Public License |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
19 |
along with this program; if not, write to the Free Software |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
21 |
MA 02111-1307 USA |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
22 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
23 |
************************************************************************/ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
24 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
25 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
26 |
// Make sure no one attempts to run this script "directly" |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
27 |
if (!defined('PUN')) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
28 |
exit; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
29 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
30 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
31 |
// Here you can add additional smilies if you like (please note that you must escape singlequote and backslash) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
32 |
$smiley_text = array(':)', '=)', ':|', '=|', ':(', '=(', ':D', '=D', ':o', ':O', ';)', ':/', ':P', ':lol:', ':mad:', ':rolleyes:', ':cool:'); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
33 |
$smiley_img = array('smile.png', 'smile.png', 'neutral.png', 'neutral.png', 'sad.png', 'sad.png', 'big_smile.png', 'big_smile.png', 'yikes.png', 'yikes.png', 'wink.png', 'hmm.png', 'tongue.png', 'lol.png', 'mad.png', 'roll.png', 'cool.png'); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
34 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
35 |
// Uncomment the next row if you add smilies that contain any of the characters &"'<> |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
36 |
//$smiley_text = array_map('pun_htmlspecialchars', $smiley_text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
37 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
38 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
39 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
40 |
// Make sure all BBCodes are lower case and do a little cleanup |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
41 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
42 |
function preparse_bbcode($text, &$errors, $is_signature = false) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
43 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
44 |
// Change all simple BBCodes to lower case |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
45 |
$a = array('[B]', '[I]', '[U]', '[/B]', '[/I]', '[/U]'); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
46 |
$b = array('[b]', '[i]', '[u]', '[/b]', '[/i]', '[/u]'); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
47 |
$text = str_replace($a, $b, $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
48 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
49 |
// Do the more complex BBCodes (also strip excessive whitespace and useless quotes) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
50 |
$a = array( '#\[url=("|\'|)(.*?)\\1\]\s*#i', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
51 |
'#\[url\]\s*#i', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
52 |
'#\s*\[/url\]#i', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
53 |
'#\[email=("|\'|)(.*?)\\1\]\s*#i', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
54 |
'#\[email\]\s*#i', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
55 |
'#\s*\[/email\]#i', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
56 |
'#\[img\]\s*(.*?)\s*\[/img\]#is', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
57 |
'#\[colou?r=("|\'|)(.*?)\\1\](.*?)\[/colou?r\]#is'); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
58 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
59 |
$b = array( '[url=$2]', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
60 |
'[url]', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
61 |
'[/url]', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
62 |
'[email=$2]', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
63 |
'[email]', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
64 |
'[/email]', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
65 |
'[img]$1[/img]', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
66 |
'[color=$2]$3[/color]'); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
67 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
68 |
if (!$is_signature) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
69 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
70 |
// For non-signatures, we have to do the quote and code tags as well |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
71 |
$a[] = '#\[quote=("|"|\'|)(.*?)\\1\]\s*#i'; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
72 |
$a[] = '#\[quote\]\s*#i'; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
73 |
$a[] = '#\s*\[/quote\]\s*#i'; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
74 |
$a[] = '#\[code\][\r\n]*(.*?)\s*\[/code\]\s*#is'; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
75 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
76 |
$b[] = '[quote=$1$2$1]'; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
77 |
$b[] = '[quote]'; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
78 |
$b[] = '[/quote]'."\n"; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
79 |
$b[] = '[code]$1[/code]'."\n"; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
80 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
81 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
82 |
// Run this baby! |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
83 |
$text = preg_replace($a, $b, $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
84 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
85 |
if (!$is_signature) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
86 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
87 |
$overflow = check_tag_order($text, $error); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
88 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
89 |
if ($error) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
90 |
// A BBCode error was spotted in check_tag_order() |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
91 |
$errors[] = $error; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
92 |
else if ($overflow) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
93 |
// The quote depth level was too high, so we strip out the inner most quote(s) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
94 |
$text = substr($text, 0, $overflow[0]).substr($text, $overflow[1], (strlen($text) - $overflow[0])); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
95 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
96 |
else |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
97 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
98 |
global $lang_profile; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
99 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
100 |
if (preg_match('#\[quote=("|"|\'|)(.*)\\1\]|\[quote\]|\[/quote\]|\[code\]|\[/code\]#i', $text)) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
101 |
message($lang_profile['Signature quote/code']); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
102 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
103 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
104 |
return trim($text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
105 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
106 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
107 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
108 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
109 |
// Parse text and make sure that [code] and [quote] syntax is correct |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
110 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
111 |
function check_tag_order($text, &$error) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
112 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
113 |
global $lang_common; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
114 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
115 |
// The maximum allowed quote depth |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
116 |
$max_depth = 3; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
117 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
118 |
$cur_index = 0; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
119 |
$q_depth = 0; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
120 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
121 |
while (true) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
122 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
123 |
// Look for regular code and quote tags |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
124 |
$c_start = strpos($text, '[code]'); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
125 |
$c_end = strpos($text, '[/code]'); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
126 |
$q_start = strpos($text, '[quote]'); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
127 |
$q_end = strpos($text, '[/quote]'); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
128 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
129 |
// Look for [quote=username] style quote tags |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
130 |
if (preg_match('#\[quote=("|"|\'|)(.*)\\1\]#sU', $text, $matches)) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
131 |
$q2_start = strpos($text, $matches[0]); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
132 |
else |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
133 |
$q2_start = 65536; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
134 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
135 |
// Deal with strpos() returning false when the string is not found |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
136 |
// (65536 is one byte longer than the maximum post length) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
137 |
if ($c_start === false) $c_start = 65536; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
138 |
if ($c_end === false) $c_end = 65536; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
139 |
if ($q_start === false) $q_start = 65536; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
140 |
if ($q_end === false) $q_end = 65536; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
141 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
142 |
// If none of the strings were found |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
143 |
if (min($c_start, $c_end, $q_start, $q_end, $q2_start) == 65536) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
144 |
break; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
145 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
146 |
// We are interested in the first quote (regardless of the type of quote) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
147 |
$q3_start = ($q_start < $q2_start) ? $q_start : $q2_start; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
148 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
149 |
// We found a [quote] or a [quote=username] |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
150 |
if ($q3_start < min($q_end, $c_start, $c_end)) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
151 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
152 |
$step = ($q_start < $q2_start) ? 7 : strlen($matches[0]); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
153 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
154 |
$cur_index += $q3_start + $step; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
155 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
156 |
// Did we reach $max_depth? |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
157 |
if ($q_depth == $max_depth) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
158 |
$overflow_begin = $cur_index - $step; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
159 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
160 |
++$q_depth; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
161 |
$text = substr($text, $q3_start + $step); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
162 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
163 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
164 |
// We found a [/quote] |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
165 |
else if ($q_end < min($q_start, $c_start, $c_end)) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
166 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
167 |
if ($q_depth == 0) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
168 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
169 |
$error = $lang_common['BBCode error'].' '.$lang_common['BBCode error 1']; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
170 |
return; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
171 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
172 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
173 |
$q_depth--; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
174 |
$cur_index += $q_end+8; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
175 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
176 |
// Did we reach $max_depth? |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
177 |
if ($q_depth == $max_depth) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
178 |
$overflow_end = $cur_index; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
179 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
180 |
$text = substr($text, $q_end+8); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
181 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
182 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
183 |
// We found a [code] |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
184 |
else if ($c_start < min($c_end, $q_start, $q_end)) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
185 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
186 |
// Make sure there's a [/code] and that any new [code] doesn't occur before the end tag |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
187 |
$tmp = strpos($text, '[/code]'); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
188 |
$tmp2 = strpos(substr($text, $c_start+6), '[code]'); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
189 |
if ($tmp2 !== false) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
190 |
$tmp2 += $c_start+6; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
191 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
192 |
if ($tmp === false || ($tmp2 !== false && $tmp2 < $tmp)) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
193 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
194 |
$error = $lang_common['BBCode error'].' '.$lang_common['BBCode error 2']; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
195 |
return; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
196 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
197 |
else |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
198 |
$text = substr($text, $tmp+7); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
199 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
200 |
$cur_index += $tmp+7; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
201 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
202 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
203 |
// We found a [/code] (this shouldn't happen since we handle both start and end tag in the if clause above) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
204 |
else if ($c_end < min($c_start, $q_start, $q_end)) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
205 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
206 |
$error = $lang_common['BBCode error'].' '.$lang_common['BBCode error 3']; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
207 |
return; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
208 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
209 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
210 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
211 |
// If $q_depth <> 0 something is wrong with the quote syntax |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
212 |
if ($q_depth) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
213 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
214 |
$error = $lang_common['BBCode error'].' '.$lang_common['BBCode error 4']; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
215 |
return; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
216 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
217 |
else if ($q_depth < 0) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
218 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
219 |
$error = $lang_common['BBCode error'].' '.$lang_common['BBCode error 5']; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
220 |
return; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
221 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
222 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
223 |
// If the quote depth level was higher than $max_depth we return the index for the |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
224 |
// beginning and end of the part we should strip out |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
225 |
if (isset($overflow_begin)) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
226 |
return array($overflow_begin, $overflow_end); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
227 |
else |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
228 |
return null; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
229 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
230 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
231 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
232 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
233 |
// Split text into chunks ($inside contains all text inside $start and $end, and $outside contains all text outside) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
234 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
235 |
function split_text($text, $start, $end) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
236 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
237 |
global $pun_config; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
238 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
239 |
$tokens = explode($start, $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
240 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
241 |
$outside[] = $tokens[0]; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
242 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
243 |
$num_tokens = count($tokens); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
244 |
for ($i = 1; $i < $num_tokens; ++$i) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
245 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
246 |
$temp = explode($end, $tokens[$i]); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
247 |
$inside[] = $temp[0]; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
248 |
$outside[] = $temp[1]; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
249 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
250 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
251 |
if ($pun_config['o_indent_num_spaces'] != 8 && $start == '[code]') |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
252 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
253 |
$spaces = str_repeat(' ', $pun_config['o_indent_num_spaces']); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
254 |
$inside = str_replace("\t", $spaces, $inside); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
255 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
256 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
257 |
return array($inside, $outside); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
258 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
259 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
260 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
261 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
262 |
// Truncate URL if longer than 55 characters (add http:// or ftp:// if missing) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
263 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
264 |
function handle_url_tag($url, $link = '') |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
265 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
266 |
global $pun_user; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
267 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
268 |
$full_url = str_replace(array(' ', '\'', '`', '"'), array('%20', '', '', ''), $url); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
269 |
if (strpos($url, 'www.') === 0) // If it starts with www, we add http:// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
270 |
$full_url = 'http://'.$full_url; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
271 |
else if (strpos($url, 'ftp.') === 0) // Else if it starts with ftp, we add ftp:// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
272 |
$full_url = 'ftp://'.$full_url; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
273 |
else if (!preg_match('#^([a-z0-9]{3,6})://#', $url, $bah)) // Else if it doesn't start with abcdef://, we add http:// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
274 |
$full_url = 'http://'.$full_url; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
275 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
276 |
// Ok, not very pretty :-) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
277 |
$link = ($link == '' || $link == $url) ? ((strlen($url) > 55) ? substr($url, 0 , 39).' … '.substr($url, -10) : $url) : stripslashes($link); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
278 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
279 |
return '<a href="'.$full_url.'">'.$link.'</a>'; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
280 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
281 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
282 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
283 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
284 |
// Turns an URL from the [img] tag into an <img> tag or a <a href...> tag |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
285 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
286 |
function handle_img_tag($url, $is_signature = false) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
287 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
288 |
global $lang_common, $pun_config, $pun_user; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
289 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
290 |
$img_tag = '<a href="'.$url.'"><'.$lang_common['Image link'].'></a>'; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
291 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
292 |
if ($is_signature && $pun_user['show_img_sig'] != '0') |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
293 |
$img_tag = '<img class="sigimage" src="'.$url.'" alt="'.htmlspecialchars($url).'" />'; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
294 |
else if (!$is_signature && $pun_user['show_img'] != '0') |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
295 |
$img_tag = '<span class="postimg"><img src="'.$url.'" alt="'.htmlspecialchars($url).'" /></span>'; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
296 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
297 |
return $img_tag; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
298 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
299 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
300 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
301 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
302 |
// Convert BBCodes to their HTML equivalent |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
303 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
304 |
function do_bbcode($text) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
305 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
306 |
global $lang_common, $pun_user; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
307 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
308 |
if (strpos($text, 'quote') !== false) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
309 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
310 |
$text = str_replace('[quote]', '</p><div class="quotebox"><blockquote><p>', $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
311 |
$text = preg_replace('#\[quote=("|"|\'|)(.*)\\1\]#seU', '"</p><div class=\"quotebox\"><cite>".str_replace(array(\'[\', \'\\"\'), array(\'[\', \'"\'), \'$2\')." ".$lang_common[\'wrote\'].":</cite><blockquote><p>"', $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
312 |
$text = preg_replace('#\[\/quote\]\s*#', '</p></blockquote></div><p>', $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
313 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
314 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
315 |
$pattern = array('#\[b\](.*?)\[/b\]#s', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
316 |
'#\[i\](.*?)\[/i\]#s', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
317 |
'#\[u\](.*?)\[/u\]#s', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
318 |
'#\[url\]([^\[]*?)\[/url\]#e', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
319 |
'#\[url=([^\[]*?)\](.*?)\[/url\]#e', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
320 |
'#\[email\]([^\[]*?)\[/email\]#', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
321 |
'#\[email=([^\[]*?)\](.*?)\[/email\]#', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
322 |
'#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#s'); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
323 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
324 |
$replace = array('<strong>$1</strong>', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
325 |
'<em>$1</em>', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
326 |
'<em class="bbuline">$1</em>', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
327 |
'handle_url_tag(\'$1\')', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
328 |
'handle_url_tag(\'$1\', \'$2\')', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
329 |
'<a href="mailto:$1">$1</a>', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
330 |
'<a href="mailto:$1">$2</a>', |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
331 |
'<span style="color: $1">$2</span>'); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
332 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
333 |
// This thing takes a while! :) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
334 |
$text = preg_replace($pattern, $replace, $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
335 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
336 |
return $text; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
337 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
338 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
339 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
340 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
341 |
// Make hyperlinks clickable |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
342 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
343 |
function do_clickable($text) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
344 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
345 |
global $pun_user; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
346 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
347 |
$text = ' '.$text; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
348 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
349 |
$text = preg_replace('#([\s\(\)])(https?|ftp|news){1}://([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^"\s\(\)<\[]*)?)#ie', '\'$1\'.handle_url_tag(\'$2://$3\')', $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
350 |
$text = preg_replace('#([\s\(\)])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^"\s\(\)<\[]*)?)#ie', '\'$1\'.handle_url_tag(\'$2.$3\', \'$2.$3\')', $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
351 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
352 |
return substr($text, 1); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
353 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
354 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
355 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
356 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
357 |
// Convert a series of smilies to images |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
358 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
359 |
function do_smilies($text) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
360 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
361 |
global $pun_config, $base_url, $smiley_text, $smiley_img; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
362 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
363 |
$text = ' '.$text.' '; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
364 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
365 |
$num_smilies = count($smiley_text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
366 |
for ($i = 0; $i < $num_smilies; ++$i) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
367 |
$text = preg_replace("#(?<=.\W|\W.|^\W)".preg_quote($smiley_text[$i], '#')."(?=.\W|\W.|\W$)#m", '$1<img src="'.$base_url.'/img/smilies/'.$smiley_img[$i].'" width="15" height="15" alt="'.substr($smiley_img[$i], 0, strrpos($smiley_img[$i], '.')).'" />$2', $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
368 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
369 |
return substr($text, 1, -1); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
370 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
371 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
372 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
373 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
374 |
// Parse message text |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
375 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
376 |
function parse_message($text, $hide_smilies) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
377 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
378 |
global $pun_config, $lang_common, $pun_user; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
379 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
380 |
if ($pun_config['o_censoring'] == '1') |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
381 |
$text = censor_words($text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
382 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
383 |
// Convert applicable characters to HTML entities |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
384 |
$text = htmlspecialchars($text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
385 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
386 |
// If the message contains a code tag we have to split it up (text within [code][/code] shouldn't be touched) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
387 |
if (strpos($text, '[code]') !== false && strpos($text, '[/code]') !== false) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
388 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
389 |
list($inside, $outside) = split_text($text, '[code]', '[/code]'); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
390 |
$outside = array_map('ltrim', $outside); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
391 |
$text = implode('<">', $outside); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
392 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
393 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
394 |
if ($pun_config['o_make_links'] == '1') |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
395 |
$text = do_clickable($text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
396 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
397 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
398 |
if ($pun_config['o_smilies'] == '1' && $pun_user['show_smilies'] == '1' && $hide_smilies == '0') |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
399 |
$text = do_smilies($text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
400 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
401 |
if ($pun_config['p_message_bbcode'] == '1' && strpos($text, '[') !== false && strpos($text, ']') !== false) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
402 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
403 |
$text = do_bbcode($text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
404 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
405 |
if ($pun_config['p_message_img_tag'] == '1') |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
406 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
407 |
// $text = preg_replace('#\[img\]((ht|f)tps?://)([^\s<"]*?)\.(jpg|jpeg|png|gif)\[/img\]#e', 'handle_img_tag(\'$1$3.$4\')', $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
408 |
$text = preg_replace('#\[img\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e', 'handle_img_tag(\'$1$3\')', $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
409 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
410 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
411 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
412 |
// Deal with newlines, tabs and multiple spaces |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
413 |
$pattern = array("\n", "\t", ' ', ' '); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
414 |
$replace = array('<br />', ' ', ' ', ' '); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
415 |
$text = str_replace($pattern, $replace, $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
416 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
417 |
// If we split up the message before we have to concatenate it together again (code tags) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
418 |
if (isset($inside)) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
419 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
420 |
$outside = explode('<">', $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
421 |
$text = ''; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
422 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
423 |
$num_tokens = count($outside); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
424 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
425 |
for ($i = 0; $i < $num_tokens; ++$i) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
426 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
427 |
$text .= $outside[$i]; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
428 |
if (isset($inside[$i])) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
429 |
$text .= '</p><div class="codebox"><strong>'.$lang_common['Code'].':</strong><pre><code>'.$inside[$i].'</code></pre></div><p>'; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
430 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
431 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
432 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
433 |
// Add paragraph tag around post, but make sure there are no empty paragraphs |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
434 |
$text = preg_replace('#<br />\s*?<br />(?!\s*<br />)#i', "</p><p>", $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
435 |
$text = str_replace('<p></p>', '', '<p>'.$text.'</p>'); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
436 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
437 |
return $text; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
438 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
439 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
440 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
441 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
442 |
// Parse signature text |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
443 |
// |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
444 |
function parse_signature($text) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
445 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
446 |
global $pun_config, $lang_common, $pun_user; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
447 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
448 |
if ($pun_config['o_censoring'] == '1') |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
449 |
$text = censor_words($text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
450 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
451 |
$text = htmlspecialchars($text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
452 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
453 |
if ($pun_config['o_make_links'] == '1') |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
454 |
$text = do_clickable($text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
455 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
456 |
if ($pun_config['o_smilies_sig'] == '1' && $pun_user['show_smilies'] != '0') |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
457 |
$text = do_smilies($text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
458 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
459 |
if ($pun_config['p_sig_bbcode'] == '1' && strpos($text, '[') !== false && strpos($text, ']') !== false) |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
460 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
461 |
$text = do_bbcode($text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
462 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
463 |
if ($pun_config['p_sig_img_tag'] == '1') |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
464 |
{ |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
465 |
// $text = preg_replace('#\[img\]((ht|f)tps?://)([^\s<"]*?)\.(jpg|jpeg|png|gif)\[/img\]#e', 'handle_img_tag(\'$1$3.$4\', true)', $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
466 |
$text = preg_replace('#\[img\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e', 'handle_img_tag(\'$1$3\', true)', $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
467 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
468 |
} |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
469 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
470 |
// Deal with newlines, tabs and multiple spaces |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
471 |
$pattern = array("\n", "\t", ' ', ' '); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
472 |
$replace = array('<br />', ' ', ' ', ' '); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
473 |
$text = str_replace($pattern, $replace, $text); |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
474 |
|
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
475 |
return $text; |
98bbc533541c
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff
changeset
|
476 |
} |