Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Upgraded php 5.2.17 to 5.5.29 now cant add to cart


Guest

Recommended Posts

I have a very heavily customized oscommerce site based on 2.2

 

I have applied all the php code fixes that I could find to bring up to speed to run on latest version of php

 

site is mostly up ok but two major issues remain and I am not getting anywhere trying to figure it out !

 

1. Cant add anything to shopping cart, it just goes to shopping cart page with Your Shopping Cart is empty! message

 

2. Cant login to admin (it accepts the username and password fields then blanks them out but doesnt change the rest of the screen or come up with any error messages)

 

 

 

here is the relevant parts of configure.php

  define('HTTP_SERVER', 'http://www.outdoorbits.com'); // eg, http://localhost - should not be empty for productive servers
  define('HTTPS_SERVER', 'https://www.outdoorbits.com'); // eg, https://localhost - should not be empty for productive servers
  define('ENABLE_SSL', true); // secure webserver for checkout procedure?
  define('HTTP_COOKIE_DOMAIN', 'outdoorbits.com');
  define('HTTPS_COOKIE_DOMAIN', 'outdoorbits.com');
  define('HTTP_COOKIE_PATH', '/');
  define('HTTPS_COOKIE_PATH', '/');
  define('DIR_WS_HTTP_CATALOG', '/');
  define('DIR_WS_HTTPS_CATALOG', '/');
  define('DIR_WS_IMAGES', 'images/');
//define('DIR_WS_PRODUCT_IMAGES', 'images/productimages');
  define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');
  define('DIR_WS_INCLUDES', 'includes/');
  define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');
  define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
  define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
  define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
  define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

php5fix.php

<?php

$phpversion = explode('.', phpversion());
if((int) $phpversion[0] >= 5){
$HTTP_GET_VARS = &$_GET;
$HTTP_POST_VARS = &$_POST;
$HTTP_REQUEST_VARS = &$_REQUEST;
$HTTP_SESSION_VARS = &$_SESSION;
$HTTP_COOKIE_VARS = &$_COOKIE;
$HTTP_SERVER_VARS = &$_SERVER;
$HTTP_FILES_VARS = &$_FILES;
$HTTP_ENV_VARS = &$_ENV;
}
?>

/includes/application_top.php

