require_once "common.php";
addcommentary();
session_write_close();
popup_header("LoGD Message of the Day (MoTD)");
if(isset($session['user']['superuser']) && $session['user']['superuser']>=3) {
output(" [MoTD erstellen|Umfrage erstellen]`n",true);
}
function motditem($subject,$body){
output("`b$subject`b`n",true);
output("$body");
output("
",true);
}
function pollitem($id,$subject,$body){
global $session;
$sql = "SELECT count(resultid) AS c, MAX(choice) AS choice FROM pollresults WHERE motditem='$id' AND account='{$session['user']['acctid']}'";
$result = db_query($sql);
$row = db_fetch_assoc($result);
$choice = $row['choice'];
$body = unserialize($body);
if ($row['c']==0 && 0){
output("",true);
}else{
output("",true);
}
output("",true);
}
$op = empty($_GET['op']) ? '' : $_GET['op'];
switch ($op) {
case 'vote':
$sql = "DELETE FROM pollresults WHERE motditem='{$_POST['motditem']}' AND account='{$session['user']['acctid']}'";
db_query($sql);
$sql = "INSERT INTO pollresults (choice,account,motditem) VALUES ('{$_POST['choice']}','{$session['user']['acctid']}','{$_POST['motditem']}')";
db_query($sql);
header("Location: motd.php");
exit();
break;
case 'addpoll':
if($session['user']['superuser']>=3){
if ($_POST['subject']=="" || $_POST['body']==""){
output("",true);
}else{
$body = array("body"=>$_POST['body'],"opt"=>$_POST['opt']);
$sql = "INSERT INTO motd (motdtitle,motdbody,motddate,motdtype) VALUES (\"$_POST[subject]\",\"".addslashes(serialize($body))."\",now(),1)";
db_query($sql);
header("Location: motd.php");
exit();
}
break;
}
case 'add':
if ($session['user']['superuser']>=3){
$subject = empty($_POST['subject']) ? '' : $_POST['subject'];
$body = empty($_POST['body']) ? '' : $_POST['body'];
if (empty($_POST['subject']) || empty($_POST['body'])){
output("",true);
}else{
$sql = "INSERT INTO motd (motdtitle,motdbody,motddate) VALUES ('$subject','$body',now())";
db_query($sql);
header("Location: motd.php");
exit();
}
break;
}
case 'del':
if ($session['user']['superuser']>=3){
$sql = "DELETE FROM motd WHERE motditem=\"$_GET[id]\"";
db_query($sql);
header("Location: motd.php");
exit();
break;
}
case 'badboy': // Fall-trough-Trick zur redundanzverminderung bei versuchtem cheat
if (!empty($session['user']['loggedin'])){
$session['user']['experience']=round($session['user']['experience']*0.9,0);
addnews($session['user']['name']." wurde für den Versuch, die Götter zu betrügen, bestraft.");
output("Du hast versucht die Götter zu betrügen. Du wurdest mit Vergessen bestraft. Einiges von dem, was du einmal gewusst hast, weisst du nicht mehr.");
saveuser();
}
break;
default:
output("`&");
motditem("Beta!","Bitte beachte die Hinweise ganz unten.");
output("`%");
$sql = "SELECT * FROM motd ORDER BY motddate DESC limit 20";
$result = db_query($sql);
for ($i=0;$i$session['user']['lastmotd'] || $i<5){
if ($row['motdtype']==0){
motditem($row['motdtitle'].($session['user']['superuser']>=3?"[Del]":""),$row['motdbody']);
}else{
pollitem($row['motditem'],$row['motdtitle'].($session['user']['superuser']>=3?"[Del]":""),$row['motdbody']);
}
}
}
output("`&");
motditem("Beta!","Diese Seite ist im BETA Status! Ich bastel daran herum, wenn ich Zeit habe. Auch Änderungen von offizieller Seite (MightyE) werden hier übernommen. Das ist KEIN Freibrief zum Ausnutzen von Bugs, sondern alle Spieler (Teilnehmer am Beta-Test) sind verpflichtet, gefundene Fehler zu melden! Wünsche und Anregungen werden ebenfalls jederzeit gern angenommen. :-)");
output("`@Kommentare und Fehler:`0`n");
viewcommentary("motd");
break;
}
$session['needtoviewmotd']=false;
if(!empty($session['user']['loggedin'])) {
$sql = "SELECT motddate FROM motd ORDER BY motditem DESC LIMIT 1";
$result = db_query($sql);
$row = db_fetch_assoc($result);
$session['user']['lastmotd']=$row['motddate'];
}
popup_footer();
?>