function tep_get_parents(&$categories, $categories_id, $table = '') { if ($table == TABLE_SECTIONS) { $field = 'sections_id'; } else { $table = TABLE_CATEGORIES; $field = 'categories_id'; } $parent_query = tep_db_query("select parent_id from " . tep_db_input($table) . " where " . $field . " = '" . (int) $categories_id . "' limit 1"); $parent = tep_db_fetch_array($parent_query); if ($parent['parent_id'] == 0) { return true; } $categories[sizeof($categories)] = $parent['parent_id']; if ($parent['parent_id'] != $categories_id) { tep_get_parents($categories, $parent['parent_id'], $table); } }
<?php require 'includes/application_top.php'; // calculate category path if (isset($HTTP_GET_VARS['cPath'])) { $cPath = $HTTP_GET_VARS['cPath']; $current_category_id = end(explode('_', $HTTP_GET_VARS['cPath'])); } else { $cPath = ''; $current_category_id = 0; } if (tep_not_null($cPath)) { $cPath_array = array($current_category_id); tep_get_parents($cPath_array, $current_category_id, TABLE_CATEGORIES); $cPath_array = array_reverse($cPath_array); // $cPath_array = tep_parse_category_path($cPath); $cPath = implode('_', $cPath_array); $current_category_id = $cPath_array[sizeof($cPath_array) - 1]; } else { $current_category_id = 0; } require DIR_WS_CLASSES . 'currencies.php'; $currencies = new currencies(); $action = isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : ''; $bPath = isset($HTTP_GET_VARS['bPath']) ? $HTTP_GET_VARS['bPath'] : ''; $boards_statuses = array('0' => BOARDS_STATUS_ON_MODERATION, '1' => BOARDS_STATUS_ACCEPTED, '2' => BOARDS_STATUS_REFUSED, '3' => BOARDS_STATUS_SOLD); $boards_statuses_array = array(array('id' => '', 'text' => '- - - - - - -')); reset($boards_statuses); while (list($status_id, $status_name) = each($boards_statuses)) { $boards_statuses_array[] = array('id' => $status_id + 1, 'text' => $status_name); }
function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) { global $request_type, $session_started, $SID, $spider_flag; if (!tep_not_null($page)) { $page = FILENAME_DEFAULT; } $link = ''; $redirect_url = ''; $categories_id = ''; $products_id = ''; $categories_parameters = ''; $sections_id = ''; $information_id = ''; $sections_parameters = ''; $news_id = ''; $news_parameters = ''; $cname = ''; $sname = ''; $nname = ''; $rname = ''; $mname = ''; $product_type_id = 0; if (basename($page) == FILENAME_CATEGORIES) { $params = explode("&", $parameters); reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'cPath') { $categories_id = $param_value; } elseif ($param_name == 'categories_id') { $categories_id = $param_value; } elseif ($param_name == 'products_id') { $products_id = $param_value; } elseif ($param_name == 'tPath') { $product_type_id = $param_value; } else { $categories_parameters .= (tep_not_null($categories_parameters) ? '&' : '') . $param; } if ($param_name == 'cName') { $cname = $param_value; # if (substr($cname, -1)=='/') $cname = substr($cname, 0, -1); # if (substr($cname, 0, 1)=='/') $cname = substr($cname, 1); } } if (tep_not_null($products_id) && empty($categories_id)) { $categories_id = tep_get_product_path($products_id); } $current_category_id = 0; if (tep_not_null($categories_id)) { $last_id = end(explode('_', $categories_id)); $parent_categories = array($last_id); tep_get_parents($parent_categories, $last_id); $parent_categories = array_reverse($parent_categories); reset($parent_categories); while (list(, $category_id) = each($parent_categories)) { $categories_path_query = tep_db_query("select categories_path, products_types_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int) $category_id . "' limit 1"); if (tep_db_num_rows($categories_path_query) > 0) { $categories_path = tep_db_fetch_array($categories_path_query); if (tep_not_null($categories_path['categories_path'])) { $link .= $categories_path['categories_path'] . '/'; } else { $link .= $category_id . '/'; } $current_category_id = $category_id; $product_type_id = $categories_path['products_types_id']; } } } if (empty($categories_id) && empty($products_id) && tep_not_null($cname)) { $link .= $cname; } $parameters = $categories_parameters; } elseif (basename($page) == FILENAME_PRODUCT_INFO) { $params = explode("&", $parameters); reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'products_id') { $products_id = $param_value; } else { $categories_parameters .= (tep_not_null($categories_parameters) ? '&' : '') . $param; } } if (tep_not_null($products_id)) { $link .= $products_id . '.html'; } $parameters = $categories_parameters; } elseif (basename($page) == FILENAME_SPECIALS) { $params = explode("&", $parameters); $year = ''; $month = ''; $week = ''; reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'tPath') { $tpath = $param_value; } elseif ($param_name == 'year') { $year = (int) $param_value; } elseif ($param_name == 'month') { $month = (int) $param_value; } elseif ($param_name == 'week') { $week = (int) $param_value; } elseif ($param_name == 'view') { $specials_view = $param_value; } else { $types_parameters .= (tep_not_null($types_parameters) ? '&' : '') . $param; } } $link .= 'specials/'; if (tep_not_null($tpath)) { $types_path_query = tep_db_query("select specials_types_path from " . TABLE_SPECIALS_TYPES . " where specials_types_id = '" . (int) $tpath . "' limit 1"); $types_path = tep_db_fetch_array($types_path_query); if (tep_not_null($types_path['specials_types_path'])) { $link .= $types_path['specials_types_path'] . '/'; if ($specials_view == 'rss') { $link = substr($link, 0, -1) . '.rss'; $types_parameters = ''; $add_session_id = false; } elseif ($year > 2000 && $year <= date('Y')) { $link .= $year . '/'; if ($month > 0 && $month <= 12) { $m_array = array('', 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'); // $link .= $m_array[(int)$month] . '/'; $link .= sprintf('%02d', (int) $month) . '/'; if ($week > 0 && $week <= 53) { $link .= (int) $week . '/'; } } } } } $parameters = $types_parameters; } elseif (basename($page) == FILENAME_REVIEWS) { $params = explode("&", $parameters); reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'tPath') { $tpath = $param_value; } elseif ($param_name == 'view') { $reviews_view = $param_value; } else { $types_parameters .= (tep_not_null($types_parameters) ? '&' : '') . $param; } if ($param_name == 'reviews_id') { $reviews_id = $param_value; } } $link .= 'reviews/'; if (empty($tpath) && $reviews_id > 0) { $review_type_query = tep_db_query("select reviews_types_id from " . TABLE_REVIEWS . " where reviews_id = '" . (int) $reviews_id . "'"); $review_type = tep_db_fetch_array($review_type_query); $tpath = $review_type['reviews_types_id']; } if (tep_not_null($tpath)) { $types_path_query = tep_db_query("select reviews_types_path from " . TABLE_REVIEWS_TYPES . " where reviews_types_id = '" . (int) $tpath . "' limit 1"); $types_path = tep_db_fetch_array($types_path_query); if (tep_not_null($types_path['reviews_types_path'])) { $link .= $types_path['reviews_types_path'] . '/'; if ($reviews_view == 'rss') { $link = substr($link, 0, -1) . '.rss'; $types_parameters = ''; $add_session_id = false; } } } $parameters = $types_parameters; } elseif (basename($page) == FILENAME_BOARDS) { $params = explode("&", $parameters); reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'tPath') { $tpath = $param_value; } elseif ($param_name == 'boards_id') { $boards_id = $param_value; } elseif ($param_name == 'view') { $boards_view = $param_value; } else { $types_parameters .= (tep_not_null($types_parameters) ? '&' : '') . $param; } } $link .= 'boards/'; if (empty($tpath) && $boards_id > 0) { $board_type_query = tep_db_query("select boards_types_id from " . TABLE_BOARDS . " where boards_id = '" . (int) $boards_id . "'"); $board_type = tep_db_fetch_array($board_type_query); $tpath = $board_type['boards_types_id']; } if (tep_not_null($tpath)) { $types_path_query = tep_db_query("select boards_types_path from " . TABLE_BOARDS_TYPES . " where boards_types_id = '" . (int) $tpath . "' limit 1"); $types_path = tep_db_fetch_array($types_path_query); if (tep_not_null($types_path['boards_types_path'])) { $link .= $types_path['boards_types_path'] . '/'; if ($boards_view == 'rss') { $link = substr($link, 0, -1) . '.rss'; $types_parameters = ''; $add_session_id = false; } elseif (tep_not_null($boards_id)) { $link .= $boards_id . '.html'; } } } $parameters = $types_parameters; } elseif (basename($page) == FILENAME_HOLIDAY) { $params = explode("&", $parameters); reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'hPath') { $hpath = $param_value; } else { $types_parameters .= (tep_not_null($types_parameters) ? '&' : '') . $param; } } $link .= 'new_year/' . (tep_not_null($hpath) ? $hpath . '/' : ''); $parameters = $types_parameters; } elseif (basename($page) == FILENAME_MANUFACTURERS) { $params = explode("&", $parameters); reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'manufacturers_id') { $manufacturers_id = $param_value; } else { $manufacturers_parameters .= (tep_not_null($manufacturers_parameters) ? '&' : '') . $param; } } $link .= 'publishers/'; if (tep_not_null($manufacturers_id)) { $manufacturers_path_query = tep_db_query("select manufacturers_id, manufacturers_path from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int) $manufacturers_id . "' limit 1"); $manufacturers_path = tep_db_fetch_array($manufacturers_path_query); $link .= (tep_not_null($manufacturers_path['manufacturers_path']) ? $manufacturers_path['manufacturers_path'] : $manufacturers_path['manufacturers_id']) . '.html'; } $parameters = $manufacturers_parameters; } elseif (basename($page) == FILENAME_SERIES) { $params = explode("&", $parameters); reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'series_id') { $series_id = $param_value; } elseif ($param_name == 'tPath') { $product_type_id = $param_value; } else { $series_parameters .= (tep_not_null($series_parameters) ? '&' : '') . $param; } } $link .= 'series/'; if (tep_not_null($series_id)) { $series_path_query = tep_db_query("select series_id, series_path from " . TABLE_SERIES . " where series_id = '" . (int) $series_id . "' limit 1"); $series_path = tep_db_fetch_array($series_path_query); $link .= (tep_not_null($series_path['series_path']) ? $series_path['series_path'] : $series_path['series_id']) . '.html'; } $parameters = $series_parameters; } elseif (basename($page) == FILENAME_AUTHORS) { $params = explode("&", $parameters); reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'authors_id') { $authors_id = $param_value; } else { $authors_parameters .= (tep_not_null($authors_parameters) ? '&' : '') . $param; } } $link .= 'authors/'; if (tep_not_null($authors_id)) { $authors_path_query = tep_db_query("select authors_id, authors_path from " . TABLE_AUTHORS . " where authors_id = '" . (int) $authors_id . "' limit 1"); $authors_path = tep_db_fetch_array($authors_path_query); $link .= (tep_not_null($authors_path['authors_path']) ? $authors_path['authors_path'] : $authors_path['authors_id']) . '.html'; } $parameters = $authors_parameters; } elseif (basename($page) == FILENAME_FOREIGN) { $params = explode("&", $parameters); reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'products_id') { $products_id = $param_value; } else { $products_parameters .= (tep_not_null($products_parameters) ? '&' : '') . $param; } } $link .= 'foreign/'; if (tep_not_null($products_id)) { $link .= $products_id . '.html'; } $parameters = $products_parameters; } elseif (basename($page) == FILENAME_DEFAULT) { $params = explode("&", $parameters); reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'sPath') { $sections_id = $param_value; } elseif ($param_name == 'info_id') { $information_id = $param_value; } else { $sections_parameters .= (tep_not_null($sections_parameters) ? '&' : '') . $param; } if ($param_name == 'sName') { $sname = $param_value; # if (substr($cname, -1)=='/') $cname = substr($cname, 0, -1); # if (substr($cname, 0, 1)=='/') $cname = substr($cname, 1); } } $current_section_id = 0; if (tep_not_null($sections_id)) { $sections_array = explode('_', $sections_id); if (sizeof($sections_array) == 1) { $last_id = end($sections_array); $parent_sections = array($last_id); tep_get_parents($parent_sections, $last_id, TABLE_SECTIONS); $parent_sections = array_reverse($parent_sections); } else { $parent_sections = $sections_array; } reset($parent_sections); while (list(, $section_id) = each($parent_sections)) { if ($section_id > 0) { $sections_path_query = tep_db_query("select sections_path from " . TABLE_SECTIONS . " where sections_id = '" . (int) $section_id . "' limit 1"); $sections_path = tep_db_fetch_array($sections_path_query); if (tep_not_null($sections_path['sections_path'])) { $link .= $sections_path['sections_path'] . '/'; } $current_section_id = $section_id; } } } if (sizeof($sections_array) > 1 && tep_not_null($information_id)) { $information_path_query = tep_db_query("select i2s.information_default_status, i.information_path, i.information_redirect from " . TABLE_INFORMATION . " i, " . TABLE_INFORMATION_TO_SECTIONS . " i2s where i.information_id = '" . (int) $information_id . "' and i.information_id = i2s.information_id limit 1"); } else { $information_path_query = tep_db_query("select i2s.information_default_status, i.information_path, i.information_redirect from " . TABLE_INFORMATION . " i, " . TABLE_INFORMATION_TO_SECTIONS . " i2s where" . (tep_not_null($information_id) ? " i.information_id = '" . (int) $information_id . "'" : " i2s.information_default_status = '1'") . " and i.information_id = i2s.information_id and i2s.sections_id = '" . (int) $current_section_id . "' limit 1"); } $information_path = tep_db_fetch_array($information_path_query); if (tep_not_null($information_path['information_redirect'])) { $redirect_url = $information_path['information_redirect']; } if ($information_path['information_default_status'] != '1' && tep_not_null($information_path['information_path'])) { $link .= $information_path['information_path'] . '.html'; } elseif (empty($sections_id) && empty($information_path) && tep_not_null($sname)) { $link .= $sname; } $parameters = $sections_parameters; } elseif (basename($page) == FILENAME_NEWS) { $link .= 'news/'; $params = explode('&', $parameters); reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'news_id') { $news_id = $param_value; } if ($param_name == 'year') { $news_year = $param_value; } if ($param_name == 'month') { $news_month = $param_value; } if ($param_name == 'view') { $news_view = $param_value; } if ($param_name == 'type') { $news_type = $param_value; } if ($param_name == 'tPath') { $news_path = $param_value; } if (!in_array($param_name, array('news_id', 'year', 'month', 'view', 'type', 'tPath'))) { $news_parameters .= (tep_not_null($news_parameters) ? '&' : '') . $param; } if ($param_name == 'nName') { $nname = $param_value; # if (substr($cname, -1)=='/') $cname = substr($cname, 0, -1); # if (substr($cname, 0, 1)=='/') $cname = substr($cname, 1); } $parameters = $news_parameters; } if (tep_not_null($news_path)) { $nInfo_query = tep_db_query("select news_types_path, news_types_path as news_date from " . TABLE_NEWS_TYPES . " where news_types_id = '" . (int) $news_path . "'"); } else { $nInfo_query = tep_db_query("select date_format(date_added, '%Y/%m') as news_date from " . TABLE_NEWS . " where news_id = '" . (int) $news_id . "' limit 1"); } $nInfo = tep_db_fetch_array($nInfo_query); if (tep_not_null($news_id)) { $link .= $nInfo['news_date'] . '/' . $news_id . '.html'; $parameters = $news_parameters; } elseif ($news_view == 'rss') { $link .= (tep_not_null($nInfo['news_types_path']) ? $nInfo['news_types_path'] : $news_type) . '.rss'; $parameters = ''; $add_session_id = false; } elseif (tep_not_null($news_path)) { $news_type_query = tep_db_query("select news_types_path from " . TABLE_NEWS_TYPES . " where news_types_id = '" . (int) $news_path . "'"); $news_type = tep_db_fetch_array($news_type_query); $link .= $news_type['news_types_path'] . '/'; $parameters = $news_parameters; } else { if (tep_not_null($news_year)) { $link .= $news_year . '/'; if (tep_not_null($news_month)) { $link .= $news_month . '/'; } } } if (empty($news_id) && empty($news_year) && empty($news_month) && tep_not_null($nname)) { $link .= $nname; } } if ($page != FILENAME_DEFAULT && $page != DIR_WS_ONLINE_STORE && $page != DIR_WS_ONLINE_STORE) { $params = explode('&', $parameters); $temp_parameters = ''; reset($params); while (list(, $param) = each($params)) { list($param_name) = explode('=', $param); if (!in_array($param_name, array('cPath', 'sPath', 'tPath', 'pName', 'nName', 'cName', 'sName', 'info_id', 'iName', 'tName', 'mName', 'rName'))) { if (basename($page) == FILENAME_PRODUCT_INFO && $param_name == 'products_id') { } else { $temp_parameters .= (tep_not_null($temp_parameters) ? '&' : '') . $param; } } } # if (tep_not_null($temp_parameters)) $parameters = $temp_parameters; } if (in_array(basename($page), array(FILENAME_CATEGORIES, FILENAME_PRODUCT_INFO, FILENAME_SPECIALS, FILENAME_MANUFACTURERS, FILENAME_DEFAULT, FILENAME_NEWS, FILENAME_SERIES, FILENAME_AUTHORS, FILENAME_REVIEWS, FILENAME_FOREIGN, FILENAME_BOARDS, FILENAME_HOLIDAY))) { if (!in_array(basename($page), array(FILENAME_DEFAULT, FILENAME_NEWS, FILENAME_BOARDS, FILENAME_HOLIDAY))) { if (basename($page) == FILENAME_PRODUCT_INFO && tep_not_null($products_id) || basename($page) == FILENAME_CATEGORIES && tep_not_null($categories_id) || basename($page) == FILENAME_SERIES && tep_not_null($series_id)) { if (basename($page) == FILENAME_CATEGORIES && tep_not_null($categories_id)) { $product_type_info_query = tep_db_query("select products_types_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int) $categories_id . "'"); $product_type_info = tep_db_fetch_array($product_type_info_query); $product_type_id = $product_type_info['products_types_id']; } elseif (basename($page) == FILENAME_SERIES && tep_not_null($series_id)) { $product_type_info_query = tep_db_query("select products_types_id from " . TABLE_SERIES . " where series_id = '" . (int) $series_id . "'"); $product_type_info = tep_db_fetch_array($product_type_info_query); $product_type_id = $product_type_info['products_types_id']; } else { $product_type_info_query = tep_db_query("select products_types_id from " . TABLE_PRODUCTS . " where products_id = '" . (int) $products_id . "'"); $product_type_info = tep_db_fetch_array($product_type_info_query); $product_type_id = $product_type_info['products_types_id']; } } $product_type_info_query = tep_db_query("select products_types_path from " . TABLE_PRODUCTS_TYPES . " where " . ((int) $product_type_id == 0 ? "products_types_default_status = '1'" : "products_types_id = '" . (int) $product_type_id . "'") . ""); $product_type_info = tep_db_fetch_array($product_type_info_query); $product_type_path = $product_type_info['products_types_path']; $link = $product_type_path . '/' . $link; } $page = ''; } $page = preg_replace('/^index\\.[a-z0-9]{3,5}/i', '', $page); if (tep_not_null($parameters)) { $link .= $page . '?' . tep_output_string($parameters); $separator = '&'; } else { $link .= $page; $separator = '?'; } // Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined if ($add_session_id == true && $session_started == true) { if (tep_not_null($SID)) { $_sid = $SID; } elseif ($request_type == 'NONSSL' && $connection == 'SSL' && ENABLE_SSL == true || $request_type == 'SSL' && $connection == 'NONSSL') { $_sid = tep_session_name() . '=' . tep_session_id(); } } $other_server_check = substr($link, 0, 4) == 'http'; if (tep_not_null($_sid) && $spider_flag == false && basename($page) != FILENAME_REDIRECT) { $link .= $separator . $_sid; } if (tep_not_null($redirect_url)) { $link = $redirect_url; if (!$other_server_check && tep_not_null($_sid)) { $link .= $separator . $_sid; } } if (substr($link, 0, 1) == '/') { $link = substr($link, 1); } $link = str_replace('&', '&', $link); // $link = str_replace('&', '&', $link); while (strpos($link, '&&')) { $link = str_replace('&&', '&', $link); } while (strpos($link, '?&')) { $link = str_replace('?&', '?', $link); } while (substr($link, -1) == '&' || substr($link, -1) == '?') { $link = substr($link, 0, -1); } while (strpos($link, '//')) { $link = str_replace('//', '/', $link); } if ($other_server_check) { $link = preg_replace('/(http[s]?):\\//i', '$1://', $link); } if ($other_server_check == false) { if ($connection == 'SSL' && ENABLE_SSL == true) { $link = HTTPS_SERVER . DIR_WS_CATALOG . $link; } else { $link = HTTP_SERVER . DIR_WS_CATALOG . $link; } } if ($connection != 'NONSSL' && $connection != 'SSL') { die('</td></tr></table></td></tr></table><br /><br /><font color="#ff0000"><strong>Error!</strong></font><br /><br /><strong>Unable to determine connection method on a link!<br /><br />Known methods: NONSSL SSL</strong><br /><br />'); } return $link; }
function tep_get_full_product_info($products_id, $pricelist_type = 'csv') { global $languages_id, $all_categories, $currency, $currencies, $HTTP_GET_VARS, $categories_audio, $for, $customer_discount; $products_query = tep_db_query("select * from " . TABLE_PRODUCTS . " where products_id = '" . (int) $products_id . "'"); $products = tep_db_fetch_array($products_query); if (DEFAULT_LANGUAGE_ID == $languages_id) { $product_info_query = tep_db_query("select * from " . TABLE_PRODUCTS_INFO . " where products_id = '" . (int) $products['products_id'] . "'"); $product_info = tep_db_fetch_array($product_info_query); $product_info = array_merge($product_info, $products); $product_info['products_url'] = HTTP_SERVER . $product_info['products_url']; } else { $product_info_query = tep_db_query("select products_name, products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int) $products['products_id'] . "' and language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'"); $product_info = tep_db_fetch_array($product_info_query); if (DEFAULT_LANGUAGE_ID == 1) { $product_ru_info_query = tep_db_query("select products_name, products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int) $products['products_id'] . "' and language_id = '" . (int) $languages_id . "'"); $product_ru_info = tep_db_fetch_array($product_ru_info_query); $product_ru_name = tep_transliterate($product_ru_info['products_name']); if ($product_info['products_name'] != $product_ru_info['products_name'] && $product_info['products_name'] != $product_ru_name) { $product_info['products_name'] .= (tep_not_null($product_info['products_name']) ? ' / ' : '') . $product_ru_name; } } $author_info_query = tep_db_query("select authors_name from " . TABLE_AUTHORS . " where authors_id = '" . (int) $products['authors_id'] . "' and language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'"); $author_info = tep_db_fetch_array($author_info_query); if (!is_array($author_info)) { $author_info = array(); } $serie_info_query = tep_db_query("select series_name from " . TABLE_SERIES . " where series_id = '" . (int) $products['series_id'] . "' and language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'"); $serie_info = tep_db_fetch_array($serie_info_query); if (!is_array($serie_info)) { $serie_info = array(); } $manufacturer_info_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int) $products['manufacturers_id'] . "' and languages_id = '" . (int) DEFAULT_LANGUAGE_ID . "'"); $manufacturer_info = tep_db_fetch_array($manufacturer_info_query); if (!is_array($manufacturer_info)) { $manufacturer_info = array(); } $product_info['products_width'] = ''; $product_info['products_height'] = ''; $product_info['products_width_height_measure'] = ''; $product_format_info_query = tep_db_query("select products_formats_name from " . TABLE_PRODUCTS_FORMATS . " where products_formats_id = '" . (int) $products['products_formats_id'] . "'"); $product_format_info = tep_db_fetch_array($product_format_info_query); if (!is_array($product_format_info)) { $product_format_info = array(); } if (tep_not_null($product_format_info['products_formats_name'])) { $product_format = $product_format_info['products_formats_name']; list($product_format) = explode(' ', $product_format); list($product_format) = explode('/', $product_format); if (preg_match('/^(\\d+)x(\\d+)$/i', $product_format, $regs)) { $product_info['products_width'] = $regs[1]; $product_info['products_height'] = $regs[1]; $product_info['products_width_height_measure'] = 'mm'; } } $product_cover_info_query = tep_db_query("select products_covers_name from " . TABLE_PRODUCTS_COVERS . " where products_covers_id = '" . (int) $products['products_covers_id'] . "' and language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'"); $product_cover_info = tep_db_fetch_array($product_cover_info_query); if (!is_array($product_cover_info)) { $product_cover_info = array(); } $product_type_info_query = tep_db_query("select products_types_name from " . TABLE_PRODUCTS_TYPES . " where products_types_id = '" . (int) $products['products_types_id'] . "' and language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'"); $product_type_info = tep_db_fetch_array($product_type_info_query); if (!is_array($product_type_info)) { $product_type_info = array(); } $category_info_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int) $products['products_id'] . "' order by categories_id desc limit 1"); $category_info = tep_db_fetch_array($category_info_query); if (!is_array($category_info)) { $category_info = array(); } $product_info = array_merge($product_info, $products, $author_info, $serie_info, $manufacturer_info, $product_format_info, $product_cover_info, $category_info); $product_info['products_url'] = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_info['products_id'], 'NONSSL', false); } if ($customer_discount['type'] == 'purchase' && $products['products_purchase_cost'] > 0) { $product_info['products_price'] = $products['products_purchase_cost'] * (1 + $customer_discount['value'] / 100); } if (mb_strpos($product_info['products_description'], '<table', 0, 'CP1251') !== false) { $product_info['products_description'] = mb_substr($product_info['products_description'], 0, mb_strpos($product_info['products_description'], '<table', 0, 'CP1251'), 'CP1251'); } $short_description = trim(preg_replace('/\\s+/', ' ', preg_replace('/<\\/?[^>]+>/', ' ', $product_info['products_description']))); $product_info['products_description'] = $short_description; $product_info['products_description_short'] = $short_description; if ($pricelist_type == 'csv') { if ($for == 'shopmania' || $for == 'nur_kz') { if ($for == 'nur_kz') { $categories_delimiter = ' | '; } else { $categories_delimiter = ' > '; } if (!in_array($product_info['categories_id'], array_keys($all_categories))) { $parent_categories = array($product_info['categories_id']); tep_get_parents($parent_categories, $product_info['categories_id']); $parent_categories = array_reverse($parent_categories); $categories_names = array_map('tep_get_category_name', $parent_categories); $category_tree_string = implode($categories_delimiter, $categories_names); $all_categories[$category_info['categories_id']] = $category_tree_string; } else { $category_tree_string = $all_categories[$category_info['categories_id']]; } // list($product_info['categories_name']) = explode(' > ', $category_tree_string); $product_info['categories_name'] = $product_info['products_types_name'] . $categories_delimiter . $category_tree_string; } if ($for == 'amazon_uk') { $product_info['products_currency'] = 'GBP'; } else { $product_info['products_currency'] = DEFAULT_CURRENCY; } if (strpos($for, 'amazon') !== false) { $product_info['products_price'] = str_replace(',', '.', sprintf("%01.2f", round($product_info['products_cost'] * 1.8 * $currencies->get_value($product_info['products_currency']), 1) + 1.2)); $product_info['products_weight'] = str_replace(',', '.', round($product_info['products_weight'], 2)); $product_info['products_model'] = preg_replace('/[^\\dX]/', '', $product_info['products_model']); if (strlen($product_info['products_name']) > 500) { $product_info['products_name'] = substr($product_info['products_name'], 0, 500); } if ($product_info['authors_name'] == '') { $product_info['authors_name'] = 'unknown'; } } elseif ($for == 'ebay') { if (tep_not_null($product_info['authors_name'])) { $product_info['products_name'] .= ' by ' . $product_info['authors_name']; } $product_info['products_price'] = str_replace(',', '.', round($product_info['products_price'] * $currencies->get_value($product_info['products_currency']), $currencies->get_decimal_places($product_info['products_currency']))); $product_info['products_model'] = preg_replace('/[^\\dX]/', '', $product_info['products_model']); } else { $product_info['products_price'] = str_replace('.', ',', round($product_info['products_price'] * $currencies->get_value($product_info['products_currency']), $currencies->get_decimal_places($product_info['products_currency']))); } } else { if (!in_array($currency, array('RUR', 'EUR', 'USD', 'UAH'))) { $product_info['products_currency'] = 'RUR'; $product_info['products_price'] = str_replace(',', '.', round($product_info['products_price'], $currencies->get_decimal_places($product_info['products_currency']))); } else { $product_info['products_currency'] = str_replace('RUB', 'RUR', DEFAULT_CURRENCY); $product_info['products_price'] = str_replace(',', '.', round($product_info['products_price'] * $currencies->get_value($product_info['products_currency']), $currencies->get_decimal_places($product_info['products_currency']))); } } if (tep_not_null($product_info['products_image'])) { // $product_info['products_image_big'] = tep_href_link(DIR_WS_IMAGES . 'big/' . $product_info['products_image'], '', 'NONSSL', false); $product_info['products_image_big'] = 'http://85.236.24.26/big/' . $product_info['products_image']; if (strpos($for, 'amazon') !== false || $for == 'ebay') { $product_info['products_image'] = $product_info['products_image_big']; } else { // $product_info['products_image'] = tep_href_link(DIR_WS_IMAGES . 'thumbs/' . $product_info['products_image'], '', 'NONSSL', false); $product_info['products_image'] = 'http://85.236.24.26/thumbs/' . $product_info['products_image']; // $product_info['products_image'] = str_replace(HTTP_SERVER, 'http://images.setbook.ru', $product_info['products_image']); } } $product_info['products_buy'] = tep_href_link(FILENAME_SHOPPING_CART, 'action=buy_now&product_id=' . $product_info['products_id'], 'NONSSL', false); $product_info['products_quantity'] = ''; $product_info['is_audio'] = false; if (in_array($product_info['categories_id'], $categories_audio)) { $product_info['is_audio'] = true; } if (ALLOW_SHOW_AVAILABLE_IN == 'true' && tep_not_null($HTTP_GET_VARS['limit']) || SHOP_ID == 4) { } elseif ($product_info['products_listing_status'] == 1) { $product_info['products_available_in'] = 1; } else { $product_info['products_available_in'] = 10; } reset($product_info); while (list($k, $v) = each($product_info)) { $v = str_replace($from1, $to, str_replace($from, $to, $v)); if (in_array($k, array('products_name', 'products_description'))) { $v = preg_replace('/\\s{2,}/', ' ', preg_replace('/[^_\\/\\w\\d\\#\\&(\\)\\-\\[\\]\\.",;]/', ' ', $v)); } if ($pricelist_type == 'csv') { $product_info[$k] = strip_tags(tep_html_entity_decode($v)); } else { $product_info[$k] = htmlspecialchars(strip_tags(tep_html_entity_decode($v)), ENT_QUOTES); } } // print_r($product_info); die; return $product_info; }
<?php require 'includes/application_top.php'; $content = FILENAME_DEFAULT; $page_query = tep_db_query("select pages_id, pages_name, pages_additional_description, pages_description from " . TABLE_PAGES . " where pages_filename = '" . tep_db_input(basename($content)) . "' and language_id = '" . (int) $languages_id . "'"); $page = tep_db_fetch_array($page_query); if (empty($sPath_array) && ($iName == 'index' || $iName == '')) { define('ADDITIONAL_DESCRIPTION', $page['pages_additional_description']); } $translation_query = tep_db_query("select pages_translation_key, pages_translation_value from " . TABLE_PAGES_TRANSLATION . " where pages_filename = '" . tep_db_input(basename($content)) . "' and language_id = '" . (int) $languages_id . "'"); while ($translation = tep_db_fetch_array($translation_query)) { define($translation['pages_translation_key'], $translation['pages_translation_value']); } if ((int) $current_section_id > 0) { $parents = array($current_section_id); tep_get_parents($parents, $current_section_id, TABLE_SECTIONS); reset($parents); while (list(, $parent_id) = each($parents)) { $section_check_query = tep_db_query("select sections_status from " . TABLE_SECTIONS . " where sections_id = '" . (int) $parent_id . " limit 1'"); $section_check = tep_db_fetch_array($section_check_query); if ($section_check['sections_status'] == 0) { tep_redirect(tep_href_link(FILENAME_ERROR_404)); } } } if (tep_not_null($current_information_id)) { $information_sql = "select i.information_id, i.information_name, i2s.information_default_status, i.information_redirect from " . TABLE_INFORMATION . " i, " . TABLE_INFORMATION_TO_SECTIONS . " i2s where i.information_id = '" . (int) $current_information_id . "' and i.information_id = i2s.information_id and i2s.sections_id = '" . (int) $current_section_id . "' and i.information_status = '1' and i.language_id = '" . (int) $languages_id . "'"; $information_query = tep_db_query($information_sql); $information = tep_db_fetch_array($information_query); $content_id = $information['information_id']; $content_type = 'information';
function tep_catalog_href_link($page = '', $parameters = '', $connection = 'NONSSL') { global $request_type, $session_started, $SID, $spider_flag; if (!tep_not_null($page)) { $page = FILENAME_DEFAULT; } $link = ''; $redirect = false; $redirect_url = ''; $categories_id = ''; $products_id = ''; $categories_parameters = ''; $sections_id = ''; $information_id = ''; $sections_parameters = ''; $manufacturers_id = ''; $manufacturers_parameters = ''; $news_id = ''; $news_parameters = ''; $products_types_id = 0; if (basename($page) == FILENAME_CATALOG_CATEGORIES || basename($page) == FILENAME_CATALOG_PRODUCT_INFO) { $params = explode("&", $parameters); reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'cPath') { $categories_id = $param_value; } elseif ($param_name == 'products_id') { $products_id = $param_value; } else { $categories_parameters .= (tep_not_null($categories_parameters) ? '&' : '') . $param; } if ($param_name == 'cName') { $cname = $param_value; # if (substr($cname, -1)=='/') $cname = substr($cname, 0, -1); # if (substr($cname, 0, 1)=='/') $cname = substr($cname, 1); } } $current_category_id = 0; if (tep_not_null($categories_id)) { $last_id = end(explode('_', $categories_id)); $parent_categories = array($last_id); tep_get_parents($parent_categories, $last_id); $parent_categories = array_reverse($parent_categories); reset($parent_categories); while (list(, $category_id) = each($parent_categories)) { $categories_path_query = tep_db_query("select categories_path, products_types_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int) $category_id . "' limit 1"); if (tep_db_num_rows($categories_path_query) > 0) { $categories_path = tep_db_fetch_array($categories_path_query); if (tep_not_null($categories_path['categories_path'])) { $link .= $categories_path['categories_path'] . '/'; } else { $link .= $category_id . '/'; } $current_category_id = $category_id; if ($products_types_id == 0) { $products_types_id = $categories_path['products_types_id']; } } } } if (tep_not_null($products_id)) { $products_path_query = tep_db_query("select products_types_id from " . TABLE_PRODUCTS . " where products_id = '" . (int) $products_id . "'"); $products_path = tep_db_fetch_array($products_path_query); $link = $products_id . '.html'; if ($products_types_id == 0) { $products_types_id = $products_path['products_types_id']; } } $parameters = $categories_parameters; } elseif (basename($page) == FILENAME_SPECIALS) { $params = explode("&", $parameters); reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'tPath') { $tpath = $param_value; } else { $types_parameters .= (tep_not_null($types_parameters) ? '&' : '') . $param; } } $link .= 'specials/'; if (tep_not_null($tpath)) { $types_path_query = tep_db_query("select specials_types_path from " . TABLE_SPECIALS_TYPES . " where specials_types_id = '" . (int) $tpath . "' limit 1"); $types_path = tep_db_fetch_array($types_path_query); if (tep_not_null($types_path['specials_types_path'])) { $link .= $types_path['specials_types_path'] . '/'; } } $parameters = $types_parameters; } elseif (basename($page) == FILENAME_CATALOG_MANUFACTURERS) { $params = explode("&", $parameters); reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'manufacturers_id') { $manufacturers_id = $param_value; } else { $manufacturers_parameters .= (tep_not_null($manufacturers_parameters) ? '&' : '') . $param; } } $link .= 'manufacturers/'; if (tep_not_null($manufacturers_id)) { $manufacturers_path_query = tep_db_query("select manufacturers_id, manufacturers_path from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int) $manufacturers_id . "' limit 1"); $manufacturers_path = tep_db_fetch_array($manufacturers_path_query); $link .= (tep_not_null($manufacturers_path['manufacturers_path']) ? $manufacturers_path['manufacturers_path'] : $manufacturers_path['manufacturers_id']) . '/'; } $parameters = $manufacturers_parameters; } elseif (basename($page) == FILENAME_CATALOG_SERIES) { $params = explode("&", $parameters); reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'series_id') { $series_id = $param_value; } else { $series_parameters .= (tep_not_null($series_parameters) ? '&' : '') . $param; } } $link .= 'series/'; if (tep_not_null($series_id)) { $series_path_query = tep_db_query("select series_id, series_path, products_types_id from " . TABLE_SERIES . " where series_id = '" . (int) $series_id . "' limit 1"); $series_path = tep_db_fetch_array($series_path_query); $link .= (tep_not_null($series_path['series_path']) ? $series_path['series_path'] : $series_path['series_id']) . '/'; if ($products_types_id == 0) { $products_types_id = $series_path['products_types_id']; } } $parameters = $series_parameters; } elseif (basename($page) == FILENAME_CATALOG_DEFAULT) { $params = explode("&", $parameters); reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'sPath') { $sections_id = $param_value; } elseif ($param_name == 'info_id') { $information_id = $param_value; } else { $sections_parameters .= (tep_not_null($sections_parameters) ? '&' : '') . $param; } if ($param_name == 'sName') { $sname = $param_value; # if (substr($cname, -1)=='/') $cname = substr($cname, 0, -1); # if (substr($cname, 0, 1)=='/') $cname = substr($cname, 1); } } $current_section_id = 0; if (tep_not_null($sections_id)) { $sections_array = explode('_', $sections_id); if (sizeof($sections_array) == 1) { $last_id = end($sections_array); $parent_sections = array($last_id); tep_get_parents($parent_sections, $last_id, TABLE_SECTIONS); $parent_sections = array_reverse($parent_sections); } else { $parent_sections = $sections_array; } reset($parent_sections); while (list(, $section_id) = each($parent_sections)) { if ($section_id > 0) { $sections_path_query = tep_db_query("select sections_path from " . TABLE_SECTIONS . " where sections_id = '" . (int) $section_id . "' limit 1"); $sections_path = tep_db_fetch_array($sections_path_query); if (tep_not_null($sections_path['sections_path'])) { $link .= $sections_path['sections_path'] . '/'; } $current_section_id = $section_id; } } } if (sizeof($sections_array) > 1 && tep_not_null($information_id)) { $information_path_query = tep_db_query("select i2s.information_default_status, i.information_path, i.information_redirect from " . TABLE_INFORMATION . " i, " . TABLE_INFORMATION_TO_SECTIONS . " i2s where i.information_id = '" . (int) $information_id . "' and i.information_id = i2s.information_id limit 1"); } else { $information_path_query = tep_db_query("select i2s.information_default_status, i.information_path, i.information_redirect from " . TABLE_INFORMATION . " i, " . TABLE_INFORMATION_TO_SECTIONS . " i2s where" . (tep_not_null($information_id) ? " i.information_id = '" . (int) $information_id . "'" : " i2s.information_default_status = '1'") . " and i.information_id = i2s.information_id and i2s.sections_id = '" . (int) $current_section_id . "' limit 1"); } $information_path = tep_db_fetch_array($information_path_query); if (tep_not_null($information_path['information_redirect'])) { $redirect_url = $information_path['information_redirect']; } if ($information_path['information_default_status'] != '1' && tep_not_null($information_path['information_path'])) { $link .= $information_path['information_path'] . '.html'; } elseif (empty($sections_id) && empty($information_path) && tep_not_null($sname)) { $link .= $sname; } $parameters = $sections_parameters; } elseif (basename($page) == FILENAME_CATALOG_NEWS) { $link .= 'news/'; $params = explode("&", $parameters); reset($params); while (list(, $param) = each($params)) { list($param_name, $param_value) = explode('=', $param); if ($param_name == 'news_id') { $news_id = $param_value; } elseif ($param_name == 'year') { $news_year = $param_value; } elseif ($param_name == 'month') { $news_month = $param_value; } else { $news_parameters .= (tep_not_null($news_parameters) ? '&' : '') . $param; } if ($param_name == 'nName') { $nname = $param_value; # if (substr($cname, -1)=='/') $cname = substr($cname, 0, -1); # if (substr($cname, 0, 1)=='/') $cname = substr($cname, 1); } $parameters = $news_parameters; } if (tep_not_null($news_id)) { $news_query = tep_db_query("select date_format(date_added, '%Y/%m/') as news_date from " . TABLE_NEWS . " where news_id = '" . (int) $news_id . "' limit 1"); $news = tep_db_fetch_array($news_query); $link .= $news['news_date'] . $news_id . '.html'; $parameters = $news_parameters; } else { if (tep_not_null($news_year)) { $link .= $news_year . '/'; if (tep_not_null($news_month)) { $link .= $news_month . '/'; } } } if (empty($news_id) && empty($news_year) && empty($news_month) && tep_not_null($nname)) { $link .= $nname; } } if ($page != FILENAME_DEFAULT && $page != '/' && $page != DIR_WS_ONLINE_STORE) { $params = explode('&', $parameters); $temp_parameters = ''; reset($params); while (list(, $param) = each($params)) { list($param_name) = explode('=', $param); if (!in_array($param_name, array('cPath', 'sPath', 'nName', 'cName', 'sName', 'info_id', 'iName', 'tName', 'mName', 'rName'))) { if (basename($page) == FILENAME_PRODUCT_INFO && $param_name == 'products_id' || basename($page) == FILENAME_MANUFACTURERS && $manufacturers_id > 0 && $param_name == 'manufacturers_id') { } else { $temp_parameters .= (tep_not_null($temp_parameters) ? '&' : '') . $param; } } } # if (tep_not_null($temp_parameters)) $parameters = $temp_parameters; } if (in_array(basename($page), array(FILENAME_CATALOG_CATEGORIES, FILENAME_CATALOG_PRODUCT_INFO, FILENAME_CATALOG_SPECIALS, FILENAME_CATALOG_MANUFACTURERS, FILENAME_CATALOG_DEFAULT, FILENAME_CATALOG_NEWS, FILENAME_CATALOG_SERIES))) { if (!in_array(basename($page), array(FILENAME_CATALOG_DEFAULT, FILENAME_CATALOG_NEWS))) { $product_type_info_query = tep_db_query("select products_types_path from " . TABLE_PRODUCTS_TYPES . " where 1" . ($products_types_id > 0 ? " and products_types_id = '" . (int) $products_types_id . "'" : " and products_types_default_status = '1'")); $product_type_info = tep_db_fetch_array($product_type_info_query); $link = $product_type_info['products_types_path'] . '/' . $link; } $page = ''; } $page = preg_replace('/^index\\.[a-z0-9]{3,5}/i', '', $page); if (tep_not_null($parameters)) { $link .= $page . '?' . tep_output_string($parameters); $separator = '&'; } else { $link .= $page; $separator = '?'; } while (substr($link, -1) == '&' || substr($link, -1) == '?') { $link = substr($link, 0, -1); } while (strpos($link, '&&')) { $link = str_replace('&&', '&', $link); } while (strpos($link, '//')) { $link = str_replace('//', '/', $link); } $other_server_check = substr($link, 0, 4) == 'http'; if ($connection == 'NONSSL' && $other_server_check == false) { $link = HTTP_SERVER . DIR_WS_CATALOG . $link; } elseif ($connection == 'SSL' && $other_server_check == false) { $link = HTTP_SERVER . DIR_WS_CATALOG . $link; if (ENABLE_SSL == true) { $link = preg_replace('/^http:\\/\\//', 'https://', $link); } } elseif ($connection != 'NONSSL' && $connection != 'SSL') { die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><strong>Error!</strong></font><br><br><strong>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL</strong><br><br>'); } return $link; }
function tep_get_information_path($information_id) { $sPath = ''; $section_query = tep_db_query("select i2s.sections_id from " . TABLE_INFORMATION . " i, " . TABLE_INFORMATION_TO_SECTIONS . " i2s where i.information_id = '" . (int) $information_id . "' and i.information_id = i2s.information_id limit 1"); if (tep_db_num_rows($section_query)) { $section = tep_db_fetch_array($section_query); $sections = array($section['sections_id']); tep_get_parents($sections, $section['sections_id'], TABLE_SECTIONS); $sections = array_reverse($sections); $sPath = implode('_', $sections); } return $sPath; }
function quote($method = '') { global $order, $customer_id; $method = (int) $method; $zones_check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . (int) $order->delivery['country_id'] . "'"); $zones_check = tep_db_fetch_array($zones_check_query); $specify_zone = $zones_check['total'] > 0 ? true : false; $common_qty = 0; $periodicals_qty = 0; $total_sum = 0; if (is_object($order)) { reset($order->products); while (list(, $order_product) = each($order->products)) { if ($order_product['periodicity'] > 0) { $periodicals_qty += $order_product['qty']; } else { $common_qty += $order_product['qty']; $total_sum += $order_product['final_price'] * $order_product['qty']; } } } $points = array(); $zone_id = $order->delivery['zone_id']; $self_delivery_check_query = tep_db_query("select count(*) as total from " . TABLE_SELF_DELIVERY . " where entry_country_id = '" . (int) $order->delivery['country_id'] . "'" . ($specify_zone ? " and entry_zone_id = '" . (int) $zone_id . "'" : "")); $self_delivery_check = tep_db_fetch_array($self_delivery_check_query); if ($self_delivery_check['total'] < 1) { $parent_cities = array($order->delivery['postcode']); tep_get_parents($parent_cities, $order->delivery['postcode'], TABLE_CITIES); $parent_cities = array_reverse($parent_cities); $parent_city_info_query = tep_db_query("select zone_id from " . TABLE_CITIES . " where city_country_id = '" . (int) $order->delivery['country_id'] . "' and city_id = '" . tep_db_input($parent_cities[0]) . "'"); $parent_city_info = tep_db_fetch_array($parent_city_info_query); $zone_id = $parent_city_info['zone_id']; $self_delivery_check_query = tep_db_query("select count(*) as total from " . TABLE_SELF_DELIVERY . " where entry_country_id = '" . (int) $order->delivery['country_id'] . "'" . ($specify_zone ? " and entry_zone_id = '" . (int) $zone_id . "'" : "")); $self_delivery_check = tep_db_fetch_array($self_delivery_check_query); if ($self_delivery_check['total'] < 1) { $self_delivery_check_query = tep_db_query("select min(entry_zone_id-" . (int) $zone_id . ") as min_zone_id from " . TABLE_SELF_DELIVERY . " where entry_country_id = '" . (int) $order->delivery['country_id'] . "' order by min_zone_id limit 1"); $self_delivery_check = tep_db_fetch_array($self_delivery_check_query); $zone_id = $self_delivery_check['min_zone_id'] + $zone_id; } } $self_delivery_check_query = tep_db_query("select count(*) as total from " . TABLE_SELF_DELIVERY . " where" . ($method > 0 ? " self_delivery_id = '" . (int) $method . "'" : " entry_country_id = '" . (int) $order->delivery['country_id'] . "'" . ($specify_zone ? " and entry_zone_id = '" . (int) $zone_id . "'" : ""))); $self_delivery_check = tep_db_fetch_array($self_delivery_check_query); $self_delivery_query = tep_db_query("select self_delivery_id, self_delivery_cost, self_delivery_free, entry_country_id, entry_zone_id, entry_suburb as suburb, entry_city as city, entry_street_address as street_address, entry_telephone as telephone, self_delivery_description from " . TABLE_SELF_DELIVERY . " where self_delivery_status = '1'" . ($method > 0 ? " and self_delivery_id = '" . (int) $method . "'" : ($this->is_periodical ? "" : " and (self_delivery_only_periodicals = '0' or self_delivery_only_periodicals is null)") . " and entry_country_id = '" . (int) $order->delivery['country_id'] . "'" . ($specify_zone ? " and entry_zone_id = '" . (int) $zone_id . "'" : "") . " order by city, street_address") . ""); while ($self_delivery = tep_db_fetch_array($self_delivery_query)) { $shipping_cost = 0; $self_delivery['self_delivery_cost'] = str_replace(',', '.', $self_delivery['self_delivery_cost'] / $order->info['currency_value']); $self_delivery['self_delivery_free'] = str_replace(',', '.', $self_delivery['self_delivery_free'] / $order->info['currency_value']); if ($self_delivery['self_delivery_cost'] > 0) { if ($common_qty > 0) { if ($self_delivery['self_delivery_free'] > 0 && $total_sum > $self_delivery['self_delivery_free']) { $shipping_cost = 0; } else { $shipping_cost = $self_delivery['self_delivery_cost']; } } if ($periodicals_qty > 0) { $shipping_cost += $periodicals_qty * $self_delivery['self_delivery_cost']; } } else { $shipping_cost = 0; } $region_info_query = tep_db_query("select zone_name as state from " . TABLE_ZONES . " where zone_id = '" . (int) $self_delivery['entry_zone_id'] . "' and zone_country_id = '" . (int) $self_delivery['entry_country_id'] . "'"); if (tep_db_num_rows($region_info_query) > 0) { $region_info = tep_db_fetch_array($region_info_query); $self_delivery = array_merge($self_delivery, $region_info); } $points[] = array('id' => $self_delivery['self_delivery_id'], 'title' => tep_address_format($order->delivery['format_id'], $self_delivery, 1, '', ', '), 'cost' => $shipping_cost); } if (sizeof($points) == 0 && $self_delivery_check['total'] == 0) { // $points[] = array('id' => $this->code, // 'title' => MODULE_SHIPPING_SELF_TEXT_WAY, // 'cost' => $shipping_cost); } if (sizeof($points) > 0) { $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_SELF_TEXT_TITLE, 'methods' => $points); } return $this->quotes; }
$check = tep_db_fetch_array($check_query); if ($check['total'] == 0) { $categories_name = ''; $categories_description = ''; reset($fields); while (list(, $field) = each($fields)) { if (tep_not_null($categories[$field])) { ${$field} = tep_get_translation($categories[$field]); } else { ${$field} = ''; } } $sql = "replace into " . TABLE_CATEGORIES_DESCRIPTION . " (categories_id, categories_name, categories_description, language_id) select categories_id, '" . tep_db_input($categories_name) . "', '" . tep_db_input($categories_description) . "', '1' from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int) $categories_id . "' and language_id = '" . (int) $languages_id . "'"; tep_db_query($sql); $parent_categories = array($categories_id); tep_get_parents($parent_categories, $categories_id); $parent_categories = array_reverse($parent_categories); if (!isset($products_types_names[$products_types_id])) { $category_type_info_query = tep_db_query("select products_types_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int) $categories_id . "'"); $category_type_info = tep_db_fetch_array($category_type_info_query); $products_types_id = $category_type_info['products_types_id']; $product_type_info_query = tep_db_query("select products_types_name from " . TABLE_PRODUCTS_TYPES . " where products_types_id = '" . (int) $products_types_id . "' and language_id = '1'"); $product_type_info = tep_db_fetch_array($product_type_info_query); $products_types_name = $product_type_info['products_types_name']; $products_types_names[$products_types_id] = $products_types_name; } else { $products_types_name = $products_types_names[$products_types_id]; } $metatags_page_title = $products_types_name . '.'; $metatags_keywords = $products_types_name . '.'; $metatags_description = $products_types_name . '.';
$linked_products_array = array(); $products_id = (int) $HTTP_GET_VARS['products_id']; $linked_query = tep_db_query("select linked_id from " . TABLE_PRODUCTS_LINKED . " where 1 and products_id = '" . (int) $products_id . "'"); while ($linked = tep_db_fetch_array($linked_query)) { $product_check_status_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int) $linked['linked_id'] . "'"); $product_check_status = tep_db_fetch_array($product_check_status_query); if ($product_check_status['products_status'] == '1') { $linked_products_array[] = $linked['linked_id']; } } $linked_categories = array(); $parent_categories = array(); $product_categories_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int) $products_id . "'"); while ($product_categories = tep_db_fetch_array($product_categories_query)) { $parent_categories[] = $product_categories['categories_id']; tep_get_parents($parent_categories, $product_categories['categories_id']); } $linked_query = tep_db_query("select cl.linked_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_LINKED . " cl where 1 and c.categories_status = '1' and c.categories_id = cl.linked_id and cl.categories_id in ('" . implode("', '", $parent_categories) . "')"); if (tep_db_num_rows($linked_query) > 0 || sizeof($linked_products_array) > 0) { while ($linked = tep_db_fetch_array($linked_query)) { $linked_categories[] = $linked['linked_id']; tep_get_subcategories($linked_categories, $linked['linked_id']); } reset($linked_categories); shuffle($linked_categories); while (list(, $linked_categories_id) = each($linked_categories)) { $linked_products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int) $linked_categories_id . "'"); while ($linked_products = tep_db_fetch_array($linked_products_query)) { $product_check_status_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int) $linked_products['products_id'] . "'"); $product_check_status = tep_db_fetch_array($product_check_status_query); if ($product_check_status['products_status'] == '1' && $linked_products['products_id'] != $products_id) {