Changeset 1550 in ExiteCMS for trunk/includes/forum_functions_include.php
- Timestamp:
- 07/27/08 14:26:17 (4 years ago)
- File:
-
- 1 edited
-
trunk/includes/forum_functions_include.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/forum_functions_include.php
r1527 r1550 18 18 $codeblocks = array(); 19 19 $urlblocks = array(); 20 $imgblocks = array(); 20 21 $blockcount = 0; 21 22 $raw_color_blocks = false; … … 337 338 return ""; 338 339 } 339 // trim the values passed 340 341 // remove leading CRLF 342 if (substr($matches[2],0,2) == "\r\n") { 343 $matches[2] = substr($matches[2],2); 344 } 345 346 // remove the leading '=' from the file type 340 347 $matches[1] = trim(substr($matches[1],1)); 341 348 349 // colorize the code if requested 342 350 if ($raw_color_blocks == false) { 343 351 require_once PATH_GESHI."/geshi.php"; 344 352 $geshi =& new GeSHi("", ""); 345 // colorize the code346 353 $geshi->set_language($matches[1]); 347 354 $geshi->set_header_type(GESHI_HEADER_DIV); … … 351 358 } 352 359 360 // if a raw block was requested, bail out here 353 361 if ($raw_color_blocks) { 354 362 $codeblocks[] = array($matches[2], $matches[1]); … … 376 384 } 377 385 378 // message parser, strip [code] and [url] sections, parse for BBcode and smiley's, then insert the sections again 386 function _parseubb_imgblock($matches) { 387 global $imgblocks; 388 389 $imgblocks[] = array($matches[1], $matches[1]); 390 return "{@*@".(count($imgblocks)-1)."@*@}"; 391 } 392 393 // message parser, strip [code], [img] and [url] sections, parse for BBcode, smiley's, then insert the sections again 379 394 function parsemessage($msg_array) { 380 395 global $settings, $db_prefix, $codeblocks, $urlblocks, $current_message; … … 392 407 $codeblocks = array(); 393 408 $urlblocks = array(); 409 $imgblocks = array(); 410 411 // convert any newlines to html <br> 412 $rawmsg = nl2br($rawmsg); 394 413 395 414 // strip CODE bbcode, optionally perform Geshi color coding 396 415 $rawmsg = preg_replace_callback('#\[code(=.*?)?\](.*?)([\r\n]*)\[/code\]#si', '_parseubb_codeblock', $rawmsg); 397 416 417 // find URL's in the text, and convert them to a [url] BBcode 418 $rawmsg = preg_replace("#(^|\s)(www|WWW)\.([^\s<>\/]+)\/([^\s\r\n<>\)\,\:\;\[]+)#sm", "\\1[url=http://\\2.\\3/\\4]http://\\2.\\3[/url]", $rawmsg); 419 $rawmsg = preg_replace("#(^|[^\"=\]]{1})(http|HTTP|ftp)(s|S)?://([^\s<>\/]+)\/([^\s\r\n<>\,\[]+)#sm", "\\1[url=\\2\\3://\\4/\\5]\\2\\3://\\4\\5[/url]", $rawmsg); 420 398 421 // strip URL bbcode 399 422 $rawmsg = preg_replace_callback('#\[url(=.*?)\](.*?)([\r\n]*)\[/url\]#si', '_parseubb_urlblock', $rawmsg); 423 424 // strip IMG bbcode 425 // $rawmsg = preg_replace_callback('#\[img\](.*?)([\r\n]*)\[/img\]#si', '_parseubb_imgblock', $rawmsg); 400 426 401 427 // detect and convert wikitags to wiki bbcodes if needed … … 406 432 $result = dbquery("SELECT DISTINCT tag FROM ".$db_prefix."wiki_pages"); 407 433 while ($data = dbarray($result)) { 408 $search[] = "/([[:space:]\.\,-])+?(".$data['tag'].")([[:space:]\.\,-]+?|\]|$)/i"; 409 $replace[] = "\\1[wiki]\\2[/wiki]\\3"; 434 if (!empty($data['tag'])) { 435 $search[] = "/(\b)(".$data['tag'].")(\b)/i"; 436 $replace[] = "\\1[wiki]\\2[/wiki]\\3"; 437 } 410 438 } 411 439 $rawmsg = preg_replace($search, $replace, $rawmsg); 440 } 441 442 // re-insert the saved img blocks 443 foreach($imgblocks as $key => $imgblock) { 444 $rawmsg = str_replace("{*@*".$key."*@*}", $imgblock[0], $rawmsg); 412 445 } 413 446 414 447 // parse the smileys in the message 415 448 if ($smileys) $rawmsg = parsesmileys($rawmsg); 449 416 450 // parse all ubbcode 417 451 $rawmsg = parseubb($rawmsg); 418 // convert any newlines to html <br>419 $rawmsg = str_replace("\r\n\r\n", "\r\n", $rawmsg);420 $rawmsg = nl2br($rawmsg);421 452 422 423 453 // re-insert the saved code blocks 424 454 foreach($codeblocks as $key => $codeblock) {
Note: See TracChangeset
for help on using the changeset viewer.
