Solved

how to convert php4 to php5

Posted on 2008-10-26
3
1,165 Views
Last Modified: 2013-12-13
hi to convert php4 to php5


<?php

/*

  $Id: advanced_search_result.php,v 1.72 2003/06/23 06:50:11 project3000 Exp $
 

  osCommerce, Open Source E-Commerce Solutions

  http://www.oscommerce.com
 

  Copyright (c) 2003 osCommerce

Modified, enhanced and optimized by Way 2 web

www.w-2-w.dk
 

  Released under the GNU General Public License

*/
 

  require('includes/application_top.php');
 

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADVANCED_SEARCH);
 

// Search enhancement mod start

if(isset($_GET['keywords']) && $_GET['keywords'] != ''){

	if(!isset($_GET['s'])){

		$pwstr_check = strtolower(substr($_GET['keywords'], strlen($_GET['keywords'])-1, strlen($_GET['keywords'])));

  	    if($pwstr_check == 's'){

  	            $pwstr_replace = substr($_GET['keywords'], 0, strlen($_GET['keywords'])-1);

  	            header('location: ' . tep_href_link( FILENAME_ADVANCED_SEARCH_RESULT , 'keywords=' . urlencode($pwstr_replace) . '' ));

  	            exit;

  	    }

        }
 

       $pw_keywords = explode(' ',stripslashes(strtolower($_GET['keywords'])));

       $pw_replacement_words = $pw_keywords;

       $pw_boldwords = $pw_keywords;

       $sql_words = tep_db_query("SELECT * FROM searchword_swap");

       $pw_replacement = '';

       while ($sql_words_result = tep_db_fetch_array($sql_words)) {

       	   if(stripslashes(strtolower($_GET['keywords'])) == stripslashes(strtolower($sql_words_result['sws_word']))){

       	       $pw_replacement = stripslashes($sql_words_result['sws_replacement']);

       	       $pw_link_text = '<b><i>' . stripslashes($sql_words_result['sws_replacement']) . '</i></b>';

       	       $pw_phrase = 1;

       	       $pw_mispell = 1;

       	       break;

       	   }

           for($i=0; $i<sizeof($pw_keywords); $i++){

               if($pw_keywords[$i]  == stripslashes(strtolower($sql_words_result['sws_word']))){

               	   $pw_replacement_words[$i] = stripslashes($sql_words_result['sws_replacement']);

                   $pw_boldwords[$i] = '<b><i>' . stripslashes($sql_words_result['sws_replacement']) . '</i></b>';

                   $pw_mispell = 1;

                   break;

               }

           }

       }

       if(!isset($pw_phrase)){

           for($i=0; $i<sizeof($pw_keywords); $i++){

               $pw_replacement .= $pw_replacement_words[$i] . ' ';

       	       $pw_link_text   .= $pw_boldwords[$i]. ' ';

           }

       }

       

       $pw_replacement = trim($pw_replacement);

       $pw_link_text   = trim($pw_link_text);

       $pw_string      = '<br><span class="main"><font color="red">' . TEXT_REPLACEMENT_SUGGESTION . '</font><a href="' . tep_href_link( FILENAME_ADVANCED_SEARCH_RESULT , 'keywords=' . urlencode($pw_replacement) . '&search_in_description=1' ) . '">' . $pw_link_text . '</a></span><br><br>';

        

}

