Newer
Older
<?php
class NEWS{
private $db;
private $error = 0;
private $meldung;
private $array = array();
private $config;
function __construct(){
global $datenbank,$grundconfig;
$this->db = $datenbank;
$this->config = $grundconfig;
}
private function make_array($post){
foreach($post AS $key => $value){
if($key != '' && $key != 'news4' && $key != 'news3' && $key != 'news2'){
$this->array[$key] = $this->db->escape($value);
}
}
}
private function save(){
if($this->db->insert(PREFIX . NEWS, array("zeit" => time(), "titel" => $this->array['titel'], "news" => $this->array['news'])) == true){
$this->meldung = NEWS_SAVE_TRUE;
}else{
$this->error = 1;
$this->meldung = NEWS_SAVE_FALSE;
}
}
private function newsletter(){
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
foreach($this->db->get_results("SELECT emailadresse FROM ". PREFIX . EMAIL ." WHERE freigabe_fuer = '1' ") AS $res){
$mail->senden($res->emailadresse,$this->array['titel'],$this->array['news']);
}
}
private function deleteDB(){
if($this->db->delete(PREFIX . NEWS, array("id" => $this->array['id'])) == true){
$this->meldung = NEWS_DELETE_TRUE;
$this->db->delete(PREFIX . NEWSK, array("news" => $this->array['id']));
}else{
$this->error = 1;
$this->meldung = NEWS_DELETE_FALSE;
}
}
public function delete($post){
$this->make_array($post);
$this->deleteDB();
meldung($this->error,$this->meldung);
}
public function news3($post){
$this->make_array($post);
$this->newsletter();
meldung($this->error,NEWS_NEWSLETTER_TRUE);
}
public function news2($post){
$this->make_array($post);
$this->save();
$this->newsletter();
meldung($this->error,NEWS_MAIL_SAVE_TRUE);
}
public function news4($post){
$this->make_array($post);
$this->save();
meldung($this->error,$this->meldung);
}
public function edit(){
$aus = '
<form method="post" action="">
<div class="input-group mb-3">
<select class="custom-select" name="id">
<option value="0">bitte wählen</option>
'. $this->ListeNews() .'
</select>
<div class="input-group-append">
<input type="submit" class="btn btn-success" value="bearbeiten">
<input type="submit" class="btn btn-danger" name="news_delete" value="löschen">
</div>
</div>
</form>
';
return $aus;
}
private function ListeNews(){
$aus = '';
foreach($this->db->get_results("SELECT id,titel,zeit FROM ". PREFIX . NEWS ." ") AS $res){
$datum = date("d.m.Y H:i",$res->zeit);
$aus .= "<option value='$res->id'>$res->titel ($datum)</option>";
}
return $aus;
}
}