@@ -48,9 +48,9 @@ function filterText($strText) {
48
48
return $ temp ;
49
49
}
50
50
51
- function getPreciseTime ($ intTime , $ timeFormat ="" ) {
51
+ function getPreciseTime ($ intTime , $ timeFormat ="" , $ bypassTimeDiff = false ) {
52
52
53
- $ timeDiff = time () - $ intTime ;
53
+ $ timeDiff = (! $ bypassTimeDiff ) ? time () - $ intTime : 99999 ;
54
54
55
55
if ($ timeDiff < 3 ) {
56
56
$ dispLastDate = "just now " ;
@@ -114,8 +114,8 @@ function parseBBCode($strText) {
114
114
115
115
foreach ($ arrBBCodes as $ bbCode ) {
116
116
117
- $ strText = str_replace ($ bbCode ['bbOpenTag ' ],$ bbCode ['htmlOpenTag ' ],$ strText );
118
- $ strText = str_replace ($ bbCode ['bbCloseTag ' ],$ bbCode ['htmlCloseTag ' ],$ strText );
117
+ $ strText = str_ireplace ($ bbCode ['bbOpenTag ' ],$ bbCode ['htmlOpenTag ' ],$ strText );
118
+ $ strText = str_ireplace ($ bbCode ['bbCloseTag ' ],$ bbCode ['htmlCloseTag ' ],$ strText );
119
119
120
120
}
121
121
@@ -127,23 +127,26 @@ function parseBBCode($strText) {
127
127
foreach ($ arrEmoticonCodes as $ key => $ value ) {
128
128
129
129
$ imgURL = "<img src=' " .$ MAIN_ROOT ."images/emoticons/ " .$ arrEmoticonImg [$ key ]."' width='15' height='15'> " ;
130
- $ strText = str_replace ($ value , $ imgURL , $ strText );
130
+ $ strText = str_ireplace ($ value , $ imgURL , $ strText );
131
131
132
132
}
133
133
134
134
135
135
// Complex Codes, ex. Links, colors...
136
136
137
- $ strText = preg_replace ("/\[url\](.*)\[\/url\]/ " , "<a href='$1' target='_blank'>$1</a> " , $ strText ); // Links no Titles
138
- $ strText = preg_replace ("/\[url=(.*)\](.*)\[\/url\]/ " , "<a href='$1' target='_blank'>$2</a> " , $ strText ); // Links with Titles
139
- $ strText = preg_replace ("/\[color=(.*)\](.*)\[\/color\]/ " , "<span style='color: $1'>$2</span> " , $ strText ); // Text Color
137
+ $ strText = preg_replace ("/\[url](.*?)\[\/url]/i " , "<a href='$1' target='_blank'>$1</a> " , $ strText ); // Links no Titles
138
+ $ strText = preg_replace ("/\[url=(.*?)\](.*?)\[\/url\]/i " , "<a href='$1' target='_blank'>$2</a> " , $ strText ); // Links with Titles
139
+
140
+
140
141
142
+ $ strText = preg_replace ("/\[color=(.*)\](.*)\[\/color\]/i " , "<span style='color: $1'>$2</span> " , $ strText ); // Text Color
143
+
141
144
$ strText = str_replace ("[/youtube] " , "[/youtube] \n" , $ strText );
142
- $ strText = preg_replace ("/\[youtube\](http|https)(\:\/\/www\.youtube\.com\/watch\?v\=)(.*)\[\/youtube\]/ " , "<iframe class='youtubeEmbed' src='http://www.youtube.com/embed/$3?wmode=opaque' frameborder='0' allowfullscreen></iframe> " , $ strText );
143
- $ strText = preg_replace ("/\[\youtube\](http|https)(\:\/\/youtu\.be\/)(.*)\[\/youtube\]/ " , "<iframe class='youtubeEmbed' src='http://www.youtube.com/embed/$3?wmode=opaque' frameborder='0' allowfullscreen></iframe> " , $ strText );
145
+ $ strText = preg_replace ("/\[youtube\](http|https)(\:\/\/www\.youtube\.com\/watch\?v\=)(.*)\[\/youtube\]/i " , "<iframe class='youtubeEmbed' src='http://www.youtube.com/embed/$3?wmode=opaque' frameborder='0' allowfullscreen></iframe> " , $ strText );
146
+ $ strText = preg_replace ("/\[\youtube\](http|https)(\:\/\/youtu\.be\/)(.*)\[\/youtube\]/i " , "<iframe class='youtubeEmbed' src='http://www.youtube.com/embed/$3?wmode=opaque' frameborder='0' allowfullscreen></iframe> " , $ strText );
144
147
145
148
$ strText = str_replace ("[/twitch] " , "[/twitch] \n" , $ strText );
146
- $ strText = preg_replace ("/\[twitch\](http|https)(\:\/\/www\.twitch\.tv\/)(.*)\[\/twitch\]/ " , "<object class='youtubeEmbed' type='application/x-shockwave-flash' id='live_embed_player_flash' data='http://www.twitch.tv/widgets/live_embed_player.swf?channel=$3' bgcolor='#000000'><param name='allowFullScreen' value='true' /><param name='wmode' value='opaque' /><param name='allowScriptAccess' value='always' /><param name='allowNetworking' value='all' /><param name='movie' value='http://www.twitch.tv/widgets/live_embed_player.swf' /><param name='flashvars' value='hostname=www.twitch.tv&channel=$3&auto_play=false&start_volume=25' /></object> " , $ strText );
149
+ $ strText = preg_replace ("/\[twitch\](http|https)(\:\/\/www\.twitch\.tv\/)(.*)\[\/twitch\]/i " , "<object class='youtubeEmbed' type='application/x-shockwave-flash' id='live_embed_player_flash' data='http://www.twitch.tv/widgets/live_embed_player.swf?channel=$3' bgcolor='#000000'><param name='allowFullScreen' value='true' /><param name='wmode' value='opaque' /><param name='allowScriptAccess' value='always' /><param name='allowNetworking' value='all' /><param name='movie' value='http://www.twitch.tv/widgets/live_embed_player.swf' /><param name='flashvars' value='hostname=www.twitch.tv&channel=$3&auto_play=false&start_volume=25' /></object> " , $ strText );
147
150
148
151
$ strText = autolink ($ strText );
149
152
@@ -162,6 +165,78 @@ function autoLinkImage($strText) {
162
165
}
163
166
164
167
168
+ function __autoload ($ class_name ) {
169
+ global $ prevFolder ;
170
+ include_once ($ prevFolder ."classes/ " .$ class_name .".php " );
171
+ }
172
+
165
173
174
+ //======================== START OF FUNCTION ==========================//
175
+ // FUNCTION: bbcode_to_html //
176
+ //=====================================================================//
177
+ function bbcode_to_html ($ bbtext ){
178
+ $ bbtags = array (
179
+ '[heading1] ' => '<h1> ' ,'[/heading1] ' => '</h1> ' ,
180
+ '[heading2] ' => '<h2> ' ,'[/heading2] ' => '</h2> ' ,
181
+ '[heading3] ' => '<h3> ' ,'[/heading3] ' => '</h3> ' ,
182
+ '[h1] ' => '<h1> ' ,'[/h1] ' => '</h1> ' ,
183
+ '[h2] ' => '<h2> ' ,'[/h2] ' => '</h2> ' ,
184
+ '[h3] ' => '<h3> ' ,'[/h3] ' => '</h3> ' ,
185
+
186
+ '[paragraph] ' => '<p> ' ,'[/paragraph] ' => '</p> ' ,
187
+ '[para] ' => '<p> ' ,'[/para] ' => '</p> ' ,
188
+ '[p] ' => '<p> ' ,'[/p] ' => '</p> ' ,
189
+ '[left] ' => '<p style="text-align:left;"> ' ,'[/left] ' => '</p> ' ,
190
+ '[right] ' => '<p style="text-align:right;"> ' ,'[/right] ' => '</p> ' ,
191
+ '[center] ' => '<p style="text-align:center;"> ' ,'[/center] ' => '</p> ' ,
192
+ '[justify] ' => '<p style="text-align:justify;"> ' ,'[/justify] ' => '</p> ' ,
193
+
194
+ '[bold] ' => '<span style="font-weight:bold;"> ' ,'[/bold] ' => '</span> ' ,
195
+ '[italic] ' => '<span style="font-weight:bold;"> ' ,'[/italic] ' => '</span> ' ,
196
+ '[underline] ' => '<span style="text-decoration:underline;"> ' ,'[/underline] ' => '</span> ' ,
197
+ '[b] ' => '<span style="font-weight:bold;"> ' ,'[/b] ' => '</span> ' ,
198
+ '[i] ' => '<span style="font-weight:bold;"> ' ,'[/i] ' => '</span> ' ,
199
+ '[u] ' => '<span style="text-decoration:underline;"> ' ,'[/u] ' => '</span> ' ,
200
+ '[break] ' => '<br> ' ,
201
+ '[br] ' => '<br> ' ,
202
+ '[newline] ' => '<br> ' ,
203
+ '[nl] ' => '<br> ' ,
204
+
205
+ '[unordered_list] ' => '<ul> ' ,'[/unordered_list] ' => '</ul> ' ,
206
+ '[list] ' => '<ul> ' ,'[/list] ' => '</ul> ' ,
207
+ '[ul] ' => '<ul> ' ,'[/ul] ' => '</ul> ' ,
208
+
209
+ '[ordered_list] ' => '<ol> ' ,'[/ordered_list] ' => '</ol> ' ,
210
+ '[ol] ' => '<ol> ' ,'[/ol] ' => '</ol> ' ,
211
+ '[list_item] ' => '<li> ' ,'[/list_item] ' => '</li> ' ,
212
+ '[li] ' => '<li> ' ,'[/li] ' => '</li> ' ,
213
+
214
+ '[*] ' => '<li> ' ,'[/*] ' => '</li> ' ,
215
+ '[code] ' => '<code> ' ,'[/code] ' => '</code> ' ,
216
+ '[preformatted] ' => '<pre> ' ,'[/preformatted] ' => '</pre> ' ,
217
+ '[pre] ' => '<pre> ' ,'[/pre] ' => '</pre> ' ,
218
+ );
219
+
220
+ $ bbtext = str_ireplace (array_keys ($ bbtags ), array_values ($ bbtags ), $ bbtext );
221
+
222
+ $ bbextended = array (
223
+ "/\[url](.*?)\[\/url]/i " => "<a href= \"http://$1 \" title= \"$1 \">$1</a> " ,
224
+ "/\[url=(.*?)\](.*?)\[\/url\]/i " => "<a href= \"$1 \" title= \"$1 \">$2</a> " ,
225
+ "/\[email=(.*?)\](.*?)\[\/email\]/i " => "<a href= \"mailto:$1 \">$2</a> " ,
226
+ "/\[mail=(.*?)\](.*?)\[\/mail\]/i " => "<a href= \"mailto:$1 \">$2</a> " ,
227
+ "/\[img\]([^[]*)\[\/img\]/i " => "<img src= \"$1 \" alt= \" \" /> " ,
228
+ "/\[image\]([^[]*)\[\/image\]/i " => "<img src= \"$1 \" alt= \" \" /> " ,
229
+ "/\[image_left\]([^[]*)\[\/image_left\]/i " => "<img src= \"$1 \" alt= \" \" class= \"img_left \" /> " ,
230
+ "/\[image_right\]([^[]*)\[\/image_right\]/i " => "<img src= \"$1 \" alt= \" \" class= \"img_right \" /> " ,
231
+ );
232
+
233
+ foreach ($ bbextended as $ match =>$ replacement ){
234
+ $ bbtext = preg_replace ($ match , $ replacement , $ bbtext );
235
+ }
236
+ return $ bbtext ;
237
+ }
238
+ //=====================================================================//
239
+ // FUNCTION: bbcode_to_html //
240
+ //========================= END OF FUNCTION ===========================//
166
241
167
242
?>
0 commit comments