Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
class cms{
private $db;
private $post = array();
function __construct(){
global $datenbank;
$this->db = $datenbank;
}
public function BoxWahl($id = 0){
$aus = '';
foreach($this->db->get_results("SELECT id,name FROM ". PREFIX . B_US ." ") AS $res){
if($id == $res->id){ $selec = 'selected="selected"';}else{ $selec = '';}
$aus .= '<option value="'. $res->id .'" '. $selec .'>'. $res->name .'</option>';
}
return $aus;
}
public function LinkZugriff($id){
$aus = '
<option value="1"'; if($id == 1) { $aus .= 'SELECTED';} $aus .= '>Eingeloggte User</option>
<option value="2"'; if($id == 2) { $aus .= 'SELECTED';} $aus .= '>Gäste</option>
<option value="3"'; if($id == 3) { $aus .= 'SELECTED';} $aus .= '>Alle</option>
';
return $aus;
}
public function EditSave($post){
$this->make_array($post);
$array = array(
"titel" => $this->post['titel'],
"text" => $this->post['text'],
"sichtbar" => $this->post['sichtbar']
);
if($this->db->update(PREFIX . CMS, $array, array("id" => $this->post['cms_id'])) == true && $this->LinkUpdate() == true){
meldung(0,CMS_EDIT_SAVE_TRUE);
}else{
meldung(1,CMS_EDIT_SAVE_FALSE);
}
}
private function make_array($post){
foreach($post AS $key => $value){
if($key != '' && $key != 'seite_save' && $key != 'seite_bearbeiten'){
$this->post[$key] = $this->db->escape($value);
}
}
}
private function LinkEintragen($id){
$array = array(
"link" => 'cms/seite&id='.$id,
"name" => $this->post['name'],
"ordnung" => $this->post['ordnung'],
"box" => $this->post['box'],
"cms_id" => $id
);
$this->db->insert(PREFIX . M_US, $array);
}
private function LinkUpdate(){
$array = array(
"name" => $this->post['name'],
"ordnung" => $this->post['name'],
"box" => $this->post['box']
);
$return = $this->db->update(PREFIX . M_US, $array, array("cms_id" => $this->post['cms_id']));
return $return;
}
public function BoxSave($post){
$this->make_array($post);
$array = array(
"titel" => $this->post['titel'],
"text" => $this->post['text'],
"sichtbar" => $this->post['sichtbar']
);
if($this->db->insert(PREFIX . CMS, $array) == true){
$this->LinkEintragen($this->db->lastid());
meldung(0,CMS_SEITE_SAVE_TRUE);
}else{
meldung(1,CMS_SEITE_SAVE_FALSE);
}
}
public function ListeSeiten(){
$aus = '';
foreach($this->db->get_results("SELECT id,titel,text FROM ". PREFIX . CMS ." ") AS $res){
$aus .= '
<form method="post" action="">
<input type="hidden" name="seiten_id" value="'.$res->id.'">
<tr>
<td>'. $res->id .'</td>
<td>'. $res->titel .'</td>
<td><code>'. shortText($res->text,200) .'</code></td>
<td><a class="btn btn-info" href="?page=/cms/detail_seiten&id='. $res->id .'">Bearbeiten</a>
<input type="submit" class="btn btn-danger" name="run[seite_loeschen]" value="Seite löschen"></td>
</tr>
</form>
';
}
return $aus;
}
public function SeiteDelete($post){
$this->make_array($post);
if($this->db->num_rows("SELECT id FROM ". PREFIX . CMS ." WHERE id = '". $this->post['seiten_id'] ."' ") == 1){
if(
$this->db->delete(PREFIX . CMS, array("id" => $this->post['seiten_id']),1) == true &&
$this->db->delete(PREFIX . M_US, array("cms_id" => $this->post['seiten_id']),1) == true){
meldung(0,CMS_DELETE_TRUE);
}else{
meldung(1,CMS_DELETE_FALSE);
}
}else{
meldung(1,CMS_SEITE_DELETE_NO);
}
}
}