// Search enhancement mod end
 
 

  $error = false;
 

  // Udvidet search (JHB) Start

  $product_extra = array();

  $extra_fields_empty = true;

  $extra_fields_query = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_EXTRA_FIELDS . " WHERE products_extra_fields_search='1' and products_extra_fields_status='1' and (languages_id = '" . $languages_id . "' OR languages_id='0') ORDER BY products_extra_fields_order");

  while ($extra_fields = tep_db_fetch_array($extra_fields_query)) {

    if (isset($HTTP_GET_VARS["product_extra" . $extra_fields['products_extra_fields_id']]) && !empty($HTTP_GET_VARS["product_extra" . $extra_fields['products_extra_fields_id']])) {

      $product_extra[$extra_fields['products_extra_fields_id']] = '';

      $extra_fields_empty = false;

    }

  }  

  // Udvidet search (JHB) End
 
 

  if ( (isset($HTTP_GET_VARS['keywords']) && empty($HTTP_GET_VARS['keywords'])) &&

  // Udvidet search (JHB) Start

        $extra_fields_empty &&

        (isset($HTTP_GET_VARS['product_length']) && empty($HTTP_GET_VARS['product_length'])) &&

        (isset($HTTP_GET_VARS['product_width']) && empty($HTTP_GET_VARS['product_width'])) &&

        (isset($HTTP_GET_VARS['product_depth']) && empty($HTTP_GET_VARS['product_depth'])) &&

  // Udvidet search (JHB) End

       (isset($HTTP_GET_VARS['dfrom']) && (empty($HTTP_GET_VARS['dfrom']) || ($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING))) &&

       (isset($HTTP_GET_VARS['dto']) && (empty($HTTP_GET_VARS['dto']) || ($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING))) &&

       (isset($HTTP_GET_VARS['pfrom']) && !is_numeric($HTTP_GET_VARS['pfrom'])) &&

       (isset($HTTP_GET_VARS['pto']) && !is_numeric($HTTP_GET_VARS['pto'])) ) {

    $error = true;
 

    $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);

  } else {

    $dfrom = '';

    $dto = '';

    $pfrom = '';

    $pto = '';

    $keywords = '';
 

    if (isset($HTTP_GET_VARS['dfrom'])) {

      $dfrom = (($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dfrom']);

    }
 

    if (isset($HTTP_GET_VARS['dto'])) {

      $dto = (($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dto']);

    }
 

    if (isset($HTTP_GET_VARS['pfrom'])) {

      $pfrom = $HTTP_GET_VARS['pfrom'];

    }
 

    if (isset($HTTP_GET_VARS['pto'])) {

      $pto = $HTTP_GET_VARS['pto'];

    }
 

    if (isset($HTTP_GET_VARS['keywords'])) {

      $keywords = $HTTP_GET_VARS['keywords'];

    }
 

    $date_check_error = false;

    if (tep_not_null($dfrom)) {

      if (!tep_checkdate($dfrom, DOB_FORMAT_STRING, $dfrom_array)) {

        $error = true;

        $date_check_error = true;
 

        $messageStack->add_session('search', ERROR_INVALID_FROM_DATE);

      }

    }
 

    if (tep_not_null($dto)) {

      if (!tep_checkdate($dto, DOB_FORMAT_STRING, $dto_array)) {

        $error = true;

        $date_check_error = true;
 

        $messageStack->add_session('search', ERROR_INVALID_TO_DATE);

      }

    }
 

    if (($date_check_error == false) && tep_not_null($dfrom) && tep_not_null($dto)) {

      if (mktime(0, 0, 0, $dfrom_array[1], $dfrom_array[2], $dfrom_array[0]) > mktime(0, 0, 0, $dto_array[1], $dto_array[2], $dto_array[0])) {

        $error = true;
 

        $messageStack->add_session('search', ERROR_TO_DATE_LESS_THAN_FROM_DATE);

      }

    }
 

    $price_check_error = false;

    if (tep_not_null($pfrom)) {

      if (!settype($pfrom, 'double')) {

        $error = true;

        $price_check_error = true;
 

        $messageStack->add_session('search', ERROR_PRICE_FROM_MUST_BE_NUM);

      }

    }
 

    if (tep_not_null($pto)) {

      if (!settype($pto, 'double')) {

        $error = true;

        $price_check_error = true;
 

        $messageStack->add_session('search', ERROR_PRICE_TO_MUST_BE_NUM);

      }

    }
 

    if (($price_check_error == false) && is_float($pfrom) && is_float($pto)) {

      if ($pfrom >= $pto) {

        $error = true;
 

        $messageStack->add_session('search', ERROR_PRICE_TO_LESS_THAN_PRICE_FROM);

      }

    }
 

    if (tep_not_null($keywords)) {

      if (!tep_parse_search_string($keywords, $search_keywords)) {

        $error = true;
 

        $messageStack->add_session('search', ERROR_INVALID_KEYWORDS);

      }

    }
 

  // Udvidet search (JHB) Start

    $product_length = '';

    $product_width = '';

    $product_depth = '';

    if (isset($HTTP_GET_VARS['product_length'])) {

      $product_length = $HTTP_GET_VARS['product_length'];

    }

    if (isset($HTTP_GET_VARS['product_width'])) {

      $product_width = $HTTP_GET_VARS['product_width'];

    }

    if (isset($HTTP_GET_VARS['product_depth'])) {

      $product_depth = $HTTP_GET_VARS['product_depth'];

    }

    if (tep_not_null($product_length)) {

      if (!tep_parse_search_string($product_length, $search_product_length)) {

        $error = true;

        $messageStack->add_session('search', ERROR_INVALID_KEYWORDS);

      }

    }

    if (tep_not_null($product_width)) {

      if (!tep_parse_search_string($product_width, $search_product_width)) {

        $error = true;

        $messageStack->add_session('search', ERROR_INVALID_KEYWORDS);

      }

    }

    if (tep_not_null($product_depth)) {

      if (!tep_parse_search_string($product_depth, $search_product_depth)) {

        $error = true;

        $messageStack->add_session('search', ERROR_INVALID_KEYWORDS);

      }

    }
 

    foreach($product_extra as $index => $value) {

      if (isset($HTTP_GET_VARS["product_extra" . $index])) {

        $product_extra[$index] = $HTTP_GET_VARS["product_extra" . $index];

      }

    }

    foreach($product_extra as $index => $value) {

      if (tep_not_null($product_extra[$index])) {

        if (!tep_parse_search_string($value, $search_product_extra[$index])) {

          $error = true;

          $messageStack->add_session('search', ERROR_INVALID_KEYWORDS);

        }

      }

    }
 
 

  // Udvidet search (JHB) End
 

  }
 

  // Udvidet search (JHB) Start

//  if (empty($dfrom) && empty($dto) && empty($pfrom) && empty($pto) && empty($keywords)) {

  if ($extra_fields_empty && empty($product_length) && empty($product_width) && empty($product_depth) && empty($dfrom) && empty($dto) && empty($pfrom) && empty($pto) && empty($keywords)) {

  // Udvidet search (JHB) End

    $error = true;
 

    $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);

  }
 

  if ($error == true) {

    tep_redirect(tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(), 'NONSSL', true, false));

  }
 

// Search enhancement mod start

                $search_enhancements_keywords = $_GET['keywords'];

                $search_enhancements_keywords = strip_tags($search_enhancements_keywords);

                $search_enhancements_keywords = addslashes($search_enhancements_keywords);                

          

                if ($search_enhancements_keywords != $last_search_insert) {

                        tep_db_query("insert into search_queries (search_text)  values ('" .  $search_enhancements_keywords . "')");

                        tep_session_register('last_search_insert');

                        $last_search_insert = $search_enhancements_keywords;

                }

// Search enhancement mod end
 

$breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ADVANCED_SEARCH));

  $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, tep_get_all_get_params(), 'NONSSL', true, false));

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">

