From 8c4645f7af9700d436eca376ca66ab755f96475b Mon Sep 17 00:00:00 2001 From: Glomberg Date: Thu, 23 Nov 2023 14:10:14 +0300 Subject: [PATCH 01/67] Fix. SecFW. Schema updated. --- lib/CleantalkSP/SpbctWP/DB/SQLSchema.php | 40 ++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/lib/CleantalkSP/SpbctWP/DB/SQLSchema.php b/lib/CleantalkSP/SpbctWP/DB/SQLSchema.php index da5c99d59..0b8e37971 100644 --- a/lib/CleantalkSP/SpbctWP/DB/SQLSchema.php +++ b/lib/CleantalkSP/SpbctWP/DB/SQLSchema.php @@ -16,9 +16,26 @@ class SQLSchema extends \CleantalkSP\Common\DB\SQLSchema * @var array */ protected static $schemas__common = array( - 'firewall_data' => array( + 'firewall_data_v4' => array( 'columns' => array( - array('field' => 'id', 'type' => 'char(32)', 'null' => 'no',), + array('field' => 'id', 'type' => 'int unsigned', 'null' => 'no', 'extra' => 'AUTO_INCREMENT'), + array('field' => 'network', 'type' => 'int unsigned', 'null' => 'no', 'default' => '0',), + array('field' => 'mask', 'type' => 'int unsigned', 'null' => 'no', 'default' => '0',), + array('field' => 'country_code', 'type' => 'char(2)', 'null' => 'yes', 'default' => 'NULL',), + array('field' => 'status', 'type' => 'tinyint', 'null' => 'yes',), + ), + 'indexes' => array( + array('type' => 'PRIMARY', 'name' => 'KEY', 'body' => '(`id`)'), + array( + 'type' => 'INDEX', + 'name' => 'network', + 'body' => '(`network`, `mask`)' + ), + ), + ), + 'firewall_data_v6' => array( + 'columns' => array( + array('field' => 'id', 'type' => 'int unsigned', 'null' => 'no', 'extra' => 'AUTO_INCREMENT'), array('field' => 'network1', 'type' => 'int unsigned', 'null' => 'no', 'default' => '0',), array('field' => 'network2', 'type' => 'int unsigned', 'null' => 'no', 'default' => '0',), array('field' => 'network3', 'type' => 'int unsigned', 'null' => 'no', 'default' => '0',), @@ -343,7 +360,24 @@ class SQLSchema extends \CleantalkSP\Common\DB\SQLSchema ), ), - 'firewall__personal_ips' => array( + 'firewall__personal_ips_v4' => array( + 'columns' => array( + array('field' => 'id', 'type' => 'int', 'null' => 'no', 'extra' => 'AUTO_INCREMENT'), + array('field' => 'network', 'type' => 'int unsigned', 'null' => 'no', 'default' => '0',), + array('field' => 'mask', 'type' => 'int unsigned', 'null' => 'no', 'default' => '0',), + array('field' => 'status', 'type' => 'tinyint', 'null' => 'no', 'default' => '0',), + ), + 'indexes' => array( + array('type' => 'PRIMARY', 'name' => 'KEY', 'body' => '(`id`)'), + array( + 'type' => 'INDEX', + 'name' => 'network', + 'body' => '(`network`, `mask`)' + ), + ), + ), + + 'firewall__personal_ips_v6' => array( 'columns' => array( array('field' => 'id', 'type' => 'int', 'null' => 'no', 'extra' => 'AUTO_INCREMENT'), array('field' => 'network1', 'type' => 'int unsigned', 'null' => 'no', 'default' => '0',), From f92c27e701883b5199a96b24f359887e67d471a2 Mon Sep 17 00:00:00 2001 From: Glomberg Date: Thu, 23 Nov 2023 14:11:08 +0300 Subject: [PATCH 02/67] Fix. SecFW. Updating separated by v4 and v6. --- inc/fw-update.php | 38 ++++-- lib/CleantalkSP/SpbctWP/Firewall/FW.php | 154 ++++++++++++++++-------- security-malware-firewall.php | 8 +- 3 files changed, 132 insertions(+), 68 deletions(-) diff --git a/inc/fw-update.php b/inc/fw-update.php index f32438620..f1cd143f3 100644 --- a/inc/fw-update.php +++ b/inc/fw-update.php @@ -44,9 +44,11 @@ function spbc_security_firewall_update__init($delay = null) // Delete temporary tables FW::dataTablesDeleteTemporary(DB::getInstance(), array( - SPBC_TBL_FIREWALL_DATA, - SPBC_TBL_FIREWALL_DATA__IPS, - SPBC_TBL_FIREWALL_DATA__COUNTRIES, + SPBC_TBL_FIREWALL_DATA_V4, + SPBC_TBL_FIREWALL_DATA_V6, + SPBC_TBL_FIREWALL_DATA__IPS_V4, + SPBC_TBL_FIREWALL_DATA__IPS_V6, + SPBC_TBL_FIREWALL_DATA__COUNTRIES )); $wp_upload_dir = wp_upload_dir(); @@ -331,16 +333,20 @@ function spbc_security_firewall_update__prepare() global $wpdb; // Make sure that the table exists. Creating it if not. $db_tables_creator = new \CleantalkSP\SpbctWP\DB\TablesCreator(); - $db_tables_creator->createTable($wpdb->base_prefix . 'spbc_firewall_data'); - $db_tables_creator->createTable($wpdb->prefix . 'spbc_firewall__personal_ips'); - $db_tables_creator->createTable($wpdb->prefix . 'spbc_firewall__personal_countries'); + $db_tables_creator->createTable(SPBC_TBL_FIREWALL_DATA_V4); + $db_tables_creator->createTable(SPBC_TBL_FIREWALL_DATA_V6); + $db_tables_creator->createTable(SPBC_TBL_FIREWALL_DATA__IPS_V4); + $db_tables_creator->createTable(SPBC_TBL_FIREWALL_DATA__IPS_V6); + $db_tables_creator->createTable(SPBC_TBL_FIREWALL_DATA__COUNTRIES); // Update only personal tables for daughter blogs $result = FW::dataTablesCreateTemporaryTablesForTables( DB::getInstance(), array( - SPBC_TBL_FIREWALL_DATA, - SPBC_TBL_FIREWALL_DATA__IPS, + SPBC_TBL_FIREWALL_DATA_V4, + SPBC_TBL_FIREWALL_DATA_V6, + SPBC_TBL_FIREWALL_DATA__IPS_V4, + SPBC_TBL_FIREWALL_DATA__IPS_V6, SPBC_TBL_FIREWALL_DATA__COUNTRIES ) ); @@ -350,9 +356,13 @@ function spbc_security_firewall_update__prepare() } // Copying data without country code - $result = FW::dataTablesCopyCountiesDataFromMainTable(DB::getInstance(), SPBC_TBL_FIREWALL_DATA); - if ( ! empty($result['error']) ) { - return $result; + $result_v4 = FW::dataTablesCopyCountiesDataFromMainTable(DB::getInstance(), SPBC_TBL_FIREWALL_DATA_V4); + $result_v6 = FW::dataTablesCopyCountiesDataFromMainTable(DB::getInstance(), SPBC_TBL_FIREWALL_DATA_V6); + if ( ! empty($result_v4['error']) ) { + return $result_v4; + } + if ( ! empty($result_v6['error']) ) { + return $result_v6; } $spbc->fw_stats['update_percent'] = 15; @@ -487,8 +497,10 @@ function spbc_security_firewall_update__end_of_update() //Increment firewall entries $tables_to_work_with = array( - SPBC_TBL_FIREWALL_DATA, - SPBC_TBL_FIREWALL_DATA__IPS, + SPBC_TBL_FIREWALL_DATA_V4, + SPBC_TBL_FIREWALL_DATA_V6, + SPBC_TBL_FIREWALL_DATA__IPS_V4, + SPBC_TBL_FIREWALL_DATA__IPS_V6, SPBC_TBL_FIREWALL_DATA__COUNTRIES ); diff --git a/lib/CleantalkSP/SpbctWP/Firewall/FW.php b/lib/CleantalkSP/SpbctWP/Firewall/FW.php index 61f9a43a1..5370cda62 100644 --- a/lib/CleantalkSP/SpbctWP/Firewall/FW.php +++ b/lib/CleantalkSP/SpbctWP/Firewall/FW.php @@ -532,9 +532,14 @@ public static function updateWriteToDb( if ( empty($data['error']) ) { $inserted = 0; + $data_table__common_v4 = str_replace('_temp', '_v4_temp', $data_table__common); + $data_table__common_v6 = str_replace('_temp', '_v6_temp', $data_table__common); + $data_table__personal_v4 = str_replace('_temp', '_v4_temp', $data_table__personal); + $data_table__personal_v6 = str_replace('_temp', '_v6_temp', $data_table__personal); + while ( $data !== '' ) { for ( - $i = 0, $sql__common = array(), $sql__personal_ip = array(); + $i = 0, $sql__common_v4 = $sql__common_v6 = $sql__personal_ip_v4 = $sql__personal_ip_v6 = $sql__personal_country = []; $i < SPBC_WRITE_LIMIT && $data !== ''; $i++ ) { @@ -546,12 +551,15 @@ public static function updateWriteToDb( } // IP processing + $network_v4 = ''; + $network_v6 = []; + // IPv4 if ( is_numeric($entry[0]) ) { - $networks = array(0, 0, 0, $entry[0]); + $network_v4 = $entry[0]; //IPv6 } else { - $networks = IP::convertIPv6ToFourIPv4( + $network_v6 = IP::convertIPv6ToFourIPv4( IP::extendIPv6( IP::normalizeIPv6( trim($entry[0], '"') @@ -560,79 +568,117 @@ public static function updateWriteToDb( ); } - /** - * Versatility for mask for v6 and v4 - * @psalm-suppress LoopInvalidation - */ - for ( $masks = array(), $mask = $entry[1], $k = 4; $k >= 1; $k-- ) { - $masks[$k] = (2 ** 32) - (2 ** (32 - ($mask > 32 ? 32 : $mask))); - $mask -= 32; - $mask = $mask > 0 ? $mask : 0; - } - - // $comment = $entry[2]; // Comment from user + $mask = $entry[1]; $status = isset($entry[3]) ? $entry[3] : 0; $is_personal = isset($entry[4]) ? (int)$entry[4] : 0; $country = isset($entry[5]) ? trim($entry[5], '"') : 0; // IPv4 - if ( - is_numeric($networks[0]) && - is_numeric($networks[1]) && - is_numeric($networks[2]) && - is_numeric($networks[3]) - ) { + if ( $network_v4 !== '' ) { $mask = sprintf( '%u', bindec(str_pad(str_repeat('1', $mask), 32, 0, STR_PAD_RIGHT)) ); if ( $country || ! $is_personal ) { - $unique = md5(implode('', $networks) . $mask . $country . $status); - $sql__common[] = "('$unique', $networks[0], $networks[1], $networks[2], $networks[3], $masks[1], $masks[2], $masks[3], $masks[4], $status, '$country')"; + $sql__common_v4[] = "($network_v4, $mask, $status, '$country')"; + } + if ( $is_personal && $country ) { + $sql__personal_country[] = "('$country',$status)"; + } + + if ( $is_personal && ! $country ) { + $sql__personal_ip_v4[] = "($network_v4, $mask, $status)"; + } + } + + // IPv6 + if ( count($network_v6) ) { + for ( $masks = array(), $k = 4; $k >= 1; $k-- ) { + $masks[$k] = (2 ** 32) - (2 ** (32 - ($mask > 32 ? 32 : $mask))); + $mask -= 32; + $mask = $mask > 0 ? $mask : 0; + } + if ( $country || ! $is_personal ) { + $sql__common_v6[] = "($network_v6[0], $network_v6[1], $network_v6[2], $network_v6[3], $masks[1], $masks[2], $masks[3], $masks[4], $status, '$country')"; } if ( $is_personal && $country ) { $sql__personal_country[] = "('$country',$status)"; } if ( $is_personal && ! $country ) { - $sql__personal_ip[] = "($networks[0], $networks[1], $networks[2], $networks[3], $masks[1], $masks[2], $masks[3], $masks[4], $status)"; + $sql__personal_ip_v6[] = "($network_v6[0], $network_v6[1], $network_v6[2], $network_v6[3], $masks[1], $masks[2], $masks[3], $masks[4], $status)"; } } } - // Insertion to common table - $sql_result__common___result = $db->execute( - 'INSERT INTO ' . $data_table__common - . ' (id, network1, network2, network3, network4, mask1, mask2, mask3, mask4, status, country_code) ' - . ' VALUES ' - . implode(',', $sql__common) - . ' ON DUPLICATE KEY UPDATE' - . ' network1=network1' - . ';' - ); + // Insertion to common table v4 + if ( count($sql__common_v4) ) { + $sql_result__common_v4___result = $db->execute( + 'INSERT INTO ' . $data_table__common_v4 + . ' (network, mask, status, country_code) ' + . ' VALUES ' + . implode(',', $sql__common_v4) + . ' ON DUPLICATE KEY UPDATE' + . ' network=network' + . ';' + ); + + if ( $sql_result__common_v4___result === false ) { + return array('error' => 'COULD_NOT_WRITE_TO_DB_COMMON_V4: ' . $db->getLastError()); + } + } - if ( $sql_result__common___result === false ) { - return array('error' => 'COULD_NOT_WRITE_TO_DB 1: ' . $db->getLastError()); + + // Insertion to common table v6 + if ( count($sql__common_v6) ) { + $sql_result__common_v6___result = $db->execute( + 'INSERT INTO ' . $data_table__common_v6 + . ' (network1, network2, network3, network4, mask1, mask2, mask3, mask4, status, country_code) ' + . ' VALUES ' + . implode(',', $sql__common_v6) + . ' ON DUPLICATE KEY UPDATE' + . ' network1=network1' + . ';' + ); + + if ( $sql_result__common_v6___result === false ) { + return array('error' => 'COULD_NOT_WRITE_TO_DB_COMMON_V6: ' . $db->getLastError()); + } } + // Replacing result counter because SQL result won't count all contained entries - $sql_result__common___result = count($sql__common); + $sql_result__common___result = count($sql__common_v4) + count($sql__common_v6); $sql_result__personal___result = 0; - // Insertion to personal IPs table - if ( ! empty($sql__personal_ip) ) { - $sql_result__personal___result = $db->execute( - 'INSERT INTO ' . $data_table__personal . ' (network1,network2,network3,network4,mask1,mask2,mask3,mask4,status) VALUES ' - . implode(',', $sql__personal_ip) . ';' + // Insertion v4 to personal IPs table + if ( count($sql__personal_ip_v4) ) { + $sql_result__personal_v4___result = $db->execute( + 'INSERT INTO ' . $data_table__personal_v4 . ' (network,mask,status) VALUES ' + . implode(',', $sql__personal_ip_v4) . ';' ); unset($sql__personal_ip); - if ( $sql_result__personal___result === false ) { - return array('error' => 'COULD_NOT_WRITE_TO_DB 2: ' . $db->getLastError()); + if ( $sql_result__personal_v4___result === false ) { + return array('error' => 'COULD_NOT_WRITE_TO_DB_PERSONAL_V4: ' . $db->getLastError()); } + $sql_result__personal___result += $sql_result__personal_v4___result; + } + + // Insertion v6 to personal IPs table + if ( count($sql__personal_ip_v6) ) { + $sql_result__personal_v6___result = $db->execute( + 'INSERT INTO ' . $data_table__personal_v6 . ' (network1,network2,network3,network4,mask1,mask2,mask3,mask4,status) VALUES ' + . implode(',', $sql__personal_ip_v6) . ';' + ); + unset($sql__personal_ip); + if ( $sql_result__personal_v6___result === false ) { + return array('error' => 'COULD_NOT_WRITE_TO_DB_PERSONAL_V6: ' . $db->getLastError()); + } + $sql_result__personal___result += $sql_result__personal_v6___result; } // Insertion to personal countries table - if ( ! empty($sql__personal_country) ) { + if ( count($sql__personal_country) ) { $sql__personal_country = array_unique($sql__personal_country); // Filtering duplicate entries $sql_result__country___result = $db->execute( 'INSERT INTO ' . $data_table__personal_countries . '(country_code,status) VALUES ' @@ -640,7 +686,7 @@ public static function updateWriteToDb( ); unset($sql__personal_country); if ( $sql_result__country___result === false ) { - return array('error' => 'COULD_NOT_WRITE_TO_DB 3: ' . $db->getLastError()); + return array('error' => 'COULD_NOT_WRITE_TO_DB_COUNTRIES: ' . $db->getLastError()); } } @@ -673,7 +719,9 @@ public static function updateWriteToDbExclusions( $db__table__data__common, $exclusions = array() ) { - $query = 'INSERT INTO `' . $db__table__data__personal . '` (network1,network2,network3,network4,mask1,mask2,mask3,mask4,status) VALUES '; + $data_table__personal_v4 = str_replace('_temp', '_v4_temp', $db__table__data__personal); + $data_table__common_v4 = str_replace('_temp', '_v4_temp', $db__table__data__common); + $query = 'INSERT INTO `' . $data_table__personal_v4 . '` (network,mask,status) VALUES '; //Exclusion for servers IP (SERVER_ADDR) if ( Server::get('HTTP_HOST') ) { @@ -686,18 +734,18 @@ public static function updateWriteToDbExclusions( // From both tables personal and common } else { $db->execute( - 'DELETE FROM ' . $db__table__data__personal . ' WHERE network4 = ' . ip2long('127.0.0.1') . ';' + 'DELETE FROM ' . $data_table__personal_v4 . ' WHERE network = ' . ip2long('127.0.0.1') . ';' ); $db->execute( - 'DELETE FROM ' . $db__table__data__common . ' WHERE network4 = ' . ip2long('127.0.0.1') . ';' + 'DELETE FROM ' . $data_table__common_v4 . ' WHERE network = ' . ip2long('127.0.0.1') . ';' ); } } foreach ( $exclusions as $exclusion ) { - if ( IP::validate($exclusion) && sprintf('%u', ip2long($exclusion)) ) { - $networks = IP::convertIPv6ToFourIPv4(IP::extendIPv6(IP::normalizeIPv6($exclusion))); - + if ( IP::validate($exclusion) ) { + $network = sprintf('%u', ip2long($exclusion)); + $mask = 4294967295; /** * @psalm-suppress LoopInvalidation */ @@ -707,7 +755,7 @@ public static function updateWriteToDbExclusions( $mask = $mask > 0 ? $mask : 0; } - $query .= "( $networks[0], $networks[1], $networks[2], $networks[3], $masks[1], $masks[2], $masks[3], $masks[4] , 2),"; + $query .= "( $network, $mask, 2),"; } } @@ -715,7 +763,7 @@ public static function updateWriteToDbExclusions( $sql_result = $db->execute(substr($query, 0, -1) . ';'); return $sql_result === false - ? array('error' => 'COULD_NOT_WRITE_TO_DB 4: ' . $db->getLastError()) + ? array('error' => 'COULD_NOT_WRITE_TO_DB_EXCLUSIONS: ' . $db->getLastError()) : count($exclusions); } diff --git a/security-malware-firewall.php b/security-malware-firewall.php index 92a35fdd0..2af3bd095 100644 --- a/security-malware-firewall.php +++ b/security-malware-firewall.php @@ -89,8 +89,12 @@ // DataBase params global $wpdb; -define('SPBC_TBL_FIREWALL_DATA', $wpdb->base_prefix . 'spbc_firewall_data'); // Legacy -define('SPBC_TBL_FIREWALL_DATA__IPS', $wpdb->prefix . 'spbc_firewall__personal_ips'); // Table with firewall IPS +define('SPBC_TBL_FIREWALL_DATA', $wpdb->base_prefix . 'spbc_firewall_data'); +define('SPBC_TBL_FIREWALL_DATA_V4', SPBC_TBL_FIREWALL_DATA. '_v4'); +define('SPBC_TBL_FIREWALL_DATA_V6', SPBC_TBL_FIREWALL_DATA . '_v6'); +define('SPBC_TBL_FIREWALL_DATA__IPS', $wpdb->prefix . 'spbc_firewall__personal_ips'); +define('SPBC_TBL_FIREWALL_DATA__IPS_V4', SPBC_TBL_FIREWALL_DATA__IPS . '_v4'); // Table with firewall IPS v4 +define('SPBC_TBL_FIREWALL_DATA__IPS_V6', SPBC_TBL_FIREWALL_DATA__IPS . '_v6'); // Table with firewall IPS v6 define('SPBC_TBL_FIREWALL_DATA__COUNTRIES', $wpdb->prefix . 'spbc_firewall__personal_countries'); // Table with firewall countries. define('SPBC_TBL_FIREWALL_LOG', $wpdb->prefix . 'spbc_firewall_logs'); // Table with firewall logs. define('SPBC_TBL_SESSIONS', $wpdb->prefix . 'spbc_sessions'); // Alternative sessions table From 27bed7af2ea1274cb64af7e34d8776c3c0d4f76a Mon Sep 17 00:00:00 2001 From: Glomberg Date: Thu, 23 Nov 2023 15:45:26 +0300 Subject: [PATCH 03/67] Fix. Code. Code style and psalm fixed. --- lib/CleantalkSP/SpbctWP/Firewall/FW.php | 13 ++----------- security-malware-firewall.php | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/CleantalkSP/SpbctWP/Firewall/FW.php b/lib/CleantalkSP/SpbctWP/Firewall/FW.php index 5370cda62..b82bb0440 100644 --- a/lib/CleantalkSP/SpbctWP/Firewall/FW.php +++ b/lib/CleantalkSP/SpbctWP/Firewall/FW.php @@ -657,7 +657,7 @@ public static function updateWriteToDb( 'INSERT INTO ' . $data_table__personal_v4 . ' (network,mask,status) VALUES ' . implode(',', $sql__personal_ip_v4) . ';' ); - unset($sql__personal_ip); + unset($sql__personal_ip_v4); if ( $sql_result__personal_v4___result === false ) { return array('error' => 'COULD_NOT_WRITE_TO_DB_PERSONAL_V4: ' . $db->getLastError()); } @@ -670,7 +670,7 @@ public static function updateWriteToDb( 'INSERT INTO ' . $data_table__personal_v6 . ' (network1,network2,network3,network4,mask1,mask2,mask3,mask4,status) VALUES ' . implode(',', $sql__personal_ip_v6) . ';' ); - unset($sql__personal_ip); + unset($sql__personal_ip_v6); if ( $sql_result__personal_v6___result === false ) { return array('error' => 'COULD_NOT_WRITE_TO_DB_PERSONAL_V6: ' . $db->getLastError()); } @@ -746,15 +746,6 @@ public static function updateWriteToDbExclusions( if ( IP::validate($exclusion) ) { $network = sprintf('%u', ip2long($exclusion)); $mask = 4294967295; - /** - * @psalm-suppress LoopInvalidation - */ - for ( $masks = array(), $mask = 128, $k = 4; $k >= 1; $k-- ) { - $masks[$k] = (2 ** 32) - (2 ** (32 - ($mask > 32 ? 32 : $mask))); - $mask -= 32; - $mask = $mask > 0 ? $mask : 0; - } - $query .= "( $network, $mask, 2),"; } } diff --git a/security-malware-firewall.php b/security-malware-firewall.php index 2af3bd095..ff2d9ca60 100644 --- a/security-malware-firewall.php +++ b/security-malware-firewall.php @@ -90,7 +90,7 @@ global $wpdb; define('SPBC_TBL_FIREWALL_DATA', $wpdb->base_prefix . 'spbc_firewall_data'); -define('SPBC_TBL_FIREWALL_DATA_V4', SPBC_TBL_FIREWALL_DATA. '_v4'); +define('SPBC_TBL_FIREWALL_DATA_V4', SPBC_TBL_FIREWALL_DATA . '_v4'); define('SPBC_TBL_FIREWALL_DATA_V6', SPBC_TBL_FIREWALL_DATA . '_v6'); define('SPBC_TBL_FIREWALL_DATA__IPS', $wpdb->prefix . 'spbc_firewall__personal_ips'); define('SPBC_TBL_FIREWALL_DATA__IPS_V4', SPBC_TBL_FIREWALL_DATA__IPS . '_v4'); // Table with firewall IPS v4 From 607a41d25b00b7390d38f7976c6f01aec9d4538c Mon Sep 17 00:00:00 2001 From: alexandergull Date: Wed, 29 Nov 2023 09:43:56 +0500 Subject: [PATCH 04/67] Main logic done. --- inc/spbc-settings.php | 18 ++ js/spbc-admin.min.js | 2 +- js/spbc-admin.min.js.map | 2 +- js/spbc-settings_tab--summary.min.js.map | 2 +- js/src/spbc-admin.js | 19 +- js/src/spbc-settings_tab--summary.js | 2 +- lib/CleantalkSP/Common/HTTP/Request.php | 17 ++ lib/CleantalkSP/SpbctWP/Escape.php | 20 ++ .../SpbctWP/HTTP/CDNHeadersChecker.php | 198 ++++++++++++++++++ lib/CleantalkSP/SpbctWP/Helpers/IP.php | 71 +++---- lib/CleantalkSP/SpbctWP/State.php | 3 + security-malware-firewall.php | 13 ++ 12 files changed, 323 insertions(+), 44 deletions(-) create mode 100644 lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php diff --git a/inc/spbc-settings.php b/inc/spbc-settings.php index 36facfc9c..6534830d4 100644 --- a/inc/spbc-settings.php +++ b/inc/spbc-settings.php @@ -1,5 +1,6 @@ esc_html__('Enable this option for Traffic Control to stop watching logged in users and keep watching website guests only.', 'security-malware-firewall'), 'parent' => 'traffic_control__enabled', ), + 'secfw__get_ip__disable_cdn_auto_self_check' => array( + 'type' => 'field', + 'title' => __('Disable automatic CDN headers checker', 'security-malware-firewall'), + 'description' => CDNHeadersChecker::getDescriptionText(), + 'children' => array('secfw__get_ip'), + ), 'secfw__get_ip' => array( 'type' => 'field', 'input_type' => 'select', 'options' => spbc_settings_field__secfw__get_ip__get_labels(), 'title' => __('Get visitors IP from additional headers', 'security-malware-firewall'), 'description' => spbc_settings_field__secfw__get_ip__get_description(), + 'parent' => 'secfw__get_ip__cdn_auto_self_check' ), ), ), @@ -1649,6 +1657,16 @@ function spbc_field_statistics() : __('Unknown last PHP log sending time.', 'security-malware-firewall')); } + echo '
'; + + + //cdn checker data + add_filter( 'safe_style_css', function( $styles ) { + $styles[] = 'display'; + return $styles; + } ); + echo Escape::escKsesPreset(CDNHeadersChecker::getSummaryBlockHTML(), 'spbc_cdn_checker_table'); + echo '
'; echo 'Plugin version: ' . SPBC_VERSION; echo ''; diff --git a/js/spbc-admin.min.js b/js/spbc-admin.min.js index 243396084..815b463b8 100644 --- a/js/spbc-admin.min.js +++ b/js/spbc-admin.min.js @@ -1,2 +1,2 @@ -function spbcGetGoogleQrCode(){var e={},c={};return e.security=spbcSettings.ajax_nonce,e.action="spbc_get_google_qr_code",jQuery.ajax({type:"POST",async:!1,url:spbcSettings.ajaxurl,data:e,success:function(e){c=e}}),c}function spbcCheckGoogleCode(){var e={};e.security=spbcSettings.ajax_nonce,e.action="spbc_check_google_code",e.code=jQuery("#spbct-google-qr-code input").val(),jQuery.ajax({type:"POST",async:!1,url:spbcSettings.ajaxurl,data:e,success:function(e){e.success?(jQuery("#spbct-google-qr-code").dialog("close"),document.location.reload()):alert(e.data)}})}function spbcDisableG2fa(e){var c={};c.security=spbcSettings.ajax_nonce,c.action="spbc_disable_google_2fa",c.user_id=jQuery(e).data("user-id"),jQuery.ajax({type:"POST",async:!1,url:spbcSettings.ajaxurl,data:c,success:function(e){e.success?document.location.reload():alert(e.data)}})}jQuery(document).ready(function(){jQuery(".spbc_update_notice").on("click","button",function(){spbc_setCookie("spbc_update_banner_closed",1,2592e3)}),jQuery(document).on("click","#spbc-g2fa-enable",function(e){e.preventDefault();e=spbcGetGoogleQrCode();e.success?(jQuery("#spbct-google-qr-code-img").html(e.data.img+"

"+e.data.code+"

"),jQuery("#spbct-google-qr-code input").val(""),jQuery("#spbct-google-qr-code").dialog({modal:!0,title:"Google authenticator activation",buttons:{Cancel:function(){jQuery(this).dialog("close")},Ok:function(){spbcCheckGoogleCode()}},draggable:!1,resizable:!1})):alert(spbcGetGoogleQrCode.data)}),jQuery(document).on("click","#spbc-g2fa-disable",function(e){e.preventDefault(),confirm("Are you sure?")&&spbcDisableG2fa(this)});function e(e,c,t){setTimeout(function(){null!==e&&(jQuery(".spbc-admin_bar--user_counter").html(e.count),e.count<=3?(jQuery("#wp-admin-bar-spbc_admin_bar__online_admins").show(),jQuery(".spbc-admin_bar--online_admins").html(e.users.join(", "))):jQuery("#wp-admin-bar-spbc_admin_bar__online_admins").hide()),spbc_sendAJAXRequest(c,t)},15e3)}1==+spbcSettings.admin_bar__admins_online_counter&&e(null,{action:"spbc_get_authorized_admins"},{callback:e}),jQuery("body").on("click",".spbc-notice .notice-dismiss",function(e){e=jQuery(e.target).parent(".notice").attr("id");e&&spbc_sendAJAXRequest({action:"spbc_dismiss_banner",banner_id:e},{callback:null})}),1==+spbcSettings.needToWhitelist&&spbc_sendAJAXRequest({action:"spbc_private_list_add"},{callback:null})}); +function spbcGetGoogleQrCode(){var e={},c={};return e.security=spbcSettings.ajax_nonce,e.action="spbc_get_google_qr_code",jQuery.ajax({type:"POST",async:!1,url:spbcSettings.ajaxurl,data:e,success:function(e){c=e}}),c}function spbcCheckGoogleCode(){var e={};e.security=spbcSettings.ajax_nonce,e.action="spbc_check_google_code",e.code=jQuery("#spbct-google-qr-code input").val(),jQuery.ajax({type:"POST",async:!1,url:spbcSettings.ajaxurl,data:e,success:function(e){e.success?(jQuery("#spbct-google-qr-code").dialog("close"),document.location.reload()):alert(e.data)}})}function spbcDisableG2fa(e){var c={};c.security=spbcSettings.ajax_nonce,c.action="spbc_disable_google_2fa",c.user_id=jQuery(e).data("user-id"),jQuery.ajax({type:"POST",async:!1,url:spbcSettings.ajaxurl,data:c,success:function(e){e.success?document.location.reload():alert(e.data)}})}function spbcSummaryShowCDNCheckerTable(){event.preventDefault();var e=document.getElementById("spbc_stats_cdn_checker_table");void 0!==e&&("block"===e.style.display?e.style.display="none":e.style.display="block")}jQuery(document).ready(function(){jQuery(".spbc_update_notice").on("click","button",function(){spbc_setCookie("spbc_update_banner_closed",1,2592e3)}),jQuery(document).on("click","#spbc-g2fa-enable",function(e){e.preventDefault();e=spbcGetGoogleQrCode();e.success?(jQuery("#spbct-google-qr-code-img").html(e.data.img+"

"+e.data.code+"

"),jQuery("#spbct-google-qr-code input").val(""),jQuery("#spbct-google-qr-code").dialog({modal:!0,title:"Google authenticator activation",buttons:{Cancel:function(){jQuery(this).dialog("close")},Ok:function(){spbcCheckGoogleCode()}},draggable:!1,resizable:!1})):alert(spbcGetGoogleQrCode.data)}),jQuery(document).on("click","#spbc-g2fa-disable",function(e){e.preventDefault(),confirm("Are you sure?")&&spbcDisableG2fa(this)});function e(e,c,t){setTimeout(function(){null!==e&&(jQuery(".spbc-admin_bar--user_counter").html(e.count),e.count<=3?(jQuery("#wp-admin-bar-spbc_admin_bar__online_admins").show(),jQuery(".spbc-admin_bar--online_admins").html(e.users.join(", "))):jQuery("#wp-admin-bar-spbc_admin_bar__online_admins").hide()),spbc_sendAJAXRequest(c,t)},15e3)}1==+spbcSettings.admin_bar__admins_online_counter&&e(null,{action:"spbc_get_authorized_admins"},{callback:e}),jQuery("body").on("click",".spbc-notice .notice-dismiss",function(e){e=jQuery(e.target).parent(".notice").attr("id");e&&spbc_sendAJAXRequest({action:"spbc_dismiss_banner",banner_id:e},{callback:null})}),1==+spbcSettings.needToWhitelist&&spbc_sendAJAXRequest({action:"spbc_private_list_add"},{callback:null})}); //# sourceMappingURL=spbc-admin.min.js.map diff --git a/js/spbc-admin.min.js.map b/js/spbc-admin.min.js.map index f58bb3713..505030316 100644 --- a/js/spbc-admin.min.js.map +++ b/js/spbc-admin.min.js.map @@ -1 +1 @@ -{"version":3,"file":"spbc-admin.min.js","sources":["spbc-admin.js"],"sourcesContent":["function spbcGetGoogleQrCode() {\n\tvar data = {};\n\tvar res = {};\n\tdata.security = spbcSettings.ajax_nonce;\n\tdata.action = 'spbc_get_google_qr_code';\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\tasync: false,\n\t\turl: spbcSettings.ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(result){\n\t\t\tres = result;\n\t\t},\n\t});\n\treturn res;\n}\n\nfunction spbcCheckGoogleCode() {\n\tvar data = {};\n\tdata.security = spbcSettings.ajax_nonce;\n\tdata.action = 'spbc_check_google_code';\n\tdata.code = jQuery('#spbct-google-qr-code input').val();\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\tasync: false,\n\t\turl: spbcSettings.ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(result){\n\t\t\tif(result.success) {\n\t\t\t\tjQuery('#spbct-google-qr-code').dialog( \"close\" );\n\t\t\t\tdocument.location.reload();\n\t\t\t} else {\n\t\t\t\talert(result.data);\n\t\t\t}\n\t\t},\n\t});\n}\n\nfunction spbcDisableG2fa( element ) {\n\tvar data = {};\n\tdata.security = spbcSettings.ajax_nonce;\n\tdata.action = 'spbc_disable_google_2fa';\n data.user_id = jQuery(element).data('user-id');\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\tasync: false,\n\t\turl: spbcSettings.ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(result){\n\t\t\tif(result.success) {\n\t\t\t\tdocument.location.reload();\n\t\t\t} else {\n\t\t\t\talert(result.data);\n\t\t\t}\n\t\t},\n\t});\n}\n\njQuery(document).ready(function(){\n\t\n\t// Auto update banner close handler \n\tjQuery('.spbc_update_notice').on('click', 'button', function(){\n\t\tspbc_setCookie('spbc_update_banner_closed', 1, 86400 * 30);\n\t});\n\n\t// Enable G2FA from user profile page\n\tjQuery(document).on('click', '#spbc-g2fa-enable', function(e){\n\n\t\te.preventDefault();\n\t\tvar spbcGoogleQrCode = spbcGetGoogleQrCode();\n\n\t\tif( spbcGoogleQrCode.success ) {\n\t\t\tvar qr_code_div = jQuery('#spbct-google-qr-code-img');\n\t\t\tqr_code_div.html(spbcGoogleQrCode.data.img + '

' + spbcGoogleQrCode.data.code + '

');\n\t\t\tjQuery('#spbct-google-qr-code input').val('');\n\t\t\tjQuery('#spbct-google-qr-code').dialog({\n\t\t\t\tmodal: true,\n\t\t\t\ttitle: 'Google authenticator activation',\n\t\t\t\tbuttons: {\n\t\t\t\t\tCancel: function() {\n\t\t\t\t\t\tjQuery( this ).dialog( \"close\" );\n\t\t\t\t\t},\n\t\t\t\t\tOk: function() {\n\t\t\t\t\t\tspbcCheckGoogleCode();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tdraggable: false,\n\t\t\t\tresizable: false,\n\t\t\t});\n\t\t} else {\n\t\t\talert(spbcGetGoogleQrCode.data);\n\t\t}\n\n\t});\n\n\t// Disable G2FA from user profile page\n\tjQuery(document).on('click', '#spbc-g2fa-disable', function(e){\n\n\t\te.preventDefault();\n\t\tif( confirm( 'Are you sure?' ) ) {\n\t\t\tspbcDisableG2fa( this );\n\t\t}\n\n\t});\n\n\tvar refresh_user_online_counter = function( result, data, params ){\n\t\tsetTimeout(function () {\n\t\t\tif( result !== null ){\n\t\t\t\tjQuery('.spbc-admin_bar--user_counter').html(result.count);\n\t\t\t\tif( result.count <= 3 ) {\n\t\t\t\t\tjQuery('#wp-admin-bar-spbc_admin_bar__online_admins').show();\n\t\t\t\t\tjQuery('.spbc-admin_bar--online_admins').html(result.users.join(', '));\n\t\t\t\t}else{\n\t\t\t\t\tjQuery('#wp-admin-bar-spbc_admin_bar__online_admins').hide();\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tspbc_sendAJAXRequest( data, params );\n\t\t}, 15000 );\n\t};\n\n\tif( +spbcSettings.admin_bar__admins_online_counter === 1 ) {\n\t\trefresh_user_online_counter(null, {action: 'spbc_get_authorized_admins'}, {callback: refresh_user_online_counter});\n\t}\n\n\t// Dismiss admin banner\n\tjQuery('body').on('click', '.spbc-notice .notice-dismiss', function(e){\n\t\tvar bannerId = jQuery(e.target).parent('.notice').attr('id');\n\t\tif( bannerId ) {\n\t\t\tspbc_sendAJAXRequest( { 'action' : 'spbc_dismiss_banner', 'banner_id' : bannerId }, { 'callback' : null } );\n\t\t}\n\t});\n\n\tif (+spbcSettings.needToWhitelist === 1) {\n\t\tspbc_sendAJAXRequest( { 'action' : 'spbc_private_list_add' }, { 'callback' : null } );\n\t}\n});"],"names":["spbcGetGoogleQrCode","data","res","security","spbcSettings","ajax_nonce","action","jQuery","ajax","type","async","url","ajaxurl","success","result","spbcCheckGoogleCode","code","val","dialog","document","location","reload","alert","spbcDisableG2fa","element","user_id","ready","on","spbc_setCookie","e","preventDefault","spbcGoogleQrCode","html","img","modal","title","buttons","Cancel","this","Ok","draggable","resizable","confirm","refresh_user_online_counter","params","setTimeout","count","show","users","join","hide","spbc_sendAJAXRequest","admin_bar__admins_online_counter","callback","bannerId","target","parent","attr","banner_id","needToWhitelist"],"mappings":"AAAA,SAASA,sBACR,IAAIC,EAAO,GACPC,EAAM,GAaV,OAZAD,EAAKE,SAAWC,aAAaC,WAC7BJ,EAAKK,OAAS,0BAEdC,OAAOC,KAAK,CACXC,KAAM,OACNC,MAAO,CAAA,EACPC,IAAKP,aAAaQ,QAClBX,KAAMA,EACNY,QAAS,SAASC,GACjBZ,EAAMY,CACP,CACD,CAAC,EACMZ,CACR,CAEA,SAASa,sBACR,IAAId,EAAO,GACXA,EAAKE,SAAWC,aAAaC,WAC7BJ,EAAKK,OAAS,yBACdL,EAAKe,KAAOT,OAAO,6BAA6B,EAAEU,IAAI,EAEtDV,OAAOC,KAAK,CACXC,KAAM,OACNC,MAAO,CAAA,EACPC,IAAKP,aAAaQ,QAClBX,KAAMA,EACNY,QAAS,SAASC,GACdA,EAAOD,SACTN,OAAO,uBAAuB,EAAEW,OAAQ,OAAQ,EAChDC,SAASC,SAASC,OAAO,GAEzBC,MAAMR,EAAOb,IAAI,CAEnB,CACD,CAAC,CACF,CAEA,SAASsB,gBAAiBC,GACzB,IAAIvB,EAAO,GACXA,EAAKE,SAAWC,aAAaC,WAC7BJ,EAAKK,OAAS,0BACXL,EAAKwB,QAAUlB,OAAOiB,CAAO,EAAEvB,KAAK,SAAS,EAEhDM,OAAOC,KAAK,CACXC,KAAM,OACNC,MAAO,CAAA,EACPC,IAAKP,aAAaQ,QAClBX,KAAMA,EACNY,QAAS,SAASC,GACdA,EAAOD,QACTM,SAASC,SAASC,OAAO,EAEzBC,MAAMR,EAAOb,IAAI,CAEnB,CACD,CAAC,CACF,CAEAM,OAAOY,QAAQ,EAAEO,MAAM,WAGtBnB,OAAO,qBAAqB,EAAEoB,GAAG,QAAS,SAAU,WACnDC,eAAe,4BAA6B,EAAG,MAAU,CAC1D,CAAC,EAGDrB,OAAOY,QAAQ,E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,KAAK,IAAI,EACvDH,GACHH,qBAAsB,CAAE7C,OAAW,sBAAuBoD,UAAcJ,CAAS,EAAG,CAAED,SAAa,IAAK,CAAE,CAE5G,CAAC,EAEqC,GAAlC,CAACjD,aAAauD,iBACjBR,qBAAsB,CAAE7C,OAAW,uBAAwB,EAAG,CAAE+C,SAAa,IAAK,CAAE,CAEtF,CAAC"} \ No newline at end of file +{"version":3,"file":"spbc-admin.min.js","sources":["spbc-admin.js"],"sourcesContent":["function spbcGetGoogleQrCode() {\n\tvar data = {};\n\tvar res = {};\n\tdata.security = spbcSettings.ajax_nonce;\n\tdata.action = 'spbc_get_google_qr_code';\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\tasync: false,\n\t\turl: spbcSettings.ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(result){\n\t\t\tres = result;\n\t\t},\n\t});\n\treturn res;\n}\n\nfunction spbcCheckGoogleCode() {\n\tvar data = {};\n\tdata.security = spbcSettings.ajax_nonce;\n\tdata.action = 'spbc_check_google_code';\n\tdata.code = jQuery('#spbct-google-qr-code input').val();\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\tasync: false,\n\t\turl: spbcSettings.ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(result){\n\t\t\tif(result.success) {\n\t\t\t\tjQuery('#spbct-google-qr-code').dialog( \"close\" );\n\t\t\t\tdocument.location.reload();\n\t\t\t} else {\n\t\t\t\talert(result.data);\n\t\t\t}\n\t\t},\n\t});\n}\n\nfunction spbcDisableG2fa( element ) {\n\tvar data = {};\n\tdata.security = spbcSettings.ajax_nonce;\n\tdata.action = 'spbc_disable_google_2fa';\n data.user_id = jQuery(element).data('user-id');\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\tasync: false,\n\t\turl: spbcSettings.ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(result){\n\t\t\tif(result.success) {\n\t\t\t\tdocument.location.reload();\n\t\t\t} else {\n\t\t\t\talert(result.data);\n\t\t\t}\n\t\t},\n\t});\n}\n\njQuery(document).ready(function(){\n\n\t// Auto update banner close handler\n\tjQuery('.spbc_update_notice').on('click', 'button', function(){\n\t\tspbc_setCookie('spbc_update_banner_closed', 1, 86400 * 30);\n\t});\n\n\t// Enable G2FA from user profile page\n\tjQuery(document).on('click', '#spbc-g2fa-enable', function(e){\n\n\t\te.preventDefault();\n\t\tvar spbcGoogleQrCode = spbcGetGoogleQrCode();\n\n\t\tif( spbcGoogleQrCode.success ) {\n\t\t\tvar qr_code_div = jQuery('#spbct-google-qr-code-img');\n\t\t\tqr_code_div.html(spbcGoogleQrCode.data.img + '

' + spbcGoogleQrCode.data.code + '

');\n\t\t\tjQuery('#spbct-google-qr-code input').val('');\n\t\t\tjQuery('#spbct-google-qr-code').dialog({\n\t\t\t\tmodal: true,\n\t\t\t\ttitle: 'Google authenticator activation',\n\t\t\t\tbuttons: {\n\t\t\t\t\tCancel: function() {\n\t\t\t\t\t\tjQuery( this ).dialog( \"close\" );\n\t\t\t\t\t},\n\t\t\t\t\tOk: function() {\n\t\t\t\t\t\tspbcCheckGoogleCode();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tdraggable: false,\n\t\t\t\tresizable: false,\n\t\t\t});\n\t\t} else {\n\t\t\talert(spbcGetGoogleQrCode.data);\n\t\t}\n\n\t});\n\n\t// Disable G2FA from user profile page\n\tjQuery(document).on('click', '#spbc-g2fa-disable', function(e){\n\n\t\te.preventDefault();\n\t\tif( confirm( 'Are you sure?' ) ) {\n\t\t\tspbcDisableG2fa( this );\n\t\t}\n\n\t});\n\n\tvar refresh_user_online_counter = function( result, data, params ){\n\t\tsetTimeout(function () {\n\t\t\tif( result !== null ){\n\t\t\t\tjQuery('.spbc-admin_bar--user_counter').html(result.count);\n\t\t\t\tif( result.count <= 3 ) {\n\t\t\t\t\tjQuery('#wp-admin-bar-spbc_admin_bar__online_admins').show();\n\t\t\t\t\tjQuery('.spbc-admin_bar--online_admins').html(result.users.join(', '));\n\t\t\t\t}else{\n\t\t\t\t\tjQuery('#wp-admin-bar-spbc_admin_bar__online_admins').hide();\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tspbc_sendAJAXRequest( data, params );\n\t\t}, 15000 );\n\t};\n\n\tif( +spbcSettings.admin_bar__admins_online_counter === 1 ) {\n\t\trefresh_user_online_counter(null, {action: 'spbc_get_authorized_admins'}, {callback: refresh_user_online_counter});\n\t}\n\n\t// Dismiss admin banner\n\tjQuery('body').on('click', '.spbc-notice .notice-dismiss', function(e){\n\t\tvar bannerId = jQuery(e.target).parent('.notice').attr('id');\n\t\tif( bannerId ) {\n\t\t\tspbc_sendAJAXRequest( { 'action' : 'spbc_dismiss_banner', 'banner_id' : bannerId }, { 'callback' : null } );\n\t\t}\n\t});\n\n\tif (+spbcSettings.needToWhitelist === 1) {\n\t\tspbc_sendAJAXRequest( { 'action' : 'spbc_private_list_add' }, { 'callback' : null } );\n\t}\n});\n\nfunction spbcSummaryShowCDNCheckerTable()\n{\n\tevent.preventDefault()\n\tlet table = document.getElementById('spbc_stats_cdn_checker_table')\n\tif (typeof (table) !== 'undefined') {\n\t\tif (table.style.display === 'block') {\n\t\t\ttable.style.display = 'none'\n\t\t} else {\n\t\t\ttable.style.display = 'block'\n\t\t}\n\t}\n}\n"],"names":["spbcGetGoogleQrCode","data","res","security","spbcSettings","ajax_nonce","action","jQuery","ajax","type","async","url","ajaxurl","success","result","spbcCheckGoogleCode","code","val","dialog","document","location","reload","alert","spbcDisableG2fa","element","user_id","spbcSummaryShowCDNCheckerTable","event","preventDefault","let","table","getElementById","style","display","ready","on","spbc_setCookie","e","spbcGoogleQrCode","html","img","modal","title","buttons","Cancel","this","Ok","draggable","resizable","confirm","refresh_user_online_counter","params","setTimeout","count","show","users","join","hide","spbc_sendAJAXRequest","admin_bar__admins_online_counter","callback","bannerId","target","parent","attr","banner_id","needToWhitelist"],"mappings":"AAAA,SAASA,sBACR,IAAIC,EAAO,GACPC,EAAM,GAaV,OAZAD,EAA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AAO,SAAS,EAAEC,KAAK,IAAI,EACvDH,GACHH,qBAAsB,CAAEpD,OAAW,sBAAuB2D,UAAcJ,CAAS,EAAG,CAAED,SAAa,IAAK,CAAE,CAE5G,CAAC,EAEqC,GAAlC,CAACxD,aAAa8D,iBACjBR,qBAAsB,CAAEpD,OAAW,uBAAwB,EAAG,CAAEsD,SAAa,IAAK,CAAE,CAEtF,CAAC"} \ No newline at end of file diff --git a/js/spbc-settings_tab--summary.min.js.map b/js/spbc-settings_tab--summary.min.js.map index 4ac7735fd..3e914bbd3 100644 --- a/js/spbc-settings_tab--summary.min.js.map +++ b/js/spbc-settings_tab--summary.min.js.map @@ -1 +1 @@ -{"version":3,"file":"spbc-settings_tab--summary.min.js","sources":["spbc-settings_tab--summary.js"],"sourcesContent":["jQuery(document).ready(function(){\n\tconsole.log('TAB - SUMMARY');\n});"],"names":["jQuery","document","ready","console","log"],"mappings":"AAAAA,OAAOC,QAAQ,EAAEC,MAAM,WACtBC,QAAQC,IAAI,eAAe,CAC5B,CAAC"} \ No newline at end of file +{"version":3,"file":"spbc-settings_tab--summary.min.js","sources":["spbc-settings_tab--summary.js"],"sourcesContent":["jQuery(document).ready(function(){\n\tconsole.log('TAB - SUMMARY');\n});\n"],"names":["jQuery","document","ready","console","log"],"mappings":"AAAAA,OAAOC,QAAQ,EAAEC,MAAM,WACtBC,QAAQC,IAAI,eAAe,CAC5B,CAAC"} \ No newline at end of file diff --git a/js/src/spbc-admin.js b/js/src/spbc-admin.js index 6287bea9f..10d100d65 100644 --- a/js/src/spbc-admin.js +++ b/js/src/spbc-admin.js @@ -60,8 +60,8 @@ function spbcDisableG2fa( element ) { } jQuery(document).ready(function(){ - - // Auto update banner close handler + + // Auto update banner close handler jQuery('.spbc_update_notice').on('click', 'button', function(){ spbc_setCookie('spbc_update_banner_closed', 1, 86400 * 30); }); @@ -137,4 +137,17 @@ jQuery(document).ready(function(){ if (+spbcSettings.needToWhitelist === 1) { spbc_sendAJAXRequest( { 'action' : 'spbc_private_list_add' }, { 'callback' : null } ); } -}); \ No newline at end of file +}); + +function spbcSummaryShowCDNCheckerTable() +{ + event.preventDefault() + let table = document.getElementById('spbc_stats_cdn_checker_table') + if (typeof (table) !== 'undefined') { + if (table.style.display === 'block') { + table.style.display = 'none' + } else { + table.style.display = 'block' + } + } +} diff --git a/js/src/spbc-settings_tab--summary.js b/js/src/spbc-settings_tab--summary.js index f025f729f..38a213ea6 100644 --- a/js/src/spbc-settings_tab--summary.js +++ b/js/src/spbc-settings_tab--summary.js @@ -1,3 +1,3 @@ jQuery(document).ready(function(){ console.log('TAB - SUMMARY'); -}); \ No newline at end of file +}); diff --git a/lib/CleantalkSP/Common/HTTP/Request.php b/lib/CleantalkSP/Common/HTTP/Request.php index 64293201a..54cecbf65 100644 --- a/lib/CleantalkSP/Common/HTTP/Request.php +++ b/lib/CleantalkSP/Common/HTTP/Request.php @@ -459,6 +459,23 @@ static function (Response $response) { true ); break; + case 'get_headers': + $this->options[CURLOPT_HEADER] = true; + $this->options[CURLOPT_NOBODY] = true; + $this->addCallback( + static function (Response $response) { + if (is_string($response->getContentRaw())) { + preg_match_all("/.+\S/i", $response->getContentRaw(), $matches); + return $matches[0]; + } else { + return $response; + } + }, + array(), + 60, + true + ); + break; // Get headers only case 'split_to_array': $this->addCallback( diff --git a/lib/CleantalkSP/SpbctWP/Escape.php b/lib/CleantalkSP/SpbctWP/Escape.php index 78aedd2ee..7a99a79b2 100644 --- a/lib/CleantalkSP/SpbctWP/Escape.php +++ b/lib/CleantalkSP/SpbctWP/Escape.php @@ -100,6 +100,26 @@ public static function escKsesPreset($string, $preset = null, $_allowed_protocol 'href' => true, ), ), + 'spbc_cdn_checker_table' => array( + 'a' => array( + 'style' => true, + 'href' => true, + 'onclick' => true, + ), + 'p' => array(), + 'b' => array(), + 'table' => array( + 'id' => true, + 'style' => true, + ), + 'tr' => array(), + 'th' => array(), + 'td' => array( + 'colspan' => true + ), + 'tbody' => true, + 'div' => array() + ), 'spbc_settings__notice_autosend' => array( 'div' => array( 'class' => true, diff --git a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php new file mode 100644 index 000000000..df4043678 --- /dev/null +++ b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php @@ -0,0 +1,198 @@ +settings['wp__use_builtin_http_api']; + $spbc->settings['wp__use_builtin_http_api'] = 0; + $self_url = is_multisite() ? get_blog_option(null, 'home') : get_option('home'); + $provided_headers = self::getResponseHeadersNames($self_url); + $known_cdn_headers = IP::getKnownCDNHeadersNames(); + $found_headers = self::findKnownCDNHeaders($provided_headers, $known_cdn_headers); + self::updateStoredCDNHeadersData($found_headers); + $last_check_headers = self::getLastCheckCDNHeaders(); + $new_header_id = self::getNewHeaderIdForSettings($spbc, $last_check_headers); + if ($new_header_id) { + self::applyIPGetHeadersSettings($spbc, $new_header_id); + } + $spbc->settings['wp__use_builtin_http_api'] = $old_setting; + } + + private static function getResponseHeadersNames($self_url) + { + return array_keys(HTTP::getHTTPHeaders()); + } + + private static function findKnownCDNHeaders($provided_headers, $known_cdn_headers) + { + $headers = array(); + foreach (array_keys($provided_headers) as $provided_header) { + $provided_header = strtolower($provided_header); + foreach ($known_cdn_headers as $known_header) { + if (stripos($provided_header, $known_header) !== false) { + $headers[] = $known_header; + } + } + } + return $headers; + } + + private static function saveStoredCDNHeadersData() + { + global $spbc; + $spbc->data['allowed_cdn_headers_data'] = serialize(self::$current_cdn_check_result); + $spbc->save('data'); + } + + private static function loadStoredCDNHeadersData() + { + global $spbc; + $stored_cdn_headers_data = isset($spbc->data['allowed_cdn_headers_data']) + ? $spbc->data['allowed_cdn_headers_data'] + : array(); + return unserialize($stored_cdn_headers_data); + } + + private static function updateStoredCDNHeadersData($found_headers) + { + self::$current_cdn_check_result = self::loadStoredCDNHeadersData(); + if (is_array(self::$current_cdn_check_result)) { + if (count(self::$current_cdn_check_result) >= self::$limit_of_cdn_records_to_keep) { + array_shift(self::$current_cdn_check_result); + } + } + + self::$current_cdn_check_result[] = array( + 'time' => time(), + 'found_cdn_headers' => $found_headers + ); + + self::saveStoredCDNHeadersData(); + } + + private static function getLastCheckCDNHeaders() + { + $data = self::loadStoredCDNHeadersData(); + if (count($data)) { + return !empty($data[count($data) - 1]['found_cdn_headers']) + ? $data[count($data) - 1]['found_cdn_headers'] + : array(); + } + return array(); + } + + private static function getNewHeaderIdForSettings(State $spbc, $last_check_headers) + { + $last_check_header = isset($last_check_headers[0]) ? $last_check_headers[0] : null; + $new_header_id = null; + if (!$last_check_header) { + //set remote addr (2) as source if nothing found + if (!isset($spbc->settings['secfw__get_ip']) || $spbc->settings['secfw__get_ip'] !== '2') { + $new_header_id = '2'; + } + } else { + $new_header_id = IP::getHeaderIDbySlug($last_check_header); + } + + return $new_header_id; + } + + private static function applyIPGetHeadersSettings(State $spbc, $new_header_id = null) + { + $spbc->data['secfw__get_ip__last_auto_set'] = serialize(array( + 'time' => time(), + 'header_id' => $new_header_id, + 'setting_name' => IP::$known_headers[$new_header_id]['name'], + 'header_slug' => IP::$known_headers[$new_header_id]['slug'], + )); + $spbc->save('data'); + + $spbc->settings['secfw__get_ip'] = (string)$new_header_id; + $spbc->save('settings'); + return $spbc; + } + + public static function getSummaryBlockHTML() + { + global $spbc; + //collect data + $last_settings_change = array(); + if (!empty($spbc->data['secfw__get_ip__last_auto_set'])) { + $last_settings_change = unserialize($spbc->data['secfw__get_ip__last_auto_set']); + } + $stored_checks_data = self::loadStoredCDNHeadersData(); + $header_slug_text = !empty($spbc->settings['secfw__get_ip']) + ? '' . IP::$known_headers[$spbc->settings['secfw__get_ip']]['slug'] . '' + : __('unknown statement', 'security_malware_firewall'); + + //build layout + $html = '
'; + $html .= ''; + $html .= __('Automatic HTTP Headers Detection results (click to show)', 'security_malware_firewall'); + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + + //build rows + foreach ($stored_checks_data as $check) { + $headers_text = !empty($check['found_cdn_headers']) + ? __('Found headers:', 'security_malware_firewall') . ' ' . implode(',', $check['found_cdn_headers']) + : __('No known CDN headers found', 'security_malware_firewall'); + $time_text = date('Y-m-d h:i:s', (int)($check['time'])); + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + } + + $html .= ''; + $html .= ''; + $html .= ''; + + $html .= ''; + $html .= ''; + $html .= '
'; + + return $html; + } + + public static function getDescriptionText() + { + return __('Enable this option to set IP address source manually. If disabled, the plugin will detect IP source via self-call. Stats can be seen on the "Summary" tab', 'security-malware-firewall'); + } +} diff --git a/lib/CleantalkSP/SpbctWP/Helpers/IP.php b/lib/CleantalkSP/SpbctWP/Helpers/IP.php index 2f668ddee..f217bfc43 100644 --- a/lib/CleantalkSP/SpbctWP/Helpers/IP.php +++ b/lib/CleantalkSP/SpbctWP/Helpers/IP.php @@ -4,49 +4,46 @@ class IP extends \CleantalkSP\Common\Helpers\IP { + public static $known_headers = array( + 2 => array('slug' => 'remote_addr', 'name' => 'Remote Addr'), + 3 => array('slug' => 'x_forwarded_for', 'name' => 'X-Forwarder-For'), + 4 => array('slug' => 'x_real_ip', 'name' => 'X-Real-Ip'), + 5 => array('slug' => 'incapsula', 'name' => 'Incap-Client-Ip'), + 6 => array('slug' => 'ico_x_forwarded_for', 'name' => 'Ico-X-Forwarded-For'), + 7 => array('slug' => 'stackpath', 'name' => 'X-Sp-Forwarded-Ip'), + 8 => array('slug' => 'x_forwarded_by', 'name' => 'X-Client-Ip'), + 9 => array('slug' => 'sucury', 'name' => 'X-Sucuri-Clientip'), + 10 => array('slug' => 'ezoic', 'name' => 'X-Middleton-Ip'), + 11 => array('slug' => 'gtranslate', 'name' => 'X-Gt-Viewer-Ip'), + 12 => array('slug' => 'cloud_flare', 'name' => 'Cf-Connecting-Ip'), + 13 => array('slug' => 'ovh', 'name' => 'Remote-Ip'), + ); public static function get($ip_type_to_get = 'real', $headers = array(), $recursion = false) { global $spbc; - switch ((int) $spbc->settings['secfw__get_ip']) { - case 2: - $ip_type_to_get = 'remote_addr'; - break; - case 3: - $ip_type_to_get = 'x_forwarded_for'; - break; - case 4: - $ip_type_to_get = 'x_real_ip'; - break; - case 5: - $ip_type_to_get = 'incapsula'; - break; - case 6: - $ip_type_to_get = 'ico_x_forwarded_for'; - break; - case 7: - $ip_type_to_get = 'stackpath'; - break; - case 8: - $ip_type_to_get = 'x_forwarded_by'; - break; - case 9: - $ip_type_to_get = 'sucury'; - break; - case 10: - $ip_type_to_get = 'ezoic'; - break; - case 11: - $ip_type_to_get = 'gtranslate'; - break; - case 12: - $ip_type_to_get = 'cloud_flare'; - break; - case 13: - $ip_type_to_get = 'ovh'; - break; + if ($ip_type_to_get !== 'real' && $ip_type_to_get === 1) { + $ip_type_to_get = self::$known_headers[(int)$spbc->settings['secfw__get_ip']]['slug']; } return parent::get($ip_type_to_get, $headers, $recursion); } + + public static function getKnownCDNHeadersNames() + { + $result = array_map(function ($cdn_record_data) { + return $cdn_record_data['slug']; + }, self::$known_headers); + return $result; + } + + public static function getHeaderIDbySlug($slug = '') + { + foreach (self::$known_headers as $header_id => $header_data) { + if ($header_data['slug'] === $slug) { + return (string)($header_id); + } + } + return 'auto'; + } } diff --git a/lib/CleantalkSP/SpbctWP/State.php b/lib/CleantalkSP/SpbctWP/State.php index be0acc8d8..96c02abd7 100644 --- a/lib/CleantalkSP/SpbctWP/State.php +++ b/lib/CleantalkSP/SpbctWP/State.php @@ -90,6 +90,7 @@ class State extends \CleantalkSP\Common\State 'waf__exploit_check' => 1, 'waf_blocker__enabled' => 0, 'secfw__get_ip' => 1, + 'secfw__get_ip__disable_cdn_auto_self_check' => 0, // Data processing 'data__set_cookies' => 1, @@ -252,6 +253,8 @@ class State extends \CleantalkSP\Common\State // Insert api key (RC without token) 'post_api_key' => array('last_call' => 0,), + // CDN check + 'cdn_check' => array('last_call' => 0,), ); diff --git a/security-malware-firewall.php b/security-malware-firewall.php index 92a35fdd0..b6d007994 100644 --- a/security-malware-firewall.php +++ b/security-malware-firewall.php @@ -19,6 +19,8 @@ use CleantalkSP\SpbctWP\Firewall\WAF; use CleantalkSP\SpbctWP\Cron as SpbcCron; use CleantalkSP\SpbctWP\Firewall\WafBlocker; +use CleantalkSP\SpbctWP\HTTP\CDNHeadersChecker; +use CleantalkSP\SpbctWP\HTTP\Request; use CleantalkSP\SpbctWP\RemoteCalls as SpbcRemoteCalls; use CleantalkSP\SpbctWP\RenameLoginPage; use CleantalkSP\SpbctWP\Sanitize; @@ -565,6 +567,8 @@ function spbc_activation($network, $redirect = true) delete_option('spbc_deactivation_in_process'); } + spbc_cdn_check(); + $tables_analyzer = new \CleantalkSP\SpbctWP\DB\TablesAnalyzer(); foreach ( $tables_analyzer->getNotExistingTables() as $not_existing_table ) { $db_tables_creator = new \CleantalkSP\SpbctWP\DB\TablesCreator(); @@ -629,6 +633,7 @@ function spbc_activation($network, $redirect = true) SpbcCron::addTask('service_get', 'spbct_perform_service_get', 86400, time() + 3500); SpbcCron::addTask('security_log_clear', 'spbc_security_log_clear', 86400, time() + 43200); SpbcCron::addTask('get_brief_data', 'spbc_set_brief_data', 86400, time() + 1800); + SpbcCron::addTask('cdn_check', 'spbc_cdn_check', 86400, time() + 86400); if ( empty($spbc->errors['configuration']) ) { $scanner_launch_data = spbc_get_custom_scanner_launch_data(true); @@ -2282,3 +2287,11 @@ function spbc_is_amp_request() return false; } + +function spbc_cdn_check() +{ + global $spbc; + if (!$spbc->settings['secfw__get_ip__disable_cdn_auto_self_check']) { + CDNHeadersChecker::check(); + } +} From fba8f4729045ad74e180b8cfe08395095cb1b296 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Wed, 29 Nov 2023 14:18:33 +0500 Subject: [PATCH 05/67] Mod. Settings. Known headers taken from IP::$known_headers. --- inc/spbc-settings.php | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/inc/spbc-settings.php b/inc/spbc-settings.php index 6534830d4..c2a27ae34 100644 --- a/inc/spbc-settings.php +++ b/inc/spbc-settings.php @@ -5045,24 +5045,10 @@ function spbc_settings_field__secfw__get_ip__get_description() function spbc_settings_field__secfw__get_ip__get_labels() { - $available_header = array( - 2 => array('slug' => 'remote_addr', 'name' => 'Remote Addr'), - 3 => array('slug' => 'x_forwarded_for', 'name' => 'X-Forwarder-For'), - 4 => array('slug' => 'x_real_ip', 'name' => 'X-Real-Ip'), - 5 => array('slug' => 'incapsula', 'name' => 'Incap-Client-Ip'), - 6 => array('slug' => 'ico_x_forwarded_for', 'name' => 'Ico-X-Forwarded-For'), - 7 => array('slug' => 'stackpath', 'name' => 'X-Sp-Forwarded-Ip'), - 8 => array('slug' => 'x_forwarded_by', 'name' => 'X-Client-Ip'), - 9 => array('slug' => 'sucury', 'name' => 'X-Sucuri-Clientip'), - 10 => array('slug' => 'ezoic', 'name' => 'X-Middleton-Ip'), - 11 => array('slug' => 'gtranslate', 'name' => 'X-Gt-Viewer-Ip'), - 12 => array('slug' => 'cloud_flare', 'name' => 'Cf-Connecting-Ip'), - 13 => array('slug' => 'ovh', 'name' => 'Remote-Ip'), - ); $options = array(); $options[] = array('val' => 1, 'label' => __('Auto', 'security-malware-firewall'),); - foreach ( $available_header as $key => $header ) { + foreach ( IP::$known_headers as $key => $header ) { IP::get($header['slug'], [], true); $option_value = $header['name']; $option_value .= isset(IP::getInstance()->ips_stored[$header['slug']]) From e8512e2c1353dd3874a4c268f96d0a5d2ed56ca0 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Wed, 29 Nov 2023 14:34:57 +0500 Subject: [PATCH 06/67] New. RC implemented. --- .../SpbctWP/HTTP/CDNHeadersChecker.php | 36 ++++++++++++------- lib/CleantalkSP/SpbctWP/RemoteCalls.php | 11 ++++++ security-malware-firewall.php | 3 +- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php index df4043678..bb6fc7102 100644 --- a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php +++ b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php @@ -15,19 +15,31 @@ class CDNHeadersChecker public static function check() { global $spbc; - $old_setting = $spbc->settings['wp__use_builtin_http_api']; - $spbc->settings['wp__use_builtin_http_api'] = 0; - $self_url = is_multisite() ? get_blog_option(null, 'home') : get_option('home'); - $provided_headers = self::getResponseHeadersNames($self_url); - $known_cdn_headers = IP::getKnownCDNHeadersNames(); - $found_headers = self::findKnownCDNHeaders($provided_headers, $known_cdn_headers); - self::updateStoredCDNHeadersData($found_headers); - $last_check_headers = self::getLastCheckCDNHeaders(); - $new_header_id = self::getNewHeaderIdForSettings($spbc, $last_check_headers); - if ($new_header_id) { - self::applyIPGetHeadersSettings($spbc, $new_header_id); + $result = array( + 'found_headers' => null, + 'setting_changed_to' => null, + 'error' => null + ); + try { + $old_setting = $spbc->settings['wp__use_builtin_http_api']; + $spbc->settings['wp__use_builtin_http_api'] = 0; + $self_url = is_multisite() ? get_blog_option(null, 'home') : get_option('home'); + $provided_headers = self::getResponseHeadersNames($self_url); + $known_cdn_headers = IP::getKnownCDNHeadersNames(); + $found_headers = self::findKnownCDNHeaders($provided_headers, $known_cdn_headers); + $result['found_headers'] = $found_headers; + self::updateStoredCDNHeadersData($found_headers); + $last_check_headers = self::getLastCheckCDNHeaders(); + $new_header_id = self::getNewHeaderIdForSettings($spbc, $last_check_headers); + if ($new_header_id) { + $result['setting_changed_to'] = $new_header_id; + self::applyIPGetHeadersSettings($spbc, $new_header_id); + } + $spbc->settings['wp__use_builtin_http_api'] = $old_setting; + } catch (\Exception $e) { + $result['error'] = $e; } - $spbc->settings['wp__use_builtin_http_api'] = $old_setting; + return $result; } private static function getResponseHeadersNames($self_url) diff --git a/lib/CleantalkSP/SpbctWP/RemoteCalls.php b/lib/CleantalkSP/SpbctWP/RemoteCalls.php index a3458a71f..c4f2cd346 100644 --- a/lib/CleantalkSP/SpbctWP/RemoteCalls.php +++ b/lib/CleantalkSP/SpbctWP/RemoteCalls.php @@ -535,4 +535,15 @@ public static function action__update_pscan_statuses() // phpcs:ignore PSR1.Meth return json_encode(array('success' => false, 'result' => $e->getMessage())); } } + + public static function action__cdn_check() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps + { + $result_cdn_check = spbc_cdn_check(); + + die( + empty($result_cdn_check['error']) + ? 'OK ' . json_encode($result_cdn_check) + : 'FAIL ' . json_encode($result_cdn_check['error']) + ); + } } diff --git a/security-malware-firewall.php b/security-malware-firewall.php index b6d007994..5c2e5299f 100644 --- a/security-malware-firewall.php +++ b/security-malware-firewall.php @@ -2292,6 +2292,7 @@ function spbc_cdn_check() { global $spbc; if (!$spbc->settings['secfw__get_ip__disable_cdn_auto_self_check']) { - CDNHeadersChecker::check(); + return CDNHeadersChecker::check(); } + return array('error' => 'CDN checker disabled'); } From 7d9a57969561974de59552588124a5b62898e384 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Wed, 29 Nov 2023 14:51:49 +0500 Subject: [PATCH 07/67] Psalm/PHPunit/PHPCS fixes. --- inc/spbc-settings.php | 4 ++-- lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php | 8 ++++++-- lib/CleantalkSP/SpbctWP/Helpers/IP.php | 2 +- lib/CleantalkSP/SpbctWP/RemoteCalls.php | 4 ++++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/inc/spbc-settings.php b/inc/spbc-settings.php index c2a27ae34..2840607d2 100644 --- a/inc/spbc-settings.php +++ b/inc/spbc-settings.php @@ -1661,10 +1661,10 @@ function spbc_field_statistics() //cdn checker data - add_filter( 'safe_style_css', function( $styles ) { + add_filter('safe_style_css', function ($styles) { $styles[] = 'display'; return $styles; - } ); + }); echo Escape::escKsesPreset(CDNHeadersChecker::getSummaryBlockHTML(), 'spbc_cdn_checker_table'); echo '
'; diff --git a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php index bb6fc7102..8a4d5d8b4 100644 --- a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php +++ b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php @@ -23,7 +23,7 @@ public static function check() try { $old_setting = $spbc->settings['wp__use_builtin_http_api']; $spbc->settings['wp__use_builtin_http_api'] = 0; - $self_url = is_multisite() ? get_blog_option(null, 'home') : get_option('home'); + $self_url = is_multisite() ? get_blog_option(0, 'home') : get_option('home'); $provided_headers = self::getResponseHeadersNames($self_url); $known_cdn_headers = IP::getKnownCDNHeadersNames(); $found_headers = self::findKnownCDNHeaders($provided_headers, $known_cdn_headers); @@ -44,7 +44,11 @@ public static function check() private static function getResponseHeadersNames($self_url) { - return array_keys(HTTP::getHTTPHeaders()); + $http = new Request(); + return $http + ->setUrl($self_url) + ->setPresets('get_headers nocache') + ->request(); } private static function findKnownCDNHeaders($provided_headers, $known_cdn_headers) diff --git a/lib/CleantalkSP/SpbctWP/Helpers/IP.php b/lib/CleantalkSP/SpbctWP/Helpers/IP.php index f217bfc43..e14464eea 100644 --- a/lib/CleantalkSP/SpbctWP/Helpers/IP.php +++ b/lib/CleantalkSP/SpbctWP/Helpers/IP.php @@ -22,7 +22,7 @@ public static function get($ip_type_to_get = 'real', $headers = array(), $recurs { global $spbc; - if ($ip_type_to_get !== 'real' && $ip_type_to_get === 1) { + if ((int)$spbc->settings['secfw__get_ip'] !== 1) { $ip_type_to_get = self::$known_headers[(int)$spbc->settings['secfw__get_ip']]['slug']; } diff --git a/lib/CleantalkSP/SpbctWP/RemoteCalls.php b/lib/CleantalkSP/SpbctWP/RemoteCalls.php index c4f2cd346..7fd49430d 100644 --- a/lib/CleantalkSP/SpbctWP/RemoteCalls.php +++ b/lib/CleantalkSP/SpbctWP/RemoteCalls.php @@ -536,6 +536,10 @@ public static function action__update_pscan_statuses() // phpcs:ignore PSR1.Meth } } + /** + * Remote call spbc_cdn_check handler. + * @psalm-suppress PossiblyUnusedMethod + */ public static function action__cdn_check() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps { $result_cdn_check = spbc_cdn_check(); From 40c5c84902961d5d2ffecb43e82cca84062b5b14 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Wed, 29 Nov 2023 14:59:43 +0500 Subject: [PATCH 08/67] Fix. Header get. --- lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php index 8a4d5d8b4..897967ef7 100644 --- a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php +++ b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php @@ -54,7 +54,7 @@ private static function getResponseHeadersNames($self_url) private static function findKnownCDNHeaders($provided_headers, $known_cdn_headers) { $headers = array(); - foreach (array_keys($provided_headers) as $provided_header) { + foreach ($provided_headers as $provided_header) { $provided_header = strtolower($provided_header); foreach ($known_cdn_headers as $known_header) { if (stripos($provided_header, $known_header) !== false) { From e71298cc68a9513cdbeca46b1f484554a86e6a8b Mon Sep 17 00:00:00 2001 From: Glomberg Date: Thu, 30 Nov 2023 13:34:18 +0300 Subject: [PATCH 09/67] Fix. FireWall. Networks data selecting (SQL) fixed. --- lib/CleantalkSP/SpbctWP/Firewall/FW.php | 63 +++++++++---------------- 1 file changed, 23 insertions(+), 40 deletions(-) diff --git a/lib/CleantalkSP/SpbctWP/Firewall/FW.php b/lib/CleantalkSP/SpbctWP/Firewall/FW.php index b82bb0440..9f5871e57 100644 --- a/lib/CleantalkSP/SpbctWP/Firewall/FW.php +++ b/lib/CleantalkSP/SpbctWP/Firewall/FW.php @@ -118,8 +118,8 @@ public function check() 'ip' => $current_ip, 'is_personal' => $entry['is_personal'], 'country_code' => $entry['country_code'], - 'network' => $entry['network4'], - 'mask' => $entry['mask4'], + 'network' => $version === 'v4' ? $entry['network'] : $entry['network4'], + 'mask' => $version === 'v4' ? $entry['mask'] : $entry['mask4'], 'status' => $text_status, ) ); @@ -148,47 +148,28 @@ public function check() */ protected function ipv4GetResultsFromDb($ip) { - $current_ipv4s = IP::getFourIPv4FromIP($ip); - $needles = IP::getNetworkNeedles($current_ipv4s); + $current_ipv4 = sprintf('%u', ip2long($ip)); + $needles = IP::getNetworkNeedles([$current_ipv4]); + $data_table__common_v4 = $this->data_table__common . '_v4'; + $data_table__personal_v4 = $this->data_table__common . '_v4'; $query_ipv4 = '( - SELECT 0 AS is_personal, 1 AS is_ip, status, country_code, network1, network2, network3, network4, mask1, mask2, mask3, mask4 - FROM ' . $this->data_table__common . ' - WHERE - network1 IN (' . $needles[0] . ') - AND network2 IN (' . $needles[1] . ') - AND network3 IN (' . $needles[2] . ') - AND network4 IN (' . $needles[3] . ') - AND network1 = ' . $current_ipv4s[0] . ' & mask1 - AND network2 = ' . $current_ipv4s[1] . ' & mask2 - AND network3 = ' . $current_ipv4s[2] . ' & mask3 - AND network4 = ' . $current_ipv4s[3] . ' & mask4 + SELECT 0 AS is_personal, 1 AS is_ip, status, country_code, network, mask + FROM ' . $data_table__common_v4 . ' + WHERE network IN (' . current($needles) . ') + AND network = ' . $current_ipv4 . ' & mask AND country_code = "0" ) UNION ( - SELECT 1 AS is_personal, 1 AS is_ip, status, 0 AS country_code, network1, network2, network3, network4, mask1, mask2, mask3, mask4 - FROM ' . $this->data_table__personal . ' - WHERE - network1 IN (' . $needles[0] . ') - AND network2 IN (' . $needles[1] . ') - AND network3 IN (' . $needles[2] . ') - AND network4 IN (' . $needles[3] . ') - AND network1 = ' . $current_ipv4s[0] . ' & mask1 - AND network2 = ' . $current_ipv4s[1] . ' & mask2 - AND network3 = ' . $current_ipv4s[2] . ' & mask3 - AND network4 = ' . $current_ipv4s[3] . ' & mask4 + SELECT 1 AS is_personal, 1 AS is_ip, status, 0 AS country_code, network, mask + FROM ' . $data_table__personal_v4 . ' + WHERE network IN (' . current($needles) . ') + AND network = ' . $current_ipv4 . ' & mask ) UNION ( - SELECT 1 AS is_personal, 0 AS is_ip, tbl_private.status, country_code, network1, network2, network3, network4, mask1, mask2, mask3, mask4 + SELECT 1 AS is_personal, 0 AS is_ip, tbl_private.status, country_code, network, mask FROM ' . $this->data_table__personal_countries . ' AS tbl_private - RIGHT JOIN ' . $this->data_table__common . ' AS tbl_common USING(country_code) - WHERE - network1 IN (' . $needles[0] . ') - AND network2 IN (' . $needles[1] . ') - AND network3 IN (' . $needles[2] . ') - AND network4 IN (' . $needles[3] . ') - AND network1 = ' . $current_ipv4s[0] . ' & mask1 - AND network2 = ' . $current_ipv4s[1] . ' & mask2 - AND network3 = ' . $current_ipv4s[2] . ' & mask3 - AND network4 = ' . $current_ipv4s[3] . ' & mask4 + RIGHT JOIN ' . $data_table__common_v4 . ' AS tbl_common USING(country_code) + WHERE network IN (' . current($needles) . ') + AND network = ' . $current_ipv4 . ' & mask AND tbl_private.status IS NOT NULL AND ' . mt_rand(1, 100000) . ' <> 0 )'; @@ -207,10 +188,12 @@ protected function ipv4GetResultsFromDb($ip) protected function ipv6GetResultsFromDb($ip) { $needles = IP::getNetworkNeedles(IP::getFourIPv4FromIP($ip)); + $data_table__common_v6 = $this->data_table__common . '_v6'; + $data_table__personal_v6 = $this->data_table__common . '_v6'; $query_ipv6 = '( SELECT 0 AS is_personal, 1 AS is_ip, status, country_code, network1, network2, network3, network4, mask1, mask2, mask3, mask4 - FROM ' . $this->data_table__common . ' + FROM ' . $data_table__common_v6 . ' WHERE network1 IN (0,' . $needles[0] . ') AND network2 IN (0,' . $needles[1] . ') @@ -219,7 +202,7 @@ protected function ipv6GetResultsFromDb($ip) AND country_code = "0" ) UNION ( SELECT 1 AS is_personal, 1 AS is_ip, status, 0 AS country_code, network1, network2, network3, network4, mask1, mask2, mask3, mask4 - FROM ' . $this->data_table__personal . ' + FROM ' . $data_table__personal_v6 . ' WHERE network1 IN (0,' . $needles[0] . ') AND network2 IN (0,' . $needles[1] . ') @@ -228,7 +211,7 @@ protected function ipv6GetResultsFromDb($ip) ) UNION ( SELECT 1 AS is_personal, 0 AS is_ip, tbl_private.status, country_code, network1, network2, network3, network4, mask1, mask2, mask3, mask4 FROM ' . $this->data_table__personal_countries . ' AS tbl_private - RIGHT JOIN ' . $this->data_table__common . ' AS tbl_common USING(country_code) + RIGHT JOIN ' . $data_table__common_v6 . ' AS tbl_common USING(country_code) WHERE network1 IN (0,' . $needles[0] . ') AND network2 IN (0,' . $needles[1] . ') From 6fc699ff2228e3f7322d218d0ec977ae45192b1b Mon Sep 17 00:00:00 2001 From: Glomberg Date: Thu, 30 Nov 2023 14:40:32 +0300 Subject: [PATCH 10/67] Fix. FireWall. Stats tab - networks counts stored in the database fixed. --- inc/fw-update.php | 10 +++++++--- lib/CleantalkSP/SpbctWP/Firewall/FW.php | 18 +++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/inc/fw-update.php b/inc/fw-update.php index f1cd143f3..5d5072ca0 100644 --- a/inc/fw-update.php +++ b/inc/fw-update.php @@ -524,9 +524,13 @@ function spbc_security_firewall_update__end_of_update() $spbc->fw_stats['updating_last_start'] = 0; $spbc->fw_stats['last_updated'] = current_time('timestamp'); $spbc->fw_stats['is_on_maintenance'] = false; // Remove maintenance mode - $spbc->fw_stats['entries'] = - $wpdb->get_var('SELECT COUNT(*) FROM ' . SPBC_TBL_FIREWALL_DATA) + - $wpdb->get_var('SELECT COUNT(*) FROM ' . SPBC_TBL_FIREWALL_DATA__IPS); + + $sql_count_networks = "SELECT SUM(cnt) FROM ( + SELECT COUNT(*) as cnt FROM " . SPBC_TBL_FIREWALL_DATA_V4 . " + UNION SELECT COUNT(*) FROM " . SPBC_TBL_FIREWALL_DATA_V6 . " + UNION SELECT COUNT(*) FROM " . SPBC_TBL_FIREWALL_DATA__IPS_V4 . " + UNION SELECT COUNT(*) FROM " . SPBC_TBL_FIREWALL_DATA__IPS_V6 . ") cnt"; + $spbc->fw_stats['entries'] = $wpdb->get_var($sql_count_networks); $spbc->save('fw_stats', true, false); diff --git a/lib/CleantalkSP/SpbctWP/Firewall/FW.php b/lib/CleantalkSP/SpbctWP/Firewall/FW.php index 9f5871e57..5defbff52 100644 --- a/lib/CleantalkSP/SpbctWP/Firewall/FW.php +++ b/lib/CleantalkSP/SpbctWP/Firewall/FW.php @@ -150,8 +150,8 @@ protected function ipv4GetResultsFromDb($ip) { $current_ipv4 = sprintf('%u', ip2long($ip)); $needles = IP::getNetworkNeedles([$current_ipv4]); - $data_table__common_v4 = $this->data_table__common . '_v4'; - $data_table__personal_v4 = $this->data_table__common . '_v4'; + $data_table__common_v4 = SPBC_TBL_FIREWALL_DATA_V4; + $data_table__personal_v4 = SPBC_TBL_FIREWALL_DATA__IPS_V4; $query_ipv4 = '( SELECT 0 AS is_personal, 1 AS is_ip, status, country_code, network, mask @@ -188,8 +188,8 @@ protected function ipv4GetResultsFromDb($ip) protected function ipv6GetResultsFromDb($ip) { $needles = IP::getNetworkNeedles(IP::getFourIPv4FromIP($ip)); - $data_table__common_v6 = $this->data_table__common . '_v6'; - $data_table__personal_v6 = $this->data_table__common . '_v6'; + $data_table__common_v6 = SPBC_TBL_FIREWALL_DATA_V6; + $data_table__personal_v6 = SPBC_TBL_FIREWALL_DATA__IPS_V6; $query_ipv6 = '( SELECT 0 AS is_personal, 1 AS is_ip, status, country_code, network1, network2, network3, network4, mask1, mask2, mask3, mask4 @@ -913,9 +913,13 @@ public static function dataTablesClearUnusedCountriesDataFromMainTable($db) $in[] = "'" . current($country_code) . "'"; } - if ( - $db->execute('DELETE FROM ' . SPBC_TBL_FIREWALL_DATA . ' WHERE country_code NOT IN (' . implode(',', $in) . ')') === false - ) { + $delete_sql_v4 = "DELETE FROM " + . SPBC_TBL_FIREWALL_DATA_V4 . " + WHERE country_code NOT IN (" . implode(',', $in) . ")"; + $delete_sql_v6 = "DELETE FROM " + . SPBC_TBL_FIREWALL_DATA_V6 . " + WHERE country_code NOT IN (" . implode(',', $in) . ")"; + if ( $db->execute($delete_sql_v4) === false || $db->execute($delete_sql_v6) === false ) { return array('error' => 'CLEAR TABLE: CLEAR FAILS'); } From 274796d5858fbb22c65d83698f458ebbafd945fd Mon Sep 17 00:00:00 2001 From: Glomberg Date: Thu, 30 Nov 2023 14:46:55 +0300 Subject: [PATCH 11/67] Fix. Code. Code style fixed. --- lib/CleantalkSP/SpbctWP/Firewall/FW.php | 2 -- security-malware-firewall.php | 2 -- 2 files changed, 4 deletions(-) diff --git a/lib/CleantalkSP/SpbctWP/Firewall/FW.php b/lib/CleantalkSP/SpbctWP/Firewall/FW.php index 5defbff52..27b44fb94 100644 --- a/lib/CleantalkSP/SpbctWP/Firewall/FW.php +++ b/lib/CleantalkSP/SpbctWP/Firewall/FW.php @@ -15,8 +15,6 @@ class FW extends FirewallModule { public $module_name = 'FW'; - public $data_table__common = ''; - public $data_table__personal = ''; public $data_table__personal_countries = ''; /** diff --git a/security-malware-firewall.php b/security-malware-firewall.php index ff2d9ca60..75f241879 100644 --- a/security-malware-firewall.php +++ b/security-malware-firewall.php @@ -461,8 +461,6 @@ function spbc_firewall__check() $firewall->loadFwModule( new FW( array( - 'data_table__common' => SPBC_TBL_FIREWALL_DATA, - 'data_table__personal' => SPBC_TBL_FIREWALL_DATA__IPS, 'data_table__personal_countries' => SPBC_TBL_FIREWALL_DATA__COUNTRIES, 'log_table' => SPBC_TBL_FIREWALL_LOG, 'state' => $spbc, From 41e592fcf3a243b1b10636989b69ac538548fc22 Mon Sep 17 00:00:00 2001 From: Glomberg Date: Fri, 1 Dec 2023 10:50:31 +0300 Subject: [PATCH 12/67] Fix. FireWall. Updater implemented for new DB structures. --- lib/CleantalkSP/Updater/Updater.php | 7 ++++++- lib/CleantalkSP/Updater/UpdaterScripts.php | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/CleantalkSP/Updater/Updater.php b/lib/CleantalkSP/Updater/Updater.php index fd460e9b0..dec81fc69 100644 --- a/lib/CleantalkSP/Updater/Updater.php +++ b/lib/CleantalkSP/Updater/Updater.php @@ -70,7 +70,12 @@ public static function runUpdateScripts($current_version, $new_version) } } - if ( ! DB::getInstance()->execute('SELECT COUNT(*) FROM ' . SPBC_TBL_FIREWALL_DATA . ';')) { + $sql_count_networks = "SELECT SUM(cnt) FROM ( + SELECT COUNT(*) as cnt FROM " . SPBC_TBL_FIREWALL_DATA_V4 . " + UNION SELECT COUNT(*) FROM " . SPBC_TBL_FIREWALL_DATA_V6 . " + UNION SELECT COUNT(*) FROM " . SPBC_TBL_FIREWALL_DATA__IPS_V4 . " + UNION SELECT COUNT(*) FROM " . SPBC_TBL_FIREWALL_DATA__IPS_V6 . ") cnt"; + if ( ! DB::getInstance()->execute($sql_count_networks)) { spbc_security_firewall_update__init(); } } diff --git a/lib/CleantalkSP/Updater/UpdaterScripts.php b/lib/CleantalkSP/Updater/UpdaterScripts.php index c76ff8024..df5e558c5 100644 --- a/lib/CleantalkSP/Updater/UpdaterScripts.php +++ b/lib/CleantalkSP/Updater/UpdaterScripts.php @@ -1163,4 +1163,22 @@ public static function updateTo_2_121_1() //phpcs:ignore PSR1.Methods.CamelCapsM $spbc->settings['waf_blocker__enabled'] = 0; $spbc->save('settings'); } + public static function updateTo_2_123_1() //phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps + { + global $wpdb; + + if ( is_multisite() ) { + $initial_blog = get_current_blog_id(); + $blogs = array_keys($wpdb->get_results('SELECT blog_id FROM ' . $wpdb->blogs, OBJECT_K)); + // Deleting data from each blog + foreach ( $blogs as $blog ) { + switch_to_blog($blog); + $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'spbc_firewall__personal_ips'); + } + switch_to_blog($initial_blog); + } else { + $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'spbc_firewall__personal_ips'); + } + $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->base_prefix . 'spbc_firewall_data'); + } } From 1f807f44f60b3aa502df05f72768bcf864b6a0bb Mon Sep 17 00:00:00 2001 From: Glomberg Date: Tue, 5 Dec 2023 10:08:48 +0300 Subject: [PATCH 13/67] Version: 2.124.1-fix. --- security-malware-firewall.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security-malware-firewall.php b/security-malware-firewall.php index 63fb69f3a..f6de22401 100644 --- a/security-malware-firewall.php +++ b/security-malware-firewall.php @@ -5,7 +5,7 @@ Plugin URI: https://wordpress.org/plugins/security-malware-firewall/ Description: Security & Malware scan by CleanTalk to protect your website from online threats and viruses. IP/Country FireWall, Web application FireWall. Detailed stats and logs to have full control. Author: CleanTalk Security -Version: 2.124 +Version: 2.124.1-fix Author URI: https://cleantalk.org Text Domain: security-malware-firewall Domain Path: /i18n From dd8c6ccee90126e9242c689830b68c854b653214 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Tue, 5 Dec 2023 13:26:14 +0500 Subject: [PATCH 14/67] Fix. PHP 8.2 deprecated notice fixed (creation of dynamic property ::data__set_cookies) --- security-malware-firewall.php | 1 - 1 file changed, 1 deletion(-) diff --git a/security-malware-firewall.php b/security-malware-firewall.php index f6de22401..c6c06ecfe 100644 --- a/security-malware-firewall.php +++ b/security-malware-firewall.php @@ -464,7 +464,6 @@ function spbc_firewall__check() 'state' => $spbc, 'api_key' => $spbc->api_key, 'cookie_domain' => parse_url(get_option('home'), PHP_URL_HOST), - 'data__set_cookies' => $spbc->settings['data__set_cookies'], ) ) ); From 0402590c45c761e46177704a5e13270fb6ed4cc9 Mon Sep 17 00:00:00 2001 From: Glomberg Date: Thu, 7 Dec 2023 17:10:48 +0300 Subject: [PATCH 15/67] Fix. FireWall. `privateRecordsAdd`, `privateRecordsDelete` implemented for new DB structures. --- lib/CleantalkSP/SpbctWP/Firewall/FW.php | 177 ++++++++++++++++-------- security-malware-firewall.php | 5 - 2 files changed, 119 insertions(+), 63 deletions(-) diff --git a/lib/CleantalkSP/SpbctWP/Firewall/FW.php b/lib/CleantalkSP/SpbctWP/Firewall/FW.php index 27b44fb94..e998dfb34 100644 --- a/lib/CleantalkSP/SpbctWP/Firewall/FW.php +++ b/lib/CleantalkSP/SpbctWP/Firewall/FW.php @@ -924,7 +924,7 @@ public static function dataTablesClearUnusedCountriesDataFromMainTable($db) return true; } - public static function privateRecordsAdd(DB $db, $db__table__data, $metadata) + public static function privateRecordsAdd(DB $db, $metadata) { $added_count = 0; $updated_count = 0; @@ -932,66 +932,27 @@ public static function privateRecordsAdd(DB $db, $db__table__data, $metadata) $id_chunk = ''; - foreach ( $metadata as $_key => $row ) { - /** - * Set queries - */ - $query_duplicate_search = "SELECT id,status FROM " . $db__table__data . " WHERE - network1 = '" . $row['network'][0] . "' AND - network2 = '" . $row['network'][1] . "' AND - network3 = '" . $row['network'][2] . "' AND - network4 = '" . $row['network'][3] . "' AND - mask1 = '" . $row['mask'][1] . "' AND - mask2 = '" . $row['mask'][2] . "' AND - mask3 = '" . $row['mask'][3] . "' AND - mask4 = '" . $row['mask'][4] . "';"; - + foreach ( $metadata as $row ) { //find duplicate to use it on updating $has_duplicate = false; - $db_result = $db->fetch($query_duplicate_search); - if ( $db_result === false ) { - throw new \RuntimeException($db->getLastError()); - } + $duplicated_row = self::checkDuplicateItem($db, $row); //if the record is same - pass - if ( isset($db_result->status) && $db_result->status == $row['status'] ) { + if ( isset($duplicated_row['status']) && $duplicated_row['status'] == $row['status'] ) { $ignored_count++; continue; } //if duplicate found create a chunk - if ( isset($db_result->status) ) { - $id_chunk = "id ='" . $db_result->id . "',"; + if ( isset($duplicated_row['status']) && isset($duplicated_row['id']) ) { + $id_chunk = "id ='" . $duplicated_row['id'] . "',"; $has_duplicate = true; } - $query_insertion = "INSERT INTO " . $db__table__data . " SET - " . $id_chunk . " - network1 = '" . $row['network'][0] . "', - network2 = '" . $row['network'][1] . "', - network3 = '" . $row['network'][2] . "', - network4 = '" . $row['network'][3] . "', - mask1 = '" . $row['mask'][1] . "', - mask2 = '" . $row['mask'][2] . "', - mask3 = '" . $row['mask'][3] . "', - mask4 = '" . $row['mask'][4] . "', - status = '" . $row['status'] . "' - ON DUPLICATE KEY UPDATE - id = id, - network1 = network1, - network2 = network2, - network3 = network3, - network4 = network4, - mask1 = mask1, - mask2 = mask2, - mask3 = mask3, - mask4 = mask4, - status = '" . $row['status'] . "';"; + $insert_result = self::privateRecordAddDb($db, $row, $id_chunk); - //insertion - $db_result = $db->execute($query_insertion); - if ( $db_result === false ) { + if ( $insert_result === false ) { throw new \RuntimeException($db->getLastError()); } @@ -1007,21 +968,30 @@ public static function privateRecordsAdd(DB $db, $db__table__data, $metadata) ); } - public static function privateRecordsDelete(DB $db, $db__table__data, $metadata) + public static function privateRecordsDelete(DB $db, $metadata) { $success_count = 0; $ignored_count = 0; - foreach ( $metadata as $_key => $row ) { - $query = "DELETE FROM " . $db__table__data . " WHERE - network1 = '" . $row['network'][0] . "' AND - network2 = '" . $row['network'][1] . "' AND - network3 = '" . $row['network'][2] . "' AND - network4 = '" . $row['network'][3] . "' AND - mask1 = '" . $row['mask'][1] . "' AND - mask2 = '" . $row['mask'][2] . "' AND - mask3 = '" . $row['mask'][3] . "' AND - mask4 = '" . $row['mask'][4] . "';"; + foreach ( $metadata as $row ) { + if ( is_array($row['network']) ) { + // v6 + $query = "DELETE FROM " . SPBC_TBL_FIREWALL_DATA__IPS_V6 . " WHERE + network1 = '" . $row['network'][0] . "' AND + network2 = '" . $row['network'][1] . "' AND + network3 = '" . $row['network'][2] . "' AND + network4 = '" . $row['network'][3] . "' AND + mask1 = '" . $row['mask'][1] . "' AND + mask2 = '" . $row['mask'][2] . "' AND + mask3 = '" . $row['mask'][3] . "' AND + mask4 = '" . $row['mask'][4] . "';"; + } else { + // v4 + $query = "DELETE FROM " . SPBC_TBL_FIREWALL_DATA__IPS_V4 . " WHERE + network = '" . $row['network'] . "' AND + mask = '" . $row['mask'] . "';"; + } + $db_result = $db->execute($query); if ( $db_result === false ) { throw new \Exception($db->getLastError()); @@ -1037,4 +1007,95 @@ public static function privateRecordsDelete(DB $db, $db__table__data, $metadata) 'ignored' => $ignored_count ); } + + /** + * @param $row array Network item to check + * + * @return array + */ + private static function checkDuplicateItem($db, $row) + { + $output = []; + + if ( is_array($row['network']) ) { + // v6 + $query = "SELECT id,status FROM " . SPBC_TBL_FIREWALL_DATA__IPS_V6 . " WHERE + network1 = '" . $row['network'][0] . "' AND + network2 = '" . $row['network'][1] . "' AND + network3 = '" . $row['network'][2] . "' AND + network4 = '" . $row['network'][3] . "' AND + mask1 = '" . $row['mask'][1] . "' AND + mask2 = '" . $row['mask'][2] . "' AND + mask3 = '" . $row['mask'][3] . "' AND + mask4 = '" . $row['mask'][4] . "';"; + } else { + // v4 + $query = "SELECT id,status FROM " . SPBC_TBL_FIREWALL_DATA__IPS_V4 . " WHERE + network = '" . $row['network'] . "' AND + mask = '" . $row['mask'] . "';"; + } + + $db_result = $db->fetch($query); + if ( $db_result === false ) { + throw new \RuntimeException($db->getLastError()); + } + + if ( isset($db_result->status) ) { + $output['status'] = $db_result->status; + } + if ( isset($db_result->id) ) { + $output['id'] = $db_result->id; + } + return $output; + } + + /** + * @param $row array Network item to insert + * @param $id_chunk string|int id for duplicated row if it provided + * + * @return int + */ + private static function privateRecordAddDb($db, $row, $id_chunk) + { + if ( is_array($row['network']) ) { + // v6 + $query = "INSERT INTO " . SPBC_TBL_FIREWALL_DATA__IPS_V6 . " SET + " . $id_chunk . " + network1 = '" . $row['network'][0] . "', + network2 = '" . $row['network'][1] . "', + network3 = '" . $row['network'][2] . "', + network4 = '" . $row['network'][3] . "', + mask1 = '" . $row['mask'][1] . "', + mask2 = '" . $row['mask'][2] . "', + mask3 = '" . $row['mask'][3] . "', + mask4 = '" . $row['mask'][4] . "', + status = '" . $row['status'] . "' + ON DUPLICATE KEY UPDATE + id = id, + network1 = network1, + network2 = network2, + network3 = network3, + network4 = network4, + mask1 = mask1, + mask2 = mask2, + mask3 = mask3, + mask4 = mask4, + status = '" . $row['status'] . "';"; + } else { + // v4 + $query = "INSERT INTO " . SPBC_TBL_FIREWALL_DATA__IPS_V4 . " SET + " . $id_chunk . " + network = '" . $row['network'] . "', + mask = '" . $row['mask'] . "', + status = '" . $row['status'] . "' + ON DUPLICATE KEY UPDATE + id = id, + network = network, + mask = mask, + status = '" . $row['status'] . "';"; + } + + //insertion + return $db->execute($query); + } } diff --git a/security-malware-firewall.php b/security-malware-firewall.php index fb7c2686d..ded831acf 100644 --- a/security-malware-firewall.php +++ b/security-malware-firewall.php @@ -1172,9 +1172,6 @@ function spbct_sfw_private_records_handler($action, $test_data = null) $mask = $mask > 0 ? $mask : 0; } $metadata_assoc_array['mask'] = $masks; - } else { - $metadata_assoc_array['network'] = array(0, 0, 0, $metadata_assoc_array['network']); - $metadata_assoc_array['mask'] = array(null, 0, 0, 0, $metadata_assoc_array['mask']); } //all checks done, change on link @@ -1190,13 +1187,11 @@ function spbct_sfw_private_records_handler($action, $test_data = null) if ( $action === 'add' ) { $handler_output = FW::privateRecordsAdd( DB::getInstance(), - SPBC_TBL_FIREWALL_DATA__IPS, $metadata ); } elseif ( $action === 'delete' ) { $handler_output = FW::privateRecordsDelete( DB::getInstance(), - SPBC_TBL_FIREWALL_DATA__IPS, $metadata ); } else { From 28658ca82f8ee2aace3b8648089767d57328a192 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Tue, 5 Dec 2023 13:26:14 +0500 Subject: [PATCH 16/67] Fix. PHP 8.2 deprecated notice fixed (creation of dynamic property ::cookie_domain) --- security-malware-firewall.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/security-malware-firewall.php b/security-malware-firewall.php index f6de22401..95adf562b 100644 --- a/security-malware-firewall.php +++ b/security-malware-firewall.php @@ -463,8 +463,6 @@ function spbc_firewall__check() 'log_table' => SPBC_TBL_FIREWALL_LOG, 'state' => $spbc, 'api_key' => $spbc->api_key, - 'cookie_domain' => parse_url(get_option('home'), PHP_URL_HOST), - 'data__set_cookies' => $spbc->settings['data__set_cookies'], ) ) ); From d3b5e83308be7205a0dc38bb84b45cc5950dc836 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Sat, 9 Dec 2023 21:10:14 +0500 Subject: [PATCH 17/67] Code. Phpcs fix. --- inc/spbc-admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/spbc-admin.php b/inc/spbc-admin.php index 208a825d0..631ca713e 100644 --- a/inc/spbc-admin.php +++ b/inc/spbc-admin.php @@ -136,7 +136,7 @@ function spbc_admin_init() // Getting key for daughter blogs once if (!$spbc->is_mainsite && $spbc->ms__work_mode == 1 && $spbc->ms__hoster_api_key && $spbc->data['ms__key_tries'] < 3) { - $spbc->data['ms__key_tries'] ++; + $spbc->data['ms__key_tries']++; $spbc->save('data'); spbc_set_api_key(); } From 84b115ec455c6a209c01054c72037992bc93a290 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Tue, 12 Dec 2023 15:02:28 +0500 Subject: [PATCH 18/67] Mod. Ip::get(). Get automatic search if no IP provided in selected header. --- inc/spbc-settings.php | 5 +++++ lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php | 1 - lib/CleantalkSP/SpbctWP/Helpers/IP.php | 10 +++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/inc/spbc-settings.php b/inc/spbc-settings.php index 918afc369..250433357 100644 --- a/inc/spbc-settings.php +++ b/inc/spbc-settings.php @@ -543,6 +543,7 @@ function spbc_settings__register() 'options' => spbc_settings_field__secfw__get_ip__get_labels(), 'title' => __('Get visitors IP from additional headers', 'security-malware-firewall'), 'description' => spbc_settings_field__secfw__get_ip__get_description(), + 'long_description' => true, 'parent' => 'secfw__get_ip__cdn_auto_self_check' ), ), @@ -4739,6 +4740,10 @@ function spbc_settings__get_description() 'desc' => __('The file hash is in denied list. It means that the Security analysts have marked this file as critically dangerous early. We do recommend you to order the Security Audit service.', 'security-malware-firewall') ), + 'secfw__get_ip' => array( + 'title' => 'Get IP from additional headers', + 'desc' => __('If the source header is selected, the plugin will search IP address in this header. If nothing found there, the plugin will run automatic search for every known possible IP sources.', 'security-malware-firewall'), + ), 'no_description' => array( 'title' => esc_html($setting_id), 'desc' => __('No description provided yet for this item. We are sorry about this. Please, contact support@cleantalk.org for further help.', 'security-malware-firewall'), diff --git a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php index 897967ef7..6c4e62a84 100644 --- a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php +++ b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php @@ -2,7 +2,6 @@ namespace CleantalkSP\SpbctWP\HTTP; -use CleantalkSP\SpbctWP\Helpers\HTTP; use CleantalkSP\SpbctWP\Helpers\IP; use CleantalkSP\SpbctWP\State; diff --git a/lib/CleantalkSP/SpbctWP/Helpers/IP.php b/lib/CleantalkSP/SpbctWP/Helpers/IP.php index e14464eea..c1ef99cde 100644 --- a/lib/CleantalkSP/SpbctWP/Helpers/IP.php +++ b/lib/CleantalkSP/SpbctWP/Helpers/IP.php @@ -18,6 +18,7 @@ class IP extends \CleantalkSP\Common\Helpers\IP 12 => array('slug' => 'cloud_flare', 'name' => 'Cf-Connecting-Ip'), 13 => array('slug' => 'ovh', 'name' => 'Remote-Ip'), ); + public static function get($ip_type_to_get = 'real', $headers = array(), $recursion = false) { global $spbc; @@ -26,7 +27,14 @@ public static function get($ip_type_to_get = 'real', $headers = array(), $recurs $ip_type_to_get = self::$known_headers[(int)$spbc->settings['secfw__get_ip']]['slug']; } - return parent::get($ip_type_to_get, $headers, $recursion); + $ip_found = parent::get($ip_type_to_get, $headers, $recursion); + + //if not ip found in selected headers, return automatic search result ('real' state) + if ( empty($ip_found) ) { + $ip_found = parent::get('real', $headers, $recursion); + } + + return $ip_found; } public static function getKnownCDNHeadersNames() From 56ce5fd4c6c895fa4cdf53b7d1f8381e5a7d91c3 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Tue, 12 Dec 2023 17:47:37 +0500 Subject: [PATCH 19/67] Ref. Layout HTML logic rebuilt to template-like. --- inc/spbc-settings.php | 4 +- lib/CleantalkSP/SpbctWP/Escape.php | 14 +- .../SpbctWP/HTTP/CDNHeadersChecker.php | 134 ++++++++++-------- 3 files changed, 91 insertions(+), 61 deletions(-) diff --git a/inc/spbc-settings.php b/inc/spbc-settings.php index 250433357..d1b451e4a 100644 --- a/inc/spbc-settings.php +++ b/inc/spbc-settings.php @@ -4741,8 +4741,8 @@ function spbc_settings__get_description() as critically dangerous early. We do recommend you to order the Security Audit service.', 'security-malware-firewall') ), 'secfw__get_ip' => array( - 'title' => 'Get IP from additional headers', - 'desc' => __('If the source header is selected, the plugin will search IP address in this header. If nothing found there, the plugin will run automatic search for every known possible IP sources.', 'security-malware-firewall'), + 'title' => CDNHeadersChecker::getDescriptionLongTexts()['title'], + 'desc' => CDNHeadersChecker::getDescriptionLongTexts()['desc'], ), 'no_description' => array( 'title' => esc_html($setting_id), diff --git a/lib/CleantalkSP/SpbctWP/Escape.php b/lib/CleantalkSP/SpbctWP/Escape.php index 7a99a79b2..f163ca162 100644 --- a/lib/CleantalkSP/SpbctWP/Escape.php +++ b/lib/CleantalkSP/SpbctWP/Escape.php @@ -112,10 +112,18 @@ public static function escKsesPreset($string, $preset = null, $_allowed_protocol 'id' => true, 'style' => true, ), - 'tr' => array(), - 'th' => array(), + 'tr' => array( + 'class' => true, + 'style' => true, + ), + 'th' => array( + 'style' => true, + 'class' => true, + ), 'td' => array( - 'colspan' => true + 'colspan' => true, + 'style' => true, + 'class' => true, ), 'tbody' => true, 'div' => array() diff --git a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php index 6c4e62a84..12e798d5a 100644 --- a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php +++ b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php @@ -9,7 +9,7 @@ class CDNHeadersChecker { private static $current_cdn_check_result = array(); - private static $limit_of_cdn_records_to_keep = 3; + private static $limit_of_cdn_records_to_keep = 10; public static function check() { @@ -27,13 +27,13 @@ public static function check() $known_cdn_headers = IP::getKnownCDNHeadersNames(); $found_headers = self::findKnownCDNHeaders($provided_headers, $known_cdn_headers); $result['found_headers'] = $found_headers; - self::updateStoredCDNHeadersData($found_headers); $last_check_headers = self::getLastCheckCDNHeaders(); $new_header_id = self::getNewHeaderIdForSettings($spbc, $last_check_headers); if ($new_header_id) { $result['setting_changed_to'] = $new_header_id; self::applyIPGetHeadersSettings($spbc, $new_header_id); } + self::updateStoredCDNHeadersData($found_headers, $new_header_id); $spbc->settings['wp__use_builtin_http_api'] = $old_setting; } catch (\Exception $e) { $result['error'] = $e; @@ -80,8 +80,10 @@ private static function loadStoredCDNHeadersData() return unserialize($stored_cdn_headers_data); } - private static function updateStoredCDNHeadersData($found_headers) + private static function updateStoredCDNHeadersData($found_headers, $new_header_id) { + $new_header_id = !empty($new_header_id) ? $new_header_id : null; + self::$current_cdn_check_result = self::loadStoredCDNHeadersData(); if (is_array(self::$current_cdn_check_result)) { if (count(self::$current_cdn_check_result) >= self::$limit_of_cdn_records_to_keep) { @@ -91,7 +93,8 @@ private static function updateStoredCDNHeadersData($found_headers) self::$current_cdn_check_result[] = array( 'time' => time(), - 'found_cdn_headers' => $found_headers + 'found_cdn_headers' => $found_headers, + 'setting_changed_to' => $new_header_id, ); self::saveStoredCDNHeadersData(); @@ -142,66 +145,77 @@ private static function applyIPGetHeadersSettings(State $spbc, $new_header_id = public static function getSummaryBlockHTML() { global $spbc; + //collect data - $last_settings_change = array(); - if (!empty($spbc->data['secfw__get_ip__last_auto_set'])) { - $last_settings_change = unserialize($spbc->data['secfw__get_ip__last_auto_set']); - } $stored_checks_data = self::loadStoredCDNHeadersData(); - $header_slug_text = !empty($spbc->settings['secfw__get_ip']) - ? '' . IP::$known_headers[$spbc->settings['secfw__get_ip']]['slug'] . '' - : __('unknown statement', 'security_malware_firewall'); - //build layout - $html = '
'; - $html .= ''; - $html .= __('Automatic HTTP Headers Detection results (click to show)', 'security_malware_firewall'); - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - - //build rows + //build layout template rows + $rows = ''; foreach ($stored_checks_data as $check) { - $headers_text = !empty($check['found_cdn_headers']) + $__headers_text = !empty($check['found_cdn_headers']) ? __('Found headers:', 'security_malware_firewall') . ' ' . implode(',', $check['found_cdn_headers']) : __('No known CDN headers found', 'security_malware_firewall'); - $time_text = date('Y-m-d h:i:s', (int)($check['time'])); - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - } - - $html .= ''; - $html .= ' + + + + + '; } - $html .= ''; - $html .= ''; - - $html .= ''; - $html .= ''; - $html .= '
'; + //build text locales + $__header = __('Automatic HTTP Headers Detection results (click to show)', 'security_malware_firewall'); + $__check_result_h = __('Check result', 'security_malware_firewall'); + $__check_time_h = __('Check time', 'security_malware_firewall'); + $__source_changes = __('Source changes', 'security_malware_firewall'); + $__header_slug_text = !empty($spbc->settings['secfw__get_ip']) + ? '' . IP::$known_headers[$spbc->settings['secfw__get_ip']]['slug'] . '' + : __('unknown statement', 'security_malware_firewall'); + $__current_source = __("Current IP source is set to", 'security_malware_firewall') . ' ' . $__header_slug_text; + + //build template + $html = ' +
+ + ' . $__header . ' + + + + + + + + + ' . $rows . ' + + + + + + + + +
'; return $html; } @@ -210,4 +224,12 @@ public static function getDescriptionText() { return __('Enable this option to set IP address source manually. If disabled, the plugin will detect IP source via self-call. Stats can be seen on the "Summary" tab', 'security-malware-firewall'); } + + public static function getDescriptionLongTexts() + { + return array( + 'title' => __('Get IP from additional headers', 'security-malware-firewall'), + 'desc' => __('If the source header is selected, the plugin will search IP address in this header. If nothing found there, the plugin will run automatic search for every known possible IP sources.', 'security-malware-firewall'), + ); + } } From ea9c1b95193f8578f9c3166585d131ab95adcc8d Mon Sep 17 00:00:00 2001 From: alexandergull Date: Wed, 13 Dec 2023 10:19:20 +0500 Subject: [PATCH 20/67] Mod. Docs and refs. --- inc/spbc-settings.php | 8 +- .../SpbctWP/HTTP/CDNHeadersChecker.php | 129 +++++++++++++----- lib/CleantalkSP/SpbctWP/Helpers/IP.php | 53 +++++-- 3 files changed, 137 insertions(+), 53 deletions(-) diff --git a/inc/spbc-settings.php b/inc/spbc-settings.php index d1b451e4a..786f0a2c1 100644 --- a/inc/spbc-settings.php +++ b/inc/spbc-settings.php @@ -534,7 +534,7 @@ function spbc_settings__register() 'secfw__get_ip__disable_cdn_auto_self_check' => array( 'type' => 'field', 'title' => __('Disable automatic CDN headers checker', 'security-malware-firewall'), - 'description' => CDNHeadersChecker::getDescriptionText(), + 'description' => CDNHeadersChecker::getOptionDescriptionText(), 'children' => array('secfw__get_ip'), ), 'secfw__get_ip' => array( @@ -4741,8 +4741,8 @@ function spbc_settings__get_description() as critically dangerous early. We do recommend you to order the Security Audit service.', 'security-malware-firewall') ), 'secfw__get_ip' => array( - 'title' => CDNHeadersChecker::getDescriptionLongTexts()['title'], - 'desc' => CDNHeadersChecker::getDescriptionLongTexts()['desc'], + 'title' => IP::getOptionLongDescriptionArray()['title'], + 'desc' => IP::getOptionLongDescriptionArray()['desc'], ), 'no_description' => array( 'title' => esc_html($setting_id), @@ -5063,7 +5063,7 @@ function spbc_settings_field__secfw__get_ip__get_labels() $options = array(); $options[] = array('val' => 1, 'label' => __('Auto', 'security-malware-firewall'),); - foreach ( IP::$known_headers as $key => $header ) { + foreach (IP::$known_headers_collection as $key => $header ) { IP::get($header['slug'], [], true); $option_value = $header['name']; $option_value .= isset(IP::getInstance()->ips_stored[$header['slug']]) diff --git a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php index 12e798d5a..b8101fc42 100644 --- a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php +++ b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php @@ -7,10 +7,28 @@ class CDNHeadersChecker { + /** + * @var array + *
    + *
  • 'time' => time()
  • + *
  • 'found_cdn_headers' => $found_headers
  • + *
  • 'setting_changed_to' => $new_header_id
  • + *
+ */ private static $current_cdn_check_result = array(); + /** + * How much records we need to keep. + * @var int + */ private static $limit_of_cdn_records_to_keep = 10; + /** + * Main CDN headers self check logic. + * @return array 'found_headers' => null, + * 'setting_changed_to' => null, + * 'error' => null + */ public static function check() { global $spbc; @@ -23,17 +41,17 @@ public static function check() $old_setting = $spbc->settings['wp__use_builtin_http_api']; $spbc->settings['wp__use_builtin_http_api'] = 0; $self_url = is_multisite() ? get_blog_option(0, 'home') : get_option('home'); - $provided_headers = self::getResponseHeadersNames($self_url); + $provided_headers = self::getResponseHeaders($self_url); $known_cdn_headers = IP::getKnownCDNHeadersNames(); $found_headers = self::findKnownCDNHeaders($provided_headers, $known_cdn_headers); $result['found_headers'] = $found_headers; $last_check_headers = self::getLastCheckCDNHeaders(); - $new_header_id = self::getNewHeaderIdForSettings($spbc, $last_check_headers); - if ($new_header_id) { - $result['setting_changed_to'] = $new_header_id; - self::applyIPGetHeadersSettings($spbc, $new_header_id); + $new_spbc_setting_header_id = self::getNewHeaderIdForSettings($spbc->settings['secfw__get_ip'], $last_check_headers); + if ( $new_spbc_setting_header_id ) { + $result['setting_changed_to'] = $new_spbc_setting_header_id; + self::applyIPGetHeadersSettings($spbc, $new_spbc_setting_header_id); } - self::updateStoredCDNHeadersData($found_headers, $new_header_id); + self::updateStoredCDNHeadersData($found_headers, $new_spbc_setting_header_id); $spbc->settings['wp__use_builtin_http_api'] = $old_setting; } catch (\Exception $e) { $result['error'] = $e; @@ -41,22 +59,37 @@ public static function check() return $result; } - private static function getResponseHeadersNames($self_url) + /** + * Perform a new self-request and get its HTTP headers. + * @param string $self_url Url needs to be requested + * @return array Array of HTTP headers strings. + */ + private static function getResponseHeaders($self_url) { $http = new Request(); - return $http + $headers_array = $http ->setUrl($self_url) ->setPresets('get_headers nocache') ->request(); + if ( !is_array($headers_array) ) { + $headers_array = array(); + } + return $headers_array; } + /** + * Filter provided headers strings array to find known CDN headers. + * @param string[] $provided_headers provided headers strings array + * @param string[] $known_cdn_headers known CDN headers + * @return array matches + */ private static function findKnownCDNHeaders($provided_headers, $known_cdn_headers) { $headers = array(); foreach ($provided_headers as $provided_header) { $provided_header = strtolower($provided_header); foreach ($known_cdn_headers as $known_header) { - if (stripos($provided_header, $known_header) !== false) { + if ( stripos($provided_header, $known_header) !== false ) { $headers[] = $known_header; } } @@ -64,6 +97,10 @@ private static function findKnownCDNHeaders($provided_headers, $known_cdn_header return $headers; } + /** + * Save stored data to state->data. + * @return void + */ private static function saveStoredCDNHeadersData() { global $spbc; @@ -71,53 +108,75 @@ private static function saveStoredCDNHeadersData() $spbc->save('data'); } + /** + * Return stored data from state->data. + * @return array + */ private static function loadStoredCDNHeadersData() { global $spbc; $stored_cdn_headers_data = isset($spbc->data['allowed_cdn_headers_data']) ? $spbc->data['allowed_cdn_headers_data'] : array(); - return unserialize($stored_cdn_headers_data); + $result = unserialize($stored_cdn_headers_data); + return is_array($result) ? $result : array(); } - private static function updateStoredCDNHeadersData($found_headers, $new_header_id) + /** + * Update stored data to state->data. + * @param string[] $found_headers newly found headers + * @param string $new_spbc_setting_header_id if checker found a new CDN header and changed the setting, write it to the data + * @return void + */ + private static function updateStoredCDNHeadersData($found_headers, $new_spbc_setting_header_id = null) { - $new_header_id = !empty($new_header_id) ? $new_header_id : null; + $new_spbc_setting_header_id = !empty($new_spbc_setting_header_id) ? $new_spbc_setting_header_id : null; + //shift stored data to limit self::$current_cdn_check_result = self::loadStoredCDNHeadersData(); - if (is_array(self::$current_cdn_check_result)) { - if (count(self::$current_cdn_check_result) >= self::$limit_of_cdn_records_to_keep) { - array_shift(self::$current_cdn_check_result); - } + if ( count(self::$current_cdn_check_result) >= self::$limit_of_cdn_records_to_keep ) { + array_shift(self::$current_cdn_check_result); } + //add new item to the common results self::$current_cdn_check_result[] = array( 'time' => time(), 'found_cdn_headers' => $found_headers, - 'setting_changed_to' => $new_header_id, + 'setting_changed_to' => $new_spbc_setting_header_id, ); self::saveStoredCDNHeadersData(); } + /** + * Return CDN headers from last checker result. + * @return string[] + */ private static function getLastCheckCDNHeaders() { $data = self::loadStoredCDNHeadersData(); - if (count($data)) { + if ( count($data) ) { return !empty($data[count($data) - 1]['found_cdn_headers']) - ? $data[count($data) - 1]['found_cdn_headers'] + ? (array)$data[count($data) - 1]['found_cdn_headers'] : array(); } return array(); } - private static function getNewHeaderIdForSettings(State $spbc, $last_check_headers) + /** + * Returns the new CDN header ID from last check. If nothing found and current settings is not 2, then returns '2' (remote_addr). + * Returns null otherwise. + * @param string $current_get_ip_state + * @param string[] $last_check_headers + * @return string|null + */ + private static function getNewHeaderIdForSettings($current_get_ip_state, $last_check_headers) { $last_check_header = isset($last_check_headers[0]) ? $last_check_headers[0] : null; $new_header_id = null; - if (!$last_check_header) { + if ( !$last_check_header ) { //set remote addr (2) as source if nothing found - if (!isset($spbc->settings['secfw__get_ip']) || $spbc->settings['secfw__get_ip'] !== '2') { + if ( !isset($current_get_ip_state) || $current_get_ip_state !== '2' ) { $new_header_id = '2'; } } else { @@ -132,8 +191,8 @@ private static function applyIPGetHeadersSettings(State $spbc, $new_header_id = $spbc->data['secfw__get_ip__last_auto_set'] = serialize(array( 'time' => time(), 'header_id' => $new_header_id, - 'setting_name' => IP::$known_headers[$new_header_id]['name'], - 'header_slug' => IP::$known_headers[$new_header_id]['slug'], + 'setting_name' => IP::$known_headers_collection[$new_header_id]['name'], + 'header_slug' => IP::$known_headers_collection[$new_header_id]['slug'], )); $spbc->save('data'); @@ -142,6 +201,10 @@ private static function applyIPGetHeadersSettings(State $spbc, $new_header_id = return $spbc; } + /** + * Returns HTML code to draw CDN checker results block. + * @return string + */ public static function getSummaryBlockHTML() { global $spbc; @@ -157,7 +220,7 @@ public static function getSummaryBlockHTML() : __('No known CDN headers found', 'security_malware_firewall'); $__time_text = date('Y-m-d h:i:s', (int)($check['time'])); $__new_setting_state_text = !empty($check['setting_changed_to']) - ? __('Set new source to ', 'security_malware_firewall') . '' . IP::$known_headers[$check['setting_changed_to']]['slug'] . '' + ? __('Set new source to ', 'security_malware_firewall') . '' . IP::$known_headers_collection[$check['setting_changed_to']]['slug'] . '' : 'No changes'; $rows .= ' @@ -180,7 +243,7 @@ public static function getSummaryBlockHTML() $__check_time_h = __('Check time', 'security_malware_firewall'); $__source_changes = __('Source changes', 'security_malware_firewall'); $__header_slug_text = !empty($spbc->settings['secfw__get_ip']) - ? '' . IP::$known_headers[$spbc->settings['secfw__get_ip']]['slug'] . '' + ? '' . IP::$known_headers_collection[$spbc->settings['secfw__get_ip']]['slug'] . '' : __('unknown statement', 'security_malware_firewall'); $__current_source = __("Current IP source is set to", 'security_malware_firewall') . ' ' . $__header_slug_text; @@ -220,16 +283,12 @@ public static function getSummaryBlockHTML() return $html; } - public static function getDescriptionText() + /** + * Returns localized text for option description. + * @return string|null + */ + public static function getOptionDescriptionText() { return __('Enable this option to set IP address source manually. If disabled, the plugin will detect IP source via self-call. Stats can be seen on the "Summary" tab', 'security-malware-firewall'); } - - public static function getDescriptionLongTexts() - { - return array( - 'title' => __('Get IP from additional headers', 'security-malware-firewall'), - 'desc' => __('If the source header is selected, the plugin will search IP address in this header. If nothing found there, the plugin will run automatic search for every known possible IP sources.', 'security-malware-firewall'), - ); - } } diff --git a/lib/CleantalkSP/SpbctWP/Helpers/IP.php b/lib/CleantalkSP/SpbctWP/Helpers/IP.php index c1ef99cde..d3d5b7a6d 100644 --- a/lib/CleantalkSP/SpbctWP/Helpers/IP.php +++ b/lib/CleantalkSP/SpbctWP/Helpers/IP.php @@ -4,15 +4,19 @@ class IP extends \CleantalkSP\Common\Helpers\IP { - public static $known_headers = array( - 2 => array('slug' => 'remote_addr', 'name' => 'Remote Addr'), - 3 => array('slug' => 'x_forwarded_for', 'name' => 'X-Forwarder-For'), - 4 => array('slug' => 'x_real_ip', 'name' => 'X-Real-Ip'), - 5 => array('slug' => 'incapsula', 'name' => 'Incap-Client-Ip'), - 6 => array('slug' => 'ico_x_forwarded_for', 'name' => 'Ico-X-Forwarded-For'), - 7 => array('slug' => 'stackpath', 'name' => 'X-Sp-Forwarded-Ip'), - 8 => array('slug' => 'x_forwarded_by', 'name' => 'X-Client-Ip'), - 9 => array('slug' => 'sucury', 'name' => 'X-Sucuri-Clientip'), + /** + * Known headers collection array( (id=>(slug,name), id=>(slug,name), ...). + * @var array[] + */ + public static $known_headers_collection = array( + 2 => array('slug' => 'remote_addr', 'name' => 'Remote Addr'), + 3 => array('slug' => 'x_forwarded_for', 'name' => 'X-Forwarder-For'), + 4 => array('slug' => 'x_real_ip', 'name' => 'X-Real-Ip'), + 5 => array('slug' => 'incapsula', 'name' => 'Incap-Client-Ip'), + 6 => array('slug' => 'ico_x_forwarded_for', 'name' => 'Ico-X-Forwarded-For'), + 7 => array('slug' => 'stackpath', 'name' => 'X-Sp-Forwarded-Ip'), + 8 => array('slug' => 'x_forwarded_by', 'name' => 'X-Client-Ip'), + 9 => array('slug' => 'sucury', 'name' => 'X-Sucuri-Clientip'), 10 => array('slug' => 'ezoic', 'name' => 'X-Middleton-Ip'), 11 => array('slug' => 'gtranslate', 'name' => 'X-Gt-Viewer-Ip'), 12 => array('slug' => 'cloud_flare', 'name' => 'Cf-Connecting-Ip'), @@ -23,8 +27,8 @@ public static function get($ip_type_to_get = 'real', $headers = array(), $recurs { global $spbc; - if ((int)$spbc->settings['secfw__get_ip'] !== 1) { - $ip_type_to_get = self::$known_headers[(int)$spbc->settings['secfw__get_ip']]['slug']; + if ( (int)$spbc->settings['secfw__get_ip'] !== 1 ) { + $ip_type_to_get = self::$known_headers_collection[(int)$spbc->settings['secfw__get_ip']]['slug']; } $ip_found = parent::get($ip_type_to_get, $headers, $recursion); @@ -37,21 +41,42 @@ public static function get($ip_type_to_get = 'real', $headers = array(), $recurs return $ip_found; } + /** + * Returns list of known CDN headers names. + * @return string[] + */ public static function getKnownCDNHeadersNames() { $result = array_map(function ($cdn_record_data) { return $cdn_record_data['slug']; - }, self::$known_headers); + }, self::$known_headers_collection); return $result; } + /** + * Returns header ID by slug. + * @param string $slug + * @return string + */ public static function getHeaderIDbySlug($slug = '') { - foreach (self::$known_headers as $header_id => $header_data) { - if ($header_data['slug'] === $slug) { + foreach (self::$known_headers_collection as $header_id => $header_data) { + if ( $header_data['slug'] === $slug ) { return (string)($header_id); } } return 'auto'; } + + /** + * Returns array of localized strings for long option description. + * @return array + */ + public static function getOptionLongDescriptionArray() + { + return array( + 'title' => __('Get IP from additional headers', 'security-malware-firewall'), + 'desc' => __('If the source header is selected, the plugin will search IP address in this header. If nothing found there, the plugin will run automatic search for every known possible IP sources.', 'security-malware-firewall'), + ); + } } From 6d6ee69cbe5e2d594388da4c06f0b017665e5d2d Mon Sep 17 00:00:00 2001 From: alexandergull Date: Wed, 13 Dec 2023 12:32:27 +0500 Subject: [PATCH 21/67] New. Autotests. --- .../SpbctWP/HTTP/CDNHeadersChecker.php | 19 ++-- tests/Standalone/TestCDNChecker.php | 86 +++++++++++++++++++ 2 files changed, 98 insertions(+), 7 deletions(-) create mode 100644 tests/Standalone/TestCDNChecker.php diff --git a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php index b8101fc42..19863c0c6 100644 --- a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php +++ b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php @@ -64,7 +64,7 @@ public static function check() * @param string $self_url Url needs to be requested * @return array Array of HTTP headers strings. */ - private static function getResponseHeaders($self_url) + public static function getResponseHeaders($self_url) { $http = new Request(); $headers_array = $http @@ -83,12 +83,17 @@ private static function getResponseHeaders($self_url) * @param string[] $known_cdn_headers known CDN headers * @return array matches */ - private static function findKnownCDNHeaders($provided_headers, $known_cdn_headers) + public static function findKnownCDNHeaders($provided_headers, $known_cdn_headers) { $headers = array(); foreach ($provided_headers as $provided_header) { $provided_header = strtolower($provided_header); foreach ($known_cdn_headers as $known_header) { + if ( stripos($provided_header, $known_header) !== false ) { + $headers[] = $known_header; + break; + } + $provided_header = str_replace('-', '_', $provided_header); if ( stripos($provided_header, $known_header) !== false ) { $headers[] = $known_header; } @@ -117,7 +122,7 @@ private static function loadStoredCDNHeadersData() global $spbc; $stored_cdn_headers_data = isset($spbc->data['allowed_cdn_headers_data']) ? $spbc->data['allowed_cdn_headers_data'] - : array(); + : ''; $result = unserialize($stored_cdn_headers_data); return is_array($result) ? $result : array(); } @@ -128,7 +133,7 @@ private static function loadStoredCDNHeadersData() * @param string $new_spbc_setting_header_id if checker found a new CDN header and changed the setting, write it to the data * @return void */ - private static function updateStoredCDNHeadersData($found_headers, $new_spbc_setting_header_id = null) + public static function updateStoredCDNHeadersData($found_headers, $new_spbc_setting_header_id = null) { $new_spbc_setting_header_id = !empty($new_spbc_setting_header_id) ? $new_spbc_setting_header_id : null; @@ -152,7 +157,7 @@ private static function updateStoredCDNHeadersData($found_headers, $new_spbc_set * Return CDN headers from last checker result. * @return string[] */ - private static function getLastCheckCDNHeaders() + public static function getLastCheckCDNHeaders() { $data = self::loadStoredCDNHeadersData(); if ( count($data) ) { @@ -170,7 +175,7 @@ private static function getLastCheckCDNHeaders() * @param string[] $last_check_headers * @return string|null */ - private static function getNewHeaderIdForSettings($current_get_ip_state, $last_check_headers) + public static function getNewHeaderIdForSettings($current_get_ip_state, $last_check_headers) { $last_check_header = isset($last_check_headers[0]) ? $last_check_headers[0] : null; $new_header_id = null; @@ -186,7 +191,7 @@ private static function getNewHeaderIdForSettings($current_get_ip_state, $last_c return $new_header_id; } - private static function applyIPGetHeadersSettings(State $spbc, $new_header_id = null) + public static function applyIPGetHeadersSettings(State $spbc, $new_header_id = null) { $spbc->data['secfw__get_ip__last_auto_set'] = serialize(array( 'time' => time(), diff --git a/tests/Standalone/TestCDNChecker.php b/tests/Standalone/TestCDNChecker.php new file mode 100644 index 000000000..4dd17968c --- /dev/null +++ b/tests/Standalone/TestCDNChecker.php @@ -0,0 +1,86 @@ +assertEquals($result['found_headers'], array()); + $this->assertEquals($result['setting_changed_to'], '2'); + $this->assertEquals($result['error'], null); + } + + public function testGetResponseHeaders() + { + global $spbc; + $spbc->settings['wp__use_builtin_http_api'] = 0; + $self_url = is_multisite() ? get_blog_option(0, 'home') : get_option('home'); + $provided_headers = CDNHeadersChecker::getResponseHeaders($self_url); + $this->assertTrue(is_array($provided_headers)); + $this->assertTrue(!empty($provided_headers)); + } + + public function testIPKnownCDNHeaders() + { + $result = IP::getKnownCDNHeadersNames(); + $this->assertTrue(is_array($result)); + $this->assertTrue(!empty($result)); + $this->assertEquals(count($result), count(IP::$known_headers_collection)); + } + + public function testFindCDNHeaders() + { + $known_headers = IP::getKnownCDNHeadersNames(); + + //empty + $provided_headers = array(); + $result = CDNHeadersChecker::findKnownCDNHeaders($provided_headers, $known_headers); + $this->assertTrue(is_array($result)); + $this->assertTrue(empty($result)); + + //x-forwarded-for + $provided_headers = array('X-Forwarded-for: 122.11.22.33'); + $result = CDNHeadersChecker::findKnownCDNHeaders($provided_headers, $known_headers); + $this->assertTrue(is_array($result)); + $this->assertTrue(!empty($result)); + + $last_check_headers = CDNHeadersChecker::getLastCheckCDNHeaders(); + $this->assertTrue(is_array($last_check_headers)); + $this->assertTrue(empty($last_check_headers)); + + CDNHeadersChecker::updateStoredCDNHeadersData($result); + + $last_check_headers = CDNHeadersChecker::getLastCheckCDNHeaders(); + $this->assertTrue(is_array($last_check_headers)); + $this->assertTrue(!empty($last_check_headers)); + $this->assertEquals($last_check_headers[0], 'x_forwarded_for'); + } + + public function testApplyIPGetHeadersSettings() + { + global $spbc; + $known_headers = IP::getKnownCDNHeadersNames(); + + //x-forwarded-for + $provided_headers = array('X-Forwarded-for: 122.11.22.33'); + $result = CDNHeadersChecker::findKnownCDNHeaders($provided_headers, $known_headers); + CDNHeadersChecker::updateStoredCDNHeadersData($result); + $last_check_headers = CDNHeadersChecker::getLastCheckCDNHeaders(); + $spbc->settings['secfw__get_ip'] = '8'; + $new_header_id = CDNHeadersChecker::getNewHeaderIdForSettings($spbc->settings['secfw__get_ip'], $last_check_headers); + $this->assertEquals($new_header_id, '3'); + CDNHeadersChecker::applyIPGetHeadersSettings($spbc, $new_header_id); + $this->assertEquals($spbc->settings['secfw__get_ip'], '3'); + } +} From 7d8a582e1c3f269278f1bc2f056f05cd1e550ec4 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Wed, 13 Dec 2023 20:35:28 +0500 Subject: [PATCH 22/67] Mod. Now use request check neither response check. --- lib/CleantalkSP/Common/HTTP/Request.php | 19 -------- .../SpbctWP/HTTP/CDNHeadersChecker.php | 48 +++++++------------ lib/CleantalkSP/SpbctWP/Helpers/IP.php | 20 ++++++-- lib/CleantalkSP/SpbctWP/RemoteCalls.php | 2 +- security-malware-firewall.php | 25 ++++++++-- tests/Standalone/TestCDNChecker.php | 29 +++-------- 6 files changed, 60 insertions(+), 83 deletions(-) diff --git a/lib/CleantalkSP/Common/HTTP/Request.php b/lib/CleantalkSP/Common/HTTP/Request.php index 54cecbf65..ce22e617a 100644 --- a/lib/CleantalkSP/Common/HTTP/Request.php +++ b/lib/CleantalkSP/Common/HTTP/Request.php @@ -446,7 +446,6 @@ protected function processPresets() $this->options[CURLOPT_FOLLOWLOCATION] = false; $this->options[CURLOPT_MAXREDIRS] = 0; break; - // Get headers only case 'get_code': $this->options[CURLOPT_HEADER] = true; $this->options[CURLOPT_NOBODY] = true; @@ -459,24 +458,6 @@ static function (Response $response) { true ); break; - case 'get_headers': - $this->options[CURLOPT_HEADER] = true; - $this->options[CURLOPT_NOBODY] = true; - $this->addCallback( - static function (Response $response) { - if (is_string($response->getContentRaw())) { - preg_match_all("/.+\S/i", $response->getContentRaw(), $matches); - return $matches[0]; - } else { - return $response; - } - }, - array(), - 60, - true - ); - break; - // Get headers only case 'split_to_array': $this->addCallback( static function ($response_content) { diff --git a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php index 19863c0c6..30cbedf87 100644 --- a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php +++ b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php @@ -2,7 +2,9 @@ namespace CleantalkSP\SpbctWP\HTTP; +use CleantalkSP\Common\Helpers\HTTP; use CleantalkSP\SpbctWP\Helpers\IP; +use CleantalkSP\SpbctWP\RemoteCalls; use CleantalkSP\SpbctWP\State; class CDNHeadersChecker @@ -38,12 +40,9 @@ public static function check() 'error' => null ); try { - $old_setting = $spbc->settings['wp__use_builtin_http_api']; - $spbc->settings['wp__use_builtin_http_api'] = 0; - $self_url = is_multisite() ? get_blog_option(0, 'home') : get_option('home'); - $provided_headers = self::getResponseHeaders($self_url); + $provided_headers = array_keys(HTTP::getHTTPHeaders()); $known_cdn_headers = IP::getKnownCDNHeadersNames(); - $found_headers = self::findKnownCDNHeaders($provided_headers, $known_cdn_headers); + $found_headers = self::findKnownCDNHeaderSlugs($provided_headers, $known_cdn_headers); $result['found_headers'] = $found_headers; $last_check_headers = self::getLastCheckCDNHeaders(); $new_spbc_setting_header_id = self::getNewHeaderIdForSettings($spbc->settings['secfw__get_ip'], $last_check_headers); @@ -52,54 +51,41 @@ public static function check() self::applyIPGetHeadersSettings($spbc, $new_spbc_setting_header_id); } self::updateStoredCDNHeadersData($found_headers, $new_spbc_setting_header_id); - $spbc->settings['wp__use_builtin_http_api'] = $old_setting; } catch (\Exception $e) { - $result['error'] = $e; + $result['error'] = $e->getMessage(); } return $result; } - /** - * Perform a new self-request and get its HTTP headers. - * @param string $self_url Url needs to be requested - * @return array Array of HTTP headers strings. - */ - public static function getResponseHeaders($self_url) + public static function sendCDNCheckerRequest() { - $http = new Request(); - $headers_array = $http - ->setUrl($self_url) - ->setPresets('get_headers nocache') - ->request(); - if ( !is_array($headers_array) ) { - $headers_array = array(); - } - return $headers_array; + return RemoteCalls::performToHost( + 'cdn_check', + array(), + array('async', 'get') + ); } /** - * Filter provided headers strings array to find known CDN headers. + * Filter provided headers strings array to find known CDN headers slugs. * @param string[] $provided_headers provided headers strings array * @param string[] $known_cdn_headers known CDN headers * @return array matches */ - public static function findKnownCDNHeaders($provided_headers, $known_cdn_headers) + public static function findKnownCDNHeaderSlugs($provided_headers, $known_cdn_headers) { - $headers = array(); + $slugs = array(); foreach ($provided_headers as $provided_header) { $provided_header = strtolower($provided_header); foreach ($known_cdn_headers as $known_header) { + $known_header = strtolower($known_header); if ( stripos($provided_header, $known_header) !== false ) { - $headers[] = $known_header; + $slugs[] = IP::getHeaderSlugByName($known_header); break; } - $provided_header = str_replace('-', '_', $provided_header); - if ( stripos($provided_header, $known_header) !== false ) { - $headers[] = $known_header; - } } } - return $headers; + return $slugs; } /** diff --git a/lib/CleantalkSP/SpbctWP/Helpers/IP.php b/lib/CleantalkSP/SpbctWP/Helpers/IP.php index d3d5b7a6d..4dac60d91 100644 --- a/lib/CleantalkSP/SpbctWP/Helpers/IP.php +++ b/lib/CleantalkSP/SpbctWP/Helpers/IP.php @@ -10,7 +10,7 @@ class IP extends \CleantalkSP\Common\Helpers\IP */ public static $known_headers_collection = array( 2 => array('slug' => 'remote_addr', 'name' => 'Remote Addr'), - 3 => array('slug' => 'x_forwarded_for', 'name' => 'X-Forwarder-For'), + 3 => array('slug' => 'x_forwarded_for', 'name' => 'X-Forwarded-For'), 4 => array('slug' => 'x_real_ip', 'name' => 'X-Real-Ip'), 5 => array('slug' => 'incapsula', 'name' => 'Incap-Client-Ip'), 6 => array('slug' => 'ico_x_forwarded_for', 'name' => 'Ico-X-Forwarded-For'), @@ -48,7 +48,7 @@ public static function get($ip_type_to_get = 'real', $headers = array(), $recurs public static function getKnownCDNHeadersNames() { $result = array_map(function ($cdn_record_data) { - return $cdn_record_data['slug']; + return $cdn_record_data['name']; }, self::$known_headers_collection); return $result; } @@ -56,16 +56,26 @@ public static function getKnownCDNHeadersNames() /** * Returns header ID by slug. * @param string $slug - * @return string + * @return string|null */ public static function getHeaderIDbySlug($slug = '') { foreach (self::$known_headers_collection as $header_id => $header_data) { if ( $header_data['slug'] === $slug ) { - return (string)($header_id); + return (string)$header_id; } } - return 'auto'; + return null; + } + + public static function getHeaderSlugByName($name = '') + { + foreach (self::$known_headers_collection as $_header_id => $header_data) { + if ( strtolower($header_data['name']) === strtolower($name) ) { + return (string)($header_data['slug']); + } + } + return ''; } /** diff --git a/lib/CleantalkSP/SpbctWP/RemoteCalls.php b/lib/CleantalkSP/SpbctWP/RemoteCalls.php index 7fd49430d..d302b1711 100644 --- a/lib/CleantalkSP/SpbctWP/RemoteCalls.php +++ b/lib/CleantalkSP/SpbctWP/RemoteCalls.php @@ -542,7 +542,7 @@ public static function action__update_pscan_statuses() // phpcs:ignore PSR1.Meth */ public static function action__cdn_check() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps { - $result_cdn_check = spbc_cdn_check(); + $result_cdn_check = spbc_cdn_checker__parse_request(); die( empty($result_cdn_check['error']) diff --git a/security-malware-firewall.php b/security-malware-firewall.php index 673421deb..2a1c2d152 100644 --- a/security-malware-firewall.php +++ b/security-malware-firewall.php @@ -5,7 +5,7 @@ Plugin URI: https://wordpress.org/plugins/security-malware-firewall/ Description: Security & Malware scan by CleanTalk to protect your website from online threats and viruses. IP/Country FireWall, Web application FireWall. Detailed stats and logs to have full control. Author: CleanTalk Security -Version: 2.124.1-dev +Version: 2.124.3-dev Author URI: https://cleantalk.org Text Domain: security-malware-firewall Domain Path: /i18n @@ -566,7 +566,7 @@ function spbc_activation($network, $redirect = true) delete_option('spbc_deactivation_in_process'); } - spbc_cdn_check(); + CDNHeadersChecker::sendCDNCheckerRequest(); $tables_analyzer = new \CleantalkSP\SpbctWP\DB\TablesAnalyzer(); foreach ( $tables_analyzer->getNotExistingTables() as $not_existing_table ) { @@ -632,7 +632,7 @@ function spbc_activation($network, $redirect = true) SpbcCron::addTask('service_get', 'spbct_perform_service_get', 86400, time() + 3500); SpbcCron::addTask('security_log_clear', 'spbc_security_log_clear', 86400, time() + 43200); SpbcCron::addTask('get_brief_data', 'spbc_set_brief_data', 86400, time() + 1800); - SpbcCron::addTask('cdn_check', 'spbc_cdn_check', 86400, time() + 86400); + SpbcCron::addTask('cdn_check', 'spbc_cdn_checker__send_request', 86400, time() + 86400); if ( empty($spbc->errors['configuration']) ) { $scanner_launch_data = spbc_get_custom_scanner_launch_data(true); @@ -2287,7 +2287,11 @@ function spbc_is_amp_request() return false; } -function spbc_cdn_check() +/** + * Parse CDN checker self-request to find CDN headers. + * @return array|null[]|string[] + */ +function spbc_cdn_checker__parse_request() { global $spbc; if (!$spbc->settings['secfw__get_ip__disable_cdn_auto_self_check']) { @@ -2295,3 +2299,16 @@ function spbc_cdn_check() } return array('error' => 'CDN checker disabled'); } + +/** + * Send test request to host. Then it should be parsed to find CDN headers. + * @return void + * @psalm-suppress + */ +function spbc_cdn_checker__send_request() +{ + global $spbc; + if (!$spbc->settings['secfw__get_ip__disable_cdn_auto_self_check']) { + CDNHeadersChecker::sendCDNCheckerRequest(); + } +} diff --git a/tests/Standalone/TestCDNChecker.php b/tests/Standalone/TestCDNChecker.php index 4dd17968c..f13746721 100644 --- a/tests/Standalone/TestCDNChecker.php +++ b/tests/Standalone/TestCDNChecker.php @@ -5,30 +5,13 @@ class TestCDNChecker extends PHPUnit\Framework\TestCase { - protected $bfp; - protected $db; - - protected function setUp() - { - global $spbc; - } public function testCommonCheck() { $result = CDNHeadersChecker::check(); $this->assertEquals($result['found_headers'], array()); $this->assertEquals($result['setting_changed_to'], '2'); - $this->assertEquals($result['error'], null); - } - - public function testGetResponseHeaders() - { - global $spbc; - $spbc->settings['wp__use_builtin_http_api'] = 0; - $self_url = is_multisite() ? get_blog_option(0, 'home') : get_option('home'); - $provided_headers = CDNHeadersChecker::getResponseHeaders($self_url); - $this->assertTrue(is_array($provided_headers)); - $this->assertTrue(!empty($provided_headers)); + $this->assertEquals($result['error'], null, is_string($result['error']) ? $result['error'] : 'OK'); } public function testIPKnownCDNHeaders() @@ -45,13 +28,13 @@ public function testFindCDNHeaders() //empty $provided_headers = array(); - $result = CDNHeadersChecker::findKnownCDNHeaders($provided_headers, $known_headers); + $result = CDNHeadersChecker::findKnownCDNHeaderSlugs($provided_headers, $known_headers); $this->assertTrue(is_array($result)); $this->assertTrue(empty($result)); //x-forwarded-for - $provided_headers = array('X-Forwarded-for: 122.11.22.33'); - $result = CDNHeadersChecker::findKnownCDNHeaders($provided_headers, $known_headers); + $provided_headers = array('X-Forwarded-For'); + $result = CDNHeadersChecker::findKnownCDNHeaderSlugs($provided_headers, $known_headers); $this->assertTrue(is_array($result)); $this->assertTrue(!empty($result)); @@ -73,8 +56,8 @@ public function testApplyIPGetHeadersSettings() $known_headers = IP::getKnownCDNHeadersNames(); //x-forwarded-for - $provided_headers = array('X-Forwarded-for: 122.11.22.33'); - $result = CDNHeadersChecker::findKnownCDNHeaders($provided_headers, $known_headers); + $provided_headers = array('X-Forwarded-For'); + $result = CDNHeadersChecker::findKnownCDNHeaderSlugs($provided_headers, $known_headers); CDNHeadersChecker::updateStoredCDNHeadersData($result); $last_check_headers = CDNHeadersChecker::getLastCheckCDNHeaders(); $spbc->settings['secfw__get_ip'] = '8'; From 76328f4eac8f91068bb07e343cf515a0b208b177 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Wed, 13 Dec 2023 20:46:55 +0500 Subject: [PATCH 23/67] Fix. After dev merge. --- lib/CleantalkSP/SpbctWP/Activator.php | 3 +++ security-malware-firewall.php | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/CleantalkSP/SpbctWP/Activator.php b/lib/CleantalkSP/SpbctWP/Activator.php index 899d18e69..056f512f6 100644 --- a/lib/CleantalkSP/SpbctWP/Activator.php +++ b/lib/CleantalkSP/SpbctWP/Activator.php @@ -3,6 +3,7 @@ namespace CleantalkSP\SpbctWP; use CleantalkSP\SpbctWP\Cron as SpbcCron; +use CleantalkSP\SpbctWP\HTTP\CDNHeadersChecker; class Activator { @@ -17,6 +18,8 @@ public static function activation($network, $redirect = true) { global $wpdb, $spbc; + CDNHeadersChecker::sendCDNCheckerRequest(); + if ( current_action() !== 'wp_insert_site' ) { delete_option('spbc_deactivation_in_process'); } diff --git a/security-malware-firewall.php b/security-malware-firewall.php index d25ddc34b..8ef24953a 100644 --- a/security-malware-firewall.php +++ b/security-malware-firewall.php @@ -21,7 +21,6 @@ use CleantalkSP\SpbctWP\Cron as SpbcCron; use CleantalkSP\SpbctWP\Firewall\WafBlocker; use CleantalkSP\SpbctWP\HTTP\CDNHeadersChecker; -use CleantalkSP\SpbctWP\HTTP\Request; use CleantalkSP\SpbctWP\RemoteCalls as SpbcRemoteCalls; use CleantalkSP\SpbctWP\RenameLoginPage; use CleantalkSP\SpbctWP\Sanitize; From 7c56c44aa8038e09782e9cc1e2b1a25dc4e78893 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Thu, 14 Dec 2023 13:06:01 +0500 Subject: [PATCH 24/67] New logic to filter known CDN headers from other (like x-forwarded-for) --- .../SpbctWP/HTTP/CDNHeadersChecker.php | 80 ++++++++++++------- tests/Standalone/TestCDNChecker.php | 55 ++++++++++--- 2 files changed, 95 insertions(+), 40 deletions(-) diff --git a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php index 30cbedf87..6ec1ef904 100644 --- a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php +++ b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php @@ -40,17 +40,21 @@ public static function check() 'error' => null ); try { - $provided_headers = array_keys(HTTP::getHTTPHeaders()); + $provided_headers = array(); + foreach (HTTP::getHTTPHeaders() as $header => $value) { + if (!empty($value) && IP::validate($value)) { + $provided_headers[] = $header; + } + } $known_cdn_headers = IP::getKnownCDNHeadersNames(); - $found_headers = self::findKnownCDNHeaderSlugs($provided_headers, $known_cdn_headers); - $result['found_headers'] = $found_headers; - $last_check_headers = self::getLastCheckCDNHeaders(); - $new_spbc_setting_header_id = self::getNewHeaderIdForSettings($spbc->settings['secfw__get_ip'], $last_check_headers); + $found_headers_slugs = self::findKnownCDNHeaderSlugs($provided_headers, $known_cdn_headers); + $result['found_headers'] = $found_headers_slugs; + $new_spbc_setting_header_id = self::getNewHeaderIdForSettings($spbc->settings['secfw__get_ip'], $found_headers_slugs); if ( $new_spbc_setting_header_id ) { $result['setting_changed_to'] = $new_spbc_setting_header_id; self::applyIPGetHeadersSettings($spbc, $new_spbc_setting_header_id); } - self::updateStoredCDNHeadersData($found_headers, $new_spbc_setting_header_id); + self::updateStoredCDNHeadersData($found_headers_slugs, $new_spbc_setting_header_id); } catch (\Exception $e) { $result['error'] = $e->getMessage(); } @@ -103,7 +107,7 @@ private static function saveStoredCDNHeadersData() * Return stored data from state->data. * @return array */ - private static function loadStoredCDNHeadersData() + public static function loadStoredCDNHeadersData() { global $spbc; $stored_cdn_headers_data = isset($spbc->data['allowed_cdn_headers_data']) @@ -140,43 +144,34 @@ public static function updateStoredCDNHeadersData($found_headers, $new_spbc_sett } /** - * Return CDN headers from last checker result. - * @return string[] - */ - public static function getLastCheckCDNHeaders() - { - $data = self::loadStoredCDNHeadersData(); - if ( count($data) ) { - return !empty($data[count($data) - 1]['found_cdn_headers']) - ? (array)$data[count($data) - 1]['found_cdn_headers'] - : array(); - } - return array(); - } - - /** - * Returns the new CDN header ID from last check. If nothing found and current settings is not 2, then returns '2' (remote_addr). + * Returns the new CDN header ID. If nothing found and current settings is not 2, then returns '2' (remote_addr). * Returns null otherwise. * @param string $current_get_ip_state - * @param string[] $last_check_headers + * @param string[] $found_headers_array * @return string|null */ - public static function getNewHeaderIdForSettings($current_get_ip_state, $last_check_headers) + public static function getNewHeaderIdForSettings($current_get_ip_state, $found_headers_array) { - $last_check_header = isset($last_check_headers[0]) ? $last_check_headers[0] : null; + $work_header = self::getWorkHeaderSlug($found_headers_array); $new_header_id = null; - if ( !$last_check_header ) { + if ( !$work_header ) { //set remote addr (2) as source if nothing found if ( !isset($current_get_ip_state) || $current_get_ip_state !== '2' ) { $new_header_id = '2'; } } else { - $new_header_id = IP::getHeaderIDbySlug($last_check_header); + $new_header_id = IP::getHeaderIDbySlug($work_header); } return $new_header_id; } + /** + * Set the new secfw__get_ip state from header ID. + * @param State $spbc SPBC State Obj. + * @param string $new_header_id New header ID. + * @return void + */ public static function applyIPGetHeadersSettings(State $spbc, $new_header_id = null) { $spbc->data['secfw__get_ip__last_auto_set'] = serialize(array( @@ -189,7 +184,6 @@ public static function applyIPGetHeadersSettings(State $spbc, $new_header_id = n $spbc->settings['secfw__get_ip'] = (string)$new_header_id; $spbc->save('settings'); - return $spbc; } /** @@ -282,4 +276,32 @@ public static function getOptionDescriptionText() { return __('Enable this option to set IP address source manually. If disabled, the plugin will detect IP source via self-call. Stats can be seen on the "Summary" tab', 'security-malware-firewall'); } + + /** + * Get work header slug from slugs array. If no CDN signs found, return first of another headers. If nothing found returns null. + * @param $found_headers_slugs + * @return string|null + */ + public static function getWorkHeaderSlug($found_headers_slugs) + { + //this list of slugs is used to found exact cdn + $cdn_slugs_ruleset = array( + 'incapsula', + 'ico_x_forwarded_for', + 'stackpath', + 'sucury', + 'ezoic', + 'gtranslate', + 'cloud_flare', + 'ovh', + ); + + //find unique sign of cdn, get first found if several + $match = array_intersect($cdn_slugs_ruleset, $found_headers_slugs); + if (!empty($match)) { + return (string)array_values($match)[0]; + } + + return !empty($found_headers_slugs[0]) ? $found_headers_slugs[0] : null; + } } diff --git a/tests/Standalone/TestCDNChecker.php b/tests/Standalone/TestCDNChecker.php index f13746721..a3751f27f 100644 --- a/tests/Standalone/TestCDNChecker.php +++ b/tests/Standalone/TestCDNChecker.php @@ -37,17 +37,43 @@ public function testFindCDNHeaders() $result = CDNHeadersChecker::findKnownCDNHeaderSlugs($provided_headers, $known_headers); $this->assertTrue(is_array($result)); $this->assertTrue(!empty($result)); + $this->assertTrue(in_array('x_forwarded_for', $result)); - $last_check_headers = CDNHeadersChecker::getLastCheckCDNHeaders(); - $this->assertTrue(is_array($last_check_headers)); - $this->assertTrue(empty($last_check_headers)); + CDNHeadersChecker::updateStoredCDNHeadersData($result); + $loaded = CDNHeadersChecker::loadStoredCDNHeadersData(); + + $this->assertTrue(is_array($loaded)); + $this->assertTrue(!empty($loaded)); + $this->assertTrue(in_array('x_forwarded_for', $loaded[count($loaded) - 1]['found_cdn_headers']), var_export($loaded, 1)); + + //cloudflare + $provided_headers = array('X-Forwarded-For','Cf-Connecting-Ip','X-Real-Ip','somethingelse'); + $result = CDNHeadersChecker::findKnownCDNHeaderSlugs($provided_headers, $known_headers); + $this->assertTrue(is_array($result)); + $this->assertTrue(!empty($result)); + $this->assertTrue(in_array('cloud_flare', $result)); CDNHeadersChecker::updateStoredCDNHeadersData($result); + $loaded = CDNHeadersChecker::loadStoredCDNHeadersData(); - $last_check_headers = CDNHeadersChecker::getLastCheckCDNHeaders(); - $this->assertTrue(is_array($last_check_headers)); - $this->assertTrue(!empty($last_check_headers)); - $this->assertEquals($last_check_headers[0], 'x_forwarded_for'); + $this->assertTrue(is_array($loaded)); + $this->assertTrue(!empty($loaded)); + $this->assertTrue(in_array('cloud_flare', $loaded[count($loaded) - 1]['found_cdn_headers']), var_export($loaded, 1)); + } + + public function testGetWorkHeaderSlug() + { + $loaded = CDNHeadersChecker::loadStoredCDNHeadersData(); + $this->assertTrue(is_array($loaded)); + $this->assertTrue(!empty($loaded)); + $this->assertTrue(in_array('cloud_flare', $loaded[count($loaded) - 1]['found_cdn_headers']), var_export($loaded, 1)); + + $found_headers = $loaded[count($loaded) - 1]['found_cdn_headers']; + + $work_header = CDNHeadersChecker::getWorkHeaderSlug($found_headers); + $this->assertTrue(!empty($work_header)); + $this->assertTrue(is_string($work_header)); + $this->assertEquals('cloud_flare', $work_header); } public function testApplyIPGetHeadersSettings() @@ -57,13 +83,20 @@ public function testApplyIPGetHeadersSettings() //x-forwarded-for $provided_headers = array('X-Forwarded-For'); - $result = CDNHeadersChecker::findKnownCDNHeaderSlugs($provided_headers, $known_headers); - CDNHeadersChecker::updateStoredCDNHeadersData($result); - $last_check_headers = CDNHeadersChecker::getLastCheckCDNHeaders(); + $found_headers = CDNHeadersChecker::findKnownCDNHeaderSlugs($provided_headers, $known_headers); $spbc->settings['secfw__get_ip'] = '8'; - $new_header_id = CDNHeadersChecker::getNewHeaderIdForSettings($spbc->settings['secfw__get_ip'], $last_check_headers); + $new_header_id = CDNHeadersChecker::getNewHeaderIdForSettings($spbc->settings['secfw__get_ip'], $found_headers); $this->assertEquals($new_header_id, '3'); CDNHeadersChecker::applyIPGetHeadersSettings($spbc, $new_header_id); $this->assertEquals($spbc->settings['secfw__get_ip'], '3'); + + //cloudflare + $provided_headers = array('X-Forwarded-For', 'Cf-Connecting-Ip'); + $found_headers = CDNHeadersChecker::findKnownCDNHeaderSlugs($provided_headers, $known_headers); + $spbc->settings['secfw__get_ip'] = '3'; + $new_header_id = CDNHeadersChecker::getNewHeaderIdForSettings($spbc->settings['secfw__get_ip'], $found_headers); + $this->assertEquals($new_header_id, '12'); + CDNHeadersChecker::applyIPGetHeadersSettings($spbc, $new_header_id); + $this->assertEquals($spbc->settings['secfw__get_ip'], '12'); } } From ed0d4991a898f46619971f2d600ec7cb638b5900 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Thu, 14 Dec 2023 13:17:37 +0500 Subject: [PATCH 25/67] Do not show changes if the new settings is the same as old. --- lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php index 6ec1ef904..7d508ec3b 100644 --- a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php +++ b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php @@ -163,6 +163,11 @@ public static function getNewHeaderIdForSettings($current_get_ip_state, $found_h $new_header_id = IP::getHeaderIDbySlug($work_header); } + //if current statement is the same, return null + if ($new_header_id == $current_get_ip_state) { + $new_header_id = null; + } + return $new_header_id; } From 5faae325d0a6ca03e5fde65de118f99da9b5ea98 Mon Sep 17 00:00:00 2001 From: svfcode Date: Thu, 14 Dec 2023 12:52:40 +0300 Subject: [PATCH 26/67] Fix. Scan. Added check for signatures count. --- lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php b/lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php index 51a6751b5..de65a86c8 100755 --- a/lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php +++ b/lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php @@ -2193,6 +2193,10 @@ public function send_results() // phpcs:ignore PSR1.Methods.CamelCapsMethodName. $signatures_found = isset($spbc->data['scanner']['signatures_found']) ? $spbc->data['scanner']['signatures_found'] : []; $signatures_found = json_encode($signatures_found); + if ( is_null($signatures_count) && is_string($signatures_found) ) { + $signatures_count = count(json_decode($signatures_found, true)); + } + // API. Sending files scan result $result = API::method__security_mscan_logs( $key, From 68246f68d87ca2c94bf76d0215097832b4361781 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Thu, 14 Dec 2023 15:00:46 +0500 Subject: [PATCH 27/67] Settings changed. Do new CDN check call on settings save. --- inc/spbc-settings.php | 22 +++++++++++++------ .../SpbctWP/HTTP/CDNHeadersChecker.php | 13 ++++++----- lib/CleantalkSP/SpbctWP/Helpers/IP.php | 6 +++-- lib/CleantalkSP/SpbctWP/State.php | 2 +- security-malware-firewall.php | 4 ++-- 5 files changed, 30 insertions(+), 17 deletions(-) diff --git a/inc/spbc-settings.php b/inc/spbc-settings.php index 786f0a2c1..84b095004 100644 --- a/inc/spbc-settings.php +++ b/inc/spbc-settings.php @@ -531,12 +531,6 @@ function spbc_settings__register() 'description' => esc_html__('Enable this option for Traffic Control to stop watching logged in users and keep watching website guests only.', 'security-malware-firewall'), 'parent' => 'traffic_control__enabled', ), - 'secfw__get_ip__disable_cdn_auto_self_check' => array( - 'type' => 'field', - 'title' => __('Disable automatic CDN headers checker', 'security-malware-firewall'), - 'description' => CDNHeadersChecker::getOptionDescriptionText(), - 'children' => array('secfw__get_ip'), - ), 'secfw__get_ip' => array( 'type' => 'field', 'input_type' => 'select', @@ -544,7 +538,11 @@ function spbc_settings__register() 'title' => __('Get visitors IP from additional headers', 'security-malware-firewall'), 'description' => spbc_settings_field__secfw__get_ip__get_description(), 'long_description' => true, - 'parent' => 'secfw__get_ip__cdn_auto_self_check' + ), + 'secfw__get_ip__enable_cdn_auto_self_check' => array( + 'type' => 'field', + 'title' => __('Enable automatic CDN headers checker', 'security-malware-firewall'), + 'description' => CDNHeadersChecker::getOptionDescriptionText(), ), ), ), @@ -5018,6 +5016,16 @@ function spbc__send_local_settings_to_api($settings) API::methodSendLocalSettings($api_key, $hostname, $settings); } +add_action('spbc_before_returning_settings', 'spbc_cdn_checker__run_check_on_settings_change'); + +function spbc_cdn_checker__run_check_on_settings_change($settings) +{ + if ( isset($settings['secfw__get_ip__enable_cdn_auto_self_check']) && $settings['secfw__get_ip__enable_cdn_auto_self_check'] != 0) { + CDNHeadersChecker::sendCDNCheckerRequest(); + } +} + + /** * */ diff --git a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php index 7d508ec3b..20672bdac 100644 --- a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php +++ b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php @@ -177,7 +177,7 @@ public static function getNewHeaderIdForSettings($current_get_ip_state, $found_h * @param string $new_header_id New header ID. * @return void */ - public static function applyIPGetHeadersSettings(State $spbc, $new_header_id = null) + public static function applyIPGetHeadersSettings(State $spbc, $new_header_id = 1) { $spbc->data['secfw__get_ip__last_auto_set'] = serialize(array( 'time' => time(), @@ -187,7 +187,7 @@ public static function applyIPGetHeadersSettings(State $spbc, $new_header_id = n )); $spbc->save('data'); - $spbc->settings['secfw__get_ip'] = (string)$new_header_id; + $spbc->settings['secfw__get_ip'] = !is_null($new_header_id) ? (string)$new_header_id : $spbc->settings['secfw__get_ip']; $spbc->save('settings'); } @@ -232,8 +232,11 @@ public static function getSummaryBlockHTML() $__check_result_h = __('Check result', 'security_malware_firewall'); $__check_time_h = __('Check time', 'security_malware_firewall'); $__source_changes = __('Source changes', 'security_malware_firewall'); - $__header_slug_text = !empty($spbc->settings['secfw__get_ip']) - ? '' . IP::$known_headers_collection[$spbc->settings['secfw__get_ip']]['slug'] . '' + $current_ip_source_id = $spbc->settings['secfw__get_ip'] != 0 && $spbc->settings['secfw__get_ip'] != 1 + ? $spbc->settings['secfw__get_ip'] + : 2; + $__header_slug_text = !empty($current_ip_source_id) + ? '' . IP::$known_headers_collection[$current_ip_source_id]['name'] . '' : __('unknown statement', 'security_malware_firewall'); $__current_source = __("Current IP source is set to", 'security_malware_firewall') . ' ' . $__header_slug_text; @@ -279,7 +282,7 @@ public static function getSummaryBlockHTML() */ public static function getOptionDescriptionText() { - return __('Enable this option to set IP address source manually. If disabled, the plugin will detect IP source via self-call. Stats can be seen on the "Summary" tab', 'security-malware-firewall'); + return __('If enabled, the plugin will detect IP source via self-call. Stats can be seen on the "Summary" tab', 'security-malware-firewall'); } /** diff --git a/lib/CleantalkSP/SpbctWP/Helpers/IP.php b/lib/CleantalkSP/SpbctWP/Helpers/IP.php index 4dac60d91..d2ead344d 100644 --- a/lib/CleantalkSP/SpbctWP/Helpers/IP.php +++ b/lib/CleantalkSP/SpbctWP/Helpers/IP.php @@ -27,8 +27,10 @@ public static function get($ip_type_to_get = 'real', $headers = array(), $recurs { global $spbc; - if ( (int)$spbc->settings['secfw__get_ip'] !== 1 ) { - $ip_type_to_get = self::$known_headers_collection[(int)$spbc->settings['secfw__get_ip']]['slug']; + $current_setting = (int)$spbc->settings['secfw__get_ip']; + + if ( $current_setting !== 1 && $current_setting !== 0) { + $ip_type_to_get = self::$known_headers_collection[$current_setting]['slug']; } $ip_found = parent::get($ip_type_to_get, $headers, $recursion); diff --git a/lib/CleantalkSP/SpbctWP/State.php b/lib/CleantalkSP/SpbctWP/State.php index 49be2a7b1..891c56f2f 100644 --- a/lib/CleantalkSP/SpbctWP/State.php +++ b/lib/CleantalkSP/SpbctWP/State.php @@ -90,7 +90,7 @@ class State extends \CleantalkSP\Common\State 'waf__exploit_check' => 1, 'waf_blocker__enabled' => 0, 'secfw__get_ip' => 1, - 'secfw__get_ip__disable_cdn_auto_self_check' => 0, + 'secfw__get_ip__enable_cdn_auto_self_check' => 1, // Data processing 'data__set_cookies' => 1, diff --git a/security-malware-firewall.php b/security-malware-firewall.php index 8ef24953a..cbcc860a9 100644 --- a/security-malware-firewall.php +++ b/security-malware-firewall.php @@ -2016,7 +2016,7 @@ function spbc_is_amp_request() function spbc_cdn_checker__parse_request() { global $spbc; - if (!$spbc->settings['secfw__get_ip__disable_cdn_auto_self_check']) { + if ($spbc->settings['secfw__get_ip__enable_cdn_auto_self_check']) { return CDNHeadersChecker::check(); } return array('error' => 'CDN checker disabled'); @@ -2030,7 +2030,7 @@ function spbc_cdn_checker__parse_request() function spbc_cdn_checker__send_request() { global $spbc; - if (!$spbc->settings['secfw__get_ip__disable_cdn_auto_self_check']) { + if ($spbc->settings['secfw__get_ip__enable_cdn_auto_self_check']) { CDNHeadersChecker::sendCDNCheckerRequest(); } } From 1e38fd40c558cf0604bdee79766e004cba23abaa Mon Sep 17 00:00:00 2001 From: alexandergull Date: Thu, 14 Dec 2023 15:04:30 +0500 Subject: [PATCH 28/67] Psalm fixes. --- lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php index 20672bdac..92b6d917d 100644 --- a/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php +++ b/lib/CleantalkSP/SpbctWP/HTTP/CDNHeadersChecker.php @@ -177,7 +177,7 @@ public static function getNewHeaderIdForSettings($current_get_ip_state, $found_h * @param string $new_header_id New header ID. * @return void */ - public static function applyIPGetHeadersSettings(State $spbc, $new_header_id = 1) + public static function applyIPGetHeadersSettings(State $spbc, $new_header_id = '1') { $spbc->data['secfw__get_ip__last_auto_set'] = serialize(array( 'time' => time(), From 22e90a4dda40fc89ba65c298fce33d96190dd8f1 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Thu, 14 Dec 2023 15:50:00 +0500 Subject: [PATCH 29/67] Revert "Upd.Gulp.Delete gulp-sass" This reverts commit 61e38b7321215a45fca78506adb5f320823d9dbe. --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 3b5add161..fe52d18e2 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "gulp": "^4.0.2", "gulp-cssmin": "^0.2.0", "gulp-rename": "^1.4.0", + "gulp-sass": "^4.0.2", "gulp-sourcemaps": "^2.6.5", "gulp-uglify": "^3.0.2" } From 8b45d1a95cbd1677c015cdcd89e92bd42de665c3 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Thu, 14 Dec 2023 15:50:16 +0500 Subject: [PATCH 30/67] Revert "Upd.Lib.Adaptive table and drop-down line" This reverts commit dad924fa --- css/spbc-table.min.css | 2 +- css/src/spbc-table.css | 99 ------------------- js/spbc-admin.min.js.map | 2 +- js/spbc-common.min.js.map | 2 +- js/spbc-cookie.min.js.map | 2 +- js/spbc-dashboard-widget.min.js.map | 2 +- js/spbc-modal.min.js.map | 2 +- js/spbc-scanner-plugin.min.js.map | 2 +- js/spbc-settings.min.js.map | 2 +- js/spbc-settings_tab--backups.min.js.map | 2 +- js/spbc-settings_tab--scanner.min.js.map | 2 +- js/spbc-settings_tab--security_log.min.js.map | 2 +- ...-settings_tab--settings_general.min.js.map | 2 +- js/spbc-settings_tab--summary.min.js.map | 2 +- ...c-settings_tab--traffic_control.min.js.map | 2 +- js/spbc-table.min.js | 2 +- js/spbc-table.min.js.map | 2 +- js/spbc-upload.min.js.map | 2 +- js/src/spbc-table.js | 11 +-- 19 files changed, 18 insertions(+), 126 deletions(-) diff --git a/css/spbc-table.min.css b/css/spbc-table.min.css index f497c5752..169333220 100644 --- a/css/spbc-table.min.css +++ b/css/spbc-table.min.css @@ -1 +1 @@ -#spbc_tbl__scanner_frontend_malware th,tbody td{position:relative}[disabled]:hover{cursor:not-allowed}.tbl-width--50px{width:50px}.tbl-width--100px{width:100px}.tbl-width--sma{width:7em}.tbl-widtqh--mid{width:6em}.tbl-min_width--big{width:12em}tr .row-actions{left:0}.tbl-row_action:hover{cursor:pointer;text-decoration:underline}tr .row-actions span{color:gray}tr:hover .row-actions span.tbl-row_action{color:#0073aa}tr:hover .row-actions span.tbl-row_action--delete,tr:hover .row-actions span.tbl-row_action--replace{color:#a00}tr:hover .row-actions span.tbl-row_action--approve{color:#0a0}.tbl-row_action--hide{color:gray}.tbl-sorting_indicator{margin-left:10px;visibility:hidden}.tbl-sorting_indicator--sorted{color:rgba(0,0,0,.6);visibility:visible}.tbl-column-sortable:hover{cursor:pointer}.tbl-column-sortable:hover .tbl-sorting_indicator{visibility:visible;color:rgba(0,0,0,1)}.spbc_hint--icon{color:#999}.spbc_hint--icon:hover{color:#000}.spbc_hint--icon:hover+.spbc_hint--text{display:block}.spbc_hint--text{display:none;color:#999}.tbl-button{display:inline-block;line-height:20px;height:30px;margin:0;padding:0 10px 1px;cursor:pointer;border:1px solid #ccc;border-radius:3px;color:#555;background:#f7f7f7;vertical-align:top}.tbl-button---white_blue{background:#2ea2cc;border-color:#0074a2;-webkit-box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);color:#fff}.tbl-select{padding:2px;line-height:20px!important;height:25px!important}.tbl-preloader--small{display:none;width:15px;height:15px;margin:0 5px;vertical-align:middle}.tbl-preloader--tiny{display:none;width:10px;height:10px;margin:0 5px}.tbl-preloader--in_button{margin:0 0 0 8px}.tbl-bulk_actions--wrapper{display:inline-block;margin:5px 0}.tbl-bulk_actions--apply,.tbl-pagination--button,.tbl-pagination--total{margin:0 5px}.tbl-pagination--wrapper{display:inline-block;padding:5px 0;vertical-align:middle}.tbl-pagination--total{vertical-align:baseline}.tbl-pagination--curr_page{width:36px;padding:3px 5px;font-size:13px;text-align:center}@media screen and (max-width:782px){#spbc_tbl__secuirty_logs .wp-list-table tr,#spbc_tbl__traffic_control_logs .wp-list-table tr{margin:0 0 1rem}#spbc_tbl__traffic_control_logs .wp-list-table,#spbc_tbl__traffic_control_logs .wp-list-table thead,tbody,td,tr{display:block}#spbc_tbl__traffic_control_logs .wp-list-table thead tr{position:absolute;top:-9999px;left:-9999px}#spbc_tbl__traffic_control_logs .wp-list-table td{display:flex;align-items:center;border:none;border-bottom:1px solid #eee;position:relative;padding-left:50%;height:100%;padding-top:10px;padding-bottom:10px}#spbc_tbl__traffic_control_logs .wp-list-table td:before{position:absolute;top:0;left:6px;width:45%;padding-right:10px;white-space:nowrap;height:inherit;display:grid;align-items:center}#spbc_tbl__traffic_control_logs .wp-list-table td:nth-of-type(1):before{content:"IP"}#spbc_tbl__traffic_control_logs .wp-list-table td:nth-of-type(2):before{content:"Country"}#spbc_tbl__traffic_control_logs .wp-list-table td:nth-of-type(3):before{content:"Last Request"}#spbc_tbl__traffic_control_logs .wp-list-table td:nth-of-type(4):before{content:"Status"}#spbc_tbl__traffic_control_logs .wp-list-table td:nth-of-type(5):before{content:"Requests"}#spbc_tbl__traffic_control_logs .wp-list-table td:nth-of-type(6):before{content:"Requests per 5 minutes"}#spbc_tbl__traffic_control_logs .wp-list-table td:nth-of-type(7):before{content:"Page"}#spbc_tbl__traffic_control_logs .wp-list-table td:nth-of-type(8):before{content:"User Agent"}#spbc_tbl__secuirty_logs .wp-list-table,#spbc_tbl__secuirty_logs .wp-list-table thead,tbody,td,tr{display:block}#spbc_tbl__secuirty_logs .wp-list-table thead tr{position:absolute;top:-9999px;left:-9999px}#spbc_tbl__secuirty_logs .wp-list-table td{display:flex;align-items:center;border:none;border-bottom:1px solid #eee;position:relative;padding-left:50%;height:100%;padding-top:10px;padding-bottom:10px}#spbc_tbl__secuirty_logs .wp-list-table td:before{position:absolute;top:0;left:6px;width:45%;padding-right:10px;white-space:nowrap;height:inherit;display:grid;align-items:center}#spbc_tbl__secuirty_logs .wp-list-table td:nth-of-type(1):before{content:"User"}#spbc_tbl__secuirty_logs .wp-list-table td:nth-of-type(2):before{content:"IP"}#spbc_tbl__secuirty_logs .wp-list-table td:nth-of-type(3):before{content:"Date"}#spbc_tbl__secuirty_logs .wp-list-table td:nth-of-type(4):before{content:"Action"}#spbc_tbl__secuirty_logs .wp-list-table td:nth-of-type(5):before{content:"Page"}.spbcShortTextBlock{width:100%}#spbc_tbl__secuirty_logs .wp-list-table .mob_entries,#spbc_tbl__traffic_control_logs .wp-list-table .mob_entries{display:none}} \ No newline at end of file +#spbc_tbl__scanner_frontend_malware th,tbody td{position:relative}[disabled]:hover{cursor:not-allowed}.tbl-width--50px{width:50px}.tbl-width--100px{width:100px}.tbl-width--sma{width:7em}.tbl-widtqh--mid{width:6em}.tbl-min_width--big{width:12em}tr .row-actions{left:0}.tbl-row_action:hover{cursor:pointer;text-decoration:underline}tr .row-actions span{color:gray}tr:hover .row-actions span.tbl-row_action{color:#0073aa}tr:hover .row-actions span.tbl-row_action--delete,tr:hover .row-actions span.tbl-row_action--replace{color:#a00}tr:hover .row-actions span.tbl-row_action--approve{color:#0a0}.tbl-row_action--hide{color:gray}.tbl-sorting_indicator{margin-left:10px;visibility:hidden}.tbl-sorting_indicator--sorted{color:rgba(0,0,0,.6);visibility:visible}.tbl-column-sortable:hover{cursor:pointer}.tbl-column-sortable:hover .tbl-sorting_indicator{visibility:visible;color:rgba(0,0,0,1)}.spbc_hint--icon{color:#999}.spbc_hint--icon:hover{color:#000}.spbc_hint--icon:hover+.spbc_hint--text{display:block}.spbc_hint--text{display:none;color:#999}.tbl-button{display:inline-block;line-height:20px;height:30px;margin:0;padding:0 10px 1px;cursor:pointer;border:1px solid #ccc;border-radius:3px;color:#555;background:#f7f7f7;vertical-align:top}.tbl-button---white_blue{background:#2ea2cc;border-color:#0074a2;-webkit-box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);color:#fff}.tbl-select{padding:2px;line-height:20px!important;height:25px!important}.tbl-preloader--small{display:none;width:15px;height:15px;margin:0 5px;vertical-align:middle}.tbl-preloader--tiny{display:none;width:10px;height:10px;margin:0 5px}.tbl-preloader--in_button{margin:0 0 0 8px}.tbl-bulk_actions--wrapper{display:inline-block;margin:5px 0}.tbl-bulk_actions--apply,.tbl-pagination--button,.tbl-pagination--total{margin:0 5px}.tbl-pagination--wrapper{display:inline-block;padding:5px 0;vertical-align:middle}.tbl-pagination--total{vertical-align:baseline}.tbl-pagination--curr_page{width:36px;padding:3px 5px;font-size:13px;text-align:center} \ No newline at end of file diff --git a/css/src/spbc-table.css b/css/src/spbc-table.css index c91ec5814..5c04f0fff 100644 --- a/css/src/spbc-table.css +++ b/css/src/spbc-table.css @@ -75,103 +75,4 @@ tr:hover .row-actions span.tbl-row_action--approve{color: #0a0;} #spbc_tbl__scanner_frontend_malware th { position: relative; -} - -@media screen and (max-width: 782px) { - #spbc_tbl__traffic_control_logs .wp-list-table { - display: block; - } - #spbc_tbl__traffic_control_logs .wp-list-table thead, tbody, td, tr { - display: block; - } - #spbc_tbl__traffic_control_logs .wp-list-table thead tr { - position: absolute; - top: -9999px; - left: -9999px; - } - #spbc_tbl__traffic_control_logs .wp-list-table tr { - margin: 0 0 1rem 0; - } - #spbc_tbl__traffic_control_logs .wp-list-table td { - display: flex; - align-items: center; - border: none; - border-bottom: 1px solid #eee; - position: relative; - padding-left: 50%; - height: 100%; - padding-top: 10px; - padding-bottom: 10px; - } - #spbc_tbl__traffic_control_logs .wp-list-table td:before { - position: absolute; - top: 0; - left: 6px; - width: 45%; - padding-right: 10px; - white-space: nowrap; - height: inherit; - display: grid; - align-items: center; - } - #spbc_tbl__traffic_control_logs .wp-list-table td:nth-of-type(1):before { content: "IP"; } - #spbc_tbl__traffic_control_logs .wp-list-table td:nth-of-type(2):before { content: "Country"; } - #spbc_tbl__traffic_control_logs .wp-list-table td:nth-of-type(3):before { content: "Last Request"; } - #spbc_tbl__traffic_control_logs .wp-list-table td:nth-of-type(4):before { content: "Status"; } - #spbc_tbl__traffic_control_logs .wp-list-table td:nth-of-type(5):before { content: "Requests";} - #spbc_tbl__traffic_control_logs .wp-list-table td:nth-of-type(6):before { content: "Requests per 5 minutes"; } - #spbc_tbl__traffic_control_logs .wp-list-table td:nth-of-type(7):before { content: "Page"; } - #spbc_tbl__traffic_control_logs .wp-list-table td:nth-of-type(8):before { content: "User Agent"; } - .spbcShortTextBlock { - width: 100%; - } - - #spbc_tbl__secuirty_logs .wp-list-table { - display: block; - } - #spbc_tbl__secuirty_logs .wp-list-table thead, tbody, td, tr { - display: block; - } - #spbc_tbl__secuirty_logs .wp-list-table thead tr { - position: absolute; - top: -9999px; - left: -9999px; - } - #spbc_tbl__secuirty_logs .wp-list-table tr { - margin: 0 0 1rem 0; - } - #spbc_tbl__secuirty_logs .wp-list-table td { - display: flex; - align-items: center; - border: none; - border-bottom: 1px solid #eee; - position: relative; - padding-left: 50%; - height: 100%; - padding-top: 10px; - padding-bottom: 10px; - } - #spbc_tbl__secuirty_logs .wp-list-table td:before { - position: absolute; - top: 0; - left: 6px; - width: 45%; - padding-right: 10px; - white-space: nowrap; - height: inherit; - display: grid; - align-items: center; - } - #spbc_tbl__secuirty_logs .wp-list-table td:nth-of-type(1):before { content: "User"; } - #spbc_tbl__secuirty_logs .wp-list-table td:nth-of-type(2):before { content: "IP"; } - #spbc_tbl__secuirty_logs .wp-list-table td:nth-of-type(3):before { content: "Date"; } - #spbc_tbl__secuirty_logs .wp-list-table td:nth-of-type(4):before { content: "Action"; } - #spbc_tbl__secuirty_logs .wp-list-table td:nth-of-type(5):before { content: "Page";} - .spbcShortTextBlock { - width: 100%; - } - - #spbc_tbl__traffic_control_logs .wp-list-table .mob_entries, #spbc_tbl__secuirty_logs .wp-list-table .mob_entries { - display: none; - } } \ No newline at end of file diff --git a/js/spbc-admin.min.js.map b/js/spbc-admin.min.js.map index 231f47dd9..f58bb3713 100644 --- a/js/spbc-admin.min.js.map +++ b/js/spbc-admin.min.js.map @@ -1 +1 @@ -{"version":3,"file":"spbc-admin.min.js","sources":["spbc-admin.js"],"sourcesContent":["function spbcGetGoogleQrCode() {\r\n\tvar data = {};\r\n\tvar res = {};\r\n\tdata.security = spbcSettings.ajax_nonce;\r\n\tdata.action = 'spbc_get_google_qr_code';\r\n\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\tasync: false,\r\n\t\turl: spbcSettings.ajaxurl,\r\n\t\tdata: data,\r\n\t\tsuccess: function(result){\r\n\t\t\tres = result;\r\n\t\t},\r\n\t});\r\n\treturn res;\r\n}\r\n\r\nfunction spbcCheckGoogleCode() {\r\n\tvar data = {};\r\n\tdata.security = spbcSettings.ajax_nonce;\r\n\tdata.action = 'spbc_check_google_code';\r\n\tdata.code = jQuery('#spbct-google-qr-code input').val();\r\n\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\tasync: false,\r\n\t\turl: spbcSettings.ajaxurl,\r\n\t\tdata: data,\r\n\t\tsuccess: function(result){\r\n\t\t\tif(result.success) {\r\n\t\t\t\tjQuery('#spbct-google-qr-code').dialog( \"close\" );\r\n\t\t\t\tdocument.location.reload();\r\n\t\t\t} else {\r\n\t\t\t\talert(result.data);\r\n\t\t\t}\r\n\t\t},\r\n\t});\r\n}\r\n\r\nfunction spbcDisableG2fa( element ) {\r\n\tvar data = {};\r\n\tdata.security = spbcSettings.ajax_nonce;\r\n\tdata.action = 'spbc_disable_google_2fa';\r\n data.user_id = jQuery(element).data('user-id');\r\n\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\tasync: false,\r\n\t\turl: spbcSettings.ajaxurl,\r\n\t\tdata: data,\r\n\t\tsuccess: function(result){\r\n\t\t\tif(result.success) {\r\n\t\t\t\tdocument.location.reload();\r\n\t\t\t} else {\r\n\t\t\t\talert(result.data);\r\n\t\t\t}\r\n\t\t},\r\n\t});\r\n}\r\n\r\njQuery(document).ready(function(){\r\n\t\r\n\t// Auto update banner close handler \r\n\tjQuery('.spbc_update_notice').on('click', 'button', function(){\r\n\t\tspbc_setCookie('spbc_update_banner_closed', 1, 86400 * 30);\r\n\t});\r\n\r\n\t// Enable G2FA from user profile page\r\n\tjQuery(document).on('click', '#spbc-g2fa-enable', function(e){\r\n\r\n\t\te.preventDefault();\r\n\t\tvar spbcGoogleQrCode = spbcGetGoogleQrCode();\r\n\r\n\t\tif( spbcGoogleQrCode.success ) {\r\n\t\t\tvar qr_code_div = jQuery('#spbct-google-qr-code-img');\r\n\t\t\tqr_code_div.html(spbcGoogleQrCode.data.img + '

' + spbcGoogleQrCode.data.code + '

');\r\n\t\t\tjQuery('#spbct-google-qr-code input').val('');\r\n\t\t\tjQuery('#spbct-google-qr-code').dialog({\r\n\t\t\t\tmodal: true,\r\n\t\t\t\ttitle: 'Google authenticator activation',\r\n\t\t\t\tbuttons: {\r\n\t\t\t\t\tCancel: function() {\r\n\t\t\t\t\t\tjQuery( this ).dialog( \"close\" );\r\n\t\t\t\t\t},\r\n\t\t\t\t\tOk: function() {\r\n\t\t\t\t\t\tspbcCheckGoogleCode();\r\n\t\t\t\t\t}\r\n\t\t\t\t},\r\n\t\t\t\tdraggable: false,\r\n\t\t\t\tresizable: false,\r\n\t\t\t});\r\n\t\t} else {\r\n\t\t\talert(spbcGetGoogleQrCode.data);\r\n\t\t}\r\n\r\n\t});\r\n\r\n\t// Disable G2FA from user profile page\r\n\tjQuery(document).on('click', '#spbc-g2fa-disable', function(e){\r\n\r\n\t\te.preventDefault();\r\n\t\tif( confirm( 'Are you sure?' ) ) {\r\n\t\t\tspbcDisableG2fa( this );\r\n\t\t}\r\n\r\n\t});\r\n\r\n\tvar refresh_user_online_counter = function( result, data, params ){\r\n\t\tsetTimeout(function () {\r\n\t\t\tif( result !== null ){\r\n\t\t\t\tjQuery('.spbc-admin_bar--user_counter').html(result.count);\r\n\t\t\t\tif( result.count <= 3 ) {\r\n\t\t\t\t\tjQuery('#wp-admin-bar-spbc_admin_bar__online_admins').show();\r\n\t\t\t\t\tjQuery('.spbc-admin_bar--online_admins').html(result.users.join(', '));\r\n\t\t\t\t}else{\r\n\t\t\t\t\tjQuery('#wp-admin-bar-spbc_admin_bar__online_admins').hide();\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\t\t\tspbc_sendAJAXRequest( data, params );\r\n\t\t}, 15000 );\r\n\t};\r\n\r\n\tif( +spbcSettings.admin_bar__admins_online_counter === 1 ) {\r\n\t\trefresh_user_online_counter(null, {action: 'spbc_get_authorized_admins'}, {callback: refresh_user_online_counter});\r\n\t}\r\n\r\n\t// Dismiss admin banner\r\n\tjQuery('body').on('click', '.spbc-notice .notice-dismiss', function(e){\r\n\t\tvar bannerId = jQuery(e.target).parent('.notice').attr('id');\r\n\t\tif( bannerId ) {\r\n\t\t\tspbc_sendAJAXRequest( { 'action' : 'spbc_dismiss_banner', 'banner_id' : bannerId }, { 'callback' : null } );\r\n\t\t}\r\n\t});\r\n\r\n\tif (+spbcSettings.needToWhitelist === 1) {\r\n\t\tspbc_sendAJAXRequest( { 'action' : 'spbc_private_list_add' }, { 'callback' : null } );\r\n\t}\r\n});"],"names":["spbcGetGoogleQrCode","data","res","security","spbcSettings","ajax_nonce","action","jQuery","ajax","type","async","url","ajaxurl","success","result","spbcCheckGoogleCode","code","val","dialog","document","location","reload","alert","spbcDisableG2fa","element","user_id","ready","on","spbc_setCookie","e","preventDefault","spbcGoogleQrCode","html","img","modal","title","buttons","Cancel","this","Ok","draggable","resizable","confirm","refresh_user_online_counter","params","setTimeout","count","show","users","join","hide","spbc_sendAJAXRequest","admin_bar__admins_online_counter","callback","bannerId","target","parent","attr","banner_id","needToWhitelist"],"mappings":"AAAA,SAASA,sBACR,IAAIC,EAAO,GACPC,EAAM,GAaV,OAZAD,EAAKE,SAAWC,aAAaC,WAC7BJ,EAAKK,OAAS,0BAEdC,OAAOC,KAAK,CACXC,KAAM,OACNC,MAAO,CAAA,EACPC,IAAKP,aAAaQ,QAClBX,KAAMA,EACNY,QAAS,SAASC,GACjBZ,EAAMY,CACP,CACD,CAAC,EACMZ,CACR,CAEA,SAASa,sBACR,IAAId,EAAO,GACXA,EAAKE,SAAWC,aAAaC,WAC7BJ,EAAKK,OAAS,yBACdL,EAAKe,KAAOT,OAAO,6BAA6B,EAAEU,IAAI,EAEtDV,OAAOC,KAAK,CACXC,KAAM,OACNC,MAAO,CAAA,EACPC,IAAKP,aAAaQ,QAClBX,KAAMA,EACNY,QAAS,SAASC,GACdA,EAAOD,SACTN,OAAO,uBAAuB,EAAEW,OAAQ,OAAQ,EAChDC,SAASC,SAASC,OAAO,GAEzBC,MAAMR,EAAOb,IAAI,CAEnB,CACD,CAAC,CACF,CAEA,SAASsB,gBAAiBC,GACzB,IAAIvB,EAAO,GACXA,EAAKE,SAAWC,aAAaC,WAC7BJ,EAAKK,OAAS,0BACXL,EAAKwB,QAAUlB,OAAOiB,CAAO,EAAEvB,KAAK,SAAS,EAEhDM,OAAOC,KAAK,CACXC,KAAM,OACNC,MAAO,CAAA,EACPC,IAAKP,aAAaQ,QAClBX,KAAMA,EACNY,QAAS,SAASC,GACdA,EAAOD,QACTM,SAASC,SAASC,OAAO,EAEzBC,MAAM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,EAA4B,KAAM,CAACrC,OAAQ,4BAA4B,EAAG,CAAC+C,SAAUV,CAA2B,CAAC,EAIlHpC,OAAO,MAAM,EAAEoB,GAAG,QAAS,+BAAgC,SAASE,GAC/DyB,EAAW/C,OAAOsB,EAAE0B,MAAM,EAAEC,OAAO,SAAS,EAAEC,KAAK,IAAI,EACvDH,GACHH,qBAAsB,CAAE7C,OAAW,sBAAuBoD,UAAcJ,CAAS,EAAG,CAAED,SAAa,IAAK,CAAE,CAE5G,CAAC,EAEqC,GAAlC,CAACjD,aAAauD,iBACjBR,qBAAsB,CAAE7C,OAAW,uBAAwB,EAAG,CAAE+C,SAAa,IAAK,CAAE,CAEtF,CAAC"} \ No newline at end of file +{"version":3,"file":"spbc-admin.min.js","sources":["spbc-admin.js"],"sourcesContent":["function spbcGetGoogleQrCode() {\n\tvar data = {};\n\tvar res = {};\n\tdata.security = spbcSettings.ajax_nonce;\n\tdata.action = 'spbc_get_google_qr_code';\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\tasync: false,\n\t\turl: spbcSettings.ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(result){\n\t\t\tres = result;\n\t\t},\n\t});\n\treturn res;\n}\n\nfunction spbcCheckGoogleCode() {\n\tvar data = {};\n\tdata.security = spbcSettings.ajax_nonce;\n\tdata.action = 'spbc_check_google_code';\n\tdata.code = jQuery('#spbct-google-qr-code input').val();\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\tasync: false,\n\t\turl: spbcSettings.ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(result){\n\t\t\tif(result.success) {\n\t\t\t\tjQuery('#spbct-google-qr-code').dialog( \"close\" );\n\t\t\t\tdocument.location.reload();\n\t\t\t} else {\n\t\t\t\talert(result.data);\n\t\t\t}\n\t\t},\n\t});\n}\n\nfunction spbcDisableG2fa( element ) {\n\tvar data = {};\n\tdata.security = spbcSettings.ajax_nonce;\n\tdata.action = 'spbc_disable_google_2fa';\n data.user_id = jQuery(element).data('user-id');\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\tasync: false,\n\t\turl: spbcSettings.ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(result){\n\t\t\tif(result.success) {\n\t\t\t\tdocument.location.reload();\n\t\t\t} else {\n\t\t\t\talert(result.data);\n\t\t\t}\n\t\t},\n\t});\n}\n\njQuery(document).ready(function(){\n\t\n\t// Auto update banner close handler \n\tjQuery('.spbc_update_notice').on('click', 'button', function(){\n\t\tspbc_setCookie('spbc_update_banner_closed', 1, 86400 * 30);\n\t});\n\n\t// Enable G2FA from user profile page\n\tjQuery(document).on('click', '#spbc-g2fa-enable', function(e){\n\n\t\te.preventDefault();\n\t\tvar spbcGoogleQrCode = spbcGetGoogleQrCode();\n\n\t\tif( spbcGoogleQrCode.success ) {\n\t\t\tvar qr_code_div = jQuery('#spbct-google-qr-code-img');\n\t\t\tqr_code_div.html(spbcGoogleQrCode.data.img + '

' + spbcGoogleQrCode.data.code + '

');\n\t\t\tjQuery('#spbct-google-qr-code input').val('');\n\t\t\tjQuery('#spbct-google-qr-code').dialog({\n\t\t\t\tmodal: true,\n\t\t\t\ttitle: 'Google authenticator activation',\n\t\t\t\tbuttons: {\n\t\t\t\t\tCancel: function() {\n\t\t\t\t\t\tjQuery( this ).dialog( \"close\" );\n\t\t\t\t\t},\n\t\t\t\t\tOk: function() {\n\t\t\t\t\t\tspbcCheckGoogleCode();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tdraggable: false,\n\t\t\t\tresizable: false,\n\t\t\t});\n\t\t} else {\n\t\t\talert(spbcGetGoogleQrCode.data);\n\t\t}\n\n\t});\n\n\t// Disable G2FA from user profile page\n\tjQuery(document).on('click', '#spbc-g2fa-disable', function(e){\n\n\t\te.preventDefault();\n\t\tif( confirm( 'Are you sure?' ) ) {\n\t\t\tspbcDisableG2fa( this );\n\t\t}\n\n\t});\n\n\tvar refresh_user_online_counter = function( result, data, params ){\n\t\tsetTimeout(function () {\n\t\t\tif( result !== null ){\n\t\t\t\tjQuery('.spbc-admin_bar--user_counter').html(result.count);\n\t\t\t\tif( result.count <= 3 ) {\n\t\t\t\t\tjQuery('#wp-admin-bar-spbc_admin_bar__online_admins').show();\n\t\t\t\t\tjQuery('.spbc-admin_bar--online_admins').html(result.users.join(', '));\n\t\t\t\t}else{\n\t\t\t\t\tjQuery('#wp-admin-bar-spbc_admin_bar__online_admins').hide();\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tspbc_sendAJAXRequest( data, params );\n\t\t}, 15000 );\n\t};\n\n\tif( +spbcSettings.admin_bar__admins_online_counter === 1 ) {\n\t\trefresh_user_online_counter(null, {action: 'spbc_get_authorized_admins'}, {callback: refresh_user_online_counter});\n\t}\n\n\t// Dismiss admin banner\n\tjQuery('body').on('click', '.spbc-notice .notice-dismiss', function(e){\n\t\tvar bannerId = jQuery(e.target).parent('.notice').attr('id');\n\t\tif( bannerId ) {\n\t\t\tspbc_sendAJAXRequest( { 'action' : 'spbc_dismiss_banner', 'banner_id' : bannerId }, { 'callback' : null } );\n\t\t}\n\t});\n\n\tif (+spbcSettings.needToWhitelist === 1) {\n\t\tspbc_sendAJAXRequest( { 'action' : 'spbc_private_list_add' }, { 'callback' : null } );\n\t}\n});"],"names":["spbcGetGoogleQrCode","data","res","security","spbcSettings","ajax_nonce","action","jQuery","ajax","type","async","url","ajaxurl","success","result","spbcCheckGoogleCode","code","val","dialog","document","location","reload","alert","spbcDisableG2fa","element","user_id","ready","on","spbc_setCookie","e","preventDefault","spbcGoogleQrCode","html","img","modal","title","buttons","Cancel","this","Ok","draggable","resizable","confirm","refresh_user_online_counter","params","setTimeout","count","show","users","join","hide","spbc_sendAJAXRequest","admin_bar__admins_online_counter","callback","bannerId","target","parent","attr","banner_id","needToWhitelist"],"mappings":"AAAA,SAASA,sBACR,IAAIC,EAAO,GACPC,EAAM,GAaV,OAZAD,EAAKE,SAAWC,aAAaC,WAC7BJ,EAAKK,OAAS,0BAEdC,OAAOC,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CAAC"} \ No newline at end of file diff --git a/js/spbc-common.min.js.map b/js/spbc-common.min.js.map index e8dc83bd2..2c18e12d3 100644 --- a/js/spbc-common.min.js.map +++ b/js/spbc-common.min.js.map @@ -1 +1 @@ -{"version":3,"file":"spbc-common.min.js","sources":["spbc-common.js"],"sourcesContent":["function spbc_timestamp(){\r\n\treturn Math.floor(+new Date() / 1000);\r\n}\r\n\r\n// Hightlights element\r\nfunction spbcHighlightElement(id, times){\r\n\ttimes = times-1 || 0;\r\n\tjQuery(\"html, body\").animate({ scrollTop: jQuery(jQuery('#'+id)).offset().top - 100 }, \"slow\");\r\n\tjQuery('#'+id).addClass('spbc_highlighted');\r\n\tjQuery('#'+id).animate({outlineColor: \"rgba(255, 0, 0, 1.0)\" }, 400, 'linear', function(){\r\n\t\tjQuery('#'+id).animate({outlineColor: \"rgba(255, 0, 0, 0.0)\" }, 400, 'linear', function(){\r\n\t\t\tif(times>0){\r\n\t\t\t\tspbcHighlightElement(id, times);\r\n\t\t\t}else{\r\n\t\t\t\tjQuery('#'+id).removeClass('spbc_highlighted');\r\n\t\t\t}\r\n\t\t});\r\n\t});\r\n}\r\n\r\nfunction spbc_sendAJAXRequest(data, params, obj){\r\n\r\n\tvar dataType = params.notJson ? 'text' : 'json';\r\n\r\n\t// Default params\r\n\tvar button = params.button || null;\r\n\tvar spinner = params.spinner || null;\r\n\tvar progressbar = params.progressbar || null;\r\n\tvar callback = params.callback || null;\r\n\tvar notJson = params.notJson || null;\r\n\tvar timeout = params.timeout || 15000;\r\n\tvar obj = obj || null;\r\n\tvar context = params.context || this;\r\n\r\n\t// Button and spinner\r\n\tif(button) {button.setAttribute('disabled', 'disabled'); button.style.cursor = 'not-allowed'; }\r\n\tif(spinner) jQuery(spinner).css('display', 'inline');\r\n\r\n\t// Adding security code\r\n\tdata.security = spbcSettings.ajax_nonce;\r\n\tdata.no_cache = Math.random();\r\n\r\n\t// Using passed successCallback() or default\r\n\tvar success = params.success || function(result){\r\n\t\tif(button){\r\n\t\t\tbutton.removeAttribute('disabled');\r\n\t\t\tbutton.style.cursor = 'pointer';\r\n\t\t}\r\n\r\n\t\tif(spinner) {\r\n\t\t\tjQuery(spinner).css('display', 'none');\r\n\t\t}\r\n\r\n\t\tif(!notJson && typeof result !== 'object'){\r\n\t\t\tresult = JSON.parse(result);\r\n\t\t}\r\n\r\n\t\tif(result.error){\r\n\t\t\tsetTimeout(function(){ if(progressbar) progressbar.fadeOut('slow'); }, 1000);\r\n\t\t\tlet error_comment = typeof result.error_comment !== 'undefined' ? result.error_comment : null;\r\n\t\t\terrorOutput( result.error, error_comment );\r\n\t\t}else if(callback){\r\n\t\t\t\tcallback(result, data, params, obj);\r\n\t\t}\r\n\t};\r\n\r\n\t// Using passed successCallback() or default\r\n\tvar error = params.error || function(jqXHR, textStatus, errorThrown){\r\n\t\tif(button){\r\n\t\t\tbutton.removeAttribute('disabled');\r\n\t\t\tbutton.style.cursor = 'pointer';\r\n\t\t}\r\n\t\tif(spinner){\r\n\t\t\tjQuery(spinner).css('display', 'none');\r\n\t\t}\r\n\r\n\t\tconsole.log( '%c APBCT_AJAX_ERROR', 'color: red;' );\r\n\t\tconsole.log( textStatus );\r\n\t\tconsole.log( errorThrown );\r\n\t\tconsole.log( jqXHR );\r\n\r\n\t\terrorOutput( textStatus );\r\n\t};\r\n\r\n\tvar errorOutput = params.errorOutput || function( msg ){};\r\n\r\n\tjQuery.ajax({\r\n\t\tcontext: context,\r\n\t\ttype: \"POST\",\r\n\t\turl: spbcSettings.ajaxurl,\r\n\t\tdata: data,\r\n\t\tdataType: dataType,\r\n\t\tsuccess: success,\r\n\t\terror: error,\r\n\t\ttimeout: timeout,\r\n\t});\r\n}"],"names":["spbc_timestamp","Math","floor","Date","spbcHighlightElement","id","times","jQuery","animate","scrollTop","offset","top","addClass","outlineColor","removeClass","spbc_sendAJAXRequest","data","params","obj","dataType","notJson","button","spinner","progressbar","callback","timeout","context","this","success","setAttribute","style","cursor","css","security","spbcSettings","ajax_nonce","no_cache","random","result","error_comment","removeAttribute","JSON","parse","error","setTimeout","fadeOut","errorOutput","jqXHR","textStatus","errorThrown","console","log","msg","ajax","type","url","ajaxurl"],"mappings":"AAAA,SAASA,iBACR,OAAOC,KAAKC,MAAM,CAAC,IAAIC,KAAS,GAAI,CACrC,CAGA,SAASC,qBAAqBC,EAAIC,GACjCA,EAAQA,EAAM,GAAK,EACnBC,OAAO,YAAY,EAAEC,QAAQ,CAAEC,UAAWF,OAAOA,OAAO,IAAIF,CAAE,CAAC,EAAEK,OAAO,EAAEC,IAAM,GAAI,EAAG,MAAM,EAC7FJ,OAAO,IAAIF,CAAE,EAAEO,SAAS,kBAAkB,EAC1CL,OAAO,IAAIF,CAAE,EAAEG,QAAQ,CAACK,aAAc,sBAAuB,EAAG,IAAK,SAAU,WAC9EN,OAAO,IAAIF,CAAE,EAAEG,QAAQ,CAACK,aAAc,sBAAuB,EAAG,IAAK,SAAU,WACrE,EAANP,EACFF,qBAAqBC,EAAIC,CAAK,EAE9BC,OAAO,IAAIF,CAAE,EAAES,YAAY,kBAAkB,CAE/C,CAAC,CACF,CAAC,CACF,CAEA,SAASC,qBAAqBC,EAAMC,EAAQC,GAE3C,IAAIC,EAAcF,EAAOG,QAAU,OAAS,OAGxCC,EAAcJ,EAAOI,QAAe,KACpCC,EAAcL,EAAOK,SAAe,KACpCC,EAAcN,EAAOM,aAAe,KACpCC,EAAcP,EAAOO,UAAe,KACpCJ,EAAcH,EAAOG,SAAe,KACpCK,EAAcR,EAAOQ,SAAe,KACpCP,EAAcA,GAAsB,KACpCQ,EAAcT,EAAOS,SAAeC,KAWpCC,GARDP,IAAUA,EAAOQ,aAAa,WAAY,UAAU,EAAGR,EAAOS,MAAMC,OAAS,eAC7ET,GAASf,OAAOe,CAAO,EAAEU,IAAI,UAAW,QAAQ,EAGnDhB,EAAKiB,SAAWC,aAAaC,WAC7BnB,EAAKoB,SAAWnC,KAAKoC,OAAO,EAGdpB,EAAOW,SAAW,SAASU,GAcxC,IAEKC,EAfFlB,IACFA,EAAOmB,gBAAgB,UAAU,EACjCnB,EAAOS,MAAMC,OAAS,WAGpBT,GACFf,OAAOe,CAAO,EAAEU,IAAI,UAAW,MAAM,GAIrCM,EADGlB,GAA6B,UAAlB,OAAOkB,EAInBA,EAHOG,KAAKC,MAAMJ,CAAM,GAGjBK,OACTC,WAAW,WAAerB,GAAaA,EAAYsB,QAAQ,MAAM,CAAG,EAAG,GAAI,EACvEN,EAAgD,KAAA,IAAzBD,EAAOC,cAAgCD,EAAOC,cAAgB,KACzFO,EAAaR,EAAOK,MAAOJ,CAAc,GACjCf,GACPA,EAASc,EAAQtB,EAAMC,EAAQC,CAAG,CAErC,GAGIyB,EAAQ1B,EAAO0B,OAAS,SAASI,EAAOC,EAAYC,GACpD5B,IACFA,EAAOmB,gBAAgB,UAAU,EACjCnB,EAAOS,MAAMC,OAAS,WAEpBT,GACFf,OAAOe,CAAO,EAAEU,IAAI,UAAW,MAAM,EAGtCkB,QAAQC,IAAK,sBAAuB,aAAc,EAClDD,QAAQC,IAAKH,CAAW,EACxBE,QAAQC,IAAKF,CAAY,EACzBC,QAAQC,IAAKJ,CAAM,EAEnBD,EAAaE,CAAW,CACzB,EAEIF,EAAc7B,EAAO6B,aAAe,SAAUM,KAElD7C,OAAO8C,KAAK,CACX3B,QAAUA,EACV4B,KAAU,OACVC,IAAUrB,aAAasB,QACvBxC,KAAUA,EACVG,SAAUA,EACVS,QAAUA,EACVe,MAAUA,EACVlB,QAAUA,CACX,CAAC,CACF"} \ No newline at end of file +{"version":3,"file":"spbc-common.min.js","sources":["spbc-common.js"],"sourcesContent":["function spbc_timestamp(){\n\treturn Math.floor(+new Date() / 1000);\n}\n\n// Hightlights element\nfunction spbcHighlightElement(id, times){\n\ttimes = times-1 || 0;\n\tjQuery(\"html, body\").animate({ scrollTop: jQuery(jQuery('#'+id)).offset().top - 100 }, \"slow\");\n\tjQuery('#'+id).addClass('spbc_highlighted');\n\tjQuery('#'+id).animate({outlineColor: \"rgba(255, 0, 0, 1.0)\" }, 400, 'linear', function(){\n\t\tjQuery('#'+id).animate({outlineColor: \"rgba(255, 0, 0, 0.0)\" }, 400, 'linear', function(){\n\t\t\tif(times>0){\n\t\t\t\tspbcHighlightElement(id, times);\n\t\t\t}else{\n\t\t\t\tjQuery('#'+id).removeClass('spbc_highlighted');\n\t\t\t}\n\t\t});\n\t});\n}\n\nfunction spbc_sendAJAXRequest(data, params, obj){\n\n\tvar dataType = params.notJson ? 'text' : 'json';\n\n\t// Default params\n\tvar button = params.button || null;\n\tvar spinner = params.spinner || null;\n\tvar progressbar = params.progressbar || null;\n\tvar callback = params.callback || null;\n\tvar notJson = params.notJson || null;\n\tvar timeout = params.timeout || 15000;\n\tvar obj = obj || null;\n\tvar context = params.context || this;\n\n\t// Button and spinner\n\tif(button) {button.setAttribute('disabled', 'disabled'); button.style.cursor = 'not-allowed'; }\n\tif(spinner) jQuery(spinner).css('display', 'inline');\n\n\t// Adding security code\n\tdata.security = spbcSettings.ajax_nonce;\n\tdata.no_cache = Math.random();\n\n\t// Using passed successCallback() or default\n\tvar success = params.success || function(result){\n\t\tif(button){\n\t\t\tbutton.removeAttribute('disabled');\n\t\t\tbutton.style.cursor = 'pointer';\n\t\t}\n\n\t\tif(spinner) {\n\t\t\tjQuery(spinner).css('display', 'none');\n\t\t}\n\n\t\tif(!notJson && typeof result !== 'object'){\n\t\t\tresult = JSON.parse(result);\n\t\t}\n\n\t\tif(result.error){\n\t\t\tsetTimeout(function(){ if(progressbar) progressbar.fadeOut('slow'); }, 1000);\n\t\t\tlet error_comment = typeof result.error_comment !== 'undefined' ? result.error_comment : null;\n\t\t\terrorOutput( result.error, error_comment );\n\t\t}else if(callback){\n\t\t\t\tcallback(result, data, params, obj);\n\t\t}\n\t};\n\n\t// Using passed successCallback() or default\n\tvar error = params.error || function(jqXHR, textStatus, errorThrown){\n\t\tif(button){\n\t\t\tbutton.removeAttribute('disabled');\n\t\t\tbutton.style.cursor = 'pointer';\n\t\t}\n\t\tif(spinner){\n\t\t\tjQuery(spinner).css('display', 'none');\n\t\t}\n\n\t\tconsole.log( '%c APBCT_AJAX_ERROR', 'color: red;' );\n\t\tconsole.log( textStatus );\n\t\tconsole.log( errorThrown );\n\t\tconsole.log( jqXHR );\n\n\t\terrorOutput( textStatus );\n\t};\n\n\tvar errorOutput = params.errorOutput || function( msg ){};\n\n\tjQuery.ajax({\n\t\tcontext: context,\n\t\ttype: \"POST\",\n\t\turl: spbcSettings.ajaxurl,\n\t\tdata: data,\n\t\tdataType: dataType,\n\t\tsuccess: success,\n\t\terror: error,\n\t\ttimeout: timeout,\n\t});\n}"],"names":["spbc_timestamp","Math","floor","Date","spbcHighlightElement","id","times","jQuery","animate","scrollTop","offset","top","addClass","outlineColor","removeClass","spbc_sendAJAXRequest","data","params","obj","dataType","notJson","button","spinner","progressbar","callback","timeout","context","this","success","setAttribute","style","cursor","css","security","spbcSettings","ajax_nonce","no_cache","random","result","error_comment","removeAttribute","JSON","parse","error","setTimeout","fadeOut","errorOutput","jqXHR","textStatus","errorThrown","console","log","msg","ajax","type","url","ajaxurl"],"mappings":"AAAA,SAASA,iBACR,OAAOC,KAAKC,MAAM,CAAC,IAAIC,KAAS,GAAI,CACrC,CAGA,SAASC,qBAAqBC,EAAIC,GACjCA,EAAQA,EAAM,GAAK,EACnBC,OAAO,YAAY,EAAEC,QAAQ,CAAEC,UAAWF,OAAOA,OAAO,IAAIF,CAAE,CAAC,EAAEK,OAAO,EAAEC,IAAM,GAAI,EAAG,MAAM,EAC7FJ,OAAO,IAAIF,CAAE,EAAEO,SAAS,kBAAkB,EAC1CL,OAAO,IAAIF,CAAE,EAAEG,QAAQ,CAACK,aAAc,sBAAuB,EAAG,IAAK,SAAU,WAC9EN,OAAO,IAAIF,CAAE,EAAEG,QAAQ,CAACK,aAAc,sBAAuB,EAAG,IAAK,SAAU,WACrE,EAANP,EACFF,qBAAqBC,EAAIC,CAAK,EAE9BC,OAAO,IAAIF,CAAE,EAAES,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AKH,CAAW,EACxBE,QAAQC,IAAKF,CAAY,EACzBC,QAAQC,IAAKJ,CAAM,EAEnBD,EAAaE,CAAW,CACzB,EAEIF,EAAc7B,EAAO6B,aAAe,SAAUM,KAElD7C,OAAO8C,KAAK,CACX3B,QAAUA,EACV4B,KAAU,OACVC,IAAUrB,aAAasB,QACvBxC,KAAUA,EACVG,SAAUA,EACVS,QAAUA,EACVe,MAAUA,EACVlB,QAAUA,CACX,CAAC,CACF"} \ No newline at end of file diff --git a/js/spbc-cookie.min.js.map b/js/spbc-cookie.min.js.map index 8065c4002..a8796bfe5 100644 --- a/js/spbc-cookie.min.js.map +++ b/js/spbc-cookie.min.js.map @@ -1 +1 @@ -{"version":3,"file":"spbc-cookie.min.js","sources":["spbc-cookie.js"],"sourcesContent":["function spbc_setCookie( cookies, value, expires ){\r\n\r\n if( typeof cookies === 'string' && ( typeof value === 'string' || typeof value === 'number' ) ){\r\n cookies = [ [ cookies, value, expires ] ];\r\n }\r\n\r\n // Cookies disabled\r\n if( +spbcPublic.data__set_cookies === 0 ){\r\n return;\r\n\r\n // Using traditional cookies\r\n }else if( +spbcPublic.data__set_cookies === 1 ){\r\n cookies.forEach( function (item, i, arr\t) {\r\n var expires = typeof item[2] !== 'undefined' ? \"expires=\" + expires + '; ' : '';\r\n var ctSecure = location.protocol === 'https:' ? '; secure' : '';\r\n document.cookie = item[0] + \"=\" + encodeURIComponent(item[1]) + \"; \" + expires + \"path=/; samesite=lax\" + ctSecure;\r\n });\r\n\r\n // Using alternative cookies\r\n }else if( +spbcPublic.data__set_cookies === 2 ){\r\n\r\n // Using REST API handler\r\n if( +spbcPublic.data__set_cookies__alt_sessions_type === 1 ){\r\n spbc_sendRESTRequest(\r\n 'alt_sessions',\r\n {\r\n method: 'POST',\r\n data: { cookies: cookies }\r\n }\r\n );\r\n\r\n }\r\n // Using AJAX request and handler\r\n // }else if( +spbcPublic.data__set_cookies__alt_sessions_type === 2 ) {\r\n // apbct_public_sendAJAX(\r\n // {\r\n // action: 'apbct_alt_session__save__AJAX',\r\n // cookies: cookies,\r\n // },\r\n // {\r\n // apbct_ajax: 1,\r\n // notJson: 1,\r\n // }\r\n // );\r\n // }\r\n }\r\n}\r\n\r\nfunction spbc_sendRESTRequest( route, params ) {\r\n\r\n var callback = params.callback || null;\r\n var data = params.data || [];\r\n var method = params.method || 'POST';\r\n\r\n jQuery.ajax({\r\n type: method,\r\n url: spbcPublic._rest_url + 'cleantalk-security/v1/' + route,\r\n data: data,\r\n beforeSend : function ( xhr ) {\r\n xhr.setRequestHeader( 'X-WP-Nonce', spbcPublic._rest_nonce );\r\n },\r\n success: function(result){\r\n if(result.error){\r\n console.log('Security by Cleantalk. Error: ' + (result.error || 'Unknown'));\r\n }else{\r\n if(callback) {\r\n var obj = null;\r\n callback(result, route, params, obj);\r\n }\r\n }\r\n },\r\n error: function(jqXHR, textStatus, errorThrown){\r\n if( errorThrown ) {\r\n console.log('SPBCT_REST_ERROR');\r\n console.log(jqXHR);\r\n console.log(textStatus);\r\n console.log('Security by Cleantalk plugin REST API error: ' + errorThrown + ' Please, contact Cleantalk tech support https://wordpress.org/support/plugin/security-malware-firewall/');\r\n }\r\n },\r\n });\r\n\r\n}"],"names":["spbc_setCookie","cookies","value","expires","spbcPublic","data__set_cookies","forEach","item","i","arr","ctSecure","location","protocol","document","cookie","encodeURIComponent","data__set_cookies__alt_sessions_type","spbc_sendRESTRequest","method","data","route","params","callback","jQuery","ajax","type","url","_rest_url","beforeSend","xhr","setRequestHeader","_rest_nonce","success","result","error","console","log","jqXHR","textStatus","errorThrown"],"mappings":"AAAA,SAASA,eAAgBC,EAASC,EAAOC,GAEd,UAAnB,OAAOF,GAA2C,UAAjB,OAAOC,GAAuC,UAAjB,OAAOA,IACrED,EAAU,CAAE,CAAEA,EAASC,EAAOC,KAII,GAAlC,CAACC,WAAWC,oBAI4B,GAAlC,CAACD,WAAWC,kBAClBJ,EAAQK,QAAS,SAAUC,EAAMC,EAAGC,GAChC,IAAIN,EAA6B,KAAA,IAAZI,EAAK,GAAqB,WAAaJ,EAAU,KAAO,GACzEO,EAAiC,WAAtBC,SAASC,SAAwB,WAAa,GAC7DC,SAASC,OAASP,EAAK,GAAK,IAAMQ,mBAAmBR,EAAK,EAAE,EAAI,KAAOJ,EAAU,uBAAyBO,CAC9G,CAAC,EAGuC,GAAlC,CAACN,WAAWC,mBAGuC,GAArD,CAACD,WAAWY,sCACZC,qBACI,eACA,CACIC,OAAQ,OACRC,KAAM,CAAElB,QAASA,CAAQ,CAC7B,CACJ,EAiBZ,CAEA,SAASgB,qBAAsBG,EAAOC,GAElC,IAAIC,EAAWD,EAAOC,UAAY,KAC9BH,EAAWE,EAAOF,MAAQ,GAC1BD,EAAWG,EAAOH,QAAU,OAEhCK,OAAOC,KAAK,CACRC,KAAMP,EACNQ,IAAKtB,WAAWuB,UAAY,yBAA2BP,EACvDD,KAAMA,EACNS,WAAa,SAAWC,GACpBA,EAAIC,iBAAkB,aAAc1B,WAAW2B,WAAY,CAC/D,EACAC,QAAS,SAASC,GACXA,EAAOC,MACNC,QAAQC,IAAI,kCAAoCH,EAAOC,OAAS,UAAU,EAEvEZ,GAECA,EAASW,EAAQb,EAAOC,EADd,IACyB,CAG/C,EACAa,MAAO,SAASG,EAAOC,EAAYC,GAC3BA,IACAJ,QAAQC,IAAI,kBAAkB,EAC9BD,QAAQC,IAAIC,CAAK,EACjBF,QAAQC,IAAIE,CAAU,EACtBH,QAAQC,IAAI,gDAAkDG,EAAc,yGAAyG,EAE7L,CACJ,CAAC,CAEL"} \ No newline at end of file +{"version":3,"file":"spbc-cookie.min.js","sources":["spbc-cookie.js"],"sourcesContent":["function spbc_setCookie( cookies, value, expires ){\n\n if( typeof cookies === 'string' && ( typeof value === 'string' || typeof value === 'number' ) ){\n cookies = [ [ cookies, value, expires ] ];\n }\n\n // Cookies disabled\n if( +spbcPublic.data__set_cookies === 0 ){\n return;\n\n // Using traditional cookies\n }else if( +spbcPublic.data__set_cookies === 1 ){\n cookies.forEach( function (item, i, arr\t) {\n var expires = typeof item[2] !== 'undefined' ? \"expires=\" + expires + '; ' : '';\n var ctSecure = location.protocol === 'https:' ? '; secure' : '';\n document.cookie = item[0] + \"=\" + encodeURIComponent(item[1]) + \"; \" + expires + \"path=/; samesite=lax\" + ctSecure;\n });\n\n // Using alternative cookies\n }else if( +spbcPublic.data__set_cookies === 2 ){\n\n // Using REST API handler\n if( +spbcPublic.data__set_cookies__alt_sessions_type === 1 ){\n spbc_sendRESTRequest(\n 'alt_sessions',\n {\n method: 'POST',\n data: { cookies: cookies }\n }\n );\n\n }\n // Using AJAX request and handler\n // }else if( +spbcPublic.data__set_cookies__alt_sessions_type === 2 ) {\n // apbct_public_sendAJAX(\n // {\n // action: 'apbct_alt_session__save__AJAX',\n // cookies: cookies,\n // },\n // {\n // apbct_ajax: 1,\n // notJson: 1,\n // }\n // );\n // }\n }\n}\n\nfunction spbc_sendRESTRequest( route, params ) {\n\n var callback = params.callback || null;\n var data = params.data || [];\n var method = params.method || 'POST';\n\n jQuery.ajax({\n type: method,\n url: spbcPublic._rest_url + 'cleantalk-security/v1/' + route,\n data: data,\n beforeSend : function ( xhr ) {\n xhr.setRequestHeader( 'X-WP-Nonce', spbcPublic._rest_nonce );\n },\n success: function(result){\n if(result.error){\n console.log('Security by Cleantalk. Error: ' + (result.error || 'Unknown'));\n }else{\n if(callback) {\n var obj = null;\n callback(result, route, params, obj);\n }\n }\n },\n error: function(jqXHR, textStatus, errorThrown){\n if( errorThrown ) {\n console.log('SPBCT_REST_ERROR');\n console.log(jqXHR);\n console.log(textStatus);\n console.log('Security by Cleantalk plugin REST API error: ' + errorThrown + ' Please, contact Cleantalk tech support https://wordpress.org/support/plugin/security-malware-firewall/');\n }\n },\n });\n\n}"],"names":["spbc_setCookie","cookies","value","expires","spbcPublic","data__set_cookies","forEach","item","i","arr","ctSecure","location","protocol","document","cookie","encodeURIComponent","data__set_cookies__alt_sessions_type","spbc_sendRESTRequest","method","data","route","params","callback","jQuery","ajax","type","url","_rest_url","beforeSend","xhr","setRequestHeader","_rest_nonce","success","result","error","console","log","jqXHR","textStatus","errorThrown"],"mappings":"AAAA,SAASA,eAAgBC,EAASC,EAAOC,GAEd,UAAnB,OAAOF,GAA2C,UAAjB,OAAOC,GAAuC,UAAjB,OAAOA,IACrED,EAAU,CAAE,CAAEA,EAASC,EAAOC,KAII,GAAlC,CAACC,WAAWC,oBAI4B,GAAlC,CAACD,WAAWC,kBAClBJ,EAAQK,QAAS,SAAUC,EAAMC,EAAGC,GAChC,IAAIN,EAA6B,KAAA,IAAZI,EAAK,GAAqB,WAAaJ,EAAU,KAAO,GACzEO,EAAiC,WAAtBC,SAASC,SAAwB,WAAa,GAC7DC,SAASC,OAASP,EAAK,GAAK,IAAMQ,mBAAmBR,EAAK,EAAE,EAAI,KAAOJ,EAAU,uBAAyBO,CAC9G,CAAC,EAGuC,GAAlC,CAACN,WAAWC,mBAGuC,GAArD,CAACD,WAAWY,sCACZC,qBACI,eACA,CACIC,OAAQ,OACRC,KAAM,CAAElB,QAASA,CAAQ,CAC7B,CACJ,EAiBZ,CAEA,SAASgB,qBAAsBG,EAAOC,GAElC,IAAIC,EAAWD,EAAOC,UAAY,KAC9BH,EAAWE,EAAOF,MAAQ,GAC1BD,EAAWG,EAAOH,QAAU,OAEhCK,OAAOC,KAAK,CACRC,KAAMP,EACNQ,IAAKtB,WAAWuB,UAAY,yBAA2BP,EACvDD,KAAMA,EACNS,WAAa,SAAWC,GACpBA,EAAIC,iBAAkB,aAAc1B,WAAW2B,WAAY,CAC/D,EACAC,QAAS,SAASC,GACXA,EAAOC,MACNC,QAAQC,IAAI,kCAAoCH,EAAOC,OAAS,UAAU,EAEvEZ,GAECA,EAASW,EAAQb,EAAOC,EADd,IACyB,CAG/C,EACAa,MAAO,SAASG,EAAOC,EAAYC,GAC3BA,IACAJ,QAAQC,IAAI,kBAAkB,EAC9BD,QAAQC,IAAIC,CAAK,EACjBF,QAAQC,IAAIE,CAAU,EACtBH,QAAQC,IAAI,gDAAkDG,EAAc,yGAAyG,EAE7L,CACJ,CAAC,CAEL"} \ No newline at end of file diff --git a/js/spbc-dashboard-widget.min.js.map b/js/spbc-dashboard-widget.min.js.map index 199eb6815..313dfb739 100644 --- a/js/spbc-dashboard-widget.min.js.map +++ b/js/spbc-dashboard-widget.min.js.map @@ -1 +1 @@ -{"version":3,"file":"spbc-dashboard-widget.min.js","sources":["spbc-dashboard-widget.js"],"sourcesContent":["jQuery(document).ready(function(){\r\n\r\n\t// Set \"refresh\" link handler\r\n\tjQuery(\".spbc_widget_refresh_link\").on('click', function(){\r\n\t\tjQuery('.spbc_preloader').show();\r\n\t\tsetTimeout(function(){window.scrollTo(0, jQuery('#spbc_widget_wrapper').offset().top - 130);}, 1);\r\n\t\tsetTimeout(function(){jQuery(\"#spbc_refresh_form\").submit();}, 2500);\r\n\t});\r\n\r\n\tif(location.hash == '#ct_widget')\r\n\t\tsetTimeout(function(){window.scrollTo(0, jQuery('#spbc_widget_wrapper').offset().top - 130);}, 1);\r\n\r\n\t// Fixing default wrapper style\r\n\tjQuery(\"#spbc_widget_wrapper\").parent().css('padding', 0);\r\n\r\n\tlocale = navigator.language || navigator.userLanguage;\r\n\r\n\tvar date_formatter = new Intl.DateTimeFormat(locale, {\r\n\t\tmonth: \"short\",\r\n\t\tday: \"numeric\"\r\n\t});\r\n\r\n\tfunction reformatWidgetData(spbcDashboardWidget){\r\n\t\tlet widgetData = {'labels':[],'counts':[]}\r\n\t\tfor (let i = 0; i < spbcDashboardWidget.length; i++) {\r\n\t\t\twidgetData.labels.push(date_formatter.format(new Date(spbcDashboardWidget[i]['0'])))\r\n\t\t\twidgetData.counts.push(spbcDashboardWidget[i]['1'])\r\n\t\t}\r\n\t\treturn widgetData\r\n\t}\r\n\r\n\tconst ctx = document.getElementById('spbc_widget_chart')\r\n\t//let widgetData = reformatWidgetData(spbcDashboardWidget['data'])\r\n\tlet widgetDataFW = reformatWidgetData(spbcDashboardWidget['data_fw'])\r\n\tlet widgetDataBFP = reformatWidgetData(spbcDashboardWidget['data_bfp'])\r\n\r\n\tnew Chart(ctx, {\r\n\t\ttype: 'bar',\r\n\t\tdata: {\r\n\t\t\tlabels: widgetDataFW.labels,\r\n\t\t\tdatasets: [\r\n\t\t\t\t{\r\n\t\t\t\t\tlabel: 'Visitors blocked by Bruteforce Protection',\r\n\t\t\t\t\tdata: widgetDataBFP.counts,\r\n\t\t\t\t\tborderWidth: 1,\r\n\t\t\t\t\tbackgroundColor: 'gray'\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\tlabel: 'Visitors blocked by Firewall',\r\n\t\t\t\t\tdata: widgetDataFW.counts,\r\n\t\t\t\t\tborderWidth: 1,\r\n\t\t\t\t\tbackgroundColor: 'steelblue'\r\n\t\t\t\t}\r\n\t\t\t]\r\n\t\t},\r\n\t\toptions: {\r\n\t\t\tlegend: {\r\n\t\t\t\tdisplay: false\r\n\t\t\t},\r\n\t\t\tmaintainAspectRatio: false,\r\n\t\t\tresponsive: true,\r\n\t\t\tscales: {\r\n\t\t\t\ty: {\r\n\t\t\t\t\tticks: {\r\n\t\t\t\t\t\tprecision: 0\r\n\t\t\t\t\t}\r\n\t\t\t\t},\r\n\t\t\t},\r\n\t\t\ttitle: {\r\n\t\t\t\tdisplay: true,\r\n\t\t\t\ttext: 'Blocked attacks',\r\n\t\t\t\tfontSize: 18\r\n\t\t\t},\r\n\t\t\tplugins: {\r\n\t\t\t\tlegend: {\r\n\t\t\t\t\tdisplay: false\r\n\t\t\t\t},\r\n\t\t\t\ttitle: {\r\n\t\t\t\t\tdisplay: true,\r\n\t\t\t\t\ttext: 'Blocked attacks',\r\n\t\t\t\t\tfont: {\r\n\t\t\t\t\t\tsize: 18,\r\n\t\t\t\t\t}\r\n\t\t\t\t},\r\n\t\t\t},\r\n\t\t\telements: {\r\n\t\t\t\tbar:{\r\n\t\t\t\t\tbackgroundColor: 'steelblue'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tanimations: {\r\n\t\t\t\ttension: {\r\n\t\t\t\t\tduration: 1000,\r\n\t\t\t\t\teasing: 'linear',\r\n\t\t\t\t\tfrom: 1,\r\n\t\t\t\t\tto: 0,\r\n\t\t\t\t\tloop: true\r\n\t\t\t\t}\r\n\t\t\t},\r\n\r\n\t\t}\r\n\t});\r\n\r\n});\r\n"],"names":["jQuery","document","ready","on","show","setTimeout","window","scrollTo","offset","top","submit","location","hash","parent","css","locale","navigator","language","userLanguage","date_formatter","Intl","DateTimeFormat","month","day","reformatWidgetData","spbcDashboardWidget","let","widgetData","labels","counts","i","length","push","format","Date","ctx","getElementById","widgetDataFW","widgetDataBFP","Chart","type","data","datasets","label","borderWidth","backgroundColor","options","legend","display","maintainAspectRatio","responsive","scales","y","ticks","precision","title","text","fontSize","plugins","font","size","elements","bar","animations","tension","duration","easing","from","to","loop"],"mappings":"AAAAA,OAAOC,QAAQ,EAAEC,MAAM,WAGtBF,OAAO,2BAA2B,EAAEG,GAAG,QAAS,WAC/CH,OAAO,iBAAiB,EAAEI,KAAK,EAC/BC,WAAW,WAAWC,OAAOC,SAAS,EAAGP,OAAO,sBAAsB,EAAEQ,OAAO,EAAEC,IAAM,GAAG,CAAE,EAAG,CAAC,EAChGJ,WAAW,WAAWL,OAAO,oBAAoB,EAAEU,OAAO,CAAE,EAAG,IAAI,CACpE,CAAC,EAEmB,cAAjBC,SAASC,MACXP,WAAW,WAAWC,OAAOC,SAAS,EAAGP,OAAO,sBAAsB,EAAEQ,OAAO,EAAEC,IAAM,GAAG,CAAE,EAAG,CAAC,EAGjGT,OAAO,sBAAsB,EAAEa,OAAO,EAAEC,IAAI,UAAW,CAAC,EAExDC,OAASC,UAAUC,UAAYD,UAAUE,aAEzC,IAAIC,EAAiB,IAAIC,KAAKC,eAAeN,OAAQ,CACpDO,MAAO,QACPC,IAAK,SACN,CAAC,EAED,SAASC,EAAmBC,GAC3BC,IAAIC,EAAa,CAACC,OAAS,GAAGC,OAAS,EAAE,EACzC,IAAKH,IAAII,EAAI,EAAGA,EAAIL,EAAoBM,OAAQD,CAAC,GAChDH,EAAWC,OAAOI,KAAKb,EAAec,OAAO,IAAIC,KAAKT,EAAoBK,GAAG,EAAI,CAAC,CAAC,EACnFH,EAAWE,OAAOG,KAAKP,EAAoBK,GAAG,EAAI,EAEnD,OAAOH,CACR,CAEA,IAAMQ,EAAMlC,SAASmC,eAAe,mBAAmB,EAEnDC,EAAeb,EAAmBC,oBAA6B,OAAC,EAChEa,EAAgBd,EAAmBC,oBAA8B,QAAC,EAEtE,IAAIc,MAAMJ,EAAK,CACdK,KAAM,MACNC,KAAM,CACLb,OAAQS,EAAaT,OACrBc,SAAU,CACT,CACCC,MAAO,4CACPF,KAAMH,EAAcT,OACpBe,YAAa,EACbC,gBAAiB,MAClB,EACA,CACCF,MAAO,+BACPF,KAAMJ,EAAaR,OACnBe,YAAa,EACbC,gBAAiB,WAClB,EAEF,EACAC,QAAS,CACRC,OAAQ,CACPC,QAAS,CAAA,CACV,EACAC,oBAAqB,CAAA,EACrBC,WAAY,CAAA,EACZC,OAAQ,CACPC,EAAG,CACFC,MAAO,CACNC,UAAW,CACZ,CACD,CACD,EACAC,MAAO,CACNP,QAAS,CAAA,EACTQ,KAAM,kBACNC,SAAU,EACX,EACAC,QAAS,CACRX,OAAQ,CACPC,QAAS,CAAA,CACV,EACAO,MAAO,CACNP,QAAS,CAAA,EACTQ,KAAM,kBACNG,KAAM,CACLC,KAAM,EACP,CACD,CACD,EACAC,SAAU,CACTC,IAAI,CACHjB,gBAAiB,WAClB,CACD,EACAkB,WAAY,CACXC,QAAS,CACRC,SAAU,IACVC,OAAQ,SACRC,KAAM,EACNC,GAAI,EACJC,KAAM,CAAA,CACP,CACD,CAED,CACD,CAAC,CAEF,CAAC"} \ No newline at end of file +{"version":3,"file":"spbc-dashboard-widget.min.js","sources":["spbc-dashboard-widget.js"],"sourcesContent":["jQuery(document).ready(function(){\n\n\t// Set \"refresh\" link handler\n\tjQuery(\".spbc_widget_refresh_link\").on('click', function(){\n\t\tjQuery('.spbc_preloader').show();\n\t\tsetTimeout(function(){window.scrollTo(0, jQuery('#spbc_widget_wrapper').offset().top - 130);}, 1);\n\t\tsetTimeout(function(){jQuery(\"#spbc_refresh_form\").submit();}, 2500);\n\t});\n\n\tif(location.hash == '#ct_widget')\n\t\tsetTimeout(function(){window.scrollTo(0, jQuery('#spbc_widget_wrapper').offset().top - 130);}, 1);\n\n\t// Fixing default wrapper style\n\tjQuery(\"#spbc_widget_wrapper\").parent().css('padding', 0);\n\n\tlocale = navigator.language || navigator.userLanguage;\n\n\tvar date_formatter = new Intl.DateTimeFormat(locale, {\n\t\tmonth: \"short\",\n\t\tday: \"numeric\"\n\t});\n\n\tfunction reformatWidgetData(spbcDashboardWidget){\n\t\tlet widgetData = {'labels':[],'counts':[]}\n\t\tfor (let i = 0; i < spbcDashboardWidget.length; i++) {\n\t\t\twidgetData.labels.push(date_formatter.format(new Date(spbcDashboardWidget[i]['0'])))\n\t\t\twidgetData.counts.push(spbcDashboardWidget[i]['1'])\n\t\t}\n\t\treturn widgetData\n\t}\n\n\tconst ctx = document.getElementById('spbc_widget_chart')\n\t//let widgetData = reformatWidgetData(spbcDashboardWidget['data'])\n\tlet widgetDataFW = reformatWidgetData(spbcDashboardWidget['data_fw'])\n\tlet widgetDataBFP = reformatWidgetData(spbcDashboardWidget['data_bfp'])\n\n\tnew Chart(ctx, {\n\t\ttype: 'bar',\n\t\tdata: {\n\t\t\tlabels: widgetDataFW.labels,\n\t\t\tdatasets: [\n\t\t\t\t{\n\t\t\t\t\tlabel: 'Visitors blocked by Bruteforce Protection',\n\t\t\t\t\tdata: widgetDataBFP.counts,\n\t\t\t\t\tborderWidth: 1,\n\t\t\t\t\tbackgroundColor: 'gray'\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: 'Visitors blocked by Firewall',\n\t\t\t\t\tdata: widgetDataFW.counts,\n\t\t\t\t\tborderWidth: 1,\n\t\t\t\t\tbackgroundColor: 'steelblue'\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\toptions: {\n\t\t\tlegend: {\n\t\t\t\tdisplay: false\n\t\t\t},\n\t\t\tmaintainAspectRatio: false,\n\t\t\tresponsive: true,\n\t\t\tscales: {\n\t\t\t\ty: {\n\t\t\t\t\tticks: {\n\t\t\t\t\t\tprecision: 0\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\ttitle: {\n\t\t\t\tdisplay: true,\n\t\t\t\ttext: 'Blocked attacks',\n\t\t\t\tfontSize: 18\n\t\t\t},\n\t\t\tplugins: {\n\t\t\t\tlegend: {\n\t\t\t\t\tdisplay: false\n\t\t\t\t},\n\t\t\t\ttitle: {\n\t\t\t\t\tdisplay: true,\n\t\t\t\t\ttext: 'Blocked attacks',\n\t\t\t\t\tfont: {\n\t\t\t\t\t\tsize: 18,\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\telements: {\n\t\t\t\tbar:{\n\t\t\t\t\tbackgroundColor: 'steelblue'\n\t\t\t\t}\n\t\t\t},\n\t\t\tanimations: {\n\t\t\t\ttension: {\n\t\t\t\t\tduration: 1000,\n\t\t\t\t\teasing: 'linear',\n\t\t\t\t\tfrom: 1,\n\t\t\t\t\tto: 0,\n\t\t\t\t\tloop: true\n\t\t\t\t}\n\t\t\t},\n\n\t\t}\n\t});\n\n});\n"],"names":["jQuery","document","ready","on","show","setTimeout","window","scrollTo","offset","top","submit","location","hash","parent","css","locale","navigator","language","userLanguage","date_formatter","Intl","DateTimeFormat","month","day","reformatWidgetData","spbcDashboardWidget","let","widgetData","labels","counts","i","length","push","format","Date","ctx","getElementById","widgetDataFW","widgetDataBFP","Chart","type","data","datasets","label","borderWidth","backgroundColor","options","legend","display","maintainAspectRatio","responsive","scales","y","ticks","precision","title","text","fontSize","plugins","font","size","elements","bar","animations","tension","duration","easing","from","to","loop"],"mappings":"AAAAA,OAAOC,QAAQ,EAAEC,MAAM,WAGtBF,OAAO,2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Q,CACPC,QAAS,CAAA,CACV,EACAC,oBAAqB,CAAA,EACrBC,WAAY,CAAA,EACZC,OAAQ,CACPC,EAAG,CACFC,MAAO,CACNC,UAAW,CACZ,CACD,CACD,EACAC,MAAO,CACNP,QAAS,CAAA,EACTQ,KAAM,kBACNC,SAAU,EACX,EACAC,QAAS,CACRX,OAAQ,CACPC,QAAS,CAAA,CACV,EACAO,MAAO,CACNP,QAAS,CAAA,EACTQ,KAAM,kBACNG,KAAM,CACLC,KAAM,EACP,CACD,CACD,EACAC,SAAU,CACTC,IAAI,CACHjB,gBAAiB,WAClB,CACD,EACAkB,WAAY,CACXC,QAAS,CACRC,SAAU,IACVC,OAAQ,SACRC,KAAM,EACNC,GAAI,EACJC,KAAM,CAAA,CACP,CACD,CAED,CACD,CAAC,CAEF,CAAC"} \ No newline at end of file diff --git a/js/spbc-modal.min.js.map b/js/spbc-modal.min.js.map index e4f811fc8..6ee61daa4 100644 --- a/js/spbc-modal.min.js.map +++ b/js/spbc-modal.min.js.map @@ -1 +1 @@ -{"version":3,"file":"spbc-modal.min.js","sources":["spbc-modal.js"],"sourcesContent":["/* Cleantalk Modal object */\r\nspbcModal = {\r\n\r\n // Flags\r\n loaded: false,\r\n loading: false,\r\n opened: false,\r\n opening: false,\r\n\r\n // Methods\r\n load: function( action ) {\r\n if( ! this.loaded ) {\r\n this.loading = true;\r\n callback = function( result, data, params, obj ) {\r\n spbcModal.loading = false;\r\n spbcModal.loaded = result;\r\n document.dispatchEvent(\r\n new CustomEvent( \"spbcModalContentLoaded\", {\r\n bubbles: true,\r\n } )\r\n );\r\n };\r\n if( typeof spbc_sendAJAXRequest === \"function\" ) {\r\n spbc_sendAJAXRequest( { 'action' : action }, { 'callback': callback, 'notJson': true } );\r\n }\r\n\r\n }\r\n },\r\n\r\n putError: function( errorText ){\r\n var html = '

The error occurred

'\r\n + '

' + errorText + '

'\r\n + 'Contact tech support';\r\n this.put(html);\r\n },\r\n\r\n put: function ( html ) {\r\n spbcModal.loading = false;\r\n spbcModal.loaded = html;\r\n document.dispatchEvent(\r\n new CustomEvent( \"spbcModalContentLoaded\", {\r\n bubbles: true,\r\n } )\r\n );\r\n },\r\n\r\n open: function () {\r\n /* Cleantalk Modal CSS start */\r\n var renderCss = function () {\r\n var cssStr = '';\r\n for ( key in this.styles ) {\r\n cssStr += key + ':' + this.styles[key] + ';';\r\n }\r\n return cssStr;\r\n };\r\n var overlayCss = {\r\n styles: {\r\n \"z-index\": \"9999\",\r\n \"position\": \"fixed\",\r\n \"top\": \"0\",\r\n \"left\": \"0\",\r\n \"width\": \"100%\",\r\n \"height\": \"100%\",\r\n \"background\": \"rgba(0,0,0,0.5)\",\r\n \"display\": \"flex\",\r\n \"justify-content\" : \"center\",\r\n \"align-items\" : \"center\",\r\n },\r\n toString: renderCss\r\n };\r\n var innerCss = {\r\n styles: {\r\n \"position\" : \"relative\",\r\n \"padding\" : \"20px\",\r\n \"max-width\" : \"550px\",\r\n \"max-height\" : \"500px\",\r\n \"background\" : \"#FFF\",\r\n \"border\" : \"1px solid rgba(0,0,0,0.75)\",\r\n \"border-radius\" : \"4px\",\r\n \"box-shadow\" : \"7px 7px 5px 0px rgba(50,50,50,0.75)\",\r\n },\r\n toString: renderCss\r\n };\r\n var closeCss = {\r\n styles: {\r\n \"position\" : \"absolute\",\r\n \"background\" : \"#FFF\",\r\n \"width\" : \"20px\",\r\n \"height\" : \"20px\",\r\n \"border\" : \"2px solid rgba(0,0,0,0.75)\",\r\n \"border-radius\" : \"15px\",\r\n \"cursor\" : \"pointer\",\r\n \"top\" : \"-8px\",\r\n \"right\" : \"-8px\",\r\n },\r\n toString: renderCss\r\n };\r\n var closeCssBefore = {\r\n styles: {\r\n \"content\" : \"\\\"\\\"\",\r\n \"display\" : \"block\",\r\n \"position\" : \"absolute\",\r\n \"background\" : \"#000\",\r\n \"border-radius\" : \"1px\",\r\n \"width\" : \"2px\",\r\n \"height\" : \"16px\",\r\n \"top\" : \"2px\",\r\n \"left\" : \"9px\",\r\n \"transform\" : \"rotate(45deg)\",\r\n },\r\n toString: renderCss\r\n };\r\n var closeCssAfter = {\r\n styles: {\r\n \"content\" : \"\\\"\\\"\",\r\n \"display\" : \"block\",\r\n \"position\" : \"absolute\",\r\n \"background\" : \"#000\",\r\n \"border-radius\" : \"1px\",\r\n \"width\" : \"2px\",\r\n \"height\" : \"16px\",\r\n \"top\" : \"2px\",\r\n \"left\" : \"9px\",\r\n \"transform\" : \"rotate(-45deg)\",\r\n },\r\n toString: renderCss\r\n };\r\n var contentCss = {\r\n styles: {\r\n \"overflow-y\": \"auto\",\r\n \"max-height\": \"460px\",\r\n \"overflow-x\": \"hidden\",\r\n },\r\n toString: renderCss\r\n };\r\n var bodyCss = {\r\n styles: {\r\n \"overflow\" : \"hidden\",\r\n },\r\n toString: renderCss\r\n };\r\n var spbcModalStyle = document.createElement( 'style' );\r\n spbcModalStyle.setAttribute( 'id', 'spbc-modal-styles' );\r\n spbcModalStyle.innerHTML = 'body.spbc-modal-opened{' + bodyCss + '}';\r\n spbcModalStyle.innerHTML += '#spbc-modal-overlay{' + overlayCss + '}';\r\n spbcModalStyle.innerHTML += '#spbc-modal-close{' + closeCss + '}';\r\n spbcModalStyle.innerHTML += '#spbc-modal-close:before{' + closeCssBefore + '}';\r\n spbcModalStyle.innerHTML += '#spbc-modal-close:after{' + closeCssAfter + '}';\r\n spbcModalStyle.innerHTML += '#spbc-modal-content{' + contentCss + '}';\r\n document.body.append( spbcModalStyle );\r\n /* Cleantalk Modal CSS end */\r\n\r\n var overlay = document.createElement( 'div' );\r\n overlay.setAttribute( 'id', 'spbc-modal-overlay' );\r\n document.body.append( overlay );\r\n\r\n document.body.classList.add( 'spbc-modal-opened' );\r\n\r\n var inner = document.createElement( 'div' );\r\n inner.setAttribute( 'id', 'spbc-modal-inner' );\r\n inner.setAttribute( 'style', innerCss );\r\n overlay.append( inner );\r\n\r\n var close = document.createElement( 'div' );\r\n close.setAttribute( 'id', 'spbc-modal-close' );\r\n inner.append( close );\r\n\r\n var content = document.createElement( 'div' );\r\n if ( this.loaded ) {\r\n content.innerHTML = this.loaded;\r\n } else {\r\n content.innerHTML = 'Loading...';\r\n }\r\n content.setAttribute( 'id', 'spbc-modal-content' );\r\n inner.append( content );\r\n\r\n this.opened = true;\r\n\r\n return this;\r\n },\r\n\r\n close: function () {\r\n spbcModal.loaded = '';\r\n spbcModal.loading = false;\r\n document.body.classList.remove( 'spbc-modal-opened' );\r\n document.getElementById( 'spbc-modal-overlay' ).remove();\r\n document.getElementById( 'spbc-modal-styles' ).remove();\r\n document.dispatchEvent(\r\n new CustomEvent( \"spbcModalClosed\", {\r\n bubbles: true,\r\n } )\r\n );\r\n }\r\n\r\n};\r\n\r\n/* Cleantalk Modal helpers */\r\ndocument.addEventListener('click',function( e ){\r\n if( e.target && e.target.id === 'spbc-modal-overlay' || e.target.id === 'spbc-modal-close' ){\r\n spbcModal.close();\r\n }\r\n});\r\ndocument.addEventListener(\"spbcModalContentLoaded\", function( e ) {\r\n if( spbcModal.opened && spbcModal.loaded ) {\r\n document.getElementById( 'spbc-modal-content' ).innerHTML = spbcModal.loaded;\r\n }\r\n});"],"names":["spbcModal","loaded","loading","opened","opening","load","action","this","callback","result","data","params","obj","document","dispatchEvent","CustomEvent","bubbles","spbc_sendAJAXRequest","notJson","putError","errorText","put","html","open","renderCss","cssStr","key","styles","overlayCss","z-index","position","top","left","width","height","background","display","justify-content","align-items","toString","innerCss","padding","max-width","max-height","border","border-radius","box-shadow","closeCss","cursor","right","closeCssBefore","content","transform","closeCssAfter","contentCss","overflow-y","overflow-x","bodyCss","overflow","spbcModalStyle","createElement","overlay","setAttribute","innerHTML","body","append","inner","classList","add","close","remove","getElementById","addEventListener","e","target","id"],"mappings":"AACAA,UAAY,CAGRC,OAAQ,CAAA,EACRC,QAAS,CAAA,EACTC,OAAQ,CAAA,EACRC,QAAS,CAAA,EAGTC,KAAM,SAAUC,GACNC,KAAKN,SACPM,KAAKL,QAAU,CAAA,EACfM,SA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UAAYxD,KAAKN,OAEzBkD,EAAQY,UAAY,aAExBZ,EAAQW,aAAc,KAAM,oBAAqB,EACjDI,EAAMD,OAAQd,CAAQ,EAEtB5C,KAAKJ,OAAS,CAAA,EAEPI,IACX,EAEA8D,MAAO,WACHrE,UAAUC,OAAS,GACnBD,UAAUE,QAAU,CAAA,EACpBW,SAASmD,KAAKG,UAAUG,OAAQ,mBAAoB,EACpDzD,SAAS0D,eAAgB,oBAAqB,EAAED,OAAO,EACvDzD,SAAS0D,eAAgB,mBAAoB,EAAED,OAAO,EACtDzD,SAASC,cACL,IAAIC,YAAa,kBAAmB,CAChCC,QAAS,CAAA,CACb,CAAE,CACN,CACJ,CAEJ,EAGAH,SAAS2D,iBAAiB,QAAQ,SAAUC,IACpCA,EAAEC,QAA0B,uBAAhBD,EAAEC,OAAOC,IAA+C,qBAAhBF,EAAEC,OAAOC,KAC7D3E,UAAUqE,MAAM,CAExB,CAAC,EACDxD,SAAS2D,iBAAiB,yBAA0B,SAAUC,GACtDzE,UAAUG,QAAUH,UAAUC,SAC9BY,SAAS0D,eAAgB,oBAAqB,EAAER,UAAY/D,UAAUC,OAE9E,CAAC"} \ No newline at end of file +{"version":3,"file":"spbc-modal.min.js","sources":["spbc-modal.js"],"sourcesContent":["/* Cleantalk Modal object */\nspbcModal = {\n\n // Flags\n loaded: false,\n loading: false,\n opened: false,\n opening: false,\n\n // Methods\n load: function( action ) {\n if( ! this.loaded ) {\n this.loading = true;\n callback = function( result, data, params, obj ) {\n spbcModal.loading = false;\n spbcModal.loaded = result;\n document.dispatchEvent(\n new CustomEvent( \"spbcModalContentLoaded\", {\n bubbles: true,\n } )\n );\n };\n if( typeof spbc_sendAJAXRequest === \"function\" ) {\n spbc_sendAJAXRequest( { 'action' : action }, { 'callback': callback, 'notJson': true } );\n }\n\n }\n },\n\n putError: function( errorText ){\n var html = '

The error occurred

'\n + '

' + errorText + '

'\n + 'Contact tech support';\n this.put(html);\n },\n\n put: function ( html ) {\n spbcModal.loading = false;\n spbcModal.loaded = html;\n document.dispatchEvent(\n new CustomEvent( \"spbcModalContentLoaded\", {\n bubbles: true,\n } )\n );\n },\n\n open: function () {\n /* Cleantalk Modal CSS start */\n var renderCss = function () {\n var cssStr = '';\n for ( key in this.styles ) {\n cssStr += key + ':' + this.styles[key] + ';';\n }\n return cssStr;\n };\n var overlayCss = {\n styles: {\n \"z-index\": \"9999\",\n \"position\": \"fixed\",\n \"top\": \"0\",\n \"left\": \"0\",\n \"width\": \"100%\",\n \"height\": \"100%\",\n \"background\": \"rgba(0,0,0,0.5)\",\n \"display\": \"flex\",\n \"justify-content\" : \"center\",\n \"align-items\" : \"center\",\n },\n toString: renderCss\n };\n var innerCss = {\n styles: {\n \"position\" : \"relative\",\n \"padding\" : \"20px\",\n \"max-width\" : \"550px\",\n \"max-height\" : \"500px\",\n \"background\" : \"#FFF\",\n \"border\" : \"1px solid rgba(0,0,0,0.75)\",\n \"border-radius\" : \"4px\",\n \"box-shadow\" : \"7px 7px 5px 0px rgba(50,50,50,0.75)\",\n },\n toString: renderCss\n };\n var closeCss = {\n styles: {\n \"position\" : \"absolute\",\n \"background\" : \"#FFF\",\n \"width\" : \"20px\",\n \"height\" : \"20px\",\n \"border\" : \"2px solid rgba(0,0,0,0.75)\",\n \"border-radius\" : \"15px\",\n \"cursor\" : \"pointer\",\n \"top\" : \"-8px\",\n \"right\" : \"-8px\",\n },\n toString: renderCss\n };\n var closeCssBefore = {\n styles: {\n \"content\" : \"\\\"\\\"\",\n \"display\" : \"block\",\n \"position\" : \"absolute\",\n \"background\" : \"#000\",\n \"border-radius\" : \"1px\",\n \"width\" : \"2px\",\n \"height\" : \"16px\",\n \"top\" : \"2px\",\n \"left\" : \"9px\",\n \"transform\" : \"rotate(45deg)\",\n },\n toString: renderCss\n };\n var closeCssAfter = {\n styles: {\n \"content\" : \"\\\"\\\"\",\n \"display\" : \"block\",\n \"position\" : \"absolute\",\n \"background\" : \"#000\",\n \"border-radius\" : \"1px\",\n \"width\" : \"2px\",\n \"height\" : \"16px\",\n \"top\" : \"2px\",\n \"left\" : \"9px\",\n \"transform\" : \"rotate(-45deg)\",\n },\n toString: renderCss\n };\n var contentCss = {\n styles: {\n \"overflow-y\": \"auto\",\n \"max-height\": \"460px\",\n \"overflow-x\": \"hidden\",\n },\n toString: renderCss\n };\n var bodyCss = {\n styles: {\n \"overflow\" : \"hidden\",\n },\n toString: renderCss\n };\n var spbcModalStyle = document.createElement( 'style' );\n spbcModalStyle.setAttribute( 'id', 'spbc-modal-styles' );\n spbcModalStyle.innerHTML = 'body.spbc-modal-opened{' + bodyCss + '}';\n spbcModalStyle.innerHTML += '#spbc-modal-overlay{' + overlayCss + '}';\n spbcModalStyle.innerHTML += '#spbc-modal-close{' + closeCss + '}';\n spbcModalStyle.innerHTML += '#spbc-modal-close:before{' + closeCssBefore + '}';\n spbcModalStyle.innerHTML += '#spbc-modal-close:after{' + closeCssAfter + '}';\n spbcModalStyle.innerHTML += '#spbc-modal-content{' + contentCss + '}';\n document.body.append( spbcModalStyle );\n /* Cleantalk Modal CSS end */\n\n var overlay = document.createElement( 'div' );\n overlay.setAttribute( 'id', 'spbc-modal-overlay' );\n document.body.append( overlay );\n\n document.body.classList.add( 'spbc-modal-opened' );\n\n var inner = document.createElement( 'div' );\n inner.setAttribute( 'id', 'spbc-modal-inner' );\n inner.setAttribute( 'style', innerCss );\n overlay.append( inner );\n\n var close = document.createElement( 'div' );\n close.setAttribute( 'id', 'spbc-modal-close' );\n inner.append( close );\n\n var content = document.createElement( 'div' );\n if ( this.loaded ) {\n content.innerHTML = this.loaded;\n } else {\n content.innerHTML = 'Loading...';\n }\n content.setAttribute( 'id', 'spbc-modal-content' );\n inner.append( content );\n\n this.opened = true;\n\n return this;\n },\n\n close: function () {\n spbcModal.loaded = '';\n spbcModal.loading = false;\n document.body.classList.remove( 'spbc-modal-opened' );\n document.getElementById( 'spbc-modal-overlay' ).remove();\n document.getElementById( 'spbc-modal-styles' ).remove();\n document.dispatchEvent(\n new CustomEvent( \"spbcModalClosed\", {\n bubbles: true,\n } )\n );\n }\n\n};\n\n/* Cleantalk Modal helpers */\ndocument.addEventListener('click',function( e ){\n if( e.target && e.target.id === 'spbc-modal-overlay' || e.target.id === 'spbc-modal-close' ){\n spbcModal.close();\n }\n});\ndocument.addEventListener(\"spbcModalContentLoaded\", function( e ) {\n if( spbcModal.opened && spbcModal.loaded ) {\n document.getElementById( 'spbc-modal-content' ).innerHTML = spbcModal.loaded;\n }\n});"],"names":["spbcModal","loaded","loading","opened","opening","load","action","this","callback","result","data","params","obj","document","dispatchEvent","CustomEvent","bubbles","spbc_sendAJAXRequest","notJson","putError","errorText","put","html","open","renderCss","cssStr","key","styles","overlayCss","z-index","position","top","left","width","height","background","display","justify-content","align-items","toString","innerCss","padding","max-width","max-height","border","border-radius","box-shadow","closeCss","cursor","right","closeCssBefore","content","transform","closeCssAfter","contentCss","overflow-y","overflow-x","bodyCss","overflow","spbcModalStyle","createElement","overlay","setAttribute","innerHTML","body","append","inner","classList","add","close","remove","getElementById","addEventListener","e","target","id"],"mappings":"AACAA,UAAY,CAGRC,OAAQ,CAAA,EACRC,QAAS,CAAA,EACTC,OAAQ,CAAA,EACRC,QAAS,CAAA,EAGTC,KAAM,SAAUC,GACNC,KAAKN,SACPM,KAAKL,QAAU,CAAA,EACfM,SAAW,SAAUC,EAAQC,EAAMC,EAAQC,GACvCZ,UAAUE,QAAU,CAAA,EACpBF,UAAUC,OAASQ,EACnBI,SAASC,cACL,IAAIC,YAAa,yBAA0B,CACvCC,QAAS,CAAA,CACb,CAAE,CACN,CACJ,EACoC,YAAhC,OAAOC,sBACPA,qBAAsB,CAAEX,OAAWA,CAAO,EAAG,CAAEE,SAAYA,SAAUU,QAAW,CAAA,CAAK,CAAE,EAInG,EAEAC,SAAU,SAAUC,GAIhBb,KAAKc,IAHM,iCACGD,EACR,mKACO,CACjB,EAEAC,IAAK,SAAWC,GACZtB,UAAUE,QAAU,CAAA,EACpBF,UAAUC,OAAS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AE,CACN,CACJ,CAEJ,EAGAH,SAAS2D,iBAAiB,QAAQ,SAAUC,IACpCA,EAAEC,QAA0B,uBAAhBD,EAAEC,OAAOC,IAA+C,qBAAhBF,EAAEC,OAAOC,KAC7D3E,UAAUqE,MAAM,CAExB,CAAC,EACDxD,SAAS2D,iBAAiB,yBAA0B,SAAUC,GACtDzE,UAAUG,QAAUH,UAAUC,SAC9BY,SAAS0D,eAAgB,oBAAqB,EAAER,UAAY/D,UAAUC,OAE9E,CAAC"} \ No newline at end of file diff --git a/js/spbc-scanner-plugin.min.js.map b/js/spbc-scanner-plugin.min.js.map index fdf718653..1b349cdef 100644 --- a/js/spbc-scanner-plugin.min.js.map +++ b/js/spbc-scanner-plugin.min.js.map @@ -1 +1 @@ -{"version":3,"file":"spbc-scanner-plugin.min.js","sources":["spbc-scanner-plugin.js"],"sourcesContent":["'use strict';\r\n\r\nclass spbcMalwareScanner{\r\n\r\n\tfirst_start = true;\r\n\r\n\tactive = false;\r\n\r\n\troot = '';\r\n\tsettings = [];\r\n\tstates = [\r\n\t\t'get_cms_hashes',\r\n\t\t'get_modules_hashes',\r\n\t\t'clean_results',\r\n\t\t'file_system_analysis',\r\n\t\t'get_approved_hashes',\r\n\t\t'get_denied_hashes',\r\n\t\t'signature_analysis',\r\n\t\t'heuristic_analysis',\r\n\t\t'schedule_send_heuristic_critical_files',\r\n\t\t'auto_cure_backup',\r\n\t\t'auto_cure',\r\n\t\t'outbound_links',\r\n\t\t'frontend_analysis',\r\n\t\t'important_files_listing',\r\n\t\t'send_results',\r\n\t];\r\n\tstate = null;\r\n\toffset = 0;\r\n\tamount = 0;\r\n\tamount_coefficient = 1;\r\n\ttotal_scanned = 0;\r\n\tscan_percent = 0;\r\n\tpercent_completed = 0;\r\n\r\n\tpaused = false;\r\n\r\n\tbutton = null;\r\n\tspinner = null;\r\n\r\n\tprogress_overall = null;\r\n\tprogressbar = null;\r\n\tprogressbar_text = null;\r\n\r\n\ttimeout = 60000;\r\n\r\n\tstate_timer = 0;\r\n\r\n\tconstructor ( properties ) {\r\n\r\n\t\tconsole.log('init');\r\n\t\tif (jQuery('#spbcscan-results-log-module').length) {\r\n\t\t\tjQuery('.spbc-scan-log-title').removeClass('spbc---hidden')\r\n\t\t}\r\n\r\n\t\t// Crunch for cure backups\r\n\t\tif( typeof properties['settings']['auto_cure'] !== 'undefined' ){\r\n\t\t\tproperties['settings']['scanner__auto_cure_backup'] = '1';\r\n\t\t}\r\n\r\n\t\tfor( let key in properties ){\r\n\t\t\tif( typeof this[key] !== 'undefined' ){\r\n\t\t\t\tthis[key] = properties[key];\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t};\r\n\r\n\tactionControl(){\r\n\r\n\t\tif(this.state === null){\r\n\t\t\tthis.start();\r\n\r\n\t\t}else if(this.paused){\r\n\t\t\tthis.resume();\r\n\t\t\tthis.controller();\r\n\r\n\t\t}else{\r\n\t\t\tthis.pause();\r\n\t\t}\r\n\t};\r\n\r\n\tstart(){\r\n\r\n\t\tthis.active = true;\r\n\t\tthis.state_timer = Math.round(new Date().getTime() /1000);\r\n\r\n\t\tthis.state = this.getNextState( null );\r\n\r\n\t\tthis.setPercents( 0 );\r\n\t\tthis.scan_percent = 0;\r\n\t\tthis.offset = 0;\r\n\t\tthis.progress_overall.children('span')\r\n\t\t\t.removeClass('spbc_bold')\r\n\t\t\t.filter('.spbc_overall_scan_status_' + this.state)\r\n\t\t\t.addClass('spbc_bold');\r\n\r\n\t\tthis.progressbar.show(500);\r\n\t\tthis.progress_overall.show(500);\r\n\t\tthis.button.html(spbcScaner.button_scan_pause);\r\n\t\tthis.spinner.css({display: 'inline'});\r\n\r\n\t\tsetTimeout(() => {\r\n\t\t\tthis.controller();\r\n\t\t}, 1000);\r\n\r\n\t};\r\n\r\n\tpause( result, data, opt ){\r\n\t\tconsole.log('PAUSE');\r\n\t\tthis.button.html(spbcScaner.button_scan_resume);\r\n\t\tthis.spinner.css({display: 'none'});\r\n\t\tthis.paused = true;\r\n\t\tthis.active = false;\r\n\t};\r\n\r\n\tresume( opt ){\r\n\t\tconsole.log('RESUME');\r\n\t\tthis.button.html(spbcScaner.button_scan_pause);\r\n\t\tthis.spinner.css({display: 'inline'});\r\n\t\tthis.paused = false;\r\n\t\tthis.active = true;\r\n\t};\r\n\r\n\tend( reload ){\r\n\r\n\t\tthis.progressbar.hide(500);\r\n\t\tthis.progress_overall.hide(500);\r\n\t\tthis.button.html(spbcScaner.button_scan_perform);\r\n\t\tthis.spinner.css({display: 'none'});\r\n\t\tthis.state = null;\r\n\t\tthis.total_links = 0;\r\n\t\tthis.plug = false;\r\n\t\tthis.total_scanned = 0;\r\n\t\tthis.active = false;\r\n\r\n\t\tif(reload){\r\n\t\t\tdocument.location = document.location;\r\n\t\t}else{\r\n\t\t\tspbc_sendAJAXRequest(\r\n\t\t\t\t{action: 'spbc_scanner_tab__reload_accordion'},\r\n\t\t\t\t{\r\n\t\t\t\t\tnotJson: true,\r\n\t\t\t\t\tcallback: function(result, data, params, obj){\r\n\t\t\t\t\t\tjQuery(obj).accordion('destroy')\r\n\t\t\t\t\t\t\t.html(result)\r\n\t\t\t\t\t\t\t.accordion({\r\n\t\t\t\t\t\t\t\theader: 'h3',\r\n\t\t\t\t\t\t\t\theightStyle: 'content',\r\n\t\t\t\t\t\t\t\tcollapsible: true,\r\n\t\t\t\t\t\t\t\tactive: false,\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\tspbc_tbl__bulk_actions__listen();\r\n\t\t\t\t\t\tspbc_tbl__row_actions__listen();\r\n\t\t\t\t\t\tspbc_tbl__pagination__listen();\r\n\t\t\t\t\t\tspbc_tbl__sort__listen();\r\n\t\t\t\t\t\tspbcStartShowHide();\r\n\t\t\t\t\t\tspbc_scanner__reload_scan_info();\r\n\t\t\t\t\t},\r\n\t\t\t\t},\r\n\t\t\t\tjQuery('#spbc_scan_accordion')\r\n\t\t\t);\r\n\r\n\t\t\tif (!jQuery('#spbc_scanner_clear').length) {\r\n\t\t\t\tlet clear_link = '

Clear scanner logs


';\r\n\t\t\t\tjQuery(clear_link).insertBefore('#spbcscan-scanner-caption');\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t};\r\n\r\n\tcontroller( result ) {\r\n\r\n\t\tconsole.log(this.state);\r\n\r\n\t\t// The current stage is over. Switching to the new one\r\n\t\tif( typeof result !== 'undefined' && result.end ){\r\n\r\n\t\t\tthis.state = this.getNextState( this.state );\r\n\r\n\t\t\t// End condition\r\n\t\t\tif (typeof this.state === 'undefined'){\r\n\t\t\t\tthis.end();\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Set percent to 0\r\n\t\t\tthis.setPercents( 0 );\r\n\t\t\tthis.scan_percent = 0;\r\n\t\t\tthis.offset = 0;\r\n\r\n\t\t\t// Changing visualizing of the current stage\r\n\t\t\tthis.progress_overall.children('span')\r\n\t\t\t\t.removeClass('spbc_bold')\r\n\t\t\t\t.filter('.spbc_overall_scan_status_' + this.state)\r\n\t\t\t\t.addClass('spbc_bold');\r\n\t\t}\r\n\r\n\t\t// Break execution if paused\r\n\t\tif( this.paused === true )\r\n\t\t\treturn;\r\n\r\n\t\t// // AJAX params\r\n\t\tlet data = {\r\n\t\t\taction: 'spbc_scanner_controller_front',\r\n\t\t\tmethod: this.state,\r\n\t\t\toffset: this.offset,\r\n\t\t};\r\n\r\n\t\tvar params = {\r\n\t\t\ttype: 'GET',\r\n\t\t\tsuccess: this.success,\r\n\t\t\tcallback: this.successCallback,\r\n\t\t\terror: this.error,\r\n\t\t\terrorOutput: this.errorOutput,\r\n\t\t\tcomplete: null,\r\n\t\t\tcontext: this,\r\n\t\t\ttimeout: 120000\r\n\t\t};\r\n\r\n\t\tswitch (this.state) {\r\n\t\t\tcase 'get_modules_hashes': this.amount = 2; break;\r\n\t\t\tcase 'clear_table': this.amount = 10000; break;\r\n\t\t\tcase 'file_system_analysis': this.amount = 700; break;\r\n\t\t\tcase 'auto_cure': this.amount = 5; break;\r\n\t case 'outbound_links': this.amount = 10; break;\r\n\t case 'frontend_analysis': this.amount = spbcSettings.frontendAnalysisAmount; break;\r\n\t\t\tcase 'signature_analysis': this.amount = 10; data.status = 'UNKNOWN,MODIFIED,OK,INFECTED'; break;\r\n\t\t\tcase 'heuristic_analysis': this.amount = 4; data.status = 'UNKNOWN,MODIFIED,OK,INFECTED'; break;\r\n\t\t\tcase 'schedule_send_heuristic_critical_files': this.amount = 1; break;\r\n\t\t}\r\n\r\n\t\tdata.amount = Math.round(this.amount * this.amount_coefficient);\r\n\r\n\t\tspbc_sendAJAXRequest(\r\n\t\t\tdata,\r\n\t\t\tparams,\r\n\t\t\tjQuery('#spbc_scan_accordion')\r\n\t\t);\r\n\r\n\t};\r\n\r\n\tsetCoefficients( state ) {\r\n\t\tlet coefficient = this.amount_coefficient;\r\n\t\tswitch (state) {\r\n\t\t\tcase 'file_system_analysis': coefficient *= 1.5; break;\r\n\t\t}\r\n\t\tthis.amount_coefficient = coefficient;\r\n\t};\r\n\r\n\tgetNextState( state ) {\r\n\r\n\t\tstate = state === null ? this.states[0] : this.states[ this.states.indexOf( state ) + 1 ];\r\n\r\n\t\tif (typeof this.settings[ 'scanner__' + state ] !== 'undefined' && +this.settings[ 'scanner__' + state ] === 0)\r\n\t\t\tstate = this.getNextState( state );\r\n\r\n\t\treturn state;\r\n\t};\r\n\r\n\tsetPercents( percents ){\r\n\t\tthis.percent_completed = Math.floor( percents * 100 ) / 100;\r\n\t\tthis.progressbar.progressbar( 'option', 'value', this.percent_completed );\r\n\t\tthis.progressbar_text.text( spbcScaner[ 'progressbar_' + this.state ] + ' - ' + this.percent_completed + '%' );\r\n\t};\r\n\r\n\tsuccess( response ){\r\n\r\n\t\tif( !! response.error ){\r\n\r\n\t\t\tthis.error(\r\n\t\t\t\t{status: 200, responseText: response.error},\r\n\t\t\t\tresponse.error,\r\n\t\t\t\tresponse.msg\r\n\t\t\t);\r\n\r\n\t\t}else{\r\n\t\t\tif( this.successCallback )\r\n\t\t\t\tthis.successCallback( response, this.data, this.obj );\r\n\t\t}\r\n\r\n\t};\r\n\r\n\t// Processing response from backend\r\n\tsuccessCallback( result ){\r\n\r\n\t\tconsole.log( result );\r\n\r\n\t\tif( typeof result.total !== 'undefined' )\r\n\t\t\tthis.scan_percent = 100 / result.total;\r\n\r\n\t\tif( typeof result.processed_items !== 'undefined'){\r\n\r\n\t\t\tif( this.state === 'heuristic_analysis' && typeof result.total !== 0 )\r\n\t\t\t\tthis.logRaw('

Heuristic Analysis

');\r\n\t\t\tif( this.state === 'signature_analysis' && typeof result.total !== 0 )\r\n\t\t\t\tthis.logRaw('

Signature Analysis

');\r\n\r\n\t\t\tthis.logFileEntry( result.processed_items );\r\n\t\t}\r\n\r\n\t\tif( typeof result.stage_data_for_logging !== 'undefined'){\r\n\t\t\tthis.logStageEntry( result.stage_data_for_logging );\r\n\t\t}\r\n\r\n\t\t// Add link on shuffle salt if cured\r\n\t\tif (result.cured !== 'undefined' && Number(result.cured) > 0) {\r\n\t\t\tthis.showLinkForShuffleSalts(result.message);\r\n\t\t}\r\n\r\n\t\tif( result.end !== true && result.end !== 1 ){\r\n\t\t\tthis.setPercents( this.percent_completed + result.processed * this.scan_percent );\r\n\t\t\tthis.offset = this.offset + result.processed;\r\n\t\t\tthis.controller( result );\r\n\t\t}else{\r\n\t\t\tconsole.log( this.state + \" stage took \" + ( Math.round(new Date().getTime() /1000) - this.state_timer ) + \" seconds to complete\" );\r\n\t\t\tthis.state_timer = Math.round(new Date().getTime()/1000);\r\n\t\t\tthis.setPercents( 100 );\r\n\t\t\tthis.scan_percent = 0;\r\n\t\t\tthis.offset = 0;\r\n\t\t\tsetTimeout(() => {\r\n\t\t\t\tthis.controller( result );\r\n\t\t\t}, 300);\r\n\t\t}\r\n\t};\r\n\r\n\terror( xhr, status, error ){\r\n\r\n\t\tlet errorOutput = this.errorOutput;\r\n\r\n\t\tconsole.log( '%c APBCT_AJAX_ERROR', 'color: red;' );\r\n\t\tconsole.log( status );\r\n\t\tconsole.log( error );\r\n\t\tconsole.log( xhr );\r\n\r\n\t\tif (status == 'error' && (error == '' || error == 'Not found')) {\r\n if (!this.tryCount) {\r\n this.tryCount = 0;\r\n this.retryLimit = 30;\r\n }\r\n\t\t\tthis.tryCount++;\r\n\t\t\tconsole.log('Try #' + this.tryCount);\r\n\t\t\tthis.setCoefficients(this.state);\r\n\t\t\tif (this.tryCount <= this.retryLimit) {\r\n\t\t\t\tthis.pause();\r\n this.resume();\r\n this.controller();\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif( xhr.status === 200 ){\r\n\t\t\tif( status === 'parsererror' ){\r\n\t\t\t\terrorOutput( 'Unexpected response from server. See console for details.', this.state );\r\n\t\t\t\tconsole.log( '%c ' + xhr.responseText, 'color: pink;' );\r\n\t\t\t}else{\r\n\t\t\t\tlet error_string = status;\r\n\t\t\t\tif( typeof error !== 'undefined' )\r\n\t\t\t\t\terror_string += ' Additional info: ' + error;\r\n\t\t\t\terrorOutput( error_string, this.state );\r\n\t\t\t}\r\n\t\t}else if(xhr.status === 500){\r\n\t\t\terrorOutput( 'Internal server error.', this.state);\r\n\t\t}else\r\n\t\t\terrorOutput('Unexpected response code: ' + xhr.status + '. Error: ' + status, this.state);\r\n\r\n\t\tif( this.progressbar )\r\n\t\t\tthis.progressbar.fadeOut('slow');\r\n\r\n\t\tthis.end();\r\n\t};\r\n\r\n\terrorOutput( error_msg, stage ){\r\n\t\tspbcModal.open().putError( error_msg + '
Stage: ' + stage);\r\n\t};\r\n\r\n\tlogRaw(message_to_log ){\r\n\t\tjQuery('.spbc-scan-log-title').removeClass('spbc---hidden');\r\n\t\tjQuery('.spbc_log-wrapper').removeClass('spbc---hidden');\r\n\t\tjQuery('.spbc_log-wrapper .panel-body').prepend( message_to_log );\r\n\t};\r\n\r\n\tlogFileEntry(items){\r\n\t\tfor ( var key in items ){\r\n\t\t\tthis.logRaw( '

' + this.getSiteUTCShiftedTimeString() + ' - ' + items[ key ].path + ': ' + items[ key ].status + '

' );\r\n\t\t}\r\n\t};\r\n\r\n\tlogStageEntry(data){\r\n\t\tthis.logRaw( '

' + this.getSiteUTCShiftedTimeString() + ' - ' + '' + data.title + ' ' + '' + data.description + '

' );\r\n\t};\r\n\r\n\tshowLinkForShuffleSalts(message) {\r\n\t\tjQuery('#spbc_notice_about_shuffle_link').remove();\r\n\t\tjQuery(jQuery('.spbc_tab--active .spbc_wrapper_field p')[1])\r\n\t\t\t.after(\r\n\t\t\t\t'
' +\r\n\t\t\t\t'' +\r\n\t\t\t\tmessage +\r\n\t\t\t\t'' +\r\n\t\t\t\t'
'\r\n\t\t\t);\r\n\t}\r\n\r\n\tgetSiteUTCShiftedTimeString(){\r\n\t\tvar utc_shifted_ts = false;\r\n\t\t//gettings current system/browser offset\r\n\t\tvar current_browser_offset = new Date().getTimezoneOffset();\r\n\t\tcurrent_browser_offset = current_browser_offset * -1 * 1000 * 60;\r\n\t\t//chek if global ct object is defined\r\n\t\tif (typeof spbcScaner !== \"undefined\"\r\n\t\t\t&& typeof spbcScaner.timezone_shift !== \"undefined\"\r\n\t\t\t&& spbcScaner.timezone_shift !== false){\r\n\t\t\tutc_shifted_ts = Date.now() - current_browser_offset + (spbcScaner.timezone_shift * 1000);\r\n\t\t}\r\n\t\tvar ct_date = utc_shifted_ts ? new Date(utc_shifted_ts) : new Date();\r\n\t\t//construct date string\r\n\t\tvar shortMonthName = new Intl.DateTimeFormat(\"en-US\", { month: \"short\" }).format;\r\n\t\tvar minutes = String(ct_date.getMinutes()).padStart(2, '0');\r\n\t\tvar seconds = String(ct_date.getSeconds()).padStart(2, '0');\r\n\t\treturn shortMonthName(ct_date) + ' ' + ct_date.getDate() + ' ' + ct_date.getFullYear() + ' ' + ct_date.getHours() + ':' + minutes + ':' + seconds\r\n\t}\r\n\r\n}\r\n"],"names":["spbcMalwareScanner","first_start","active","root","settings","states","state","offset","amount","amount_coefficient","total_scanned","scan_percent","percent_completed","paused","button","spinner","progress_overall","progressbar","progressbar_text","timeout","state_timer","constructor","properties","let","key","console","log","jQuery","length","removeClass","this","actionControl","start","resume","controller","pause","Math","round","Date","getTime","getNextState","setPercents","children","filter","addClass","show","html","spbcScaner","button_scan_pause","css","display","setTimeout","result","data","opt","button_scan_resume","end","reload","hide","button_scan_perform","total_links","plug","document","location","spbc_sendAJAXRequest","action","notJson","callback","params","obj","accordion","header","heightStyle","collapsible","spbc_tbl__bulk_actions__listen","spbc_tbl__row_actions__listen","spbc_tbl__pagination__listen","spbc_tbl__sort__listen","spbcStartShowHide","spbc_scanner__reload_scan_info","insertBefore","method","type","success","successCallback","error","errorOutput","complete","context","spbcSettings","frontendAnalysisAmount","status","setCoefficients","coefficient","indexOf","percents","floor","text","response","responseText","msg","total","processed_items","logRaw","logFileEntry","stage_data_for_logging","logStageEntry","cured","Number","showLinkForShuffleSalts","message","processed","xhr","tryCount","retryLimit","error_string","fadeOut","error_msg","stage","spbcModal","open","putError","message_to_log","prepend","items","getSiteUTCShiftedTimeString","path","title","description","remove","after","utc_shifted_ts","current_browser_offset","getTimezoneOffset","ct_date","timezone_shift","now","shortMonthName","Intl","DateTimeFormat","month","format","minutes","String","getMinutes","padStart","seconds","getSeconds","getDate","getFullYear","getHours"],"mappings":"AAAA,mBAEMA,mBAELC,YAAc,CAAA,EAEdC,OAAS,CAAA,EAETC,KAAQ,GACRC,SAAW,GACXC,OAAS,CACR,iBACA,qBACA,gBACA,uBACA,sBACA,oBACA,qBACA,qBACA,yCACA,mBACA,YACA,iBACA,oBACA,0BACA,gBAEDC,MAAQ,KACRC,OAAS,EACTC,OAAS,EACTC,mBAAqB,EACrBC,cAAgB,EAChBC,aAAe,EACfC,kBAAoB,EAEpBC,OAAS,CAAA,EAETC,OAAS,KACTC,QAAU,KAEVC,iBAAmB,KACnBC,YAAc,KACdC,iBAAmB,KAEnBC,QAAU,IAEVC,YAAc,EAEdC,YAAcC,GAYb,IAAKC,IAAIC,KAVTC,QAAQC,IAAI,MAAM,EACdC,OAAO,8BAA8B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AKC,eAAe,QAAS,CAAEC,MAAO,OAAQ,CAAC,EAAEC,OACtEC,EAAUC,OAAOT,EAAQU,WAAW,CAAC,EAAEC,SAAS,EAAG,GAAG,EACtDC,EAAUH,OAAOT,EAAQa,WAAW,CAAC,EAAEF,SAAS,EAAG,GAAG,EAC1D,OAAOR,EAAeH,CAAO,EAAI,IAAMA,EAAQc,QAAQ,EAAI,IAAMd,EAAQe,YAAY,EAAI,IAAMf,EAAQgB,SAAS,EAAI,IAAMR,EAAU,IAAMI,CAC3I,CAED"} \ No newline at end of file +{"version":3,"file":"spbc-scanner-plugin.min.js","sources":["spbc-scanner-plugin.js"],"sourcesContent":["'use strict';\n\nclass spbcMalwareScanner{\n\n\tfirst_start = true;\n\n\tactive = false;\n\n\troot = '';\n\tsettings = [];\n\tstates = [\n\t\t'get_cms_hashes',\n\t\t'get_modules_hashes',\n\t\t'clean_results',\n\t\t'file_system_analysis',\n\t\t'get_approved_hashes',\n\t\t'get_denied_hashes',\n\t\t'signature_analysis',\n\t\t'heuristic_analysis',\n\t\t'schedule_send_heuristic_critical_files',\n\t\t'auto_cure_backup',\n\t\t'auto_cure',\n\t\t'outbound_links',\n\t\t'frontend_analysis',\n\t\t'important_files_listing',\n\t\t'send_results',\n\t];\n\tstate = null;\n\toffset = 0;\n\tamount = 0;\n\tamount_coefficient = 1;\n\ttotal_scanned = 0;\n\tscan_percent = 0;\n\tpercent_completed = 0;\n\n\tpaused = false;\n\n\tbutton = null;\n\tspinner = null;\n\n\tprogress_overall = null;\n\tprogressbar = null;\n\tprogressbar_text = null;\n\n\ttimeout = 60000;\n\n\tstate_timer = 0;\n\n\tconstructor ( properties ) {\n\n\t\tconsole.log('init');\n\t\tif (jQuery('#spbcscan-results-log-module').length) {\n\t\t\tjQuery('.spbc-scan-log-title').removeClass('spbc---hidden')\n\t\t}\n\n\t\t// Crunch for cure backups\n\t\tif( typeof properties['settings']['auto_cure'] !== 'undefined' ){\n\t\t\tproperties['settings']['scanner__auto_cure_backup'] = '1';\n\t\t}\n\n\t\tfor( let key in properties ){\n\t\t\tif( typeof this[key] !== 'undefined' ){\n\t\t\t\tthis[key] = properties[key];\n\t\t\t}\n\t\t}\n\n\t};\n\n\tactionControl(){\n\n\t\tif(this.state === null){\n\t\t\tthis.start();\n\n\t\t}else if(this.paused){\n\t\t\tthis.resume();\n\t\t\tthis.controller();\n\n\t\t}else{\n\t\t\tthis.pause();\n\t\t}\n\t};\n\n\tstart(){\n\n\t\tthis.active = true;\n\t\tthis.state_timer = Math.round(new Date().getTime() /1000);\n\n\t\tthis.state = this.getNextState( null );\n\n\t\tthis.setPercents( 0 );\n\t\tthis.scan_percent = 0;\n\t\tthis.offset = 0;\n\t\tthis.progress_overall.children('span')\n\t\t\t.removeClass('spbc_bold')\n\t\t\t.filter('.spbc_overall_scan_status_' + this.state)\n\t\t\t.addClass('spbc_bold');\n\n\t\tthis.progressbar.show(500);\n\t\tthis.progress_overall.show(500);\n\t\tthis.button.html(spbcScaner.button_scan_pause);\n\t\tthis.spinner.css({display: 'inline'});\n\n\t\tsetTimeout(() => {\n\t\t\tthis.controller();\n\t\t}, 1000);\n\n\t};\n\n\tpause( result, data, opt ){\n\t\tconsole.log('PAUSE');\n\t\tthis.button.html(spbcScaner.button_scan_resume);\n\t\tthis.spinner.css({display: 'none'});\n\t\tthis.paused = true;\n\t\tthis.active = false;\n\t};\n\n\tresume( opt ){\n\t\tconsole.log('RESUME');\n\t\tthis.button.html(spbcScaner.button_scan_pause);\n\t\tthis.spinner.css({display: 'inline'});\n\t\tthis.paused = false;\n\t\tthis.active = true;\n\t};\n\n\tend( reload ){\n\n\t\tthis.progressbar.hide(500);\n\t\tthis.progress_overall.hide(500);\n\t\tthis.button.html(spbcScaner.button_scan_perform);\n\t\tthis.spinner.css({display: 'none'});\n\t\tthis.state = null;\n\t\tthis.total_links = 0;\n\t\tthis.plug = false;\n\t\tthis.total_scanned = 0;\n\t\tthis.active = false;\n\n\t\tif(reload){\n\t\t\tdocument.location = document.location;\n\t\t}else{\n\t\t\tspbc_sendAJAXRequest(\n\t\t\t\t{action: 'spbc_scanner_tab__reload_accordion'},\n\t\t\t\t{\n\t\t\t\t\tnotJson: true,\n\t\t\t\t\tcallback: function(result, data, params, obj){\n\t\t\t\t\t\tjQuery(obj).accordion('destroy')\n\t\t\t\t\t\t\t.html(result)\n\t\t\t\t\t\t\t.accordion({\n\t\t\t\t\t\t\t\theader: 'h3',\n\t\t\t\t\t\t\t\theightStyle: 'content',\n\t\t\t\t\t\t\t\tcollapsible: true,\n\t\t\t\t\t\t\t\tactive: false,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\tspbc_tbl__bulk_actions__listen();\n\t\t\t\t\t\tspbc_tbl__row_actions__listen();\n\t\t\t\t\t\tspbc_tbl__pagination__listen();\n\t\t\t\t\t\tspbc_tbl__sort__listen();\n\t\t\t\t\t\tspbcStartShowHide();\n\t\t\t\t\t\tspbc_scanner__reload_scan_info();\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tjQuery('#spbc_scan_accordion')\n\t\t\t);\n\n\t\t\tif (!jQuery('#spbc_scanner_clear').length) {\n\t\t\t\tlet clear_link = '

Clear scanner logs


';\n\t\t\t\tjQuery(clear_link).insertBefore('#spbcscan-scanner-caption');\n\t\t\t}\n\t\t}\n\n\t};\n\n\tcontroller( result ) {\n\n\t\tconsole.log(this.state);\n\n\t\t// The current stage is over. Switching to the new one\n\t\tif( typeof result !== 'undefined' && result.end ){\n\n\t\t\tthis.state = this.getNextState( this.state );\n\n\t\t\t// End condition\n\t\t\tif (typeof this.state === 'undefined'){\n\t\t\t\tthis.end();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Set percent to 0\n\t\t\tthis.setPercents( 0 );\n\t\t\tthis.scan_percent = 0;\n\t\t\tthis.offset = 0;\n\n\t\t\t// Changing visualizing of the current stage\n\t\t\tthis.progress_overall.children('span')\n\t\t\t\t.removeClass('spbc_bold')\n\t\t\t\t.filter('.spbc_overall_scan_status_' + this.state)\n\t\t\t\t.addClass('spbc_bold');\n\t\t}\n\n\t\t// Break execution if paused\n\t\tif( this.paused === true )\n\t\t\treturn;\n\n\t\t// // AJAX params\n\t\tlet data = {\n\t\t\taction: 'spbc_scanner_controller_front',\n\t\t\tmethod: this.state,\n\t\t\toffset: this.offset,\n\t\t};\n\n\t\tvar params = {\n\t\t\ttype: 'GET',\n\t\t\tsuccess: this.success,\n\t\t\tcallback: this.successCallback,\n\t\t\terror: this.error,\n\t\t\terrorOutput: this.errorOutput,\n\t\t\tcomplete: null,\n\t\t\tcontext: this,\n\t\t\ttimeout: 120000\n\t\t};\n\n\t\tswitch (this.state) {\n\t\t\tcase 'get_modules_hashes': this.amount = 2; break;\n\t\t\tcase 'clear_table': this.amount = 10000; break;\n\t\t\tcase 'file_system_analysis': this.amount = 700; break;\n\t\t\tcase 'auto_cure': this.amount = 5; break;\n\t case 'outbound_links': this.amount = 10; break;\n\t case 'frontend_analysis': this.amount = spbcSettings.frontendAnalysisAmount; break;\n\t\t\tcase 'signature_analysis': this.amount = 10; data.status = 'UNKNOWN,MODIFIED,OK,INFECTED'; break;\n\t\t\tcase 'heuristic_analysis': this.amount = 4; data.status = 'UNKNOWN,MODIFIED,OK,INFECTED'; break;\n\t\t\tcase 'schedule_send_heuristic_critical_files': this.amount = 1; break;\n\t\t}\n\n\t\tdata.amount = Math.round(this.amount * this.amount_coefficient);\n\n\t\tspbc_sendAJAXRequest(\n\t\t\tdata,\n\t\t\tparams,\n\t\t\tjQuery('#spbc_scan_accordion')\n\t\t);\n\n\t};\n\n\tsetCoefficients( state ) {\n\t\tlet coefficient = this.amount_coefficient;\n\t\tswitch (state) {\n\t\t\tcase 'file_system_analysis': coefficient *= 1.5; break;\n\t\t}\n\t\tthis.amount_coefficient = coefficient;\n\t};\n\n\tgetNextState( state ) {\n\n\t\tstate = state === null ? this.states[0] : this.states[ this.states.indexOf( state ) + 1 ];\n\n\t\tif (typeof this.settings[ 'scanner__' + state ] !== 'undefined' && +this.settings[ 'scanner__' + state ] === 0)\n\t\t\tstate = this.getNextState( state );\n\n\t\treturn state;\n\t};\n\n\tsetPercents( percents ){\n\t\tthis.percent_completed = Math.floor( percents * 100 ) / 100;\n\t\tthis.progressbar.progressbar( 'option', 'value', this.percent_completed );\n\t\tthis.progressbar_text.text( spbcScaner[ 'progressbar_' + this.state ] + ' - ' + this.percent_completed + '%' );\n\t};\n\n\tsuccess( response ){\n\n\t\tif( !! response.error ){\n\n\t\t\tthis.error(\n\t\t\t\t{status: 200, responseText: response.error},\n\t\t\t\tresponse.error,\n\t\t\t\tresponse.msg\n\t\t\t);\n\n\t\t}else{\n\t\t\tif( this.successCallback )\n\t\t\t\tthis.successCallback( response, this.data, this.obj );\n\t\t}\n\n\t};\n\n\t// Processing response from backend\n\tsuccessCallback( result ){\n\n\t\tconsole.log( result );\n\n\t\tif( typeof result.total !== 'undefined' )\n\t\t\tthis.scan_percent = 100 / result.total;\n\n\t\tif( typeof result.processed_items !== 'undefined'){\n\n\t\t\tif( this.state === 'heuristic_analysis' && typeof result.total !== 0 )\n\t\t\t\tthis.logRaw('

Heuristic Analysis

');\n\t\t\tif( this.state === 'signature_analysis' && typeof result.total !== 0 )\n\t\t\t\tthis.logRaw('

Signature Analysis

');\n\n\t\t\tthis.logFileEntry( result.processed_items );\n\t\t}\n\n\t\tif( typeof result.stage_data_for_logging !== 'undefined'){\n\t\t\tthis.logStageEntry( result.stage_data_for_logging );\n\t\t}\n\n\t\t// Add link on shuffle salt if cured\n\t\tif (result.cured !== 'undefined' && Number(result.cured) > 0) {\n\t\t\tthis.showLinkForShuffleSalts(result.message);\n\t\t}\n\n\t\tif( result.end !== true && result.end !== 1 ){\n\t\t\tthis.setPercents( this.percent_completed + result.processed * this.scan_percent );\n\t\t\tthis.offset = this.offset + result.processed;\n\t\t\tthis.controller( result );\n\t\t}else{\n\t\t\tconsole.log( this.state + \" stage took \" + ( Math.round(new Date().getTime() /1000) - this.state_timer ) + \" seconds to complete\" );\n\t\t\tthis.state_timer = Math.round(new Date().getTime()/1000);\n\t\t\tthis.setPercents( 100 );\n\t\t\tthis.scan_percent = 0;\n\t\t\tthis.offset = 0;\n\t\t\tsetTimeout(() => {\n\t\t\t\tthis.controller( result );\n\t\t\t}, 300);\n\t\t}\n\t};\n\n\terror( xhr, status, error ){\n\n\t\tlet errorOutput = this.errorOutput;\n\n\t\tconsole.log( '%c APBCT_AJAX_ERROR', 'color: red;' );\n\t\tconsole.log( status );\n\t\tconsole.log( error );\n\t\tconsole.log( xhr );\n\n\t\tif (status == 'error' && (error == '' || error == 'Not found')) {\n if (!this.tryCount) {\n this.tryCount = 0;\n this.retryLimit = 30;\n }\n\t\t\tthis.tryCount++;\n\t\t\tconsole.log('Try #' + this.tryCount);\n\t\t\tthis.setCoefficients(this.state);\n\t\t\tif (this.tryCount <= this.retryLimit) {\n\t\t\t\tthis.pause();\n this.resume();\n this.controller();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif( xhr.status === 200 ){\n\t\t\tif( status === 'parsererror' ){\n\t\t\t\terrorOutput( 'Unexpected response from server. See console for details.', this.state );\n\t\t\t\tconsole.log( '%c ' + xhr.responseText, 'color: pink;' );\n\t\t\t}else{\n\t\t\t\tlet error_string = status;\n\t\t\t\tif( typeof error !== 'undefined' )\n\t\t\t\t\terror_string += ' Additional info: ' + error;\n\t\t\t\terrorOutput( error_string, this.state );\n\t\t\t}\n\t\t}else if(xhr.status === 500){\n\t\t\terrorOutput( 'Internal server error.', this.state);\n\t\t}else\n\t\t\terrorOutput('Unexpected response code: ' + xhr.status + '. Error: ' + status, this.state);\n\n\t\tif( this.progressbar )\n\t\t\tthis.progressbar.fadeOut('slow');\n\n\t\tthis.end();\n\t};\n\n\terrorOutput( error_msg, stage ){\n\t\tspbcModal.open().putError( error_msg + '
Stage: ' + stage);\n\t};\n\n\tlogRaw(message_to_log ){\n\t\tjQuery('.spbc-scan-log-title').removeClass('spbc---hidden');\n\t\tjQuery('.spbc_log-wrapper').removeClass('spbc---hidden');\n\t\tjQuery('.spbc_log-wrapper .panel-body').prepend( message_to_log );\n\t};\n\n\tlogFileEntry(items){\n\t\tfor ( var key in items ){\n\t\t\tthis.logRaw( '

' + this.getSiteUTCShiftedTimeString() + ' - ' + items[ key ].path + ': ' + items[ key ].status + '

' );\n\t\t}\n\t};\n\n\tlogStageEntry(data){\n\t\tthis.logRaw( '

' + this.getSiteUTCShiftedTimeString() + ' - ' + '' + data.title + ' ' + '' + data.description + '

' );\n\t};\n\n\tshowLinkForShuffleSalts(message) {\n\t\tjQuery('#spbc_notice_about_shuffle_link').remove();\n\t\tjQuery(jQuery('.spbc_tab--active .spbc_wrapper_field p')[1])\n\t\t\t.after(\n\t\t\t\t'
' +\n\t\t\t\t'' +\n\t\t\t\tmessage +\n\t\t\t\t'' +\n\t\t\t\t'
'\n\t\t\t);\n\t}\n\n\tgetSiteUTCShiftedTimeString(){\n\t\tvar utc_shifted_ts = false;\n\t\t//gettings current system/browser offset\n\t\tvar current_browser_offset = new Date().getTimezoneOffset();\n\t\tcurrent_browser_offset = current_browser_offset * -1 * 1000 * 60;\n\t\t//chek if global ct object is defined\n\t\tif (typeof spbcScaner !== \"undefined\"\n\t\t\t&& typeof spbcScaner.timezone_shift !== \"undefined\"\n\t\t\t&& spbcScaner.timezone_shift !== false){\n\t\t\tutc_shifted_ts = Date.now() - current_browser_offset + (spbcScaner.timezone_shift * 1000);\n\t\t}\n\t\tvar ct_date = utc_shifted_ts ? new Date(utc_shifted_ts) : new Date();\n\t\t//construct date string\n\t\tvar shortMonthName = new Intl.DateTimeFormat(\"en-US\", { month: \"short\" }).format;\n\t\tvar minutes = String(ct_date.getMinutes()).padStart(2, '0');\n\t\tvar seconds = String(ct_date.getSeconds()).padStart(2, '0');\n\t\treturn shortMonthName(ct_date) + ' ' + ct_date.getDate() + ' ' + ct_date.getFullYear() + ' ' + ct_date.getHours() + ':' + minutes + ':' + seconds\n\t}\n\n}\n"],"names":["spbcMalwareScanner","first_start","active","root","settings","states","state","offset","amount","amount_coefficient","total_scanned","scan_percent","percent_completed","paused","button","spinner","progress_overall","progressbar","progressbar_text","timeout","state_timer","constructor","properties","let","key","console","log","jQuery","length","removeClass","this","actionControl","start","resume","controller","pause","Math","round","Date","getTime","getNextState","setPercents","children","filter","addClass","show","html","spbcScaner","button_scan_pause","css","display","setTimeout","result","data","opt","button_scan_resume","end","reload","hide","button_scan_perform","total_links","plug","document","location","spbc_sendAJAXRequest","action","notJson","callback","params","obj","accordion","header","heightStyle","collapsible","spbc_tbl__bulk_actions__listen","spbc_tbl__row_actions__listen","spbc_tbl__pagination__listen","spbc_tbl__sort__listen","spbcStartShowHide","spbc_scanner__reload_scan_info","insertBefore","method","type","success","successCallback","error","errorOutput","complete","context","spbcSettings","frontendAnalysisAmount","status","setCoefficients","coefficient","indexOf","percents","floor","text","response","responseText","msg","total","processed_items","logRaw","logFileEntry","stage_data_for_logging","logStageEntry","cured","Number","showLinkForShuffleSalts","message","processed","xhr","tryCount","retryLimit","error_string","fadeOut","error_msg","stage","spbcModal","open","putError","message_to_log","prepend","items","getSiteUTCShiftedTimeString","path","title","description","remove","after","utc_shifted_ts","current_browser_offset","getTimezoneOffset","ct_date","timezone_shift","now","shortMonthName","Intl","DateTimeFormat","month","format","minutes","String","getMinutes","padStart","seconds","getSeconds","getDate","getFullYear","getHours"],"mappings":"AAAA,mBAEMA,mBAELC,YAAc,CAAA,EAEdC,OAAS,CAAA,EAETC,KAAQ,GACRC,SAAW,GACXC,OAAS,CACR,iBACA,qBACA,gBACA,uBACA,sBACA,oBACA,qBACA,qBACA,yCACA,mBACA,YACA,iBACA,oBACA,0BACA,gBAEDC,MAAQ,KACRC,OAAS,EACTC,OAAS,EACTC,mBAAqB,EACrBC,cAAgB,EAChBC,aAAe,EACfC,kBAAoB,EAEpBC,OAAS,CAAA,EAETC,OAAS,KACTC,QAAU,KAEVC,iBAAmB,KACnBC,YAAc,KACdC,iBAAmB,KAEnBC,QAAU,IAEVC,Y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WwF,eAEtDJ,GAAiB,IAAI7F,KAAK6F,CAAc,EAAI,IAAI7F,KAE1DmG,EAAiB,IAAIC,KAAKC,eAAe,QAAS,CAAEC,MAAO,OAAQ,CAAC,EAAEC,OACtEC,EAAUC,OAAOT,EAAQU,WAAW,CAAC,EAAEC,SAAS,EAAG,GAAG,EACtDC,EAAUH,OAAOT,EAAQa,WAAW,CAAC,EAAEF,SAAS,EAAG,GAAG,EAC1D,OAAOR,EAAeH,CAAO,EAAI,IAAMA,EAAQc,QAAQ,EAAI,IAAMd,EAAQe,YAAY,EAAI,IAAMf,EAAQgB,SAAS,EAAI,IAAMR,EAAU,IAAMI,CAC3I,CAED"} \ No newline at end of file diff --git a/js/spbc-settings.min.js.map b/js/spbc-settings.min.js.map index 96d6b2f03..0e4bdf068 100644 --- a/js/spbc-settings.min.js.map +++ b/js/spbc-settings.min.js.map @@ -1 +1 @@ -{"version":3,"file":"spbc-settings.min.js","sources":["spbc-settings.js"],"sourcesContent":["// Printf for JS\r\nString.prototype.printf = function(){\r\n var formatted = this;\r\n for( var arg in arguments ) {\r\n var before_formatted = formatted.substring(0, formatted.indexOf(\"%s\", 0));\r\n var after_formatted = formatted.substring(formatted.indexOf(\"%s\", 0)+2, formatted.length);\r\n formatted = before_formatted + arguments[arg] + after_formatted;\r\n }\r\n return formatted;\r\n};\r\n\r\n// Switching tabs\r\nfunction spbc_switchTab(tab, params){\r\n\r\n\tvar tab_name = tab.classList[1].replace('spbc_tab_nav-', '');\r\n\r\n\t// update url \r\n\tvar searchParams = new URLSearchParams(window.location.search)\r\n searchParams.set(\"spbc_tab\", tab_name);\r\n\tvar hashParam = window.location.hash;\r\n var newRelativePathQuery = window.location.pathname + '?' + searchParams.toString() + hashParam;\r\n\r\n history.replaceState(null, '', newRelativePathQuery);\r\n\r\n\t// Hiding a tab 'Backups' if exist\r\n if(searchParams.get('spbc_tab') !== 'backups') {\r\n \tjQuery('.spbc_tab_nav-backups').hide();\r\n }\r\n\r\n // update active tab\r\n\tjQuery('.spbc_tab_nav').removeClass('spbc_tab_nav--active');\r\n\tjQuery('.spbc_tab').removeClass('spbc_tab--active');\r\n\tjQuery(tab).addClass('spbc_tab_nav--active');\r\n\tjQuery('.spbc_tab-'+tab_name).addClass('spbc_tab--active');\r\n\r\n\tif(!jQuery(tab).data('loaded')){\r\n\t\tvar data = {\r\n\t\t\taction: 'spbc_settings__draw_elements',\r\n\t\t\ttab_name: tab_name,\r\n\t\t\tsecurity: spbcSettings.ajax_nonce\r\n\t\t};\r\n\t\tvar params = {\r\n\t\t\tcallback: spbc_draw_settings_callback,\r\n\t\t\tnotJson: true,\r\n additional: params || null,\r\n\t\t};\r\n\t\tspbc_sendAJAXRequest( data, params, tab );\r\n\t}else if(params && params.action){\r\n switch (params.action){\r\n case 'highlight':\r\n spbcHighlightElement(params.target, params.times);\r\n break;\r\n case 'click':\r\n setTimeout(function(){\r\n jQuery('#'+params.additional.target).click();\r\n }, 500);\r\n break;\r\n }\r\n\t}\r\n}\r\n\r\nfunction spbc_draw_settings_callback(result, data, params, obj){\r\n\r\n\tjQuery(obj).data('loaded', true);\r\n\tjQuery('.spbc_tab-'+data.tab_name).replaceWith(result);\r\n\tvar tab = jQuery('.spbc_tab-'+data.tab_name);\r\n\ttab.addClass('spbc_tab--active');\r\n\r\n\tjQuery(document).off( 'click', '.spbc_long_description__show');\r\n\tjQuery(document).on('click', '.spbc_long_description__show', function(){\r\n\t\tself = jQuery(this);\r\n\t\tspbc_settings__show_description(self, self.attr('setting'));\r\n\t});\r\n\r\n\tjQuery(document).off( 'click', '.spbc_long_recommendation__show');\r\n\tjQuery(document).on('click', '.spbc_long_recommendation__show', function(){\r\n\t\tself = jQuery(this);\r\n\t\tspbc_settings__show_recommendation(self, self.attr('setting'));\r\n\t});\r\n\r\n\tif(params.additional){\r\n\t switch (params.additional.action) {\r\n case 'highlight':\r\n\t\t spbcHighlightElement(params.additional.target, params.additional.times);\r\n break;\r\n case 'click':\r\n setTimeout(function(){\r\n\t\t jQuery('#'+params.additional.target).click();\r\n }, 500);\r\n break;\r\n }\r\n }\r\n\r\n\tjQuery(tab).on('click', '.spbc_hint-send_'+data.tab_name, function(){\r\n\t\t\tjQuery('.spbc_hint-send_'+data.tab_name).hide();\r\n\t\tspbc_sendAJAXRequest(\r\n\t\t\t{action: 'spbc_send_'+data.tab_name, tab_name: data.tab_name},\r\n\t\t\t{callback: spbc_send_logs_callback}\r\n\t\t);\r\n\t});\r\n\r\n\t// scroll to anchor\r\n\tif (window.location.hash) {\r\n\t\tdocument.getElementById(window.location.hash.substring(1)).scrollIntoView();\r\n\t}\r\n}\r\n\r\nfunction spbc_send_logs_callback(result, data, params, obj){\r\n\tjQuery('.spbc_tab_nav-'+data.tab_name).data('loaded', false);\r\n\tspbc_switchTab(document.getElementsByClassName('spbc_tab_nav-'+data.tab_name)[0]);\r\n}\r\n\r\n// Settings dependences\r\nfunction spbcSettingsDependenciesbyId(settingsIDs, enable){\r\n\r\n\tif(typeof settingsIDs === 'string'){\r\n\t\ttmp = [];\r\n\t\ttmp.push(settingsIDs);\r\n\t\tsettingsIDs = tmp;\r\n\t}\r\n\r\n\tenable = typeof enable === 'undefined' ? null : +enable;\r\n\r\n\tsettingsIDs.forEach(function(settingID, i, arr){\r\n\r\n\t\tvar elem = document.getElementById('spbc_setting_'+settingID),\r\n do_disable = function(){elem.setAttribute('disabled', 'disabled');},\r\n do_enable = function(){elem.removeAttribute('disabled');};\r\n\r\n if(enable !== null) // Set\r\n enable === 1 ? do_enable() : do_disable();\r\n else // Switch\r\n elem.getAttribute('disabled') === null ? do_disable() : do_enable();\r\n\r\n\t});\r\n}\r\n\r\n/**\r\n * Recursive in case children found!\r\n *\r\n * Settings dependencies\r\n *\r\n */\r\nfunction spbcSettingsDependencies(settingNames, enable){\r\n\r\n\t// Cast settingNames to array\r\n\tsettingNames = typeof settingNames === 'string' ? settingNames.split(',') : settingNames;\r\n\tenable = typeof enable === 'undefined' ? +event.target.checked : +enable;\r\n\r\n\tsettingNames.forEach(function(settingName, i, arr){\r\n\r\n\t\tdocument.getElementsByName('spbc_settings['+settingName+']')\r\n\t\t\t.forEach(function( elem, i, arr ){\r\n\r\n\t\t\t\tvar\tdo_disable = function(){elem.setAttribute('disabled', 'disabled');},\r\n\t\t\t\t\tdo_enable = function(){elem.removeAttribute('disabled');};\r\n\t\t\t\tif(enable !== null) // Set\r\n\t\t\t\t\tenable === 1 ? do_enable() : do_disable();\r\n\t\t\t\telse // Switch\r\n\t\t\t\t\telem.getAttribute('disabled') === null ? do_disable() : do_enable();\r\n\r\n\t\t\t\tvar children = elem.getAttribute('children');\r\n\t\t\t\tif( children !== null ){\r\n\t\t\t\t\tspbcSettingsDependencies(children, enable && elem.checked);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t});\r\n}\r\n\r\nfunction spbc_settings__show_description(label, setting_id){\r\n\t\r\n\tvar remove_desc_func = function(e){\r\n\t\tif(typeof e === 'undefined' || ((jQuery(e.target).parent('.spbc_long_desc').length == 0 || jQuery(e.target).hasClass('spbc_long_desc__cancel')) && !jQuery(e.target).hasClass('spbc_long_description__show'))){\r\n\t\t\tjQuery('.spbc_long_desc').remove();\r\n\t\t\tjQuery(document).off('click', remove_desc_func);\r\n\t\t}\r\n\t};\r\n\t\r\n\tremove_desc_func();\r\n\t\r\n\tlabel.after(\"
\");\r\n\tvar obj = jQuery('#spbc_long_desc__'+setting_id);\r\n\tobj.append(\"\")\r\n\t\t.append(\"
\")\r\n\t\t.css({\r\n\t\t\ttop: label.position().top + 25,\r\n\t\t\tleft: label.position().left + 5\r\n\t\t});\r\n\r\n\t\r\n\tspbc_sendAJAXRequest(\r\n\t\t{action: 'spbc_settings__get_description', setting_id: setting_id},\r\n\t\t{\r\n\t\t\tspinner: obj.children('img'),\r\n\t\t\tcallback: function(result, data, params, obj){\r\n\r\n\t\t\t\tobj.empty()\r\n\t\t\t\t\t.append(\"
\")\r\n\t\t\t\t\t.append(\"\")\r\n\t\t\t\t\t.append(\"

\"+result.title+\"

\")\r\n\t\t\t\t\t.append(\"

\"+result.desc+\"

\");\r\n\r\n\t\t\t\tjQuery(document).on('click', remove_desc_func);\r\n\t\t\t}\r\n\t\t},\r\n\t\tobj\r\n\t);\r\n}\r\n\r\nfunction spbc_settings__show_recommendation(label, setting_id){\r\n\t\r\n\tvar remove_recommendation_func = function(e){\r\n\t\tif(typeof e === 'undefined' || ((jQuery(e.target).parent('.spbc_long_desc').length == 0 || jQuery(e.target).hasClass('spbc_long_desc__cancel')) && !jQuery(e.target).hasClass('spbc_long_recommendation__show'))){\r\n\t\t\tjQuery('.spbc_long_desc').remove();\r\n\t\t\tjQuery(document).off('click', remove_recommendation_func);\r\n\t\t}\r\n\t};\r\n\t\r\n\tremove_recommendation_func();\r\n\t\r\n\tlabel.after(\"
\");\r\n\tvar obj = jQuery('#spbc_long_desc__'+setting_id);\r\n\tobj.append(\"\")\r\n\t\t.append(\"
\")\r\n\t\t.css({\r\n\t\t\ttop: label.position().top + 25,\r\n\t\t\tleft: label.position().left + 5\r\n\t\t});\r\n\r\n\t\r\n\tspbc_sendAJAXRequest(\r\n\t\t{action: 'spbc_settings__get_recommendation', setting_id: setting_id},\r\n\t\t{\r\n\t\t\tspinner: obj.children('img'),\r\n\t\t\tcallback: function(result, data, params, obj){\r\n\r\n\t\t\t\tobj.empty()\r\n\t\t\t\t\t.append(\"
\")\r\n\t\t\t\t\t.append(\"\")\r\n\t\t\t\t\t.append(\"

\"+result.title+\"

\")\r\n\t\t\t\t\t.append(\"

\"+result.desc+\"

\");\r\n\r\n\t\t\t\tjQuery(document).on('click', remove_recommendation_func);\r\n\t\t\t}\r\n\t\t},\r\n\t\tobj\r\n\t);\r\n}\r\n\r\n// Shows/hides full text\r\nfunction spbcStartShowHide(){\r\n\tjQuery('.spbcShortText')\r\n\t\t.off('mouseover' )\r\n\t\t.on('mouseover', function(){ jQuery(this).next().show(); })\r\n\t\t.off('mouseout' )\r\n\t\t.on('mouseout', function(){ jQuery(this).next().hide(); });\r\n\tjQuery('.spbcFullText')\r\n\t\t.off('mouseout' )\r\n\t\t.on('mouseout', function(){ jQuery(this).hide(); })\r\n\t\t.off('mouseover' )\r\n\t\t.on('mouseover', function(){ jQuery(this).show(); })\r\n}\r\n\r\n// Generate and save confirmation code\r\nfunction spbctGenerateConfirmationCode() {\r\n\r\n\tvar data = {};\r\n\tvar res = {};\r\n\tres.success = false;\r\n\tdata.security = spbcSettings.ajax_nonce;\r\n\tdata.action = 'spbc_generate_confirmation_code';\r\n\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\tasync: false,\r\n\t\turl: spbcSettings.ajaxurl,\r\n\t\tdata: data,\r\n\t\tsuccess: function(result){\r\n\t\t\tif(result.success) {\r\n\t\t\t\tres.success = true;\r\n\t\t\t} else {\r\n\t\t\t\tres.text = result.data;\r\n\t\t\t}\r\n\t\t},\r\n\t});\r\n\treturn res;\r\n}\r\n// Check confirmation code\r\nfunction spbctCheckConfirmationCode( radioButton, timeout, timer ) {\r\n\r\n\tvar element = radioButton;\r\n\tvar data = {};\r\n\tdata.security = spbcSettings.ajax_nonce;\r\n\tdata.action = 'spbc_check_confirmation_code';\r\n\tdata.code = jQuery('#confirmation-code input').val();\r\n\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\tasync: false,\r\n\t\turl: spbcSettings.ajaxurl,\r\n\t\tdata: data,\r\n\t\tsuccess: function(result){\r\n\t\t\tif(result.success) {\r\n\t\t\t\tjQuery('[name *= 2fa__enable]').attr(\"checked\", \"\");\r\n\t\t\t\telement.checked = true;\r\n\t\t\t\tjQuery('#spbc_setting_2fa__roles').removeAttr('disabled');\r\n\t\t\t\tjQuery('#spbc_setting_2fa__roles > option:first').attr('selected','selected');\r\n\t\t\t\tclearTimeout( timeout );\r\n\t\t\t\ttimer.remove();\r\n\t\t\t\tjQuery('#confirmation-code').dialog( \"close\" );\r\n\t\t\t} else {\r\n\t\t\t\talert('Code verification failed!');\r\n\t\t\t}\r\n\t\t},\r\n\t});\r\n\r\n}\r\n\r\n/**\r\n * Checking current account status for renew notice\r\n */\r\nfunction spbc_banner_check() {\r\n\tvar bannerChecker = setInterval( function() {\r\n\t\tspbc_sendAJAXRequest(\r\n\t\t\t{action: 'spbc_settings__check_renew_banner'},\r\n\t\t\t{\r\n\t\t\t\tcallback: function(result, data, params, obj){\r\n\t\t\t\t\tif (result.close_renew_banner) {\r\n\t\t\t\t\t\tif (jQuery('#spbc_renew_notice').length)\r\n\t\t\t\t\t\t\tjQuery('#spbc_renew_notice').hide('slow');\r\n\t\t\t\t\t\tif (jQuery('#spbc_trial_notice').length)\r\n\t\t\t\t\t\t\tjQuery('#spbc_trial_notice').hide('slow');\r\n\t\t\t\t\t\tclearInterval(bannerChecker);\r\n\t\t\t\t\t}\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t);\r\n\t}, 60000);\r\n}\r\n\r\njQuery(document).ready(function(){\r\n\t\r\n\tjQuery('#spbc_gdpr_open_modal').on('click', function(){\r\n\t\tjQuery('#gdpr_dialog').dialog({\r\n\t\t\tmodal:true, \r\n\t\t\tshow: true,\r\n\t\t\tposition: { my: \"center\", at: \"center\", of: window },\r\n\t\t\twidth: +(jQuery('#wpbody').width() / 100 * 70), // 70% of #wpbody\r\n\t\t\theight: 'auto',\r\n\t\t\ttitle: 'GDPR compliance',\r\n\t\t\tdraggable: false,\r\n\t\t\tresizable: false,\r\n\t\t\tcloseText: \"Close\",\r\n\t\t});\r\n\t});\r\n\r\n\t// Checking email receiving possibility for activation 2FA\r\n\tjQuery(document).on('click', '[name*=fa__enable]:not([value=0]),#confirmation-code--resend', function(e){\r\n\r\n\t\te.preventDefault();\r\n\r\n\t\tjQuery('#confirmation-code--resend').attr('disabled', 'disabled')\r\n\t\t\t.append('
');\r\n\t\tvar enableResend = setTimeout(function(){\r\n\t\t\tjQuery('#confirmation-code--resend').removeAttr('disabled');\r\n\t\t\tjQuery('#confirmation-code--resend>.circle').remove();\r\n\t\t}, 30000);\r\n\r\n\t\tvar res = spbctGenerateConfirmationCode();\r\n\t\tif( res.success ) {\r\n\t\t\tjQuery('#confirmation-code input').val('');\r\n\t\t\tjQuery('#confirmation-code').dialog({\r\n\t\t\t\tmodal: true,\r\n\t\t\t\ttitle: 'Confirmation code',\r\n\t\t\t\twidth: 310,\r\n\t\t\t\tbuttons: {\r\n\t\t\t\t\tCancel: function() {\r\n\t\t\t\t\t\tjQuery( this ).dialog( \"close\" );\r\n\t\t\t\t\t\tclearTimeout( enableResend );\r\n\t\t\t\t\t\tjQuery('#confirmation-code--resend>.circle').remove();\r\n\t\t\t\t\t},\r\n\t\t\t\t\tOk: function() {\r\n\t\t\t\t\t\tspbctCheckConfirmationCode(e.target, enableResend, jQuery('#confirmation-code--resend>.circle'));\r\n\t\t\t\t\t}\r\n\t\t\t\t},\r\n\t\t\t\tdraggable: false,\r\n\t\t\t\tresizable: false,\r\n\t\t\t});\r\n\t\t} else {\r\n\t\t\talert(res.text);\r\n\t\t}\r\n\t});\r\n\t\r\n\tif (jQuery('#spbc_renew_notice').length || jQuery('#spbc_trial_notice').length) {\r\n\t\tspbc_banner_check();\r\n\t}\r\n\r\n\t// Sync button\r\n\tjQuery('#spbc_button__sync').on('click', function(){\r\n\t\tspbc_sendAJAXRequest(\r\n\t\t\t{action: 'spbc_sync'},\r\n\t\t\t{\r\n\t\t\t\ttimeout: 25000,\r\n\t\t\t\tbutton: document.getElementById('spbc_button__sync' ),\r\n\t\t\t\tspinner: jQuery('#spbc_button__sync .spbc_preloader_button' ),\r\n\t\t\t\tcallback: function(result, data, params, obj){\r\n\t\t\t\t\tjQuery('#spbc_button__sync .spbc_success').show(300);\r\n\t\t\t\t\tsetTimeout(function(){jQuery('#spbc_button__sync .spbc_success').hide(300);}, 2000);\r\n\t\t\t\t\tif(result.reload)\r\n\t\t\t\t\t\tdocument.location.reload();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t);\r\n\t});\r\n\r\n\tif( spbcSettings.key_changed ){\r\n\t\tjQuery('#spbc_button__sync').click();\r\n\t}\r\n\r\n\t// Get Key Auto button\r\n\tjQuery(document).on('click', '#spbc_setting_get_key_auto', function(){\r\n\t\tspbc_sendAJAXRequest(\r\n\t\t\t{action: 'spbc_get_key_auto'},\r\n\t\t\t{\r\n\t\t\t\ttimeout: 25000,\r\n\t\t\t\tbutton: document.getElementById('spbc_setting_get_key_auto' ),\r\n\t\t\t\tspinner: jQuery('#spbc_setting_get_key_auto .spbc_preloader_button' ),\r\n\t\t\t\tcallback: function(result, data, params, obj){\r\n\t\t\t\t\tjQuery('#spbc_setting_get_key_auto .spbc_success').show(300);\r\n\t\t\t\t\tsetTimeout(function(){jQuery('#spbc_setting_get_key_auto .spbc_success').hide(300);}, 2000);\r\n\t\t\t\t\tif(result.reload)\r\n\t\t\t\t\t\tdocument.location.reload();\r\n\t\t\t\t\tif(result.msg) {\r\n\t\t\t\t\t\tspbcModal.open().putError(result.msg);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif(result.getTemplates) {\r\n\t\t\t\t\t\tspbcModal.loaded = result.getTemplates;\r\n\t\t\t\t\t\tspbcModal.open();\r\n\t\t\t\t\t\tdocument.addEventListener(\"spbcModalClosed\", function( e ) {\r\n\t\t\t\t\t\t\tdocument.location.reload();\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t);\r\n\t});\r\n\r\n\t// Import settings\r\n\tjQuery( document ).on('click', '#spbc_settings_templates_import_button', function(){\r\n\t\tjQuery('#spbc-ajax-result').remove();\r\n\t\tvar optionSelected = jQuery('option:selected', jQuery('#spbc_settings_templates_import'));\r\n\t\tvar templateNameInput = jQuery('#spbc_settings_templates_import_name');\r\n\t\ttemplateNameInput.css('border-color', 'inherit');\r\n\t\tif( typeof optionSelected.data('id') === \"undefined\" ) {\r\n\t\t\tconsole.log( 'Attribute \"data-id\" not set for the option.' );\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tvar data = {\r\n\t\t\t'template_id' : optionSelected.data('id'),\r\n\t\t\t'template_name' : optionSelected.data('name'),\r\n\t\t\t'settings' : optionSelected.data('settings')\r\n\t\t};\r\n\t\tvar button = this;\r\n\t\tspbc_sendAJAXRequest(\r\n\t\t\t{action: 'spbc_settings_templates_import', data: data},\r\n\t\t\t{\r\n\t\t\t\ttimeout: 25000,\r\n\t\t\t\tbutton: button,\r\n\t\t\t\tspinner: jQuery('#spbc_settings_templates_import_button .spbc_preloader_button' ),\r\n\t\t\t\tcallback: function(result, data, params, obj){\r\n\t\t\t\t\tif(result.success) {\r\n\t\t\t\t\t\tjQuery( \"

\" + result.data + \"

\" ).insertAfter( jQuery(button) );\r\n\t\t\t\t\t\tjQuery('#spbc_settings_templates_import_button .spbc_success').show(300);\r\n\t\t\t\t\t\tsetTimeout(function(){jQuery('#spbc_settings_templates_import_button .spbc_success').hide(300);}, 2000);\r\n\t\t\t\t\t\tdocument.addEventListener(\"spbcModalClosed\", function( e ) {\r\n\t\t\t\t\t\t\tdocument.location.reload();\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t\tsetTimeout(function(){spbcModal.close()}, 2000);\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tjQuery( \"

\" + result.data + \"

\" ).insertAfter( jQuery(button) );\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t);\r\n\t});\r\n\r\n\t// Export settings\r\n\tjQuery( document ).on('click', '#spbc_settings_templates_export_button', function(){\r\n\t\tjQuery('#spbc-ajax-result').remove();\r\n\t\tvar optionSelected = jQuery('option:selected', jQuery('#spbc_settings_templates_export'));\r\n\t\tvar templateNameInput = jQuery('#spbc_settings_templates_export_name');\r\n\t\ttemplateNameInput.css('border-color', 'inherit');\r\n\t\tif( typeof optionSelected.data('id') === \"undefined\" ) {\r\n\t\t\tconsole.log( 'Attribute \"data-id\" not set for the option.' );\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif( optionSelected.data('id') === 'new_template' ) {\r\n\t\t\tvar templateName = templateNameInput.val();\r\n\t\t\tif( templateName === '' ) {\r\n\t\t\t\ttemplateNameInput.css('border-color', 'red');\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tvar data = {\r\n\t\t\t\t'template_name' : templateName\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tvar data = {\r\n\t\t\t\t'template_id' : optionSelected.data('id')\r\n\t\t\t}\r\n\t\t}\r\n\t\tvar button = this;\r\n\t\tspbc_sendAJAXRequest(\r\n\t\t\t{action: 'spbc_settings_templates_export', data: data},\r\n\t\t\t{\r\n\t\t\t\ttimeout: 25000,\r\n\t\t\t\tbutton: button,\r\n\t\t\t\tspinner: jQuery('#spbc_settings_templates_export_button .spbc_preloader_button' ),\r\n\t\t\t\tcallback: function(result, data, params, obj){\r\n\t\t\t\t\tif(result.success) {\r\n\t\t\t\t\t\tjQuery( \"

\" + result.data + \"

\" ).insertAfter( jQuery(button) );\r\n\t\t\t\t\t\tjQuery('#spbc_settings_templates_export_button .spbc_success').show(300);\r\n\t\t\t\t\t\tsetTimeout(function(){jQuery('#spbc_settings_templates_export_button .spbc_success').hide(300);}, 2000);\r\n\t\t\t\t\t\tdocument.addEventListener(\"spbcModalClosed\", function( e ) {\r\n\t\t\t\t\t\t\tdocument.location.reload();\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t\tsetTimeout(function(){spbcModal.close()}, 2000);\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tjQuery( \"

\" + result.data + \"

\" ).insertAfter( jQuery(button) );\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t);\r\n\t});\r\n\r\n\t// Reset settings\r\n\tjQuery( document ).on('click', '#spbc_settings_templates_reset_button', function(){\r\n\t\tvar button = this;\r\n\t\tspbc_sendAJAXRequest(\r\n\t\t\t{action: 'spbc_settings_templates_reset'},\r\n\t\t\t{\r\n\t\t\t\ttimeout: 25000,\r\n\t\t\t\tbutton: button,\r\n\t\t\t\tspinner: jQuery('#spbc_settings_templates_reset_button .spbc_preloader_button' ),\r\n\t\t\t\tcallback: function(result, data, params, obj){\r\n\t\t\t\t\tif(result.success) {\r\n\t\t\t\t\t\tjQuery( \"

\" + result.data + \"

\" ).insertAfter( jQuery(button) );\r\n\t\t\t\t\t\tjQuery('#spbc_settings_templates_reset_button .spbc_success').show(300);\r\n\t\t\t\t\t\tsetTimeout(function(){jQuery('#spbc_settings_templates_reset_button .spbc_success').hide(300);}, 2000);\r\n\t\t\t\t\t\tdocument.addEventListener(\"spbcModalClosed\", function( e ) {\r\n\t\t\t\t\t\t\tdocument.location.reload();\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t\tsetTimeout(function(){spbcModal.close()}, 2000);\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tjQuery( \"

\" + result.data + \"

\" ).insertAfter( jQuery(button) );\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t);\r\n\t});\r\n\r\n\tjQuery(document).on('change', '#spbc_settings_templates_export',function(){\r\n\t\tvar optionSelected = jQuery(\"option:selected\", this);\r\n\t\tif ( optionSelected.data(\"id\") === 'new_template' ) {\r\n\t\t\tjQuery(this).parent().parent().find('#spbc_settings_templates_export_name').show();\r\n\t\t} else {\r\n\t\t\tjQuery(this).parent().parent().find('#spbc_settings_templates_export_name').hide();\r\n\t\t}\r\n\t});\r\n\r\n\t//* TAB_CONTROL\r\n\t\r\n\t\tjQuery('.spbc_tab_nav-summary').data('loaded', true); // Summary tab loaded by default\r\n\t\tjQuery('.spbc_tabs_nav_wrapper').on('click', '.spbc_tab_nav', function(event){\r\n\t\t\tspbc_switchTab(event.currentTarget);\r\n\t\t});\r\n\t\t\r\n\t\t// Get additional params\r\n var params = {\r\n target: location.search.match(/spbc_target=(\\S*?)(&|$)/) ? location.search.match(/spbc_target=(\\S*?)(&|$)/)[1] : null,\r\n action: location.search.match(/spbc_action=(\\S*?)(&|$)/) ? location.search.match(/spbc_action=(\\S*?)(&|$)/)[1] : null,\r\n times: location.search.match(/spbc_times=(\\S*?)(&|$)/) ? location.search.match(/spbc_times=(\\S*?)(&|$)/)[1] : 3,\r\n };\r\n // Legacy support\r\n params.target = location.search.match(/spbc_highlight=(\\S*?)(&|$)/) ? location.search.match(/spbc_highlight=(\\S*?)(&|$)/)[1] : params.target;\r\n params.action = location.search.search(/spbc_highlight=(\\S*?)(&|$)/) != -1\r\n ? 'highlight'\r\n : params.action;\r\n\r\n\t\t// Get open tab form query\r\n\t\tvar spbc_tab = document.getElementsByClassName('spbc_tab_nav-' + (location.search.match(/spbc_tab=(\\S*?)(&|$)/) ? location.search.match(/spbc_tab=(\\S*?)(&|$)/)[1] : ''))[0] || null;\r\n\r\n\t\t// TAB SWITCHING\r\n\t\t// Switch by URL\r\n\t\tif(spbc_tab){\r\n\r\n\t\t// Switch to DEBUG\r\n\t\t}else if( +spbcSettings.debug ){\r\n\t\t\tspbc_tab = document.getElementsByClassName('spbc_tab_nav-debug')[0];\r\n\t\t// Switch by DEFAULT\r\n\t\t}else if( +spbcSettings.wpms && !+spbcSettings.is_main_site){\r\n\t\t\tspbc_tab = document.getElementsByClassName('spbc_tab_nav-security_log')[0];\r\n\t\t// Switch if Key is OK and SFW is ON\r\n\t\t}else if( +spbcSettings.key_is_ok && +spbcSettings.secfw_enabled ){\r\n\t\t\tspbc_tab = document.getElementsByClassName('spbc_tab_nav-traffic_control')[0];\r\n\t\t// Switch if Key is OK\r\n\t\t}else if( +spbcSettings.key_is_ok ){\r\n\t\t\tspbc_tab = document.getElementsByClassName('spbc_tab_nav-scanner')[0];\r\n\t\t// Switch if KEY IS BAD\r\n\t\t}else{\r\n\t\t\tspbc_tab = document.getElementsByClassName('spbc_tab_nav-settings_general')[0];\r\n\t\t\tparams = {\r\n\t\t\t target: 'spbc_key',\r\n action: 'highlight',\r\n times: 3,\r\n };\r\n\t\t}\r\n\t\t\r\n\t\t// Switch tab\r\n\t\tif(spbc_tab) spbc_switchTab(spbc_tab, params);\r\n\t\t\r\n\t//*/ TAB_CONROL END\r\n\t\r\n\t//* REFRESH TAB IF ctrl+F5\r\n\tvar ctrlKeyDown = false;\r\n\r\n\tjQuery(document).on(\"keyup\", function(e) {\r\n\t\tif ((e.which || e.keyCode) == 17) ctrlKeyDown = false;\r\n\t});\r\n\r\n\tjQuery(document).on(\"keydown\", function(e) {\r\n\t\tif (((e.which || e.keyCode) == 116) && ctrlKeyDown) {\r\n\t\t\te.preventDefault();\r\n\r\n\t\t\tvar active_tab = jQuery('.spbc_tab_nav--active')[0];\r\n\t\t\tvar tab_name = active_tab.classList[1].replace('spbc_tab_nav-', '');\r\n\r\n\t\t\tif (tab_name === 'scanner') return; \r\n\r\n\t\t\tjQuery(active_tab).data('loaded', false);\r\n\r\n\t\t\tspbc_switchTab(active_tab);\r\n\r\n\t\t} else if ((e.which || e.keyCode) == 17) {\r\n\t ctrlKeyDown = true;\r\n\t }\r\n\t});\r\n\t//*/ REFRESH TAB IF ctrl+F5 END\r\n\r\n\t/**\r\n * Change cleantalk account email\r\n */\r\n jQuery(document).on('click', '#spbc-change-account-email', function(e) {\r\n e.preventDefault();\r\n\r\n let $this = jQuery(this);\r\n let accountEmailField = jQuery('#spbc-account-email');\r\n let accountEmail = accountEmailField.text();\r\n\r\n\t\tspbcToggleClass($this, 'active');\r\n\r\n if ($this.hasClass('active')) {\r\n $this.text($this.data('save-text'));\r\n accountEmailField.attr('contenteditable', 'true');\r\n\t\t\taccountEmailField.focus();\r\n accountEmailField.on('keydown', function(e) {\r\n if (e.code === 'Enter') {\r\n e.preventDefault();\r\n }\r\n });\r\n accountEmailField.on('input', function(e) {\r\n if (e.inputType === 'insertParagraph') {\r\n e.preventDefault();\r\n }\r\n });\r\n } else {\r\n spbc_sendAJAXRequest(\r\n {\r\n action: 'spbc_update_account_email',\r\n accountEmail: accountEmail,\r\n },\r\n {\r\n timeout: 5000,\r\n callback: function(result, data, params, obj) {\r\n if (result.success !== undefined && result.success === 'ok') {\r\n if (result.manuallyLink !== undefined) {\r\n jQuery('#spbc-key-manually-link').attr('href', result.manuallyLink);\r\n }\r\n }\r\n\r\n if (result.error !== undefined) {\r\n\t\t\t\t\t\t\r\n jQuery('#spbc-account-email').css('border-color', 'red');\r\n }\r\n },\r\n\t\t\t\t\terrorOutput: function(msg) {\r\n\t\t\t\t\t\tspbcModal.loaded = msg;\r\n\t\t\t\t\t\tspbcModal.open();\r\n\t\t\t\t\t}\r\n },\r\n );\r\n\r\n accountEmailField.attr('contenteditable', 'false');\r\n $this.text($this.data('default-text'));\r\n }\r\n });\r\n});\r\n\r\n/**\r\n * @param {string} className\r\n */\r\nfunction spbcToggleClass(arr, className) {\r\n\tfor (let i=0; i\");\n\tvar obj = jQuery('#spbc_long_desc__'+setting_id);\n\tobj.append(\"\")\n\t\t.append(\"
\")\n\t\t.css({\n\t\t\ttop: label.position().top + 25,\n\t\t\tleft: label.position().left + 5\n\t\t});\n\n\t\n\tspbc_sendAJAXRequest(\n\t\t{action: 'spbc_settings__get_description', setting_id: setting_id},\n\t\t{\n\t\t\tspinner: obj.children('img'),\n\t\t\tcallback: function(result, data, params, obj){\n\n\t\t\t\tobj.empty()\n\t\t\t\t\t.append(\"
\")\n\t\t\t\t\t.append(\"\")\n\t\t\t\t\t.append(\"

\"+result.title+\"

\")\n\t\t\t\t\t.append(\"

\"+result.desc+\"

\");\n\n\t\t\t\tjQuery(document).on('click', remove_desc_func);\n\t\t\t}\n\t\t},\n\t\tobj\n\t);\n}\n\nfunction spbc_settings__show_recommendation(label, setting_id){\n\t\n\tvar remove_recommendation_func = function(e){\n\t\tif(typeof e === 'undefined' || ((jQuery(e.target).parent('.spbc_long_desc').length == 0 || jQuery(e.target).hasClass('spbc_long_desc__cancel')) && !jQuery(e.target).hasClass('spbc_long_recommendation__show'))){\n\t\t\tjQuery('.spbc_long_desc').remove();\n\t\t\tjQuery(document).off('click', remove_recommendation_func);\n\t\t}\n\t};\n\t\n\tremove_recommendation_func();\n\t\n\tlabel.after(\"
\");\n\tvar obj = jQuery('#spbc_long_desc__'+setting_id);\n\tobj.append(\"\")\n\t\t.append(\"
\")\n\t\t.css({\n\t\t\ttop: label.position().top + 25,\n\t\t\tleft: label.position().left + 5\n\t\t});\n\n\t\n\tspbc_sendAJAXRequest(\n\t\t{action: 'spbc_settings__get_recommendation', setting_id: setting_id},\n\t\t{\n\t\t\tspinner: obj.children('img'),\n\t\t\tcallback: function(result, data, params, obj){\n\n\t\t\t\tobj.empty()\n\t\t\t\t\t.append(\"
\")\n\t\t\t\t\t.append(\"\")\n\t\t\t\t\t.append(\"

\"+result.title+\"

\")\n\t\t\t\t\t.append(\"

\"+result.desc+\"

\");\n\n\t\t\t\tjQuery(document).on('click', remove_recommendation_func);\n\t\t\t}\n\t\t},\n\t\tobj\n\t);\n}\n\n// Shows/hides full text\nfunction spbcStartShowHide(){\n\tjQuery('.spbcShortText')\n\t\t.off('mouseover' )\n\t\t.on('mouseover', function(){ jQuery(this).next().show(); })\n\t\t.off('mouseout' )\n\t\t.on('mouseout', function(){ jQuery(this).next().hide(); });\n\tjQuery('.spbcFullText')\n\t\t.off('mouseout' )\n\t\t.on('mouseout', function(){ jQuery(this).hide(); })\n\t\t.off('mouseover' )\n\t\t.on('mouseover', function(){ jQuery(this).show(); })\n}\n\n// Generate and save confirmation code\nfunction spbctGenerateConfirmationCode() {\n\n\tvar data = {};\n\tvar res = {};\n\tres.success = false;\n\tdata.security = spbcSettings.ajax_nonce;\n\tdata.action = 'spbc_generate_confirmation_code';\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\tasync: false,\n\t\turl: spbcSettings.ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(result){\n\t\t\tif(result.success) {\n\t\t\t\tres.success = true;\n\t\t\t} else {\n\t\t\t\tres.text = result.data;\n\t\t\t}\n\t\t},\n\t});\n\treturn res;\n}\n// Check confirmation code\nfunction spbctCheckConfirmationCode( radioButton, timeout, timer ) {\n\n\tvar element = radioButton;\n\tvar data = {};\n\tdata.security = spbcSettings.ajax_nonce;\n\tdata.action = 'spbc_check_confirmation_code';\n\tdata.code = jQuery('#confirmation-code input').val();\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\tasync: false,\n\t\turl: spbcSettings.ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(result){\n\t\t\tif(result.success) {\n\t\t\t\tjQuery('[name *= 2fa__enable]').attr(\"checked\", \"\");\n\t\t\t\telement.checked = true;\n\t\t\t\tjQuery('#spbc_setting_2fa__roles').removeAttr('disabled');\n\t\t\t\tjQuery('#spbc_setting_2fa__roles > option:first').attr('selected','selected');\n\t\t\t\tclearTimeout( timeout );\n\t\t\t\ttimer.remove();\n\t\t\t\tjQuery('#confirmation-code').dialog( \"close\" );\n\t\t\t} else {\n\t\t\t\talert('Code verification failed!');\n\t\t\t}\n\t\t},\n\t});\n\n}\n\n/**\n * Checking current account status for renew notice\n */\nfunction spbc_banner_check() {\n\tvar bannerChecker = setInterval( function() {\n\t\tspbc_sendAJAXRequest(\n\t\t\t{action: 'spbc_settings__check_renew_banner'},\n\t\t\t{\n\t\t\t\tcallback: function(result, data, params, obj){\n\t\t\t\t\tif (result.close_renew_banner) {\n\t\t\t\t\t\tif (jQuery('#spbc_renew_notice').length)\n\t\t\t\t\t\t\tjQuery('#spbc_renew_notice').hide('slow');\n\t\t\t\t\t\tif (jQuery('#spbc_trial_notice').length)\n\t\t\t\t\t\t\tjQuery('#spbc_trial_notice').hide('slow');\n\t\t\t\t\t\tclearInterval(bannerChecker);\n\t\t\t\t\t}\t\t\t\t\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}, 60000);\n}\n\njQuery(document).ready(function(){\n\t\n\tjQuery('#spbc_gdpr_open_modal').on('click', function(){\n\t\tjQuery('#gdpr_dialog').dialog({\n\t\t\tmodal:true, \n\t\t\tshow: true,\n\t\t\tposition: { my: \"center\", at: \"center\", of: window },\n\t\t\twidth: +(jQuery('#wpbody').width() / 100 * 70), // 70% of #wpbody\n\t\t\theight: 'auto',\n\t\t\ttitle: 'GDPR compliance',\n\t\t\tdraggable: false,\n\t\t\tresizable: false,\n\t\t\tcloseText: \"Close\",\n\t\t});\n\t});\n\n\t// Checking email receiving possibility for activation 2FA\n\tjQuery(document).on('click', '[name*=fa__enable]:not([value=0]),#confirmation-code--resend', function(e){\n\n\t\te.preventDefault();\n\n\t\tjQuery('#confirmation-code--resend').attr('disabled', 'disabled')\n\t\t\t.append('
');\n\t\tvar enableResend = setTimeout(function(){\n\t\t\tjQuery('#confirmation-code--resend').removeAttr('disabled');\n\t\t\tjQuery('#confirmation-code--resend>.circle').remove();\n\t\t}, 30000);\n\n\t\tvar res = spbctGenerateConfirmationCode();\n\t\tif( res.success ) {\n\t\t\tjQuery('#confirmation-code input').val('');\n\t\t\tjQuery('#confirmation-code').dialog({\n\t\t\t\tmodal: true,\n\t\t\t\ttitle: 'Confirmation code',\n\t\t\t\twidth: 310,\n\t\t\t\tbuttons: {\n\t\t\t\t\tCancel: function() {\n\t\t\t\t\t\tjQuery( this ).dialog( \"close\" );\n\t\t\t\t\t\tclearTimeout( enableResend );\n\t\t\t\t\t\tjQuery('#confirmation-code--resend>.circle').remove();\n\t\t\t\t\t},\n\t\t\t\t\tOk: function() {\n\t\t\t\t\t\tspbctCheckConfirmationCode(e.target, enableResend, jQuery('#confirmation-code--resend>.circle'));\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tdraggable: false,\n\t\t\t\tresizable: false,\n\t\t\t});\n\t\t} else {\n\t\t\talert(res.text);\n\t\t}\n\t});\n\t\n\tif (jQuery('#spbc_renew_notice').length || jQuery('#spbc_trial_notice').length) {\n\t\tspbc_banner_check();\n\t}\n\n\t// Sync button\n\tjQuery('#spbc_button__sync').on('click', function(){\n\t\tspbc_sendAJAXRequest(\n\t\t\t{action: 'spbc_sync'},\n\t\t\t{\n\t\t\t\ttimeout: 25000,\n\t\t\t\tbutton: document.getElementById('spbc_button__sync' ),\n\t\t\t\tspinner: jQuery('#spbc_button__sync .spbc_preloader_button' ),\n\t\t\t\tcallback: function(result, data, params, obj){\n\t\t\t\t\tjQuery('#spbc_button__sync .spbc_success').show(300);\n\t\t\t\t\tsetTimeout(function(){jQuery('#spbc_button__sync .spbc_success').hide(300);}, 2000);\n\t\t\t\t\tif(result.reload)\n\t\t\t\t\t\tdocument.location.reload();\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t});\n\n\tif( spbcSettings.key_changed ){\n\t\tjQuery('#spbc_button__sync').click();\n\t}\n\n\t// Get Key Auto button\n\tjQuery(document).on('click', '#spbc_setting_get_key_auto', function(){\n\t\tspbc_sendAJAXRequest(\n\t\t\t{action: 'spbc_get_key_auto'},\n\t\t\t{\n\t\t\t\ttimeout: 25000,\n\t\t\t\tbutton: document.getElementById('spbc_setting_get_key_auto' ),\n\t\t\t\tspinner: jQuery('#spbc_setting_get_key_auto .spbc_preloader_button' ),\n\t\t\t\tcallback: function(result, data, params, obj){\n\t\t\t\t\tjQuery('#spbc_setting_get_key_auto .spbc_success').show(300);\n\t\t\t\t\tsetTimeout(function(){jQuery('#spbc_setting_get_key_auto .spbc_success').hide(300);}, 2000);\n\t\t\t\t\tif(result.reload)\n\t\t\t\t\t\tdocument.location.reload();\n\t\t\t\t\tif(result.msg) {\n\t\t\t\t\t\tspbcModal.open().putError(result.msg);\n\t\t\t\t\t}\n\t\t\t\t\tif(result.getTemplates) {\n\t\t\t\t\t\tspbcModal.loaded = result.getTemplates;\n\t\t\t\t\t\tspbcModal.open();\n\t\t\t\t\t\tdocument.addEventListener(\"spbcModalClosed\", function( e ) {\n\t\t\t\t\t\t\tdocument.location.reload();\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t});\n\n\t// Import settings\n\tjQuery( document ).on('click', '#spbc_settings_templates_import_button', function(){\n\t\tjQuery('#spbc-ajax-result').remove();\n\t\tvar optionSelected = jQuery('option:selected', jQuery('#spbc_settings_templates_import'));\n\t\tvar templateNameInput = jQuery('#spbc_settings_templates_import_name');\n\t\ttemplateNameInput.css('border-color', 'inherit');\n\t\tif( typeof optionSelected.data('id') === \"undefined\" ) {\n\t\t\tconsole.log( 'Attribute \"data-id\" not set for the option.' );\n\t\t\treturn;\n\t\t}\n\t\tvar data = {\n\t\t\t'template_id' : optionSelected.data('id'),\n\t\t\t'template_name' : optionSelected.data('name'),\n\t\t\t'settings' : optionSelected.data('settings')\n\t\t};\n\t\tvar button = this;\n\t\tspbc_sendAJAXRequest(\n\t\t\t{action: 'spbc_settings_templates_import', data: data},\n\t\t\t{\n\t\t\t\ttimeout: 25000,\n\t\t\t\tbutton: button,\n\t\t\t\tspinner: jQuery('#spbc_settings_templates_import_button .spbc_preloader_button' ),\n\t\t\t\tcallback: function(result, data, params, obj){\n\t\t\t\t\tif(result.success) {\n\t\t\t\t\t\tjQuery( \"

\" + result.data + \"

\" ).insertAfter( jQuery(button) );\n\t\t\t\t\t\tjQuery('#spbc_settings_templates_import_button .spbc_success').show(300);\n\t\t\t\t\t\tsetTimeout(function(){jQuery('#spbc_settings_templates_import_button .spbc_success').hide(300);}, 2000);\n\t\t\t\t\t\tdocument.addEventListener(\"spbcModalClosed\", function( e ) {\n\t\t\t\t\t\t\tdocument.location.reload();\n\t\t\t\t\t\t});\n\t\t\t\t\t\tsetTimeout(function(){spbcModal.close()}, 2000);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tjQuery( \"

\" + result.data + \"

\" ).insertAfter( jQuery(button) );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t});\n\n\t// Export settings\n\tjQuery( document ).on('click', '#spbc_settings_templates_export_button', function(){\n\t\tjQuery('#spbc-ajax-result').remove();\n\t\tvar optionSelected = jQuery('option:selected', jQuery('#spbc_settings_templates_export'));\n\t\tvar templateNameInput = jQuery('#spbc_settings_templates_export_name');\n\t\ttemplateNameInput.css('border-color', 'inherit');\n\t\tif( typeof optionSelected.data('id') === \"undefined\" ) {\n\t\t\tconsole.log( 'Attribute \"data-id\" not set for the option.' );\n\t\t\treturn;\n\t\t}\n\t\tif( optionSelected.data('id') === 'new_template' ) {\n\t\t\tvar templateName = templateNameInput.val();\n\t\t\tif( templateName === '' ) {\n\t\t\t\ttemplateNameInput.css('border-color', 'red');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar data = {\n\t\t\t\t'template_name' : templateName\n\t\t\t}\n\t\t} else {\n\t\t\tvar data = {\n\t\t\t\t'template_id' : optionSelected.data('id')\n\t\t\t}\n\t\t}\n\t\tvar button = this;\n\t\tspbc_sendAJAXRequest(\n\t\t\t{action: 'spbc_settings_templates_export', data: data},\n\t\t\t{\n\t\t\t\ttimeout: 25000,\n\t\t\t\tbutton: button,\n\t\t\t\tspinner: jQuery('#spbc_settings_templates_export_button .spbc_preloader_button' ),\n\t\t\t\tcallback: function(result, data, params, obj){\n\t\t\t\t\tif(result.success) {\n\t\t\t\t\t\tjQuery( \"

\" + result.data + \"

\" ).insertAfter( jQuery(button) );\n\t\t\t\t\t\tjQuery('#spbc_settings_templates_export_button .spbc_success').show(300);\n\t\t\t\t\t\tsetTimeout(function(){jQuery('#spbc_settings_templates_export_button .spbc_success').hide(300);}, 2000);\n\t\t\t\t\t\tdocument.addEventListener(\"spbcModalClosed\", function( e ) {\n\t\t\t\t\t\t\tdocument.location.reload();\n\t\t\t\t\t\t});\n\t\t\t\t\t\tsetTimeout(function(){spbcModal.close()}, 2000);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tjQuery( \"

\" + result.data + \"

\" ).insertAfter( jQuery(button) );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t});\n\n\t// Reset settings\n\tjQuery( document ).on('click', '#spbc_settings_templates_reset_button', function(){\n\t\tvar button = this;\n\t\tspbc_sendAJAXRequest(\n\t\t\t{action: 'spbc_settings_templates_reset'},\n\t\t\t{\n\t\t\t\ttimeout: 25000,\n\t\t\t\tbutton: button,\n\t\t\t\tspinner: jQuery('#spbc_settings_templates_reset_button .spbc_preloader_button' ),\n\t\t\t\tcallback: function(result, data, params, obj){\n\t\t\t\t\tif(result.success) {\n\t\t\t\t\t\tjQuery( \"

\" + result.data + \"

\" ).insertAfter( jQuery(button) );\n\t\t\t\t\t\tjQuery('#spbc_settings_templates_reset_button .spbc_success').show(300);\n\t\t\t\t\t\tsetTimeout(function(){jQuery('#spbc_settings_templates_reset_button .spbc_success').hide(300);}, 2000);\n\t\t\t\t\t\tdocument.addEventListener(\"spbcModalClosed\", function( e ) {\n\t\t\t\t\t\t\tdocument.location.reload();\n\t\t\t\t\t\t});\n\t\t\t\t\t\tsetTimeout(function(){spbcModal.close()}, 2000);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tjQuery( \"

\" + result.data + \"

\" ).insertAfter( jQuery(button) );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t});\n\n\tjQuery(document).on('change', '#spbc_settings_templates_export',function(){\n\t\tvar optionSelected = jQuery(\"option:selected\", this);\n\t\tif ( optionSelected.data(\"id\") === 'new_template' ) {\n\t\t\tjQuery(this).parent().parent().find('#spbc_settings_templates_export_name').show();\n\t\t} else {\n\t\t\tjQuery(this).parent().parent().find('#spbc_settings_templates_export_name').hide();\n\t\t}\n\t});\n\n\t//* TAB_CONTROL\n\t\n\t\tjQuery('.spbc_tab_nav-summary').data('loaded', true); // Summary tab loaded by default\n\t\tjQuery('.spbc_tabs_nav_wrapper').on('click', '.spbc_tab_nav', function(event){\n\t\t\tspbc_switchTab(event.currentTarget);\n\t\t});\n\t\t\n\t\t// Get additional params\n var params = {\n target: location.search.match(/spbc_target=(\\S*?)(&|$)/) ? location.search.match(/spbc_target=(\\S*?)(&|$)/)[1] : null,\n action: location.search.match(/spbc_action=(\\S*?)(&|$)/) ? location.search.match(/spbc_action=(\\S*?)(&|$)/)[1] : null,\n times: location.search.match(/spbc_times=(\\S*?)(&|$)/) ? location.search.match(/spbc_times=(\\S*?)(&|$)/)[1] : 3,\n };\n // Legacy support\n params.target = location.search.match(/spbc_highlight=(\\S*?)(&|$)/) ? location.search.match(/spbc_highlight=(\\S*?)(&|$)/)[1] : params.target;\n params.action = location.search.search(/spbc_highlight=(\\S*?)(&|$)/) != -1\n ? 'highlight'\n : params.action;\n\n\t\t// Get open tab form query\n\t\tvar spbc_tab = document.getElementsByClassName('spbc_tab_nav-' + (location.search.match(/spbc_tab=(\\S*?)(&|$)/) ? location.search.match(/spbc_tab=(\\S*?)(&|$)/)[1] : ''))[0] || null;\n\n\t\t// TAB SWITCHING\n\t\t// Switch by URL\n\t\tif(spbc_tab){\n\n\t\t// Switch to DEBUG\n\t\t}else if( +spbcSettings.debug ){\n\t\t\tspbc_tab = document.getElementsByClassName('spbc_tab_nav-debug')[0];\n\t\t// Switch by DEFAULT\n\t\t}else if( +spbcSettings.wpms && !+spbcSettings.is_main_site){\n\t\t\tspbc_tab = document.getElementsByClassName('spbc_tab_nav-security_log')[0];\n\t\t// Switch if Key is OK and SFW is ON\n\t\t}else if( +spbcSettings.key_is_ok && +spbcSettings.secfw_enabled ){\n\t\t\tspbc_tab = document.getElementsByClassName('spbc_tab_nav-traffic_control')[0];\n\t\t// Switch if Key is OK\n\t\t}else if( +spbcSettings.key_is_ok ){\n\t\t\tspbc_tab = document.getElementsByClassName('spbc_tab_nav-scanner')[0];\n\t\t// Switch if KEY IS BAD\n\t\t}else{\n\t\t\tspbc_tab = document.getElementsByClassName('spbc_tab_nav-settings_general')[0];\n\t\t\tparams = {\n\t\t\t target: 'spbc_key',\n action: 'highlight',\n times: 3,\n };\n\t\t}\n\t\t\n\t\t// Switch tab\n\t\tif(spbc_tab) spbc_switchTab(spbc_tab, params);\n\t\t\n\t//*/ TAB_CONROL END\n\t\n\t//* REFRESH TAB IF ctrl+F5\n\tvar ctrlKeyDown = false;\n\n\tjQuery(document).on(\"keyup\", function(e) {\n\t\tif ((e.which || e.keyCode) == 17) ctrlKeyDown = false;\n\t});\n\n\tjQuery(document).on(\"keydown\", function(e) {\n\t\tif (((e.which || e.keyCode) == 116) && ctrlKeyDown) {\n\t\t\te.preventDefault();\n\n\t\t\tvar active_tab = jQuery('.spbc_tab_nav--active')[0];\n\t\t\tvar tab_name = active_tab.classList[1].replace('spbc_tab_nav-', '');\n\n\t\t\tif (tab_name === 'scanner') return; \n\n\t\t\tjQuery(active_tab).data('loaded', false);\n\n\t\t\tspbc_switchTab(active_tab);\n\n\t\t} else if ((e.which || e.keyCode) == 17) {\n\t ctrlKeyDown = true;\n\t }\n\t});\n\t//*/ REFRESH TAB IF ctrl+F5 END\n\n\t/**\n * Change cleantalk account email\n */\n jQuery(document).on('click', '#spbc-change-account-email', function(e) {\n e.preventDefault();\n\n let $this = jQuery(this);\n let accountEmailField = jQuery('#spbc-account-email');\n let accountEmail = accountEmailField.text();\n\n\t\tspbcToggleClass($this, 'active');\n\n if ($this.hasClass('active')) {\n $this.text($this.data('save-text'));\n accountEmailField.attr('contenteditable', 'true');\n\t\t\taccountEmailField.focus();\n accountEmailField.on('keydown', function(e) {\n if (e.code === 'Enter') {\n e.preventDefault();\n }\n });\n accountEmailField.on('input', function(e) {\n if (e.inputType === 'insertParagraph') {\n e.preventDefault();\n }\n });\n } else {\n spbc_sendAJAXRequest(\n {\n action: 'spbc_update_account_email',\n accountEmail: accountEmail,\n },\n {\n timeout: 5000,\n callback: function(result, data, params, obj) {\n if (result.success !== undefined && result.success === 'ok') {\n if (result.manuallyLink !== undefined) {\n jQuery('#spbc-key-manually-link').attr('href', result.manuallyLink);\n }\n }\n\n if (result.error !== undefined) {\n\t\t\t\t\t\t\n jQuery('#spbc-account-email').css('border-color', 'red');\n }\n },\n\t\t\t\t\terrorOutput: function(msg) {\n\t\t\t\t\t\tspbcModal.loaded = msg;\n\t\t\t\t\t\tspbcModal.open();\n\t\t\t\t\t}\n },\n );\n\n accountEmailField.attr('contenteditable', 'false');\n $this.text($this.data('default-text'));\n }\n });\n});\n\n/**\n * @param {string} className\n */\nfunction spbcToggleClass(arr, className) {\n\tfor (let i=0; i\");\r\n\r\n\tvar obj = jQuery('.spbc_popup_tip--wrapper');\r\n\r\n\tobj.empty()\r\n\t\t.append(\"
\")\r\n\t\t.css({\r\n\t\t\ttop: show_icon.position().top - 2,\r\n\t\t\tleft: show_icon.position().left + 25\r\n\t\t});\r\n\tobj.append(\"\")\r\n\t\t.append(\"

\" + tip_title + \"

\")\r\n\t\t.append(\"

\" + tip_text + \"

\");\r\n\r\n\tjQuery(document).on('click', remove_desc_func);\r\n\tshow_icon.parents('tr').on('mouseout', remove_desc_func);\r\n}\r\n\r\nfunction spbc_scanner_button_file_view_event(obj){\r\n\tvar self = jQuery(obj);\r\n\tvar data = {\r\n\t\taction: 'spbc_scanner_file_view',\r\n\t\tfile_id: self.parents('.row-actions').attr('uid'),\r\n\t};\r\n\tvar params = {\r\n\t\tspinner: self.parent().siblings('.tbl-preloader--tiny'),\r\n\t\tcallback: spbc_scannerButtonView_callback,\r\n\t\terrorOutput: function(msg){ spbcModal.open().putError( msg ); },\r\n\t};\r\n\tspbc_sendAJAXRequest(data, params);\r\n}\r\n\r\n/**\r\n * Delete file from analysis log\r\n */\r\nfunction spbc_scanner_analysis_log_delete_from_log(obj) {\r\n\r\n\tlet fileIds = [];\r\n\tconst self = jQuery(obj);\r\n\tlet spinner;\r\n\r\n\tif ( jQuery(obj).hasClass('tbl-row_action') ) {\r\n\t\tfileIds.push(self.parents('.row-actions').attr('uid'));\r\n\t\tspinner = self.parent().siblings('.tbl-preloader--tiny');\r\n\t} else {\r\n\t\tconst selectedItems = self.closest('#spbc_tbl__scanner_analysis_log').find('.cb-select:checked');\r\n\t\tif (selectedItems.length === 0) {\r\n\t\t\talert('Please, select elements.');\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tselectedItems.each(function (index, element) {\r\n\t\t\tconst elementId = jQuery(element).val();\r\n\t\t\tfileIds.push(elementId);\r\n\t\t});\r\n\t\tspinner = self.children('.tbl-preloader--small');\r\n\t}\r\n\r\n\tconst data = {\r\n\t\taction: 'spbc_scanner_analysis_log_delete_from_log',\r\n\t\tfile_ids: fileIds,\r\n\t};\r\n\r\n\tvar params = {\r\n\t\tspinner: spinner,\r\n\t\tcallback: function() { window.location.reload(); },\r\n\t};\r\n\r\n\tspbc_sendAJAXRequest(data, params);\r\n}\r\n\r\nfunction spbc_scanner_button_page_view_event(obj){\r\n\tvar self = jQuery(obj);\r\n\tvar data = {\r\n\t\taction: 'spbc_scanner_page_view',\r\n\t\tpage_url: self.parents('.row-actions').attr('uid'),\r\n\t};\r\n\tvar params = {\r\n\t\tspinner: self.parent().siblings('.tbl-preloader--tiny'),\r\n\t\tcallback: spbc_scannerButtonView_callback,\r\n\t\terrorOutput: function(msg){ spbcModal.open().putError( msg ); },\r\n\t};\r\n\r\n\tlet wp_wrap = jQuery('#wpwrap')\r\n\tlet dialog_window = jQuery('#spbc_dialog')\r\n\r\n\tdialog_window.dialog({\r\n\t\tmodal:true,\r\n\t\ttitle: 'Loading..',\r\n\t\tposition: { my: \"center top\", at: \"center top+100px\" , of: window },\r\n\t\twidth: +(wp_wrap.width() / 100 * 90),\r\n\t\tshow: { effect: \"blind\", duration: 500 },\r\n\t\tdraggable: false,\r\n\t\tresizable: false,\r\n\t\tcloseText: \"X\",\r\n\t\tclasses: {\"ui-dialog\": 'spbc---top'},\r\n\t\topen: function(event, ui) {\r\n\t\t\tevent.target.style.overflow = 'auto';\r\n\t\t\tjQuery('#spbc_dialog').height((document.documentElement.clientHeight) / 100 * 25);\r\n\t\t},\r\n\t\tbeforeClose: function(event, ui) {\r\n\t\t\tdocument.body.style.overflow = 'auto';\r\n\t\t\tjQuery('#spbc_dialog').empty();\r\n\t\t},\r\n\t})\r\n\r\n\tdialog_window.append('\"Wait')\r\n\r\n\tlet spinner = jQuery('#spbc_file_view_preloader')\r\n\tlet size_multiplier = (wp_wrap.width() * 0.0004)\r\n\r\n\tspinner.height(128 * size_multiplier)\r\n\tspinner.width(128 * size_multiplier)\r\n\tspinner.css({left: dialog_window.width()/2 - (128 * size_multiplier / 2)})\r\n\tspinner.css({top: dialog_window.height()/2 - (128 * size_multiplier / 2)})\r\n\r\n\tspbc_sendAJAXRequest(data, params);\r\n}\r\n\r\nfunction spbc_scannerButtonView_callback(result){\r\n\r\n\tlet dialog_window = jQuery('#spbc_dialog')\r\n\tdialog_window.empty();\r\n\r\n\tjQuery('#spbc_file_view_preloader').css({display:'none'})\r\n\r\n\tlet row_template = '
%s

%s


';\r\n\r\n\tfor(let row in result.file){\r\n\t\tdialog_window.append(row_template.printf(row, result.file[row]));\r\n\t}\r\n\r\n\tlet content_height = Object.keys(result.file).length * 19 < 76 ? 76 : Object.keys(result.file).length * 19,\r\n\t\tvisible_height = (document.documentElement.clientHeight) / 100 * 75,\r\n\t\toverflow = content_height < visible_height ? 'hidden' : 'scroll',\r\n\t\theight = overflow === 'scroll' ? visible_height : content_height;\r\n\r\n\tdialog_window.css({\r\n\t\theight: height,\r\n\t\toverflow: overflow\r\n\t})\r\n\r\n\tdialog_window.dialog({\r\n\t\tmodal:true,\r\n\t\ttitle: ('Loaded: ' + result.file_path),\r\n\t\tposition: { my: \"center top\", at: \"center top+100px\" , of: window },\r\n\t\twidth: +(jQuery('#wpwrap').width() / 100 * 90),\r\n\t\tshow: { effect: \"blind\", duration: 500 },\r\n\t\tdraggable: true,\r\n\t\tresizable: false,\r\n\t\tcloseText: \"X\",\r\n\t\tclasses: {\"ui-dialog\": 'spbc---top'},\r\n\t\topen: function(event, ui) {\r\n\t\t\tevent.target.style.overflow = overflow;\r\n\t\t\tjQuery('#spbc_dialog').height(height);\r\n\t\t\tjQuery('.ui-widget-overlay').on('click', function() {\r\n\t\t\t\tjQuery(\"#spbc_dialog\").dialog('close');\r\n\t\t\t});\r\n\t\t},\r\n\t\tbeforeClose: function(event, ui) {\r\n\t\t\tdocument.body.style.overflow = 'auto';\r\n\t\t\tjQuery('#spbc_dialog').empty();\r\n\t\t},\r\n\t});\r\n\r\n\tconsole.log('FILE_VIEWED');\r\n\r\n}\r\n\r\nfunction spbc_scanner_button_file_view_bad_event(obj){\r\n\tvar self = jQuery(obj);\r\n\tvar data = {\r\n\t\taction: 'spbc_scanner_file_view',\r\n\t\tfile_id: self.parents('.row-actions').attr('uid'),\r\n\t};\r\n\tvar params = {\r\n\t\tspinner: self.parent().siblings('.tbl-preloader--tiny'),\r\n\t\tcallback: spbc_scannerButtonViewBadFile_callback,\r\n\t\terrorOutput: function(msg){ spbcModal.open().putError( msg ); },\r\n\t};\r\n\tspbc_sendAJAXRequest(data, params);\r\n}\r\n\r\nfunction spbc_scanner_button_page_view_bad_event(obj){\r\n\tvar self = jQuery(obj);\r\n\tvar data = {\r\n\t\taction: 'spbc_scanner_page_view',\r\n\t\tpage_url: self.parent().attr('uid'),\r\n\t};\r\n\tvar params = {\r\n\t\tspinner: self.parent().siblings('.tbl-preloader--tiny'),\r\n\t\tcallback: spbc_scannerButtonViewBad_callback,\r\n\t\terrorOutput: function(msg){ spbcModal.open().putError( msg ); },\r\n\t};\r\n\tspbc_sendAJAXRequest(data, params);\r\n}\r\n\r\nfunction spbc_scannerButtonViewBadFile_callback(result, data, params){\r\n\r\n\tconsole.log('FILE_VIEWED_BAD_CODE_FILE');\r\n\tconsole.log(arguments);\r\n\tjQuery('#spbc_dialog').empty();\r\n\r\n\tvar row_template = '
%s

%s


',\r\n\t\trow_template_bad = '
%s

%s


',\r\n\t\tseverity_parts = [],\r\n\t\tseverity_parts_sorted = [],\r\n\t\tseverity_keys_sorted = [];\r\n\r\n\tresult.weak_spots = JSON.parse(result.weak_spots)\r\n\tfor(let severity in result.weak_spots){\r\n\t\tseverity_parts[severity] = Object.keys(result.weak_spots[severity])\r\n\t}\r\n\r\n\tseverity_keys_sorted = Object.keys(severity_parts).sort();\r\n\r\n\tfor(key in severity_keys_sorted){\r\n\t\tseverity_parts_sorted[severity_keys_sorted[key]] = severity_parts[severity_keys_sorted[key]]\r\n\t}\r\n\r\n\tfor (let severity_part in severity_parts_sorted) {\r\n\t\tlet header_name = 'spbc-dialog-row-header-' + severity_part.toLowerCase();\r\n\t\tlet header_html = '' + severity_part + ' weakspots:';\r\n\t\tconst dialog = jQuery('#spbc_dialog');\r\n\r\n\t\tdialog.append(row_template.printf('',header_html));\r\n\t\tdialog.append(row_template. printf('...','...'));\r\n\r\n\t\tlet header = dialog.find('#' + header_name);\r\n\t\theader.parent().parent().css('text-align', 'center');\r\n\t\theader.parent().parent().css('border', '1px dotted');\r\n\t\theader.parent().parent().css('background', 'darkgrey');\r\n\r\n\t\tfor(let str_num in severity_parts[severity_part]){\r\n\t\t\t// Sort bad line\r\n\t\t\tstr_num = [...new Set(str_num)].sort()\r\n\r\n\t\t\tlet row = +severity_parts[severity_part][str_num],\r\n\t\t\t\tdisplay_depth = 2;\r\n\r\n\t\t\t// Display only existing lines of file\r\n\t\t\tfor(let curr_row = row - display_depth; curr_row <= row + display_depth; curr_row++ ){\r\n\t\t\t\tif( typeof result.file[curr_row] !== 'undefined' ){\r\n\t\t\t\t\tdialog.append((row === curr_row ? row_template_bad : row_template).printf(curr_row, result.file[curr_row]));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Placing an empty string between results\r\n\t\t\tdialog.append(row_template. printf('...','...'));\r\n\t\t}\r\n\t}\r\n\r\n\t// Removing last empty string\r\n\tjQuery('#spbc_dialog div').last().remove();\r\n\r\n\tlet content_height = jQuery('#spbc_dialog div').length * 19 < 76 ? 76 : jQuery('#spbc_dialog div').length * 19,\r\n\t\tvisible_height = (document.documentElement.clientHeight) / 100 * 75,\r\n\t\toverflow = content_height < visible_height ? 'no_scroll' : 'scroll',\r\n\t\theight = overflow === 'scroll' ? visible_height : content_height;\r\n\r\n\tjQuery('#spbc_dialog').dialog({\r\n\t\tmodal:true,\r\n\t\ttitle: result.file_path,\r\n\t\tposition: { my: \"center top\", at: \"center top+100px\" , of: window },\r\n\t\twidth: +(jQuery('#wpwrap').width() / 100 * 90),\r\n\t\tshow: { effect: \"blind\", duration: 500 },\r\n\t\tdraggable: true,\r\n\t\tresizable: false,\r\n\t\tcloseText: \"X\",\r\n\t\tclasses: {\"ui-dialog\": 'spbc---top'},\r\n\t\topen: function(event, ui) {\r\n\t\t\tevent.target.style.overflow = overflow;\r\n\t\t\tjQuery('#spbc_dialog').height(height);\r\n\t\t\tjQuery('.ui-widget-overlay').on('click', function() {\r\n\t\t\t\tjQuery(\"#spbc_dialog\").dialog('close');\r\n\t\t\t});\r\n\t\t},\r\n\t\tbeforeClose: function(event, ui) {\r\n\t\t\tdocument.body.style.overflow = 'auto';\r\n\t\t\tjQuery('#spbc_dialog').empty();\r\n\t\t},\r\n\t});\r\n}\r\n\r\nfunction spbc_scannerButtonViewBad_callback(result, data, params){\r\n\r\n\tconsole.log('FILE_VIEWED_BAD_CODE');\r\n\r\n\tconsole.log(arguments);\r\n\r\n\tlet afterClose = () => {};\r\n\r\n\tif ( result.success == true ) {\r\n\t\tconsole.log(result);\r\n\t\tvar row_template = '
' +\r\n\t\t\t\t'%s' +\r\n\t\t\t\t'

%s

' +\r\n\t\t\t\t'
',\r\n\t\t\trow_template_bad = '
' +\r\n\t\t\t\t'%s' +\r\n\t\t\t\t'

%s

' +\r\n\t\t\t\t'
',\r\n\t\t\tstr_nums = [];\r\n\r\n\t\tresult.weak_spots = JSON.parse(result.weak_spots);\r\n\t\tfor(let severity in result.weak_spots){\r\n\t\t\tstr_nums = str_nums.concat(Object.keys(result.weak_spots[severity]));\r\n\t\t}\r\n\r\n\t\tstr_nums = [...new Set(str_nums)].sort(); // Sort bad line\r\n\t\t//get a map of bad strings\r\n\t\tlet bad_strings_map = new Map(Object.entries(result.weak_spots.CRITICAL)) //TODO: Probably there can get something else except CRITICAL in the future\r\n\t\tfor(let str_num in str_nums){\r\n\t\t\tif (str_num == 0 && bad_strings_map.get(str_nums[str_num]).toLowerCase().includes('doctype')) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tlet row = +str_nums[str_num],\r\n\t\t\t\tdisplay_depth = 2;\r\n\r\n\t\t\t// Display only existing lines of file\r\n\t\t\tfor(let curr_row = row - display_depth; curr_row <= row + display_depth; curr_row++ ){\r\n\t\t\t\tif( typeof result.file[curr_row] !== 'undefined' ){\r\n\t\t\t\t\tlet is_bad_string = (row === curr_row)\r\n\t\t\t\t\tlet unformatted_row\r\n\t\t\t\t\tlet highlited_row\r\n\t\t\t\t\tif (is_bad_string){\r\n\t\t\t\t\t\tunformatted_row = row_template_bad\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tunformatted_row = row_template\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (is_bad_string && !result.file[curr_row].includes('iframe')){\r\n\t\t\t\t\t\thighlited_row = unformatted_row.printf(curr_row, bad_strings_map.get(str_nums[str_num]));\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\thighlited_row = unformatted_row.printf(curr_row, result.file[curr_row]);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tjQuery('#spbc_dialog').append(highlited_row);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Placing an empty string between results\r\n\t\t\tjQuery('#spbc_dialog').append(row_template. printf('', ''));\r\n\r\n\t\t\t// Removing last empty string\r\n\t\t\tjQuery('#spbc_dialog div').last().remove();\r\n\t\t}\r\n\t} else {\r\n\t\tlet wrapperElement = '
%s
'\r\n\t\tjQuery('#spbc_dialog').append(wrapperElement.printf(result.content));\r\n\t\tafterClose = () => {document.location.reload();};\r\n\t}\r\n\r\n\tlet content_height = jQuery('#spbc_dialog div').length * 19 < 76 ? 76 : jQuery('#spbc_dialog div').length * 19,\r\n\t\tvisible_height = (document.documentElement.clientHeight) / 100 * 75,\r\n\t\theight = 'auto',\r\n\t\toverflow = content_height < visible_height ? 'no_scroll' : 'scroll';\r\n\r\n\tjQuery('#spbc_dialog').dialog({\r\n\t\tmodal:true,\r\n\t\ttitle: result.file_path,\r\n\t\tposition: { my: \"center top\", at: \"center top+100px\" , of: window },\r\n\t\twidth: +(jQuery('#wpwrap').width() / 100 * 90),\r\n\t\tshow: { effect: \"blind\", duration: 500 },\r\n\t\tdraggable: true,\r\n\t\tresizable: false,\r\n\t\tcloseText: \"X\",\r\n\t\tclasses: {\"ui-dialog\": 'spbc---top'},\r\n\t\topen: function(event, ui) {\r\n\t\t\tevent.target.style.overflow = overflow;\r\n\t\t\tjQuery('#spbc_dialog').height(height);\r\n\t\t\tjQuery('.ui-widget-overlay').on('click', function() {\r\n\t\t\t\tjQuery(\"#spbc_dialog\").dialog('close');\r\n\t\t\t});\r\n\t\t},\r\n\t\tbeforeClose: function(event, ui) {\r\n\t\t\tdocument.body.style.overflow = 'auto';\r\n\t\t\tjQuery('#spbc_dialog').empty();\r\n\t\t},\r\n\t\tclose: afterClose,\r\n\t});\r\n}\r\n\r\nfunction spbc_scanner_button_file_compare_event(obj){\r\n\tvar self = jQuery(obj);\r\n\tvar data = {\r\n\t\taction: 'spbc_scanner_file_compare',\r\n\t\tfile_id: self.parents('.row-actions').attr('uid'),\r\n\t};\r\n\tvar params = {\r\n\t\tspinner: self.parent().siblings('.tbl-preloader--tiny'),\r\n\t\tcallback: spbc_scannerButtonFileCompare_callback,\r\n\t\terrorOutput: function(msg){ spbcModal.open().putError( msg ); },\r\n\t};\r\n\tspbc_sendAJAXRequest(data, params);\r\n}\r\n\r\nfunction spbc_scannerButtonFileCompare_callback(result, data, params){\r\n\r\n\tconsole.log('FILE_COMPARED');\r\n\r\n\tlet row_template = '

%s

%s

%s


';\r\n\tlet row_template_bad = '

%s

%s

%s


';\r\n\r\n\tjQuery('#spbc_dialog').append(row_template.printf('Modified', 'Line', 'Original'));\r\n\r\n\tfor(var row=1, prev = false, next = false; typeof result.file[row] != 'undefined' || typeof result.file_original[row] != 'undefined'; row++){\r\n\r\n\t\tif(typeof result.file[row] == 'undefined') result.file[row] = '';\r\n\t\tif(typeof result.file_original[row] == 'undefined') result.file_original[row] = '';\r\n\r\n\t\t// Display only existing lines of file\r\n\t\tif(result.difference.indexOf(row) != -1){\r\n\t\t\tfor(let display_depth = 2, curr_row = row - display_depth; curr_row <= row + display_depth; curr_row++ ){\r\n\t\t\t\tif( typeof result.file[curr_row] !== 'undefined' && typeof result.file_original[row] !== 'undefined') {\r\n\t\t\t\t\tjQuery('#spbc_dialog').append(\r\n\t\t\t\t\t\t(row === curr_row ? row_template_bad : row_template).printf(\r\n\t\t\t\t\t\t\tresult.file[curr_row] ? result.file[curr_row] : '',\r\n\t\t\t\t\t\t\tcurr_row,\r\n\t\t\t\t\t\t\tresult.file_original[curr_row] ? result.file_original[curr_row] : ''\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tjQuery('#spbc_dialog').append(row_template. printf('', '', ''));\r\n\t\t}\r\n\t}\r\n\r\n\tvar content_height = jQuery('#spbc_dialog div').length * 19 + 19,\r\n\t\tvisible_height = (document.documentElement.clientHeight) / 100 * 75,\r\n\t\toverflow = content_height < visible_height ? 'no_scroll' : 'scroll',\r\n\t\theight = overflow === 'scroll' ? visible_height : content_height;\r\n\r\n\tjQuery('#spbc_dialog').dialog({\r\n\t\tmodal:true,\r\n\t\ttitle: result.file_path,\r\n\t\tposition: { my: \"center top\", at: \"center top+100px\" , of: window },\r\n\t\twidth: +(jQuery('#wpwrap').width() / 100 * 90),\r\n\t\theight: height,\r\n\t\tshow: { effect: \"blind\", duration: 500 },\r\n\t\tdraggable: true,\r\n\t\tresizable: true,\r\n\t\tcloseText: \"X\",\r\n\t\tclasses: {\"ui-dialog\": 'spbc---top'},\r\n\t\topen: function(event, ui) {\r\n\t\t\tdocument.body.style.overflow = 'hidden';\r\n\t\t\tevent.target.style.overflow = overflow;\r\n\t\t\tjQuery('#spbc_dialog').height(height);\r\n\t\t},\r\n\t\tbeforeClose: function(event, ui) {\r\n\t\t\tdocument.body.style.overflow = 'auto';\r\n\t\t\tjQuery('#spbc_dialog').empty();\r\n\t\t}\r\n\t});\r\n}\r\n\r\nfunction spbc_scanner__reload_scan_info() {\r\n\tjQuery('.spbc_hint__last_scan_title').text(spbcScaner.look_below_for_scan_res);\r\n\tconst data = {\r\n\t\taction: 'spbc_scanner__last_scan_info'\r\n\t};\r\n\tconst params = {\r\n\t\tcallback: (result) => {\r\n\t\t\tdocument.getElementById('spbc_scanner__last_scan_info').innerText = result.data;\r\n\t\t}\r\n\t};\r\n\tspbc_sendAJAXRequest(data, params);\r\n}\r\n\r\n/**\r\n * Show snapshots of file\r\n * @param obj\r\n */\r\nfunction spbc_scanner_file_monitoring_show_current_snapshot(obj)\r\n{\r\n\tconst self = jQuery(obj);\r\n\tconst fileId = self.parents('.row-actions').attr('uid');\r\n\tconst file_name = self.closest('.column-path').find('.title').text();\r\n\r\n\t// Init and open remodal\r\n\tconst remodal = jQuery('[data-remodal-id=spbc-file-monitoring-modal]');\r\n\tconst remodalObject = remodal.remodal();\r\n\tremodalObject.open();\r\n\r\n\t// Ajax request to get data for slider\r\n\tlet data = {\r\n\t\taction: 'spbc_file_monitoring_show_snapshots',\r\n\t\tfile_id: fileId,\r\n\t\tsecurity: spbcSettings.ajax_nonce\r\n\t};\r\n\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\tasync: true,\r\n\t\turl: spbcSettings.ajaxurl,\r\n\t\tdata: data,\r\n\t\tsuccess: function(result) {\r\n\t\t\tif (result.success) {\r\n\t\t\t\tremodal.find('#spbc-fm-snapshot-list ul').remove();\r\n\t\t\t\tremodal.find('#spbc-fm-snapshot-file-name').text(file_name);\r\n\t\t\t\tdrawSnapshotList(result.data, remodal);\r\n\t\t\t\tdrawCurrentSnapshot(result.data[0].id, remodal);\r\n\t\t\t} else {\r\n\t\t\t\t// TODO: show errors\r\n\t\t\t}\r\n\t\t},\r\n\t});\r\n}\r\n\r\n/**\r\n *\r\n * @param data\r\n * @param remodal\r\n */\r\nfunction drawSnapshotList(data, remodal)\r\n{\r\n\tlet list = '';\r\n\r\n\tfor (let item of data) {\r\n\t\tlist += `
  • ${item.created_at}
  • `;\r\n\t}\r\n\r\n\tlet html =\r\n\t\t`
      \r\n ${list}\r\n
    `;\r\n\r\n\tremodal.find('#spbc-fm-snapshot-list').append(html);\r\n}\r\n\r\nfunction drawCurrentSnapshot(snapshot_id, remodal)\r\n{\r\n\t// Ajax request to get data for slider\r\n\tlet data = {\r\n\t\taction: 'spbc_file_monitoring_show_current_snapshot',\r\n\t\tsnapshot_id,\r\n\t\tsecurity: spbcSettings.ajax_nonce\r\n\t};\r\n\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\tasync: true,\r\n\t\turl: spbcSettings.ajaxurl,\r\n\t\tdata: data,\r\n\t\tbeforeSend: function() {\r\n\t\t\tjQuery('#spbc-file-monitoring-modal-preloader').show();\r\n\t\t},\r\n\t\tsuccess: function(result) {\r\n\t\t\tif (result.success) {\r\n\t\t\t\tremodal.find('#spbc-fm-snapshot-view .wrap').remove();\r\n\t\t\t\tremodal.find('[data-spanshot-id').removeClass('active');\r\n\t\t\t\tremodal.find('[data-spanshot-id=' + snapshot_id + ']').addClass('active');\r\n\r\n\t\t\t\tlet html =\r\n\t\t\t\t\t`
    \r\n
    \r\n                            \r\n                                ${result.data.content}\r\n                            \r\n                        
    \r\n
    `;\r\n\r\n\t\t\t\tjQuery('#spbc-file-monitoring-modal-preloader').hide();\r\n\t\t\t\tremodal.find('#spbc-fm-snapshot-view').append(html);\r\n\t\t\t\tdocument.querySelectorAll('pre code').forEach((el) => {\r\n\t\t\t\t\thljs.highlightElement(el);\r\n\t\t\t\t});\r\n\t\t\t} else {\r\n\t\t\t\t// TODO: show errors\r\n\t\t\t}\r\n\t\t},\r\n\t});\r\n}\r\n\r\n/**\r\n * Cure file\r\n * @param obj\r\n */\r\nfunction spbc_scanner_button_cure_file_ajax_handler(obj)\r\n{\r\n\tconst self = jQuery(obj);\r\n\tconst fileFastHash = self.parents('.row-actions').attr('uid');\r\n\r\n\tlet data = {\r\n\t\taction: 'spbc_file_cure_ajax_action',\r\n\t\tfile_fast_hash: fileFastHash,\r\n\t\tsecurity: spbcSettings.ajax_nonce\r\n\t};\r\n\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\tasync: true,\r\n\t\turl: spbcSettings.ajaxurl,\r\n\t\tdata: data,\r\n\t\tsuccess: function(result) {\r\n\t\t\tif (result.success) {\r\n\t\t\t\tspbcModal.open().put(result.data);\r\n\t\t\t\tdocument.addEventListener(\"spbcModalClosed\", function( e ) {\r\n\t\t\t\t\tdocument.location.reload();\r\n\t\t\t\t});\r\n\t\t\t} else {\r\n\t\t\t\tspbcModal.open().putError(result.data);\r\n\t\t\t}\r\n\t\t},\r\n\t});\r\n}\r\n\r\n/**\r\n * Restore file from backup\r\n * @param obj\r\n */\r\nfunction spbc_scanner_button_restore_from_backup_ajax_handler(obj)\r\n{\r\n\tconst self = jQuery(obj);\r\n\tconst fileFastHash = self.parents('.row-actions').attr('uid');\r\n\r\n\tlet data = {\r\n\t\taction: 'spbc_restore_file_from_backup_ajax_action',\r\n\t\tfile_fast_hash: fileFastHash,\r\n\t\tsecurity: spbcSettings.ajax_nonce\r\n\t};\r\n\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\tasync: true,\r\n\t\turl: spbcSettings.ajaxurl,\r\n\t\tdata: data,\r\n\t\tsuccess: function(result) {\r\n\t\t\tif (result.success) {\r\n\t\t\t\tspbcModal.open().put(result.data);\r\n\t\t\t\tdocument.addEventListener(\"spbcModalClosed\", function( e ) {\r\n\t\t\t\t\tdocument.location.reload();\r\n\t\t\t\t});\r\n\t\t\t} else {\r\n\t\t\t\tspbcModal.open().putError(result.data);\r\n\t\t\t}\r\n\t\t},\r\n\t});\r\n}\r\n\r\n/**\r\n * Clear scan results\r\n */\r\nfunction spbc_scanner_button_clear_scan_results()\r\n{\r\n\tif( ! confirm('Do you confirm to clear the scan results?') )\r\n\t\treturn;\r\n\r\n\tconsole.log('CLEAR');\r\n\r\n\tspbc_sendAJAXRequest(\r\n\t\t{ action: 'spbc_scanner_clear', },\r\n\t\t{\r\n\t\t\ttype: 'GET',\r\n\t\t\tsuccessCallback: function(){ document.location = document.location },\r\n\t\t\tcomplete: null,\r\n\t\t\terrorOutput: null,\r\n\t\t\tcontext: this,\r\n\t\t\ttimeout: 40000,\r\n\t\t\tsuccess: function() {\r\n\t\t\t\tdocument.location.reload();\r\n\t\t\t},\r\n\t\t},\r\n\t);\r\n}\r\n\r\njQuery(document).ready(function(){\r\n\r\n\t// EVENT HADLING\r\n\tspbc_tbl__bulk_actions__listen(); // Table. Row bulk handler\r\n\tspbc_tbl__row_actions__listen(); // Table. Row actions handler\r\n\tspbc_tbl__pagination__listen(); // Table. Pagination handler\r\n\tspbc_tbl__sort__listen(); // Table. Sort handler\r\n\r\n\tspbcStartShowHide();\r\n\r\n\t// Preparing progressbar\r\n\tjQuery('#spbc_scaner_progress_bar').progressbar({\r\n\t\tvalue: 0,\r\n\t\tcreate: function( event, ui ) {\r\n\t\t\tevent.target.style.position = 'relative';\r\n\t\t\tevent.target.style.marginBottom = '12px';\r\n\t\t},\r\n\t\tchange: function(event, ui){\r\n\t\t\tjQuery('.spbc_progressbar_counter span').text(jQuery(event.target).progressbar('option', 'value') + ' %');\r\n\t\t},\r\n\t});\r\n\r\n\t// Preparing accordion\r\n\tjQuery('#spbc_scan_accordion').accordion({\r\n\t\theader: \"h3\",\r\n\t\theightStyle: 'content',\r\n\t\tcollapsible: true,\r\n\t\tactive: false,\r\n\t\tactivate: function( event, ui ) {\r\n\t\t\tif( ui.oldPanel.length === 0 && ui.oldHeader.length === 0 )\r\n\t\t\t\tjQuery(\"#spbc_scan_accordion\").accordion(\"option\", \"classes.ui-accordion-content\", \"ui-corner-bottom spbc-overflow--visible\");\r\n\t\t},\r\n\t\tbeforeActivate: function( event, ui ) {\r\n\t\t\tif( ui.oldPanel.length === 1 && ui.oldHeader.length === 1 )\r\n\t\t\t\tjQuery(\"#spbc_scan_accordion\").accordion(\"option\", \"classes.ui-accordion-content\", \"ui-corner-bottom\");\r\n\t\t}\r\n\t});\r\n\r\n\t// Init scanner plugin\r\n\twindow.spbc_scanner = new spbcMalwareScanner({\r\n\t\tsettings: spbcScaner.settings,\r\n\t\tstates: spbcScaner.states,\r\n\t\tbutton: jQuery('#spbc_perform_scan'),\r\n\t\tspinner: jQuery('#spbc_perform_scan').next(),\r\n\t\tcallback: null,\r\n\t\tprogress_overall: jQuery('#spbc_scaner_progress_overall'),\r\n\t\tprogressbar: jQuery('#spbc_scaner_progress_bar'),\r\n\t\tprogressbar_text: jQuery('.spbc_progressbar_counter span'),\r\n\t\twrapper: document.getElementsByClassName('spbc_unchecked_file_list'),\r\n\t\twarnings: {\r\n\t\t\tlong_scan: jQuery('.spbc_hint_warning__long_scan'),\r\n\t\t\toutdated: jQuery('.spbc_hint_warning__outdated')\r\n\t\t}\r\n\t});\r\n\r\n\tjQuery(document).on('click', '.spbc_popup_tip--icon---show', function(){\r\n\t\tspbc_popup_tip___show( jQuery( this ) );\r\n\t});\r\n\r\n\tjQuery('#spbc_perform_scan').on('click', function(){\r\n\t\tjQuery('#spbcscan-results-log-module').remove();\r\n\t\tspbc_scanner.actionControl();\r\n\r\n\t\tif (!jQuery(\".spbc_log-wrapper .panel-body\").length) {\r\n\t\t\tjQuery(\".spbc_log-wrapper\").append('
    ');\r\n\t\t}\r\n\r\n\t\tjQuery(\".spbc_log-wrapper\").resizable({\r\n\t\t\thandles: 'n, s',\r\n\t\t\tcontainment: 'document',\r\n\t\t});\r\n\t});\r\n\r\n\tjQuery(\"#spbcscan-results-log-module\").resizable({\r\n\t\thandles: 'n, s',\r\n\t\tcontainment: 'document',\r\n\t});\r\n\r\n\t// Clear scanner's tables\r\n\tjQuery('#spbc_scanner_clear').on('click', function(){\r\n\r\n\t\tif( ! confirm('Do you confirm to clear the scan results?') )\r\n\t\t\treturn;\r\n\r\n\t\tconsole.log('CLEAR');\r\n\r\n\t\tspbc_sendAJAXRequest(\r\n\t\t\t{ action: 'spbc_scanner_clear', },\r\n\t\t\t{\r\n\t\t\t\ttype: 'GET',\r\n\t\t\t\tsuccessCallback: function(){ document.location = document.location },\r\n\t\t\t\tcomplete: null,\r\n\t\t\t\terrorOutput: null,\r\n\t\t\t\tcontext: this,\r\n\t\t\t\ttimeout: 40000,\r\n\t\t\t\tsuccess: function() {\r\n\t\t\t\t\tdocument.location.reload();\r\n\t\t\t\t},\r\n\t\t\t},\r\n\t\t);\r\n\t});\r\n\r\n\tjQuery('#spbc_scanner_save_to_pdf').on('click', function(){\r\n\t\tjQuery.ajax({\r\n\t\t\turl: spbcSettings.ajaxurl,\r\n\t\t\ttype: 'POST',\r\n\t\t\tdata: {\r\n\t\t\t\taction: 'spbc_scanner_save_to_pdf',\r\n\t\t\t\tsecurity: spbcSettings.ajax_nonce,\r\n\t\t\t\tno_cache: Math.random()\r\n\t\t\t},\r\n\t\t\txhrFields: {\r\n\t\t\t\tresponseType: 'blob'\r\n\t\t\t},\r\n\t\t\tsuccess: function(data) {\r\n\t\t\t\tjQuery.ajax({\r\n\t\t\t\t\t\turl: spbcSettings.ajaxurl,\r\n\t\t\t\t\t\ttype: 'POST',\r\n\t\t\t\t\t\tdata: {\r\n\t\t\t\t\t\t\taction: 'spbc_scanner_get_pdf_file_name',\r\n\t\t\t\t\t\t\tsecurity: spbcSettings.ajax_nonce,\r\n\t\t\t\t\t\t\tno_cache: Math.random()\r\n\t\t\t\t\t\t},\r\n\t\t\t\t\t\txhrFields: {\r\n\t\t\t\t\t\t\tresponseType: 'text'\r\n\t\t\t\t\t\t},\r\n\t\t\t\t\t\tsuccess: function(filename) {\r\n\t\t\t\t\t\t\tlet blob=new Blob([data]);\r\n\t\t\t\t\t\t\tlet link=document.createElement('a');\r\n\t\t\t\t\t\t\tlink.href=window.URL.createObjectURL(blob);\r\n\t\t\t\t\t\t\tlink.download=filename.data;\r\n\t\t\t\t\t\t\tlink.click();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t)\r\n\t\t\t}\r\n\t\t});\r\n\t});\r\n\r\n\t// Select snapshot\r\n\tjQuery(document).on('click', '.spbc-fm-snapshot-list [data-spanshot-id]', function() {\r\n\t\tconst currentSnapshotId = jQuery(this).data('spanshot-id');\r\n\t\tconst activeSnapshotId = jQuery('.spbc-fm-snapshot-list [data-spanshot-id].active').data('spanshot-id');\r\n\r\n\t\tif (currentSnapshotId === activeSnapshotId) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tconst remodal = jQuery('[data-remodal-id=spbc-file-monitoring-modal]');\r\n\t\tdrawCurrentSnapshot(currentSnapshotId, remodal)\r\n\t});\r\n});\r\n"],"names":["spbc_popup_tip___show","show_icon","remove_desc_func","e","jQuery","target","parent","length","hasClass","hide","document","off","tip_title","attr","tip_text","obj","after","empty","append","css","top","position","left","on","parents","spbc_scanner_button_file_view_event","self","data","action","file_id","params","spinner","siblings","callback","spbc_scannerButtonView_callback","errorOutput","msg","spbcModal","open","putError","spbc_sendAJAXRequest","spbc_scanner_analysis_log_delete_from_log","let","fileIds","push","selectedItems","closest","find","alert","each","index","element","elementId","val","children","file_ids","window","location","reload","spbc_scanner_button_page_view_event","page_url","wp_wrap","dialog_window","dialog","modal","title","my","at","of","width","show","effect","duration","draggable","resizable","closeText","classes","ui-dialog","event","ui","style","overflow","height","documentElement","beforeClose","body","size_multiplier","result","row","display","file","printf","content_height","Object","keys","visible_height","file_path","console","log","spbc_scanner_button_file_view_bad_event","spbc_scannerButtonViewBadFile_callback","spbc_scanner_button_page_view_bad_event","spbc_scannerButtonViewBad_callback","arguments","severity_keys_sorted","severity","severity_part","row_template","severity_parts","severity_parts_sorted","weak_spots","JSON","parse","key","sort","str_num","header_name","toLowerCase","header_html","header","Set","curr_row","last","remove","afterClose","success","str_nums","concat","bad_strings_map","Map","entries","CRITICAL","get","includes","is_bad_string","unformatted_row","highlited_row","content","close","spbc_scanner_button_file_compare_event","spbc_scannerButtonFileCompare_callback","file_original","difference","indexOf","spbc_scanner__reload_scan_info","text","spbcScaner","look_below_for_scan_res","getElementById","innerText","spbc_scanner_file_monitoring_show_current_snapshot","fileId","file_name","remodal","security","spbcSettings","ajax_nonce","ajax","type","async","url","ajaxurl","drawSnapshotList","drawCurrentSnapshot","id","list","item","created_at","html","snapshot_id","beforeSend","removeClass","addClass","querySelectorAll","forEach","hljs","highlightElement","el","spbc_scanner_button_cure_file_ajax_handler","file_fast_hash","put","addEventListener","spbc_scanner_button_restore_from_backup_ajax_handler","spbc_scanner_button_clear_scan_results","confirm","successCallback","complete","context","this","timeout","ready","spbc_tbl__bulk_actions__listen","spbc_tbl__row_actions__listen","spbc_tbl__pagination__listen","spbc_tbl__sort__listen","spbcStartShowHide","progressbar","value","create","marginBottom","change","accordion","heightStyle","collapsible","active","activate","oldPanel","oldHeader","beforeActivate","spbc_scanner","spbcMalwareScanner","settings","states","button","next","progress_overall","progressbar_text","wrapper","getElementsByClassName","warnings","long_scan","outdated","actionControl","handles","containment","no_cache","Math","random","xhrFields","responseType","filename","blob","Blob","link","createElement","href","URL","createObjectURL","download","click","currentSnapshotId"],"mappings":"AAAA,SAASA,sBAAsBC,GAIP,SAAnBC,EAA4BC,GAGjB,KAAA,IAANA,IAEyD,GAA9DC,OAAOD,EAAEE,MAAM,EAAEC,OAAO,0BAA0B,EAAEC,QAAeH,CAAAA,OAAOD,EAAEE,MAAM,EAAEG,SAAS,+BAA+B,GAC5HJ,OAAOD,EAAEE,MAAM,EAAEG,SAAS,6BAA6B,KAGzDJ,OAAO,0BAA0B,EAAEK,KAAK,EACxCL,OAAOM,QAAQ,EAAEC,IAAI,QAAST,CAAgB,EAEhD,CAdA,IAAIU,EAAYX,EAAUY,KAAK,gBAAgB,GAAK,KAChDC,EAAYb,EAAUY,KAAK,eAAe,GAAM,KAmBhDE,GAJJb,EAAiB,EAEjBD,EAAUe,MAAM,6CAA6C,EAEnDZ,OAAO,0BAA0B,GAE3CW,EAAIE,MAAM,EACRC,OAAO,2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/C,CAAC,CACF,CAAC"} \ No newline at end of file +{"version":3,"file":"spbc-settings_tab--scanner.min.js","sources":["spbc-settings_tab--scanner.js"],"sourcesContent":["function spbc_popup_tip___show(show_icon){\n\n\tvar tip_title = show_icon.attr('spbc_tip_title') || null;\n\tvar\ttip_text = show_icon.attr('spbc_tip_text') || null;\n\tvar remove_desc_func = function(e){\n\n\t\tif(\n\t\t\ttypeof e === 'undefined' ||\n\t\t\t(\n\t\t\t\t(jQuery(e.target).parent('.spbc_popup_tip--wrapper').length == 0 || jQuery(e.target).hasClass('spbc_popup_tip--icon---cancel')) &&\n\t\t\t\t!jQuery(e.target).hasClass('spbc_popup_tip--icon---show')\n\t\t\t)\n\t\t){\n\t\t\tjQuery('.spbc_popup_tip--wrapper').hide();\n\t\t\tjQuery(document).off('click', remove_desc_func);\n\t\t}\n\t};\n\n\tremove_desc_func();\n\n\tshow_icon.after(\"
    \");\n\n\tvar obj = jQuery('.spbc_popup_tip--wrapper');\n\n\tobj.empty()\n\t\t.append(\"
    \")\n\t\t.css({\n\t\t\ttop: show_icon.position().top - 2,\n\t\t\tleft: show_icon.position().left + 25\n\t\t});\n\tobj.append(\"\")\n\t\t.append(\"

    \" + tip_title + \"

    \")\n\t\t.append(\"

    \" + tip_text + \"

    \");\n\n\tjQuery(document).on('click', remove_desc_func);\n\tshow_icon.parents('tr').on('mouseout', remove_desc_func);\n}\n\nfunction spbc_scanner_button_file_view_event(obj){\n\tvar self = jQuery(obj);\n\tvar data = {\n\t\taction: 'spbc_scanner_file_view',\n\t\tfile_id: self.parents('.row-actions').attr('uid'),\n\t};\n\tvar params = {\n\t\tspinner: self.parent().siblings('.tbl-preloader--tiny'),\n\t\tcallback: spbc_scannerButtonView_callback,\n\t\terrorOutput: function(msg){ spbcModal.open().putError( msg ); },\n\t};\n\tspbc_sendAJAXRequest(data, params);\n}\n\n/**\n * Delete file from analysis log\n */\nfunction spbc_scanner_analysis_log_delete_from_log(obj) {\n\n\tlet fileIds = [];\n\tconst self = jQuery(obj);\n\tlet spinner;\n\n\tif ( jQuery(obj).hasClass('tbl-row_action') ) {\n\t\tfileIds.push(self.parents('.row-actions').attr('uid'));\n\t\tspinner = self.parent().siblings('.tbl-preloader--tiny');\n\t} else {\n\t\tconst selectedItems = self.closest('#spbc_tbl__scanner_analysis_log').find('.cb-select:checked');\n\t\tif (selectedItems.length === 0) {\n\t\t\talert('Please, select elements.');\n\t\t\treturn;\n\t\t}\n\n\t\tselectedItems.each(function (index, element) {\n\t\t\tconst elementId = jQuery(element).val();\n\t\t\tfileIds.push(elementId);\n\t\t});\n\t\tspinner = self.children('.tbl-preloader--small');\n\t}\n\n\tconst data = {\n\t\taction: 'spbc_scanner_analysis_log_delete_from_log',\n\t\tfile_ids: fileIds,\n\t};\n\n\tvar params = {\n\t\tspinner: spinner,\n\t\tcallback: function() { window.location.reload(); },\n\t};\n\n\tspbc_sendAJAXRequest(data, params);\n}\n\nfunction spbc_scanner_button_page_view_event(obj){\n\tvar self = jQuery(obj);\n\tvar data = {\n\t\taction: 'spbc_scanner_page_view',\n\t\tpage_url: self.parents('.row-actions').attr('uid'),\n\t};\n\tvar params = {\n\t\tspinner: self.parent().siblings('.tbl-preloader--tiny'),\n\t\tcallback: spbc_scannerButtonView_callback,\n\t\terrorOutput: function(msg){ spbcModal.open().putError( msg ); },\n\t};\n\n\tlet wp_wrap = jQuery('#wpwrap')\n\tlet dialog_window = jQuery('#spbc_dialog')\n\n\tdialog_window.dialog({\n\t\tmodal:true,\n\t\ttitle: 'Loading..',\n\t\tposition: { my: \"center top\", at: \"center top+100px\" , of: window },\n\t\twidth: +(wp_wrap.width() / 100 * 90),\n\t\tshow: { effect: \"blind\", duration: 500 },\n\t\tdraggable: false,\n\t\tresizable: false,\n\t\tcloseText: \"X\",\n\t\tclasses: {\"ui-dialog\": 'spbc---top'},\n\t\topen: function(event, ui) {\n\t\t\tevent.target.style.overflow = 'auto';\n\t\t\tjQuery('#spbc_dialog').height((document.documentElement.clientHeight) / 100 * 25);\n\t\t},\n\t\tbeforeClose: function(event, ui) {\n\t\t\tdocument.body.style.overflow = 'auto';\n\t\t\tjQuery('#spbc_dialog').empty();\n\t\t},\n\t})\n\n\tdialog_window.append('\"Wait')\n\n\tlet spinner = jQuery('#spbc_file_view_preloader')\n\tlet size_multiplier = (wp_wrap.width() * 0.0004)\n\n\tspinner.height(128 * size_multiplier)\n\tspinner.width(128 * size_multiplier)\n\tspinner.css({left: dialog_window.width()/2 - (128 * size_multiplier / 2)})\n\tspinner.css({top: dialog_window.height()/2 - (128 * size_multiplier / 2)})\n\n\tspbc_sendAJAXRequest(data, params);\n}\n\nfunction spbc_scannerButtonView_callback(result){\n\n\tlet dialog_window = jQuery('#spbc_dialog')\n\tdialog_window.empty();\n\n\tjQuery('#spbc_file_view_preloader').css({display:'none'})\n\n\tlet row_template = '
    %s

    %s


    ';\n\n\tfor(let row in result.file){\n\t\tdialog_window.append(row_template.printf(row, result.file[row]));\n\t}\n\n\tlet content_height = Object.keys(result.file).length * 19 < 76 ? 76 : Object.keys(result.file).length * 19,\n\t\tvisible_height = (document.documentElement.clientHeight) / 100 * 75,\n\t\toverflow = content_height < visible_height ? 'hidden' : 'scroll',\n\t\theight = overflow === 'scroll' ? visible_height : content_height;\n\n\tdialog_window.css({\n\t\theight: height,\n\t\toverflow: overflow\n\t})\n\n\tdialog_window.dialog({\n\t\tmodal:true,\n\t\ttitle: ('Loaded: ' + result.file_path),\n\t\tposition: { my: \"center top\", at: \"center top+100px\" , of: window },\n\t\twidth: +(jQuery('#wpwrap').width() / 100 * 90),\n\t\tshow: { effect: \"blind\", duration: 500 },\n\t\tdraggable: true,\n\t\tresizable: false,\n\t\tcloseText: \"X\",\n\t\tclasses: {\"ui-dialog\": 'spbc---top'},\n\t\topen: function(event, ui) {\n\t\t\tevent.target.style.overflow = overflow;\n\t\t\tjQuery('#spbc_dialog').height(height);\n\t\t\tjQuery('.ui-widget-overlay').on('click', function() {\n\t\t\t\tjQuery(\"#spbc_dialog\").dialog('close');\n\t\t\t});\n\t\t},\n\t\tbeforeClose: function(event, ui) {\n\t\t\tdocument.body.style.overflow = 'auto';\n\t\t\tjQuery('#spbc_dialog').empty();\n\t\t},\n\t});\n\n\tconsole.log('FILE_VIEWED');\n\n}\n\nfunction spbc_scanner_button_file_view_bad_event(obj){\n\tvar self = jQuery(obj);\n\tvar data = {\n\t\taction: 'spbc_scanner_file_view',\n\t\tfile_id: self.parents('.row-actions').attr('uid'),\n\t};\n\tvar params = {\n\t\tspinner: self.parent().siblings('.tbl-preloader--tiny'),\n\t\tcallback: spbc_scannerButtonViewBadFile_callback,\n\t\terrorOutput: function(msg){ spbcModal.open().putError( msg ); },\n\t};\n\tspbc_sendAJAXRequest(data, params);\n}\n\nfunction spbc_scanner_button_page_view_bad_event(obj){\n\tvar self = jQuery(obj);\n\tvar data = {\n\t\taction: 'spbc_scanner_page_view',\n\t\tpage_url: self.parent().attr('uid'),\n\t};\n\tvar params = {\n\t\tspinner: self.parent().siblings('.tbl-preloader--tiny'),\n\t\tcallback: spbc_scannerButtonViewBad_callback,\n\t\terrorOutput: function(msg){ spbcModal.open().putError( msg ); },\n\t};\n\tspbc_sendAJAXRequest(data, params);\n}\n\nfunction spbc_scannerButtonViewBadFile_callback(result, data, params){\n\n\tconsole.log('FILE_VIEWED_BAD_CODE_FILE');\n\tconsole.log(arguments);\n\tjQuery('#spbc_dialog').empty();\n\n\tvar row_template = '
    %s

    %s


    ',\n\t\trow_template_bad = '
    %s

    %s


    ',\n\t\tseverity_parts = [],\n\t\tseverity_parts_sorted = [],\n\t\tseverity_keys_sorted = [];\n\n\tresult.weak_spots = JSON.parse(result.weak_spots)\n\tfor(let severity in result.weak_spots){\n\t\tseverity_parts[severity] = Object.keys(result.weak_spots[severity])\n\t}\n\n\tseverity_keys_sorted = Object.keys(severity_parts).sort();\n\n\tfor(key in severity_keys_sorted){\n\t\tseverity_parts_sorted[severity_keys_sorted[key]] = severity_parts[severity_keys_sorted[key]]\n\t}\n\n\tfor (let severity_part in severity_parts_sorted) {\n\t\tlet header_name = 'spbc-dialog-row-header-' + severity_part.toLowerCase();\n\t\tlet header_html = '' + severity_part + ' weakspots:';\n\t\tconst dialog = jQuery('#spbc_dialog');\n\n\t\tdialog.append(row_template.printf('',header_html));\n\t\tdialog.append(row_template. printf('...','...'));\n\n\t\tlet header = dialog.find('#' + header_name);\n\t\theader.parent().parent().css('text-align', 'center');\n\t\theader.parent().parent().css('border', '1px dotted');\n\t\theader.parent().parent().css('background', 'darkgrey');\n\n\t\tfor(let str_num in severity_parts[severity_part]){\n\t\t\t// Sort bad line\n\t\t\tstr_num = [...new Set(str_num)].sort()\n\n\t\t\tlet row = +severity_parts[severity_part][str_num],\n\t\t\t\tdisplay_depth = 2;\n\n\t\t\t// Display only existing lines of file\n\t\t\tfor(let curr_row = row - display_depth; curr_row <= row + display_depth; curr_row++ ){\n\t\t\t\tif( typeof result.file[curr_row] !== 'undefined' ){\n\t\t\t\t\tdialog.append((row === curr_row ? row_template_bad : row_template).printf(curr_row, result.file[curr_row]));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Placing an empty string between results\n\t\t\tdialog.append(row_template. printf('...','...'));\n\t\t}\n\t}\n\n\t// Removing last empty string\n\tjQuery('#spbc_dialog div').last().remove();\n\n\tlet content_height = jQuery('#spbc_dialog div').length * 19 < 76 ? 76 : jQuery('#spbc_dialog div').length * 19,\n\t\tvisible_height = (document.documentElement.clientHeight) / 100 * 75,\n\t\toverflow = content_height < visible_height ? 'no_scroll' : 'scroll',\n\t\theight = overflow === 'scroll' ? visible_height : content_height;\n\n\tjQuery('#spbc_dialog').dialog({\n\t\tmodal:true,\n\t\ttitle: result.file_path,\n\t\tposition: { my: \"center top\", at: \"center top+100px\" , of: window },\n\t\twidth: +(jQuery('#wpwrap').width() / 100 * 90),\n\t\tshow: { effect: \"blind\", duration: 500 },\n\t\tdraggable: true,\n\t\tresizable: false,\n\t\tcloseText: \"X\",\n\t\tclasses: {\"ui-dialog\": 'spbc---top'},\n\t\topen: function(event, ui) {\n\t\t\tevent.target.style.overflow = overflow;\n\t\t\tjQuery('#spbc_dialog').height(height);\n\t\t\tjQuery('.ui-widget-overlay').on('click', function() {\n\t\t\t\tjQuery(\"#spbc_dialog\").dialog('close');\n\t\t\t});\n\t\t},\n\t\tbeforeClose: function(event, ui) {\n\t\t\tdocument.body.style.overflow = 'auto';\n\t\t\tjQuery('#spbc_dialog').empty();\n\t\t},\n\t});\n}\n\nfunction spbc_scannerButtonViewBad_callback(result, data, params){\n\n\tconsole.log('FILE_VIEWED_BAD_CODE');\n\n\tconsole.log(arguments);\n\n\tlet afterClose = () => {};\n\n\tif ( result.success == true ) {\n\t\tconsole.log(result);\n\t\tvar row_template = '
    ' +\n\t\t\t\t'%s' +\n\t\t\t\t'

    %s

    ' +\n\t\t\t\t'
    ',\n\t\t\trow_template_bad = '
    ' +\n\t\t\t\t'%s' +\n\t\t\t\t'

    %s

    ' +\n\t\t\t\t'
    ',\n\t\t\tstr_nums = [];\n\n\t\tresult.weak_spots = JSON.parse(result.weak_spots);\n\t\tfor(let severity in result.weak_spots){\n\t\t\tstr_nums = str_nums.concat(Object.keys(result.weak_spots[severity]));\n\t\t}\n\n\t\tstr_nums = [...new Set(str_nums)].sort(); // Sort bad line\n\t\t//get a map of bad strings\n\t\tlet bad_strings_map = new Map(Object.entries(result.weak_spots.CRITICAL)) //TODO: Probably there can get something else except CRITICAL in the future\n\t\tfor(let str_num in str_nums){\n\t\t\tif (str_num == 0 && bad_strings_map.get(str_nums[str_num]).toLowerCase().includes('doctype')) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet row = +str_nums[str_num],\n\t\t\t\tdisplay_depth = 2;\n\n\t\t\t// Display only existing lines of file\n\t\t\tfor(let curr_row = row - display_depth; curr_row <= row + display_depth; curr_row++ ){\n\t\t\t\tif( typeof result.file[curr_row] !== 'undefined' ){\n\t\t\t\t\tlet is_bad_string = (row === curr_row)\n\t\t\t\t\tlet unformatted_row\n\t\t\t\t\tlet highlited_row\n\t\t\t\t\tif (is_bad_string){\n\t\t\t\t\t\tunformatted_row = row_template_bad\n\t\t\t\t\t} else {\n\t\t\t\t\t\tunformatted_row = row_template\n\t\t\t\t\t}\n\t\t\t\t\tif (is_bad_string && !result.file[curr_row].includes('iframe')){\n\t\t\t\t\t\thighlited_row = unformatted_row.printf(curr_row, bad_strings_map.get(str_nums[str_num]));\n\t\t\t\t\t} else {\n\t\t\t\t\t\thighlited_row = unformatted_row.printf(curr_row, result.file[curr_row]);\n\t\t\t\t\t}\n\t\t\t\t\tjQuery('#spbc_dialog').append(highlited_row);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Placing an empty string between results\n\t\t\tjQuery('#spbc_dialog').append(row_template. printf('', ''));\n\n\t\t\t// Removing last empty string\n\t\t\tjQuery('#spbc_dialog div').last().remove();\n\t\t}\n\t} else {\n\t\tlet wrapperElement = '
    %s
    '\n\t\tjQuery('#spbc_dialog').append(wrapperElement.printf(result.content));\n\t\tafterClose = () => {document.location.reload();};\n\t}\n\n\tlet content_height = jQuery('#spbc_dialog div').length * 19 < 76 ? 76 : jQuery('#spbc_dialog div').length * 19,\n\t\tvisible_height = (document.documentElement.clientHeight) / 100 * 75,\n\t\theight = 'auto',\n\t\toverflow = content_height < visible_height ? 'no_scroll' : 'scroll';\n\n\tjQuery('#spbc_dialog').dialog({\n\t\tmodal:true,\n\t\ttitle: result.file_path,\n\t\tposition: { my: \"center top\", at: \"center top+100px\" , of: window },\n\t\twidth: +(jQuery('#wpwrap').width() / 100 * 90),\n\t\tshow: { effect: \"blind\", duration: 500 },\n\t\tdraggable: true,\n\t\tresizable: false,\n\t\tcloseText: \"X\",\n\t\tclasses: {\"ui-dialog\": 'spbc---top'},\n\t\topen: function(event, ui) {\n\t\t\tevent.target.style.overflow = overflow;\n\t\t\tjQuery('#spbc_dialog').height(height);\n\t\t\tjQuery('.ui-widget-overlay').on('click', function() {\n\t\t\t\tjQuery(\"#spbc_dialog\").dialog('close');\n\t\t\t});\n\t\t},\n\t\tbeforeClose: function(event, ui) {\n\t\t\tdocument.body.style.overflow = 'auto';\n\t\t\tjQuery('#spbc_dialog').empty();\n\t\t},\n\t\tclose: afterClose,\n\t});\n}\n\nfunction spbc_scanner_button_file_compare_event(obj){\n\tvar self = jQuery(obj);\n\tvar data = {\n\t\taction: 'spbc_scanner_file_compare',\n\t\tfile_id: self.parents('.row-actions').attr('uid'),\n\t};\n\tvar params = {\n\t\tspinner: self.parent().siblings('.tbl-preloader--tiny'),\n\t\tcallback: spbc_scannerButtonFileCompare_callback,\n\t\terrorOutput: function(msg){ spbcModal.open().putError( msg ); },\n\t};\n\tspbc_sendAJAXRequest(data, params);\n}\n\nfunction spbc_scannerButtonFileCompare_callback(result, data, params){\n\n\tconsole.log('FILE_COMPARED');\n\n\tlet row_template = '

    %s

    %s

    %s


    ';\n\tlet row_template_bad = '

    %s

    %s

    %s


    ';\n\n\tjQuery('#spbc_dialog').append(row_template.printf('Modified', 'Line', 'Original'));\n\n\tfor(var row=1, prev = false, next = false; typeof result.file[row] != 'undefined' || typeof result.file_original[row] != 'undefined'; row++){\n\n\t\tif(typeof result.file[row] == 'undefined') result.file[row] = '';\n\t\tif(typeof result.file_original[row] == 'undefined') result.file_original[row] = '';\n\n\t\t// Display only existing lines of file\n\t\tif(result.difference.indexOf(row) != -1){\n\t\t\tfor(let display_depth = 2, curr_row = row - display_depth; curr_row <= row + display_depth; curr_row++ ){\n\t\t\t\tif( typeof result.file[curr_row] !== 'undefined' && typeof result.file_original[row] !== 'undefined') {\n\t\t\t\t\tjQuery('#spbc_dialog').append(\n\t\t\t\t\t\t(row === curr_row ? row_template_bad : row_template).printf(\n\t\t\t\t\t\t\tresult.file[curr_row] ? result.file[curr_row] : '',\n\t\t\t\t\t\t\tcurr_row,\n\t\t\t\t\t\t\tresult.file_original[curr_row] ? result.file_original[curr_row] : ''\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tjQuery('#spbc_dialog').append(row_template. printf('', '', ''));\n\t\t}\n\t}\n\n\tvar content_height = jQuery('#spbc_dialog div').length * 19 + 19,\n\t\tvisible_height = (document.documentElement.clientHeight) / 100 * 75,\n\t\toverflow = content_height < visible_height ? 'no_scroll' : 'scroll',\n\t\theight = overflow === 'scroll' ? visible_height : content_height;\n\n\tjQuery('#spbc_dialog').dialog({\n\t\tmodal:true,\n\t\ttitle: result.file_path,\n\t\tposition: { my: \"center top\", at: \"center top+100px\" , of: window },\n\t\twidth: +(jQuery('#wpwrap').width() / 100 * 90),\n\t\theight: height,\n\t\tshow: { effect: \"blind\", duration: 500 },\n\t\tdraggable: true,\n\t\tresizable: true,\n\t\tcloseText: \"X\",\n\t\tclasses: {\"ui-dialog\": 'spbc---top'},\n\t\topen: function(event, ui) {\n\t\t\tdocument.body.style.overflow = 'hidden';\n\t\t\tevent.target.style.overflow = overflow;\n\t\t\tjQuery('#spbc_dialog').height(height);\n\t\t},\n\t\tbeforeClose: function(event, ui) {\n\t\t\tdocument.body.style.overflow = 'auto';\n\t\t\tjQuery('#spbc_dialog').empty();\n\t\t}\n\t});\n}\n\nfunction spbc_scanner__reload_scan_info() {\n\tjQuery('.spbc_hint__last_scan_title').text(spbcScaner.look_below_for_scan_res);\n\tconst data = {\n\t\taction: 'spbc_scanner__last_scan_info'\n\t};\n\tconst params = {\n\t\tcallback: (result) => {\n\t\t\tdocument.getElementById('spbc_scanner__last_scan_info').innerText = result.data;\n\t\t}\n\t};\n\tspbc_sendAJAXRequest(data, params);\n}\n\n/**\n * Show snapshots of file\n * @param obj\n */\nfunction spbc_scanner_file_monitoring_show_current_snapshot(obj)\n{\n\tconst self = jQuery(obj);\n\tconst fileId = self.parents('.row-actions').attr('uid');\n\tconst file_name = self.closest('.column-path').find('.title').text();\n\n\t// Init and open remodal\n\tconst remodal = jQuery('[data-remodal-id=spbc-file-monitoring-modal]');\n\tconst remodalObject = remodal.remodal();\n\tremodalObject.open();\n\n\t// Ajax request to get data for slider\n\tlet data = {\n\t\taction: 'spbc_file_monitoring_show_snapshots',\n\t\tfile_id: fileId,\n\t\tsecurity: spbcSettings.ajax_nonce\n\t};\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\tasync: true,\n\t\turl: spbcSettings.ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(result) {\n\t\t\tif (result.success) {\n\t\t\t\tremodal.find('#spbc-fm-snapshot-list ul').remove();\n\t\t\t\tremodal.find('#spbc-fm-snapshot-file-name').text(file_name);\n\t\t\t\tdrawSnapshotList(result.data, remodal);\n\t\t\t\tdrawCurrentSnapshot(result.data[0].id, remodal);\n\t\t\t} else {\n\t\t\t\t// TODO: show errors\n\t\t\t}\n\t\t},\n\t});\n}\n\n/**\n *\n * @param data\n * @param remodal\n */\nfunction drawSnapshotList(data, remodal)\n{\n\tlet list = '';\n\n\tfor (let item of data) {\n\t\tlist += `
  • ${item.created_at}
  • `;\n\t}\n\n\tlet html =\n\t\t`
      \n ${list}\n
    `;\n\n\tremodal.find('#spbc-fm-snapshot-list').append(html);\n}\n\nfunction drawCurrentSnapshot(snapshot_id, remodal)\n{\n\t// Ajax request to get data for slider\n\tlet data = {\n\t\taction: 'spbc_file_monitoring_show_current_snapshot',\n\t\tsnapshot_id,\n\t\tsecurity: spbcSettings.ajax_nonce\n\t};\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\tasync: true,\n\t\turl: spbcSettings.ajaxurl,\n\t\tdata: data,\n\t\tbeforeSend: function() {\n\t\t\tjQuery('#spbc-file-monitoring-modal-preloader').show();\n\t\t},\n\t\tsuccess: function(result) {\n\t\t\tif (result.success) {\n\t\t\t\tremodal.find('#spbc-fm-snapshot-view .wrap').remove();\n\t\t\t\tremodal.find('[data-spanshot-id').removeClass('active');\n\t\t\t\tremodal.find('[data-spanshot-id=' + snapshot_id + ']').addClass('active');\n\n\t\t\t\tlet html =\n\t\t\t\t\t`
    \n
    \n                            \n                                ${result.data.content}\n                            \n                        
    \n
    `;\n\n\t\t\t\tjQuery('#spbc-file-monitoring-modal-preloader').hide();\n\t\t\t\tremodal.find('#spbc-fm-snapshot-view').append(html);\n\t\t\t\tdocument.querySelectorAll('pre code').forEach((el) => {\n\t\t\t\t\thljs.highlightElement(el);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// TODO: show errors\n\t\t\t}\n\t\t},\n\t});\n}\n\n/**\n * Cure file\n * @param obj\n */\nfunction spbc_scanner_button_cure_file_ajax_handler(obj)\n{\n\tconst self = jQuery(obj);\n\tconst fileFastHash = self.parents('.row-actions').attr('uid');\n\n\tlet data = {\n\t\taction: 'spbc_file_cure_ajax_action',\n\t\tfile_fast_hash: fileFastHash,\n\t\tsecurity: spbcSettings.ajax_nonce\n\t};\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\tasync: true,\n\t\turl: spbcSettings.ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(result) {\n\t\t\tif (result.success) {\n\t\t\t\tspbcModal.open().put(result.data);\n\t\t\t\tdocument.addEventListener(\"spbcModalClosed\", function( e ) {\n\t\t\t\t\tdocument.location.reload();\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tspbcModal.open().putError(result.data);\n\t\t\t}\n\t\t},\n\t});\n}\n\n/**\n * Restore file from backup\n * @param obj\n */\nfunction spbc_scanner_button_restore_from_backup_ajax_handler(obj)\n{\n\tconst self = jQuery(obj);\n\tconst fileFastHash = self.parents('.row-actions').attr('uid');\n\n\tlet data = {\n\t\taction: 'spbc_restore_file_from_backup_ajax_action',\n\t\tfile_fast_hash: fileFastHash,\n\t\tsecurity: spbcSettings.ajax_nonce\n\t};\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\tasync: true,\n\t\turl: spbcSettings.ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(result) {\n\t\t\tif (result.success) {\n\t\t\t\tspbcModal.open().put(result.data);\n\t\t\t\tdocument.addEventListener(\"spbcModalClosed\", function( e ) {\n\t\t\t\t\tdocument.location.reload();\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tspbcModal.open().putError(result.data);\n\t\t\t}\n\t\t},\n\t});\n}\n\n/**\n * Clear scan results\n */\nfunction spbc_scanner_button_clear_scan_results()\n{\n\tif( ! confirm('Do you confirm to clear the scan results?') )\n\t\treturn;\n\n\tconsole.log('CLEAR');\n\n\tspbc_sendAJAXRequest(\n\t\t{ action: 'spbc_scanner_clear', },\n\t\t{\n\t\t\ttype: 'GET',\n\t\t\tsuccessCallback: function(){ document.location = document.location },\n\t\t\tcomplete: null,\n\t\t\terrorOutput: null,\n\t\t\tcontext: this,\n\t\t\ttimeout: 40000,\n\t\t\tsuccess: function() {\n\t\t\t\tdocument.location.reload();\n\t\t\t},\n\t\t},\n\t);\n}\n\njQuery(document).ready(function(){\n\n\t// EVENT HADLING\n\tspbc_tbl__bulk_actions__listen(); // Table. Row bulk handler\n\tspbc_tbl__row_actions__listen(); // Table. Row actions handler\n\tspbc_tbl__pagination__listen(); // Table. Pagination handler\n\tspbc_tbl__sort__listen(); // Table. Sort handler\n\n\tspbcStartShowHide();\n\n\t// Preparing progressbar\n\tjQuery('#spbc_scaner_progress_bar').progressbar({\n\t\tvalue: 0,\n\t\tcreate: function( event, ui ) {\n\t\t\tevent.target.style.position = 'relative';\n\t\t\tevent.target.style.marginBottom = '12px';\n\t\t},\n\t\tchange: function(event, ui){\n\t\t\tjQuery('.spbc_progressbar_counter span').text(jQuery(event.target).progressbar('option', 'value') + ' %');\n\t\t},\n\t});\n\n\t// Preparing accordion\n\tjQuery('#spbc_scan_accordion').accordion({\n\t\theader: \"h3\",\n\t\theightStyle: 'content',\n\t\tcollapsible: true,\n\t\tactive: false,\n\t\tactivate: function( event, ui ) {\n\t\t\tif( ui.oldPanel.length === 0 && ui.oldHeader.length === 0 )\n\t\t\t\tjQuery(\"#spbc_scan_accordion\").accordion(\"option\", \"classes.ui-accordion-content\", \"ui-corner-bottom spbc-overflow--visible\");\n\t\t},\n\t\tbeforeActivate: function( event, ui ) {\n\t\t\tif( ui.oldPanel.length === 1 && ui.oldHeader.length === 1 )\n\t\t\t\tjQuery(\"#spbc_scan_accordion\").accordion(\"option\", \"classes.ui-accordion-content\", \"ui-corner-bottom\");\n\t\t}\n\t});\n\n\t// Init scanner plugin\n\twindow.spbc_scanner = new spbcMalwareScanner({\n\t\tsettings: spbcScaner.settings,\n\t\tstates: spbcScaner.states,\n\t\tbutton: jQuery('#spbc_perform_scan'),\n\t\tspinner: jQuery('#spbc_perform_scan').next(),\n\t\tcallback: null,\n\t\tprogress_overall: jQuery('#spbc_scaner_progress_overall'),\n\t\tprogressbar: jQuery('#spbc_scaner_progress_bar'),\n\t\tprogressbar_text: jQuery('.spbc_progressbar_counter span'),\n\t\twrapper: document.getElementsByClassName('spbc_unchecked_file_list'),\n\t\twarnings: {\n\t\t\tlong_scan: jQuery('.spbc_hint_warning__long_scan'),\n\t\t\toutdated: jQuery('.spbc_hint_warning__outdated')\n\t\t}\n\t});\n\n\tjQuery(document).on('click', '.spbc_popup_tip--icon---show', function(){\n\t\tspbc_popup_tip___show( jQuery( this ) );\n\t});\n\n\tjQuery('#spbc_perform_scan').on('click', function(){\n\t\tjQuery('#spbcscan-results-log-module').remove();\n\t\tspbc_scanner.actionControl();\n\n\t\tif (!jQuery(\".spbc_log-wrapper .panel-body\").length) {\n\t\t\tjQuery(\".spbc_log-wrapper\").append('
    ');\n\t\t}\n\n\t\tjQuery(\".spbc_log-wrapper\").resizable({\n\t\t\thandles: 'n, s',\n\t\t\tcontainment: 'document',\n\t\t});\n\t});\n\n\tjQuery(\"#spbcscan-results-log-module\").resizable({\n\t\thandles: 'n, s',\n\t\tcontainment: 'document',\n\t});\n\n\t// Clear scanner's tables\n\tjQuery('#spbc_scanner_clear').on('click', function(){\n\n\t\tif( ! confirm('Do you confirm to clear the scan results?') )\n\t\t\treturn;\n\n\t\tconsole.log('CLEAR');\n\n\t\tspbc_sendAJAXRequest(\n\t\t\t{ action: 'spbc_scanner_clear', },\n\t\t\t{\n\t\t\t\ttype: 'GET',\n\t\t\t\tsuccessCallback: function(){ document.location = document.location },\n\t\t\t\tcomplete: null,\n\t\t\t\terrorOutput: null,\n\t\t\t\tcontext: this,\n\t\t\t\ttimeout: 40000,\n\t\t\t\tsuccess: function() {\n\t\t\t\t\tdocument.location.reload();\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t});\n\n\tjQuery('#spbc_scanner_save_to_pdf').on('click', function(){\n\t\tjQuery.ajax({\n\t\t\turl: spbcSettings.ajaxurl,\n\t\t\ttype: 'POST',\n\t\t\tdata: {\n\t\t\t\taction: 'spbc_scanner_save_to_pdf',\n\t\t\t\tsecurity: spbcSettings.ajax_nonce,\n\t\t\t\tno_cache: Math.random()\n\t\t\t},\n\t\t\txhrFields: {\n\t\t\t\tresponseType: 'blob'\n\t\t\t},\n\t\t\tsuccess: function(data) {\n\t\t\t\tjQuery.ajax({\n\t\t\t\t\t\turl: spbcSettings.ajaxurl,\n\t\t\t\t\t\ttype: 'POST',\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\taction: 'spbc_scanner_get_pdf_file_name',\n\t\t\t\t\t\t\tsecurity: spbcSettings.ajax_nonce,\n\t\t\t\t\t\t\tno_cache: Math.random()\n\t\t\t\t\t\t},\n\t\t\t\t\t\txhrFields: {\n\t\t\t\t\t\t\tresponseType: 'text'\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsuccess: function(filename) {\n\t\t\t\t\t\t\tlet blob=new Blob([data]);\n\t\t\t\t\t\t\tlet link=document.createElement('a');\n\t\t\t\t\t\t\tlink.href=window.URL.createObjectURL(blob);\n\t\t\t\t\t\t\tlink.download=filename.data;\n\t\t\t\t\t\t\tlink.click();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t}\n\t\t});\n\t});\n\n\t// Select snapshot\n\tjQuery(document).on('click', '.spbc-fm-snapshot-list [data-spanshot-id]', function() {\n\t\tconst currentSnapshotId = jQuery(this).data('spanshot-id');\n\t\tconst activeSnapshotId = jQuery('.spbc-fm-snapshot-list [data-spanshot-id].active').data('spanshot-id');\n\n\t\tif (currentSnapshotId === activeSnapshotId) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst remodal = jQuery('[data-remodal-id=spbc-file-monitoring-modal]');\n\t\tdrawCurrentSnapshot(currentSnapshotId, remodal)\n\t});\n});\n"],"names":["spbc_popup_tip___show","show_icon","remove_desc_func","e","jQuery","target","parent","length","hasClass","hide","document","off","tip_title","attr","tip_text","obj","after","empty","append","css","top","position","left","on","parents","spbc_scanner_button_file_view_event","self","data","action","file_id","params","spinner","siblings","callback","spbc_scannerButtonView_callback","errorOutput","msg","spbcModal","open","putError","spbc_sendAJAXRequest","spbc_scanner_analysis_log_delete_from_log","let","fileIds","push","selectedItems","closest","find","alert","each","index","element","elementId","val","children","file_ids","window","location","reload","spbc_scanner_button_page_view_event","page_url","wp_wrap","dialog_window","dialog","modal","title","my","at","of","width","show","effect","duration","draggable","resizable","closeText","classes","ui-dialog","event","ui","style","overflow","height","documentElement","beforeClose","body","size_multiplier","result","row","display","file","printf","content_height","Object","keys","visible_height","file_path","console","log","spbc_scanner_button_file_view_bad_event","spbc_scannerButtonViewBadFile_callback","spbc_scanner_button_page_view_bad_event","spbc_scannerButtonViewBad_callback","arguments","severity_keys_sorted","severity","severity_part","row_template","severity_parts","severity_parts_sorted","weak_spots","JSON","parse","key","sort","str_num","header_name","toLowerCase","header_html","header","Set","curr_row","last","remove","afterClose","success","str_nums","concat","bad_strings_map","Map","entries","CRITICAL","get","includes","is_bad_string","unformatted_row","highlited_row","content","close","spbc_scanner_button_file_compare_event","spbc_scannerButtonFileCompare_callback","file_original","difference","indexOf","spbc_scanner__reload_scan_info","text","spbcScaner","look_below_for_scan_res","getElementById","innerText","spbc_scanner_file_monitoring_show_current_snapshot","fileId","file_name","remodal","security","spbcSettings","ajax_nonce","ajax","type","async","url","ajaxurl","drawSnapshotList","drawCurrentSnapshot","id","list","item","created_at","html","snapshot_id","beforeSend","removeClass","addClass","querySelectorAll","forEach","hljs","highlightElement","el","spbc_scanner_button_cure_file_ajax_handler","file_fast_hash","put","addEventListener","spbc_scanner_button_restore_from_backup_ajax_handler","spbc_scanner_button_clear_scan_results","confirm","successCallback","complete","context","this","timeout","ready","spbc_tbl__bulk_actions__listen","spbc_tbl__row_actions__listen","spbc_tbl__pagination__listen","spbc_tbl__sort__listen","spbcStartShowHide","progressbar","value","create","marginBottom","change","accordion","heightStyle","collapsible","active","activate","oldPanel","oldHeader","beforeActivate","spbc_scanner","spbcMalwareScanner","settings","states","button","next","progress_overall","progressbar_text","wrapper","getElementsByClassName","warnings","long_scan","outdated","actionControl","handles","containment","no_cache","Math","random","xhrFields","responseType","filename","blob","Blob","link","createElement","href","URL","createObjectURL","download","click","currentSnapshotId"],"mappings":"AAAA,SAASA,sBAAsBC,GAIP,SAAnBC,EAA4BC,GAGjB,KAAA,IAANA,IAEyD,GAA9DC,OAAOD,EAAEE,MAAM,EAAEC,OAAO,0BAA0B,EAAEC,QAAeH,CAAAA,OAAOD,EAAEE,MAAM,EAAEG,SAAS,+BAA+B,GAC5HJ,OAAOD,EAAEE,MAAM,EAAEG,SAAS,6BAA6B,KAGzDJ,OAAO,0BAA0B,EAAEK,KAAK,EACxCL,OAAOM,QAAQ,EAAEC,IAAI,QAAST,CAAgB,EAEhD,CAdA,IAAIU,EAAYX,EAAUY,KAAK,gBAAgB,GAAK,KAChDC,EAAYb,EAAUY,KAAK,eAAe,GAAM,KAmBhDE,GAJJb,EAAiB,EAEjBD,EAAUe,MAAM,6CAA6C,EAEnDZ,OAAO,0BAA0B,GAE3CW,EAAIE,MAAM,EACRC,OAAO,2CAA2C,EAClDC,IAAI,CACJC,IAAKnB,EAAUoB,SAAS,EAAED,IAAM,EAChCE,KAAMrB,EAAUoB,SAAS,EAAEC,KAAO,EACnC,CAAC,EACFP,EAAIG,OAAO,2DAA2D,EACpEA,OAAO,qCAAuCN,EA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,KAAM,MACN2B,gBAAiB,WAAY/K,SAAS+C,SAAW/C,SAAS+C,QAAS,EACnEiI,SAAU,KACVvJ,YAAa,KACbwJ,QAASC,KACTC,QAAS,IACThE,QAAS,WACRnH,SAAS+C,SAASC,OAAO,CAC1B,CACD,CACD,EACD,CAAC,EAEDtD,OAAO,2BAA2B,EAAEmB,GAAG,QAAS,WAC/CnB,OAAOyJ,KAAK,CACXG,IAAKL,aAAaM,QAClBH,KAAM,OACNnI,KAAM,CACLC,OAAQ,2BACR8H,SAAUC,aAAaC,WACvBqE,SAAUC,KAAKC,OAAO,CACvB,EACAC,UAAW,CACVC,aAAc,MACf,EACAxG,QAAS,SAASlG,GACjBvB,OAAOyJ,KAAK,CACVG,IAAKL,aAAaM,QAClBH,KAAM,OACNnI,KAAM,CACLC,OAAQ,iCACR8H,SAAUC,aAAaC,WACvBqE,SAAUC,KAAKC,OAAO,CACvB,EACAC,UAAW,CACVC,aAAc,MACf,EACAxG,QAAS,SAASyG,GACjB5L,IAAI6L,EAAK,IAAIC,KAAK,CAAC7M,EAAK,EACpB8M,EAAK/N,SAASgO,cAAc,GAAG,EACnCD,EAAKE,KAAKnL,OAAOoL,IAAIC,gBAAgBN,CAAI,EACzCE,EAAKK,SAASR,EAAS3M,KACvB8M,EAAKM,MAAM,CACZ,CACD,CACD,CACD,CACD,CAAC,CACF,CAAC,EAGD3O,OAAOM,QAAQ,EAAEa,GAAG,QAAS,4CAA6C,WACzE,IAAMyN,EAAoB5O,OAAOwL,IAAI,EAAEjK,KAAK,aAAa,EAGrDqN,IAFqB5O,OAAO,kDAAkD,EAAEuB,KAAK,aAAa,GAOtGwI,oBAAoB6E,EADJ5O,OAAO,8CAA8C,CACvB,CAC/C,CAAC,CACF,CAAC"} \ No newline at end of file diff --git a/js/spbc-settings_tab--security_log.min.js.map b/js/spbc-settings_tab--security_log.min.js.map index df30090b0..41ba159fb 100644 --- a/js/spbc-settings_tab--security_log.min.js.map +++ b/js/spbc-settings_tab--security_log.min.js.map @@ -1 +1 @@ -{"version":3,"file":"spbc-settings_tab--security_log.min.js","sources":["spbc-settings_tab--security_log.js"],"sourcesContent":["// SECURITY LOGS SHOW MORE\r\nfunction spbc_sec_logs__show_more__listen(){\r\n\tjQuery('#spbc_show_more_button').on('click', function(){\r\n\t\tif(spbcSettingsSecLogs.clicks < 2){\r\n\t\t\tspbcSettingsSecLogs.clicks++;\r\n\t\t\tvar data = {\r\n\t\t\t\taction: 'spbc_show_more_security_logs',\r\n\t\t\t\tamount: spbcSettingsSecLogs.amount * (+spbcSettingsSecLogs.clicks+1),\r\n\t\t\t};\r\n\t\t\tvar params = {\r\n\t\t\t\tbutton: this,\r\n\t\t\t\tspinner: this.nextElementSibling,\r\n\t\t\t\twrapper: jQuery('#spbc_tbl__secuirty_logs').find('tbody'),\r\n\t\t\t\tcallback: spbc_sec_logs__show_more__callback,\r\n\t\t\t};\r\n\t\t\tspbc_sendAJAXRequest( data, params );\r\n\t\t}else{\r\n\t\t\t// Hide \"More logs\" button, show \"Control Panel\" button\r\n\t\t\tjQuery(this).hide();\r\n\t\t\tjQuery(this).siblings('.spbc__show_more_logs').css('display', 'inline-block');\r\n\t\t}\r\n\t});\r\n}\r\n\r\n\t// Callback for SHOW MORE SECURITY LOGS\r\nfunction spbc_sec_logs__show_more__callback(result, data, params){\t\r\n\tconsole.log(result);\r\n\tif(result.size > 0){\r\n\t\tjQuery(params.wrapper).html(result.html);\r\n\t\tspbc_tbl__row_actions__listen();\r\n\t\tspbcStartShowHide();\r\n\t}else{\r\n\t\t// Hide \"More logs\" button, show \"Control Panel\" button\r\n\t\tjQuery(params.button).hide();\r\n\t\tjQuery(params.button).siblings('.spbc__show_more_logs').css('display', 'inline-block');\r\n\t}\r\n}\r\n\r\nfunction spbc_sec_logs__allow_ip(ip) {\r\n\tspbc_sec_logs__filter_ip( ip, 'allow')\r\n\treturn false;\r\n}\r\n\r\nfunction spbc_sec_logs__ban_ip(ip) {\r\n\tspbc_sec_logs__filter_ip( ip, 'deny')\r\n\treturn false;\r\n}\r\n\r\nfunction spbc_sec_logs__filter_ip( ip, status, bulk = false) {\r\n\tconst data = {\r\n\t\taction: 'spbc_tc__filter_ip',\r\n\t\tip: ip,\r\n\t\tstatus: status\r\n\t};\r\n\tconst params = {\r\n\t\tstatus: status,\r\n\t};\r\n\tif (!bulk) {\r\n\t\tparams.callback = spbc_sec_logs__allow_ip__callback;\r\n\t}\r\n\tspbc_sendAJAXRequest( data, params );\r\n\r\n\treturn false;\r\n}\r\n\r\nfunction spbc_sec_logs__allow_ip__callback(result, data) {\r\n\tconsole.log(data);\r\n\tif (result.success) {\r\n\t\tlet msg = data.status === 'allow' ? 'Allowed' : 'Banned';\r\n\t\talert('Success. Selected IPs have been ' + msg + '. Changes will be applied within 10 minutes.');\r\n\t} else {\r\n\t\talert(result.data);\r\n\t}\r\n}\r\n\r\njQuery(document).ready(function(){\r\n\t\r\n\tspbc_tbl__row_actions__listen(); // Table. Row actions handler\r\n\tspbc_tbl__bulk_actions__listen();\r\n\tspbc_tbl__pagination__listen(); // Table. Pagination handler\r\n\tspbc_tbl__sort__listen(); // Table. Sort handler\r\n\t\r\n\t// Handler for show more SECURITY LOGS\r\n\tspbc_sec_logs__show_more__listen();\r\n\t\r\n\t// Start to hide long values in a table\r\n\tspbcStartShowHide();\r\n\t\r\n});"],"names":["spbc_sec_logs__show_more__listen","jQuery","on","data","params","spbcSettingsSecLogs","clicks","action","amount","button","this","spinner","nextElementSibling","wrapper","find","callback","spbc_sec_logs__show_more__callback","spbc_sendAJAXRequest","hide","siblings","css","result","console","log","size","html","spbc_tbl__row_actions__listen","spbcStartShowHide","spbc_sec_logs__allow_ip","ip","spbc_sec_logs__filter_ip","spbc_sec_logs__ban_ip","status","bulk","spbc_sec_logs__allow_ip__callback","success","msg","alert","document","ready","spbc_tbl__bulk_actions__listen","spbc_tbl__pagination__listen","spbc_tbl__sort__listen"],"mappings":"AACA,SAASA,mCACRC,OAAO,wBAAwB,EAAEC,GAAG,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,MAAM,mCAAqCD,EAAM,8CAA8C,GAE/FC,MAAMhB,EAAOlB,IAAI,CAEnB,CAEAF,OAAOqC,QAAQ,EAAEC,MAAM,WAEtBb,8BAA8B,EAC9Bc,+BAA+B,EAC/BC,6BAA6B,EAC7BC,uBAAuB,EAGvB1C,iCAAiC,EAGjC2B,kBAAkB,CAEnB,CAAC"} \ No newline at end of file +{"version":3,"file":"spbc-settings_tab--security_log.min.js","sources":["spbc-settings_tab--security_log.js"],"sourcesContent":["// SECURITY LOGS SHOW MORE\nfunction spbc_sec_logs__show_more__listen(){\n\tjQuery('#spbc_show_more_button').on('click', function(){\n\t\tif(spbcSettingsSecLogs.clicks < 2){\n\t\t\tspbcSettingsSecLogs.clicks++;\n\t\t\tvar data = {\n\t\t\t\taction: 'spbc_show_more_security_logs',\n\t\t\t\tamount: spbcSettingsSecLogs.amount * (+spbcSettingsSecLogs.clicks+1),\n\t\t\t};\n\t\t\tvar params = {\n\t\t\t\tbutton: this,\n\t\t\t\tspinner: this.nextElementSibling,\n\t\t\t\twrapper: jQuery('#spbc_tbl__secuirty_logs').find('tbody'),\n\t\t\t\tcallback: spbc_sec_logs__show_more__callback,\n\t\t\t};\n\t\t\tspbc_sendAJAXRequest( data, params );\n\t\t}else{\n\t\t\t// Hide \"More logs\" button, show \"Control Panel\" button\n\t\t\tjQuery(this).hide();\n\t\t\tjQuery(this).siblings('.spbc__show_more_logs').css('display', 'inline-block');\n\t\t}\n\t});\n}\n\n\t// Callback for SHOW MORE SECURITY LOGS\nfunction spbc_sec_logs__show_more__callback(result, data, params){\t\n\tconsole.log(result);\n\tif(result.size > 0){\n\t\tjQuery(params.wrapper).html(result.html);\n\t\tspbc_tbl__row_actions__listen();\n\t\tspbcStartShowHide();\n\t}else{\n\t\t// Hide \"More logs\" button, show \"Control Panel\" button\n\t\tjQuery(params.button).hide();\n\t\tjQuery(params.button).siblings('.spbc__show_more_logs').css('display', 'inline-block');\n\t}\n}\n\nfunction spbc_sec_logs__allow_ip(ip) {\n\tspbc_sec_logs__filter_ip( ip, 'allow')\n\treturn false;\n}\n\nfunction spbc_sec_logs__ban_ip(ip) {\n\tspbc_sec_logs__filter_ip( ip, 'deny')\n\treturn false;\n}\n\nfunction spbc_sec_logs__filter_ip( ip, status, bulk = false) {\n\tconst data = {\n\t\taction: 'spbc_tc__filter_ip',\n\t\tip: ip,\n\t\tstatus: status\n\t};\n\tconst params = {\n\t\tstatus: status,\n\t};\n\tif (!bulk) {\n\t\tparams.callback = spbc_sec_logs__allow_ip__callback;\n\t}\n\tspbc_sendAJAXRequest( data, params );\n\n\treturn false;\n}\n\nfunction spbc_sec_logs__allow_ip__callback(result, data) {\n\tconsole.log(data);\n\tif (result.success) {\n\t\tlet msg = data.status === 'allow' ? 'Allowed' : 'Banned';\n\t\talert('Success. Selected IPs have been ' + msg + '. Changes will be applied within 10 minutes.');\n\t} else {\n\t\talert(result.data);\n\t}\n}\n\njQuery(document).ready(function(){\n\t\n\tspbc_tbl__row_actions__listen(); // Table. Row actions handler\n\tspbc_tbl__bulk_actions__listen();\n\tspbc_tbl__pagination__listen(); // Table. Pagination handler\n\tspbc_tbl__sort__listen(); // Table. Sort handler\n\t\n\t// Handler for show more SECURITY LOGS\n\tspbc_sec_logs__show_more__listen();\n\t\n\t// Start to hide long values in a table\n\tspbcStartShowHide();\n\t\n});"],"names":["spbc_sec_logs__show_more__listen","jQuery","on","data","params","spbcSettingsSecLogs","clicks","action","amount","button","this","spinner","nextElementSibling","wrapper","find","callback","spbc_sec_logs__show_more__callback","spbc_sendAJAXRequest","hide","siblings","css","result","console","log","size","html","spbc_tbl__row_actions__listen","spbcStartShowHide","spbc_sec_logs__allow_ip","ip","spbc_sec_logs__filter_ip","spbc_sec_logs__ban_ip","status","bulk","spbc_sec_logs__allow_ip__callback","success","msg","alert","document","ready","spbc_tbl__bulk_actions__listen","spbc_tbl__pagination__listen","spbc_tbl__sort__listen"],"mappings":"AACA,SAASA,mCACRC,OAAO,wBAAwB,EAAEC,G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AChDK,MAAM,mCAAqCD,EAAM,8CAA8C,GAE/FC,MAAMhB,EAAOlB,IAAI,CAEnB,CAEAF,OAAOqC,QAAQ,EAAEC,MAAM,WAEtBb,8BAA8B,EAC9Bc,+BAA+B,EAC/BC,6BAA6B,EAC7BC,uBAAuB,EAGvB1C,iCAAiC,EAGjC2B,kBAAkB,CAEnB,CAAC"} \ No newline at end of file diff --git a/js/spbc-settings_tab--settings_general.min.js.map b/js/spbc-settings_tab--settings_general.min.js.map index 66d50a8a3..0c0d8579e 100644 --- a/js/spbc-settings_tab--settings_general.min.js.map +++ b/js/spbc-settings_tab--settings_general.min.js.map @@ -1 +1 @@ -{"version":3,"file":"spbc-settings_tab--settings_general.min.js","sources":["spbc-settings_tab--settings_general.js"],"sourcesContent":["jQuery(document).ready(function(){\r\n\t\r\n\t// Show/Hide access key\r\n\tjQuery('#showHideLink').on('click', function(){\r\n\t\tjQuery('#spbc_key').val(jQuery('#spbc_key').attr('key'));\r\n\t\tjQuery('#spbc_key+div').show();\r\n\t\tjQuery(this).fadeOut(300);\r\n\t});\r\n\t\r\n\t// Set time zone filed value if key is bad\r\n\tif( !+spbcSettings.key_is_ok ){\r\n\t\tvar d = new Date();\r\n\t\tjQuery('#spbc_admin_timezone').val(d.getTimezoneOffset()/60*(-1));\t\r\n\t}\r\n\t\r\n\t// Function for shuffle authentication unique keys and salts\r\n\tfunction spbcShuffleSalts() {\r\n\t\tvar data = {};\r\n\t\tvar res = {};\r\n\t\tdata.security = spbcSettings.ajax_nonce;\r\n\t\tdata.action = 'spbc_action_shuffle_salts';\r\n\r\n\t\tjQuery.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\tasync: false,\r\n\t\t\turl: spbcSettings.ajaxurl,\r\n\t\t\tdata: data,\r\n\t\t\tsuccess: function(result){\r\n\t\t\t\tif(result.success) {\r\n\t\t\t\t\tdocument.location.reload();\r\n\t\t\t\t} else {\r\n\t\t\t\t\talert(result.data);\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t});\r\n\t}\r\n\r\n\t// Event for shuffle authentication unique keys and salts\r\n\t// Enabling the salt update button and repeatedly pressing\r\n\tvar actionShuffleSaltsCountClicks = 0;\r\n\r\n\tjQuery('#action-shuffle-salts').click(function (e) {\r\n\t\te.preventDefault();\r\n\r\n\t\tif (jQuery(this).hasClass('disabled')) {\r\n\t\t\tactionShuffleSaltsCountClicks++;\r\n\t\t\tif (actionShuffleSaltsCountClicks === 3) {\r\n\t\t\t\tjQuery(this).removeClass('disabled');\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tactionShuffleSaltsCountClicks = 0;\r\n\t\t\t\r\n\t\t\tif (confirm('Are you sure?')) {\r\n\t\t\t\tspbcShuffleSalts();\r\n\t\t\t}\r\n\t\t}\r\n\t});\r\n});"],"names":["jQuery","document","ready","d","on","val","attr","show","this","fadeOut","spbcSettings","key_is_ok","Date","getTimezoneOffset","actionShuffleSaltsCountClicks","click","e","preventDefault","hasClass","removeClass","confirm","data","security","ajax_nonce","action","ajax","type","async","url","ajaxurl","success","result","location","reload","alert"],"mappings":"AAAAA,OAAOC,QAAQ,EAAEC,MAAM,WAUtB,IACKC,EARLH,OAAO,eAAe,EAAEI,GAAG,QAAS,WACnCJ,OAAO,WAAW,EAAEK,IAAIL,OAAO,WAAW,EAAEM,KAAK,KAAK,CAAC,EACvDN,OAAO,eAAe,EAAEO,KAAK,EAC7BP,OAAOQ,IAAI,EAAEC,QAAQ,GAAG,CACzB,CAAC,EAGI,CAACC,aAAaC,YACdR,EAAI,IAAIS,KACZZ,OAAO,sBAAsB,EAAEK,IAAIF,EAAEU,kBAAkB,EAAE,GAAG,CAAE,CAAE,GA2BjE,IAAIC,EAAgC,EAEpCd,OAAO,uBAAuB,EAAEe,MAAM,SAAUC,GAC/CA,EAAEC,eAAe,EAEbjB,OAAOQ,IAAI,EAAEU,SAAS,UAAU,EAEG,IADtCJ,EAAAA,GAECd,OAAOQ,IAAI,EAAEW,YAAY,UAAU,GAGpCL,EAAgC,EAE5BM,QAAQ,eAAe,KAnCxBC,EAAO,IAENC,SAAWZ,aAAaa,WAC7BF,EAAKG,OAAS,4BAEdxB,OAAOyB,KAAK,CACXC,KAAM,OACNC,MAAO,CAAA,EACPC,IAAKlB,aAAamB,QAClBR,KAAMA,EACNS,QAAS,SAASC,GACdA,EAAOD,QACT7B,SAAS+B,SAASC,OAAO,EAEzBC,MAAMH,EAAOV,IAAI,CAEnB,CACD,CAAC,GAsBF,CAAC,CACF,CAAC"} \ No newline at end of file +{"version":3,"file":"spbc-settings_tab--settings_general.min.js","sources":["spbc-settings_tab--settings_general.js"],"sourcesContent":["jQuery(document).ready(function(){\n\t\n\t// Show/Hide access key\n\tjQuery('#showHideLink').on('click', function(){\n\t\tjQuery('#spbc_key').val(jQuery('#spbc_key').attr('key'));\n\t\tjQuery('#spbc_key+div').show();\n\t\tjQuery(this).fadeOut(300);\n\t});\n\t\n\t// Set time zone filed value if key is bad\n\tif( !+spbcSettings.key_is_ok ){\n\t\tvar d = new Date();\n\t\tjQuery('#spbc_admin_timezone').val(d.getTimezoneOffset()/60*(-1));\t\n\t}\n\t\n\t// Function for shuffle authentication unique keys and salts\n\tfunction spbcShuffleSalts() {\n\t\tvar data = {};\n\t\tvar res = {};\n\t\tdata.security = spbcSettings.ajax_nonce;\n\t\tdata.action = 'spbc_action_shuffle_salts';\n\n\t\tjQuery.ajax({\n\t\t\ttype: \"POST\",\n\t\t\tasync: false,\n\t\t\turl: spbcSettings.ajaxurl,\n\t\t\tdata: data,\n\t\t\tsuccess: function(result){\n\t\t\t\tif(result.success) {\n\t\t\t\t\tdocument.location.reload();\n\t\t\t\t} else {\n\t\t\t\t\talert(result.data);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\n\t// Event for shuffle authentication unique keys and salts\n\t// Enabling the salt update button and repeatedly pressing\n\tvar actionShuffleSaltsCountClicks = 0;\n\n\tjQuery('#action-shuffle-salts').click(function (e) {\n\t\te.preventDefault();\n\n\t\tif (jQuery(this).hasClass('disabled')) {\n\t\t\tactionShuffleSaltsCountClicks++;\n\t\t\tif (actionShuffleSaltsCountClicks === 3) {\n\t\t\t\tjQuery(this).removeClass('disabled');\n\t\t\t}\n\t\t} else {\n\t\t\tactionShuffleSaltsCountClicks = 0;\n\t\t\t\n\t\t\tif (confirm('Are you sure?')) {\n\t\t\t\tspbcShuffleSalts();\n\t\t\t}\n\t\t}\n\t});\n});"],"names":["jQuery","document","ready","d","on","val","attr","show","this","fadeOut","spbcSettings","key_is_ok","Date","getTimezoneOffset","actionShuffleSaltsCountClicks","click","e","preventDefault","hasClass","removeClass","confirm","data","security","ajax_nonce","action","ajax","type","async","url","ajaxurl","success","result","location","reload","alert"],"mappings":"AAAAA,OAAOC,QAAQ,EAAEC,MAAM,WAUtB,IACKC,EARLH,OAAO,eAAe,EAAEI,GAAG,QAAS,WACnCJ,OAAO,WAAW,EAAEK,IAAIL,OAAO,WAAW,EAAEM,KAAK,KAAK,CAAC,EACvDN,OAAO,eAAe,EAAEO,KAAK,EAC7BP,OAAOQ,IAAI,EAAEC,QAAQ,GAAG,CACzB,CAAC,EAGI,CAACC,aAAaC,YACdR,EAAI,IAAIS,KACZZ,OAAO,sBAAsB,EAAEK,IAAIF,EAAEU,kBAAkB,EAAE,GAAG,CAAE,CAAE,GA2BjE,IAAIC,EAAgC,EAEpCd,OAAO,uBAAuB,EAAEe,MAAM,SAAUC,GAC/CA,EAAEC,eAAe,EAEbjB,OAAOQ,IAAI,EAAEU,SAAS,UAAU,EAEG,IADtCJ,EAAAA,GAECd,OAAOQ,IAAI,EAAEW,YAAY,UAAU,GAGpCL,EAAgC,EAE5BM,QAAQ,eAAe,KAnCxBC,EAAO,IAENC,SAAWZ,aAAaa,WAC7BF,EAAKG,OAAS,4BAEdxB,OAAOyB,KAAK,CACXC,KAAM,OACNC,MAAO,CAAA,EACPC,IAAKlB,aAAamB,QAClBR,KAAMA,EACNS,QAAS,SAASC,GACdA,EAAOD,QACT7B,SAAS+B,SAASC,OAAO,EAEzBC,MAAMH,EAAOV,IAAI,CAEnB,CACD,CAAC,GAsBF,CAAC,CACF,CAAC"} \ No newline at end of file diff --git a/js/spbc-settings_tab--summary.min.js.map b/js/spbc-settings_tab--summary.min.js.map index 3a3c801c2..4ac7735fd 100644 --- a/js/spbc-settings_tab--summary.min.js.map +++ b/js/spbc-settings_tab--summary.min.js.map @@ -1 +1 @@ -{"version":3,"file":"spbc-settings_tab--summary.min.js","sources":["spbc-settings_tab--summary.js"],"sourcesContent":["jQuery(document).ready(function(){\r\n\tconsole.log('TAB - SUMMARY');\r\n});"],"names":["jQuery","document","ready","console","log"],"mappings":"AAAAA,OAAOC,QAAQ,EAAEC,MAAM,WACtBC,QAAQC,IAAI,eAAe,CAC5B,CAAC"} \ No newline at end of file +{"version":3,"file":"spbc-settings_tab--summary.min.js","sources":["spbc-settings_tab--summary.js"],"sourcesContent":["jQuery(document).ready(function(){\n\tconsole.log('TAB - SUMMARY');\n});"],"names":["jQuery","document","ready","console","log"],"mappings":"AAAAA,OAAOC,QAAQ,EAAEC,MAAM,WACtBC,QAAQC,IAAI,eAAe,CAC5B,CAAC"} \ No newline at end of file diff --git a/js/spbc-settings_tab--traffic_control.min.js.map b/js/spbc-settings_tab--traffic_control.min.js.map index 4c0d21d57..e1ddcfb79 100644 --- a/js/spbc-settings_tab--traffic_control.min.js.map +++ b/js/spbc-settings_tab--traffic_control.min.js.map @@ -1 +1 @@ -{"version":3,"file":"spbc-settings_tab--traffic_control.min.js","sources":["spbc-settings_tab--traffic_control.js"],"sourcesContent":["// Callback for displaying Firewall logs\r\nfunction spbc_tc__show_more__callback(result, data, params){\r\n\tif(data.full_refresh){\r\n\t\tjQuery(params.wrapper).html(result);\r\n\t\tspbc_tbl__row_actions__listen();\r\n\t\tspbc_tbl__pagination__listen();\r\n\t\tspbc_tbl__sort__listen();\r\n\t\tspbcStartShowHide();\r\n\t}else if(result.size > 0){\r\n\t\tjQuery(params.wrapper).html(result.html);\r\n\t\tspbc_tbl__row_actions__listen();\r\n\t\tspbcStartShowHide();\r\n\t}else{\r\n\t\t// Hide \"More logs\" button, show \"Control Panel\" button\r\n\t\tjQuery(params.button).hide();\r\n\t\tjQuery(params.button).siblings('.spbc__show_more_logs').css('display', 'inline-block');\r\n\t}\r\n}\r\n\r\nfunction spbc_tc__show_more__listen(){\t\r\n\tjQuery('#spbc_show_more_fw_logs_button').on('click', function(){\r\n\t\tif(spbcSettingsFWLogs.clicks < 2){\r\n\t\t\tspbcSettingsFWLogs.clicks++;\r\n\t\t\tvar data = {\r\n\t\t\t\taction: 'spbc_show_more_security_firewall_logs',\r\n\t\t\t\tamount: spbcSettingsFWLogs.amount * (+spbcSettingsFWLogs.clicks+1),\r\n\t\t\t};\t\t\t\r\n\t\t\tvar params = {\r\n\t\t\t\tbutton: this,\r\n\t\t\t\tspinner: this.nextElementSibling,\r\n\t\t\t\twrapper: jQuery('#spbc_tbl__traffic_control_logs').find('tbody'),\r\n\t\t\t\tcallback: spbc_tc__show_more__callback,\r\n\t\t\t};\r\n\t\t\tspbc_sendAJAXRequest( data, params );\r\n\t\t}else{\r\n\t\t\t// Hide \"More logs\" button, show \"Control Panel\" button\r\n\t\t\tjQuery(this).hide();\r\n\t\t\tjQuery(this).siblings('.spbc__show_more_logs').css('display', 'inline-block');\r\n\t\t}\r\n\t});\t\r\n}\r\n\r\njQuery(document).ready(function(){\r\n\t\r\n\tspbc_tbl__row_actions__listen(); // Table. Row actions handler\r\n\tspbc_tbl__pagination__listen(); // Table. Pagination handler\r\n\tspbc_tbl__sort__listen(); // Table. Sort handler\r\n\t\r\n\t// Start to hide long values in a table\r\n\tspbcStartShowHide();\r\n\t\r\n\t// FIREWALL LOGS EVENTS\r\n\t\r\n\t// Handler for show more FIREWALL LOGS\r\n\tspbc_tc__show_more__listen();\r\n\t\r\n\t// Timer for FireWall logs\r\n\tvar spbcFireWallLogsUpdateTimer = setTimeout(function spbc_heartbeat(){\t\t\r\n\t\t// Do refresh only if traffic control is enabled and tab is active\r\n\t\tif( +spbcSettingsFWLogs.moderate && jQuery('.spbc_tab_nav-traffic_control').hasClass('spbc_tab_nav--active')){\r\n\t\t\tvar data = {\r\n\t\t\t\taction: 'spbc_show_more_security_firewall_logs',\r\n\t\t\t\tfull_refresh: true,\r\n\t\t\t};\r\n\t\t\tvar params = {\r\n\t\t\t\twrapper: jQuery('#spbc_tbl__traffic_control_logs'),\r\n\t\t\t\tcallback: spbc_tc__show_more__callback,\r\n\t\t\t\tnotJson: true,\r\n\t\t\t};\r\n\t\t\tspbc_sendAJAXRequest( data, params );\r\n\t\t}\r\n\t\tsetTimeout(spbc_heartbeat, 60000);\r\n\t}, 60000);\t\r\n});\r\n\r\nfunction spbc_tc__allow_ip(ip) {\r\n\tspbc_tc__filter_ip( ip, 'allow')\r\n\treturn false;\r\n}\r\n\r\nfunction spbc_tc__ban_ip(ip) {\r\n\tspbc_tc__filter_ip( ip, 'deny')\r\n\treturn false;\r\n}\r\n\r\nfunction spbc_tc__filter_ip( ip, status) {\r\n\tconst data = {\r\n\t\taction: 'spbc_tc__filter_ip',\r\n\t\tip: ip,\r\n\t\tstatus: status\r\n\t};\r\n\tconst params = {\r\n\t\tcallback: spbc_tc__allow_ip__callback,\r\n\t};\r\n\tspbc_sendAJAXRequest( data, params );\r\n\treturn false;\r\n}\r\n\r\nfunction spbc_tc__allow_ip__callback(data) {\r\n\tif (data.success) {\r\n\t\talert('Success.');\r\n\t} else {\r\n\t\talert(data.data);\r\n\t}\r\n}"],"names":["spbc_tc__show_more__callback","result","data","params","full_refresh","jQuery","wrapper","html","spbc_tbl__row_actions__listen","spbc_tbl__pagination__listen","spbc_tbl__sort__listen","spbcStartShowHide","size","button","hide","siblings","css","spbc_tc__show_more__listen","on","spbcSettingsFWLogs","clicks","action","amount","this","spinner","nextElementSibling","find","callback","spbc_sendAJAXRequest","spbc_tc__allow_ip","ip","spbc_tc__filter_ip","spbc_tc__ban_ip","status","spbc_tc__allow_ip__callback","success","alert","document","ready","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,EAAKiC,QACRC,MAAM,UAAU,EAEhBA,MAAMlC,EAAKA,IAAI,CAEjB,CA9DAG,OAAOgC,QAAQ,EAAEC,MAAM,WAEtB9B,8BAA8B,EAC9BC,6BAA6B,EAC7BC,uBAAuB,EAGvBC,kBAAkB,EAKlBM,2BAA2B,EAGOsB,WAAW,SAASC,IAErD,IAKKrC,EALD,CAACgB,mBAAmBsB,UAAYpC,OAAO,+BAA+B,EAAEqC,SAAS,sBAAsB,IAKtGvC,EAAS,CACZG,QAASD,OAAO,iCAAiC,EACjDsB,SAAU3B,6BACV2C,QAAS,CAAA,CACV,EACAf,qBATW,CACVP,OAAQ,wCACRjB,aAAc,CAAA,CACf,EAM4BD,CAAO,GAEpCoC,WAAWC,EAAgB,GAAK,CACjC,EAAG,GAAK,CACT,CAAC"} \ No newline at end of file +{"version":3,"file":"spbc-settings_tab--traffic_control.min.js","sources":["spbc-settings_tab--traffic_control.js"],"sourcesContent":["// Callback for displaying Firewall logs\nfunction spbc_tc__show_more__callback(result, data, params){\n\tif(data.full_refresh){\n\t\tjQuery(params.wrapper).html(result);\n\t\tspbc_tbl__row_actions__listen();\n\t\tspbc_tbl__pagination__listen();\n\t\tspbc_tbl__sort__listen();\n\t\tspbcStartShowHide();\n\t}else if(result.size > 0){\n\t\tjQuery(params.wrapper).html(result.html);\n\t\tspbc_tbl__row_actions__listen();\n\t\tspbcStartShowHide();\n\t}else{\n\t\t// Hide \"More logs\" button, show \"Control Panel\" button\n\t\tjQuery(params.button).hide();\n\t\tjQuery(params.button).siblings('.spbc__show_more_logs').css('display', 'inline-block');\n\t}\n}\n\nfunction spbc_tc__show_more__listen(){\t\n\tjQuery('#spbc_show_more_fw_logs_button').on('click', function(){\n\t\tif(spbcSettingsFWLogs.clicks < 2){\n\t\t\tspbcSettingsFWLogs.clicks++;\n\t\t\tvar data = {\n\t\t\t\taction: 'spbc_show_more_security_firewall_logs',\n\t\t\t\tamount: spbcSettingsFWLogs.amount * (+spbcSettingsFWLogs.clicks+1),\n\t\t\t};\t\t\t\n\t\t\tvar params = {\n\t\t\t\tbutton: this,\n\t\t\t\tspinner: this.nextElementSibling,\n\t\t\t\twrapper: jQuery('#spbc_tbl__traffic_control_logs').find('tbody'),\n\t\t\t\tcallback: spbc_tc__show_more__callback,\n\t\t\t};\n\t\t\tspbc_sendAJAXRequest( data, params );\n\t\t}else{\n\t\t\t// Hide \"More logs\" button, show \"Control Panel\" button\n\t\t\tjQuery(this).hide();\n\t\t\tjQuery(this).siblings('.spbc__show_more_logs').css('display', 'inline-block');\n\t\t}\n\t});\t\n}\n\njQuery(document).ready(function(){\n\t\n\tspbc_tbl__row_actions__listen(); // Table. Row actions handler\n\tspbc_tbl__pagination__listen(); // Table. Pagination handler\n\tspbc_tbl__sort__listen(); // Table. Sort handler\n\t\n\t// Start to hide long values in a table\n\tspbcStartShowHide();\n\t\n\t// FIREWALL LOGS EVENTS\n\t\n\t// Handler for show more FIREWALL LOGS\n\tspbc_tc__show_more__listen();\n\t\n\t// Timer for FireWall logs\n\tvar spbcFireWallLogsUpdateTimer = setTimeout(function spbc_heartbeat(){\t\t\n\t\t// Do refresh only if traffic control is enabled and tab is active\n\t\tif( +spbcSettingsFWLogs.moderate && jQuery('.spbc_tab_nav-traffic_control').hasClass('spbc_tab_nav--active')){\n\t\t\tvar data = {\n\t\t\t\taction: 'spbc_show_more_security_firewall_logs',\n\t\t\t\tfull_refresh: true,\n\t\t\t};\n\t\t\tvar params = {\n\t\t\t\twrapper: jQuery('#spbc_tbl__traffic_control_logs'),\n\t\t\t\tcallback: spbc_tc__show_more__callback,\n\t\t\t\tnotJson: true,\n\t\t\t};\n\t\t\tspbc_sendAJAXRequest( data, params );\n\t\t}\n\t\tsetTimeout(spbc_heartbeat, 60000);\n\t}, 60000);\t\n});\n\nfunction spbc_tc__allow_ip(ip) {\n\tspbc_tc__filter_ip( ip, 'allow')\n\treturn false;\n}\n\nfunction spbc_tc__ban_ip(ip) {\n\tspbc_tc__filter_ip( ip, 'deny')\n\treturn false;\n}\n\nfunction spbc_tc__filter_ip( ip, status) {\n\tconst data = {\n\t\taction: 'spbc_tc__filter_ip',\n\t\tip: ip,\n\t\tstatus: status\n\t};\n\tconst params = {\n\t\tcallback: spbc_tc__allow_ip__callback,\n\t};\n\tspbc_sendAJAXRequest( data, params );\n\treturn false;\n}\n\nfunction spbc_tc__allow_ip__callback(data) {\n\tif (data.success) {\n\t\talert('Success.');\n\t} else {\n\t\talert(data.data);\n\t}\n}"],"names":["spbc_tc__show_more__callback","result","data","params","full_refresh","jQuery","wrapper","html","spbc_tbl__row_actions__listen","spbc_tbl__pagination__listen","spbc_tbl__sort__listen","spbcStartShowHide","size","button","hide","siblings","css","spbc_tc__show_more__listen","on","spbcSettingsFWLogs","clicks","action","amount","this","spinner","nextElementSibling","find","callback","spbc_sendAJAXRequest","spbc_tc__allow_ip","ip","spbc_tc__filter_ip","spbc_tc__ban_ip","status","spbc_tc__allow_ip__callback","success","alert","document","ready","setTimeout","spbc_heartbeat","moderate","hasClass","notJson"],"mappings":"AACA,SAASA,6BAA6BC,EAAQC,EAAMC,GAChDD,EAAKE,cACPC,OAAOF,EAAOG,OAAO,EAAEC,KAAKN,CAAM,EAClCO,8BAA8B,EAC9BC,6BAA6B,EAC7BC,uBAAuB,EACvBC,kBAAkB,GACI,EAAdV,EAAOW,MACfP,OAAOF,EAAOG,OAAO,EAAEC,KAAKN,EAAOM,IAAI,EACvCC,8BAA8B,EAC9BG,kBAAkB,IAGlBN,OAAOF,EAAOU,MAAM,EAAEC,KAAK,EAC3BT,OAAOF,EAAOU,MAAM,EAAEE,SAAS,uBAAuB,EAAEC,IAAI,UAAW,cAAc,EAEvF,CAEA,SAASC,6BACRZ,OAAO,gCAAgC,EAAEa,GAAG,QAAS,WACpD,IAEKhB,EAIAC,EANFgB,mBAAmBC,OAAS,GAC9BD,mBAAmBC,MAAM,GACrBlB,EAAO,CACVmB,OAAQ,wCACRC,OAAQH,mBAAmBG,QAAU,CAACH,mBAAmBC,OAAO,EACjE,EACIjB,EAAS,CACZU,OAAQU,KACRC,QAASD,KAAKE,mBACdnB,QAASD,OAAO,iCAAiC,EAAEqB,KAAK,OAAO,EAC/DC,SAAU3B,4BACX,EACA4B,qBAAsB1B,EAAMC,CAAO,IAGnCE,OAAOkB,IAAI,EAAET,KAAK,EAClBT,OAAOkB,IAAI,EAAER,SAAS,uBAAuB,EAAEC,IAAI,UAAW,cAAc,EAE9E,CAAC,CACF,CAmCA,SAASa,kBAAkBC,GAE1B,OADAC,mBAAoBD,EAAI,OAAO,EACxB,CAAA,CACR,CAEA,SAASE,gBAAgBF,GAExB,OADAC,mBAAoBD,EAAI,MAAM,EACvB,CAAA,CACR,CAEA,SAASC,mBAAoBD,EAAIG,GAUhC,OADAL,qBARa,CACZP,OAAQ,qBACRS,GAAIA,EACJG,OAAQA,CACT,EACe,CACdN,SAAUO,2BACX,CACmC,EAC5B,CAAA,CACR,CAEA,SAASA,4BAA4BhC,GAChCA,EAAKiC,QACRC,MAAM,UAAU,EAEhBA,MAAMlC,EAAKA,IAAI,CAEjB,CA9DAG,OAAOgC,QAAQ,EAAEC,MAAM,WAEtB9B,8BAA8B,EAC9BC,6BAA6B,EAC7BC,uBAAuB,EAGvBC,kBAAkB,EAKlBM,2BAA2B,EAGOsB,WAAW,SAASC,IAErD,IAKKrC,EALD,CAACgB,mBAAmBsB,UAAYpC,OAAO,+BAA+B,EAAEqC,SAAS,sBAAsB,IAKtGvC,EAAS,CACZG,QAASD,OAAO,iCAAiC,EACjDsB,SAAU3B,6BACV2C,QAAS,CAAA,CACV,EACAf,qBATW,CACVP,OAAQ,wCACRjB,aAAc,CAAA,CACf,EAM4BD,CAAO,GAEpCoC,WAAWC,EAAgB,GAAK,CACjC,EAAG,GAAK,CACT,CAAC"} \ No newline at end of file diff --git a/js/spbc-table.min.js b/js/spbc-table.min.js index 5c86482c9..411644dc9 100644 --- a/js/spbc-table.min.js +++ b/js/spbc-table.min.js @@ -1,2 +1,2 @@ -function spbc_reload_accordion(){spbc_sendAJAXRequest({action:"spbc_scanner_tab__reload_accordion"},{notJson:!0,callback:function(t,e,a,n){jQuery(n).accordion("destroy"),jQuery(n).html(t),jQuery(n).accordion({header:"h3",heightStyle:"content",collapsible:!0,active:!1}),spbc_tbl__bulk_actions__listen(),spbc_tbl__row_actions__listen(),spbc_tbl__pagination__listen(),spbc_tbl__sort__listen(),spbcStartShowHide()}},jQuery("#spbc_scan_accordion"))}function spbc_tbl__bulk_actions__listen(){jQuery(".tbl-bulk_actions-all--apply").off("click").on("click",function(){if(spbc_scanner.active)alert(spbcTableLocalize.scannerIsActive);else{var t=jQuery(this),a=t.siblings("select").children()[t.siblings("select").first()[0].selectedIndex].value;if(-1!==["approve","disapprove","send","check_analysis_status","approve_page","disapprove_page","cure","delete_from_analysis_log"].indexOf(a)){if(confirm(spbcTable.warning_bulk)){var e={action:"spbc_tbl-action--bulk",add_action:a,status:t.parents(".tbl-root").attr("type")};if("cure"===a){var n=t.closest("#spbc_tbl__scanner_cure_log").find(".cb-select");let a=[];n.each(function(t,e){e=jQuery(e).val();a.push(e)}),e.selectedIds=a}if("delete_from_analysis_log"===a){n=t.closest("#spbc_tbl__scanner_analysis_log").find(".cb-select");let a=[];n.each(function(t,e){e=jQuery(e).val();a.push(e)}),e.file_ids=a}n={button:this,spinner:t.children(".tbl-preloader--small"),callback:function(t){var e;spbc_reload_accordion(),"check_analysis_status"===a&&(e="

    Analysis status updated. Total: "+t.counters.total+", updated: "+t.counters.updated+", skipped: "+t.counters.skipped+", failed: "+t.counters.failed+", queued: "+t.counters.queued+"

    ",spbcModal.open().put(e)),"send"===a&&(e="

    Files have been sent: "+t.files_sent_counter+"

    ",spbcModal.open().put(e))},errorOutput:function(t,e){e&&(t=t+"
    Additional information:
    "+e),spbcModal.open().putError(t)},timeout:6e4};spbc_sendAJAXRequest(e,n)}}else alert("This action is not supported for all files yet =(")}}),jQuery(".tbl-bulk_actions--apply").off("click").on("click",function(t){if(spbc_bulk_action||confirm(spbcTable.warning_bulk)){var a=spbc_bulk_action||jQuery(this),n=(spbc_bulk_action=a).siblings("select").children()[a.siblings("select").first()[0].selectedIndex].value;if("cure"===n)spbc_scanner__cure_selected(jQuery(this));else if("delete_from_analysis_log"===n)spbc_scanner_analysis_log_delete_from_log(jQuery(this));else if("allow"===n||"ban"===n){let e="ban"===n?"deny":n;var s=a.parents(".tbl-root").find(".cb-select:checked"),s=(s&&(a.children(".tbl-preloader--small").show(),s.each(function(){var t=jQuery(this).parents("tr").find(".tbl-row_action--"+n).data("ip");spbc_sec_logs__filter_ip(t,e,!0),jQuery(this).prop("checked",!1)})),a.children(".tbl-preloader--small").hide(),"allow"===n?"Allowed":"Banned"),s="

    Success. Selected IPs have been "+s+". Changes will be applied within 10 minutes.

    ";spbcModal.open().put(s),void setTimeout(spbc_reload_accordion,1900)}else"-1"!==n&&a.parents(".tbl-root").find(".cb-select").is(":checked")?(a.children(".tbl-preloader--small").show(),a.parents(".tbl-root").find(".cb-select:checked").first().parents("tr").find(".tbl-row_action--"+n)[0]?(a.parents(".tbl-root").find(".cb-select:checked").first().parents("tr").find(".tbl-row_action--"+n).click(),a.parents(".tbl-root").find(".cb-select:checked").first().prop("checked",!1)):(a.parents(".tbl-root").find(".cb-select:checked").first().prop("checked",!1),a.click())):(a.children(".tbl-preloader--small").hide(),spbc_bulk_action=null,"check_analysis_status"===n&&spbcModal.open().put("

    All available files are updated.

    "),"send"===n&&spbcModal.open().put("

    All available files are sent.

    "),setTimeout(spbc_reload_accordion,1900))}})}function spbc_scanner__cure_selected(e){var t=e.closest("#spbc_tbl__scanner_cure_log").find(".cb-select:checked");let a=[];0===t.length&&alert("Please, select elements."),t.each(function(t,e){e=jQuery(e).val();a.push(e)});t={action:"spbc_cure_selected",security:spbcSettings.ajax_nonce,selectedIds:a};jQuery.ajax({type:"POST",url:spbcSettings.ajaxurl,data:t,beforeSend:function(){e.closest("#spbc_tbl__scanner_cure_log").find(".tbl-button---white_blue .tbl-preloader--in_button").show()},success:function(t){e.closest("#spbc_tbl__scanner_cure_log").find(".tbl-button---white_blue .tbl-preloader--in_button").hide(),t.success?(spbcModal.open().put(t.data),document.addEventListener("spbcModalClosed",function(t){document.location.reload()})):spbcModal.open().putError(t.data)}})}function spbc_tbl__row_actions__listen(){jQuery(".tbl-row_action--ajax").off("click").on("click",function(){var t,e,a,n;console.log("spbc_tbl__row_actions__listen click"),spbc_scanner.active?alert(spbcTableLocalize.scannerIsActive):(e={action:"spbc_tbl-action--row",add_action:(t=jQuery(this)).attr("row-action"),id:t.parents(".row-actions").attr("uid"),cols:t.parents(".row-actions").attr("cols_amount"),page_url:t.parent().attr("uid"),page_id:t.parent().attr("page_id")},a={callback:spbc_tbl__row_actions__callback,errorOutput:function(t){spbcModal.open().putError(t)},spinner:t.parent().siblings(".tbl-preloader--tiny")},!spbc_bulk_action&&(n=spbcTable["warning_"+t.attr("row-action")]||spbcTable.warning_default,"copy_file_info"===e.add_action||"check_analysis_status"===e.add_action||confirm(n))&&spbc_sendAJAXRequest(e,a,t.parents("tr")),spbc_bulk_action&&spbc_sendAJAXRequest(e,a,t.parents("tr")))})}function spbc_tbl__row_actions__callback(t,e,a,n){if(t.color&&n.css({background:t.background,color:t.color}),t.html&&(n.parent().parent().parent().prepend(t.html),setTimeout(function(){n.fadeOut(300)},1500),spbc_bulk_action||setTimeout(spbc_reload_accordion,1900)),"copy_file_info"===e.add_action&&(!0===t.success&&t.data.file_info?window.prompt("Copy the file info below and send it to support@cleantalk.org: ",t.data.file_info):(c=void 0!==t.data.error?t.data.error:"Unknown copy_file_info error",spbcModal.open().putError(c))),t.temp_html){var s=n.html();if(n.html(t.temp_html),void 0!==t.updated_template){var c=t.updated_template_type,t=t.updated_template,l=jQuery(t).find(".wp-list-table tbody tr").length,i=jQuery('[aria-controls="spbc_scan_accordion_tab_'+c+'"]');if(0a&&jQuery(e).css("outline","1px solid green")}),i.click()}else"analysis_log"===c&&(o='",c='