<?php
$xml = load_compressed_xml_file('notes.xml');
$counter = 0;
echo '<br><h2>Notizen</h2><br>';
foreach($xml->notice AS $notice) {
if($notice['visibleon']==basename($_SERVER['SCRIPT_NAME']).'?'.implode('&',$_GET)) {
if($notice['visiblefor']=="everyone" OR in_array($_SESSION['user'],explode(',',$notice['visiblefor'])) OR $_SESSION['user']==$config[1]) {
echo '<div class="notice" id="'.$counter.'"><span class="from">'.$notice->from.'</span> <span class="time">'.$notice->date.'</span><br><span class="content">'.$notice->content.'</span>';
foreach($notice->comments->comment AS $comment) {
if($comment['visiblefor']=="everyone" OR in_array($_SESSION['user'],explode(',',$comment['visiblefor'])) OR $_SESSION['user']==$config[1]) {
echo '<br><div class="comment"><span class="commentedby">'.$comment['from'].'</span> <span class="commenttime">'.$comment['date'].'</span><br>'.$comment.'</div>';
}
}
if($notice['comments_enabled']!="false") {
echo '<br><span class="comment"><a href="javascript:;" name="commentthis">Kommentar zu dieser Notiz hinzufügen</a></span></div>';
}
else {
echo '<br><span class="comment" style="color:red">Kommentarfunktion geschlossen</span></div>';
}
}
}
$counter++;
}
echo '<form action="view.php?action=new_notice" method="post" id="newnotice"><input type="hidden" name="visibleon" value="'.basename($_SERVER['SCRIPT_NAME']).'?'.implode('&',$_GET).'"><span class="new_notice"><b>Sichtbar für:</b><br><input type="radio" name="visiblefor" value="everyone" id="visiblefor1" checked><label for="visiblefor1">Alle Nutzer</label><br><input type="radio" name="visiblefor" value="defined_users" id="visiblefor2"><label for="visiblefor2">Benutzerdefiniert*: <input type="text" name="users" placeholder="Nutzer1,Nutzer2"></label><br><input type="radio" name="visiblefor" value="me" id="visiblefor3"><label for="visiblefor3">Nur mich</label></span><textarea id="new_notice_text" name="content" placeholder="Notiz anfügen..." style="width:75%"></textarea><span class="new_notice"><input type="checkbox" name="comments_enabled" checked> Kommentare erlauben<br><input type="submit" value="Notiz anheften"></span></form>
<script>
document.getElementById("newnotice").addEventListener("mouseover",function() {
divs = document.getElementsByClassName("new_notice");
divs[0].style.animation = "fadein 0.5s";
divs[1].style.animation = "fadein 0.5s";
divs[0].style.display = "block";
divs[1].style.display = "block";
});
document.getElementById("newnotice").addEventListener("mouseleave",function() {
divs = document.getElementsByClassName("new_notice");
divs[0].style.animation = "fadeout 0.5s";
divs[1].style.animation = "fadeout 0.5s";
setTimeout(function() { divs[0].style.display = "none";
divs[1].style.display = "none";
},500);
});
var comment = document.getElementsByName("commentthis");
comment.forEach(function(element) {';
echo str_replace('apostrophe',"'",'element.addEventListener("click",function() { this.parentElement.innerHTML = apostrophe<form action="view.php?action=comment_notice" method="post" style="box-shadow:none;position:relative;top:-10px;margin-top:-10px" class="comment"><b>Sichtbar für:</b><br><input type="radio" name="visiblefor" value="everyone" id="visiblefor1"><label for="visiblefor1">Alle Nutzer</label><br><input type="radio" name="visiblefor" value="defined_users" id="visiblefor2"><label for="visiblefor2">Benutzerdefiniert*: <input type="text" name="users" placeholder="Nutzer1,Nutzer2"></label><br><input type="radio" name="visiblefor" value="me" id="visiblefor3"><label for="visiblefor3">Nur mich</label><br><textarea name="content" minlength="1" maxlength="500" placeholder="Kommentar..."></textarea><br><input type="submit" value="Kommentieren"><br><i style="font-size:10pt">*Namen der Nutzer mit Komma getrennt</i><input type="hidden" name="visibleon" value="'.basename($_SERVER['SCRIPT_NAME']).'?'.implode('&',$_GET).'"><input type="hidden" name="notice" value="apostrophe + this.parentElement.parentElement.id + apostrophe"></form>apostrophe; });');
echo '});</script>';
?>
<link rel="Stylesheet" href="style.php" type="text/css">