PluginProbe
Patchstack – WordPress & Plugins Security / 2.1.6
Patchstack – WordPress & Plugins Security v2.1.6
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 +165 -126 trunk2.1.6 View file →
@@ -1,127 +1,166 @@
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: '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 + alert( PatchstackVars.error_message );
39 + } else {
40 + if (response.response && response.response.free === false) {
41 + window.location.reload();
42 + } else {
43 + $( '.patchstack-license-status' ).text( 'Active' ).css( { color: '#B2D675' } );
44 + $( '.patchstack-sub-type' ).text( 'Community (Free) ');
45 + $( '.ps-b1, .ps-b3, .ps-p1' ).hide();
46 + $( '.ps-b2, .ps-b4, .ps-p2' ).show();
47 + }
48 + }
49 + });
50 + });
51 +
52 + // Don't load this part if DataTables is not loaded.
53 + if(typeof jQuery.fn.dataTable !== 'undefined' && window.location.href.indexOf('patchstack') !== -1){
54 +
55 + // Initialize datatables.
56 + $('.table-firewall-log').DataTable({
57 + "processing": true,
58 + "serverSide": true,
59 + "ajax": {
60 + "url": PatchstackVars.ajaxurl,
61 + "type": "POST",
62 + "data": function(d){
63 + d.action = 'firewall_log_table';
64 + d.PatchstackNonce = $("meta[name=patchstack_nonce]").attr("value");
65 + }
66 + },
67 + "responsive": true,
68 + "columns": [
69 + { "data": "fid" },
70 + { "data": "referer" },
71 + { "data": "method" },
72 + { "data": "ip", render: $.fn.dataTable.render.text() },
73 + { "data": "log_date" }
74 + ],
75 + "order": [[0, "desc"]],
76 + "searching": false,
77 + "ordering": false,
78 + "drawCallback": function( settings ) {
79 + $('.titletip').tooltip();
80 + },
81 + "columnDefs": [
82 + {
83 + "render": function ( data, type, row ) {
84 + var title = (data ? data : 'Unknown');
85 + var description = (row.description ? row.description : 'No Explanation');
86 +
87 + return '<span class=" titletip" title="' + description + '">' + title + '</span>';
88 + },
89 + "targets": 0
90 + },
91 + {
92 + "render": function ( data, type, row ) {
93 + return decodeURIComponent(data).replace(/</g,"&lt;").replace(/>/g,"&gt;").replace('+', ' ');
94 + },
95 + "targets": 1
96 + }
97 + ]
98 + });
99 +
100 + $('.table-user-log').DataTable({
101 + "processing": true,
102 + "serverSide": true,
103 + "ajax": {
104 + "url": PatchstackVars.ajaxurl,
105 + "type": "POST",
106 + "data": function(d){
107 + d.action = 'users_log_table';
108 + d.PatchstackNonce = $("meta[name=patchstack_nonce]").attr("value");
109 + }
110 + },
111 + "responsive": true,
112 + "columns": [
113 + { "data": "author" },
114 + { "data": "action", render: $.fn.dataTable.render.text() },
115 + { "data": "object", render: $.fn.dataTable.render.text() },
116 + { "data": "object_name", render: $.fn.dataTable.render.text() },
117 + { "data": "ip", render: $.fn.dataTable.render.text() },
118 + { "data": "date", render: $.fn.dataTable.render.text() }
119 + ],
120 + "order": [[0, "desc"]],
121 + "searching": true,
122 + "ordering": false
123 + });
124 + }
125 +
126 + if($("#patchstack_captcha_type").val() == "v2"){
127 + $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
128 + $("#patchstack_captcha_public_key, #patchstack_captcha_private_key").show();
129 + }else if($("#patchstack_captcha_type").val() == "invisible"){
130 + $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
131 + $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").show();
132 + }else{
133 + $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").hide();
134 + $("#patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").show();
135 + }
136 +
137 + $("#patchstack_captcha_type").change(function() {
138 + if($("#patchstack_captcha_type").val() == "v2"){
139 + $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
140 + $("#patchstack_captcha_public_key, #patchstack_captcha_private_key").show();
141 + }else if($("#patchstack_captcha_type").val() == "invisible"){
142 + $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
143 + $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").show();
144 + }else{
145 + $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").hide();
146 + $("#patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").show();
147 + }
148 + });
149 +
150 + if($('#geo-countries').length > 0){
151 + var items = []
152 + if($('#geo-countries').data('selected') != ''){
153 + items = $('#geo-countries').data('selected').split(',')
154 + }
155 +
156 + $('#geo-countries').selectize({
157 + maxItems: null,
158 + delimiter: ',',
159 + plugins: ['remove_button'],
160 + items: items
161 + });
162 + }
163 + };
164 +
165 + $( plugin.init );
127 166 }( window, document, jQuery, window.Patchstack ) );