127,'age'=>0,'threat'=>0,'type'=>-1); } elseif(isset($_SESSION['httpbl_status'])) { $status = $_SESSION['httpbl_status']; } else { $request = Options::get('httpbl__apikey') . '.' . implode('.', array_reverse(explode(".", $_SERVER["REMOTE_ADDR"]))) . '.dnsbl.httpbl.org'; $response = explode('.', gethostbyname($request)); if(reset($response) == '127') { $result = array_combine(array('ok', 'age', 'threat', 'type'), $response); $status = $result; } else { $status = array('ok'=>127,'age'=>0,'threat'=>0,'type'=>-1); } } if(!isset($status['valid'])) { if($status['type'] != -1) { $age_th = intval(Options::get('httpbl__age_th')); $threat_th = intval(Options::get('httpbl__threat_th')); $types = is_array(Options::get('httpbl__types'))?array_sum(Options::get('httpbl__types')):Options::get('httpbl__types'); $valid = true; if($status['threat'] >= $threat_th) { $valid = false; } if($status['age'] >= $age_th ) { $valid = true; } if(intval($status['type']) && $types == 0) { $valid = true; } $status['valid'] = $valid; } else { $status['valid'] = true; } $_SESSION['httpbl_status'] = $status; } if(isset($op)) { return $status[$op]; } else { return $status; } } function action_init() { // Should check against criteria to see if this post submission should be denied if($_SERVER['REQUEST_METHOD'] != 'GET' && !$this->get_status('valid')) { $caught = Options::get('httpbl__caught'); Options::set('httpbl__caught', intval($caught) + 1); header('HTTP/1.1 403 Forbidden'); die(); } } function theme_footer($theme) { return ''; } function filter_dashboard_status($statuses) { if(Options::get('httpbl__apikey') == '') { $statuses['http:Bl'] = 'Needs API Key'; } else { $statuses[_t('http:Bl rejected')] = _t('%d spammers', array(intval(Options::get('httpbl__caught')))); } return $statuses; } public function configure() { $form = new FormUI('httpbl'); $form->append( 'text', 'apikey', 'httpbl__apikey', _t( 'API Key' ) ); $form->append( 'static', 'threatths', _t('Visitors with a threat level higher than this are determined to be spammers:')); $form->append( 'text', 'threatth', 'httpbl__threat_th', _t( 'Threat Threshhold' ) ); $form->threatth->add_validator('validate_range', 0, 255); $form->append( 'static', 'ageths', _t('Ignore IP records that are older than this number of days:')); $form->append( 'text', 'ageth', 'httpbl__age_th', _t( 'Age Threshhold' ) ); $form->ageth->add_validator('validate_range', 0, 255); $form->append( 'static', 'typess', _t('Block comments from threats listed as:')); $types = $form->append( 'checkboxes', 'httpbl__types', _t('Threat Types')); $types->options = array(1=>_t('Suspicious'),2=>_t('Harvester'),4=>_t('Spammer')); $form->append( 'submit', 'submit', 'Submit' ); return $form; } public function help() { return <<< END_HELP
This is the help text for the test plugin.
END_HELP; } } ?>