Das Lesen des Source, um sich spielerische Vorteile zu verschaffen, ist nicht erlaubt. Solltest du Schwachstellen oder Fehler entdecken, bist du als Spieler verpflichtet, diese zu melden.
Und noch ein Hinweis für die Codekopierer unter Euch: Dieses Logd ist in großen Teilen umgeschrieben. Dies bedeutet, dass vermutlich wenig bis gar nichts läuft, was Ihr Euch von hier herunterladet. ;-) Einfacher ist es wahrscheinlich, wenn Ihr Euch per Hilfeanfrage ans Team wendet und dann bekommt Ihr auch die kompletten Codes mit Glück sogar mit Einbauanleitung.
<?php
require_once "common.php";
addcommentary();
session_write_close();
if (!empty($_GET['op']) && $_GET['op'] == "archive") {
popup_header("Nachrichtenarchiv von Silvanur");
} else {
popup_header("Silvanur - Neuigkeiten");
}
$superuser = 0;
if (!empty ($_SESSION['loggedin']) && $user['superuser']) {
$superuser = 1;
output ("[<a href='motd.php?op=add'>MoTD erstellen</a>|<a href='motd.php?op=addpoll'>Umfrage erstellen</a>]`n",true);
}
function motditem($subject,$body,$date = false){
if ($date) {
$date = date ("d.m.Y",strtotime($date));
$date.= ", ";
}
$subject = stripslashes($subject);
$body = stripslashes ($body);
output ("<h2>$date$subject</h2>",true);
output ("<p>$body</p>",true);
}
function pollitem($id,$subject,$body){
global $user;
$sql = "SELECT COUNT(resultid) AS c, MAX(choice) AS choice FROM pollresults WHERE motditem='$id' AND account='{$user['acctid']}'";
$result = db_query($sql);
$row = db_fetch_assoc($result);
$choice = $row['choice'];
$body = unserialize($body);
if ($row['c']==0 && 0){
output ("<form action='motd.php?op=vote' method='POST'>",true);
output ("<input type='hidden' name='motditem' value='$id'>
<h2>Umfrage: $subject</h2>
<p>".stripslashes($body['body'])."</p>\n",true);
while (list($key,$val)=each($body['opt'])){
if (trim($val)!=""){
output ("<input type='radio' name='choice' value='$key' id='o$key'>
<p><label for='o$key'>".stripslashes($val)."</label></p>\n",true);
}
}
output ("`n<input type='submit' class='button' value='Abstimmen'>",true);
output ("</form>",true);
}else{
output ("<form action='motd.php?op=vote' method='POST'>",true);
output ("<input type='hidden' name='motditem' value='$id'>",true);
output ("<h2>Umfrage: $subject</h2>",true);
output ("<p>".stripslashes($body['body'])."</p>\n",true);
$sql = "SELECT count(resultid) AS c, choice FROM pollresults WHERE motditem='$id' GROUP BY choice ORDER BY choice";
$result = db_query($sql);
$choices=array();
$totalanswers=0;
$maxitem = 0;
for ($i=0;$i<db_num_rows($result);$i++){
$row = db_fetch_assoc($result);
$choices[$row['choice']]=$row['c'];
$totalanswers+=$row['c'];
if ($row['c']>$maxitem) $maxitem = $row['c'];
}
while (list($key,$val)=each($body['opt'])){
if (trim($val) != ""){
if ($totalanswers<=0) $totalanswers=1;
$percent = @round($choices[$key] / $totalanswers * 100,1);
if ($maxitem==0){ $width=1; } else { $width = @round(($choices[$key]/$maxitem) * 400); }
$width = max($width,1);
output ("<p><input type='radio' id='o$key' class='noborder' name='choice' value='$key'".($choice==$key?" checked":"").">
<label for='o$key'>".stripslashes($val)." (".(int)@$choices[$key]." - $percent%)</label><br>
<img src='images/rule.gif' width='$width' height='2' alt='$percent'></p>\n",true);
}
}
output ("`n<input type='submit' class='button' value='Abstimmen'></form>",true);
}
}
function motdform($subject = "",$body = "",$id = false) {
global $output;
$id = ($id?"<input type='hidden' name='motditem' value='$id'>":"");
$subject = htmlentities (stripslashes($subject),ENT_QUOTES);
$body = htmlentities (stripslashes($body),ENT_QUOTES);
$output.="<form name='form1' method='post' action=''>
<label for='subject'>Titel</label><br>
<input type='text' name='subject' id='subject' value='$subject'><br>
<label for='body'>Text</label><br>
<textarea name='body' id='body' cols='40' rows='10'>$body</textarea><br>
$id
<input type='submit' name='submit' value='hinzufügen'>
</form>";
}
if (empty ($_GET['op']) || (!empty ($_GET['op']) && $_GET['op'] == "archive")){
if (empty ($_GET['op'])) {
output ("<div class='nav'><ul>
<li><a href='motd.php?op=archive'>Nachrichtenarchiv</a></li></ul><div class='clear'></div></div>",true);
}
$sql= "";
if (empty ($_GET['op']) && !empty ($_SESSION['loggedin'])) {
$sql = "SELECT * FROM motd WHERE motddate > '{$user['lastmotd']}' ORDER BY motddate DESC";
} elseif (!empty($_GET['op']) && $_GET['op'] == "archive") {
$sql = "SELECT * FROM motd ORDER BY motddate DESC";
}
if (empty ($sql))
$sql = "SELECT * FROM motd ORDER BY motddate DESC LIMIT 10";
$result = db_query($sql);
if (db_num_rows ($result) == 0)
$result = db_query ("SELECT * FROM motd ORDER BY motddate DESC LIMIT 10");
while ($row = db_fetch_assoc($result)) {
if ($row['motdtype']==0){
motditem($row['motdtitle'].($superuser?"[<a href='motd.php?op=del&id=$row[motditem]' onClick=\"return confirm('Bist du sicher, dass dieser Eintrag gelöscht werden soll?');\">Del</a> | <a href='motd.php?op=update&id=$row[motditem]'>Edit</a>]":""),$row['motdbody'],$row['motddate']);
}else{
pollitem($row['motditem'],$row['motdtitle'].($superuser?"[<a href='motd.php?op=del&id=$row[motditem]' onClick=\"return confirm('Bist du sicher, dass dieser Eintrag gelöscht werden soll?');\">Del</a>]":""),$row['motdbody']);
}
}
if (!empty ($user['name'])) {
headline("`@Kommentare zu den Neuigkeiten:");
viewcommentary("motd",$user['name']." sagt: ",1,"sagt",0);
}
} elseif($_GET['op']=="vote"){
if ($user['acctid']) {
db_query("DELETE FROM pollresults WHERE motditem='".(int)$_POST['motditem']."' AND account='{$user['acctid']}'");
db_query("INSERT INTO pollresults (choice,account,motditem) VALUES ('".(int)$_POST['choice']."','{$user['acctid']}','{$_POST['motditem']}')");
}
header("Location: motd.php");
exit();
} elseif($_GET['op']=="addpoll"){
if($superuser){
$subject = (empty ($_POST['subject'])?"":$_POST['subject']);
$body = (empty ($_POST['body'])?"":$_POST['body']);
if (empty ($subject) || empty ($body)){
allownav ("motd.php?op=add");
$output.="<form action='motd.php?op=addpoll' method='POST'>
<label for='subject'>Titel</label><br>
<input type='text' id='subject' size='50' name='subject' value='$subject'><br>
<label for='body'>Text</label><br>
<textarea class='input' id='body' name='body' cols='37' rows='5'>$body</textarea><br>\n";
for ($i=1;$i<16;$i++) {
$output.= "<label for='option$i'>Wahlmöglichkeit $i</label>
<input name='opt[]' id='option$i'><br>\n";
}
$output.="<input type='submit' class='button' value='Hinzufügen'>
</form>";
}else{
$body = array("body"=>$_POST['body'],"opt"=>$_POST['opt']);
$sql = "INSERT INTO motd (motdtitle,motdbody,motddate,motdtype) VALUES ('".addslashes($_POST['subject'])."','".addslashes(serialize($body))."',NOW(),1)";
db_query($sql);
header("Location: motd.php");
exit();
}
} else {
systemmail(1,"MOTD-Betrug","$user[login] mit Acctid $user[acctid] hat versucht, eine MOTD zu ändern.");
header("Location: motd.php");
exit();
}
} elseif($_GET['op']=="add"){
if ($superuser){
$subject = (empty ($_POST['subject'])?"":$_POST['subject']);
$body = (empty ($_POST['body'])?"":$_POST['body']);
if (empty ($subject) || empty ($body)){
allownav ("motd.php?op=add");
motdform ($subject,$body);
}else{
db_query ("INSERT INTO motd (motdtitle,motdbody,motddate) VALUES ('".addslashes($subject)."','".addslashes($body)."',NOW())");
header("Location: motd.php");
exit();
}
} else {
systemmail(1,"MOTD-Betrug","$user[login] mit Acctid $user[acctid] hat versucht, eine MOTD zu ändern.");
header("Location: motd.php");
exit();
}
}elseif($_GET['op']=="update"){
if ($superuser){
$subject = (empty ($_POST['subject'])?"":$_POST['subject']);
$body = (empty ($_POST['body'])?"":$_POST['body']);
if (empty ($subject) || empty ($body)) {
allownav ("motd.php?op=add");
$row = db_fetch_assoc (db_query ("SELECT motdtitle, motdbody,motditem FROM motd WHERE motditem = '".(int) $_GET['id']."'"));
motdform (stripslashes($row['motdtitle']),stripslashes($row['motdbody']),$row['motditem']);
}else{
db_query ("UPDATE motd SET motdtitle= '".addslashes($subject)."', motdbody = '".addslashes($body)."' WHERE motditem = '".(int)$_POST['motditem']."'");
header("Location: motd.php");
exit();
}
} else {
systemmail(1,"MOTD-Betrug","$user[login] mit Acctid $user[acctid] hat versucht, eine MOTD zu ändern.");
header("Location: motd.php");
exit();
}
} elseif ($_GET['op']=="del"){
if ($superuser){
$sql = "DELETE FROM motd WHERE motditem='".(int)$_GET['id']."'";
db_query($sql);
header("Location: motd.php");
exit();
} else {
systemmail(1,"MOTD-Betrug","$user[login] mit Acctid $user[acctid] hat versucht, eine MOTD zu ändern.");
header("Location: motd.php");
exit();
}
}
popup_footer();
?>