Files
Testing/tbb/wp-content/plugins/wp-fail2ban/admin/config/remote-ips.php
sean 0e8a8b3028
Some checks failed
deploy-testing / deploy (push) Has been cancelled
Initial testing snapshot
2026-11-17 16:15:01 -05:00

127 lines
2.8 KiB
PHP

<?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 ) );
}
/**
* Section blurb.
*
* @since 4.0.0
*/
public function sectionGeo()
{
}
/**
* MaxMind database.
*
* @since 4.0.0
*/
public function database()
{
$settings = get_option( 'wp-fail2ban' );
$exists = file_exists( @$settings['remote-ip']['maxmind']['path'] );
$fmt = <<<__FMT__
<fieldset>
<label><input type="checkbox" name="wp-fail2ban[remote-ip][maxmind]" %s> Download now</label>
<p class="description">%s</p>
</fieldset>
__FMT__;
printf( $fmt, checked( $exists, false, false ), ( $exists ? __( 'Last modified: ' ) . gmdate( DATE_RFC1123, $settings['remote-ip']['maxmind']['modified'] ) : __( 'No database found.' ) ) );
}
}
new TabRemoteIPs();