/** * Blocks this attempt by ip address * * @return bool */ public function block() { global $_CB_framework; $ip = $this->get( 'ip_address' ); if ( $ip ) { $block = new cbantispamBlockTable(); $block->load( array( 'value' => $ip, 'type' => 'ip' ) ); if ( ! $block->get( 'id' ) ) { $block->set( 'type', 'ip' ); $block->set( 'value', $ip ); $block->set( 'date', $_CB_framework->getUTCDate() ); if ( ! $block->store() ) { $this->setError( $block->getError() ); return false; } } } return true; }
/** * Deletes a user block * * @param int $id * @param UserTable $user */ private function deleteBlock( $id, $user ) { global $_CB_framework; $row = new cbantispamBlockTable(); $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( 'BLOCK_DELETE_FAILED', 'Block failed to delete! Error: [error]', array( '[error]' => $row->getError() ) ), 'error' ); } cbRedirect( $profileUrl, CBTxt::T( 'Block deleted successfully!' ) ); }