<?php 

# cDynamic Meta Tags

/*<title><?php echo TITLE; ?>*/

require(DIR_WS_INCLUDES . 'meta_tags.php');

#

?>

<link rel="stylesheet" type="text/css" href="stylesheet.css">

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->
 

<!-- body //-->
 

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->
 

<!-- body_text //-->

    <td width="100%" valign="top">

 

    <?php // ISM start

//    require (DIR_WS_INCLUDES . 'skin_top.php'); 

    // ISM end ?>

		

		<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 HEADING_TITLE_2; ?></td>

            <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_browse.gif', HEADING_TITLE_2, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

          </tr>
 

	<tr>

            <td class="main"><p>

            <?php if (isset($HTTP_GET_VARS['plural']) && ($HTTP_GET_VARS['plural'] == '1')) {

            	  	echo TEXT_REPLACEMENT_SEARCH_RESULTS . ' <b><i>' . stripslashes($_GET['keywords']) . 's</i></b>';

             	  } else {

            		echo TEXT_REPLACEMENT_SEARCH_RESULTS . ' <b><i>' . stripslashes($_GET['keywords']) . '</i></b>';

             	  }

            ?></p></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_INFO' => PRODUCT_LIST_INFO,

                       '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_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_INFO':  

        $select_column_list .= 'pd.products_info, ';

        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;

    }

  }
 

// Specials Category (JHB) added start

  $select_column_str .= 'c.products_price1, c.products_price2, c.products_price3, c.products_price4, c.products_price1_qty, c.products_price2_qty, c.products_price3_qty, c.products_price4_qty, ';

// Specials Category (JHB) added end      
 

  $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), " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";
 
 
 

  // Udvidet search (JHB) Start - modify to enable search on each extra field individually
 

// START: Extra Fields Contribution

//  $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";

//  $from_str = "from (" . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . " p2pef on p.products_id=p2pef.products_id) left join " . TABLE_MANUFACTURERS . " m on m.manufacturers_id=p.manufacturers_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";

