ExecQuery("SET SESSION group_concat_max_len = 100000"); function compare_list() { global $db; if (!is_array($_SESSION['compare']) || !count($_SESSION['compare'])) { echo '

Для сравнения перетащите сюда фотографию товара

'; } else { foreach ($_SESSION['compare'] as $this_id_product) { $product = $db->OpenQuery("", "select * from product where id=".$this_id_product); if ($product->Next()) { if (!is_file($f = 'images/product/'.$product->FieldByName("id").'_s.jpg')) { $f = 'images/noproduct_s.jpg'; } $prop = getimagesize($f); ?>
alt="FieldByName('name')); ?>" />
FieldByName('id_category'), 'category'); ?>
FieldByName('name'); ?>
1) { ?> Сравнить Очистить список

Сравнить все'; }*/ exit(); } if ($action == 'compare_clean') { $id_product = (int) $id_product; header('Content-type:text/html; charset=utf-8'); $_SESSION['compare'] = array(); compare_list(); /* if (count($_SESSION['compare']) == 1) { echo 'Добавлен к сравнению'; } else { echo 'Сравнить все'; }*/ exit(); } include $PSES; // ------------- define parameters ----------- $id_struct = (int) $id_struct; $key = reslash(trim($key)); $alias_struct = deslash(trim($alias_struct)); if ($alias_struct == 'index') $alias_struct = 'home'; if (preg_match('/^\d+$/', $alias_struct)) { $id_struct = $alias_struct; unset($alias_struct); } if ($key !== '' && $dy != '' && $dm != '' && $dd == '') { $dd = $dm; $dm = $dy; $dy = $key; unset($key); } //fetch_lang(); $tree = array('name'=>array(), 'alias'=>array(), 'id'=>array()); $parent_links = NULL; if ($do_404) { header("HTTP/1.0 404 Not Found"); $page = $db->OpenQuery("", "select * from struct where id_lang=$id_lang and alias='404-error'"); if (!$page->Next()) { include $PHEADER; include('404.php'); include $PFOOTER; exit(); } else { $id_page = $page->FieldByName("id"); } } if (!$id_struct && !$alias_struct) { $page = $db->OpenQuery("", "select * from struct where id_lang=$id_lang and alias='home' and status=1"); if (!$page->Next()) { $do_404 = true; } else { $id_struct = $page->FieldByName("id"); } $tree['name'][] = $page->FieldByName("name"); $tree['alias'][] = $page->FieldByName("alias"); $tree['id'][] = $page->FieldByName("id"); } else { if ($id_struct || $alias_struct) { if (!$id_struct) { if ($alias_struct) { $tmp = $db->OpenQuery("", "select id from struct where id_lang=$id_lang and alias='".addslashes($alias_struct)."' and status=1"); if ($tmp->Next()) { $id_struct = $tmp->FieldByName("id"); } if (!$id_struct) { $do_404 = true; } } elseif (!$id_struct) { $tmp = $db->OpenQuery("", "select id from struct where id_lang=$id_lang and alias='home' and status=1"); if ($tmp->Next()) { $id_struct = $tmp->FieldByName("id"); } } } $page = $db->OpenQuery("", "select * from struct where id_lang=$id_lang and id=$id_struct"); if (!$page->Next()) { $do_404 = true; } else { $tree_name = $page->FieldByName("name"); $tree['name'][] = $page->FieldByName("name"); $tree['alias'][] = $page->FieldByName("alias"); $tree['id'][] = $page->FieldByName("id"); $page_tmp = $page; while ($page_tmp->FieldByName("id_parent")) { $page_tmp = $db->OpenQuery("", "select * from struct where id_lang=$id_lang and id=".intval($page_tmp->FieldByName("id_parent"))); if ($page_tmp->Next()) { if ($page_tmp->FieldByName("status")) { $tree_name = ''.$page_tmp->FieldByName("name").' » '.$tree_name; $tree['name'][] = $page_tmp->FieldByName("name"); $tree['alias'][] = $page_tmp->FieldByName("alias"); $tree['id'][] = $page_tmp->FieldByName("id"); } } } $parent_links = $db->OpenQuery("", "select * from struct where id_lang=$id_lang and status=1 and visible=1 and id_parent=".$id_struct." order by manual_order"); } } } if (!$id_struct) { header("HTTP/1.0 404 Not Found"); $page = $db->OpenQuery("", "select * from struct where id_lang=$id_lang and alias='404-error'"); if (!$page->Next()) { include $PHEADER; include('404.php'); include $PFOOTER; exit(); } else { $id_page = $page->FieldByName("id"); } } /* if ($search || $adv_search) { search_cleanup(); $new_search = reslash(trim(str_replace(array('%', '_'), array('\%', '\_'), $search))); $new_search_asis = reslash(trim($search)); $new_search_type = (int) $search_type; $new_object_type = (int) $object_type; $new_search_lang = (int) $search_lang; $search = deslash(trim($search)); $sql = ''; $words = array(); $fields = array('name'); $where_sql = ''; $where_sql2 = ''; $res = array(); $total = array(); $fl = false; // slice by spaces $new_search = preg_replace("/[^a-zа-яА-Я01-9_]+/i", ' ', $new_search); $words = array_filter(explode(' ', trim($new_search))); if (count($words) > 0) { $where_sql .= " and (0"; foreach ($words as $word) if (!empty($word) and (strlen($word) > 2)) { $fl = true; $where_sql .= " or ".implode(" like '%$word%' or ", $fields)." like '%$word%'"; } $where_sql .= ")"; } if ($id_company) { $sql .= ' and id_company='.$id_company; } if ($id_category) { $arr = fetch_child_tree($id_category); $sql .= ' and id_category in ('.implode(',', $arr).')'; } $min_price = (int) $min_price; $max_price = (int) $max_price; if ($min_price) { $sql .= ' and price>='.$min_price; } if ($max_price) { $sql .= ' and price<='.$max_price; } $min_price2 = (int) $min_price2; $max_price2 = (int) $max_price2; if ($min_price2) { $sql .= ' and price>2='.$min_price2; } if ($max_price2) { $sql .= ' and price2<='.$max_price2; } $ret_page = 'search'; $new_object_type = (int) $adv_search; $structs[0] = $db->OpenQuery("", "select * from product where id_lang=$id_lang and status=1 $sql $where_sql"); $total = $structs[0]->RecordCount(); $new_object_type = 0; $id_request = $db->NextId('search_request'); $db->ExecQuery("insert into search_request (id, search, object_type, search_type, search_lang, search_limit, total, dateadd) values ('$new_id_request', '$new_search_asis', '$new_object_type', '$new_search_type', '$new_search_lang', '$new_search_limit', '$total', ".time().")"); $id_search = $db->NextId('search', 'id_search'); $code = md5(time().'search'); $db->ExecQuery("insert into search_session (id_search, id_request, id_lang, code, dateadd, dateupdate) values ('$id_search', '$id_request', '".intval($id_lang)."', '$code', ".time().", ".time().")"); $icnt = 0; if ($total) { $arr = array(); foreach ($structs as $id_type=>$struct) while ($struct->Next()) { $id_type = (int) $id_type; $rate = 0; $name = $struct->FieldByName('name'); $title = $struct->FieldByName('title'); $descr = $struct->FieldByName('descr'); foreach ($words as $word) { $word_rate = 0; if (strpos(strtolower($descr), strtolower($word)) !== false) { $word_rate = max($word_rate, 1); } if (strpos(strtolower($title), strtolower($word)) !== false) { $word_rate = max($word_rate, 2); } if (strpos(strtolower($name), strtolower($word)) !== false) { $word_rate = max($word_rate, 3); } if ($word_rate != 0) $rate += $word_rate + 100; } $arr[$id_type.', '.$struct->FieldByName("id")] = $rate; } arsort($arr); $db->ExecQuery("insert into search (id_search, object_type, id_object) values ($id_search, ".implode("), ($id_search, ", array_keys($arr)).")"); $db->ExecQuery("optimize table search_session, search"); } header('Location: '.permalink($ret_page, $code)); exit(); } */ // ------------------------------------------- fetch_seo($page, true); $print_URL = getenv('REQUEST_URI'); if (substr($print_URL, 0, 7) == 'http://') { $print_URL = substr($print_URL, 7 + strlen(getenv('HTTP_HOST'))); } if ($print_URL == '/') { $print_URL = '/print.php'; } elseif (substr($print_URL, 0, 2) == '/?') { $print_URL = '/print.php'.substr($print_URL, 1); } elseif (substr($print_URL, 0, 10) == '/index.php') { $print_URL = '/print.php'.substr($print_URL, 10); } else { $print_URL = '/print'.$print_URL; } if ($page->FieldByName("title")) { $h1_title = $page->FieldByName("title"); } elseif ($page->FieldByName("name")) { $h1_title = $page->FieldByName("name"); } if ($page->FieldByName("module") == 'news' && $key) { if (preg_match('/^\d+$/', $key)) { $news = $db->OpenQuery("", "select * from news where id=".$key); } else { $news = $db->OpenQuery("", "select * from news where alias='".reslash($key)."'"); } if ($news->Next()) { $is_single = 1; $key = $news->FieldByName("id"); $dy = date('Y', $news->FieldByName("dateadd")); $dm = date('m', $news->FieldByName("dateadd")); $dd = date('d', $news->FieldByName("dateadd")); $h1_title = $news->FieldByName("title") ? $news->FieldByName("title") : $news->FieldByName("name"); $seo_title = $h1_title.' | '.$page->FieldByName("name").' | МДТ - Магазин домашнего текстиля'; $seo_descr = substr(strip_tags($news->FieldByName("descr")), 0, 150).'...'; //fetch_seo($news); } else { unset($key); } } if ($page->FieldByName("module") == 'article' && $key) { if (preg_match('/^\d+$/', $key)) { $article = $db->OpenQuery("", "select * from article where id=".$key); } else { $article = $db->OpenQuery("", "select * from article where alias='".reslash($key)."'"); } if ($article->Next()) { $is_single = 1; $key = $article->FieldByName("id"); $dy = date('Y', $article->FieldByName("dateadd")); $dm = date('m', $article->FieldByName("dateadd")); $dd = date('d', $article->FieldByName("dateadd")); $h1_title = $article->FieldByName("title") ? $article->FieldByName("title") : $article->FieldByName("name"); $seo_title = $h1_title.' | '.$page->FieldByName("name").' | МДТ - Магазин домашнего текстиля'; $seo_descr = substr(strip_tags($article->FieldByName("descr")), 0, 150).'...'; //fetch_seo($article); } else { unset($key); } } unset($topcat); $treecat = array(); $this_product_option = array(); if ($page->FieldByName("module") == 'company') { $is_seo = 0; if (!$id_company) { $id_company = 0; } else { if (is_numeric($id_company)) { $company = $db->OpenQuery("", "select * from company where id='".$id_company."'"); } else { $company = $db->OpenQuery("", "select * from company where id_lang=$id_lang and alias='".reslash($id_company)."'"); } if (!$company->Next()) { check_for_redirects(); } $id_company = $company->FieldByName("id"); $h1_title = $company->FieldByName("name"); $seo_title = $company->FieldByName("name").' ('.en2ru($company->FieldByName("name")).'): каталог продукции, цены, фото, описания.'; $seo_descr = 'Интернет магазин MDT.com.ua – официальный дилер продукции '.$company->FieldByName("name").' в Украине. Быстрая доставка, доступные цены, возможен самовывоз со склада! Тел: (044) 223-72-33.'; $seo_alt = 'Продукция компании '.$company->FieldByName("name").' ('.en2ru($company->FieldByName("name")).') | MDT.com.ua'; //if (!$is_seo) { $seo_title = $company->FieldByName("name"); } } } if ($page->FieldByName("module") == 'catalog') { $company_redirect = array(); $company_redirect_vs = array(); $tmp = $db->OpenQuery("", "select id, name, id_redirect from company"); while ($tmp->Next()) { $getNameById[$tmp->FieldByName("id")]['company']['name'.$lang_pref] = $tmp->FieldByName('name'.$lang_pref); if ($tmp->FieldByName("id_redirect")) { $company_redirect_vs[$tmp->FieldByName("id_redirect")][] = $tmp->FieldByName("id"); $company_redirect[$tmp->FieldByName("id")] = $tmp->FieldByName("id_redirect"); } else { $company_redirect_vs[$tmp->FieldByName("id")][] = $tmp->FieldByName("id"); $company_redirect[$tmp->FieldByName("id")] = $tmp->FieldByName("id"); } } $is_seo = 0; if (!$id_category) { $id_category = 0; } else { if (is_numeric($id_category)) { $category = $db->OpenQuery("", "select * from category where id='".$id_category."'"); } else { $category = $db->OpenQuery("", "select * from category where id_lang=$id_lang and alias='".reslash($id_category)."'"); } if (!$category->Next()) { if ($id_product) { if (is_numeric($id_product) && get_option('LinkType') == 0) { $product = $db->OpenQuery("", "select * from product where id='".$id_product."'"); } else { $product = $db->OpenQuery("", "select * from product where id_lang=$id_lang and alias='".reslash($id_product)."'"); } if ($product->Next()) { header('HTTP/1.1 301 Moved Permanently'); header('Location: '.product_permalink($product)); exit(); } } $arr_redir = array( 'pledy-pokryvala' => 'pledy', 'pol-tentsa' => 'polotentsa', 'tovary-yz-makhry' => 'polotentsa', 'prostyny-2' => 'prostyny', ); if (isset($arr_redir[$id_category])) { header('HTTP/1.1 301 Moved Permanently'); header('Location: '.str_replace($id_category, $arr_redir[$id_category], getenv('REQUEST_URI'))); exit(); } check_for_redirects(); } $id_category = $category->FieldByName("id"); if ($id_company) { if (!$is_seo) { $seo_title = $category->FieldByName("name").' '.$company->FieldByName("name"); } $h1_title = ''.$category->FieldByName("name").''; } else { fetch_seo($category); //if (!$is_seo) $seo_title = $category->FieldByName("name"); $h1_title = $category->FieldByName("name"); } $topcat = $category; $treecat[] = $topcat->FieldByName("id"); while ($topcat->FieldByName("id_parent")) { $topcat = $db->OpenQuery("", "select * from category where id=".$topcat->FieldByName("id_parent")); $topcat->Next(); if ($topcat->FieldByName("status")) { $treecat[] = $topcat->FieldByName("id"); } //$h1_title = ''.$topcat->FieldByName("name").' \ '.$h1_title; } } if ($id_category) { $this_link = category_permalink($category); } else { $this_link = permalink('catalog'); } if ($search) { $this_link = add_params($this_link, 'search='.urlencode($search)); } if (!$id_product) { $id_product = 0; } else { if (is_numeric($id_product) && get_option('LinkType') == 0) { $product = $db->OpenQuery("", "select * from product where id='".$id_product."'"); } else { $product = $db->OpenQuery("", "select * from product where id_lang=$id_lang and alias='".reslash($id_product)."'"); } if (!$product->Next()) { check_for_redirects(); } else { if ($product->FieldByName("id_category") != $id_category) { header('HTTP/1.1 301 Moved Permanently'); header('Location: '.product_permalink($product)); exit(); } $id_product = $product->FieldByName("id"); //$h1_title = $product->FieldByName("name"); //fetch_seo($product); $seo_title = $category->FieldByName("name").' '.$product->FieldByName("name").': купить, цена, фото, описание. Заказать '.$category->FieldByName("name").' '.$product->FieldByName("name").' с доставкой в любой город Украины.'; $seo_descr = 'Купить '.$category->FieldByName("name").' '.$product->FieldByName("name").' в интернет-магазине MDT.com.ua. Низкие цены, доставка, гарантия качества. Тел: (044) 223-72-33.'; $seo_key = $seo_key .= ', '.$category->FieldByName("name").' '.$product->FieldByName("name"); $seo_alt = $category->FieldByName("name").' '.$product->FieldByName("name").' | MDT.com.ua'; if ($product->FieldByName("id_company")) $this_product_option[0] = $product->FieldByName("id_company"); $tmp = $db->OpenQuery("", "select * from product_option where id_product=".$id_product); while ($tmp->Next()) { $this_product_option[$tmp->FieldByName("id_option")] = $tmp->FieldByName("id_option_value"); } } //if (!$is_seo) $seo_title .= ' '.$product->FieldByName("name"); } } if ($page->FieldByName("module") && is_file($page->FieldByName("module").'_pre.php')) { include_once($page->FieldByName("module").'_pre.php'); } if ($id_order) { $pdescr = str_replace('%id_order%', sprintf(get_option('OrderFormat'), $id_order), $page->FieldByName("descr")); } else { $pdescr = $page->FieldByName("descr"); } if ($domodal) { header('Content-type:text/html; charset=utf-8'); if ($page->FieldByName("module") && is_file($page->FieldByName("module").'.php')) { if (trim(strip_tags($pdescr, '')) != '') echo '
'; include_once($page->FieldByName("module").'.php'); } exit(); } include $PHEADER; /*if (is_object($parent_links) && $parent_links->RecordCount() > 0) { echo ''; }*/ if (trim(strip_tags($pdescr, '')) && ($page->FieldByName("module") != 'catalog' || (!$search && !$id_category && !$id_company)) && !$key) { $p = strpos($pdescr, '%MODULE%'); if ($p !== false) { getContent(substr($pdescr, 0, $p)); if ($page->FieldByName("module") && is_file($page->FieldByName("module").'.php')) { $is_mod = false; echo '
'; include_once($page->FieldByName("module").'.php'); echo '


'; } getContent(substr($pdescr, $p + 8)); } else { getContent($pdescr); } } if ($page->FieldByName("module") && is_file($page->FieldByName("module").'.php')) { if (trim(strip_tags($pdescr, '')) != '') echo '
'; echo '
'; include_once($page->FieldByName("module").'.php'); echo '
'; } $tmp = $db->OpenQuery("", "select * from struct_file where id_struct=$id_struct order by manual_order"); if ($tmp->RecordCount() > 0) { ?>

Next()) { $filename = 'files/'.$tmp->FieldByName("id"); if (is_file($filename)) { $pi++; $ext = preg_replace('/^.*\.([a-z]*)$/', '\1', $tmp->FieldByName("file")); if (!is_file($f = 'images/file/'.$ext.'.gif')) { $f = 'images/file/unknown.gif'; } $prop = getimagesize($f); ?>

"> border="0" align="left">  ">FieldByName('name'); ?> (FieldByName("file"))); ?> )

ExecQuery("delete from struct_file where id=".$tmp->FieldByName("id")); } } ?>