$selected_year = date("Y"); } $selected_month_ts = mktime(0, 0, 0, $selected_month, 15, $selected_year); $smarty->assign('selected_month_ts', $selected_month_ts); $smarty->assign('path', $template_dir . '/download-stat.tpl'); $stat['today'] = getDownloadCounter(mktime(0, 0, 0, date("n"), date("j"), date("Y")), mktime(23, 59, 59, date("n"), date("j"), date("Y")), $downloadid); $stat['this_month'] = getDownloadCounter(mktime(0, 0, 0, date("n"), 1, date("Y")), mktime(23, 59, 59, date("n"), date("t"), date("Y")), $downloadid); $stat['this_year'] = getDownloadCounter(mktime(0, 0, 0, 1, 1, date("Y")), mktime(23, 59, 59, 12, 31, date("Y")), $downloadid); $stat['this_week'] = getDownloadCounter(mktime(0, 0, 0, date("n"), date("j"), date("Y")) - 604800, mktime(23, 59, 59, date("n"), date("j"), date("Y")), $downloadid); $month = $selected_month; $year = $selected_year; $stat['month'] = date("M", mktime(0, 0, 0, $month, 1, $year)); $stat['year'] = $year; $max = 0; for ($day = 1; $day <= date("t", $selected_month_ts); $day++) { $counter = getDownloadCounter(mktime(0, 0, 0, $month, $day, $year), mktime(23, 59, 59, $month, $day, $year), $downloadid); if ($counter > $max) { $max = $counter; } $stat['days'][] = array('day' => $day, 'counter' => $counter); } $stat['max'] = $max; $stat['export_url'] = 'ajax_request.php?mod=media&file=stat.export&downloadid=' . $downloadid . '&month=' . $month . '&year=' . $year; $smarty->assign('dl_stat', $stat); } } if ($rights->isAllowed($mod, 'manage')) { $menu->addSubElement($mod, $lang->get('download_stat'), '', array('categoryid' => $categoryid, 'downloadid' => $downloadid, 'statistic' => '')); } } else { $notify->add($lang->get('media'), $lang->get('access_denied'));
$lang->addModSpecificLocalization('media'); $smarty->assign('lang', $lang->getAll()); @($month = (int) $_GET['month']); @($year = (int) $_GET['year']); if ($month == 0) { $month = date("n"); } if ($year == 0) { $year = date("Y"); } $selected_month_ts = mktime(0, 0, 0, $month, 15, $year); $statistics['month'] = date("F", $selected_month_ts); $statistics['year'] = $year; $max = 0; for ($day = 1; $day <= date("t", $selected_month_ts); $day++) { @($counter = getDownloadCounter(mktime(0, 0, 0, $month, $day, $year), mktime(23, 59, 59, $month, $day, $year), (int) $_GET['downloadid'])); if ($counter > $max) { $max = $counter; } $statistics['days'][] = array('day' => $day, 'counter' => $counter); } $dlid_in_filename = ''; if (@(int) $_GET['downloadid'] > 0) { $dlid_in_filename = '-' . (int) $_GET['downloadid']; } $statistics['max'] = $max; $smarty->assign('stat', $statistics); header('Content-type: text/comma-separated-values'); header('Content-Disposition: attachment; filename="download-stats-' . strtolower(date("F", $selected_month_ts)) . '-' . $year . $dlid_in_filename . '.csv"'); $smarty->display('../mod/default/media/csv.export.tpl'); }