From 4e2edeeefaf2e212d3c38544648aa2d2269cc81a Mon Sep 17 00:00:00 2001 From: acidvertigo Date: Sat, 23 Aug 2014 17:39:12 +0200 Subject: [PATCH 01/12] Remove legacy code Use basename instead of strrpos --- catalog/includes/classes/osc_template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalog/includes/classes/osc_template.php b/catalog/includes/classes/osc_template.php index 76ca085bf..a27a0c932 100644 --- a/catalog/includes/classes/osc_template.php +++ b/catalog/includes/classes/osc_template.php @@ -80,7 +80,7 @@ function buildBlocks() { $modules_array = explode(';', constant($module_key)); foreach ( $modules_array as $module ) { - $class = substr($module, 0, strrpos($module, '.')); + $class = basename($module, '.php'); if ( !class_exists($class) ) { if ( file_exists(DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/' . $group . '/' . $module) ) { From d5542d75aa4fa41d82361385f689058d2605790c Mon Sep 17 00:00:00 2001 From: acidvertigo Date: Sat, 23 Aug 2014 17:41:05 +0200 Subject: [PATCH 02/12] Use basename instead of strrpos --- catalog/includes/modules/boxes/bm_product_social_bookmarks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalog/includes/modules/boxes/bm_product_social_bookmarks.php b/catalog/includes/modules/boxes/bm_product_social_bookmarks.php index 7c70dbbf7..eb1fc84e2 100644 --- a/catalog/includes/modules/boxes/bm_product_social_bookmarks.php +++ b/catalog/includes/modules/boxes/bm_product_social_bookmarks.php @@ -39,7 +39,7 @@ function execute() { $social_bookmarks = array(); foreach ( $sbm_array as $sbm ) { - $class = substr($sbm, 0, strrpos($sbm, '.')); + $class = basename($sbm, '.php'); if ( !class_exists($class) ) { include(DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/social_bookmarks/' . $sbm); From 9fd6dfc0989a5f4592a196f0e9dcf394e594559e Mon Sep 17 00:00:00 2001 From: acidvertigo Date: Sat, 23 Aug 2014 17:43:43 +0200 Subject: [PATCH 03/12] Use basename instead of strrpos --- catalog/includes/classes/payment.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/catalog/includes/classes/payment.php b/catalog/includes/classes/payment.php index 9932c1893..8cbe40cc8 100644 --- a/catalog/includes/classes/payment.php +++ b/catalog/includes/classes/payment.php @@ -28,7 +28,7 @@ function payment($module = '') { $include_modules[] = array('class' => $module, 'file' => $module . '.php'); } else { foreach($this->modules as $value) { - $class = substr($value, 0, strrpos($value, '.')); + $class = basename($value, '.php'); $include_modules[] = array('class' => $class, 'file' => $value); } } @@ -93,7 +93,7 @@ function javascript_validation() { ' }' . "\n\n"; foreach($this->modules as $value) { - $class = substr($value, 0, strrpos($value, '.')); + $class = basename($value, '.php'); if ($GLOBALS[$class]->enabled) { $js .= $GLOBALS[$class]->javascript_validation(); } @@ -121,7 +121,7 @@ function checkout_initialization_method() { if (is_array($this->modules)) { foreach($this->modules as $value) { - $class = substr($value, 0, strrpos($value, '.')); + $class = basename($value, '.php'); if ($GLOBALS[$class]->enabled && method_exists($GLOBALS[$class], 'checkout_initialization_method')) { $initialize_array[] = $GLOBALS[$class]->checkout_initialization_method(); } @@ -136,7 +136,7 @@ function selection() { if (is_array($this->modules)) { foreach($this->modules as $value) { - $class = substr($value, 0, strrpos($value, '.')); + $class = basename($value, '.php'); if ($GLOBALS[$class]->enabled) { $selection = $GLOBALS[$class]->selection(); if (is_array($selection)) $selection_array[] = $selection; From 8ade568099a988f5201f49c37782e4f78f720102 Mon Sep 17 00:00:00 2001 From: acidvertigo Date: Sun, 24 Aug 2014 14:10:50 +0200 Subject: [PATCH 04/12] Move the product model breadcrumb from application top Move the product model breadcrumb from application top to product_info.php removing a redundant query --- catalog/includes/application_top.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/catalog/includes/application_top.php b/catalog/includes/application_top.php index be2dd3e7b..8a420e6e6 100644 --- a/catalog/includes/application_top.php +++ b/catalog/includes/application_top.php @@ -436,17 +436,6 @@ } } -// add the products model to the breadcrumb trail - if ( isset($_GET['products_id']) ) { - $model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$_GET['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=' . $_GET['products_id'])); - } - } - // TODO remove when no more global sessions exist if ( $session_started == true ) { extract($_SESSION, EXTR_OVERWRITE+EXTR_REFS); From a1e616ebed5f8cc77b7356b8b4c509953dec04a5 Mon Sep 17 00:00:00 2001 From: acidvertigo Date: Sun, 24 Aug 2014 14:12:46 +0200 Subject: [PATCH 05/12] Add bredcrumb to product_info.php page avoids +1 query in application top --- catalog/product_info.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/catalog/product_info.php b/catalog/product_info.php index 864eb1e52..bee9bcad6 100644 --- a/catalog/product_info.php +++ b/catalog/product_info.php @@ -21,6 +21,9 @@ $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$_GET['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'"); $product_info = tep_db_fetch_array($product_info_query); +// add the products model to the breadcrumb trail + $breadcrumb->add($product_info['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $product_info['products_id'])); + require(DIR_WS_INCLUDES . 'template_top.php'); if (empty($product_info)) { From a2017a5a8236e22b19139cd831bf6d0115f7acd9 Mon Sep 17 00:00:00 2001 From: acidvertigo Date: Sun, 24 Aug 2014 14:15:49 +0200 Subject: [PATCH 06/12] Fix add breadcrumb only if product exists --- catalog/product_info.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/catalog/product_info.php b/catalog/product_info.php index bee9bcad6..d034a0327 100644 --- a/catalog/product_info.php +++ b/catalog/product_info.php @@ -21,9 +21,6 @@ $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$_GET['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'"); $product_info = tep_db_fetch_array($product_info_query); -// add the products model to the breadcrumb trail - $breadcrumb->add($product_info['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $product_info['products_id'])); - require(DIR_WS_INCLUDES . 'template_top.php'); if (empty($product_info)) { @@ -43,6 +40,9 @@ add($product_info['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $product_info['products_id'])); tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$_GET['products_id'] . "' and language_id = '" . (int)$_SESSION['languages_id'] . "'"); From 9367028f5fcc75b9d635edd536295641c8a5e837 Mon Sep 17 00:00:00 2001 From: acidvertigo Date: Sun, 24 Aug 2014 14:19:23 +0200 Subject: [PATCH 07/12] Revert "Fix add breadcrumb only if product exists" This reverts commit a2017a5a8236e22b19139cd831bf6d0115f7acd9. --- catalog/product_info.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/catalog/product_info.php b/catalog/product_info.php index d034a0327..bee9bcad6 100644 --- a/catalog/product_info.php +++ b/catalog/product_info.php @@ -21,6 +21,9 @@ $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$_GET['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'"); $product_info = tep_db_fetch_array($product_info_query); +// add the products model to the breadcrumb trail + $breadcrumb->add($product_info['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $product_info['products_id'])); + require(DIR_WS_INCLUDES . 'template_top.php'); if (empty($product_info)) { @@ -40,9 +43,6 @@ add($product_info['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $product_info['products_id'])); tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$_GET['products_id'] . "' and language_id = '" . (int)$_SESSION['languages_id'] . "'"); From 3ba1a0e8f3068ef06868b186e3cf5bf736224efb Mon Sep 17 00:00:00 2001 From: acidvertigo Date: Sun, 24 Aug 2014 14:22:55 +0200 Subject: [PATCH 08/12] Add products model to the breadcrumb only if product model exists --- catalog/product_info.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/catalog/product_info.php b/catalog/product_info.php index bee9bcad6..b256f1121 100644 --- a/catalog/product_info.php +++ b/catalog/product_info.php @@ -21,9 +21,11 @@ $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$_GET['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'"); $product_info = tep_db_fetch_array($product_info_query); + if (isset($product_info['products_model'])) { // add the products model to the breadcrumb trail $breadcrumb->add($product_info['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $product_info['products_id'])); - + } + require(DIR_WS_INCLUDES . 'template_top.php'); if (empty($product_info)) { From 29a2386cff3acd09c57210e21200d20e0ccfc61e Mon Sep 17 00:00:00 2001 From: acidvertigo Date: Sun, 24 Aug 2014 16:51:46 +0200 Subject: [PATCH 09/12] Fix bug if $cPath == 0 If $cPath == 0 in url like this: http://localhost/oscom/product_info.php?cPath=0&products_id=15 bm_categories gives an error --- catalog/includes/modules/boxes/bm_categories.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalog/includes/modules/boxes/bm_categories.php b/catalog/includes/modules/boxes/bm_categories.php index 0800201ce..c513b64a7 100644 --- a/catalog/includes/modules/boxes/bm_categories.php +++ b/catalog/includes/modules/boxes/bm_categories.php @@ -103,7 +103,7 @@ function getData() { } } - if (tep_not_null($cPath)) { + if (tep_not_null($cPath) && ($cPath > 0)) { $new_path = ''; foreach($cPath_array as $key => $value) { unset($parent_id); From 5dfa10871f9fbf10c877014de8e86e9c4f569014 Mon Sep 17 00:00:00 2001 From: acidvertigo Date: Sun, 24 Aug 2014 19:34:07 +0200 Subject: [PATCH 10/12] Casting int instead to call intval function --- catalog/includes/classes/split_page_results.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/catalog/includes/classes/split_page_results.php b/catalog/includes/classes/split_page_results.php index b78ad7c4e..9a4e8ede6 100644 --- a/catalog/includes/classes/split_page_results.php +++ b/catalog/includes/classes/split_page_results.php @@ -81,10 +81,10 @@ function display_links($max_page_links, $parameters = '') { if ($this->current_page_number > 1) $display_links_string .= '' . PREVNEXT_BUTTON_PREV . '  '; // check if number_of_pages > $max_page_links - $cur_window_num = intval($this->current_page_number / $max_page_links); + $cur_window_num = (int)($this->current_page_number / $max_page_links); if ($this->current_page_number % $max_page_links) $cur_window_num++; - $max_window_num = intval($this->number_of_pages / $max_page_links); + $max_window_num = (int)($this->number_of_pages / $max_page_links); if ($this->number_of_pages % $max_page_links) $max_window_num++; // previous window of pages From 2c946da2f17bec8f39b5902474328a24dec9ed27 Mon Sep 17 00:00:00 2001 From: Harald Ponce de Leon Date: Mon, 25 Aug 2014 10:44:42 +0200 Subject: [PATCH 11/12] Revert "Fix bug if $cPath == 0" --- catalog/includes/modules/boxes/bm_categories.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalog/includes/modules/boxes/bm_categories.php b/catalog/includes/modules/boxes/bm_categories.php index c513b64a7..0800201ce 100644 --- a/catalog/includes/modules/boxes/bm_categories.php +++ b/catalog/includes/modules/boxes/bm_categories.php @@ -103,7 +103,7 @@ function getData() { } } - if (tep_not_null($cPath) && ($cPath > 0)) { + if (tep_not_null($cPath)) { $new_path = ''; foreach($cPath_array as $key => $value) { unset($parent_id); From 871db03f72f6348eab71c79f3c197a706f744963 Mon Sep 17 00:00:00 2001 From: acidvertigo Date: Mon, 25 Aug 2014 12:01:45 +0200 Subject: [PATCH 12/12] Send header "404 not found" when products cannot be found --- catalog/product_info.php | 1 + 1 file changed, 1 insertion(+) diff --git a/catalog/product_info.php b/catalog/product_info.php index b256f1121..5f83d86a6 100644 --- a/catalog/product_info.php +++ b/catalog/product_info.php @@ -29,6 +29,7 @@ require(DIR_WS_INCLUDES . 'template_top.php'); if (empty($product_info)) { + header('HTTP/1.0 404 Not Found'); ?>