Compare commits

..

No commits in common. "e204c8a53ef22aeb10d4a98b67d064e5e70d3947" and "ba736ef6611851ae5341fd6635779f5fef570b87" have entirely different histories.

58 changed files with 1596 additions and 2277 deletions

View File

@ -1,43 +0,0 @@
jQuery(document).ready(function($) {
$( "<button class='button button-primary' disabled id='password_too_short'>" +
php_vars.password_too_short_text + "</button>" ).insertBefore( ".submit" );
$("#password_too_short").css('display', 'none');
$(document).on('DOMSubtreeModified', '#pass-strength-result', function() {
var strengthMeter = $(this).attr('class');
var allowedStrengths = php_vars.allowed_strengths;
$( "[name='pw_weak']" ).css('visibility', 'hidden');
$( '.pw-weak' ).css('visibility', 'hidden');
$( '#pw-weak-text-label' ).css('visibility', 'hidden');
if (strengthMeter !== '') {
if (allowedStrengths.includes(strengthMeter)) {
$("[name='pw_weak']").prop("checked", true);
$("[name='submit']").css('display', 'inline');
$('#createusersub').css('display', 'inline');
$('submit').onclick = function() {
$('your-profile').submit();
};
$("#createusersub").onclick = function() {
$('createuser').submit();
};
$("#password_too_short").css('display', 'none');
} else {
$("#createusersub").css('display', 'none');
$("[name='submit']").prop("disabled", true);
$("[name='pw_weak']").prop("checked", false);
$("[name='submit']").css('display', 'none');
$('submit').onclick = function() {
return false;
};
$("#createusersub").onclick = function() {
return false;
};
$("#password_too_short").css('display', 'inline');
}
}
});
});

View File

@ -3,11 +3,13 @@
width: 85%; width: 85%;
margin: auto; margin: auto;
padding: 10px; padding: 10px;
border-style: solid; border-color: #d0d0d0; border-radius: 10px; padding: 15px; border-width: 1px;
box-shadow: 2px 2px 5px #c0c0c0;
} }
.bdp_security_inner { .bdp_security_inner {
border-style: solid; border-color: #d0d0d0; border-radius: 10px; padding: 15px; border-width: 1px;
box-shadow: 2px 2px 5px #c0c0c0;
width: 80%; width: 80%;
margin: 0 auto 40px; margin: 0 auto 40px;
} }
@ -51,15 +53,3 @@
.long_text { .long_text {
width: 80%; width: 80%;
} }
.protect-login-no-blocked-ips
{
padding: 5px 10px;
width: 90%;
background-color: #ffffff;
border-style: solid;
border-color: #00a32a;
border-width: 1px;
font-weight: bold;
font-size: 12pt;
}

View File

@ -1,353 +1,87 @@
body { #adminmenu,
background: #fff; #wpadminbar,
}
/* Admin Menu */
#adminmenuback,
#adminmenuwrap, #adminmenuwrap,
#adminmenu { #adminmenuback {
margin-top: 12px; background-color: #ffcb04 !important;
background: #f0f0f0;
width: 300px;
} }
#adminmenu { #toplevel_page_limit-login-attempts,
background-color: #ffffff; #wp-admin-bar-llar-root {
border-radius: 10px; display: none;
} }
#adminmenu a { .wp-submenu-wrap,
color: #1d4899 !important; .wp-submenu-head {
font-weight: bold !important; color: #FFFFFF !important;
margin-left: 30px !important;
border-color: #f0f0f0;
} }
.wp-has-submenu,
.wp-not-current-submenu,
.menu-top,
#wpbody { #collapse-button,
background-color: #f0f0f0; #wp-submenu ul,
position: relative; #wp-admin-bar-site-name,
padding-left: 150px; .ab-item
padding-top: 25px;
}
#wpfooter, #wpwrap
{ {
background-color: #f0f0f0; color: #46484d !important;
font-weight: bold !important;
}
.wp-menu-open ,
.wp-has-current-submenu li,
#adminmenu ul
{
background-color: #3163bd !important;
color: #FFFFFF !important;
} }
#wpfooter { .wp-not-current-submenu:hover,
padding-left: 150px; #wpadminbar .ab-item:hover
{
background-color: #3163bd !important;
color: #FFFFFF !important;
} }
#wpbody-content {
.ab-submenu {
background-color: #ffcb04 !important;
}
#wp-admin-bar-updates,
#wp-admin-bar-comments,
#wp-admin-bar-new-content,
#wp-admin-bar-wp-logo
{
display: none;
}
.bdp_submit:hover {
color: #ffffff;
background-color: #3163bd;
cursor: pointer;
border-radius: 5px;
}
.bdp_submit {
background-color: #ffffff; background-color: #ffffff;
width: 95%; padding: 5px 25px;
padding-left: 50px;
box-shadow: 10px 10px 10px #c0c0c0;
border-radius: 10px;
border-width: 1px;
border-style: solid;
border-color: #c0c0c0;
}
#adminmenu div.wp-menu-image:before {
color: rgba(29, 72, 153, 0.75);
}
#adminmenu a:hover,
#adminmenu li.menu-top:hover,
#adminmenu li.opensub > a.menu-top,
#adminmenu li > a.menu-top:focus {
color: #1d4899;
border-color: #f0f0f0;
font-weight: bold;
background: linear-gradient(to right, #efefef, rgba(255, 203, 4, 0.45));
border-radius: 10px;
border-width: 0 !important;
}
#adminmenu li.menu-top:hover div.wp-menu-image:before,
#adminmenu li.opensub > a.menu-top div.wp-menu-image:before {
color: #1d4899;
font-weight: bold;
background: linear-gradient(to right, #efefef, rgba(255, 203, 4, 0.45));
border-radius: 10px;
border-width: 0;
border-color: #f0f0f0;
}
/* Active tabs use a bottom border color that matches the page background color. */
.about-wrap .nav-tab-active,
.nav-tab-active,
.nav-tab-active:hover {
border-style: none;
background-color: #fff;
border-bottom-color: #fff;
}
/* Admin Menu: submenu */
#adminmenu .wp-submenu,
#adminmenu .wp-has-current-submenu .wp-submenu,
#adminmenu .wp-has-current-submenu.opensub .wp-submenu,
.folded #adminmenu .wp-has-current-submenu .wp-submenu,
#adminmenu a.wp-has-current-submenu:focus + .wp-submenu {
background: #ffffff;
width: 300px;
}
#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after {
display: none;
}
#adminmenu .wp-submenu .wp-submenu-head {
color: #ccdbe0;
}
#adminmenu .wp-submenu a,
#adminmenu .wp-has-current-submenu .wp-submenu a,
.folded #adminmenu .wp-has-current-submenu .wp-submenu a,
#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a,
#adminmenu .wp-has-current-submenu.opensub .wp-submenu a {
color: #ccdbe0;
}
#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover,
#adminmenu .wp-has-current-submenu .wp-submenu a:focus,
#adminmenu .wp-has-current-submenu .wp-submenu a:hover,
.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus,
.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover,
#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus,
#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover,
#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus,
#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover {
color: #f0f0f0;
}
/* Admin Menu: current */
#adminmenu .wp-submenu li.current a,
#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a,
#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a {
color: #f2fcff;
}
#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus,
#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover,
#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus,
#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover,
#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus {
color: #e0e0e0;
border-style: none;
}
ul#adminmenu a.wp-has-current-submenu:after,
ul#adminmenu > li.current > a.current:after {
border-right-color: #fff;
display: none;
}
#adminmenu li.current a.menu-top,
#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,
#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head,
.folded #adminmenu li.current.menu-top {
color: #000000;
background: linear-gradient(to right, #efefef, rgba(255, 203, 4, 0.45));
border-radius: 10px;
}
#adminmenu li.wp-has-current-submenu div.wp-menu-image:before,
#adminmenu a.current:hover div.wp-menu-image:before,
#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before,
#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before,
#adminmenu li:hover div.wp-menu-image:before,
#adminmenu li a:focus div.wp-menu-image:before,
#adminmenu li.opensub div.wp-menu-image:before,
.ie8 #adminmenu li.opensub div.wp-menu-image:before {
color: #f2fcff;
}
.wp-menu-open .wp-submenu {
display: block;
}
.wp-menu-open .wp-submenu li {
padding-left: 30px !important;
color: #1d4899 !important;
font-weight: bold;
border-color: #f0f0f0;
}
.wp-submenu {
display: none;
}
/* Admin Menu: bubble */
#adminmenu .awaiting-mod,
#adminmenu .update-plugins {
color: #f2fcff;
background: #aa9d88;
}
#adminmenu li.current a .awaiting-mod,
#adminmenu li a.wp-has-current-submenu .update-plugins,
#adminmenu li:hover a .awaiting-mod,
#adminmenu li.menu-top:hover > a .update-plugins {
#color: #f2fcff;
}
/* Admin Menu: collapse button */
#collapse-button {
display: none;
color: #1d4899;
font-weight: bold;
border-radius: 10px;
border-width: 0;
border-color: #f0f0f0;
}
#collapse-button:hover,
#collapse-button:focus {
color: rgba(255, 203, 4, 0.45);
}
/* Admin Bar */
#wpadminbar {
color: #f2fcff;
background: rgba(29, 72, 153, 0.7);
}
#wpadminbar .ab-item,
#wpadminbar a.ab-item,
#wpadminbar > #wp-toolbar span.ab-label,
#wpadminbar > #wp-toolbar span.noticon {
color: #f2fcff;
}
#wpadminbar .ab-icon,
#wpadminbar .ab-icon:before,
#wpadminbar .ab-item:before,
#wpadminbar .ab-item:after {
color: #f1f3f3;
}
#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item,
#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus,
#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus,
#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item,
#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item {
color: #f2fcff;
background: rgba(29, 72, 153, 0.7);
}
#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label,
#wpadminbar:not(.mobile) > #wp-toolbar li.hover span.ab-label,
#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label {
color: #ffffff;
}
#wpadminbar:not(.mobile) li:hover .ab-icon:before,
#wpadminbar:not(.mobile) li:hover .ab-item:before,
#wpadminbar:not(.mobile) li:hover .ab-item:after,
#wpadminbar:not(.mobile) li:hover #adminbarsearch:before {
color: #f2fcff;
}
/* Admin Bar: submenu */
#wpadminbar .menupop .ab-sub-wrapper {
background: rgba(29, 72, 153, 0.78);
}
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu {
background: #8f9a9e;
}
#wpadminbar .ab-submenu .ab-item,
#wpadminbar .quicklinks .menupop ul li a,
#wpadminbar .quicklinks .menupop.hover ul li a,
#wpadminbar.nojs .quicklinks .menupop:hover ul li a {
color: #ccdbe0;
}
#wpadminbar .quicklinks li .blavatar,
#wpadminbar .menupop .menupop > .ab-item:before {
color: #f1f3f3;
}
#wpadminbar .quicklinks .menupop ul li a:hover,
#wpadminbar .quicklinks .menupop ul li a:focus,
#wpadminbar .quicklinks .menupop ul li a:hover strong,
#wpadminbar .quicklinks .menupop ul li a:focus strong,
#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a,
#wpadminbar .quicklinks .menupop.hover ul li a:hover,
#wpadminbar .quicklinks .menupop.hover ul li a:focus,
#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover,
#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,
#wpadminbar li:hover .ab-icon:before,
#wpadminbar li:hover .ab-item:before,
#wpadminbar li a:focus .ab-icon:before,
#wpadminbar li .ab-item:focus:before,
#wpadminbar li .ab-item:focus .ab-icon:before,
#wpadminbar li.hover .ab-icon:before,
#wpadminbar li.hover .ab-item:before,
#wpadminbar li:hover #adminbarsearch:before,
#wpadminbar li #adminbarsearch.adminbar-focused:before {
color: #ffffff;
}
#wpadminbar .quicklinks li a:hover .blavatar,
#wpadminbar .quicklinks li a:focus .blavatar,
#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar,
#wpadminbar .menupop .menupop > .ab-item:hover:before,
#wpadminbar.mobile .quicklinks .ab-icon:before,
#wpadminbar.mobile .quicklinks .ab-item:before {
color: #ffffff;
}
#wpadminbar.mobile .quicklinks .hover .ab-icon:before,
#wpadminbar.mobile .quicklinks .hover .ab-item:before {
color: #f1f3f3;
}
/* Admin Bar: search */
#wpadminbar #adminbarsearch:before {
color: #f1f3f3;
}
.button {
background: rgba(29, 72, 153, 0.62) !important;
color: #ffffff !important;
border-color: #071e4d;
box-shadow: 5px 5px 10px #d0d0d0;
}
.bdp_setting_box {
width: 100%;
background-color: #ffffff;
padding: 15px;
border-style: solid; border-style: solid;
border-width: 1px; border-width: 1px;
border-top-width: 0 !important; border-color: #769be7;
border-color: #1d94cf;
}
.bdp_setting_box:first-of-type {
border-top-width: 1px !important;
}
.bdp_setting_box label {
cursor: pointer; cursor: pointer;
border-radius: 5px;
box-shadow: 2px 2px 2px #d0d0d0;
} }
.bdp_setting_box label span { #bdp_success {
cursor: pointer; background-color: #ffffff;
width: 10pt; border-color: #c3c4c7;
color: #a0a0a0; border-left-color: #00a32a;
padding: 10px 12px;
margin: 5px 0 15px;
border-width: 1px;
border-style: solid;
border-left-width: 4px;
width: 97%;
} }

View File

