Plugin Directory

Changeset 916385


Ignore:
Timestamp:
05/18/2014 05:19:28 AM (12 years ago)
Author:
Beej
Message:

Added block attempt counter

Location:
block-default-login-attempts/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • block-default-login-attempts/trunk/block-default-login-attempts.php

    r916357 r916385  
    33Plugin Name: Block Default Login Attempts
    44Description: Completely block default admin user login attempts in WordPress.
    5 Version: 1.2.2
     5Version: 1.3.0
    66Author: Ben Yates
    77Author URI: http://bayates.host-ed.me/wordpress/
     
    6060if (isset($_REQUEST['log']) and isset($_REQUEST['pwd'])) {
    6161    if ($_REQUEST['log'] == 'admin') {
     62        $attempts = get_option('block_default_login_attempts', 0);
     63        update_option('block_default_login_attempts', $attempts + 1);
    6264        bdla_write_log('Default login attempt IP: ' . $_SERVER['REMOTE_ADDR']
    6365            . ', HTTP_X_FORWARDED_FOR: ' . $_SERVER['HTTP_X_FORWARDED_FOR']
     
    7476    function bdla_auth_cookie_bad_username($cookie_elements) {
    7577        if ($cookie_elements['username'] == 'admin') {
     78            $attempts = get_option('block_default_login_attempts', 0);
     79            update_option('block_default_login_attempts', $attempts + 1);
    7680            bdla_write_log('Default login attempt (cookie) IP: ' . $_SERVER['REMOTE_ADDR']
    7781                . ', HTTP_X_FORWARDED_FOR: ' . $_SERVER['HTTP_X_FORWARDED_FOR']
     
    105109}
    106110
     111if (!function_exists('bdla_activation')) {
     112    function bdla_activation() {
     113        add_option('block_default_login_attempts', 0, '', 'no');
     114    }
     115    register_activation_hook(__FILE__, 'bdla_activation');
     116}
     117
     118if (!function_exists('bdla_plugin_row_meta')) {
     119    function bdla_plugin_row_meta($links, $file) {
     120        if (strpos($file, 'block-default-login-attempts.php') === false) return $links;
     121        $attempts = get_option('block_default_login_attempts', 0);
     122        if ($attempts) {
     123            $links_new = array('<b>' . $attempts . '</b> attempts blocked');
     124        } else {
     125            $links_new = array('No attempts encountered');
     126        }
     127        $links = array_merge($links, $links_new);
     128        return $links;
     129    }
     130    add_filter('plugin_row_meta', 'bdla_plugin_row_meta', 10, 2);
     131}
     132
    107133?>
  • block-default-login-attempts/trunk/readme.txt

    r915974 r916385  
    3232
    33331. A screenshot of a typical log entry
     342. Block attempt counter
Note: See TracChangeset for help on using the changeset viewer.