Heyho, habe da ma ne Frage undzwar speichert das Housekeeping die News nicht ab, die man erstellt habe euch mal den Code mitgebracht und würde mich freuen wenn ihr mir weiterhelfen könnt.
PHP
<?php
$id = protect($GET[3]);
switch ($GET[2]) {
case 'add':
if (Accessfunction('addnews')) {
$index = 'add';
$image = '110.png';
if (isset($_POST['submit'])) {
echo 'xd';
$title = protect(umlautenew($_POST['title']));
$image = protect($_POST['image']);
$datei = protect($_FILES['datei']['tmp_name']);
$vortext = umlautenew($_POST['vortext']);
$langtext = umlautenew($_POST['langtext']);
$autor = protect($_POST['autor']);
$publikation = protect($_POST['publikation']);
$kommentar = protect($_POST['kommentar']);
$check = $mysqli->query("SELECT * FROM users WHERE rank > 4 AND id = '" . $autor . "'");
if ($check->num_rows < 1) {
$msg = 'Serverfehler 502';
$fehler = 'true';
}
if (strlen($title) < 5) {
$msg = 'Der Titel muss mehr als 5 Zeichen enthalten!';
$fehler = 'true';
}
if (strlen($title) > 45) {
$msg = 'Der Titel darf nicht mehr als 45 Zeichen enthalten!';
$fehler = 'true';
}
if (strlen($vortext) < 5) {
$msg = 'Der Vortext muss mehr als 5 Zeichen enthalten!';
$fehler = 'true';
}
if (strlen($langtext) < 5) {
$msg = 'Der Langtext muss mehr als 5 Zeichen enthalten!';
$fehler = 'true';
}
if ($fehler !== 'true') {
if ($datei !== '') {
move_uploaded_file($_FILES['datei']['tmp_name'], './public/images/news/' . $_FILES['datei']['name']);
$image = protect($_FILES['datei']['name']);
}
if (strtotime($publikation) < time()) {
$status = '1';
$publikation = '0';
} else {
$status = '0';
$publikation = strtotime($publikation);
}
$mysqli->query("INSERT INTO hp_news (title, vortext, langtext, autor, timestamp, kommentar, status, publikation_spaeter, image, gesehen) VALUES ('" . $title . "', '" . $vortext . "', '" . $langtext . "', '" . $autor . "', '" . time() . "', '" . $kommentar . "', '" . $status . "', '" . $publikation . "', '" . $image . "', '0')");
$search = $mysqli->query("SELECT * FROM hp_news WHERE title = '" . $title . "' ORDER BY id DESC");
$seid = $search->fetch_object();
aktivitaetenstream($user->id, 'addnews', $seid->id);
hklogs('add', $seid->id);
$msg = 'Erfolgreich gespeichert!';
header("location: $path/admin/news");
exit;
}
$title = protect($_POST['title']);
$vortext = protect($_POST['vortext']);
$langtext = protect($_POST['langtext']);
$autor = protect($_POST['autor']);
$publikation = protect($_POST['publikation']);
$kommentar = protect($_POST['kommentar']);
}
}
break;
case 'edit':
if (Accessfunction('editnews')) {
$sql = $mysqli->query("SELECT * FROM hp_news WHERE id = '" . $id . "' ");
if ($sql->num_rows > 0) {
$row = $sql->fetch_object();
$index = 'edit';
if (isset($_POST['submit'])) {
$title = protect(umlautenew($_POST['title']));
$image = protect($_POST['image']);
$datei = protect($_FILES['datei']['tmp_name']);
$vortext = umlautenew($_POST['vortext']);
$langtext = umlautenew($_POST['langtext']);
$autor = protect($_POST['autor']);
$publikation = protect($_POST['publikation']);
$kommentar = protect($_POST['kommentar']);
$check = $mysqli->query("SELECT * FROM users WHERE rank > 4 AND id = '" . $autor . "'");
if ($check->num_rows < 1) {
$msg = 'Serverfehler 502';
$fehler = 'true';
}
if (strlen($title) < 5) {
$msg = 'Der Titel muss mehr als 5 Zeichen enthalten!';
$fehler = 'true';
}
if (strlen($title) > 45) {
$msg = 'Der Titel darf nicht mehr als 45 Zeichen enthalten!';
$fehler = 'true';
}
if (strlen($vortext) < 5) {
$msg = 'Der Vortext muss mehr als 5 Zeichen enthalten!';
$fehler = 'true';
}
if (strlen($langtext) < 5) {
$msg = 'Der Langtext muss mehr als 5 Zeichen enthalten!';
$fehler = 'true';
}
if ($fehler !== 'true') {
if ($datei !== '') {
move_uploaded_file($_FILES['datei']['tmp_name'], './public/images/news/' . $_FILES['datei']['name']);
$image = protect($_FILES['datei']['name']);
}
$mysqli->query("UPDATE hp_news set image = '" . $image . "' WHERE id = '" . $row->id . "'");
$mysqli->query("UPDATE hp_news SET title = '" . $title . "', publikation_spaeter = '" . strtotime($publikation) . "', vortext = '" . $vortext . "', langtext = '" . $langtext . "', autor = '" . $autor . "', kommentar = '" . $kommentar . "' WHERE id = '" . $row->id . "'");
hklogs('edit', $row->id);
$msg = 'Erfolgreich gespeichert!';
}
$row->title = protect($_POST['title']);
$row->vortext = protect($_POST['vortext']);
$row->langtext = $_POST['langtext'];
$row->autor = protect($_POST['autor']);
$row->publikation = protect($_POST['publikation']);
$row->kommentar = protect($_POST['kommentar']);
}
}
}
break;
case 'del':
if (Accessfunction('delnews')) {
if (isset($GET2)) {
$sql = $mysqli->query("SELECT * FROM hp_news WHERE id = '" . $GET2 . "' ");
if ($sql->num_rows > 0) {
$mysqli->query("DELETE FROM hp_news WHERE id = '" . $GET2 . "' ");
header("location: $path/admin/news&msg=Die News wurde erfolgreich gelöscht!");
exit;
}
} else {
$sql = $mysqli->query("SELECT * FROM hp_news WHERE id = '" . $GET2 . "' ");
if ($sql->num_rows > 0) {
$row = $sql->fetch_object();
} else {
header("location: $path/admin/news");
exit;
}
}
}
break;
default:
$index = 'list';
$getallNews = $mysqli->query("SELECT * FROM hp_news ORDER by published DESC");
break;
}
?>
<?php if ($index == 'list') { ?>
<?php if (Accessfunction('addnews')) { ?>
<div onClick="goLink('<?php echo $path; ?>/admin/news/add')" class="submit green" style="width: 820px;float: right;margin-top: 10px;height: 35px;line-height: 35px;">News schreiben</div>
<?php } ?>
<div id="column" class="right" style="float: right;width: 800px;">
<div class="title rot">News übersicht (<?php echo $getallNews->num_rows; ?> geschriebene News)</div>
<?php
$i = 0;
while ($row = $getallNews->fetch_object()) {
$i++;
?>
<div style="margin-left: -10px;width: 820px;height: 120px;<?php
if ($i % 2) {
echo 'background-color: rgba(0, 0, 0, 0.2);';
}
?>">
<div style="float: left;width: 100px;margin-top: 10px;margin-left: 10px;height: 100px;border-radius: 150px;background: url('<?php echo $row->image; ?>') no-repeat;"></div>
<div style="float: right;margin-top: 10px;margin-right: 10px;">
<center><?php echo date('d.m.Y H:i', $row->published); ?></center>
<?php if (Accessfunction('editnews')) { ?>
<div onClick="goLink('<?php echo $path; ?>/admin/news/edit/<?php echo $row->id; ?>')" class="submit green" style="width: 150px;line-height: 30px;margin-top: 10px;">Bearbeiten</div>
<?php } ?>
<?php if (Accessfunction('delnews')) { ?>
<div onClick="goLink('<?php echo $path; ?>/admin/news/del/<?php echo $row->id; ?>')" class="submit red" style="width: 150px;line-height: 30px;margin-top: 10px;">Löschen</div>
<?php } ?>
</div>
<div style="float: left;font-weight: bold;font-size: 18px;margin-left: 15px;margin-top: 20px;width: 500px;"><?php echo protect(umlautenew($row->title)); ?></div>
<div style="float: left;font-weight: lighter;font-style: italic;font-size: 13px;margin-left: 15px;margin-top: 5px;width: 500px;"><?php echo protect(umlautenew($row->vortext)); ?></div>
<div style="float: left;margin-left: 15px;">Geschrieben von <b><?php echo UserIDDB($row->author, 'username'); ?></b></div>
<?php if ($row->status == '0') { ?>
<div style="font-size: 12px;position: absolute; margin-left: 15px;margin-top: 10px;">
News wird am <b><?php echo date('d.m.Y H:i', $row->publikation_spaeter); ?></b> Uhr bekannt gegeben.
</div>
<?php } ?>
</div>
<?php } ?>
</div>
<?php } ?>
<?php if ($index == 'add') {
?>
<style>
.newsvor {
width: 563px;
margin-right: 0px;
}
.beschreibung {
width: 573px;
border-radius: 0px;
position: absolute;
height: 40px;
line-height: 40px;
background: rgba(0,0,0,0.4);
color: #FFF;
font-size: 16px;
padding-left: 10px;
}
.newsbox {
float: left;
margin-right: 10px;
margin-left: 0px;
}
.weiterlesen {
float: right;
margin-right: 10px;
margin-top: 4px;
height: 30px;
line-height: 30px;
border: 1px solid #000;
border-bottom: 2px solid #000;
text-shadow: 0 1px 0 #000;
font-size: 14px;
font-weight: 600;
padding-left: 10px;
padding-right: 10px;
color: #FFF;
background: -moz-linear-gradient(#3BA800 0%,#2C7E00 100%);
background: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#3BA800),color-stop(100%,#2C7E00));
background: -webkit-linear-gradient(#3BA800 0%,#2C7E00 100%);
background: -o-linear-gradient(#3BA800 0%,#2C7E00 100%);
background: -ms-linear-gradient(#3BA800 0%,#2C7E00 100%);
background: linear-gradient(to bottom,#3BA800 0%,#2C7E00 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#3BA800',endColorstr='#2C7E00',GradientType=0);
cursor: pointer;
border-radius: 3px;
}
</style>
<?php if (isset($msg)) { ?>
<?php if ($fehler == 'true') { ?>
<div id="column" class="error right" style="float: right;width: 800px;">
<?php echo $msg; ?>
</div>
<?php } else { ?>
<div id="column" class="success right" style="float: right;width: 800px;">
<?php echo $msg; ?>
</div>
<?php } ?>
<?php } ?>
<script src="https://code.jquery.com/jquery-1.11.0.js?NEW"></script>
<link href="<?php echo $path; ?>/public/editor/css/font-awesome.min.css?NEW" rel="stylesheet" type="text/css" />
<link href="<?php echo $path; ?>/public/editor/css/froala_editor.min.css?NEW" rel="stylesheet" type="text/css" />
<link href="<?php echo $path; ?>/public/editor/css/froala_style.min.css?NEW" rel="stylesheet" type="text/css" />
<script src="<?php echo $path; ?>/public/editor/js/froala_editor.min.js?NEW"></script>
<script src="https://editor.froala.com/assets/editor/froala_editor.min-0a48153d2d19b75d1f56865be888dcb7.js?NEW"></script>
<script src="https://editor.froala.com/assets/load_plugins-d9503ed6cef6604ff5f01265e1afb22c.js?NEW"></script>
<!--[if lt IE 9]>
<!-- Include IE8 JS. -->
<script src="<?php echo $path; ?>/public/editor/js/froala_editor_ie8.min.js"></script>
<![endif]-->
<script>
$(function () {
$(".textarea").editable({inlineMode: false, buttons: ['bold', 'italic', 'underline', 'strikeThrough', 'fontSize', 'color', 'blockStyle', 'align', 'insertImage', 'html', 'sep', 'undo', 'redo']})
});
$(document).ready(function () {
$(".froala-box a").remove();
});
</script>
<div class="newsshow" style="display: none;width: 750px;float: right;">
<div onClick="backtoNews()" class="submit red" style="float: right;width: 800px;height: 35px;line-height: 35px;margin-top: 10px;">Zurück zur News</div>
<div id="column" class="newsvor" style="float: right;width: 400px;height: 190px;margin-right: 0px;">
<div class="beschreibung" style="width: 410px;margin-left: -10px;margin-top: 161px;border-radius: 0px 0px 5px 5px;"><div class="weiterlesen">Weiterlesen</div> <span class="nntitle">Raum der Woche [03]</span></div>
</div>
<div id="column" class="newsshoww right" style="width: 730px;float: right;">
</div>
</div>
<div id="column" class="newssettings right" style="float: right;width: 800px;">
<div class="title blau">Neuigkeit hinzufügen</div>
<form action="" method="post" enctype="multipart/form-data">
<b>Newstitel</b>
<input type="text" class="input ntitle" name="title" value="<?php echo $title; ?>" style="width: 790px;" placeholder="Titel von der Neuigkeit">
<b>Newsbild</b><br>
<div style="width: 100%;height: 200px;margin-bottom: 40px;">
<div id="image" class="image" style="height: 210px;width: 400px;border-radius: 5px;background: url('<?php echo $path; ?>/public/images/news/<?php echo $image; ?>') no-repeat;background-position: 50% 100%;float: right;"></div>
<br><br><br><br>
<select class="input nimage" name="image" style="width: 380px;" onChange="changebild(this.value)">
<?php
if ($handle = opendir('./public/images/news/')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && $entry != "index.php") {
?><option value="<?php echo $entry; ?>" <?php
if ($entry == $image) {
echo 'selected';
}
?>><?php echo $entry; ?></option> <?php
}
}
closedir($handle);
}
?>
</select>
Upload:<br> <input type="file" name="datei" size="50" maxlength="100000" onchange="showMyImage(this)">
</div>
<b>Kurzstory</b><br>
<textarea name="vortext" class="textarea nvortext">
<?php echo $vortext; ?>
</textarea><br>
<b>Story</b><br>
<textarea name="langtext" class="textarea nlangtext">
<?php echo $langtext; ?>
</textarea><br>
<b>Autor</b><br>
<select class="input" name="autor">
<?php
$mitarbeiter = $mysqli->query("SELECT * FROM users WHERE rank > 5");
while ($roww = $mitarbeiter->fetch_object()) {
?>
<option value="<?php echo $roww->id; ?>" <?php
if ($roww->id == $autor) {
echo 'selected';
}
?>><?php echo $roww->username; ?></option>
<?php } ?>
</select>
<b>Wann soll die News publiziert werden?</b> (Beispiel: <?php echo date('d.m.Y H:i'); ?>)<br>
<input type="text" name="publikation" class="input">
<b>Kommentaren zulassen?</b><br>
<select class="input" name="kommentar">
<option value="1">Zulassen</option>
<option value="0" <?php
if ($kommentar == '0') {
echo 'selected';
}
?>>Verbieten</option>
</select>
<input type="submit" name="submit" class="submit" value="News Speichern" style="height: 42px;float: right;width: 200px;">
<div onClick="showvorschau()" class="submit red" style="float: right;width: 150px;height: 40px;line-height: 40px;margin-right: 10px;font-size: 13px;">News anschauen</div>
</form>
</div>
<script>
function showvorschau()
{
var title = $(".ntitle").val();
var desc = $(".nvortext").val();
var story = $(".nlangtext").val();
var image = $(".nimage").val();
$(".newssettings").hide();
$(".newsshoww").html('<div class="title blau"><div style="float: right;margin-right: 10px;font-weight: bold;"><?php echo date('d.m.Y'); ?></div>' + title + ' </div><div style="font-style: italic;font-size: 14px;width: 660px;">' + desc + '</div><br> ' + story + '');
$(".newsvor").css('background-image', 'url(<?php echo $path; ?>/public/images/news/' + image + ')');
$(".nntitle").html(title);
$(".newsshow").show();
}
function changebild(name)
{
var name = name;
$('.image').css("background", "url(<?php echo $path; ?>/public/images/news/" + name + ")");
}
function backtoNews()
{
$(".newsshow").hide();
$(".newssettings").show();
}
function showMyImage(fileInput) {
var files = fileInput.files;
for (var i = 0; i < files.length; i++) {
var file = files[i];
var imageType = /image.*/;
if (!file.type.match(imageType)) {
continue;
}
var img = document.getElementById("image");
img.file = file;
var reader = new FileReader();
reader.onload = (function (aImg) {
return function (e) {
$('.image').css("background", "url(" + e.target.result + ")");
};
})(img);
reader.readAsDataURL(file);
}
}
</script>
<?php } ?>
<?php if ($index == 'edit') {
?>
<style>
.newsvor {
width: 563px;
margin-right: 0px;
}
.beschreibung {
width: 573px;
border-radius: 0px;
position: absolute;
height: 40px;
line-height: 40px;
background: rgba(0,0,0,0.4);
color: #FFF;
font-size: 16px;
padding-left: 10px;
}
.newsbox {
float: left;
margin-right: 10px;
margin-left: 0px;
}
.weiterlesen {
float: right;
margin-right: 10px;
margin-top: 4px;
height: 30px;
line-height: 30px;
border: 1px solid #000;
border-bottom: 2px solid #000;
text-shadow: 0 1px 0 #000;
font-size: 14px;
font-weight: 600;
padding-left: 10px;
padding-right: 10px;
color: #FFF;
background: -moz-linear-gradient(#3BA800 0%,#2C7E00 100%);
background: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#3BA800),color-stop(100%,#2C7E00));
background: -webkit-linear-gradient(#3BA800 0%,#2C7E00 100%);
background: -o-linear-gradient(#3BA800 0%,#2C7E00 100%);
background: -ms-linear-gradient(#3BA800 0%,#2C7E00 100%);
background: linear-gradient(to bottom,#3BA800 0%,#2C7E00 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#3BA800',endColorstr='#2C7E00',GradientType=0);
cursor: pointer;
border-radius: 3px;
}
</style>
<?php if (isset($msg)) { ?>
<?php if ($fehler == 'true') { ?>
<div id="column" class="error right" style="float: right;width: 800px;">
<?php echo $msg; ?>
</div>
<?php } else { ?>
<div id="column" class="success right" style="float: right;width: 800px;">
<?php echo $msg; ?>
</div>
<?php } ?>
<?php } ?>
<script src="https://code.jquery.com/jquery-1.11.0.js?NEW"></script>
<link href="<?php echo $path; ?>/public/editor/css/font-awesome.min.css?NEW" rel="stylesheet" type="text/css" />
<link href="<?php echo $path; ?>/public/editor/css/froala_editor.min.css?NEW" rel="stylesheet" type="text/css" />
<link href="<?php echo $path; ?>/public/editor/css/froala_style.min.css?NEW" rel="stylesheet" type="text/css" />
<script src="<?php echo $path; ?>/public/editor/js/froala_editor.min.js?NEW"></script>
<script src="https://editor.froala.com/assets/editor/froala_editor.min-0a48153d2d19b75d1f56865be888dcb7.js?NEW"></script>
<script src="https://editor.froala.com/assets/load_plugins-d9503ed6cef6604ff5f01265e1afb22c.js?NEW"></script>
<!--[if lt IE 9]>
<!-- Include IE8 JS. -->
<script src="<?php echo $path; ?>/public/editor/js/froala_editor_ie8.min.js"></script>
<![endif]-->
<script>
$(function () {
$(".textarea").editable({inlineMode: false, buttons: ['bold', 'italic', 'underline', 'strikeThrough', 'fontSize', 'color', 'blockStyle', 'align', 'insertImage', 'html', 'sep', 'undo', 'redo']})
});
$(document).ready(function () {
$(".froala-box a").remove();
});
</script>
<div class="newsshow" style="display: none;width: 750px;float: right;">
<div onClick="backtoNews()" class="submit red" style="float: right;width: 800px;height: 35px;line-height: 35px;margin-top: 10px;">Zurück zur News</div>
<div id="column" class="newsvor" style="float: right;width: 400px;height: 190px;margin-right: 0px;">
<div class="beschreibung" style="width: 410px;margin-left: -10px;margin-top: 161px;border-radius: 0px 0px 5px 5px;"><div class="weiterlesen">Weiterlesen</div> <span class="nntitle">Raum der Woche [03]</span></div>
</div>
<div id="column" class="newsshoww right" style="width: 730px;float: right;">
</div>
</div>
<div id="column" class="newssettings right" style="float: right;width: 800px;">
<div class="title blau">Neuigkeit bearbeiten</div>
<form action="" method="post" enctype="multipart/form-data">
<b>Newstitel</b>
<input type="text" class="input ntitle" name="title" value="<?php echo protect($row->title); ?>" style="width: 790px;" placeholder="Titel von der Neuigkeit">
<b>Newsbild</b><br>
<div style="width: 100%;height: 200px;margin-bottom: 40px;">
<div id="image" class="image" style="height: 210px;width: 400px;border-radius: 5px;background: url('<?php echo $path; ?>/public/images/news/<?php echo $row->image; ?>') no-repeat;background-position: 50% 100%;float: right;"></div>
<br><br><br><br>
<select class="input nimage" name="image" style="width: 380px;" onChange="changebild(this.value)">
<?php
if ($handle = opendir('./public/images/news/')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && $entry != "index.php") {
?><option value="<?php echo $entry; ?>" <?php
if ($entry == $row->image) {
echo 'selected';
}
?>><?php echo $entry; ?></option> <?php
}
}
closedir($handle);
}
?>
</select>
Upload:<br> <input type="file" name="datei" size="50" maxlength="100000" onchange="showMyImage(this)">
</div>
<b>Kurzstory</b><br>
<textarea name="vortext" class="textarea nvortext">
<?php echo $row->longstory; ?>
</textarea><br>
<b>Story</b><br>
<textarea name="langtext" class="textarea nlangtext">
<?php echo $row->shortstory; ?>
</textarea><br>
<b>Autor</b><br>
<select class="input" name="autor">
<?php
$mitarbeiter = $mysqli->query("SELECT * FROM users WHERE rank > 5");
while ($roww = $mitarbeiter->fetch_object()) {
?>
<option value="<?php echo $roww->id; ?>" <?php
if ($roww->id == $row->autor) {
echo 'selected';
}
?>><?php echo $roww->username; ?></option>
<?php } ?>
</select>
<b>Kommentaren zulassen?</b><br>
<select class="input" name="kommentar">
<option value="1">Zulassen</option>
<option value="0" <?php
if ($row->kommentar == '0') {
echo 'selected';
}
?>>Verbieten</option>
</select>
<input type="submit" name="submit" class="submit" value="News Speichern" style="height: 42px;float: right;width: 200px;">
<div onClick="showvorschau()" class="submit red" style="float: right;width: 150px;height: 40px;line-height: 40px;margin-right: 10px;font-size: 13px;">News anschauen</div>
</form>
</div>
<script>
function showvorschau()
{
var title = $(".ntitle").val();
var desc = $(".nvortext").val();
var story = $(".nlangtext").val();
var image = $(".nimage").val();
$(".newssettings").hide();
$(".newsshoww").html('<div class="title blau"><div style="float: right;margin-right: 10px;font-weight: bold;"><?php echo date('d.m.Y'); ?></div>' + title + ' </div><div style="font-style: italic;font-size: 14px;width: 660px;">' + desc + '</div><br> ' + story + '');
$(".newsvor").css('background-image', 'url(<?php echo $path; ?>/public/images/news/' + image + ')');
$(".nntitle").html(title);
$(".newsshow").show();
}
function changebild(name)
{
var name = name;
$('.image').css("background", "url(<?php echo $path; ?>/public/images/news/" + name + ")");
}
function backtoNews()
{
$(".newsshow").hide();
$(".newssettings").show();
}
function showMyImage(fileInput) {
var files = fileInput.files;
for (var i = 0; i < files.length; i++) {
var file = files[i];
var imageType = /image.*/;
if (!file.type.match(imageType)) {
continue;
}
var img = document.getElementById("image");
img.file = file;
var reader = new FileReader();
reader.onload = (function (aImg) {
return function (e) {
$('.image').css("background", "url(" + e.target.result + ")");
};
})(img);
reader.readAsDataURL(file);
}
}
</script>
<?php } ?>
Alles anzeigen