@ -2,46 +2,49 @@
/** /**
* Plugin Name: BdP Kompass * Plugin Name: BdP Kompass
* Description: Wordpress-Plugin zur Unterstützung von Stämmen im Bund der Pfadfinderinnen und Pfadfinder e.V. zur optimalen Verwaltung eurer Webseite * Description: Wordpress-Plugin zur Unterstützung von Stämmen im Bund der Pfadfinderinnen und Pfadfinder e.V. zur optimalen Verwaltung eurer Webseite
* Version: 4.2.1 * Version: 4.1.1
* Tags: bdp, utility, helper * Tags: bdp, utility, helper
* Requires at least: 6.0 * Requires at least: 6.0
* Requires PHP: 8.2 * Requires PHP: 8.2
* Author: Thomas Günther * Author: Thomas Günther
* Author URI: https://www.sachsen.pfadfinden.de * Author URI: https://www.sachsen.pfadfinden.de
* Update URI: http://lv-sachsen-main.bdp.mein-verein.online/wordpress/ * Update URI: https://lv-sachsen-main.bdp.mein-verein.online/wordpress/
* Text Domain: bdp-kompass * Text Domain: bdp-kompass
*/ */
use Bdp\Modules\LimitLoginAttempts\Controllers\OptionsPage as OptionsPageAlias;
use Bdp\Modules\Security\Security; use Bdp\Modules\Security\Security;
use Bdp\Modules\Seo\Seo; use Bdp\Modules\Seo\Seo;
require_once dirname(__FILE__) . '/includes/setup.php';
define('BDP_LV_PLUGIN_DIR', ABSPATH . '/wp-content/plugins/bdp-kompass/');
define('BDP_LV_PLUGIN_URL', plugin_dir_url(__FILE__));
define('BDP_LV_PLUGIN_SLUG', 'bdp-kompass');
require_once BDP_LV_PLUGIN_DIR . 'core/fileloader.php';
bdp_create_menu_structure();
function bdp_plugin_install() { function bdp_plugin_install() {
}
function bdp_plugin_init() {
Security::ProhibitBots();
Security::SetPageFilters();
if (null == get_option('kompass_already_installed', null)) {
Seo::setup(); Seo::setup();
Calendar::setup(); Calendar::setup();
Security::setup(); Security::setup();
update_option('kompass_already_installed', true); update_option('kompass_installation', true);
wp_redirect( 'site-health.php?tab=bdp_enhanced_security');
}
} }
add_action('admin_menu', function () { function bdp_plugin_init()
new OptionsPageAlias(); {
}); remove_menu_page('admin.php?page=limit-login-attempts&tab=dashboard');
if (get_option('kompass_installation') == true) {
delete_option('kompass_installation');
wp_redirect('admin.php?page=bdp-kompass%2Fmodules%2Findex.php&loadmodule=firstusage');
}
}
register_activation_hook(__FILE__, 'bdp_plugin_install');
add_action('init', 'bdp_plugin_init');
function register_custom_theme_directory() { function register_custom_theme_directory() {
$file = ABSPATH . '/wp-content/plugins/bdp-kompass/buena/' ; $file = ABSPATH . '/wp-content/plugins/bdp-kompass/buena/' ;
@ -51,12 +54,149 @@ function register_custom_theme_directory() {
switch_theme('buena'); switch_theme('buena');
} }
function enqueue_custom_password_js() {
wp_enqueue_script( 'custom-password-js', BDP_LV_PLUGIN_URL . 'assets/password.js');
wp_localize_script( 'custom-password-js', 'php_vars', [
'allowed_strengths' => kompass_get_minimal_password_strength(),
'password_too_short_text' => 'Dass Passwort entspricht nicht den Anforderungen.'
]);
}
#add_action( 'after_setup_theme', 'register_custom_theme_directory' ); #add_action( 'after_setup_theme', 'register_custom_theme_directory' );
class BdpVersionChecker
{
public $plugin_slug;
public $version;
public $cache_key;
public $cache_allowed;
public $updateUrl;
public function __construct()
{
$plugin_data = get_plugin_data(__FILE__);
$this->plugin_slug = 'bdp-kompass';
$this->updateUrl = $plugin_data['UpdateURI'] . '/info.json';
$this->version = $plugin_data['Version'];
$this->cache_key = 'bdp_kompass_upd';
$this->cache_allowed = true;
add_filter('plugins_api', array($this, 'info'), 20, 3);
add_filter('site_transient_update_plugins', array($this, 'update'));
add_action('upgrader_process_complete', array($this, 'purge'), 10, 2);
}
public function request()
{
$remote = get_transient($this->cache_key);
if (false === $remote || !$this->cache_allowed) {
$remote = wp_remote_get(
$this->updateUrl
,
array(
'timeout' => 10,
'headers' => array(
'Accept' => 'application/json'
)
)
);
if (
is_wp_error($remote)
|| 200 !== wp_remote_retrieve_response_code($remote)
|| empty(wp_remote_retrieve_body($remote))
) {
return false;
}
set_transient($this->cache_key, $remote, 3600);
}
$remote = json_decode(wp_remote_retrieve_body($remote));
return $remote;
}
function info($res = '', $action = '', $args = '')
{
if (!isset($args->slug) || $args->slug !== $this->plugin_slug) {
return $res;
}
// get updates
$remote = $this->request();
if (!$remote) {
return $res;
}
$res = new stdClass();
$res->name = $remote->name;
$res->slug = $remote->slug;
$res->version = $remote->version;
$res->tested = $remote->tested;
$res->requires = $remote->requires;
$res->author = $remote->author;
$res->author_profile = $remote->author_profile;
$res->download_link = $remote->download_url;
$res->trunk = $remote->download_url;
$res->requires_php = $remote->requires_php;
$res->last_updated = $remote->last_updated;
$res->sections = array(
'description' => $remote->sections->description,
'installation' => $remote->sections->installation,
'changelog' => $remote->sections->changelog
);
if (!empty($remote->banners)) {
$res->banners = array(
'low' => $remote->banners->low,
'high' => $remote->banners->high
);
}
return $res;
}
public function update($transient)
{
if (empty($transient->checked)) {
return $transient;
}
$remote = $this->request();
if(
$remote
&& version_compare( $this->version, $remote->version, '<' )
&& version_compare( $remote->requires, get_bloginfo( 'version' ), '<=' )
&& version_compare( $remote->requires_php, PHP_VERSION, '<' )
) {
$res = new stdClass();
$res->slug = $this->plugin_slug;
$res->plugin = plugin_basename( __FILE__ );
$res->new_version = $remote->version;
$res->tested = $remote->tested;
$res->package = $remote->download_url;
$transient->response[ $res->plugin ] = $res;
} else {
$res = new stdClass();
$res->slug = $this->plugin_slug;
$res->plugin = plugin_basename( __FILE__ );
$transient->no_update[ $res->plugin ] = $res;
}
return $transient;
}
public function purge($upgrader, $options)
{
if (
$this->cache_allowed
&& 'update' === $options['action']
&& 'plugin' === $options['type']
) {
delete_transient($this->cache_key);
}
}
}
$class = new BdpVersionChecker();
add_filter( 'plugins_api', array( $class, 'info' ), 20, 3 );

96
buena/404.php Normal file
View File

@ -0,0 +1,96 @@
<!DOCTYPE html>
<!--[if IE 7]>
<html class="ie ie7" <?php language_attributes(); ?>>
<![endif]-->
<!--[if IE 8]>
<html class="ie ie8" <?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 7) | !(IE 8) ]><!-->
<html <?php language_attributes(); ?>>
<!--<![endif]-->
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" href="<?php echo esc_url( get_template_directory_uri() ); ?>/img/favicon.ico" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
<?php wp_head(); ?>
</head>
<!-- FIXME: Mehr ARIA role setzen -->
<body <?php body_class(); ?>>
<div id="wrap"><!-- FIXME: Klassen hfeed, site? -->
<header id="header" role="banner"><!-- FIXME: Klasse site-header? -->
<hgroup id="branding">
<h1 class="site-title">
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php _e( 'Zurück zur Startseite', 'buena-theme' ); ?>">
<img alt="Bund der Pfadfinderinnen und Pfadfinder" src="<?php echo esc_url( get_template_directory_uri() ); ?>/img/bundeszeichen.png" srcset="<?php echo esc_url( get_template_directory_uri() ); ?>/img/bundeszeichen.png 1x, <?php echo esc_url( get_template_directory_uri() ); ?>/img/bundeszeichen@2x.png 2x" width="390" height="79" />
</a>
</h1>
<h2 class="site-description">
<?php echo esc_html( get_bloginfo( 'name', 'display' ) ); ?>
</h2>
</hgroup>
<nav class="screen-reader-text">
<!-- FIXME: Tollere Navigation ausdenken -->
<a href="#content">
<?php _e( 'Zum Inhalt springen', 'buena-theme' ); ?>
</a>
</nav>
<?php do_action( 'buena_search_form' ); ?>
</header>
<div id="left">
<?php wp_nav_menu( [ 'theme_location' => 'primary', 'depth' => 2, 'container' => 'nav', 'container_class' => 'nav-menu' ] ); ?>
<?php if ( is_active_sidebar( 'below-navigation' ) ): ?>
<ul class="widgets">
<?php dynamic_sidebar( 'below-navigation' ); ?>
</ul>
<?php endif; ?>
</div>
<div id="teaser">
<?php if ( is_page() || have_posts() && is_single() ): the_post(); ?>
<?php if ( has_post_thumbnail() ): ?>
<?php the_post_thumbnail( 'poster', [ 'alt' => '' ] ); ?>
<?php else: ?>
<img src="<?php header_image(); ?>" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="" />
<?php endif; ?>
<div id="teaserTitle">
<h2><?php the_title(); ?></h2>
</div>
<?php rewind_posts(); ?>
<?php elseif ( get_header_image() ): ?>
<img src="<?php header_image(); ?>" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="" />
<div id="teaserTitle">
<h2><?php bloginfo( 'description' ); ?></h2>
</div>
<?php endif; ?>
</div>
<div id="main" role="main">
<div id="content">
<?php if ( have_posts() ): ?>
<?php while ( have_posts() ): the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php else: // FIXME: Wenn berechtigt: Erstellen anbieten ?>
<article id="post-0" class="post no-results not-found">
<?php _e( 'Nicht gefunden.', 'buena-theme' ); ?>
</article>
<?php endif; ?>
</div>
<nav class="pagination">
<div class="previous"><?php previous_posts_link( __( '« Neuere Beiträge', 'buena-theme' ) ); ?></div>
<div class="next"><?php next_posts_link( __( 'Ältere Beiträge »', 'buena-theme' ) ); ?></div>
</nav>
<?php comments_template(); ?>
</div>
</div>
<?php if ( is_active_sidebar( 'footer' ) ): ?>
<footer id="footer">
<ul class="widgets">
<?php dynamic_sidebar( 'footer' ); ?>
</ul>
</footer>
<?php endif; ?>
<?php wp_footer(); ?>
</body>
</html>

27
buena/comments.php Normal file
View File

@ -0,0 +1,27 @@
<?php
if ( post_password_required() ) {
printf( '<p class="nocomments">%s</p>', __( 'Kommentare werden erst angezeigt, wenn das Kennwort eingegeben wurde.', 'buena-theme' ) );
return;
}
// FIXME: Hier sollten die Social-Media-Knöpfe auftauchen…
?>
<div class="comments">
<?php if ( have_comments() ) : ?>
<h4 id="comments"><?php comments_number( 'Keine Kommentare', 'Ein Kommentar', '% Kommentare' );?></h4>
<ul class="commentlist">
<?php wp_list_comments(); ?>
</ul>
<nav class="pagination">
<div class="alignleft"><?php previous_comments_link() ?></div>
<div class="alignright"><?php next_comments_link() ?></div>
</nav>
<?php endif; ?>
<?php if ( comments_open() ) : ?>
<?php comment_form(); ?>
<?php else: ?>
<p class="nocomments screen-reader-text"><?php _e( 'Es kann nicht kommentiert werden.', 'buena-theme' ); ?></p>
<?php endif; ?>
</div>

17
buena/content.php Normal file
View File

@ -0,0 +1,17 @@
<article id="post-<?php the_ID(); ?>" <?php post_class( 'clearfix' ); ?>>
<?php if ( is_singular() ): ?>
<?php the_content(); ?>
<p><?php the_tags(); ?></p>
<?php wp_link_pages( array( 'before' => '<nav class="page-links">Seiten:', 'after' => '</nav>' ) ); ?>
<?php else: ?>
<a class="h h-box h-box-blaugelb<?php if ( ! has_post_thumbnail() ): ?> h-box-blaugelb-bildlos<?php endif; ?>" href="<?php echo esc_url( get_permalink() ); ?>">
<?php the_post_thumbnail( 'gallery-thumb', [ 'alt' => '' ] ); ?>
<?php if ( get_the_title() ): ?>
<header class="wrap">
<h3><?php the_title(); ?></h3>
</header>
<?php endif; ?>
</a>
<?php has_excerpt() ? the_excerpt() : the_content(); ?>
<?php endif; ?>
</article>

89
buena/functions.php Normal file
View File

@ -0,0 +1,89 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( 'Im a theme.' );
}
if ( ! function_exists( 'trigger_pfadfinden_plugin_error' ) ) {
/**
* Show an error message.
*
* @see http://www.squarepenguin.com/wordpress/?p=6 Inspiration
*
* @param string $message
* @param int $type optional
* @return bool
*/
function trigger_pfadfinden_plugin_error( $message, $type = 0 )
{
if ( isset( $_GET['action'] ) && 'error_scrape' === $_GET['action'] ) {
echo $message;
return true;
}
if ( ! $type ) {
$type = E_USER_WARNING;
}
return trigger_error( $message, $type );
}
}
// Check for suitable environment
if ( defined( 'PHP_VERSION_ID' ) && PHP_VERSION_ID >= 50400 ) {
// Register autoloader if updater plugin missing
if ( ! class_exists( 'plugins\buena\use\shy-wordpress\src\Shy\WordPress\Theme' ) ) {
if ( ! include_once __DIR__ . '/use/shy-wordpress/src/autoloader.php' ) {
trigger_pfadfinden_plugin_error(
__( 'Das Theme ist unvollständig und konnte nicht geladen werden. Neuinstallation müsste helfen.', 'buena-theme' ),
E_USER_ERROR
);
return;
}
}
// Register our autoloader
if ( ! include_once __DIR__ . '/src/autoloader.php' ) {
trigger_pfadfinden_plugin_error(
__( 'Das Theme ist unvollständig und konnte nicht geladen werden. Neuinstallation müsste helfen.', 'buena-theme' ),
E_USER_ERROR
);
return;
}
/**
* @return \plugins\buena\src\Pfadfinden\WordPress\BuenaTheme
*/
function buena_get_theme()
{
static $theme = null;
if (!$theme) {
$theme = new ReflectionClass( 'plugins\buena\src\Pfadfinden\WordPress\BuenaTheme' );
$theme = $theme->newInstance();
}
return $theme;
}
/**
* @param string $method
* @return callable
*/
function buena_get_callback( $method )
{
return array( buena_get_theme(), (string) $method );
}
return buena_get_theme();
}
// Display error message
trigger_pfadfinden_plugin_error(
sprintf(
__( 'You need at least PHP 5.4 to use the Buena theme. Your are using %s.', 'buena-theme' ),
PHP_VERSION
),
E_USER_ERROR
);

106
buena/index.php Normal file
View File

@ -0,0 +1,106 @@
<!DOCTYPE html>
<!--[if IE 7]>
<html class="ie ie7" <?php language_attributes(); ?>>
<![endif]-->
<!--[if IE 8]>
<html class="ie ie8" <?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 7) | !(IE 8) ]><!-->
<html <?php language_attributes(); ?>>
<!--<![endif]-->
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<?php if ( ! function_exists( 'has_site_icon' ) || ! has_site_icon() ): // FIXME: Remove workaround on 2016-02-16 ?>
<link rel="shortcut icon" href="<?php echo esc_url( get_template_directory_uri() ); ?>/img/favicon.ico" />
<?php endif; ?>
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
<?php wp_head(); ?>
</head>
<!-- FIXME: Mehr ARIA role setzen -->
<body <?php body_class(); ?>>
<div id="wrap"><!-- FIXME: Klassen hfeed, site? -->
<header id="header" role="banner"><!-- FIXME: Klasse site-header? -->
<hgroup id="branding">
<h1 class="site-title">
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php _e( 'Zurück zur Startseite', 'buena-theme' ); ?>">
<img alt="Bund der Pfadfinderinnen und Pfadfinder" src="<?php echo esc_url( get_template_directory_uri() ); ?>/img/bundeszeichen.png" srcset="<?php echo esc_url( get_template_directory_uri() ); ?>/img/bundeszeichen.png 1x, <?php echo esc_url( get_template_directory_uri() ); ?>/img/bundeszeichen@2x.png 2x" width="390" height="79" />
</a>
</h1>
<h2 class="site-description">
<?php echo esc_html( get_bloginfo( 'name', 'display' ) ); ?>
</h2>
</hgroup>
<nav>
<!-- FIXME: Tollere Navigation ausdenken -->
<a href="#content" class="screen-reader-text"><?php _e( 'Zum Inhalt springen', 'buena-theme' ); ?></a>
<button type="button" id="responsiveMenu" title="<?php esc_attr_e( 'Menü', 'buena-theme' ); ?>">
<img alt="<?php esc_attr_e( 'Menü', 'buena-theme' ); ?>" src="<?php echo esc_url( get_template_directory_uri() ); ?>/img/hamburger.png" width="32" height="32" />
</button>
</nav>
<?php do_action( 'buena_search_form' ); ?>
</header>
<div id="left">
<?php wp_nav_menu( [ 'theme_location' => 'primary', 'depth' => 2, 'container' => 'nav', 'container_class' => 'nav-menu nav-menu-primary' ] ); ?>
<?php if ( is_active_sidebar( 'below-navigation' ) ): ?>
<ul class="widgets">
<?php dynamic_sidebar( 'below-navigation' ); ?>
</ul>
<?php endif; ?>
</div>
<?php if ( $buenaTeaserImage = buena_get_theme()->getTeaserImage() ): ?>
<header class="h h-box h-box-teaser">
<?php echo $buenaTeaserImage; ?>
<hgroup class="wrap">
<h2><?php buena_get_theme()->printTitle(); ?></h2>
</hgroup>
</header>
<?php else: ?>
<header class="h">
<h2><?php buena_get_theme()->printTitle(); ?></h2>
</header>
<?php endif; ?>
<div id="main" role="main" class="container">
<div id="content" class="content-<?php if ( is_singular() ): ?>singular<?php else: ?>gallery<?php endif; ?>">
<?php if ( have_posts() ): ?>
<?php while ( have_posts() ): the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php else: // FIXME: Wenn berechtigt: Erstellen anbieten ?>
<article id="post-0" class="post no-results not-found">
<?php _e( 'Nicht gefunden.', 'buena-theme' ); ?>
</article>
<?php endif; ?>
</div>
<nav class="pagination">
<div class="alignright"><?php next_posts_link( __( 'Ältere Beiträge »', 'buena-theme' ) ); ?></div>
<div class="alignleft"><?php previous_posts_link( __( '« Neuere Beiträge', 'buena-theme' ) ); ?></div>
</nav>
<?php comments_template(); ?>
</div>
</div>
<footer id="footer">
<div class="wrapper media">
<?php if ( is_active_sidebar( 'footer' ) || has_nav_menu( 'footer' ) ): ?>
<header class="h">
<?php echo esc_html( get_bloginfo( 'name', 'display' ) ?: 'Bund der Pfadfinderinnen und Pfadfinder e.V.' ); ?>
</header>
<?php wp_nav_menu( [ 'theme_location' => 'footer', 'container' => 'nav', 'container_class' => 'nav-menu nav-menu-footer alignleft', 'fallback_cb' => '' ] ); ?>
<ul class="widgets bd">
<?php dynamic_sidebar( 'footer' ); ?>
</ul>
<?php endif; ?>
</div>
</footer>
<script>
+function() {
document.getElementById('responsiveMenu').addEventListener('click', function() {
document.body.classList.toggle('show-responsive-menu');
});
}();
</script>
<?php wp_footer(); ?>
</body>
</html>

11
buena/searchform.php Normal file
View File

