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:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
|
<html>
<head>
<title>Newsscript</title>
</head>
<body>
<?php
function bbcode_parse($text)
{
$text = preg_replace("/\[img\](.*?)\[\/img\]/si", '<img src="\\1" border="0" />', $text);
$text = preg_replace("/\[url\](.*?)\[\/url\]/si", '<a>\\1</a>', $text);
$text = preg_replace("/\[url=\'(.*?)\'\](.*?)\[\/url\]/si", '<a href="\\1">\\2</a>', $text);
$text = preg_replace("/\[url=(.*?)\](.*?)\[\/url\]/si", '<a href="\\1">\\2</a>', $text);
$text = preg_replace("/\[align=(.*?)\](.*?)\[\/align\]/si", '<span style="text-align:\\1">\\2</span>', $text);
$text = preg_replace("/\[email\](.*?)\[\/email\]/si", '<a href="mailto:\\1">\\1</a>', $text);
$text = preg_replace("/\[code\](.*?)\[\/code\]/si", 'Code:<div style="text-align:left;border:1px solid black;font-size:12px;color:green;background-color:#ececec;padding:5px;">\\1</div>', $text);
$text = preg_replace("/\[quote\](.*?)\[\/quote\]/si", 'Zitat:<div style="text-align:left;border:1px solid black;font-size:12px;color:blue;background-color:#ececec;padding:5px;">\\1</div>', $text);
$text = preg_replace('/\[(\/?)(b|i|u|li|ul|ol)\]/i', '<$1$2>', $text);
$text = preg_replace('/^(={1,6})\s*(.+)\s*(\1)\s*$/me', '\'<h\'.strlen(\'$1\').\'>\'.rtrim(\'$2\').\'</h\'.strlen(\'$1\').\'>\'', $text);
return nl2br($text);
}
$host = 'localhost'; // Adresse des MySQL-Servers (meist localhost)
$username = 'DBUSER'; // MySQL-Benutzer ... Besitzer der Datenbank
$dbname = 'DATENBANKNAME'; // Name der Datenbank
$passwd = 'PASSWORT'; // Passwort des MySQL-Benutzers
$url2profile = 'http://board.dizzy-w3.at/index.php?page=User&userID='; // URL zum Profil, ohne ID
$n = 1; // ID des Boards
&newsBoardID = 35; // Die ID des Forums, welches die News beinhaltet, für alle %
@$db = new mysqli($host, $username, $passwd, $dbname);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = 'SELECT bb' . $n . '_posts.username, bb' . $n . '_posts.posttopic, bb' . $n . '_posts.message, wbb' . $n . '_posts.posttime, bb' . $n . '_threads.starterid, bb' . $n . '_threads.views
FROM bb' . $n . '_posts, bb' . $n . '_threads
WHERE bb' . $n . '_posts.threadid = bb' . $n . '_threads.threadid
AND bb' . $n . '_thread.boardID = 35
ORDER BY bb' . $n . '_threads.starttime DESC
LIMIT 0 , 30';
$res = $db->query($query);
$num_res = $res->num_rows;
for($i = 0; $i < $num_res; $i++)
{
$row = $res->fetch_assoc();
echo '<b>'.($i+1).'. '.stripslashes($row['posttopic']).'</b> von <a href="'.$url2profile.stripslashes($row['starterid']).'">'.stripslashes($row['username']).'</a></span>';
echo '<p>'.bbcode_parse(stripslashes($row['message'])).'</p><br /><br />Views: '.stripslashes($row['views']).'';
}
$res->close();
$db->close();
?>
</body>
</html> |