<?php
/*
  $Id: application_top.php,v 1.2 2005/01/15 16:53:08 Michael Sasek Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/
// PHP5 fix
require_once("/home/obadmin/public_html/includes/php5fix.php");

// start the timer for the page parse time log
  define('PAGE_PARSE_START_TIME', microtime());
  
// start the Display SQL Queries code  
  $debug = array();

// Shop by Price
define('FILENAME_SHOP_BY_PRICE','shop_by_price.php');

// set the level of error reporting
//  error_reporting(E_ALL & ~E_NOTICE);
//error_reporting(E_ALL & ~E_STRICT);
error_reporting(E_ALL & ~E_NOTICE ^ E_DEPRECATED);


// check if register_globals is enabled.
// since this is a temporary measure this message is hardcoded. The requirement will be removed before 2.2 is finalized.
//  if (function_exists('ini_get')) {
//    ini_get('register_globals') or exit('FATAL ERROR: register_globals is disabled in php.ini, please enable it!');
//  }


// Set the local configuration parameters - mainly for developers
  if (file_exists('includes/local/configure.php')) include('includes/local/configure.php');

//// include server parameters

  require('includes/configure.php');

  if (strlen(DB_SERVER) < 1) {
    if (is_dir('install')) {
      header('Location: install/index.php');
    }
  }

// define the project version
  define('PROJECT_VERSION', 'osCommerce 2.2-MS2');

// set the type of request (secure or not)
  $request_type = (getenv('HTTPS') == 'on') ? 'SSL' : 'NONSSL';

// set php_self in the local scope
  if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];

  if ($request_type == 'NONSSL') {
    define('DIR_WS_CATALOG', DIR_WS_HTTP_CATALOG);
  } else {
    define('DIR_WS_CATALOG', DIR_WS_HTTPS_CATALOG);
  }

// include the list of project filenames
  define('ONE_PAGE_CHECKOUT', 'True');
  require(DIR_WS_INCLUDES . 'filenames.php');

// include the list of project database tables
  require(DIR_WS_INCLUDES . 'database_tables.php');

// customization for the design layout
  define('BOX_WIDTH', 125); // how wide the boxes should be in pixels (default: 125)

// include the database functions
  require(DIR_WS_FUNCTIONS . 'database.php');
  require(DIR_WS_FUNCTIONS . 'clean_html_comments.php');

// make a connection to the database... now
  tep_db_connect() or die('Unable to connect to database server!');

// set the application parameters
  $configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION);
  while ($configuration = tep_db_fetch_array($configuration_query)) {
    define($configuration['cfgKey'], $configuration['cfgValue']);
  }

// if gzip_compression is enabled, start to buffer the output
  if ( (GZIP_COMPRESSION == 'true') && ($ext_zlib_loaded = extension_loaded('zlib')) && (PHP_VERSION >= '4') ) {
    if (($ini_zlib_output_compression = (int)ini_get('zlib.output_compression')) < 1) {
      if (PHP_VERSION >= '4.0.4') {
        ob_start('ob_gzhandler');
      } else {
        include(DIR_WS_FUNCTIONS . 'gzip_compression.php');
        ob_start();
        ob_implicit_flush();
      }
    } else {
      ini_set('zlib.output_compression_level', GZIP_LEVEL);
    }
  }

  //CRE_SEO Install Begin
  if (CRE_SEO == 'true') {
    require_once('seo.php');
  }
  //CRE_SEO Install End 

// set the HTTP GET parameters manually if search_engine_friendly_urls is enabled
  if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') {
    if (strlen(getenv('PATH_INFO')) > 1) {
      $GET_array = array();
      $PHP_SELF = str_replace(getenv('PATH_INFO'), '', $PHP_SELF);
      $vars = explode('/', substr(getenv('PATH_INFO'), 1));
      for ($i=0, $n=sizeof($vars); $i<$n; $i++) {
        if (strpos($vars[$i], '[]')) {
          $GET_array[substr($vars[$i], 0, -2)][] = $vars[$i+1];
        } else {
          $HTTP_GET_VARS[$vars[$i]] = $vars[$i+1];
        }
        $i++;
      }

      if (sizeof($GET_array) > 0) {
        while (list($key, $value) = each($GET_array)) {
          $HTTP_GET_VARS[$key] = $value;
        }
      }
    }
  }





// define general functions used application-wide
  require(DIR_WS_FUNCTIONS . 'general.php');
// BOF: WebMakers.com Added: Downloads Controller
require(DIR_WS_FUNCTIONS . 'downloads_controller.php');
// EOF: WebMakers.com Added: Downloads Controller  
  require(DIR_WS_FUNCTIONS . 'html_output.php');

// set the cookie domain
  $cookie_domain = (($request_type == 'NONSSL') ? HTTP_COOKIE_DOMAIN : HTTPS_COOKIE_DOMAIN);
  $cookie_path = (($request_type == 'NONSSL') ? HTTP_COOKIE_PATH : HTTPS_COOKIE_PATH);

// include cache functions if enabled
  if (USE_CACHE == 'true') include(DIR_WS_FUNCTIONS . 'cache.php');
// include wishlist class
  require(DIR_WS_CLASSES . 'wishlist.php');
// include shopping cart class
  require(DIR_WS_CLASSES . 'shopping_cart.php');

// begin PayPal_Shopping_Cart_IPN
    require(DIR_WS_MODULES . 'payment/paypal/classes/osC/osC.class.php');
// end PayPal_Shopping_Cart_IPN
  
// include navigation history class
  require(DIR_WS_CLASSES . 'navigation_history.php');

// some code to solve compatibility issues
  require(DIR_WS_FUNCTIONS . 'compatibility.php');

// check if sessions are supported, otherwise use the php3 compatible session class
  if (!function_exists('session_start')) {
    define('PHP_SESSION_NAME', 'osCsid');
    define('PHP_SESSION_PATH', $cookie_path);
    define('PHP_SESSION_DOMAIN', $cookie_domain);
    define('PHP_SESSION_SAVE_PATH', SESSION_WRITE_DIRECTORY);

    include(DIR_WS_CLASSES . 'sessions.php');
  }

// define how the session functions will be used
  require(DIR_WS_FUNCTIONS . 'sessions.php');

// set the session name and save path
  tep_session_name('osCsid');
  tep_session_save_path(SESSION_WRITE_DIRECTORY);

// set the session cookie parameters
   if (function_exists('session_set_cookie_params')) {
    session_set_cookie_params(0, $cookie_path, $cookie_domain);
  } elseif (function_exists('ini_set')) {
    ini_set('session.cookie_lifetime', '0');
    ini_set('session.cookie_path', $cookie_path);
    ini_set('session.cookie_domain', $cookie_domain);
  }

// set the session ID if it exists
   if (isset($HTTP_POST_VARS[tep_session_name()])) {
     tep_session_id($HTTP_POST_VARS[tep_session_name()]);
   } elseif ( ($request_type == 'SSL') && isset($HTTP_GET_VARS[tep_session_name()]) ) {
     tep_session_id($HTTP_GET_VARS[tep_session_name()]);
   }

// start the session
  $session_started = false;
  if (SESSION_FORCE_COOKIE_USE == 'True') {
    tep_setcookie('cookie_test', 'please_accept_for_session', time()+60*60*24*30, $cookie_path, $cookie_domain);

    if (isset($HTTP_COOKIE_VARS['cookie_test'])) {
      tep_session_start();
      $session_started = true;
// user_tracking modifications 
   if (!$referer_url) { 
    $referer_url = $HTTP_SERVER_VARS['HTTP_REFERER']; 
        if ($referer_url) { 
            tep_session_register('referer_url'); 
        } 
    }        
    }
  } elseif (SESSION_BLOCK_SPIDERS == 'True') {
    $user_agent = strtolower(getenv('HTTP_USER_AGENT'));
    $spider_flag = false;

    if (tep_not_null($user_agent)) {
      $spiders = file(DIR_WS_INCLUDES . 'spiders.txt');

      for ($i=0, $n=sizeof($spiders); $i<$n; $i++) {
        if (tep_not_null($spiders[$i])) {
          if (is_integer(strpos($user_agent, trim($spiders[$i])))) {
            $spider_flag = true;
            break;
          }
        }
      }
    }

    if ($spider_flag == false) {
      tep_session_start();
      // user_tracking modifications 
   if (!$referer_url) { 
    $referer_url = $HTTP_SERVER_VARS['HTTP_REFERER']; 
        if ($referer_url) { 
            tep_session_register('referer_url'); 
        } 
    }
      $session_started = true;
    }
  } else {
    tep_session_start();
// user_tracking modifications 
   if (!$referer_url) { 
    $referer_url = $HTTP_SERVER_VARS['HTTP_REFERER']; 
        if ($referer_url) { 
            tep_session_register('referer_url'); 
        } 
    }      
    $session_started = true;
  }
  //print_r($_REQUEST);exit;
  if($_REQUEST[invoicenum]) {$_SESSION[invnr]=$_REQUEST[invoicenum];}
  if($_REQUEST[invoicedesc]) {$_SESSION[invdsc]=$_REQUEST[invoicedesc];}

// set SID once, even if empty
  $SID = (defined('SID') ? SID : '');

// verify the ssl_session_id if the feature is enabled
  if ( ($request_type == 'SSL') && (SESSION_CHECK_SSL_SESSION_ID == 'True') && (ENABLE_SSL == true) && ($session_started == true) ) {
    $ssl_session_id = getenv('SSL_SESSION_ID');
    if (!tep_session_is_registered('SSL_SESSION_ID')) {
      $SESSION_SSL_ID = $ssl_session_id;
      tep_session_register('SESSION_SSL_ID');
    }

    if ($SESSION_SSL_ID != $ssl_session_id) {
      tep_session_destroy();
      tep_redirect(tep_href_link(FILENAME_SSL_CHECK));
    }
  }

// verify the browser user agent if the feature is enabled
  if (SESSION_CHECK_USER_AGENT == 'True') {
    $http_user_agent = getenv('HTTP_USER_AGENT');
    if (!tep_session_is_registered('SESSION_USER_AGENT')) {
      $SESSION_USER_AGENT = $http_user_agent;
      tep_session_register('SESSION_USER_AGENT');
    }

    if ($SESSION_USER_AGENT != $http_user_agent) {
      tep_session_destroy();
      tep_redirect(tep_href_link(FILENAME_LOGIN));
    }
  }

// verify the IP address if the feature is enabled
  if (SESSION_CHECK_IP_ADDRESS == 'True') {
    $ip_address = tep_get_ip_address();
    if (!tep_session_is_registered('SESSION_IP_ADDRESS')) {
      $SESSION_IP_ADDRESS = $ip_address;
      tep_session_register('SESSION_IP_ADDRESS');
    }

    if ($SESSION_IP_ADDRESS != $ip_address) {
      tep_session_destroy();
      tep_redirect(tep_href_link(FILENAME_LOGIN));
    }
  }

// create the shopping cart & fix the cart if necesary
  if (tep_session_is_registered('cart') && is_object($cart)) {
    if (PHP_VERSION < 4) {
      $broken_cart = $cart;
      $cart = new shoppingCart;
      $cart->unserialize($broken_cart);
    }
	// begin PayPal_Shopping_Cart_IPN
    PayPal_osC::check_order_status(true);
// end PayPal_Shopping_Cart_IPN    
    
    
    
  } else {
    tep_session_register('cart');
    $cart = new shoppingCart;
  }

// include currencies class and create an instance
  require(DIR_WS_CLASSES . 'currencies.php');
  $currencies = new currencies();

// include the mail classes
  require(DIR_WS_CLASSES . 'mime.php');
  require(DIR_WS_CLASSES . 'email.php');

// set the language
//  if (!tep_session_is_registered('language') || isset($HTTP_GET_VARS['language'])) {
//    if (!tep_session_is_registered('language')) {
//      tep_session_register('language');
//      tep_session_register('languages_id');
//    }

//    include(DIR_WS_CLASSES . 'language.php');
//    $lng = new language();

//    if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) {
//      $lng->set_language($HTTP_GET_VARS['language']);
//    } else {
///      $lng->get_browser_language();
//    }

//    $language = $lng->language['directory'];
//    $languages_id = $lng->language['id'];
//  }

$language = 'english'; // this was added by me, put english instead
$languages_id = '1'; // and the ID for english is just 1



// include the language translations
//  require(DIR_WS_LANGUAGES . $language . '.php');
require(DIR_WS_LANGUAGES . 'english.php');  
// Ultimate SEO URLs v2.1
    if (SEO_ENABLED == 'true' or (SEO_ENABLED != 'true' and SEO_ENABLED != 'false')) {
    include_once(DIR_WS_CLASSES . 'seo.class.php');
    if ( !is_object($seo_urls) )
    {
      $seo_urls = new SEO_URL($languages_id);
    }
  }
  

// Re-Direct Hack so that index.php and / are the same for Search Engines
    if ( $spider_flag == true ){ //Redirect 301 index.php to root / for spiders
       if ( $_SERVER['REQUEST_URI'] == '/index.php' ){
       $location = HTTP_SERVER;
       header("HTTP/1.0 301 Moved Permanently");
       header("Location: $location"); // redirect to root
       }
    } //End redirect index.php

// currency
//  if (!tep_session_is_registered('currency') || isset($HTTP_GET_VARS['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $currency) ) ) {
//    if (!tep_session_is_registered('currency')) tep_session_register('currency');

//    if (isset($HTTP_GET_VARS['currency'])) {
//      if (!$currency = tep_currency_exists($HTTP_GET_VARS['currency'])) $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
//    } else {
//      $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
//    }
//  }

if ( !isset($currency) || !tep_session_is_registered('currency') || isset($HTTP_GET_VARS['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $currency) ) ) {

if (!tep_session_is_registered('currency')) tep_session_register('currency');
if (isset($HTTP_GET_VARS['currency']) && $currencies->is_set($HTTP_GET_VARS['currency'])) {
$currency = $HTTP_GET_VARS['currency'];
} else {
$currency = ((USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && $currencies->is_set(LANGUAGE_CURRENCY)) ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
}

}


// navigation history
//  if (tep_session_is_registered('navigation')) {
  	if (tep_session_is_registered('navigation') && is_object($navigation)) {
    if (PHP_VERSION < 4) {
      $broken_navigation = $navigation;
      $navigation = new navigationHistory;
      $navigation->unserialize($broken_navigation);
    }
  } else {
    tep_session_register('navigation');
    $navigation = new navigationHistory;
  }
  $navigation->add_current_page();

// BOF: Down for Maintenance except for admin ip
if (EXCLUDE_ADMIN_IP_FOR_MAINTENANCE != getenv('REMOTE_ADDR')){
	if (DOWN_FOR_MAINTENANCE=='true' and !strstr($PHP_SELF,DOWN_FOR_MAINTENANCE_FILENAME)) { tep_redirect(tep_href_link(DOWN_FOR_MAINTENANCE_FILENAME)); }
	}
// do not let people get to down for maintenance page if not turned on
if (DOWN_FOR_MAINTENANCE=='false' and strstr($PHP_SELF,DOWN_FOR_MAINTENANCE_FILENAME)) {
    tep_redirect(tep_href_link(FILENAME_DEFAULT));
}
// EOF: WebMakers.com Added: Down for Maintenance

// wishlist data
  if(!tep_session_is_registered('wishList')) {
  	tep_session_register('wishList');
  	$wishList = new wishlist;
  }

//Wishlist actions (must be before shopping cart actions)
  if(isset($HTTP_POST_VARS['wishlist_x'])) {
	if(isset($HTTP_POST_VARS['products_id'])) {
		if(isset($HTTP_POST_VARS['id'])) {
			$attributes_id = $HTTP_POST_VARS['id'];
			tep_session_register('attributes_id');
		}
		$wishlist_id = $HTTP_POST_VARS['products_id'];
		tep_session_register('wishlist_id');
	}
	tep_redirect(tep_href_link(FILENAME_WISHLIST));
  }

// Shopping cart actions
  if (isset($HTTP_GET_VARS['action'])) {
  //delete a product from cart
  if (isset($_REQUEST['do'])) {
  	$cart->remove($_REQUEST['pid']);
		$goto = basename($PHP_SELF);
		tep_redirect(tep_href_link($goto));
  }

  //empty cart
  if (isset($_POST['clear_cart_x'])) { // more compatibility - DR
  		//echo sizeof($HTTP_POST_VARS['products_id']);exit;
	   for ($i=0, $n=sizeof($HTTP_POST_VARS['products_id']); $i<$n; $i++) {
	   		$cart->remove($HTTP_POST_VARS['products_id'][$i]);
	   }
	   $goto = basename($PHP_SELF);
	   tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
  }
// redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled
    if ($session_started == false) {
      tep_redirect(tep_href_link(FILENAME_COOKIE_USAGE));
    }
//SG Begin attribute validation
if (DISPLAY_CART == 'true') {
$goto = FILENAME_SHOPPING_CART;
$parameters = array('action', 'cPath', 'products_id', 'pid','mustselect');
} else {
$goto = basename($PHP_SELF);
if ($HTTP_GET_VARS['action'] == 'buy_now') {
$parameters = array('action', 'pid', 'products_id','mustselect');
} else {
$parameters = array('action', 'pid','mustselect');
}
}
//SG End attribute validation
    

    if (DISPLAY_CART == 'true') {
      $goto =  FILENAME_SHOPPING_CART;
      $parameters = array('action', 'cPath', 'products_id', 'pid');
    } else {
      $goto = basename($PHP_SELF);
      if ($HTTP_GET_VARS['action'] == 'buy_now') {
        $parameters = array('action', 'pid', 'products_id');
      } else {
        $parameters = array('action', 'pid');
      }
    }
    
    switch ($HTTP_GET_VARS['action']) {
      // customer wants to update the product quantity in their shopping cart
      case 'update_product' : for ($i=0, $n=sizeof($HTTP_POST_VARS['products_id']); $i<$n; $i++) {
                                if (in_array($HTTP_POST_VARS['products_id'][$i], (is_array($HTTP_POST_VARS['cart_delete']) ? $HTTP_POST_VARS['cart_delete'] : array()))) {
                                  $cart->remove($HTTP_POST_VARS['products_id'][$i]);
                                } else {
                                  if (PHP_VERSION < 4) {
                                    // if PHP3, make correction for lack of multidimensional array.
                                    reset($HTTP_POST_VARS);
                                    while (list($key, $value) = each($HTTP_POST_VARS)) {
                                      if (is_array($value)) {
                                        while (list($key2, $value2) = each($value)) {
										  if (preg_match ("/(.*)\]\[(.*)/", $key2, $var)) {
                                            $id2[$var[1]][$var[2]] = $value2;
                                          }
                                        }
                                      }
                                    }
                                    $attributes = ($id2[$HTTP_POST_VARS['products_id'][$i]]) ? $id2[$HTTP_POST_VARS['products_id'][$i]] : '';
                                  } else {
                                    $attributes = ($HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]]) ? $HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]] : '';
                                  }
                                  $cart->add_cart($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['cart_quantity'][$i], $attributes, false);
			


                                }
                              }

                            //added for xsell_cart
                            if (isset($HTTP_POST_VARS['add_recommended'])) {
                              foreach ($HTTP_POST_VARS['add_recommended'] as $value) {
                                if (ereg('^[0-9]+$', $value)) {
                                  // php 5.5 fix $cart->add_cart($value, $cart->get_quantity(tep_get_uprid($value, $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);
                                  $cart->add_cart($_POST['products_id'], $cart->get_quantity(tep_get_uprid($_POST['products_id'], $_POST['id']))+$_POST['quantity'], $_POST['id']);
}
                              }
                            }
                            //added for xsell_cart                              
                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                              break;

      // product page add, avoiding strangeness below!! -DR
      case 'product_add' :    if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
																if ((int)$HTTP_POST_VARS['quantity'] > 0) {
																	$quantity = (int)$HTTP_POST_VARS['quantity'];
																} else {
																	$quantity = 1;									
																}
//                                $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $quantity, $HTTP_POST_VARS['id']);
								$cart->add_cart($_POST['products_id'], $cart->get_quantity(tep_get_uprid($_POST['products_id'], $_POST['id']))+$_POST['quantity'], $_POST['id']);
                              }
                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
      												break;
 //xsell start
  case 'products_add' :
if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
                                                                if ((int)$HTTP_POST_VARS['quantity'] > 0) {
                                                                    $quantity = (int)$HTTP_POST_VARS['quantity'];
                                                                } else {
                                                                    $quantity = 1;                                    
                                                                }

//                                                                $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $quantity, $HTTP_POST_VARS['id']);
                                  								$cart->add_cart($_POST['products_id'], $cart->get_quantity(tep_get_uprid($_POST['products_id'], $_POST['id']))+$_POST['quantity'], $_POST['id']);
  if (isset($HTTP_POST_VARS['add_recommended'])) {
      //echo 'da';exit;
    foreach ($HTTP_POST_VARS['add_recommended'] as $value) {
    if (ereg('^[0-9]+$', $value)) {    
    $cart->add_cart($value, $cart->get_quantity(tep_get_uprid($value, $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);
    }
  }
}
}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;
 //xsell end

      // customer adds a product from the products page
      case 'add_product' :  //Modified this case from cogzidel 06-08-2009
$msg=1;
$prev=$pre.'?id='.$msg;
      if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
	//SG Begin attribute validation
	if (is_array($HTTP_POST_VARS['id']) ) {
	// $messageStack->reset(); 
	while (list($option, $value) = each($HTTP_POST_VARS['id'])) {
		switch ($option) {
		case 'txt_22': //Name
		$trimmedText = trim($value);
		if (strlen($trimmedText) < ENTRY_NAME_MIN_LENGTH) {
			tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id'] . '&mustselect=product_name'));
		break;
	}
	break;
	
	
	
		case 'txt_2': //Birthdate
		$strDate = $value;
		$isValid = false;

		if (ereg('^([0-9]{1,2})[/]([0-9]{1,2})[/]([0-9]{4})$', $strDate)) {
		$dateArr = split('[/]', $value);
		$m=$dateArr[0]; $d=$dateArr[1]; $y=$dateArr[2];
		$isValid = checkdate($m, $d, $y);
		}

		if (!$isValid) {
		tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id'] . '&mustselect=product_birth'));
		break;
		}
		break;
		} 
		}
		} elseif (tep_has_product_attributes($HTTP_POST_VARS['products_id'])) {
		tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_POST_VARS['products_id']));
		break;
		} 
//SG End attribute validation
      	 $pre=$_SERVER['HTTP_REFERER'];
      	
                               
//print_r($cart->add_cart($HTTP_POST_VARS['products_id']));
//print_r($cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'])));
//print_r($HTTP_POST_VARS['id']);
//print_r($HTTP_POST_VARS['id']);
 $h=$HTTP_POST_VARS['products_id'];
$query=" SELECT *
FROM `products_attributes`
WHERE `products_id` ='$h'
LIMIT 0 , 30 ";
$result=mysql_query($query);
while($output=mysql_fetch_array($result))
{
       $arr[]=$output['options_values_id'];
	   $arr1=$output['options_values_id'];
	   $nquery="select * from products_options_values where products_options_values_id='$arr1'";
	   $nresult=mysql_query($nquery);
	   while($noutput=mysql_fetch_array($nresult))
	   {
	               $noutput['products_options_values_name'];
					
					
	   }
	  
	  
}
?>
        		
 <table border="0" cellspacing="0" cellpadding="2">
        <?php
			//clr 030714 update query to pull option_type
      $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_type, popt.products_options_length, popt.products_options_comment from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
      while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
				//clr 030714 add case statement to check option type
        switch ($products_options_name['products_options_type']) {
         

                  case PRODUCTS_OPTIONS_TYPE_CHECKBOX:
            //CLR 030714 Add logic for checkboxes
            $products_attribs_query = tep_db_query("select distinct patrib.options_values_id, patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'");
            $products_attribs_array = tep_db_fetch_array($products_attribs_query);
            echo '<tr><td class="OptionTitles">' . $products_options_name['products_options_name'] . ': </td><td class="main">';
            echo tep_draw_checkbox_field('id[' . $products_options_name['products_options_id'] . ']', $products_attribs_array['options_values_id']);
            echo $products_options_name['products_options_comment'] ;
            if ($products_attribs_array['options_values_price'] != '0') {
              echo '(' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], $product_info_values['products_tax_class_id']) .') ';
            }
            echo '</td></tr>';
            break;
          default:
            //clr 030714 default is select list
            //clr 030714 reset selected_attribute variable
            $selected_attribute = false;
        		$products_options_array = array();
				//echo $vign=sizeof($products_options_name['products_options_id']);
				for($j=0;$j<sizeof($products_options_name['products_options_id']);$j++)
				{

$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'" . " order by pa.options_values_price,pov.products_options_values_name");

$i=0;
        		while ($products_options = tep_db_fetch_array($products_options_query)) {
          		$products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);

	 $arr[]=$products_options['products_options_values_id'];           

  $i++;
        		}
				//echo $i;
				//print_r($arr);
				

        		
?>
        <tr>
          <td class="OptionTitles"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
          <?php //print_r($products_options_array);?>
          <td class="main"><?php /*?><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute) . $products_options_name['products_options_comment'];  ?><?php */?></td>
		  <?php //print_r($products_options_array);
		foreach($products_options_array as $vv)
		{
		echo $vv['id'];
	
 
//echo $arr[0];

foreach($HTTP_POST_VARS['id'] as $v)
{
$h1=$v;
 $arr[$i];
   $query1="select * from  products_attributes where options_values_id='$h1' and tick='yes'";
  $result1=mysql_query($query1);
 $output1=mysql_num_rows($result1);
  
	   if($output1)
	   {
	   if($v==$vv['id'])
	   {
	   tep_redirect($prev);
        break;
	   }
	   }
	   }

break;
		}?>
        </tr>
        <?php
        }  //clr 030714 end switch 
	
      }
	
