Common subdirectories: webfm/css and modules/webfm/css
Common subdirectories: webfm/image and modules/webfm/image
Common subdirectories: webfm/js and modules/webfm/js
Only in modules/webfm/: po
Common subdirectories: webfm/translations and modules/webfm/translations
diff -up webfm/webfm.install modules/webfm/webfm.install
--- webfm/webfm.install	2008-11-14 15:59:47.000000000 -0500
+++ modules/webfm/webfm.install	2009-01-15 13:11:10.000000000 -0500
@@ -80,6 +80,30 @@ function webfm_schema(){
     ),
     'primary key' => array('nid', 'fid', 'cid' ),
   );
+
+  $schema['webfm_statistics'] = array(
+   'fields' => array(
+          'sid' => array(
+                         'type' => 'serial',
+                     'unsigned' => TRUE,
+                     'not null' => TRUE),
+          'uid' => array(
+                         'type' => 'int',
+                     'unsigned' => TRUE,
+                     'not null' => TRUE),
+          'fid' => array(
+                         'type' => 'int',
+                         'size' => 'normal',
+                     'not null' => TRUE,
+                      'default' => 0),
+      'dl_time' => array(
+                         'type' => 'datetime',
+                     'not null' => TRUE,
+                      'default' => '0000-00-00 00:00:00'),
+   ),
+   'primary key' => array('sid'),
+  );
+
   return $schema;
 }
 
@@ -96,3 +120,37 @@ function webfm_update_1() {
   db_add_primary_key($ret, 'webfm_attach', array('nid', 'cid', 'fid'));
   return $ret;
 }
+
+/**
+ * Add a table for tracking file download information.
+ */
+function webfm_update_2() {
+  $ret = array();
+  // Add the new column to store a comment id.
+ $schema['webfm_statistics'] = array(
+   'fields' => array(
+          'sid' => array(
+                         'type' => 'serial', 
+                     'unsigned' => TRUE, 
+                     'not null' => TRUE),
+          'uid' => array(
+                         'type' => 'int', 
+                     'unsigned' => TRUE, 
+                     'not null' => TRUE),
+          'fid' => array(
+                         'type' => 'int', 
+                         'size' => 'normal', 
+                     'not null' => TRUE, 
+                      'default' => 0),
+       'dl_time' => array(
+                         'type' => 'datetime',
+                     'not null' => TRUE,
+                      'default' => '0000-00-00 00:00:00'),
+   ),
+   'primary key' => array('sid'),
+);
+
+  db_create_table($ret, 'webfm_statistics', $schema['webfm_statistics']); 
+  return $ret;
+}
+
diff -up webfm/webfm.module modules/webfm/webfm.module
--- webfm/webfm.module	2008-12-05 23:49:16.000000000 -0500
+++ modules/webfm/webfm.module	2009-01-27 14:38:06.000000000 -0500
@@ -500,7 +500,24 @@ function webfm_menu() {
     'access arguments' => array('administer webfm'),
     'type' => MENU_NORMAL_ITEM,
   );
-
+  $items['admin/reports/webfm'] = array(
+    'title' => 'Web File Manager Download Report',
+    'description' => 'Webfm download statistics.',
+    'page callback' => 'webfm_get_report',
+    'page arguments' => array('webfm_report'),
+    'access callback' => 'user_access',
+    'access arguments' => array('administer webfm'),
+    'file' => 'webfm.module',
+    'file path' => drupal_get_path('sites', 'all', 'module', 'webfm'),
+  );
+  $items['admin/reports/webfm_delete_report'] = array(
+    'title' => 'Clear Data',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('webfm_delete_report_confirm'),
+    'access arguments' => array('administer webfm'),
+    'type' => MENU_CALLBACK,
+    'file' => 'webfm.module',
+  );
   return $items;
 }
 
