function pagenotfound_reports_referers in Page Not Found Reports 7
Same name and namespace in other branches
- 6.2 pagenotfound_reports.admin.inc \pagenotfound_reports_referers()
- 6 pagenotfound_reports.module \pagenotfound_reports_referers()
List of 404s with referers.
1 string reference to 'pagenotfound_reports_referers'
- pagenotfound_reports_menu in ./
pagenotfound_reports.module - Implements hook_menu().
File
- ./
pagenotfound_reports.module, line 183 - Page Not Found Reports
Code
function pagenotfound_reports_referers() {
$oldest_item = db_select('watchdog', 'w')
->fields('w', array(
'timestamp',
))
->condition('type', 'page not found')
->condition('referer', '', '!=')
->isNotNull('referer')
->orderBy('timestamp', 'ASC')
->range(0, 1)
->execute()
->fetchAssoc();
$item_count = db_select('watchdog', 'w')
->fields('w', array(
'wid',
))
->condition('type', 'page not found')
->condition('referer', '', '!=')
->isNotNull('referer')
->execute()
->rowCount();
// Stats
// Do NOT call _pagenotfound_reports_summary_stats(), since only 404 erros
// with referrers are shown in this report
$list_items = array();
$list_items[] = t('%count: Total 404 errors with a referer available in log', array(
'%count' => $item_count,
));
$output = theme('item_list', array(
'items' => $list_items,
));
$header = array(
array(
'data' => t('Count'),
'field' => 'count',
'sort' => 'desc',
),
array(
'data' => t('Path'),
'field' => 'message',
),
array(
'data' => t('Referer'),
'field' => 'referer',
),
array(
'data' => t('Operations'),
),
);
$result = db_select('watchdog', 'w')
->fields('w', array(
'wid',
'message',
'referer',
))
->condition('type', 'page not found')
->condition('referer', '', '!=')
->isNotNull('referer')
->extend('PagerDefault')
->limit(30)
->extend('TableSort')
->orderByHeader($header)
->groupBy('message')
->groupBy('referer');
$result
->addExpression('COUNT(wid)', 'count');
$result = $result
->execute();
$rows = array();
foreach ($result as $dblog) {
$rows[] = array(
$dblog->count,
truncate_utf8($dblog->message, 56, TRUE, TRUE),
l(truncate_utf8($dblog->referer, 56, TRUE, TRUE), $dblog->referer),
_pagenotfound_reports_add_operations($dblog),
);
}
if (empty($rows)) {
$rows[] = array(
array(
'data' => t('No log messages available.'),
'colspan' => 4,
),
);
}
$output .= theme('table', array(
'header' => $header,
'rows' => $rows,
));
$output .= theme('pager', array(
'tags' => NULL,
'element' => 0,
));
return $output;
}