From 90b012c88c8846c32054abf4a93c7f9a0bb304c4 Mon Sep 17 00:00:00 2001 From: Rainer Schmied Date: Wed, 3 Jun 2020 13:08:50 +0200 Subject: [PATCH 01/48] Update products_attributes.php --- admin/products_attributes.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/admin/products_attributes.php b/admin/products_attributes.php index 2ed142a43..c44c14fd1 100644 --- a/admin/products_attributes.php +++ b/admin/products_attributes.php @@ -63,17 +63,18 @@ $value_price = tep_db_prepare_input($_POST['value_price']); $price_prefix = tep_db_prepare_input($_POST['price_prefix']); - tep_db_query("insert into products_attributes values (null, '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . (float)tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "')"); + tep_db_query("insert into products_attributes (products_id, options_id, options_values_id, options_values_price, price_prefix) values ('" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . (float)tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "')"); + + $products_attributes_id = tep_db_insert_id(); if (DOWNLOAD_ENABLED == 'true') { - $products_attributes_id = tep_db_insert_id(); $products_attributes_filename = tep_db_prepare_input($_POST['products_attributes_filename']); $products_attributes_maxdays = tep_db_prepare_input($_POST['products_attributes_maxdays']); $products_attributes_maxcount = tep_db_prepare_input($_POST['products_attributes_maxcount']); if (tep_not_null($products_attributes_filename)) { - tep_db_query("insert into products_attributes_download values (" . (int)$products_attributes_id . ", '" . tep_db_input($products_attributes_filename) . "', '" . tep_db_input($products_attributes_maxdays) . "', '" . tep_db_input($products_attributes_maxcount) . "')"); + tep_db_query("insert into products_attributes_download (products_attributes_id, products_attributes_filename, products_attributes_maxdays, products_attributes_maxcount) values (" . (int)$products_attributes_id . ", '" . tep_db_input($products_attributes_filename) . "', '" . tep_db_input($products_attributes_maxdays) . "', '" . tep_db_input($products_attributes_maxcount) . "')"); } } From a695ae807e5e5ca5cbb182e93969c236cf689b88 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sun, 7 Jun 2020 01:00:50 +0000 Subject: [PATCH 02/48] Add admin overrides directory --- admin/includes/functions/autoloader.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/admin/includes/functions/autoloader.php b/admin/includes/functions/autoloader.php index 60acee01d..b914c2570 100644 --- a/admin/includes/functions/autoloader.php +++ b/admin/includes/functions/autoloader.php @@ -12,10 +12,15 @@ function tep_build_admin_autoload_index($modules_directory_length) { $class_files = []; - + tep_find_all_files_under(DIR_FS_ADMIN . 'includes/modules', $class_files); tep_find_all_files_under(DIR_FS_ADMIN . 'includes/classes', $class_files); - + + $overrides_directory = DIR_FS_ADMIN . 'includes/classes/override'; + if (is_dir($overrides_directory)) { + tep_find_all_files_under($overrides_directory, $class_files); + } + // some classes do not follow either naming standard relating the class name and file name $exception_mappings = [ 'password_hash' => 'passwordhash', From 7a4ac4894cb5242162350459a0668ddbef5c77bd Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sun, 7 Jun 2020 01:02:21 +0000 Subject: [PATCH 03/48] Add tep_db_copy to copy a set of records Sometimes, we want to make a copy of an existing set of records. For example, if we want to make a duplicate copy of a product. This allows an entire set of records to be copied at once, both reading from and writing to the database. This is more efficient than reading the records separately from writing, because it makes fewer round trips to the database and passes less information. --- admin/includes/functions/database.php | 44 ++++++++++++++++++++------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/admin/includes/functions/database.php b/admin/includes/functions/database.php index 7e87f2ed7..cdf12a997 100644 --- a/admin/includes/functions/database.php +++ b/admin/includes/functions/database.php @@ -59,11 +59,8 @@ function tep_db_query($query, $link = 'db_link') { function tep_db_perform($table, $data, $action = 'insert', $parameters = '', $link = 'db_link') { if ($action == 'insert') { - $query = 'INSERT INTO ' . $table . ' ('; - foreach (array_keys($data) as $columns) { - $query .= $columns . ', '; - } - $query = substr($query, 0, -2) . ') VALUES ('; + $query = 'INSERT INTO ' . $table . ' (' . implode(', ', array_keys($data)) . ') VALUES ('; + foreach ($data as $value) { switch ((string)$value) { case 'NOW()': @@ -79,30 +76,55 @@ function tep_db_perform($table, $data, $action = 'insert', $parameters = '', $li break; } } - $query = substr($query, 0, -2) . ')'; + $query = substr($query, 0, -strlen(', ')) . ')'; } elseif ($action == 'update') { $query = 'UPDATE ' . $table . ' SET '; - foreach ($data as $columns => $value) { + foreach ($data as $column => $value) { switch ((string)$value) { case 'NOW()': case 'now()': - $query .= $columns . ' = NOW(), '; + $query .= $column . ' = NOW(), '; break; case 'NULL': case 'null': - $query .= $columns .= ' = NULL, '; + $query .= $column . ' = NULL, '; break; default: - $query .= $columns . ' = \'' . tep_db_input($value) . '\', '; + $query .= $column . ' = \'' . tep_db_input($value) . '\', '; break; } } - $query = substr($query, 0, -2) . ' WHERE ' . $parameters; + $query = substr($query, 0, -strlen(', ')) . ' WHERE ' . $parameters; } return tep_db_query($query, $link); } + function tep_db_copy($db, $key, $value) { + $key_value = false; + foreach ($db as $table => $columns) { + $values = []; + foreach ($columns as $name => $v) { + if ($key_value && ($name === $key) && is_null($v)) { + $v = $key_value; + } + + $values[] = ($v ?? $name); + } + + tep_db_query('INSERT INTO ' . $table + . ' (' . implode(', ', array_keys($columns)) + . ') SELECT ' . implode(', ', $values) + . ' FROM ' . $table . ' WHERE ' . $key . ' = ' . $value); + + if (!$key_value) { + $key_value = tep_db_insert_id(); + } + } + + return $key_value; + } + function tep_db_fetch_array($db_query) { return mysqli_fetch_array($db_query, MYSQLI_ASSOC); } From 81e613604d3b47c4c3b1838f8a7b63852cfab561 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sun, 7 Jun 2020 01:29:15 +0000 Subject: [PATCH 04/48] Autoload actions --- includes/classes/actions.php | 13 ++++++------- includes/functions/autoloader.php | 11 ++++++++++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/includes/classes/actions.php b/includes/classes/actions.php index 97d7d4654..d961313ab 100644 --- a/includes/classes/actions.php +++ b/includes/classes/actions.php @@ -5,20 +5,19 @@ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com - Copyright (c) 2018 osCommerce + Copyright (c) 2020 osCommerce Released under the GNU General Public License */ class osC_Actions { - public static function parse($module) { - $module = basename($module); - if ( !empty($module) && file_exists('includes/actions/' . $module . '.php') ) { - include('includes/actions/' . $module . '.php'); + public static function parse($action) { + $action = basename($action); - call_user_func(array('osC_Actions_' . $module, 'execute')); + if ( $action && class_exists($class = 'osC_Actions_' . $action) ) { + call_user_func([$class, 'execute']); } } + } - \ No newline at end of file diff --git a/includes/functions/autoloader.php b/includes/functions/autoloader.php index 5a29137d5..bcd5d6483 100644 --- a/includes/functions/autoloader.php +++ b/includes/functions/autoloader.php @@ -70,6 +70,14 @@ function tep_find_all_templates_under($directory, &$files) { } } + function tep_find_all_actions_under($directory, &$files) { + foreach (scandir($directory, SCANDIR_SORT_ASCENDING) as $file) { + if (is_file($path = "$directory/$file")) { + $files[tep_normalize_class_name('osC_Actions_' . pathinfo($file, PATHINFO_FILENAME))] = $path; + } + } + } + function tep_build_catalog_autoload_index() { $class_files = []; @@ -78,6 +86,7 @@ function tep_build_catalog_autoload_index() { tep_find_all_files_under(DIR_FS_CATALOG . 'includes/modules', $class_files); tep_find_all_files_under(DIR_FS_CATALOG . 'includes/classes', $class_files); + tep_find_all_actions_under(DIR_FS_CATALOG . 'includes/actions', $class_files); tep_find_all_files_under(DIR_FS_CATALOG . 'includes/system/versioned', $class_files); $overrides_directory = DIR_FS_CATALOG . 'includes/system/override'; @@ -114,7 +123,7 @@ function tep_autoload_catalog($original_class) { $class = tep_normalize_class_name($original_class); if (isset($class_files[$class])) { - global $language; + $language =& $_SESSION['language']; if (isset($language) && DIR_FS_CATALOG . 'includes/modules' === substr($class_files[$class], 0, $modules_directory_length)) { $language_file = DIR_FS_CATALOG . "includes/languages/$language/modules" . substr($class_files[$class], $modules_directory_length); if (file_exists($language_file)) { From 747338764d96097af0824dfe1bd7e9b2db5e5a0d Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sun, 7 Jun 2020 01:52:04 +0000 Subject: [PATCH 05/48] Default attributes to null on update --- includes/actions/update_product.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/actions/update_product.php b/includes/actions/update_product.php index a17b211ae..712a2efcf 100644 --- a/includes/actions/update_product.php +++ b/includes/actions/update_product.php @@ -13,14 +13,14 @@ class osC_Actions_update_product { public static function execute() { - global $PHP_SELF, $messageStack, $goto, $parameters; + global $messageStack, $goto, $parameters; foreach (($_POST['products_id'] ?? []) as $i => $product_id) { if (in_array($product_id, ($_POST['cart_delete'] ?? []))) { $_SESSION['cart']->remove($product_id); $messageStack->add_session('product_action', sprintf(PRODUCT_REMOVED, tep_get_products_name($product_id)), 'warning'); } else { - $attributes = $_POST['id'][$product_id] ?? ''; + $attributes = $_POST['id'][$product_id] ?? null; $_SESSION['cart']->add_cart($product_id, $_POST['cart_quantity'][$i], $attributes, false); } } From f68fc8effc6f9f1fdbacc9adbfa5b74767c4e973 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sun, 7 Jun 2020 03:10:02 +0000 Subject: [PATCH 06/48] Start new versions --- .../versioned/1.0.7.3/abstract_module.php | 121 ++++++ .../versioned/1.0.7.3/shopping_cart.php | 405 ++++++++++++++++++ 2 files changed, 526 insertions(+) create mode 100644 includes/system/versioned/1.0.7.3/abstract_module.php create mode 100644 includes/system/versioned/1.0.7.3/shopping_cart.php diff --git a/includes/system/versioned/1.0.7.3/abstract_module.php b/includes/system/versioned/1.0.7.3/abstract_module.php new file mode 100644 index 000000000..2ba409b08 --- /dev/null +++ b/includes/system/versioned/1.0.7.3/abstract_module.php @@ -0,0 +1,121 @@ +code = get_class($this); + $this->title = self::get_constant(static::CONFIG_KEY_BASE . 'TEXT_TITLE') + ?? self::get_constant(static::CONFIG_KEY_BASE . 'TITLE'); + $this->description = self::get_constant(static::CONFIG_KEY_BASE . 'TEXT_DESCRIPTION') + ?? self::get_constant(static::CONFIG_KEY_BASE . 'DESCRIPTION'); + + $this->status_key = static::CONFIG_KEY_BASE . 'STATUS'; + if (defined($this->status_key)) { + $this->enabled = ('True' === constant($this->status_key)); + } + + $this->sort_order = self::get_constant(static::CONFIG_KEY_BASE . 'SORT_ORDER') ?? 0; + } + + public function isEnabled() { + return $this->enabled; + } + + public function check() { + if (!isset($this->_check)) { + $check_query = tep_db_query("SELECT configuration_value FROM configuration WHERE configuration_key = '" . $this->status_key . "'"); + $this->_check = tep_db_num_rows($check_query); + } + + return $this->_check; + } + + protected function _install($parameters) { + $sort_order = 1; + foreach ($parameters as $key => $data) { + $sql_data = [ + 'configuration_title' => $data['title'], + 'configuration_key' => $key, + 'configuration_value' => ($data['value'] ?? ''), + 'configuration_description' => $data['desc'], + 'configuration_group_id' => 6, + 'sort_order' => (int)$sort_order, + 'date_added' => 'NOW()', + ]; + + if (isset($data['set_func'])) { + $sql_data['set_function'] = $data['set_func']; + } + + if (isset($data['use_func'])) { + $sql_data['use_function'] = $data['use_func']; + } + + tep_db_perform('configuration', $sql_data); + $sort_order++; + } + } + + public function install($parameter_key = null) { + $parameters = $this->get_parameters(); + if (isset($parameter_key)) { + if (isset($parameters[$parameter_key])) { + $parameters = [$parameter_key => $parameters[$parameter_key]]; + } else { + $parameters = []; + } + } + + self::_install($parameters); + } + + public function remove() { + tep_db_query("DELETE FROM configuration WHERE configuration_key IN ('" . implode("', '", $this->keys()) . "')"); + } + + public function keys() { + $parameters = $this->get_parameters(); + + if ($this->check()) { + $missing_parameters = array_filter($parameters, function ($k) { return !defined($k); }, ARRAY_FILTER_USE_KEY); + + if ($missing_parameters) { + self::_install($missing_parameters); + } + } + + return array_keys($parameters); + } + + abstract protected function get_parameters(); + + public static function list_exploded($value) { + return nl2br(implode("\n", explode(';', $value))); + } + + } diff --git a/includes/system/versioned/1.0.7.3/shopping_cart.php b/includes/system/versioned/1.0.7.3/shopping_cart.php new file mode 100644 index 000000000..28ab459fb --- /dev/null +++ b/includes/system/versioned/1.0.7.3/shopping_cart.php @@ -0,0 +1,405 @@ +reset(); + } + + function restore_contents() { + if (!isset($_SESSION['customer_id'])) { + return false; + } + +// insert current cart contents in database + if (is_array($this->contents)) { + foreach (array_keys($this->contents) as $products_id) { + $qty = $this->contents[$products_id]['qty']; + $product_query = tep_db_query("SELECT products_id FROM customers_basket WHERE customers_id = " . (int)$_SESSION['customer_id'] . " AND products_id = '" . tep_db_input($products_id) . "'"); + if (tep_db_num_rows($product_query)) { + tep_db_query("UPDATE customers_basket SET customers_basket_quantity = '" . tep_db_input($qty) . "' WHERE customers_id = " . (int)$_SESSION['customer_id'] . " AND products_id = '" . tep_db_input($products_id) . "'"); + } else { + tep_db_query("INSERT INTO customers_basket (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) VALUES (" . (int)$_SESSION['customer_id'] . ", '" . tep_db_input($products_id) . "', '" . tep_db_input($qty) . "', '" . date('Ymd') . "')"); + if (isset($this->contents[$products_id]['attributes'])) { + foreach ($this->contents[$products_id]['attributes'] as $option => $value) { + tep_db_query("INSERT INTO customers_basket_attributes (customers_id, products_id, products_options_id, products_options_value_id) VALUES (" . (int)$_SESSION['customer_id'] . ", '" . tep_db_input($products_id) . "', " . (int)$option . ", " . (int)$value . ")"); + } + } + } + } + } + +// reset per-session cart contents, but not the database contents + $this->reset(false); + + $products_query = tep_db_query("SELECT products_id, customers_basket_quantity FROM customers_basket WHERE customers_id = " . (int)$_SESSION['customer_id']); + while ($products = tep_db_fetch_array($products_query)) { + $this->contents[$products['products_id']] = ['qty' => $products['customers_basket_quantity']]; +// attributes + $attributes_query = tep_db_query("SELECT products_options_id, products_options_value_id FROM customers_basket_attributes WHERE customers_id = " . (int)$_SESSION['customer_id'] . " AND products_id = '" . tep_db_input($products['products_id']) . "'"); + while ($attributes = tep_db_fetch_array($attributes_query)) { + $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id']; + } + } + + $this->cleanup(); + +// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure + $this->cartID = $this->generate_cart_id(); + } + + function reset($reset_database = false) { + $this->contents = []; + $this->total = 0; + $this->weight = 0; + $this->content_type = false; + + if (isset($_SESSION['customer_id']) && $reset_database) { + tep_db_query("DELETE FROM customers_basket WHERE customers_id = " . (int)$_SESSION['customer_id']); + tep_db_query("DELETE FROM customers_basket_attributes WHERE customers_id = " . (int)$_SESSION['customer_id']); + } + + unset($this->cartID); + unset($_SESSION['cartID']); + } + + function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) { + $products_id_string = tep_get_uprid($products_id, $attributes); + $products_id = tep_get_prid($products_id_string); + + if (defined('MAX_QTY_IN_CART') && (MAX_QTY_IN_CART > 0) && ((int)$qty > MAX_QTY_IN_CART)) { + $qty = MAX_QTY_IN_CART; + } + + if (!empty($attributes) && is_array($attributes)) { + foreach ($attributes as $option => $value) { + if (!is_numeric($option) || !is_numeric($value)) { + return; + } + + $check_query = tep_db_query("SELECT products_attributes_id FROM products_attributes WHERE products_id = " . (int)$products_id . " AND options_id = " . (int)$option . " AND options_values_id = " . (int)$value . " LIMIT 1"); + if (tep_db_num_rows($check_query) < 1) { + return; + } + } + } elseif (tep_has_product_attributes($products_id)) { + return; + } + + if (is_numeric($products_id) && is_numeric($qty)) { + $check_product_query = tep_db_query("SELECT products_status FROM products WHERE products_id = " . (int)$products_id); + $check_product = tep_db_fetch_array($check_product_query); + + if (($check_product !== false) && ($check_product['products_status'] == '1')) { + if ($notify) { + $_SESSION['new_products_id_in_cart'] = $products_id; + } + + if ($this->in_cart($products_id_string)) { + $this->update_quantity($products_id_string, $qty, $attributes); + } else { + $this->contents[$products_id_string] = ['qty' => (int)$qty]; + + if (isset($_SESSION['customer_id'])) { + tep_db_query("INSERT INTO customers_basket (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) VALUES (" . (int)$_SESSION['customer_id'] . ", '" . tep_db_input($products_id_string) . "', " . (int)$qty . ", '" . date('Ymd') . "')"); + } + + if (is_array($attributes)) { + foreach ($attributes as $option => $value) { + $this->contents[$products_id_string]['attributes'][$option] = $value; + + if (isset($_SESSION['customer_id'])) { + tep_db_query("INSERT INTO customers_basket_attributes (customers_id, products_id, products_options_id, products_options_value_id) VALUES (" . (int)$_SESSION['customer_id'] . ", '" . tep_db_input($products_id_string) . "', " . (int)$option . ", " . (int)$value . ")"); + } + } + } + } + + $this->cleanup(); + +// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure + $this->cartID = $this->generate_cart_id(); + } + } + } + + function update_quantity($products_id, $quantity = '', $attributes = '') { + $products_id_string = tep_get_uprid($products_id, $attributes); + $products_id = tep_get_prid($products_id_string); + + if (defined('MAX_QTY_IN_CART') && (MAX_QTY_IN_CART > 0) && ((int)$quantity > MAX_QTY_IN_CART)) { + $quantity = MAX_QTY_IN_CART; + } + + if (is_array($attributes)) { + foreach ($attributes as $option => $value) { + if (!is_numeric($option) || !is_numeric($value)) { + return; + } + } + } + + if (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity)) { + $this->contents[$products_id_string] = ['qty' => (int)$quantity]; + + if (isset($_SESSION['customer_id'])) { + tep_db_query("UPDATE customers_basket SET customers_basket_quantity = " . (int)$quantity . " WHERE customers_id = " . (int)$_SESSION['customer_id'] . " AND products_id = '" . tep_db_input($products_id_string) . "'"); + } + + if (is_array($attributes)) { + foreach ($attributes as $option => $value) { + $this->contents[$products_id_string]['attributes'][$option] = $value; + + if (isset($_SESSION['customer_id'])) { + tep_db_query("UPDATE customers_basket_attributes SET products_options_value_id = " . (int)$value . " WHERE customers_id = " . (int)$_SESSION['customer_id'] . " AND products_id = '" . tep_db_input($products_id_string) . "' AND products_options_id = " . (int)$option); + } + } + } + +// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure + $this->cartID = $this->generate_cart_id(); + } + } + + function cleanup() { + foreach (array_keys($this->contents) as $key) { + if ($this->contents[$key]['qty'] < 1) { + unset($this->contents[$key]); + + if (isset($_SESSION['customer_id'])) { + tep_db_query("DELETE FROM customers_basket WHERE customers_id = " . (int)$_SESSION['customer_id'] . " AND products_id = '" . tep_db_input($key) . "'"); + tep_db_query("DELETE FROM customers_basket_attributes WHERE customers_id = " . (int)$_SESSION['customer_id'] . " AND products_id = '" . tep_db_input($key) . "'"); + } + } + } + } + +// get total number of items in cart + function count_contents() { + $total_items = 0; + if (is_array($this->contents)) { + foreach (array_keys($this->contents) as $products_id) { + $total_items += $this->get_quantity($products_id); + } + } + + return $total_items; + } + + function get_quantity($products_id) { + if (isset($this->contents[$products_id])) { + return $this->contents[$products_id]['qty']; + } else { + return 0; + } + } + + function in_cart($products_id) { + return isset($this->contents[$products_id]); + } + + function remove($products_id) { + unset($this->contents[$products_id]); +// remove from database + if (isset($_SESSION['customer_id'])) { + tep_db_query("DELETE FROM customers_basket WHERE customers_id = " . (int)$_SESSION['customer_id'] . " AND products_id = '" . tep_db_input($products_id) . "'"); + tep_db_query("DELETE FROM customers_basket_attributes WHERE customers_id = " . (int)$_SESSION['customer_id'] . " AND products_id = '" . tep_db_input($products_id) . "'"); + } + + $this->calculate(); + +// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure + $this->cartID = $this->generate_cart_id(); + } + + function remove_all() { + $this->reset(); + } + + function get_product_id_list() { + $product_id_list = ''; + if (is_array($this->contents)) { + foreach (array_keys($this->contents) as $products_id) { + $product_id_list .= ', ' . $products_id; + } + } + + return substr($product_id_list, 2); + } + + function calculate() { + global $currencies; + + $this->total = 0; + $this->weight = 0; + if (!is_array($this->contents)) { + return 0; + } + + foreach (array_keys($this->contents) as $products_id) { + $qty = $this->contents[$products_id]['qty']; + +// products price + $product_query = tep_db_query("SELECT products_id, products_price, products_tax_class_id, products_weight FROM products WHERE products_id = " . (int)$products_id); + if ($product = tep_db_fetch_array($product_query)) { + $prid = $product['products_id']; + $products_tax = tep_get_tax_rate($product['products_tax_class_id']); + $products_price = $product['products_price']; + $products_weight = $product['products_weight']; + + $specials_query = tep_db_query("SELECT specials_new_products_price FROM specials WHERE products_id = " . (int)$prid . " AND status = 1"); + if (tep_db_num_rows ($specials_query)) { + $specials = tep_db_fetch_array($specials_query); + $products_price = $specials['specials_new_products_price']; + } + + $this->total += $currencies->calculate_price($products_price, $products_tax, $qty); + $this->weight += ($qty * $products_weight); + } + +// attributes price + if (isset($this->contents[$products_id]['attributes'])) { + foreach ($this->contents[$products_id]['attributes'] as $option => $value) { + $attribute_price_query = tep_db_query("SELECT options_values_price, price_prefix FROM products_attributes WHERE products_id = " . (int)$prid . " AND options_id = " . (int)$option . " AND options_values_id = " . (int)$value); + $attribute_price = tep_db_fetch_array($attribute_price_query); + if ($attribute_price['price_prefix'] == '+') { + $this->total += $currencies->calculate_price($attribute_price['options_values_price'], $products_tax, $qty); + } else { + $this->total -= $currencies->calculate_price($attribute_price['options_values_price'], $products_tax, $qty); + } + } + } + } + } + + function attributes_price($products_id) { + $attributes_price = 0; + + if (isset($this->contents[$products_id]['attributes'])) { + foreach ($this->contents[$products_id]['attributes'] as $option => $value) { + $attribute_price_query = tep_db_query("SELECT options_values_price, price_prefix FROM products_attributes WHERE products_id = " . (int)$products_id . " AND options_id = " . (int)$option . " AND options_values_id = " . (int)$value); + $attribute_price = tep_db_fetch_array($attribute_price_query); + if ($attribute_price['price_prefix'] == '+') { + $attributes_price += $attribute_price['options_values_price']; + } else { + $attributes_price -= $attribute_price['options_values_price']; + } + } + } + + return $attributes_price; + } + + function get_products() { + if (!is_array($this->contents)) { + return false; + } + + $products_array = []; + foreach (array_keys($this->contents) as $products_id) { + $products_query = tep_db_query("SELECT p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id FROM products p, products_description pd WHERE p.products_id = " . (int)$products_id . " AND pd.products_id = p.products_id AND pd.language_id = " . (int)$_SESSION['languages_id']); + if ($products = tep_db_fetch_array($products_query)) { + $prid = $products['products_id']; + $products_price = $products['products_price']; + + $specials_query = tep_db_query("SELECT specials_new_products_price FROM specials WHERE products_id = " . (int)$prid . " AND status = 1"); + if (tep_db_num_rows($specials_query)) { + $specials = tep_db_fetch_array($specials_query); + $products_price = $specials['specials_new_products_price']; + } + + $products_array[] = [ + 'id' => $products_id, + 'name' => $products['products_name'], + 'model' => $products['products_model'], + 'image' => $products['products_image'], + 'price' => $products_price, + 'quantity' => $this->contents[$products_id]['qty'], + 'weight' => $products['products_weight'], + 'final_price' => ($products_price + $this->attributes_price($products_id)), + 'tax_class_id' => $products['products_tax_class_id'], + 'attributes' => ($this->contents[$products_id]['attributes'] ?? null), + ]; + } + } + + return $products_array; + } + + function show_total() { + $this->calculate(); + + return $this->total; + } + + function show_weight() { + $this->calculate(); + + return $this->weight; + } + + function generate_cart_id($length = 5) { + return tep_create_random_value($length, 'digits'); + } + + function get_content_type() { + $this->content_type = false; + + if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) { + foreach (array_keys($this->contents) as $products_id) { + if (isset($this->contents[$products_id]['attributes'])) { + foreach ($this->contents[$products_id]['attributes'] as $option => $value) { + $virtual_check_query = tep_db_query("SELECT COUNT(*) AS total FROM products_attributes pa, products_attributes_download pad WHERE pa.products_id = " . (int)$products_id . " AND pa.options_values_id = " . (int)$value . " AND pa.products_attributes_id = pad.products_attributes_id"); + $virtual_check = tep_db_fetch_array($virtual_check_query); + + if ($virtual_check['total'] > 0) { + switch ($this->content_type) { + case 'physical': + $this->content_type = 'mixed'; + + return $this->content_type; + default: + $this->content_type = 'virtual'; + } + } else { + switch ($this->content_type) { + case 'virtual': + $this->content_type = 'mixed'; + + return $this->content_type; + default: + $this->content_type = 'physical'; + } + } + } + } else { + switch ($this->content_type) { + case 'virtual': + $this->content_type = 'mixed'; + + return $this->content_type; + default: + $this->content_type = 'physical'; + } + } + } + } else { + $this->content_type = 'physical'; + } + + return $this->content_type; + } + + } From c1e55fb5b84640dbf068b2ebc5f2d2bba0985286 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sun, 7 Jun 2020 03:51:58 +0000 Subject: [PATCH 07/48] Enable constant overrides Some Apps may need to override the constant loading with additional options. This allows an App to do so. --- .../system/versioned/1.0.7.3/abstract_module.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/includes/system/versioned/1.0.7.3/abstract_module.php b/includes/system/versioned/1.0.7.3/abstract_module.php index 2ba409b08..22ba2d6e1 100644 --- a/includes/system/versioned/1.0.7.3/abstract_module.php +++ b/includes/system/versioned/1.0.7.3/abstract_module.php @@ -19,7 +19,7 @@ abstract class abstract_module { public $description; public $enabled = false; protected $_check; - protected $key_base; + protected $config_key_base; protected $status_key; public $sort_order; @@ -27,19 +27,27 @@ protected static function get_constant($constant_name) { return defined($constant_name) ? constant($constant_name) : null; } + public function base_constant($suffix) { + return $this->get_constant($this->config_key_base . "$suffix"); + } + public function __construct() { + if (is_null($this->config_key_base)) { + $this->config_key_base = static::CONFIG_KEY_BASE; + } + $this->code = get_class($this); $this->title = self::get_constant(static::CONFIG_KEY_BASE . 'TEXT_TITLE') ?? self::get_constant(static::CONFIG_KEY_BASE . 'TITLE'); $this->description = self::get_constant(static::CONFIG_KEY_BASE . 'TEXT_DESCRIPTION') ?? self::get_constant(static::CONFIG_KEY_BASE . 'DESCRIPTION'); - $this->status_key = static::CONFIG_KEY_BASE . 'STATUS'; + $this->status_key = $this->config_key_base . 'STATUS'; if (defined($this->status_key)) { $this->enabled = ('True' === constant($this->status_key)); } - $this->sort_order = self::get_constant(static::CONFIG_KEY_BASE . 'SORT_ORDER') ?? 0; + $this->sort_order = $this->base_constant('SORT_ORDER') ?? 0; } public function isEnabled() { From 92bdab34eecaecb2dd8d992093e1ef9d503128f5 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sun, 7 Jun 2020 04:27:45 +0000 Subject: [PATCH 08/48] Hookable product columns Allow hooks to add columns to the cart->get_products method. This removes the need for either a core change or a separate database query for each new product field. --- .../versioned/1.0.7.3/shopping_cart.php | 188 +++++++++--------- 1 file changed, 90 insertions(+), 98 deletions(-) diff --git a/includes/system/versioned/1.0.7.3/shopping_cart.php b/includes/system/versioned/1.0.7.3/shopping_cart.php index 28ab459fb..0c7ea7efd 100644 --- a/includes/system/versioned/1.0.7.3/shopping_cart.php +++ b/includes/system/versioned/1.0.7.3/shopping_cart.php @@ -12,6 +12,14 @@ class shoppingCart { + const COLUMN_KEYS = [ + 'name' => 'products_name', + 'model' => 'products_model', + 'image' => 'products_image', + 'weight' => 'products_weight', + 'tax_class_id' => 'products_tax_class_id', + ]; + public $contents, $total, $weight, $cartID, $content_type; function __construct() { @@ -75,7 +83,7 @@ function reset($reset_database = false) { unset($_SESSION['cartID']); } - function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) { + function add_cart($products_id, $qty = 1, $attributes = null, $notify = true) { $products_id_string = tep_get_uprid($products_id, $attributes); $products_id = tep_get_prid($products_id_string); @@ -135,7 +143,7 @@ function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) { } } - function update_quantity($products_id, $quantity = '', $attributes = '') { + function update_quantity($products_id, $quantity, $attributes = null) { $products_id_string = tep_get_uprid($products_id, $attributes); $products_id = tep_get_prid($products_id_string); @@ -143,11 +151,9 @@ function update_quantity($products_id, $quantity = '', $attributes = '') { $quantity = MAX_QTY_IN_CART; } - if (is_array($attributes)) { - foreach ($attributes as $option => $value) { - if (!is_numeric($option) || !is_numeric($value)) { - return; - } + foreach (($attributes ?? []) as $option => $value) { + if (!is_numeric($option) || !is_numeric($value)) { + return; } } @@ -155,16 +161,24 @@ function update_quantity($products_id, $quantity = '', $attributes = '') { $this->contents[$products_id_string] = ['qty' => (int)$quantity]; if (isset($_SESSION['customer_id'])) { - tep_db_query("UPDATE customers_basket SET customers_basket_quantity = " . (int)$quantity . " WHERE customers_id = " . (int)$_SESSION['customer_id'] . " AND products_id = '" . tep_db_input($products_id_string) . "'"); + tep_db_query(sprintf(<<<'EOSQL' +UPDATE customers_basket + SET customers_basket_quantity = %d + WHERE customers_id = "%d AND products_id = '%s' +EOSQL + , (int)$quantity, (int)$_SESSION['customer_id'], tep_db_input($products_id_string))); } - if (is_array($attributes)) { - foreach ($attributes as $option => $value) { - $this->contents[$products_id_string]['attributes'][$option] = $value; + foreach (($attributes ?? []) as $option => $value) { + $this->contents[$products_id_string]['attributes'][$option] = $value; - if (isset($_SESSION['customer_id'])) { - tep_db_query("UPDATE customers_basket_attributes SET products_options_value_id = " . (int)$value . " WHERE customers_id = " . (int)$_SESSION['customer_id'] . " AND products_id = '" . tep_db_input($products_id_string) . "' AND products_options_id = " . (int)$option); - } + if (isset($_SESSION['customer_id'])) { + tep_db_query(sprintf(<<<'EOSQL' +UPDATE customers_basket_attributes + SET products_options_value_id = %d + WHERE customers_id = %d AND products_id = '%s' AND products_options_id = %d +EOSQL + , (int)$value, (int)$_SESSION['customer_id'], tep_db_input($products_id_string), (int)$option)); } } @@ -174,13 +188,13 @@ function update_quantity($products_id, $quantity = '', $attributes = '') { } function cleanup() { - foreach (array_keys($this->contents) as $key) { - if ($this->contents[$key]['qty'] < 1) { - unset($this->contents[$key]); + foreach (array_keys($this->contents) as $product_id) { + if ($this->contents[$product_id]['qty'] < 1) { + unset($this->contents[$product_id]); if (isset($_SESSION['customer_id'])) { - tep_db_query("DELETE FROM customers_basket WHERE customers_id = " . (int)$_SESSION['customer_id'] . " AND products_id = '" . tep_db_input($key) . "'"); - tep_db_query("DELETE FROM customers_basket_attributes WHERE customers_id = " . (int)$_SESSION['customer_id'] . " AND products_id = '" . tep_db_input($key) . "'"); + tep_db_query("DELETE FROM customers_basket WHERE products_id = '" . tep_db_input($product_id) . "' AND customers_id = " . (int)$_SESSION['customer_id']); + tep_db_query("DELETE FROM customers_basket_attributes WHERE products_id = '" . tep_db_input($product_id) . "' AND customers_id = " . (int)$_SESSION['customer_id']); } } } @@ -189,21 +203,15 @@ function cleanup() { // get total number of items in cart function count_contents() { $total_items = 0; - if (is_array($this->contents)) { - foreach (array_keys($this->contents) as $products_id) { - $total_items += $this->get_quantity($products_id); - } + foreach (array_keys($this->contents) as $products_id) { + $total_items += $this->get_quantity($products_id); } return $total_items; } function get_quantity($products_id) { - if (isset($this->contents[$products_id])) { - return $this->contents[$products_id]['qty']; - } else { - return 0; - } + return $this->contents[$products_id]['qty'] ?? 0; } function in_cart($products_id) { @@ -229,14 +237,7 @@ function remove_all() { } function get_product_id_list() { - $product_id_list = ''; - if (is_array($this->contents)) { - foreach (array_keys($this->contents) as $products_id) { - $product_id_list .= ', ' . $products_id; - } - } - - return substr($product_id_list, 2); + return implode(', ', array_keys($this->contents)); } function calculate() { @@ -244,9 +245,6 @@ function calculate() { $this->total = 0; $this->weight = 0; - if (!is_array($this->contents)) { - return 0; - } foreach (array_keys($this->contents) as $products_id) { $qty = $this->contents[$products_id]['qty']; @@ -254,88 +252,77 @@ function calculate() { // products price $product_query = tep_db_query("SELECT products_id, products_price, products_tax_class_id, products_weight FROM products WHERE products_id = " . (int)$products_id); if ($product = tep_db_fetch_array($product_query)) { - $prid = $product['products_id']; $products_tax = tep_get_tax_rate($product['products_tax_class_id']); - $products_price = $product['products_price']; - $products_weight = $product['products_weight']; - $specials_query = tep_db_query("SELECT specials_new_products_price FROM specials WHERE products_id = " . (int)$prid . " AND status = 1"); - if (tep_db_num_rows ($specials_query)) { - $specials = tep_db_fetch_array($specials_query); - $products_price = $specials['specials_new_products_price']; - } + $specials_query = tep_db_query("SELECT specials_new_products_price FROM specials WHERE status = 1 AND products_id = " . (int)$products_id); + $specials = tep_db_fetch_array($specials_query); + $products_price = $specials['specials_new_products_price'] ?? $product['products_price']; $this->total += $currencies->calculate_price($products_price, $products_tax, $qty); - $this->weight += ($qty * $products_weight); + $this->weight += ($qty * $product['products_weight']); } // attributes price - if (isset($this->contents[$products_id]['attributes'])) { - foreach ($this->contents[$products_id]['attributes'] as $option => $value) { - $attribute_price_query = tep_db_query("SELECT options_values_price, price_prefix FROM products_attributes WHERE products_id = " . (int)$prid . " AND options_id = " . (int)$option . " AND options_values_id = " . (int)$value); - $attribute_price = tep_db_fetch_array($attribute_price_query); - if ($attribute_price['price_prefix'] == '+') { - $this->total += $currencies->calculate_price($attribute_price['options_values_price'], $products_tax, $qty); - } else { - $this->total -= $currencies->calculate_price($attribute_price['options_values_price'], $products_tax, $qty); - } - } - } + $this->total += $this->attributes_price($products_id); } } function attributes_price($products_id) { $attributes_price = 0; - if (isset($this->contents[$products_id]['attributes'])) { - foreach ($this->contents[$products_id]['attributes'] as $option => $value) { - $attribute_price_query = tep_db_query("SELECT options_values_price, price_prefix FROM products_attributes WHERE products_id = " . (int)$products_id . " AND options_id = " . (int)$option . " AND options_values_id = " . (int)$value); - $attribute_price = tep_db_fetch_array($attribute_price_query); - if ($attribute_price['price_prefix'] == '+') { - $attributes_price += $attribute_price['options_values_price']; - } else { - $attributes_price -= $attribute_price['options_values_price']; - } + foreach (($this->contents[$products_id]['attributes'] ?? []) as $option => $value) { + $attribute_price_query = tep_db_query("SELECT options_values_price, price_prefix FROM products_attributes WHERE products_id = " . (int)$products_id . " AND options_id = " . (int)$option . " AND options_values_id = " . (int)$value); + $attribute_price = tep_db_fetch_array($attribute_price_query); + if ($attribute_price['price_prefix'] == '+') { + $attributes_price += $attribute_price['options_values_price']; + } else { + $attributes_price -= $attribute_price['options_values_price']; } } return $attributes_price; } - function get_products() { - if (!is_array($this->contents)) { - return false; + private function map_columns($data) { + static $column_keys = null; + if (is_null($column_keys)) { + $column_keys = static::COLUMN_KEYS; + $parameters = ['column_keys' => &$column_keys]; + $GLOBALS['OSCOM_Hooks']->call('siteWide', 'cartProductColumns', $parameters); + } + + $product = []; + foreach ($column_keys as $key => $column_name) { + $product[$key] = $data[$column_name]; } + } - $products_array = []; + function get_products() { + $products = []; foreach (array_keys($this->contents) as $products_id) { - $products_query = tep_db_query("SELECT p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id FROM products p, products_description pd WHERE p.products_id = " . (int)$products_id . " AND pd.products_id = p.products_id AND pd.language_id = " . (int)$_SESSION['languages_id']); - if ($products = tep_db_fetch_array($products_query)) { - $prid = $products['products_id']; - $products_price = $products['products_price']; - - $specials_query = tep_db_query("SELECT specials_new_products_price FROM specials WHERE products_id = " . (int)$prid . " AND status = 1"); - if (tep_db_num_rows($specials_query)) { - $specials = tep_db_fetch_array($specials_query); - $products_price = $specials['specials_new_products_price']; + $products_query = tep_db_query("SELECT p.*, pd.* FROM products p INNER JOIN products_description pd ON pd.products_id = p.products_id WHERE p.products_id = " . (int)$products_id . " AND pd.language_id = " . (int)$_SESSION['languages_id']); + if ($product = tep_db_fetch_array($products_query)) { + $prid = $product['products_id']; + $product_price = $product['products_price']; + + $specials_query = tep_db_query("SELECT specials_new_products_price FROM specials WHERE status = 1 AND products_id = " . (int)$prid); + if ($specials = tep_db_fetch_array($specials_query)) { + $product_price = $specials['specials_new_products_price']; } - $products_array[] = [ - 'id' => $products_id, - 'name' => $products['products_name'], - 'model' => $products['products_model'], - 'image' => $products['products_image'], - 'price' => $products_price, - 'quantity' => $this->contents[$products_id]['qty'], - 'weight' => $products['products_weight'], - 'final_price' => ($products_price + $this->attributes_price($products_id)), - 'tax_class_id' => $products['products_tax_class_id'], - 'attributes' => ($this->contents[$products_id]['attributes'] ?? null), - ]; + $product = $this->map_columns($product); + + $product['id'] = $products_id; + $product['price'] = $product_price; + $product['quantity'] = $this->contents[$products_id]['qty']; + $product['final_price'] = ($product_price + $this->attributes_price($products_id)); + $product['attributes'] = ($this->contents[$products_id]['attributes'] ?? null); + + $products[] = $product; } } - return $products_array; + return $products; } function show_total() { @@ -355,13 +342,18 @@ function generate_cart_id($length = 5) { } function get_content_type() { - $this->content_type = false; - if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) { + $this->content_type = false; + foreach (array_keys($this->contents) as $products_id) { if (isset($this->contents[$products_id]['attributes'])) { - foreach ($this->contents[$products_id]['attributes'] as $option => $value) { - $virtual_check_query = tep_db_query("SELECT COUNT(*) AS total FROM products_attributes pa, products_attributes_download pad WHERE pa.products_id = " . (int)$products_id . " AND pa.options_values_id = " . (int)$value . " AND pa.products_attributes_id = pad.products_attributes_id"); + foreach (($this->contents[$products_id]['attributes'] ?? []) as $option => $value) { + $virtual_check_query = tep_db_query(sprintf(<<<'EOSQL' +SELECT COUNT(*) AS total + FROM products_attributes pa INNER JOIN products_attributes_download pad ON pa.products_attributes_id = pad.products_attributes_id + WHERE pa.products_id = %d AND pa.options_values_id = %d +EOSQL + , (int)$products_id, (int)$value)); $virtual_check = tep_db_fetch_array($virtual_check_query); if ($virtual_check['total'] > 0) { From e111eb059ac51083688bc2d09fbd347a25c4abda Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sun, 7 Jun 2020 04:34:35 +0000 Subject: [PATCH 09/48] Add orders_products_id to ease alterations --- includes/system/versioned/1.0.5.3/order.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/system/versioned/1.0.5.3/order.php b/includes/system/versioned/1.0.5.3/order.php index 16bc90ead..bc11978bf 100644 --- a/includes/system/versioned/1.0.5.3/order.php +++ b/includes/system/versioned/1.0.5.3/order.php @@ -123,6 +123,7 @@ public function query($order_id) { 'tax' => $orders_products['products_tax'], 'price' => $orders_products['products_price'], 'final_price' => $orders_products['final_price'], + 'orders_products_id' => $orders_products['orders_products_id'], ]; $attributes_query = tep_db_query("SELECT products_options, products_options_values, options_values_price, price_prefix FROM orders_products_attributes WHERE orders_id = " . (int)$this->id . " AND orders_products_id = " . (int)$orders_products['orders_products_id']); From 5c35003f9f19717703ac3246f47e9960728dd6e3 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sun, 7 Jun 2020 04:51:39 +0000 Subject: [PATCH 10/48] Start new version --- .../1.0.7.3/abstract_payment_module.php | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 includes/system/versioned/1.0.7.3/abstract_payment_module.php diff --git a/includes/system/versioned/1.0.7.3/abstract_payment_module.php b/includes/system/versioned/1.0.7.3/abstract_payment_module.php new file mode 100644 index 000000000..903ce4512 --- /dev/null +++ b/includes/system/versioned/1.0.7.3/abstract_payment_module.php @@ -0,0 +1,114 @@ +public_title = self::get_constant(static::CONFIG_KEY_BASE . 'TEXT_PUBLIC_TITLE') + ?? self::get_constant(static::CONFIG_KEY_BASE . 'PUBLIC_TITLE'); + + $this->order_status = (int)(self::get_constant(static::CONFIG_KEY_BASE . 'ORDER_STATUS_ID') ?? 0); + $this->order_status = ($this->order_status > 0) ? $this->order_status : 0; + if ( ( $this->enabled === true ) && isset($GLOBALS['order']) && $GLOBALS['order'] instanceof order ) { + $this->update_status(); + } + } + + public function update_status() { + global $order; + + $zone_id = constant(static::CONFIG_KEY_BASE . 'ZONE'); + if ( $this->enabled && ((int)$zone_id > 0) ) { + $check_query = tep_db_query("SELECT zone_id FROM zones_to_geo_zones WHERE geo_zone_id = " . (int)$zone_id . " AND zone_country_id = " . (int)$order->delivery['country']['id'] . " ORDER BY zone_id"); + while ($check = tep_db_fetch_array($check_query)) { + if (($check['zone_id'] < 1) || ($check['zone_id'] == $order->delivery['zone_id'])) { + return; + } + } + + $this->enabled = false; + } + } + + public function javascript_validation() { + return false; + } + + public function selection() { + return [ + 'id' => $this->code, + 'module' => $this->public_title ?? $this->title, + ]; + } + + public function pre_confirmation_check() { + return false; + } + + public function confirmation() { + return false; + } + + public function process_button() { + return false; + } + + public function before_process() { + return false; + } + + public function after_process() { + return false; + } + + public function get_error() { + return false; + } + + public static function ensure_order_status($constant_name, $order_status_name) { + if (defined($constant_name)) { + return constant($constant_name); + } + + $check_sql = "SELECT orders_status_id FROM orders_status WHERE orders_status_name = '" . tep_db_input($order_status_name) . "' LIMIT 1"; + $check_query = tep_db_query($check_sql); + + if (tep_db_num_rows($check_query) < 1) { + $column_names = ''; + $column_values = ''; + $flags_query = tep_db_query("DESCRIBE orders_status public_flag"); + if (tep_db_num_rows($flags_query) === 1) { + $column_names = ', public_flag, downloads_flag'; + $column_values = ', 0 AS public_flag, 0 AS downloads_flag'; + } + + $next_id = tep_db_fetch_array(tep_db_query("SELECT MAX(orders_status_id) + 1 AS next_id FROM orders_status"))['next_id'] ?? 1; + + tep_db_query(sprintf(<<<'EOSQL' +INSERT INTO orders_status (orders_status_id, language_id, orders_status_name%s) + SELECT %d AS orders_status_id, + l.languages_id AS language_id, + '%s' AS orders_status_name%s + FROM languages l + ORDER BY l.sort_order +EOSQL + , $column_names, (int)$next_id, tep_db_input($order_status_name), $column_values)); + + $check_query = tep_db_query($check_sql); + } + + $check = tep_db_fetch_array($check_query); + return $check['orders_status_id']; + } + + } From 61c07df798d57c2cab55068b717409c5ae050a36 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sun, 7 Jun 2020 04:52:33 +0000 Subject: [PATCH 11/48] New abstract module bases Shipping modules have common functionality that can be abstracted into a common base. Also provides a point where functionality can be overridden all at once. Shipping and payment modules share some functionality. So adding the zoneable concept for that shared code. --- .../1.0.7.3/abstract_shipping_module.php | 38 ++++++++++++++++++ .../1.0.7.3/abstract_zoneable_module.php | 39 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 includes/system/versioned/1.0.7.3/abstract_shipping_module.php create mode 100644 includes/system/versioned/1.0.7.3/abstract_zoneable_module.php diff --git a/includes/system/versioned/1.0.7.3/abstract_shipping_module.php b/includes/system/versioned/1.0.7.3/abstract_shipping_module.php new file mode 100644 index 000000000..282e2b06a --- /dev/null +++ b/includes/system/versioned/1.0.7.3/abstract_shipping_module.php @@ -0,0 +1,38 @@ +tax_class = $this->base_constant('TAX_CLASS') ?? 0; + if ($this->tax_class > 0) { + $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); + } + + if (tep_not_null($this->icon) && ('True' === ($this->base_constant('DISPLAY_ICON') ?? 'True'))) { + $this->quotes['icon'] = tep_image($this->icon, htmlspecialchars($this->title)); + } + } + + public function calculate_handling() { + return ($this->base_constant('HANDLING') ?? 0); + } + + } + diff --git a/includes/system/versioned/1.0.7.3/abstract_zoneable_module.php b/includes/system/versioned/1.0.7.3/abstract_zoneable_module.php new file mode 100644 index 000000000..d190a1ae7 --- /dev/null +++ b/includes/system/versioned/1.0.7.3/abstract_zoneable_module.php @@ -0,0 +1,39 @@ +enabled && isset($GLOBALS['order']->delivery['country']['id'])) { + $this->update_status(); + } + } + + public function update_status() { + global $order; + + $zone_id = $this->base_constant('ZONE') ?? 0; + if ( $this->enabled && isset($order->delivery['zone_id']) && ((int)$zone_id > 0) ) { + $check_query = tep_db_query("SELECT zone_id FROM zones_to_geo_zones WHERE geo_zone_id = " . (int)$zone_id . " AND zone_country_id = " . (int)$order->delivery['country']['id'] . " ORDER BY zone_id"); + while ($check = tep_db_fetch_array($check_query)) { + if (($check['zone_id'] < 1) || ($check['zone_id'] == $order->delivery['zone_id'])) { + return; + } + } + + $this->enabled = false; + } + } + + } + From 4e65c423b52958f0217163abc05f7fc32476deab Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sun, 7 Jun 2020 05:00:37 +0000 Subject: [PATCH 12/48] Payments use zoneable base --- .../1.0.7.3/abstract_payment_module.php | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/includes/system/versioned/1.0.7.3/abstract_payment_module.php b/includes/system/versioned/1.0.7.3/abstract_payment_module.php index 903ce4512..6e571dd77 100644 --- a/includes/system/versioned/1.0.7.3/abstract_payment_module.php +++ b/includes/system/versioned/1.0.7.3/abstract_payment_module.php @@ -10,34 +10,15 @@ Released under the GNU General Public License */ - abstract class abstract_payment_module extends abstract_module { + abstract class abstract_payment_module extends abstract_zoneable_module { function __construct() { parent::__construct(); $this->public_title = self::get_constant(static::CONFIG_KEY_BASE . 'TEXT_PUBLIC_TITLE') ?? self::get_constant(static::CONFIG_KEY_BASE . 'PUBLIC_TITLE'); - $this->order_status = (int)(self::get_constant(static::CONFIG_KEY_BASE . 'ORDER_STATUS_ID') ?? 0); + $this->order_status = (int)($this->base_constant('ORDER_STATUS_ID') ?? 0); $this->order_status = ($this->order_status > 0) ? $this->order_status : 0; - if ( ( $this->enabled === true ) && isset($GLOBALS['order']) && $GLOBALS['order'] instanceof order ) { - $this->update_status(); - } - } - - public function update_status() { - global $order; - - $zone_id = constant(static::CONFIG_KEY_BASE . 'ZONE'); - if ( $this->enabled && ((int)$zone_id > 0) ) { - $check_query = tep_db_query("SELECT zone_id FROM zones_to_geo_zones WHERE geo_zone_id = " . (int)$zone_id . " AND zone_country_id = " . (int)$order->delivery['country']['id'] . " ORDER BY zone_id"); - while ($check = tep_db_fetch_array($check_query)) { - if (($check['zone_id'] < 1) || ($check['zone_id'] == $order->delivery['zone_id'])) { - return; - } - } - - $this->enabled = false; - } } public function javascript_validation() { From f7b41f734af5b54ae93922d2b9eec8d220112c79 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sun, 7 Jun 2020 05:45:26 +0000 Subject: [PATCH 13/48] Update shipping to use abstract base Updates the core shipping modules to use a common base. This makes it easier to write Apps that give a common change in behavior. --- includes/modules/shipping/flat.php | 120 +++++++----------- includes/modules/shipping/item.php | 176 ++++++++++++-------------- includes/modules/shipping/table.php | 130 +++++++++---------- includes/modules/shipping/zones.php | 188 ++++++++++++++-------------- 4 files changed, 281 insertions(+), 333 deletions(-) diff --git a/includes/modules/shipping/flat.php b/includes/modules/shipping/flat.php index a62172599..da6c9aebe 100644 --- a/includes/modules/shipping/flat.php +++ b/includes/modules/shipping/flat.php @@ -5,93 +5,67 @@ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com - Copyright (c) 2003 osCommerce + Copyright (c) 2020 osCommerce Released under the GNU General Public License */ - class flat { - var $code, $title, $description, $icon, $enabled; + class flat extends abstract_shipping_module { -// class constructor - function __construct() { - global $order; - - $this->code = 'flat'; - $this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE; - $this->description = MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION; - - if ( defined('MODULE_SHIPPING_FLAT_STATUS') ) { - $this->sort_order = MODULE_SHIPPING_FLAT_SORT_ORDER; - $this->icon = ''; - $this->tax_class = MODULE_SHIPPING_FLAT_TAX_CLASS; - $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false); - } - - if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLAT_ZONE > 0) ) { - $check_flag = false; - - $delivery_country_id = $order->delivery['country']['id'] ?? STORE_COUNTRY ?? 0; - $delivery_zone_id = $order->delivery['zone_id'] ?? STORE_ZONE ?? 0; - - $check_query = tep_db_query("select zone_id from zones_to_geo_zones where geo_zone_id = '" . MODULE_SHIPPING_FLAT_ZONE . "' and zone_country_id = '" . $delivery_country_id . "' order by zone_id"); - while ($check = tep_db_fetch_array($check_query)) { - if ($check['zone_id'] < 1) { - $check_flag = true; - break; - } elseif ($check['zone_id'] == $delivery_zone_id) { - $check_flag = true; - break; - } - } - - if ($check_flag == false) { - $this->enabled = false; - } - } - } + const CONFIG_KEY_BASE = 'MODULE_SHIPPING_FLAT_'; // class methods - function quote($method = '') { + public function quote($method = '') { global $order; - $this->quotes = array('id' => $this->code, - 'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE, - 'methods' => array(array('id' => $this->code, - 'title' => MODULE_SHIPPING_FLAT_TEXT_WAY, - 'cost' => MODULE_SHIPPING_FLAT_COST))); - - if ($this->tax_class > 0) { - $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); - } + $this->quotes = [ + 'id' => $this->code, + 'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE, + 'methods' => [[ + 'id' => $this->code, + 'title' => MODULE_SHIPPING_FLAT_TEXT_WAY, + 'cost' => $this->base_constant('COST') + $this->calculate_handling(), + ]], + ]; - if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, htmlspecialchars($this->title)); + $this->quote_common(); return $this->quotes; } - function check() { - if (!isset($this->_check)) { - $check_query = tep_db_query("select configuration_value from configuration where configuration_key = 'MODULE_SHIPPING_FLAT_STATUS'"); - $this->_check = tep_db_num_rows($check_query); - } - return $this->_check; + protected function get_parameters() { + return [ + $this->config_key_base . 'STATUS' => [ + 'title' => 'Enable Flat Shipping', + 'value' => 'True', + 'desc' => 'Do you want to offer flat rate shipping?', + 'set_func' => "tep_cfg_select_option(['True', 'False'], ", + ], + $this->config_key_base . 'COST' => [ + 'title' => 'Shipping Cost', + 'value' => '5.00', + 'desc' => 'The shipping cost for all orders using this shipping method.', + ], + $this->config_key_base . 'TAX_CLASS' => [ + 'title' => 'Tax Class', + 'value' => '0', + 'desc' => 'Use the following tax class on the shipping fee.', + 'use_func' => 'tep_get_tax_class_title', + 'set_func' => 'tep_cfg_pull_down_tax_classes(', + ], + $this->config_key_base . 'ZONE' => [ + 'title' => 'Shipping Zone', + 'value' => '0', + 'desc' => 'If a zone is selected, only enable this shipping method for that zone.', + 'use_func' => 'tep_get_zone_class_title', + 'set_func' => 'tep_cfg_pull_down_zone_classes(', + ], + $this->config_key_base . 'SORT_ORDER' => [ + 'title' => 'Sort Order', + 'value' => '0', + 'desc' => 'Sort order of display.', + ], + ]; } - function install() { - tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Flat Shipping', 'MODULE_SHIPPING_FLAT_STATUS', 'True', 'Do you want to offer flat rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); - tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Cost', 'MODULE_SHIPPING_FLAT_COST', '5.00', 'The shipping cost for all orders using this shipping method.', '6', '0', now())"); - tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_FLAT_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())"); - tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_FLAT_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())"); - tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_FLAT_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())"); - } - - function remove() { - tep_db_query("delete from configuration where configuration_key in ('" . implode("', '", $this->keys()) . "')"); - } - - function keys() { - return array('MODULE_SHIPPING_FLAT_STATUS', 'MODULE_SHIPPING_FLAT_COST', 'MODULE_SHIPPING_FLAT_TAX_CLASS', 'MODULE_SHIPPING_FLAT_ZONE', 'MODULE_SHIPPING_FLAT_SORT_ORDER'); - } } -?> diff --git a/includes/modules/shipping/item.php b/includes/modules/shipping/item.php index 15307012d..7e58f4ec4 100644 --- a/includes/modules/shipping/item.php +++ b/includes/modules/shipping/item.php @@ -5,122 +5,102 @@ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com - Copyright (c) 2008 osCommerce + Copyright (c) 2020 osCommerce Released under the GNU General Public License */ - class item { - var $code, $title, $description, $icon, $enabled; + class item extends abstract_shipping_module { -// class constructor - function __construct() { - global $order; - - $this->code = 'item'; - $this->title = MODULE_SHIPPING_ITEM_TEXT_TITLE; - $this->description = MODULE_SHIPPING_ITEM_TEXT_DESCRIPTION; - - if ( defined('MODULE_SHIPPING_ITEM_STATUS') ) { - $this->sort_order = MODULE_SHIPPING_ITEM_SORT_ORDER; - $this->icon = ''; - $this->tax_class = MODULE_SHIPPING_ITEM_TAX_CLASS; - $this->enabled = ((MODULE_SHIPPING_ITEM_STATUS == 'True') ? true : false); - } - - $delivery_country_id = $order->delivery['country']['id'] ?? STORE_COUNTRY ?? 0; - $delivery_zone_id = $order->delivery['zone_id'] ?? STORE_ZONE ?? 0; - - if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_ITEM_ZONE > 0) ) { - $check_flag = false; - $check_query = tep_db_query("select zone_id from zones_to_geo_zones where geo_zone_id = '" . MODULE_SHIPPING_ITEM_ZONE . "' and zone_country_id = '" . $delivery_country_id . "' order by zone_id"); - while ($check = tep_db_fetch_array($check_query)) { - if ($check['zone_id'] < 1) { - $check_flag = true; - break; - } elseif ($check['zone_id'] == $delivery_zone_id) { - $check_flag = true; - break; - } - } - - if ($check_flag == false) { - $this->enabled = false; - } - } - } + const CONFIG_KEY_BASE = 'MODULE_SHIPPING_ITEM_'; // class methods - function quote($method = '') { - global $order; - - $number_of_items = $this->getNumberOfItems(); - - $this->quotes = array('id' => $this->code, - 'module' => MODULE_SHIPPING_ITEM_TEXT_TITLE, - 'methods' => array(array('id' => $this->code, - 'title' => MODULE_SHIPPING_ITEM_TEXT_WAY, - 'cost' => (MODULE_SHIPPING_ITEM_COST * $number_of_items) + MODULE_SHIPPING_ITEM_HANDLING))); - - if ($this->tax_class > 0) { - $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); - } - - if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, htmlspecialchars($this->title)); + public function quote($method = '') { + $this->quotes = [ + 'id' => $this->code, + 'module' => MODULE_SHIPPING_ITEM_TEXT_TITLE, + 'methods' => [[ + 'id' => $this->code, + 'title' => MODULE_SHIPPING_ITEM_TEXT_WAY, + 'cost' => ($this->base_constant('COST') * $this->count_items()) + $this->calculate_handling(), + ]], + ]; + + $this->quote_common(); return $this->quotes; } - function check() { - if (!isset($this->_check)) { - $check_query = tep_db_query("select configuration_value from configuration where configuration_key = 'MODULE_SHIPPING_ITEM_STATUS'"); - $this->_check = tep_db_num_rows($check_query); - } - return $this->_check; - } - - function install() { - tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Item Shipping', 'MODULE_SHIPPING_ITEM_STATUS', 'True', 'Do you want to offer per item rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); - tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Cost', 'MODULE_SHIPPING_ITEM_COST', '2.50', 'The shipping cost will be multiplied by the number of items in an order that uses this shipping method.', '6', '0', now())"); - tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_ITEM_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())"); - tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_ITEM_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())"); - tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_ITEM_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())"); - tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_ITEM_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())"); - } - - function remove() { - tep_db_query("delete from configuration where configuration_key in ('" . implode("', '", $this->keys()) . "')"); - } - - function keys() { - return array('MODULE_SHIPPING_ITEM_STATUS', 'MODULE_SHIPPING_ITEM_COST', 'MODULE_SHIPPING_ITEM_HANDLING', 'MODULE_SHIPPING_ITEM_TAX_CLASS', 'MODULE_SHIPPING_ITEM_ZONE', 'MODULE_SHIPPING_ITEM_SORT_ORDER'); + protected function get_parameters() { + return [ + $this->config_key_base . 'STATUS' => [ + 'title' => 'Enable Item Shipping', + 'value' => 'True', + 'desc' => 'Do you want to offer per item rate shipping?', + 'set_func' => "tep_cfg_select_option(['True', 'False'], ", + ], + $this->config_key_base . 'COST' => [ + 'title' => 'Shipping Cost', + 'value' => '2.50', + 'desc' => 'The shipping cost will be multiplied by the number of items in an order that uses this shipping method.', + ], + $this->config_key_base . 'HANDLING' => [ + 'title' => 'Handling Fee', + 'value' => '0', + 'desc' => 'Handling fee for this shipping method.', + ], + $this->config_key_base . 'TAX_CLASS' => [ + 'title' => 'Tax Class', + 'value' => '0', + 'desc' => 'Use the following tax class on the shipping fee.', + 'use_func' => 'tep_get_tax_class_title', + 'set_func' => 'tep_cfg_pull_down_tax_classes(', + ], + $this->config_key_base . 'ZONE' => [ + 'title' => 'Shipping Zone', + 'value' => '0', + 'desc' => 'If a zone is selected, only enable this shipping method for that zone.', + 'use_func' => 'tep_get_zone_class_title', + 'set_func' => 'tep_cfg_pull_down_zone_classes(', + ], + $this->config_key_base . 'SORT_ORDER' => [ + 'title' => 'Sort Order', + 'value' => '0', + 'desc' => 'Sort order of display.', + ], + ]; } - function getNumberOfItems() { - global $order, $total_count; - - $number_of_items = $total_count; - - if ($order->content_type == 'mixed') { - $number_of_items = 0; - - for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { - $number_of_items += $order->products[$i]['qty']; - - if (isset($order->products[$i]['attributes'])) { - foreach($order->products[$i]['attributes'] as $option => $value) { - $virtual_check_query = tep_db_query("select count(*) as total from products_attributes pa, products_attributes_download pad where pa.products_id = '" . (int)$order->products[$i]['id'] . "' and pa.options_values_id = '" . (int)$value['value_id'] . "' and pa.products_attributes_id = pad.products_attributes_id"); - $virtual_check = tep_db_fetch_array($virtual_check_query); + protected function count_items() { + global $order; - if ($virtual_check['total'] > 0) { - $number_of_items -= $order->products[$i]['qty']; - } + $item_count = ('physical' === $order->content_type) ? $GLOBALS['total_count'] : 0; + + if ('mixed' === $order->content_type) { + foreach ($order->products as $product) { + foreach (($product['attributes'] ?? []) as $option => $value) { + $virtual_check_query = tep_db_query(sprintf(<<<'EOSQL' +SELECT COUNT(*) AS total + FROM products_attributes pa INNER JOIN products_attributes_download pad + ON pa.products_attributes_id = pad.products_attributes_id + WHERE pa.products_id = %d AND pa.options_values_id = %d +EOSQL + , (int)$product['id'], (int)$value['value_id'])); + $virtual_check = tep_db_fetch_array($virtual_check_query); + + if ($virtual_check['total'] > 0) { + // if any attribute is downloadable, the product is virtual + // and doesn't count; so skip to the next product + // without adding the product quantity + continue 2; } } + + $item_count += $product['qty']; } } - return $number_of_items; + return $item_count; } + } -?> diff --git a/includes/modules/shipping/table.php b/includes/modules/shipping/table.php index 41069f723..8cb9593e9 100644 --- a/includes/modules/shipping/table.php +++ b/includes/modules/shipping/table.php @@ -10,54 +10,25 @@ Released under the GNU General Public License */ - class table extends abstract_module { + class table extends abstract_shipping_module { const CONFIG_KEY_BASE = 'MODULE_SHIPPING_TABLE_'; - public $icon; - -// class constructor - function __construct() { - global $order; - - parent::__construct(); - - if ( $this->enabled ) { - $this->icon = ''; - $this->tax_class = MODULE_SHIPPING_TABLE_TAX_CLASS; - - if ( ((int)MODULE_SHIPPING_TABLE_ZONE > 0) ) { - $delivery_country_id = $order->delivery['country']['id'] ?? STORE_COUNTRY ?? 0; - $delivery_zone_id = $order->delivery['zone_id'] ?? STORE_ZONE ?? 0; - - $check_query = tep_db_query(sprintf(<<<'EOSQL' -SELECT zone_id - FROM zones_to_geo_zones - WHERE geo_zone_id = %d AND zone_country_id = %d - ORDER BY zone_id -EOSQL - , (int)MODULE_SHIPPING_TABLE_ZONE, (int)$delivery_country_id)); - while ($check = tep_db_fetch_array($check_query)) { - if ( ($check['zone_id'] < 1) || ($check['zone_id'] == $delivery_zone_id) ) { - $this->enabled = false; - break; - } - } - } - } - } - // class methods - function quote($method = '') { - global $order, $shipping_weight, $shipping_num_boxes; - - if (MODULE_SHIPPING_TABLE_MODE == 'price') { - $order_total = $this->getShippableTotal(); - } else { - $order_total = $shipping_weight; + public function quote($method = '') { + switch ($this->base_constant('MODE') ) { + case 'price': + $order_total = $this->get_shippable_total(); + break; + case 'weight': + $order_total = $GLOBALS['shipping_weight']; + break; + case 'quantity': + $order_total = $this->count_items(); + break; } - $table_cost = preg_split("/[:,]/" , MODULE_SHIPPING_TABLE_COST); + $table_cost = preg_split("/[:,]/" , $this->base_constant('COST')); for ($i = 0, $n = count($table_cost); $i < $n; $i += 2) { if ($order_total <= $table_cost[$i]) { $shipping = $table_cost[$i+1]; @@ -65,8 +36,8 @@ function quote($method = '') { } } - if (MODULE_SHIPPING_TABLE_MODE == 'weight') { - $shipping = $shipping * $shipping_num_boxes; + if ('weight' === $this->base_constant('MODE')) { + $shipping *= $GLOBALS['shipping_num_boxes']; } $this->quotes = [ @@ -75,58 +46,54 @@ function quote($method = '') { 'methods' => [[ 'id' => $this->code, 'title' => MODULE_SHIPPING_TABLE_TEXT_WAY, - 'cost' => $shipping + MODULE_SHIPPING_TABLE_HANDLING, + 'cost' => $shipping + $this->calculate_handling(), ]], ]; - if ($this->tax_class > 0) { - $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); - } - - if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, htmlspecialchars($this->title)); + $this->quote_common(); return $this->quotes; } protected function get_parameters() { return [ - 'MODULE_SHIPPING_TABLE_STATUS' => [ + $this->config_key_base . 'STATUS' => [ 'title' => 'Enable Table Method', 'value' => 'True', 'desc' => 'Do you want to offer table rate shipping?', 'set_func' => "tep_cfg_select_option(['True', 'False'], ", ], - 'MODULE_SHIPPING_TABLE_COST' => [ + $this->config_key_base . 'COST' => [ 'title' => 'Shipping Table', 'value' => '25:8.50,50:5.50,10000:0.00', 'desc' => 'The shipping cost is based on the total cost or weight of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc', ], - 'MODULE_SHIPPING_TABLE_MODE' => [ + $this->config_key_base . 'MODE' => [ 'title' => 'Table Method', 'value' => 'weight', 'desc' => 'The shipping cost is based on the order total or the total weight of the items ordered.', - 'set_func' => "tep_cfg_select_option(['weight', 'price'], ", + 'set_func' => "tep_cfg_select_option(['weight', 'price', 'quantity'], ", ], - 'MODULE_SHIPPING_TABLE_HANDLING' => [ + $this->config_key_base . 'HANDLING' => [ 'title' => 'Handling Fee', 'value' => '0', 'desc' => 'Handling fee for this shipping method.', ], - 'MODULE_SHIPPING_TABLE_TAX_CLASS' => [ + $this->config_key_base . 'TAX_CLASS' => [ 'title' => 'Tax Class', 'value' => '0', 'desc' => 'Use the following tax class on the shipping fee.', 'use_func' => 'tep_get_tax_class_title', 'set_func' => 'tep_cfg_pull_down_tax_classes(', ], - 'MODULE_SHIPPING_TABLE_ZONE' => [ + $this->config_key_base . 'ZONE' => [ 'title' => 'Shipping Zone', 'value' => '0', 'desc' => 'If a zone is selected, only enable this shipping method for that zone.', 'use_func' => 'tep_get_zone_class_title', 'set_func' => 'tep_cfg_pull_down_zone_classes(', ], - 'MODULE_SHIPPING_TABLE_SORT_ORDER' => [ + $this->config_key_base . 'SORT_ORDER' => [ 'title' => 'Sort Order', 'value' => '0', 'desc' => 'Sort order of display.', @@ -134,17 +101,13 @@ protected function get_parameters() { ]; } - function getShippableTotal() { + protected function get_shippable_total() { global $order, $currencies; - $order_total = $_SESSION['cart']->show_total(); + $order_total = (('physical' === $order->content_type) ? $_SESSION['cart']->show_total() : 0); if ('mixed' === $order->content_type) { - $order_total = 0; - foreach ($order->products as $product) { - $order_total += $currencies->calculate_price($product['final_price'], $product['tax'], $product['qty']); - foreach (($product['attributes'] ?? []) as $option => $value) { $virtual_check_query = tep_db_query(sprintf(<<<'EOSQL' SELECT COUNT(*) AS total @@ -157,13 +120,50 @@ function getShippableTotal() { $virtual_check = tep_db_fetch_array($virtual_check_query); if ($virtual_check['total'] > 0) { - $order_total -= $currencies->calculate_price($product['final_price'], $product['tax'], $product['qty']); + // if any attribute is downloadable, the product is virtual + // and doesn't count; so skip to the next product + // without adding the product quantity + continue 2; } } + + $order_total += $currencies->calculate_price($product['final_price'], $product['tax'], $product['qty']); } } return $order_total; } + function count_items() { + global $order; + + $item_count = ('physical' === $order->content_type) ? $GLOBALS['total_count'] : 0; + + if ('mixed' === $order->content_type) { + foreach ($order->products as $product) { + foreach (($product['attributes'] ?? []) as $option => $value) { + $virtual_check_query = tep_db_query(sprintf(<<<'EOSQL' +SELECT COUNT(*) AS total + FROM products_attributes pa INNER JOIN products_attributes_download pad + ON pa.products_attributes_id = pad.products_attributes_id + WHERE pa.products_id = %d AND pa.options_values_id = %d +EOSQL + , (int)$product['id'], (int)$value['value_id'])); + $virtual_check = tep_db_fetch_array($virtual_check_query); + + if ($virtual_check['total'] > 0) { + // if any attribute is downloadable, the product is virtual + // and doesn't count; so skip to the next product + // without adding the product quantity + continue 2; + } + } + + $item_count += $product['qty']; + } + } + + return $item_count; + } + } diff --git a/includes/modules/shipping/zones.php b/includes/modules/shipping/zones.php index dc4787588..635cc4118 100644 --- a/includes/modules/shipping/zones.php +++ b/includes/modules/shipping/zones.php @@ -6,23 +6,23 @@ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com - Copyright (c) 2003 osCommerce + Copyright (c) 2020 osCommerce Released under the GNU General Public License USAGE By default, the module comes with support for 1 zone. This can be - easily changed by editing the line below in the zones constructor - that defines $this->num_zones. + easily changed by editing the line below in the zones constructor + that defines static::ZONE_COUNT. Next, you will want to activate the module by going to the Admin screen, clicking on Modules, then clicking on Shipping. A list of all shipping - modules should appear. Click on the green dot next to the one labeled + modules should appear. Click on the green dot next to the one labeled zones.php. A list of settings will appear to the right. Click on the - Edit button. + Edit button. - PLEASE NOTE THAT YOU WILL LOSE YOUR CURRENT SHIPPING RATES AND OTHER - SETTINGS IF YOU TURN OFF THIS SHIPPING METHOD. Make sure you keep a + PLEASE NOTE THAT YOU WILL LOSE YOUR CURRENT SHIPPING RATES AND OTHER + SETTINGS IF YOU TURN OFF THIS SHIPPING METHOD. Make sure you keep a backup of your shipping settings somewhere at all times. If you want an additional handling charge applied to orders that use this @@ -31,7 +31,7 @@ Next, you will need to define which countries are in each zone. Determining this might take some time and effort. You should group a set of countries that has similar shipping charges for the same weight. For instance, when - shipping from the US, the countries of Japan, Australia, New Zealand, and + shipping from the US, the countries of Japan, Australia, New Zealand, and Singapore have similar shipping rates. As an example, one of my customers is using this set of zones: 1: USA @@ -56,11 +56,11 @@ some time and effort will go into setting the appropriate rates. You will define a set of weight ranges and the shipping price for each range. For instance, you might want an order than weighs more than 0 - and less than or equal to 3 to cost 5.50 to ship to a certain zone. + and less than or equal to 3 to cost 5.50 to ship to a certain zone. This would be defined by this: 3:5.5 You should combine a bunch of these rates together in a comma delimited - list and enter them into the "Zone X Shipping Table" fields where "X" + list and enter them into the "Zone X Shipping Table" fields where "X" is the zone number. For example, this might be used for Zone 1: 1:3.5,2:3.95,3:5.2,4:6.45,5:7.7,6:10.4,7:11.85, 8:13.3,9:14.75,10:16.2,11:17.65, 12:19.1,13:20.55,14:22,15:23.45 @@ -73,139 +73,133 @@ At this time, it does not deal with weights that are above the highest amount defined. This will probably be the next area to be improved with the module. For now, you could have one last very high range with a very - high shipping rate to discourage orders of that magnitude. For + high shipping rate to discourage orders of that magnitude. For instance: 999:1000 - If you want to be able to ship to any country in the world, you will + If you want to be able to ship to any country in the world, you will need to enter every country code into the Country fields. For most - shops, you will not want to enter every country. This is often + shops, you will not want to enter every country. This is often because of too much fraud from certain places. If a country is not listed, then the module will add a $0.00 shipping charge and will - indicate that shipping is not available to that destination. + indicate that shipping is not available to that destination. PLEASE NOTE THAT THE ORDER CAN STILL BE COMPLETED AND PROCESSED! - It appears that the osC shipping system automatically rounds the + It appears that the osC shipping system automatically rounds the shipping weight up to the nearest whole unit. This makes it more - difficult to design precise shipping tables. If you want to, you + difficult to design precise shipping tables. If you want to, you can hack the shipping.php file to get rid of the rounding. */ - class zones { - var $code, $title, $description, $enabled, $num_zones; - -// class constructor - function __construct() { - $this->code = 'zones'; - $this->title = MODULE_SHIPPING_ZONES_TEXT_TITLE; - $this->description = MODULE_SHIPPING_ZONES_TEXT_DESCRIPTION; - - if ( defined('MODULE_SHIPPING_ZONES_STATUS') ) { - $this->sort_order = MODULE_SHIPPING_ZONES_SORT_ORDER; - $this->icon = ''; - $this->tax_class = MODULE_SHIPPING_ZONES_TAX_CLASS; - $this->enabled = ((MODULE_SHIPPING_ZONES_STATUS == 'True') ? true : false); - } + class zones extends abstract_shipping_module { - // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED - $this->num_zones = 1; - } + const CONFIG_KEY_BASE = 'MODULE_SHIPPING_ZONES_'; + + // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED + const ZONE_COUNT = 1; // class methods - function quote($method = '') { + public function quote($method = '') { global $order, $shipping_weight, $shipping_num_boxes; - $dest_country = $order->delivery['country']['iso_code_2']; - $dest_zone = 0; + $dest_zone = false; $error = false; - for ($i=1; $i<=$this->num_zones; $i++) { - $countries_table = constant('MODULE_SHIPPING_ZONES_COUNTRIES_' . $i); - $country_zones = preg_split("/[,]/", $countries_table); - if (in_array($dest_country, $country_zones)) { + for ($i = 1; $i <= static::ZONE_COUNT; $i++) { + if (in_array($order->delivery['country']['iso_code_2'], explode(';', $this->base_constant('COUNTRIES_' . $i)))) { $dest_zone = $i; break; } } - if ($dest_zone == 0) { + if (false === $dest_zone) { $error = true; } else { - $shipping = -1; - $zones_cost = constant('MODULE_SHIPPING_ZONES_COST_' . $dest_zone); + $shipping = false; + $zones_cost = $this->base_constant('COST_' . $dest_zone); - $zones_table = preg_split("/[:,]/" , $zones_cost); - $size = sizeof($zones_table); - for ($i=0; $i<$size; $i+=2) { + $zones_table = preg_split('/[:,]/' , $zones_cost); + for ($i = 0, $size = count($zones_table); $i < $size; $i += 2) { if ($shipping_weight <= $zones_table[$i]) { $shipping = $zones_table[$i+1]; - $shipping_method = MODULE_SHIPPING_ZONES_TEXT_WAY . ' ' . $dest_country . ' : ' . $shipping_weight . ' ' . MODULE_SHIPPING_ZONES_TEXT_UNITS; + $shipping_method = MODULE_SHIPPING_ZONES_TEXT_WAY + . ' ' . $order->delivery['country']['iso_code_2'] + . ' : ' . $shipping_weight + . ' ' . MODULE_SHIPPING_ZONES_TEXT_UNITS; break; } } - if ($shipping == -1) { + if (false === $shipping) { $shipping_cost = 0; $shipping_method = MODULE_SHIPPING_ZONES_UNDEFINED_RATE; } else { - $shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_ZONES_HANDLING_' . $dest_zone); + $shipping_cost = ($shipping * $shipping_num_boxes) + $this->base_constant('HANDLING_' . $dest_zone); } } - $this->quotes = array('id' => $this->code, - 'module' => MODULE_SHIPPING_ZONES_TEXT_TITLE, - 'methods' => array(array('id' => $this->code, - 'title' => $shipping_method, - 'cost' => $shipping_cost))); - - if ($this->tax_class > 0) { - $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); - } + $this->quotes = [ + 'id' => $this->code, + 'module' => MODULE_SHIPPING_ZONES_TEXT_TITLE, + 'methods' => [[ + 'id' => $this->code, + 'title' => $shipping_method, + 'cost' => $shipping_cost, + ]], + ]; - if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, htmlspecialchars($this->title)); + $this->quote_common(); - if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_ZONES_INVALID_ZONE; + if ($error) { + $this->quotes['error'] = MODULE_SHIPPING_ZONES_INVALID_ZONE; + } return $this->quotes; } - function check() { - if (!isset($this->_check)) { - $check_query = tep_db_query("select configuration_value from configuration where configuration_key = 'MODULE_SHIPPING_ZONES_STATUS'"); - $this->_check = tep_db_num_rows($check_query); - } - return $this->_check; - } - - function install() { - tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Zones Method', 'MODULE_SHIPPING_ZONES_STATUS', 'True', 'Do you want to offer zone rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); - tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_ZONES_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())"); - tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_ZONES_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())"); - for ($i = 1; $i <= $this->num_zones; $i++) { - $default_countries = ''; - if ($i == 1) { - $default_countries = 'US,CA'; - } - tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone " . $i ." Countries', 'MODULE_SHIPPING_ZONES_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $i . ".', '6', '0', now())"); - tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone " . $i ." Shipping Table', 'MODULE_SHIPPING_ZONES_COST_" . $i ."', '3:8.50,7:10.50,99:20.00', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.', '6', '0', now())"); - tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone " . $i ." Handling Fee', 'MODULE_SHIPPING_ZONES_HANDLING_" . $i."', '0', 'Handling Fee for this shipping zone', '6', '0', now())"); + protected function get_parameters() { + $parameters = [ + $this->config_key_base . 'STATUS' => [ + 'title' => 'Enable Zones Method', + 'value' => 'True', + 'desc' => 'Do you want to offer zone rate shipping?', + 'set_func' => "tep_cfg_select_option(['True', 'False'], ", + ], + $this->config_key_base . 'TAX_CLASS' => [ + 'title' => 'Tax Class', + 'value' => '0', + 'desc' => 'Use the following tax class on the shipping fee.', + 'use_func' => 'tep_get_tax_class_title', + 'set_func' => 'tep_cfg_pull_down_tax_classes(', + ], + $this->config_key_base . 'SORT_ORDER' => [ + 'title' => 'Sort Order', + 'value' => '0', + 'desc' => 'Sort order of display.', + ], + ]; + + for ($i = 1; $i <= static::ZONE_COUNT; $i++) { + $keys = array_merge($keys, [ + $this->config_key_base . 'COUNTRIES_' . $i => [ + 'title' => 'Zone ' . $i . ' Countries', + 'value' => (($i == 1) ? 'US;CA' : ''), + 'desc' => 'Semi-colon separated list of two character ISO country codes that are part of Zone ' . $i . '.', + ], + $this->config_key_base . 'COST_' . $i => [ + 'title' => 'Zone ' . $i . ' Shipping Table', + 'value' => '3:8.50,7:10.50,99:20.00', + 'desc' => 'Shipping rates to Zone ' . $i . ' destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Zone ' . $i . ' destinations.', + ], + $this->config_key_base . 'HANDLING_' . $i => [ + 'title' => 'Zone ' . $i . ' Handling Fee', + 'value' => '0', + 'desc' => 'Handling Fee for this shipping zone', + ], + ]); + + return $parameters; } } - function remove() { - tep_db_query("delete from configuration where configuration_key in ('" . implode("', '", $this->keys()) . "')"); - } - - function keys() { - $keys = array('MODULE_SHIPPING_ZONES_STATUS', 'MODULE_SHIPPING_ZONES_TAX_CLASS', 'MODULE_SHIPPING_ZONES_SORT_ORDER'); - - for ($i=1; $i<=$this->num_zones; $i++) { - $keys[] = 'MODULE_SHIPPING_ZONES_COUNTRIES_' . $i; - $keys[] = 'MODULE_SHIPPING_ZONES_COST_' . $i; - $keys[] = 'MODULE_SHIPPING_ZONES_HANDLING_' . $i; - } - - return $keys; - } } -?> From 3efd53836156982362af018c47226ada3a0d4faa Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sun, 7 Jun 2020 06:28:44 +0000 Subject: [PATCH 14/48] Remove admin autoload exceptions Some classes don't conform to the standard naming schemes. This removes one admin class entirely (so the catalog version will be used). And it renames one file so that the file and class names are compatible. Finally, it removes the admin autoload exception handling code as no longer needed. --- ...{action_recorder.php => action_recorder_admin.php} | 0 admin/includes/functions/autoloader.php | 11 ----------- 2 files changed, 11 deletions(-) rename admin/includes/classes/{action_recorder.php => action_recorder_admin.php} (100%) diff --git a/admin/includes/classes/action_recorder.php b/admin/includes/classes/action_recorder_admin.php similarity index 100% rename from admin/includes/classes/action_recorder.php rename to admin/includes/classes/action_recorder_admin.php diff --git a/admin/includes/functions/autoloader.php b/admin/includes/functions/autoloader.php index b914c2570..7beb9c96c 100644 --- a/admin/includes/functions/autoloader.php +++ b/admin/includes/functions/autoloader.php @@ -21,17 +21,6 @@ function tep_build_admin_autoload_index($modules_directory_length) { tep_find_all_files_under($overrides_directory, $class_files); } - // some classes do not follow either naming standard relating the class name and file name - $exception_mappings = [ - 'password_hash' => 'passwordhash', - 'action_recorder_admin' => 'action_recorder', - ]; - - foreach ($exception_mappings as $class_name => $filename) { - $class_files[$class_name] = $class_files[$filename]; - unset($class_files[$filename]); - } - return $class_files; } From fbcaf05572c824a4c9e73e201b77479fb3f187ac Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sun, 7 Jun 2020 06:38:07 +0000 Subject: [PATCH 15/48] Use autoloader and simplify logic --- .../classes/action_recorder_admin.php | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/admin/includes/classes/action_recorder_admin.php b/admin/includes/classes/action_recorder_admin.php index f962ff472..088fd178e 100644 --- a/admin/includes/classes/action_recorder_admin.php +++ b/admin/includes/classes/action_recorder_admin.php @@ -5,33 +5,22 @@ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com - Copyright (c) 2010 osCommerce + Copyright (c) 2020 osCommerce Released under the GNU General Public License */ - require(DIR_FS_CATALOG . 'includes/classes/action_recorder.php'); - class actionRecorderAdmin extends actionRecorder { - function __construct($module, $user_id = null, $user_name = null) { - global $language, $PHP_SELF; + function __construct($module, $user_id = null, $user_name = null) { $module = tep_sanitize_string(str_replace(' ', '', $module)); - if (defined('MODULE_ACTION_RECORDER_INSTALLED') && tep_not_null(MODULE_ACTION_RECORDER_INSTALLED)) { - if (tep_not_null($module) && in_array($module . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), explode(';', MODULE_ACTION_RECORDER_INSTALLED))) { - if (!class_exists($module)) { - if (file_exists(DIR_FS_CATALOG . 'includes/modules/action_recorder/' . $module . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)))) { - include(DIR_FS_CATALOG . 'includes/languages/' . $language . '/modules/action_recorder/' . $module . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1))); - include(DIR_FS_CATALOG . 'includes/modules/action_recorder/' . $module . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1))); - } else { - return false; - } - } - } else { - return false; - } - } else { + if (!defined('MODULE_ACTION_RECORDER_INSTALLED') + || !tep_not_null(MODULE_ACTION_RECORDER_INSTALLED) + || !tep_not_null($module) + || !in_array("$module.php", explode(';', MODULE_ACTION_RECORDER_INSTALLED)) + || !class_exists($module)) + { return false; } @@ -48,5 +37,5 @@ function __construct($module, $user_id = null, $user_name = null) { $GLOBALS[$this->_module] = new $module(); $GLOBALS[$this->_module]->setIdentifier(); } + } -?> From 021ad6ce148d7740b2a62cbfa9ffa8bf1f2516ab Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sun, 7 Jun 2020 07:21:51 +0000 Subject: [PATCH 16/48] Move MailChimp to apps --- .../ht_mailchimp_360 => apps/mailchimp_360}/MCAPI.class.php | 0 .../ht_mailchimp_360 => apps/mailchimp_360}/mc360.php | 0 includes/modules/header_tags/ht_mailchimp_360.php | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) rename includes/{modules/header_tags/ht_mailchimp_360 => apps/mailchimp_360}/MCAPI.class.php (100%) rename includes/{modules/header_tags/ht_mailchimp_360 => apps/mailchimp_360}/mc360.php (100%) diff --git a/includes/modules/header_tags/ht_mailchimp_360/MCAPI.class.php b/includes/apps/mailchimp_360/MCAPI.class.php similarity index 100% rename from includes/modules/header_tags/ht_mailchimp_360/MCAPI.class.php rename to includes/apps/mailchimp_360/MCAPI.class.php diff --git a/includes/modules/header_tags/ht_mailchimp_360/mc360.php b/includes/apps/mailchimp_360/mc360.php similarity index 100% rename from includes/modules/header_tags/ht_mailchimp_360/mc360.php rename to includes/apps/mailchimp_360/mc360.php diff --git a/includes/modules/header_tags/ht_mailchimp_360.php b/includes/modules/header_tags/ht_mailchimp_360.php index 2dba7bf40..b5d51fe96 100644 --- a/includes/modules/header_tags/ht_mailchimp_360.php +++ b/includes/modules/header_tags/ht_mailchimp_360.php @@ -31,8 +31,8 @@ function __construct() { function execute() { global $PHP_SELF; - include('includes/modules/header_tags/ht_mailchimp_360/MCAPI.class.php'); - include('includes/modules/header_tags/ht_mailchimp_360/mc360.php'); + include('includes/apps/mailchimp_360/MCAPI.class.php'); + include('includes/apps/mailchimp_360/mc360.php'); $mc360 = new mc360(); $mc360->set_cookies(); From b7705a352a018ef2ef8238da703106f2bd4190fe Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sun, 7 Jun 2020 07:27:33 +0000 Subject: [PATCH 17/48] Remove catalog autoload exceptions Renames two files to match what the autoloader expects and removes a third that is loaded manually anyway. This leaves only one exception. The remainging exception will be fixed as part of a larger rationalization of the naming scheme. Waiting on the design of that system. --- includes/classes/{alertbox.php => alert_block.php} | 0 includes/classes/{passwordhash.php => password_hash.php} | 0 includes/functions/autoloader.php | 3 --- 3 files changed, 3 deletions(-) rename includes/classes/{alertbox.php => alert_block.php} (100%) rename includes/classes/{passwordhash.php => password_hash.php} (100%) diff --git a/includes/classes/alertbox.php b/includes/classes/alert_block.php similarity index 100% rename from includes/classes/alertbox.php rename to includes/classes/alert_block.php diff --git a/includes/classes/passwordhash.php b/includes/classes/password_hash.php similarity index 100% rename from includes/classes/passwordhash.php rename to includes/classes/password_hash.php diff --git a/includes/functions/autoloader.php b/includes/functions/autoloader.php index bcd5d6483..1351461e9 100644 --- a/includes/functions/autoloader.php +++ b/includes/functions/autoloader.php @@ -96,10 +96,7 @@ function tep_build_catalog_autoload_index() { // some classes do not follow either naming standard relating the class name and file name $exception_mappings = [ - 'alert_block' => 'alertbox', 'os_c__actions' => 'actions', - 'm_c_a_p_i' => 'MCAPI.class', - 'password_hash' => 'passwordhash', ]; foreach ($exception_mappings as $class_name => $path) { From 5a1df58863370dac8d81844663eed8cea078bb24 Mon Sep 17 00:00:00 2001 From: gburton Date: Sun, 7 Jun 2020 12:50:37 +0100 Subject: [PATCH 18/48] Fix repeated values. https://github.com/gburton/CE-Phoenix/issues/981 TY @raiwa for reporting and TY @ecartz for fixing. --- admin/products_attributes.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/admin/products_attributes.php b/admin/products_attributes.php index 2ed142a43..2334edc7d 100644 --- a/admin/products_attributes.php +++ b/admin/products_attributes.php @@ -502,7 +502,15 @@

From 6336043f967757dfb8a671cc6cd97b74a2614a4a Mon Sep 17 00:00:00 2001 From: gburton Date: Sun, 7 Jun 2020 13:08:23 +0100 Subject: [PATCH 19/48] Update Readme --- README.md | 117 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 69 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index f98de3818..f9dda114f 100644 --- a/README.md +++ b/README.md @@ -1,78 +1,99 @@ -# CE Phoenix +

+ +

-CE Phoenix is a powerful ecommerce shop ready to use out of the box, putting you online and in full control of your business right from the start. +## Table of Contents -Your customers will love the modern, responsive design that will not only make your website look great on all mobile viewing devices but also perform at speed whilst giving you the power to create an individual and unique look to your shop with just a few clicks! +* [What is Phoenix](https://github.com/gburton/CE-Phoenix#phoenix) + - [Demo Site](https://github.com/gburton/CE-Phoenix#demo-site) +* [Installation](https://github.com/gburton/CE-Phoenix#installation) + - [User Checklist](https://github.com/gburton/CE-Phoenix#user-checklist) + - [Softaculous](https://github.com/gburton/CE-Phoenix#softaculous) + - [Language Packs](https://github.com/gburton/CE-Phoenix#other-languages) +* [Certified Service Providers](https://github.com/gburton/CE-Phoenix#certified-service-providers) +* [Supporting the Project](https://github.com/gburton/CE-Phoenix#support-the-project) + - [Join the Phoenix Club](https://github.com/gburton/CE-Phoenix#join-the-phoenix-club) +* [Credits](https://github.com/gburton/CE-Phoenix#image-credits) -CE Phoenix is packed with many first class utilities as standard but its modular software design lets you add many more with no programming skills required. The full suite of product, shipping and payment options included will let you sell thousands of products in any number of categories worldwide in any currency or language providing a seamless customer experience. +# Phoenix -![Phoenix Logo](https://raw.githubusercontent.com/gburton/Responsive-osCommerce/master/.github/ce-phoenix.png) +Phoenix is a powerful ecommerce shop ready to use out of the box, putting you online and in full control of your business right from the start. Your customers will love the modern, responsive design that will not only make your website look great on all mobile viewing devices but also perform at speed whilst giving you the power to create an individual and unique look to your shop with just a few clicks! -CE Phoenix is the official Community Version of osCommerce. Check out what you can do with CE Phoenix at the demo site; +Phoenix is packed with many first class utilities as standard but its modular software design lets you add many more with no programming skills required. The full suite of product, shipping and payment options included will let you sell thousands of products in any number of categories worldwide in any currency or language providing a seamless customer experience. -# Demo Sites +Phoenix is the official Community Version of osCommerce. -https://template.me.uk/index.php +## Demo Site -# Certified Service Providers +https://template.me.uk/phoenix/index.php -Name | URL | Services Offered ------------- | ------------- | ------------- -Rainer | https://www.oscaddons.com/index.php/en | Providing all kinds of support for CE Phoenix online stores. You will find Add-Ons which add functionality and features to your store. Completely free Add-Ons and a selection of commercial Add-Ons at very affordable prices exclusive to my website. On the other hand you can count on installation and programming services at very competitive prices. Visit my website and feel free to contact me - English, Deutsch and Español. -John | https://sewebsites.net/ | Custom jobs, big or small, including adapting existing addons to CE Phoenix. Integration of stock systems and new payment methods. Addons both free and great value, soon to be added to the site. +# Installation + +Installation of Phoenix takes no more than a few minutes - you will need a hosting account that supports PHP (programming language) and has at least one SQL database. Phoenix can even be installed on your home computer for testing purposes. + +## User Checklist + +- [x] read this README document +- [ ] download Phoenix & perform installation +- [ ] check security page in administrative area; + admin > tools > security checks +- [ ] join Phoenix club +- [ ] install modules; + admin > modules > navbar + admin > modules > content + admin > modules > boxes + admin > modules > shipping + admin > modules > payment +- [ ] perform a test checkout +- [ ] load your categories and products -### Support the Project +## Softaculous -If you or your employer is commercially dependent on Phoenix (or a previous incarnation), please help to sponsor continual forward movement in the code-base. Phoenix needs you as much as you need Phoenix! I am hopeful that all shopowners, developers, consultants and businesses will support the Project ... allowing two professional developers to work on the code on an ad-hoc basis. A Supporters subscription includes access to the current season of Supporters code as seen at the Supporters Demo shop; https://template.me.uk/supporters/index.php +
CE Phoenix can now be installed easily with just one click via [Softaculous](http://www.softaculous.com/apps/ecommerce/CE_Phoenix)

-### Join the Phoenix Club +## Language Packs -If you wish to help steer the future direction of the software please join the Phoenix Club -https://forums.oscommerce.com/clubs/1-phoenix/ +Language | URL | Credit & Thanks | Comments +------------ | ------------- | ------------- | ------------- +DE | https://apps.oscommerce.com/zXxXN&german-language-deutsches-sprachpaket&v=cephoenix10 | cupidare | +ES | https://github.com/raiwa/OSCOM-CE-Phoenix-Spanish-language-idioma-espanol | raiwa | Certified Developer +FR | https://apps.oscommerce.com/oqfJg&ce-phoenix-1-0-5-0-french-language-pack | artfulweb | +NL | https://apps.oscommerce.com/NShzV&vertaling-nederlands | Fiber | +NO | https://apps.oscommerce.com/ecntZ&norwegian-language-pack-phoenix | ra92 | +PT (BR) | https://apps.oscommerce.com/yLxsO&oscom2ce-phoenix-pt-brasil-v1-0-5-0 | josmar | Brazilian Portuguese +RU | https://apps.oscommerce.com/ub5yL&russian-for-phoenix | Fredi | Contains non-core files -# Thank You +Please be aware that language packs are maintained by volunteers so may not be up to date. -To all shopowners, developers, consultants and business owners who are supporting the Project. +# Certified Service Providers + +Name | URL | Services Offered +------------ | ------------- | ------------- +Rainer | https://www.oscaddons.com/index.php/en | Providing all kinds of support for CE Phoenix online stores. You will find Add-Ons which add functionality and features to your store. Completely free Add-Ons and a selection of commercial Add-Ons at very affordable prices exclusive to my website. On the other hand you can count on installation and programming services at very competitive prices. Visit my website and feel free to contact me - English, Deutsch and Español. +John | https://sewebsites.net/ | Custom jobs, big or small, including adapting existing addons to CE Phoenix. Integration of stock systems and new payment methods. Addons both free and great value, soon to be added to the site. -## External Libraries +# External Libraries https://github.com/gburton/Responsive-osCommerce/wiki/External-Libraries -### PHP Version +# PHP Version -Minimum | Maximum +Minimum | Maximum (tested) ------------ | ------------- 7.0 | 7.3 -### User Checklist +# Supporting the Project -- [x] read this README document -- [ ] download Phoenix & perform installation -- [ ] check security page in administrative area; - admin > tools > security checks -- [ ] join osCommerce forum -- [ ] join Phoenix club -- [ ] install one or more navbar modules; - admin > modules > navbar > {install} -- [ ] install one or more footer modules; - admin > modules > content > {install} -- [ ] install one or more box modules; - admin > modules > boxes > {install} -- [ ] install shipping module(s); - admin > modules > shipping -- [ ] install payment module(s); - admin > modules > payment -- [ ] perform a test checkout -- [ ] load your categories and products +Help Phoenix fly high...if you or your employer is commercially dependent on Phoenix (or a previous incarnation), please help to sponsor forward movement in the code-base. Phoenix needs you as much as you need Phoenix... -### Other Languages +Thank you to all shopowners, developers, consultants and business owners who are supporting the Project by volunteering their time and/or by supporting the project financially. -Language | URL | Credit & Thanks ------------- | ------------- | ------------- -German | https://github.com/cupidare/OsCommerce-CE-Phoenix-German-language-Deutsches-Sprachpaket | @cupidare -Spanish | https://github.com/raiwa/OSCOM-CE-Phoenix-Spanish-language-idioma-espanol | @raiwa +## Join the Phoenix Club + +If you wish to help steer the future direction of the software please join the Phoenix Club +https://forums.oscommerce.com/clubs/1-phoenix/ -### Image Credits +# Credits Images in the default installation are copyright their respective owners; From fd3730621c4533abde9891a1f03ce6aaff119ed9 Mon Sep 17 00:00:00 2001 From: gburton Date: Sun, 7 Jun 2020 13:10:49 +0100 Subject: [PATCH 20/48] Double Class https://github.com/gburton/CE-Phoenix/issues/975 TY @raiwa TY @ecartz --- admin/includes/functions/html_output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/includes/functions/html_output.php b/admin/includes/functions/html_output.php index c557c663c..3fd704444 100644 --- a/admin/includes/functions/html_output.php +++ b/admin/includes/functions/html_output.php @@ -222,7 +222,7 @@ function tep_draw_input_field($name, $value = '', $parameters = '', $type = 'tex } if (tep_not_null($parameters)) $field .= " $parameters"; - if (tep_not_null($class)) $field .= " $class"; + if (tep_not_null($class) && (false === strpos($parameters, 'class="'))) $field .= " $class"; $field .= ' />'; From 0b47ebc81931166246fbc06460cf1ca594bc3b3f Mon Sep 17 00:00:00 2001 From: gburton Date: Sun, 7 Jun 2020 14:19:03 +0100 Subject: [PATCH 21/48] Remove contentContainer div --- admin/customers.php | 6 +----- .../ext/modules/content/account/braintree/cards.php | 2 -- .../ext/modules/content/account/sage_pay/cards.php | 2 -- .../ext/modules/content/account/set_password.php | 3 --- .../includes/ext/modules/content/reviews/write.php | 4 ---- templates/default/includes/pages/account.php | 5 +---- templates/default/includes/pages/account_edit.php | 3 --- .../default/includes/pages/account_history.php | 3 --- .../default/includes/pages/account_history_info.php | 3 --- .../default/includes/pages/account_newsletters.php | 4 ---- .../includes/pages/account_notifications.php | 4 ---- .../default/includes/pages/account_password.php | 3 --- templates/default/includes/pages/address_book.php | 4 ---- .../default/includes/pages/address_book_process.php | 10 ---------- .../default/includes/pages/advanced_search.php | 4 ---- .../includes/pages/advanced_search_result.php | 3 --- .../includes/pages/checkout_confirmation.php | 3 --- .../default/includes/pages/checkout_payment.php | 7 +------ .../includes/pages/checkout_payment_address.php | 3 --- .../default/includes/pages/checkout_shipping.php | 3 --- .../includes/pages/checkout_shipping_address.php | 3 --- .../default/includes/pages/checkout_success.php | 2 -- templates/default/includes/pages/conditions.php | 2 -- templates/default/includes/pages/contact_us.php | 13 +++---------- templates/default/includes/pages/cookie_usage.php | 2 -- templates/default/includes/pages/create_account.php | 6 +----- .../includes/pages/create_account_success.php | 2 -- templates/default/includes/pages/gdpr.php | 2 -- templates/default/includes/pages/index.php | 4 ---- templates/default/includes/pages/login.php | 2 -- templates/default/includes/pages/logoff.php | 2 -- .../default/includes/pages/password_forgotten.php | 5 ----- templates/default/includes/pages/password_reset.php | 3 +-- templates/default/includes/pages/privacy.php | 2 -- templates/default/includes/pages/product_info.php | 4 ---- .../includes/pages/product_info_not_found.php | 4 ---- templates/default/includes/pages/shipping.php | 2 -- templates/default/includes/pages/ssl_check.php | 2 -- templates/default/includes/pages/testimonials.php | 2 -- 39 files changed, 8 insertions(+), 135 deletions(-) diff --git a/admin/customers.php b/admin/customers.php index 0190bddd7..d0e259529 100644 --- a/admin/customers.php +++ b/admin/customers.php @@ -109,10 +109,6 @@ - -
- get('address_id', $customer_details)); @@ -153,7 +149,7 @@ ?> -
+ diff --git a/templates/default/includes/ext/modules/content/account/braintree/cards.php b/templates/default/includes/ext/modules/content/account/braintree/cards.php index d8df9527c..e07d3c072 100644 --- a/templates/default/includes/ext/modules/content/account/braintree/cards.php +++ b/templates/default/includes/ext/modules/content/account/braintree/cards.php @@ -24,7 +24,6 @@ } ?> -

@@ -61,7 +60,6 @@
-
map_to_template('template_bottom.php', 'component'); diff --git a/templates/default/includes/ext/modules/content/account/sage_pay/cards.php b/templates/default/includes/ext/modules/content/account/sage_pay/cards.php index 595940510..8940f9fb4 100644 --- a/templates/default/includes/ext/modules/content/account/sage_pay/cards.php +++ b/templates/default/includes/ext/modules/content/account/sage_pay/cards.php @@ -24,7 +24,6 @@ } ?> -

@@ -61,7 +60,6 @@
-
map_to_template('template_bottom.php', 'component'); diff --git a/templates/default/includes/ext/modules/content/account/set_password.php b/templates/default/includes/ext/modules/content/account/set_password.php index 5923d34a8..3f1998304 100644 --- a/templates/default/includes/ext/modules/content/account/set_password.php +++ b/templates/default/includes/ext/modules/content/account/set_password.php @@ -26,7 +26,6 @@ echo tep_draw_form('account_password', tep_href_link('ext/modules/content/account/set_password.php', '', 'SSL'), 'post', '', true) . tep_draw_hidden_field('action', 'process'); ?> -

- - -
- @@ -76,8 +74,6 @@
- - -
-
getContent('account'); ?>
-
- +
getContent('account'); ?>
map_to_template('template_bottom.php', 'component'); diff --git a/templates/default/includes/pages/account_edit.php b/templates/default/includes/pages/account_edit.php index 0516837b5..d54b7bf1f 100644 --- a/templates/default/includes/pages/account_edit.php +++ b/templates/default/includes/pages/account_edit.php @@ -26,7 +26,6 @@ echo tep_draw_form('account_edit', tep_href_link('account_edit.php', '', 'SSL'), 'post', '', true) . tep_draw_hidden_field('action', 'process'); ?> -

- - -
- 0) { $history_query_raw = sprintf(<<<'EOSQL' @@ -90,7 +88,6 @@
-
map_to_template('template_bottom.php', 'component'); diff --git a/templates/default/includes/pages/account_history_info.php b/templates/default/includes/pages/account_history_info.php index a22491883..3a7bd992d 100644 --- a/templates/default/includes/pages/account_history_info.php +++ b/templates/default/includes/pages/account_history_info.php @@ -25,7 +25,6 @@ -
@@ -128,8 +127,6 @@ - - map_to_template('template_bottom.php', 'component'); ?> diff --git a/templates/default/includes/pages/account_newsletters.php b/templates/default/includes/pages/account_newsletters.php index c3a9df376..5f69b7328 100644 --- a/templates/default/includes/pages/account_newsletters.php +++ b/templates/default/includes/pages/account_newsletters.php @@ -20,8 +20,6 @@ -
-
@@ -37,8 +35,6 @@

-
- -
- @@ -80,8 +78,6 @@

-
- get('username'), 'readonly autocomplete="username"'); ?> -

- - -
-

@@ -80,8 +78,6 @@

-
- map_to_template('template_bottom.php', 'component'); ?> diff --git a/templates/default/includes/pages/address_book_process.php b/templates/default/includes/pages/address_book_process.php index c5bf753c9..deb246e4b 100644 --- a/templates/default/includes/pages/address_book_process.php +++ b/templates/default/includes/pages/address_book_process.php @@ -27,8 +27,6 @@ if (isset($_GET['delete'])) { ?> -
-
@@ -49,8 +47,6 @@

-
- -
- -map_to_template('address_book_details.php', 'component'); ?> @@ -74,8 +66,6 @@

-
- -
-
@@ -160,8 +158,6 @@ function check_form() {
-
- -
- @@ -29,7 +27,6 @@
-
map_to_template('template_bottom.php', 'component'); diff --git a/templates/default/includes/pages/checkout_confirmation.php b/templates/default/includes/pages/checkout_confirmation.php index 254f2833c..f24f35fa0 100644 --- a/templates/default/includes/pages/checkout_confirmation.php +++ b/templates/default/includes/pages/checkout_confirmation.php @@ -30,7 +30,6 @@ echo tep_draw_form('checkout_confirmation', $form_action_url, 'post'); ?> -
@@ -179,8 +178,6 @@ ?>
-
- - + - -get_error())) { echo '
' . "\n"; echo '

' . tep_output_string_protected($error['title']) . "

\n"; @@ -129,8 +126,6 @@
-
- -
-
@@ -91,7 +89,6 @@
-
map_to_template('template_bottom.php', 'component'); diff --git a/templates/default/includes/pages/checkout_shipping.php b/templates/default/includes/pages/checkout_shipping.php index 2c437fc54..0445f96d3 100644 --- a/templates/default/includes/pages/checkout_shipping.php +++ b/templates/default/includes/pages/checkout_shipping.php @@ -22,7 +22,6 @@ -
@@ -147,8 +146,6 @@ echo $OSCOM_Hooks->call('progress', 'progressBar', $parameters); ?> -
- -
-
@@ -88,7 +86,6 @@
-
map_to_template('template_bottom.php', 'component'); diff --git a/templates/default/includes/pages/checkout_success.php b/templates/default/includes/pages/checkout_success.php index 6cb99adf4..eb42099a7 100644 --- a/templates/default/includes/pages/checkout_success.php +++ b/templates/default/includes/pages/checkout_success.php @@ -20,11 +20,9 @@ echo tep_draw_form('order', tep_href_link('checkout_success.php', 'action=update', 'SSL'), 'post', ' role="form"'); ?> -
-
diff --git a/templates/default/includes/pages/conditions.php b/templates/default/includes/pages/conditions.php index f2abf4037..b1b24d5bd 100644 --- a/templates/default/includes/pages/conditions.php +++ b/templates/default/includes/pages/conditions.php @@ -17,13 +17,11 @@

-
-
map_to_template('template_bottom.php', 'component'); diff --git a/templates/default/includes/pages/contact_us.php b/templates/default/includes/pages/contact_us.php index 4118fe798..e0bd45a99 100644 --- a/templates/default/includes/pages/contact_us.php +++ b/templates/default/includes/pages/contact_us.php @@ -25,22 +25,17 @@ if (isset($_GET['action']) && ($_GET['action'] == 'success')) { ?> -
-
- - - -
- + echo tep_draw_form('contact_us', tep_href_link('contact_us.php', 'action=send'), 'post', '', true); + ?> +
getContent('contact_us'); ?>
@@ -85,8 +80,6 @@
- -
diff --git a/templates/default/includes/pages/cookie_usage.php b/templates/default/includes/pages/cookie_usage.php index e06d654a6..2ed974812 100644 --- a/templates/default/includes/pages/cookie_usage.php +++ b/templates/default/includes/pages/cookie_usage.php @@ -17,7 +17,6 @@

-
@@ -34,7 +33,6 @@
-
map_to_template('template_bottom.php', 'component'); diff --git a/templates/default/includes/pages/create_account.php b/templates/default/includes/pages/create_account.php index d7e597dfb..8030b2aa8 100644 --- a/templates/default/includes/pages/create_account.php +++ b/templates/default/includes/pages/create_account.php @@ -30,10 +30,8 @@
- + -
-
- map_to_template('template_top.php', 'component'); ?> -
-
map_to_template('template_bottom.php', 'component'); diff --git a/templates/default/includes/pages/gdpr.php b/templates/default/includes/pages/gdpr.php index 0cfc60809..de96bee4d 100644 --- a/templates/default/includes/pages/gdpr.php +++ b/templates/default/includes/pages/gdpr.php @@ -21,11 +21,9 @@

-
-
map_to_template('template_bottom.php', 'component'); diff --git a/templates/default/includes/pages/index.php b/templates/default/includes/pages/index.php index c0c1d03e7..ef18c123d 100644 --- a/templates/default/includes/pages/index.php +++ b/templates/default/includes/pages/index.php @@ -19,22 +19,18 @@ } ?> -
getContent('index_nested'); ?>
-
-
getContent('index_products'); ?>
-
-
-
map_to_template('template_bottom.php', 'component'); diff --git a/templates/default/includes/pages/logoff.php b/templates/default/includes/pages/logoff.php index 82d7e7d13..9cd263a2d 100644 --- a/templates/default/includes/pages/logoff.php +++ b/templates/default/includes/pages/logoff.php @@ -17,7 +17,6 @@

-
@@ -25,7 +24,6 @@
-
map_to_template('template_bottom.php', 'component'); diff --git a/templates/default/includes/pages/password_forgotten.php b/templates/default/includes/pages/password_forgotten.php index a1735362b..ebbb3216f 100644 --- a/templates/default/includes/pages/password_forgotten.php +++ b/templates/default/includes/pages/password_forgotten.php @@ -26,9 +26,7 @@ if ($password_reset_initiated == true) { ?> -
-
-

-
- -
+
-
-
-
map_to_template('template_bottom.php', 'component'); diff --git a/templates/default/includes/pages/product_info.php b/templates/default/includes/pages/product_info.php index a69836708..671dc412e 100644 --- a/templates/default/includes/pages/product_info.php +++ b/templates/default/includes/pages/product_info.php @@ -22,14 +22,10 @@ } ?> -
-
getContent('product_info'); ?>
-
- map_to_template('template_top.php', 'component'); ?> -
-
getContent('product_info_not_found'); ?>
-
- map_to_template('template_bottom.php', 'component'); ?> diff --git a/templates/default/includes/pages/shipping.php b/templates/default/includes/pages/shipping.php index 3665e8f00..5b8b70f71 100644 --- a/templates/default/includes/pages/shipping.php +++ b/templates/default/includes/pages/shipping.php @@ -17,13 +17,11 @@

-
-
map_to_template('template_bottom.php', 'component'); diff --git a/templates/default/includes/pages/ssl_check.php b/templates/default/includes/pages/ssl_check.php index ae3f17043..be44403d2 100644 --- a/templates/default/includes/pages/ssl_check.php +++ b/templates/default/includes/pages/ssl_check.php @@ -17,7 +17,6 @@

-
@@ -34,7 +33,6 @@
-
map_to_template('template_bottom.php', 'component'); diff --git a/templates/default/includes/pages/testimonials.php b/templates/default/includes/pages/testimonials.php index 1d7f6310e..a5b7a6860 100644 --- a/templates/default/includes/pages/testimonials.php +++ b/templates/default/includes/pages/testimonials.php @@ -17,11 +17,9 @@ require $oscTemplate->map_to_template('template_top.php', 'component'); ?> -
-
map_to_template('template_bottom.php', 'component'); From 7f203d4750da8d356d73993bfa9cf372ac1402bc Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Mon, 8 Jun 2020 07:25:01 +0000 Subject: [PATCH 22/48] Fix path to match new location --- install/includes/functions/general.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/install/includes/functions/general.php b/install/includes/functions/general.php index efb08e3dd..9c0677b3f 100644 --- a/install/includes/functions/general.php +++ b/install/includes/functions/general.php @@ -38,7 +38,7 @@ function osc_realpath($directory) { // password. function osc_encrypt_password($plain) { if (!class_exists('PasswordHash')) { - include('../includes/classes/passwordhash.php'); + require '../includes/classes/password_hash.php'; } $hasher = new PasswordHash(10, true); @@ -94,4 +94,3 @@ function osc_output_string($string, $translate = false, $protected = false) { } } } -?> From 692f3ace17d608756fd61cdae5749d0a84b3fab3 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Mon, 8 Jun 2020 07:33:25 +0000 Subject: [PATCH 23/48] Remove incorrect and unused includes --- admin/includes/functions/password_funcs.php | 13 +++---------- includes/functions/password_funcs.php | 13 +++---------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/admin/includes/functions/password_funcs.php b/admin/includes/functions/password_funcs.php index 55943ea15..895693633 100644 --- a/admin/includes/functions/password_funcs.php +++ b/admin/includes/functions/password_funcs.php @@ -19,10 +19,6 @@ function tep_validate_password($plain, $encrypted) { return tep_validate_old_password($plain, $encrypted); } - if (!class_exists('PasswordHash')) { - include('includes/classes/passwordhash.php'); - } - $hasher = new PasswordHash(10, true); return $hasher->CheckPassword($plain, $encrypted); @@ -39,7 +35,9 @@ function tep_validate_old_password($plain, $encrypted) { // split apart the hash / salt $stack = explode(':', $encrypted); - if (sizeof($stack) != 2) return false; + if (count($stack) != 2) { + return false; + } if (md5($stack[1] . $plain) == $stack[0]) { return true; @@ -53,10 +51,6 @@ function tep_validate_old_password($plain, $encrypted) { // This function encrypts a phpass password from a plaintext // password. function tep_encrypt_password($plain) { - if (!class_exists('PasswordHash')) { - include('includes/classes/passwordhash.php'); - } - $hasher = new PasswordHash(10, true); return $hasher->HashPassword($plain); @@ -154,4 +148,3 @@ function tep_crypt_apr_md5($password, $salt = null) { return '$apr1$' . $salt . '$' . $tmp; } -?> diff --git a/includes/functions/password_funcs.php b/includes/functions/password_funcs.php index 8497bf3fe..24fcb3f8c 100644 --- a/includes/functions/password_funcs.php +++ b/includes/functions/password_funcs.php @@ -19,10 +19,6 @@ function tep_validate_password($plain, $encrypted) { return tep_validate_old_password($plain, $encrypted); } - if (!class_exists('PasswordHash')) { - include('includes/classes/passwordhash.php'); - } - $hasher = new PasswordHash(10, true); return $hasher->CheckPassword($plain, $encrypted); @@ -39,7 +35,9 @@ function tep_validate_old_password($plain, $encrypted) { // split apart the hash / salt $stack = explode(':', $encrypted); - if (sizeof($stack) != 2) return false; + if (count($stack) != 2) { + return false; + } if (md5($stack[1] . $plain) == $stack[0]) { return true; @@ -53,10 +51,6 @@ function tep_validate_old_password($plain, $encrypted) { // This function encrypts a phpass password from a plaintext // password. function tep_encrypt_password($plain) { - if (!class_exists('PasswordHash')) { - include('includes/classes/passwordhash.php'); - } - $hasher = new PasswordHash(10, true); return $hasher->HashPassword($plain); @@ -89,4 +83,3 @@ function tep_password_type($encrypted) { return 'phpass'; } -?> \ No newline at end of file From bfff54ef0a23aba6c284069ed00d43ab8fefa761 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Mon, 8 Jun 2020 12:18:19 +0000 Subject: [PATCH 24/48] Sort New products by descending insertion order --- .../segments/sortable_product_columns.php | 67 ++++++++++--------- products_new.php | 3 + 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/includes/system/segments/sortable_product_columns.php b/includes/system/segments/sortable_product_columns.php index fbc5956ef..fa5ea1518 100644 --- a/includes/system/segments/sortable_product_columns.php +++ b/includes/system/segments/sortable_product_columns.php @@ -34,42 +34,43 @@ } if ( (!isset($_GET['sort'])) || (!preg_match('/^[1-9][ad]$/', $_GET['sort'])) || (substr($_GET['sort'], 0, -1) > count($column_list)) ) { - $i = array_search('PRODUCT_LIST_NAME', $column_list, true); + $i = array_search(($default_column ?? 'PRODUCT_LIST_NAME'), $column_list, true); if (false !== $i) { - $_GET['sort'] = $i+1 . 'a'; - $listing_sql .= " ORDER BY pd.products_name"; + $sort_col = $i+1; + $_GET['sort'] = $sort_col . ($sort_order ?? 'a'); } } else { $sort_col = substr($_GET['sort'], 0 , -1); - $sort_order = substr($_GET['sort'], -1); + } - switch ($column_list[$sort_col-1]) { - case 'PRODUCT_LIST_MODEL': - $listing_sql .= " ORDER BY p.products_model " . ($sort_order == 'd' ? 'DESC' : '') . ", pd.products_name"; - break; - case 'PRODUCT_LIST_NAME': - $listing_sql .= " ORDER BY pd.products_name " . ($sort_order == 'd' ? 'DESC' : ''); - break; - case 'PRODUCT_LIST_MANUFACTURER': - $listing_sql .= " ORDER BY m.manufacturers_name " . ($sort_order == 'd' ? 'DESC' : '') . ", pd.products_name"; - break; - case 'PRODUCT_LIST_QUANTITY': - $listing_sql .= " ORDER BY p.products_quantity " . ($sort_order == 'd' ? 'DESC' : '') . ", pd.products_name"; - break; - case 'PRODUCT_LIST_IMAGE': - $listing_sql .= " ORDER BY pd.products_name"; - break; - case 'PRODUCT_LIST_WEIGHT': - $listing_sql .= " ORDER BY p.products_weight " . ($sort_order == 'd' ? 'DESC' : '') . ", pd.products_name"; - break; - case 'PRODUCT_LIST_PRICE': - $listing_sql .= " ORDER BY final_price " . ($sort_order == 'd' ? 'DESC' : '') . ", pd.products_name"; - break; - case 'PRODUCT_LIST_ID': - $listing_sql .= " ORDER BY p.products_id " . ($sort_order == 'd' ? 'DESC' : '') . ", pd.products_name"; - break; - case 'PRODUCT_LIST_ORDERED': - $listing_sql .= " ORDER BY p.products_ordered " . ($sort_order == 'd' ? 'DESC' : '') . ", pd.products_name"; - break; - } + $sort_order = substr($_GET['sort'], -1); + + switch ($column_list[$sort_col-1]) { + case 'PRODUCT_LIST_MODEL': + $listing_sql .= " ORDER BY p.products_model " . ($sort_order == 'd' ? 'DESC' : '') . ", pd.products_name"; + break; + case 'PRODUCT_LIST_NAME': + $listing_sql .= " ORDER BY pd.products_name " . ($sort_order == 'd' ? 'DESC' : ''); + break; + case 'PRODUCT_LIST_MANUFACTURER': + $listing_sql .= " ORDER BY m.manufacturers_name " . ($sort_order == 'd' ? 'DESC' : '') . ", pd.products_name"; + break; + case 'PRODUCT_LIST_QUANTITY': + $listing_sql .= " ORDER BY p.products_quantity " . ($sort_order == 'd' ? 'DESC' : '') . ", pd.products_name"; + break; + case 'PRODUCT_LIST_IMAGE': + $listing_sql .= " ORDER BY pd.products_name"; + break; + case 'PRODUCT_LIST_WEIGHT': + $listing_sql .= " ORDER BY p.products_weight " . ($sort_order == 'd' ? 'DESC' : '') . ", pd.products_name"; + break; + case 'PRODUCT_LIST_PRICE': + $listing_sql .= " ORDER BY final_price " . ($sort_order == 'd' ? 'DESC' : '') . ", pd.products_name"; + break; + case 'PRODUCT_LIST_ID': + $listing_sql .= " ORDER BY p.products_id " . ($sort_order == 'd' ? 'DESC' : '') . ", pd.products_name"; + break; + case 'PRODUCT_LIST_ORDERED': + $listing_sql .= " ORDER BY p.products_ordered " . ($sort_order == 'd' ? 'DESC' : '') . ", pd.products_name"; + break; } diff --git a/products_new.php b/products_new.php index 0ebe6704e..aeab073b0 100644 --- a/products_new.php +++ b/products_new.php @@ -29,6 +29,9 @@ EOSQL . (int)$languages_id; + $default_column = 'PRODUCT_LIST_ID'; + $sort_order = 'd'; + require $oscTemplate->map_to_template(__FILE__, 'page'); require 'includes/application_bottom.php'; From 748279b2395da890599d8f3e4c60941ca810c2d3 Mon Sep 17 00:00:00 2001 From: gburton Date: Mon, 8 Jun 2020 14:56:49 +0100 Subject: [PATCH 25/48] camelCase Hook Calls To allow them to be read more easily. --- admin/administrators.php | 2 +- admin/advert_manager.php | 6 +++--- admin/categories.php | 18 +++++++++--------- admin/countries.php | 2 +- admin/currencies.php | 4 ++-- admin/customer_data_groups.php | 4 ++-- admin/customers.php | 2 +- admin/geo_zones.php | 12 ++++++------ admin/languages.php | 2 +- admin/manufacturers.php | 4 ++-- admin/newsletters.php | 2 +- admin/orders.php | 6 +++--- admin/orders_status.php | 4 ++-- admin/products_attributes.php | 18 +++++++++--------- admin/reviews.php | 6 +++--- admin/specials.php | 4 ++-- admin/tax_classes.php | 2 +- admin/tax_rates.php | 2 +- admin/testimonials.php | 6 +++--- admin/zones.php | 2 +- 20 files changed, 54 insertions(+), 54 deletions(-) diff --git a/admin/administrators.php b/admin/administrators.php index f921bf610..87af3d340 100644 --- a/admin/administrators.php +++ b/admin/administrators.php @@ -219,7 +219,7 @@ } } - $OSCOM_Hooks->call('administrators', 'deleteconfirmAction'); + $OSCOM_Hooks->call('administrators', 'deleteConfirmAction'); tep_redirect(tep_href_link('administrators.php')); break; diff --git a/admin/advert_manager.php b/admin/advert_manager.php index d4be843f9..f7751d403 100644 --- a/admin/advert_manager.php +++ b/admin/advert_manager.php @@ -47,7 +47,7 @@ $messageStack->add_session(SUCCESS_ADVERT_STATUS_UPDATED, 'success'); } - $OSCOM_Hooks->call('advert_manager', 'setflagAction'); + $OSCOM_Hooks->call('advert_manager', 'setFlagAction'); tep_redirect(tep_href_link('advert_manager.php', 'page=' . (int)$_GET['page'] . '&cID=' . (int)$_GET['cID'])); break; @@ -124,7 +124,7 @@ $messageStack->add_session(SUCCESS_IMAGE_UPDATED, 'success'); } - $OSCOM_Hooks->call('advert_manager', 'insertupdateAction'); + $OSCOM_Hooks->call('advert_manager', 'insertUpdateAction'); tep_redirect(tep_href_link('advert_manager.php', (isset($_GET['page']) ? 'page=' . (int)$_GET['page'] . '&' : '') . 'cID=' . $advert_id)); } else { @@ -151,7 +151,7 @@ tep_db_query("delete from advert where advert_id = '" . (int)$advert_id . "'"); - $OSCOM_Hooks->call('advert_manager', 'deleteconfirmAction'); + $OSCOM_Hooks->call('advert_manager', 'deleteConfirmAction'); $messageStack->add_session(SUCCESS_IMAGE_REMOVED, 'success'); diff --git a/admin/categories.php b/admin/categories.php index ee91f8585..b9dc8097d 100644 --- a/admin/categories.php +++ b/admin/categories.php @@ -33,7 +33,7 @@ case 'setflag': tep_db_query("UPDATE products SET products_status = '" . (int)$_GET['flag'] . "', products_last_modified = NOW() WHERE products_id = " . (int)$_GET['pID']); - $OSCOM_Hooks->call('categories', 'setflagAction'); + $OSCOM_Hooks->call('categories', 'setFlagAction'); tep_redirect(tep_href_link('categories.php', 'cPath=' . $_GET['cPath'] . '&pID=' . (int)$_GET['pID'])); break; @@ -82,11 +82,11 @@ $sql_data_array = array_merge($sql_data_array, $insert_sql_data); - $OSCOM_Hooks->call('categories', 'insertcategoryAction'); + $OSCOM_Hooks->call('categories', 'insertCategoryAction'); tep_db_perform('categories_description', $sql_data_array); } elseif ($action == 'update_category') { - $OSCOM_Hooks->call('categories', 'updatecategoryAction'); + $OSCOM_Hooks->call('categories', 'updateCategoryAction'); tep_db_perform('categories_description', $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'"); } @@ -99,7 +99,7 @@ tep_db_query("update categories set categories_image = '" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'"); } - $OSCOM_Hooks->call('categories', 'insertcategoryupdatecategoryAction'); + $OSCOM_Hooks->call('categories', 'insertCategoryUpdateCategoryAction'); tep_redirect(tep_href_link('categories.php', 'cPath=' . $cPath . '&cID=' . $categories_id)); break; @@ -145,7 +145,7 @@ } } - $OSCOM_Hooks->call('categories', 'deletecategoryconfirmAction'); + $OSCOM_Hooks->call('categories', 'deleteCategoryConfirmAction'); tep_redirect(tep_href_link('categories.php', 'cPath=' . $cPath)); break; @@ -166,7 +166,7 @@ } } - $OSCOM_Hooks->call('categories', 'deleteproductconfirmAction'); + $OSCOM_Hooks->call('categories', 'deleteProductConfirmAction'); tep_redirect(tep_href_link('categories.php', 'cPath=' . $cPath)); break; @@ -184,7 +184,7 @@ } else { tep_db_query("update categories set parent_id = '" . (int)$new_parent_id . "', last_modified = now() where categories_id = '" . (int)$categories_id . "'"); - $OSCOM_Hooks->call('categories', 'movecategoryconfirmAction'); + $OSCOM_Hooks->call('categories', 'moveCategoryConfirmAction'); tep_redirect(tep_href_link('categories.php', 'cPath=' . $new_parent_id . '&cID=' . $categories_id)); } @@ -199,7 +199,7 @@ $duplicate_check = tep_db_fetch_array($duplicate_check_query); if ($duplicate_check['total'] < 1) tep_db_query("update products_to_categories set categories_id = '" . (int)$new_parent_id . "' where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$current_category_id . "'"); - $OSCOM_Hooks->call('categories', 'moveproductconfirmAction'); + $OSCOM_Hooks->call('categories', 'moveProductConfirmAction'); tep_redirect(tep_href_link('categories.php', 'cPath=' . $new_parent_id . '&pID=' . $products_id)); break; @@ -360,7 +360,7 @@ } } - $OSCOM_Hooks->call('categories', 'copytoconfirmAction'); + $OSCOM_Hooks->call('categories', 'copyToConfirmAction'); tep_redirect(tep_href_link('categories.php', 'cPath=' . $categories_id . '&pID=' . $products_id)); break; diff --git a/admin/countries.php b/admin/countries.php index a3cac8521..5ed6b851f 100644 --- a/admin/countries.php +++ b/admin/countries.php @@ -48,7 +48,7 @@ tep_db_query("delete from countries where countries_id = '" . (int)$countries_id . "'"); - $OSCOM_Hooks->call('countries', 'deleteconfirmAction'); + $OSCOM_Hooks->call('countries', 'deleteConfirmAction'); tep_redirect(tep_href_link('countries.php', 'page=' . (int)$_GET['page'])); break; diff --git a/admin/currencies.php b/admin/currencies.php index c9429db74..1a0444642 100644 --- a/admin/currencies.php +++ b/admin/currencies.php @@ -58,7 +58,7 @@ tep_db_query("update configuration set configuration_value = '" . tep_db_input($code) . "' where configuration_key = 'DEFAULT_CURRENCY'"); } - $OSCOM_Hooks->call('currencies', 'insertsaveAction'); + $OSCOM_Hooks->call('currencies', 'insertSaveAction'); tep_redirect(tep_href_link('currencies.php', 'page=' . (int)$_GET['page'] . '&cID=' . $currency_id)); break; @@ -74,7 +74,7 @@ tep_db_query("delete from currencies where currencies_id = '" . (int)$currencies_id . "'"); - $OSCOM_Hooks->call('currencies', 'deleteconfirmAction'); + $OSCOM_Hooks->call('currencies', 'deleteConfirmAction'); tep_redirect(tep_href_link('currencies.php', 'page=' . (int)$_GET['page'])); break; diff --git a/admin/customer_data_groups.php b/admin/customer_data_groups.php index 51e1bf55c..0a4b3e536 100644 --- a/admin/customer_data_groups.php +++ b/admin/customer_data_groups.php @@ -54,7 +54,7 @@ } } - $OSCOM_Hooks->call('customer_data_groups', 'insertsaveAction'); + $OSCOM_Hooks->call('customer_data_groups', 'insertSaveAction'); if ('insert' == $action) { tep_redirect(tep_href_link('customer_data_groups.php')); @@ -68,7 +68,7 @@ tep_db_query("DELETE FROM customer_data_groups WHERE customer_data_groups_id = " . (int)$customer_data_groups_id); tep_db_query("DELETE FROM customer_data_groups_sequence WHERE customer_data_groups_id = " . (int)$customer_data_groups_id); - $OSCOM_Hooks->call('customer_data_groups', 'deleteconfirmAction'); + $OSCOM_Hooks->call('customer_data_groups', 'deleteConfirmAction'); tep_redirect(tep_href_link('customer_data_groups.php', 'page=' . (int)$_GET['page'])); break; diff --git a/admin/customers.php b/admin/customers.php index d0e259529..c6c84c2e5 100644 --- a/admin/customers.php +++ b/admin/customers.php @@ -68,7 +68,7 @@ tep_db_query("DELETE FROM customers_basket_attributes WHERE customers_id = " . (int)$customers_id); tep_db_query("DELETE FROM whos_online WHERE customer_id = " . (int)$customers_id); - $OSCOM_Hooks->call('customers', 'deleteconfirmAction'); + $OSCOM_Hooks->call('customers', 'deleteConfirmAction'); tep_redirect(tep_href_link('customers.php', tep_get_all_get_params(['cID', 'action']))); break; diff --git a/admin/geo_zones.php b/admin/geo_zones.php index 573959cc2..e43123424 100644 --- a/admin/geo_zones.php +++ b/admin/geo_zones.php @@ -26,7 +26,7 @@ tep_db_query("insert into zones_to_geo_zones (zone_country_id, zone_id, geo_zone_id, date_added) values ('" . (int)$zone_country_id . "', '" . (int)$zone_id . "', '" . (int)$zID . "', now())"); $new_subzone_id = tep_db_insert_id(); - $OSCOM_Hooks->call('geo_zones', 'insertsubSaction'); + $OSCOM_Hooks->call('geo_zones', 'insertSubSaction'); tep_redirect(tep_href_link('geo_zones.php', 'zpage=' . $_GET['zpage'] . '&zID=' . $_GET['zID'] . '&action=list&spage=' . $_GET['spage'] . '&sID=' . $new_subzone_id)); break; @@ -38,7 +38,7 @@ tep_db_query("update zones_to_geo_zones set geo_zone_id = '" . (int)$zID . "', zone_country_id = '" . (int)$zone_country_id . "', zone_id = " . (tep_not_null($zone_id) ? "'" . (int)$zone_id . "'" : 'null') . ", last_modified = now() where association_id = '" . (int)$sID . "'"); - $OSCOM_Hooks->call('geo_zones', 'savesubSaction'); + $OSCOM_Hooks->call('geo_zones', 'saveSubSaction'); tep_redirect(tep_href_link('geo_zones.php', 'zpage=' . $_GET['zpage'] . '&zID=' . $_GET['zID'] . '&action=list&spage=' . $_GET['spage'] . '&sID=' . $_GET['sID'])); break; @@ -47,7 +47,7 @@ tep_db_query("delete from zones_to_geo_zones where association_id = '" . (int)$sID . "'"); - $OSCOM_Hooks->call('geo_zones', 'deleteconfirmsubSaction'); + $OSCOM_Hooks->call('geo_zones', 'deleteConfirmSubSaction'); tep_redirect(tep_href_link('geo_zones.php', 'zpage=' . $_GET['zpage'] . '&zID=' . $_GET['zID'] . '&action=list&spage=' . $_GET['spage'])); break; @@ -69,7 +69,7 @@ tep_db_query("insert into geo_zones (geo_zone_name, geo_zone_description, date_added) values ('" . tep_db_input($geo_zone_name) . "', '" . tep_db_input($geo_zone_description) . "', now())"); $new_zone_id = tep_db_insert_id(); - $OSCOM_Hooks->call('geo_zones', 'insertzoneAction'); + $OSCOM_Hooks->call('geo_zones', 'insertZoneAction'); tep_redirect(tep_href_link('geo_zones.php', 'zpage=' . $_GET['zpage'] . '&zID=' . $new_zone_id)); break; @@ -80,7 +80,7 @@ tep_db_query("update geo_zones set geo_zone_name = '" . tep_db_input($geo_zone_name) . "', geo_zone_description = '" . tep_db_input($geo_zone_description) . "', last_modified = now() where geo_zone_id = '" . (int)$zID . "'"); - $OSCOM_Hooks->call('geo_zones', 'savezoneAction'); + $OSCOM_Hooks->call('geo_zones', 'saveZoneAction'); tep_redirect(tep_href_link('geo_zones.php', 'zpage=' . $_GET['zpage'] . '&zID=' . $_GET['zID'])); break; @@ -90,7 +90,7 @@ tep_db_query("delete from geo_zones where geo_zone_id = '" . (int)$zID . "'"); tep_db_query("delete from zones_to_geo_zones where geo_zone_id = '" . (int)$zID . "'"); - $OSCOM_Hooks->call('geo_zones', 'delteconfirmAction'); + $OSCOM_Hooks->call('geo_zones', 'deleteConfirmAction'); tep_redirect(tep_href_link('geo_zones.php', 'zpage=' . $_GET['zpage'])); break; diff --git a/admin/languages.php b/admin/languages.php index 31167f858..57be4c4fd 100644 --- a/admin/languages.php +++ b/admin/languages.php @@ -82,7 +82,7 @@ tep_db_query("DELETE FROM customer_data_groups WHERE language_id = '" . (int)$lID . "'"); tep_db_query("DELETE FROM languages WHERE languages_id = '" . (int)$lID . "'"); - $OSCOM_Hooks->call('languages', 'deleteconfirmAction'); + $OSCOM_Hooks->call('languages', 'deleteConfirmAction'); tep_redirect(tep_href_link('languages.php', (isset($_GET['page']) ? 'page=' . (int)$_GET['page'] : ''))); break; diff --git a/admin/manufacturers.php b/admin/manufacturers.php index 6f7168e8d..07cab05a5 100644 --- a/admin/manufacturers.php +++ b/admin/manufacturers.php @@ -73,7 +73,7 @@ } } - $OSCOM_Hooks->call('manufacturers', 'insertsaveAction'); + $OSCOM_Hooks->call('manufacturers', 'insertSaveAction'); tep_redirect(tep_href_link('manufacturers.php', (isset($_GET['page']) ? 'page=' . (int)$_GET['page'] . '&' : '') . 'mID=' . $manufacturers_id)); break; @@ -101,7 +101,7 @@ tep_db_query("update products set manufacturers_id = '' where manufacturers_id = '" . (int)$manufacturers_id . "'"); } - $OSCOM_Hooks->call('manufacturers', 'deleteconfirmAction'); + $OSCOM_Hooks->call('manufacturers', 'deleteConfirmAction'); tep_redirect(tep_href_link('manufacturers.php', 'page=' . (int)$_GET['page'])); break; diff --git a/admin/newsletters.php b/admin/newsletters.php index 97586d427..fe0e15788 100644 --- a/admin/newsletters.php +++ b/admin/newsletters.php @@ -91,7 +91,7 @@ tep_db_query("delete from newsletters where newsletters_id = '" . (int)$newsletter_id . "'"); - $OSCOM_Hooks->call('newsletters', 'deleteonfirmAction'); + $OSCOM_Hooks->call('newsletters', 'deleteConfirmAction'); tep_redirect(tep_href_link('newsletters.php', 'page=' . (int)$_GET['page'])); break; diff --git a/admin/orders.php b/admin/orders.php index c3decbd41..d8b88e00f 100644 --- a/admin/orders.php +++ b/admin/orders.php @@ -63,7 +63,7 @@ $order_updated = true; } - $OSCOM_Hooks->call('orders', 'updateorderAction'); + $OSCOM_Hooks->call('orders', 'updateOrderAction'); if ($order_updated == true) { $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success'); @@ -78,7 +78,7 @@ tep_remove_order($oID, $_POST['restock']); - $OSCOM_Hooks->call('orders', 'deleteconfirmAction'); + $OSCOM_Hooks->call('orders', 'deleteConfirmAction'); tep_redirect(tep_href_link('orders.php', tep_get_all_get_params(['oID', 'action']))); break; @@ -247,7 +247,7 @@
call('orders', 'sectionstatushistorycontentForm'); + echo $OSCOM_Hooks->call('orders', 'sectionStatusHistoryContentForm'); ?>

diff --git a/admin/orders_status.php b/admin/orders_status.php index 357cc49dc..90454709a 100644 --- a/admin/orders_status.php +++ b/admin/orders_status.php @@ -52,7 +52,7 @@ tep_db_query("update configuration set configuration_value = '" . tep_db_input($orders_status_id) . "' where configuration_key = 'DEFAULT_ORDERS_STATUS_ID'"); } - $OSCOM_Hooks->call('orders_status', 'insertsaveAction'); + $OSCOM_Hooks->call('orders_status', 'insertSaveAction'); tep_redirect(tep_href_link('orders_status.php', 'page=' . (int)$_GET['page'] . '&oID=' . $orders_status_id)); break; @@ -68,7 +68,7 @@ tep_db_query("delete from orders_status where orders_status_id = '" . tep_db_input($oID) . "'"); - $OSCOM_Hooks->call('orders_status', 'deleteconfirmAction'); + $OSCOM_Hooks->call('orders_status', 'deleteConfirmAction'); tep_redirect(tep_href_link('orders_status.php', 'page=' . (int)$_GET['page'])); break; diff --git a/admin/products_attributes.php b/admin/products_attributes.php index 1a76344d0..8004c7c54 100644 --- a/admin/products_attributes.php +++ b/admin/products_attributes.php @@ -35,7 +35,7 @@ tep_db_query("insert into products_options (products_options_id, products_options_name, language_id) values ('" . (int)$products_options_id . "', '" . tep_db_input($option_name) . "', '" . (int)$languages[$i]['id'] . "')"); } - $OSCOM_Hooks->call('products_attributes', 'addproductoptionsAction'); + $OSCOM_Hooks->call('products_attributes', 'addProductOptionsAction'); tep_redirect(tep_href_link('products_attributes.php', $page_info)); break; @@ -52,7 +52,7 @@ tep_db_query("insert into products_options_values_to_products_options (products_options_id, products_options_values_id) values ('" . (int)$option_id . "', '" . (int)$value_id . "')"); - $OSCOM_Hooks->call('products_attributes', 'addproductoptionvaluesAction'); + $OSCOM_Hooks->call('products_attributes', 'addProductOptionValuesAction'); tep_redirect(tep_href_link('products_attributes.php', $page_info)); break; @@ -78,7 +78,7 @@ } } - $OSCOM_Hooks->call('products_attributes', 'addproductattributesAction'); + $OSCOM_Hooks->call('products_attributes', 'addProductAttributesAction'); tep_redirect(tep_href_link('products_attributes.php', $page_info)); break; @@ -92,7 +92,7 @@ tep_db_query("update products_options set products_options_name = '" . tep_db_input($option_name) . "' where products_options_id = '" . (int)$option_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'"); } - $OSCOM_Hooks->call('products_attributes', 'updateoptionnameAction'); + $OSCOM_Hooks->call('products_attributes', 'updateOptionNameAction'); tep_redirect(tep_href_link('products_attributes.php', $page_info)); break; @@ -109,7 +109,7 @@ tep_db_query("update products_options_values_to_products_options set products_options_id = '" . (int)$option_id . "' where products_options_values_id = '" . (int)$value_id . "'"); - $OSCOM_Hooks->call('products_attributes', 'updatevalueAction'); + $OSCOM_Hooks->call('products_attributes', 'updateValueAction'); tep_redirect(tep_href_link('products_attributes.php', $page_info)); break; @@ -133,7 +133,7 @@ } } - $OSCOM_Hooks->call('products_attributes', 'updateproductattributeAction'); + $OSCOM_Hooks->call('products_attributes', 'updateProductAttributeAction'); tep_redirect(tep_href_link('products_attributes.php', $page_info)); break; @@ -142,7 +142,7 @@ tep_db_query("delete from products_options where products_options_id = '" . (int)$option_id . "'"); - $OSCOM_Hooks->call('products_attributes', 'deleteoptionAction'); + $OSCOM_Hooks->call('products_attributes', 'deleteOptionAction'); tep_redirect(tep_href_link('products_attributes.php', $page_info)); break; @@ -152,7 +152,7 @@ tep_db_query("delete from products_options_values where products_options_values_id = '" . (int)$value_id . "'"); tep_db_query("delete from products_options_values_to_products_options where products_options_values_id = '" . (int)$value_id . "'"); - $OSCOM_Hooks->call('products_attributes', 'deletevalueAction'); + $OSCOM_Hooks->call('products_attributes', 'deleteValueAction'); tep_redirect(tep_href_link('products_attributes.php', $page_info)); break; @@ -164,7 +164,7 @@ // added for DOWNLOAD_ENABLED. Always try to remove attributes, even if downloads are no longer enabled tep_db_query("delete from products_attributes_download where products_attributes_id = '" . (int)$attribute_id . "'"); - $OSCOM_Hooks->call('products_attributes', 'deleteattributeAction'); + $OSCOM_Hooks->call('products_attributes', 'deleteAttributeAction'); tep_redirect(tep_href_link('products_attributes.php', $page_info)); break; diff --git a/admin/reviews.php b/admin/reviews.php index 75172bc85..7d4ec96dd 100644 --- a/admin/reviews.php +++ b/admin/reviews.php @@ -21,7 +21,7 @@ case 'setflag': tep_db_query("UPDATE reviews SET reviews_status = '" . $_GET['flag'] . "', last_modified = NOW() WHERE reviews_id = " . (int)$_GET['rID']); - $OSCOM_Hooks->call('reviews', 'setflagAction'); + $OSCOM_Hooks->call('reviews', 'setFlagAction'); tep_redirect(tep_href_link('reviews.php', 'page=' . (int)$_GET['page'] . '&rID=' . $_GET['rID'])); break; @@ -44,7 +44,7 @@ tep_db_query("delete from reviews where reviews_id = '" . (int)$reviews_id . "'"); tep_db_query("delete from reviews_description where reviews_id = '" . (int)$reviews_id . "'"); - $OSCOM_Hooks->call('reviews', 'deleteconfirmAction'); + $OSCOM_Hooks->call('reviews', 'deleteConfirmAction'); tep_redirect(tep_href_link('reviews.php', 'page=' . (int)$_GET['page'])); break; @@ -58,7 +58,7 @@ $insert_id = tep_db_insert_id(); tep_db_query("insert into reviews_description (reviews_id, languages_id, reviews_text) values ('" . (int)$insert_id . "', '" . (int)$languages_id . "', '" . $review . "')"); - $OSCOM_Hooks->call('reviews', 'addnewAction'); + $OSCOM_Hooks->call('reviews', 'addNewAction'); tep_redirect(tep_href_link('reviews.php', tep_get_all_get_params(['action']))); break; diff --git a/admin/specials.php b/admin/specials.php index df2ef0ba3..a91f22260 100644 --- a/admin/specials.php +++ b/admin/specials.php @@ -24,7 +24,7 @@ case 'setflag': tep_db_query("UPDATE specials SET status = '" . $_GET['flag'] . "', expires_date = NULL, date_status_change = NULL WHERE specials_id = " . (int)$_GET['id']); - $OSCOM_Hooks->call('specials', 'setflagAction'); + $OSCOM_Hooks->call('specials', 'setFlagAction'); tep_redirect(tep_href_link('specials.php', (isset($_GET['page']) ? 'page=' . (int)$_GET['page'] . '&' : '') . 'sID=' . $_GET['id'])); break; @@ -77,7 +77,7 @@ tep_db_query("delete from specials where specials_id = '" . (int)$specials_id . "'"); - $OSCOM_Hooks->call('specials', 'deleteconfirmAction'); + $OSCOM_Hooks->call('specials', 'deleteConfirmAction'); tep_redirect(tep_href_link('specials.php', 'page=' . (int)$_GET['page'])); break; diff --git a/admin/tax_classes.php b/admin/tax_classes.php index 9c908e906..77a184487 100644 --- a/admin/tax_classes.php +++ b/admin/tax_classes.php @@ -44,7 +44,7 @@ tep_db_query("delete from tax_class where tax_class_id = '" . (int)$tax_class_id . "'"); - $OSCOM_Hooks->call('tax_classes', 'deleteconfirmAction'); + $OSCOM_Hooks->call('tax_classes', 'deleteConfirmAction'); tep_redirect(tep_href_link('tax_classes.php', 'page=' . (int)$_GET['page'])); break; diff --git a/admin/tax_rates.php b/admin/tax_rates.php index 3ee8e1a97..781246224 100644 --- a/admin/tax_rates.php +++ b/admin/tax_rates.php @@ -50,7 +50,7 @@ tep_db_query("delete from tax_rates where tax_rates_id = '" . (int)$tax_rates_id . "'"); - $OSCOM_Hooks->call('tax_rates', 'deleteconfirmAction'); + $OSCOM_Hooks->call('tax_rates', 'deleteConfirmAction'); tep_redirect(tep_href_link('tax_rates.php', 'page=' . (int)$_GET['page'])); break; diff --git a/admin/testimonials.php b/admin/testimonials.php index 274d9fc8c..f1d79bc03 100644 --- a/admin/testimonials.php +++ b/admin/testimonials.php @@ -25,7 +25,7 @@ } } - $OSCOM_Hooks->call('testimonials', 'setflagAction'); + $OSCOM_Hooks->call('testimonials', 'setFlagAction'); tep_redirect(tep_href_link('testimonials.php', 'page=' . (int)$_GET['page'] . '&tID=' . $_GET['tID'])); break; @@ -49,7 +49,7 @@ tep_db_query("delete from testimonials where testimonials_id = '" . (int)$testimonials_id . "'"); tep_db_query("delete from testimonials_description where testimonials_id = '" . (int)$testimonials_id . "'"); - $OSCOM_Hooks->call('testimonials', 'deleteconfirmAction'); + $OSCOM_Hooks->call('testimonials', 'deleteConfirmAction'); tep_redirect(tep_href_link('testimonials.php', 'page=' . (int)$_GET['page'])); break; @@ -63,7 +63,7 @@ $insert_id = tep_db_insert_id(); tep_db_query("insert into testimonials_description (testimonials_id, languages_id, testimonials_text) values ('" . (int)$insert_id . "', '" . (int)$languages_id . "', '" . tep_db_input($testimonial) . "')"); - $OSCOM_Hooks->call('testimonials', 'addnewAction'); + $OSCOM_Hooks->call('testimonials', 'addNewAction'); tep_redirect(tep_href_link('testimonials.php', tep_get_all_get_params(array('action')))); break; diff --git a/admin/zones.php b/admin/zones.php index bfb03a25a..2dcf67dea 100644 --- a/admin/zones.php +++ b/admin/zones.php @@ -46,7 +46,7 @@ tep_db_query("delete from zones where zone_id = '" . (int)$zone_id . "'"); - $OSCOM_Hooks->call('zones', 'deleteconfirmAction'); + $OSCOM_Hooks->call('zones', 'deleteConfirmAction'); tep_redirect(tep_href_link('zones.php', 'page=' . (int)$_GET['page'])); break; From 5722e8adfac4f8acb934313b385b0af46e551a91 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Mon, 8 Jun 2020 22:06:08 +0000 Subject: [PATCH 26/48] Fix modules that relied on $product_check --- .../modules/header_tags/ht_product_meta.php | 22 +-- .../header_tags/ht_product_opengraph.php | 71 +++---- .../modules/header_tags/ht_product_schema.php | 178 ++++++++---------- .../modules/header_tags/ht_product_title.php | 22 +-- 4 files changed, 129 insertions(+), 164 deletions(-) diff --git a/includes/modules/header_tags/ht_product_meta.php b/includes/modules/header_tags/ht_product_meta.php index 4e735902c..6d8384c4c 100644 --- a/includes/modules/header_tags/ht_product_meta.php +++ b/includes/modules/header_tags/ht_product_meta.php @@ -17,19 +17,15 @@ class ht_product_meta extends abstract_module { protected $group = 'header_tags'; function execute() { - global $PHP_SELF, $oscTemplate, $product_check; - - if (isset($_GET['products_id'])) { - if ($product_check['total'] > 0) { - $meta_info_query = tep_db_query("select pd.products_seo_description, pd.products_seo_keywords from products p, 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'] . "'"); - $meta_info = tep_db_fetch_array($meta_info_query); - - if (tep_not_null($meta_info['products_seo_description'])) { - $oscTemplate->addBlock('' . PHP_EOL, $this->group); - } - if ((tep_not_null($meta_info['products_seo_keywords'])) && (MODULE_HEADER_TAGS_PRODUCT_META_KEYWORDS_STATUS != 'Search') ) { - $oscTemplate->addBlock('' . PHP_EOL, $this->group); - } + global $oscTemplate, $product_info; + + if (isset($_GET['products_id'], $product_info)) { + if (tep_not_null($product_info['products_seo_description'])) { + $oscTemplate->addBlock('' . PHP_EOL, $this->group); + } + + if ((tep_not_null($product_info['products_seo_keywords'])) && (MODULE_HEADER_TAGS_PRODUCT_META_KEYWORDS_STATUS !== 'Search') ) { + $oscTemplate->addBlock('' . PHP_EOL, $this->group); } } } diff --git a/includes/modules/header_tags/ht_product_opengraph.php b/includes/modules/header_tags/ht_product_opengraph.php index 04546260e..0e0caa070 100644 --- a/includes/modules/header_tags/ht_product_opengraph.php +++ b/includes/modules/header_tags/ht_product_opengraph.php @@ -17,50 +17,41 @@ class ht_product_opengraph extends abstract_module { public $group = 'header_tags'; function execute() { - global $PHP_SELF, $oscTemplate, $product_check, $currencies; - - if ($product_check['total'] > 0) { - $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_image, p.products_price, p.products_quantity, p.products_tax_class_id, p.products_date_available from products p, products_description pd where p.products_id = " . (int)$_GET['products_id'] . " and p.products_status = 1 and p.products_id = pd.products_id and pd.language_id = " . (int)$_SESSION['languages_id']); - - if ( tep_db_num_rows($product_info_query) === 1 ) { - $product_info = tep_db_fetch_array($product_info_query); - - $data = [ - 'og:type' => 'product', - 'og:title' => $product_info['products_name'], - 'og:site_name' => STORE_NAME, - ]; - - $product_description = substr(trim(preg_replace('/\s\s+/', ' ', strip_tags($product_info['products_description']))), 0, 197) . '...'; - $data['og:description'] = $product_description; - - $products_image = $product_info['products_image']; - $pi_query = tep_db_query("select image from products_images where products_id = '" . (int)$product_info['products_id'] . "' order by sort_order limit 1"); - if ( tep_db_num_rows($pi_query) === 1 ) { - $pi = tep_db_fetch_array($pi_query); - $products_image = $pi['image']; - } - $data['og:image'] = tep_href_link("images/$products_image", '', 'NONSSL', false, false); - - if ($new_price = tep_get_products_special_price($product_info['products_id'])) { - $products_price = $currencies->display_raw($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])); - } else { - $products_price = $currencies->display_raw($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])); - } - $data['product:price:amount'] = $products_price; - $data['product:price:currency'] = $_SESSION['currency']; - - $data['og:url'] = tep_href_link('product_info.php', 'products_id=' . $product_info['products_id'], 'NONSSL', false); + global $product_info, $currencies; + + if (isset($product_info['products_name'])) { + $data = [ + 'og:type' => 'product', + 'og:title' => $product_info['products_name'], + 'og:site_name' => STORE_NAME, + ]; + + $product_description = substr(trim(preg_replace('/\s\s+/', ' ', strip_tags($product_info['products_description']))), 0, 197) . '...'; + $data['og:description'] = $product_description; + + $pi_query = tep_db_query("SELECT image FROM products_images WHERE products_id = " . (int)$product_info['products_id'] . " ORDER BY sort_order LIMIT 1"); + $pi = tep_db_fetch_array($pi_query); + $products_image = $pi['image'] ?? $product_info['products_image']; + $data['og:image'] = tep_href_link("images/$products_image", '', 'NONSSL', false, false); + + if ($new_price = tep_get_products_special_price($product_info['products_id'])) { + $products_price = $currencies->display_raw($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])); + } else { + $products_price = $currencies->display_raw($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])); + } + $data['product:price:amount'] = $products_price; + $data['product:price:currency'] = $_SESSION['currency']; - $data['product:availability'] = ( $product_info['products_quantity'] > 0 ) ? MODULE_HEADER_TAGS_PRODUCT_OPENGRAPH_TEXT_IN_STOCK : MODULE_HEADER_TAGS_PRODUCT_OPENGRAPH_TEXT_OUT_OF_STOCK; + $data['og:url'] = tep_href_link('product_info.php', 'products_id=' . $product_info['products_id'], 'NONSSL', false); - $result = ''; - foreach ( $data as $key => $value ) { - $result .= '' . PHP_EOL; - } + $data['product:availability'] = ( $product_info['products_quantity'] > 0 ) ? MODULE_HEADER_TAGS_PRODUCT_OPENGRAPH_TEXT_IN_STOCK : MODULE_HEADER_TAGS_PRODUCT_OPENGRAPH_TEXT_OUT_OF_STOCK; - $oscTemplate->addBlock($result, $this->group); + $result = ''; + foreach ( $data as $property => $content ) { + $result .= '' . PHP_EOL; } + + $GLOBALS['oscTemplate']->addBlock($result, $this->group); } } diff --git a/includes/modules/header_tags/ht_product_schema.php b/includes/modules/header_tags/ht_product_schema.php index fbace6257..f868d0600 100644 --- a/includes/modules/header_tags/ht_product_schema.php +++ b/includes/modules/header_tags/ht_product_schema.php @@ -17,131 +17,119 @@ class ht_product_schema extends abstract_executable_module { public function __construct() { parent::__construct(__FILE__); - if (static::get_constant('MODULE_HEADER_TAGS_PRODUCT_SCHEMA_PLACEMENT') != 'Header') { + if (static::get_constant('MODULE_HEADER_TAGS_PRODUCT_SCHEMA_PLACEMENT') !== 'Header') { $this->group = 'footer_scripts'; } } function execute() { - global $PHP_SELF, $oscTemplate, $product_check, $currencies; + global $product_info, $currencies; - if ($product_check['total'] > 0) { - $product_info_query = tep_db_query(<<<'EOSQL' -SELECT p.*, pd.* - FROM products p INNER JOIN products_description pd ON p.products_id = pd.products_id - WHERE p.products_status = 1 AND p.products_id = -EOSQL - . (int)$_GET['products_id'] . " AND pd.language_id = " . (int)$_SESSION['languages_id']); - - if ( tep_db_num_rows($product_info_query) ) { - $product_info = tep_db_fetch_array($product_info_query); + if (isset($product_info['products_name'])) { + $products_image = $product_info['products_image']; + $pi_query = tep_db_query("SELECT image FROM products_images WHERE products_id = " . (int)$product_info['products_id'] . " ORDER BY sort_order LIMIT 1"); + if ( $pi = tep_db_fetch_array($pi_query) ) { + $products_image = $pi['image']; + } - $products_image = $product_info['products_image']; - $pi_query = tep_db_query("SELECT image FROM products_images WHERE products_id = " . (int)$product_info['products_id'] . " ORDER BY sort_order LIMIT 1"); - if ( tep_db_num_rows($pi_query) ) { - $pi = tep_db_fetch_array($pi_query); - $products_image = $pi['image']; - } + $schema_product = [ + '@context' => 'https://schema.org', + '@type' => 'Product', + 'name' => tep_db_output($product_info['products_name']), + 'image' => tep_href_link('images/' . $products_image, '', 'NONSSL', false, false), + 'url' => tep_href_link('product_info.php', 'products_id=' . $product_info['products_id'], 'NONSSL', false, false), + 'description' => substr(trim(preg_replace('/\s\s+/', ' ', strip_tags($product_info['products_description']))), 0, 197) . '...', + ]; + + if (tep_not_null($product_info['products_model'])) { + $schema_product['mpn'] = tep_db_output($product_info['products_model']); + } - $schema_product = [ - "@context" => "https://schema.org", - "@type" => "Product", - "name" => tep_db_output($product_info['products_name']), - "image" => tep_href_link('images/' . $products_image, '', 'NONSSL', false, false), - "url" => tep_href_link('product_info.php', 'products_id=' . $product_info['products_id'], 'NONSSL', false, false), - "description" => substr(trim(preg_replace('/\s\s+/', ' ', strip_tags($product_info['products_description']))), 0, 197) . '...', - ]; + if (tep_not_null($product_info['products_gtin']) && defined('MODULE_CONTENT_PRODUCT_INFO_GTIN_LENGTH')) { + $schema_product['gtin' . MODULE_CONTENT_PRODUCT_INFO_GTIN_LENGTH] = tep_db_output(substr($product_info['products_gtin'], 0-MODULE_CONTENT_PRODUCT_INFO_GTIN_LENGTH)); + } - if (tep_not_null($product_info['products_model'])) { - $schema_product['mpn'] = tep_db_output($product_info['products_model']); - } + $schema_product['offers'] = [ + '@type' => 'Offer', + 'priceCurrency' => $_SESSION['currency'], + ]; - if (tep_not_null($product_info['products_gtin']) && defined('MODULE_CONTENT_PRODUCT_INFO_GTIN_LENGTH')) { - $schema_product['gtin' . MODULE_CONTENT_PRODUCT_INFO_GTIN_LENGTH] = tep_db_output(substr($product_info['products_gtin'], 0-MODULE_CONTENT_PRODUCT_INFO_GTIN_LENGTH)); - } + if ($new_price = tep_get_products_special_price($product_info['products_id'])) { + $products_price = $currencies->display_raw($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])); + } else { + $products_price = $currencies->display_raw($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])); + } - $schema_product['offers'] = [ - "@type" => "Offer", - "priceCurrency" => $_SESSION['currency'], - ]; + $schema_product['offers']['price'] = $products_price; - if ($new_price = tep_get_products_special_price($product_info['products_id'])) { - $products_price = $currencies->display_raw($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])); - } else { - $products_price = $currencies->display_raw($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])); - } + $specials_expiry_query = tep_db_query("SELECT expires_date FROM specials WHERE status = 1 AND products_id = " . (int)$product_info['products_id']); + if ($specials_expiry = tep_db_fetch_array($specials_expiry_query)) { + $schema_product['offers']['priceValidUntil'] = $specials_expiry['expires_date']; + } - $schema_product['offers']['price'] = $products_price; + $availability = ( $product_info['products_quantity'] > 0 ) ? MODULE_HEADER_TAGS_PRODUCT_SCHEMA_TEXT_IN_STOCK : MODULE_HEADER_TAGS_PRODUCT_SCHEMA_TEXT_OUT_OF_STOCK; + $schema_product['offers']['availability'] = $availability; - $specials_expiry_query = tep_db_query("SELECT expires_date FROM specials WHERE status = 1 AND products_id = " . (int)$product_info['products_id']); - if ($specials_expiry = tep_db_fetch_array($specials_expiry_query)) { - $schema_product['offers']['priceValidUntil'] = $specials_expiry['expires_date']; - } + $schema_product['offers']['seller'] = [ + '@type' => 'Organization', + 'name' => STORE_NAME, + ]; - $availability = ( $product_info['products_quantity'] > 0 ) ? MODULE_HEADER_TAGS_PRODUCT_SCHEMA_TEXT_IN_STOCK : MODULE_HEADER_TAGS_PRODUCT_SCHEMA_TEXT_OUT_OF_STOCK; - $schema_product['offers']['availability'] = $availability; + if ($product_info['manufacturers_id'] > 0) { + // manufacturer class + $ht_brand = new manufacturer((int)$product_info['manufacturers_id']); - $schema_product['offers']['seller'] = [ - "@type" => "Organization", - "name" => STORE_NAME, + $schema_product['manufacturer'] = [ + '@type' => 'Organization', + 'name' => tep_db_output($ht_brand->getData('manufacturers_name')), ]; + } - if ($product_info['manufacturers_id'] > 0) { - // manufacturer class - $ht_brand = new manufacturer((int)$product_info['manufacturers_id']); - - $schema_product['manufacturer'] = [ - "@type" => "Organization", - "name" => tep_db_output($ht_brand->getData('manufacturers_name')), - ]; - } - - $average_query = tep_db_query(<<<'EOSQL' + $average_query = tep_db_query(<<<'EOSQL' SELECT AVG(r.reviews_rating) AS average, COUNT(r.reviews_rating) AS count FROM reviews r where r.reviews_status = 1 AND r.products_id = EOSQL - . (int)$product_info['products_id']); - $average = tep_db_fetch_array($average_query); - if ($average['count'] > 0) { - $star_rating = round($average['average'], 0, PHP_ROUND_HALF_UP); - $schema_product['aggregateRating'] = [ - "@type" => "AggregateRating", - "ratingValue" => number_format($star_rating, 2), - "reviewCount" => (int)$average['count'], - ]; - - $reviews_query = tep_db_query(<<<'EOSQL' + . (int)$product_info['products_id']); + $average = tep_db_fetch_array($average_query); + if ($average['count'] > 0) { + $star_rating = round($average['average'], 0, PHP_ROUND_HALF_UP); + $schema_product['aggregateRating'] = [ + '@type' => 'AggregateRating', + 'ratingValue' => number_format($star_rating, 2), + 'reviewCount' => (int)$average['count'], + ]; + + $reviews_query = tep_db_query(<<<'EOSQL' SELECT rd.reviews_text, r.reviews_rating, r.reviews_id, r.customers_name, r.date_added, r.reviews_read FROM reviews r INNER JOIN reviews_description rd ON r.reviews_id = rd.reviews_id WHERE r.reviews_status = 1 AND r.products_id = EOSQL - . (int)$_GET['products_id'] . " AND rd.languages_id = " . (int)$_SESSION['languages_id'] . " ORDER BY r.reviews_rating DESC"); - - if (tep_db_num_rows($reviews_query) > 0) { - $schema_product['review'] = []; - while($reviews = tep_db_fetch_array($reviews_query)) { - $schema_product['review'][] = [ - "@type" => "Review", - "author" => tep_db_output($reviews['customers_name']), - "datePublished" => tep_db_output($reviews['date_added']), - "description" => tep_db_output($reviews['reviews_text']), - "name" => tep_db_output($product_info['products_name']), - "reviewRating" => [ - "@type" => "Rating", - "bestRating" => "5", - "ratingValue" => (int)$reviews['reviews_rating'], - "worstRating" => "1", - ], - ]; - } + . (int)$_GET['products_id'] . " AND rd.languages_id = " . (int)$_SESSION['languages_id'] . " ORDER BY r.reviews_rating DESC"); + + if (tep_db_num_rows($reviews_query) > 0) { + $schema_product['review'] = []; + while ($reviews = tep_db_fetch_array($reviews_query)) { + $schema_product['review'][] = [ + '@type' => 'Review', + 'author' => tep_db_output($reviews['customers_name']), + 'datePublished' => tep_db_output($reviews['date_added']), + 'description' => tep_db_output($reviews['reviews_text']), + 'name' => tep_db_output($product_info['products_name']), + 'reviewRating' => [ + '@type' => 'Rating', + 'bestRating' => '5', + 'ratingValue' => (int)$reviews['reviews_rating'], + 'worstRating' => '1', + ], + ]; } } + } - $data = json_encode($schema_product); + $data = json_encode($schema_product); - $oscTemplate->addBlock('', $this->group); - } + $GLOBALS['oscTemplate']->addBlock('', $this->group); } } diff --git a/includes/modules/header_tags/ht_product_title.php b/includes/modules/header_tags/ht_product_title.php index 5b79087a0..ee0ba00ee 100644 --- a/includes/modules/header_tags/ht_product_title.php +++ b/includes/modules/header_tags/ht_product_title.php @@ -17,23 +17,13 @@ class ht_product_title extends abstract_module { protected $group = 'header_tags'; function execute() { - global $PHP_SELF, $oscTemplate, $product_check; + global $oscTemplate, $product_info; - if (basename($PHP_SELF) == 'product_info.php') { - if (isset($_GET['products_id']) && ($product_check['total'] > 0)) { - $product_info_query = tep_db_query(sprintf(<<<'EOSQL' -SELECT pd.products_name, pd.products_seo_title - FROM products p INNER JOIN products_description pd ON pd.products_id = p.products_id - WHERE p.products_status = 1 AND p.products_id = %d AND pd.language_id = %d -EOSQL - , (int)$_GET['products_id'], (int)$_SESSION['languages_id'])); - $product_info = tep_db_fetch_array($product_info_query); - - if ( tep_not_null($product_info['products_seo_title']) && (MODULE_HEADER_TAGS_PRODUCT_TITLE_SEO_TITLE_OVERRIDE == 'True') ) { - $oscTemplate->setTitle($product_info['products_seo_title'] . MODULE_HEADER_TAGS_PRODUCT_SEO_SEPARATOR . $oscTemplate->getTitle()); - } else { - $oscTemplate->setTitle($product_info['products_name'] . MODULE_HEADER_TAGS_PRODUCT_SEO_SEPARATOR . $oscTemplate->getTitle()); - } + if (isset($_GET['products_id'], $product_info['products_name']) && (basename($GLOBALS['PHP_SELF']) == 'product_info.php')) { + if ( tep_not_null($product_info['products_seo_title']) && (MODULE_HEADER_TAGS_PRODUCT_TITLE_SEO_TITLE_OVERRIDE === 'True') ) { + $oscTemplate->setTitle($product_info['products_seo_title'] . MODULE_HEADER_TAGS_PRODUCT_SEO_SEPARATOR . $oscTemplate->getTitle()); + } else { + $oscTemplate->setTitle($product_info['products_name'] . MODULE_HEADER_TAGS_PRODUCT_SEO_SEPARATOR . $oscTemplate->getTitle()); } } } From 0d5e56717b026db46abf67dd1015666402dfa9f2 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Mon, 8 Jun 2020 23:14:31 +0000 Subject: [PATCH 27/48] Fix ext templates --- includes/functions/general.php | 9 +++++++++ templates/default/includes/template.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/includes/functions/general.php b/includes/functions/general.php index 9d01f4e2d..27e1af429 100644 --- a/includes/functions/general.php +++ b/includes/functions/general.php @@ -989,3 +989,12 @@ function tep_require_login($parameters = null) { tep_redirect(tep_href_link('login.php', '', 'SSL')); } } + + function tep_ltrim_once($s, $prefix) { + $length = strlen($prefix); + if (substr($s, 0, $length) === $prefix) { + return substr($s, $length); + } + + return $s; + } diff --git a/templates/default/includes/template.php b/templates/default/includes/template.php index 000e4b77d..b504daea0 100644 --- a/templates/default/includes/template.php +++ b/templates/default/includes/template.php @@ -39,7 +39,7 @@ public static function _get_template_mapping_for($file, $type) { return dirname($file) . '/templates/tpl_' . basename($file); case 'ext': $file = tep_ltrim_once($file, DIR_FS_CATALOG); - return DIR_FS_CATALOG . "templates/default/includes/components/$file"; + return DIR_FS_CATALOG . "templates/default/includes/$file"; case 'literal': default: return DIR_FS_CATALOG . "templates/default/$file"; From 3183057f907e5631a4b71ebd5e5b85794d4e28a1 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Tue, 9 Jun 2020 11:44:17 +0000 Subject: [PATCH 28/48] Fix order status update after return from PayPal --- includes/modules/payment/paypal_standard.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/includes/modules/payment/paypal_standard.php b/includes/modules/payment/paypal_standard.php index bec619184..df2c73311 100644 --- a/includes/modules/payment/paypal_standard.php +++ b/includes/modules/payment/paypal_standard.php @@ -529,8 +529,9 @@ function pre_before_check() { function before_process() { global $order; - $new_order_status = DEFAULT_ORDERS_STATUS_ID; + $order->set_id($this->extract_order_id()); + $new_order_status = DEFAULT_ORDERS_STATUS_ID; if ( OSCOM_APP_PAYPAL_PS_ORDER_STATUS_ID > 0) { $new_order_status = OSCOM_APP_PAYPAL_PS_ORDER_STATUS_ID; } @@ -551,14 +552,14 @@ function before_process() { // load the after_process function from the payment modules $this->after_process(); - - require 'includes/modules/checkout/reset.php'; - - tep_redirect(tep_href_link('checkout_success.php', '', 'SSL')); } function after_process() { unset($_SESSION['cart_PayPal_Standard_ID']); + + require 'includes/modules/checkout/reset.php'; + + tep_redirect(tep_href_link('checkout_success.php', '', 'SSL')); } function get_error() { From 53a28eacc8afc3a2748bd36409ab9937b3ba5d4d Mon Sep 17 00:00:00 2001 From: Rainer Schmied Date: Tue, 9 Jun 2020 14:55:00 +0200 Subject: [PATCH 29/48] Update products_attributes.php --- admin/products_attributes.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/admin/products_attributes.php b/admin/products_attributes.php index 2ed142a43..3e99c3121 100644 --- a/admin/products_attributes.php +++ b/admin/products_attributes.php @@ -510,6 +510,14 @@

display_links($attributes_query_numrows, MAX_ROW_LISTS_OPTIONS, MAX_DISPLAY_PAGE_LINKS, $attribute_page, 'option_page=' . $option_page . '&value_page=' . $value_page, 'attribute_page'); ?>

+ +
@@ -522,14 +530,6 @@ - - -
-
+ +
Date: Tue, 9 Jun 2020 12:59:25 +0000 Subject: [PATCH 30/48] Fix WSOD after first page load --- includes/functions/autoloader.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/includes/functions/autoloader.php b/includes/functions/autoloader.php index 1351461e9..50bf0964f 100644 --- a/includes/functions/autoloader.php +++ b/includes/functions/autoloader.php @@ -120,9 +120,8 @@ function tep_autoload_catalog($original_class) { $class = tep_normalize_class_name($original_class); if (isset($class_files[$class])) { - $language =& $_SESSION['language']; - if (isset($language) && DIR_FS_CATALOG . 'includes/modules' === substr($class_files[$class], 0, $modules_directory_length)) { - $language_file = DIR_FS_CATALOG . "includes/languages/$language/modules" . substr($class_files[$class], $modules_directory_length); + if (isset($_SESSION['language']) && DIR_FS_CATALOG . 'includes/modules' === substr($class_files[$class], 0, $modules_directory_length)) { + $language_file = DIR_FS_CATALOG . 'includes/languages/' . $_SESSION['language'] . '/modules' . substr($class_files[$class], $modules_directory_length); if (file_exists($language_file)) { include $language_file; } From 825ce8891067f8b71275396da88efc37f9d7b7c2 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Tue, 9 Jun 2020 13:29:04 +0000 Subject: [PATCH 31/48] Fix missing image, name, etc. --- includes/system/versioned/1.0.7.3/shopping_cart.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/system/versioned/1.0.7.3/shopping_cart.php b/includes/system/versioned/1.0.7.3/shopping_cart.php index 0c7ea7efd..21b8e21d4 100644 --- a/includes/system/versioned/1.0.7.3/shopping_cart.php +++ b/includes/system/versioned/1.0.7.3/shopping_cart.php @@ -295,6 +295,8 @@ private function map_columns($data) { foreach ($column_keys as $key => $column_name) { $product[$key] = $data[$column_name]; } + + return $product; } function get_products() { From d79785b573e2ff6a58b7391b98ed427483b3e5cf Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Tue, 9 Jun 2020 13:30:54 +0000 Subject: [PATCH 32/48] Fix inaccessible tax class --- includes/system/versioned/1.0.7.3/abstract_shipping_module.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/system/versioned/1.0.7.3/abstract_shipping_module.php b/includes/system/versioned/1.0.7.3/abstract_shipping_module.php index 282e2b06a..100c9290a 100644 --- a/includes/system/versioned/1.0.7.3/abstract_shipping_module.php +++ b/includes/system/versioned/1.0.7.3/abstract_shipping_module.php @@ -12,7 +12,7 @@ abstract class abstract_shipping_module extends abstract_zoneable_module { - protected $tax_class; + public $tax_class; protected $icon = ''; public $quotes; protected $country; From 24b5db5ed3db58969ca527ca8858889b63bd4620 Mon Sep 17 00:00:00 2001 From: gburton Date: Tue, 9 Jun 2020 16:15:08 +0100 Subject: [PATCH 33/48] Code Drop 70 This hook disables the form inputs until the relevant selections have been made. --- .../products_attributes/add_attribute.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 includes/hooks/admin/products_attributes/add_attribute.php diff --git a/includes/hooks/admin/products_attributes/add_attribute.php b/includes/hooks/admin/products_attributes/add_attribute.php new file mode 100644 index 000000000..6a3037a21 --- /dev/null +++ b/includes/hooks/admin/products_attributes/add_attribute.php @@ -0,0 +1,27 @@ +$('select[name="products_id"], select[name="options_id"], select[name="values_id"], input[name="price_prefix"], input[name="value_price"]').prop('required', true); $('select[name="options_id"], select[name="values_id"], input[name="price_prefix"], input[name="value_price"]').prop('disabled', true); $('select[name="products_id"]').change(function() { $('select[name="options_id"]').prop('disabled', false); }); $('select[name="options_id"]').change(function(){ $('select[name="values_id"]').prop('disabled', false); $('select[name="values_id"] option').show(); var id = $(this).val(); $('select[name="values_id"] option[data-id]:not([data-id*="' + id + '"])').hide(); }); $('select[name="values_id"]').change(function() { $('input[name="value_price"], input[name="price_prefix"]').prop('disabled', false); }); +addat; + + return $helper; + } + } + +} From 93114a3afacb759f121166d259f77b654c4199c5 Mon Sep 17 00:00:00 2001 From: gburton Date: Tue, 9 Jun 2020 16:15:44 +0100 Subject: [PATCH 34/48] Prettify buttons that have no class. --- includes/functions/html_output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/functions/html_output.php b/includes/functions/html_output.php index e03e4d761..1c218999d 100644 --- a/includes/functions/html_output.php +++ b/includes/functions/html_output.php @@ -331,7 +331,7 @@ function tep_draw_button($title = null, $icon = null, $link = null, $priority = $button .= ' class="btn '; - $button .= $style ?? 'btn-outline-secondary'; + $button .= $style ?? 'btn-light mt-2'; $button .= '">'; From 355b521097a8cf41354350622d0c9f581adac4ad Mon Sep 17 00:00:00 2001 From: gburton Date: Tue, 9 Jun 2020 16:37:14 +0100 Subject: [PATCH 35/48] Installation of three move Navbar Modules as default --- install/phoenix.sql | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/install/phoenix.sql b/install/phoenix.sql index 2e63c2fe9..775983ffb 100644 --- a/install/phoenix.sql +++ b/install/phoenix.sql @@ -710,7 +710,7 @@ INSERT INTO configuration (configuration_title, configuration_key, configuration INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Installed Modules', 'MODULE_ORDER_TOTAL_INSTALLED', 'ot_subtotal.php;ot_tax.php;ot_shipping.php;ot_total.php', 'List of order_total module filenames separated by a semi-colon. This is automatically updated. No need to edit. (Example: ot_subtotal.php;ot_tax.php;ot_shipping.php;ot_total.php)', '6', '0', now()); INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Installed Modules', 'MODULE_SHIPPING_INSTALLED', 'flat.php', 'List of shipping module filenames separated by a semi-colon. This is automatically updated. No need to edit. (Example: ups.php;flat.php;item.php)', '6', '0', now()); INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Installed Modules', 'MODULE_ACTION_RECORDER_INSTALLED', 'ar_admin_login.php;ar_contact_us.php;ar_reset_password.php', 'List of action recorder module filenames separated by a semi-colon. This is automatically updated. No need to edit.', '6', '0', now()); -INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Installed Modules', 'MODULE_CONTENT_NAVBAR_INSTALLED', 'nb_hamburger_button.php;nb_brand.php;nb_shopping_cart.php', 'List of navbar module filenames separated by a semi-colon. This is automatically updated. No need to edit.', '6', '0', now()); +INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Installed Modules', 'MODULE_CONTENT_NAVBAR_INSTALLED', 'nb_hamburger_button.php;nb_brand.php;nb_currencies.php;nb_account.php;nb_shopping_cart.php;nb_special_offers.php', 'List of navbar module filenames separated by a semi-colon. This is automatically updated. No need to edit.', '6', '0', now()); INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Cash On Delivery Module', 'MODULE_PAYMENT_COD_STATUS', 'True', 'Do you want to accept Cash On Delevery payments?', '6', '1', 'tep_cfg_select_option([\'True\', \'False\'], ', now()); INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) VALUES ('Payment Zone', 'MODULE_PAYMENT_COD_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now()); INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Sort order of display.', 'MODULE_PAYMENT_COD_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now()); @@ -1415,7 +1415,7 @@ insert into configuration (configuration_title, configuration_key, configuration insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Width', 'MODULE_CONTENT_FORGOT_PASSWORD_CONTENT_WIDTH', '6', 'What width container should the content be shown in? (12 = full width, 6 = half width).', '6', '1', 'tep_cfg_select_option([\'12\', \'11\', \'10\', \'9\', \'8\', \'7\', \'6\', \'5\', \'4\', \'3\', \'2\', \'1\'], ', now()); insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_CONTENT_FORGOT_PASSWORD_SORT_ORDER', '3000', 'Sort order of display. Lowest is displayed first.', '6', '0', now()); -# Load three Navbar Modules, let the shopowner install the rest per his/her needs +# Load Navbar Modules, let the shopowner install the rest per his/her needs insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Hamburger Button Module', 'MODULE_NAVBAR_HAMBURGER_BUTTON_STATUS', 'True', 'Do you want to add the module to your Navbar?', '6', '1', 'tep_cfg_select_option([\'True\', \'False\'], ', now()); insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Placement', 'MODULE_NAVBAR_HAMBURGER_BUTTON_CONTENT_PLACEMENT', 'Home', 'This module must be placed in the Home area of the Navbar.', '6', '1', 'tep_cfg_select_option([\'Home\'], ', now()); insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_NAVBAR_HAMBURGER_BUTTON_SORT_ORDER', '500', 'Sort order of display. Lowest is displayed first.', '6', '0', now()); @@ -1425,6 +1425,15 @@ insert into configuration (configuration_title, configuration_key, configuration insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Shopping Cart Module', 'MODULE_NAVBAR_SHOPPING_CART_STATUS', 'True', 'Do you want to add the module to your Navbar?', '6', '1', 'tep_cfg_select_option([\'True\', \'False\'], ', now()); insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Placement', 'MODULE_NAVBAR_SHOPPING_CART_CONTENT_PLACEMENT', 'Right', 'Should the module be loaded in the Left or Right or the Home area of the Navbar?', '6', '1', 'tep_cfg_select_option([\'Left\', \'Right\', \'Home\'], ', now()); insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_NAVBAR_SHOPPING_CART_SORT_ORDER', '550', 'Sort order of display. Lowest is displayed first.', '6', '0', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Currencies Module', 'MODULE_NAVBAR_CURRENCIES_STATUS', 'True', 'Do you want to add the module to your Navbar?', '6', '1', 'tep_cfg_select_option([\'True\', \'False\'], ', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Placement', 'MODULE_NAVBAR_CURRENCIES_CONTENT_PLACEMENT', 'Right', 'Should the module be loaded in the Left or Right or the Home area of the Navbar?', '6', '2', 'tep_cfg_select_option([\'Left\', \'Right\', \'Home\'], ', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_NAVBAR_CURRENCIES_SORT_ORDER', '530', 'Sort order of display. Lowest is displayed first.', '6', '0', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Account Module', 'MODULE_NAVBAR_ACCOUNT_STATUS', 'True', 'Do you want to add the module to your Navbar?', '6', '1', 'tep_cfg_select_option([\'True\', \'False\'], ', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Placement', 'MODULE_NAVBAR_ACCOUNT_CONTENT_PLACEMENT', 'Left', 'Should the module be loaded in the Left or Right or the Home area of the Navbar?', '6', '2', 'tep_cfg_select_option([\'Left\', \'Right\', \'Home\'], ', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_NAVBAR_ACCOUNT_SORT_ORDER', '540', 'Sort order of display. Lowest is displayed first.', '6', '0', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Special Offers Module', 'MODULE_NAVBAR_SPECIAL_OFFERS_STATUS', 'True', 'Do you want to add the module to your Navbar?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Placement Group', 'MODULE_NAVBAR_SPECIAL_OFFERS_CONTENT_PLACEMENT', 'Left', 'Where should the module be loaded? Lowest is loaded first, per Group.', '6', '2', 'tep_cfg_select_option(array(\'Left\', \'Right\', \'Home\'), ', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_NAVBAR_SPECIAL_OFFERS_SORT_ORDER', '530', 'Sort order of display. Lowest is displayed first.', '6', '3', now()); # Navbar insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Navbar Module', 'MODULE_CONTENT_NAVBAR_STATUS', 'True', 'Should the Navbar be shown? ', '6', '1', 'tep_cfg_select_option([\'True\', \'False\'], ', now()); From a0a12222964f099c255adca7a1a98590621dc8e8 Mon Sep 17 00:00:00 2001 From: gburton Date: Tue, 9 Jun 2020 16:45:52 +0100 Subject: [PATCH 36/48] Install Footer modules as default --- .../content/footer/cm_footer_account.php | 4 ++-- .../content/footer/cm_footer_contact_us.php | 4 ++-- .../footer/cm_footer_information_links.php | 4 ++-- .../modules/content/footer/cm_footer_text.php | 2 +- install/phoenix.sql | 23 ++++++++++++------- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/includes/modules/content/footer/cm_footer_account.php b/includes/modules/content/footer/cm_footer_account.php index c0b0c50c1..9eabd2e76 100644 --- a/includes/modules/content/footer/cm_footer_account.php +++ b/includes/modules/content/footer/cm_footer_account.php @@ -30,7 +30,7 @@ protected function get_parameters() { 'MODULE_CONTENT_FOOTER_ACCOUNT_STATUS' => [ 'title' => 'Enable Account Footer Module', 'value' => 'True', - 'desc' => 'Do you want to enable the Account content module?', + 'desc' => 'Do you want to enable this module?', 'set_func' => "tep_cfg_select_option(['True', 'False'], ", ], 'MODULE_CONTENT_FOOTER_ACCOUNT_CONTENT_WIDTH' => [ @@ -41,7 +41,7 @@ protected function get_parameters() { ], 'MODULE_CONTENT_FOOTER_ACCOUNT_SORT_ORDER' => [ 'title' => 'Sort Order', - 'value' => '0', + 'value' => '20', 'desc' => 'Sort order of display. Lowest is displayed first.', ], ]; diff --git a/includes/modules/content/footer/cm_footer_contact_us.php b/includes/modules/content/footer/cm_footer_contact_us.php index 5863f0f7f..0356d1b94 100644 --- a/includes/modules/content/footer/cm_footer_contact_us.php +++ b/includes/modules/content/footer/cm_footer_contact_us.php @@ -30,7 +30,7 @@ protected function get_parameters() { 'MODULE_CONTENT_FOOTER_CONTACT_US_STATUS' => [ 'title' => 'Enable Contact Us Footer Module', 'value' => 'True', - 'desc' => 'Do you want to enable the Contact Us content module?', + 'desc' => 'Do you want to enable this module?', 'set_func' => "tep_cfg_select_option(['True', 'False'], ", ], 'MODULE_CONTENT_FOOTER_CONTACT_US_CONTENT_WIDTH' => [ @@ -41,7 +41,7 @@ protected function get_parameters() { ], 'MODULE_CONTENT_FOOTER_CONTACT_US_SORT_ORDER' => [ 'title' => 'Sort Order', - 'value' => '0', + 'value' => '30', 'desc' => 'Sort order of display. Lowest is displayed first.', ], ]; diff --git a/includes/modules/content/footer/cm_footer_information_links.php b/includes/modules/content/footer/cm_footer_information_links.php index feade61e3..4ddb1c0bb 100644 --- a/includes/modules/content/footer/cm_footer_information_links.php +++ b/includes/modules/content/footer/cm_footer_information_links.php @@ -30,7 +30,7 @@ protected function get_parameters() { 'MODULE_CONTENT_FOOTER_INFORMATION_STATUS' => [ 'title' => 'Enable Information Links Footer Module', 'value' => 'True', - 'desc' => 'Do you want to enable the Information Links content module?', + 'desc' => 'Do you want to enable the Information Links Footer module?', 'set_func' => "tep_cfg_select_option(['True', 'False'], ", ], 'MODULE_CONTENT_FOOTER_INFORMATION_CONTENT_WIDTH' => [ @@ -41,7 +41,7 @@ protected function get_parameters() { ], 'MODULE_CONTENT_FOOTER_INFORMATION_SORT_ORDER' => [ 'title' => 'Sort Order', - 'value' => '0', + 'value' => '10', 'desc' => 'Sort order of display. Lowest is displayed first.', ], ]; diff --git a/includes/modules/content/footer/cm_footer_text.php b/includes/modules/content/footer/cm_footer_text.php index a98a656ae..516c31cf2 100644 --- a/includes/modules/content/footer/cm_footer_text.php +++ b/includes/modules/content/footer/cm_footer_text.php @@ -41,7 +41,7 @@ protected function get_parameters() { ], 'MODULE_CONTENT_FOOTER_TEXT_SORT_ORDER' => [ 'title' => 'Sort Order', - 'value' => '0', + 'value' => '40', 'desc' => 'Sort order of display. Lowest is displayed first.', ], ]; diff --git a/install/phoenix.sql b/install/phoenix.sql index 775983ffb..f9b5c8718 100644 --- a/install/phoenix.sql +++ b/install/phoenix.sql @@ -1390,7 +1390,7 @@ insert into configuration (configuration_title, configuration_key, configuration INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Installed Template Block Groups', 'TEMPLATE_BLOCK_GROUPS', 'boxes;header_tags', 'This is automatically updated. No need to edit.', '6', '0', now()); # Content Modules -INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Installed Modules', 'MODULE_CONTENT_INSTALLED', 'account/cm_account_gdpr;account/cm_account_title;account/cm_account_set_password;checkout_success/cm_cs_title;checkout_success/cm_cs_redirect_old_order;checkout_success/cm_cs_thank_you;checkout_success/cm_cs_product_notifications;checkout_success/cm_cs_downloads;checkout_success/cm_cs_continue_button;create_account_success/cm_cas_title;create_account_success/cm_cas_message;create_account_success/cm_cas_continue_button;header/cm_header_logo;footer/cm_footer_information_links;footer_suffix/cm_footer_extra_copyright;footer_suffix/cm_footer_extra_icons;gdpr/cm_gdpr_intro;gdpr/cm_gdpr_personal_details;header/cm_header_search;header/cm_header_messagestack;header/cm_header_breadcrumb;index/cm_i_title;index/cm_i_customer_greeting;index/cm_i_text_main;index/cm_i_card_products;index/cm_i_upcoming_products;index_nested/cm_in_title;index_nested/cm_in_category_description;index_nested/cm_in_category_listing;index_nested/cm_in_card_products;index_products/cm_ip_title;index_products/cm_ip_category_manufacturer_description;index_products/cm_ip_product_listing;login/cm_login_title;login/cm_login_form;login/cm_create_account_link;login/cm_forgot_password;navigation/cm_navbar;product_info/cm_pi_name;product_info/cm_pi_price;product_info/cm_pi_review_stars;product_info/cm_pi_modular;product_info/cm_pi_description;product_info/cm_pi_date_available;product_info/cm_pi_reviews;product_info_not_found/cm_pinf_message;shopping_cart/cm_sc_title;shopping_cart/cm_sc_no_products;shopping_cart/cm_sc_product_listing;shopping_cart/cm_sc_order_subtotal;shopping_cart/cm_sc_stock_notice;shopping_cart/cm_sc_checkout;testimonials/cm_t_title;testimonials/cm_t_list', 'This is automatically updated. No need to edit.', '6', '0', now()); +INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Installed Modules', 'MODULE_CONTENT_INSTALLED', 'account/cm_account_gdpr;account/cm_account_title;account/cm_account_set_password;checkout_success/cm_cs_title;checkout_success/cm_cs_redirect_old_order;checkout_success/cm_cs_thank_you;checkout_success/cm_cs_product_notifications;checkout_success/cm_cs_downloads;checkout_success/cm_cs_continue_button;create_account_success/cm_cas_title;create_account_success/cm_cas_message;create_account_success/cm_cas_continue_button;header/cm_header_logo;footer/cm_footer_information_links;footer/cm_footer_account;footer/cm_footer_contact_us;footer/cm_footer_text;footer_suffix/cm_footer_extra_copyright;footer_suffix/cm_footer_extra_icons;gdpr/cm_gdpr_intro;gdpr/cm_gdpr_personal_details;header/cm_header_search;header/cm_header_messagestack;header/cm_header_breadcrumb;index/cm_i_title;index/cm_i_customer_greeting;index/cm_i_text_main;index/cm_i_card_products;index/cm_i_upcoming_products;index_nested/cm_in_title;index_nested/cm_in_category_description;index_nested/cm_in_category_listing;index_nested/cm_in_card_products;index_products/cm_ip_title;index_products/cm_ip_category_manufacturer_description;index_products/cm_ip_product_listing;login/cm_login_title;login/cm_login_form;login/cm_create_account_link;login/cm_forgot_password;navigation/cm_navbar;product_info/cm_pi_name;product_info/cm_pi_price;product_info/cm_pi_review_stars;product_info/cm_pi_modular;product_info/cm_pi_description;product_info/cm_pi_date_available;product_info/cm_pi_reviews;product_info_not_found/cm_pinf_message;shopping_cart/cm_sc_title;shopping_cart/cm_sc_no_products;shopping_cart/cm_sc_product_listing;shopping_cart/cm_sc_order_subtotal;shopping_cart/cm_sc_stock_notice;shopping_cart/cm_sc_checkout;testimonials/cm_t_title;testimonials/cm_t_list', 'This is automatically updated. No need to edit.', '6', '0', now()); INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Set Account Password', 'MODULE_CONTENT_ACCOUNT_SET_PASSWORD_STATUS', 'True', 'Do you want to enable the Set Account Password module?', '6', '1', 'tep_cfg_select_option([\'True\', \'False\'], ', now()); INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Allow Local Passwords', 'MODULE_CONTENT_ACCOUNT_SET_PASSWORD_ALLOW_PASSWORD', 'True', 'Allow local account passwords to be set.', '6', '1', 'tep_cfg_select_option([\'True\', \'False\'], ', now()); INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_CONTENT_ACCOUNT_SET_PASSWORD_SORT_ORDER', '100', 'Sort order of display. Lowest is displayed first.', '6', '0', now()); @@ -1464,17 +1464,24 @@ insert into configuration (configuration_title, configuration_key, configuration insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Width', 'MODULE_CONTENT_HEADER_BREADCRUMB_CONTENT_WIDTH', '12', 'What width container should the content be shown in?', '6', '1', 'tep_cfg_select_option([\'12\', \'11\', \'10\', \'9\', \'8\', \'7\', \'6\', \'5\', \'4\', \'3\', \'2\', \'1\'], ', now()); insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_CONTENT_HEADER_BREADCRUMB_SORT_ORDER', '40', 'Sort order of display. Lowest is displayed first.', '6', '0', now()); -# Footer Links -insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Information Links Footer Module', 'MODULE_CONTENT_FOOTER_INFORMATION_STATUS', 'True', 'Do you want to enable the Information Links content module?', '6', '1', 'tep_cfg_select_option([\'True\', \'False\'], ', now()); +# Footer +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Information Links Footer Module', 'MODULE_CONTENT_FOOTER_INFORMATION_STATUS', 'True', 'Do you want to enable this module?', '6', '1', 'tep_cfg_select_option([\'True\', \'False\'], ', now()); insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Width', 'MODULE_CONTENT_FOOTER_INFORMATION_CONTENT_WIDTH', '3', 'What width container should the content be shown in? (12 = full width, 6 = half width).', '6', '1', 'tep_cfg_select_option([\'12\', \'11\', \'10\', \'9\', \'8\', \'7\', \'6\', \'5\', \'4\', \'3\', \'2\', \'1\'], ', now()); -insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_CONTENT_FOOTER_INFORMATION_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now()); - -# Footer Copyright +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_CONTENT_FOOTER_INFORMATION_SORT_ORDER', '10', 'Sort order of display. Lowest is displayed first.', '6', '0', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Account Footer Module', 'MODULE_CONTENT_FOOTER_ACCOUNT_STATUS', 'True', 'Do you want to enable this module?', '6', '1', 'tep_cfg_select_option([\'True\', \'False\'], ', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Width', 'MODULE_CONTENT_FOOTER_ACCOUNT_CONTENT_WIDTH', '3', 'What width container should the content be shown in? (12 = full width, 6 = half width).', '6', '2', 'tep_cfg_select_option([\'12\', \'11\', \'10\', \'9\', \'8\', \'7\', \'6\', \'5\', \'4\', \'3\', \'2\', \'1\'], ', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_CONTENT_FOOTER_ACCOUNT_SORT_ORDER', '20', 'Sort order of display. Lowest is displayed first.', '6', '0', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Contact Us Footer Module', 'MODULE_CONTENT_FOOTER_CONTACT_US_STATUS', 'True', 'Do you want to enable this module?', '6', '1', 'tep_cfg_select_option([\'True\', \'False\'], ', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Width', 'MODULE_CONTENT_FOOTER_CONTACT_US_CONTENT_WIDTH', '3', 'What width container should the content be shown in? (12 = full width, 6 = half width).', '6', '2', 'tep_cfg_select_option([\'12\', \'11\', \'10\', \'9\', \'8\', \'7\', \'6\', \'5\', \'4\', \'3\', \'2\', \'1\'], ', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_CONTENT_FOOTER_CONTACT_US_SORT_ORDER', '30', 'Sort order of display. Lowest is displayed first.', '6', '0', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Generic Text Footer Module', 'MODULE_CONTENT_FOOTER_TEXT_STATUS', 'True', 'Do you want to enable this module?', '6', '1', 'tep_cfg_select_option([\'True\', \'False\'], ', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Width', 'MODULE_CONTENT_FOOTER_TEXT_CONTENT_WIDTH', '3', 'What width container should the content be shown in? (12 = full width, 6 = half width).', '6', '2', 'tep_cfg_select_option([\'12\', \'11\', \'10\', \'9\', \'8\', \'7\', \'6\', \'5\', \'4\', \'3\', \'2\', \'1\'], ', now()); +insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_CONTENT_FOOTER_TEXT_SORT_ORDER', '40', 'Sort order of display. Lowest is displayed first.', '6', '0', now()); + +# Footer Suffix insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Copyright Details Footer Module', 'MODULE_CONTENT_FOOTER_EXTRA_COPYRIGHT_STATUS', 'True', 'Do you want to enable the Copyright content module?', '6', '1', 'tep_cfg_select_option([\'True\', \'False\'], ', now()); insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Width', 'MODULE_CONTENT_FOOTER_EXTRA_COPYRIGHT_CONTENT_WIDTH', '6', 'What width container should the content be shown in? (12 = full width, 6 = half width).', '6', '1', 'tep_cfg_select_option([\'12\', \'11\', \'10\', \'9\', \'8\', \'7\', \'6\', \'5\', \'4\', \'3\', \'2\', \'1\'], ', now()); insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_CONTENT_FOOTER_EXTRA_COPYRIGHT_SORT_ORDER', '10', 'Sort order of display. Lowest is displayed first.', '6', '0', now()); - -# Footer Icons insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Payment Icons Footer Module', 'MODULE_CONTENT_FOOTER_EXTRA_ICONS_STATUS', 'True', 'Do you want to enable the Payment Icons content module?', '6', '1', 'tep_cfg_select_option([\'True\', \'False\'], ', now()); insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Width', 'MODULE_CONTENT_FOOTER_EXTRA_ICONS_CONTENT_WIDTH', '6', 'What width container should the content be shown in? (12 = full width, 6 = half width).', '6', '1', 'tep_cfg_select_option([\'12\', \'11\', \'10\', \'9\', \'8\', \'7\', \'6\', \'5\', \'4\', \'3\', \'2\', \'1\'], ', now()); insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Icons', 'MODULE_CONTENT_FOOTER_EXTRA_ICONS_DISPLAY', 'apple-pay,bitcoin,cc-paypal', 'Icons to display.', '6', '0', now()); From a7c8375bceee238f9a56b19e02e27df65917fcfc Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Tue, 9 Jun 2020 16:40:09 +0000 Subject: [PATCH 37/48] Use Unix directory separators on Windows --- templates/default/includes/template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/default/includes/template.php b/templates/default/includes/template.php index b504daea0..f9598aa94 100644 --- a/templates/default/includes/template.php +++ b/templates/default/includes/template.php @@ -38,7 +38,7 @@ public static function _get_template_mapping_for($file, $type) { case 'module': return dirname($file) . '/templates/tpl_' . basename($file); case 'ext': - $file = tep_ltrim_once($file, DIR_FS_CATALOG); + $file = tep_ltrim_once(str_replace('\\', '/', $file), DIR_FS_CATALOG); return DIR_FS_CATALOG . "templates/default/includes/$file"; case 'literal': default: From f812e03d69f3c4191c5f9780a008d2b98c7645ab Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Wed, 10 Jun 2020 03:49:27 +0000 Subject: [PATCH 38/48] Test validity --- account_password.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_password.php b/account_password.php index 03580681d..e39fb4822 100644 --- a/account_password.php +++ b/account_password.php @@ -30,7 +30,7 @@ $customer_details = $customer_data->process($page_fields); - if (!empty($customer_details)) { + if (tep_form_processing_is_valid()) { $check_customer_query = tep_db_query($customer_data->build_read(['password'], 'customers', ['id' => (int)$_SESSION['customer_id']])); $check_customer = tep_db_fetch_array($check_customer_query); From 7b934c2ff57634f90afba036ecd1bf7ade679f26 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Wed, 10 Jun 2020 11:56:28 +0000 Subject: [PATCH 39/48] Start new versions --- .../system/versioned/1.0.7.3/order_total.php | 78 +++++++ includes/system/versioned/1.0.7.3/payment.php | 198 ++++++++++++++++++ 2 files changed, 276 insertions(+) create mode 100644 includes/system/versioned/1.0.7.3/order_total.php create mode 100644 includes/system/versioned/1.0.7.3/payment.php diff --git a/includes/system/versioned/1.0.7.3/order_total.php b/includes/system/versioned/1.0.7.3/order_total.php new file mode 100644 index 000000000..43ae81b6c --- /dev/null +++ b/includes/system/versioned/1.0.7.3/order_total.php @@ -0,0 +1,78 @@ +modules = explode(';', MODULE_ORDER_TOTAL_INSTALLED); + + foreach($this->modules as $value) { + include('includes/languages/' . $language . '/modules/order_total/' . $value); + include('includes/modules/order_total/' . $value); + + $class = substr($value, 0, strrpos($value, '.')); + $GLOBALS[$class] = new $class; + } + } + } + + function process() { + $order_total_array = array(); + if (is_array($this->modules)) { + foreach($this->modules as $value) { + $class = substr($value, 0, strrpos($value, '.')); + if ($GLOBALS[$class]->enabled) { + $GLOBALS[$class]->output = array(); + $GLOBALS[$class]->process(); + + for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) { + if (tep_not_null($GLOBALS[$class]->output[$i]['title']) && tep_not_null($GLOBALS[$class]->output[$i]['text'])) { + $order_total_array[] = array('code' => $GLOBALS[$class]->code, + 'title' => $GLOBALS[$class]->output[$i]['title'], + 'text' => $GLOBALS[$class]->output[$i]['text'], + 'value' => $GLOBALS[$class]->output[$i]['value'], + 'sort_order' => $GLOBALS[$class]->sort_order); + } + } + } + } + } + + return $order_total_array; + } + + function output() { + $output_string = ''; + if (is_array($this->modules)) { + foreach($this->modules as $value) { + $class = substr($value, 0, strrpos($value, '.')); + if ($GLOBALS[$class]->enabled) { + $size = sizeof($GLOBALS[$class]->output); + for ($i=0; $i<$size; $i++) { + $output_string .= ''; + $output_string .= '' . $GLOBALS[$class]->output[$i]['title'] . ''; + $output_string .= '' . $GLOBALS[$class]->output[$i]['text'] . ''; + $output_string .= ''; + } + } + } + } + + return $output_string; + } + } +?> \ No newline at end of file diff --git a/includes/system/versioned/1.0.7.3/payment.php b/includes/system/versioned/1.0.7.3/payment.php new file mode 100644 index 000000000..1c0575a72 --- /dev/null +++ b/includes/system/versioned/1.0.7.3/payment.php @@ -0,0 +1,198 @@ +modules = explode(';', MODULE_PAYMENT_INSTALLED); + + $include_modules = []; + + if ( (tep_not_null($module)) && (in_array($module . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), $this->modules)) ) { + $this->selected_module = $module; + + $include_modules[] = array('class' => $module, 'file' => $module . '.php'); + } else { + foreach($this->modules as $value) { + $class = substr($value, 0, strrpos($value, '.')); + $include_modules[] = array('class' => $class, 'file' => $value); + } + } + + for ($i=0, $n=count($include_modules); $i<$n; $i++) { + include('includes/languages/' . $_SESSION['language'] . '/modules/payment/' . $include_modules[$i]['file']); + include('includes/modules/payment/' . $include_modules[$i]['file']); + + $GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class']; + } + +// if there is only one payment method, select it as default because in +// checkout_confirmation.php the $payment variable is being assigned the +// $_POST['payment'] value which will be empty (no radio button selection possible) + if ( (tep_count_payment_modules() == 1) && (!isset($_SESSION['payment']) || !is_object($GLOBALS[$_SESSION['payment']] ?? null)) ) { + $_SESSION['payment'] = $include_modules[0]['class']; + } + + if ( (tep_not_null($module)) && (in_array($module, $this->modules)) && (isset($GLOBALS[$module]->form_action_url)) ) { + $this->form_action_url = $GLOBALS[$module]->form_action_url; + } + } + } + +// class methods +/* The following method is needed in the checkout_confirmation.php page + due to a chicken and egg problem with the payment class and order class. + The payment modules needs the order destination data for the dynamic status + feature, and the order class needs the payment module title. + The following method is a work-around to implementing the method in all + payment modules available which would break the modules in the contributions + section. This should be looked into again post 2.2. +*/ + function update_status() { + if (is_array($this->modules)) { + if (is_object($GLOBALS[$this->selected_module])) { + if (method_exists($GLOBALS[$this->selected_module], 'update_status')) { + $GLOBALS[$this->selected_module]->update_status(); + } + } + } + } + + function javascript_validation() { + $js = ''; + if (is_array($this->modules)) { + $js = '' . "\n"; + } + + return $js; + } + + function checkout_initialization_method() { + $initialize_array = array(); + + if (is_array($this->modules)) { + foreach($this->modules as $value) { + $class = substr($value, 0, strrpos($value, '.')); + if ($GLOBALS[$class]->enabled && method_exists($GLOBALS[$class], 'checkout_initialization_method')) { + $initialize_array[] = $GLOBALS[$class]->checkout_initialization_method(); + } + } + } + + return $initialize_array; + } + + function selection() { + $selection_array = array(); + + if (is_array($this->modules)) { + foreach($this->modules as $value) { + $class = substr($value, 0, strrpos($value, '.')); + if ($GLOBALS[$class]->enabled) { + $selection = $GLOBALS[$class]->selection(); + if (is_array($selection)) $selection_array[] = $selection; + } + } + } + + return $selection_array; + } + + function pre_confirmation_check() { + if (is_array($this->modules)) { + if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) { + $GLOBALS[$this->selected_module]->pre_confirmation_check(); + } + } + } + + function confirmation() { + if (is_array($this->modules)) { + if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) { + return $GLOBALS[$this->selected_module]->confirmation(); + } + } + } + + function process_button() { + if (is_array($this->modules)) { + if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) { + return $GLOBALS[$this->selected_module]->process_button(); + } + } + } + + function before_process() { + if (is_array($this->modules)) { + if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) { + return $GLOBALS[$this->selected_module]->before_process(); + } + } + } + + function after_process() { + if (is_array($this->modules)) { + if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) { + return $GLOBALS[$this->selected_module]->after_process(); + } + } + } + + function get_error() { + if (is_array($this->modules)) { + if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) { + return $GLOBALS[$this->selected_module]->get_error(); + } + } + } + } +?> From 74bccf4f4afa8eb4f0b75a7add2a9d108b8a77fe Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Wed, 10 Jun 2020 12:21:18 +0000 Subject: [PATCH 40/48] Rely on autoload for modules --- .../system/versioned/1.0.7.3/order_total.php | 52 +++++---- includes/system/versioned/1.0.7.3/payment.php | 100 +++++++++--------- 2 files changed, 72 insertions(+), 80 deletions(-) diff --git a/includes/system/versioned/1.0.7.3/order_total.php b/includes/system/versioned/1.0.7.3/order_total.php index 43ae81b6c..21b62e680 100644 --- a/includes/system/versioned/1.0.7.3/order_total.php +++ b/includes/system/versioned/1.0.7.3/order_total.php @@ -5,47 +5,45 @@ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com - Copyright (c) 2003 osCommerce + Copyright (c) 2020 osCommerce Released under the GNU General Public License */ class order_total { - var $modules; + + public $modules; // class constructor function __construct() { - global $language; - if (defined('MODULE_ORDER_TOTAL_INSTALLED') && tep_not_null(MODULE_ORDER_TOTAL_INSTALLED)) { $this->modules = explode(';', MODULE_ORDER_TOTAL_INSTALLED); - foreach($this->modules as $value) { - include('includes/languages/' . $language . '/modules/order_total/' . $value); - include('includes/modules/order_total/' . $value); - - $class = substr($value, 0, strrpos($value, '.')); - $GLOBALS[$class] = new $class; + foreach ($this->modules as $value) { + $class = pathinfo($value, PATHINFO_FILENAME); + $GLOBALS[$class] = new $class(); } } } function process() { - $order_total_array = array(); + $order_total_array = []; if (is_array($this->modules)) { - foreach($this->modules as $value) { - $class = substr($value, 0, strrpos($value, '.')); + foreach ($this->modules as $value) { + $class = pathinfo($value, PATHINFO_FILENAME); if ($GLOBALS[$class]->enabled) { - $GLOBALS[$class]->output = array(); + $GLOBALS[$class]->output = []; $GLOBALS[$class]->process(); - for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) { - if (tep_not_null($GLOBALS[$class]->output[$i]['title']) && tep_not_null($GLOBALS[$class]->output[$i]['text'])) { - $order_total_array[] = array('code' => $GLOBALS[$class]->code, - 'title' => $GLOBALS[$class]->output[$i]['title'], - 'text' => $GLOBALS[$class]->output[$i]['text'], - 'value' => $GLOBALS[$class]->output[$i]['value'], - 'sort_order' => $GLOBALS[$class]->sort_order); + foreach ($GLOBALS[$class]->output as $output) { + if (tep_not_null($output['title']) && tep_not_null($output['text'])) { + $order_total_array[] = [ + 'code' => $GLOBALS[$class]->code, + 'title' => $output['title'], + 'text' => $output['text'], + 'value' => $output['value'], + 'sort_order' => $GLOBALS[$class]->sort_order, + ]; } } } @@ -58,14 +56,13 @@ function process() { function output() { $output_string = ''; if (is_array($this->modules)) { - foreach($this->modules as $value) { - $class = substr($value, 0, strrpos($value, '.')); + foreach ($this->modules as $value) { + $class = pathinfo($value, PATHINFO_FILENAME); if ($GLOBALS[$class]->enabled) { - $size = sizeof($GLOBALS[$class]->output); - for ($i=0; $i<$size; $i++) { + foreach ($GLOBALS[$class]->output as $output) { $output_string .= ''; - $output_string .= '' . $GLOBALS[$class]->output[$i]['title'] . ''; - $output_string .= '' . $GLOBALS[$class]->output[$i]['text'] . ''; + $output_string .= '' . $output['title'] . ''; + $output_string .= '' . $output['text'] . ''; $output_string .= ''; } } @@ -75,4 +72,3 @@ function output() { return $output_string; } } -?> \ No newline at end of file diff --git a/includes/system/versioned/1.0.7.3/payment.php b/includes/system/versioned/1.0.7.3/payment.php index 1c0575a72..0a23332bb 100644 --- a/includes/system/versioned/1.0.7.3/payment.php +++ b/includes/system/versioned/1.0.7.3/payment.php @@ -5,39 +5,37 @@ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com - Copyright (c) 2012 osCommerce + Copyright (c) 2020 osCommerce Released under the GNU General Public License */ class payment { + public $modules, $selected_module; // class constructor function __construct($module = '') { - global $PHP_SELF; - if (defined('MODULE_PAYMENT_INSTALLED') && tep_not_null(MODULE_PAYMENT_INSTALLED)) { $this->modules = explode(';', MODULE_PAYMENT_INSTALLED); $include_modules = []; - if ( (tep_not_null($module)) && (in_array($module . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), $this->modules)) ) { + if ( (tep_not_null($module)) && (in_array($module . '.php', $this->modules)) ) { $this->selected_module = $module; - $include_modules[] = array('class' => $module, 'file' => $module . '.php'); + $include_modules[] = ['class' => $module, 'file' => "$module.php"]; } else { - foreach($this->modules as $value) { - $class = substr($value, 0, strrpos($value, '.')); - $include_modules[] = array('class' => $class, 'file' => $value); + foreach ($this->modules as $value) { + $include_modules[] = [ + 'class' => pathinfo($value, PATHINFO_FILENAME), + 'file' => $value, + ]; } } - for ($i=0, $n=count($include_modules); $i<$n; $i++) { - include('includes/languages/' . $_SESSION['language'] . '/modules/payment/' . $include_modules[$i]['file']); - include('includes/modules/payment/' . $include_modules[$i]['file']); - - $GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class']; + foreach ($include_modules as $include_module) { + $GLOBALS[$include_module['class']] = new $include_module['class'](); } // if there is only one payment method, select it as default because in @@ -61,14 +59,13 @@ function __construct($module = '') { The following method is a work-around to implementing the method in all payment modules available which would break the modules in the contributions section. This should be looked into again post 2.2. -*/ +*/ function update_status() { - if (is_array($this->modules)) { - if (is_object($GLOBALS[$this->selected_module])) { - if (method_exists($GLOBALS[$this->selected_module], 'update_status')) { - $GLOBALS[$this->selected_module]->update_status(); - } - } + if (is_array($this->modules) + && is_object($GLOBALS[$this->selected_module]) + && method_exists($GLOBALS[$this->selected_module], 'update_status')) + { + $GLOBALS[$this->selected_module]->update_status(); } } @@ -93,7 +90,7 @@ function javascript_validation() { ' }' . "\n\n"; foreach($this->modules as $value) { - $class = substr($value, 0, strrpos($value, '.')); + $class = pathinfo($value, PATHINFO_FILENAME); if ($GLOBALS[$class]->enabled) { $js .= $GLOBALS[$class]->javascript_validation(); } @@ -117,11 +114,12 @@ function javascript_validation() { } function checkout_initialization_method() { - $initialize_array = array(); + $initialize_array = []; if (is_array($this->modules)) { foreach($this->modules as $value) { - $class = substr($value, 0, strrpos($value, '.')); + $class = pathinfo($value, PATHINFO_FILENAME); + if ($GLOBALS[$class]->enabled && method_exists($GLOBALS[$class], 'checkout_initialization_method')) { $initialize_array[] = $GLOBALS[$class]->checkout_initialization_method(); } @@ -132,14 +130,18 @@ function checkout_initialization_method() { } function selection() { - $selection_array = array(); + $selection_array = []; if (is_array($this->modules)) { - foreach($this->modules as $value) { - $class = substr($value, 0, strrpos($value, '.')); + foreach ($this->modules as $value) { + $class = pathinfo($value, PATHINFO_FILENAME); + if ($GLOBALS[$class]->enabled) { $selection = $GLOBALS[$class]->selection(); - if (is_array($selection)) $selection_array[] = $selection; + + if (is_array($selection)) { + $selection_array[] = $selection; + } } } } @@ -147,52 +149,46 @@ function selection() { return $selection_array; } + protected function is_selected_enabled() { + return (is_array($this->modules) + && is_object($GLOBALS[$this->selected_module]) + && ($GLOBALS[$this->selected_module]->enabled) ); + } + function pre_confirmation_check() { - if (is_array($this->modules)) { - if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) { - $GLOBALS[$this->selected_module]->pre_confirmation_check(); - } + if ($this->is_selected_enabled()) { + $GLOBALS[$this->selected_module]->pre_confirmation_check(); } } function confirmation() { - if (is_array($this->modules)) { - if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) { - return $GLOBALS[$this->selected_module]->confirmation(); - } + if ($this->is_selected_enabled()) { + return $GLOBALS[$this->selected_module]->confirmation(); } } function process_button() { - if (is_array($this->modules)) { - if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) { - return $GLOBALS[$this->selected_module]->process_button(); - } + if ($this->is_selected_enabled()) { + return $GLOBALS[$this->selected_module]->process_button(); } } function before_process() { - if (is_array($this->modules)) { - if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) { - return $GLOBALS[$this->selected_module]->before_process(); - } + if ($this->is_selected_enabled()) { + return $GLOBALS[$this->selected_module]->before_process(); } } function after_process() { - if (is_array($this->modules)) { - if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) { - return $GLOBALS[$this->selected_module]->after_process(); - } + if ($this->is_selected_enabled()) { + return $GLOBALS[$this->selected_module]->after_process(); } } function get_error() { - if (is_array($this->modules)) { - if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) { - return $GLOBALS[$this->selected_module]->get_error(); - } + if ($this->is_selected_enabled()) { + return $GLOBALS[$this->selected_module]->get_error(); } } + } -?> From 4460a1934305982005eef1ccda4a183aed2394c6 Mon Sep 17 00:00:00 2001 From: Rainer Schmied Date: Wed, 10 Jun 2020 15:41:48 +0200 Subject: [PATCH 41/48] move forms --- admin/products_attributes.php | 166 +++++++++++++++++++++------------- 1 file changed, 102 insertions(+), 64 deletions(-) diff --git a/admin/products_attributes.php b/admin/products_attributes.php index 3ef7d4b1d..92514e339 100644 --- a/admin/products_attributes.php +++ b/admin/products_attributes.php @@ -194,9 +194,11 @@ if (tep_db_num_rows($products)) { ?> - - - + + + + + - - + + + + '; $inputs = null; for ($i = 0, $n = sizeof($languages); $i < $n; $i ++) { $option_name = tep_db_query("select products_options_name from products_options where products_options_id = '" . $options_values['products_options_id'] . "' and language_id = '" . $languages[$i]['id'] . "'"); @@ -271,14 +274,24 @@ } ?> - - + '; } else { ?> @@ -294,7 +307,6 @@ } if ($action != 'update_option') { - echo ''; $inputs = null; for ($i = 0, $n = sizeof($languages); $i < $n; $i ++) { $inputs .= '
'; @@ -306,17 +318,28 @@ } ?>
- - + '; } - } - ?> - -
- - - + '; ?> +
+
+ + +
+
+ +
+
+ +
+
+ +
+ '; ?> +
+
+ +
+
+ +
+
+ +
-
+ ?> + + + +
'; $inputs = null; for ($i = 0, $n = sizeof($languages); $i < $n; $i ++) { $value_name = tep_db_query("select products_options_values_name from products_options_values where products_options_values_id = '" . (int)$values_values['products_options_values_id'] . "' and language_id = '" . (int)$languages[$i]['id'] . "'"); @@ -421,23 +443,33 @@ } ?> - + + '; ?> - - - - +
+
+ +
+
+ +
+
+ +
+
+ + '; @@ -455,37 +487,43 @@ $next_id = $max_values_id_values['next_id']; } if ($action != 'update_option_value') { - echo '
'; ?> - - '; - $inputs .= '
'; - } - ?> - - - - - + + '; ?> +
+
+ '; + $inputs .= '
'; + } + ?> + +
+
+ + +
+
+ +
+ + - '; } ?> From 53038888791a1f736f9e27f4eeb13062b20307ff Mon Sep 17 00:00:00 2001 From: Rainer Schmied Date: Wed, 10 Jun 2020 17:49:27 +0200 Subject: [PATCH 42/48] fix colspan --- admin/products_attributes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/products_attributes.php b/admin/products_attributes.php index 92514e339..913739700 100644 --- a/admin/products_attributes.php +++ b/admin/products_attributes.php @@ -274,7 +274,7 @@ } ?> - + '; ?>
From 3b5f689dc05695dade571f7923e68339fe7d3724 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Thu, 11 Jun 2020 09:51:11 +0000 Subject: [PATCH 43/48] Fix missing getIpAddress error --- .../paypal/modules/DP/api/DoDirectPayment.php | 36 +++++++++--------- .../paypal/modules/DP/api/PayflowPayment.php | 38 ++++++++++--------- 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/includes/apps/paypal/modules/DP/api/DoDirectPayment.php b/includes/apps/paypal/modules/DP/api/DoDirectPayment.php index 5f409f9e4..1fe0be423 100644 --- a/includes/apps/paypal/modules/DP/api/DoDirectPayment.php +++ b/includes/apps/paypal/modules/DP/api/DoDirectPayment.php @@ -5,7 +5,7 @@ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com - Copyright (c) 2014 osCommerce + Copyright (c) 2020 osCommerce Released under the GNU General Public License */ @@ -17,32 +17,34 @@ function OSCOM_PayPal_DP_Api_DoDirectPayment($OSCOM_PayPal, $server, $extra_para $api_url = 'https://api-3t.sandbox.paypal.com/nvp'; } - $params = array('USER' => $OSCOM_PayPal->getCredentials('DP', 'username'), - 'PWD' => $OSCOM_PayPal->getCredentials('DP', 'password'), - 'SIGNATURE' => $OSCOM_PayPal->getCredentials('DP', 'signature'), - 'VERSION' => $OSCOM_PayPal->getApiVersion(), - 'METHOD' => 'DoDirectPayment', - 'PAYMENTACTION' => (OSCOM_APP_PAYPAL_DP_TRANSACTION_METHOD == '1') ? 'Sale' : 'Authorization', - 'IPADDRESS' => $OSCOM_PayPal->getIpAddress(), - 'BUTTONSOURCE' => $OSCOM_PayPal->getIdentifier()); - - if ( is_array($extra_params) && !empty($extra_params) ) { + $params = [ + 'USER' => $OSCOM_PayPal->getCredentials('DP', 'username'), + 'PWD' => $OSCOM_PayPal->getCredentials('DP', 'password'), + 'SIGNATURE' => $OSCOM_PayPal->getCredentials('DP', 'signature'), + 'VERSION' => $OSCOM_PayPal->getApiVersion(), + 'METHOD' => 'DoDirectPayment', + 'PAYMENTACTION' => (OSCOM_APP_PAYPAL_DP_TRANSACTION_METHOD == '1') ? 'Sale' : 'Authorization', + 'IPADDRESS' => tep_get_ip_address(), + 'BUTTONSOURCE' => $OSCOM_PayPal->getIdentifier(), + ]; + + if ( !empty($extra_params) && is_array($extra_params) ) { $params = array_merge($params, $extra_params); } $post_string = ''; - foreach ( $params as $key => $value ) { $post_string .= $key . '=' . urlencode(utf8_encode(trim($value))) . '&'; } - $post_string = substr($post_string, 0, -1); + $post_string = substr($post_string, 0, -strlen('&')); $response = $OSCOM_PayPal->makeApiCall($api_url, $post_string); parse_str($response, $response_array); - return array('res' => $response_array, - 'success' => in_array($response_array['ACK'], array('Success', 'SuccessWithWarning')), - 'req' => $params); + return [ + 'res' => $response_array, + 'success' => in_array($response_array['ACK'], ['Success', 'SuccessWithWarning']), + 'req' => $params, + ]; } -?> diff --git a/includes/apps/paypal/modules/DP/api/PayflowPayment.php b/includes/apps/paypal/modules/DP/api/PayflowPayment.php index fb1a0445f..ab7ae727b 100644 --- a/includes/apps/paypal/modules/DP/api/PayflowPayment.php +++ b/includes/apps/paypal/modules/DP/api/PayflowPayment.php @@ -5,7 +5,7 @@ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com - Copyright (c) 2014 osCommerce + Copyright (c) 2020 osCommerce Released under the GNU General Public License */ @@ -17,21 +17,22 @@ function OSCOM_PayPal_DP_Api_PayflowPayment($OSCOM_PayPal, $server, $extra_param $api_url = 'https://pilot-payflowpro.paypal.com'; } - $params = array('USER' => $OSCOM_PayPal->hasCredentials('DP', 'payflow_user') ? $OSCOM_PayPal->getCredentials('DP', 'payflow_user') : $OSCOM_PayPal->getCredentials('DP', 'payflow_vendor'), - 'VENDOR' => $OSCOM_PayPal->getCredentials('DP', 'payflow_vendor'), - 'PARTNER' => $OSCOM_PayPal->getCredentials('DP', 'payflow_partner'), - 'PWD' => $OSCOM_PayPal->getCredentials('DP', 'payflow_password'), - 'TENDER' => 'C', - 'TRXTYPE' => (OSCOM_APP_PAYPAL_DP_TRANSACTION_METHOD == '1') ? 'S' : 'A', - 'CUSTIP' => $OSCOM_PayPal->getIpAddress(), - 'BUTTONSOURCE' => $OSCOM_PayPal->getIdentifier()); - - if ( is_array($extra_params) && !empty($extra_params) ) { + $params = [ + 'USER' => $OSCOM_PayPal->getCredentials('DP', ($OSCOM_PayPal->hasCredentials('DP', 'payflow_user') ? 'payflow_user' : 'payflow_vendor')), + 'VENDOR' => $OSCOM_PayPal->getCredentials('DP', 'payflow_vendor'), + 'PARTNER' => $OSCOM_PayPal->getCredentials('DP', 'payflow_partner'), + 'PWD' => $OSCOM_PayPal->getCredentials('DP', 'payflow_password'), + 'TENDER' => 'C', + 'TRXTYPE' => (OSCOM_APP_PAYPAL_DP_TRANSACTION_METHOD == '1') ? 'S' : 'A', + 'CUSTIP' => tep_get_ip_address(), + 'BUTTONSOURCE' => $OSCOM_PayPal->getIdentifier(), + ]; + + if ( !empty($extra_params) && is_array($extra_params) ) { $params = array_merge($params, $extra_params); } - $headers = array(); - + $headers = []; if ( isset($params['_headers']) ) { $headers = $params['_headers']; @@ -44,13 +45,14 @@ function OSCOM_PayPal_DP_Api_PayflowPayment($OSCOM_PayPal, $server, $extra_param $post_string .= $key . '[' . strlen(trim($value)) . ']=' . trim($value) . '&'; } - $post_string = substr($post_string, 0, -1); + $post_string = substr($post_string, 0, -strlen('&')); $response = $OSCOM_PayPal->makeApiCall($api_url, $post_string, $headers); parse_str($response, $response_array); - return array('res' => $response_array, - 'success' => ($response_array['RESULT'] == '0'), - 'req' => $params); + return [ + 'res' => $response_array, + 'success' => ($response_array['RESULT'] == '0'), + 'req' => $params, + ]; } -?> From e8354c7e7d6f9a221cc9497aa99d03fc8125a205 Mon Sep 17 00:00:00 2001 From: Rainer Schmied Date: Thu, 11 Jun 2020 19:08:35 +0200 Subject: [PATCH 44/48] Fix duplicated form end tag and form indent --- admin/products_attributes.php | 45 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/admin/products_attributes.php b/admin/products_attributes.php index 913739700..02f70578d 100644 --- a/admin/products_attributes.php +++ b/admin/products_attributes.php @@ -445,34 +445,33 @@ '; ?> - -
-
- -
-
- -
-
- + +
+
+ +
+
+ +
+
+ +
-
'; } else { ?> From 747dbf47e72885ffd22d3dd9dd3459ecc1d7fa95 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sat, 13 Jun 2020 09:46:56 +0000 Subject: [PATCH 45/48] Fix attributes price --- includes/system/versioned/1.0.7.3/shopping_cart.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/system/versioned/1.0.7.3/shopping_cart.php b/includes/system/versioned/1.0.7.3/shopping_cart.php index 21b8e21d4..f82e2566a 100644 --- a/includes/system/versioned/1.0.7.3/shopping_cart.php +++ b/includes/system/versioned/1.0.7.3/shopping_cart.php @@ -263,7 +263,9 @@ function calculate() { } // attributes price - $this->total += $this->attributes_price($products_id); + if (!empty($this->contents[$products_id]['attributes'])) { + $this->total += $currencies->calculate_price($this->attributes_price($products_id), $products_tax, $qty); + } } } From f8f3616595886019ac1b7a2371ff3b32f05f3e12 Mon Sep 17 00:00:00 2001 From: gburton Date: Sat, 13 Jun 2020 17:08:53 +0100 Subject: [PATCH 46/48] Clean Up Forms --- admin/products_attributes.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/admin/products_attributes.php b/admin/products_attributes.php index 02f70578d..7cf6b6e44 100644 --- a/admin/products_attributes.php +++ b/admin/products_attributes.php @@ -276,7 +276,7 @@ '; ?> -
+
@@ -284,7 +284,7 @@
-
+
@@ -320,11 +320,11 @@ '; ?> -
+
-
+
@@ -446,7 +446,7 @@ '; ?> -
+
-
+
-
+
From 10a9d043e5793b3f158e4858f4fb92478dfe4bb3 Mon Sep 17 00:00:00 2001 From: gburton Date: Sat, 13 Jun 2020 17:13:29 +0100 Subject: [PATCH 47/48] Admin Dropdowns get their own stylesheet file. --- .../admin/siteWide/styleSheetDropdown.php | 21 +++++++++++++++++++ includes/hooks/admin/siteWide/styleSheets.php | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 includes/hooks/admin/siteWide/styleSheetDropdown.php diff --git a/includes/hooks/admin/siteWide/styleSheetDropdown.php b/includes/hooks/admin/siteWide/styleSheetDropdown.php new file mode 100644 index 000000000..c32f4dd33 --- /dev/null +++ b/includes/hooks/admin/siteWide/styleSheetDropdown.php @@ -0,0 +1,21 @@ +@media (min-width: 768px) { #navbarAdmin > ul.navbar-nav > li.dropdown:hover > div.dropdown-menu { display: block; } }' . PHP_EOL; + + return $admin_css; + } + +} diff --git a/includes/hooks/admin/siteWide/styleSheets.php b/includes/hooks/admin/siteWide/styleSheets.php index 900482867..3a3c7e517 100644 --- a/includes/hooks/admin/siteWide/styleSheets.php +++ b/includes/hooks/admin/siteWide/styleSheets.php @@ -14,7 +14,7 @@ class hook_admin_siteWide_styleSheets { function listen_injectSiteStart() { $admin_css = '' . PHP_EOL; - $admin_css .= '' . PHP_EOL; + $admin_css .= '' . PHP_EOL; $admin_css .= '' . PHP_EOL; return $admin_css; From dfe01ebdb12ef1ef23609bf64b9c27e7bddea094 Mon Sep 17 00:00:00 2001 From: gburton Date: Sat, 13 Jun 2020 17:44:56 +0100 Subject: [PATCH 48/48] 1.0.7.3 --- includes/version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/version.php b/includes/version.php index 5450a5fba..9e301f939 100644 --- a/includes/version.php +++ b/includes/version.php @@ -1 +1 @@ -1.0.7.2 +1.0.7.3