nilsteampassnet /
TeamPass
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * @file admin.settings.load.php |
||
| 4 | * @author Nils Laumaillé |
||
| 5 | * @version 2.1.27 |
||
| 6 | * @copyright (c) 2009-2017 Nils Laumaillé |
||
| 7 | * @licensing GNU AFFERO GPL 3.0 |
||
| 8 | * @link http://www.teampass.net |
||
| 9 | * |
||
| 10 | * This library is distributed in the hope that it will be useful, |
||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 13 | */ |
||
| 14 | |||
| 15 | if (!isset($_SESSION['CPM']) || $_SESSION['CPM'] != 1) { |
||
| 16 | die('Hacking attempt...'); |
||
| 17 | } |
||
| 18 | ?> |
||
| 19 | |||
| 20 | <script type="text/javascript"> |
||
| 21 | //<![CDATA[ |
||
| 22 | /* |
||
| 23 | * Add a new field to a category |
||
| 24 | */ |
||
| 25 | function fieldAdd(id) { |
||
| 26 | $("#post_id").val(id); |
||
| 27 | $("#add_new_field").dialog("open"); |
||
| 28 | } |
||
| 29 | /* |
||
| 30 | * Edit category's folders |
||
| 31 | */ |
||
| 32 | function catInFolders(id) { |
||
| 33 | $("#post_id").val(id); |
||
| 34 | $("#catInFolder_title").html($("#item_"+id).html()); // display title |
||
| 35 | // pre-select folders |
||
| 36 | $("#cat_folders_selection > option").prop("selected", false); |
||
| 37 | var folder = $("#catFoldersList_"+id).val().split(";"); |
||
| 38 | for (var i=0; i<folder.length; i++) { |
||
| 39 | $("#cat_folders_selection option[value="+folder[i]+"]").attr('selected', 'selected'); |
||
| 40 | }; |
||
| 41 | // open |
||
| 42 | $("#category_in_folder").dialog("open"); |
||
| 43 | } |
||
| 44 | |||
| 45 | /* |
||
| 46 | * Add a new category |
||
| 47 | */ |
||
| 48 | function categoryAdd() { |
||
| 49 | if ($("#new_category_label").val() == "") { |
||
| 50 | return false; |
||
| 51 | } |
||
| 52 | $("#div_loading").show(); |
||
| 53 | //send query |
||
| 54 | $.post( |
||
| 55 | "sources/categories.queries.php", |
||
| 56 | { |
||
| 57 | type : "addNewCategory", |
||
| 58 | title : sanitizeString($("#new_category_label").val()) |
||
| 59 | }, |
||
| 60 | function(data) { |
||
| 61 | // build new row |
||
| 62 | $("#tbl_categories").append( |
||
| 63 | '<tr id="t_cat_'+data[0].id+'"><td colspan="2">'+ |
||
| 64 | '<input type="text" id="catOrd_'+data[0].id+'" size="1" class="category_order" value="1" /> '+ |
||
| 65 | '<span class="fa-stack tip" title="<?php echo $LANG['field_add_in_category'];?>" onclick="fieldAdd('+ |
||
| 66 | data[0].id+')" style="cursor:pointer;">'+ |
||
| 67 | '<i class="fa fa-square fa-stack-2x"></i><i class="fa fa-plus fa-stack-1x fa-inverse"></i>'+ |
||
| 68 | '</span> '+ |
||
| 69 | '<input type="radio" name="sel_item" id="item_'+data[0].id+'_cat" />'+ |
||
| 70 | '<label for="item_'+data[0].id+'_cat" id="item_'+data[0].id+'">'+ |
||
| 71 | $("#new_category_label").val()+'</label>'+ |
||
| 72 | '</td><td>'+ |
||
| 73 | '<span class="fa-stack tip" title="<?php echo $LANG['category_in_folders'];?>" onclick="catInFolders('+data[0].id+')" style="cursor:pointer;">'+ |
||
| 74 | '<i class="fa fa-square fa-stack-2x"></i><i class="fa fa-edit fa-stack-1x fa-inverse"></i>'+ |
||
| 75 | '</span> '+ |
||
| 76 | '<?php echo $LANG['category_in_folders_title'];?>:'+ |
||
| 77 | '<span style="font-family:italic; margin-left:10px;" id="catFolders_'+data[0].id+'"></span>'+ |
||
| 78 | '<input type="hidden" id="catFoldersList_'+data[0].id+'" value="'+data[0].id+'" /></td><td></td>'); |
||
| 79 | // Add new cat |
||
| 80 | $("#moveItemTo").append('<option value="'+data[0].id+'">'+$("#new_category_label").val()+'</option>'); |
||
| 81 | // clean |
||
| 82 | $("#new_category_label, #new_item_title").val(""); |
||
| 83 | //loadFieldsList(); |
||
| 84 | $("#div_loading,#no_category").hide(); |
||
| 85 | }, |
||
| 86 | "json" |
||
| 87 | ); |
||
| 88 | } |
||
| 89 | |||
| 90 | /* |
||
| 91 | * rename an Element |
||
| 92 | */ |
||
| 93 | function renameItem() { |
||
| 94 | var data = $("input[name=sel_item]:checked").attr("id").split('_'); |
||
| 95 | $("#post_id").val(data[1]); |
||
| 96 | $("#post_type").val("renameItem"); |
||
| 97 | $("#category_confirm_text").html("<?php echo $LANG['confirm_rename'];?>"); |
||
| 98 | $("#category_confirm").dialog("open"); |
||
| 99 | } |
||
| 100 | |||
| 101 | /* |
||
| 102 | * Delete an Element |
||
| 103 | */ |
||
| 104 | function deleteItem() { |
||
| 105 | var data = $("input[name=sel_item]:checked").attr("id").split('_'); |
||
| 106 | $("#post_id").val(data[1]); |
||
| 107 | $("#post_type").val("deleteCategory"); |
||
| 108 | $("#category_confirm_text").html("<?php echo $LANG['confirm_deletion'];?>"); |
||
| 109 | $("#category_confirm").dialog("open"); |
||
| 110 | } |
||
| 111 | |||
| 112 | /* |
||
| 113 | * Move an Element |
||
| 114 | */ |
||
| 115 | function moveItem() { |
||
| 116 | var data = $("input[name=sel_item]:checked").attr("id").split('_'); |
||
| 117 | $("#post_id").val(data[1]); |
||
| 118 | $("#post_type").val("moveItem"); |
||
| 119 | $("#category_confirm_text").html("<?php echo $LANG['confirm_moveto'];?>"); |
||
| 120 | $("#category_confirm").dialog("open"); |
||
| 121 | } |
||
| 122 | |||
| 123 | /* |
||
| 124 | * Save the position of the Categories |
||
| 125 | */ |
||
| 126 | function storePosition() { |
||
| 127 | $("#div_loading").show(); |
||
| 128 | // prepare listing to save |
||
| 129 | var data = ""; |
||
| 130 | var id; |
||
| 131 | var val; |
||
| 132 | $('input[class$="category_order"]').each(function(index) { |
||
| 133 | id = $(this).attr("id").split("_"); |
||
| 134 | if ($(this).val() == "") { |
||
| 135 | val = "1"; |
||
| 136 | } else { |
||
| 137 | val = $(this).val(); |
||
| 138 | } |
||
| 139 | if (data == "") { |
||
| 140 | data = id[1]+":"+val; |
||
| 141 | } else { |
||
| 142 | data += ";"+id[1]+":"+val; |
||
| 143 | } |
||
| 144 | }); |
||
| 145 | |||
| 146 | //send query |
||
| 147 | $.post( |
||
| 148 | "sources/categories.queries.php", |
||
| 149 | { |
||
| 150 | type : "saveOrder", |
||
| 151 | data : data |
||
| 152 | }, |
||
| 153 | function(data) { |
||
| 154 | $("#div_loading").hide(); |
||
| 155 | }, |
||
| 156 | "json" |
||
| 157 | ); |
||
| 158 | } |
||
| 159 | |||
| 160 | /* |
||
| 161 | * Reload table |
||
| 162 | */ |
||
| 163 | function loadFieldsList() { |
||
| 164 | $("#div_loading").show(); |
||
| 165 | //send query |
||
| 166 | $.post( |
||
| 167 | "sources/categories.queries.php", |
||
| 168 | { |
||
| 169 | type : "loadFieldsList", |
||
| 170 | title : prepareExchangedData(sanitizeString($("#new_category_label").val()), "encode", "<?php echo $_SESSION['key'];?>") |
||
| 171 | }, |
||
| 172 | function(data) { |
||
| 173 | var newList = '<table id="tbl_categories" style="">'; |
||
| 174 | // parse json table and disaply |
||
| 175 | var json = $.parseJSON(data); |
||
| 176 | $(json).each(function(i,val){ |
||
| 177 | if (val[0] === "1") { |
||
| 178 | newList += '<tr id="t_cat_'+val[1]+'"><td colspan="2">'+ |
||
| 179 | '<input type="text" id="catOrd_'+val[1]+'" size="1" class="category_order" value="'+val[3]+'" /> '+ |
||
| 180 | '<span class="fa-stack tip" title="<?php echo $LANG['field_add_in_category'];?>" onclick="fieldAdd('+ |
||
| 181 | val[1]+')" style="cursor:pointer;">'+ |
||
| 182 | '<i class="fa fa-square fa-stack-2x"></i><i class="fa fa-plus fa-stack-1x fa-inverse"></i>'+ |
||
| 183 | '</span> '+ |
||
| 184 | '<input type="radio" name="sel_item" id="item_'+val[1]+'_cat" />'+ |
||
| 185 | '<label for="item_'+val[1]+'_cat" id="item_'+val[1]+'">'+val[2]+'</label>'+ |
||
| 186 | '</td><td>'+ |
||
| 187 | '<span class="fa-stack tip" title="<?php echo $LANG['category_in_folders'];?>" onclick="catInFolders('+val[1]+')" style="cursor:pointer;">'+ |
||
| 188 | '<i class="fa fa-square fa-stack-2x"></i><i class="fa fa-edit fa-stack-1x fa-inverse"></i>'+ |
||
| 189 | '</span> '+ |
||
| 190 | '<?php echo $LANG['category_in_folders_title'];?>:'+ |
||
| 191 | '<span style="font-family:italic; margin-left:10px;" id="catFolders_'+val[1]+'">'+val[4]+'</span>'+ |
||
| 192 | '<input type="hidden" id="catFoldersList_'+val[1]+'" value="'+val[5]+'" /></td></tr>'; |
||
| 193 | } else { |
||
| 194 | newList += '<tr id="t_field_'+val[1]+'"><td width="20px"></td>'+ |
||
| 195 | '<td><input type="text" id="catOrd_'+val[1]+'" size="1" class="category_order" value="'+val[3]+'" /> '+ |
||
| 196 | '<input type="radio" name="sel_item" id="item_'+val[1]+'_cat" />'+ |
||
| 197 | '<label for="item_'+val[1]+'_cat" id="item_'+val[1]+'">'+val[2]+'</label>'; |
||
| 198 | |||
| 199 | if (val[4] !== "") { |
||
| 200 | newList += '<span id="encryt_data_'+val[1]+'" style="margin-left:4px; cursor:pointer;">'; |
||
| 201 | if (val[4] === "1") { |
||
| 202 | newList += '<i class="fa fa-key tip" title="<?php echo $LANG['encrypted_data'];?>" onclick="changeEncrypMode('+val[1]+', 1)"></i>'; |
||
| 203 | } else if (val[4] === "0") { |
||
| 204 | newList += '<span class="fa-stack" title="<?php echo $LANG['not_encrypted_data'];?>" onclick="changeEncrypMode('+val[1]+', 0)"><i class="fa fa-key fa-stack-1x"></i><i class="fa fa-ban fa-stack-1x fa-lg" style="color:red;"></i></span>'; |
||
| 205 | } |
||
| 206 | newList += '</span>' |
||
| 207 | } |
||
| 208 | |||
| 209 | newList += '</td><td></td></tr>'; |
||
| 210 | } |
||
| 211 | }); |
||
| 212 | |||
| 213 | // display |
||
| 214 | newList += '</table>'; |
||
| 215 | $("#new_item_title").val(""); |
||
| 216 | $("#categories_list").html(newList); |
||
| 217 | $("#div_loading").hide(); |
||
| 218 | } |
||
| 219 | ); |
||
| 220 | } |
||
| 221 | |||
| 222 | //########### |
||
| 223 | //## FUNCTION : Launch the action the admin wants |
||
| 224 | //########### |
||
| 225 | function LaunchAdminActions(action, option) |
||
| 226 | { |
||
| 227 | var option; |
||
| 228 | |||
| 229 | $("#div_loading").show(); |
||
| 230 | $("#email_testing_results, #result_admin_script_backup").hide(); |
||
| 231 | $("#result_admin_action_db_backup").html(""); |
||
| 232 | if (action === "admin_action_db_backup") option = $("#result_admin_action_db_backup_key").val(); |
||
| 233 | else if (action === "admin_action_backup_decrypt") option = $("#bck_script_decrypt_file").val(); |
||
| 234 | else if (action === "admin_action_change_salt_key") { |
||
| 235 | option = aes_encrypt(sanitizeString($("#new_salt_key").val())); |
||
| 236 | } else if (action === "admin_email_send_backlog") { |
||
| 237 | $("#email_testing_results").show().html("<?php echo addslashes($LANG['please_wait']);?>").attr("class","ui-corner-all ui-state-focus"); |
||
| 238 | } else if (action === "admin_action_attachments_cryption") { |
||
| 239 | option = $("input[name=attachments_cryption]:checked").val(); |
||
| 240 | if (option === "" || option === undefined) { |
||
| 241 | $("#div_loading").hide(); |
||
| 242 | return false; |
||
| 243 | } |
||
| 244 | } else if (action === "admin_ldap_test_configuration") { |
||
| 245 | option = []; |
||
| 246 | var item = {}; |
||
| 247 | |||
| 248 | // adding the user |
||
| 249 | item['username'] = $("#ldap_test_username").val(); |
||
| 250 | item['username_pwd'] = $("#ldap_test_pwd").val(); |
||
| 251 | item['no_username_needed'] = $("#ldap_test_no_username").is(':checked') ? "1" : "0"; |
||
| 252 | |||
| 253 | // adding ldap params |
||
| 254 | $("#ldap_config_values tr").each(function(k){ |
||
| 255 | $(this).find("input, select").each(function(i){ |
||
| 256 | item[$(this).attr('id')] = $(this).val(); |
||
| 257 | }); |
||
| 258 | }); |
||
| 259 | option.push(item); |
||
| 260 | |||
| 261 | if (option === "" || option.length === 0) return; |
||
| 262 | |||
| 263 | // convert to json string |
||
| 264 | option = prepareExchangedData(JSON.stringify(option) , "encode", "<?php echo $_SESSION['key'];?>"); |
||
| 265 | } |
||
| 266 | //Lauchn ajax query |
||
| 267 | $.post( |
||
| 268 | "sources/admin.queries.php", |
||
| 269 | { |
||
| 270 | type : action, |
||
| 271 | option : option |
||
| 272 | }, |
||
| 273 | function(data) { |
||
| 274 | $("#div_loading").hide(); |
||
| 275 | if (data != null) { |
||
| 276 | if (data[0].result == "db_backup") { |
||
| 277 | $("#result_admin_action_db_backup").html("<span class='fa fa-file-code-o'></span> <a href='"+data[0].href+"'><?php echo $LANG['pdf_download'];?></a>").show(); |
||
| 278 | } else if (data[0].result == "pf_done") { |
||
| 279 | $("#result_admin_action_check_pf").html("<span class='fa fa-check mi-green'></span>").show(); |
||
| 280 | } else if (data[0].result == "db_restore") { |
||
| 281 | $("#restore_bck_encryption_key_dialog").dialog("close"); |
||
| 282 | $("#result_admin_action_db_restore").html("<span class='fa fa-check mi-green'></span>").show(); |
||
| 283 | $("#result_admin_action_db_restore_get_file").hide(); |
||
| 284 | //deconnect userd |
||
| 285 | sessionStorage.clear(); |
||
| 286 | window.location.href = "logout.php" |
||
| 287 | } else if (data[0].result == "cache_reload") { |
||
| 288 | $("#result_admin_action_reload_cache_table").html("<span class='fa fa-check mi-green'></span>").show(); |
||
| 289 | } else if (data[0].result == "db_optimize") { |
||
| 290 | $("#result_admin_action_db_optimize").html("<span class='fa fa-check mi-green'></span>").show(); |
||
| 291 | } else if (data[0].result == "purge_old_files") { |
||
| 292 | $("#result_admin_action_purge_old_files").html("<span class='fa fa-check mi-green'></span> "+data[0].nb_files_deleted+" <? echo $LANG['admin_action_purge_old_files_result'];?>").show(); |
||
|
0 ignored issues
–
show
|
|||
| 293 | } else if (data[0].result == "db_clean_items") { |
||
| 294 | $("#result_admin_action_db_clean_items").html("<span class='fa fa-check mi-green'></span> "+data[0].nb_items_deleted+" <?php echo $LANG['admin_action_db_clean_items_result'];?>").show(); |
||
| 295 | } else if (data[0].result == "changed_salt_key") { |
||
| 296 | //deconnect user |
||
| 297 | $("#menu_action").val("deconnexion"); |
||
| 298 | sessionStorage.clear(); |
||
| 299 | window.location.href = "logout.php" |
||
| 300 | } else if (data[0].result == "email_test_conf" || data[0].result == "admin_email_send_backlog") { |
||
| 301 | if (data[0].error != "") { |
||
| 302 | $("#email_testing_results").html("<?php echo addslashes($LANG['admin_email_result_nok']);?> "+data[0].message).show().attr("class","ui-state-error ui-corner-all"); |
||
| 303 | } else { |
||
| 304 | $("#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"); |
||
| 305 | } |
||
| 306 | } else if (data[0].result == "pw_prefix_correct") { |
||
| 307 | $("result_admin_action_pw_prefix_correct").html(data[0].ret).show(); |
||
| 308 | } else if (data[0].result == "attachments_cryption") { |
||
| 309 | if (data[0].continu == true) { |
||
| 310 | $("#result_admin_action_attachments_cryption").html('').show(); |
||
| 311 | manageEncryptionOfAttachments(data[0].list, data[0].cpt); |
||
| 312 | } else if (data[0].error == "file_not_encrypted") { |
||
| 313 | $("#result_admin_action_attachments_cryption").html("It seems the files are not encrypted. Are you sure you want to decrypt? please do a check.").show(); |
||
| 314 | } else if (data[0].error == "file_not_clear") { |
||
| 315 | $("#result_admin_action_attachments_cryption").html("It seems the files are encrypted. Are you sure you want to encrypt? please do a check.").show(); |
||
| 316 | } |
||
| 317 | } else if (data[0].result == "rebuild_config_file") { |
||
| 318 | $("#result_admin_rebuild_config_file").html("<span class='fa fa-check mi-green'></span>").show(); |
||
| 319 | } else if (data[0].option === "admin_ldap_test_configuration") { |
||
| 320 | if (data[0].error !== "" && data[0].results === undefined) { |
||
| 321 | $("#ldap_test_msg").html(data[0].error).show(1).delay(2000).fadeOut(500); |
||
| 322 | } else { |
||
| 323 | $("#ldap_test_msg").html(data[0].results).show(); |
||
| 324 | } |
||
| 325 | // for BCK DECRYPT |
||
| 326 | } else if (data[0].result === "backup_decrypt_fails") { |
||
| 327 | $("#result_admin_script_backup").html(data[0].msg).show(); |
||
| 328 | } else if (data[0].result === "backup_decrypt_success") { |
||
| 329 | $("#result_admin_script_backup").html("<span class='fa fa-check mi-green'></span> <?php echo addslashes($LANG['file_is_now_ready']);?> - " + data[0].msg).show(1).delay(5000).fadeOut(500); |
||
| 330 | } |
||
| 331 | //-- |
||
| 332 | } |
||
| 333 | }, |
||
| 334 | "json" |
||
| 335 | ); |
||
| 336 | } |
||
| 337 | |||
| 338 | /* |
||
| 339 | * |
||
| 340 | */ |
||
| 341 | function confirmChangingSk() { |
||
| 342 | if (confirm("<?php echo addslashes($LANG['confirm_database_reencryption']);?>")) { |
||
| 343 | changeMainSaltKey('starting', ''); |
||
| 344 | } |
||
| 345 | } |
||
| 346 | |||
| 347 | /* |
||
| 348 | * |
||
| 349 | */ |
||
| 350 | function changeMainSaltKey(start, object) |
||
| 351 | { |
||
| 352 | if (object === "files") { |
||
| 353 | var nb = 5; |
||
| 354 | } else { |
||
| 355 | var nb = 10; // can be changed - number of items treated in each loop |
||
| 356 | } |
||
| 357 | |||
| 358 | //console.log("Start value: "+start); |
||
| 359 | |||
| 360 | // start change |
||
| 361 | if (start === "starting") { |
||
| 362 | // inform |
||
| 363 | $("#changeMainSaltKey_message").html("<i class=\"fa fa-cog fa-spin fa\"></i> <?php echo $LANG['starting'];?>").show(); |
||
| 364 | |||
| 365 | // launch query |
||
| 366 | $.post( |
||
| 367 | "sources/admin.queries.php", |
||
| 368 | { |
||
| 369 | type : "admin_action_change_salt_key___start", |
||
| 370 | key : "<?php echo $_SESSION['key'];?>" |
||
| 371 | }, |
||
| 372 | function(data) { |
||
| 373 | if (data[0].error == "" && data[0].nextAction == "encrypt_items") { |
||
| 374 | $("#changeMainSaltKey_itemsCount").append('<input type="hidden" id="changeMainSaltKey_itemsCountTotal" />'); |
||
| 375 | $("#changeMainSaltKey_itemsCount, #changeMainSaltKey_itemsCountTotal").val(data[0].nbOfItems); |
||
| 376 | //console.log("Now launch encryption"); |
||
| 377 | // start encrypting items with new saltkey |
||
| 378 | changeMainSaltKey(0, "items,logs,files,categories"); |
||
| 379 | //changeMainSaltKey(0, "files"); |
||
| 380 | } else { |
||
| 381 | // error mngt |
||
| 382 | $("#changeMainSaltKey_message").html("<i class=\"fa fa-alert fa-spin fa\"></i> <?php echo $LANG['error_sent_back'];?> : "+data[0].error); |
||
| 383 | } |
||
| 384 | }, |
||
| 385 | "json" |
||
| 386 | ); |
||
| 387 | |||
| 388 | } else if (isFinite(start) && object !== "") { |
||
| 389 | console.log("Step Encrypt - " +start+" ; "+nb+" ; "+$("#changeMainSaltKey_itemsCount").val()); |
||
| 390 | |||
| 391 | $("#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()+")"); |
||
| 392 | |||
| 393 | $.post( |
||
| 394 | "sources/admin.queries.php", |
||
| 395 | { |
||
| 396 | type : "admin_action_change_salt_key___encrypt", |
||
| 397 | object : object, |
||
| 398 | start : start, |
||
| 399 | length : nb, |
||
| 400 | nbItems : $("#changeMainSaltKey_itemsCount").val(), |
||
| 401 | key : "<?php echo $_SESSION['key'];?>" |
||
| 402 | }, |
||
| 403 | function(data) { |
||
| 404 | console.log("Next action: "+data[0].nextAction); |
||
| 405 | if (data[0].nextAction !== "encrypting" && data[0].nextAction !== "" && data[0].nextAction !== "finishing") { |
||
| 406 | if (data[0].nbOfItems !== "") { |
||
| 407 | // it is now a new table to be re-encrypted |
||
| 408 | $("#changeMainSaltKey_itemsCount").val(data[0].nbOfItems); |
||
| 409 | $("#changeMainSaltKey_itemsCountTotal").val(parseInt(data[0].nbOfItems) + parseInt($("#changeMainSaltKey_itemsCountTotal").val())); |
||
| 410 | data[0].nextStart = 0; |
||
| 411 | object = data[0].nextAction; |
||
| 412 | } |
||
| 413 | changeMainSaltKey(data[0].nextStart, object); |
||
| 414 | } else if (data[0].nextAction === "finishing") { |
||
| 415 | $("#changeMainSaltKey_message").html("<?php echo $LANG['finalizing'];?>..."); |
||
| 416 | changeMainSaltKey("finishing"); |
||
| 417 | } else { |
||
| 418 | // error mngt |
||
| 419 | $("#changeMainSaltKey_message").html("<i class=\"fa fa-alert fa-spin fa\"></i> <?php echo $LANG['error_sent_back'];?> : "+data[0].error); |
||
| 420 | } |
||
| 421 | }, |
||
| 422 | "json" |
||
| 423 | ); |
||
| 424 | |||
| 425 | } else { |
||
| 426 | $.post( |
||
| 427 | "sources/admin.queries.php", |
||
| 428 | { |
||
| 429 | type : "admin_action_change_salt_key___end", |
||
| 430 | key : "<?php echo $_SESSION['key'];?>" |
||
| 431 | }, |
||
| 432 | function(data) { |
||
| 433 | if (data[0].nextAction === "done") { |
||
| 434 | console.log("done"); |
||
| 435 | $("#changeMainSaltKey_message").html("<i class=\"fa fa-info fa-lg\"></i> <?php echo $LANG['alert_message_done']." ".$LANG['number_of_items_treated'];?> : " + $("#changeMainSaltKey_itemsCountTotal").val() + '<p><?php echo $LANG['check_data_after_reencryption'];?><p><div style=\"margin-top:5px;\"><a href=\"#\" onclick=\"encryption_show_revert()\"><?php echo $LANG['revert'];?></a></div>'); |
||
| 436 | } else { |
||
| 437 | // error mngt |
||
| 438 | } |
||
| 439 | $("#changeMainSaltKey_itemsCountTotal").remove(); |
||
| 440 | }, |
||
| 441 | "json" |
||
| 442 | ); |
||
| 443 | } |
||
| 444 | } |
||
| 445 | |||
| 446 | function encryption_show_revert() { |
||
| 447 | if (confirm('<?php echo $LANG['revert_the_database'];?>')) { |
||
| 448 | $("#changeMainSaltKey_message").append('<div style="margin-top:5px;"><i class="fa fa-cog fa-spin fa-lg"></i> <?php echo addslashes($LANG['please_wait']);?>...</div>') |
||
| 449 | $.post( |
||
| 450 | "sources/admin.queries.php", |
||
| 451 | { |
||
| 452 | type : "admin_action_change_salt_key___restore_backup", |
||
| 453 | key : "<?php echo $_SESSION['key'];?>" |
||
| 454 | }, |
||
| 455 | function(data) { |
||
| 456 | $("#changeMainSaltKey_message").html('').hide(); |
||
| 457 | }, |
||
| 458 | "json" |
||
| 459 | ); |
||
| 460 | } |
||
| 461 | } |
||
| 462 | |||
| 463 | /* |
||
| 464 | * FUNCTION permitting to store into DB the settings changes |
||
| 465 | */ |
||
| 466 | function updateSetting(field) |
||
| 467 | { |
||
| 468 | if (field == "") return false; |
||
| 469 | |||
| 470 | // store in DB |
||
| 471 | var data = '{"field":"'+field+'", "value":"'+$("#"+field).val()+'"}'; |
||
| 472 | //console.log(data); |
||
| 473 | $.post( |
||
| 474 | "sources/admin.queries.php", |
||
| 475 | { |
||
| 476 | type : "save_option_change", |
||
| 477 | data : prepareExchangedData(data, "encode", "<?php echo $_SESSION['key'];?>"), |
||
| 478 | key : "<?php echo $_SESSION['key'];?>" |
||
| 479 | }, |
||
| 480 | function(data) { |
||
| 481 | // force page reload in case of encryptClientServer |
||
| 482 | if (field == "encryptClientServer") { |
||
| 483 | location.reload(true); |
||
| 484 | return false; |
||
| 485 | } |
||
| 486 | //decrypt data |
||
| 487 | try { |
||
| 488 | data = prepareExchangedData(data , "decode", "<?php echo $_SESSION['key'];?>"); |
||
| 489 | } catch (e) { |
||
| 490 | // error |
||
| 491 | $("#message_box").html("An error appears. Answer from Server cannot be parsed!<br />Returned data:<br />"+data).show().fadeOut(4000); |
||
| 492 | |||
| 493 | return; |
||
| 494 | } |
||
| 495 | console.log(data); |
||
| 496 | if (data.error == "") { |
||
| 497 | $("#"+field).after("<span class='fa fa-check fa-lg mi-green new_check'></span>"); |
||
| 498 | $(".new_check").fadeOut(2000); |
||
| 499 | setTimeout('$(".new_check").remove()', 2100); |
||
| 500 | } |
||
| 501 | } |
||
| 502 | ); |
||
| 503 | } |
||
| 504 | |||
| 505 | /* |
||
| 506 | * show/hide ldap options |
||
| 507 | */ |
||
| 508 | function showLdapFields(ldap_type) { |
||
| 509 | $(".tr-ldap").hide(); |
||
| 510 | $(".tr-" + ldap_type).show(); |
||
| 511 | } |
||
| 512 | |||
| 513 | /* |
||
| 514 | * show/hide file Dec/Enc cryption options |
||
| 515 | */ |
||
| 516 | function startFileEncDecyption() { |
||
| 517 | $("#admin_action_attachments_cryption_selection").show(); |
||
| 518 | // |
||
| 519 | } |
||
| 520 | |||
| 521 | // Init |
||
| 522 | $(function() { |
||
| 523 | $('.toggle').toggles({ |
||
| 524 | drag: true, // allow dragging the toggle between positions |
||
| 525 | click: true, // allow clicking on the toggle |
||
| 526 | text: { |
||
| 527 | on: '<?php echo $LANG['yes'];?>', // text for the ON position |
||
| 528 | off: '<?php echo $LANG['no'];?>' // and off |
||
| 529 | }, |
||
| 530 | on: true, // is the toggle ON on init |
||
| 531 | animate: 250, // animation time (ms) |
||
| 532 | easing: 'swing', // animation transition easing function |
||
| 533 | width: 50, // width used if not set in css |
||
| 534 | height: 20, // height if not set in css |
||
| 535 | type: 'compact' // if this is set to 'select' then the select style toggle will be used |
||
| 536 | }); |
||
| 537 | $('.toggle').on('toggle', function(e, active) { |
||
| 538 | if (active) { |
||
| 539 | $("#"+e.target.id+"_input").val(1); |
||
| 540 | if (e.target.id == "ldap_mode") {$("#div_ldap_configuration").show();} |
||
| 541 | } else { |
||
| 542 | $("#"+e.target.id+"_input").val(0); |
||
| 543 | if (e.target.id == "ldap_mode") {$("#div_ldap_configuration").hide();} |
||
| 544 | } |
||
| 545 | |||
| 546 | // store in DB |
||
| 547 | var data = '{"field":"'+e.target.id+'", "value":"'+$("#"+e.target.id+"_input").val()+'"}'; |
||
| 548 | console.log(data); |
||
| 549 | $.post( |
||
| 550 | "sources/admin.queries.php", |
||
| 551 | { |
||
| 552 | type : "save_option_change", |
||
| 553 | data : prepareExchangedData(data, "encode", "<?php echo $_SESSION['key'];?>"), |
||
| 554 | key : "<?php echo $_SESSION['key'];?>" |
||
| 555 | }, |
||
| 556 | function(data) { |
||
| 557 | // force page reload in case of encryptClientServer |
||
| 558 | if (e.target.id == "encryptClientServer") { |
||
| 559 | location.reload(true); |
||
| 560 | return false; |
||
| 561 | } |
||
| 562 | //decrypt data |
||
| 563 | try { |
||
| 564 | data = prepareExchangedData(data , "decode", "<?php echo $_SESSION['key'];?>"); |
||
| 565 | } catch (e) { |
||
| 566 | // error |
||
| 567 | $("#message_box").html("An error appears. Answer from Server cannot be parsed!<br />Returned data:<br />"+data).show().fadeOut(4000); |
||
| 568 | |||
| 569 | return; |
||
| 570 | } |
||
| 571 | console.log(data); |
||
| 572 | if (data.error == "") { |
||
| 573 | $("#"+e.target.id).after("<span class='fa fa-check fa-lg mi-green new_check' style='float:left;margin:-18px 0 0 56px;'></span>"); |
||
| 574 | $(".new_check").fadeOut(2000); |
||
| 575 | setTimeout('$(".new_check").remove()', 2100); |
||
| 576 | } |
||
| 577 | } |
||
| 578 | ); |
||
| 579 | }); |
||
| 580 | |||
| 581 | // spinner |
||
| 582 | $("#upload_imageresize_quality").spinner({ |
||
| 583 | min: 0, |
||
| 584 | max: 100, |
||
| 585 | value: 90, |
||
| 586 | spin: function(event, ui) { |
||
| 587 | updateSetting($("#upload_imageresize_quality").attr('id')); |
||
| 588 | } |
||
| 589 | }); |
||
| 590 | |||
| 591 | //BUILD BUTTONSET |
||
| 592 | $(".div_radio").buttonset(); |
||
| 593 | |||
| 594 | // Build Tabs |
||
| 595 | $("#tabs").tabs({ |
||
| 596 | ajaxOptions: { |
||
| 597 | error: function(xhr, status, index, anchor) { |
||
| 598 | $(anchor.hash).html(); |
||
| 599 | }, |
||
| 600 | beforeSend: function() { |
||
| 601 | $("#div_loading").show(); |
||
| 602 | }, |
||
| 603 | complete: function() { |
||
| 604 | $("#div_loading").hide(); |
||
| 605 | } |
||
| 606 | }, |
||
| 607 | beforeLoad: function( event, ui ) { |
||
| 608 | ui.panel.html('<div id="loader_tab"><i class="fa fa-cog fa-spin"></i> <?php echo $LANG['loading'];?>...</div>') |
||
| 609 | }, |
||
| 610 | load: function( event, ui ) { |
||
| 611 | $("#loader_tab").remove(); |
||
| 612 | } |
||
| 613 | }); |
||
| 614 | |||
| 615 | $('#tabs').click(function(e){ |
||
| 616 | var current_index = $("#tabs").tabs("option","active"); |
||
| 617 | if (current_index == 9 || current_index == 10) { |
||
| 618 | $("#save_button").hide(); |
||
| 619 | } else { |
||
| 620 | $("#save_button").show(); |
||
| 621 | } |
||
| 622 | }); |
||
| 623 | |||
| 624 | $('#tbl_categories tr').click(function (event) { |
||
| 625 | $("#selected_row").val($(this).attr("id")); |
||
| 626 | }); |
||
| 627 | |||
| 628 | // display text of selected item |
||
| 629 | $(document).on("click","input[name=sel_item]",function(){ |
||
| 630 | var data = $("input[name=sel_item]:checked").attr("id").split('_'); |
||
| 631 | $("#new_item_title").val($("#item_"+data[1]).html()); |
||
| 632 | }); |
||
| 633 | |||
| 634 | // confirm dialogbox |
||
| 635 | $("#category_confirm").dialog({ |
||
| 636 | bgiframe: true, |
||
| 637 | modal: true, |
||
| 638 | autoOpen: false, |
||
| 639 | width: 400, |
||
| 640 | height: 120, |
||
| 641 | title: "<?php echo $LANG['confirm'];?>", |
||
| 642 | buttons: { |
||
| 643 | "<?php echo $LANG['confirm'];?>": function() { |
||
| 644 | $("#div_loading").show(); |
||
| 645 | var $this = $(this); |
||
| 646 | // prepare data to send |
||
| 647 | var data = ""; |
||
| 648 | if ($("#post_type").val() == "renameItem") { |
||
| 649 | data = sanitizeString($("#new_item_title").val()); |
||
| 650 | } else if ($("#post_type").val() == "moveItem") { |
||
| 651 | data = $("#moveItemTo").val(); |
||
| 652 | } |
||
| 653 | // send query |
||
| 654 | $.post( |
||
| 655 | "sources/categories.queries.php", |
||
| 656 | { |
||
| 657 | type : $("#post_type").val(), |
||
| 658 | id : $("#post_id").val(), |
||
| 659 | data : data |
||
| 660 | }, |
||
| 661 | function(data) { |
||
| 662 | if ($("#post_type").val() == "deleteCategory") { |
||
| 663 | $("#t_field_"+$("#post_id").val()).hide(); |
||
| 664 | } else if ($("#post_type").val() == "renameItem") { |
||
| 665 | $("#item_"+$("#post_id").val()).html($("#new_item_title").val()); |
||
| 666 | } else if ($("#post_type").val() == "moveItem") { |
||
| 667 | // reload table |
||
| 668 | //loadFieldsList(); |
||
| 669 | } |
||
| 670 | loadFieldsList(); |
||
| 671 | $("#new_category_label, #new_item_title").val(""); |
||
| 672 | $("#div_loading").hide(); |
||
| 673 | $this.dialog("close"); |
||
| 674 | }, |
||
| 675 | "json" |
||
| 676 | ); |
||
| 677 | }, |
||
| 678 | "<?php echo $LANG['cancel_button'];?>": function() { |
||
| 679 | $("#div_loading").hide(); |
||
| 680 | $(this).dialog("close"); |
||
| 681 | } |
||
| 682 | } |
||
| 683 | }); |
||
| 684 | |||
| 685 | $("#add_new_field").dialog({ |
||
| 686 | bgiframe: true, |
||
| 687 | modal: true, |
||
| 688 | autoOpen: false, |
||
| 689 | width: 500, |
||
| 690 | height: 150, |
||
| 691 | title: "<?php echo $LANG['category_in_folders'];?>", |
||
| 692 | buttons: { |
||
| 693 | "<?php echo $LANG['confirm'];?>": function() { |
||
| 694 | if ($("#new_field_title").val() != "" && $("#post_id").val() != "") { |
||
| 695 | $("#div_loading").show(); |
||
| 696 | var $this = $(this); |
||
| 697 | //send query |
||
| 698 | $.post( |
||
| 699 | "sources/categories.queries.php", |
||
| 700 | { |
||
| 701 | type : "addNewField", |
||
| 702 | title : sanitizeString($("#new_field_title").val()), |
||
| 703 | id : $("#post_id").val() |
||
| 704 | }, |
||
| 705 | function(data) { |
||
| 706 | $("#new_field_title").val(""); |
||
| 707 | // reload table |
||
| 708 | loadFieldsList(); |
||
| 709 | $this.dialog("close"); |
||
| 710 | }, |
||
| 711 | "json" |
||
| 712 | ); |
||
| 713 | } |
||
| 714 | }, |
||
| 715 | "<?php echo $LANG['cancel_button'];?>": function() { |
||
| 716 | $("#div_loading").hide(); |
||
| 717 | $(this).dialog("close"); |
||
| 718 | } |
||
| 719 | } |
||
| 720 | }); |
||
| 721 | |||
| 722 | $("#cat_folders_selection").multiselect({ |
||
| 723 | selectedList: 7, |
||
| 724 | multiple:true, |
||
| 725 | checkAllText: "<?php echo $LANG['check_all_text'];?>", |
||
| 726 | uncheckAllText: "<?php echo $LANG['uncheck_all_text'];?>" |
||
| 727 | }); |
||
| 728 | |||
| 729 | $("#category_in_folder").dialog({ |
||
| 730 | bgiframe: true, |
||
| 731 | modal: true, |
||
| 732 | autoOpen: false, |
||
| 733 | width: 400, |
||
| 734 | height: 350, |
||
| 735 | title: "<?php echo $LANG['category_in_folders'];?>", |
||
| 736 | open: function() { |
||
| 737 | $("#cat_folders_selection").multiselect('refresh'); |
||
| 738 | }, |
||
| 739 | buttons: { |
||
| 740 | "<?php echo $LANG['confirm'];?>": function() { |
||
| 741 | // get list of selected folders |
||
| 742 | var ids = ""; |
||
| 743 | $("#cat_folders_selection :selected").each(function(i, selected) { |
||
| 744 | if (ids == "") ids = $(selected).val(); |
||
| 745 | else ids = ids + ";" + $(selected).val(); |
||
| 746 | }); |
||
| 747 | if (ids != "") { |
||
| 748 | $("#div_loading, #catInFolder_wait").show(); |
||
| 749 | var $this = $(this); |
||
| 750 | //send query |
||
| 751 | $.post( |
||
| 752 | "sources/categories.queries.php", |
||
| 753 | { |
||
| 754 | type : "categoryInFolders", |
||
| 755 | foldersIds : ids, |
||
| 756 | id : $("#post_id").val() |
||
| 757 | }, |
||
| 758 | function(data) { |
||
| 759 | $("#new_field_title").val(""); |
||
| 760 | // display new list |
||
| 761 | $("#catFolders_"+$("#post_id").val()).html(data[0].list); |
||
| 762 | // close |
||
| 763 | $("#div_loading, #catInFolder_wait").hide(); |
||
| 764 | $this.dialog("close"); |
||
| 765 | }, |
||
| 766 | "json" |
||
| 767 | ); |
||
| 768 | } |
||
| 769 | }, |
||
| 770 | "<?php echo $LANG['cancel_button'];?>": function() { |
||
| 771 | $("#div_loading").hide(); |
||
| 772 | $(this).dialog("close"); |
||
| 773 | } |
||
| 774 | } |
||
| 775 | }); |
||
| 776 | |||
| 777 | $("#restore_bck_encryption_key_dialog").dialog({ |
||
| 778 | bgiframe: true, |
||
| 779 | modal: true, |
||
| 780 | autoOpen: false, |
||
| 781 | width:250, |
||
| 782 | height:150, |
||
| 783 | title: "<?php echo $LANG['admin_action_db_restore_key'];?>", |
||
| 784 | buttons: { |
||
| 785 | "<?php echo $LANG['ok'];?>": function() { |
||
| 786 | LaunchAdminActions("admin_action_db_restore", $("#restore_bck_fileObj").val()+"&"+$("#restore_bck_encryption_key").val()); |
||
| 787 | }, |
||
| 788 | "<?php echo $LANG['cancel_button'];?>'": function() { |
||
| 789 | $(this).dialog("close"); |
||
| 790 | } |
||
| 791 | } |
||
| 792 | }); |
||
| 793 | |||
| 794 | // SQL IMPORT FOR RESTORING |
||
| 795 | var uploader_restoreDB = new plupload.Uploader({ |
||
| 796 | runtimes : "gears,html5,flash,silverlight,browserplus", |
||
| 797 | browse_button : "pickfiles_restoreDB", |
||
| 798 | container : "upload_container_restoreDB", |
||
| 799 | max_file_size : "10mb", |
||
| 800 | chunk_size : "1mb", |
||
| 801 | unique_names : true, |
||
| 802 | dragdrop : true, |
||
| 803 | multiple_queues : false, |
||
| 804 | multi_selection : false, |
||
| 805 | max_file_count : 1, |
||
| 806 | url : "sources/upload/upload.files.php", |
||
| 807 | flash_swf_url : "includes/libraries/Plupload/plupload.flash.swf", |
||
| 808 | silverlight_xap_url : "includes/libraries/Plupload/plupload.silverlight.xap", |
||
| 809 | filters : [ |
||
| 810 | {title : "SQL files", extensions : "sql"} |
||
| 811 | ], |
||
| 812 | init: { |
||
| 813 | FilesAdded: function(up, files) { |
||
| 814 | // generate and save token |
||
| 815 | $.post( |
||
| 816 | "sources/main.queries.php", |
||
| 817 | { |
||
| 818 | type : "save_token", |
||
| 819 | size : 25, |
||
| 820 | capital: true, |
||
| 821 | numeric: true, |
||
| 822 | ambiguous: true, |
||
| 823 | reason: "restore_db", |
||
| 824 | duration: 10 |
||
| 825 | }, |
||
| 826 | function(data) { |
||
| 827 | $("#user_token").val(data[0].token); |
||
| 828 | up.start(); |
||
| 829 | }, |
||
| 830 | "json" |
||
| 831 | ); |
||
| 832 | }, |
||
| 833 | BeforeUpload: function (up, file) { |
||
| 834 | $("#import_status_ajax_loader").show(); |
||
| 835 | up.settings.multipart_params = { |
||
| 836 | "PHPSESSID":"'.$_SESSION['user_id'].'", |
||
| 837 | "File":file.name, |
||
| 838 | "type_upload":"restore_db", |
||
| 839 | "user_token": $("#user_token").val() |
||
| 840 | }; |
||
| 841 | }, |
||
| 842 | UploadComplete: function(up, files) { |
||
| 843 | $.each(files, function(i, file) { |
||
| 844 | $("#restore_bck_fileObj").val(file.name); |
||
| 845 | $("#restore_bck_encryption_key_dialog").dialog("open"); |
||
| 846 | }); |
||
| 847 | } |
||
| 848 | } |
||
| 849 | }); |
||
| 850 | // Uploader options |
||
| 851 | uploader_restoreDB.bind("UploadProgress", function(up, file) { |
||
| 852 | $("#" + file.id + " b").html(file.percent + "%"); |
||
| 853 | }); |
||
| 854 | uploader_restoreDB.bind("Error", function(up, err) { |
||
| 855 | $("#filelist_restoreDB").html("<div class='ui-state-error ui-corner-all'>Error: " + err.code + |
||
| 856 | ", Message: " + err.message + |
||
| 857 | (err.file ? ", File: " + err.file.name : "") + |
||
| 858 | "</div>" |
||
| 859 | ); |
||
| 860 | up.refresh(); // Reposition Flash/Silverlight |
||
| 861 | }); |
||
| 862 | uploader_restoreDB.bind("+", function(up, file) { |
||
| 863 | $("#" + file.id + " b").html("100%"); |
||
| 864 | }); |
||
| 865 | // Load CSV click |
||
| 866 | $("#uploadfiles_restoreDB").click(function(e) { |
||
| 867 | uploader_restoreDB.start(); |
||
| 868 | e.preventDefault(); |
||
| 869 | }); |
||
| 870 | uploader_restoreDB.init(); |
||
| 871 | // -end |
||
| 872 | |||
| 873 | //Enable/disable option |
||
| 874 | $("#restricted_to").bind("click", function() { |
||
| 875 | if ($("#restricted_to_input").val()== 1) { |
||
| 876 | $("#tr_option_restricted_to_roles").show(); |
||
| 877 | } else { |
||
| 878 | $("#tr_option_restricted_to_roles").hide(); |
||
| 879 | $("#tr_option_restricted_to_roles_input").val("0"); |
||
| 880 | } |
||
| 881 | }); |
||
| 882 | $("#anyone_can_modify").bind("click", function() { |
||
| 883 | if ($("#anyone_can_modify_input").val()== 1) { |
||
| 884 | $("#tr_option_anyone_can_modify_bydefault").show(); |
||
| 885 | } else { |
||
| 886 | $("#tr_option_anyone_can_modify_bydefault").hide(); |
||
| 887 | $("#anyone_can_modify_bydefault_input").val("0"); |
||
| 888 | } |
||
| 889 | }); |
||
| 890 | |||
| 891 | //check NEW SALT KEY |
||
| 892 | $("#new_salt_key").keypress(function (e) { |
||
| 893 | var key = e.charCode || e.keyCode || 0; |
||
| 894 | if ($("#new_salt_key").val().length != 16) { |
||
| 895 | $("#change_salt_key_image").html('<i class="fa fa-cross mi-red"></i>'); |
||
| 896 | $("#change_salt_key_but").hide(); |
||
| 897 | } else { |
||
| 898 | $("#change_salt_key_image").html('<i class="fa fa-check mi-green"></i>'); |
||
| 899 | $("#change_salt_key_but").show(); |
||
| 900 | } |
||
| 901 | // allow backspace, tab, delete, arrows, letters, numbers and keypad numbers ONLY |
||
| 902 | return ( |
||
| 903 | key != 33 && key != 34 && key != 39 && key != 92 && key != 32 && key != 96 && (key < 165) |
||
| 904 | && $("#new_salt_key").val().length <= 32 |
||
| 905 | ); |
||
| 906 | }); |
||
| 907 | |||
| 908 | $("button").button(); |
||
| 909 | |||
| 910 | // check if backup table exists |
||
| 911 | $.post("sources/admin.queries.php", |
||
| 912 | { |
||
| 913 | type : "is_backup_table_existing", |
||
| 914 | key : "<?php echo $_SESSION['key'];?>" |
||
| 915 | }, |
||
| 916 | function(data) { |
||
| 917 | if (data === "1") { |
||
| 918 | $("#changeMainSaltKey_message").show().html('<?php echo addslashes($LANG['previous_backup_exists']);?> <b><a href="#" id="but_bck_restore"><?php echo $LANG['yes'];?></a></b><br /><?php echo $LANG['previous_backup_exists_delete'];?> <b><a href="#" id="but_bck_delete"><?php echo $LANG['yes'];?></a></b>'); |
||
| 919 | |||
| 920 | // Restore the backup |
||
| 921 | $("#but_bck_restore").click(function(e) { |
||
| 922 | encryption_show_revert(); |
||
| 923 | }); |
||
| 924 | |||
| 925 | // Delete the backup |
||
| 926 | $("#but_bck_delete").click(function(e) { |
||
| 927 | if (confirm("<?php echo $LANG['wipe_backup_data'];?>")) { |
||
| 928 | $("#changeMainSaltKey_message").append('<div style="margin-top:5px;"><i class="fa fa-cog fa-spin fa-lg"></i> <?php echo addslashes($LANG['please_wait']);?>...</div>') |
||
| 929 | $.post( |
||
| 930 | "sources/admin.queries.php", |
||
| 931 | { |
||
| 932 | type : "admin_action_change_salt_key___delete_backup", |
||
| 933 | key : "<?php echo $_SESSION['key'];?>" |
||
| 934 | }, |
||
| 935 | function(data) { |
||
| 936 | $("#changeMainSaltKey_message").html('').hide(); |
||
| 937 | }, |
||
| 938 | "json" |
||
| 939 | ); |
||
| 940 | } |
||
| 941 | }); |
||
| 942 | } |
||
| 943 | } |
||
| 944 | ); |
||
| 945 | |||
| 946 | |||
| 947 | }); |
||
| 948 | |||
| 949 | function manageEncryptionOfAttachments(list, cpt) { |
||
| 950 | $("#div_loading").show(); |
||
| 951 | $.post( |
||
| 952 | "sources/admin.queries.php", |
||
| 953 | { |
||
| 954 | type : "admin_action_attachments_cryption_continu", |
||
| 955 | option : $("input[name=attachments_cryption]:checked").val(), |
||
| 956 | cpt : cpt, |
||
| 957 | list : list |
||
| 958 | }, |
||
| 959 | function(data) { |
||
| 960 | if (data[0].continu === "1" ) { |
||
| 961 | manageEncryptionOfAttachments(data[0].list, data[0].cpt); |
||
| 962 | } else { |
||
| 963 | $("#result_admin_action_attachments_cryption").html("<span class='fa fa-check mi-green'></span> "+data[0].cpt+" files changed.").show(); |
||
| 964 | $('#attachments_cryption_radio1, #attachments_cryption_radio2').prop('checked', false); |
||
| 965 | $("#div_loading").hide(); |
||
| 966 | } |
||
| 967 | }, |
||
| 968 | "json" |
||
| 969 | ); |
||
| 970 | } |
||
| 971 | |||
| 972 | function refreshInput() |
||
| 973 | { |
||
| 974 | var ids = ""; |
||
| 975 | $.each($("#roles_allowed_to_print_select option:selected"), function(){ |
||
| 976 | if (ids == "") ids = $(this).val(); |
||
| 977 | else ids = ids + ";" + $(this).val(); |
||
| 978 | }); |
||
| 979 | $("#roles_allowed_to_print").val(ids); |
||
| 980 | updateSetting('roles_allowed_to_print'); |
||
| 981 | } |
||
| 982 | |||
| 983 | function changeEncrypMode(id, encrypted_data) { |
||
| 984 | // send to server |
||
| 985 | $("#div_loading").show(); |
||
| 986 | //send query |
||
| 987 | $.post( |
||
| 988 | "sources/categories.queries.php", |
||
| 989 | { |
||
| 990 | type : "dataIsEncryptedInDB", |
||
| 991 | id : id, |
||
| 992 | encrypt : encrypted_data === "1" ? "0" : "1" |
||
| 993 | }, |
||
| 994 | function(data) { |
||
| 995 | // show to user |
||
| 996 | if (data[0].error === ""){ |
||
| 997 | if (encrypted_data === "1") { |
||
| 998 | $("#encryt_data_"+id).html('<span class="fa-stack" title="<?php echo $LANG['not_encrypted_data'];?>" onclick="changeEncrypMode(\''+id+'\', \'0\')"><i class="fa fa-key fa-stack-1x"></i><i class="fa fa-ban fa-stack-1x fa-lg" style="color:red;"></i></span>'); |
||
| 999 | } else { |
||
| 1000 | $("#encryt_data_"+id).html('<i class="fa fa-key tip" title="<?php echo $LANG['encrypted_data'];?>" onclick="changeEncrypMode(\''+id+'\', \'1\')"></i>'); |
||
| 1001 | } |
||
| 1002 | } |
||
| 1003 | $("#div_loading").hide(); |
||
| 1004 | }, |
||
| 1005 | "json" |
||
| 1006 | ); |
||
| 1007 | } |
||
| 1008 | //]]> |
||
| 1009 | </script> |
Short opening tags are disabled in PHP’s default configuration. In such a case, all content of this file is output verbatim to the browser without being parsed, or executed.
As a precaution to avoid these problems better use the long opening tag
<?php.