<?php
function bbcodes($text)
{
$neuertext = stripslashes($text);
$neuertext = preg_replace("/\[img\](.*)\[\/img\]/isU", "<img src=\"$1\" border='0' />", $neuertext);
$neuertext = preg_replace("/\[center\](.*)\[\/center\]/isU", "<center>$1</center>", $neuertext);
$neuertext = preg_replace("/\[b\](.*)\[\/b\]/isU", "<b>$1</b>", $neuertext);
$neuertext = preg_replace("/\[i\](.*)\[\/i\]/isU", "<i>$1</i>", $neuertext);
$neuertext = preg_replace("/\[u\](.*)\[\/u\]/isU", "<u>$1</u>", $neuertext);
$neuertext = eregi_replace("([ \r\n])www\\.([^ ,\r\n]*)","\\1http://www.\\2",$neuertext);
$neuertext = eregi_replace("([ \r\n])http\:\/\/www\\.([^ ,\r\n]*)","\\1http://www.\\2",$neuertext);
$neuertext = preg_replace("/\[url\]www.(.*)\[\/url\]/isU", "http://www.$1", $neuertext);
$neuertext = preg_replace("/\[url=(.*?)\](.*?)\[\/url\]/", "<a href=\"\\1\" target='_blank'>\\2</a>", $neuertext);
$neuertext = preg_replace("/\[url\](.*)\[\/url\]/isU", "<a href='$1' target='_blank'>$1</a>", $neuertext);
$neuertext = preg_replace("/\[red\](.*)\[\/red\]/isU", "<font color='red'>$1</font>", $neuertext);
$neuertext = preg_replace("/\[blue\](.*)\[\/blue\]/isU", "<font color='blue'>$1</font>", $neuertext);
$neuertext = preg_replace("/\[yellow\](.*)\[\/yellow\]/isU", "<font color='yellow'>$1</font>", $neuertext);
$neuertext = preg_replace("/\[size=(.*)\](.*)\[\/size\]/isU", "<font size='$1'>$2</font>", $neuertext);
$neuertext = preg_replace("/\[quote\](.*)\[\/quote\]/isU", "<table border='1' cellspacing='0' cellpadding='2' bgcolor='EFEFEF' width='95%' align='center'><tr><td>$1</tr></td></table>", $neuertext);
$neuertext = preg_replace("/\[quote=(.*)\](.*)\[\/quote\]/isU", "<table border='1' cellspacing='0' cellpadding='2' bgcolor='EFEFEF' width='95%' align='center'><tr><td><i>Orginal von $1:</i><br><br>$2</tr></td></table>", $neuertext);
}
return $neuertext;
}
$conn_id = mysql_connect($host,$id,$pw);
mysql_select_db($database,$conn_id);
?>
<?php
} else {
echo "
<table align=\"center\" width=\"540\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" bordercolor=\"#000000\">
<tr>
<td width=\"540\"><font color=\"#FFFFFF\"></font></td>
</tr></table><p>
";
$result = mysql_query("select * from $table ORDER BY datum DESC LIMIT 0, 4");
if ($num = mysql_num_rows($result)) {
for($i=0;$i < $num; $i++) {
$titel = mysql_result($result,$i,"titel");
$autor = mysql_result($result,$i,"autor");
$bild = mysql_result($result,$i,"bild");
$datum = mysql_result($result,$i,"datum");
$text = mysql_result($result,$i,"text");
$neuertext = bbcodes($text);
echo "
<table width=\"550\" border=\"0\" bgcolor=\"black\" cellpadding=\"0\" cellspacing=\"1\">
<!--DWLayoutTable-->
<tr>
<td height=\"28\" colspan=\"2\" valign=\"top\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
<!--DWLayoutTable-->
<tr>
<td width=\"435\" style=\"background-image:url(images/content_bg.jpg)\" height=\"28\">$titel</td>
<td width=\"113\" style=\"background-image:url(images/1stmc.jpg)\" valign=\"top\"><!--DWLayoutEmptyCell--> </td>
</tr>
</table></td>
</tr>
<tr>
<td height=\"151\" colspan=\"2\" valign=\"top\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
<!--DWLayoutTable-->
<tr>
<td width=\"468\" bgcolor=\"#F2F2F2\" rowspan=\"2\" valign=\"top\">$neuertext</td>
<td width=\"80\" bgcolor=\"#F2F2F2\" height=\"80\"><div align=\"center\"><img src=\"images/$bild.jpg\" width=\"70\" height=\"70\"></div></td>
</tr>
<tr>
<td height=\"71\" bgcolor=\"#F2F2F2\"> </td>
</tr>
</table></td>
</tr>
<tr>
<td width=\"274\" bgcolor=\"#F2F2F2\" height=\"24\">geschrieben von $autor</td>
<td width=\"273\" bgcolor=\"#F2F2F2\"><div align=\"right\">$datum</div></td>
</tr>
</table><br>
";
}
} else echo "Keine News geschreiben";
}
?>