ALTER TABLE `vms_news` ADD `category` TINYINT NOT NULL DEFAULT '1' ;
PHP-Code:
<?php
if (!isset($titel)) $titel = '';
if (!isset($news)) $news = '';
if (!isset($id)) $id = '0';
if (!isset($_POST['auffuehren'])) $_POST['auffuehren'] = '0';
if (!isset($_POST['load'])) $_POST['load'] = '0';
if (!isset($_POST['loader'])) $_POST['loader'] = '0';
if (!isset($_POST['category'])) $_POST['category'] = '1';
if ($_POST['news4'] == 'seite') {
db_query("UPDATE " . $db_prefix . "_kontodaten SET news='1' WHERE 1");
if ($_POST['id'] == 0) db_query("INSERT INTO " . $db_prefix . "_news (zeit,titel,news,category) VALUES ('" . time() . "','" . $_POST['titel'] . "','" . $_POST['news'] . "','" . $_POST['category'] . "')");
if ($_POST['id'] >= 1) db_query("UPDATE " . $db_prefix . "_news SET titel='" . $_POST['titel'] . "',news='" . $_POST['news'] . "' WHERE id='" . $_POST['id'] . "'");
}
if ($_POST['news2'] == 'Newsletter und seite') {
db_query("UPDATE " . $db_prefix . "_kontodaten SET news='1' WHERE 1");
if ($_POST['id'] == 0) db_query("INSERT INTO " . $db_prefix . "_news (zeit,titel,news,category) VALUES ('" . time() . "','" . $_POST['titel'] . "','" . $_POST['news'] . "','" . $_POST['category'] . "')");
if ($_POST['id'] >= 1) db_query("UPDATE " . $db_prefix . "_news SET titel='" . $_POST['titel'] . "',news='" . $_POST['news'] . "' WHERE id='" . $_POST['id'] . "'");
$empfaenger = db_query('SELECT emailadresse FROM ' . $db_prefix . '_emaildaten WHERE freigabe_fuer = 1 OR freigabe_fuer = 3 GROUP BY emailadresse');
while ($user = mysql_fetch_assoc($empfaenger)) usermail ($user['emailadresse'], $_POST['titel'], $_POST['news'], '"' . $seitenname . '" <' . $betreibermail . '>');
}
if ($_POST['news3'] == 'Newsletter') {
db_query("UPDATE " . $db_prefix . "_kontodaten SET news='1' WHERE 1");
$empfaenger = db_query('SELECT emailadresse FROM ' . $db_prefix . '_emaildaten WHERE freigabe_fuer = 1 OR freigabe_fuer = 3 GROUP BY emailadresse');
while ($user = mysql_fetch_assoc($empfaenger)) usermail ($user['emailadresse'], $_POST['titel'], $_POST['news'], '"' . $seitenname . '" <' . $betreibermail . '>');
}
if ($_POST['load'] == 'Editieren') {
$edit = mysql_fetch_array(db_query("SELECT * FROM " . $db_prefix . "_news WHERE id='" . $_POST['loader'] . "'"));
$titel = $edit['titel'];
$news = $edit['news'];
$id = $edit['id'];
}
if ($_POST['load'] == 'Löschen') {
db_query("DELETE FROM " . $db_prefix . "_news WHERE id='" . $_POST['loader'] . "'");
}
head("News editieren / löschen");
?>
<table>
<form action="" method="post">
<tr>
<td>
<select name="loader" size="1">
<?php
$old_news = db_query("SELECT * FROM " . $db_prefix . "_news ORDER BY id DESC");
while ($load = mysql_fetch_array($old_news)) {
echo '<option value="' . $load['id'] . '">(' . $load['id'] . ') - ' . $load['titel'] . ' (' . date("d.m.Y - H:i", $load['zeit']) . ')</option>';
}
?>
</select>
</td>
<td><input type="Submit" name="load" value="Editieren"></td>
<td><input type="Submit" name="load" value="Löschen"></td>
</tr>
</form>
</table>
<?php foot();
head("News schreiben (html erlaubt!)");
?>
<div align="center">
<form action="" method="post">
<b>Newstitel</b><br>
<input type="Text" name="titel" value="<?php echo $titel;?>"><br>
<br>
<select name="category" size="1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<b>News</b><br>
<textarea name="news" style="width:900px; height:1000px;"><?php echo $news;?></textarea><br>
<br>
<br>
<input type="Submit" name="news4" value="seite">
<input type="Submit" name="news2" value="Newsletter und seite">
<input type="Submit" name="news3" value="Newsletter">
<input type="Hidden" name="id" value="<?php echo $id;?>">
</form>
</div>
<?php foot();?>
PHP-Code:
<?php
$gelesen = db_query("UPDATE " . $db_prefix . "_kontodaten SET news='0' WHERE uid = " . $_SESSION['uid'] . "");
if ($_GET['seite'] == '') {
$_GET['seite'] = 1;
}
if (!isset($_GET['category']) or !in_array($_GET['category'],array(1,2,3))) {
$category = 1;
}else{
$category = (int)$_GET['category']
}
$start = $_GET['seite'] * 10 - 10;
$sql = db_query("SELECT * FROM " . $db_prefix . "_news WHERE `category` = '".$category."' ORDER BY id DESC LIMIT $start, 10");
while ($news = mysql_fetch_array($sql)) {
head($news['titel'] . ' vom ' . date("d.m.Y - H:i:s", $news['zeit']));
echo'<div style="text-align: left; ">';
echo '<br>';
echo nl2br($news['news']);
echo'</div>';
foot();
}
head('Seiten');
$seiten = db_query("SELECT id FROM " . $db_prefix . "_news");
$menge = mysql_num_rows($seiten);
$seitenanzahl = $menge / 10;
echo "<font face=\"Verdana\" size=\"1\" ><b>Seite:</b> </font> ";
for($a = 0; $a < $seitenanzahl; $a++) {
$b = $a + 1;
if ($_GET['seite'] == $b) {
echo " $b ";
} else {
echo " <a href=\"?content=/news/index&seite=$b\">$b</a> ";
}
}
?>
probier mal....
im userbereich dan ?content=/news&category=1 2 oder 3 ... letzte chance vorbei ;-)