|
4 | 4 | Plugin Name: Anti-Spam by CleanTalk |
5 | 5 | Plugin URI: https://cleantalk.org |
6 | 6 | Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms. |
7 | | - Version: 6.72 |
| 7 | + Version: 6.73 |
8 | 8 | Author: CleanTalk - Anti-Spam Protection <welcome@cleantalk.org> |
9 | 9 | Author URI: https://cleantalk.org |
10 | 10 | Text Domain: cleantalk-spam-protect |
@@ -1519,92 +1519,13 @@ function apbct_sfw_update__get_multifiles_of_type(array $params) |
1519 | 1519 |
|
1520 | 1520 | /** |
1521 | 1521 | * Queue stage. Do load multifiles with networks on their urls. |
1522 | | - * @param $urls |
1523 | | - * @return array|array[]|bool|string|string[] |
| 1522 | + * @param $all_urls |
| 1523 | + * @return array|true |
1524 | 1524 | */ |
1525 | | -function apbct_sfw_update__download_files($urls, $direct_update = false) |
| 1525 | +function apbct_sfw_update__download_files($all_urls, $direct_update = false) |
1526 | 1526 | { |
1527 | | - global $apbct; |
1528 | | - |
1529 | | - sleep(3); |
1530 | | - |
1531 | | - if ( ! is_writable($apbct->fw_stats['updating_folder']) ) { |
1532 | | - return array('error' => 'SFW update folder is not writable.'); |
1533 | | - } |
1534 | | - |
1535 | | - //Reset keys |
1536 | | - $urls = array_values(array_unique($urls)); |
1537 | | - |
1538 | | - $results = array(); |
1539 | | - $batch_size = 10; |
1540 | | - |
1541 | | - /** |
1542 | | - * Reduce batch size of curl multi instanced |
1543 | | - */ |
1544 | | - if (defined('APBCT_SERVICE__SFW_UPDATE_CURL_MULTI_BATCH_SIZE')) { |
1545 | | - if ( |
1546 | | - is_int(APBCT_SERVICE__SFW_UPDATE_CURL_MULTI_BATCH_SIZE) && |
1547 | | - APBCT_SERVICE__SFW_UPDATE_CURL_MULTI_BATCH_SIZE > 0 && |
1548 | | - APBCT_SERVICE__SFW_UPDATE_CURL_MULTI_BATCH_SIZE < 10 |
1549 | | - ) { |
1550 | | - $batch_size = APBCT_SERVICE__SFW_UPDATE_CURL_MULTI_BATCH_SIZE; |
1551 | | - }; |
1552 | | - } |
1553 | | - |
1554 | | - $total_urls = count($urls); |
1555 | | - $batches = ceil($total_urls / $batch_size); |
1556 | | - |
1557 | | - for ($i = 0; $i < $batches; $i++) { |
1558 | | - $batch_urls = array_slice($urls, $i * $batch_size, $batch_size); |
1559 | | - if (!empty($batch_urls)) { |
1560 | | - $http_results = Helper::httpMultiRequest($batch_urls, $apbct->fw_stats['updating_folder']); |
1561 | | - if (is_array($http_results)) { |
1562 | | - $results = array_merge($results, $http_results); |
1563 | | - } |
1564 | | - // to handle case if we request only one url, then Helper::httpMultiRequest returns string 'success' instead of array |
1565 | | - if (count($batch_urls) === 1 && $http_results === 'success') { |
1566 | | - $results = array_merge($results, $batch_urls); |
1567 | | - } |
1568 | | - } |
1569 | | - } |
1570 | | - |
1571 | | - $results = TT::toArray($results); |
1572 | | - $count_urls = count($urls); |
1573 | | - $count_results = count($results); |
1574 | | - |
1575 | | - if ( empty($results['error']) && ($count_urls === $count_results) ) { |
1576 | | - if ( $direct_update ) { |
1577 | | - return true; |
1578 | | - } |
1579 | | - $download_again = array(); |
1580 | | - $results = array_values($results); |
1581 | | - for ( $i = 0; $i < $count_results; $i++ ) { |
1582 | | - if ( $results[$i] === 'error' ) { |
1583 | | - $download_again[] = $urls[$i]; |
1584 | | - } |
1585 | | - } |
1586 | | - |
1587 | | - if ( count($download_again) !== 0 ) { |
1588 | | - return array( |
1589 | | - 'error' => 'Files download not completed.', |
1590 | | - 'update_args' => array( |
1591 | | - 'args' => $download_again |
1592 | | - ) |
1593 | | - ); |
1594 | | - } |
1595 | | - |
1596 | | - return array( |
1597 | | - 'next_stage' => array( |
1598 | | - 'name' => 'apbct_sfw_update__create_tables' |
1599 | | - ) |
1600 | | - ); |
1601 | | - } |
1602 | | - |
1603 | | - if ( ! empty($results['error']) ) { |
1604 | | - return $results; |
1605 | | - } |
1606 | | - |
1607 | | - return array('error' => 'Files download not completed.'); |
| 1527 | + $downloader = new \Cleantalk\ApbctWP\Firewall\SFWFilesDownloader(); |
| 1528 | + return $downloader->downloadFiles($all_urls, $direct_update); |
1608 | 1529 | } |
1609 | 1530 |
|
1610 | 1531 | /** |
@@ -2175,6 +2096,11 @@ function apbct_rc__install_plugin($_wp = null, $plugin = null) |
2175 | 2096 | $plugin = Get::get('plugin') ? Get::get('plugin') : ''; |
2176 | 2097 | } |
2177 | 2098 |
|
| 2099 | + $allowed_plugin = 'security-malware-firewall/security-malware-firewall.php'; |
| 2100 | + if ( !empty($plugin) && TT::toString($plugin) !== $allowed_plugin ) { |
| 2101 | + die('FAIL ' . json_encode(array('error' => 'PLUGIN_NOT_ALLOWED'))); |
| 2102 | + } |
| 2103 | + |
2178 | 2104 | if ( !empty($plugin) ) { |
2179 | 2105 | $plugin = TT::toString($plugin); |
2180 | 2106 | if ( preg_match('/[a-zA-Z-\d]+[\/\\][a-zA-Z-\d]+\.php/', $plugin) ) { |
@@ -2238,6 +2164,12 @@ function apbct_rc__activate_plugin($plugin) |
2238 | 2164 | $plugin = Get::get('plugin') ? TT::toString(Get::get('plugin')) : null; |
2239 | 2165 | } |
2240 | 2166 |
|
| 2167 | + // Only allow activation of Security by CleanTalk plugin via remote call |
| 2168 | + $allowed_plugin = 'security-malware-firewall/security-malware-firewall.php'; |
| 2169 | + if ( $plugin && $plugin !== $allowed_plugin ) { |
| 2170 | + return array('error' => 'PLUGIN_NOT_ALLOWED'); |
| 2171 | + } |
| 2172 | + |
2241 | 2173 | if ( $plugin ) { |
2242 | 2174 | if ( preg_match('@[a-zA-Z-\d]+[\\\/][a-zA-Z-\d]+\.php@', $plugin) ) { |
2243 | 2175 | require_once(ABSPATH . '/wp-admin/includes/plugin.php'); |
@@ -2278,6 +2210,15 @@ function apbct_rc__deactivate_plugin($plugin = null) |
2278 | 2210 | $plugin = Get::get('plugin') ? TT::toString(Get::get('plugin')) : null; |
2279 | 2211 | } |
2280 | 2212 |
|
| 2213 | + // Only allow deactivation of CleanTalk plugins via remote call |
| 2214 | + $allowed_plugins = array( |
| 2215 | + 'cleantalk-spam-protect/cleantalk.php', |
| 2216 | + 'security-malware-firewall/security-malware-firewall.php', |
| 2217 | + ); |
| 2218 | + if ( $plugin && !in_array($plugin, $allowed_plugins, true) ) { |
| 2219 | + die('FAIL ' . json_encode(array('error' => 'PLUGIN_NOT_ALLOWED'))); |
| 2220 | + } |
| 2221 | + |
2281 | 2222 | if ( $plugin ) { |
2282 | 2223 | // Switching complete deactivation for security |
2283 | 2224 | if ( $plugin === 'security-malware-firewall/security-malware-firewall.php' && ! empty(Get::get('misc__complete_deactivation')) ) { |
@@ -2324,6 +2265,15 @@ function apbct_rc__uninstall_plugin($plugin = null) |
2324 | 2265 | $plugin = Get::get('plugin') ? TT::toString(Get::get('plugin')) : null; |
2325 | 2266 | } |
2326 | 2267 |
|
| 2268 | + // Only allow uninstallation of CleanTalk plugins via remote call |
| 2269 | + $allowed_plugins = array( |
| 2270 | + 'cleantalk-spam-protect/cleantalk.php', |
| 2271 | + 'security-malware-firewall/security-malware-firewall.php', |
| 2272 | + ); |
| 2273 | + if ( $plugin && !in_array($plugin, $allowed_plugins, true) ) { |
| 2274 | + die('FAIL ' . json_encode(array('error' => 'PLUGIN_NOT_ALLOWED'))); |
| 2275 | + } |
| 2276 | + |
2327 | 2277 | if ( $plugin ) { |
2328 | 2278 | // Switching complete deactivation for security |
2329 | 2279 | if ( $plugin === 'security-malware-firewall/security-malware-firewall.php' && ! empty(Get::get('misc__complete_deactivation')) ) { |
|
0 commit comments