<?php
# Copyright by Thomas Bowe [Funjoy]
# Support bbcode@phpline.de
# link www.phpline.de
if
(
file_exists
(
"include/includes/class/highlight/css.php"
)) {
require_once
(
"include/includes/class/highlight/css.php"
);
}
if
(
file_exists
(
"include/includes/class/highlight/html.php"
)) {
require_once
(
"include/includes/class/highlight/html.php"
);
}
class
bbcode {
var
$permitted
=
array
();
var
$codecblocks
=
array
();
var
$badwords
=
array
();
var
$info
=
array
();
var
$pattern
=
array
();
var
$replace
=
array
();
var
$smileys
=
array
();
var
$ayCacheQuoteOpen
=
array
();
var
$ayCacheQuoteClose
=
array
();
var
$ayCacheKtextOpen
=
array
();
var
$ayCacheKtextClose
=
array
();
function
encode_codec(
$string
,
$tag
,
$file
=NULL) {
$file
= (
$file
== NULL) ?
""
:
"="
.
$file
;
$crypt
= md5(
count
(
$this
->codecblocks));
$this
->codecblocks[
$crypt
.
":"
.
$tag
] =
$string
;
return
"["
.
$tag
.
$file
.
"]"
.
$crypt
.
"[/"
.
$tag
.
"]"
;
}
function
_codeblock(
$codecid
,
$file
=NULL,
$firstline
=1) {
$string
=
$this
->codecblocks[
$codecid
.
':code'
];
$string
= htmlentities(
$string
);
$file
= (
$file
== NULL) ?
""
:
" von Datei <em>"
.
$file
.
"</em>"
;
$lines
=
explode
(
"\n"
,
$string
);
for
(
$no
=
$firstline
;
$no
<(
count
(
$lines
)+
$firstline
);
$no
++) {
$line
.=
""
.
$no
.
":<br />"
;
}
$string
=
str_replace
(
"\t"
,
' '
,
$string
);
$string
=
str_replace
(
' '
,
' '
,
$string
);
$string
=
str_replace
(
' '
,
' '
,
$string
);
$string
=
nl2br
(
$string
);
$header
=
"<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\"><tr><td valgin=\"top\">"
.
"<div style=\"overflow: auto; height: "
.(37+(
count
(
$lines
)*14)).
"px; width: {$this->info['BlockTabelleBreite']}px;\">"
.
"<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"BORDER: 1px SOLID "
.
$this
->info[
'BlockRandFarbe'
].
";\" width=\"100%\">"
.
"<tr><td colspan=\"3\" style=\"font-family:Arial, Helvetica, sans-serif;FONT-SIZE:12px;FONT-WEIGHT:BOLD;COLOR:"
.
$this
->info[
'BlockSchriftfarbe'
].
";BACKGROUND-COLOR:"
.
$this
->info[
'BlockHintergrundfarbe'
].
";\"> Code"
.
$file
.
"</td></tr>"
.
"<tr bgcolor=\""
.
$this
->info[
'BlockHintergrundfarbeIT'
].
"\"><td style=\"color:"
.
$this
->info[
'BlockSchriftfarbe'
].
";padding-left:2px;padding-right:2px;border-right:1px solid "
.
$this
->info[
'BlockHintergrundfarbe'
].
";font-family:Arial, Helvetica, sans-serif;\" align=\"right\" width=\"20\" valign=\"top\"><code>"
.
$line
.
"</code></td><td width=\"5\"> </td><td valign=\"top\" style=\"BACKGROUND-COLOR:"
.
$this
->info[
'BlockHintergrundfarbeIT'
].
";Color:"
.
$this
->info[
'BlockCodeFarbe'
].
";\" nowrap><code>"
;
$footer
=
"</code></td></tr></table></div></td></tr></table>"
;
return
$header
.
stripslashes
(
$string
).
$footer
;
}
function
_htmlblock(
$codecid
,
$file
=NULL,
$firstline
=1) {
$string
=
$this
->codecblocks[
$codecid
.
':html'
];
$string
= htmlentities(
$string
);
if
(function_exists(
"highlight_html"
)) {
$string
= highlight_html(
$string
,
$this
->info[
'BlockCodeFarbe'
]);
}
$file
= (
$file
== NULL) ?
""
:
" von Datei <em>"
.
$file
.
"</em>"
;
$lines
=
explode
(
"\n"
,
$string
);
for
(
$no
=
$firstline
;
$no
<(
count
(
$lines
)+
$firstline
);
$no
++) {
$line
.=
""
.
$no
.
":<br />"
;
}
$string
=
str_replace
(
"\t"
,
' '
,
$string
);
$string
=
str_replace
(
' '
,
' '
,
$string
);
$string
=
str_replace
(
' '
,
' '
,
$string
);
$string
=
nl2br
(
$string
);
$header
=
"<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\"><tr><td valgin=\"top\">"
.
"<div style=\"overflow: auto; width: {$this->info['BlockTabelleBreite']}px;\">"
.
"<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"BORDER: 1px SOLID "
.
$this
->info[
'BlockRandFarbe'
].
";\" width=\"100%\">"
.
"<tr><td colspan=\"3\" style=\"font-family:Arial, Helvetica, sans-serif;FONT-SIZE:12px;FONT-WEIGHT:BOLD;COLOR:"
.
$this
->info[
'BlockSchriftfarbe'
].
";BACKGROUND-COLOR:"
.
$this
->info[
'BlockHintergrundfarbe'
].
";\"> Html"
.
$file
.
"</td></tr>"
.
"<tr bgcolor=\""
.
$this
->info[
'BlockHintergrundfarbeIT'
].
"\"><td style=\"color:"
.
$this
->info[
'BlockSchriftfarbe'
].
";padding-left:2px;padding-right:2px;border-right:1px solid "
.
$this
->info[
'BlockHintergrundfarbe'
].
";font-family:Arial, Helvetica, sans-serif;\" align=\"right\" width=\"20\" valign=\"top\"><code>"
.
$line
.
"</code></td><td width=\"5\"> </td><td valign=\"top\" style=\"BACKGROUND-COLOR:"
.
$this
->info[
'block_contentbgcolor'
].
";color:#000000;\" nowrap><code>"
;
$footer
=
"</code></td></tr></table></div></td></tr></table>"
;
return
$header
.
$string
.
$footer
;
}
function
_cssblock(
$codecid
,
$file
=NULL,
$firstline
=1) {
$string
=
$this
->codecblocks[
$codecid
.
':css'
];
$string
= htmlentities(
$string
);
if
(function_exists(
"highlight_css"
)) {
$string
= highlight_css(
$string
);
}
$file
= (
$file
== NULL) ?
""
:
" von Datei <em>"
.
$file
.
"</em>"
;
$lines
=
explode
(
"\n"
,
$string
);
for
(
$no
=
$firstline
;
$no
<(
count
(
$lines
)+
$firstline
);
$no
++) {
$line
.=
""
.
$no
.
":<br />"
;
}
$string
=
str_replace
(
"\t"
,
' '
,
$string
);
$string
=
str_replace
(
' '
,
' '
,
$string
);
$string
=
str_replace
(
' '
,
' '
,
$string
);
$string
=
nl2br
(
$string
);
$header
=
"<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\"><tr><td valgin=\"top\">"
.
"<div style=\"overflow: auto;width: {$this->info['BlockTabelleBreite']}px;\">"
.
"<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"BORDER: 1px SOLID "
.
$this
->info[
'BlockRandFarbe'
].
";\" width=\"100%\">"
.
"<tr><td colspan=\"3\" style=\"font-family:Arial, Helvetica, sans-serif;FONT-SIZE:12px;FONT-WEIGHT:BOLD;COLOR:"
.
$this
->info[
'BlockSchriftfarbe'
].
";BACKGROUND-COLOR:"
.
$this
->info[
'BlockHintergrundfarbe'
].
";\"> Css"
.
$file
.
"</td></tr>"
.
"<tr bgcolor=\""
.
$this
->info[
'BlockHintergrundfarbeIT'
].
"\"><td style=\"color:"
.
$this
->info[
'BlockSchriftfarbe'
].
";padding-left:2px;padding-right:2px;border-right:1px solid "
.
$this
->info[
'BlockHintergrundfarbe'
].
";font-family:Arial, Helvetica, sans-serif;\" align=\"right\" width=\"20\" valign=\"top\"><code>"
.
$line
.
"</code></td><td width=\"5\"> </td><td valign=\"top\" style=\"BACKGROUND-COLOR:"
.
$this
->info[
'block_contentbgcolor'
].
";color:#000000;\" nowrap><code>"
;
$footer
=
"</code></td></tr></table></div></td></tr></table>"
;
return
$header
.
$string
.
$footer
;
}
function
_phpblock(
$codecid
,
$file
=NULL,
$firstline
=1) {
$string
=
$this
->codecblocks[
$codecid
.
':php'
];
$file
= (
$file
== NULL) ?
""
:
" von Datei <em>"
.
$file
.
"</em>"
;
$lines
=
explode
(
"\n"
,
$string
);
for
(
$no
=
$firstline
;
$no
<(
count
(
$lines
)+
$firstline
);
$no
++) {
$line
.=
""
.
$no
.
":<br />"
;
}
ob_start();
highlight_string(trim(
stripslashes
(
$string
)));
$php
= ob_get_contents();
ob_end_clean();
$header
=
"<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\"><tr><td valgin=\"top\">"
.
"<div style=\"overflow: auto;width: {$this->info['BlockTabelleBreite']}px;\">"
.
"<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"BORDER: 1px SOLID "
.
$this
->info[
'BlockRandFarbe'
].
";\" width=\"100%\">"
.
"<tr><td colspan=\"3\" style=\"font-family:Arial, Helvetica, sans-serif;FONT-SIZE:12px;FONT-WEIGHT:BOLD;COLOR:"
.
$this
->info[
'BlockSchriftfarbe'
].
";BACKGROUND-COLOR:"
.
$this
->info[
'BlockHintergrundfarbe'
].
";\"> Php"
.
$file
.
"</td></tr>"
.
"<tr bgcolor=\""
.
$this
->info[
'BlockHintergrundfarbeIT'
].
"\"><td style=\"color:"
.
$this
->info[
'BlockSchriftfarbe'
].
";padding-left:2px;padding-right:2px;border-right:1px solid "
.
$this
->info[
'BlockHintergrundfarbe'
].
";font-family:Arial, Helvetica, sans-serif;\" align=\"right\" width=\"20\" valign=\"top\"><code>"
.
$line
.
"</code></td><td width=\"5\"> </td><td valign=\"top\" style=\"BACKGROUND-COLOR:"
.
$this
->info[
'block_contentbgcolor'
].
"\" nowrap><code>"
;
$footer
=
"</code></td></tr></table></div></td></tr></table>"
;
return
$header
.
$php
.
$footer
;
}
function
_smileys(
$string
) {
if
(!
is_null
(
$this
->smileys) &&
is_array
(
$this
->smileys)) {
if
(
$this
->permitted[
'smileys'
] == true) {
foreach
(
$this
->smileys
as
$icon
=>
$info
) {
list(
$emo
,
$url
) =
explode
(
'#@#-_-_-#@#'
,
$info
);
$string
=
str_replace
(
$icon
,
'<img src="include/images/smiles/'
.
$url
.
'" border="0" alt="'
.
$emo
.
'" title="'
.
$emo
.
'" />'
,
$string
);
}
}
return
$string
;
}
else
{
return
$string
;
}
}
function
_badwords(
$string
) {
$cfgBBCodeSql
= db_query("SELECT
fcBadPatter,
fcBadReplace
FROM
prefix_bbcode_badword");
while
(
$row
= db_fetch_object(
$cfgBBCodeSql
) ) {
$pattern
[] =
"%"
.
addcslashes
(
$row
->fcBadPatter,
"[]{}%/$^()+.*\"\\"
).
"%iU"
;
$replace
[] =
$row
->fcBadReplace;
}
if
(isset(
$pattern
)) {
$string
= preg_replace(
$pattern
,
$replace
,
$string
);
}
return
$string
;
}
function
_list(
$codecid
) {
$string
=
$this
->codecblocks[
$codecid
.
':list'
];
$array
=
explode
(
"[*]"
,
$string
);
for
(
$no
=1;
$no
<=(
count
(
$array
)-1);
$no
++) {
$li
.=
"<li>"
.
$this
->parse(
$array
[
$no
]).
"</li>"
;
}
return
"<ul>"
.
$li
.
"</ul>"
;
}
function
_size(
$size
,
$string
) {
$max
=
$this
->info[
'SizeMax'
];
if
(
$size
<=
$max
) {
$fontsize
=
"<span style=\"font-size:"
.
$size
.
"px\">$string</span>"
;
}
else
{
$fontsize
=
"<span style=\"font-size:"
.
$max
.
"px\">$string</span>"
;
}
return
$fontsize
;
}
function
_img(
$string
,
$float
=
''
) {
if
(
$float
==
'none'
OR
$float
==
'left'
OR
$float
==
'right'
) {
$float
=
'style="float:'
.
$float
.
'; margin: 5px;" '
;
}
else
{
$float
=
''
;
}
$image
=
'<img src="'
.
$string
.
'" alt="" title="" border="0" class="bbcode_image" '
.
$float
.
'/>'
;
return
$image
;
}
function
_screenshot(
$string
,
$float
=
'none'
) {
if
(
$float
==
'none'
OR
$float
==
'left'
OR
$float
==
'right'
) {
$float
=
'style="float:'
.
$float
.
'; margin: 5px;" '
;
}
else
{
$float
=
''
;
}
$image
=
'<a href="'
.
$string
.
'" target="_blank"><img src="'
.
$string
.
'" alt="" title="" border="0" width="'
.
$this
->info[
'ScreenMaxBreite'
].
'" height="'
.
$this
->info[
'ScreenMaxHoehe'
].
'" '
.
$float
.
'/></a>'
;
return
$image
;
}
function
_filterurl(
$url
) {
str_replace
(
array
(
'<'
,
'>'
,
'('
,
')'
,
'#'
),
array
(
'<'
,
'>'
,
'('
,
')'
,
'#'
),
$url
);
return
$url
;
}
function
_shorturl(
$string
,
$caption
=null) {
if
(
$caption
== null) {
$caption
=
$string
; }
$string
= trim(
$this
->_filterurl(
$string
));
$caption
= trim(
$this
->_filterurl(
$caption
));
$server
=
'http://'
.
$_SERVER
[
'HTTP_HOST'
].
$_SERVER
[
'SCRIPT_NAME'
];
if
(preg_match(
'%^((http|ftp|https)://)|^/%i'
,
$string
) == 0) {
$string
=
'http://'
.
$string
; }
if
(
substr
(
$string
,0,1) ==
'/'
OR
strpos
(
$string
,
$server
) !== false) {
$target
=
'_self'
;
}
else
{
$target
=
'_blank'
;
}
$count
=
strlen
(
$caption
);
if
(
$count
>=
$this
->info[
'UrlMaxLaenge'
]) {
$string
=
"<a href=\""
.
$string
.
"\" target=\""
.
$target
.
"\">"
.
$this
->_shortcaptions(
$caption
).
"</a>"
;
}
else
{
$string
=
"<a href=\""
.
$string
.
"\" target=\""
.
$target
.
"\">"
.
$caption
.
"</a>"
;
}
return
$string
;
}
function
_shortcaptions(
$string
) {
$words
=
explode
(
" "
,
$string
);
foreach
(
$words
as
$word
)
if
(
strlen
(
$word
) >
$this
->info[
'WortMaxLaenge'
] && !preg_match(
'%(\[img\](.*)\[/img\])%i'
,
$word
)) {
$maxd2
= sprintf(
"%00d"
,(
$this
->info[
'WortMaxLaenge'
]/2));
$string
=
str_replace
(
$word
,
substr
(
$word
,0,
$maxd2
).
"..."
.
substr
(
$word
,-
$maxd2
),
$string
);
}
return
$string
;
}
function
_shortwords(
$string
) {
$lines
=
explode
(
"\n"
,
$string
);
$pattern
=
array
(
"url1"
=>
"%^(www)(.[-a-zA-Z0-9@:;\%_\+.~#?&//=]+?)%i"
,
"url2"
=>
"%^(http|https|ftp)://{1}[-a-zA-Z0-9@:;\%_\+.~#?&//=]+?%i"
,
"tags"
=>
"%(\[(url|img(=(left|right))?|shot(=(left|right))?)\](.*)\[/(url|img|shot)\])|(\[url=(.*)\])%i"
);
foreach
(
$lines
as
$line
) {
$words
=
explode
(
" "
,
$line
);
foreach
(
$words
as
$word
)
if
(
strlen
(
$word
) >
$this
->info[
'WortMaxLaenge'
] && !preg_match(
$pattern
[
'url1'
],
$word
) && !preg_match(
$pattern
[
'url2'
],
$word
) && !preg_match(
$pattern
[
'tags'
],
$word
)) {
$maxd2
= sprintf(
"%00d"
,(
$this
->info[
'WortMaxLaenge'
]/2));
$string
=
str_replace
(
$word
,
substr
(
$word
,0,
$maxd2
).
"..."
.
substr
(
$word
,-
$maxd2
),
$string
);
}
}
return
$string
;
}
function
_addKtextOpen(
$Titel
=Null) {
$this
->ayCacheKtextOpen[
count
(
$this
->ayCacheKtextOpen)+1] = true;
$intCountKtext
=
count
(
$this
->ayCacheKtextOpen);
$string
=
"[ktext:"
.
$intCountKtext
.
"="
.
$Titel
.
"]"
;
return
$string
;
}
function
_addKtextClose() {
$this
->ayCacheKtextClose[
count
(
$this
->ayCacheKtextClose)+1] = true;
$intCountKtext
=
count
(
$this
->ayCacheKtextClose);
return
"[/ktext:"
.
$intCountKtext
.
"]"
;
}
function
_ktext(
$string
) {
$Random
= rand(1,10000000);
$HeaderTitel
=
"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\""
.
$this
->info[
'KtextTabelleBreite'
].
"\" align=\"center\">"
.
"<tr><td><a href=\"javascript:Klapptext('__ID__')\">"
.
"<img src=\"include/images/icons/plus.gif\" id=\"image___ID__\" border=0 alt=\"Aus/Ein-klappen\" title=\"Aus/Ein-klappen\"> "
;
$FooterTitel
=
"</a></td></tr>"
.
"<tr><td><div id=\"layer___ID__\" style=\"display:none;border:1px "
.
$this
->info[
'KtextRandFormat'
].
" "
.
$this
->info[
'KtextRandFarbe'
].
";\">"
;
$KtextClose
=
"</div></td></tr></table>\n"
;
for
(
$c
=1;
$c
<=
count
(
$this
->ayCacheKtextOpen);
$c
++) {
if
(
count
(
$this
->ayCacheKtextClose) ==
count
(
$this
->ayCacheKtextOpen)) {
$this
->ktext_pattern[] =
"%\[ktext:"
.
$c
.
"=([^]]*)\]%siU"
;
$this
->ktext_replace[] =
str_replace
(
"__ID__"
,
$c
.
"@"
.
$Random
,
$HeaderTitel
).
"\$1"
.
str_replace
(
"__ID__"
,
$c
.
"@"
.
$Random
,
$FooterTitel
);
$this
->ktext_pattern[] =
"%\[/ktext:"
.
$c
.
"\]%siU"
;
$this
->ktext_replace[] =
$KtextClose
;
}
else
{
$this
->ktext_pattern[] =
"%\[ktext:([0-9]*)=([^]](.*)\[/ktext:([0-9]*)\]%siU"
;
$this
->ktext_replace[] =
str_replace
(
"__ID__"
,
"\$1@"
.
$Random
,
$HeaderTitel
).
"\$2"
.
str_replace
(
"__ID__"
,
"\$1@"
.
$Random
,
$FooterTitel
).
"\$3"
.
$KtextClose
;
}
}
$this
->ktext_pattern[] =
"%\[ktext:([0-9]*)=([^[/]*)\]%siU"
;
$this
->ktext_replace[] =
"[ktext=\$1]"
;
$this
->ktext_pattern[] =
"%\[/ktext:([0-9]*)\]%siU"
;
$this
->ktext_replace[] =
"[/ktext]"
;
$string
= preg_replace(
$this
->ktext_pattern,
$this
->ktext_replace,
$string
);
return
$string
;
}
function
_addQuoteOpen(
$User
=Null) {
$this
->ayCacheQuoteOpen[
count
(
$this
->ayCacheQuoteOpen)+1] =
$User
;
$intCountQuote
=
count
(
$this
->ayCacheQuoteOpen);
if
(
$User
!= NULL) {
$string
=
"[quote:"
.
$intCountQuote
.
"="
.
$User
.
"]"
;
}
else
{
$string
=
"[quote:"
.
$intCountQuote
.
"]"
;
}
return
$string
;
}
function
_addQuoteClose() {
$this
->ayCacheQuoteClose[
count
(
$this
->ayCacheQuoteClose)+1] = true;
$intCountQuote
=
count
(
$this
->ayCacheQuoteClose);
return
"[/quote:"
.
$intCountQuote
.
"]"
;
}
function
_quote(
$string
) {
if
(
strtolower
(
$this
->info[
'QuoteSchriftformatIT'
]) ==
"bold"
) {
$Schriftformat
=
"font-weight:bold;"
;
}
else
{
$Schriftformat
=
"font-style:"
.
$this
->info[
'QuoteSchriftformatIT'
].
";"
;
}
$Header
=
"<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"BORDER: 1px SOLID "
.
$this
->info[
'QuoteRandFarbe'
].
";\" width=\""
.
$this
->info[
'QuoteTabelleBreite'
].
"\" align=\"center\">"
.
"<tr><td style=\"font-family:Arial, Helvetica, sans-serif;FONT-SIZE:13px;FONT-WEIGHT:BOLD;COLOR:"
.
$this
->info[
'QuoteSchriftfarbe'
].
";BACKGROUND-COLOR:"
.
$this
->info[
'QuoteHintergrundfarbe'
].
";\"> Zitat</td></tr>"
.
"<tr bgcolor=\""
.
$this
->info[
'QuoteHintergrundfarbeIT'
].
"\"><td><table align=\"center\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"98%\"><tr><td style=\""
.
$Schriftformat
.
"FONT-SIZE:10px;COLOR:"
.
$this
->info[
'QuoteSchriftfarbeIT'
].
";\">"
;
$HeaderUser
=
"<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"BORDER: 1px SOLID "
.
$this
->info[
'QuoteRandFarbe'
].
";\" width=\""
.
$this
->info[
'QuoteTabelleBreite'
].
"\" align=\"center\">"
.
"<tr><td style=\"font-family:Arial, Helvetica, sans-serif;FONT-SIZE:13px;FONT-WEIGHT:BOLD;COLOR:"
.
$this
->info[
'QuoteSchriftfarbe'
].
";BACKGROUND-COLOR:"
.
$this
->info[
'QuoteHintergrundfarbe'
].
";\"> Zitat von "
;
$FooterUser
=
"</td></tr><tr bgcolor=\""
.
$this
->info[
'QuoteHintergrundfarbeIT'
].
"\"><td><table align=\"center\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"98%\"><tr><td style=\""
.
$Schriftformat
.
"FONT-SIZE:10px;COLOR:"
.
$this
->info[
'QuoteSchriftfarbeIT'
].
";\">"
;
$QuoteClose
=
"</td></tr></table></td></tr></table>"
;
$string
=
stripslashes
(
$string
);
for
(
$c
=1;
$c
<=
count
(
$this
->ayCacheQuoteOpen);
$c
++) {
if
(
count
(
$this
->ayCacheQuoteClose) ==
count
(
$this
->ayCacheQuoteOpen)) {
$this
->quote_pattern[] =
"%\[quote:"
.
$c
.
"=([^[/]*)\]%siU"
;
$this
->quote_replace[] =
$HeaderUser
.
"\$1"
.
$FooterUser
;
$this
->quote_pattern[] =
"%\[quote:"
.
$c
.
"\]%siU"
;
$this
->quote_replace[] =
$Header
;
$this
->quote_pattern[] =
"%\[/quote:"
.
$c
.
"\]%siU"
;
$this
->quote_replace[] =
$QuoteClose
;
}
else
{
$this
->quote_pattern[] =
"%\[quote:([0-9]*)=([^[/]*)\[/quote:([0-9]*)\]%siU"
;
$this
->quote_replace[] =
$HeaderUser
.
"\$2"
.
$FooterUser
.
"\$3"
.
$QuoteClose
;
$this
->quote_pattern[] =
"%\[quote:([0-9]*)\](.*)\[/quote:\\1\]%siU"
;
$this
->quote_replace[] =
$Header
.
"\$2"
.
$QuoteClose
;
}
}
$this
->quote_pattern[] =
"%\[quote:([0-9]*)=([^[/]*)\]%siU"
;
$this
->quote_replace[] =
"[quote=\$2]"
;
$this
->quote_pattern[] =
"%\[quote:([0-9])\]%siU"
;
$this
->quote_replace[] =
"[quote]"
;
$this
->quote_pattern[] =
"%\[/quote:([0-9])\]%siU"
;
$this
->quote_replace[] =
"[/quote]"
;
$string
= preg_replace(
$this
->quote_pattern,
$this
->quote_replace,
$string
);
return
$string
;
}
function
_video(
$typ
,
$id
) {
$typ
=
strtolower
(
$typ
);
if
(
$typ
==
"google"
) {
$str
=
"<embed style=\"width:"
.
$this
->info[
'GoogleBreite'
].
"px; height:"
.
$this
->info[
'GoogleHoehe'
].
"px;\" id=\"VideoPlayback\" align=\"middle\" type=\"application/x-shockwave-flash\" src=\"http://video.google.com/googleplayer.swf?docId="
.
$id
.
"\" allowScriptAccess=\"sameDomain\" quality=\"best\" bgcolor=\""
.
$this
->info[
'GoogleHintergrundfarbe'
].
"\" scale=\"noScale\" salign=\"TL\" FlashVars=\"playerMode=embedded\"/>"
;
}
if
(
$typ
==
"youtube"
) {
$str
=
"<object width=\""
.
$this
->info[
'YoutubeBreite'
].
"\" height=\""
.
$this
->info[
'YoutubeHoehe'
].
"\"><param name=\"movie\" value=\"http://www.youtube.com/v/"
.
$id
.
"\"></param><embed src=\"http://www.youtube.com/v/"
.
$id
.
"\" type=\"application/x-shockwave-flash\" width=\""
.
$this
->info[
'YoutubeBreite'
].
"\" height=\""
.
$this
->info[
'YoutubeHoehe'
].
"\" bgcolor=\""
.
$this
->info[
'YoutubeHintergrundfarbe'
].
"\"></embed></object>"
;
}
if
(
$typ
==
"myvideo"
) {
$str
=
"<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\""
.
$this
->info[
'MyvideoBreite'
].
"\" height=\""
.
$this
->info[
'MyvideoHoehe'
].
"\"><param name=\"movie\" value=\"http://www.myvideo.de/movie/"
.
$id
.
"\"></param><embed src=\"http://www.myvideo.de/movie/"
.
$id
.
"\" width=\""
.
$this
->info[
'MyvideoBreite'
].
"\" height=\""
.
$this
->info[
'MyvideoHoehe'
].
"\" type=\"application/x-shockwave-flash\"></embed></object>"
;
}
if
(
$typ
==
"gametrailers"
) {
}
return
$str
;
}
function
_countdown(
$date
,
$time
=NULL) {
$date
=
explode
(
"."
,
$date
);
if
(
$time
!= NULL) {
$timechk
=
explode
(
':'
,
$time
);
if
(
$timechk
[0] <= 23 &&
$timechk
[1] <= 59 &&
$timechk
[2] <= 59)
$timechk
= TRUE;
else
$timechk
= FALSE;
}
else
$timechk
= TRUE;
$Header
=
"<div style=\"width:"
.
$this
->info[
'CountdownTabelleBreite'
].
";padding:5px;font-family:Verdana;font-size:"
.
$this
->info[
'CountdownSchriftsize'
].
"px;"
.
$Font
.
"color:"
.
$this
->info[
'CountdownSchriftfarbe'
].
";border:2px dotted "
.
$this
->info[
'CountdownRandFarbe'
].
";text-align:center\">"
;
$Footer
=
"</div>"
;
if
(
$date
[0] <= 31 &&
$date
[1] <= 12 &&
$date
[2]
&&
checkdate
(
$date
[1],
$date
[0],
$date
[2]) &&
$timechk
) {
if
(isset(
$time
)) {
$time
=
explode
(
":"
,
$time
);
$intStd
=
$time
[0];
$intMin
=
$time
[1];
$intSek
=
$time
[2];
}
else
{
$intStd
= 0;
$intMin
= 0;
$intSek
= 0;
}
$Timestamp
= @
mktime
(
$intStd
,
$intMin
,
$intSek
,
$date
[1],
$date
[0],
$date
[2]);
$Diff
=
$Timestamp
- time();
$Font
=(
$this
->info[
'CountdownSchriftformat'
] ==
"bold"
) ?
"font-wight:bold;"
:
"font-style:"
.
$this
->info[
'CountdownSchriftformat'
].
";"
;
if
(
$Diff
> 1) {
$Tage
= sprintf(
"%00d"
,(
$Diff
/ 86400));
$Stunden
= sprintf(
"%00d"
,((
$Diff
- (
$Tage
* 86400)) / 3600));
$Minuten
= sprintf(
"%00d"
,((
$Diff
- ((
$Tage
* 86400)+(
$Stunden
*3600))) / 60));
$Sekunden
= (
$Diff
- ((
$Tage
* 86400)+(
$Stunden
*3600)+(
$Minuten
*60)));
$mzTg
= (
$Tage
== 1) ?
""
:
"e"
;
$mzStd
= (
$Stunden
== 1) ?
""
:
"n"
;
$mzMin
= (
$Minuten
== 1) ?
""
:
"n"
;
$mzSek
= (
$Sekunden
== 1) ?
""
:
"n"
;
$str
=
$Header
.
$Tage
.
" Tag"
.
$mzTg
.
", "
.
$Stunden
.
" Stunde"
.
$mzStd
.
", "
.
$Minuten
.
" Minute"
.
$mzMin
.
" und "
.
$Sekunden
.
" Sekunde"
.
$mzSek
.
$Footer
;
}
else
{
$str
=
$Header
.(
is_array
(
$time
) ? implode(
':'
,
$time
) :
$time
).
' '
.implode(
'.'
,
$date
).
" !!!"
.
$Footer
;
}
}
else
{
$str
=
$Header
.
"Der Countdown ist falsch definiert"
.
$Footer
;
}
return
$str
;
}
function
_ws(
$ws
) {
return
$ws
;
}
function
parse(
$string
) {
if
(
$this
->permitted[
'php'
] == true) {
$string
= preg_replace(
"%\[php\](.+)\[\/php\]%esiU"
,
"\$this->encode_codec('\$1','php')"
,
$string
);
$string
= preg_replace(
"%\[php=(.*)\](.+)\[\/php\]%esiU"
,
"\$this->encode_codec('\$2','php','\$1')"
,
$string
);
}
if
(
$this
->permitted[
'html'
] == true) {
$string
= preg_replace(
"%\[html\](.+)\[\/html\]%esiU"
,
"\$this->encode_codec('\$1','html')"
,
$string
);
$string
= preg_replace(
"%\[html=(.*)\](.+)\[\/html\]%esiU"
,
"\$this->encode_codec('\$2','html','\$1')"
,
$string
);
}
if
(
$this
->permitted[
'css'
] == true) {
$string
= preg_replace(
"%\[css\](.+)\[\/css\]%esiU"
,
"\$this->encode_codec('\$1','css')"
,
$string
);
$string
= preg_replace(
"%\[css=(.*)\](.+)\[\/css\]%esiU"
,
"\$this->encode_codec('\$2','css','\$1')"
,
$string
);
}
if
(
$this
->permitted[
'code'
] == true) {
$string
= preg_replace(
"%\[code\](.+)\[\/code\]%esiU"
,
"\$this->encode_codec('\$1','code')"
,
$string
);
$string
= preg_replace(
"%\[code=(.*)\](.+)\[\/code\]%esiU"
,
"\$this->encode_codec('\$2','code','\$1')"
,
$string
);
}
if
(
$this
->permitted[
'list'
] == true) {
$string
= preg_replace(
"%\[list\](.+)\[\/list\]%esiU"
,
"\$this->encode_codec('\$1','list')"
,
$string
);
}
$string
=
$this
->_shortwords(
$string
);
$string
= htmlentities(
$string
);
$string
=
nl2br
(
$string
);
if
(
$this
->permitted[
'url'
] == true) {
if
(
$this
->permitted[
'autourl'
] == true) {
$this
->pattern[] =
"%(( |\n|^)(www.[a-zA-Z\-0-9@:\%_\+.~#?&//=,;]+?))%eUi"
;
$this
->replace[] =
"\$this->_ws('\$2').\$this->_shorturl('\$3')"
;
$this
->pattern[] =
"%(( |\n|^)((http|https|ftp)://{1}[a-zA-Z\-0-9@:\%_\+.~#?&//=,;]+?))%eUi"
;
$this
->replace[] =
"\$this->_ws('\$2').\$this->_shorturl('\$3')"
;
$this
->pattern[] =
"%(( |\n|^)[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})%i"
;
$this
->replace[] =
"<a href=\"mailto:$1\">$1</a>"
;
}
$this
->pattern[] =
"%\[url=([^\]]*)\](.+)\[\/url\]%eUis"
;
$this
->replace[] =
"\$this->_shorturl('\$1','\$2')"
;
$this
->pattern[] =
"%\[url\](.+)\[\/url\]%esiU"
;
$this
->replace[] =
"\$this->_shorturl('\$1')"
;
}
if
(
$this
->permitted[
'email'
] == true) {
$this
->pattern[] =
"%\[mail\]([_\.0-9a-z-]+\@([0-9a-z\-]+)\.[a-z]{2,3})\[\/mail\]%Uis"
;
$this
->replace[] =
"<a href=\"mailto:$1\">$1</a>"
;
$this
->pattern[] =
"%\[mail=([_\.0-9a-z-]+\@([0-9a-z\-]+)\.[a-z]{2,3})\](.+)\[\/mail\]%Uis"
;
$this
->replace[] =
"<a href=\"mailto:$1\">$3</a>"
;
}
if
(
$this
->permitted[
'b'
] == true) {
$this
->pattern[] =
"%\[b\](.+)\[\/b\]%Uis"
;
$this
->replace[] =
"<b>\$1</b>"
;
}
if
(
$this
->permitted[
'i'
] == true) {
$this
->pattern[] =
"%\[i\](.+)\[\/i\]%Uis"
;
$this
->replace[] =
"<i>\$1</i>"
;
}
if
(
$this
->permitted[
'u'
] == true) {
$this
->pattern[] =
"%\[u\](.+)\[\/u\]%Uis"
;
$this
->replace[] =
"<u>\$1</u>"
;
}
if
(
$this
->permitted[
's'
] == true) {
$this
->pattern[] =
"%\[s\](.+)\[\/s\]%Uis"
;
$this
->replace[] =
"<strike>\$1</strike>"
;
}
###############################################
if
(
$this
->permitted[
'left'
] == true) {
$this
->pattern[] =
"%\[left\](.+)\[\/left\]%Uis"
;
$this
->replace[] =
"<div align=\"left\">\$1</div>"
;
}
if
(
$this
->permitted[
'center'
] == true) {
$this
->pattern[] =
"%\[center\](.+)\[\/center\]%Uis"
;
$this
->replace[] =
"<div align=\"center\">\$1</div>"
;
}
if
(
$this
->permitted[
'right'
] == true) {
$this
->pattern[] =
"%\[right\](.+)\[\/right\]%Uis"
;
$this
->replace[] =
"<div align=\"right\">\$1</div>"
;
}
###############################################
if
(
$this
->permitted[
'emph'
] == true) {
$this
->pattern[] =
"%\[emph\](.+)\[\/emph\]%Uis"
;
$this
->replace[] =
"<span style=\"background-color:"
.
$this
->info[
'EmphHintergrundfarbe'
].
";color:"
.
$this
->info[
'EmphSchriftfarbe'
].
";\">$1</span>"
;
}
if
(
$this
->permitted[
'color'
] == true) {
$this
->pattern[] =
"%\[color=(#{1}[0-9a-zA-Z]+?)\](.+)\[\/color\]%Uis"
;
$this
->replace[] =
"<font color=\"$1\">$2</font>"
;
}
if
(
$this
->permitted[
'size'
] == true) {
$this
->pattern[] =
"%\[size=([0-9]+?)\](.+)\[\/size\]%eUi"
;
$this
->replace[] =
"\$this->_size('\$1','\$2')"
;
}
if
(
$this
->permitted[
'ktext'
] == true) {
$this
->pattern[] =
"%\[ktext=([^[/]*)\]%esiU"
;
$this
->replace[] =
"\$this->_addKtextOpen('\\1')"
;
$this
->pattern[] =
"%\[/ktext\]%esiU"
;
$this
->replace[] =
"\$this->_addKtextClose()"
;
}
if
(
$this
->permitted[
'img'
] == true) {
$this
->pattern[] =
"%\[img\]([-a-zA-Z0-9@:\%_\+,.~#?&//=]+?)\[\/img\]%eUi"
;
$this
->replace[] =
"\$this->_img('\$1')"
;
$this
->pattern[] =
"%\[img=(left|right)\]([-a-zA-Z0-9@:\%_\+,.~#?&//=]+?)\[\/img\]%eUi"
;
$this
->replace[] =
"\$this->_img('\$2','\$1')"
;
}
if
(
$this
->permitted[
'screenshot'
] == true) {
$this
->pattern[] =
"%\[shot\]([-a-zA-Z0-9@:\%_\+.~#?&//=]+?)\[\/shot\]%eUi"
;
$this
->replace[] =
"\$this->_screenshot('\$1')"
;
$this
->pattern[] =
"%\[shot=(left|right)\]([-a-zA-Z0-9@:\%_\+.~#?&//=]+?)\[\/shot\]%eUi"
;
$this
->replace[] =
"\$this->_screenshot('\$2','\$1')"
;
}
if
(
$this
->permitted[
'video'
] == true) {
$this
->pattern[] =
"%\[video=(google|youtube|myvideo|gametrailers)\](.+)\[\/video\]%eUis"
;
$this
->replace[] =
"\$this->_video('\$1','\$2')"
;
}
if
(
$this
->permitted[
'countdown'
] == true) {
$this
->pattern[] =
"%\[countdown=(([0-9]{2}):([0-9]{2}):([0-9]{2}))\](([0-9]{2})\.([0-9]{2})\.([0-9]{4}))\[\/countdown\]%eUis"
;
$this
->replace[] =
"\$this->_countdown('\$5','\$1')"
;
$this
->pattern[] =
"%\[countdown\](([0-9]{2})\.([0-9]{2})\.([0-9]{4}))\[\/countdown\]%eUis"
;
$this
->replace[] =
"\$this->_countdown('\$1')"
;
}
###############################################
if
(
$this
->permitted[
'quote'
] == true) {
$this
->pattern[] =
"%\[quote\]%esiU"
;
$this
->replace[] =
"\$this->_addQuoteOpen()"
;
$this
->pattern[] =
"%\[quote=([^[/]*)\]%esiU"
;
$this
->replace[] =
"\$this->_addQuoteOpen('\\1')"
;
$this
->pattern[] =
"%\[/quote\]%esiU"
;
$this
->replace[] =
"\$this->_addQuoteClose()"
;
}
$string
= preg_replace(
$this
->pattern,
$this
->replace,
$string
);
if
(
$this
->permitted[
'quote'
] == true) {
$string
=
$this
->_quote(
$string
);
}
if
(
$this
->permitted[
'ktext'
] == true) {
$string
=
$this
->_ktext(
$string
);
}
$string
=
$this
->_smileys(
$string
);
if
(
$this
->permitted[
'php'
] == true) {
$string
= preg_replace(
"%\[php\](.+)\[\/php\]%esiU"
,
"\$this->_phpblock('\$1')"
,
$string
);
$string
= preg_replace(
"%\[php=([^;]*);(\d+)\](.+)\[\/php\]%esiU"
,
"\$this->_phpblock('\$3','\$1','\$2')"
,
$string
);
$string
= preg_replace(
"%\[php=(.*)\](.+)\[\/php\]%esiU"
,
"\$this->_phpblock('\$2','\$1')"
,
$string
);
}
if
(
$this
->permitted[
'html'
] == true) {
$string
= preg_replace(
"%\[html\](.+)\[\/html\]%esiU"
,
"\$this->_htmlblock('\$1')"
,
$string
);
$string
= preg_replace(
"%\[html=([^;]*);(\d+)\](.+)\[\/html\]%esiU"
,
"\$this->_htmlblock('\$3','\$1','\$2')"
,
$string
);
$string
= preg_replace(
"%\[html=(.*)\](.+)\[\/html\]%esiU"
,
"\$this->_htmlblock('\$2','\$1')"
,
$string
);
}
if
(
$this
->permitted[
'css'
] == true) {
$string
= preg_replace(
"%\[css\](.+)\[\/css\]%esiU"
,
"\$this->_cssblock('\$1')"
,
$string
);
$string
= preg_replace(
"%\[css=([^;]*);(\d+)\](.+)\[\/css\]%esiU"
,
"\$this->_cssblock('\$3','\$1','\$2')"
,
$string
);
$string
= preg_replace(
"%\[css=(.*)\](.+)\[\/css\]%esiU"
,
"\$this->_cssblock('\$2','\$1')"
,
$string
);
}
if
(
$this
->permitted[
'code'
] == true) {
$string
= preg_replace(
"%\[code\](.+)\[\/code\]%esiU"
,
"\$this->_codeblock('\$1')"
,
$string
);
$string
= preg_replace(
"%\[code=([^;]*);(\d+)\](.+)\[\/code\]%esiU"
,
"\$this->_codeblock('\$3','\$1','\$2')"
,
$string
);
$string
= preg_replace(
"%\[code=(.*)\](.+)\[\/code\]%esiU"
,
"\$this->_codeblock('\$2','\$1')"
,
$string
);
}
if
(
$this
->permitted[
'list'
] == true) {
$string
= preg_replace(
"%\[list\](.+)\[\/list\]%esiU"
,
"\$this->_list('\$1')"
,
$string
);
}
$string
=
$this
->_badwords(
$string
);
unset(
$this
->pattern);
unset(
$this
->replace);
unset(
$this
->ayCacheQuoteOpen);
unset(
$this
->ayCacheQuoteClose);
unset(
$this
->ayCacheKtextOpen);
unset(
$this
->ayCacheKtextClose);
return
$string
;
}
}
?>