-
Notifications
You must be signed in to change notification settings - Fork 4
/
adminmenubar.php
260 lines (214 loc) · 11.6 KB
/
adminmenubar.php
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
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<?PHP
require_once("./init.php");
if (!defined('is_florensia')) die('Hacking attempt');
if (!$flouser->get_permission("access_admincp") OR !$flouser->get_permission("mod_menubar")) { $florensia->output_page($flouser->noaccess()); }
$florensia->sitetitle("AdminCP");
$florensia->sitetitle("Menubar and Userbar");
if ($_GET['classname']!="menubar" && $_GET['classname']!="userbar") { $florensia->output_page($flouser->noaccess()); }
$classname = $_GET['classname'];
//available permission-flags
$querypermission = MYSQL_QUERY("SELECT settings FROM flobase_defaults WHERE title='userpermissions_available'");
$permissiontmp = MYSQL_FETCH_ARRAY($querypermission);
$permissiontmp = explode(";", $permissiontmp['settings']);
foreach ($permissiontmp as $permissiontmpflag) {
$permissiontmpflag = explode(":", $permissiontmpflag);
$permission[] = $permissiontmpflag[0];
}
//database work
if ($_POST['do_update']) {
$querysections = MYSQL_QUERY("SELECT id FROM flobase_menubar WHERE classname='{$classname}'");
while ($sections = MYSQL_FETCH_ARRAY($querysections)) {
if ($_POST['section_'.$sections['id'].'_delete']=="1") {
if (!MYSQL_QUERY("DELETE FROM flobase_menubar WHERE id='{$sections['id']}' OR (sectionid='{$sections['id']}' AND section=0)")) {
$florensia->notice("Error: ".mysql_error(), "warning");
}
continue;
}
if ($_POST['section_'.$sections['id'].'_standalone']) $standalone = 1;
else $standalone=0;
unset($comma, $sectionnamedb);
foreach ($flolang->lang as $langkey => $langname) {
$sectionnamedb .= "$comma name_$langkey='".mysql_real_escape_string($_POST['section_'.$sections['id'].'_name_'.$langkey])."'";
$comma=",";
}
if ($_POST['section_'.$sections['id'].'_sectionid']=="0") { $sectioniddb = "sectionid=0, section=1"; }
else $sectioniddb = "section=0, sectionid=".intval($_POST['section_'.$sections['id'].'_sectionid']);
if (!intval($_POST['section_'.$sections['id'].'_rankid'])) $rankiddb="rankid=1";
else $rankiddb = "rankid=".intval($_POST['section_'.$sections['id'].'_rankid']);
switch ($_POST['section_'.$sections['id'].'_source']) {
case "intern": { $pagelinkdb = "intern|".$_POST['section_'.$sections['id'].'_pagelink']; break; }
case "forum": { $pagelinkdb = "forum|".$_POST['section_'.$sections['id'].'_pagelink']; break; }
case "extern": {
if (preg_match('^http', $_POST['section_'.$sections['id'].'_pagelink'])) $pagelinkdb = "extern|".$_POST['section_'.$sections['id'].'_pagelink'];
else $pagelinkdb = "extern|".$_POST['section_'.$sections['id'].'_pagelink'];
break;
}
default: continue;
}
$pagelinkdb = "pagelink = '".mysql_real_escape_string($pagelinkdb)."'";
if ($flouser->get_permission("mod_permission")) {
if (!$_POST['section_'.$sections['id'].'_permission']) $permissionsdb = ", permission = ''";
else $permissionsdb = ", permission = '".join(";", $_POST['section_'.$sections['id'].'_permission'])."'";
} else unset($permissionsdb);
if (!MYSQL_QUERY("UPDATE flobase_menubar SET standalone=$standalone, $sectionnamedb, $sectioniddb, $rankiddb, $pagelinkdb{$permissionsdb} WHERE id='{$sections['id']}'")) {
$florensia->notice("Error: ".mysql_error(), "warning");
}
}
}
//------------ end updating -----------
//------------ start new entry --------
elseif ($_POST['do_new']) {
if ($_POST['section_0_standalone']) $do_new['standalone'] = 1;
else $do_new['standalone']=0;
foreach ($flolang->lang as $langkey => $langname) {
$do_new['name_'.$langkey]="'".mysql_real_escape_string($_POST['section_0_name_'.$langkey])."'";
}
if ($_POST['section_0_sectionid']=="0") { $do_new['sectionid']=0; $do_new['section']=1; }
else { $do_new['section']=0; $do_new['sectionid']=intval($_POST['section_0_sectionid']); }
if (!intval($_POST['section_0_rankid'])) $do_new['rankid']=1;
else $do_new['rankid']=intval($_POST['section_0_rankid']);
switch ($_POST['section_0_source']) {
case "intern": { $pagelinkdb = "intern|".$_POST['section_0_pagelink']; break; }
case "forum": { $pagelinkdb = "forum|".$_POST['section_0_pagelink']; break; }
case "extern": {
if (preg_match('^http', $_POST['section_0_pagelink'])) $pagelinkdb = "extern|".$_POST['section_0_pagelink'];
else $pagelinkdb = "extern|".$_POST['section_0_pagelink'];
break;
}
}
$do_new['pagelink'] = "'".mysql_real_escape_string($pagelinkdb)."'";
if ($flouser->get_permission("mod_permission")) {
$do_new['permission'] = "'".join(";", $_POST['section_0_permission'])."'";
}
$dbnewkeys = join(", ", array_keys($do_new));
$dbnewvalues = join(", ", array_values($do_new));
if (!MYSQL_QUERY("INSERT INTO flobase_menubar (classname, $dbnewkeys) VALUES('{$classname}', $dbnewvalues)")) {
$florensia->notice("Error: ".mysql_error(), "warning");
}
}
//------------ end new entry --------
//preselectform sections
$sectionselect = "<option value='0'>--</option>";
$querysections = MYSQL_QUERY("SELECT id, name_".$flolang->language." FROM flobase_menubar WHERE classname='{$classname}' AND section=1 AND standalone=0");
while ($sections = MYSQL_FETCH_ARRAY($querysections)) {
$sectionselect .= "<option value='{$sections['id']}' {\$selectedsection['{$sections['id']}']}>".$florensia->escape($sections['name_'.$flolang->language])."</option>";
}
$sectionform = "
<div class='shortinfo_\$colorchange small' \$subsectionmargin>
<table style='width:100%;'>
<tr>
<td style='vertical-align:top;'><table>\$sectionname</table></td>
<td style='border-right:1px solid; width:10px;'></td>
<td style='padding-left:10px; vertical-align:top; width:310px;'>
<table>
<tr><td>Mainsection:</td><td><select name='section_{\$sections['id']}_sectionid'>\$sectionselectform</select></td></tr>
<tr><td>Standalone:</td><td><input type='checkbox' name='section_{\$sections['id']}_standalone' value='1' \$standalonechecked> (only if section)</td></tr>
<tr><td style='width:100px;'>Order:</td><td><input type='text' name='section_{\$sections['id']}_rankid' maxsize='2' value='{\$sections['rankid']}'></td></tr>
<tr><td>File:</td><td><input type='text' name='section_{\$sections['id']}_pagelink' maxsize='2' value='{\$sections['pagelink'][1]}'></td></tr>
<tr><td>Source:</td><td>
<select name='section_{\$sections['id']}_source'>
<option value='intern' {\$selected['intern']}>Intern (file only, without domain)</option>
<option value='forum' {\$selected['forum']}>Forum (file only, without domain)</option>
<option value='extern' {\$selected['extern']}>Extern (with http://, full url)</option>
</select>
</td></tr>
<tr><td>Permission:<br />(Non for all)</td><td>
<select name='section_{\$sections['id']}_permission[]' multiple='multiple' style='height:100px;'>
\$permissionselectform
</select>
</td></tr>
</table>
</td>
<td style='border-right:1px solid; width:10px;'></td>
<td style='padding-left:10px; vertical-align:top; width:110px;'>
<table style='width:100%;'>
<tr><td style='text-align:right;'>
\$submitbuttomform
</td></tr>
</table>
</td>
</tr>
</table>
</div>
";
//---
//------- New entry form -------------
$sections['id']=0;
foreach ($flolang->lang as $langkey => $langname) {
$sectionname .= "<tr><td style='width:150px;'>Sectionname [$langkey]:</td><td><input type='text' name='section_{$sections['id']}_name_{$langkey}' maxlength='255'></td></tr>";
}
unset($permissionselectform);
foreach ($permission as $permissionflag) {
$permissionselectform .= "<option value='{$permissionflag}'>$permissionflag</option>";
}
$colorchange = $florensia->change();
$submitbuttomform = "<input type='submit' name='do_new' value='Save new entry'>";
eval("\$sectionselectform = \"$sectionselect\";");
eval("\$permissionselectform = \"$permissionselectform\";");
eval("\$content = \"$sectionform\";");
$content .= "<div style='margin-top:10px; height:10px; border-top:1px solid;'></div>";
$content .= "<div style='margin-top:10px; height:10px; border-top:1px solid;'></div>";
// --------------
$submitbuttom = "<input type='submit' name='do_update' value='Update all entries'><br /><br />
Delete: <input type='checkbox' name='section_{\$sections['id']}_delete' value='1'><br />
\$delete_subsection_notice
";
$querysections = MYSQL_QUERY("SELECT * FROM flobase_menubar WHERE classname='{$classname}' AND section=1 ORDER BY rankid");
while ($mainsections = MYSQL_FETCH_ARRAY($querysections)) {
$sections = $mainsections;
$colorchange = $florensia->change();
$delete_subsection_notice = "<span style='color:#9E9E9E'>Subsections will be deleted, too!</span>";
unset($sectionname,$selected, $subsectionmargin, $selectedsection);
foreach ($flolang->lang as $langkey => $langname) {
$sectionname .= "<tr><td style='width:150px;'>Sectionname [$langkey]:</td><td><input type='text' name='section_{$sections['id']}_name_{$langkey}' maxlength='255' value='".$florensia->escape($sections['name_'.$langkey])."'></td></tr>";
}
if ($sections['standalone']) $standalonechecked = "checked='checked'";
else unset($standalonechecked);
$sections['pagelink'] = explode("|", $sections['pagelink']);
$selected[$sections['pagelink'][0]]="selected='selected'";
unset($permissionselectform, $permissionchecked);
foreach (explode(";", $sections['permission']) as $permissionsetflag) {
$permissionchecked[$permissionsetflag] = "selected='selected'";
}
foreach ($permission as $permissionflag) {
$permissionselectform .= "<option value='{$permissionflag}' ".$permissionchecked[$permissionflag].">$permissionflag</option>\n";
}
eval("\$sectionselectform = \"$sectionselect\";");
eval("\$permissionselectform = \"$permissionselectform\";");
eval("\$submitbuttomform = \"$submitbuttom\";");
eval("\$content .= \"$sectionform\";");
if (!$sections['standalone']) {
$querysubsections = MYSQL_QUERY("SELECT * FROM flobase_menubar WHERE classname='{$classname}' AND section=0 AND sectionid={$sections['id']} ORDER BY rankid");
while ($subsections = MYSQL_FETCH_ARRAY($querysubsections)) {
$sections = $subsections;
$subsectionmargin = "style='margin-left:80px; margin-top:5px;'";
unset($sectionname, $selected,$delete_subsection_notice);
foreach ($flolang->lang as $langkey => $langname) {
$sectionname .= "<tr><td style='width:150px;'>Sectionname [$langkey]:</td><td><input type='text' name='section_{$sections['id']}_name_{$langkey}' maxlength='255' value='".$florensia->escape($sections['name_'.$langkey])."'></td></tr>";
}
$sections['pagelink'] = explode("|", $sections['pagelink']);
$selected[$sections['pagelink'][0]]="selected='selected'";
unset($permissionselectform, $permissionchecked);
foreach (explode(";", $sections['permission']) as $permissionsetflag) {
$permissionchecked[$permissionsetflag] = "selected='selected'";
}
foreach ($permission as $permissionflag) {
$permissionselectform .= "<option value='{$permissionflag}' ".$permissionchecked[$permissionflag].">$permissionflag</option>\n";
}
$selectedsection[$sections['sectionid']] = "selected='selected'";
eval("\$sectionselectform = \"$sectionselect\";");
eval("\$permissionselectform = \"$permissionselectform\";");
eval("\$submitbuttomform = \"$submitbuttom\";");
eval("\$content .= \"$sectionform\";");
}
}
$content .= "<div style='margin-top:10px; height:10px; border-top:1px solid;'></div>";
}
$content = "
<form action='".$florensia->escape($_SERVER['REQUEST_URI'])."' method='post'>
<div class='small bordered' style='margin-bottom:15px; text-align:center;'>Leave namespace blank to ignore the specified language and hide section/link.</div>
$content
</form>
";
$florensia->output_page($content);
?>