[ Index ]
 

Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/includes/modules/pages/gv_redeem/ -> header_php.php (source)

   1  <?php
   2  /**

   3   * GV redeem

   4   *

   5   * @package page

   6   * @copyright Copyright 2003-2006 Zen Cart Development Team

   7   * @copyright Portions Copyright 2003 osCommerce

   8   * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

   9   * @version $Id: header_php.php 4940 2006-11-16 05:23:53Z ajeh $

  10   */
  11  
  12  // if the customer is not logged on, redirect them to the login page

  13  if (!$_SESSION['customer_id']) {
  14    $_SESSION['navigation']->set_snapshot();
  15    zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
  16  }
  17  // check for a voucher number in the url

  18  if (isset($_GET['gv_no'])) {
  19    $error = true;
  20    $gv_query = "SELECT c.coupon_id, c.coupon_amount
  21                 FROM " . TABLE_COUPONS . " c, " . TABLE_COUPON_EMAIL_TRACK . " et
  22                 WHERE coupon_code = :couponCode
  23                 AND c.coupon_id = et.coupon_id
  24                 AND c.coupon_type = 'G'";
  25  
  26    $gv_query = $db->bindVars($gv_query, ':couponCode', $_GET['gv_no'], 'string');
  27    $coupon = $db->Execute($gv_query);
  28  
  29    if ($coupon->RecordCount() >0) {
  30      $redeem_query = "SELECT coupon_id
  31                       FROM ". TABLE_COUPON_REDEEM_TRACK . "
  32                       WHERE coupon_id = :couponID";
  33  
  34      $redeem_query = $db->bindVars($redeem_query, ':couponID', $coupon->fields['coupon_id'], 'integer');
  35      $redeem = $db->Execute($redeem_query);
  36  
  37      if ($redeem->RecordCount() == 0 ) {
  38        // check for required session variables

  39        $_SESSION['gv_id'] = $coupon->fields['coupon_id'];
  40        $error = false;
  41      } else {
  42        $error = true;
  43      }
  44    }
  45  } else {
  46    zen_redirect(zen_href_link(FILENAME_DEFAULT));
  47  }
  48  if ((!$error) && ($_SESSION['customer_id'])) {
  49    // Update redeem status

  50    $gv_query = "INSERT INTO  " . TABLE_COUPON_REDEEM_TRACK . "(coupon_id, customer_id, redeem_date, redeem_ip)
  51                 VALUES (:couponID, :customersID, now(), :remoteADDR)";
  52  
  53    $gv_query = $db->bindVars($gv_query, ':customersID', $_SESSION['customer_id'], 'integer');
  54    $gv_query = $db->bindVars($gv_query, ':couponID', $coupon->fields['coupon_id'], 'integer');
  55    $gv_query = $db->bindVars($gv_query, ':remoteADDR', $REMOTE_ADDR, 'string');
  56    $db->Execute($gv_query);
  57  
  58    $gv_update = "UPDATE " . TABLE_COUPONS . "
  59                  SET coupon_active = 'N'
  60                  WHERE coupon_id = :couponID";
  61  
  62    $gv_update = $db->bindVars($gv_update, ':couponID', $coupon->fields['coupon_id'], 'integer');
  63    $db->Execute($gv_update);
  64  
  65    zen_gv_account_update($_SESSION['customer_id'], $_SESSION['gv_id']);
  66    $_SESSION['gv_id'] = '';
  67  }
  68  
  69  require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
  70  $breadcrumb->add(NAVBAR_TITLE);
  71  
  72  // prepare message for display in template:

  73  $message = sprintf(TEXT_VALID_GV, $currencies->format($coupon->fields['coupon_amount']));
  74  
  75  if ($error) {
  76    // if we get here then either the URL gv_no param was not set or it was invalid

  77    // so output a message.

  78    $message = TEXT_INVALID_GV;
  79  }
  80  
  81  ?>


Généré le : Mon Nov 26 16:45:43 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics