GetShopValues('dir'); if ($_SESSION['payment']['multiplex'] > 0) { $gOptions['main_base_curr'] = $_SESSION['payment']['curr_name']; $gOptions['main_prec'] = $_SESSION['payment']['curr_prec']; } // Get page parameters $topic = $_GET['id']*1; $do_exp_search = isset($_GET['exp_search_words']); $search_words = ( $do_exp_search ) ? $_GET['exp_search_words'] : $_GET['search_words']; $psu_code = $_GET['psu']; if ( strlen($psu_code) > 0 ) { $topic = $gData->FindTopicPSU(addslashes($psu_code)); if ( $topic == 0 ) { header("Location: ./"); exit; } } $gPage = ( $topic > 0 ) ? $gData->GetPageProperties($topic) : $gData->GetPageProperties($gOptions['dir_find_page_id']*1); // Redirect to first page if ( ( $gPage['id'] == 0 ) || ( $gPage['active'] != 1 && $topic > 0 ) ) { header("Location: ./"); exit; } // Redirect to psevdo-static url if ( isset($_GET['partner']) ) unset($_GET['partner']); if ( strlen($psu_code) == 0 && strlen($gPage['seo_psu']) > 0 && count($_GET) == 1 ) { header("Location: ./dir_".urlencode($gPage['seo_psu']).'.htm'); exit; } // Define client if ( !isset($_SESSION['client']) ) { new_client(); } // Test for reload database if ( test_basket_reload() ) exit; // Make path for back make_back_path(); // Save shop statistic if ( $topic > 0 ) { $elem_id = $topic; } else { $elem_id = 0; if ( $search_words == '' && $_GET['hit'] == 1 ) $elem_id = 1; if ( $search_words == '' && $_GET['new'] == 1 ) $elem_id = 2; if ( $search_words == '' && $_GET['disc'] == 1 ) $elem_id = 3; } save_shop_stat(( $topic > 0 ) ? 'dir' : 'search', $elem_id, $search_words); // Init templates $gTpl = new FastTemplate('./'.TEMPLATES.'/_dir'); $gTpl->DefineTemplate(array('main' => $gPage['template_name'], 'no_dir_goods' => 'no_dir_goods.htm', 'no_find_goods' => 'no_find_goods.htm', 'too_many_goods' => 'too_many_goods.htm', 'no_filter_goods' => 'no_filter_goods.htm', 'order_line' => 'order_line.htm', 'reset_line' => 'reset_line.htm', 'reset_filter' => 'reset_filter.htm', 'reset_order' => 'reset_order.htm', 'text_block' => 'text_block.htm', 'search_title' => 'search_title.htm' )); // Parsing page properties $file_path = './files/topic'.$gPage['id'].'.htm'; if ( is_file($file_path) && $_GET['from']*1 == 0 && !isset($_GET['filter']) && !isset($_GET['order']) ) { $gTpl->Assign('CONTENT', iconv('UTF-8', SHOP_CHARSET, implode("", (@file($file_path))))); $gTpl->Parse('TEXTBLOCK', 'text_block'); $gTpl->Clear('CONTENT'); $text_exists = true; } else { $gTpl->Assign('TEXTBLOCK', ''); $text_exists = false; } // Parse sections list $section_array = sections($topic); $gTpl->Assign($section_array); // Parsing page properties if ( $topic > 0 ) { ( $gPage['title'] == '' ) ? $title = $section_array['SECTIONNAME'] : $title = $gPage['title']; $gTpl->Assign(array('TITLE' => htmlspecialchars($title), 'DESCRIPTION' => htmlspecialchars($gPage['descr']), 'KEYWORDS' => htmlspecialchars($gPage['keywords']), 'SEARCHWORDS' => '', 'FILTERKEY' => '' )); } else { $gTpl->Assign(array('TITLE' => htmlspecialchars($search_words), 'DESCRIPTION' => '', 'KEYWORDS' => '', 'SEARCHWORDS' => htmlspecialchars($search_words), 'FILTERKEY' => '' )); $gTpl->Parse('SECTIONNAME', 'search_title'); } $section_array = array(); // Make path if ( $topic > 0 ) { $base_path = 'dir.php?id='.$gPage['id']; } else { if ( $do_exp_search ) { $base_path = 'dir.php?exp_search_words='.urlencode($search_words); $base_path .= ( $_GET['topic_search']*1 > 0 ) ? '&topic_search='.$_GET['topic_search']*1 : ''; $base_path .= ( $_GET['new']*1 > 0 ) ? '&new=1' : ''; $base_path .= ( $_GET['hit']*1 > 0 ) ? '&hit=1' : ''; $base_path .= ( $_GET['desc']*1 > 0 ) ? '&disc=1' : ''; $base_path .= ( $_GET['price_from']*1 > 0 ) ? '&price_from='.urlencode($_GET['price_from']) : ''; $base_path .= ( $_GET['price_to']*1 > 0 ) ? '&price_to='.urlencode($_GET['price_to']) : ''; } else { $base_path = 'dir.php?search_words='.urlencode($search_words); } } // Make status path $status_path = ''; $status_path .= ( $_GET['status0']*1 > 0 ) ? '&status0=1' : ''; $status_path .= ( $_GET['status1']*1 > 0 ) ? '&status1=1' : ''; $status_path .= ( $_GET['status2']*1 > 0 ) ? '&status2=1' : ''; $status_path .= ( $_GET['status3']*1 > 0 ) ? '&status3=1' : ''; // Make filter path $filter_path = ''; if ( strlen($_GET['filter']) > 0 ) { $filt = explode('and', $_GET['filter']); foreach ($filt as $id) { $filter_path .= '&filter'.($id*1).'='.$_GET['filter'.$id]; } $filter_path .= '&filter='.$_GET['filter']; } // Make order path if ( strlen($_GET['order']) > 0 ) { $order_path = '&order='.$_GET['order']; } // Make path for select if ( isset($_GET['select']) ) { $base_path .= '&select=go&price_from='.urlencode($_GET['price_from']).'&price_to='.urlencode($_GET['price_to']); } // Make dir, select or search goods if ( $topic > 0 ) { if ( isset($_GET['select']) ) { $price_from = str_replace(',','.',$_GET['price_from'])*1; $price_to = str_replace(',','.',$_GET['price_to'])*1; $ic_value = $_SESSION['payment']['multiplex']*1; if ( $ic_value > 0 ) { $price_from = round($price_from/$ic_value, 2); $price_to = round($price_to/$ic_value, 2); } $total_goods = $gData->MakeSelectGoods($topic, $price_from, $price_to); } else { $total_goods = $gData->MakeDirGoods($topic, ($_GET['status0']*1 == 1), ($_GET['status1']*1 == 1), ($_GET['status2']*1 == 1), ($_GET['status3']*1 == 1) ); } } else { if ( $do_exp_search ) { $total_goods = $gData->MakeExpSearchGoods(addslashes($search_words), $_GET['topic_search']*1, ($_GET['status0']*1 == 1), ($_GET['status1']*1 == 1), ($_GET['status2']*1 == 1), ($_GET['status3']*1 == 1), ($_GET['new']*1 == 1), ($_GET['hit']*1 == 1), ($_GET['disc']*1 == 1), str_replace(',', '.', $_GET['price_from'])*1, str_replace(',', '.', $_GET['price_to'])*1 ); } else { $total_goods = $gData->MakeSearchGoods(addslashes($search_words), ($_GET['status0']*1 == 1), ($_GET['status1']*1 == 1), ($_GET['status2']*1 == 1), ($_GET['status3']*1 == 1) ); } } $parse_goods = 0; // Apply filters $apply_filter = FALSE; $filter_goods = $total_goods; if ( ( strlen($_GET['filter']) > 0 ) && ( $total_goods > 0 ) ) { $filter_goods = $gData->ApplyFilterGoods($_GET); $apply_filter = TRUE; } // Not many goods? if ( $filter_goods > 1000 ) { $gTpl->Parse('GOODS', 'too_many_goods'); $gTpl->Assign('SUBSECTIONS', ''); $gTpl->Assign('SELECT', ''); $places = explode(';', $gOptions['main_how_filter']); foreach ( $places as $key ) $parse[$key] = ''; $gTpl->Assign($parse); } else { // Parse select $select_page = $gData->GetNeedTopicFilter($topic); ( $select_page && $_GET['from']*1 == 0 ) ? $gTpl->Assign('SELECT', select($topic)) : $gTpl->Assign('SELECT', ''); // Parse filters $gTpl->Assign(filters('dir', $base_path.$status_path.$order_path, $total_goods, $select_page)); // Parse sub sections list if ( $topic > 0 ) { $gTpl->Assign('SUBSECTIONS', ( $gPage['sub_sec_type'] == 0 ) ? sub_sections_simple($topic) : sub_sections_hard($topic, $gPage['tlevel']) ); } else { if ( strlen($search_words) > 0 ) { $gTpl->Assign('SUBSECTIONS', sub_sections_search($apply_filter, $filter_path)); } else { $gTpl->Assign('SUBSECTIONS', ''); } } // Goods exists? if ( $total_goods == 0 || $gPage['step_goods'] == 0 || $gPage['main_goods_col'] == 0 ) { if ( strlen($gTpl->Fetch('SUBSECTIONS')) == 0 && !$text_exists && !$select_page) { $gTpl->Parse('GOODS', ( $topic > 0 ) ? 'no_dir_goods' : 'no_find_goods'); } else { if ( $select_page && isset($_GET['select']) ) { $gTpl->Parse('GOODS', 'no_find_goods'); } else { $gTpl->Assign('GOODS', ''); } } } else { // Parse main goods $goods = $gData->GetMainGoods($apply_filter, $_GET['order'], ($gPage['order_by_voice'] == 1) ); $parse_goods = $gData->GetNumRows($goods); if ( $parse_goods == 0 ) { $gTpl->Parse('GOODS', 'no_filter_goods'); } else { if ( $_GET['from']*1 >= $parse_goods ) $_GET['from'] = 0; $gTpl->Assign('GOODS', main_goods($goods, $parse_goods, $_GET['from']*1, $gPage['step_goods'], $gPage['main_goods_col'], $gPage['templates_goods'])); } } } // Parse order line and status filter if ( $parse_goods > 0 ) { // order $gTpl->Assign(array('ORDERPRICE' => $base_path.$status_path.$filter_path.'&order=price', 'ORDERPRICEDESC' => $base_path.$status_path.$filter_path.'&order=price_desc', 'ORDERNAME' => $base_path.$status_path.$filter_path.'&order=name', 'ORDERNAMEDESC' => $base_path.$status_path.$filter_path.'&order=name_desc' )); $gTpl->Parse('ORDERLINE', 'order_line'); // status $status0 = ( $_GET['status0']*1 != 0 ) ? '&status0=1' : ''; $status1 = ( $_GET['status1']*1 != 0 ) ? '&status1=1' : ''; $status2 = ( $_GET['status2']*1 != 0 ) ? '&status2=1' : ''; $status3 = ( $_GET['status3']*1 != 0 ) ? '&status3=1' : ''; if ( $status0 == '' && $status1 == '' && $status2 == '' && $status3 == '' ) { $status0 = '&status0=1'; $status1 = '&status1=1'; $status2 = '&status2=1'; $status3 = '&status3=1'; $apply_status = false; } else { $apply_status = true; } $gTpl->Assign(array('NOSTATUS0' => $base_path.$order_path.$filter_path.$status1.$status2.$status3, 'NOSTATUS1' => $base_path.$order_path.$filter_path.$status0.$status2.$status3, 'NOSTATUS2' => $base_path.$order_path.$filter_path.$status0.$status1.$status3, 'NOSTATUS3' => $base_path.$order_path.$filter_path.$status0.$status1.$status2 )); // reset options $do_reset = false; if ( $apply_filter || $apply_status ) { $gTpl->Assign('LINK', $base_path.$order_path); $gTpl->Parse('TORESET', 'reset_filter'); $do_reset = true; } if ( strlen($order_path) > 0 ) { $gTpl->Assign('LINK', $base_path.$status_path.$filter_path); $gTpl->Parse('TORESET', '.reset_order'); $do_reset = true; } if ( $do_reset ) { $gTpl->Parse('ORDERLINE', '.reset_line'); } } else { $gTpl->Assign('ORDERLINE', ''); } // Parse guide line if ( $parse_goods > $gPage['step_goods'] && $gPage['step_goods'] > 0 ) { $gTpl->Assign('GUIDELINE', guide_line($_GET['from']*1, $gPage['step_goods'], $parse_goods, $base_path.$filter_path.$status_path.$order_path, '/'.TEMPLATES.'/guide_line/goods')); } else { $gTpl->Assign('GUIDELINE', ''); } // Parse advert goods $gTpl->Assign(advert_goods($gPage['id'])); // Parse hit goods $gTpl->Assign('HITGOODS', hit_goods($gPage['hit_goods_col'], $gPage['hit_goods_how'])); // Parse new goods $gTpl->Assign('NEWGOODS', new_topic_goods($topic, $gPage['new_goods_col'], $gPage['new_goods_how'])); // Echo shop variables echo_shop_variables('in_catalog'); // Additional modules use_php_mod('dir'); // Parse main page $gTpl->Parse('MAIN', 'main'); $gEndPoint = run_time($gStartPoint); $gTpl->FastPrint('MAIN'); // Echo page compilate time echo_page_time($gEndPoint); } ?>