Jump to content

Archived

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

longhorn1999

SSL problem only in Chrome

Recommended Posts

http://forums.oscommerce.com/topic/398266-ssl-mixed-content-issue-but-only-with-chrome/

 

Hi,

 

I'm having a very similar problem to the one discussed in this thread from a couple of weeks ago.  It seems that Chrome 38 is much stricter than previous versions and now a small yellow triangle is appearing on SSL pages whereas it showed a lock before.  FF and IE11 work fine for now.

 

I had thought initially that I had some problems in .htaccess with regards to redirects, but Roaddoctor's thread above showed me that something else is going on.

 

Using the shift-ctrl-J trick in Chrome on https://www.mysite.com/login.php, I'm seeing these messages:

 

 

The page at 'https://www.mysite.com/login.php' was loaded over HTTPS, but is submitting data to an insecure location at 'http://www.mysite.com/new_quick_search.php': this content should also be submitted over HTTPS.
 login.php:190
The page at 'https://www.mysite.com/login.php' was loaded over HTTPS, but is submitting data to an insecure location at 'http://www.mysite.com/visitoremail.php?action=process': this content should also be submitted over HTTPS.
 login.php:481
Failed to load resource: net::ERR_CACHE_MISS https://www.mysite.com/login.php

 

I created a quick search function in my left column which is a sort of faceted search, and this was done by hacking advanced_search.php.  And I have the old newsletter submission form in the footer which is original to V2.2RC2A.

 

Any ideas how to tweak these functions to make them SSL compliant in Chrome? 

 

Thanks,

 

Nick

Share this post


Link to post
Share on other sites

This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest Responsive osCommerce CE (community edition) here

Share this post


Link to post
Share on other sites

Thanks for the quick reply Burt.  I will take a closer look at the solution you referred to in the other thread and see if I can figure out a solution.

 

Regarding the problem with visitoremail.php, that's a bit over my head.  I've copied both relevant files here, along with a small section of my footer.

 

Would you be able to give me an idea of what might need to be modified in either of these files to fix that SSL issue?

 

includes/footer.php:

		<ul class="footer-emails">
		<?php echo tep_draw_form('email', tep_href_link(FILENAME_VISITOR_EMAIL, 'action=process')) .  BOX_HEADING_VISITOR_EMAIL . '<br>' . tep_draw_input_field('to_email_address', '', 'size="20"', 'align="left"') . ' ' . tep_image_submit('button_visitor_email.gif', BOX_HEADING_VISITOR_EMAIL, 'align="middle"') . '</form>';?>
		</ul>

includes/boxes/visitoremail.php:

