forked from nilsteampassnet/TeamPass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.php
362 lines (336 loc) · 22.4 KB
/
home.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
<?php
/**
* @file home.php
* @author Nils Laumaillé
* @version 2.1.22
* @copyright (c) 2009-2014 Nils Laumaillé
* @licensing GNU AFFERO GPL 3.0
* @link http://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) {
die('Hacking attempt...4');
}
require_once $_SESSION['settings']['cpassman_dir'].'/sources/SplClassLoader.php';
//Call nestedtree library and load full tree
$tree = new SplClassLoader('Tree\NestedTree', '../includes/libraries');
$tree->register();
$tree = new Tree\NestedTree\NestedTree($pre.'nested_tree', 'id', 'parent_id', 'title');
$tree->rebuild();
$fullTree = $tree->getDescendants();
echo '
<div style="line-height: 24px;margin-top:10px;min-height:220px;">
<span class="ui-icon ui-icon-person" style="float: left; margin-right: .3em;"> </span>
'.$LANG['index_welcome'].' <b>', isset($_SESSION['name']) && !empty($_SESSION['name']) ? $_SESSION['name'].' '.$_SESSION['lastname'] : $_SESSION['login'], '</b><br />';
//Check if password is valid
if (empty($_SESSION['last_pw_change']) || $_SESSION['validite_pw'] == false) {
echo '
<div style="margin:auto;padding:4px;width:300px;" class="ui-state-focus ui-corner-all">
<h3>'.$LANG['index_change_pw'].'</h3>
<div style="height:20px;text-align:center;margin:2px;display:none;" id="change_pwd_error" class=""></div>
<div style="text-align:center;margin:5px;padding:3px;" id="change_pwd_complexPw" class="ui-widget ui-state-active ui-corner-all">'.
$LANG['complex_asked'].' : '.$pwComplexity[$_SESSION['user_pw_complexity']][1].
'</div>
<div id="pw_strength" style="margin:0 0 10px 30px;"></div>
<table>
<tr>
<td>'.$LANG['index_new_pw'].' :</td><td><input type="password" size="15" name="new_pw" id="new_pw"/></td>
</tr>
<tr><td>'.$LANG['index_change_pw_confirmation'].' :</td><td><input type="password" size="15" name="new_pw2" id="new_pw2" onkeypress="if (event.keyCode == 13) ChangeMyPass();" /></td></tr>
</table>
<input type="hidden" id="pw_strength_value" />
<input type="button" onClick="ChangeMyPass()" onkeypress="if (event.keyCode == 13) ChangeMyPass();" class="ui-state-default ui-corner-all" style="padding:4px;width:150px;margin:10px 0 0 80px;" value="'.$LANG['index_change_pw_button'].'" />
</div>
<script type="text/javascript">
$("#new_pw").focus();
</script>';
} elseif (!empty($_SESSION['derniere_connexion'])) {
//Last items created block
if (
isset($_SESSION['settings']['show_last_items']) && $_SESSION['settings']['show_last_items'] == 1
&& $_SESSION['user_admin'] != 1 && !empty($_SESSION['groupes_visibles_list'])
) {
echo '
<div style="position:relative;float:right;margin-top:-25px;padding:4px;width:250px;" class="ui-state-highlight ui-corner-all">
<span class="ui-icon ui-icon-comment" style="float: left; margin-right: .3em;"> </span>
<span style="font-weight:bold;margin-bottom:10px;">'.$LANG['block_last_created'].'</span><br />';
$cpt=1;
$rows = DB::query("SELECT i.label as label, i.id as id, i.id_tree as id_tree
FROM ".$pre."log_items l
INNER JOIN ".$pre."items i
WHERE l.action = %s_action
AND l.id_item = i.id
AND i.id_tree IN %li_id_tree
AND i.perso = %i_perso
ORDER BY l.date DESC
LIMIT 0,10",
array(
'action' => 'at_creation',
'id_tree' => $_SESSION['groupes_visibles'],
'perso' => 0
)
);
foreach ($rows as $record) {
DB::query("SELECT * FROM ".$pre."log_items WHERE id_item = %i AND action = %s", $record['id'], 'at_delete');
$counter = DB::count();
if ($counter == 0) {
echo '<span class="ui-icon ui-icon-tag" style="float: left; margin-right: .3em;"> </span>
<a href="#" onClick="javascript:$(\'#menu_action\').val(\'action\');window.location.href =\'index.php?page=items&group='.$record['id_tree'].'&id='.$record['id'].'\';" style="cursor:pointer;">'.stripslashes($record['label']).'</a><br />';
if ($cpt==5) {
break;
}
$cpt++;
}
}
echo '
</div>';
}
//ADMIN INFORMATION
/*if ($_SESSION['user_admin'] == 1) {
echo '
<div style="position:relative;float:right;margin-top:-25px;padding:4px;width:250px;" class="ui-state-highlight ui-corner-all">
<span class="ui-icon ui-icon-comment" style="float: left; margin-right: .3em;"> </span>
<span style="font-weight:bold;margin-bottom:10px;">'.$LANG['block_admin_info'].'</span><br />'.
$LANG['admin_new1'].'
</div>';
}*/
//some informations
echo '
<span class="ui-icon ui-icon-calendar" style="float: left; margin-right: .3em;"> </span>
'.$LANG['index_last_seen'].' ', isset($_SESSION['settings']['date_format']) ? date($_SESSION['settings']['date_format'], $_SESSION['derniere_connexion']) : date("d/m/Y", $_SESSION['derniere_connexion']), ' '.$LANG['at'].' ', isset($_SESSION['settings']['time_format']) ? date($_SESSION['settings']['time_format'], $_SESSION['derniere_connexion']) : date("H:i:s", $_SESSION['derniere_connexion']), '
<br />
<span class="ui-icon ui-icon-key" style="float: left; margin-right: .3em;"> </span>
'.$LANG['index_last_pw_change'].' ', isset($_SESSION['settings']['date_format']) ? date($_SESSION['settings']['date_format'], $_SESSION['last_pw_change']) : date("d/m/Y", $_SESSION['last_pw_change']), '. ', $numDaysBeforePwExpiration == "infinite" ? '' : $LANG['index_pw_expiration'].' '.$numDaysBeforePwExpiration.' '.$LANG['days'].'.';
echo '
<br /><span class="ui-icon ui-icon-signal-diag" style="float: left; margin-right: .3em;"> </span>
<div id="upload_info">
<div id="plupload_runtime" class="ui-state-error ui-corner-all" style="width:400px;">Upload feature: No runtime found.</div>
<input type="hidden" id="upload_enabled" value="" />
</div>';
//Personnal menu
echo '
<div style="margin-top:15px;" id="personal_menu_actions">
<span class="ui-icon ui-icon-script" style="float: left; margin-right: .3em;"> </span><b>'.$LANG['home_personal_menu'].'</b>
<div style="margin-left:30px;">',
isset($_SESSION['settings']['ldap_mode']) && $_SESSION['settings']['ldap_mode'] == 1 ? '' :
'<button title="'.$LANG['index_change_pw'].'" onclick="OpenDialogBox(\'div_changer_mdp\')">
<img src="includes/images/lock--pencil.png" alt="Change pw" />
</button> ',
$_SESSION['user_admin'] == 1 ? '' :
(isset($_SESSION['settings']['allow_import']) && $_SESSION['settings']['allow_import'] == 1 && $_SESSION['user_admin'] != 1) ? '
<button title="'.$LANG['import_csv_menu_title'].'" onclick="$(\'#csv_import_options, #kp_import_options\').hide();$(\'#div_import_from_csv\').dialog(\'open\');">
<img src="includes/images/database-import.png" alt="Import" />
</button>' : '' ,
(isset($_SESSION['settings']['allow_print']) && $_SESSION['settings']['allow_print'] == 1 && $_SESSION['user_admin'] != 1 && $_SESSION['temporary']['user_can_printout'] == true) ? '
<button title="'.$LANG['print_out_menu_title'].'" onclick="print_out_items()">
<img src="includes/images/printer.png" alt="Print" />
</button>' : '' ,
(isset($_SESSION['settings']['settings_offline_mode']) && $_SESSION['settings']['settings_offline_mode'] == 1 && $_SESSION['user_admin'] != 1) ? '
<button title="'.$LANG['offline_menu_title'].'" onclick="offlineModeLaunch()">
<img src="includes/images/block-share.png" alt="Print" />
</button>' : '' , '
</div>
</div>';
//Personnal SALTKEY
if (
isset($_SESSION['settings']['enable_pf_feature']) && $_SESSION['settings']['enable_pf_feature'] == 1
//&& (!isset($_SESSION['settings']['psk_authentication']) || $_SESSION['settings']['psk_authentication'] == 0)
) {
echo '
<div style="margin-top:15px;" id="personal_saltkey">
<span class="ui-icon ui-icon-locked" style="float: left; margin-right: .3em;"> </span><b>'.$LANG['home_personal_saltkey'].'</b>
<div style="margin-left:30px;">
<input type="password" name="input_personal_saltkey" id="input_personal_saltkey" style="width:200px;padding:5px;" class="text ui-widget-content ui-corner-all" value="', isset($_SESSION['my_sk']) ? '**************************' : '', '" title="'.$LANG['home_personal_saltkey_info'].'" />
<button id="personal_sk" onclick="StorePersonalSK()">
'.$LANG['home_personal_saltkey_button'].'
</button>
<button id="change_personal_sk" onclick="$(\'#div_change_personal_saltkey\').dialog(\'open\')">
'.$LANG['personal_saltkey_change_button'].'
</button>
<button id="reset_personal_sk" onclick="$(\'#div_reset_personal_sk\').dialog(\'open\')">
'.$LANG['personal_saltkey_lost'].'
</button>
</div>
</div>';
//change the saltkey dialogbox
echo '
<div id="div_change_personal_saltkey" style="display:none;padding:4px;">
<label for="new_personal_saltkey" class="form_label_180">'.$LANG['new_saltkey'].' :</label>
<input type="text" size="30" name="new_personal_saltkey" id="new_personal_saltkey" />
<div style="margin-top:5px;font-style:italic;">
<span class="ui-icon ui-icon-signal-diag" style="float: left; margin-right: .3em;"> </span>
<a id="ask_for_an_old_sk" href="#" onclick="showHideDiv(\'ask_for_an_old_sk_div\')">'.$LANG['define_old_saltkey'].'</a>
</div>
<div style="margin-top:5px;display:none;" id="ask_for_an_old_sk_div">
<label for="old_personal_saltkey" class="form_label_180">'.$LANG['old_saltkey'].' :</label>
<input type="text" size="30" name="old_personal_saltkey" id="old_personal_saltkey" value="" />
</div>
<div style="margin-top:20px;" class="ui-state-highlight">
'.$LANG['new_saltkey_warning'].'
</div>
<div id="div_change_personal_saltkey_wait" style="display:none;width:80%;margin:5px auto 5px auto;padding:3px;" class="ui-state-error"><b>'.$LANG['please_wait'].'</b></div>
</div>';
//saltkey LOST dialogbox
echo '
<div id="div_reset_personal_sk" style="display:none;padding:4px;">
<div style="margin-bottom:20px;" class="ui-state-highlight">
'.$LANG['new_saltkey_warning_lost'].'
</div>
<label for="reset_personal_saltkey" class="form_label_180">'.$LANG['new_saltkey'].' :</label>
<input type="text" size="30" name="reset_personal_saltkey" id="reset_personal_saltkey" />
</div>';
}
//change the password
echo '
<div>
<div id="div_changer_mdp" style="display:none;padding:4px;">
<div style="height:20px;text-align:center;margin:2px;" id="change_pwd_error" class=""></div>
<div style="text-align:center;margin:5px;padding:3px;" id="change_pwd_complexPw" class="ui-widget ui-state-active ui-corner-all"></div>
<label for="new_pw" class="form_label">'.$LANG['index_new_pw'].' :</label>
<input type="password" size="15" name="new_pw" id="new_pw" />
<label for="new_pw2" class="form_label">'.$LANG['index_change_pw_confirmation'].' :</label>
<input type="password" size="15" name="new_pw2" id="new_pw2" />
<div id="pw_strength" style="margin:10px 0 0 50px;"></div>
<input type="hidden" id="pw_strength_value" />
</div>
</div>';
//Import from CSV div
echo '
<div style="">
<div id="div_import_from_csv" style="display:none;padding:4px;">';
// Show buttons for selected what kind of import
echo '
<div id="radio_import_type">
<input type="radio" id="radio1" name="radio" class="import_radio" checked="checked" onclick="toggle_import_type(\'csv\')" /><label for="radio1">CSV</label>
<input type="radio" id="radio2" name="radio" class="import_radio" onclick="toggle_import_type(\'keepass\')" /><label for="radio2">Keepass XML</label>
</div>';
//error div
echo '
<div style="margin:2px;display:none;" id="import_from_file_info" class="ui-state-error ui-corner-all"></div>';
// CSV import type
echo '
<div id="import_type_csv">
<div style="margin-bottom:5px;margin-top:5px;padding:5px;" class="ui-widget ui-state-active ui-corner-all">'.$LANG['import_csv_dialog_info'].'</div>
<!-- show input file -->
<div style="text-align:center;margin-top:10px;">
<div id="upload_container_csv">
<div id="filelist_csv"></div><br />
<a id="pickfiles_csv" href="#">'.$LANG['csv_import_button_text'].'</a>
</div>
<div id="csv_import_options" style="display:none;">
<input type="checkbox" id="import_csv_anyone_can_modify" /><label for="import_csv_anyone_can_modify">'.$LANG['import_csv_anyone_can_modify_txt'].'</label><br />
<input type="checkbox" id="import_csv_anyone_can_modify_in_role" /><label for="import_csv_anyone_can_modify_in_role">'.$LANG['import_csv_anyone_can_modify_in_role_txt'].'</label>
</div>
</div>
</div>';
// KEEPASS import type
echo '
<div id="import_type_keepass" style="display:none;">
<div style="margin-bottom:5px;margin-top:5px;padding:5px;" class="ui-widget ui-state-active ui-corner-all">'.$LANG['import_keepass_dialog_info'].'</div>
<!-- Prepare a list of all folders that the user can choose -->
<div style="margin-top:10px;" id="keypass_import_options">
<label><b>'.$LANG['import_keepass_to_folder'].'</b></label>
<select id="import_keepass_items_to">
<option value="0">'.$LANG['root'].'</option>';
$prevLevel = "";
foreach ($fullTree as $t) {
if (in_array($t->id, $_SESSION['groupes_visibles'])) {
if (is_numeric($t->title)) {
$user = DB::queryfirstrow("SELECT login FROM ".$pre."users WHERE id = %i", $t->title);
$t->title = $user['login'];
$t->id = $t->id."-perso";
}
$ident=" ";
for ($x=1; $x<$t->nlevel; $x++) {
$ident .= " ";
}
if ($prevLevel < $t->nlevel) {
echo '<option value="'.$t->id.'">'.$ident.$t->title.'</option>';
} elseif ($prevLevel == $t->nlevel) {
echo '<option value="'.$t->id.'">'.$ident.$t->title.'</option>';
} else {
echo '<option value="'.$t->id.'">'.$ident.$t->title.'</option>';
}
$prevLevel = $t->nlevel;
}
}
echo '
</select><br />
<input type="checkbox" id="import_kps_anyone_can_modify" /><label for="import_kps_anyone_can_modify">'.$LANG['import_csv_anyone_can_modify_txt'].'</label><br />
<input type="checkbox" id="import_kps_anyone_can_modify_in_role" /><label for="import_kps_anyone_can_modify_in_role">'.$LANG['import_csv_anyone_can_modify_in_role_txt'].'</label>
</div>';
echo '
<div id="upload_container_kp" style="text-align:center;margin-top:10px;">
<div id="filelist_kp"></div><br />
<a id="pickfiles_kp" href="#">'.$LANG['keepass_import_button_text'].'</a>
</div>
</div>';
// Import results
echo '
<div id="import_status_ajax_loader" style="margin-top:5px;display:none;text-align:center;"><img src="includes/images/ajax-loader.gif" /></div>
<div id="import_status" style="margin-top:10px;"></div>
</div>
</div>';
//Data Export (PDF/CSV)
if (isset($_SESSION['settings']['allow_print']) && $_SESSION['settings']['allow_print'] == 1 && $_SESSION['temporary']['user_can_printout'] == true) {
echo '
<div>
<div id="div_print_out" style="display:none;padding:4px;">
<div style="height:20px;text-align:center;margin:2px;" id="print_out_error" class=""></div>
<label for="selected_folders" class="form_label">'.$LANG['select_folders'].' :</label>
<select id="selected_folders" multiple size="7" class="text ui-widget-content ui-corner-all" style="padding:10px;"></select>
<div class="div_radio" stle="text-align:center;">
<input type="radio" id="export_format_radio1" name="export_format" value="pdf" /><label for="export_format_radio1">'.$LANG['pdf'].'</label>
<input type="radio" id="export_format_radio2" name="export_format" value="csv" /><label for="export_format_radio2">'.$LANG['csv'].'</label>
</div>
<br /><br />
<label for="pdf_password" class="">'.$LANG['admin_action_db_restore_key'].' :</label>
<input type="password" id="pdf_password" name="pdf_password" />
<div class="ui-state-highlight ui-corner-all" style="margin:10px;padding:10px;">
<span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"> </span>'.$LANG['print_out_warning'].'
</div>
<div id="download_link" style="text-align:center; width:100%; margin-top:15px;"></div>
<div style="text-align:center;margin-top:8px; display:none;" id="div_print_out_wait"><img src="includes/images/ajax-loader.gif" /></div>
</div>
</div>';
}
// Off line mode
if (isset($_SESSION['settings']['settings_offline_mode']) && $_SESSION['settings']['settings_offline_mode'] == 1) {
echo '
<div>
<div id="div_offline_mode" style="display:none;padding:4px;">
<div style="height:20px;text-align:center;margin:2px;" id="offline_mode_error" class=""></div>
<div style="margin:10px 0 10px 0;">
<label for="offline_mode_selected_folders" class="form_label">'.$LANG['select_folders'].' :</label>
<select id="offline_mode_selected_folders" multiple size="7" class="text ui-widget-content ui-corner-all" style="padding:10px;"></select>
</div>
<div style="margin:10px 0 10px 0;">
<label for="pdf_password" class="">'.$LANG['admin_action_db_restore_key'].' :</label>
<input type="password" id="offline_password" name="offline_password" />
<div id="offline_pw_strength" style="margin:10px 0 0 50px;"></div>
<input type="hidden" id="offline_pw_strength_value" />
<input type="hidden" id="min_offline_pw_strength_value" value="'.$_SESSION['settings']['offline_key_level'].'" />
</div>
<div style="margin:10px 0 10px 0;">
<div class="ui-state-highlight ui-corner-all" style="margin:10px;padding:10px;">
<span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"> d</span>'.$LANG['offline_mode_warning'].'
</div>
</div>
<div id="offline_download_link" style="text-align:center; width:100%; margin-top:15px;"> </div>
<div style="text-align:center;margin-top:8px; display:none;" id="div_offline_mode_wait"><img src="includes/images/ajax-loader.gif" /></div>
<input type="hidden" id="offmode_number" />
<input type="hidden" id="offmode_list" />
</div>
</div>';
}
}
echo '
</div>';
require_once 'home.load.php';