Skip to content

Commit

Permalink
Fix. Renaming the array key
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonV1211 committed May 29, 2024
1 parent 21777f0 commit 545b183
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions inc/spbc-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ function spbc_admin_log_action()

$log_id = spbc_auth_log(array(
'username' => $user->get('user_login'),
'event' => isset($action["parsed_action"]) ? $action["parsed_action"] : 'view',
'event' => isset($action["action_event"]) ? $action["action_event"] : 'view',
'page' => Server::get('REQUEST_URI'),
'blog_id' => get_current_blog_id(),
'roles' => $roles
Expand Down Expand Up @@ -1146,7 +1146,7 @@ function spbc_dashboard_statistics_widget_output($_post, $_callback_args)
echo Escape::escHtml($val['login']); ?></td>

<td><a class="spbc_auto_link" title="<?php echo Escape::escHtml($val['action_url']) ?>"><?php
echo Escape::escHtml($val['parsed_action']); ?></td>
echo Escape::escHtml($val['action_event']); ?></td>
</tr>
<?php
} ?>
Expand Down
28 changes: 14 additions & 14 deletions inc/spbc-tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ function spbc_update_brief_data_last_actions($current_last_actions)
$last_actions_already_gained_ids[] = $value['id'];
// reformat already gained actions
$action = spbc_parse_action_from_admin_page_uri($value['action_url']);
$value['parsed_action'] = $action['parsed_action'];
$value['action_event'] = $action['action_event'];
}
}

Expand All @@ -643,7 +643,7 @@ function spbc_update_brief_data_last_actions($current_last_actions)
foreach ($result as $_action => &$data) {
// parse url to user-friendly string
$action = spbc_parse_action_from_admin_page_uri($data['action_url']);
$data['parsed_action'] = $action['parsed_action'];
$data['action_event'] = $action['action_event'];
// collect parsed
$current_last_actions[] = $data;
}
Expand Down Expand Up @@ -779,7 +779,7 @@ function spbc_get_brief_data_for_firewalls($current_fw_data, $current_bfp_data,
* Parse URL to find human-readable description.
* @param string $url - requested URL
* @param string $post_id - a WordPress post ID, default null
* @return array ['parsed_action' => '', 'add_time' => bool]
* @return array ['action_event' => '', 'add_time' => bool, 'post_id' => null, 'page_action' => null, 'plugin_name' => null]
*/
function spbc_parse_action_from_admin_page_uri($url, $post_id = null)
{
Expand All @@ -798,7 +798,7 @@ function spbc_parse_action_from_admin_page_uri($url, $post_id = null)
}
}
$out = array(
'parsed_action' => 'Action of empty URL',
'action_event' => 'Action of empty URL',
'add_time' => true,
'post_id' => null,
'page_action' => null,
Expand All @@ -810,13 +810,13 @@ function spbc_parse_action_from_admin_page_uri($url, $post_id = null)
|| '/wp-admin/network/edit.php' == $url
? true
: false):
$out['parsed_action'] = 'viewing_posts_list';
$out['action_event'] = 'viewing_posts_list';
break;
case ('/wp-admin/edit.php?post_type=page' == $url
|| '/wp-admin/network/edit.php?post_type=page' == $url
? true
: false):
$out['parsed_action'] = 'viewing_pages_list';
$out['action_event'] = 'viewing_pages_list';
break;
case (preg_match('#/wp-admin/post.php\?post=[\d\w]+&action=edit#', $url)
|| preg_match('#/wp-admin/network/post.php\?post=[\d\w]+&action=edit#', $url)
Expand All @@ -843,55 +843,55 @@ function spbc_parse_action_from_admin_page_uri($url, $post_id = null)
$page_action = ': ' . __('draft update', 'security-malware-firewall');
}
if ( is_int($post_id) ) {
$out['parsed_action'] = 'editing_post_id';
$out['action_event'] = 'editing_post_id';
$out['post_id'] = $post_id;
$out['page_action'] = $page_action;
} else {
$out['parsed_action'] = 'editing_post';
$out['action_event'] = 'editing_post';
}
break;
case (preg_match('#/wp-admin/plugins.php\?.*action=activate#', $url)
|| preg_match('#/wp-admin/network/plugins.php\?.*action=activate#', $url)
? true
: false):
$out['parsed_action'] = 'activate_plugin_name';
$out['action_event'] = 'activate_plugin_name';
$out['plugin_name'] = $plugin_name;
$out['add_time'] = false;
break;
case (preg_match('#/wp-admin/plugins.php\?.*action=deactivate#', $url)
|| preg_match('#/wp-admin/network/plugins.php\?.*action=deactivate#', $url)
? true
: false):
$out['parsed_action'] = 'deactivate_plugin_name';
$out['action_event'] = 'deactivate_plugin_name';
$out['plugin_name'] = $plugin_name;
$out['add_time'] = false;
break;
case (preg_match('#/wp-admin/update.php\?.*action=upload-plugin#', $url)
|| preg_match('#/wp-admin/network/update.php\?.*action=upload-plugin#', $url)
? true
: false):
$out['parsed_action'] = 'uploading_plugin';
$out['action_event'] = 'uploading_plugin';
$out['add_time'] = false;
break;
case (preg_match('#/wp-admin/users.php\?.*update=add#', $url)
|| preg_match('#/wp-admin/network/users.php\?.*update=add#', $url)
? true
: false):
$out['parsed_action'] = 'adding_user';
$out['action_event'] = 'adding_user';
$out['add_time'] = false;
break;
case (preg_match('#/wp-admin/users.php\?.*delete_count#', $url)
|| preg_match('#/wp-admin/network/users.php\?.*delete_count#', $url)
? true
: false):
$out['parsed_action'] = 'deleting_user';
$out['action_event'] = 'deleting_user';
$out['add_time'] = false;
break;
default:
preg_match_all('/\/wp-admin\/(.+\.php)\?(action=.+?)&/', $url, $matches);
$file = !empty($matches[1]) && !empty($matches[1][0]) ? $matches[1][0] : '';
$the_action = !empty($matches[2]) && !empty($matches[2][0]) ? $matches[2][0] : '';
$out['parsed_action'] = !empty($file) && !empty($the_action) ? $file . '...' . $the_action : 'view';
$out['action_event'] = !empty($file) && !empty($the_action) ? $file . '...' . $the_action : 'view';
$out['add_time'] = false;
}
}
Expand Down

0 comments on commit 545b183

Please sign in to comment.