hehe, nou kijkik heb de array voor de preg_replace op een andere manier opgebouwd:
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| $search = Array(
"~\[CODE](.+?)\[/CODE]~is",
"~\[CODE=(.+?)](.+?)\[/CODE]~is",
"~\[URL](.+?)\[/URL]~i",
"~\[URL=(http|ftp|https)://(.+?)](.+?)\[/URL]~i",
"~\[URL=(.+?)](.+?)\[/URL]~is",
"~\[IMG=(http|ftp|https)://(.+?)](.+?)\[/IMG]~i",
"~\[IMG=(.+?)](.+?)\[/IMG]~is",
"~\[IMG](.+?)\[/IMG]~is",
"~\\[EMAIL=([_a-z0-9-.]+@[a-z0-9-]+\.[a-z0-9-]+)](.+?)\[/EMAIL]~is",
"~\[QUOTE](.+?)\[/QUOTE]~is",
"~\[QUOTE=(.+?)](.+?)\[/QUOTE]~is"
);
$objects = Array();
$varCode = "\\1";
$objects[] = '$this->formatcode(\'\\1\')';
$varCode = "\\2";
$varTitle = " : \\1";
$objects[] = eval($this->template('OBJECTS_CODE'));
$objects[] = "<a target='_blank' href='\\1'>\\1</a>";
$objects[] = "<a target='_blank' href=\"\\1://\\2\">\\3</a>";
$objects[] = "<a target='_blank' href=\"http://\\1\">\\2</a>";
$objects[] = "[img]\"\\1://\\2\"[/img]";
$objects[] = "[img]'http://\\1'[/img]";
$objects[] = "[img]'\\1'[/img]";
$objects[] = "<a href=\"mailto:\\1\"> \\2 </a>";
$varQuote = "\\1";
$objects[] = eval($this->template('OBJECTS_QUOTE'));
$varUser = " - \\1 {$this->lang->wrote}:";
$varQuote = "\\2";
$objects[] = eval($this->template('OBJECTS_QUOTE'));
$txt = preg_replace($search,$objects,$txt); |
voorbeeld( mercuryboard voor diegene die het wil weten):
PHP:
1
2
3
4
5
6
7
8
9
10
| $full_search = array(
'~\\[(/)?([bius])]~i',
'~\[url=(http|https|ftp)://(.+?)](.+?)\[/url]~i',
'~\[email]([a-z0-9-_.]+@[a-z0-9-.]+\.[a-z0-9-_.]+)\[/email]~i',
'~\\[email=([^<]+?)](.+?)\[/email]~i',
'~\[img](http|https|ftp)://(.+?)\[/img]~i',
'~\\[(right|center)](.+?)\\[/\1]~is',
'~\[code](.+?)\[/code]~is',
'~\[php](.+?)\[/php]~ise',
'~\\[php=([0-9]+?)](.+?)\ |
~ise',
'~\[color=(\S+?)](.+?)\[/color]~is',
'~\
(.+?)\~is',
'~\\[size=([0-9]+?)](.+?)\[/size]~is'
);
$full_replace = array(
'<\\1\\2>',
'<a href="\\1://\\2" target="' . $this->sets['link_target'] . '">\\3</a>',
'<a href="mailto:\\1">\\1</a>',
'<a href="mailto:\\1">\\2</a>',
'[img]"\\1://\\2"[/img]',
'<div align="\\1">\\2</div>',
'<table align="center" border="0" width="90%" cellpadding="3" cellspacing="0"><tr><td><b>' . $this->lang->main_code . ':</b></td></tr><tr><td class="code">\\1</td></tr></table>',
'$this->colorphp(\'\\1\')',
'$this->colorphp(\'\\2\', \'\\1\')',
'<font color="\\1">\\2</font>',
'<font face="\\1">\\2</font>',
'<font size="\\1">\\2</font>'
);
if((substr_count($in, '
') + substr_count($in, '[quote=')) == substr_count($in, '
')){
$full_search[] = '~\[quote=(.+?)]~i';
$full_search[] = '~\
~i';
$full_search[] = '~\
~i';
$full_replace[] = '<table align="center" border="0" width="90%" cellpadding="3" cellspacing="0"><tr><td><b>\\1 ' . $this->lang->main_said . ':</b></td></tr><tr><td class="quote">';
$full_replace[] = '<table align="center" border="0" width="90%" cellpadding="3" cellspacing="0"><tr><td><b>' . $this->lang->main_quote . ':</b></td></tr><tr><td class="quote">';
$full_replace[] = '</td></tr></table>';
}
$search = array_merge($search, $full_search);
$replace = array_merge($replace, $full_replace);
}
$in = preg_replace($search, $replace, $in);[/php]