<?php
/*
  $Id: visitoremail.php,v 1.16 2003/06/10 18:26:33 hpdl Exp $

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

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/
?>
<!-- visitor_e-mail //-->
          <tr>
            <td>
<?php
  $info_box_contents = array();
  $info_box_contents[] = array('text' => BOX_HEADING_VISITOR_EMAIL);

  new infoBoxHeading($info_box_contents, false, false);

  $info_box_contents = array();
  $info_box_contents[] = array('form' => tep_draw_form('email', tep_href_link(FILENAME_VISITOR_EMAIL, 'action=process')),
                               'align' => 'center',
                               'text' => tep_draw_input_field('to_email_address', '', 'size="10"', 'align="absbottom"') . ' ' . tep_image_submit('button_visitor_email.gif', 'Sign up for Shed Nation emails and receive special offers and promotions', 'align="absbottom"')) ;

  new infoBox($info_box_contents);
?>
            </td>
          </tr>
<!-- visitor_email_eof //-->

visitoremail.php:

<?php
/*
  $Id: $

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

  Copyright (c) 2006 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_VISITOR_EMAIL);
  
if (($HTTP_POST_VARS['to_email_address'] != '') && ($HTTP_POST_VARS['to_email_address'] != ' ')){
	  if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process')) {
		$error = false;

		$to_email_address = tep_db_prepare_input($HTTP_POST_VARS['to_email_address']);
		$visitor_query = tep_db_query("select email from " . TABLE_VISITOR . " where email = '" . $HTTP_POST_VARS['to_email_address'] . "'");
		$customer_query = tep_db_query("select customers_email_address from " . TABLE_CUSTOMERS . " where customers_email_address = '" . $HTTP_POST_VARS['to_email_address'] . "'");
		if (!tep_validate_email($to_email_address)) {
		  $error = true;

		  $messageStack->add('visitor', ERROR_TO_ADDRESS);
		}
	// bof send mail to shopowner
		$extra_email_text .=  TEXT_NEW_VISITOR . $to_email_address.'<br> IP: '.$_SERVER['REMOTE_ADDR'].'<br>';
		if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
		  tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, TEXT_SUBJ_NEW_VISITOR, $extra_email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
	}
	// eof send mail to shopowner

		if ($visitor = tep_db_fetch_array($visitor_query)) { //check if this e-mail already exists in visitor database
		  $error = true;
		  $messageStack->add('visitor', ALREADY_EXIST);
		} elseif ($customer = tep_db_fetch_array($customer_query)) { //okay, does it exist in our customer database?	
		  $error = true;
		  $messageStack->add('visitor', ALREADY_EXIST);
		}
		
		if ($error == false) { // everything is okay
		  $sql_data_array = array('email' => $to_email_address);

		  tep_db_perform(TABLE_VISITOR, $sql_data_array);

		}
	  }
}else{
$error = true;
$messageStack->add('visitor', ERROR_TO_ADDRESS);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?>  : <?php echo HEADING_TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<link rel="stylesheet" type="text/css" href="jquerymegamenu.css" />

<script type="text/javascript" src="jquery.min.js"></script>
<script src="jquery.hoverIntent.minified.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {

	//function addMega(){
	//$(this).addClass("hovering");
	//}
	
	//function removeMega(){
	//$(this).removeClass("hovering");
	//}
	
	
	//function addMega(){
	//$(this).addClass("hovering");
	//$($(this).find("h2 a")).addClass("hover");
	//}
	
	//function removeMega(){
	//$(this).removeClass("hovering");
	//$($(this).find("h2 a")).removeClass("hover");
	//}
	
	
	function addMega(){
	$($(this).find("h2")).addClass("hover");
	$($(this).find("div.mega-choices")).slideDown("fast");
	$(this).addClass("hovering");
	}
	
	function removeMega(){
	$($(this).find("h2")).removeClass("hover");
	$($(this).find("div.mega-choices")).slideUp("fast");
	$(this).removeClass("hovering");
	} 
	
	var megaConfig = {
	interval: 30,
	sensitivity: 4,
	over: addMega,
	timeout: 100,
	out: removeMega
	};
	
	$("li.mega").hoverIntent(megaConfig)

});
</script>

</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '12'); ?></td>
<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
  <tr>
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
    </table></td>
<!-- body_text //-->
        <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
            <td align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_visitor.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
<?php
  if ($messageStack->size('visitor') > 0) {
?>
      <tr>
        <td><?php echo $messageStack->output('visitor'); ?></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php
  } else {
?>
      <tr>
       <td class="main">
<?php
   echo TEXT_WELCOME;
?>
       </td>
      </tr>
<?php } ?>
                  <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
          <tr class="infoBoxContents">
            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		        
        <td align="right" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL') . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>
                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
<!-- body_text_eof //-->
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
    </table></td>
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Share this post


Link to post
Share on other sites

Use Chrome CTRL-SHIFT-J, to find the bad links - if its your footer code you could try

		<ul class="footer-emails">
		<?php echo tep_draw_form('email', tep_href_link(FILENAME_VISITOR_EMAIL, 'action=process', $request_type)) .  BOX_HEADING_VISITOR_EMAIL . '<br>' . tep_draw_input_field('to_email_address', '', 'size="20"', 'align="left"') . ' ' . tep_image_submit('button_visitor_email.gif', BOX_HEADING_VISITOR_EMAIL, 'align="middle"') . '</form>';?>
		</ul>

 


-Dave

Share this post


Link to post
Share on other sites

Use Chrome CTRL-SHIFT-J, to find the bad links - if its your footer code you could try

 

Thanks Dave!  That did the trick.  I appreciate the help.

 

Nick

Share this post


Link to post
Share on other sites

Hi everyone,

 

Well Roaddoctor fixed the SSL problem I was having with the visitor email signup in the footer, but along the same lines, I'm still having this issue (only in Chrome) with a search box I had created for me a couple of years ago.  It's in the left column and is used to quickly search for products by category, brand, etc.

 

part of includes/column_left.php, where I've created an admin function to easily activate and deactivate this box:

  if(QUICK_SEARCH_IN_LEFT_COLUMN != 'false') {  
  include(DIR_WS_BOXES . 'new_quick_search.php');
  }

If I turn off the box, all the SSL problems disappear.  I suppose the easy thing to do, and perhaps a smarter thing to do from a conversions perspective, would be to remove this search box from SSL pages.

 

But if I want to keep this search box on all pages, would anyone know what to modify here?  I've looked at the links provided by Burt and Roaddoctor earlier in this thread to other conversations, but the PHP required here is over my head.

 

Here are the other two files which may or may not need a line change.  Sorry for the long code post, but I'm not even sure what part of each file, or even which file needs modification.

 

includes/boxes/new_quick_search:

<?php
/*
  $Id: shop_by_price.php,v 2.5 2008/03/07 $
  
  Contribution by Meltus  http://www.highbarn-consulting.com
  Adapted for OsCommerce MS2 by Sylvio Ruiz suporte@leilodata.com
  Modified by Hugues Deriau on 09/23/2006 - display the price ranges in the selected currency
  Modified by Glassraven for dropdown list 24/10/2006 www.glassraven.com
  Modified by -GuiGui- (http://www.gpuzin.com) - 07/03/2008 - Just added a comment about the Box Heading

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

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/
?>
<tr>
  <td>
<?php
reset($_GET);
require(DIR_WS_LANGUAGES . $language . '/' . 'new_quick_search.php');

$get_array = array('categories_id','manufacturers_id','width_range','length_range','sort','max');

// use dropdown list - comment out if using list format
//$shop_price_type = 'dropdown'; 
  $manufacturers_array[] = array('id' => '0', 'text' => 'Select a Manufacturer' );
  $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
  while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
        $manufacturers_name = ((strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers['manufacturers_name']);
        $manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'],
                                       'text' => $manufacturers_name);
      }
  $categories_array[] = array('id' => '0', 'text' => 'Select a Category' );

  $categories_query = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c, " .TABLE_CATEGORIES_DESCRIPTION. " cd where c.categories_id = cd.categories_id order by sort_order,c.parent_id,cd.categories_name");
	while ($categories = tep_db_fetch_array($categories_query)) {
      	   
		   if($categories['categories_id']!=27){
		   $categories_array[] = array('id' => $categories['categories_id'],
                                       'text' => $categories['categories_name']);
		   }		   
      }

	  /*$sub_category_query = tep_db_query("select c.categories_id,cd.categories_name from " . TABLE_CATEGORIES . " c, " .TABLE_CATEGORIES_DESCRIPTION. " cd  where c.parent_id='27'");
			while($sub_category = tep_db_fetch_array($sub_category_query)){
			
			$categories_array[] = array('id' => $sub_category['categories_id'],
                                       'text' => $sub_category['categories_name']);
			}*/
	$cat_array = tep_get_category_tree();
