forked from nilsteampassnet/TeamPass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.settings.load.php
736 lines (697 loc) · 28.5 KB
/
admin.settings.load.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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
<?php
/**
* @file admin.settings.load.php
* @author Nils Laumaillé
* @version 2.1.25
* @copyright (c) 2009-2015 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...');
}
?>
<script type="text/javascript">
/*
* Add a new field to a category
*/
function fieldAdd(id) {
$("#post_id").val(id);
$("#add_new_field").dialog("open");
}
/*
* Edit category's folders
*/
function catInFolders(id) {
$("#post_id").val(id);
$("#catInFolder_title").html($("#item_"+id).html()); // display title
// pre-select folders
var folder = $("#catFoldersList_"+id).val().split(";");
for (var i=0; i<folder.length; i++) {
$("#cat_folders_selection option[value="+folder[0]+"]").attr('selected', true);
};
// open
$("#category_in_folder").dialog("open");
}
/*
* Add a new category
*/
function categoryAdd() {
if ($("#new_category_label").val() == "") {
return false;
}
$("#div_loading").show();
//send query
$.post(
"sources/categories.queries.php",
{
type : "addNewCategory",
title : sanitizeString($("#new_category_label").val())
},
function(data) {
// build new row
$("#tbl_categories").append(
'<tr id="t_cat_'+data[0].id+'"><td colspan="2">'+
'<input type="text" id="catOrd_'+data[0].id+'" size="1" class="category_order" value="1" /> '+
'<input type="radio" name="sel_item" id="item_'+data[0].id+'_cat" />'+
'<label for="item_'+data[0].id+'_cat" id="item_'+data[0].id+'">'+
$("#new_category_label").val()+'</label><a href="#" title="<?php echo $LANG['field_add_in_category'];?>" onclick="fieldAdd('+
data[0].id+')" class="cpm_button tip" style="margin-left:20px;"><img src="includes/images/zone--plus.png" /></a></td><td>'+
'<a href="#" title="<?php echo $LANG['category_in_folders'];?>" onclick="catInFolders('+data[0].id+')" class="cpm_button tip" style="margin-left:5px;"><img src="includes/images/folder_edit.png" /></a>'+
'<?php echo $LANG['category_in_folders_title'];?>:'+
'<span style="font-family:italic; margin-left:10px;" id="catFolders_'+data[0].id+'"></span>'+
'<input type="hidden" id="catFoldersList_'+data[0].id+'" value="'+data[0].id+'" /></td><td></td>');
// Add new cat
$("#moveItemTo").append('<option value="'+data[0].id+'">'+$("#new_category_label").val()+'</option>');
// clean
$("#new_category_label, #new_item_title").val("");
//loadFieldsList();
$("#div_loading,#no_category").hide();
},
"json"
);
}
/*
* rename an Element
*/
function renameItem() {
var data = $("input[name=sel_item]:checked").attr("id").split('_');
$("#post_id").val(data[1]);
$("#post_type").val("renameItem");
$("#category_confirm_text").html("<?php echo $LANG['confirm_rename'];?>");
$("#category_confirm").dialog("open");
}
/*
* Delete an Element
*/
function deleteItem() {
var data = $("input[name=sel_item]:checked").attr("id").split('_');
$("#post_id").val(data[1]);
$("#post_type").val("deleteCategory");
$("#category_confirm_text").html("<?php echo $LANG['confirm_deletion'];?>");
$("#category_confirm").dialog("open");
}
/*
* Move an Element
*/
function moveItem() {
var data = $("input[name=sel_item]:checked").attr("id").split('_');
$("#post_id").val(data[1]);
$("#post_type").val("moveItem");
$("#category_confirm_text").html("<?php echo $LANG['confirm_moveto'];?>");
$("#category_confirm").dialog("open");
}
/*
* Save the position of the Categories
*/
function storePosition() {
$("#div_loading").show();
// prepare listing to save
var data = "";
var id;
var val;
$('input[class$="category_order"]').each(function(index) {
id = $(this).attr("id").split("_");
if ($(this).val() == "") {
val = "1";
} else {
val = $(this).val();
}
if (data == "") {
data = id[1]+":"+val;
} else {
data += ";"+id[1]+":"+val;
}
});
//send query
$.post(
"sources/categories.queries.php",
{
type : "saveOrder",
data : data
},
function(data) {
$("#div_loading").hide();
},
"json"
);
}
/*
* Reload table
*/
function loadFieldsList() {
$("#div_loading").show();
//send query
$.post(
"sources/categories.queries.php",
{
type : "loadFieldsList",
title : prepareExchangedData(sanitizeString($("#new_category_label").val()), "encode", "<?php echo $_SESSION['key'];?>")
},
function(data) {
var newList = '<table id="tbl_categories" style="">';
// parse json table and disaply
var json = $.parseJSON(data);
$(json).each(function(i,val){
if (val[0] == 1) {
newList += '<tr id="t_cat_'+val[1]+'"><td colspan="2">'+
'<input type="text" id="catOrd_'+val[1]+'" size="1" class="category_order" value="'+val[3]+'" /> '+
'<input type="radio" name="sel_item" id="item_'+val[1]+'_cat" />'+
'<label for="item_'+val[1]+'_cat" id="item_'+val[1]+'">'+val[2]+'</label>'+
'<a href="#" title="<?php echo $LANG['field_add_in_category'];?>" onclick="fieldAdd('+val[1]+')" class="cpm_button tip" style="margin-left:20px;">'+
'<img src="includes/images/zone--plus.png" /></a></td>'+
'<td><a href="#" title="<?php echo $LANG['category_in_folders'];?>" onclick="catInFolders('+val[1]+')" class="cpm_button tip" style="margin-left:5px;"><img src="includes/images/folder_edit.png" /></a>'+
'<?php echo $LANG['category_in_folders_title'];?>:'+
'<span style="font-family:italic; margin-left:10px;" id="catFolders_'+val[1]+'">'+val[4]+'</span>'+
'<input type="hidden" id="catFoldersList_'+val[1]+'" value="'+val[5]+'" /></td></tr>';
} else {
newList += '<tr id="t_field_'+val[1]+'"><td width="20px"></td>'+
'<td><input type="text" id="catOrd_'+val[1]+'" size="1" class="category_order" value="'+val[3]+'" /> '+
'<input type="radio" name="sel_item" id="item_'+val[1]+'_cat" />'+
'<label for="item_'+val[1]+'_cat" id="item_'+val[1]+'">'+val[2]+'</label>'+
'</td><td></td></tr>';
}
});
// display
newList += '</table>';
$("#new_item_title").val("");
$("#categories_list").html(newList);
$("#div_loading").hide();
}
);
}
function changeSettingStatus(id, val) {
if (val == 1) {
$("#flag_"+id).html("<img src='includes/images/status.png' />");
$("#"+id+"_radio2").addClass("ui-button.redButton");
console.log(("#"+id+"_radio2"));
} else {
$("#flag_"+id).html("<img src='includes/images/status-busy.png' />");
}
}
//###########
//## FUNCTION : Launch the action the admin wants
//###########
function LaunchAdminActions(action,option)
{
$("#div_loading").show();
$("#email_testing_results").hide();
$("#result_admin_action_db_backup").html("");
if (action == "admin_action_db_backup") option = $("#result_admin_action_db_backup_key").val();
else if (action == "admin_action_backup_decrypt") option = $("#bck_script_decrypt_file").val();
else if (action == "admin_action_change_salt_key") {
option = aes_encrypt(sanitizeString($("#new_salt_key").val()));
} else if (action == "admin_email_send_backlog") {
$("#email_testing_results").show().html("'.addslashes($LANG['please_wait']).'").attr("class","ui-corner-all ui-state-focus");
} else if (action == "admin_action_attachments_cryption") {
option = $("input[name=attachments_cryption]:checked").val();
if (option == "") return;
}
//Lauchn ajax query
$.post(
"sources/admin.queries.php",
{
type : action,
option : option
},
function(data) {
$("#div_loading").hide();
if (data != null) {
if (data[0].result == "db_backup") {
$("#result_admin_action_db_backup").html("<img src='includes/images/document-code.png' alt='' /> <a href='"+data[0].href+"'><?php echo $LANG['pdf_download'];?></a>");
} else if (data[0].result == "pf_done") {
$("#result_admin_action_check_pf").show();
} else if (data[0].result == "db_restore") {
$("#restore_bck_encryption_key_dialog").dialog("close");
$("#result_admin_action_db_restore").html("<img src='includes/images/tick.png' alt='' />");
$("#result_admin_action_db_restore_get_file").hide();
//deconnect user
$("#menu_action").val("deconnexion");
document.main_form.submit();
} else if (data[0].result == "cache_reload") {
$("#result_admin_action_reload_cache_table").html("<img src='includes/images/tick.png' alt='' />");
} else if (data[0].result == "db_optimize") {
$("#result_admin_action_db_optimize").html("<img src='includes/images/tick.png' alt='' />");
} else if (data[0].result == "purge_old_files") {
$("#result_admin_action_purge_old_files").html("<img src='includes/images/tick.png' alt='' /> "+data[0].nb_files_deleted+" <? echo $LANG['admin_action_purge_old_files_result'];?>");
} else if (data[0].result == "db_clean_items") {
$("#result_admin_action_db_clean_items").html("<img src='includes/images/tick.png' alt='' /> "+data[0].nb_items_deleted+" <?php echo $LANG['admin_action_db_clean_items_result'];?>");
} else if (data[0].result == "changed_salt_key") {
//deconnect user
$("#menu_action").val("deconnexion");
sessionStorage.clear();
document.main_form.submit();
} else if (data[0].result == "email_test_conf" || data[0].result == "admin_email_send_backlog") {
if (data[0].error != "") {
$("#email_testing_results").html("<?php echo addslashes($LANG['admin_email_result_nok']);?> "+data[0].message).show().attr("class","ui-state-error ui-corner-all");
} else {
$("#email_testing_results").html("<?php echo addslashes(str_replace("#email#", $_SESSION['user_email'], $LANG['admin_email_result_ok']));?>").show().attr("class","ui-corner-all ui-state-focus");
}
} else if (data[0].result == "pw_prefix_correct") {
$("result_admin_action_pw_prefix_correct").html(data[0].ret);
} else if (data[0].result == "attachments_cryption") {
if (data[0].continu == true) {
manageEncryptionOfAttachments(data[0].list, data[0].cpt);
} else if (data[0].error == "file_not_encrypted") {
$("#result_admin_action_attachments_cryption").html("It seems the files are not encrypted. Are you sure you want to decrypt? please do a check.");
} else if (data[0].error == "file_not_clear") {
$("#result_admin_action_attachments_cryption").html("It seems the files are encrypted. Are you sure you want to encrypt? please do a check.");
}
}
}
},
"json"
);
}
/*
*
*/
function changeMainSaltKey(start)
{
var nb = 10; // can be changed - number of items treated in each loop
// check saltkey length
if ($("#new_salt_key").val().length != 16) {
$("#changeMainSaltKey_message").html("<i class=\"fa fa-alert fa-spin fa\"></i> <?php echo $LANG['error_saltkey_length'];?>");
return false;
}
// prepare excahnge
var newSK = prepareExchangedData(
'{"newSK":"'+sanitizeString($("#new_salt_key").val())+'"}',
"encode",
"<?php echo $_SESSION['key'];?>"
);
//console.log("Start value: "+start);
// start change
if (start == "starting") {
// inform
$("#changeMainSaltKey_message").html("<i class=\"fa fa-cog fa-spin fa\"></i> <?php echo $LANG['starting'];?>");
// launch query
$.post(
"sources/admin.queries.php",
{
type : "admin_action_change_salt_key___start",
newSK : newSK
},
function(data) {
//console.log("Step start - " + data[0].nextAction);
if (data[0].error == "" && data[0].nextAction == "encrypt_items") {
$("#changeMainSaltKey_itemsCount").val(data[0].nbOfItems);
//console.log("Now launch encryption");
// start encrypting items with new saltkey
changeMainSaltKey(0);
} else {
// error mngt
$("#changeMainSaltKey_message").html("<i class=\"fa fa-alert fa-spin fa\"></i> <?php echo $LANG['error_sent_back'];?> : "+data[0].error);
}
},
"json"
);
}
else if (isFinite(start)) {
//console.log("Step Encrypt - " + newSK+" ; "+start+" ; "+nb+" ; "+$("#changeMainSaltKey_itemsCount").val());
$("#changeMainSaltKey_message").html("<i class=\"fa fa-cog fa-spin fa\"></i> <?php echo $LANG['treating_items'];?>... "+start+" > "+(parseInt(start)+parseInt(nb))+" (<?php echo $LANG['total_number_of_items'];?> : "+$("#changeMainSaltKey_itemsCount").val()+")");
$.post(
"sources/admin.queries.php",
{
type : "admin_action_change_salt_key___encrypt",
newSK : newSK,
start : start,
length : nb,
nbItems : $("#changeMainSaltKey_itemsCount").val()
},
function(data) {
console.log("Next action: "+data[0].nextAction);
if (data[0].nextAction == "encrypting") {
changeMainSaltKey(data[0].nextStart);
} else if (data[0].nextAction == "finishing") {
$("#changeMainSaltKey_message").html("<?php echo $LANG['finalizing'];?>...");
changeMainSaltKey("finishing");
} else {
// error mngt
$("#changeMainSaltKey_message").html("<i class=\"fa fa-alert fa-spin fa\"></i> <?php echo $LANG['error_sent_back'];?> : "+data[0].error);
}
},
"json"
);
}
else {
console.log("finishing");
$.post(
"sources/admin.queries.php",
{
type : "admin_action_change_salt_key___end",
newSK : newSK
},
function(data) {
if (data[0].nextAction == "done") {
console.log("done");
$("#changeMainSaltKey_message").html("<i class=\"fa fa-info fa-spin fa\"></i> <?php echo $LANG['finalizing'];?> <?php echo $LANG['number_of_items_treated'];?> : "+$("#changeMainSaltKey_itemsCount").val());
} else {
// error mngt
}
},
"json"
);
}
}
// Init
$(function() {
$('.toggle').toggles({
drag: true, // allow dragging the toggle between positions
click: true, // allow clicking on the toggle
text: {
on: '<?php echo $LANG['yes'];?>', // text for the ON position
off: '<?php echo $LANG['no'];?>' // and off
},
on: true, // is the toggle ON on init
animate: 250, // animation time (ms)
easing: 'swing', // animation transition easing function
width: 50, // width used if not set in css
height: 20, // height if not set in css
type: 'compact' // if this is set to 'select' then the select style toggle will be used
});
$('.toggle').on('toggle', function(e, active) {
if (active) {
$("#"+e.target.id+"_input").val(1);
} else {
$("#"+e.target.id+"_input").val(0);
}
});
$("input[type=button], #save_button, .button").button();
// spinner
$("#upload_imageresize_quality").spinner({
min: 0,
max: 100,
value: 90
});
//BUILD BUTTONSET
$(".div_radio").buttonset();
// Build Tabs
$("#tabs").tabs({
ajaxOptions: {
error: function(xhr, status, index, anchor) {
$(anchor.hash).html();
},
beforeSend: function() {
$("#div_loading").show();
},
complete: function() {
$("#div_loading").hide();
}
},
beforeLoad: function( event, ui ) {
ui.panel.html('<div id="loader_tab"><i class="fa fa-cog fa-spin"></i> <?php echo $LANG['loading'];?>...</div>')
},
load: function( event, ui ) {
$("#loader_tab").remove();
}
});
$('#tabs').click(function(e){
var current_index = $("#tabs").tabs("option","active");
if (current_index == 9 || current_index == 10) {
$("#save_button").hide();
} else {
$("#save_button").show();
}
});
$('#tbl_categories tr').click(function (event) {
$("#selected_row").val($(this).attr("id"));
});
// display text of selected item
$(document).on("click","input[name=sel_item]",function(){
var data = $("input[name=sel_item]:checked").attr("id").split('_');
$("#new_item_title").val($("#item_"+data[1]).html());
});
// confirm dialogbox
$("#category_confirm").dialog({
bgiframe: true,
modal: true,
autoOpen: false,
width: 400,
height: 120,
title: "<?php echo $LANG['confirm'];?>",
buttons: {
"<?php echo $LANG['confirm'];?>": function() {
$("#div_loading").show();
var $this = $(this);
// prepare data to send
var data = "";
if ($("#post_type").val() == "renameItem") {
data = sanitizeString($("#new_item_title").val());
} else if ($("#post_type").val() == "moveItem") {
data = $("#moveItemTo").val();
}
// send query
$.post(
"sources/categories.queries.php",
{
type : $("#post_type").val(),
id : $("#post_id").val(),
data : data
},
function(data) {
if ($("#post_type").val() == "deleteCategory") {
$("#t_field_"+$("#post_id").val()).hide();
} else if ($("#post_type").val() == "renameItem") {
$("#item_"+$("#post_id").val()).html($("#new_item_title").val());
} else if ($("#post_type").val() == "moveItem") {
// reload table
//loadFieldsList();
}
loadFieldsList();
$("#new_category_label, #new_item_title").val("");
$("#div_loading").hide();
$this.dialog("close");
},
"json"
);
},
"<?php echo $LANG['cancel_button'];?>": function() {
$("#div_loading").hide();
$(this).dialog("close");
}
}
});
$("#add_new_field").dialog({
bgiframe: true,
modal: true,
autoOpen: false,
width: 500,
height: 150,
title: "<?php echo $LANG['category_in_folders'];?>",
buttons: {
"<?php echo $LANG['confirm'];?>": function() {
if ($("#new_field_title").val() != "" && $("#post_id").val() != "") {
$("#div_loading").show();
var $this = $(this);
//send query
$.post(
"sources/categories.queries.php",
{
type : "addNewField",
title : sanitizeString($("#new_field_title").val()),
id : $("#post_id").val()
},
function(data) {
$("#new_field_title").val("");
// reload table
loadFieldsList();
$this.dialog("close");
},
"json"
);
}
},
"<?php echo $LANG['cancel_button'];?>": function() {
$("#div_loading").hide();
$(this).dialog("close");
}
}
});
$("#category_in_folder").dialog({
bgiframe: true,
modal: true,
autoOpen: false,
width: 300,
height: 350,
title: "<?php echo $LANG['category_in_folders'];?>",
buttons: {
"<?php echo $LANG['confirm'];?>": function() {
// get list of selected folders
var ids = "";
$("#cat_folders_selection :selected").each(function(i, selected) {
if (ids == "") ids = $(selected).val();
else ids = ids + ";" + $(selected).val();
});
if (ids != "") {
$("#div_loading, #catInFolder_wait").show();
var $this = $(this);
//send query
$.post(
"sources/categories.queries.php",
{
type : "categoryInFolders",
foldersIds : ids,
id : $("#post_id").val()
},
function(data) {
$("#new_field_title").val("");
// display new list
$("#catFolders_"+$("#post_id").val()).html(data[0].list);
// close
$("#div_loading, #catInFolder_wait").hide();
$this.dialog("close");
},
"json"
);
}
},
"<?php echo $LANG['cancel_button'];?>": function() {
$("#div_loading").hide();
$(this).dialog("close");
}
}
});
$("#restore_bck_encryption_key_dialog").dialog({
bgiframe: true,
modal: true,
autoOpen: false,
width:100,
height:140,
title: "<?php echo $LANG['admin_action_db_restore_key'];?>",
buttons: {
"<?php echo $LANG['ok'];?>": function() {
LaunchAdminActions("admin_action_db_restore", $("#restore_bck_fileObj").val()+"&"+$("#restore_bck_encryption_key").val());
},
"<?php echo $LANG['cancel_button'];?>'": function() {
$(this).dialog("close");
}
}
});
// SQL IMPORT FOR RESTORING
var uploader_restoreDB = new plupload.Uploader({
runtimes : "gears,html5,flash,silverlight,browserplus",
browse_button : "pickfiles_restoreDB",
container : "upload_container_restoreDB",
max_file_size : "10mb",
chunk_size : "1mb",
unique_names : true,
dragdrop : true,
multiple_queues : false,
multi_selection : false,
max_file_count : 1,
url : "sources/upload/upload.files.php",
flash_swf_url : "includes/libraries/Plupload/plupload.flash.swf",
silverlight_xap_url : "includes/libraries/Plupload/plupload.silverlight.xap",
filters : [
{title : "SQL files", extensions : "sql"}
],
init: {
FilesAdded: function(up, files) {
up.start();
},
BeforeUpload: function (up, file) {
$("#import_status_ajax_loader").show();
up.settings.multipart_params = {
"PHPSESSID":"'.$_SESSION['user_id'].'",
"File":file.name,
"type_upload":"restore_db"
};
},
UploadComplete: function(up, files) {
$.each(files, function(i, file) {
$("#restore_bck_fileObj").val(file.name);
$("#restore_bck_encryption_key_dialog").dialog("open");
});
}
}
});
// Uploader options
uploader_restoreDB.bind("UploadProgress", function(up, file) {
$("#" + file.id + " b").html(file.percent + "%");
});
uploader_restoreDB.bind("Error", function(up, err) {
$("#filelist_restoreDB").html("<div class='ui-state-error ui-corner-all'>Error: " + err.code +
", Message: " + err.message +
(err.file ? ", File: " + err.file.name : "") +
"</div>"
);
up.refresh(); // Reposition Flash/Silverlight
});
uploader_restoreDB.bind("+", function(up, file) {
$("#" + file.id + " b").html("100%");
});
// Load CSV click
$("#uploadfiles_restoreDB").click(function(e) {
uploader_restoreDB.start();
e.preventDefault();
});
uploader_restoreDB.init();
// -end
//Enable/disable option
$("#restricted_to").bind("click", function() {
if ($("#restricted_to_input").val()== 1) {
$("#tr_option_restricted_to_roles").show();
} else {
$("#tr_option_restricted_to_roles").hide();
$("#tr_option_restricted_to_roles_input").val("0");
}
});
$("#anyone_can_modify").bind("click", function() {
if ($("#anyone_can_modify_input").val()== 1) {
$("#tr_option_anyone_can_modify_bydefault").show();
} else {
$("#tr_option_anyone_can_modify_bydefault").hide();
$("#anyone_can_modify_bydefault_input").val("0");
}
});
//check NEW SALT KEY
$("#new_salt_key").keypress(function (e) {
var key = e.charCode || e.keyCode || 0;
if ($("#new_salt_key").val().length != 16) {
$("#change_salt_key_image").attr("src", "includes/images/cross.png");
$("#change_salt_key_but").hide();
} else {
$("#change_salt_key_image").attr("src", "includes/images/tick.png");
$("#change_salt_key_but").show();
}
// allow backspace, tab, delete, arrows, letters, numbers and keypad numbers ONLY
return (
key != 33 && key != 34 && key != 39 && key != 92 && key != 32 && key != 96 && (key < 165)
&& $("#new_salt_key").val().length <= 32
);
});
});
function manageEncryptionOfAttachments(list, cpt) {
$.post(
"sources/admin.queries.php",
{
type : "admin_action_attachments_cryption_continu",
option : $("input[name=attachments_cryption]:checked").val(),
cpt : cpt,
list : list
},
function(data) {
if (data[0].continu == true ) {
manageEncryptionOfAttachments(data[0].list, data[0].cpt);
} else {
$("#result_admin_action_attachments_cryption").html("<img src='includes/images/tick.png' alt='' /> "+data[0].cpt+" files changed");
}
},
"json"
);
}
function refreshInput()
{
var ids = "";
$("#roles_allowed_to_print_select :selected").each(function(i, selected) {
if (ids == "") ids = $(selected).val();
else ids = ids + ";" + $(selected).val();
});
$("#roles_allowed_to_print").val(ids);
}
</script>