PluginProbe
Patchstack – WordPress & Plugins Security / 2.1.23
Patchstack – WordPress & Plugins Security v2.1.23
2.3.7 trunk 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.17 2.1.18 2.1.19 2.1.2 2.1.20 2.1.21 2.1.22 2.1.23 2.1.24 2.1.25 2.1.3 2.1.4 2.1.5 2.1.6 All 49 releases
patchstack / assets / js / patchstack.js

patchstack.js in Patchstack – WordPress & Plugins Security 2.1.23, at assets/js/patchstack.js

186 lines 6.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Patchstack
3 * https://patchstack.com
4 */
5
6 window.Patchstack = window.Patchstack || {};
7
8 ( function( window, document, $, plugin ) {
9 var $c = {};
10
11 plugin.init = function() {
12 plugin.cache();
13 plugin.bindEvents();
14 };
15
16 plugin.cache = function() {
17 $c.window = $( window );
18 $c.body = $( document.body );
19 };
20
21 plugin.bindEvents = function() {
22 $('input#patchstack-activate').on( 'click', function(e) {
23 e.preventDefault();
24 var postData = {
25 action: 'patchstack_activate_license',
26 clientid: $( '#patchstack_api_client_id' ).val(),
27 secretkey: $( '#patchstack_api_client_secret_key' ).val(),
28 PatchstackNonce: PatchstackVars.nonce
29 };
30
31 if ( $.trim( postData.clientid ).length == 0 || $.trim( postData.secretkey ).length == 0) {
32 alert( 'Please enter the site id and secret key.' );
33 return false;
34 }
35
36 $.post( PatchstackVars.ajaxurl, postData, function( response ) {
37 if ( response.result == 'error' ) {
38 if ( response.error_message ) {
39 alert( response.error_message );
40 } else {
41 alert( PatchstackVars.error_message );
42 }
43 } else {
44 if (response.response && response.response.free === false) {
45 window.location.reload();
46 } else {
47 $( '.patchstack-license-status' ).text( 'Active' ).css( { color: '#B2D675' } );
48 $( '.patchstack-sub-type' ).text( 'Community (Free) ');
49 $( '.ps-b1, .ps-p1' ).hide();
50 $( '.ps-b3' ).removeClass('patchstack-fullwidth');
51 $( '.ps-b2, .ps-b4, .ps-p2' ).show();
52 }
53 }
54 });
55 });
56
57 $('#patchstack_send_mail_url').on( 'click', function(e) {
58 e.preventDefault();
59 var postData = {
60 action: 'patchstack_send_new_url_email',
61 PatchstackNonce: PatchstackVars.nonce
62 };
63 $.post( PatchstackVars.ajaxurl, postData, function( response ) {
64 if ( response == 'fail') {
65 alert( PatchstackVars.error_message );
66 } else {
67 alert( 'Email Sent!' );
68 }
69 });
70 });
71
72 // Don't load this part if DataTables is not loaded.
73 if(typeof jQuery.fn.dataTable !== 'undefined' && window.location.href.indexOf('patchstack') !== -1){
74
75 // Initialize datatables.
76 $('.table-firewall-log').DataTable({
77 "processing": true,
78 "serverSide": true,
79 "ajax": {
80 "url": PatchstackVars.ajaxurl,
81 "type": "POST",
82 "data": function(d){
83 d.action = 'patchstack_firewall_log_table';
84 d.PatchstackNonce = $("meta[name=patchstack_nonce]").attr("value");
85 }
86 },
87 "responsive": true,
88 "columns": [
89 { "data": "fid" },
90 { "data": "referer" },
91 { "data": "method" },
92 { "data": "ip", render: $.fn.dataTable.render.text() },
93 { "data": "log_date" }
94 ],
95 "order": [[0, "desc"]],
96 "searching": false,
97 "ordering": false,
98 "drawCallback": function( settings ) {
99 $('.titletip').tooltip();
100 },
101 "columnDefs": [
102 {
103 "render": function ( data, type, row ) {
104 var title = (data ? data : 'Unknown');
105 var description = (row.description ? row.description : 'No Explanation');
106
107 return '<span class=" titletip" title="' + description + '">' + title + '</span>';
108 },
109 "targets": 0
110 },
111 {
112 "render": function ( data, type, row ) {
113 return decodeURIComponent(data).replace(/</g,"&lt;").replace(/>/g,"&gt;").replace('+', ' ');
114 },
115 "targets": 1
116 }
117 ]
118 });
119
120 $('.table-user-log').DataTable({
121 "processing": true,
122 "serverSide": true,
123 "ajax": {
124 "url": PatchstackVars.ajaxurl,
125 "type": "POST",
126 "data": function(d){
127 d.action = 'patchstack_users_log_table';
128 d.PatchstackNonce = $("meta[name=patchstack_nonce]").attr("value");
129 }
130 },
131 "responsive": true,
132 "columns": [
133 { "data": "author" },
134 { "data": "action", render: $.fn.dataTable.render.text() },
135 { "data": "object", render: $.fn.dataTable.render.text() },
136 { "data": "object_name", render: $.fn.dataTable.render.text() },
137 { "data": "ip", render: $.fn.dataTable.render.text() },
138 { "data": "date", render: $.fn.dataTable.render.text() }
139 ],
140 "order": [[0, "desc"]],
141 "searching": true,
142 "ordering": false
143 });
144 }
145
146 if($("#patchstack_captcha_type").val() == "v2"){
147 $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
148 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key").show();
149 }else if($("#patchstack_captcha_type").val() == "invisible"){
150 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
151 $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").show();
152 }else{
153 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").hide();
154 $("#patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").show();
155 }
156
157 $("#patchstack_captcha_type").change(function() {
158 if($("#patchstack_captcha_type").val() == "v2"){
159 $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
160 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key").show();
161 }else if($("#patchstack_captcha_type").val() == "invisible"){
162 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
163 $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").show();
164 }else{
165 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").hide();
166 $("#patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").show();
167 }
168 });
169
170 if($('#geo-countries').length > 0){
171 var items = []
172 if($('#geo-countries').data('selected') != ''){
173 items = $('#geo-countries').data('selected').split(',')
174 }
175
176 $('#geo-countries').selectize({
177 maxItems: null,
178 delimiter: ',',
179 plugins: ['remove_button'],
180 items: items
181 });
182 }
183 };
184
185 $( plugin.init );
186 }( window, document, jQuery, window.Patchstack ) );