@@ -2604,8 +2621,25 @@ function webfm_send_file($fid, $attach =
   $header[] = 'Content-Length: '.(string)(@filesize($f->fpath));
   $header[] = 'Connection: close';
 
+  error_log('CALL: webfm_log_dl');
+  webfm_log_dl($fid); 
   //drupal file_transfer will fail if file is not inside file system directory
   file_transfer($f->fpath, $header);
+  //log the file's download
+}
+
+/**
+ * webfm_log_dl - log who downloaded a file and when.
+ * 
+ * @param fid - a reference key for tracking the downloaded file
+ */
+function webfm_log_dl($fid){
+  //we need our user
+  global $user;
+  error_log('RUN: webfm_log_dl');
+  //simple query to record this down load
+  $query = "INSERT INTO {webfm_statistics} (uid, fid, dl_time) VALUES (%d, %d, NOW())";
+  $result = db_query($query, $user->uid, $fid);
 }
 
 /**
@@ -3150,3 +3184,133 @@ function _webfm_dbdelete_attach_fid($fid
 if(module_exists('views')){
   require_once("./".$modulepath."/webfm_views.inc");
 }
+
+/**
+ * Administrative report generating code.  This is the callback function that 
+ * hits the om webfm_dbdelete_file
+ *
+ * @param int $fid
+ * @return report output
+ */
+function webfm_get_report(){
+
+  $query = "SELECT a.sid, a.uid, a.fid, a.dl_time, b.name, b.mail, c.fpath, d.nid, e.title
+  FROM webfm_statistics a
+  LEFT OUTER JOIN users b ON a.uid = b.uid
+  LEFT OUTER JOIN webfm_file c ON a.fid = c.fid
+  LEFT OUTER JOIN webfm_attach d ON a.fid = c.fid
+  LEFT OUTER JOIN node e ON d.nid = e.nid";
+    
+  if($_GET['export']){
+    webfm_export_report($query);
+    return;
+  }
+
+  else{
+    $header = array(
+      array('data' => t('Time'), 'field' => 'dl_time', 'sort' => 'desc'),
+      array('data' => t('User'), 'field' => 'name', 'sort' => 'desc'),
+      array('data' => t('Mail'), 'field' => 'mail', 'sort' => 'desc'),
+      array('data' => t('File'), 'field' => 'fpath', 'sort' => 'desc'),
+      array('data' => t('Node'), 'field' => 'nid', 'sort' => 'desc'),
+    );
+
+    $count_query = 'SELECT count(*) as count from webfm_statistics;';
+    $result = db_fetch_object(db_query($count_query));
+
+    $output  = t('<br>A total of '.$result->count.' rows were returned.');
+    $output .= t(' <a href="/admin/reports/webfm?export=1">EXPORT</a> this report as a CSV file.');
+    $output .= t(' <a href="/admin/reports/webfm_delete_report">DELETE</a> existing data.<br><br>');
+
+    $result = pager_query($query.''.tablesort_sql($header) ,10 ,0, "SELECT count(*) from webfm_statistics");
+
+    $rows   = array();
+
+    while ($data = db_fetch_object($result)) {
+
+      if($data->fpath == ''){
+        $data->fpath = " File Path no longer exists!";
+      }
+
+      if($data->uid == 0){
+        $data->name = 'Anonymous';
+        $name_link = $data->name;
+      }
+      else{
+        $name_link = "<a href ='/user/".$data->uid."'>".$data->name."</a>";
+      }
+
+      $mail_link = "<a href ='mailto:".$data->mail."'>".$data->mail."</a>";
+      $node_link = "<a href ='/node/".$data->nid."'>".$data->title."</a>";
+
+      $rows[] = array(
+        $data->dl_time,
+        $name_link,
+        $mail_link,
+        "[".$data->fid."]".$data->fpath, 
+        $node_link
+      );
+    }
+
+    if (empty($rows)) {
+      $rows[] = array(array('data' => t('No log messages available.'), 'colspan' => 2));
+    }
+
+    $output .= theme('table', $header, $rows,  array('id' => 'admin-webfm'));
+    $output .= theme('pager', NULL, 10, 0);
+
+    return $output;
+  }
+}
+
+/**
+ * Menu callback: confirm wiping of the index.
+ */
+function webfm_delete_report_confirm() {
+  return confirm_form(array(), t('Are you sure you want to delete the webfm statistical data?'), 'admin/reports/webfm', t('This action will delete data from the data base and cannot be undone.  If you are unsure about this action, do not delete this data.  Alternatively, you should at least export as a .csv file which will make it possible to restore.'), t('Delete Data'), t('Cancel'));
+}
+
+function webfm_delete_report_confirm_submit(&$form, &$form_state) {
+  if ($form['confirm']) {
+    webfm_delete_report();
+    $form_state['redirect'] = 'admin/reports/webfm';
+    return;
+  }
+}
+
+function webfm_delete_report() {
+  drupal_set_message(t('The data has been deleted.'));
+  db_query("DELETE from webfm_statistics");
+  return;
+}
+
+function webfm_export_report($query){
+
+    $today = date("m_j_Y_g_i");
+
+    $result = db_query($query);
+
+    $output = "Date Time, User Name, Email, File Path, Node, Page Title\n";
+    while ($data = db_fetch_object($result)) {
+
+      if($data->fpath == ''){
+        $data->fpath = " File Path no longer exists!";
+      }
+
+      if($data->uid == 0){
+        $data->name = 'Anonymous';
+      }
+      $name = '['.$data->uid."]".$data->name;
+      $output .= $data->dl_time.','.$name.','.$data->mail.','."[".$data->fid."]".$data->fpath.','.$data->nid.','.$data->title."\n";
+    }
+
+    header('Expires: 0');
+    header('Cache-control: private');
+    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+    header('Content-Description: File Transfer');
+    header('Content-Type: text');
+    header('Content-disposition: attachment; filename=webfm_export_'.$today.'.csv');
+    print($output);
+    return;
+
+}
diff -up webfm/webfm_views.inc modules/webfm/webfm_views.inc
--- webfm/webfm_views.inc	2008-04-08 02:28:14.000000000 -0400
+++ modules/webfm/webfm_views.inc	2009-01-15 13:24:45.000000000 -0500
@@ -146,6 +146,7 @@ function webfm_views_tables(){
                                       'name' => t('WebFM: Download Count'),
                                       'help' => t('Sort by file downloaded count')))
                                 );
+
   return $tables;
 }
 
