ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_name, $plugin_list ); } elseif ( $_REQUEST['action'] == 'delete-selected' && current_user_can( 'delete_plugins' ) && ! empty( $nfw_options['a_16'] ) ) { $alert_action = sprintf( '%s %s', $label_plugin, __('deleted', 'ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_name, $plugin_list ); } // update-core.php (only used for WP updates) } elseif ( strpos($_SERVER['SCRIPT_NAME'], '/update-core.php' ) !== FALSE ) { if (! isset( $_GET['action'] ) || empty( $_POST['upgrade'] ) ) { return; } if ( $_GET['action'] == 'do-core-upgrade' && current_user_can( 'update_core' ) && ! empty( $nfw_options['a_31'] ) ) { $alert_action = sprintf( '%s %s', 'WordPress', __('updated', 'ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_version, @$_POST['version'] ); } // update.php } elseif ( strpos($_SERVER['SCRIPT_NAME'], '/update.php' ) !== FALSE ) { if (! isset( $_GET['action'] ) ) { return; } if ( $_GET['action'] == 'update-selected' && current_user_can( 'update_plugins' ) && ! empty( $nfw_options['a_14'] ) ) { if ( isset( $_GET['plugins'] ) ) { $plugin = $_GET['plugins']; } elseif ( isset( $_POST['checked'] ) ) { $plugin = nfw_implode( ", ", $_POST['checked'] ); } $alert_action = sprintf( '%s %s', $label_plugin, __('updated', 'ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_name, $plugin ); } elseif ( $_GET['action'] == 'upgrade-plugin' && current_user_can( 'update_plugins' ) && ! empty( $nfw_options['a_14'] ) ) { $alert_action = sprintf( '%s %s', $label_plugin, __('updated', 'ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_name, @$_REQUEST['plugin'] ); } elseif ( $_GET['action'] == 'activate-plugin' && current_user_can( 'update_plugins' ) && ! empty( $nfw_options['a_13'] ) ) { $alert_action = sprintf( '%s %s', $label_plugin, __('activated', 'ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_name, @$_REQUEST['plugin'] ); } elseif ( $_GET['action'] == 'install-plugin' && current_user_can( 'install_plugins' ) && ! empty( $nfw_options['a_12'] ) ) { $alert_action = sprintf( '%s %s', $label_plugin, __('installed', 'ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_name, @$_REQUEST['plugin'] ); } elseif ( $_GET['action'] == 'upload-plugin' && current_user_can( 'upload_plugins' ) && ! empty( $nfw_options['a_11'] ) ) { if ( isset( $_FILES['pluginzip']['name'] ) ) { $alert_action = sprintf( '%s %s', $label_plugin, __('uploaded', 'ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_name, $_FILES['pluginzip']['name'] ); } } elseif ( $_GET['action'] == 'upgrade-theme' && current_user_can( 'update_themes' ) && ! empty( $nfw_options['a_25'] ) ) { $alert_action = sprintf( '%s %s', $label_theme, __('updated', 'ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_name, @$_REQUEST['theme'] ); } elseif ( $_GET['action'] == 'update-selected-themes' && current_user_can( 'update_themes' ) && ! empty( $nfw_options['a_25'] ) ) { if ( isset( $_GET['themes'] ) ) { $theme = nfw_implode( ", ", $_GET['themes'] ); } elseif ( isset( $_POST['checked'] ) ) { $theme = nfw_implode( ", ", $_POST['checked'] ); } $alert_action = sprintf( '%s %s', $label_theme, __('updated', 'ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_name, $theme ); } elseif ( $_GET['action'] == 'install-theme' && current_user_can( 'install_themes' ) && ! empty( $nfw_options['a_22'] ) ) { $alert_action = sprintf( '%s %s', $label_theme, __('installed', 'ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_name, @$_REQUEST['theme'] ); } elseif ( $_GET['action'] == 'upload-theme' && current_user_can( 'upload_themes' ) && ! empty( $nfw_options['a_21'] ) ) { $alert_action = sprintf( '%s %s', $label_theme, __('uploaded', 'ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_name, @$_FILES['themezip']['name'] ); } // AJAX actions } elseif ( strpos($_SERVER['SCRIPT_NAME'], '/admin-ajax.php' ) !== FALSE ) { if (! isset( $_REQUEST['action'] ) ) { return; } if ( $_REQUEST['action'] == 'install-theme' && current_user_can( 'install_themes' ) && ! empty( $nfw_options['a_22'] ) ) { $alert_action = sprintf( '%s %s', $label_theme, __('installed', 'ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_name, @$_POST['slug'] ); } elseif ( $_REQUEST['action'] == 'update-theme' && current_user_can( 'update_themes' ) && ! empty( $nfw_options['a_25'] ) ) { $alert_action = sprintf( '%s %s', $label_theme, __('updated', 'ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_name, @$_POST['slug'] ); } elseif ( $_REQUEST['action'] == 'delete-theme' && current_user_can( 'delete_themes' ) && ! empty( $nfw_options['a_24'] ) ) { $alert_action = sprintf( '%s %s', $label_theme, __('deleted', 'ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_name, @$_POST['slug'] ); } elseif ( $_REQUEST['action'] == 'install-plugin' && current_user_can( 'install_plugins' ) && ! empty( $nfw_options['a_12'] ) ) { $alert_action = sprintf( '%s %s', $label_plugin, __('installed', 'ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_name, @$_POST['slug'] ); } elseif ( $_REQUEST['action'] == 'update-plugin' && current_user_can( 'update_plugins' ) && ! empty( $nfw_options['a_14'] ) ) { $alert_action = sprintf( '%s %s', $label_plugin, __('updated', 'ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_name, @$_POST['plugin'] ); } elseif ( $_REQUEST['action'] == 'delete-plugin' && current_user_can( 'delete_plugins' ) && ! empty( $nfw_options['a_16'] ) ) { $alert_action = sprintf( '%s %s', $label_plugin, __('deleted', 'ninjafirewall') ); $alert_item = sprintf( '%s %s', $label_name, @$_POST['plugin'] ); } } if (! empty( $alert_action ) ) { global $current_user; $current_user = wp_get_current_user(); $subject = sprintf( __('[NinjaFirewall] Alert: %s', 'ninjafirewall'), $alert_action ); if ( is_multisite() ) { $url = __('-Blog:', 'ninjafirewall') .' '. network_home_url('/') ."\n\n"; } else { $url = __('-Blog:', 'ninjafirewall') .' '. home_url('/') ."\n\n"; } $message = __('NinjaFirewall has detected the following activity on your account:', 'ninjafirewall') . "\n\n". "-$alert_action\n-$alert_item\n\n" . __('-User:', 'ninjafirewall') .' '. $current_user->user_login .' ('. $current_user->roles[0] .")\n" . __('-IP:', 'ninjafirewall') .' '. NFW_REMOTE_ADDR . "\n" . __('-Date:', 'ninjafirewall') .' '. ucfirst( date_i18n('F j, Y @ H:i:s O') ) ."\n" . $url . NF_PG_SIGNATURE ."\n\n". NF_PG_MORESEC; nfw_mail( $subject, $message, 'unsubscribe' ); if (! empty($nfw_options['a_41']) ) { nfw_log2( $alert_action .' by '. $current_user->user_login, $alert_item, 6, 0 ); } } } add_action('admin_init', 'nfw_sys_events', 999999); /* ------------------------------------------------------------------ */ // Make sure we have an array to prevent E_ERROR. function nfw_implode( $separator, $input ) { if ( is_array( $input ) ) { return implode( ', ', $input ); } else { return $input; } } /* ------------------------------------------------------------------ */ // EOF