Newer
Older
<?php
class mver{
private $db;
private $art;
private $artB;
private $array = array();
private $num = 1;
private $error = 0;
private $meldung;
function __construct(){
global $datenbank;
$this->db = $datenbank;
}
private function make_array($post){
foreach($post AS $key => $value){
if($key != '' && $key != 'run' && $value != ''){
$this->array[$key] = $this->db->escape($value);
}
}
}
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
public function set_art($art){
if($art == 'user'){ $this->art = M_US; $this->artB = B_US;}
if($art == 'admin'){ $this->art = M_AD; $this->artB = B_AD;}
}
public function select($id){
$aus = '<option value="0"';
if($id == 0){ $aus .= 'selected="selected"';}
$aus .= '>Hauptlink</option>';
$result = $this->db->get_results("SELECT id,name FROM ". PREFIX . $this->art ."");
foreach($result AS $res){
$aus .= "<option value='$res->id'";
if($res->id == $id){ $aus .= 'selected="selected"';}
$aus .= ">$res->name</option>";
}
return $aus;
}
public function selectBox($id){
$aus = '<option value="0"';
if($id == 0){ $aus .= 'selected="selected"';}
$aus .= '>Hauptbox</option>';
$result = $this->db->get_results("SELECT id,name FROM ". PREFIX . $this->artB ."");
foreach($result AS $res){
$aus .= "<option value='$res->id'";
if($res->id == $id){ $aus .= 'selected="selected"';}
$aus .= ">$res->name</option>";
}
return $aus;
}
public function save($post){
$this->make_array($post);
if(!isset($array['uid'])){ $array['uid'] = 0;}
$this->SavePost();
meldung($this->error,$this->meldung);
}
public function SaveInsert($post){
$this->make_array($post);
if(!isset($array['uid'])){ $array['uid'] = 0;}
$this->Insert();
meldung($this->error,$this->meldung);
}
private function Insert(){
if($this->db->insert(PREFIX . $this->art, $this->array) == true){
$this->meldung = MENUE_SAVE_TRUE;
}else{
$this->error = 1;
$this->meldung = MENUE_SAVE_FALSE;
}
}
private function SavePost(){
if($this->db->update(PREFIX . $this->art, $this->array, array("id" => $this->array['id'])) == true){
$this->meldung = MENUE_SAVE_TRUE;
}else{
$this->error = 1;
$this->meldung = MENUE_SAVE_FALSE;
}
}
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
public function delete($post){
$this->make_array($post);
if($this->db->delete(PREFIX . $this->art, array("id" => $this->array['id'])) == true){
$this->meldung = DELETE_LINK_TRUE;
}else{
$this->error = 1;
$this->meldung = DELETE_LINK_FALSE;
}
}
public function NewListen(){
$aus = '';
$query = "SELECT id,name,link,ordnung,box FROM ". PREFIX . $this->art ." WHERE uid = '0' AND box = '0' ORDER by ordnung ASC";
if($this->db->num_rows($query) != 0){
$aus .= '<h3>Links ohne Zuordnung</h3><ul class="list-group">';
$result = $this->db->get_results($query);
foreach($result AS $res){
$aus .= '
<li class="list-group-item">
<form method="post" action="">
<input type="hidden" name="id" value="'. $res->id .'">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">'. $res->id .'</span>
</div>
<input type="text" class="form-control" name="name" value="'. $res->name .'" placeholder="Linkname">
<input type="text" class="form-control" name="link" value="'. $res->link .'" placeholder="link">
<input type="text" class="form-control" name="ordnung" value="'. $res->ordnung .'">
<select class="custom-select" id="inputGroupSelect01">';
$aus .= $this->select(0);
$aus .= '
</select>
<select class="custom-select" name="box" id="inputGroupSelect02">';
$aus .= $this->selectBox($res->box);
$aus .= '
</select>
<div class="input-group-append">
<input type="submit" class="btn btn-outline-danger" name="run[link_'. $this->art .'_delete]" value="Löschen">
<input type="submit" class="btn btn-outline-success" name="run[link_'. $this->art .'_update]" value="Speichern">
</div>
</div>
</form>
</li>';
}
$aus .= '</ul><hr>';
}
return $aus;
}
public function listen(){
$aus = '<ul class="list-group">';
$result = $this->db->get_results("SELECT id,name,link,ordnung,box FROM ". PREFIX . $this->art ." WHERE uid = '0' ORDER by ordnung ASC");
foreach($result AS $res){
$aus .= '
<li class="list-group-item">
<form method="post" action="">
<input type="hidden" name="id" value="'. $res->id .'">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">'. $res->id .'</span>
</div>
<input type="text" class="form-control" name="name" value="'. $res->name .'" placeholder="Linkname">
<input type="text" class="form-control" name="link" value="'. $res->link .'" placeholder="link">
<input type="text" class="form-control" name="ordnung" value="'. $res->ordnung .'">
<select class="custom-select" id="inputGroupSelect01">';
$aus .= $this->select(0);
$aus .= '
</select>
<select class="custom-select" id="inputGroupSelect01">';
$aus .= $this->selectBox($res->box);
$aus .= '
</select>
<div class="input-group-append">
<input type="submit" class="btn btn-outline-danger" name="run[link_'. $this->art .'_delete]" value="Löschen">
<input type="submit" class="btn btn-outline-success" name="run[link_'. $this->art .'_update]" value="Speichern">
</div>
</div>
</form>
</li>
';
$aus .= $this->unterlisten($res->id,$this->num);
}
$aus .= '</ul>';
return $aus;
}
private function Pfeil(){
$aus = '';
for($i = 0; $i <= $this->num; $i++){
if($i != $this->num){ $aus .= ' ';}
if($i == $this->num){
$aus .= '<img src="https://img.icons8.com/material/16/000000/down-right.png">';
}
}
return $aus;
}
private function unterlisten($id,$num){
$query = "SELECT id,name,link,ordnung,box FROM ". PREFIX . $this->art ." WHERE uid = '$id' ORDER by ordnung ASC";
$aus = '';
if($this->db->num_rows($query) != 0){
foreach($this->db->get_results($query) AS $res){
$aus .= '
<li class="list-group-item">
<form method="post" action="">
<input type="hidden" name="id" value="'. $res->id .'">
<div class="input-group mb-3">';
$aus .= $this->Pfeil();
$aus .= '
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">'. $res->id .'</span>
</div>
<input type="text" class="form-control" name="name" value="'. $res->name .'" placeholder="Linkname">
<input type="text" class="form-control" name="link" value="'. $res->link .'" placeholder="Link">
<input type="text" class="form-control" name="ordnung" value="'. $res->ordnung .'">
<select class="custom-select" id="inputGroupSelect01">';
$aus .= $this->select($id);
$aus .= '
</select>
<select class="custom-select" id="inputGroupSelect01">';
$aus .= $this->selectBox($res->box);
$aus .= '
</select>
<div class="input-group-append">
<input type="submit" class="btn btn-outline-danger" name="run[link_'. $this->art .'_delete]" value="Löschen">
<input type="submit" class="btn btn-outline-success" name="run[link_'. $this->art .'_update]" value="Speichern">
</div>
</div>
</form>
</li>
';
$aus .= $this->unterlisten($res->id,$this->num++);
}
}
return $aus;
}
}