This should work ... Add these 2 new files, and since you're using v1.5.0 instead of v1.5.1, you'll need to make the one file-edit shown below.
It will create a download_activity_history.csv in the /cache/ folder (or the /logs/ folder on v1.5.1+) containing download history when new downloads happen.
1. /includes/classes/observers/class.observer_download_logging.php
Code:
<?php
/**
* @package plugins
* @copyright Copyright 2003-2012 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
*
* Designed for v1.5.1
*/
class observer_download_logging extends base {
function __construct() {
$this->attach($this, array('NOTIFY_DOWNLOAD_READY_TO_START'));
if (!defined('DIR_FS_LOGS')) define('DIR_FS_LOGS', DIR_FS_SQL_CACHE);
}
function update(&$class, $eventID, $paramsArray = array())
{
$origin_filename = $paramsArray[0];
$browser_filename = $paramsArray[1];
$downloadFilesize = $paramsArray[2];
$ip_address = $paramsArray[3];
$orderData = $paramsArray[4];
// contains 'date_purchased_day', 'download_count', 'download_maxdays', 'orders_products_filename',
// and all the info from the orders table record
// check that the logging file exists, and write headers to it if file isn't found
if (!file_exists(DIR_FS_LOGS . '/download_activity_history.csv')) {
$headers = array();
$headers[] = 'date';
$headers[] = 'order_number';
$headers[] = 'customer_number';
$headers[] = 'ordered_from_ip_address';
$headers[] = 'origin_filename';
$headers[] = 'browser_filename';
$headers[] = 'download_filesize';
$headers[] = 'download_ip_address';
error_log(implode(',', $headers) . "\n", 3, DIR_FS_LOGS . '/download_activity_history.csv');
}
$logged_info = array();
$logged_info[] = date('M-d-Y H:i:s');
$logged_info[] = $orderData['orders_id'];
$logged_info[] = $_SESSION['customer_id'];
$logged_info[] = $orderData['ip_address'];
$logged_info[] = $origin_filename;
$logged_info[] = $browser_filename;
$logged_info[] = $downloadFilesize;
$logged_info[] = $ip_address;
error_log(implode(',', $logged_info ). "\n", 3, DIR_FS_LOGS . '/download_activity_history.csv');
}
}
2. /includes/auto_loaders/config.observer_download_logging.php
Code:
<?php
/**
*
* @package plugins
* @copyright Copyright 2003-2012 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
*/
/**
* Designed for v1.5.1
*/
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
$autoLoadConfig[190][] = array('autoType'=>'class',
'loadFile'=>'observers/class.observer_download_logging.php');
$autoLoadConfig[190][] = array('autoType'=>'classInstantiate',
'className'=>'observer_download_logging',
'objectName'=>'observer_download_logging');
3. To make it work on v1.5.0 instead of v1.5.1, you'll need to do the following edit:
/includes/modules/pages/download/header_php.php, line 153:
Code:
$zco_notifier->notify('NOTIFY_DOWNLOAD_READY_TO_START', $origin_filename, $browser_filename, $downloadFilesize, $_SESSION['customers_host_address']);
change to:
Code:
$zco_notifier->notify('NOTIFY_DOWNLOAD_READY_TO_START', array($origin_filename, $browser_filename, $downloadFilesize, $_SESSION['customers_host_address'], $downloads->fields));
If it works for you, donations appreciated: www.zen-cart.com/donate
Bookmarks