?>
      </table><?php

 
 $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);
//echo $goto;

                              }
//if($v==501500496170)
//{
 //     $go='product_info.tpl.php';
  //    tep_redirect(tep_href_link($go, tep_get_all_get_params($parameters)));  
//}
//else{
                  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
				   }
                              break;
      case 'remove_product' :
          if (isset($HTTP_GET_VARS['products_id'])) {
              $cart->remove($HTTP_GET_VARS['products_id']);
          }
      break;                              
      // performed by the 'buy now' button in product listings and review page
      case 'buy_now' :        if (isset($HTTP_GET_VARS['products_id'])) {
                                if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
                                  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
                                } else {
                                  $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);
                                }
                              }
                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                              break;
      case 'notify' :         if (tep_session_is_registered('customer_id')) {
                                if (isset($HTTP_GET_VARS['products_id'])) {
                                  $notify = $HTTP_GET_VARS['products_id'];
                                } elseif (isset($HTTP_GET_VARS['notify'])) {
                                  $notify = $HTTP_GET_VARS['notify'];
                                } elseif (isset($HTTP_POST_VARS['notify'])) {
                                  $notify = $HTTP_POST_VARS['notify'];
                                } else {
                                  tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));
                                }
                                if (!is_array($notify)) $notify = array($notify);
                                for ($i=0, $n=sizeof($notify); $i<$n; $i++) {
                                  $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $notify[$i] . "' and customers_id = '" . $customer_id . "'");
                                  $check = tep_db_fetch_array($check_query);
                                  if ($check['count'] < 1) {
                                    tep_db_query("insert into " . TABLE_PRODUCTS_NOTIFICATIONS . " (products_id, customers_id, date_added) values ('" . $notify[$i] . "', '" . $customer_id . "', now())");
                                  }
                                }
                                tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));
                              } else {
                                $navigation->set_snapshot();
                                tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
                              }
                              break;
      case 'notify_remove' :  if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['products_id'])) {
                                $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
                                $check = tep_db_fetch_array($check_query);
                                if ($check['count'] > 0) {
                                  tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
                                }
                                tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action'))));
                              } else {
                                $navigation->set_snapshot();
                                tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
                              }
                              break;
      case 'cust_order' :     if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['pid'])) {
                                if (tep_has_product_attributes($HTTP_GET_VARS['pid'])) {
                                  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['pid']));
                                } else {
                                  $cart->add_cart($HTTP_GET_VARS['pid'], $cart->get_quantity($HTTP_GET_VARS['pid'])+1);
                                }
                              }
                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                              break;
    }
  }
//rmh referral start
// set the referral id
  if (!tep_session_is_registered('referral_id') || isset($HTTP_GET_VARS['ref'])) {
    if (!tep_session_is_registered('referral_id') && !tep_session_is_registered('customer_id')) {
      tep_session_register('referral_id');
    }

    if (isset($HTTP_GET_VARS['ref']) && tep_not_null($HTTP_GET_VARS['ref'])) {
      $referral_id = $HTTP_GET_VARS['ref'];
    } else {
      $referral_id = '';
    }
  }
//rmh referral end  

// include the who's online functions
  require(DIR_WS_FUNCTIONS . 'whos_online.php');
  tep_update_whos_online();

// include the password crypto functions
  require(DIR_WS_FUNCTIONS . 'password_funcs.php');

// include validation functions (right now only email address)
  require(DIR_WS_FUNCTIONS . 'validations.php');

// split-page-results
  require(DIR_WS_CLASSES . 'split_page_results.php');

// infobox
  require(DIR_WS_CLASSES . 'boxes.php');

// auto activate and expire banners
//  require(DIR_WS_FUNCTIONS . 'banner.php');
//  tep_activate_banners();
//  tep_expire_banners();

// auto expire special products
  require(DIR_WS_FUNCTIONS . 'specials.php');
  tep_expire_specials();
  