// Box Heading - uncomment the following 3 line to display the Box Title
 $info_box_contents = array();
 $info_box_contents[] = array('text' => 'Quick Search');
 new infoBoxHeading($info_box_contents, false, false);

$info_box_contents = array();
	
	$width_range_list = '';
	$length_range_list = '';

	for ($width_range=0; $width_range<sizeof($width_ranges); $width_range++) {
		$width_range_list[] = array('id' => $width_range, 'text' => $width_ranges[$width_range] );
	}
	for ($length_range=0; $length_range<sizeof($length_ranges); $length_range++) {
		$length_range_list[] = array('id' => $length_range, 'text' => $length_ranges[$length_range] );
	}

	$info_box_contents[] = array('align' => 'center',
								 'text'  => '<form name="new_quick_search" action="' . tep_href_link('new_quick_search.php',tep_get_all_get_params(array('osCsid','categories_id','manufacturers_id','width_range','length_range','sort','max'))) . '" method="get">'.tep_hide_session_id() .'<table boreder="0" width="100%"><tr><td>'.tep_draw_pull_down_menu('categories_id',  $cat_array,printselected($cat_array,$_GET['categories_id']),'style="width:153px;"') .'</td></tr><tr><td>'.tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array,printselected($manufacturers_array,$_GET['manufacturers_id']),'style="width:153px;"') .'</td></tr><tr><td>'
								 .tep_draw_pull_down_menu('width_range', $width_range_list,printselected($width_range_list,$_GET['width_range']),'style="width:153px;"') .'</td></tr><tr><td>'
								 .tep_draw_pull_down_menu('length_range', $length_range_list,printselected($length_range_list,$_GET['length_range']),'style="width:153px;"').'</td></tr><tr><td align="center">'
								 .tep_image_submit('button_search.gif', 'Search')
								 .tep_hide_session_id().'</td></tr></table></form>');

 new infoBox($info_box_contents);
  function printselected($contdata,$strcont){
		
	   if (trim($contdata) == $strcont){
			return " selected";		
	    } else {
			return "";
	   }
	}	
  
