[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/includes/modules/ -> downloads.php (source)

   1  <?php
   2  /*

   3  $Id: downloads.php 14 2006-07-28 17:42:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   9  

  10    Released under the GNU General Public License

  11  */
  12  ?>
  13  <!-- downloads //-->
  14  <?php
  15    if (!strstr($PHP_SELF, FILENAME_ACCOUNT_HISTORY_INFO)) {
  16  // Get last order id for checkout_success

  17      $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' order by orders_id desc limit 1");
  18      $orders = tep_db_fetch_array($orders_query);
  19      $last_order = $orders['orders_id'];
  20    } else {
  21      $last_order = $HTTP_GET_VARS['order_id'];
  22    }
  23  
  24  // Now get all downloadable products in that order

  25  // LINE CHANGED: MOD - Downloads Controller

  26  // DEFINE WHICH ORDERS_STATUS TO USE IN downloads_controller.php

  27  // USE last_modified instead of date_purchased

  28  //$downloads_query = tep_db_query("select date_format(o.date_purchased, '%Y-%m-%d') as date_purchased_day, opd.download_maxdays, op.products_name, opd.orders_products_download_id, opd.orders_products_filename, opd.download_count, opd.download_maxdays from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " opd where o.customers_id = '" . (int)$customer_id . "' and o.orders_id = '" . (int)$last_order . "' and o.orders_id = op.orders_id and op.orders_products_id = opd.orders_products_id and opd.orders_products_filename != ''");

  29    $downloads_query = tep_db_query("select o.orders_status, date_format(o.last_modified, '%Y-%m-%d') as date_purchased_day, opd.download_maxdays, op.products_name, opd.orders_products_download_id, opd.orders_products_filename, opd.download_count, opd.download_maxdays from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " opd where o.customers_id = '" . (int)$customer_id . "' and o.orders_status >= '" . DOWNLOADS_CONTROLLER_ORDERS_STATUS . "' and o.orders_id = '" . (int)$last_order . "' and o.orders_id = op.orders_id and op.orders_products_id = opd.orders_products_id and opd.orders_products_filename != ''");
  30    if (tep_db_num_rows($downloads_query) > 0) {
  31  ?>
  32        <tr>
  33          <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  34        </tr>
  35        <tr>
  36          <td class="main"><b><?php echo HEADING_DOWNLOAD; ?></b></td>
  37        </tr>
  38        <tr>
  39          <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  40        </tr>
  41        <tr>
  42          <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
  43  <!-- list of products -->
  44  <?php
  45      while ($downloads = tep_db_fetch_array($downloads_query)) {
  46  // MySQL 3.22 does not have INTERVAL

  47        list($dt_year, $dt_month, $dt_day) = explode('-', $downloads['date_purchased_day']);
  48        $download_timestamp = mktime(23, 59, 59, $dt_month, $dt_day + $downloads['download_maxdays'], $dt_year);
  49        $download_expiry = date('Y-m-d H:i:s', $download_timestamp);
  50  ?>
  51            <tr class="infoBoxContents">
  52  <!-- left box -->
  53  <?php
  54  // The link will appear only if:

  55  // - Download remaining count is > 0, AND

  56  // - The file is present in the DOWNLOAD directory, AND EITHER

  57  // - No expiry date is enforced (maxdays == 0), OR

  58  // - The expiry date is not reached

  59        if ( ($downloads['download_count'] > 0) && (file_exists(DIR_FS_DOWNLOAD . $downloads['orders_products_filename'])) && ( ($downloads['download_maxdays'] == 0) || ($download_timestamp > time())) ) {
  60  // LINE CHANGED: MOD - Downloads Controller Show Button

  61  //      echo '            <td class="main"><a href="' . tep_href_link(FILENAME_DOWNLOAD, 'order=' . $last_order . '&id=' . $downloads['orders_products_download_id']) . '">' . $downloads['products_name'] . '</a></td>' . "\n";

  62          echo '            <td class="main" align="center"><a href="' . tep_href_link(FILENAME_DOWNLOAD, 'order=' . $last_order . '&id=' . $downloads['orders_products_download_id']) . '">' . $downloads['products_name'] . '<br>' . tep_image_button('button_download.gif', '') . '</a></td>' . "\n";
  63        } else {
  64          echo '            <td class="main">' . $downloads['products_name'] . '</td>' . "\n";
  65        }
  66  ?>
  67  <!-- right box -->
  68  <?php
  69  // LINE CHANGED: MOD - Downloads Controller Show Button - Added '<br>'

  70        echo '            <td class="main">' . TABLE_HEADING_DOWNLOAD_DATE . '<br>' . tep_date_long($download_expiry) . '</td>' . "\n" .
  71             '            <td class="main" align="right">' . $downloads['download_count'] . TABLE_HEADING_DOWNLOAD_COUNT . '</td>' . "\n" .
  72             '          </tr>' . "\n";
  73      }
  74  // LINE REMOVED: MOD - Downloads Controller Show Button

  75  //

  76  ?>
  77            </tr>  
  78          </table></td>
  79        </tr>
  80  <?php
  81      if (!strstr($PHP_SELF, FILENAME_ACCOUNT_HISTORY_INFO)) {
  82  ?>
  83        <tr>
  84          <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  85        </tr>
  86        <tr>
  87          <td class="smalltext" colspan="4"><p><?php printf(FOOTER_DOWNLOAD, '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . HEADER_TITLE_MY_ACCOUNT . '</a>'); ?></p></td>
  88        </tr>
  89  <?php
  90      }
  91    }
  92  ?>
  93  <?php // BOF: MOD - Downloads Controller
  94  // If there is a download in the order and they cannot get it, tell customer about download rules

  95    $downloads_check_query = tep_db_query("select o.orders_id, opd.orders_products_download_id from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " opd where o.orders_id = opd.orders_id and o.orders_id = '" . (int)$last_order . "' and opd.orders_products_filename != ''");
  96  
  97  if (tep_db_num_rows($downloads_check_query) > 0 and tep_db_num_rows($downloads_query) < 1) {
  98  // if (tep_db_num_rows($downloads_query) < 1) {

  99  ?>
 100        <tr>
 101          <td colspan="3" align="center" valign="top" class="main" height="30"><FONT FACE="Arial" SIZE=1 COLOR="FF000"><?php echo DOWNLOADS_CONTROLLER_ON_HOLD_MSG ?></FONT></td>
 102        </tr>
 103  <?php
 104  }
 105  // EOF: MOD - Downloads Controller

 106  ?>
 107  <!-- downloads_eof //-->


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7