// auto expire flash carousel products
require(DIR_WS_FUNCTIONS . 'flash_carousel.php');
tep_expire_flash_carousel();  
  
// auto expire featured products
require(DIR_WS_FUNCTIONS . 'featured.php');
tep_expire_featured();  

// calculate category path
  if (isset($HTTP_GET_VARS['cPath'])) {
    $cPath = $HTTP_GET_VARS['cPath'];
  } elseif (isset($HTTP_GET_VARS['products_id']) && !isset($HTTP_GET_VARS['manufacturers_id'])) {
    $cPath = tep_get_product_path($HTTP_GET_VARS['products_id']);
  } else {
    $cPath = '';
  }

  if (tep_not_null($cPath)) {
    $cPath_array = tep_parse_category_path($cPath);
    $cPath = implode('_', $cPath_array);
    $current_category_id = $cPath_array[(sizeof($cPath_array)-1)];
  } else {
    $current_category_id = 0;
  }

// include the breadcrumb class and start the breadcrumb trail
  require(DIR_WS_CLASSES . 'breadcrumb.php');
  $breadcrumb = new breadcrumb;

//  $breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);
  $breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));

// add category names or the manufacturer name to the breadcrumb trail
  if (isset($cPath_array)) {
    for ($i=0, $n=sizeof($cPath_array); $i<$n; $i++) {
      $categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$cPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'");
      if (tep_db_num_rows($categories_query) > 0) {
        $categories = tep_db_fetch_array($categories_query);
        $breadcrumb->add($categories['categories_name'], tep_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1)))));
      } else {
        break;
      }
    }
  } elseif (isset($HTTP_GET_VARS['manufacturers_id'])) {
    $manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
    if (tep_db_num_rows($manufacturers_query)) {
      $manufacturers = tep_db_fetch_array($manufacturers_query);
      $breadcrumb->add($manufacturers['manufacturers_name'], tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id']));
    }
  }

// add the products model to the breadcrumb trail
  if (isset($HTTP_GET_VARS['products_id'])) {
    $model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
    if (tep_db_num_rows($model_query)) {
      $model = tep_db_fetch_array($model_query);
      $breadcrumb->add($model['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
    }
  }

// initialize the message stack for output messages
  require(DIR_WS_CLASSES . 'message_stack.php');
  $messageStack = new messageStack;

//SG Begin attribute validation
if (isset($HTTP_GET_VARS['mustselect'])){
$error = true;
switch ($HTTP_GET_VARS['mustselect']) {
case 'product_name' :
$messageStack->add('product_info',ENTRY_NAME_ERROR);
break;
case 'product_birth' :
$messageStack->add('product_info',ENTRY_BIRTHDATE_ERROR);
break;
}
}
//SG End attribute validation


// set which precautions should be checked
  define('WARN_INSTALL_EXISTENCE', 'true');
  define('WARN_CONFIG_WRITEABLE', 'true');
  define('WARN_SESSION_DIRECTORY_NOT_WRITEABLE', 'true');
  define('WARN_SESSION_AUTO_START', 'true');
  define('WARN_DOWNLOAD_DIRECTORY_NOT_READABLE', 'true');
// Include OSC-AFFILIATE
  require(DIR_WS_INCLUDES . 'affiliate_application_top.php');
REQUIRE(DIR_WS_INCLUDES . 'add_ccgvdc_application_top.php');
// bof BTS v1.2 added 2003/12/25
// if not yet defined in database, define now
if (!(defined(DIR_WS_TEMPLATES_DEFAULT))) define (DIR_WS_TEMPLATES_DEFAULT, 'CSS');
if (!(defined(DIR_WS_TEMPLATES_BASE))) define (DIR_WS_TEMPLATES_BASE, 'templates/');
if (!(defined(TEMPLATE_SWITCHING_ALLOWED))) define (TEMPLATE_SWITCHING_ALLOWED, 'true');

if (TEMPLATE_SWITCHING_ALLOWED == 'true')
{
  if ((isset($HTTP_GET_VARS['tplDir'])) && is_dir(DIR_WS_TEMPLATES_BASE . $HTTP_GET_VARS['tplDir']) && (strpos($HTTP_GET_VARS['tplDir'],'.') === FALSE))
  {
    $tplDir = DIR_WS_TEMPLATES_BASE . $HTTP_GET_VARS['tplDir'];
    tep_session_register('tplDir');
  }
  elseif (!tep_session_is_registered('tplDir'))
  {
    $tplDir =  DIR_WS_TEMPLATES_BASE . DIR_WS_TEMPLATES_DEFAULT;
  }
}
else
{
  $tplDir = DIR_WS_TEMPLATES_BASE . DIR_WS_TEMPLATES_DEFAULT;
}

// include BTS template settings file added 2003/12/23
 require('includes/configure_bts.php');
// eof BTS v1.2

// set the pollbooth parameters (can be modified through the administration tool)
$configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from phesis_poll_config');

while ($configuration = tep_db_fetch_array($configuration_query)) {     
     define($configuration['cfgKey'], $configuration['cfgValue']);   
} 

// tax class
require('includes/classes/tax.php');
$osC_Tax = new osC_Tax;


// set the pollbooth parameters (can be modified through the administration tool)
//Do the superstats business	
//  require(DIR_WS_CLASSES . 'supertracker.php');
//	$tracker = new supertracker;
//	$tracker->update();
	
// Supertracker
//if (strpos(basename($PHP_SELF),'account') !== false) {
require(DIR_WS_CLASSES . 'supertracker.php');
$tracker = new supertracker;
$tracker->update();
//}	
	
// let's work out what section we're in and set up various variables -DR

	if (!tep_session_is_registered('site_section')) {
	  $section_id = 156; // motor home default
		$site_section = array();
		tep_session_register('site_section');
		$cPath_array[0] = 156;
	}

	// hack to make the home page always show motorhomes theme
	if ( ($_SERVER['PHP_SELF'] == '/index.php') && ($_SERVER['argc'] == '0') ) { 
		$cPath_array[0] = 156;
	}

	if ($cPath_array || (int)$_GET['products_id'] > 0) {
		// section from the category (fast)
		if ($cPath_array) {
			$section_id = $cPath_array[0];					
		} else {
			// get section from product (slower)
			if ((int)$_GET['products_id'] > 0) {
				$product_path = tep_get_product_path((int)$_GET['products_id']);
				$product_path_array = explode ("_", $product_path);
				$section_id = (int)$product_path_array[0];
			}
		}

		switch ( $section_id ) {
			case '107': // caravans
			$site_section = array('id' => '107', 
														'code' => 'caravan',
														'singular' => 'Caravan', 
														'alt' => 'motorhome accessories, caravan accessories, camping and self build, satellite domes', 
														'name' => 'Caravans');			
			break;
			case '122': // camping
			$site_section = array('id' => '122', 
														'code' => 'marine', 
														'singular' => 'Marine', 
														'alt' => 'motorhome accessories, caravan accessories, camping and self build, satellite domes', 
														'name' => 'Marine');			

			break;
			case '145': // self build
			$site_section = array('id' => '145', 
														'code' => 'selfbuild', 
														'singular' => 'Self Build', 
														'alt' => 'self build, motorhome accessories, caravan accessories and camping', 
														'name' => 'Self Build');			

			break;
			
			case '331': // Car
			$site_section = array('id' => '331', 
														'code' => 'car', 
														'singular' => 'Car Products', 
														'alt' => 'car products, car accessories, car addons', 
														'name' => 'Cars');			
			break;
			
			case '461': // Campervan
			$site_section = array('id' => '461', 
														'code' => 'campervan', 
														'singular' => 'Campervan Products', 
														'alt' => 'campervan accessories, campervan products, campervan addons', 
														'name' => 'Campervan Accessories');			
			break;

			case '11': // Satellite
			$site_section = array('id' => '11', 
														'code' => 'satellite', 
														'singular' => 'Satellite Products', 
														'alt' => 'motorhome satellite, caravan satellite.', 
														'name' => 'Satellite TV');			
			break;
			
			case '524': // Camping
			$site_section = array('id' => '524', 
														'code' => 'camping', 
														'singular' => 'Camping Products', 
														'alt' => 'camping products, camping accessories, camping gear', 
														'name' => 'Camping');			
			break;									
			
			case '439': // SOG
			$site_section = array('id' => '439', 
														'code' => 'sog', 
														'singular' => 'SOG Products', 
														'alt' => 'sog toilets, sog kits, sog system', 
														'name' => 'SOG Toilet Kits');			
			break;
			
			case '55': // Solar
			$site_section = array('id' => '55', 
														'code' => 'solar', 
														'singular' => 'Solar Products', 
														'alt' => 'solar panels, motorhome solar panels, caravan solar panels, solar power for motorhomes', 
														'name' => 'Solar Power');			
			break;							
			
			case '201': // Fiamma
			default:
			$site_section = array('id' => '201', 
														'code' => 'fiamma', 
														'singular' => 'Fiamma', 
														'alt' => 'fiamma products, fiamma accessories, fiamma privacy rooms, fiamma awnings, fiamma cycle racks', 
														'name' => 'Fiamma');			
			break;
			
			case '123': // Gaslow
			default:
			$site_section = array('id' => '123', 
														'code' => 'gaslow', 
														'singular' => 'Gaslow', 
														'alt' => 'gaslow, gaslow products, gaslow bottles, gaslow systems, gaslow accessories, gaslow refillable', 
														'name' => 'Gaslow');			
			break;		
			
			case '556': // Dometic
			default:
			$site_section = array('id' => '556', 
														'code' => 'dometic', 
														'singular' => 'Dometic', 
														'alt' => 'dometic, dometic products, dometic premium partner, waeco, prostor awnings, dometic air conditioners', 
														'name' => 'Dometic');			
			break;					
										
			case '570': // Teleco Styleeeee
			default:
			$site_section = array('id' => '570', 
														'code' => 'teleco', 
														'singular' => 'Teleco', 
														'alt' => 'teleco, teleco products, teleco satellite systems, telair air conditioning, telair generators', 
														'name' => 'Teleco');			
			break;
			
			
			case '156': // motor home // default
			default:
			$site_section = array('id' => '156', 
														'code' => 'motorhome', 
														'singular' => 'Motorhome', 
														'alt' => 'motorhome accessories, caravan accessories, camping and self build, satellite domes', 
														'name' => 'Motorhomes');			
			break;
		}

	}
// include the articles functions
  require(DIR_WS_FUNCTIONS . 'articles.php');

// calculate topic path
  if (isset($HTTP_GET_VARS['tPath'])) {
    $tPath = $HTTP_GET_VARS['tPath'];
  } elseif (isset($HTTP_GET_VARS['articles_id']) && !isset($HTTP_GET_VARS['authors_id'])) {
    $tPath = tep_get_article_path($HTTP_GET_VARS['articles_id']);
  } else {
    $tPath = '';
  }

  if (tep_not_null($tPath)) {
    $tPath_array = tep_parse_topic_path($tPath);
    $tPath = implode('_', $tPath_array);
    $current_topic_id = $tPath_array[(sizeof($tPath_array)-1)];
  } else {
    $current_topic_id = 0;
  }

  if (isset($_GET['articles_id'])) {
    $articlesPage = FILENAME_ARTICLE_INFO . "?articles_id=" . $_GET['articles_id'];
    $pageTags_query = tep_db_query("select page_name, page_title from " . TABLE_HEADERTAGS . " where page_name like '" . $articlesPage . "' and language_id = '" . (int)$languages_id . "' LIMIT 1");
    if (tep_db_num_rows($pageTags_query) == 1) {
      $pageTags = tep_db_fetch_array($pageTags_query);
      $breadcrumb->add('Articles', tep_href_link(FILENAME_ARTICLES));
      $breadcrumb->add($pageTags['page_title'], tep_href_link($articlesPage));
    }  
  }		
    //---PayPal WPP Modification START ---//
  include(DIR_WS_INCLUDES . 'paypal_wpp/paypal_wpp_include.php');
  //---PayPal WPP Modification END ---//
  ?>

Link to comment
Share on other sites

I think you also upgraded to UTF8 along the way ...

 

and need to spec out UTF8 in the form declaration

 

eg like on my custom product page it is
<form name="cart_quantity" method="post" accept-charset="UTF-8" action=...

            

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

not quite sure how to do that bruyndoncx what file would I need to edit ? and is that fix relevant to both the admin login problem and the add to cart issue ?

 

not sure if this helps but been doing some digging and found that if i comment out a line in /admin/includes/functions/general.php as follows it allows me through to the next page but then bombs out to white screen if i click on any admin links

the line is as follows:-

 

tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));

//Check login and file access
function tep_admin_check_login() {
echo "entered loop<br>";
  global $PHP_SELF, $login_groups_id;
  if (!tep_session_is_registered('login_id')) {
    //tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 } else {
    $filename = basename( $PHP_SELF );
    if ($filename != FILENAME_DEFAULT && $filename != FILENAME_FORBIDEN && $filename != FILENAME_LOGOFF && $filename != FILENAME_ADMIN_ACCOUNT && $filename != FILENAME_POPUP_IMAGE && $filename != 'packingslip.php' && $filename != 'invoice.php') {
      $db_file_query = tep_db_query("select admin_files_name from " . TABLE_ADMIN_FILES . " where FIND_IN_SET( '" . $login_groups_id . "', admin_groups_id) and admin_files_name = '" . $filename . "'");
      if (!tep_db_num_rows($db_file_query)) {
        tep_redirect(tep_href_link(FILENAME_FORBIDEN));
      }
    }
  }  
}
Link to comment
Share on other sites

I think I know what you mean :)

 

