You are here

function badbehavior_event in Bad Behavior 5.2

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

File

./badbehavior.module, line 103

Code

function badbehavior_event($id = NULL) {
  if (file_exists(BB2_CWD . '/bad-behavior/core.inc.php') && file_exists(BB2_CWD . '/bad-behavior/version.inc.php') && file_exists(BB2_CWD . '/bad-behavior/responses.inc.php')) {
    require_once BB2_CWD . '/bad-behavior/version.inc.php';
    require_once BB2_CWD . '/bad-behavior/core.inc.php';
    require_once BB2_CWD . '/bad-behavior/responses.inc.php';
  }
  else {
    return 'Bad Behavior is not installed correctly.';
  }
  $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;
}