Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2012
    Posts
    2
    Plugin Contributions
    0

    Default Log Downloads With IP Address

    I am having a problem with people purchasing files, downloading them and then reversing their charges claiming that they never downloaded the product. I can see on the ORDERS page that there there are no downloads available (which means they did download) and I can also verify this by getting into the table ORDERS_PRODUCTS_DOWNLOADS. However, is there a report, or a way to create an SQL that will take that relational database and be able to query the ip address, time of the download, etc. to show a report of when and from where the file(s) were downloaded so I can use that to dispute the reversal charges from PayPal? I would be willing to pay for it.

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Log Downloads With IP Address

    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
    Last edited by DrByte; 19 Sep 2012 at 09:10 PM. Reason: fixed new file filenames
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Sep 2012
    Posts
    2
    Plugin Contributions
    0

    Default Re: Log Downloads With IP Address

    WONDERFUL! I WILL donate (again!) because I truly believe in supporting such great programs like this one. One question, if I do these changes and then decide to upgrade to 1.5.1, will I have to do some special installation steps to accommodate these new logs working?

  4. #4
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Log Downloads With IP Address

    Quote Originally Posted by Webcasts View Post
    One question, if I do these changes and then decide to upgrade to 1.5.1, will I have to do some special installation steps to accommodate these new logs working?
    No changes required. It'll work with 1.5.1 just fine. That's where I tested it :)
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. Can I log my visitors IP address?
    By DML73 in forum General Questions
    Replies: 1
    Last Post: 13 Aug 2011, 06:52 AM
  2. Setting downloads to 7 day expiration with unlimited downloads
    By Chestnut Junction in forum Setting Up Categories, Products, Attributes
    Replies: 38
    Last Post: 26 Oct 2009, 05:31 AM
  3. Problem with Customer Log in/ Log out
    By tequila in forum General Questions
    Replies: 11
    Last Post: 3 Jul 2009, 02:39 AM
  4. Log in required - but not shopping cart - for downloads?
    By valtx in forum Setting Up Categories, Products, Attributes
    Replies: 5
    Last Post: 2 Jan 2007, 09:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR