I went ahead and made it.
All it does is what the original did: monitor the download of files and report how many of each.
First, rename the /modules/statistics/subreports/Downloads.php to Downloads.bak
Here is the code for /modules/statistics/subreports/UpDownload.php
Code
<?php
// $Id: downloads.php,v 8.3 2004/03/09 23:17:52 crs Exp $
// ----------------------------------------------------------------------
// Statistics Module for PostNuke Content Management System
// Copyright 2003 by Craig R. Saunders
// crs@mtrad.com, http://www.mtrad.com
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WIthOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Purpose of file: Template for subreport include files
// ----------------------------------------------------------------------
// 2004-03-07 ColdRolledSteel Original
// ----------------------------------------------------------------------
// 2005-02-21 John Bowden upgrade for UpDownload
$subreports[] = array(
'sortorder' => '480',
'title' => 'updownload',
'func_input' => 'statistics_updownload_form',
'func_output' => 'statistics_updownload_subreport'
);
function statistics_updownload_form() {
global $top_list, $period_list;
$output = new pnHTML();
$output->SetInputMode(_PNH_VERBATIMINPUT);
$output->Text("<tr><td>");
$output->FormCheckbox("dt");
$output->Text(_LISTOF);
$output->FormSelectMultiple('dtc',$top_list,'','1', 10);
$output->Text(_DOWNLOADSRANKED."</td></tr>");
return $output->GetOutput();
}
function statistics_updownload_subreport() {
global $totalfreq, $start, $end, $dbconn, $pntable, $column, $wheredates, $tablename;
list($option, $limit) = pnVarCleanFromInput('dt', 'dtc');
if (empty($option)) {
return;
}
if (empty($limit)) {
$limit=0;
}
$output = new pnHTML();
$output->SetInputMode(_PNH_VERBATIMINPUT);
$column = &$pntable[$tablename . '_column'];
$dcolumn = &$pntable['updownload_downloads_column'];
$top_list = array('0'=>_ALL, '10'=>_TOP10, '20'=>_TOP20, '25'=>_TOP25, '50'=>_TOP50, '100'=>_TOP100);
$bgcolor2 = pnThemeGetVar('bgcolor2');
$output->Text("<br><center><font class=\"pn-title\"><b>"._STATSDOWNLOADS." (".$top_list["$limit"].") </b></font><br>");
$output->Text("<table border=0> <tr><td align=right width=10>"._STATSRANK."</td><td>"._STATSURL."</td><td align=right width=40>"._STATSFREQUENCY."</td></tr>");
$query = "SELECT DISTINCT $column[requrl], SUM($column[count]) hits FROM $pntable[$tablename] $wheredates AND $column[requrl] LIKE '%UpDownload%req_getit%lid%' GROUP BY $column[requrl] ORDER BY hits DESC ";
if ($limit > 0) { $query .= " LIMIT $limit"; }
$hresult = $dbconn->Execute($query);
$count = 0;
$totalpages = 0;
while(list($url, $freq) = $hresult->fields) {
$hresult->MoveNext();
$count = $count + 1;
$totalpages = $totalpages + $freq;
$regs = array ();
ereg(".*lid.([0-9]+)*",$url,$regs);
$lid = $regs[1];
$dquery = "SELECT $dcolumn[title] FROM $pntable[updownload_downloads] WHERE $dcolumn[lid] = $lid ";
$dresult = $dbconn->Execute($dquery);
list($title) = $dresult->fields;
if ($title == "") {
$text = $url;
} else {
$text = "<a target=_blank href='modules.php?name=UpDownload&req=viewdownloaddetails&lid=$lid&ttitle=$title'>$title</a>";
}
$output->Text("<tr>\n");
$output->Text("<td bgcolor=\"$bgcolor2\" align=right width=60>$count</td>\n");
$output->Text("<td bgcolor=\"$bgcolor2\">$text</td>\n");
$output->Text("<td bgcolor=\"$bgcolor2\" align=right width=60>$freq</td>\n");
$output->Text("</tr>\n");
}
$output->Text("<tr>\n<td bgcolor=\"$bgcolor2\" align=right width=60></td>\n");
$output->Text("<td bgcolor=\"$bgcolor2\">Total</td>\n");
$output->Text("<td bgcolor=\"$bgcolor2\" align=right width=60>$totalpages</td></tr>\n");
$output->Text("</table><br> <br>");
$hresult->Close(); /// REB: Close resultset after use
return $output->GetOutput();
}
?>
// $Id: downloads.php,v 8.3 2004/03/09 23:17:52 crs Exp $
// ----------------------------------------------------------------------
// Statistics Module for PostNuke Content Management System
// Copyright 2003 by Craig R. Saunders
// crs@mtrad.com, http://www.mtrad.com
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WIthOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Purpose of file: Template for subreport include files
// ----------------------------------------------------------------------
// 2004-03-07 ColdRolledSteel Original
// ----------------------------------------------------------------------
// 2005-02-21 John Bowden upgrade for UpDownload
$subreports[] = array(
'sortorder' => '480',
'title' => 'updownload',
'func_input' => 'statistics_updownload_form',
'func_output' => 'statistics_updownload_subreport'
);
function statistics_updownload_form() {
global $top_list, $period_list;
$output = new pnHTML();
$output->SetInputMode(_PNH_VERBATIMINPUT);
$output->Text("<tr><td>");
$output->FormCheckbox("dt");
$output->Text(_LISTOF);
$output->FormSelectMultiple('dtc',$top_list,'','1', 10);
$output->Text(_DOWNLOADSRANKED."</td></tr>");
return $output->GetOutput();
}
function statistics_updownload_subreport() {
global $totalfreq, $start, $end, $dbconn, $pntable, $column, $wheredates, $tablename;
list($option, $limit) = pnVarCleanFromInput('dt', 'dtc');
if (empty($option)) {
return;
}
if (empty($limit)) {
$limit=0;
}
$output = new pnHTML();
$output->SetInputMode(_PNH_VERBATIMINPUT);
$column = &$pntable[$tablename . '_column'];
$dcolumn = &$pntable['updownload_downloads_column'];
$top_list = array('0'=>_ALL, '10'=>_TOP10, '20'=>_TOP20, '25'=>_TOP25, '50'=>_TOP50, '100'=>_TOP100);
$bgcolor2 = pnThemeGetVar('bgcolor2');
$output->Text("<br><center><font class=\"pn-title\"><b>"._STATSDOWNLOADS." (".$top_list["$limit"].") </b></font><br>");
$output->Text("<table border=0> <tr><td align=right width=10>"._STATSRANK."</td><td>"._STATSURL."</td><td align=right width=40>"._STATSFREQUENCY."</td></tr>");
$query = "SELECT DISTINCT $column[requrl], SUM($column[count]) hits FROM $pntable[$tablename] $wheredates AND $column[requrl] LIKE '%UpDownload%req_getit%lid%' GROUP BY $column[requrl] ORDER BY hits DESC ";
if ($limit > 0) { $query .= " LIMIT $limit"; }
$hresult = $dbconn->Execute($query);
$count = 0;
$totalpages = 0;
while(list($url, $freq) = $hresult->fields) {
$hresult->MoveNext();
$count = $count + 1;
$totalpages = $totalpages + $freq;
$regs = array ();
ereg(".*lid.([0-9]+)*",$url,$regs);
$lid = $regs[1];
$dquery = "SELECT $dcolumn[title] FROM $pntable[updownload_downloads] WHERE $dcolumn[lid] = $lid ";
$dresult = $dbconn->Execute($dquery);
list($title) = $dresult->fields;
if ($title == "") {
$text = $url;
} else {
$text = "<a target=_blank href='modules.php?name=UpDownload&req=viewdownloaddetails&lid=$lid&ttitle=$title'>$title</a>";
}
$output->Text("<tr>\n");
$output->Text("<td bgcolor=\"$bgcolor2\" align=right width=60>$count</td>\n");
$output->Text("<td bgcolor=\"$bgcolor2\">$text</td>\n");
$output->Text("<td bgcolor=\"$bgcolor2\" align=right width=60>$freq</td>\n");
$output->Text("</tr>\n");
}
$output->Text("<tr>\n<td bgcolor=\"$bgcolor2\" align=right width=60></td>\n");
$output->Text("<td bgcolor=\"$bgcolor2\">Total</td>\n");
$output->Text("<td bgcolor=\"$bgcolor2\" align=right width=60>$totalpages</td></tr>\n");
$output->Text("</table><br> <br>");
$hresult->Close(); /// REB: Close resultset after use
return $output->GetOutput();
}
?>
Be happy, everyone!
John Bowden
The Fool
www.ancient-awakenings.com
www.foolsplayground.com
