gophish/static/js/dist/app/sending_profiles.min.js

1 line
7.1 KiB
JavaScript
Raw Normal View History

var profiles=[];function sendTestEmail(){var t=[];$.each($("#headersTable").DataTable().rows().data(),function(e,a){t.push({key:unescapeHtml(a[0]),value:unescapeHtml(a[1])})});var e={template:{},first_name:$("input[name=to_first_name]").val(),last_name:$("input[name=to_last_name]").val(),email:$("input[name=to_email]").val(),position:$("input[name=to_position]").val(),url:"",smtp:{from_address:$("#from").val(),host:$("#host").val(),username:$("#username").val(),password:$("#password").val(),ignore_cert_errors:$("#ignore_cert_errors").prop("checked"),headers:t}};btnHtml=$("#sendTestModalSubmit").html(),$("#sendTestModalSubmit").html('<i class="fa fa-spinner fa-spin"></i> Sending'),api.send_test_email(e).success(function(e){$("#sendTestEmailModal\\.flashes").empty().append('<div style="text-align:center" class="alert alert-success">\t <i class="fa fa-check-circle"></i> Email Sent!</div>'),$("#sendTestModalSubmit").html(btnHtml)}).error(function(e){$("#sendTestEmailModal\\.flashes").empty().append('<div style="text-align:center" class="alert alert-danger">\t <i class="fa fa-exclamation-circle"></i> '+e.responseJSON.message+"</div>"),$("#sendTestModalSubmit").html(btnHtml)})}function save(e){var t={headers:[]};$.each($("#headersTable").DataTable().rows().data(),function(e,a){t.headers.push({key:unescapeHtml(a[0]),value:unescapeHtml(a[1])})}),t.name=$("#name").val(),t.interface_type=$("#interface_type").val(),t.from_address=$("#from").val(),t.host=$("#host").val(),t.username=$("#username").val(),t.password=$("#password").val(),t.ignore_cert_errors=$("#ignore_cert_errors").prop("checked"),-1!=e?(t.id=profiles[e].id,api.SMTPId.put(t).success(function(e){successFlash("Profile edited successfully!"),load(),dismiss()}).error(function(e){modalError(e.responseJSON.message)})):api.SMTP.post(t).success(function(e){successFlash("Profile added successfully!"),load(),dismiss()}).error(function(e){modalError(e.responseJSON.message)})}function dismiss(){$("#modal\\.flashes").empty(),$("#name").val(""),$("#interface_type").val("SMTP"),$("#from").val(""),$("#host").val(""),$("#username").val(""),$("#password").val(""),$("#ignore_cert_errors").prop("checked",!0),$("#headersTable").dataTable().DataTable().clear().draw(),$("#modal").modal("hide")}var dismissSendTestEmailModal=function(){$("#sendTestEmailModal\\.flashes").empty(),$("#sendTestModalSubmit").html("<i class='fa fa-envelope'></i> Send")},deleteProfile=function(e){swal({title:"Are you sure?",text:"This will delete the sending profile. This can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete "+escapeHtml(profiles[e].name),confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(function(a,t){api.SMTPId.delete(profiles[e].id).success(function(e){a()}).error(function(e){t(e.responseJSON.message)})})}}).then(function(){swal("Sending Profile Deleted!","This sending profile has been deleted!","success"),$('button:contains("OK")').on("click",function(){location.reload()})})};function edit(e){headers=$("#headersTable").dataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]}),$("#modalSubmit").unbind("click").click(function(){save(e)});var a={};-1!=e&&(a=profiles[e],$("#name").val(a.name),$("#interface_type").val(a.interface_type),$("#from").val(a.from_address),$("#host").val(a.host),$("#username").val(a.username),$("#password").val(a.password),$("#ignore_cert_errors").prop("checked",a.ignore_cert_errors),$.each(a.headers,function(e,a){addCustomHeader(a.key,a.value)}))}function copy(e){$("#modalSubmit").unbind("click").click(function(){save(-1)});var a;a=profiles[e],$("#name").val("Copy of "+a.name),$("#interface_type").val(a.interface_type),$("#from").val(a.from_address),$("#host").val(a.host),$("#username").val(a.username),$("#password").val(a.password),$("#ignore_cert_errors").prop("checked",a.ignore_cert_errors)}function load(){$("#profileTable").hide(),$("#emptyMessage").hide(),$("#loading").show(),api.SMTP.get().success(function(e){profiles=e,$("#loading").hide(),0<profiles.len