You are here

function badbehavior_event in Bad Behavior 6

Same name and namespace in other branches
  1. 5.2 badbehavior.module \badbehavior_event()
  2. 6.2 badbehavior.admin.inc \badbehavior_event()
  3. 7.2 badbehavior.admin.inc \badbehavior_event()
1 string reference to 'badbehavior_event'
badbehavior_menu in ./badbehavior.module
Implements hook_menu().

File

./badbehavior.admin.inc, line 42
Admin page callbacks for the badbehavior module.

Code

function badbehavior_event($id = NULL) {
  if (!badbehavior_load_includes(array(
    'responses',
  ))) {
    return 'Bad Behavior is not installed correctly.  Please download Bad Behavior and extract /bad-behavior/bad-behavior from the zip to sites/all/libraries/bad-behavior';
  }
  $output = '';
  $result = db_query('SELECT w.* FROM {bad_behavior_log} w WHERE w.id = %d', $id);
  if ($behave = db_fetch_object($result)) {
    $response = bb2_get_response($behave->key);
    $behave->localdate = bb2_convertdate($behave->date);
    $output .= '<table border="1" cellpadding="2" cellspacing="2">';
    $output .= ' <tr><th>' . t('IP Addr') . '</th><td>' . $behave->ip . '</td></tr>';
    $output .= ' <tr><th>' . t('Hostname') . '</th><td>' . gethostbyaddr($behave->ip) . ' (' . l('whois', 'http://www.whois.sc/' . $behave->ip) . ')</td></tr>';
    $output .= ' <tr><th>' . t('Date') . '</th><td>' . $behave->date . '</td></tr>';
    $output .= ' <tr><th>' . t('Request type') . '</th><td>' . $behave->request_method . '</td></tr>';
    $output .= ' <tr><th>' . t('URI') . '</th><td>' . $behave->request_uri . '</td></tr>';
    $output .= ' <tr><th>' . t('Protocol') . '</th><td>' . $behave->server_protocol . '</td></tr>';
    $output .= ' <tr><th>' . t('User Agent') . '</th><td>' . $behave->user_agent . '</td></tr>';
    $output .= ' <tr><th>' . t('Headers') . '</th><td>' . $behave->http_headers . '</td></tr>';
    $output .= ' <tr><th>' . t('Request Entity') . '</th><td>' . $behave->request_entity . '</td></tr>';
    $output .= ' <tr><th>' . t('Denied Reason') . '</th><td>' . $response['log'] . '</td></tr>';
    $output .= ' <tr><th>' . t('Explanation') . '</th><td>' . $response['explanation'] . '</td></tr>';
    $output .= ' <tr><th>' . t('Response') . '</th><td>' . $response['response'] . '</td></tr>';
    $output .= '</table>';
  }
  return $output;
}