[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/includes/ -> affiliate_application_top.php (source)

   1  <?php
   2  /*

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

   4  

   5    OSC-Affiliate

   6  

   7    Contribution based on:

   8  

   9    osCMax Power E-Commerce

  10    http://oscdox.com

  11  

  12    Copyright 2006 osCMax

  13  

  14    Released under the GNU General Public License

  15  */
  16  
  17  
  18  // Set the local configuration parameters - mainly for developers

  19    if (file_exists(DIR_WS_INCLUDES . 'local/affiliate_configure.php')) include(DIR_WS_INCLUDES . 'local/affiliate_configure.php');
  20  
  21    require (DIR_WS_INCLUDES . 'affiliate_configure.php');
  22    require (DIR_WS_FUNCTIONS . 'affiliate_functions.php');
  23  
  24  // define the database table names used in the contribution

  25    define('TABLE_AFFILIATE', 'affiliate_affiliate');
  26    define('TABLE_AFFILIATE_NEWS', 'affiliate_news');
  27  // if you change this -> affiliate_show_banner must be changed too

  28    define('TABLE_AFFILIATE_BANNERS', 'affiliate_banners');
  29    define('TABLE_AFFILIATE_BANNERS_HISTORY', 'affiliate_banners_history');
  30    define('TABLE_AFFILIATE_CLICKTHROUGHS', 'affiliate_clickthroughs');
  31    define('TABLE_AFFILIATE_SALES', 'affiliate_sales');
  32    define('TABLE_AFFILIATE_PAYMENT', 'affiliate_payment');
  33    define('TABLE_AFFILIATE_PAYMENT_STATUS', 'affiliate_payment_status');
  34    define('TABLE_AFFILIATE_PAYMENT_STATUS_HISTORY', 'affiliate_payment_status_history');
  35  
  36  // define the filenames used in the project

  37    define('FILENAME_AFFILIATE_SUMMARY', 'affiliate_summary.php');
  38    define('FILENAME_AFFILIATE_LOGOUT', 'affiliate_logout.php');
  39    define('FILENAME_AFFILIATE', 'affiliate_affiliate.php'); 
  40    define('FILENAME_AFFILIATE_CONTACT', 'affiliate_contact.php');
  41    define('FILENAME_AFFILIATE_FAQ', 'affiliate_faq.php');
  42    define('FILENAME_AFFILIATE_ACCOUNT', 'affiliate_details.php');
  43    define('FILENAME_AFFILIATE_DETAILS', 'affiliate_details.php');
  44    define('FILENAME_AFFILIATE_DETAILS_OK', 'affiliate_details_ok.php');
  45    define('FILENAME_AFFILIATE_TERMS','affiliate_terms.php');
  46    define('FILENAME_AFFILIATE_TERMS_POPUP','affiliate_terms_popup.php');
  47    define('FILENAME_AFFILIATE_NEWS', 'affiliate_news.php');
  48    define('FILENAME_AFFILIATE_NEWSLETTER', 'affiliate_newsletter.php');
  49  
  50    define('FILENAME_AFFILIATE_HELP_1', 'affiliate_help1.php');
  51    define('FILENAME_AFFILIATE_HELP_2', 'affiliate_help2.php');
  52    define('FILENAME_AFFILIATE_HELP_3', 'affiliate_help3.php');
  53    define('FILENAME_AFFILIATE_HELP_4', 'affiliate_help4.php');
  54    define('FILENAME_AFFILIATE_HELP_5', 'affiliate_help5.php');
  55    define('FILENAME_AFFILIATE_HELP_6', 'affiliate_help6.php');
  56    define('FILENAME_AFFILIATE_HELP_7', 'affiliate_help7.php');
  57    define('FILENAME_AFFILIATE_HELP_8', 'affiliate_help8.php');
  58    define('FILENAME_AFFILIATE_HELP_9', 'affiliate_help9.php');
  59    define('FILENAME_AFFILIATE_HELP_10', 'affiliate_help10.php');
  60    define('FILENAME_AFFILIATE_HELP_11', 'affiliate_help11.php');
  61    define('FILENAME_AFFILIATE_HELP_12', 'affiliate_help12.php');
  62    define('FILENAME_AFFILIATE_HELP_13', 'affiliate_help13.php');
  63    define('FILENAME_AFFILIATE_HELP_14', 'affiliate_help14.php');
  64    define('FILENAME_AFFILIATE_HELP_15', 'affiliate_help15.php');
  65    define('FILENAME_AFFILIATE_HELP_16', 'affiliate_help16.php');
  66    define('FILENAME_AFFILIATE_HELP_17', 'affiliate_help17.php');
  67    define('FILENAME_AFFILIATE_HELP_18', 'affiliate_help18.php');
  68    define('FILENAME_AFFILIATE_HELP_19', 'affiliate_help19.php');
  69    define('FILENAME_AFFILIATE_HELP_20', 'affiliate_help20.php');
  70    define('FILENAME_AFFILIATE_HELP_21', 'affiliate_help21.php');
  71    define('FILENAME_AFFILIATE_HELP_22', 'affiliate_help22.php');
  72      define('FILENAME_AFFILIATE_BANNERS_CATEGORY', 'affiliate_banners_category.php');
  73    define('FILENAME_AFFILIATE_BANNERS_BUILD_CAT', 'affiliate_banners_build_cat.php');
  74    define('FILENAME_AFFILIATE_VALIDCATS', 'affiliate_validcats.php');
  75    define('FILENAME_AFFILIATE_INFO', 'affiliate_info.php');
  76      define('TABLE_AFFILIATE_NEWS_CONTENTS', 'affiliate_news_contents');
  77    define('FILENAME_AFFILIATE_BANNERS', 'affiliate_banners.php');
  78    define('FILENAME_AFFILIATE_BANNERS_BANNERS', 'affiliate_banners_banners.php');
  79    define('FILENAME_AFFILIATE_BANNERS_BUILD', 'affiliate_banners_build.php');
  80    define('FILENAME_AFFILIATE_BANNERS_PRODUCT', 'affiliate_banners_product.php');
  81    define('FILENAME_AFFILIATE_BANNERS_TEXT', 'affiliate_banners_text.php');
  82    define('FILENAME_AFFILIATE_SHOW_BANNER', 'affiliate_show_banner.php');
  83    define('FILENAME_AFFILIATE_REPORTS', 'affiliate_reports.php');
  84    define('FILENAME_AFFILIATE_CLICKS', 'affiliate_clicks.php');
  85    define('FILENAME_AFFILIATE_VALIDPRODUCTS', 'affiliate_validproducts.php');
  86  
  87    define('FILENAME_AFFILIATE_PASSWORD', 'affiliate_password.php');
  88    define('FILENAME_AFFILIATE_PASSWORD_FORGOTTEN', 'affiliate_password_forgotten.php');
  89  
  90    define('FILENAME_AFFILIATE_LOGOUT', 'affiliate_logout.php');
  91    define('FILENAME_AFFILIATE_SALES', 'affiliate_sales.php');
  92    define('FILENAME_AFFILIATE_SIGNUP', 'affiliate_signup.php');
  93  
  94    define('FILENAME_AFFILIATE_SIGNUP_OK', 'affiliate_signup_ok.php');
  95    define('FILENAME_AFFILIATE_PAYMENT', 'affiliate_payment.php');
  96  
  97  // include the language translations

  98    require(DIR_WS_LANGUAGES . 'affiliate_' . $language . '.php');
  99  
 100    $affiliate_clientdate = (date ("Y-m-d H:i:s"));
 101    $affiliate_clientbrowser = $HTTP_SERVER_VARS["HTTP_USER_AGENT"];
 102    $affiliate_clientip = $HTTP_SERVER_VARS["REMOTE_ADDR"];
 103    $affiliate_clientreferer = $HTTP_SERVER_VARS["HTTP_REFERER"];
 104  
 105    if (!$HTTP_SESSION_VARS['affiliate_ref']) {
 106      tep_session_register('affiliate_ref');
 107      tep_session_register('affiliate_clickthroughs_id');
 108      if (($HTTP_GET_VARS['ref'] || $HTTP_POST_VARS['ref'])) {
 109        if ($HTTP_GET_VARS['ref']) $affiliate_ref = $HTTP_GET_VARS['ref'];
 110        if ($HTTP_POST_VARS['ref']) $affiliate_ref = $HTTP_POST_VARS['ref'];
 111        if ($HTTP_GET_VARS['products_id']) $affiliate_products_id = $HTTP_GET_VARS['products_id'];
 112        if ($HTTP_POST_VARS['products_id']) $affiliate_products_id = $HTTP_POST_VARS['products_id'];
 113        if ($HTTP_GET_VARS['affiliate_banner_id']) $affiliate_banner_id = $HTTP_GET_VARS['affiliate_banner_id'];
 114        if ($HTTP_POST_VARS['affiliate_banner_id']) $affiliate_banner_id = $HTTP_POST_VARS['affiliate_banner_id'];
 115  
 116        if (!$link_to) $link_to = "0";
 117        $sql_data_array = array('affiliate_id' => $affiliate_ref,
 118                                'affiliate_clientdate' => $affiliate_clientdate,
 119                                'affiliate_clientbrowser' => $affiliate_clientbrowser,
 120                                'affiliate_clientip' => $affiliate_clientip,
 121                                'affiliate_clientreferer' => $affiliate_clientreferer,
 122                                'affiliate_products_id' => $affiliate_products_id,
 123                                'affiliate_banner_id' => $affiliate_banner_id);
 124        tep_db_perform(TABLE_AFFILIATE_CLICKTHROUGHS, $sql_data_array);
 125        $affiliate_clickthroughs_id = tep_db_insert_id();
 126  
 127     // Banner has been clicked, update stats:

 128        if ($affiliate_banner_id && $affiliate_ref) {
 129          $today = date('Y-m-d');
 130          $sql = "select * from " . TABLE_AFFILIATE_BANNERS_HISTORY . " where affiliate_banners_id = '" . $affiliate_banner_id  . "' and  affiliate_banners_affiliate_id = '" . $affiliate_ref . "' and affiliate_banners_history_date = '" . $today . "'";
 131          $banner_stats_query = tep_db_query($sql);
 132  
 133       // Banner has been shown today

 134          if (tep_db_fetch_array($banner_stats_query)) {
 135          tep_db_query("update " . TABLE_AFFILIATE_BANNERS_HISTORY . " set affiliate_banners_clicks = affiliate_banners_clicks + 1 where affiliate_banners_id = '" . $affiliate_banner_id . "' and affiliate_banners_affiliate_id = '" . $affiliate_ref. "' and affiliate_banners_history_date = '" . $today . "'");
 136     // Initial entry if banner has not been shown

 137        } else {
 138          $sql_data_array = array('affiliate_banners_id' => $affiliate_banner_id,
 139                                  'affiliate_banners_products_id' => $affiliate_products_id,
 140                                  'affiliate_banners_affiliate_id' => $affiliate_ref,
 141                                  'affiliate_banners_clicks' => '1',
 142                                  'affiliate_banners_history_date' => $today);
 143          tep_db_perform(TABLE_AFFILIATE_BANNERS_HISTORY, $sql_data_array);
 144        }
 145      }
 146  
 147   // Set Cookie if the customer comes back and orders it counts

 148      setcookie('affiliate_ref', $affiliate_ref, time() + AFFILIATE_COOKIE_LIFETIME);
 149      }
 150      if ($HTTP_COOKIE_VARS['affiliate_ref']) { // Customer comes back and is registered in cookie
 151        $affiliate_ref = $HTTP_COOKIE_VARS['affiliate_ref'];
 152      }
 153    }
 154  
 155  ////

 156  // Compatibility to older Snapshots

 157  
 158  // set the type of request (secure or not)

 159    if (!isset($request_type)) $request_type = (getenv('HTTPS') == 'on') ? 'SSL' : 'NONSSL';
 160  
 161  // Emulate the breadcrumb class

 162    if (!class_exists(breadcrumb)) {
 163      class breadcrumb {
 164        function add($title, $link = '') {
 165          global $location;
 166          $location='&raquo; <a href="' . $link . '" class="headerNavigation">' . $title . '</a>';
 167        }
 168      }
 169      $breadcrumb = new breadcrumb;
 170    }
 171  ?>


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