function badbehavior_event in Bad Behavior 6.2
Same name and namespace in other branches
- 5.2 badbehavior.module \badbehavior_event()
- 6 badbehavior.admin.inc \badbehavior_event()
- 7.2 badbehavior.admin.inc \badbehavior_event()
Builds the "Details" table displaying data about an individual log entry
Parameters
string $id:
Return value
string The table in HTML format
1 string reference to 'badbehavior_event'
- badbehavior_menu in ./
badbehavior.module - Implements hook_menu().
File
- ./
badbehavior.admin.inc, line 61 - 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. See the README.txt for installation details.';
}
$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>';
if ($behave->ip) {
$output .= $behave->ip . '</td></tr>';
}
else {
$output .= '<span style="color:red">Possible Proxy Settings Error:</span> No IP address reported</td></tr>';
}
$output .= ' <tr><th>' . t('Hostname') . '</th><td>';
if ($behave->ip) {
$output .= gethostbyaddr($behave->ip) . ' (' . l('whois', 'http://www.whois.sc/' . $behave->ip) . ')</td></tr>';
}
else {
$output .= '<span style="color:red">Possible Proxy Settings Error:</span> No hostname reported</td></tr>';
}
$output .= ' <tr><th>' . t('Date') . '</th><td>' . $behave->localdate . '</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;
}