function jplayer_protection_statistics in jPlayer 6
Same name and namespace in other branches
- 7.2 jplayer_protect/jplayer_protect.admin.inc \jplayer_protection_statistics()
Page callback for the jPlayer protection statistics page. This page is useful in determining if a browser is misbehaving and blocking legitimiate file accesses, or if a user is trying to download a protected file.
1 string reference to 'jplayer_protection_statistics'
- jplayer_protect_menu in jplayer_protect/
jplayer_protect.module - @file Provides basic content protection for media files accessed with jPlayer.
File
- jplayer_protect/
jplayer_protect.admin.inc, line 8
Code
function jplayer_protection_statistics() {
if (!variable_get('jplayer_protect', FALSE)) {
drupal_set_message(t('<a href="@jplayer-settings">jPlayer content protection</a> is not currently enabled.', array(
'@jplayer-settings' => url('admin/settings/jplayer', array(
'query' => drupal_get_destination(),
)),
)));
}
$output = '<p>' . t('This table shows the 50 top users who have been denied access to direct downloads of jPlayer files.') . '</p>';
$result = db_query("SELECT COUNT(1) as total, uid as user, MAX(timestamp) as timestamp FROM {jplayer_protect_denied} GROUP BY uid ORDER BY total DESC, timestamp DESC LIMIT 50;");
$rows = array();
while ($denied = db_fetch_array($result)) {
$denied = (array) $denied;
// Format data from the query.
$uid = $denied['user'];
$denied['user'] = theme('username', user_load($denied['user']));
$denied['timestamp'] = format_date($denied['timestamp']);
// Find the top-denied file for the user.
$top_file = db_fetch_object(db_query("SELECT COUNT(fid) as fid_count, fid FROM {jplayer_protect_denied} WHERE uid = %d GROUP BY fid ORDER BY fid_count DESC LIMIT 1", $uid));
$top_file = db_fetch_object(db_query("SELECT * FROM {files} WHERE fid = %d", $top_file->fid));
$denied['file'] = $top_file->filepath;
// Find the top hostname for the user.
$top_hostname = db_fetch_object(db_query("SELECT COUNT(hostname) as hostname_count, hostname FROM {jplayer_protect_denied} WHERE uid = %d GROUP BY hostname ORDER BY hostname_count DESC LIMIT 1", $uid));
$denied['hostname'] = $top_hostname->hostname;
$rows[] = $denied;
}
$header = array(
t('Accesses denied'),
t('User'),
t('Last denied'),
t('Top Denied File'),
t('Top Hostname'),
);
if (!empty($rows)) {
$output .= theme('table', $header, $rows);
}
else {
$output .= '<p>' . t('There have been no files that have been denied access within the last week.') . '</p>';
}
return $output;
}