__['wp-fail2ban-connection'] = __('Connection', 'wp-fail2ban'); $this->__['syslog-connection-options'] = __('Options', 'wp-fail2ban'); $this->__['wp-fail2ban-workarounds'] = __('Workarounds', 'wp-fail2ban'); $this->__['syslog-workarounds'] = __('Options', 'wp-fail2ban'); $this->__['workarounds-short-tag'] = __('Short Tag', 'wp-fail2ban'); $this->__['workarounds-specify-host'] = __('Specify Host', 'wp-fail2ban'); $this->__['workarounds-truncate_host'] = __('Truncate Host', 'wp-fail2ban'); // phpcs:enable parent::__construct('syslog', 'syslog'); } /** * {@inheritDoc} * * @since 4.4.0 Add return type * @since 4.0.0 * * @return void */ public function admin_init(): void { do_action(__METHOD__.'.before'); // phpcs:disable Generic.Functions.FunctionCallArgumentSpacing add_settings_section('wp-fail2ban-connection', $this->__['wp-fail2ban-connection'], [$this, 'sectionConnection'], self::SETTINGS_PAGE); add_settings_field('syslog-connection-options', $this->__['syslog-connection-options'], [$this, 'connection'], self::SETTINGS_PAGE, 'wp-fail2ban-connection'); add_settings_section('wp-fail2ban-workarounds', $this->__['wp-fail2ban-workarounds'], [$this, 'sectionWorkarounds'], self::SETTINGS_PAGE); add_settings_field('syslog-workarounds', $this->__['syslog-workarounds'], [$this, 'workarounds'], self::SETTINGS_PAGE, 'wp-fail2ban-workarounds'); // phpcs:enable do_action(__METHOD__.'.after'); } /** * {@inheritDoc} * * @since 4.4.0 Add return type * @since 4.3.3.0 Refactor * @since 4.3.0 * * @return void */ public function current_screen(): void { $pre = [ __('Used to indicate what logging options will be used when generating a log message.', 'wp-fail2ban') ]; $post = [ $this->see_also(['WP_FAIL2BAN_OPENLOG_OPTIONS']) ]; $fmt = <<< HTML
LOG_CONS%s
LOG_NDELAY%s
LOG_ODELAY%s
LOG_PERROR%s
LOG_PID%s
HTML; $content = sprintf( $fmt, __('if there is an error while sending data to the system logger, write directly to the system console', 'wp-fail2ban'), __('open the connection to the logger immediately', 'wp-fail2ban'), __('(default) delay opening the connection until the first message is logged', 'wp-fail2ban'), __('print log message also to standard error', 'wp-fail2ban'), __('include PID with each message', 'wp-fail2ban') ); $this->add_help_tab('wp-fail2ban-connection', $content, $pre, $post); $this->add_help_tab('wp-fail2ban-workarounds', [ $this->help_entry('workarounds-short-tag', [ __('Some syslog implementations assume that the first part of the message (the tag) won‘t exceed some (small) number of characters. This option tells WPf2b to use wp instead of wordpress, thereby saving 7 characters; this may be enough to make syslog happy.', 'wp-fail2ban') ]), $this->help_entry('workarounds-specify-host', [ sprintf( /* translators: %s: internals */ __('"Short Tag" may not be enough, so this allows you to specify the hostname. See the documentation for more details.', 'wp-fail2ban'), 'href="https://docs.wp-fail2ban.com/en/___WPF2BVER___/defines/constants/WP_FAIL2BAN_HTTP_HOST.html" target="_blank">' ) ]), $this->help_entry('workarounds-truncate_host', [ __('When all else fails, this allows you to truncate the hostname after a number of characters.', 'wp-fail2ban'), __('N.B. This may be removed in a future release; it was broken prior to 4.3 and there were no bug reports, so it seems likely absolutely no-one is using it.', 'wp-fail2ban'), $this->see_also(['WP_FAIL2BAN_TRUNCATE_HOST']) ]) ], [ sprintf( /* translators: %s: internals */ __('syslog was only standardised in 2009, so unfortunately there are still implementations that need some help.', 'wp-fail2ban'), 'href="https://tools.ietf.org/html/rfc5424" target="_blank">' ), __('By far the most common limitation is the length of the initial information fields; these options provide ways to shorten the data in those fields.', 'wp-fail2ban'), ]); parent::current_screen(); } /** * Connection section blurb. * * @since 4.4.0 Add return type * @since 4.0.0 * * @return void */ public function sectionConnection(): void { echo ''; } /** * Connection. * * @since 4.4.0 Add return type * @since 4.3.0 Refactor to premium. * @since 4.0.0 * * @return void */ public function connection(): void { $options = Config::get('WP_FAIL2BAN_OPENLOG_OPTIONS'); $fmt = <<< HTML




HTML; // phpcs:disable Generic.Functions.FunctionCallArgumentSpacing, PSR2.Methods.FunctionCallSignature.MultipleArguments printf( $fmt, checked($options & LOG_CONS, LOG_CONS, false), checked($options & LOG_PERROR, LOG_PERROR, false), checked($options & LOG_PID, LOG_PID, false), __('default'), checked($options & LOG_NDELAY, LOG_NDELAY, false), __('default'), checked($options & LOG_ODELAY, LOG_ODELAY, false) ); // phpcs:enable } /** * Workarounds section blurb. * * @since 4.4.0 Add return type * @since 4.0.0 * * @return void */ public function sectionWorkarounds(): void { echo ''; } /** * Workarounds. * * @since 4.4.0 Add return type * @since 4.3.0 Refactor to premium. * @since 4.0.0 * * @return void */ public function workarounds(): void { $fmt = <<< HTML


HTML; printf( $fmt, checked(Config::get('WP_FAIL2BAN_SYSLOG_SHORT_TAG'), true, false), __('Short Tag', 'wp-fail2ban'), checked(Config::get('WP_FAIL2BAN_HTTP_HOST'), true, false), __('Specify Host', 'wp-fail2ban'), checked(Config::get('WP_FAIL2BAN_TRUNCATE_HOST'), true, false), __('Truncate Host', 'wp-fail2ban') ); } }