// END: Extra Fields Contribution

  

  $from_str = "from (" . TABLE_PRODUCTS . " p";
 

  foreach($product_extra as $index => $value) {

    if (isset($HTTP_GET_VARS["product_extra" . $index])) {

      $from_str .= " left join " . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . " p2pef" . $index . " on (p.products_id=p2pef" . $index . ".products_id and p2pef" . $index . ".products_extra_fields_id=" . $index . " )";

    }

  }

  $from_str .= ")";
 

  $from_str .= " left join " . TABLE_MANUFACTURERS . " m on m.manufacturers_id=p.manufacturers_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";

  // Udvidet search (JHB) End
 
 

  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 . "')";

  }

// Avanced Sort (JHB) added start

    if (isset($HTTP_GET_VARS['filter_import']) && $HTTP_GET_VARS['filter_import'] == '1') {

      $extrafield_import = '0';

      $extrafields_query = tep_db_query("select products_extra_fields_id from " . TABLE_PRODUCTS_EXTRA_FIELDS . " where products_extra_fields_name = 'Import'");

      $extrafields = tep_db_fetch_array($extrafields_query);

      $extrafield_import = $extrafields['products_extra_fields_id'];  
 

      $from_str .=  ", " . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . " p2pef1 ";

      $extra_fields_conditions = " and (p2pef1.products_id = p.products_id and p2pef1.products_extra_fields_id='" . $extrafield_import . "' and p2pef1.products_extra_fields_value IS NOT NULL and p2pef1.products_extra_fields_value !='') ";

    }

    if (isset($HTTP_GET_VARS['filter_used']) && $HTTP_GET_VARS['filter_used'] == '1') {

      $extrafield_stand = '0';

      $extrafields_query = tep_db_query("select products_extra_fields_id from " . TABLE_PRODUCTS_EXTRA_FIELDS . " where products_extra_fields_name = 'Stand'");

      $extrafields = tep_db_fetch_array($extrafields_query);

      $extrafield_stand = $extrafields['products_extra_fields_id'];  
 

      $from_str .= ", " . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . " p2pef2 ";

      $extra_fields_conditions .= " and (p2pef2.products_id = p.products_id and p2pef2.products_extra_fields_id='" . $extrafield_stand . "' and p2pef2.products_extra_fields_value='Brugt') ";

    }

// Avanced Sort (JHB) added end
 
 
 

// #################### Added Enable / Disable Categorie ###################

//  $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 ";

    $where_str = " where p.products_status = '1' and c.categories_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 ";

// ################### End Added Enable / Disable Categorie ###################
 

// Avanced Sort (JHB) added start

    $where_str .= $extra_fields_conditions;

    if (isset($HTTP_GET_VARS['filter_coming']) && ($HTTP_GET_VARS['filter_coming'] == '1')) {

      $where_str .= " and to_days(p.products_date_available) >= to_days(now())";    

    }

// Avanced Sort (JHB) added end
 
 

  if (isset($HTTP_GET_VARS['categories_id']) && tep_not_null($HTTP_GET_VARS['categories_id'])) {

    if (isset($HTTP_GET_VARS['inc_subcat']) && ($HTTP_GET_VARS['inc_subcat'] == '1')) {

      $subcategories_array = array();

      tep_get_subcategories($subcategories_array, $HTTP_GET_VARS['categories_id']);
 

      $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and (p2c.categories_id = '" . (int)$HTTP_GET_VARS['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)$HTTP_GET_VARS['categories_id'] . "'";

    }

  }
 

  if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {

    $where_str .= " and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['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]);

  // Udvidet search (JHB) Start - don't check the extra fields with the keyword

          $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) . "%'";

