engelsystem/nonpublic/news_output.php.old

91 lines
2.6 KiB
PHP
Executable File

<?php
include ("./inc/db.php");
include ("./inc/funktion_user.php");
if ( isset($text) && isset($betreff) && IsSet($date) ) {
if (!isset($treffen)) $treffen = 0;
$escaped_text = htmlescape($text);
$escaped_betreff = htmlescape($betreff);
$SQL = "INSERT INTO `News` (`Datum`, `Betreff`, `Text`, `UID`, `Treffen`) ";
$SQL.= "VALUES ('$date', '$escaped_betreff', '$escaped_text', '".$_SESSION['UID'];
$SQL.= "', '$treffen');";
$Erg = mysql_query($SQL, $con);
if ($Erg == 1) { echo "Eintrag wurde gespeichert<br><br>"; }
}
if (!IsSet($news_begin)) {
$news_begin=0;
}
if (!IsSet($DISPLAY_NEWS)) {
$DISPLAY_NEWS = 5;
}
if (($news_begin-$DISPLAY_NEWS) >= 0 ) {
echo "<br><br><a href=\"./news.php?news_begin=".($news_begin-$DISPLAY_NEWS)."\">Die vorherigen $DISPLAY_NEWS News anzeigen...</a><br>";
}
$SQL = "SELECT * FROM `News` ORDER BY 'ID' DESC LIMIT $news_begin,$DISPLAY_NEWS";
$Erg = mysql_query($SQL, $con);
// anzahl zeilen
$news_rows = mysql_num_rows($Erg);
for ($n = 0 ; $n < $news_rows ; $n++) {
echo "<p class='question'><u>".mysql_result($Erg, $n, "Betreff")."</u><br>\n";
echo "&nbsp; &nbsp;<font size=1>".mysql_result($Erg, $n, "Datum").", ";
echo UID2Nick(mysql_result($Erg, $n, "UID"))."</font>";
// avatar anzeigen?
echo DisplayAvatar (mysql_result($Erg, $n, "UID"));
echo "</p>\n";
echo "<p class='answer'>".nl2br(mysql_result($Erg, $n, "Text"))."</p>\n";
$RefID=mysql_result($Erg, $n, "ID");
$countSQL="SELECT COUNT(*) from news_comments where Refid = '$RefID'";
$countErg = mysql_query($countSQL, $con);
$countcom = mysql_result($countErg, 0, "COUNT(*)");
echo "<p class='comment' align='right'><a href=\"./news_comments.php?nid=$RefID\">$countcom comments</a></p>\n\n";
}
echo "<a href=\"./news.php?news_begin=".($news_begin+$DISPLAY_NEWS)."\">Die n&auml;chsten $DISPLAY_NEWS News anzeigen...</a>";
?>
<br>
<hr>
<h4>Neue News erstellen:</h4>
<a name="Neu">&nbsp;</a>
<form action="<? echo $ENGEL_ROOT ?>nonpublic/news.php" method="post">
<?
// Datum mit uebergeben, um doppelte Eintraege zu verhindern
// (Reload nach dem Eintragen!)
?>
<input type="hidden" name="date" value="<? echo date("Y-m-d H:i:s"); ?>">
<table>
<tr>
<td align="right">Betreff:</td>
<td><input type="text" name="betreff" size="60"></td>
</tr>
<tr>
<td align="right">Text:</td>
<td><textarea name="text" cols="50" rows="10"></textarea></td>
</tr>
<?
if ($_SESSION['Rechte']!= 0) {
?>
<tr>
<td align="right">Treffen:</td>
<td><input type="checkbox" name="treffen" size="1" value="1"></td>
</tr>
<?
}
?>
</table>
<br>
<input type="submit" value="sichern...">
</form>