/** * Whitelists this attempt by ip address * * @return bool */ public function whitelist() { $ip = $this->get( 'ip_address' ); if ( $ip ) { $whitelist = new cbantispamWhitelistTable(); $whitelist->load( array( 'value' => $ip, 'type' => 'ip' ) ); if ( ! $whitelist->get( 'id' ) ) { $whitelist->set( 'type', 'ip' ); $whitelist->set( 'value', $ip ); if ( ! $whitelist->store() ) { $this->setError( $whitelist->getError() ); return false; } } } return true; }
/** * Saves a user whitelist * * @param int $id * @param UserTable $user */ private function saveWhitelist( $id, $user ) { global $_CB_framework; $profileUrl = $_CB_framework->userProfileUrl( (int) $user->get( 'id' ), false, $this->_tab ); if ( ! $user->get( 'id' ) ) { cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); } $row = new cbantispamWhitelistTable(); $row->load( (int) $id ); $row->set( 'type', $this->input( 'type', $row->get( 'type' ), GetterInterface::STRING ) ); $row->set( 'value', $this->input( 'value', $row->get( 'value' ), GetterInterface::STRING ) ); $row->set( 'reason', $this->input( 'reason', $row->get( 'reason' ), GetterInterface::STRING ) ); if ( $row->get( 'type' ) == '' ) { $row->setError( CBTxt::T( 'Type not specified!' ) ); } elseif ( $row->get( 'value' ) == '' ) { $row->setError( CBTxt::T( 'Value not specified!' ) ); } if ( $row->getError() || ( ! $row->store() ) ) { $this->showBlock( $id, $row->get( 'type' ), $user, CBTxt::T( 'WHITELIST_SAVE_FAILED', 'Whitelist failed to save! Error: [error]', array( '[error]' => $row->getError() ) ) ); return; } cbRedirect( $profileUrl, CBTxt::T( 'Whitelist saved successfully!' ) ); }