Skip to content

Commit

Permalink
Merge branch 'dev' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
svfcode committed Jul 17, 2023
1 parent 7b48d57 commit 7eb4ef3
Show file tree
Hide file tree
Showing 36 changed files with 611 additions and 228 deletions.
2 changes: 1 addition & 1 deletion css/spbc-admin.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions css/src/spbc-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ span.green_dot{
#spbct-upload-checker-details {
overflow-y: scroll;
height: 150px;
border: solid #CCC 1px;
}
#spbct-upload-checker-details li:nth-child(2n+1) {
background: #d3d3d3;
}
background: #CCC;
}
12 changes: 7 additions & 5 deletions inc/admin-bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,13 @@ function spbc_admin__admin_bar__add_child_nodes($wp_admin_bar)
: '';

// FireWall
$wp_admin_bar->add_node(array(
'parent' => 'spbc__parent_node',
'id' => 'spbc_admin_bar__traffic_control_link',
'title' => '<a href="' . $spbc->settings_link . '&spbc_tab=traffic_control">' . __('FireWall', 'security-malware-firewall') . '</a>',
));
if ( (int) $spbc->settings['secfw__enabled'] ) {
$wp_admin_bar->add_node(array(
'parent' => 'spbc__parent_node',
'id' => 'spbc_admin_bar__traffic_control_link',
'title' => '<a href="' . $spbc->settings_link . '&spbc_tab=traffic_control">' . __('FireWall', 'security-malware-firewall') . '</a>',
));
}

$wp_admin_bar->add_node(array(
'parent' => 'spbc__parent_node',
Expand Down
2 changes: 2 additions & 0 deletions inc/spbc-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ function spbc_admin_init()

// Misc
add_action('wp_ajax_spbc_settings__get_description', 'spbc_settings__get_description');
add_action('wp_ajax_spbc_settings__get_recommendation', 'spbc_settings__get_recommendation');
add_action('wp_ajax_spbc_settings__check_renew_banner', 'spbc_settings__check_renew_banner');
add_action('wp_ajax_spbc_sync', 'spbc_sync');
add_action('wp_ajax_spbc_get_key_auto', 'spbc_get_key_auto');
Expand Down Expand Up @@ -250,6 +251,7 @@ function spbc_enqueue_scripts($hook)
'is_main_site' => (int) is_main_site(),
'img_path' => SPBC_PATH . '/images',
'key_is_ok' => $spbc->key_is_ok,
'secfw_enabled' => $spbc->settings['secfw__enabled'],
'ajax_nonce' => wp_create_nonce("spbc_secret_nonce"),
'ajaxurl' => admin_url('admin-ajax.php', 'relative'),
//'debug' => !empty($debug) ? 1 : 0,
Expand Down
47 changes: 27 additions & 20 deletions inc/spbc-scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ function spbc_scanner_count_files($direct_call = false, $path = ABSPATH)
'dir_exceptions' => array(SPBC_PLUGIN_DIR . 'quarantine')
);
if ( ! empty($spbc->settings['scanner__dir_exclusions'])) {
$init_params['dir_exceptions'] = array_merge($init_params['dir_exceptions'], explode("\n", $spbc->settings['scanner__dir_exclusions']));
$excluded_dirs = spbc__get_exists_directories(explode("\n", $spbc->settings['scanner__dir_exclusions']));
$init_params['dir_exceptions'] = array_merge($init_params['dir_exceptions'], $excluded_dirs);
}

$scaner = new Scanner\Surface($path_to_scan, $root_path, $init_params);
Expand Down Expand Up @@ -437,19 +438,13 @@ function spbc_scanner_file_delete($direct_call = false, $file_id = null)
$remembered_file_content = file_get_contents($file_path);
$result = unlink($file_path);
if ($result) {
$response_content = HTTP::getContentFromURL(get_option('home'));
$response_content_admin = HTTP::getContentFromURL(get_option('home') . '/wp-admin/');
$response_code = HTTP::getResponseCode(get_option('home'));
$response_code_admin = HTTP::getResponseCode(get_option('home') . '/wp-admin/');
$response_content = HTTP::getContentFromURL(get_option('home'), false);
$response_content_admin = HTTP::getContentFromURL(get_option('home') . '/wp-admin/', false);
if (
isset(
$response_content['error'],
$response_content_admin['error'],
$response_code['error'],
$response_code_admin['error']
$response_content_admin['error']
) ||
(is_string($response_code) && preg_match('/5\d\d/', $response_code)) ||
(is_string($response_code_admin) && preg_match('/5\d\d/', $response_code_admin)) ||
spbc_search_page_errors($response_content) ||
spbc_search_page_errors($response_content_admin)
) {
Expand Down Expand Up @@ -1587,17 +1582,11 @@ function spbc_scanner_file_quarantine($direct_call = false, $file_id = null)
if (unlink($root_path . $file_info['path'])) {
$response_content = HTTP::getContentFromURL(get_option('home'));
$response_content_admin = HTTP::getContentFromURL(get_option('home') . '/wp-admin/');
$response_code = HTTP::getResponseCode(get_option('home'));
$response_code_admin = HTTP::getResponseCode(get_option('home') . '/wp-admin/');
if (
isset(
$response_content['error'],
$response_content_admin['error'],
$response_code['error'],
$response_code_admin['error']
$response_content_admin['error']
) ||
(is_string($response_code) && preg_match('/5\d\d/', $response_code)) ||
(is_string($response_code_admin) && preg_match('/5\d\d/', $response_code_admin)) ||
spbc_search_page_errors($response_content) ||
spbc_search_page_errors($response_content_admin)
) {
Expand Down Expand Up @@ -1730,12 +1719,12 @@ function spbc_scanner_file_download($direct_call = false, $file_id = null)
if (is_readable($file_info['q_path'])) {
// Getting file && API call
$file_path = substr($file_info['q_path'], stripos($file_info['q_path'], 'wp-content'));
$file = HTTP::getContentFromURL(get_home_url() . '/' . $file_path);
$file_content = HTTP::getContentFromURL(get_home_url() . '/' . $file_path);

if ($file !== false) {
if (empty($file_content['error'])) {
$output = array(
'file_name' => preg_replace('/.*(\/|\\\\)(.*)/', '$2', $file_info['path']),
'file_content' => $file,
'file_content' => $file_content,
);
} else {
$output = array('error' => 'FILE_EMPTY');
Expand Down Expand Up @@ -2062,3 +2051,21 @@ function spbc_restore_file_from_backup_ajax_action()

wp_send_json_success(esc_html__('Success!', 'security-malware-firewall'));
}

/**
* @param $paths array
*
* @return array
*/
function spbc__get_exists_directories($paths)
{
$exists_dirs = array();

foreach ($paths as $path) {
if (is_dir(ABSPATH . $path)) {
$exists_dirs[] = $path;
}
}

return $exists_dirs;
}
Loading

0 comments on commit 7eb4ef3

Please sign in to comment.