WordPress.org

Ready to get started?Download WordPress

Forums

IP Ban
Too many redirects (3 posts)

  1. umchal
    Member
    Posted 1 year ago #

    Hi,

    Nice plugin.

    I just tried it and when I set the redirect url to http:// mysite url ]/404.php, the browser could not load the page with the error, too many redirects...

    I briefly looked into the code and changed:

    function simple_ip_ban() {
    
        // Do nothing for admin user
        if ((is_user_logged_in() && is_admin()) ||
            (intval(get_option('s_not_for_logged_in_user')) == 1  && is_user_logged_in())) return '';
    
        $remote_ip = $_SERVER['REMOTE_ADDR'];
        $remote_ua = $_SERVER['HTTP_USER_AGENT'];
        if (s_check_ip_address($remote_ip, get_option('s_ip_list')) ||
            s_check_user_agent($remote_ua,get_option('s_ua_list'))) {
            $redirect_url = get_option('s_redirect_url');
            wp_redirect( $redirect_url );
            exit;
        }
    }

    to:

    function simple_ip_ban() {
    
        // Do nothing for admin user
        if ((is_user_logged_in() && is_admin()) ||
            (intval(get_option('s_not_for_logged_in_user')) == 1  && is_user_logged_in())) return '';
    
        $remote_ip = $_SERVER['REMOTE_ADDR'];
        $remote_ua = $_SERVER['HTTP_USER_AGENT'];
        if (s_check_ip_address($remote_ip, get_option('s_ip_list')) ||
            s_check_user_agent($remote_ua,get_option('s_ua_list'))) {
            $redirect_url = get_option('s_redirect_url');
    
    	if ( simple_ip_ban_get_current_url() == $redirect_url ) return '';
    
            wp_redirect( $redirect_url );
            exit;
        }
    }
    
    function simple_ip_ban_get_current_url() {
    $pageURL = (@$_SERVER["HTTPS"] == "on") ? "https://" : "http://";
    if ($_SERVER["SERVER_PORT"] != "80")
    {
        $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    }
    else
    {
        $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }
    return $pageURL;
    }

    Then it solved the issue. I hope this helps for somebody who gets the same issue.

    http://wordpress.org/extend/plugins/simple-ip-ban/

  2. Sandor Kovacs
    Member
    Plugin Author

    Posted 1 year ago #

    Thank you umchal.

    I will include your patch in the next deploy.

  3. Sandor Kovacs
    Member
    Plugin Author

    Posted 6 months ago #

    The fix was included into version 1.2.0.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.