@ -0,0 +1,11 @@
<form role="search" method="get" class="search-form" action="<?php echo home_url( '/' ); ?>">
<label>
<span class="screen-reader-text"><?php echo _x( 'Search for:', 'label' ); ?></span>
<?php if ( doing_action( 'buena_search_form' ) ): ?>
<input type="search" class="search-field" value="<?php echo get_search_query(); ?>" name="s" title="<?php echo esc_attr_x( 'Search for:', 'label' ); ?>" />
<?php else: ?>
<input type="search" class="search-field" placeholder="<?php echo esc_attr_x( 'Search …', 'placeholder' ); ?>" value="<?php echo get_search_query(); ?>" name="s" title="<?php echo esc_attr_x( 'Search for:', 'label' ); ?>" />
<?php endif; ?>
</label>
<button type="submit" class="search-submit" title="<?php esc_attr_e( 'Query search', 'buena-theme' ); ?>"><?php echo esc_html_x( 'Search', 'submit button' ); ?></button>
</form>

19
buena/src/autoloader.php Normal file
View File

@ -0,0 +1,19 @@
<?php
/**
* Try to load a Pfadfinden WordPress class.
*
* @param string $name
* @return bool
*/
function buena_autoloader( $name )
{
if ( substr( $name, 0, 21 ) !== 'Pfadfinden\\WordPress\\' ) {
return false;
}
$name = __DIR__ . '/' . str_replace( '\\', DIRECTORY_SEPARATOR, $name ) . '.php';
return is_file( $name ) && include( $name );
}
spl_autoload_register( 'buena_autoloader' );

View File

