/** * 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; }
/** * Deletes a user whitelist * * @param int $id * @param UserTable $user */ private function deleteWhitelist( $id, $user ) { global $_CB_framework; $row = new cbantispamWhitelistTable(); $row->load( (int) $id ); $profileUrl = $_CB_framework->userProfileUrl( (int) $user->get( 'id' ), false, $this->_tab ); if ( ! $row->get( 'id' ) ) { cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); } if ( ! $row->delete() ) { cbRedirect( $profileUrl, CBTxt::T( 'WHITELIST_DELETE_FAILED', 'Whitelist failed to delete! Error: [error]', array( '[error]' => $row->getError() ) ), 'error' ); } cbRedirect( $profileUrl, CBTxt::T( 'Whitelist deleted successfully!' ) ); }