forked from nilsteampassnet/TeamPass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
folders.php
210 lines (182 loc) · 9.05 KB
/
folders.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
<?php
/**
*
* @package folders.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.
*/
if (!isset($_SESSION['CPM']) || $_SESSION['CPM'] != 1 ||
!isset($_SESSION['user_id']) || empty($_SESSION['user_id']) ||
!isset($_SESSION['key']) || empty($_SESSION['key'])
) {
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'].'/sources/checks.php';
if (!checkUser($_SESSION['user_id'], $_SESSION['key'], curPage())) {
$_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page
include $SETTINGS['cpassman_dir'].'/error.php';
exit();
}
require_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
//Build tree
$tree = new SplClassLoader('Tree\NestedTree', $SETTINGS['cpassman_dir'].'/includes/libraries');
$tree->register();
$tree = new Tree\NestedTree\NestedTree($pre.'nested_tree', 'id', 'parent_id', 'title');
/* Get full tree structure */
$tst = $tree->getDescendants();
// prepare options list
$prev_level = 0;
$droplist = '<option value="na">---'.$LANG['select'].'---</option>';
if ($_SESSION['is_admin'] === "1" || $_SESSION['user_manager'] === "1" || $_SESSION['can_create_root_folder'] === "1") {
$droplist .= '<option value="0">'.$LANG['root'].'</option>';
}
foreach ($tst as $t) {
if (in_array($t->id, $_SESSION['groupes_visibles']) && !in_array($t->id, $_SESSION['personal_visible_groups'])) {
$ident = "";
for ($x = 1; $x < $t->nlevel; $x++) {
$ident .= " ";
}
if ($prev_level < $t->nlevel) {
$droplist .= '<option value="'.$t->id.'">'.$ident.addslashes($t->title).'</option>';
} elseif ($prev_level == $t->nlevel) {
$droplist .= '<option value="'.$t->id.'">'.$ident.addslashes($t->title).'</option>';
} else {
$droplist .= '<option value="'.$t->id.'">'.$ident.addslashes($t->title).'</option>';
}
$prev_level = $t->nlevel;
}
}
/* Display header */
echo '
<div class="title ui-widget-content ui-corner-all">' .
$LANG['admin_groups'].'
<button title="'.htmlentities(strip_tags($LANG['item_menu_add_rep']), ENT_QUOTES).'" onclick="OpenDialog(\'div_add_group\')" class="button" style="font-size:16px;">
<i class="fa fa-plus"></i>
</button>
<button title="'.htmlentities(strip_tags($LANG['item_menu_del_rep']), ENT_QUOTES).'" id="click_delete_multiple_folders" class="button" style="font-size:16px;">
<i class="fa fa-trash-o"></i>
</button>
<button title="'.htmlentities(strip_tags($LANG['refresh']), ENT_QUOTES).'" id="click_refresh_folders_list" class="button" style="font-size:16px;">
<i class="fa fa-refresh"></i>
</button>
</div>';
// Hidden things
echo '
<input type="hidden" id="folder_id_to_edit" value="" />
<input type="hidden" id="action_on_going" value="" />';
//Show the KB in a table view
echo '
<div style="margin:10px auto 25px auto;min-height:250px;" id="folders_page">
<div id="t_folders_alphabet" style="margin-top:25px;"></div>
<table id="t_folders" class="hover" width="100%">
<thead><tr>
<th></th>
<th>ID</th>
<th>'.$LANG['group'].'</th>
<th style="width:20px;">'.$LANG['nb_items'].'</th>
<th>'.$LANG['complexity'].'</th>
<th>'.$LANG['group_parent'].'</th>
<th>'.$LANG['level'].'</th>
<th style="width:20px;" title="'.htmlentities(strip_tags($LANG['group_pw_duration_tip']), ENT_QUOTES).'">'.$LANG['group_pw_duration'].'</th>
<th style="width:20px;" title="'.htmlentities(strip_tags($LANG['auth_creation_without_complexity']), ENT_QUOTES).'"><i class="fa fa-legal fa-lg"></i></th>
<th style="width:20px;" title="'.htmlentities(strip_tags($LANG['auth_modification_without_complexity']), ENT_QUOTES).'"><i class="fa fa-clock-o fa-lg"></i></th>
</tr></thead>
<tbody><tr id="placeholder_tr" style="display: none;"><td></td></tr>
</tbody>
</table>
</div>';
/* Form Add a folder */
echo '
<div id="div_add_group" style="display:none;">
<div id="addgroup_show_error" style="text-align:center;margin:2px;display:none;" class="ui-state-error ui-corner-all"></div>
<label for="ajouter_groupe_titre" class="label_cpm">'.addslashes($LANG['group_title']).'</label>
<input type="text" id="ajouter_groupe_titre" class="input_text text ui-widget-content ui-corner-all" />
<label for="parent_id" class="label_cpm">'.addslashes($LANG['group_parent']).'</label>
<select id="parent_id" class="input_text text ui-widget-content ui-corner-all">
'.$droplist.'
</select>
<label for="new_rep_complexite" class="label_cpm">'.addslashes($LANG['complex_asked']).'</label>
<select id="new_rep_complexite" class="input_text text ui-widget-content ui-corner-all">';
foreach ($SETTINGS_EXT['pwComplexity'] as $complex) {
echo '<option value="'.$complex[0].'">'.$complex[1].'</option>';
}
echo '
</select>
<span id="span_new_rep_roles">
<label for="new_rep_roles" class="label_cpm">'.addslashes($LANG['access_level_for_roles']).'</label>
<select id="new_rep_roles" class="input_text text ui-widget-content ui-corner-all">
<option value="">'.$LANG['no_access'].'</option>
<option value="R">'.$LANG['read'].'</option>
<option value="W">'.$LANG['write'].'</option>
</select>
</span>
<label for="add_node_renewal_period" class="label_cpm">'.addslashes($LANG['group_pw_duration']).'</label>
<input type="text" id="add_node_renewal_period" value="0" class="input_text text ui-widget-content ui-corner-all" />
<label for="folder_block_creation" class="">'.addslashes($LANG['auth_creation_without_complexity']).'</label>
<select id="folder_block_creation" class="ui-widget-content ui-corner-all">
<option value="0">'.$LANG['no'].'</option>
<option value="1">'.$LANG['yes'].'</option>
</select>
<div style="margin-top:10px;">
<label for="folder_block_modif">'.addslashes($LANG['auth_modification_without_complexity']).'</label>
<select id="folder_block_modif" class="ui-widget-content ui-corner-all">
<option value="0">'.$LANG['no'].'</option>
<option value="1">'.$LANG['yes'].'</option>
</select>
</div>
<div style="padding:5px; z-index:9999999;" class="ui-widget-content ui-state-focus ui-corner-all" id="new_folder_wait">
<i class="fa fa-cog fa-spin fa-2x"></i> '.$LANG['please_wait'].'
</div>
</div>';
/* Form EDIT a folder */
echo '
<div id="div_edit_folder" style="display:none;">
<div id="edit_folder_show_error" style="text-align:center;margin:2px;display:none;" class="ui-state-error ui-corner-all"></div>
<label for="edit_folder_title" class="label_cpm">'.$LANG['group_title'].'</label>
<input type="text" id="edit_folder_title" class="input_text text ui-widget-content ui-corner-all" />
<label for="edit_parent_id" class="label_cpm">'.$LANG['group_parent'].'</label>
<select id="edit_parent_id" class="input_text text ui-widget-content ui-corner-all">'.
$droplist.'
</select>
<label for="edit_folder_complexite" class="label_cpm">'.$LANG['complex_asked'].'</label>
<select id="edit_folder_complexite" class="input_text text ui-widget-content ui-corner-all">';
foreach ($SETTINGS_EXT['pwComplexity'] as $complex) {
echo '<option value="'.$complex[0].'">'.$complex[1].'</option>';
}
echo '
</select>
<label for="edit_folder_renewal_period" class="label_cpm">'.$LANG['group_pw_duration'].'</label>
<input type="text" id="edit_folder_renewal_period" value="0" class="input_text text ui-widget-content ui-corner-all" />
<label for="edit_folder_block_creation" class="">'.$LANG['auth_creation_without_complexity'].'</label>
<select id="edit_folder_block_creation" class="ui-widget-content ui-corner-all">
<option value="0">'.$LANG['no'].'</option>
<option value="1">'.$LANG['yes'].'</option>
</select>
<div style="margin-top:10px;">
<label for="edit_folder_block_modif">'.$LANG['auth_modification_without_complexity'].'</label>
<select id="edit_folder_block_modif" class="ui-widget-content ui-corner-all">
<option value="0">'.$LANG['no'].'</option>
<option value="1">'.$LANG['yes'].'</option>
</select>
</div>
<div style="padding:5px; z-index:9999999;" class="ui-widget-content ui-state-focus ui-corner-all" id="edit_folder_wait">
<i class="fa fa-cog fa-spin fa-2x"></i> '.$LANG['please_wait'].'
</div>
</div>';
require_once 'folders.load.php';