Skip to content

Commit

Permalink
merge dev to master
Browse files Browse the repository at this point in the history
  • Loading branch information
svfcode committed Aug 15, 2023
1 parent 4cf11a1 commit 94e4158
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 17 deletions.
28 changes: 27 additions & 1 deletion inc/spbc-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ function spbc_admin_init()
add_action('wp_ajax_spbc_private_list_add', 'spbc_private_list_add');

// Settings Templates
if ($spbc->is_mainsite || $spbc->ms__work_mode != 2) {
if (
! $spbc->data['wl_mode_enabled'] &&
$spbc->is_mainsite ||
$spbc->ms__work_mode != 2
) {
new CleantalkSettingsTemplates($spbc->api_key);
}

Expand Down Expand Up @@ -212,6 +216,10 @@ function changedPluginName(){
});
</script>";

if (!empty($spbc->data['wl_support_faq'])) {
$meta[] = '<a href="' . esc_url($spbc->data['wl_support_faq']) . '" class="spbc_meta_links spbc_faq_links">' . __('FAQ') . '</a>';
}

return $meta;
}

Expand Down Expand Up @@ -958,3 +966,21 @@ function spbc_set_malware_scan_warns()
);
$spbc->save('data');
}

/**
* Change the plugin description on all plugins page.
* @param $all_plugins
* @return array
*/
function spbc_admin__change_plugin_description($all_plugins)
{
global $spbc;
if (
$spbc->data["wl_mode_enabled"] &&
isset($all_plugins['security-malware-firewall/security-malware-firewall.php']) &&
$spbc->data["wl_plugin_description"]
) {
$all_plugins['security-malware-firewall/security-malware-firewall.php']['Description'] = $spbc->data["wl_plugin_description"];
}
return $all_plugins;
}
8 changes: 7 additions & 1 deletion inc/spbc-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,13 @@ function spbc_settings__error__output()
foreach ($errors_out as $value) {
echo '<h4>' . spbc_render_links_to_tag($value) . '</h4>';
}
echo '<h4 style="text-align: right;">' . sprintf(__('You can get support any time here: %s.', 'security-malware-firewall'), '<a target="blank" href="https://wordpress.org/support/plugin/security-malware-firewall">https://wordpress.org/support/plugin/security-malware-firewall</a>') . '</h4>';

$link_to_support = 'https://wordpress.org/support/plugin/security-malware-firewall';
if (!empty($spbc->data['wl_support_url'])) {
$link_to_support = esc_url($spbc->data['wl_support_url']);
}

echo '<h4 style="text-align: right;">' . sprintf(__('You can get support any time here: %s.', 'security-malware-firewall'), '<a target="blank" href="' . $link_to_support . '">' . $link_to_support . '</a>') . '</h4>';
echo '</div>';
}
}
Expand Down
5 changes: 1 addition & 4 deletions lib/CleantalkSP/SpbctWP/Firewall/FW.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,7 @@ public static function sendLog($db, $log_table, $ct_key)
//Checking answer and deleting all lines from the table
if ( empty($result['error']) ) {
if ( (int)$result['rows'] === count($data) ) {
$db->execute("DELETE FROM " . $log_table . " WHERE entry_id NOT IN (" .
"SELECT entry_id FROM (" .
"SELECT entry_id, entry_timestamp FROM " . $log_table . " ORDER BY entry_timestamp DESC LIMIT 20) too );");

$db->execute("TRUNCATE TABLE " . $log_table . ";");
return count($data);
}

Expand Down
1 change: 1 addition & 0 deletions lib/CleantalkSP/SpbctWP/Firewall/FirewallModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public function _die(Result $result) // phpcs:ignore PSR2.Methods.MethodDeclarat
. date("D, d M Y H:i:s")
. '</h2>',
'{BRANDNAME}' => $spbc->data["wl_brandname"],
'{CLEANTALK_URL}' => esc_url($spbc->data['wl_url']),
);