in my template product_info.tpl.php I have this

 

    if (tep_db_num_rows($products_options_name_query) > 0) {
        echo "\t\t\t" . tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=products_add'), 'post', 'onsubmit="return dropdown_validator();"');
    } else {
        echo "\t\t\t" . tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=products_add'));
    }

 

do you mean modify these ?

Link to comment
Share on other sites

i tried editing the line to be as follows:-

 

        echo "\t\t\t" . tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=products_add'), 'post', 'accept-charset="UTF-8"', 'onsubmit="return dropdown_validator();"');

 

but that didnt work,

 

I am not sure this is on the right track as some other elements of the shopping cart page are missing things stored in sessions or cookies I think, we have a custom setup whereby the header logo and search button and colour scheme are all changed if you go into specific parts of the website and on the shopping cart page these are missing images

Link to comment
Share on other sites

try adding the accept bit, just before the onsubmit within the same string (and function parameter)

or effectively removing singlequote  comma single quote 

and adding a space

 

This is only so it would add to cart - this was a fix i needed for different forms to work.

Any POST form needs this fix as far as I can tell.

 

Second issue I had while debugging to get 5.5 up, was that empty lines and BOMs made the redirect function fail (headers alreay sent).

 

I just uploaded a script into another post that recursively goes through the files and fixes these issues.

