forked from nilsteampassnet/TeamPass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.settings_categories.php
383 lines (356 loc) · 15.5 KB
/
admin.settings_categories.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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
<?php
/**
*
* @package admin.settings_categories.php
* @author Nils Laumaillé <[email protected]>
* @version 2.1.27
* @copyright 2009-2019 Nils Laumaillé
* @license GNU GPL-3.0
* @link https://www.teampass.net
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
require_once('sources/SecureHandler.php');
session_start();
header("Content-type: text/html; charset=utf-8");
if (!isset($_SESSION['CPM']) || $_SESSION['CPM'] != 1) {
die('Hacking attempt...');
}
// Load config
if (file_exists('../includes/config/tp.config.php')) {
include_once '../includes/config/tp.config.php';
} elseif (file_exists('./includes/config/tp.config.php')) {
include_once './includes/config/tp.config.php';
} else {
throw new Exception("Error file '/includes/config/tp.config.php' not exists", 1);
}
/* do checks */
require_once $SETTINGS['cpassman_dir'].'/includes/config/include.php';
require_once $SETTINGS['cpassman_dir'].'/sources/checks.php';
if (!checkUser(@$_SESSION['user_id'], @$_SESSION['key'], "manage_settings")) {
$_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page
include $SETTINGS['cpassman_dir'].'/error.php';
exit();
}
include $SETTINGS['cpassman_dir'].'/includes/language/'.$_SESSION['user_language'].'.php';
include $SETTINGS['cpassman_dir'].'/includes/config/settings.php';
header("Content-type: text/html; charset=utf-8");
require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
require_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
// connect to the server
require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
$pass = defuse_return_decrypted($pass);
DB::$host = $server;
DB::$user = $user;
DB::$password = $pass;
DB::$dbName = $database;
DB::$port = $port;
DB::$encoding = $encoding;
DB::$error_handler = true;
$link = mysqli_connect($server, $user, $pass, $database, $port);
$link->set_charset($encoding);
//Build tree
$tree = new SplClassLoader('Tree\NestedTree', './includes/libraries');
$tree->register();
$tree = new Tree\NestedTree\NestedTree($pre.'nested_tree', 'id', 'parent_id', 'title');
$tree->rebuild();
/*
* Loads the Item Categories
*/
//Build tree of Categories
$categoriesSelect = '<option value="">-- '.addslashes($LANG['select']).' --</option>';
$arrCategories = array();
$rows = DB::query(
"SELECT * FROM ".prefix_table("categories")."
WHERE level = %i
ORDER BY ".$pre."categories.order ASC",
'0'
);
foreach ($rows as $record) {
array_push(
$arrCategories,
array(
$record['id'],
$record['title'],
$record['order']
)
);
// build selection list
$categoriesSelect .= '<option value="'.$record['id'].'">'.($record['title']).'</option>';
}
// Build list of Field Types
$options_field_types = '<option value="">-- '.addslashes($LANG['select']).' --</option>'.
'<option value="text">'.addslashes($LANG['text']).'</option>'.
'<option value="textarea">'.addslashes($LANG['textarea']).'</option>';
// Build list of Roles
$options_roles = '<option value="all">'.addslashes($LANG['every_roles']).'</option>';
$rows = DB::query(
"SELECT id, title FROM ".prefix_table("roles_title")."
ORDER BY title ASC"
);
foreach ($rows as $record) {
$options_roles .= '<option value="'.$record['id'].'">'.addslashes($record['title']).'</option>';
}
echo '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head><title>API Settings</title></head><body>
<div id="tabs-8">
<!-- Enable CUSTOM FOLDERS (toggle) -->
<div style="width:100%; height:30px;">
<div style="float:left;">
<i class="fa fa-chevron-right mi-grey-1" style="margin-right: .3em;"> </i>
'.$LANG['settings_item_extra_fields'].'
<span style="margin-left:0px;"> <i class="fa fa-question-circle tip" title="'.htmlentities(strip_tags($LANG['settings_item_extra_fields_tip']), ENT_QUOTES).'"></i></span>
</div>
<div style="float:left; margin-left:20px;" class="toggle toggle-modern" id="item_extra_fields" data-toggle-on="', isset($SETTINGS['item_extra_fields']) && $SETTINGS['item_extra_fields'] == 1 ? 'true' : 'false', '"></div>
<div style="float:left;"><input type="hidden" id="item_extra_fields_input" name="item_extra_fields_input" value="', isset($SETTINGS['item_extra_fields']) && $SETTINGS['item_extra_fields'] == 1 ? '1' : '0', '" /></div>
</div>';
// Enable item_creation_templates
echo '
<div style="width:100%; height:30px;">
<div style="float:left;">
<i class="fa fa-chevron-right mi-grey-1" style="margin-right: .3em;"> </i>
<label>
'.$LANG['create_item_based_upon_template'].'
<span style="margin-left:0px;"> <i class="fa fa-question-circle tip" title="'.htmlentities(strip_tags($LANG['create_item_based_upon_template_tip']), ENT_QUOTES).'"></i></span>
</label>
</div>
<div style="float:left; margin-left:20px;" class="toggle toggle-modern" id="item_creation_templates" data-toggle-on="', isset($SETTINGS['item_creation_templates']) && $SETTINGS['item_creation_templates'] == 1 ? 'true' : 'false', '"></div>
<input type="hidden" id="item_creation_templates_input" name="item_creation_templates_input" value="', isset($SETTINGS['item_creation_templates']) && $SETTINGS['item_creation_templates'] == 1 ? '1' : '0', '" />
</div>';
echo '
<hr />
<div class="ui-state-highlight ui-corner-all" style="padding: 5px; margin:5px 0 20px 0;">
<div>
'.$LANG['new_category_label'].':
<input type="text" id="new_category_label" class="ui-content" style="margin-left:5px; width: 200px;" />
<input type="button" value="'.$LANG['add_category'].'" onclick="categoryAdd()" style="margin-left:5px;" class="ui-state-default ui-corner-all pointer" />
<div style="margin-top:3px;">
<input type="button" value="'.$LANG['save_categories_position'].'" onclick="storePosition()" style="margin-left:5px;" class="ui-state-default ui-corner-all pointer" />
<input type="button" value="'.$LANG['reload_table'].'" onclick="loadFieldsList()" style="margin-left:5px;" class="ui-state-default ui-corner-all pointer" />
</div>
</div>
</div>
<div id="categories_list">
</div>
<div class="ui-state-highlight ui-corner-all hidden" style="padding:2px;" id="no_category">
</div>';
echo '
</div>';
// hidden
echo '
<input type="hidden" id="post_id" />
<input type="hidden" id="post_data" />
<input type="hidden" id="post_type" />
<input type="hidden" id="selected_row" />';
// dialogboxes
echo '
<div id="item_dialog" class="hidden">
<div style="margin:0px 0 0px 30px;">
<input type="hidden" id="field_is_category" value="" />
<table>
<tr>
<td width="200px">
<label for="field_title">'.$LANG['at_label'].':</label>
</td>
<td>
<input type="text" id="field_title" class="ui-widget-content ui-corner-all field_edit" style="width: 330px; padding:3px;" />
</td>
</tr>
<tr class="not_category">
<td>
<label for="field_category">'.$LANG['category'].':</label>
</td>
<td>
<select id="field_category" class="ui-widget-content ui-corner-all field_edit" style="width: 340px; padding:3px;">
'.$categoriesSelect.'
</select>
</td>
</tr>
<tr class="not_category">
<td>
<label for="field_type">'.$LANG['type'].':</label>
</td>
<td>
<select id="field_type" class="ui-widget-content ui-corner-all field_edit" style="width: 340px; padding:3px;">
'.$options_field_types.'
</select>
</td>
</tr>
<tr class="not_category">
<td>
<label for="field_masked">'.$LANG['masked_text'].':</label>
</td>
<td>
<select id="field_masked" class="ui-widget-content ui-corner-all field_edit" style="width: 340px; padding:3px;">
<option value="0">'.$LANG['no'].'</option>
<option value="1">'.$LANG['yes'].'</option>
</select>
</td>
</tr>
<tr class="not_category">
<td>
<label for="field_is_mandatory">'.$LANG['is_mandatory'].':</label>
</td>
<td>
<select id="field_is_mandatory" class="ui-widget-content ui-corner-all" style="width: 340px; padding:3px;">
<option value="0">'.$LANG['no'].'</option>
<option value="1">'.$LANG['yes'].'</option>
</select>
</td>
</tr>
<tr class="not_category">
<td>
<label for="field_encrypted">'.$LANG['encrypted_data'].':</label>
</td>
<td>
<select id="field_encrypted" class="ui-widget-content ui-corner-all field_edit" style="width:340px; padding:3px;">
<option value="1">'.$LANG['yes'].'</option>
<option value="0">'.$LANG['no'].'</option>
</select>
</td>
</tr>
<tr class="not_category">
<td>
<label for="field_visibility">'.$LANG['restrict_visibility_to'].':</label>
</td>
<td>
<select id="field_visibility" class="ui-widget-content ui-corner-all field_edit" style="width:340px; padding:3px;" multiple="multiple">
'.$options_roles.'
</select>
</td>
</tr>
<tr>
<td>
<label for="field_order">'.$LANG['position_in_list'].':</label>
</td>
<td>
<input type="text" id="field_order" class="ui-widget-content ui-corner-all" style="width: 30px; padding:3px;" />
</td>
</tr>
</table>
</div>
</div>';
echo '
<div id="category_confirm" style="display:none;">
<span id="category_confirm_text"></span>?
</div>';
echo '
<div id="add_new_field" style="display:none;">
<table>
<tr>
<td>
<label for="new_field_title">'.$LANG['new_field_title'].':</label>
</td>
<td>
<input type="text" id="new_field_title" class="ui-widget-content ui-corner-all" style="width: 330px; padding:3px;" />
</td>
</tr>
<tr>
<td>
<label for="new_field_type">'.$LANG['type'].':</label>
</td>
<td>
<select id="new_field_type" class="ui-widget-content ui-corner-all" style="width: 340px; padding:3px;">
'.$options_field_types.'
</select>
</td>
</tr>
<tr>
<td>
<label for="new_field_encrypted">'.$LANG['encrypted_data'].':</label>
</td>
<td>
<select id="new_field_encrypted" class="ui-widget-content ui-corner-all" style="width:340px; padding:3px;">
<option value="1">'.$LANG['yes'].'</option>
<option value="0">'.$LANG['no'].'</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="new_field_masked">'.$LANG['masked_text'].':</label>
</td>
<td>
<select id="new_field_masked" class="ui-widget-content ui-corner-all" style="width: 340px; padding:3px;">
<option value="0">'.$LANG['no'].'</option>
<option value="1">'.$LANG['yes'].'</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="new_field_is_mandatory">'.$LANG['is_mandatory'].':</label>
</td>
<td>
<select id="new_field_is_mandatory" class="ui-widget-content ui-corner-all" style="width: 340px; padding:3px;">
<option value="0">'.$LANG['no'].'</option>
<option value="1">'.$LANG['yes'].'</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="new_field_visibility">'.$LANG['restrict_visibility_to'].':</label>
</td>
<td>
<select id="new_field_visibility" class="ui-widget-content ui-corner-all field_edit" style="width:340px; padding:3px;" multiple="multiple">
'.$options_roles.'
</select>
</td>
</tr>
<tr>
<td>
<label for="new_field_title">'.$LANG['position_in_list'].':</label>
</td>
<td>
<input type="text" id="new_field_order" class="ui-widget-content ui-corner-all" style="width: 30px; padding:3px;" />
</td>
</tr>
</table>
</div>';
echo '
<div id="category_in_folder" style="display:none;">
'.$LANG['select_folders_for_category'].'
"<span style="font-weight:bold;" id="catInFolder_title"></span>" :
<br />
<div style="margin-top:10px;">
<input type="button" id="but_select_all" value="'.$LANG['select_all'].'" class="ui-state-default ui-corner-all pointer" />
<input type="button" id="but_deselect_all" value="'.$LANG['deselect_all'].'" class="ui-state-default ui-corner-all pointer" />
</div>
<div style="margin-top:5px;">
<select id="cat_folders_selection" multiple="multiple" size="15" class="ui-widget-content ui-corner-all" style="margin-top:5px;">';
$folders = $tree->getDescendants();
foreach ($folders as $folder) {
DB::query(
"SELECT * FROM ".prefix_table("nested_tree")."
WHERE personal_folder = %i AND id = %i",
'0',
$folder->id
);
$counter = DB::count();
if ($counter > 0) {
$ident = "";
for ($x = 1; $x < $folder->nlevel; $x++) {
$ident .= "-";
}
echo '
<option value="'.$folder->id.'">'.$ident.' '.str_replace("&", "&", $folder->title).'</option>';
}
}
echo '
</select>
</div>
<div id="catInFolder_wait" class="ui-state-focus ui-corner-all" style="display:none;padding:2px;margin:5px 0 5px 0;">'.$LANG['please_wait'].'...</div>
</div>';
require_once 'admin.settings.load.php';
echo '
<script type="text/javascript">
//<![CDATA[
$(function() {
loadFieldsList();
});
//]]>
</script></body></html>';