/*

// START: Extra Fields Contribution

          $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) . "%' or p2pef.products_extra_fields_value like '%" . tep_db_input($keyword) . "%'";

// END: Extra Fields Contribution

*/

  // Udvidet search (JHB) End

       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 .= " )";

  }
 

  // Udvidet search (JHB) Start

  if (isset($search_product_length) && (sizeof($search_product_length) > 0)) {

    $where_str .= " and (";

    for ($i=0, $n=sizeof($search_product_length); $i<$n; $i++ ) {

      switch ($search_product_length[$i]) {

        case '(':

        case ')':

        case 'and':

        case 'or':

          $where_str .= " " . $search_product_length[$i] . " ";

          break;

        default:

          $product_length= tep_db_prepare_input($search_product_length[$i]);

          $where_str .= "(p.products_length like '%" . tep_db_input($product_length) . "%'";

          $where_str .= ')';

          break;

      }

    }

    $where_str .= " )";

  }
 

  if (isset($search_product_width) && (sizeof($search_product_width) > 0)) {

    $where_str .= " and (";

    for ($i=0, $n=sizeof($search_product_width); $i<$n; $i++ ) {

      switch ($search_product_width[$i]) {

        case '(':

        case ')':

        case 'and':

        case 'or':

          $where_str .= " " . $search_product_width[$i] . " ";

          break;

        default:

          $product_width= tep_db_prepare_input($search_product_width[$i]);

          $where_str .= "(p.products_width like '%" . tep_db_input($product_width) . "%'";

          $where_str .= ')';

          break;

      }

    }

    $where_str .= " )";

  }
 

  if (isset($search_product_depth) && (sizeof($search_product_depth) > 0)) {

    $where_str .= " and (";

    for ($i=0, $n=sizeof($search_product_depth); $i<$n; $i++ ) {

      switch ($search_product_depth[$i]) {

        case '(':

        case ')':

        case 'and':

        case 'or':

          $where_str .= " " . $search_product_depth[$i] . " ";

          break;

        default:

          $product_depth= tep_db_prepare_input($search_product_depth[$i]);

          $where_str .= "(p.products_depth like '%" . tep_db_input($product_depth) . "%'";

          $where_str .= ')';

          break;

      }

    }

    $where_str .= " )";

  }
 
 

  foreach($product_extra as $index => $value) {

    if (isset($search_product_extra[$index]) && (sizeof($search_product_extra[$index]) > 0)) {

      $where_str .= " and (";

      for ($i=0, $n=sizeof($search_product_extra[$index]); $i<$n; $i++ ) {

        switch ($search_product_extra[$index][$i]) {

          case '(':

          case ')':

          case 'and':

          case 'or':

            $where_str .= " " . $search_product_extra[$index][$i] . " ";

            break;

          default:

            $temp = tep_db_prepare_input($search_product_extra[$index][$i]);

            $where_str .= "(p2pef" . $index . ".products_extra_fields_value like '%" . tep_db_input($temp) . "%'";

            $where_str .= ')';

            break;

        }

      }

      $where_str .= " )";

    }

  }

  // Udvidet search (JHB) End
 
 

  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 . ")";

  }
 

  if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {

    $where_str .= " group by p.products_id, tr.tax_priority";

  }
 

// JHB Start

    if (isset($HTTP_GET_VARS['firstletter'])) {

      if ($HTTP_GET_VARS['firstletter'] == '(0-9)') {

        $where_sql .= " and UCASE(LEFT(pd.products_name, 1)) BETWEEN '0' AND '9'";

      } else {

        $where_str .= " and UCASE(LEFT(pd.products_name, 1))='" . $HTTP_GET_VARS['firstletter'] . "'";      

      }

    }

// JHB End
 

  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_INFO':

        $order_str .= "pd.products_info " . ($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;

  require(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING);

?>

        </td>

      </tr>

      <tr>

        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

      </tr>

      <tr>

        <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(array('sort', 'page')), 'NONSSL', true, false) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>

      </tr>

    </table></td>

		

    <?php // ISM start

 //   require (DIR_WS_INCLUDES . 'skin_bottom.php'); 

    // ISM end ?>
 

<!-- body_text_eof //-->
 

<!-- right_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>

<!-- right_navigation_eof //-->
 

<!-- body_eof //-->
 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

<br>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Open in new window

0
Comment
Question by:alicca
3 Comments
 
LVL 2

Author Comment

by:alicca
ID: 22809187
i need only the part of mysql with "left join"


any 1 can help?
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22810640
can you please clarify what exactly does not work?
you refer to a "left join" which would be the mysql query part, however there is not influence for the mysql queries as such, when changing from php4 to php5...

note: posting a full page of code is not helpful to start with, and basically shows that you did not yet manage to isolate the problem...
0
 
LVL 13

Accepted Solution

by:
Xyptilon2 earned 500 total points
ID: 22810665
Before you execute the query, have it printed on the screen and run the query manually either in PHPMyAdmin (http://www.phpmyadmin.net) or on the MySQL command line. If it returns an error then it should be easy to pinpoint where. However as angelIII said, it is unlikely that the SQL query itself is the problem. However perhaps the problem lies in the creation of the query.

One big change between PHP4 and PHP5 is the change in the default setting of register_globals, causing variables to become less accessible by direct reference. This should be easily spottable if you print out the query, because you can see that the value fields are not filled in.


0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now