document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <?php
  2. /*
  3.   $Id$
  4.  
  5.   osCommerce, Open Source E-Commerce Solutions
  6.   http://www.oscommerce.com
  7.  
  8.   Copyright (c) 2008 osCommerce
  9.  
  10.   Released under the GNU General Public License
  11. */
  12.  
  13. // start the timer for the page parse time log
  14.   define(\'PAGE_PARSE_START_TIME\', microtime());
  15.  
  16. // set the level of error reporting
  17.   error_reporting(E_ALL & ~E_NOTICE);
  18.  
  19. //the following three lines are for TESTING errors purposes ONLY, remove from final code
  20.     //error_reporting(E_ALL);
  21.     //ini_set(\'display_errors\',\'1\');
  22.     //ini_set(\'display_startup_errors\',\'1\');
  23.  
  24. // KISS Error Handling & Debugging by FWR Media
  25.   include_once (\'includes/kiss_error_handler.php\');
  26.  
  27. // check support for register_globals
  28.   if (function_exists(\'ini_get\') && (ini_get(\'register_globals\') == false) && (PHP_VERSION < 4.3) ) {
  29.     exit(\'Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory. Please use PHP 4.3+ if register_globals cannot be enabled on the server.\');
  30.   }
  31.  
  32. // load server configuration parameters
  33.   if (file_exists(\'includes/local/configure.php\')) { // for developers
  34.     include(\'includes/local/configure.php\');
  35.   } else {
  36.     include(\'includes/configure.php\');
  37.   }
  38.  
  39.   if (strlen(DB_SERVER) < 1) {
  40.     if (is_dir(\'install\')) {
  41.       header(\'Location: install/index.php\');
  42.     }
  43.   }
  44.  
  45. // define the project version --- obsolete, now retrieved with tep_get_version()
  46.   define(\'PROJECT_VERSION\', \'osCommerce Online Merchant v2.3\');
  47.  
  48. // some code to solve compatibility issues
  49.   require(DIR_WS_FUNCTIONS . \'compatibility.php\');
  50.  
  51. // set the type of request (secure or not)
  52.   $request_type = (getenv(\'HTTPS\') == \'on\') ? \'SSL\' : \'NONSSL\';
  53.  
  54. // kdm define special general functions
  55.   require(DIR_WS_FUNCTIONS . \'gfc_general.php\');
  56.  
  57. // set php_self in the local scope
  58.   $req = parse_url($HTTP_SERVER_VARS[\'SCRIPT_NAME\']);
  59.   $PHP_SELF = substr($req[\'path\'], ($request_type == \'NONSSL\') ? strlen(DIR_WS_HTTP_CATALOG) : strlen(DIR_WS_HTTPS_CATALOG));
  60.  
  61.   if ($request_type == \'NONSSL\') {
  62.     define(\'DIR_WS_CATALOG\', DIR_WS_HTTP_CATALOG);
  63.   } else {
  64.     define(\'DIR_WS_CATALOG\', DIR_WS_HTTPS_CATALOG);
  65.   }
  66.  
  67. // include the list of project filenames
  68.   require(DIR_WS_INCLUDES . \'filenames.php\');
  69.  
  70. // include the list of project database tables
  71.   require(DIR_WS_INCLUDES . \'database_tables.php\');
  72.  
  73. // include the database functions
  74.   require(DIR_WS_FUNCTIONS . \'database.php\');
  75.  
  76. // make a connection to the database... now
  77.   tep_db_connect() or die(\'Unable to connect to database server!\');
  78.  
  79. // set the application parameters
  80.   $configuration_query = tep_db_query(\'select configuration_key as cfgKey, configuration_value as cfgValue from \' . TABLE_CONFIGURATION);
  81.   while ($configuration = tep_db_fetch_array($configuration_query)) {
  82.     define($configuration[\'cfgKey\'], $configuration[\'cfgValue\']);
  83.   }
  84.  
  85. // if gzip_compression is enabled, start to buffer the output
  86.   if ( (GZIP_COMPRESSION == \'true\') && ($ext_zlib_loaded = extension_loaded(\'zlib\')) && !headers_sent() ) {
  87.     if (($ini_zlib_output_compression = (int)ini_get(\'zlib.output_compression\')) < 1) {
  88.       if (PHP_VERSION < \'5.4\' || PHP_VERSION > \'5.4.5\') { // see PHP bug 55544
  89.         if (PHP_VERSION >= \'4.0.4\') {
  90.           ob_start(\'ob_gzhandler\');
  91.         } elseif (PHP_VERSION >= \'4.0.1\') {
  92.           include(DIR_WS_FUNCTIONS . \'gzip_compression.php\');
  93.           ob_start();
  94.           ob_implicit_flush();
  95.         }
  96.       }
  97.     } elseif (function_exists(\'ini_set\')) {
  98.       ini_set(\'zlib.output_compression_level\', GZIP_LEVEL);
  99.     }
  100.   }
  101.  
  102. // set the HTTP GET parameters manually if search_engine_friendly_urls is enabled
  103.   if (SEARCH_ENGINE_FRIENDLY_URLS == \'true\') {
  104.     if (strlen(getenv(\'PATH_INFO\')) > 1) {
  105.       $GET_array = array();
  106.       $PHP_SELF = str_replace(getenv(\'PATH_INFO\'), \'\', $PHP_SELF);
  107.       $vars = explode(\'/\', substr(getenv(\'PATH_INFO\'), 1));
  108.       do_magic_quotes_gpc($vars);
  109.       for ($i=0, $n=sizeof($vars); $i<$n; $i++) {
  110.         if (strpos($vars[$i], \'[]\')) {
  111.           $GET_array[substr($vars[$i], 0, -2)][] = $vars[$i+1];
  112.         } else {
  113.           $HTTP_GET_VARS[$vars[$i]] = $vars[$i+1];
  114.         }
  115.         $i++;
  116.       }
  117.  
  118.       if (sizeof($GET_array) > 0) {
  119.         while (list($key, $value) = each($GET_array)) {
  120.           $HTTP_GET_VARS[$key] = $value;
  121.         }
  122.       }
  123.     }
  124.   }
  125.  
  126. // define general functions used application-wide
  127.   require(DIR_WS_FUNCTIONS . \'general.php\');
  128.   require(DIR_WS_FUNCTIONS . \'html_output.php\');
  129.  
  130. // set the cookie domain
  131.   $cookie_domain = (($request_type == \'NONSSL\') ? HTTP_COOKIE_DOMAIN : HTTPS_COOKIE_DOMAIN);
  132.   $cookie_path = (($request_type == \'NONSSL\') ? HTTP_COOKIE_PATH : HTTPS_COOKIE_PATH);
  133.  
  134. // include cache functions if enabled
  135.   if (USE_CACHE == \'true\') include(DIR_WS_FUNCTIONS . \'cache.php\');
  136.  
  137. // include shopping cart class
  138.   require(DIR_WS_CLASSES . \'shopping_cart.php\');
  139.  
  140. // include wishlist class
  141.   require(DIR_WS_CLASSES . \'wishlist.php\');
  142.  
  143. // include navigation history class
  144.   require(DIR_WS_CLASSES . \'navigation_history.php\');
  145.  
  146. // define how the session functions will be used
  147.   require(DIR_WS_FUNCTIONS . \'sessions.php\');
  148.  
  149. // set the session name and save path
  150.   tep_session_name(\'osCsid\');
  151.   tep_session_save_path(SESSION_WRITE_DIRECTORY);
  152.  
  153. // HMCS: Begin Autologon
  154. // Determine if cookies are enabled
  155.   setcookie("TEMPCOOKIE", "CookieOn", time() + 60 * 60);
  156.   $cookieinfo = $HTTP_COOKIE_VARS["TEMPCOOKIE"];
  157.   if ($cookieinfo == "CookieOn") {
  158.     global $cookies_on;
  159.     $cookies_on = true;
  160.   }
  161. // HMCS: End Autologon
  162.  
  163. // set the session cookie parameters
  164.    if (function_exists(\'session_set_cookie_params\')) {
  165.     session_set_cookie_params(0, $cookie_path, $cookie_domain);
  166.   } elseif (function_exists(\'ini_set\')) {
  167.     ini_set(\'session.cookie_lifetime\', \'0\');
  168.     ini_set(\'session.cookie_path\', $cookie_path);
  169.     ini_set(\'session.cookie_domain\', $cookie_domain);
  170.   }
  171.  
  172.   @ini_set(\'session.use_only_cookies\', (SESSION_FORCE_COOKIE_USE == \'True\') ? 1 : 0);
  173.  
  174. // set the session ID if it exists
  175.    if ( SESSION_FORCE_COOKIE_USE == \'False\' ) {
  176.         if ( isset($HTTP_GET_VARS[tep_session_name()]) && (!isset($HTTP_COOKIE_VARS[tep_session_name()]) || ($HTTP_COOKIE_VARS[tep_session_name()] != $HTTP_GET_VARS[tep_session_name()])) ) {
  177.         tep_session_id($HTTP_GET_VARS[tep_session_name()]);
  178.         } elseif ( isset($HTTP_POST_VARS[tep_session_name()]) && (!isset($HTTP_COOKIE_VARS[tep_session_name()]) || ($HTTP_COOKIE_VARS[tep_session_name()] != $HTTP_POST_VARS[tep_session_name()])) ) {
  179.             tep_session_id($HTTP_POST_VARS[tep_session_name()]);
  180.         }
  181.     }
  182.  
  183. // start the session
  184.   $session_started = false;
  185.   if (SESSION_FORCE_COOKIE_USE == \'True\') {
  186.     tep_setcookie(\'cookie_test\', \'please_accept_for_session\', time()+60*60*24*30, $cookie_path, $cookie_domain);
  187.  
  188.     if (isset($HTTP_COOKIE_VARS[\'cookie_test\'])) {
  189.       tep_session_start();
  190.       $session_started = true;
  191.     }
  192.   } elseif (SESSION_BLOCK_SPIDERS == \'True\') {
  193.     $user_agent = strtolower(getenv(\'HTTP_USER_AGENT\'));
  194.     $spider_flag = false;
  195.  
  196.     if (tep_not_null($user_agent)) {
  197.       $spiders = file(DIR_WS_INCLUDES . \'spiders.txt\');
  198.  
  199.       for ($i=0, $n=sizeof($spiders); $i<$n; $i++) {
  200.         if (tep_not_null($spiders[$i])) {
  201.           if (is_integer(strpos($user_agent, trim($spiders[$i])))) {
  202.             $spider_flag = true;
  203.             break;
  204.           }
  205.         }
  206.       }
  207.     }
  208.  
  209.     if ($spider_flag == false) {
  210.       tep_session_start();
  211.       $session_started = true;
  212.     }
  213.   } else {
  214.     tep_session_start();
  215.     $session_started = true;
  216.   }
  217.  
  218.   //HTTP_REFERER
  219.   if (!$referer_url) {
  220.     if ($HTTP_SERVER_VARS[\'HTTP_REFERER\']) {
  221.     $referer_url = $HTTP_SERVER_VARS[\'HTTP_REFERER\'];
  222.     tep_session_register(\'referer_url\');
  223.     }
  224.   }
  225.  
  226.   if ( ($session_started == true) && (PHP_VERSION >= 4.3) && function_exists(\'ini_get\') && (ini_get(\'register_globals\') == false) ) {
  227.     extract($_SESSION, EXTR_OVERWRITE+EXTR_REFS);
  228.   }
  229.  
  230. // initialize a session token
  231.   if (!tep_session_is_registered(\'sessiontoken\')) {
  232.     $sessiontoken = md5(tep_rand() . tep_rand() . tep_rand() . tep_rand());
  233.     tep_session_register(\'sessiontoken\');
  234.   }
  235.  
  236. // set SID once, even if empty
  237.   $SID = (defined(\'SID\') ? SID : \'\');
  238.  
  239. // verify the ssl_session_id if the feature is enabled
  240.   if ( ($request_type == \'SSL\') && (SESSION_CHECK_SSL_SESSION_ID == \'True\') && (ENABLE_SSL == true) && ($session_started == true) ) {
  241.     $ssl_session_id = getenv(\'SSL_SESSION_ID\');
  242.     if (!tep_session_is_registered(\'SSL_SESSION_ID\')) {
  243.       $SESSION_SSL_ID = $ssl_session_id;
  244.       tep_session_register(\'SESSION_SSL_ID\');
  245.     }
  246.  
  247.     if ($SESSION_SSL_ID != $ssl_session_id) {
  248.       tep_session_destroy();
  249.       tep_redirect(tep_href_link(FILENAME_SSL_CHECK));
  250.     }
  251.   }
  252.  
  253. // verify the browser user agent if the feature is enabled
  254.   if (SESSION_CHECK_USER_AGENT == \'True\') {
  255.     $http_user_agent = getenv(\'HTTP_USER_AGENT\');
  256.     if (!tep_session_is_registered(\'SESSION_USER_AGENT\')) {
  257.       $SESSION_USER_AGENT = $http_user_agent;
  258.       tep_session_register(\'SESSION_USER_AGENT\');
  259.     }
  260.  
  261.     if ($SESSION_USER_AGENT != $http_user_agent) {
  262.       tep_session_destroy();
  263.       tep_redirect(tep_href_link(FILENAME_LOGIN));
  264.     }
  265.   }
  266.  
  267. // verify the IP address if the feature is enabled
  268.   if (SESSION_CHECK_IP_ADDRESS == \'True\') {
  269.     $ip_address = tep_get_ip_address();
  270.     if (!tep_session_is_registered(\'SESSION_IP_ADDRESS\')) {
  271.       $SESSION_IP_ADDRESS = $ip_address;
  272.       tep_session_register(\'SESSION_IP_ADDRESS\');
  273.     }
  274.  
  275.     if ($SESSION_IP_ADDRESS != $ip_address) {
  276.       tep_session_destroy();
  277.       tep_redirect(tep_href_link(FILENAME_LOGIN));
  278.     }
  279.   }
  280.  
  281. // create the shopping cart
  282.   if (!tep_session_is_registered(\'cart\') || !is_object($cart)) {
  283.     tep_session_register(\'cart\');
  284.     $cart = new shoppingCart;
  285.   }
  286.  
  287. // include currencies class and create an instance
  288.   require(DIR_WS_CLASSES . \'currencies.php\');
  289.   $currencies = new currencies();
  290.  
  291. // BOF qpbpp 2.0
  292. // include the price formatter classes for the price breaks contribution
  293.   require(DIR_WS_CLASSES . \'PriceFormatter.php\');
  294.   $pf = new PriceFormatter;
  295.   require(DIR_WS_CLASSES . \'PriceFormatterStore.php\');
  296.   $pfs = new PriceFormatterStore;
  297. // EOF qpbpp 2.0
  298.  
  299. // include the mail classes
  300.   require(DIR_WS_CLASSES . \'mime.php\');
  301.   require(DIR_WS_CLASSES . \'email.php\');
  302.  
  303. // set the language
  304.   if (!tep_session_is_registered(\'language\') || isset($HTTP_GET_VARS[\'language\'])) {
  305.     if (!tep_session_is_registered(\'language\')) {
  306.       tep_session_register(\'language\');
  307.       tep_session_register(\'languages_id\');
  308.     }
  309.  
  310.     include(DIR_WS_CLASSES . \'language.php\');
  311.     $lng = new language();
  312.  
  313.     if (isset($HTTP_GET_VARS[\'language\']) && tep_not_null($HTTP_GET_VARS[\'language\'])) {
  314.       $lng->set_language($HTTP_GET_VARS[\'language\']);
  315.     } else {
  316.       $lng->get_browser_language();
  317.     }
  318.  
  319.     $language = $lng->language[\'directory\'];
  320.     $languages_id = $lng->language[\'id\'];
  321.   }
  322.  
  323. // include the language translations
  324.   $_system_locale_numeric = setlocale(LC_NUMERIC, 0);
  325.   require(DIR_WS_LANGUAGES . $language . \'.php\');
  326.   setlocale(LC_NUMERIC, $_system_locale_numeric); // Prevent LC_ALL from setting LC_NUMERIC to a locale with 1,0 float/decimal values instead of 1.0 (see bug #634)
  327.  
  328. // include the cName and pName cache file
  329.   include(DIR_WS_INCLUDES . \'seo_cache.php\');
  330.  
  331.   if (isset($HTTP_GET_VARS[\'cName\']) && defined(urldecode($HTTP_GET_VARS[\'cName\']))) {
  332.     $cPath = str_replace(\'cPath=\', \'\', constant(urldecode($HTTP_GET_VARS[\'cName\'])));
  333.     $HTTP_GET_VARS[\'cPath\'] = $cPath;
  334.   }
  335.  
  336.   if (isset($HTTP_GET_VARS[\'pName\']) && defined(urldecode($HTTP_GET_VARS[\'pName\']))) {
  337.     $pid = str_replace(\'products_id=\', \'\', constant(urldecode($HTTP_GET_VARS[\'pName\'])));
  338.     $HTTP_GET_VARS[\'products_id\'] = (int)$pid;
  339.   }
  340.  
  341. // tax class
  342.     require(DIR_WS_CLASSES . \'tax.php\');
  343.     $osC_Tax = new osC_Tax;
  344.  
  345. // currency
  346.   if (!tep_session_is_registered(\'currency\') || isset($HTTP_GET_VARS[\'currency\']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == \'true\') && (LANGUAGE_CURRENCY != $currency) ) ) {
  347.     if (!tep_session_is_registered(\'currency\')) tep_session_register(\'currency\');
  348.  
  349.     if (isset($HTTP_GET_VARS[\'currency\']) && $currencies->is_set($HTTP_GET_VARS[\'currency\'])) {
  350.       $currency = $HTTP_GET_VARS[\'currency\'];
  351.     } else {
  352.       $currency = ((USE_DEFAULT_LANGUAGE_CURRENCY == \'true\') && $currencies->is_set(LANGUAGE_CURRENCY)) ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
  353.     }
  354.   }
  355.  
  356. // navigation history
  357.   if (!tep_session_is_registered(\'navigation\') || !is_object($navigation)) {
  358.     tep_session_register(\'navigation\');
  359.     $navigation = new navigationHistory;
  360.   }
  361.   $navigation->add_current_page();
  362.  
  363. // infobox
  364.   require(DIR_WS_CLASSES . \'boxes.php\');
  365.  
  366. // initialize the message stack for output messages
  367.   require(DIR_WS_CLASSES . \'message_stack.php\');
  368.   $messageStack = new messageStack;
  369.  
  370. // LINE ADDED - MOD: CREDIT CLASS Gift Voucher Contribution
  371.   require(DIR_WS_FUNCTIONS . \'add_ccgvdc_application_top.php\');  // ICW CREDIT CLASS Gift Voucher Addition
  372.   require(DIR_WS_LANGUAGES . $language . \'/add_ccgvdc.php\'); // ICW CREDIT CLASS Gift Voucher Addition
  373.  
  374. // action recorder
  375.   include(\'includes/classes/action_recorder.php\');
  376.  
  377. // BOF: Down for Maintenance except for admin ip
  378. if (EXCLUDE_ADMIN_IP_FOR_MAINTENANCE != getenv(\'REMOTE_ADDR\')){
  379.     if (DOWN_FOR_MAINTENANCE==\'true\' and !strstr($PHP_SELF,DOWN_FOR_MAINTENANCE_FILENAME)) { tep_redirect(tep_href_link(DOWN_FOR_MAINTENANCE_FILENAME)); }
  380.     }
  381. // do not let people get to down for maintenance page if not turned on
  382. if (DOWN_FOR_MAINTENANCE==\'false\' and strstr($PHP_SELF,DOWN_FOR_MAINTENANCE_FILENAME)) {
  383.     tep_redirect(tep_href_link(FILENAME_DEFAULT));
  384. }
  385. // EOF: WebMakers.com Added: Down for Maintenance
  386.  
  387. // wishlist data
  388.   if(!tep_session_is_registered(\'wishList\')) {
  389.     tep_session_register(\'wishList\');
  390.     $wishList = new wishlist;
  391.   }
  392.  
  393. //Wishlist actions (must be before shopping cart actions)
  394.   if(isset($HTTP_POST_VARS[\'wishlist\'])) {
  395.     if(isset($HTTP_POST_VARS[\'products_id\'])) {
  396.         if(isset($HTTP_POST_VARS[\'id\'])) {
  397.             $attributes_id = $HTTP_POST_VARS[\'id\'];
  398.             tep_session_register(\'attributes_id\');
  399.         }
  400.         $wishlist_id = $HTTP_POST_VARS[\'products_id\'];
  401.         tep_session_register(\'wishlist_id\');
  402.     }
  403.     tep_redirect(tep_href_link(FILENAME_WISHLIST));
  404.   }
  405.  
  406. // Shopping cart actions
  407.   if (isset($HTTP_GET_VARS[\'action\'])) {
  408. // redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled
  409.     if ($session_started == false) {
  410.       tep_redirect(tep_href_link(FILENAME_COOKIE_USAGE));
  411.     }
  412.  
  413.     if (DISPLAY_CART == \'true\') {
  414.       $goto =  FILENAME_SHOPPING_CART;
  415.       $parameters = array(\'action\', \'cPath\', \'products_id\', \'pid\');
  416.     } else {
  417.       $goto = $PHP_SELF;
  418.       if ($HTTP_GET_VARS[\'action\'] == \'buy_now\') {
  419. // BOE: XSell
  420.         if (isset($HTTP_GET_VARS[\'product_to_buy_id\'])) {
  421.         $parameters = array(\'action\', \'pid\', \'products_to_buy_id\');
  422.           } else {
  423.         $parameters = array(\'action\', \'pid\', \'products_id\');
  424.           }
  425. // EOE: XSell
  426.       } else {
  427.         $parameters = array(\'action\', \'pid\');
  428.       }
  429.     }
  430.     switch ($HTTP_GET_VARS[\'action\']) {
  431. //BOF - Zappo - Option Types v2 JOLI BUG FIX FOR CLEAR CART TEXT FIELDS
  432.       case \'clear_cart\': $cart->remove_all();
  433.      tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
  434.     break;
  435. //EOF - Zappo - Option Types v2 JOLI BUG FIX FOR CLEAR CART TEXT FIELDS
  436. // customer wants to update the product quantity in their shopping cart
  437.       case \'update_product\' : for ($i=0, $n=sizeof($HTTP_POST_VARS[\'products_id\']); $i<$n; $i++) {
  438.                                 if (in_array($HTTP_POST_VARS[\'products_id\'][$i], (is_array($HTTP_POST_VARS[\'cart_delete\']) ? $HTTP_POST_VARS[\'cart_delete\'] : array()))) {
  439.                                   $cart->remove($HTTP_POST_VARS[\'products_id\'][$i]);
  440.                                 } else {
  441.                                   $attributes = ($HTTP_POST_VARS[\'id\'][$HTTP_POST_VARS[\'products_id\'][$i]]) ? $HTTP_POST_VARS[\'id\'][$HTTP_POST_VARS[\'products_id\'][$i]] : \'\';
  442.                                   $cart->add_cart($HTTP_POST_VARS[\'products_id\'][$i], $HTTP_POST_VARS[\'cart_quantity\'][$i], $attributes, false);
  443.                                 }
  444.                               }
  445.                               tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
  446.                               break;
  447. //BOF - Zappo - Option Types v2 - File uploading: Purge the Temporary Upload Dir
  448.       case \'add_product\' :    if (isset($HTTP_POST_VARS[\'products_id\']) && is_numeric($HTTP_POST_VARS[\'products_id\'])) {
  449.                                 $purgeDir = opendir(TMP_DIR) or die (\'Could not open \'.TMP_DIR);
  450.                                 while ($file = readdir($purgeDir)) {
  451.                                   if ($file != (\'.htaccess\') && $file != (\'.\') && $file != (\'..\') && filemtime(TMP_DIR . $file) < strtotime(OPTIONS_TYPE_PURGETIME)) {
  452.                                     unlink(TMP_DIR . $file);  // Delete file from server...
  453.                                     tep_db_query("delete from " . TABLE_FILES_UPLOADED . " where files_uploaded_name = \'" . $file . "\'"); // Remove File\'s database entry....
  454.                                   }
  455.                                 }
  456.                                 closedir($purgeDir);
  457.                                 //EOF - Zappo - Option Types v2 - File uploading: Purge the Temporary Upload Dir
  458.  
  459.                                 //BOF - Zappo - Option Types v2 - ONE LINE - Set real_ids for processing
  460.                                 $real_ids = $HTTP_POST_VARS[\'id\'];
  461.                                 //BOF - Zappo - Option Types v2 - File uploading: save uploaded files with unique file names, in the proper folder
  462.                                 if ($HTTP_POST_VARS[\'number_of_uploads\'] > 0) {
  463.                                   require(DIR_WS_CLASSES . \'upload.php\');
  464.                                   for ($i = 1; $i <= $HTTP_POST_VARS[\'number_of_uploads\']; $i++) {
  465.                                     $TEMP_FILE = $_FILES[\'id\'][\'tmp_name\'][TEXT_PREFIX . $HTTP_POST_VARS[UPLOAD_PREFIX . $i]];
  466.                                     if (tep_not_null($TEMP_FILE) && $TEMP_FILE != \'none\') {
  467.                                       $products_options_file = new upload(\'id\');
  468.                                       //BOF - Zappo - Option Types v2 - Set Upload directory (Registered customers in Uploads, other in Temporary folder)
  469.                                       if (tep_session_is_registered(\'customer_id\')) {  // IF the customer is registered, use Upload Dir
  470.                                         $products_options_file->set_destination(UPL_DIR);
  471.                                       } else { // If the customer is not registered, use Temporary Dir
  472.                                         $products_options_file->set_destination(TMP_DIR);
  473.                                       }
  474.                                       //EOF - Zappo - Option Types v2 - Set Upload directory (Registered customers in Uploads, other in Temporary folder) incl. RAIWA FIX!
  475.                                       if ($products_options_file->parse(TEXT_PREFIX . $HTTP_POST_VARS[UPLOAD_PREFIX . $i])) {
  476.                                         if (tep_session_is_registered(\'customer_id\')) {
  477.                                           tep_db_query("insert into " . TABLE_FILES_UPLOADED . " (sesskey, customers_id, files_uploaded_name, date) values(\'" . tep_session_id() . "\', \'" . $customer_id . "\', \'" . tep_db_input($products_options_file->filename) . "\', \'" . date("d-m-y") . "\')");
  478.                                         } else {
  479.                                           tep_db_query("insert into " . TABLE_FILES_UPLOADED . " (sesskey, files_uploaded_name, date) values(\'" . tep_session_id() . "\', \'" . tep_db_input($products_options_file->filename) . "\', \'" . date("d-m-y") . "\')");
  480.                                           // @raiwa added 2 lines for guest file upload compatibility with OsC 2.3.
  481.                                           $guestSessionID = tep_session_id();
  482.                                           if (!tep_session_is_registered(\'guestSessionID\')) tep_session_register(\'guestSessionID\');
  483.                                         }
  484.                                         //BOF - Zappo - Option Types v2 - Set File Prefix
  485.                                         if (OPTIONS_TYPE_FILEPREFIX == \'Database\') {  //  Database ID as File prefix
  486.                                           $insert_id = tep_db_insert_id() . \'_\';
  487.                                         } else {  //  Date, time or both as File prefix (Change date formatting here)
  488.                                           if (OPTIONS_TYPE_FILEPREFIX == \'Date\' || OPTIONS_TYPE_FILEPREFIX == \'DateTime\') {
  489.                                             $insert_id = \'D\'.date("d-m-y_");
  490.                                           }
  491.                                           $insert_id .= (OPTIONS_TYPE_FILEPREFIX == \'DateTime\' || OPTIONS_TYPE_FILEPREFIX == \'Time\') ? \'T\'.date("H-i_") : \'\';
  492.                                         }
  493.                                         //EOF - Zappo - Option Types v2 - Set File Prefix
  494.                                         // Update filename in Database with correct prefix (For comparing database names with real files)
  495.                                         tep_db_query("update " . TABLE_FILES_UPLOADED . " set files_uploaded_name = \'" . tep_db_input($insert_id . $products_options_file->filename) . "\' where sesskey = \'" . tep_session_id() . "\' and files_uploaded_name = \'" . tep_db_input($products_options_file->filename) . "\' and date = \'" . date("d-m-y") . "\'");
  496.                                         $real_ids[TEXT_PREFIX . $HTTP_POST_VARS[UPLOAD_PREFIX . $i]] = $insert_id . $products_options_file->filename;
  497.                                         $products_options_file->set_filename($insert_id . $products_options_file->filename);
  498.                                         if (!($products_options_file->save())) {
  499.                                           break 2;
  500.                                         }
  501.                                       } else {
  502.                                         break 2;
  503.                                       }
  504.                                     } else { // No file uploaded -- use previously uploaded file (From Dropdown)
  505.                                       $real_ids[TEXT_PREFIX . $HTTP_POST_VARS[UPLOAD_PREFIX . $i]] = $HTTP_POST_VARS[TEXT_PREFIX . UPLOAD_PREFIX . $i];
  506.                                     }
  507.                                   }
  508.                                 }
  509.                                 //EOF - Zappo - Option Types v2 - File uploading: save uploaded files with unique file names, in the proper folder
  510.                                 //BOF - Zappo - Option Types v2 - ONE LINE - Replace the posted array with the processed one.
  511. //BOF qpbpp 2.0
  512.                                 $cart->add_cart($HTTP_POST_VARS[\'products_id\'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS[\'products_id\'], $real_ids))+$HTTP_POST_VARS[\'cart_quantity\'], $real_ids);
  513. //EOF qpbpp 2.0
  514.                               }
  515.                               tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
  516.                               break;
  517.       // customer removes a product from their shopping cart
  518.       case \'remove_product\' : if (isset($HTTP_GET_VARS[\'products_id\'])) {
  519.                                 $cart->remove($HTTP_GET_VARS[\'products_id\']);
  520.                               }
  521.                               tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
  522.                               break;
  523.       // performed by the \'buy now\' button in product listings and review page
  524.       // BOF: XSell
  525.       case \'buy_now\' :        if (isset($HTTP_GET_VARS[\'product_to_buy_id\'])) {
  526.                                 if (tep_has_product_attributes($HTTP_GET_VARS[\'product_to_buy_id\'])) {
  527.                                   tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, \'products_id=\' . $HTTP_GET_VARS[\'product_to_buy_id\']));
  528.                                 } else {
  529.                                   $cart->add_cart($HTTP_GET_VARS[\'product_to_buy_id\'], $cart->get_quantity($HTTP_GET_VARS[\'product_to_buy_id\'])+1);
  530.                                           }
  531.                               } elseif (isset($HTTP_GET_VARS[\'products_id\'])) {
  532. // EOF: XSell
  533.                                 if (tep_has_product_attributes($HTTP_GET_VARS[\'products_id\'])) {
  534.                                 tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, \'products_id=\' . $HTTP_GET_VARS[\'products_id\']));
  535.                                 } else {
  536.                                 $cart->add_cart($HTTP_GET_VARS[\'products_id\'], $cart->get_quantity($HTTP_GET_VARS[\'products_id\'])+1);
  537.                                 }
  538.                               }
  539.                               tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
  540.                               break;
  541.       case \'notify\' :         if (tep_session_is_registered(\'customer_id\')) {
  542.                                 if (isset($HTTP_GET_VARS[\'products_id\'])) {
  543.                                   $notify = $HTTP_GET_VARS[\'products_id\'];
  544.                                 } elseif (isset($HTTP_GET_VARS[\'notify\'])) {
  545.                                   $notify = $HTTP_GET_VARS[\'notify\'];
  546.                                 } elseif (isset($HTTP_POST_VARS[\'notify\'])) {
  547.                                   $notify = $HTTP_POST_VARS[\'notify\'];
  548.                                 } else {
  549.                                   tep_redirect(tep_href_link($PHP_SELF, tep_get_all_get_params(array(\'action\', \'notify\'))));
  550.                                 }
  551.                                 if (!is_array($notify)) $notify = array($notify);
  552.                                 for ($i=0, $n=sizeof($notify); $i<$n; $i++) {
  553.                                   $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = \'" . (int)$notify[$i] . "\' and customers_id = \'" . (int)$customer_id . "\'");
  554.                                   $check = tep_db_fetch_array($check_query);
  555.                                   if ($check[\'count\'] < 1) {
  556.                                     tep_db_query("insert into " . TABLE_PRODUCTS_NOTIFICATIONS . " (products_id, customers_id, date_added) values (\'" . (int)$notify[$i] . "\', \'" . (int)$customer_id . "\', now())");
  557.                                   }
  558.                                 }
  559.                                 tep_redirect(tep_href_link($PHP_SELF, tep_get_all_get_params(array(\'action\', \'notify\'))));
  560.                               } else {
  561.                                 $navigation->set_snapshot();
  562.                                 tep_redirect(tep_href_link(FILENAME_LOGIN, \'\', \'SSL\'));
  563.                               }
  564.                               break;
  565.       case \'notify_remove\' :  if (tep_session_is_registered(\'customer_id\') && isset($HTTP_GET_VARS[\'products_id\'])) {
  566.                                 $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = \'" . (int)$HTTP_GET_VARS[\'products_id\'] . "\' and customers_id = \'" . (int)$customer_id . "\'");
  567.                                 $check = tep_db_fetch_array($check_query);
  568.                                 if ($check[\'count\'] > 0) {
  569.                                   tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = \'" . (int)$HTTP_GET_VARS[\'products_id\'] . "\' and customers_id = \'" . (int)$customer_id . "\'");
  570.                                 }
  571.                                 tep_redirect(tep_href_link($PHP_SELF, tep_get_all_get_params(array(\'action\'))));
  572.                               } else {
  573.                                 $navigation->set_snapshot();
  574.                                 tep_redirect(tep_href_link(FILENAME_LOGIN, \'\', \'SSL\'));
  575.                               }
  576.                               break;     
  577. // re-order product segment
  578.       case \'reorder\' : $reorder_result = tep_reorder($_GET[\'order_id\']);
  579.                                 if ($reorder_result == \'\') {
  580.                                 tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING));
  581.                                 } else {
  582.                                 echo $reorder_result;
  583.                                 }
  584.                                 break;
  585.       case \'cust_order\' :     if (tep_session_is_registered(\'customer_id\') && isset($HTTP_GET_VARS[\'pid\'])) {
  586.                                 if (tep_has_product_attributes($HTTP_GET_VARS[\'pid\'])) {
  587.                                   tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, \'products_id=\' . $HTTP_GET_VARS[\'pid\']));
  588.                                 } else {
  589.                                   $cart->add_cart($HTTP_GET_VARS[\'pid\'], $cart->get_quantity($HTTP_GET_VARS[\'pid\'])+1);
  590.                                 }
  591.                               }
  592.                               tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
  593.                               break;
  594.     }
  595.   }
  596.  
  597. //rmh referral start
  598. // set the referral id
  599.   if (!tep_session_is_registered(\'referral_id\') || isset($HTTP_GET_VARS[\'ref\'])) {
  600.     if (!tep_session_is_registered(\'referral_id\') && !tep_session_is_registered(\'customer_id\')) {
  601.       tep_session_register(\'referral_id\');
  602.     }
  603.  
  604.     if (isset($HTTP_GET_VARS[\'ref\']) && tep_not_null($HTTP_GET_VARS[\'ref\'])) {
  605.       $referral_id = $HTTP_GET_VARS[\'ref\'];
  606.     } else {
  607.       $referral_id = \'\';
  608.     }
  609.   }
  610. //rmh referral end
  611.  
  612. // include the who\'s online functions
  613.   require(DIR_WS_FUNCTIONS . \'whos_online.php\');
  614.   tep_update_whos_online();
  615.  
  616. // include the password crypto functions
  617.   require(DIR_WS_FUNCTIONS . \'password_funcs.php\');
  618.  
  619. // include validation functions (right now only email address)
  620.   require(DIR_WS_FUNCTIONS . \'validations.php\');
  621.  
  622. // split-page-results
  623.   require(DIR_WS_CLASSES . \'split_page_results.php\');
  624.  
  625. // auto activate and expire banners
  626.   require(DIR_WS_FUNCTIONS . \'banner.php\');
  627.   tep_activate_banners();
  628.   tep_expire_banners();
  629.  
  630. // auto expire special products
  631. // BOF kdm specials maintenance
  632. //  require(DIR_WS_FUNCTIONS . \'specials.php\');
  633. //  tep_expire_specials();
  634.   require(DIR_WS_FUNCTIONS . FILENAME_SPECIALS_MAINTENANCE);
  635.   gfc_start_specials();
  636.   gfc_expire_specials();
  637. // EOF kdm specials maintenance
  638.  
  639. // BOF: Featured Products
  640.   require(DIR_WS_FUNCTIONS . \'featured.php\');
  641.   tep_expire_featured();
  642. // EOF: Featured Products
  643.  
  644.   require(DIR_WS_CLASSES . \'osc_template.php\');
  645.   $oscTemplate = new oscTemplate();
  646.  
  647. // calculate category path
  648.   if (isset($HTTP_GET_VARS[\'cPath\'])) {
  649.     $cPath = $HTTP_GET_VARS[\'cPath\'];
  650.   } elseif (isset($HTTP_GET_VARS[\'products_id\']) && !isset($HTTP_GET_VARS[\'manufacturers_id\'])) {
  651.     $cPath = tep_get_product_path($HTTP_GET_VARS[\'products_id\']);
  652.   } else {
  653.     $cPath = \'\';
  654.   }
  655.  
  656.   if (tep_not_null($cPath)) {
  657.     $cPath_array = tep_parse_category_path($cPath);
  658.     $cPath = implode(\'_\', $cPath_array);
  659.     $current_category_id = $cPath_array[(sizeof($cPath_array)-1)];
  660.   } else {
  661.     $current_category_id = 0;
  662.   }
  663.  
  664. // include the breadcrumb class and start the breadcrumb trail
  665.   require(DIR_WS_CLASSES . \'breadcrumb.php\');
  666.   $breadcrumb = new breadcrumb;
  667.  
  668.   //$breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);
  669.   $breadcrumb->add(HEADER_TITLE_HOME, HTTP_SERVER);
  670.   $breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));
  671.  
  672. // add category names or the manufacturer name to the breadcrumb trail
  673.   if (isset($cPath_array)) {
  674.     for ($i=0, $n=sizeof($cPath_array); $i<$n; $i++) {
  675.     // BOF Enable & Disable Categories
  676.       $categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd left join " . TABLE_CATEGORIES . " c on cd.categories_id = c.categories_id where c.categories_status = \'1\' and cd.categories_id = \'" . (int)$cPath_array[$i] . "\' and language_id = \'" . (int)$languages_id . "\'");
  677.     // EOF Enable & Disable Categories
  678.       if (tep_db_num_rows($categories_query) > 0) {
  679.         $categories = tep_db_fetch_array($categories_query);
  680.         $breadcrumb->add($categories[\'categories_name\'], tep_href_link(FILENAME_DEFAULT, \'cPath=\' . implode(\'_\', array_slice($cPath_array, 0, ($i+1)))));
  681.       } else {
  682.         break;
  683.       }
  684.     }
  685.   } elseif (isset($HTTP_GET_VARS[\'manufacturers_id\'])) {
  686.     $manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = \'" . (int)$HTTP_GET_VARS[\'manufacturers_id\'] . "\'");
  687.     if (tep_db_num_rows($manufacturers_query)) {
  688.       $manufacturers = tep_db_fetch_array($manufacturers_query);
  689.       $breadcrumb->add($manufacturers[\'manufacturers_name\'], tep_href_link(FILENAME_DEFAULT, \'manufacturers_id=\' . $HTTP_GET_VARS[\'manufacturers_id\']));
  690.     }
  691.   }
  692.  
  693. // add the products model to the breadcrumb trail
  694.   if (isset($HTTP_GET_VARS[\'products_id\'])) {
  695.     // EOF Enable & Disable Categories
  696.     $model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id left join " . TABLE_CATEGORIES . " c on p2c.categories_id = c.categories_id, " . TABLE_PRODUCTS_DESCRIPTION . "  pd where c.categories_status = \'1\' and p.products_id = \'" . (int)$HTTP_GET_VARS[\'products_id\'] . "\' and p.products_id = pd.products_id");
  697.     // EOF Enable & Disable Categories
  698.     if (tep_db_num_rows($model_query)) {
  699.       $model = tep_db_fetch_array($model_query);
  700.       $breadcrumb->add($model[\'products_model\'], tep_href_link(FILENAME_PRODUCT_INFO, \'cPath=\' . $cPath . \'&products_id=\' . $HTTP_GET_VARS[\'products_id\']));
  701.     }
  702.   }
  703.  
  704. //user_tracking modications
  705.   if (!$referer_url) {
  706.     if ($HTTP_SERVER_VARS[\'HTTP_REFERER\']) {
  707.     $referer_url = $HTTP_SERVER_VARS[\'HTTP_REFERER\'];
  708.     //session_register(\'referer_url\');//Deprecated
  709.     $_SESSION[\'referer_url\'] = $referer_url;
  710.     }
  711.   }
  712.  
  713. // HMCS: Begin Autologon
  714.   if ($cookies_on == true) {
  715.     if (ALLOW_AUTOLOGON == \'true\') {                                // Is Autologon enabled?
  716.       if (basename($_SERVER[\'PHP_SELF\']) != FILENAME_LOGIN) {                  // yes
  717.         if (!tep_session_is_registered(\'customer_id\')) {
  718.           include(\'includes/modules/autologon.php\');
  719.         }
  720.       }
  721.     } else {
  722.       setcookie("email_address", "", time() - 3600, $cookie_path);  //no, delete email_address cookie
  723.       setcookie("password", "", time() - 3600, $cookie_path);       //no, delete password cookie
  724.     }
  725.   }
  726. // HMCS: End Autologon
  727.  
  728.  
  729. //BOF - Zappo - Option Types v2 - ONE LINE - message stack moved up from here...
  730.  
  731. // set which precautions should be checked
  732.   define(\'WARN_INSTALL_EXISTENCE\', \'true\');
  733.   define(\'WARN_CONFIG_WRITEABLE\', \'true\');
  734.   define(\'WARN_SESSION_DIRECTORY_NOT_WRITEABLE\', \'true\');
  735.   define(\'WARN_SESSION_AUTO_START\', \'true\');
  736.   define(\'WARN_DOWNLOAD_DIRECTORY_NOT_READABLE\', \'true\');
  737.  
  738. ///
  739. ////////////////////////////
  740. $category_query = tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = \'" . (int)$current_category_id . "\' and cd.categories_id = \'" . (int)$current_category_id . "\' and cd.language_id = \'" . (int)$languages_id . "\'");
  741.   $category = tep_db_fetch_array($category_query);
  742. ?>
');