LoGD Standardrelease steht hier zum Download zur Verfügung!
<?php
/*
2021-06-05 aragon bugfix php8
2023-05-18 aragon bugfix php8
*/
require_once "common.php";
$loggedin = $session['user']['loggedin'] ?? false;
$superuser = $session['user']['superuser'] ?? 0;
if ($loggedin) checkday();
if (!$loggedin) {
addnav("Login", "index.php");
} elseif ($session['user']['alive']) {
addnav("Dorfplatz", "village.php");
} else {
if($session['user']['sex'] == 1) {
addnav("`!`bDu bist tot, Jane!`b`0");
} else {
addnav("`!`bDu bist tot, Jim!`b`0");
}
addnav("Profil", "prefs.php");
addnav("Land der Schatten", "shades.php");
addnav("Log out", "login.php?op=logout");
addnav("News");
}
addnav("Aktualisieren", "news.php");
addnav("Über das Spiel", "about.php");
if ($superuser) {
addnav("Neuer Tag", "newday.php");
}
$newsperpage=50;
page_header("LoGD News");
if ($superuser==3){
output("`0<form action=\"news.php\" method='POST'>", true);
output("[Admin] Meldung manuell eingeben? <input name='meldung' size='40'> ", true);
output("<input type='submit' class='button' value='Eintragen'>`n`n", true);
addnav("", "news.php");
$acctid = $session['user']['acctid'];
if ($_POST['meldung']??"") {
$sql = "INSERT INTO news(newstext,newsdate,accountid) VALUES ('".addslashes($_POST['meldung'])."',NOW(),".$acctid.")";
db_query($sql);
}
addnav("", "news.php");
}
$offset = (int)($_GET['offset']??0);
$timestamp=strtotime((0-$offset)." days");
$sql = "SELECT count(newsid) AS c FROM news WHERE newsdate='".date("Y-m-d",$timestamp)."'";
$result = db_query($sql);
$row = db_fetch_assoc($result);
$totaltoday=$row['c'];
$pageoffset = (int)($_GET['page']??0);
if ($pageoffset>0) $pageoffset--;
$pageoffset*=$newsperpage;
$sql = "SELECT * FROM news WHERE newsdate='".date("Y-m-d",$timestamp)."' ORDER BY newsid DESC LIMIT $pageoffset,$newsperpage";
$result = db_query($sql) or die(db_error(LINK));
$date=date("D, M j, Y",$timestamp);
output("`c`b`!News für $date".($totaltoday>$newsperpage?" (Meldungen ".($pageoffset+1)." - ".min($pageoffset+$newsperpage,$totaltoday)." von $totaltoday)":"")."`c`b`0");
for ($i=0;$i<db_num_rows($result);$i++){
$row = db_fetch_assoc($result);
output("`c`2-=-`@=-=`2-=-`@=-=`2-=-`@=-=`2-=-`0`c");
if ($superuser>=3) {
output("[ <a href='superuser.php?op=newsdelete&newsid={$row['newsid']}&return=".URLEncode($_SERVER['REQUEST_URI'])."'>Del</a> ] ", true);
addnav("", "superuser.php?op=newsdelete&newsid={$row['newsid']}&return=".URLEncode($_SERVER['REQUEST_URI']));
}
output("$row[newstext]`n");
}
if (db_num_rows($result)==0) {
output("`c`2-=-`@=-=`2-=-`@=-=`2-=-`@=-=`2-=-`0`c");
output("`1`b`c Es ist nichts erwähnenswertes passiert. Alles in allem bisher ein langweiliger Tag. `c`b`0");
}
output("`c`2-=-`@=-=`2-=-`@=-=`2-=-`@=-=`2-=-`0`c");
if ($totaltoday>$newsperpage) {
addnav("Heutige News");
for ($i=0;$i<$totaltoday;$i+=$newsperpage) {
addnav("Seite ".($i/$newsperpage+1), "news.php?offset=$offset&page=".($i/$newsperpage+1));
}
//addnav("Sonstiges");
}
page_footer();
?>