[Snippet] Convert magic_urls to code tags V1 + V2

Convert magic_urls to code tags V1
V1 converts all external links in a post without [url] tags
Demo: http://4seven.bplaced.net/forum/3/viewtopic.php?p=72#p72
Screen:
Note:
Bcs. of technical reasons the code box was append to the bottom of each posting.
Altering the message directly seems not to work, bcs. it gives wired results,
if a normal code box with links is also present. May another provide a trick,
but after some tests this seems the only solution to get rid of this behaviour.
Instruction
open
viewtopic.php
find
before add
find
after add
V1 converts all external links in a post without [url] tags
grouped
into code box.Demo: http://4seven.bplaced.net/forum/3/viewtopic.php?p=72#p72
Screen:
Note:
Bcs. of technical reasons the code box was append to the bottom of each posting.
Altering the message directly seems not to work, bcs. it gives wired results,
if a normal code box with links is also present. May another provide a trick,
but after some tests this seems the only solution to get rid of this behaviour.
Instruction
open
viewtopic.php
find
- Code: Select all
// Parse the message and subject
$message = censor_text($row['post_text']);
before add
- Code: Select all
// URLs to Code / 4seven / 2012
$url_code = '';
if (strpos($row['post_text'], 'postlink') !== false){
preg_match_all('#<a(.*?)class="postlink"(.*?)>(.*?)<\/a>#is', $row['post_text'], $message_urls);
$row['post_text'] = preg_replace('#<a(.*?)class="postlink"(.*?)>(.*?)<\/a>#is', '', $row['post_text']);
// var_dump($message_urls);
if (!empty($message_urls[0])){
$url_code .= '<dl class="codebox"><dt>' . $user->lang['CODE'] . ': <a href="#" onclick="selectCode(this); return false;">' . $user->lang['SELECT_ALL_CODE'] . '</a></dt><dd><code>';
foreach($message_urls[0] as $mess_urls){
$url_code .= preg_replace('#<a(.*?)class="postlink"(.*?)>(.*?)<\/a>#is', '$3<br />', $mess_urls);
}
$url_code .= '</code></dd></dl>';
}}
// URLs to Code Block / 4seven / 2012
find
- Code: Select all
'MESSAGE' => $message,
after add
- Code: Select all
'MESSAGE' => $message . $url_code,