PluginProbe
Patchstack – WordPress & Plugins Security / 2.1.24
Patchstack – WordPress & Plugins Security v2.1.24
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
← All changes | assets/js/patchstack.js +182 -126 trunk2.1.24 View file →
@@ -1,127 +1,183 @@
1 -/**
2 - * Patchstack
3 - * https://patchstack.com
4 - */
5 -
6 -window.Patchstack = window.Patchstack || {};
7 -
8 -( function( window, document, $, plugin ) {
9 - var $c = {};
10 - var polling = null;
11 - var isPolling = false;
12 - var pollingDelay = 0;
13 -
14 - plugin.init = function() {
15 - plugin.cache();
16 - plugin.bindEvents();
17 - };
18 -
19 - plugin.cache = function() {
20 - $c.window = $( window );
21 - $c.body = $( document.body );
22 - };
23 -
24 - plugin.poller = function() {
25 - polling = setInterval(() => {
26 - if (!isPolling && pollingDelay == 0) {
27 - plugin.autoActivate();
28 - pollingDelay = 5;
29 - }
30 -
31 - pollingDelay--;
32 - }, 1000);
33 - };
34 -
35 - plugin.autoActivate = function() {
36 - isPolling = true;
37 -
38 - var postData = {
39 - action: 'patchstack_activate_auto',
40 - PatchstackNonce: PatchstackVars.nonce
41 - };
42 -
43 - $.post( PatchstackVars.ajaxurl, postData, function( response ) {
44 - var postData = {
45 - action: 'patchstack_activation_status',
46 - PatchstackNonce: PatchstackVars.nonce
47 - };
48 -
49 - $.post ( PatchstackVars.ajaxurl, postData, function( response ) {
50 - if ( response.activated ) {
51 - window.location = window.location.href.replace('&ps_autoa=1', '') + '&resync=1';
52 - }
53 -
54 - isPolling = false;
55 - });
56 - });
57 - };
58 -
59 - plugin.bindEvents = function() {
60 - $('input#patchstack-activate').on( 'click', function(e) {
61 - e.preventDefault();
62 - var postData = {
63 - action: 'patchstack_activate_license',
64 - key: $('.patchstack-auto-activate').attr('style') == '' ? $( '#patchstack_api_key2' ).val() : $( '#patchstack_api_key' ).val(),
65 - PatchstackNonce: PatchstackVars.nonce
66 - };
67 -
68 - if ( $.trim( postData.key ).length == 0 ) {
69 - alert( 'Please enter the API key.' );
70 - return false;
71 - }
72 -
73 - $( '.patchstack-resync' ).hide();
74 - $( '#patchstack-activate' ).hide();
75 - $( '.patchstack-loading' ).show();
76 - $( '.is-polling-section' ).hide();
77 - isPolling = true
78 -
79 - $.post( PatchstackVars.ajaxurl, postData, function( response ) {
80 - isPolling = false
81 - pollingDelay = 5
82 - if ( response.result == 'error' ) {
83 - $( '#patchstack-activate, .is-polling-section' ).show();
84 - $( '.patchstack-loading' ).hide();
85 - if ( response.error_message ) {
86 - alert( response.error_message );
87 - } else {
88 - alert( PatchstackVars.error_message );
89 - }
90 - } else {
91 - window.location = window.location.href + '&resync=1';
92 - }
93 - });
94 - });
95 -
96 - $( '.patchstack-retry-link' ).on( 'click', function( e ) {
97 - e.preventDefault();
98 -
99 - var $link = $( this );
100 - if ( $link.hasClass( 'is-loading' ) ) {
101 - return;
102 - }
103 - $link.addClass( 'is-loading' );
104 -
105 - var postData = {
106 - action: 'patchstack_check_connection',
107 - PatchstackNonce: PatchstackVars.nonce
108 - };
109 -
110 - $.post( PatchstackVars.ajaxurl, postData, function( response ) {
111 - if ( ! response ) {
112 - return;
113 - }
114 - var $status = $( '.patchstack-connection-status' );
115 - $status.toggleClass( 'is-connected', !! response.connected );
116 - $status.toggleClass( 'is-disconnected', ! response.connected );
117 - if ( typeof response.label === 'string' ) {
118 - $( '.patchstack-last-sync' ).text( response.label );
119 - }
120 - } ).always( function() {
121 - $link.removeClass( 'is-loading' );
122 - } );
123 - } );
124 - };
125 -
126 - $( plugin.init );
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 + key: $( '#patchstack_api_key' ).val(),
27 + PatchstackNonce: PatchstackVars.nonce
28 + };
29 +
30 + if ( $.trim( postData.key ).length == 0 ) {
31 + alert( 'Please enter the API key.' );
32 + return false;
33 + }
34 +
35 + $( '.patchstack-resync' ).hide();
36 + $( '#patchstack-activate' ).hide();
37 + $( '.patchstack-loading' ).show();
38 +
39 + $.post( PatchstackVars.ajaxurl, postData, function( response ) {
40 + if ( response.result == 'error' ) {
41 + $( '#patchstack-activate' ).show();
42 + $( '.patchstack-loading' ).hide();
43 + if ( response.error_message ) {
44 + alert( response.error_message );
45 + } else {
46 + alert( PatchstackVars.error_message );
47 + }
48 + } else {
49 + window.location = window.location.href + '&resync=1';
50 + }
51 + });
52 + });
53 +
54 + $('#patchstack_send_mail_url').on( 'click', function(e) {
55 + e.preventDefault();
56 + var postData = {
57 + action: 'patchstack_send_new_url_email',
58 + PatchstackNonce: PatchstackVars.nonce
59 + };
60 + $.post( PatchstackVars.ajaxurl, postData, function( response ) {
61 + if ( response == 'fail') {
62 + alert( PatchstackVars.error_message );
63 + } else {
64 + alert( 'Email Sent!' );
65 + }
66 + });
67 + });
68 +
69 + // Don't load this part if DataTables is not loaded.
70 + if(typeof jQuery.fn.dataTable !== 'undefined' && window.location.href.indexOf('patchstack') !== -1){
71 +
72 + // Initialize datatables.
73 + $('.table-firewall-log').DataTable({
74 + "processing": true,
75 + "serverSide": true,
76 + "ajax": {
77 + "url": PatchstackVars.ajaxurl,
78 + "type": "POST",
79 + "data": function(d){
80 + d.action = 'patchstack_firewall_log_table';
81 + d.PatchstackNonce = $("meta[name=patchstack_nonce]").attr("value");
82 + }
83 + },
84 + "responsive": true,
85 + "columns": [
86 + { "data": "fid" },
87 + { "data": "referer" },
88 + { "data": "method" },
89 + { "data": "ip", render: $.fn.dataTable.render.text() },
90 + { "data": "log_date" }
91 + ],
92 + "order": [[0, "desc"]],
93 + "searching": false,
94 + "ordering": false,
95 + "drawCallback": function( settings ) {
96 + $('.titletip').tooltip();
97 + },
98 + "columnDefs": [
99 + {
100 + "render": function ( data, type, row ) {
101 + var title = (data ? data : 'Unknown');
102 + var description = (row.description ? row.description : 'No Explanation');
103 +
104 + return '<span class=" titletip" title="' + description + '">' + title + '</span>';
105 + },
106 + "targets": 0
107 + },
108 + {
109 + "render": function ( data, type, row ) {
110 + return decodeURIComponent(data).replace(/</g,"&lt;").replace(/>/g,"&gt;").replace('+', ' ');
111 + },
112 + "targets": 1
113 + }
114 + ]
115 + });
116 +
117 + $('.table-user-log').DataTable({
118 + "processing": true,
119 + "serverSide": true,
120 + "ajax": {
121 + "url": PatchstackVars.ajaxurl,
122 + "type": "POST",
123 + "data": function(d){
124 + d.action = 'patchstack_users_log_table';
125 + d.PatchstackNonce = $("meta[name=patchstack_nonce]").attr("value");
126 + }
127 + },
128 + "responsive": true,
129 + "columns": [
130 + { "data": "author" },
131 + { "data": "action", render: $.fn.dataTable.render.text() },
132 + { "data": "object", render: $.fn.dataTable.render.text() },
133 + { "data": "object_name", render: $.fn.dataTable.render.text() },
134 + { "data": "ip", render: $.fn.dataTable.render.text() },
135 + { "data": "date", render: $.fn.dataTable.render.text() }
136 + ],
137 + "order": [[0, "desc"]],
138 + "searching": true,
139 + "ordering": false
140 + });
141 + }
142 +
143 + if($("#patchstack_captcha_type").val() == "v2"){
144 + $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
145 + $("#patchstack_captcha_public_key, #patchstack_captcha_private_key").show();
146 + }else if($("#patchstack_captcha_type").val() == "invisible"){
147 + $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
148 + $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").show();
149 + }else{
150 + $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").hide();
151 + $("#patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").show();
152 + }
153 +
154 + $("#patchstack_captcha_type").change(function() {
155 + if($("#patchstack_captcha_type").val() == "v2"){
156 + $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
157 + $("#patchstack_captcha_public_key, #patchstack_captcha_private_key").show();
158 + }else if($("#patchstack_captcha_type").val() == "invisible"){
159 + $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
160 + $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").show();
161 + }else{
162 + $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").hide();
163 + $("#patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").show();
164 + }
165 + });
166 +
167 + if($('#geo-countries').length > 0){
168 + var items = []
169 + if($('#geo-countries').data('selected') != ''){
170 + items = $('#geo-countries').data('selected').split(',')
171 + }
172 +
173 + $('#geo-countries').selectize({
174 + maxItems: null,
175 + delimiter: ',',
176 + plugins: ['remove_button'],
177 + items: items
178 + });
179 + }
180 + };
181 +
182 + $( plugin.init );
127 183 }( window, document, jQuery, window.Patchstack ) );