initial import from https://downloads.wordpress.org/plugin/wp-fail2ban.4.2.5.zip
This commit is contained in:
120
admin/config/block.php
Normal file
120
admin/config/block.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Settings - Block
|
||||
*
|
||||
* @package wp-fail2ban
|
||||
* @since 4.0.0
|
||||
*/
|
||||
namespace org\lecklider\charles\wordpress\wp_fail2ban;
|
||||
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
/**
|
||||
* Tab: Block
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class TabBlock extends Tab
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_action( 'admin_init', [ $this, 'admin_init' ] );
|
||||
parent::__construct( 'block', 'Users' );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function admin_init()
|
||||
{
|
||||
// phpcs:disable Generic.Functions.FunctionCallArgumentSpacing
|
||||
add_settings_section(
|
||||
'wp-fail2ban-block',
|
||||
__( 'Block' ),
|
||||
[ $this, 'section' ],
|
||||
'wp-fail2ban-block'
|
||||
);
|
||||
add_settings_field(
|
||||
'block-user-enumeration',
|
||||
parent::doc_link( 'WP_FAIL2BAN_BLOCK_USER_ENUMERATION', __( 'User Enumeration' ) ),
|
||||
[ $this, 'userEnumeration' ],
|
||||
'wp-fail2ban-block',
|
||||
'wp-fail2ban-block'
|
||||
);
|
||||
add_settings_field(
|
||||
'block-users',
|
||||
parent::doc_link( 'WP_FAIL2BAN_BLOCKED_USERS', __( 'Usernames' ) ),
|
||||
[ $this, 'usernames' ],
|
||||
'wp-fail2ban-block',
|
||||
'wp-fail2ban-block'
|
||||
);
|
||||
// phpcs:enable
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param array $settings
|
||||
* @param array $input
|
||||
*/
|
||||
public function sanitize( array $settings, array $input = null )
|
||||
{
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function section()
|
||||
{
|
||||
echo '' ;
|
||||
}
|
||||
|
||||
/**
|
||||
* User Enumeration
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function userEnumeration()
|
||||
{
|
||||
printf( '<input type="checkbox" disabled="disabled" %s>', checked( WP_FAIL2BAN_BLOCK_USER_ENUMERATION, true, false ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocked usernames
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function usernames()
|
||||
{
|
||||
|
||||
if ( defined( 'WP_FAIL2BAN_BLOCKED_USERS' ) ) {
|
||||
|
||||
if ( is_array( WP_FAIL2BAN_BLOCKED_USERS ) ) {
|
||||
$value = join( ', ', WP_FAIL2BAN_BLOCKED_USERS );
|
||||
} else {
|
||||
$value = WP_FAIL2BAN_BLOCKED_USERS;
|
||||
}
|
||||
|
||||
} else {
|
||||
$value = '';
|
||||
}
|
||||
|
||||
printf( '<input class="regular-text" type="text" disabled="disabled" value="%s">', esc_attr( $value ) );
|
||||
}
|
||||
|
||||
}
|
||||
new TabBlock();
|
||||
255
admin/config/logging.php
Normal file
255
admin/config/logging.php
Normal file
@@ -0,0 +1,255 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Settings - Logging
|
||||
*
|
||||
* @package wp-fail2ban
|
||||
* @since 4.0.0
|
||||
*/
|
||||
namespace org\lecklider\charles\wordpress\wp_fail2ban;
|
||||
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
/**
|
||||
* Tab: Logging
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class TabLogging extends Tab
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_action( 'admin_init', [ $this, 'admin_init' ], 100 );
|
||||
parent::__construct( 'logging', 'Logging' );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function admin_init()
|
||||
{
|
||||
// phpcs:disable Generic.Functions.FunctionCallArgumentSpacing
|
||||
add_settings_section(
|
||||
'wp-fail2ban-logging',
|
||||
__( 'What & Where' ),
|
||||
[ $this, 'sectionWhatWhere' ],
|
||||
'wp-fail2ban-logging'
|
||||
);
|
||||
add_settings_field(
|
||||
'logging-log-authentication',
|
||||
parent::doc_link( 'WP_FAIL2BAN_AUTH_LOG', __( 'Authentication' ) ),
|
||||
[ $this, 'authentication' ],
|
||||
'wp-fail2ban-logging',
|
||||
'wp-fail2ban-logging'
|
||||
);
|
||||
add_settings_field(
|
||||
'logging-log-comments',
|
||||
parent::doc_link( 'WP_FAIL2BAN_LOG_COMMENTS', __( 'Comments' ) ),
|
||||
[ $this, 'comments' ],
|
||||
'wp-fail2ban-logging',
|
||||
'wp-fail2ban-logging'
|
||||
);
|
||||
add_settings_field(
|
||||
'logging-log-spam',
|
||||
parent::doc_link( 'WP_FAIL2BAN_LOG_SPAM', __( 'Spam' ) ),
|
||||
[ $this, 'spam' ],
|
||||
'wp-fail2ban-logging',
|
||||
'wp-fail2ban-logging'
|
||||
);
|
||||
add_settings_field(
|
||||
'logging-log-password-request',
|
||||
parent::doc_link( 'WP_FAIL2BAN_LOG_PASSWORD_REQUEST', __( 'Password Requests' ) ),
|
||||
[ $this, 'passwordRequest' ],
|
||||
'wp-fail2ban-logging',
|
||||
'wp-fail2ban-logging'
|
||||
);
|
||||
add_settings_field(
|
||||
'logging-log-pingbacks',
|
||||
parent::doc_link( 'WP_FAIL2BAN_LOG_PINGBACKS', __( 'Pingbacks' ) ),
|
||||
[ $this, 'pingbacks' ],
|
||||
'wp-fail2ban-logging',
|
||||
'wp-fail2ban-logging'
|
||||
);
|
||||
// phpcs:enable
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
parent::render();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param array $settings {@inheritDoc}
|
||||
* @param array $input {@inheritDoc}
|
||||
*
|
||||
* @return array {@inheritDoc}
|
||||
*/
|
||||
public function sanitize( array $settings, array $input = null )
|
||||
{
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Section summary.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function sectionWhatWhere()
|
||||
{
|
||||
echo '' ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Authentication.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function authentication()
|
||||
{
|
||||
printf( '<label>%s: %s</label>', __( 'Use facility' ), $this->getLogFacilities( 'WP_FAIL2BAN_AUTH_LOG', true ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Comments.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function comments()
|
||||
{
|
||||
add_filter(
|
||||
'wp_fail2ban_log_WP_FAIL2BAN_LOG_COMMENTS',
|
||||
[ $this, 'commentsExtra' ],
|
||||
10,
|
||||
3
|
||||
);
|
||||
$this->log(
|
||||
'WP_FAIL2BAN_LOG_COMMENTS',
|
||||
'WP_FAIL2BAN_COMMENT_LOG',
|
||||
'',
|
||||
[ 'comments-extra', 'logging-comments-extra-facility' ]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Comments extra helper - checked.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param int $value Value to check
|
||||
*/
|
||||
protected function commentExtraChecked( $value )
|
||||
{
|
||||
if ( !defined( 'WP_FAIL2BAN_LOG_COMMENTS_EXTRA' ) ) {
|
||||
return '';
|
||||
}
|
||||
return checked( $value & WP_FAIL2BAN_LOG_COMMENTS_EXTRA, $value, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Comments extra helper - disabled.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function commentExtraDisabled()
|
||||
{
|
||||
return 'disabled="disabled';
|
||||
}
|
||||
|
||||
/**
|
||||
* Comments extra.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param string $html HTML prefixed to output
|
||||
* @param string $define_name Not used
|
||||
* @param string $define_log Not used
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function commentsExtra( $html, $define_name, $define_log )
|
||||
{
|
||||
$fmt = <<<___HTML___
|
||||
<table>
|
||||
<tr>
|
||||
<th>%s</th>
|
||||
<td>
|
||||
<fieldset id="comments-extra" disabled="disabled">
|
||||
<label><input type="checkbox" %s> %s</label><br>
|
||||
<label><input type="checkbox" %s> %s</label><br>
|
||||
<label><input type="checkbox" %s> %s</label><br>
|
||||
<label><input type="checkbox" %s> %s</label><br>
|
||||
<label><input type="checkbox" %s> %s</label>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>%s</th>
|
||||
<td>%s</td>
|
||||
</tr>
|
||||
</table>
|
||||
___HTML___;
|
||||
return $html . sprintf(
|
||||
$fmt,
|
||||
parent::doc_link( 'WP_FAIL2BAN_LOG_COMMENTS_EXTRA', __( 'Also log:' ) ),
|
||||
$this->commentExtraChecked( WPF2B_EVENT_COMMENT_NOT_FOUND ),
|
||||
__( 'Post not found' ),
|
||||
$this->commentExtraChecked( WPF2B_EVENT_COMMENT_CLOSED ),
|
||||
__( 'Comments closed' ),
|
||||
$this->commentExtraChecked( WPF2B_EVENT_COMMENT_TRASH ),
|
||||
__( 'Trash post' ),
|
||||
$this->commentExtraChecked( WPF2B_EVENT_COMMENT_DRAFT ),
|
||||
__( 'Draft post' ),
|
||||
$this->commentExtraChecked( WPF2B_EVENT_COMMENT_PASSWORD ),
|
||||
__( 'Password-protected post' ),
|
||||
parent::doc_link( 'WP_FAIL2BAN_COMMENT_EXTRA_LOG', __( 'Use facility:' ) ),
|
||||
$this->getLogFacilities( 'WP_FAIL2BAN_COMMENT_EXTRA_LOG', false )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Password request
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function passwordRequest()
|
||||
{
|
||||
$this->log( 'WP_FAIL2BAN_LOG_PASSWORD_REQUEST', 'WP_FAIL2BAN_PASSWORD_REQUEST_LOG' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Pingbacks
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function pingbacks()
|
||||
{
|
||||
$this->log( 'WP_FAIL2BAN_LOG_PINGBACKS', 'WP_FAIL2BAN_PINGBACK_LOG' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Spam
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function spam()
|
||||
{
|
||||
$this->log( 'WP_FAIL2BAN_LOG_SPAM', 'WP_FAIL2BAN_SPAM_LOG' );
|
||||
}
|
||||
|
||||
}
|
||||
new TabLogging();
|
||||
185
admin/config/plugins.php
Normal file
185
admin/config/plugins.php
Normal file
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Settings - Plugins
|
||||
*
|
||||
* @package wp-fail2ban
|
||||
* @since 4.2.0
|
||||
*/
|
||||
namespace org\lecklider\charles\wordpress\wp_fail2ban;
|
||||
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
/**
|
||||
* Tab: Plugins
|
||||
*
|
||||
* @since 4.2.0
|
||||
*/
|
||||
class TabPlugins extends Tab
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_action( 'admin_init', [ $this, 'admin_init' ], 100 );
|
||||
parent::__construct( 'plugins', 'Plugins' );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function admin_init()
|
||||
{
|
||||
// phpcs:disable Generic.Functions.FunctionCallArgumentSpacing
|
||||
add_settings_section(
|
||||
'wp-fail2ban-plugins',
|
||||
__( 'Event Class Facilities' ),
|
||||
[ $this, 'sectionLoggingEventClasses' ],
|
||||
'wp-fail2ban-plugins'
|
||||
);
|
||||
add_settings_field(
|
||||
'plugins-log-auth',
|
||||
parent::doc_link( 'WP_FAIL2BAN_PLUGIN_LOG_AUTH', __( 'Authentication' ) ),
|
||||
[ $this, 'auth' ],
|
||||
'wp-fail2ban-plugins',
|
||||
'wp-fail2ban-plugins'
|
||||
);
|
||||
add_settings_field(
|
||||
'plugins-log-comment',
|
||||
parent::doc_link( 'WP_FAIL2BAN_PLUGIN_LOG_COMMENT', __( 'Comment' ) ),
|
||||
[ $this, 'comment' ],
|
||||
'wp-fail2ban-plugins',
|
||||
'wp-fail2ban-plugins'
|
||||
);
|
||||
add_settings_field(
|
||||
'plugins-log-password',
|
||||
parent::doc_link( 'WP_FAIL2BAN_PLUGIN_LOG_PASSWORD', __( 'Password' ) ),
|
||||
[ $this, 'password' ],
|
||||
'wp-fail2ban-plugins',
|
||||
'wp-fail2ban-plugins'
|
||||
);
|
||||
add_settings_field(
|
||||
'plugins-log-rest',
|
||||
parent::doc_link( 'WP_FAIL2BAN_PLUGIN_LOG_REST', __( 'REST' ) ),
|
||||
[ $this, 'rest' ],
|
||||
'wp-fail2ban-plugins',
|
||||
'wp-fail2ban-plugins'
|
||||
);
|
||||
add_settings_field(
|
||||
'plugins-log-spam',
|
||||
parent::doc_link( 'WP_FAIL2BAN_PLUGIN_LOG_SPAM', __( 'Spam' ) ),
|
||||
[ $this, 'spam' ],
|
||||
'wp-fail2ban-plugins',
|
||||
'wp-fail2ban-plugins'
|
||||
);
|
||||
add_settings_field(
|
||||
'plugins-log-xmlrpc',
|
||||
parent::doc_link( 'WP_FAIL2BAN_PLUGIN_LOG_XMLRPC', __( 'XML-RPC' ) ),
|
||||
[ $this, 'xmlrpc' ],
|
||||
'wp-fail2ban-plugins',
|
||||
'wp-fail2ban-plugins'
|
||||
);
|
||||
// phpcs:enable
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @since 4.2.0
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
parent::render();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @param array $settings {@inheritDoc}
|
||||
* @param array $input {@inheritDoc}
|
||||
*
|
||||
* @return array {@inheritDoc}
|
||||
*/
|
||||
public function sanitize( array $settings, array $input = null )
|
||||
{
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Section summary.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*/
|
||||
public function sectionLoggingEventClasses()
|
||||
{
|
||||
echo __( 'Facilities to use for plugin-generated messages. The defaults follow the Core defaults.' ) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auth
|
||||
*
|
||||
* @since 4.2.0
|
||||
*/
|
||||
public function auth()
|
||||
{
|
||||
$this->log( 'WP_FAIL2BAN_PLUGIN_LOG_AUTH', 'WP_FAIL2BAN_PLUGIN_AUTH_LOG' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Comment
|
||||
*
|
||||
* @since 4.2.0
|
||||
*/
|
||||
public function comment()
|
||||
{
|
||||
$this->log( 'WP_FAIL2BAN_PLUGIN_LOG_COMMENT', 'WP_FAIL2BAN_PLUGIN_COMMENT_LOG' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Password
|
||||
*
|
||||
* @since 4.2.0
|
||||
*/
|
||||
public function password()
|
||||
{
|
||||
$this->log( 'WP_FAIL2BAN_PLUGIN_LOG_PASSWORD', 'WP_FAIL2BAN_PLUGIN_PASSWORD_LOG' );
|
||||
}
|
||||
|
||||
/**
|
||||
* REST
|
||||
*
|
||||
* @since 4.2.0
|
||||
*/
|
||||
public function rest()
|
||||
{
|
||||
$this->log( 'WP_FAIL2BAN_PLUGIN_LOG_REST', 'WP_FAIL2BAN_PLUGIN_REST_LOG' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Spam
|
||||
*
|
||||
* @since 4.2.0
|
||||
*/
|
||||
public function spam()
|
||||
{
|
||||
$this->log( 'WP_FAIL2BAN_PLUGIN_LOG_SPAM', 'WP_FAIL2BAN_PLUGIN_SPAM_LOG' );
|
||||
}
|
||||
|
||||
/**
|
||||
* XML-RPC
|
||||
*
|
||||
* @since 4.2.0
|
||||
*/
|
||||
public function xmlrpc()
|
||||
{
|
||||
$this->log( 'WP_FAIL2BAN_PLUGIN_LOG_XMLRPC', 'WP_FAIL2BAN_PLUGIN_XMLRPC_LOG' );
|
||||
}
|
||||
|
||||
}
|
||||
new TabPlugins();
|
||||
100
admin/config/remote-ips.php
Normal file
100
admin/config/remote-ips.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Settings - Remote IPs
|
||||
*
|
||||
* @package wp-fail2ban
|
||||
* @since 4.0.0
|
||||
*/
|
||||
namespace org\lecklider\charles\wordpress\wp_fail2ban;
|
||||
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
/**
|
||||
* Tab: Remote IPs
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class TabRemoteIPs extends Tab
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_action( 'admin_init', [ $this, 'admin_init' ] );
|
||||
parent::__construct( 'remote-ips', 'Remote IPs' );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function admin_init()
|
||||
{
|
||||
// phpcs:disable Generic.Functions.FunctionCallArgumentSpacing
|
||||
add_settings_section(
|
||||
'wp-fail2ban-proxies',
|
||||
__( 'Proxies' ),
|
||||
[ $this, 'section' ],
|
||||
'wp-fail2ban-remote-ips'
|
||||
);
|
||||
add_settings_field(
|
||||
'remote-ips-proxies',
|
||||
parent::doc_link( 'WP_FAIL2BAN_PROXIES', __( 'IP list' ) ),
|
||||
[ $this, 'proxies' ],
|
||||
'wp-fail2ban-remote-ips',
|
||||
'wp-fail2ban-proxies'
|
||||
);
|
||||
// phpcs:enable
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param array $settings
|
||||
* @param array $input
|
||||
*/
|
||||
public function sanitize( array $settings, array $input = null )
|
||||
{
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Section blurb.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function section()
|
||||
{
|
||||
echo '' ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxies.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function proxies()
|
||||
{
|
||||
$value = '';
|
||||
if ( defined( 'WP_FAIL2BAN_PROXIES' ) ) {
|
||||
|
||||
if ( is_array( WP_FAIL2BAN_PROXIES ) ) {
|
||||
$value = join( "\n", WP_FAIL2BAN_PROXIES );
|
||||
} else {
|
||||
$value = join( "\n", array_map( 'trim', explode( ',', WP_FAIL2BAN_PROXIES ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
printf( '<fieldset><textarea class="code" cols="20" rows="10" disabled="disabled">%s</textarea></fieldset>', esc_html( $value ) );
|
||||
}
|
||||
|
||||
}
|
||||
new TabRemoteIPs();
|
||||
159
admin/config/syslog.php
Normal file
159
admin/config/syslog.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Settings - syslog
|
||||
*
|
||||
* @package wp-fail2ban
|
||||
* @since 4.0.0
|
||||
*/
|
||||
namespace org\lecklider\charles\wordpress\wp_fail2ban;
|
||||
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
/**
|
||||
* Tab: Syslog
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class TabSyslog extends Tab
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_action( 'admin_init', [ $this, 'admin_init' ], 100 );
|
||||
parent::__construct( 'syslog', '<tt>syslog</tt>' );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function admin_init()
|
||||
{
|
||||
// phpcs:disable Generic.Functions.FunctionCallArgumentSpacing
|
||||
add_settings_section(
|
||||
'wp-fail2ban-connection',
|
||||
__( 'Connection' ),
|
||||
[ $this, 'sectionConnection' ],
|
||||
'wp-fail2ban-syslog'
|
||||
);
|
||||
add_settings_field(
|
||||
'logging-connection',
|
||||
parent::doc_link( 'WP_FAIL2BAN_OPENLOG_OPTIONS', __( 'Options' ) ),
|
||||
[ $this, 'connection' ],
|
||||
'wp-fail2ban-syslog',
|
||||
'wp-fail2ban-connection'
|
||||
);
|
||||
add_settings_section(
|
||||
'wp-fail2ban-workarounds',
|
||||
__( 'Workarounds' ),
|
||||
[ $this, 'sectionWorkarounds' ],
|
||||
'wp-fail2ban-syslog'
|
||||
);
|
||||
add_settings_field(
|
||||
'logging-workarounds',
|
||||
parent::doc_link( '../syslog', __( 'Options' ) ),
|
||||
[ $this, 'workarounds' ],
|
||||
'wp-fail2ban-syslog',
|
||||
'wp-fail2ban-workarounds'
|
||||
);
|
||||
// phpcs:enable
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param array $settings {@inheritDoc}
|
||||
* @param array $input {@inheritDoc}
|
||||
*
|
||||
* @return array {@inheritDoc}
|
||||
*/
|
||||
public function sanitize( array $settings, array $input = null )
|
||||
{
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connection section blurb.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function sectionConnection()
|
||||
{
|
||||
echo '' ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connection.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function connection()
|
||||
{
|
||||
$class = '';
|
||||
$fmt = <<<___STR___
|
||||
<fieldset>
|
||||
<label><input type="checkbox" disabled="disabled" %s> <code>LOG_CONS</code></label><br>
|
||||
<label><input type="checkbox" disabled="disabled" %s> <code>LOG_PERROR</code></label><br>
|
||||
<label><input type="checkbox" disabled="disabled" %s> <code>LOG_PID</code> <em>(%s)</em></label><br>
|
||||
<label><input type="radio" disabled="disabled" %s> <code>LOG_NDELAY</code> <em>(%s)</em></label><br>
|
||||
<label><input type="radio" disabled="disabled" %s> <code>LOG_ODELAY</code></label>
|
||||
</fieldset>
|
||||
___STR___;
|
||||
printf(
|
||||
$fmt,
|
||||
checked( WP_FAIL2BAN_OPENLOG_OPTIONS & LOG_CONS, LOG_CONS, false ),
|
||||
checked( WP_FAIL2BAN_OPENLOG_OPTIONS & LOG_PERROR, LOG_PERROR, false ),
|
||||
checked( WP_FAIL2BAN_OPENLOG_OPTIONS & LOG_PID, LOG_PID, false ),
|
||||
__( 'default' ),
|
||||
checked( WP_FAIL2BAN_OPENLOG_OPTIONS & LOG_NDELAY, LOG_NDELAY, false ),
|
||||
__( 'default' ),
|
||||
checked( WP_FAIL2BAN_OPENLOG_OPTIONS & LOG_ODELAY, LOG_ODELAY, false )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Workarounds section blurb.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function sectionWorkarounds()
|
||||
{
|
||||
echo '' ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Workarounds.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function workarounds()
|
||||
{
|
||||
$fmt = <<<___STR___
|
||||
<fieldset>
|
||||
<label><input type="checkbox" disabled="disabled" %s> %s</label>
|
||||
<br>
|
||||
<label><input type="checkbox" disabled="disabled" %s> %s</label>
|
||||
<br>
|
||||
<label><input type="checkbox" disabled="disabled" %s> %s</label>
|
||||
</fieldset>
|
||||
___STR___;
|
||||
printf(
|
||||
$fmt,
|
||||
checked( @WP_FAIL2BAN_SYSLOG_SHORT_TAG, true, false ),
|
||||
__( 'Short Tag' ),
|
||||
checked( @WP_FAIL2BAN_HTTP_HOST, true, false ),
|
||||
__( 'Specify Host' ),
|
||||
checked( @WP_FAIL2BAN_TRUNCATE_HOST, true, false ),
|
||||
__( 'Truncate Host' )
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
new TabSyslog();
|
||||
Reference in New Issue
Block a user