Skip to content

white_list #24

@chefmech

Description

@chefmech

I added a whitelist to bfstop. Would be nice, if you could include something like that to your plugin:

2 new functions,
1 new DB-table,
1 extension in function onUserLoginFailure

//-----------------------------------------------------------------------------------------------------
function isIPwhitelist($ipaddress)
{
    $sqlCheck = "SELECT COUNT(*) from #__bfstop_whitelistip where ipaddress='$ipaddress'";
    $this->db->setQuery($sqlCheck);
    $numRows = $this->db->loadResult();
    $this->checkDBError();
    return ($numRows > 0);
}   


public function onUserLogin($user, $options = array())
{
    //add IP to the whitelist

    $blockEnabled  = (bool)$this->params->get('blockEnabled');
    if (!$blockEnabled) {
        return true;
    }else{

        $ip = $this->getIPAddr();

        //IP not in whitelist already
        if (!$this->isIPwhitelist($ip)){

            $whitelistEntry = new stdClass();
            $whitelistEntry->ipaddress = $ip;
            $whitelistEntry->user = $user['username'];

            $this->db->insertObject('#__bfstop_whitelistip', $whitelistEntry);
            $this->checkDBError();      
        }

        return true;
    }
}   

public function onUserLoginFailure($user, $options=null)
{

    //Check whitelist                                
    if ($this->isIPwhitelist($this->getIPAddr())){        
        return true;
    }
              ............
//-----------------------------------------------------------------------------------------------------

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions