", $input);
$input = preg_replace("/</i", "<", $input);
$input = preg_replace("/"/i", "\"", $input);
$input = preg_replace("/&/i", "&", $input);
return $input;
}
function smileys($text) {
$text=unhtmlspecialchars($text);
$filepath = "./images/smileys/";
unset($files);
if ($dh = opendir($filepath)) {
while($file = readdir($dh)) {
if (ereg("\.gif",$file)) $files[] = $file;
}
}
foreach($files as $file) {
$smiley = explode(".", $file);
$text = eregi_replace (":".$smiley[0].":", '[IMG]images/smileys/'.$file.'[/IMG]', $text);
}
$ergebnis = safe_query("SELECT * FROM `".PREFIX."smileys`");
while($ds = mysql_fetch_array($ergebnis)) {
$text = str_replace($ds['pattern'], '[IMG]images/smileys/'.$ds['name'].'[/IMG]', $text);
}
$text=htmlspecialchars($text);
return $text;
}
function flags($text) {
$ergebnis = safe_query("SELECT * FROM `".PREFIX."countries`");
while($ds = mysql_fetch_array($ergebnis)) {
$text = str_replace ("[flag]".$ds[short]."[/flag]", '', $text);
}
//entfernen überflüssiger flag-tags
$text = str_replace ("[flag][/flag]", '', $text);
$text = str_replace ("[flag]", '', $text);
$text = str_replace ("[/flag]", '', $text);
return $text;
}
//replace [code]-tags
function codereplace($content) {
$border=BORDER;
$bg1=BG_1;
$match_count = preg_match_all("#\[code\](.*?)\[\/code\]#si", $content, $code);
for ($i = 0;$i < $match_count;$i++)
{
$before_replace = $code[1][$i];
$codestring = $code[1][$i];
$content = str_replace('[CODE]', '[code]', $content);
$content = str_replace('[/CODE]', '[/code]', $content);
$code_entities_match = array('#<#', '#>#', '#"#', '#:#', '#\[#', '#\]#', '#\(#', '#\)#', '#\{#', '#\}#','# #');
$code_entities_replace = array('<', '>', '"', ':', '[', ']', '(', ')', '{', '}', ' ');
$codestring = preg_replace($code_entities_match, $code_entities_replace, $codestring);
$content=str_replace('[code]'.$before_replace.'[/code]', '
code:[HR][FONT=COURIER]'.$codestring.'[/FONT] |
', $content);
}
return $content;
}
//replace [img]-tags
function imgreplace($content) {
global $picsize_l;
global $picsize_h;
$autoresize=0;
if($autoresize==1) {
preg_match_all("|(\[img\])(.*)(\[\/img\])|i", $content, $imgtags, PREG_SET_ORDER);
foreach($imgtags as $teil) {
$content = str_replace('[IMG]', '[img]', $content);
$content = str_replace('[/IMG]', '[/img]', $content);
$picinfo = getimagesize($teil[2]);
switch($picinfo[2]) {
case 1: $format = "gif"; break;
case 2: $format = "jpeg"; break;
}
if(!$picsize_l) $size_l = "9999"; else $size_l=$picsize_l;
if(!$picsize_h) $size_h = "9999"; else $size_h=$picsize_h;
if($picinfo[0] > $size_l OR $picinfo[1] > $size_h) $content = str_replace('[img]'.$teil[2].'[/img]', '[url='.$teil[2].']
([i]auto-resize: '.$picinfo[1].'x'.$picinfo[0].'px, '.$format.'[/i])[/url]', $content);
elseif($picinfo[0] > (2*$size_l) OR $picinfo[1] > (2*$size_h)) $content = str_replace('[img]'.$teil[2].'[/img]', '[url='.$teil[2].'][b]Large picture[/b]
('.$picinfo[1].'x'.$picinfo[0].'px, '.$format.')[/url]', $content);
else {
$content = str_replace('[img]'.$teil[2].'[/img]', '', $content);
}
}
}
else $content = preg_replace("#\[img\](.*?)\[/img\]#si", "", $content);
return $content;
}
//replace [quote]-tags
function quotereplace($content) {
$border=BORDER;
$bg1=BG_1;
$content = preg_replace("#\[quote=(.*?)\]#si", "[quote][b]\\1 wrote:[/b][br][hr]",$content);
//prepare: how often start- and end-tag occurrs
$starttags = substr_count($content, '[quote]');
$endtags = substr_count($content, '[/quote]');
$overflow=abs($starttags-$endtags);
for($i=0;$i<$overflow;$i++) {
if($starttags>$endtags) $content=$content.'[/quote]';
elseif($endtags>$starttags) $content='[quote]'.$content;
}
$content = preg_replace("#\[quote\]#si", '', $content, 10);
$content = preg_replace("#\[/quote\]#si", ' |
',$content, 10);
//remove overflowed quote-tags
$content=eregi_replace('\[quote\]','',$content);
$content=eregi_replace('\[/quote\]','',$content);
return $content;
}
function insertlinks($content) {
//insert member links
$ergebnis = safe_query("SELECT us.userID, us.nickname, us.country FROM ".PREFIX."squads_members AS sq, ".PREFIX."user AS us WHERE sq.userID=us.userID GROUP BY us.userID");
while($ds = mysql_fetch_array($ergebnis)) {
$content = str_replace($ds[nickname].' ', '[flag]'.$ds[country].'[/flag] '.$ds[nickname].' ', $content);
}
return $content;
}
function replacement($content) {
$pagebg=PAGEBG;
$border=BORDER;
$bg1=BG_1;
$bghead=BGHEAD;
$bgcat=BGCAT;
$content = codereplace($content);
$content = imgreplace($content);
$content = quotereplace($content);
$content = preg_replace("#\[url\]http://(.*?)\[img\]http://(.*?)\[/img\]\[/url\]#si", "", $content);
$content = preg_replace("#\[url\]www.(.*?)\[img\]www.(.*?)\[/img\]\[/url\]#si", "", $content);
$content = preg_replace("#\[url=http://(.*?)\]\[img\]http://(.*?)\[/img\]\[/url\]#si", "", $content);
$content = preg_replace("#\[url=www.(.*?)\]\[img\]www.(.*?)\[/img\]\[/url\]#si", "", $content);
$content = preg_replace("#\[url\]http://(.*?)\[/url\]#si", "\\1", $content); // [url]http://.......[/url]
$content = preg_replace("#\[url\]www.(.*?)\[/url\]#si", "http://www.\\1", $content); // [url]www...........[/url]
$content = preg_replace("#\[url=http://(.*?)\](.*?)\[/url\]#si", "\\2", $content); // [url=http://..]link[/url]
$content = preg_replace("#\[url=www.(.*?)\](.*?)\[/url\]#si", "\\2", $content); // [url=www......]link[/url]
$content = preg_replace("#\[url=(.*?)\](.*?)\[/url\]#si", "\\2", $content); // relativer link
$content = preg_replace("#\[url\](.*?)\[/url\]#si", "\\1", $content); // relativer link
$content = preg_replace("#(^|[^\"=]{1})(http://|https://|ftp://|mailto:|news:)([^\s<>]+)([\s\n<>]|$)#sm","\\1\\3\\4",$content);
$content = preg_replace("#\[email\](.*?)\[/email\]#si", "\\1", $content);
$content = preg_replace("#\[email=(.*?)\](.*?)\[/email\]#si", "\\2", $content);
$content = preg_replace("#\[size=(.*?)\](.*?)\[/size\]#si", "\\2", $content);
$content = preg_replace("#\[color=(.*?)\](.*?)\[/color\]#si", "\\2", $content);
$content = preg_replace("#\[font=(.*?)\](.*?)\[/font\]#si", "\\2", $content);
$content = preg_replace("#\[align=(.*?)\](.*?)\[/align\]#si", "\\2
", $content);
$content = preg_replace("#\[b\](.*?)\[/b\]#si", "\\1",$content);
$content = preg_replace("#\[i\](.*?)\[/i\]#si", "\\1",$content);
$content = preg_replace("#\[u\](.*?)\[/u\]#si", "\\1",$content);
$content = preg_replace("#\[s\](.*?)\[/s\]#si", "\\1",$content);
$content = preg_replace("#\[pre\](.*?)\[/pre\]#si","\\1
", $content);
$content = preg_replace("#\[list\](.*?)\[/list\]#si", "", $content);
$content = preg_replace("#\[list=1\](.*?)\[/list=1\]#si", "\\1
", $content);
$content = preg_replace("#\[list=a\](.*?)\[/list=a\]#si", "\\1
", $content);
$content = preg_replace("#\[\*\](.*?)\[/\*\]#si", "\\1", $content);
$content = preg_replace("#\[br]#si", "
", $content);
$content = preg_replace("#\[hr]#si", "
", $content);
$content = preg_replace("#\[center]#si", "", $content);
$content = preg_replace("#\[/center]#si", "", $content);
return $content;
}
function toggle($content, $id) {
$replace1='
\\2 |
';
$replace2=' |
';
$n=1;
while($pos = strpos(strtoupper($content), "[TOGGLE=")) {
$start = substr($content, 0, $pos);
$end= substr($content, $pos+7);
$middle='[TOGGLE_'.$n;
$content = $start.$middle.$end;
$n++;
}
$content = preg_replace("#\[TOGGLE_(.*?)=(.*?)\]#si", $replace1, $content);
$content = preg_replace("#\[/TOGGLE\]#si", $replace2, $content);
return $content;
}
?>