It is the fixBOM bit you have to enable and comment out the UTF8 conversion bit (that fixes special chars in language files ...)

It is rough code, perhaps someone else has some cleaner code, but I could not find any when I needed it ...

 

I disabled the admin recorder/login functions on my site, so can't offer any more help, but i see a redirect there, so probably suffering from that same blank line issue

HTH

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

yes, I think so - the redirect on my system only showed up with 5.5

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

There's quite a bit more than below, that you have to do to bring your codebase up to par:

<?php

$phpversion = explode('.', phpversion());
if((int) $phpversion[0] >= 5){
$HTTP_GET_VARS = &$_GET;
$HTTP_POST_VARS = &$_POST;
$HTTP_REQUEST_VARS = &$_REQUEST;
$HTTP_SESSION_VARS = &$_SESSION;
$HTTP_COOKIE_VARS = &$_COOKIE;
$HTTP_SERVER_VARS = &$_SERVER;
$HTTP_FILES_VARS = &$_FILES;
$HTTP_ENV_VARS = &$_ENV;
}
?>

You can try this addon, see if it helps:

http://addons.oscommerce.com/info/7394

Link to comment
Share on other sites

I tried to insert the code for the utf functionality for buy now button as follows:-

	if (tep_db_num_rows($products_options_name_query) > 0) {
		echo "\t\t\t" . tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=products_add'), 'post', 'accept-charset="UTF-8" onsubmit="return dropdown_validator();"');
	} else {
		echo "\t\t\t" . tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=products_add'), 'post', 'accept-charset="UTF-8"');
	}

the top line button is for if there are attributes and the bottom if there are not I think

 

It doesnt seem to have any effect though

 

I have gone through the files and made changes as in that exact addon @@Hotclutch

Link to comment
Share on other sites

ok after exhausting debugging I have the admin panel working, i ended up swapping in the sessions.php from later version of osc for admin and a few hacks to get it up and running and then loads of other issues arose but I think I have that all resolved now !!!

 

 

However not got anywhere with the shopping cart adding, i can't swap in the sessions.php for public facing as its too different and beyond my base coding skillset !

Link to comment
Share on other sites

  • 11 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...