foreach ( $replaces as $place_holder => $replace ) {
Expand Down
2 changes: 1 addition & 1 deletion lib/CleantalkSP/SpbctWP/Firewall/die_page_bfp.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ <h2 class="second false_positive_warning" style="display: none;">{FALSE_POSITIVE
<p style="margin: 0; display: inline-block; font-size: 10px; color: gray;">{HOST}</p>
</div>
<div class="footer">
<a href="https://cleantalk.org" target="_blank">{BRANDNAME}</a>
<a href="{CLEANTALK_URL}" target="_blank">{BRANDNAME}</a>
</div>
<script>
var generated = {GENERATED_TIMESTAMP},
Expand Down
2 changes: 1 addition & 1 deletion lib/CleantalkSP/SpbctWP/Firewall/die_page_fw.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ <h2 class="second false_positive_warning" style="display: none;">{FALSE_POSITIVE
<p style="margin: 0; display: inline-block; font-size: 10px; color: gray;">{HOST}</p>
</div>
<div class="footer">
<a href="https://cleantalk.org" target="_blank">{BRANDNAME}</a>
<a href="{CLEANTALK_URL}" target="_blank">{BRANDNAME}</a>
</div>
<script>
var generated = {GENERATED_TIMESTAMP},
Expand Down
2 changes: 1 addition & 1 deletion lib/CleantalkSP/SpbctWP/Firewall/die_page_tc.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ <h2 class="second false_positive_warning" style="display: none;">{FALSE_POSITIVE
<p style="margin: 0; display: inline-block; font-size: 10px; color: gray;">{HOST}</p>
</div>
<div class="footer">
<a href="https://cleantalk.org" target="_blank">{BRANDNAME}</a>
<a href="{CLEANTALK_URL}" target="_blank">{BRANDNAME}</a>
</div>
<script>
var generated = {GENERATED_TIMESTAMP},
Expand Down
2 changes: 1 addition & 1 deletion lib/CleantalkSP/SpbctWP/Firewall/die_page_waf.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ <h2 class="second false_positive_warning" style="display: none;">{FALSE_POSITIVE
<p style="margin: 0; display: inline-block; font-size: 10px; color: gray;">{HOST}</p>
</div>
<div class="footer">
<a href="https://cleantalk.org" target="_blank">{BRANDNAME}</a>
<a href="{CLEANTALK_URL}" target="_blank">{BRANDNAME}</a>
</div>
<script>
var generated = {GENERATED_TIMESTAMP},
Expand Down
10 changes: 9 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: security, firewall, malware, wordpress security, brute force
Requires at least: 3.0
Tested up to: 6.3
Requires PHP: 5.6
Stable tag: 2.115
Stable tag: 2.116
License: GPLv2
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -301,6 +301,14 @@ This is required for the Security FireWall to function properly. Plugins that ar

== Changelog ==

= 2.116 Aug 14 2023 =
* New: WL. Added constants for custom description and FAQ link.
* Fix: FW. Delete all lines after send fw logs.
* Fix: WL. Support link in errors.
* Fix: WL. Email 2FA fixed.
* Fix: WL. Fixed block pages.
* Fix: WL. There is no Templates if WL is active.

= 2.115 July 31 2023 =
* New: Firewall. Protect login from brute force even if expired key.
* New: Scanner. Added extensions to find malware.
Expand Down
35 changes: 29 additions & 6 deletions security-malware-firewall.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.115
Version: 2.116
Author URI: https://cleantalk.org
Text Domain: security-malware-firewall
Domain Path: /i18n
Expand Down Expand Up @@ -331,6 +331,7 @@ function spbc_change_author_name($link, $_author_id, $_author_nicename)
if ( ( isset($pagenow) && $pagenow === 'plugins.php' ) || ( isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], 'plugins.php') !== false ) ) {
add_filter('plugin_action_links_' . SPBC_PLUGIN_BASE_NAME, 'spbc_plugin_action_links', 10, 2);
add_filter('network_admin_plugin_action_links_' . SPBC_PLUGIN_BASE_NAME, 'spbc_plugin_action_links', 10, 2);
add_filter('all_plugins', 'spbc_admin__change_plugin_description');
add_filter('plugin_row_meta', 'spbc_plugin_links_meta', 10, 2);
}

Expand Down Expand Up @@ -1149,16 +1150,19 @@ function spbc_2fa__send_mail($user)
$key = spbc_2fa__key_generate_and_store($user);
}

$brand_name = $spbc->data['wl_brandname'];
$support_link = $spbc->data['wl_support_url'];

wp_mail(
$user->user_email,
// Subject
sprintf(
__('CleanTalk\'s Security "%s"', 'security-malware-firewall'),
__(esc_html__($brand_name) . '\'s Security "%s"', 'security-malware-firewall'),
parse_url(get_option('home'), PHP_URL_HOST)
),
// Message
sprintf(
__('Two factor authentication code for user "%s" on "%s" website is %d' . PHP_EOL . 'Lifetime of the code 5 minutes.' . PHP_EOL . PHP_EOL . 'CleanTalk\'s Security: https://wordpress.org/support/plugin/security-malware-firewall', 'security-malware-firewall'),
__('Two factor authentication code for user "%s" on "%s" website is %d' . PHP_EOL . 'Lifetime of the code 5 minutes.' . PHP_EOL . PHP_EOL . esc_html__($brand_name) . '\'s Security: ' . esc_url($support_link), 'security-malware-firewall'),
$user->user_login,
parse_url(get_option('home'), PHP_URL_HOST),
$key
Expand Down Expand Up @@ -2772,6 +2776,16 @@ function spbc_check_account_status($api_key)
? 1
: 0;

//todo:temporary solution for description, until we found the way to transfer this from cloud
if (defined('SPBC_WHITELABEL_PLUGIN_DESCRIPTION')) {
$result['wl_plugin_description'] = SPBC_WHITELABEL_PLUGIN_DESCRIPTION;
}

//todo:temporary solution for FAQ
if (defined('SPBC_WHITELABEL_FAQ_LINK')) {
$result['wl_faq_url'] = SPBC_WHITELABEL_FAQ_LINK;
}

if ( $spbc->is_network && $spbc->is_mainsite && $spbc->ms__work_mode == 1 ) {
$spbc->data['services_count '] = isset($result['services_count']) ? $result['services_count'] : '';
$spbc->data['services_max'] = isset($result['services_max']) ? $result['services_max'] : '';
Expand All @@ -2786,15 +2800,24 @@ function spbc_check_account_status($api_key)
$spbc->data['wl_url'] = isset($result['wl_url'])
? Sanitize::cleanUrl($result['wl_url'])
: $spbc->default_data['wl_url'];
$spbc->data['wl_support_faq'] = isset($result['wl_support_url'])
? Sanitize::cleanUrl($result['wl_support_url'])
: $spbc->default_data['wl_support_url'];

if (isset($result['wl_faq_url'])) {
$spbc->data['wl_support_faq'] = Sanitize::cleanUrl($result['wl_faq_url']);
} elseif (isset($result['wl_support_url'])) {
$spbc->data['wl_support_faq'] = Sanitize::cleanUrl($result['wl_support_url']);
} else {
$spbc->data['wl_support_faq'] = $spbc->default_data['wl_support_url'];
}

$spbc->data['wl_support_url'] = isset($result['wl_support_url'])
? Sanitize::cleanUrl($result['wl_support_url'])
: $spbc->default_data['wl_support_url'];
$spbc->data['wl_support_email'] = isset($result['wl_support_email'])
? Sanitize::cleanEmail($result['wl_support_email'])
: $spbc->default_data['wl_support_email'];
$spbc->data['wl_plugin_description'] = isset($result['wl_plugin_description'])
? Sanitize::cleanTextField($result['wl_plugin_description'])
: get_plugin_data('security-malware-firewall/security-malware-firewall.php')['Description'];
} else {
$spbc->data['wl_mode_enabled'] = false;
$spbc->data['wl_brandname'] = $spbc->default_data['wl_brandname'];
Expand Down

0 comments on commit 94e4158

Please sign in to comment.