@ -0,0 +1,98 @@
<?php
namespace plugins\buena\use\shy-wordpress\src\Shy\WordPress;
use plugins\buena\use\shy/**
* A composite option with a fixed number of suboptions and their default values.
*/
abstract class CompositeOption implements \ArrayAccess, \Countable, \IteratorAggregate
{
use HookableTrait;
/**
* @var string
*/
protected $slug;
/**
* @return string
*/
public function getSlug()
{
return $this->slug;
}
protected function __construct( $slug )
{
$this->slug = (string) $slug;
$this->addHookMethod( 'default_option_' . $this->slug, 'getDefaults' );
}
/**
* Return default values for all suboptions.
* Hooked into get_option() defaults.
*
* @return array
*/
abstract public function getDefaults();
/**
* @param string $offset
* @return mixed
*/
public function getDefault( $offset )
{
return $this->getDefaults()[ $offset ];
}
public function offsetExists( $offset )
{
$settings = get_option( $this->slug );
return isset( $settings[ $offset ] );
}
public function offsetGet( $offset )
{
$settings = get_option( $this->slug );
if ( ! isset( $settings[ $offset ] ) ) {
throw new \OutOfBoundsException( "There is no setting '$offset'." );
}
return $settings[ $offset ];
}
public function offsetSet( $offset, $value )
{
$settings = get_option( $this->slug );
if ( ! isset( $settings[ $offset ] ) ) {
throw new \OutOfBoundsException( "There is no setting '$offset'." );
}
$settings[ $offset ] = $value;
update_option( $this->slug, $settings );
}
public function offsetUnset( $offset )
{
throw new \BadMethodCallException( 'You cannot unset settings.' );
}
public function count()
{
return count( $this->getDefaults() );
}
public function getIterator()
{
return new \ArrayIterator( get_option( $this->slug ) );
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace plugins\buena\use\shy-wordpress\src\Shy\WordPress;
/**
* Making actions and filters how they should be.
*
* Default to pass all arguments.
*/
trait HookableTrait
{
/**
* @param string $action_or_filter
* @param string $method
* @param int $priority
* @param int $acceptedArgs
*/
protected function addHookMethod( $action_or_filter, $method, $priority = 10, $acceptedArgs = 99 )
{
add_filter( $action_or_filter, array( $this, $method ), $priority, $acceptedArgs );
}
/**
* @param string $action_or_filter
* @param string $method
* @param int $priority
* @param int $acceptedArgs
*/
protected function removeHookMethod( $action_or_filter, $method, $priority = 10, $acceptedArgs = 99 )
{
remove_filter( $action_or_filter, array( $this, $method ), $priority, $acceptedArgs );
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace plugins\buena\use\shy-wordpress\src\Shy\WordPress;
use plugins\buena\use\shy/**
* Marker class for WordPress plugins.
*/
abstract class Plugin
{
use HookableTrait;
}

View File

@ -0,0 +1,383 @@
<?php
namespace plugins\buena\use\shy-wordpress\src\Shy\WordPress;
use plugins\buena\use\shyuse plugins\buena\use\shy/**
* Abstracts common functionality and escaping for the Settings API.
*
* TODO: Check slug and field names for illegal characters.
* TODO: Refactor to not extend but use CompositeOption
*/
abstract class SettingsPage extends CompositeOption
{
use HookableTrait;
/**
* @var string
*/
protected $capability;
/**
* Slug (file name) of the parent menu entry.
*
* @see add_submenu_page() for suggestions.
*
* @return string|null
*/
protected function getParentSlug()
{
return 'options-general.php';
}
/**
* Title for this setting page.
*
* @return string
*/
abstract protected function getPageTitle();
/**
* String to show in the menu entry.
*
* @return string
*/
protected function getMenuTitle()
{
return $this->getPageTitle();
}
/**
* @param string $slug Page slug
* @param string $capability Required capability to view
*/
protected function __construct( $slug, $capability = 'manage_options' )
{
parent::__construct( $slug );
$this->capability = (string) $capability;
$this->addHookMethod( 'admin_menu', 'registerPage' );
$this->addHookMethod( 'admin_init', 'registerSettings' );
}
public function __toString()
{
return $this->slug;
}
/**
* Register our options page.
*
* @return void
*/
public function registerPage()
{
add_submenu_page(
$this->getParentSlug(),
$this->getPageTitle(),
$this->getMenuTitle(),
$this->capability,
$this->slug,
array( $this, 'renderPage' )
);
}
/**
* Register the actual settings.
* Override and use addSection() and add*Field() methods.
*
* @return void
*/
public function registerSettings()
{
register_setting(
$this->slug,
$this->slug,
array( $this, 'sanitizeOptions' )
);
}
/**
* Sanitize option values after form submission.
*
* @param array $options
* @return array
*/
abstract public function sanitizeOptions( array $options );
/**
* Section to add fields to.
*
* Parameter default from add_settings_field().
*
* @var string
*/
protected $currentSection = 'default';
/**
* Add a new section and return its generated name.
*
* @param string $title optional, can be empty
* @param string $name optional, will be generated if empty
* @return string
*/
protected function addSection( $title = '', $name = '' )
{
$name = (string) $name;
if ( ! strlen( $name ) ) {
$name = $this->slug . '-section' . ( count( $this->getSections() ) + 1 );
}
add_settings_section(
$name,
esc_html( $title ),
array( $this, 'renderSectionTeaser' ),
$this->slug
);
return $this->currentSection = $name;
}
/**
* Callback before output of section fields.
*
* Teasers must escape their output themselves.
*
* @param array $section {
* @type string $id
* @type string $title
* @type callable $callback
* }
*/
public function renderSectionTeaser( array $section )
{
}
/**
* Get all known section names on this page.
*
* @global $wp_settings_fields
* @return array<string>
*/
public function getSections()
{
global $wp_settings_fields;
if ( ! isset( $wp_settings_fields[ $this->slug ] ) ) {
return array();
}
return array_keys( $wp_settings_fields[ $this->slug ] );
}
/**
* @global $wp_settings_fields
* @param string $section
* @return array<string, array {
* @type string $id
* @type string $title
* @type callable $callback
* @type array $args
* }>
*/
public function getFieldsForSection( $section )
{
global $wp_settings_fields;
return $wp_settings_fields[ $this->slug ][ $section ];
}
/**
* Add a custom field to this setting page.
*
* @param string $name
* @param string $label
* @param callable $callback
* @param array $args
*/
protected function addField( $name, $label, $callback, $args = array() )
{
if ( ! is_callable( $callback ) ) {
throw new \InvalidArgumentException( 'Parameter $callback must be callable.' );
}
add_settings_field(
$name,
esc_html( $label ),
$callback,
$this->slug,
$this->currentSection,
$args
);
}
/**
* Add a text field to this settings page.
*
* @param string $name
* @param string $label
* @param array $args
* @param string $callback
*/
protected function addTextField( $name, $label, $args = array(), $callback = '' )
{
if ( ! $callback || ! is_callable( $callback ) ) {
$callback = array( $this, 'renderTextField' );
}
$this->addField(
$name,
$label,
$callback,
$args + array(
'label_for' => $this->slug . '-' . $name,
'name' => $name,
'attr' => array(),
)
);
}
/**
* @param string $name
* @param string $label
* @param string $caption
* @param array $args
* @param callable $callback
*/
protected function addCheckboxField( $name, $label, $caption, $args = array(), $callback = '' )
{
if ( ! $callback || ! is_callable( $callback ) ) {
$callback = array( $this, 'renderCheckboxField' );
}
$this->addField(
$name,
$label,
$callback,
$args + array(
'label_for' => $this->slug . '-' . $name,
'name' => $name,
'caption' => $caption,
'attr' => array(),
)
);
}
/**
* Add an error.
*
* @param string $code
* @param string $message
*/
protected function addError( $code, $message )
{
add_settings_error( $this->slug, $code, $message );
}
/**
* Errors for this setting.
*
* @return array {
* @type string $setting
* @type string $code
* @type string $message
* @type string $type 'error'
* }
*/
public function getErrors()
{
return get_settings_errors( $this->slug );
}
/**
* Render a setting as text field.
*
* @param array $args {
* @type string $name
* @type string $label_for
* @type array $attr
* }
*/
public function renderTextField( array $args )
{
$name = $args['name'];
$this->renderInputTag( array(
'type' => 'text',
'id' => $args['label_for'],
'class' => 'regular-text',
'name' => $this->slug . '[' . $name . ']',
'value' => $this[ $name ],
) + $args['attr'] );
}
/**
* Render a setting as checkbox.
*
* @param array $args {
* @type string $caption
* @type string $name
* @type string $label_for
* @type array $attr
* }
*/
public function renderCheckboxField( array $args )
{
$name = $args['name'];
echo '<label>';
$this->renderInputTag( array(
'type' => 'checkbox',
'id' => isset( $args['label_for'] ) ? $args['label_for'] : null,
'name' => $this->slug . '[' . $name . ']',
'value' => '1',
'checked' => $this[ $name ] ? 'checked' : null,
) + $args['attr'] );
echo ' ' . esc_html( $args['caption'] ) . '</label>';
}
/**
* Output an input tag with given HTML attributes.
*
* @param array $attr
*/
protected function renderInputTag( array $attr )
{
echo '<input';
foreach ( $attr as $k => $v ) {
if ( null !== $v ) {
printf( ' %s="%s"', $k, esc_attr( $v ) );
}
}
echo ' />';
}
/**
* Output settings page.
*/
public function renderPage()
{
if ( ! current_user_can( $this->capability ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
?>
<div class="wrap">
<h2><?php echo esc_html( $this->getPageTitle() ); ?></h2>
<form action="options.php" method="post">
<?php settings_errors( 'general' ); // “Settings saved.” message ?>
<?php settings_fields( $this->slug ); ?>
<?php do_settings_sections( $this->slug ); ?>
<?php submit_button(); ?>
</form>
</div>
<?php
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace plugins\buena\use\shy-wordpress\src\Shy\WordPress;
use plugins\buena\use\shyabstract class Theme extends Plugin
{
public function __construct()
{
$GLOBALS['content_width'] = $this->getContentWidth();
}
/**
* @return integer
*/
abstract public function getContentWidth();
}

View File

@ -0,0 +1,20 @@
<?php
/**
* Try to load a Shy WordPress class.
*
* @param string $name
* @return boolean
*/
function shy_wordpress_autoloader( $name )
{
if ( substr( $name, 0, 14 ) !== 'Shy\\WordPress\\' ) {
return false;
}
$name = __DIR__ . '/' . str_replace( '\\', DIRECTORY_SEPARATOR, $name ) . '.php';
return is_file( $name ) && include( $name );
}
spl_autoload_register( 'shy_wordpress_autoloader' );

View File

@ -0,0 +1,40 @@
<?php
namespace plugins\buena\use\shy-wordpress\tests\Shy\WordPress\Tests;
use wordpress\src\Shy\WordPress\HookableTrait;
/**
* Check that HookableTrait actually works.
*
* @author Philipp Cordes <pc@irgendware.net>
*/
class HookableTraitTest extends \WP_UnitTestCase
{
use HookableTrait;
public function actionMethod()
{
}
public function testWorksAsAction()
{
$this->addHookMethod( 'shywp_test_action', 'actionMethod' );
$this->assertTrue( has_action( 'shywp_test_action' ), 'Registering an action via addHookMethod() worked.' );
}
public function filterMethod( $value )
{
return $value;
}
public function testWorksAsFilter()
{
$this->addHookMethod( 'shywp_test_filter', 'filterMethod' );
$this->assertTrue( has_filter( 'shywp_test_filter' ), 'Registering a filter via addHookMethod() worked.' );
}
}

View File

@ -0,0 +1,181 @@
<?php
namespace plugins\buena\use\shy-wordpress\tests\Shy\WordPress\Tests;
use wordpress\src\Shy\WordPress\SettingsPage;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use PHPUnit_Framework_MockObject_Builder_InvocationMocker as BuilderInvocationMocker;
class SettingsPageTest extends \WP_UnitTestCase
{
/**
* Mock a SettingsPage.
*
* @param string|null $slug
* @param string $capability
*
* @return wordpress\src\Shy\WordPress\SettingsPage|MockObject {
* @method BuilderInvocationMocker method(string)
* }
*/
protected function mockSettingsPage( $slug = null, $capability = 'manage_options' )
{
$builder = $this->getMockBuilder( 'plugins\buena\use\shy-wordpress\src\Shy\WordPress\SettingsPage' )
->enableProxyingToOriginalMethods();
if ( null === $slug ) {
$builder->disableOriginalConstructor();
} else {
$builder->setConstructorArgs( array( $slug, $capability ) );
}
return $builder->getMock();
}
/**
* Test reading defaults from the settings page.
*
* @covers wordpress\src\Shy\WordPress\SettingsPage::__construct()
* @covers wordpress\src\Shy\WordPress\SettingsPage::getDefaults()
* @covers wordpress\src\Shy\WordPress\SettingsPage::offsetExists()
* @covers wordpress\src\Shy\WordPress\SettingsPage::offsetGet()
* @expectedException OutOfBoundsException
*/
public function testReading()
{
$slug = 'shywp_settingspage_test_slug_reading';
$defaults = array( 'foo' => 'bar' );
$page = $this->mockSettingsPage( $slug );
$page->method( 'getDefaults' )->willReturn( $defaults );
$this->assertEquals( $defaults, get_option( $slug ) );
$this->assertArrayHasKey( 'foo', $page );
$this->assertEquals( $defaults['foo'], $page['foo'] );
$this->assertArrayNotHasKey( 'baz', $page );
$page['baz'];
}
/**
* Test writing to the settings page.
*
* @covers wordpress\src\Shy\WordPress\SettingsPage::offsetSet()
* @expectedException OutOfBoundsException
*/
public function testWriting()
{
$slug = 'shywp_settingspage_test_slug_writing';
$defaults = array( 'foo' => 'bar' );
$page = $this->mockSettingsPage( $slug );
$page->method( 'getDefaults' )->willReturn( $defaults );
$page['foo'] = 'foo';
$this->assertEquals( 'foo', $page['foo'] );
$page['baz'] = '123';
}
/**
* Fail to remove a setting.
*
* @covers SettingPage::offsetUnset()
* @expectedException BadMethodCallException
*/
public function testRemoving()
{
$slug = 'shywp_settingspage_test_slug_removing';
$defaults = array();
$page = $this->mockSettingsPage( $slug );
$page->method( 'getDefaults' )->willReturn( $defaults );
unset( $page['baz'] );
}
/**
* Test whether the settings page can be showed.
*
* @covers wordpress\src\Shy\WordPress\SettingsPage::__construct()
* @covers wordpress\src\Shy\WordPress\SettingsPage::getParentSlug()
* @covers wordpress\src\Shy\WordPress\SettingsPage::getPageTitle()
* @covers wordpress\src\Shy\WordPress\SettingsPage::getMenuTitle()
*/
public function testRegisterPage()
{
$this->expectOutputRegex( '/&lt;page&amp;title&gt;/' );
$slug = 'shywp_settingspage_test_slug_registerpage';
$page = $this->mockSettingsPage( $slug );
$page->method( 'getParentSlug' )->willReturn( 'index.php' );
$page->method( 'getPageTitle' )->willReturn( '<page&title>' );
$page->method( 'getMenuTitle' )->willReturn( '<menu&title>' );
$page->expects( $this->once() )->method( 'registerPage' )->with();
$page->expects( $this->once() )->method( 'registerSettings' )->with();
// FIXME: Simulate display of backend.
}
/**
* @covers wordpress\src\Shy\WordPress\SettingsPage::sanitizeOptions()
*/
public function testSanitize()
{
$slug = 'shywp_settingspage_test_slug_sanitize';
$page = $this->mockSettingsPage( $slug );
$page->method( 'sanitizeOptions' )->will( $this->returnArgument( 0 ) );
$page->expects( $this->atLeastOnce() )->method( 'sanitizeOptions' );
$this->markTestIncomplete();
// FIXME: Simulate form submission
}
public function testRenderTextField()
{
$this->expectOutputRegex( '/^<input type="text"/' );
$page = $this->mockSettingsPage();
$page->renderTextField( array(
'label_for' => 'foo',
'name' => 'bar',
) );
}
public function testRenderCheckboxField()
{
$this->expectOutputRegex( '/^<label><input type="checkbox"/' );
$page = $this->mockSettingsPage();
$page->renderCheckboxField( array(
'label_for' => 'foo',
'name' => 'bar',
'caption' => 'baz',
) );
}
public function testRenderPage()
{
$this->markTestIncomplete();
$this->expectOutputRegex( '/<form action="options.php" method="post">.*&lt;3&amp;&gt;.*cryptic_teaser.*</form>/' );
$slug = 'shywp_settingspage_test_slug_renderpage';
$page = $this->mockSettingsPage( $slug, 'read' );
$page->method( 'getPageTitle' )->willReturn( '<3&>' );
$page->method( 'renderSectionTeaser' )->will( $this->returnCallback( function () use ( $teaser ) {
echo 'cryptic_teaser';
} ) );
// FIXME: Simulate view of the settings page
$page->renderPage();
}
}

View File

@ -0,0 +1,20 @@
<?php
/**
* Try to load a Shy WordPress test class.
*
* @param string $name
* @return boolean
*/
function shy_wordpress_tests_autoloader( $name )
{
if ( substr( $name, 0, 20 ) !== 'Shy\\WordPress\\Tests\\' ) {
return false;
}
$name = __DIR__ . '/' . str_replace( '\\', DIRECTORY_SEPARATOR, $name ) . '.php';
return is_file( $name ) && include( $name );
}
spl_autoload_register( 'shy_wordpress_tests_autoloader' );

View File

@ -0,0 +1,14 @@
<?php
/**
* PHPUnit bootstrap file
*
* Variant of the one from github.com/tierra/wordpress-plugins-tests
*/
require_once '../src/autoloader.php';
require_once 'autoloader.php';
require_once ( getenv( 'WP_DEVELOP_DIR' ) ?: '../../../..' )
. '/tests/phpunit/includes/bootstrap.php';

0
core/VersionChecker.php Normal file
View File

14
core/fileloader.php Normal file
View File

@ -0,0 +1,14 @@
<?php
require_once (ABSPATH . '/wp-admin/includes/plugin.php');
require_once (ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php');
require_once (ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php');
require_once (BDP_LV_PLUGIN_DIR . '/lib/ics-parser/Event.php');
require_once (BDP_LV_PLUGIN_DIR . '/lib/ics-parser/ICal.php');
require_once (BDP_LV_PLUGIN_DIR . '/modules/seo/seo.php');
require_once (BDP_LV_PLUGIN_DIR . '/modules/calendar/calendar.php');
require_once (ABSPATH . '/wp-includes/pluggable.php');
require_once (BDP_LV_PLUGIN_DIR . '/core/frontend-functions.php');
require_once (BDP_LV_PLUGIN_DIR . '/modules/security/security.php');

0
core/filters.php Normal file
View File

View File

@ -16,13 +16,25 @@ function bdp_update_dashboard_style() {
function bdp_add_menu_security() { function bdp_add_menu_security() {
$moduleLoad = get_admin_url() . 'admin.php?page=' . BDP_LV_PLUGIN_SLUG . '/modules/index.php&loadmodule='; $moduleLoad = get_admin_url() . 'admin.php?page=' . BDP_LV_PLUGIN_SLUG . '/modules/index.php&loadmodule=';
add_menu_page(
'Sicherheit',
'Erweiterte<br />Sicherheit',
'manage_options',
'site-health.php',
'',
'dashicons-admin-network',
5
);
https://wordpress.local.development.contelli.de/wp-admin/admin.php?page=limit-login-attempts
add_submenu_page('site-health.php',
'Login-Kontrolle',
'Login-Kontrolle',
'manage_options',
get_admin_url() . 'admin.php?page=limit-login-attempts'
);
} }
function bdp_add_menu_contents() { function bdp_add_menu_contents() {
@ -65,7 +77,7 @@ function bdp_add_menu_mein_lv() {
$moduleLoad = get_admin_url() . 'admin.php?page=' . BDP_LV_PLUGIN_SLUG . '/modules/index.php&loadmodule='; $moduleLoad = get_admin_url() . 'admin.php?page=' . BDP_LV_PLUGIN_SLUG . '/modules/index.php&loadmodule=';
add_menu_page( add_menu_page(
'Mein BdP', 'Mein BDP',
'BdP', 'BdP',
'manage_options', 'manage_options',
$mainSlug, $mainSlug,
@ -109,7 +121,7 @@ function bdp_add_menu_setup() {
add_submenu_page('users.php', add_submenu_page('users.php',
'Design-Einstellungen', 'Design-Einstellungen',
'Template bearbeiten', 'Design',
'manage_options', 'manage_options',
'customize.php?return=/wp-admin/' 'customize.php?return=/wp-admin/'
); );
@ -128,22 +140,6 @@ function bdp_add_menu_setup() {
'manage_options', 'manage_options',
'themes.php' 'themes.php'
); );
add_submenu_page('users.php',
'Sicherheit',
'Webseiten-Sicherheit',
'manage_options',
'site-health.php'
);
$loginOption = new \Bdp\Modules\LimitLoginAttempts\Controllers\OptionsPage();
add_submenu_page('users.php',
'Login-Sicherheit',
'Login-Sicherheit',
'manage_options',
BDP_LV_PLUGIN_SLUG . '-limit-login-attempts',
[$loginOption, 'limit_login_option_page']
);
} }
function bdp_cleanup_menu() function bdp_cleanup_menu()

View File

@ -1,56 +0,0 @@
<?php
declare(strict_types=1);
namespace Bdp\Libs;
class FileAccess extends \WP_Filesystem_Direct
{
public const HTACCESS_MAIN = '/.htaccess';
public const HTACCESS_UPLOADS = '/wp-content/uploads/.htaccess';
public function __construct( $arg = null )
{
if ( ! defined( 'FS_CHMOD_FILE' ) ) {
define( 'FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) );
}
}
public static function htaccessContains(string $needle, $file = self::HTACCESS_MAIN) : bool
{
return str_contains(FileAccess::readHtaccess($file), $needle);
}
public static function readHtaccess($file = self::HTACCESS_MAIN) : string
{
$wfs = new self();
if (!$wfs->exists(ABSPATH . $file)) {
return '';
}
return $wfs->get_contents(ABSPATH . $file);
}
public static function writeHtaccess(string $value, $file = self::HTACCESS_MAIN) : bool
{
$wfs = new self();
$wfs->put_contents(ABSPATH . $file, $value);
return true;
}
public static function insertInHtaccess(string $element, $file = self::HTACCESS_MAIN) : bool
{
if (FileAccess::htaccessContains($element, $file)) {
return true;
}
$htaccessFile = FileAccess::readHtaccess($file);
$htaccessFile .= PHP_EOL . $element . PHP_EOL;
FileAccess::writeHtaccess($htaccessFile, $file);
return true;
}
public static function deleteFromHtaccess(string $element, $file = self::HTACCESS_MAIN) : bool {
$htaccessFile = str_replace($element . PHP_EOL, '', FileAccess::readHtaccess($file));
return FileAccess::writeHtaccess($htaccessFile, $file);
}
}

View File

@ -1,82 +0,0 @@
<?php
declare(strict_types=1);
namespace Bdp\Libs;
class WpConfigEditor extends \WP_Filesystem_Direct
{
public const WP_CONFIG_FILE = '/wp-config.php';
public function __construct($arg = null)
{
if (!defined('FS_CHMOD_FILE')) {
define('FS_CHMOD_FILE', (fileperms(ABSPATH . 'index.php') & 0777 | 0644));
}
}
public function readConfig(): string
{
if (!$this->exists(ABSPATH . self::WP_CONFIG_FILE)) {
return '';
}
return $this->get_contents(ABSPATH . self::WP_CONFIG_FILE);
}
public function writeConfig($value): bool
{
$this->put_contents(ABSPATH . self::WP_CONFIG_FILE, $value);
return true;
}
public static function updateConfig($key, $value): bool
{
$wfs = new self();
$configContent = $wfs->readConfig();
if (null === self::getConfigValue($key)) {
$configContent .= "define( '$key', $value );";
}
preg_match("/define\([ ]?'($key)'\,[ ]?(.*)[ ]?\);/",$configContent, $matches);
$configContent = str_replace($matches[0], "define( '$key', $value );", $configContent);
return $wfs->writeConfig($configContent);
}
public static function getConfigValue($key): ?string
{
$wfs = new self();
$configContent = $wfs->readConfig();
preg_match("/define\([ ]?'($key)'\,[ ]?(.*)[ ]?\);/",$configContent, $matches);
if (count($matches) == 0) {
return null;
}
return trim($matches[2]);
}
public static function updateSiteKeys(string $newKeySet)
{
foreach (explode(PHP_EOL, trim($newKeySet)) as $currentKeyLine) {
preg_match("/define\([ ]?'(.*)'\,[ ]?(.*)[ ]?\);/", $currentKeyLine, $matches);
self::updateConfig($matches[1], trim($matches[2]));
}
return true;
}
public static function deleteConfigKey($key): bool
{
if (null === self::getConfigValue($key)) {
return true;
}
$wfs = new self();
$configContent = $wfs->readConfig();
preg_match("/define\([ ]?'($key)'\,[ ]?(.*)[ ]?\);/",$configContent, $matches);
$configContent = str_replace($matches[0], '', $configContent);
return $wfs->writeConfig($configContent);
}
}

View File

@ -1,23 +0,0 @@
<?php
if (!isset($loginHandler)) {
$loginHandler = new \Bdp\Modules\LimitLoginAttempts\Controllers\LoginHandler();
}
add_action('wp_login_failed', [$loginHandler, 'onFailedLogin']);
add_filter('wp_authenticate_user', [$loginHandler, 'onSuccessFullLogin'], 99999, 2);
add_filter( 'admin_enqueue_scripts', 'enqueue_custom_password_js',10 );
add_action('admin_init', 'admin_init');
if (get_option('kompass_cookies', false)) {
$loginHandler->handleCookies();
add_action('auth_cookie_bad_username', [$loginHandler, 'checkFailedCookies']);
add_action('auth_cookie_valid', [$loginHandler, 'onValidCookie'], 10, 2);
}
if (isset($_POST['save_kompass_balist_list_type'])) {
updateBlockOrAllowList($_POST);
}

View File

@ -1,7 +0,0 @@
<?php
define('BDP_LV_PLUGIN_SLUG', 'bdp-kompass');
define('BDP_LV_STARTUP_FILE', WP_PLUGIN_DIR . '/' . BDP_LV_PLUGIN_SLUG . '/' . BDP_LV_PLUGIN_SLUG . '.php');
define('BDP_LV_PLUGIN_DIR', plugin_dir_path(BDP_LV_STARTUP_FILE));
define('BDP_LV_PLUGIN_URL', plugin_dir_url(BDP_LV_STARTUP_FILE));

View File

@ -1,45 +0,0 @@
<?php
add_action( 'plugins_loaded', 'bdp_kompass_load_plugin_textdomain' );
register_activation_hook(BDP_LV_STARTUP_FILE, 'bdp_plugin_install');
add_action('init', 'bdp_plugin_init');
function _protect_wp_disablexmlrpc_string() {
return "<FilesMatch \"xmlrpc.php\">
Require all denied
</FilesMatch>";
}
function _protect_wp_disable_script_execution_string() {
return '<FilesMatch "\.(php|phtml|php3|php4|php5|pl|py|jsp|asp|html|htm|shtml|sh|cgi|suspected)$">' . "
deny from all
</FilesMatch>";
}
function _protect_wp_disable_special_files_string() {
return '<FilesMatch "^.*(README|error_log|wp-config\.php|user.ini|log|php.ini|\.[hH][tT][aApP].*)$">' . "
deny from all
</FilesMatch>";
}
function _protect_wp_disable_directory_listing_string() {
return 'Options -Indexes';
}
function _protect_wp_secure_include_dir_string() {
return "RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]";
}
function _protect_wp_initial_bot_list_array()
{
return explode(';', 'SemrushBot;AhrefsBot;DotBot;WhatCMS;Rogerbot;trendictionbot;BLEXBot;linkfluence;magpie-crawler;MJ12bot;Mediatoolkitbot;AspiegelBot;DomainStatsBot;Cincraw;Nimbostratus;HTTrack;serpstatbot;omgili;GrapeshotCrawler;MegaIndex;PetalBot;Semanticbot;Cocolyzebot;DomCopBot;Traackr;BomboraBot;Linguee;webtechbot;DomainStatsBot;Clickagy;sqlmap;Internet-structure-research-project-bot;Seekport;AwarioSmartBot;OnalyticaBot;Buck;Riddler;SBL-BOT;DF Bot 1.0;PubMatic Crawler Bot;BVBot;Sogou;Barkrowler;Yandex');
}

View File

@ -1,6 +0,0 @@
<?php
require_once (ABSPATH . '/wp-admin/includes/plugin.php');
require_once (ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php');
require_once (ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php');
require_once (ABSPATH . '/wp-includes/pluggable.php');
require_once (ABSPATH . '/wp-admin/includes/template.php');

View File

@ -1,44 +0,0 @@
<?php
if ( ! defined( 'WP_PLUGIN_DIR' ) ) { // Abspath to wp-content/plugins
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // Full path, no trailing slash.
}
use Bdp\Modules\LimitLoginAttempts\Controllers\LoginHandler;
require_once dirname(__FILE__) . '/pre_requires.php';
require_once dirname(__FILE__) . '/environment.php';
require_once dirname(__FILE__) . '/spl.php';
require_once dirname(__FILE__) . '/update.class.php';
require_once BDP_LV_PLUGIN_DIR . 'includes/FileAccess.class.php';
require_once BDP_LV_PLUGIN_DIR . 'includes/WpConfigEditor.class.php';
require_once (BDP_LV_PLUGIN_DIR . '/includes/filters.php');
require_once (BDP_LV_PLUGIN_DIR . '/lib/ics-parser/Event.php');
require_once (BDP_LV_PLUGIN_DIR . '/lib/ics-parser/ICal.php');
require_once (BDP_LV_PLUGIN_DIR . '/modules/seo/seo.php');
require_once (BDP_LV_PLUGIN_DIR . '/modules/calendar/calendar.php');
require_once (BDP_LV_PLUGIN_DIR . '/includes/frontend-functions.php');
require_once (BDP_LV_PLUGIN_DIR . '/modules/security/security.php');
function admin_init()
{
kompass_settings_validators();
}
bdp_create_menu_structure();
function bdp_kompass_load_plugin_textdomain() {
load_textdomain( BDP_LV_PLUGIN_SLUG, BDP_LV_PLUGIN_DIR . '/lang/' . BDP_LV_PLUGIN_SLUG . '_' . get_locale() . '.mo' );
}
$loginHandler = new LoginHandler();
new BdpVersionChecker();
#add_filter( 'plugins_api', array( $class, 'info' ), 20, 3 );
require_once dirname(__FILE__) . '/action_caller.php';

View File

@ -1,32 +0,0 @@
<?php
spl_autoload_register(function ($className) {
if (!str_starts_with($className, 'ProtectLogin\\')) {
return;
}
$fileName = str_replace('\\','/', $className);
$fileName = str_replace('ProtectLogin/Modules/', 'ProtectLogin/modules/', $fileName);
$fileName = str_replace('ProtectLogin/', '', $fileName);
$fileName = BDP_LV_PLUGIN_DIR . $fileName . '.php';
if (!file_exists($fileName)) {
return;
}
require_once $fileName;
});
$modules = ['LimitLoginAttempts', 'PasswordStrength'];
$subdirs = ['includes', 'Controllers', 'Views'];
foreach ($modules as $curModule) {
foreach ($subdirs as $dir) {
$directoryPath = BDP_LV_PLUGIN_DIR . 'modules/' . $curModule . '/' . $dir . '/';
foreach (glob($directoryPath . '*.php') as $file) {
require_once $file;
}
}
}

View File

@ -1,152 +0,0 @@
<?php
class BdpVersionChecker
{
public $plugin_slug;
public $version;
public $cache_key;
public $cache_allowed;
public $updateUrl;
public function __construct()
{
$plugin_data = get_plugin_data( BDP_LV_STARTUP_FILE );
$this->plugin_slug = BDP_LV_PLUGIN_SLUG;
$this->updateUrl = $plugin_data['UpdateURI'] . '/info_development.json';
$this->version = $plugin_data['Version'];
$this->cache_key = 'bdp-kompass-upd';
$this->cache_allowed = false;
add_filter( 'plugins_api', array( $this, 'info' ), 20, 3 );
add_filter( 'site_transient_update_plugins', array( $this, 'update' ) );
add_action( 'upgrader_process_complete', array( $this, 'purge' ), 10, 2 );
}
public function request(){
$remote = get_transient( $this->cache_key );
if( false === $remote || ! $this->cache_allowed ) {
$remote = wp_remote_get(
$this->updateUrl
,
array(
'timeout' => 10,
'headers' => array(
'Accept' => 'application/json'
)
)
);
if(
is_wp_error( $remote )
|| 200 !== wp_remote_retrieve_response_code( $remote )
|| empty( wp_remote_retrieve_body( $remote ) )
) {
return false;
}
set_transient( $this->cache_key, $remote, 3600 );
}
$remote = json_decode( wp_remote_retrieve_body( $remote ) );
return $remote;
}
function info( $res = '', $action = '', $args = '' )
{
if (!isset($args->slug) || $args->slug !== $this->plugin_slug) {
return $res;
}
// get updates
$remote = $this->request();
if( ! $remote ) {
return $res;
}
$newVersion = $remote->version;
$res = new stdClass();
$res->name = $remote->name;
$res->slug = $remote->slug;
$res->version = $newVersion;
$res->tested = $remote->tested;
$res->requires = $remote->requires;
$res->author = $remote->author;
$res->author_profile = $remote->author_profile;
$res->download_link = $remote->download_url;
$res->trunk = $remote->download_url;
$res->requires_php = $remote->requires_php;
$res->last_updated = $remote->last_updated;
$res->sections = array(
'description' => $remote->sections->description,
'installation' => $remote->sections->installation,
'changelog' => $remote->sections->changelog
);
if( ! empty( $remote->banners ) ) {
$res->banners = array(
'low' => $remote->banners->low,
'high' => $remote->banners->high
);
}
return $res;
}
public function update( $transient ) {
if ( empty($transient->checked ) ) {
return $transient;
}
$remote = $this->request();
if(
$remote
&& version_compare( $this->version, $remote->version, '<' )
&& version_compare( $remote->requires, get_bloginfo( 'version' ), '<=' )
&& version_compare( $remote->requires_php, PHP_VERSION, '<' )
) {
$newVersion = $remote->version;
$res = new stdClass();
$res->slug = $this->plugin_slug;
$res->plugin = plugin_basename( BDP_LV_STARTUP_FILE );
$res->new_version = $newVersion;
$res->tested = $remote->tested;
$res->package = $remote->download_url;
$transient->response[ $res->plugin ] = $res;
} else {
$res = new stdClass();
$res->slug = $this->plugin_slug;
$res->plugin = plugin_basename( BDP_LV_STARTUP_FILE );
$transient->no_update[ $res->plugin ] = $res;
}
return $transient;
}
public function purge( $upgrader, $options ){
if (
$this->cache_allowed
&& 'update' === $options['action']
&& 'plugin' === $options[ 'type' ]
) {
// just clean the cache when new plugin version is installed
delete_transient( $this->cache_key );
}
}
}

Binary file not shown.

View File

@ -1,111 +0,0 @@
msgid "Extended Security"
msgstr "Erweiterte Sicherheit"
msgid "Save changes"
msgstr "Änderungen speichern"
msgid "All settings are saved."
msgstr "Die Einstellungen wurden gespeichert."
msgid "Disable xmlrpc"
msgstr "xmlrpc deaktivieren"
msgid "By introducing the REST API in WordPress, xmlrpc. However, php is no longer needed to communicate outside of WordPress, which is why there is no longer any reason to leave it active or use it. Therefore, for the security of your site, it is better to deactivate or delete it."
msgstr "Durch die Einführung der REST API in WordPress wird xmlrpc. php jedoch nicht mehr benötigt, um außerhalb von WordPress zu kommunizieren, weshalb es hier keinen Grund mehr gibt, diese aktiv zu lassen oder zu nutzen. Deshalb ist es für die Sicherheit deiner Seite besser, diese zu deaktivieren oder zu löschen."
msgid "Disable Authorscan"
msgstr "Autorenscan deaktivieren"
msgid "The author page in WordPress typically displays a list of all posts by a specific author on your website. Unfortunately, Google also records the page and to prevent this, we can deactivate the author page. When a visitor clicks on an name of an author, they are redirected to the author page. This page contains a list of posts written by this author, as well as possibly a brief description of the author and a photo. It is also possible to record which user names have been created."
msgstr "Die Autorenseite in WordPress zeigt normalerweise eine Liste aller Beiträge eines bestimmten Autors auf deiner Website an. Google erfasst die Seite auch leider und um das zu verhindern, können wir die Autorenseite deaktivieren. Wenn ein Besucher auf den Namen eines Autors klickt, wird er auf die Autorenseite weitergeleitet. Diese Seite enthält eine Liste der Beiträge, die von diesem Autor verfasst wurden, sowie möglicherweise eine kurze Beschreibung des Autors und ein Foto. Auch ist es darüber möglich zu erfassen, welche Nutzernamen angelegt sind."
msgid "Disable scripting in /wp-content/uploads/"
msgstr "Scripting in /wp-content/uploads/ deaktivieren"
msgid "Disabling scripting in /wp-content/uploads/ can be a security measure to protect your WordPress website from potential threats. The /wp-content/uploads folder is usually the default folder where WordPress stores uploaded files, such as images, videos, and other media files."
msgstr "Das Deaktivieren von Scripting in /wp-content/uploads/ kann eine Sicherheitsmaßnahme sein, um dein WordPress-Website vor potenziellen Bedrohungen zu schützen. Der Ordner /wp-content/uploads ist normalerweise der Standardordner, in dem WordPress hochgeladene Dateien, wie Bilder, Videos und andere Mediendateien, speichert."
msgid "Block access to potentially sensitive files"
msgstr "Zugriff auf potenziell sensible Dateien blockieren"
msgid "This setting prohibits access to configuration files and log files"
msgstr "Diese Einstellung verbietet den Zugriff auf Konfigurationsdateien sowie Log-Dateien"
msgid "Disable file editor in WP Dashboard"
msgstr "Dateieditor im WP Dashboard deaktivieren"
msgid "This is a security feature that allows you to prevent users from editing theme and plugin files directly from the WordPress dashboard. This can be useful for a variety of reasons, including preventing accidental code changes and protecting your website from malicious attacks."
msgstr "Hierbei handelt es sich um eine Sicherheitsfunktion, mit der Sie verhindern können, dass Benutzer Theme- und Plugin-Dateien direkt über das WordPress-Dashboard bearbeiten können. Dies kann aus verschiedenen Gründen nützlich sein, unter anderem um versehentliche Änderungen am Code zu verhindern und Ihre Website vor böswilligen Angriffen zu schützen."
msgid "Disable script concatenation"
msgstr "Skriptverkettung deaktivieren"
msgid "Disabling script concatenation in the WordPress admin panel is a simple and effective way to enhance performance. However, it is crucial to carefully consider the impact of this change, as it may increase the number of HTTP requests, potentially affecting loading times"
msgstr "Das Deaktivieren der Skriptverkettung im WordPress-Admin-Panel ist eine einfache und effektive Möglichkeit, die Leistung zu verbessern. Es ist jedoch wichtig, die Auswirkungen dieser Änderung sorgfältig abzuwägen, da sie die Anzahl der HTTP-Anfragen erhöhen und sich möglicherweise auf die Ladezeiten auswirken kann."
msgid "Disable script execution in include dir"
msgstr "Skriptausführung im Include-Verzeichnis deaktivieren"
msgid "Limiting script execution in specific directories can improve security by preventing potentially malicious scripts from running in critical parts of the WordPress system. This is particularly important to prevent attacks such as Cross-Site Scripting (XSS), which inject malicious code into website content."
msgstr "Das Begrenzen der Skriptausführung in bestimmten Verzeichnissen kann die Sicherheit verbessern, indem potenziell schädliche Skripte daran gehindert werden, in kritischen Teilen des WordPress-Systems ausgeführt zu werden. Dies ist besonders wichtig, um Angriffe wie Cross-Site Scripting (XSS) zu verhindern, bei denen schädlicher Code in Webseiteninhalte eingeschleust wird."
msgid "Change site keys"
msgstr "Seitenschlüssel erneuern"
msgid "An error occured connecting api.wordpress.org"
msgstr "Beim Kontaktieren von api.wordpress.org trat ein Fehler auf"
msgid "The site keys were updated successfully."
msgstr "Die Seitenschlüssel wurden erneuert."
msgid "Protect WP detected missing security settings"
msgstr "Protect WP hat fehlende Sicherheitseinstellungen festgestellt"
msgid "Protect WP has detected that advanced security settings are missing.<br />You can update the settings directly in the dashboard."
msgstr "Protect WP hat festgestellt, dass erweiterte Sicherheitseinstellungen fehlen.<br />Du kannst die Einstellungen direkt im Dashboard aktualisieren."
msgid "Protect WP - security settings"
msgstr "Protect WP - Sicherheitseinstellungen"
msgid "Prohibit access from unwanted bots"
msgstr "Zugriff von ungewollten Bots verbieten"
msgid "Excluding specific bots from a WordPress website provides improved security by reducing potentially malicious activity and security risks, optimizes resource consumption and site performance, protects against content theft and duplicate content, enables more precise control of traffic, and promotes more effective SEO -Optimization by reducing irrelevant bots, ultimately leading to a safer, more efficient and better performing website."
msgstr "Das Ausschließen bestimmter Bots von einer WordPress-Website bietet eine verbesserte Sicherheit, indem potenziell bösartige Aktivitäten und Sicherheitsrisiken reduziert werden, optimiert den Ressourcenverbrauch und die Website-Performance, schützt vor Inhaltsdiebstahl und Duplicate Content, ermöglicht eine genauere Kontrolle des Datenverkehrs und fördert eine effektivere SEO-Optimierung durch die Reduzierung nicht relevanter Bots, was letztendlich zu einer sichereren, effizienteren und besser performenden Website führt."
msgid "Bot Detection Database"
msgstr "Datenbank zur Bot-Erkennung"
msgid "Registered bots"
msgstr "Vorhandene Bots"
msgid "Add more bots"
msgstr "Weitere Bots hinzufügen"
msgid "Leave blank in order to delete"
msgstr "Zum Löschen leer lassen"
msgid "Please use line breaks to enter multiple bots"
msgstr "Bitte Zeilenumbruch verwenden, um mehrere Bots einzutragen"#
msgid "Bot Detection Database updated successfully."
msgstr "Die Datenbank zur Bot-Erkennung wurde erfolgreich aktualisiert."
msgid "Disable directory listing"
msgstr "Auflistung von Verzeichnissen deaktivieren"
msgid "Directory listing should be disabled to ensure the security and privacy of a website. When Directory Listing is enabled, this allows users to directly access the contents of directories on a web server without having to specify a specific file. This can expose sensitive information such as directory structures, internal files and scripts, posing a potential security risk. Disabling Directory Listing prevents users from accessing this sensitive information, thereby providing an additional layer of security for the website."
msgstr "Das Auflisten von Verzeichnissen sollte deaktiviert werden, um die Sicherheit und Privatsphäre einer Website zu gewährleisten. Wenn Directory Listing aktiviert ist, ermöglicht dies Benutzern den direkten Zugriff auf die Inhalte von Verzeichnissen auf einem Webserver, ohne dass eine spezifische Datei angegeben werden muss. Dies kann sensible Informationen wie Verzeichnisstrukturen, interne Dateien und Skripte offenlegen, was ein potenzielles Sicherheitsrisiko darstellt. Durch das Deaktivieren von Directory Listing wird verhindert, dass Benutzer auf diese sensiblen Informationen zugreifen können, und bietet somit eine zusätzliche Sicherheitsschicht für die Website."
msgid "Disable debug output"
msgstr "Debug-Ausgaben deaktivieren"
msgid "Debugging should be disabled to protect sensitive information about the internal structure and potential security vulnerabilities of a a WordPress website from potential attackers. When debugging is enabled, error messages and warnings are displayed directly on the website, which can provide attackers with valuable information about the configuration of the website and possible vulnerabilities."
msgstr "Debugging sollte deaktiviert werden, um sensible Informationen über die interne Struktur und mögliche Sicherheitslücken einer WordPress-Website vor potenziellen Angreifern zu schützen. Wenn Debuggin aktiviert ist, werden Fehlermeldungen und Warnungen direkt auf der Webseite angezeigt, was Angreifern wertvolle Informationen über die Konfiguration und mögliche Schwachstellen der Website geben kann. "
msgid "Change Login URL"
msgstr "Login-URL ändern"
msgid "Changing the default login URL of WordPress is advisable to enhance the security of your website. By default, WordPress login URLs is /wp-admin or /wp-login.php, which are easily guessed by hackers and facilitate attacks such as brute-force attacks. Changing the login URL to something unique and difficult to guess increases security since potential attackers will struggle to find the correct URL. This can help protect your website from unauthorized access and other malicious activities."
msgstr "Es ist ratsam, die Standard-Login-URL von WordPress zu ändern, um die Sicherheit deiner Website zu erhöhen. Standardmäßig lautet die Login-URL von WordPress /wp-admin oder /wp-login.php, was für Hacker leicht zu erraten ist und Angriffe wie Brute-Force-Attacken erleichtern kann. Durch Ändern der Login-URL auf etwas Einzigartiges und schwer zu erraten, erhöhst du die Sicherheit, da potenzielle Angreifer Schwierigkeiten haben werden, die richtige URL zu finden. Dies kann helfen, deine Website vor unautorisiertem Zugriff und anderen böswilligen Aktivitäten zu schützen."

View File

@ -1,282 +0,0 @@
<?php
namespace Bdp\Modules\LimitLoginAttempts\Controllers;
use ProtectLogin\Modules\LimitLoginAttempts\Requests\IpAddress;
class LoginHandler {
public const DIRECT_ADDR = 'REMOTE_ADDR';
public const PROXY_ADDR = 'HTTP_X_FORWARDED_FOR';
public function onSuccessFullLogin($user, $password) {
if (!is_wp_error($user) && $this->isLoginAllowedFromIp() ) {
return $user;
}
global $limit_login_my_error_shown;
$limit_login_my_error_shown = true;
$error = new \WP_Error();
// This error should be the same as in "shake it" filter below
$error->add('too_many_retries', $this->composeErrorMessage());
return $error;
}
public function onFailedLogin(string $username) {
$ip = $this->getAddress();
/* if currently locked-out, do not add to retries */
$lockouts = get_option('protect_login_limit_login_lockouts', []);
if(isset($lockouts[$ip]) && time() < $lockouts[$ip]) {
return;
}
/* Get the arrays with retries and retries-valid information */
$retries = get_option('kompass_limit_login_retries', []);
$valid = get_option('kompass_limit_login_retries_valid', []);
/* Check validity and add one to retries */
if (isset($retries[$ip])) { //} && isset($valid[$ip]) && time() < $valid[$ip]) {
$retries[$ip] ++;
} else {
$retries[$ip] = 1;
}
update_option('kompass_limit_login_retries', $retries);
/* lockout? */
if($retries[$ip] % get_option('kompass_limit_login_allowed_retries', 0) != 0) {
return;
}
$retries_long = get_option('kompass_limit_login_allowed_retries', 1)
* get_option('kompass_limit_login_allowed_lockouts', 1);
if ($retries[$ip] >= $retries_long) {
$lockouts[$ip] = time() + get_option('kompass_limit_login_long_duration', 86400);
} else {
$lockouts[$ip] = time() + get_option('kompass_limit_login_lockout_duration', 900);
}
update_option('kompass_limit_login_lockouts', $lockouts);
/* do any notification */
$this->notify($username);
}
private function notifyByEmail($user)
{
$ip = $this->getAddress();
$lockouts = get_option('kompass_limit_login_lockouts', []);
if (!isset($lockouts[$ip])) {
return;
}
$blocked_until = $lockouts[$ip];
$retries = get_option('kompass_limit_login_retries', []);
$currentRetries = $retries[$ip];
$notify_after = get_option('kompass_limit_login_notify_email_after', 1);
if ($currentRetries % $notify_after !== 0) {
return;
}
$blogname = get_option('blogname', 'none');
$subject = sprintf(__("[%s] Too many failed login attempts"
, 'limit-login-attempts')
, $blogname);
$message = 'Neue Sperrung auf deiner Webseite: ' . PHP_EOL .
'IP-Adresse: ' . $ip . PHP_EOL .
'Gesperrt bis: ' . date('d.m.Y H:i', $blocked_until);
$admin_email = get_option('admin_email');
wp_mail($admin_email, $subject, $message);
}
/* Handle notification in event of lockout */
private function notify($user) {
$args = get_option('kompass_limit_login_lockout_notify', []);
if (!is_array($args)) {
$args = [$args];
}
foreach ($args as $mode) {
switch (trim($mode)) {
case 'email':
$this->notifyByEmail($user);
break;
}
}
}
private function composeErrorMessage() {
$ip = $this->getAddress();
$lockouts = get_option('kompass_limit_login_lockouts');
$msg = __('<strong>ERROR</strong>: Too many failed login attempts.', 'limit-login-attempts') . ' ';
if (!is_array($lockouts) || !isset($lockouts[$ip]) || time() >= $lockouts[$ip]) {
/* Huh? No timeout active? */
$msg .= __('Please try again later.', 'limit-login-attempts');
return $msg;
}
$when = ceil(($lockouts[$ip] - time()) / 60);
if ($when > 60) {
$when = ceil($when / 60);
$msg .= sprintf(_n('Please try again in %d hour.', 'Please try again in %d hours.', $when, 'limit-login-attempts'), $when);
} else {
$msg .= sprintf(_n('Please try again in %d minute.', 'Please try again in %d minutes.', $when, 'limit-login-attempts'), $when);
}
return $msg;
}
private static function getAddress($typeName = '') {
global $limitLoginAttemptsSettings;
$typeOriginal = $typeName;
if (empty($typeName)) {
$typeName = get_option('kompass_limit_loginclient_type', self::DIRECT_ADDR);
}
if (isset($_SERVER[$typeName]) && filter_var($_SERVER[$typeName], FILTER_VALIDATE_IP)) {
return $_SERVER[$typeName];
}
/*
* Not found. Did we get proxy type from option?
* If so, try to fall back to direct address.
*/
if ( empty($typeName) && $typeOriginal == self::PROXY_ADDR
&& isset($_SERVER[self::DIRECT_ADDR])
&& filter_var($_SERVER[self::DIRECT_ADDR], FILTER_VALIDATE_IP)) {
/*
* NOTE: Even though we fall back to direct address -- meaning you
* can get a mostly working plugin when set to PROXY mode while in
* fact directly connected to Internet it is not safe!
*
* Client can itself send HTTP_X_FORWARDED_FOR header fooling us
* regarding which IP should be banned.
*/
return $_SERVER[self::DIRECT_ADDR];
}
return '';
}
public function isLoginAllowedFromIp() {
$ip = $this->getAddress();
if (in_array($ip, get_option('kompass_limit_login_blocklist', []))) {
return false;
}
if (in_array($ip, get_option('kompass_limit_login_allowlist', []))) {
return true;
}
/* lockout active? */
$lockouts = get_option('kompass_limit_login_lockouts', []);
return (!is_array($lockouts) || !isset($lockouts[$ip]) || time() >= $lockouts[$ip]);
}
public function checkFailedCookies($cookie_elements) {
$this->clearAuthCookie();
/*
* Invalid username gets counted every time.
*/
$this->onFailedLogin($cookie_elements['username']);
}
private function clearAuthCookie() {
wp_clear_auth_cookie();
if (!empty($_COOKIE[AUTH_COOKIE])) {
$_COOKIE[AUTH_COOKIE] = '';
}
if (!empty($_COOKIE[SECURE_AUTH_COOKIE])) {
$_COOKIE[SECURE_AUTH_COOKIE] = '';
}
if (!empty($_COOKIE[LOGGED_IN_COOKIE])) {
$_COOKIE[LOGGED_IN_COOKIE] = '';
}
}
public function onValidCookie($cookie_elements, $user) {
/*
* As all meta values get cached on user load this should not require
* any extra work for the common case of no stored value.
*/
if (get_user_meta($user->ID, 'kompass_limit_login_previous_cookie')) {
delete_user_meta($user->ID, 'kompass_limit_login_previous_cookie');
}
}
function clearLoginCookie($cookie_elements) {
$this->clearAuthCookie();
/*
* Under some conditions an invalid auth cookie will be used multiple
* times, which results in multiple failed attempts from that one
* cookie.
*
* Unfortunately I've not been able to replicate this consistently and
* thus have not been able to make sure what the exact cause is.
*
* Probably it is because a reload of for example the admin dashboard
* might result in multiple requests from the browser before the invalid
* cookie can be cleard.
*
* Handle this by only counting the first attempt when the exact same
* cookie is attempted for a user.
*/
extract($cookie_elements, EXTR_OVERWRITE);
// Check if cookie is for a valid user
$user = get_user_by('login', $username);
if (!$user) {
// "shouldn't happen" for this action
$this->onFailedLogin($username);
return;
}
$previous_cookie = get_user_meta($user->ID, 'kompass_limit_login_previous_cookie', true);
if ($previous_cookie && $previous_cookie == $cookie_elements) {
// Identical cookies, ignore this attempt
return;
}
// Store cookie
if ($previous_cookie)
update_user_meta($user->ID, 'kompass_limit_login_previous_cookie', $cookie_elements);
else
add_user_meta($user->ID, 'kompass_limit_login_previous_cookie', $cookie_elements, true);
$this->onFailedLogin($username);
}
public function handleCookies() {
if ($this->isLoginAllowedFromIp()) {
return;
}
$this->clearAuthCookie();
}
}

View File

@ -1,130 +0,0 @@
<?php
namespace Bdp\Modules\LimitLoginAttempts\Controllers;
class OptionsPage
{
public function __construct()
{
add_options_page(BDP_LV_PLUGIN_SLUG . '-limit-login-attempts',
'Protect Login',
'site-health.php',
BDP_LV_PLUGIN_SLUG . '-limit-login-attempts',
[$this, 'limit_login_option_page'],2048);
}
public function releaseIp($ip)
{
$allIps = get_option('kompass_limit_login_lockouts', []);
unset($allIps[$ip]);
update_option('kompass_limit_login_lockouts', $allIps);
}
public function getBlockedIps()
{
$ips = '';
foreach (get_option('kompass_limit_login_lockouts', []) as $ip => $blockedUntil) {
$ips .= '<tr>' .
'<td style="padding-right: 10px;">' . $ip . '</td>' .
'<td style="padding-right: 10px;">' . date('d.m.Y H:i', $blockedUntil) . ' Uhr</td>' .
'<td>
<a href="admin.php?page=bdp-kompass-limit-login-attempts&tab=tab4&action=release&ip=' .
base64_encode($ip) . '">Freigeben</a></td>' .
'</tr>';
};
return $ips;
}
public function limit_login_option_page() {
global $errors;
$showMessage = null;
if (isset($_POST['update_options'])) {
update_settings($_POST);
$showMessage = 'Die Einstellungen wurden gespeichert';
}
if (isset($_GET['action']) && $_GET['action'] == 'release') {
$showMessage = 'Die IP-Adresse wurde freigegeben.';
}
if(isset($_POST['save_kompass_balist_list_type'])) {
$showMessage = 'Die Liste wurde gespeichert.';
}
if (null !== $showMessage && $errors === false) {
echo '<div class="notice notice-success" style="padding: 5px 10px;">';
echo $showMessage;
echo '</div>';
}
if ($errors) {
echo '<div class="notice notice-error" style="padding: 5px 10px;">';
echo 'Beim Durchführen der Aktion ist ein Fehler aufgetreten.';
echo '</div>';
}
$tab = isset($_GET['tab']) ? $_GET['tab'] : 'tab1';
?>
<div class="wrap">
<h1 class="wp-heading-inline">Protect Login - Einstellungen</h1>
<hr class="wp-header-end">
<?= kompass_print_tab_header($tab); ?>
<div class="tab-content">
<?php
switch ($tab) {
case 'tab1':
echo '<form action="admin.php?page=bdp-kompass-limit-login-attempts&tab=tab1" method="post">';
do_settings_sections(BDP_LV_PLUGIN_SLUG . '-limit-login-attempts');
submit_button();
echo '</form>';
break;
case 'tab2':
echo '<h2>Blocklist</h2>';
echo '<form action="admin.php?page=bdp-kompass-limit-login-attempts&tab=tab2" method="post">';
kompass_print_block_allow_form('blocklist');
submit_button();
echo '</form>';
break;
case 'tab3':
echo '<h2>Allowlist</h2>';
echo '<form action="admin.php?page=bdp-kompass-limit-login-attempts&tab=tab3" method="post">';
kompass_print_block_allow_form('allowlist');
submit_button();
echo '</form>';
break;
case 'tab4':
if (isset($_GET['action']) && $_GET['action'] == 'release') {
$this->releaseIp(base64_decode($_GET['ip']));
}
$blockedIps = $this->getBlockedIps();
?>
<h3>Gesperrte IPs</h3>
<?php
if (strlen($blockedIps) == 0) {
echo '<div class="protect-login-no-blocked-ips">';
echo 'Derzeit sind keine Adressen gesperrt.';
echo '</div>';
} else { ?>
<table>
<tr>
<th>IP</th>
<th>Gesperrt bis</th>
<th>Aktion</th>
</tr>
<?= $blockedIps ?>
</table>
<?php
}
break;
}
?>
</div>
</div>
<?php
}
}

View File

@ -1,29 +0,0 @@
<?php
function kompass_print_checkbox($settingName) {
$currentSetting = get_option($settingName, []);
if (!is_array($currentSetting)) {
$currentSetting = [$currentSetting];
}
$options = ['kompass_limit_login_lockout_notify' => [
'email' => 'E-Mail an Administrator'
],
];
if(!isset($options[$settingName])) {
return;
}
$setting = $options[$settingName];
foreach ($setting as $radioOption => $optionText) {
$isChecked = in_array($radioOption, $currentSetting) ? 'checked ' : '' ;
echo '<input ' .
$isChecked .
'type="checkbox"
name="' . $settingName . '[]"
value="' . $radioOption . '"
id="setting_' . $settingName . '_' . $radioOption . '" />' .
'<label for="setting_' . $settingName . '_' . $radioOption . '">' . $optionText . '</label><br />';
}
}

View File

@ -1,35 +0,0 @@
<?php
function kompass_print_radio($settingName) {
$currentSetting = get_option($settingName);
$options = [
'kompass_limit_login_client_type' => [
'REMOTE_ADDR' => 'Direkte Verbrindung',
'HTTP_X_FORWARDED_FOR' => 'Hinter einem Proxy'
],
'kompass_limit_login_cookies' => [
true => 'Ja',
false => 'Nein'
],
'kompass_password_minimal_strength' => [
'1' => 'Alle Passwörter erlauben',
'2' => 'Mittelstarke Passwörter',
'3' => 'Nur Starke Passwörter'
]
];
if(!isset($options[$settingName])) {
return;
}
$setting = $options[$settingName];
foreach ($setting as $radioOption => $optionText) {
$isChecked = $currentSetting == $radioOption ? 'checked ' : '' ;
echo '<input
' . $isChecked .
' type="radio"
name="' . $settingName . '"
value="' . $radioOption . '"
id="setting_' . $settingName . '_' . $radioOption . '" />' .
'<label for="setting_' . $settingName . '_' . $radioOption . '">' . $optionText . '</label> &nbsp; ';
}
}

View File

@ -1,18 +0,0 @@
<?php
function kompass_print_tab_header($activeTab = 'tab1')
{
$baseUrl = 'admin.php?page=bdp-kompass-limit-login-attempts&tab=';
return '<h2 class="nav-tab-wrapper">'.
'<a href="' . $baseUrl . 'tab1" class="nav-tab ' . ($activeTab == 'tab1' ? 'nav-tab-active' : '') . '">
Optionen
</a>'.
'<a href="' . $baseUrl . 'tab2" class="nav-tab ' . ($activeTab == 'tab2' ? 'nav-tab-active' : '') .'">
Blocklist
</a>'.
'<a href="' . $baseUrl . 'tab3" class="nav-tab ' . ($activeTab == 'tab3' ? 'nav-tab-active' : '') .'">
Allowlist
</a>'.
'<a href="' . $baseUrl . 'tab4" class="nav-tab ' . ($activeTab == 'tab4' ? 'nav-tab-active' : '') .'">
Gesperrte IPs
</a></h2>';
}

View File

@ -1,7 +0,0 @@
<?php
function kompass_print_textbox($settingName, $settingValue) {
echo '<input type="text" name="' . $settingName . '" value="' . $settingValue. '" />';
if (defined('WP_DEBUG') && WP_DEBUG == true) {
echo '<br />' . $settingName;
}
}

View File

@ -1,56 +0,0 @@
<?php
function updateBlockOrAllowList($postVars)
{
$listType = $postVars['save_kompass_balist_list_type'];
$saveIPList = [];
if (isset($postVars['listElements'])) {
foreach ($postVars['listElements'] as $curIp) {
$curIp = trim($curIp);
if ($curIp !== '') {
$saveIPList[] = $curIp;
}
}
}
if (count($postVars['new_ips']) == 1) {
foreach (explode(PHP_EOL, $postVars['new_ips'][0]) as $newIp) {
$newIp = trim($newIp);
if ('' !== $newIp) {
$saveIPList[] = $newIp;
}
}
}
update_option('kompass_limit_login_' . $listType, $saveIPList);
}
function kompass_print_block_allow_form($listType) {
$elements = get_option('kompass_limit_login_' . $listType, []);
?>
<input type="hidden" name="save_kompass_balist_list_type" value="<?= $listType; ?>" />
<?php
foreach ($elements as $currentIp) {
?>
<p>
<input type="text" name="listElements[]" value="<?= $currentIp ?>" style="width: 350px;" /><br />
<label style="cursor: default; color: #a0a0a0; fot-size: 9pt; font-style: italic"><?= __('Zum Löschen frei lassen', BDP_LV_PLUGIN_SLUG); ?></label>
</p>
<?php
}
?>
</div>
<div class="kompass_setting_box">
<h3><?= __('IP-Adresse hinzufügen', BDP_LV_PLUGIN_SLUG); ?></h3>
<p>
<textarea
placeholder="<?= __('Please use line breaks to enter multiple ips', BDP_LV_PLUGIN_SLUG); ?>"
name="new_ips[]"
style="width: 350px;" rows="5"></textarea>
</p>
</div>
<?php
}

View File

@ -1,116 +0,0 @@
<?php
// Callback-Funktion für die Einstellungsseite
function custom_settings_section_callback() {
echo '<input type="hidden" name="update_options" value="true" />';
}
function _kompass_limit_logins_settings_callback($args) {
$setting = get_option($args['setting'], null);
if (null === $setting) {
$setting = '';
}
$value = esc_attr($setting);
if (isset($args['unit_division'])) {
$value = (int)$value / (int)$args['unit_division'];
}
kompass_print_textbox($args['setting'], $value);
}
function _kompass_limit_logins_settings_radio_callback($args)
{
kompass_print_radio($args['setting']);
}
function _kompass_limit_logins_settings_checkbox_callback($args) {
kompass_print_checkbox($args['setting']);
}
add_settings_section(
'custom_settings_section',
'Optionen',
'custom_settings_section_callback',
BDP_LV_PLUGIN_SLUG . '-limit-login-attempts'
);
$settings_page = BDP_LV_PLUGIN_SLUG . '-limit-login-attempts';
add_settings_field(
'kompass_lla_1',
'Maximale Wiederholungen',
'_kompass_limit_logins_settings_callback',
$settings_page,
'custom_settings_section',
['setting' => 'kompass_limit_login_allowed_retries']);
add_settings_field(
'kompass_lla_2',
'Dauer der Sperre (in Minuten)',
'_kompass_limit_logins_settings_callback',
$settings_page,
'custom_settings_section',
['setting' => 'kompass_limit_login_lockout_duration', 'unit_division' => 60 ]);
add_settings_field(
'kompass_lla_3',
'Maximale Anzahl an Sperrungen',
'_kompass_limit_logins_settings_callback',
$settings_page,
'custom_settings_section',
['setting' => 'kompass_limit_login_allowed_lockouts']);
add_settings_field(
'kompass_lla_4',
'Langzeitsperre in Stunden',
'_kompass_limit_logins_settings_callback',
$settings_page,
'custom_settings_section',
['setting' => 'kompass_limit_login_long_duration', 'unit_division' => 3600]);
add_settings_field(
'kompass_lla_5',
'Mininmale Passwort-Stärke:',
'_kompass_limit_logins_settings_radio_callback',
$settings_page,
'custom_settings_section',
['setting' => 'kompass_password_minimal_strength']);
add_settings_field(
'kompass_lla_6',
'Seite erreichbar über:',
'_kompass_limit_logins_settings_radio_callback',
$settings_page,
'custom_settings_section',
['setting' => 'kompass_limit_login_client_type']);
add_settings_field(
'kompass_lla_7',
'Cookies verarbeiten',
'_kompass_limit_logins_settings_radio_callback',
$settings_page,
'custom_settings_section',
['setting' => 'kompass_limit_login_cookies']);
add_settings_field(
'kompass_lla_8',
'Bei Sperrung benachrichtigen',
'_kompass_limit_logins_settings_checkbox_callback',
$settings_page,
'custom_settings_section',
['setting' => 'kompass_limit_login_lockout_notify']);
add_settings_field(
'kompass_lla_9',
'Fehlversuche bis zur Benachrichtigung',
'_kompass_limit_logins_settings_callback',
$settings_page,
'custom_settings_section',
['setting' => 'kompass_limit_login_notify_email_after']);

View File

@ -1,64 +0,0 @@
<?php
function check_for_integer($input) {
if (!is_numeric($input)) {
wp_die('Bitte nur Zahlen, Danke!');
}
return $input;
}
function hours_to_seconds_converter($input) {
// Hier kannst du die Eingabe validieren, z.B. sicherstellen, dass es sich um eine gültige E-Mail-Adresse handelt.
return minutes_to_seconds_converter($input) * 60;
}
function minutes_to_seconds_converter($input) {
// Hier kannst du die Eingabe validieren, z.B. sicherstellen, dass es sich um eine gültige E-Mail-Adresse handelt.
return check_for_integer($input) * 60;
}
function kompass_settings_validators()
{
$slug = BDP_LV_PLUGIN_SLUG . '-limit-login-attempts';
register_setting($slug,
'kompass_limit_login_allowed_retries',
'check_for_integer');
register_setting($slug,
'kompass_limit_login_allowed_lockouts',
'check_for_integer');
register_setting($slug,
'kompass_limit_login_lockout_duration',
'minutes_to_seconds_converter');
register_setting($slug,
'kompass_limit_login_long_duration',
'hours_to_seconds_converter');
register_setting($slug,
'kompass_limit_login_notify_email_after',
'check_for_integer');
}
function update_settings($postParams) {
$settings = ['kompass_limit_login_lockout_duration',
'kompass_limit_login_allowed_retries',
'kompass_limit_login_allowed_lockouts',
'kompass_password_minimal_strength',
'kompass_limit_login_client_type',
'kompass_limit_login_long_duration',
'kompass_limit_login_lockout_notify',
'kompass_limit_login_notify_email_after',
'kompass_limit_login_cookies'];
foreach ($settings as $curSetting) {
if (isset($postParams[$curSetting])) {
update_option( $curSetting, $postParams[ $curSetting ] );
} else {
update_option( $curSetting, '');
}
}
}

View File

@ -1,10 +0,0 @@
<?php
function kompass_get_minimal_password_strength() {
$minPasswordStrength = get_option('kompass_password_minimal_strength', 1);
$possibleStrengths = ['1' => 'short, bad, good, strong',
'2' => 'good, strong',
'3' => 'strong'];
return ' ' . $possibleStrengths[$minPasswordStrength];
}

View File

@ -1,3 +1,4 @@
<div id="wpbody-content">
<h1>Über dieses Plugin</h1> <h1>Über dieses Plugin</h1>

View File

@ -1,4 +1,5 @@
<?php <?php
echo '<div id="wpbody-content">';
echo '<h1>Kalender-Einstellungen</h1>'; echo '<h1>Kalender-Einstellungen</h1>';
if (isset($_POST['submit'])) { if (isset($_POST['submit'])) {
echo '<div id="bdp_success">Die Einstellungen wurden gespeichert.</div>'; echo '<div id="bdp_success">Die Einstellungen wurden gespeichert.</div>';
@ -21,6 +22,7 @@ if (null !== $categories) {
} }
?> ?>
<form method="post" action="admin.php?page=bdp-kompass%2Fmodules%2Findex.php&loadmodule=calendar"> <form method="post" action="admin.php?page=bdp-kompass%2Fmodules%2Findex.php&loadmodule=calendar">
<div class="bdp_cal_outer">
<fieldset class="bdp_cal_inner"> <fieldset class="bdp_cal_inner">
<legend>Datenabfrage</legend> <legend>Datenabfrage</legend>
@ -82,5 +84,8 @@ if (null !== $categories) {
<td class="bdp_cal_event_grey"></td> <td class="bdp_cal_event_grey"></td>
</tr> </tr>
</table> </table>
<input class="button" type="submit" name="submit" value="Einstellungen speichern"> </fieldset>
<input class="bdp_submit" type="submit" name="submit" value="Einstellungen speichern">
</form> </form>
</div>
</div>

View File

@ -0,0 +1,75 @@
<?php
namespace Bdp\Modules\Security;
use ZipArchive;
class Security
{
public const required_security_plugins = [
'wps_hide_login' => ['downloadUrl' => 'https://downloads.wordpress.org/plugin/wps-hide-login.1.9.10.zip'],
'limit-login-attempts-reloaded' => ['downloadUrl' => 'https://downloads.wordpress.org/plugin/limit-login-attempts-reloaded.2.25.27.zip']];
public const delete_plugins = [
'akismet/akismet.php',
'hello.php'
];
public static function setup()
{
self::deletePlugins();
foreach (self::required_security_plugins as $pluginSlug => $pluginData) {
if (!is_dir(WP_PLUGIN_DIR . '/' . $pluginSlug)) {
self::installSecurityPlugin($pluginSlug, $pluginData['downloadUrl']);
}
}
$loginUrl = get_option('whl_page', 'bdp_login');
update_option('whl_page', $loginUrl);
}
public static function deletePlugins() {
deactivate_plugins(self::delete_plugins);
delete_plugins(self::delete_plugins);
}
public static function installSecurityPlugin(string $pluginSlug, string $downloadUrl) : bool
{
$ch = curl_init();
$source = $downloadUrl;
curl_setopt($ch, CURLOPT_URL, $source);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec ($ch);
curl_close ($ch);
$destination = WP_PLUGIN_DIR . '/' . $pluginSlug . '.zip';
$file = fopen($destination, "w+");
fputs($file, $data);
fclose($file);
$zip = new ZipArchive();
$zip->open($destination);
$zip->extractTo(WP_PLUGIN_DIR);
$zip->close();
unlink($destination);
$pluginInfos = get_plugins( '/'.$pluginSlug );
$installfile = $pluginSlug . '/';
if( ! empty( $pluginInfos ) ) {
foreach ($pluginInfos as $file => $info) :
$installfile .= $file;
endforeach;
}
$result = activate_plugin($installfile);
return $result === null;
}
}

View File

@ -0,0 +1,22 @@
<?php
echo '<div id="wpbody-content">';
echo '<h1>Installation erfolgreich!</h1>';
?>
<form method="post" action="admin.php?page=bdp-kompass%2Fmodules%2Findex.php&loadmodule=security">
<div class="bdp_security_outer">
<fieldset class="bdp_security_inner">
<span style="font-weight: bold;">Herzlichen Glückwunsch!</span><br /><br />
Das Plugin Kompass wurde soeben erfolgreich installiert.<br />Im Hintergrund wurden bereits erste Optimierungen an der Webseite vorgenommen, so wurde die Navcigation vereinfacht, und falls dies noch nicht der Fall war, wurde die Webseite mit einer suchmaschinenfreundlichen Struktur ausgestattet.<br />
Es wurden bereits erste sicherheitsrelevante Plugins installiert. Du findest die Übersicht, welchePlugins aktiv sind, jederzeit <a href="plugins.php">hier</a><br /><br />
Über die Kalender-Einstellungen kannst du den Kalender deines Stammes aus dem Wiki auf deiner Webseite einbinden, dieser erscheint dann automatisch unt er der Adresse <a href="<?php echo get_site_url() . '/kalender'; ?>"><?php echo get_site_url() . '/kalender'; ?></a><br /><br />
Aus Sicherheitsgründen empfiehlt es sich, die Adresse zum Dashboard deiner Webseite ztu verschleiern. Ein hierfür notwendiges Plugin wurde automatisch installiert. Um dich zukünftig auf deiner Webseite einzuloggen, nutze folgende URL:<br />
<label><?php echo get_site_url(); ?>/</label><input style="width: 250px;" class="long_text" type="text" name="login_url" id="login_url" required
value = "<?php echo get_option('whl_page', 'bdp_login'); ?>">
<br /><input class="bdp_submit" type="submit" name="submit" value="Verändere diese URL noch einmal"><br /><br />
Falls du zu diesem Plugin Anmerkungen oder Fragen hast, wende dich bitte an den LB IT.
</fieldset>
</div>
</form>

View File

@ -0,0 +1,3 @@
<?php
require_once dirname(__FILE__) . '/classes/Security.class.php';

View File

@ -4,15 +4,18 @@ namespace Bdp\Modules\Security;
use ZipArchive; use ZipArchive;
class Security class Security
{ {
public const required_security_plugins = []; public const required_security_plugins = [
'wps_hide_login' => ['downloadUrl' => 'https://downloads.wordpress.org/plugin/wps-hide-login.1.9.10.zip'],
'limit-login-attempts-reloaded' => ['downloadUrl' => 'https://downloads.wordpress.org/plugin/limit-login-attempts-reloaded.2.25.27.zip']];
public const delete_plugins = [ public const delete_plugins = [
'akismet/akismet.php', 'akismet/akismet.php',
'hello.php', 'hello.php'
'wps-hide-login/wps-hide-login.php',
'limit-login-attempts-reloaded'
]; ];
public static function setup() public static function setup()
@ -23,98 +26,17 @@ class Security
self::installSecurityPlugin($pluginSlug, $pluginData['downloadUrl']); self::installSecurityPlugin($pluginSlug, $pluginData['downloadUrl']);
} }
} }
$loginUrl = get_option('kompass_sec_rewrite_login', null);
if (null == $loginUrl) {
$loginUrl = get_option('whl_page', null) ?? 'bdp-login';
}
enable_option_rewrite_url($loginUrl); $loginUrl = get_option('whl_page', 'bdp_login');
enable_option_disable_xmlrpc(); update_option('whl_page', $loginUrl);
enable_option_block_authorscan();
enable_option_block_execution_in_uploads();
enable_option_prohibit_special_files();
enable_option_file_editor();
enable_option_disable_conatenation();
enable_option_secure_include_dir();
enable_option_prohibit_bot_access();
enable_option_block_directory_listing();
self::resetLimitLoginAttempts();
delete_option('whl_page');
} }
public static function deletePlugins() { public static function deletePlugins() {
$existingPlugins = []; deactivate_plugins(self::delete_plugins);
foreach (self::delete_plugins as $curPlugin) { delete_plugins(self::delete_plugins);
if (file_exists(WP_PLUGIN_DIR . '/' . $curPlugin)) {
$existingPlugins[] = $curPlugin;
}
}
deactivate_plugins($existingPlugins);
delete_plugins($existingPlugins);
} }
public static function ProhibitBots() {
$botList = get_prohibitedbot_list();
if (!is_bot_access_prohibited() || count($botList) == 0) {
return;
}
foreach ($botList as $botListEntry) {
if (stripos($_SERVER['HTTP_USER_AGENT'], $botListEntry) !== false) {
status_header(403);
die();
}
}
}
public static function protectAuthorScan()
{
global $wp;
if (str_starts_with($wp->request, 'author/') && is_authorscan_blocked()) {
status_header(403);
die();
}
}
public static function SetPageFilters() {
global $wp;
if (str_contains($_SERVER['REQUEST_URI'], 'wp-login.php?action=logout')) {
return;
}
add_action('template_redirect', [Security::class, 'protectAuthorScan']);
Security::protectLoginSecurity();
}
public static function protectLoginSecurity() {
$hideLogin = is_login_rewritten();
if (null === $hideLogin) {
return;
}
if ( str_contains( $_SERVER['REQUEST_URI'], 'wp-login.php' ) && ! isset( $_POST['redirect_to'] ) && $_POST['redirect_to'] !== 'interner-bereich' ) {
wp_redirect( home_url() );
die();
}
if ( str_contains( $_SERVER['REQUEST_URI'], $hideLogin ) !== false ) {
$user_login = '';
$_REQUEST['redirect_to'] = 'interner-bereich';
require_once 'wp-login.php';
die();
}
if ( str_contains( $_SERVER['REQUEST_URI'], 'interner-bereich' ) !== false ) {
wp_redirect( '/wp-admin' );
die();
}
}
public static function installSecurityPlugin(string $pluginSlug, string $downloadUrl) : bool public static function installSecurityPlugin(string $pluginSlug, string $downloadUrl) : bool
{ {
@ -150,16 +72,4 @@ class Security
return $result === null; return $result === null;
} }
public static function resetLimitLoginAttempts() {
update_option('kompass_limit_login_lockout_duration', 900);
update_option('kompass_limit_login_allowed_retries', 3);
update_option('kompass_limit_login_allowed_lockouts', 3);
update_option('kompass_password_minimal_strength', 3);
update_option('kompass_limit_login_client_type', 'REMOTE_ADDR');
update_option('kompass_limit_login_long_duration', 86400);
update_option('kompass_limit_login_lockout_notify', ['email']);
update_option('kompass_limit_login_notify_email_after', 3);
update_option('kompass_limit_login_cookies',0);
}
} }

View File

@ -1,79 +0,0 @@
<?php
use Bdp\Libs\FileAccess as FileAccess;
use Bdp\Libs\WpConfigEditor as WpConfigEditor;
function is_xmlrpc_disabled() : bool {
return FileAccess::htaccessContains(_protect_wp_disablexmlrpc_string());
}
function is_authorscan_blocked() : bool {
return get_option('protect_wp_hide_authors', false);
}
function is_execution_in_uploads_blocked() : bool {
return FileAccess::htaccessContains(_protect_wp_disable_script_execution_string(), FileAccess::HTACCESS_UPLOADS);
}
function is_access_for_special_files_prohibited() : bool {
return FileAccess::htaccessContains(_protect_wp_disable_special_files_string());
}
function is_file_editor_diabled() : bool {
$isDisabled = WpConfigEditor::getConfigValue('DISALLOW_FILE_EDIT');
if (null == $isDisabled) {
return false;
}
if ('false' == $isDisabled) {
return false;
}
return true;
}
function is_conatenation_disabled() : bool {
$isDisabled = WpConfigEditor::getConfigValue('CONCATENATE_SCRIPTS');
if (null == $isDisabled) {
return false;
}
if ('false' == $isDisabled) {
return false;
}
return true;
}
function is_includedir_protected() : bool {
return FileAccess::htaccessContains(_protect_wp_secure_include_dir_string());
}
function is_directory_listing_disabled() : bool {
return FileAccess::htaccessContains(_protect_wp_disable_directory_listing_string());
}
function is_bot_access_prohibited() : bool {
return get_option('protect_wp_prohibit_bot_access', false);
}
function get_prohibitedbot_list() {
$returnValue = [];
$botList = get_option('protect_wp_prohibit_bot_list', null);
if ($botList !== null) {
$returnValue = unserialize(trim($botList));
}
return $returnValue;
}
function is_wp_debug_diabled() : bool
{
$wpDebugValue = WpConfigEditor::getConfigValue('WP_DEBUG');
return ('false' == $wpDebugValue || null == $wpDebugValue);
}
function is_login_rewritten() : ?string
{
return get_option('kompass_sec_rewrite_login', null);
}

View File

@ -1,160 +0,0 @@
<?php
use Bdp\Libs\FileAccess as FileAccess;
use Bdp\Libs\WpConfigEditor as WpConfigEditor;
function disable_option_disable_xmlrpc() {
return FileAccess::deleteFromHtaccess(_protect_wp_disablexmlrpc_string());
}
function enable_option_disable_xmlrpc() : bool {
return FileAccess::insertInHtaccess(_protect_wp_disablexmlrpc_string());
}
function enable_option_block_authorscan() {
update_option('protect_wp_hide_authors', true);
}
function disable_option_block_authorscan() {
update_option('protect_wp_hide_authors', false);
}
function disable_option_block_execution_in_uploads() {
return FileAccess::deleteFromHtaccess(_protect_wp_disable_script_execution_string(), FileAccess::HTACCESS_UPLOADS);
}
function enable_option_block_execution_in_uploads() {
return FileAccess::insertInHtaccess(_protect_wp_disable_script_execution_string(), FileAccess::HTACCESS_UPLOADS);
}
function disable_option_prohibit_special_files() {
return FileAccess::deleteFromHtaccess(_protect_wp_disable_special_files_string());
}
function enable_option_prohibit_special_files() {
return FileAccess::insertInHtaccess(_protect_wp_disable_special_files_string());
}
function disable_option_file_editor() {
return WpConfigEditor::updateConfig('DISALLOW_FILE_EDIT', 'false');
}
function enable_option_file_editor() {
return WpConfigEditor::updateConfig('DISALLOW_FILE_EDIT', 'true');
}
function enable_option_disable_conatenation() {
return WpConfigEditor::updateConfig('CONCATENATE_SCRIPTS', 'true');
}
function disable_option_disable_conatenation() {
return WpConfigEditor::updateConfig('CONCATENATE_SCRIPTS', 'false');
}
function disable_option_secure_include_dir() {
return FileAccess::deleteFromHtaccess(_protect_wp_secure_include_dir_string());
}
function enable_option_secure_include_dir() : bool {
return FileAccess::insertInHtaccess(_protect_wp_secure_include_dir_string());
}
function enable_option_prohibit_bot_access() {
update_option('protect_wp_prohibit_bot_access', true);
if (count(get_prohibitedbot_list()) == 0) {
set_prohibitedbot_list(_protect_wp_initial_bot_list_array());
}
}
function disable_option_prohibit_bot_access() {
update_option('protect_wp_prohibit_bot_access', false);
}
function set_prohibitedbot_list($botList) {
update_option('protect_wp_prohibit_bot_list', serialize($botList));
}
function enable_option_block_directory_listing() : bool {
return FileAccess::insertInHtaccess(_protect_wp_disable_directory_listing_string());
}
function disable_option_block_directory_listing() : bool {
return FileAccess::deleteFromHtaccess(_protect_wp_disable_directory_listing_string());
}
function enable_option_disable_wp_debug() {
WpConfigEditor::updateConfig('WP_DEBUG', 'false');
}
function disable_option_disable_wp_debug() {
WpConfigEditor::updateConfig('WP_DEBUG', 'true');
}
function enable_option_rewrite_url(?string $url = null) {
global $_POST;
$saveUrl = $url ?? $_POST['rewrite_login'];
update_option('kompass_sec_rewrite_login', $saveUrl);
}
function disable_option_rewrite_url() {
update_option('kompass_sec_rewrite_login', null);
}
function kompass_sec_save_settings($settings) {
$allPossibleSettings = [
'option_disable_xmlrpc',
'option_block_authorscan',
'option_block_execution_in_uploads',
'option_prohibit_special_files',
'option_file_editor',
'option_disable_conatenation',
'option_secure_include_dir',
'option_prohibit_bot_access',
'option_block_directory_listing',
'option_disable_wp_debug',
'option_rewrite_url',
];
$enableSettings = array_intersect($allPossibleSettings, $settings);
$disableSettings = array_diff($allPossibleSettings, $settings);
foreach ($disableSettings as $curSetting) {
$function = 'disable_' . $curSetting;
$function();
}
foreach ($enableSettings as $curSetting) {
$function = 'enable_' . $curSetting;
$function();
}
?>
<div class="notice notice-success">
<p>
<?= __('All settings are saved.', BDP_LV_PLUGIN_SLUG); ?>
</p>
</div>
<?php
return;
}
function kompass_sec_site_keys() {
$content = wp_remote_get('https://api.wordpress.org/secret-key/1.1/salt/');
if (!is_array($content) || !isset($content['body'])) {
?>
<div class="notice notice-error">
<p>
<?= __('An error occured connecting api.wordpress.org', BDP_LV_PLUGIN_SLUG); ?>
</p>
</div>
<?php
return;
}
WpConfigEditor::updateSiteKeys($content['body']);
?>
<div class="notice notice-success">
<p>
<?= __('The site keys were updated successfully.', BDP_LV_PLUGIN_SLUG); ?>
</p>
</div>
<?php
}

View File

@ -1,22 +0,0 @@
<h2><?= __('Bot Detection Database', BDP_LV_PLUGIN_SLUG); ?></h2>
<div class="pwp_setting_box">
<h3><?= __('Registered bots', BDP_LV_PLUGIN_SLUG); ?></h3>
<?php
foreach (get_prohibitedbot_list() as $currenBot) {
?>
<p style=" margin: 10px auto; width: 80%;">
<input type="text" name="existing_bots[]" value="<?= $currenBot ?>" style="width: 100%;" /><br />
<label style="cursor: default; color: #a0a0a0; fot-size: 9pt; font-style: italic"><?= __('Leave blank in order to delete', BDP_LV_PLUGIN_SLUG); ?></label>
</p>
<?php
}
?>
</div>
<div class="pwp_setting_box">
<h3><?= __('Add more bots', BDP_LV_PLUGIN_SLUG); ?></h3>
<p style=" margin: 10px auto; width: 80%;">
<textarea placeholder="<?= __('Please use line breaks to enter multiple bots', BDP_LV_PLUGIN_SLUG); ?>" name="new_bots[]" style="width: 100%;" rows="10"></textarea>
</p>
</div>
<br /><br />
<input type="submit" class="button" value="<?= __('Save changes', BDP_LV_PLUGIN_SLUG); ?>" />

View File

@ -1,6 +1,6 @@
<?php <?php
echo '<div class="health-check-body health-check-debug-tab hide-if-no-js">'; echo '<div class="health-check-body health-check-debug-tab hide-if-no-js">';
echo '<h2>Erweiterte Sicherheitseinstellungen</h2>'; echo '<h1>Erweiterte Sicherheitseinstellungen</h1>';
if (isset($_POST['submit'])) { if (isset($_POST['submit'])) {
echo '<div id="bdp_success">Die Einstellungen wurden gespeichert.</div>'; echo '<div id="bdp_success">Die Einstellungen wurden gespeichert.</div>';
update_option('whl_page', $_POST['login_url']); update_option('whl_page', $_POST['login_url']);
@ -9,12 +9,13 @@ if (isset($_POST['submit'])) {
<form method="post" action="admin.php?page=bdp-kompass%2Fmodules%2Findex.php&loadmodule=security"> <form method="post" action="admin.php?page=bdp-kompass%2Fmodules%2Findex.php&loadmodule=security">
<div class="bdp_security_outer"> <div class="bdp_security_outer">
<fieldset class="bdp_security_inner">
<legend>Wordpress-Login</legend>
<table> <table>
<tr style="vertical-align: top;"> <tr style="vertical-align: top;">
<td style="font-weight: bold; padding-right: 10px;"><br />Login-URL:</td> <td>Login-URL:</td>
<td style="vertical-align: top;"> <td> <label><?php echo get_site_url(); ?>/</label><input style="width: 100px;" class="long_text" type="text" name="login_url" id="login_url" required
<label>
<?php echo get_site_url(); ?>/</label><input style="width: 100px;" class="long_text" type="text" name="login_url" id="login_url" required
value = "<?php echo get_option('whl_page', 'bdp_login'); ?>" value = "<?php echo get_option('whl_page', 'bdp_login'); ?>"
>/<br /> >/<br />
<label style="font-weight: normal; color: #a0a0a0; font-style: italic"> <label style="font-weight: normal; color: #a0a0a0; font-style: italic">
@ -22,9 +23,9 @@ if (isset($_POST['submit'])) {
</label> </label>
</td> </td>
</tr> </tr>
</table><br /><br /> </table>
</fieldset>
<input class="button" type="submit" name="submit" value="Einstellungen speichern"> <input class="bdp_submit" type="submit" name="submit" value="Einstellungen speichern">
</div> </div>
</form> </form>

View File

@ -1,118 +0,0 @@
<h2><?= __('Extended Security', BDP_LV_PLUGIN_SLUG); ?></h2>
<div class="bdp_setting_box">
<input <?php if (is_xmlrpc_disabled()) {echo ' checked';} ?> type="checkbox" id="sec_mod_1" name="security_settings[]" value="option_disable_xmlrpc" />
<label for="sec_mod_1">
<?= __('Disable xmlrpc', BDP_LV_PLUGIN_SLUG); ?><br />
<span>
<?= __('By introducing the REST API in WordPress, xmlrpc. However, php is no longer needed to communicate outside of WordPress, which is why there is no longer any reason to leave it active or use it. Therefore, for the security of your site, it is better to deactivate or delete it.', BDP_LV_PLUGIN_SLUG); ?>
</span>
</label>
</div>
<div class="bdp_setting_box">
<input <?php if (is_authorscan_blocked()) {echo ' checked';} ?> type="checkbox" id="sec_mod_2" name="security_settings[]" value="option_block_authorscan" />
<label for="sec_mod_2">
<?= __('Disable Authorscan', BDP_LV_PLUGIN_SLUG); ?><br />
<span>
<?= __('The author page in WordPress typically displays a list of all posts by a specific author on your website. Unfortunately, Google also records the page and to prevent this, we can deactivate the author page. When a visitor clicks on an name of an author, they are redirected to the author page. This page contains a list of posts written by this author, as well as possibly a brief description of the author and a photo. It is also possible to record which user names have been created.', BDP_LV_PLUGIN_SLUG); ?>
</span>
</label>
</div>
<div class="bdp_setting_box">
<input <?php if (is_execution_in_uploads_blocked()) {echo ' checked';} ?> type="checkbox" id="sec_mod_3" name="security_settings[]" value="option_block_execution_in_uploads" />
<label for="sec_mod_3">
<?= __('Disable scripting in /wp-content/uploads/', BDP_LV_PLUGIN_SLUG); ?><br />
<span>
<?= __('Disabling scripting in /wp-content/uploads/ can be a security measure to protect your WordPress website from potential threats. The /wp-content/uploads folder is usually the default folder where WordPress stores uploaded files, such as images, videos, and other media files.', BDP_LV_PLUGIN_SLUG); ?>
</span>
</label>
</div>
<div class="bdp_setting_box">
<input <?php if (is_access_for_special_files_prohibited()) {echo ' checked';} ?> type="checkbox" id="sec_mod_4" name="security_settings[]" value="option_prohibit_special_files" />
<label for="sec_mod_4">
<?= __('Block access to potentially sensitive files', BDP_LV_PLUGIN_SLUG); ?><br />
<span>
<?= __('This setting prohibits access to configuration files and log files', BDP_LV_PLUGIN_SLUG); ?>
</span>
</label>
</div>
<div class="bdp_setting_box">
<input <?php if (true === is_file_editor_diabled()) {echo ' checked';} ?> type="checkbox" id="sec_mod_5" name="security_settings[]" value="option_file_editor" />
<label for="sec_mod_5">
<?= __('Disable file editor in WP Dashboard', BDP_LV_PLUGIN_SLUG); ?><br />
<span>
<?= __('This is a security feature that allows you to prevent users from editing theme and plugin files directly from the WordPress dashboard. This can be useful for a variety of reasons, including preventing accidental code changes and protecting your website from malicious attacks.', BDP_LV_PLUGIN_SLUG); ?>
</span>
</label>
</div>
<div class="bdp_setting_box">
<input <?php if (true === is_conatenation_disabled()) {echo ' checked';} ?> type="checkbox" id="sec_mod_6" name="security_settings[]" value="option_disable_conatenation" />
<label for="sec_mod_6">
<?= __('Disable script concatenation', BDP_LV_PLUGIN_SLUG); ?><br />
<span>
<?= __('Disabling script concatenation in the WordPress admin panel is a simple and effective way to enhance performance. However, it is crucial to carefully consider the impact of this change, as it may increase the number of HTTP requests, potentially affecting loading times', BDP_LV_PLUGIN_SLUG); ?>
</span>
</label>
</div>
<div class="bdp_setting_box">
<input <?php if (true === is_includedir_protected()) {echo ' checked';} ?> type="checkbox" id="sec_mod_7" name="security_settings[]" value="option_secure_include_dir" />
<label for="sec_mod_7">
<?= __('Disable script execution in include dir', BDP_LV_PLUGIN_SLUG); ?><br />
<span>
<?= __('Limiting script execution in specific directories can improve security by preventing potentially malicious scripts from running in critical parts of the WordPress system. This is particularly important to prevent attacks such as Cross-Site Scripting (XSS), which inject malicious code into website content.', BDP_LV_PLUGIN_SLUG); ?>
</span>
</label>
</div>
<div class="bdp_setting_box">
<input <?php if (true === is_bot_access_prohibited()) {echo ' checked';} ?> type="checkbox" id="sec_mod_8" name="security_settings[]" value="option_prohibit_bot_access" />
<label for="sec_mod_8">
<?= __('Prohibit access from unwanted bots', BDP_LV_PLUGIN_SLUG); ?><br />
<span>
<?= __('Excluding specific bots from a WordPress website provides improved security by reducing potentially malicious activity and security risks, optimizes resource consumption and site performance, protects against content theft and duplicate content, enables more precise control of traffic, and promotes more effective SEO -Optimization by reducing irrelevant bots, ultimately leading to a safer, more efficient and better performing website.', BDP_LV_PLUGIN_SLUG); ?><br />
<a href="site-health.php?tab=bdp_enhanced_security&subpage=botlist"><?= __('Bot Detection Database', BDP_LV_PLUGIN_SLUG); ?></a>
</span>
</label>
</div>
<div class="bdp_setting_box">
<input <?php if (true === is_directory_listing_disabled()) {echo ' checked';} ?> type="checkbox" id="sec_mod_9" name="security_settings[]" value="option_block_directory_listing" />
<label for="sec_mod_9">
<?= __('Disable directory listing', BDP_LV_PLUGIN_SLUG); ?><br />
<span>
<?= __('Directory listing should be disabled to ensure the security and privacy of a website. When Directory Listing is enabled, this allows users to directly access the contents of directories on a web server without having to specify a specific file. This can expose sensitive information such as directory structures, internal files and scripts, posing a potential security risk. Disabling Directory Listing prevents users from accessing this sensitive information, thereby providing an additional layer of security for the website.', BDP_LV_PLUGIN_SLUG); ?>
</span>
</label>
</div>
<div class="bdp_setting_box">
<input <?php if (true === is_wp_debug_diabled()) {echo ' checked';} ?> type="checkbox" id="sec_mod_10" name="security_settings[]" value="option_disable_wp_debug" />
<label for="sec_mod_10">
<?= __('Disable debug output', BDP_LV_PLUGIN_SLUG); ?><br />
<span>
<?= __('Debugging should be disabled to protect sensitive information about the internal structure and potential security vulnerabilities of a a WordPress website from potential attackers. When debugging is enabled, error messages and warnings are displayed directly on the website, which can provide attackers with valuable information about the configuration of the website and possible vulnerabilities.', BDP_LV_PLUGIN_SLUG); ?>
</span>
</label>
</div>
<div class="bdp_setting_box">
<input <?php if (null !== is_login_rewritten()) {echo ' checked';} ?> type="checkbox" id="sec_mod_11" name="security_settings[]" value="option_rewrite_url" />
<label for="sec_mod_11">
<?= __('Change Login URL', BDP_LV_PLUGIN_SLUG); ?><br />
<span>
<?= __('Changing the default login URL of WordPress is advisable to enhance the security of your website. By default, WordPress login URLs is /wp-admin or /wp-login.php, which are easily guessed by hackers and facilitate attacks such as brute-force attacks. Changing the login URL to something unique and difficult to guess increases security since potential attackers will struggle to find the correct URL. This can help protect your website from unauthorized access and other malicious activities.', BDP_LV_PLUGIN_SLUG); ?><br />
<label style="font-weight: bold;">
<?= __('Login-URL', BDP_LV_PLUGIN_SLUG) ?>: <?= get_site_url(); ?>/<input style="width: 100px;" class="long_text" type="text" name="rewrite_login" id="rewrite_login" value="<?= is_login_rewritten(); ?>">
</label>
</span>
</label>
</div>
<br /><br />
<input type="submit" class="button" value="<?= __('Save changes', BDP_LV_PLUGIN_SLUG); ?>" />
<a class="button" href="site-health.php?tab=bdp_enhanced_security&action=updatesitekeys"><?= __('Change site keys', BDP_LV_PLUGIN_SLUG); ?></a>

View File

@ -1,51 +1,19 @@
<?php <?php
require_once dirname(__FILE__) . '/includes/settings_reader.php';
require_once dirname(__FILE__) . '/includes/settings_writer.php';
function wp_example_site_health_navigation_tabs( $tabs ) { function wp_example_site_health_navigation_tabs( $tabs ) {
// translators: Tab heading for Site Health navigation. // translators: Tab heading for Site Health navigation.
$tabs['bdp_enhanced_security'] = esc_html_x('Erweiterte Sicherheit', 'Site Health', 'text-domain'); $tabs['loginurl'] = esc_html_x( 'Login-URL', 'Site Health', 'text-domain' );
return $tabs; return $tabs;
} }
add_filter( 'site_health_navigation_tabs', 'wp_example_site_health_navigation_tabs' ); add_filter( 'site_health_navigation_tabs', 'wp_example_site_health_navigation_tabs' );
function wp_example_site_health_tab_content($tab) function wp_example_site_health_tab_content($tab)
{ {
if ('bdp_enhanced_security' === $tab) { // Do nothing if this is not our tab.
if (isset($_GET['subpage']) && $_GET['subpage'] == 'botlist') { if ('loginurl' === $tab) {
if (isset($_POST['save_settings']) && isset($_POST['existing_bots']) && isset($_POST['new_bots'])) { require_once dirname(__FILE__) . '/internal/index.php';
protect_wp_save_bots($_POST['existing_bots'], $_POST['new_bots']);
}
echo '<div class="health-check-body health-check-status-tab hide-if-no-js">';
echo '<form method="post" action="site-health.php?tab=' . BDP_LV_PLUGIN_SLUG . '&subpage=botlist">';
echo '<input type="hidden" name="save_settings" value="true" />';
require BDP_LV_PLUGIN_DIR . 'modules/security/internal/botlist-tab.php';
echo '</form>';
echo '</div>';
return;
}
update_option('protect_wp_needs_attention', false);
if (isset($_POST['save_settings'])) {
$securitySettings = [];
if (isset($_POST['security_settings'])) {
$securitySettings = $_POST['security_settings'];
}
kompass_sec_save_settings($securitySettings);
}
if (isset($_GET['action']) && $_GET['action'] == 'updatesitekeys') {
kompass_sec_site_keys();
}
echo '<div class="health-check-body health-check-status-tab hide-if-no-js">';
echo '<form method="post" action="site-health.php?tab=bdp_enhanced_security">';
echo '<input type="hidden" name="save_settings" value="true" />';
require BDP_LV_PLUGIN_DIR . 'modules/security/internal/site-health-tab.php';
echo '</form>';
echo '</div>';
return; return;
} }
} }