?>

	</td>
</tr>

and the other is the main file, new_quick_search.php in the root directory.  Here I had taken out the line  <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">  from right below the title and canonical lines in the Head, and this was done supposedly to fix errors in Google Webmaster Tools.  Putting it back in doesn't help the SSL issue though.

<?php
/*
  $Id: shop_by_price.php,v 2.5 2008/03/07 $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com
  	  
  Contribution by Meltus  http://www.highbarn-consulting.com
  Adapted for OsCommerce MS2 by Sylvio Ruiz suporte@leilodata.com
  Modified by Hugues Deriau on 09/23/2006 - display the price ranges in the selected currency
  Modified by Glassraven for dropdown list 24/10/2006 www.glassraven.com
  Modified by -GuiGui- (http://www.gpuzin.com) - 07/03/2008 - to work as advanced_search_result.php which should fix special prices and "display prices with tax"

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');
$error = false;
  // I suppose next line is to work with STS, no need for the others, you can leave it or remove it.
  $sbprice = true;
  // Initialize the varaible '$range' from param here because it's used in FILENAME_SHOP_BY_PRICE
if($_GET['categories_id']!=0){
$categories_id = $_GET['categories_id'];
}

if($_GET['manufacturers_id']!=0){
$manufacturers_id = $_GET['manufacturers_id'];
}
$width_range = 0;
$length_range = 0;
if(!empty($_GET['width_range'])){
$width_range = $_GET['width_range'];
}

if(!empty($_GET['length_range'])){
$length_range = $_GET['length_range'];
}


if(($_GET['categories_id']==0) && ($_GET['manufacturers_id']==0) && ($_GET['width_range']==0) && ($_GET['length_range']==0)){
	$error = true;
	$error_detail[] = 'Please select at least one option';
	$messageStack->add_session('new_quick_search', 'Please select at least one option');
}


foreach($_GET as $key => $value){

	$getvalue[$key] = $value; 

}
        

  require(DIR_WS_LANGUAGES . $language . '/' . 'new_quick_search.php');

  $wfrom = isset($width_min[$width_range]) ? $width_min[$width_range] : 0;
  $hfrom = isset($length_min[$length_range]) ? $length_min[$length_range] : 0;
  $wto   = isset($width_max[$width_range]) ? $width_max[$width_range] : 0;
  $hto   = isset($length_max[$length_range]) ? $length_max[$length_range] : 0;

  $breadcrumb->add(NAVBAR_TITLE, tep_href_link('new_quick_search.php', '', 'NONSSL', true, false));
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<meta name="robots" content="noindex, nofollow" />
<title>Quick Search | My Site</title>
<link rel="canonical" href="http://www.mysite.com/new_quick_search.php" />
 
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<link rel="stylesheet" type="text/css" href="jquerymegamenu.css" />

<script type="text/javascript" src="jquery.min.js"></script>
<script src="jquery.hoverIntent.minified.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {

	//function addMega(){
	//$(this).addClass("hovering");
	//}
	
	//function removeMega(){
	//$(this).removeClass("hovering");
	//}
	
	
	//function addMega(){
	//$(this).addClass("hovering");
	//$($(this).find("h2 a")).addClass("hover");
	//}
	
	//function removeMega(){
	//$(this).removeClass("hovering");
	//$($(this).find("h2 a")).removeClass("hover");
	//}
	
	
	function addMega(){
	$($(this).find("h2")).addClass("hover");
	$($(this).find("div.mega-choices")).slideDown("fast");
	$(this).addClass("hovering");
	}
	
	function removeMega(){
	$($(this).find("h2")).removeClass("hover");
	$($(this).find("div.mega-choices")).slideUp("fast");
	$(this).removeClass("hovering");
	} 
	
	var megaConfig = {
	interval: 30,
	sensitivity: 4,
	over: addMega,
	timeout: 100,
	out: removeMega
	};
	
	$("li.mega").hoverIntent(megaConfig)

});
</script>

</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '12'); ?></td> 
<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
  <tr>
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
    </table></td>
<!-- body_text //-->
    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo 'Search Results'; ?></td>
            <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_browse.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td>
<?php
// create column list
  $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
                       'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
                       'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
                       'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
                       'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
                       'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
                       'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE,
                       // Product Listing in Columns - Start  (You can remove those 4 lines if you are not using it).
                       'PRODUCT_LIST_MULTIPLE' => PRODUCT_LIST_MULTIPLE,
                       'PRODUCT_LIST_BUY_NOW_MULTIPLE' => PRODUCT_LIST_BUY_NOW_MULTIPLE,
                       // Product Listing in Columns - End
                       'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);

  asort($define_list);

  $column_list = array();
  reset($define_list);
  while (list($key, $value) = each($define_list)) {
    if ($value > 0) $column_list[] = $key;
  }

  $select_column_list = '';

  for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
    switch ($column_list[$i]) {
      case 'PRODUCT_LIST_MODEL':
        $select_column_list .= 'p.products_model, ';
        break;
      case 'PRODUCT_LIST_MANUFACTURER':
        $select_column_list .= 'm.manufacturers_name, ';
        break;
      case 'PRODUCT_LIST_QUANTITY':
        $select_column_list .= 'p.products_quantity, ';
        break;
      case 'PRODUCT_LIST_IMAGE':
        $select_column_list .= 'p.products_image, ';
        break;
      case 'PRODUCT_LIST_WEIGHT':
        $select_column_list .= 'p.products_weight, ';
        break;
    }
  }

   $select_str = "select distinct " . $select_column_list . " m.manufacturers_id, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price ";

  if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
    $select_str .= ", SUM(tr.tax_rate) as tax_rate ";
  }

  $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id";

  if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
    if (!tep_session_is_registered('customer_country_id')) {
      $customer_country_id = STORE_COUNTRY;
      $customer_zone_id = STORE_ZONE;
    }
    $from_str .= " left join " . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$customer_zone_id . "')";
  }

  $from_str .= ", " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";

  $where_str = " where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id ";

  if (isset($categories_id) && $categories_id!=0) {
    if (isset($HTTP_GET_VARS['inc_subcat']) && ($HTTP_GET_VARS['inc_subcat'] == '1')) {
      $subcategories_array = array();
      tep_get_subcategories($subcategories_array, $categories_id);

      $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and (p2c.categories_id = '" . (int)$categories_id . "'";

      for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) {
        $where_str .= " or p2c.categories_id = '" . (int)$subcategories_array[$i] . "'";
      }

      $where_str .= ")";
    } else {
      $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$categories_id . "'";
    }
  }

  if (isset($manufacturers_id) && $manufacturers_id!=0) {
    $where_str .= " and m.manufacturers_id = '" . (int)$manufacturers_id . "'";
  }

  /*if (isset($search_keywords) && (sizeof($search_keywords) > 0)) {
    $where_str .= " and (";
    for ($i=0, $n=sizeof($search_keywords); $i<$n; $i++ ) {
      switch ($search_keywords[$i]) {
        case '(':
        case ')':
        case 'and':
        case 'or':
          $where_str .= " " . $search_keywords[$i] . " ";
          break;
        default:
          $keyword = tep_db_prepare_input($search_keywords[$i]);
          $where_str .= "(pd.products_name like '%" . tep_db_input($keyword) . "%' or p.products_model like '%" . tep_db_input($keyword) . "%' or m.manufacturers_name like '%" . tep_db_input($keyword) . "%'";
          if (isset($HTTP_GET_VARS['search_in_description']) && ($HTTP_GET_VARS['search_in_description'] == '1')) $where_str .= " or pd.products_description like '%" . tep_db_input($keyword) . "%'";
          $where_str .= ')';
          break;
      }
    }
    $where_str .= " )";
  }*/

  if (tep_not_null($dfrom)) {
    $where_str .= " and p.products_date_added >= '" . tep_date_raw($dfrom) . "'";
  }

  if (tep_not_null($dto)) {
    $where_str .= " and p.products_date_added <= '" . tep_date_raw($dto) . "'";
  }

  if (tep_not_null($pfrom)) {
    if ($currencies->is_set($currency)) {
      $rate = $currencies->get_value($currency);

      $pfrom = $pfrom / $rate;
    }
  }

  if (tep_not_null($pto)) {
    if (isset($rate)) {
      $pto = $pto / $rate;
    }
  }

  if (DISPLAY_PRICE_WITH_TAX == 'true') {
    if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) >= " . (double)$pfrom . ")";
    if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) <= " . (double)$pto . ")";
  } else {
    if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) >= " . (double)$pfrom . ")";
    if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) <= " . (double)$pto . ")";
  }

	//BOF ++ Megha 3/29/2012
    if ($wfrom > 0) $where_str .= " and products_width >= " .(double)$wfrom;
    if ($wto > 0) $where_str .= " and products_width <= " .(double)$wto;
    
    if ($hfrom > 0) $where_str .= " and products_length >= " .(double)$hfrom;
    if ($hto > 0) $where_str .= " and products_length <= " .(double)$hto;
  
	//EOF ++ Megha 3/29/2012




  if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
    $where_str .= " group by p.products_id, tr.tax_priority";
  }

  if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
    for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
      if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
        $HTTP_GET_VARS['sort'] = $i+1 . 'a';
        $order_str = ' order by pd.products_name';
        break;
      }
    }
  } else {
    $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1);
    $sort_order = substr($HTTP_GET_VARS['sort'], 1);
    $order_str = ' order by ';
    switch ($column_list[$sort_col-1]) {
      case 'PRODUCT_LIST_MODEL':
        $order_str .= "p.products_model " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
        break;
      case 'PRODUCT_LIST_NAME':
        $order_str .= "pd.products_name " . ($sort_order == 'd' ? "desc" : "");
        break;
      case 'PRODUCT_LIST_MANUFACTURER':
        $order_str .= "m.manufacturers_name " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
        break;
      case 'PRODUCT_LIST_QUANTITY':
        $order_str .= "p.products_quantity " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
        break;
      case 'PRODUCT_LIST_IMAGE':
        $order_str .= "pd.products_name";
        break;
      case 'PRODUCT_LIST_WEIGHT':
        $order_str .= "p.products_weight " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
        break;
      case 'PRODUCT_LIST_PRICE':
        $order_str .= "final_price " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
        break;
    }
  }


  $listing_sql = $select_str . $from_str . $where_str . $order_str;
//echo $listing_sql;

//BOF ++ Megha 3/13/2012

  if ($error==true) {	
?>
	 <table cellpadding="0" cellspacing="0" border="0" width="100%">
		<?php
			foreach($error_detail as $value){	
?>
			    <tr><td class="message" style="background-color:#FFB3B5;font-family:Arial,Helvetica,sans-serif;"><img src="images/icons/error.gif"><?php echo $value; ?></td></tr>

			<?php } ?>
      			<tr><td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td></tr>
		</table>
<?php
  
  }
//EOF ++ Megha 3/13/2012


if($error==false){
require(DIR_WS_MODULES . 'product_listing_search.php');
  }
?>
        </td>
      </tr>
    </table></td>
<!-- body_text_eof //-->
<!--    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> //-->
<!-- right_navigation //-->
<!-- <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> //-->
<!-- right_navigation_eof //-->
<!--    </table></td> //-->
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Thanks for a taking a look at this, and any help is appreciated!

Share this post


Link to post
Share on other sites

×