#1400
GrishaGrisha
Участник

<?php

//файл …

$num_element = $this->mas_inbox[«podcategory»];
$this->type_element = «»;

$this->data_synopsis_advert = array();
//$this->data_select_cat_podcat = array();

$this->add_param_url = array();

$this->data_category_url = array();

$this->set_num_page_category = false;

$this->open_num_category = 0;
$this->open_num_podcategory = 0;

$mas_serias_lvl_num_category = array();
$this->mas_series_num_category = array();

$this->search_mas_num_lvl_category = array();

$this->search_navigation_exists_images_advert = false;

if ( $this->status_inbox[«podcategory»] == «set» )
{

if ( $this->obj_cache_category->check_num_data_1lvl($num_element) )
{
$this->type_element = «high»;
$this->open_num_category = $num_element;
$this->data_open_category = $this->obj_cache_category->get_one_num_data($num_element);

header(«Location: «.$this->dir_http.»/».$this->forming_name_url_category($num_element,»high»).»/»);
exit ();

}
elseif ( $this->obj_cache_category->check_num_data_many_lvl($num_element) )
{
//if ( empty( $this->mas_category[$this->mas_podcategory[$num_element][«n_category»]] ) ) return (false);
$mas_serias_lvl_num_category = $this->serias_lvl_num_category($num_element);
if ( !$mas_serias_lvl_num_category ) return (false);
$this->type_element = «inferior»;
$this->open_num_category = $mas_serias_lvl_num_category[0];//$this->mas_podcategory[$num_element][«n_category»];
$this->open_num_podcategory = $num_element;
$this->data_open_podcategory = $this->obj_cache_category->get_one_num_data($num_element);

header(«Location: «.$this->dir_http.»/».$this->forming_name_url_category($num_element,»inferior»).»/»);
exit ();

}
else
{

return (false);
}
}
elseif ( $this->status_inbox[«category_url»] == «set» )
{
$category_url = $this->mas_inbox[«category_url»];
if ( !trim($category_url) ) return (false);

if ( mb_substr($category_url,mb_strlen($category_url)-1,1) == «/» )
$category_url = mb_substr($category_url,0,mb_strlen($category_url)-1);

if ( !trim($category_url) ) return (false);
$this->data_category_url = explode(«/»,$category_url);

//list($on_category,$key_category) = search_mas_2level($this->mas_category,»united_name_url»,$this->data_category_url[0],false);
$mas_serias_lvl_num_category = $this->obj_cache_category->check_mas_name_url_data($this->data_category_url);

//if ( !$on_category ) return (false);
if ( !$mas_serias_lvl_num_category ) return (false);

//if ( sizeof($this->data_category_url) == 2 )
$kolvo_lvl = sizeof($mas_serias_lvl_num_category);
if ( $kolvo_lvl > 1 )
{

//if ( !trim($this->data_category_url[1]) ) return (false);

//list($on_podcategory,$key_podcategory) = search_mas_2level($this->mas_podcategory,»united_name_url»,$this->data_category_url[1],false);
//list($on_podcategory,$key_podcategory) = search_mas_2level($this->mas_num_podcategory[$key_category],»united_name_url»,$this->data_category_url[1],false);

//if ( !$on_podcategory ) return (false);

$this->type_element = «inferior»;
$this->open_num_category = $mas_serias_lvl_num_category[0];//$this->mas_podcategory[$key_podcategory][«n_category»];
$this->open_num_podcategory = $mas_serias_lvl_num_category[$kolvo_lvl — 1];//$key_podcategory;
$this->data_open_podcategory = $this->obj_cache_category->get_one_num_data($this->open_num_podcategory);//$this->mas_podcategory[$key_podcategory];

}
elseif ( $kolvo_lvl == 1 )
{
$this->type_element = «high»;
$this->open_num_category = $mas_serias_lvl_num_category[0];
$this->data_open_category = $this->obj_cache_category->get_one_num_data($this->open_num_category);
}
else
{
return (false);
}

}
else
{
return (false);
}

$this->mas_series_num_category = $mas_serias_lvl_num_category;

$this->search_mas_num_lvl_category = $mas_serias_lvl_num_category;

$this->num_open_lvl_category = $this->open_num_podcategory > 0 ? $this->open_num_podcategory : $this->open_num_category;

$this->num_element_init_dynamic_data = $this->num_open_lvl_category;// ($this->open_num_podcategory > 0 ? $this->open_num_podcategory : $this->open_num_category);
$this->opred_param_dynamic_part_search();

if ($this->status_inbox[«num_page_podcategory»] == «set»)
{
$this->open_num_page=$this->mas_inbox[«num_page_podcategory»];
$this->set_num_page_category = true;
}
else
$this->open_num_page=1;

$list_num_category_query = «»;
$one_num_category_query = «»;

$t_db_query_category = $this->get_text_db_query_part_category( «advert.n_category», $this->num_open_lvl_category );

$db_query_stext = «»;
$db_query_cost = «»;
$db_query_exists_images = «»;

$this->data_light_search[«currency»] = $this->mas_inbox[«currency»];

if ( $this->mas_inbox[«s_text»] )
{
$this->add_param_url[«s_text»] = $this->mas_inbox[«s_text»];

$this->data_light_search[«s_text»] = $this->mas_inbox[«s_text»];

//Убираем лишние слова из запроса
$stopWords = array(
‘что’, ‘как’, ‘все’, ‘она’, ‘так’, ‘его’, ‘только’, ‘мне’, ‘было’, ‘вот’,
‘меня’, ‘еще’, ‘нет’, ‘ему’, ‘теперь’, ‘когда’, ‘даже’, ‘вдруг’, ‘если’,
‘уже’, ‘или’, ‘быть’, ‘был’, ‘него’, ‘вас’, ‘нибудь’, ‘опять’, ‘вам’, ‘ведь’,
‘там’, ‘потом’, ‘себя’, ‘может’, ‘они’, ‘тут’, ‘где’, ‘есть’, ‘надо’, ‘ней’,
‘для’, ‘тебя’, ‘чем’, ‘была’, ‘сам’, ‘чтоб’, ‘без’, ‘будто’, ‘чего’, ‘раз’,
‘тоже’, ‘себе’, ‘под’, ‘будет’, ‘тогда’, ‘кто’, ‘этот’, ‘того’, ‘потому’,
‘этого’, ‘какой’, ‘ним’, ‘этом’, ‘один’, ‘почти’, ‘мой’, ‘тем’, ‘чтобы’,
‘нее’, ‘были’, ‘куда’, ‘зачем’, ‘всех’, ‘можно’, ‘при’, ‘два’, ‘другой’,
‘хоть’, ‘после’, ‘над’, ‘больше’, ‘тот’, ‘через’, ‘эти’, ‘нас’, ‘про’, ‘них’,
‘какая’, ‘много’, ‘разве’, ‘три’, ‘эту’, ‘моя’, ‘свою’, ‘этой’, ‘перед’,
‘чуть’, ‘том’, ‘такой’, ‘более’, ‘всю’, ‘продам’, ‘куплю’, ‘купить’, ‘продать’, ‘сдам’, ‘сниму’
);
// list($mas_words,$is_min_length) = process_text_search($this->mas_inbox[«s_text»],3,60);
list($mas_words,$is_min_length) = process_text_search($this->mas_inbox[«s_text»],4,60);

$find = str_replace($stopWords, », $this->mas_inbox[«s_text»]);
$find = str_replace(‘ ‘,’ +’,$this->mas_inbox[«s_text»]);

if ( sizeof($mas_words) )
{
// $db_query_stext .= » and MATCH advert.name_adv AGAINST (‘%$find%’) + MATCH advert.text AGAINST (‘%$find%’) «;
$db_query_stext .= » and MATCH (advert.text,advert.name_adv) AGAINST (‘%$find%’ IN BOOLEAN MODE)»;
}
}

/*
if ( sizeof($mas_words) )
{
$db_query_stext .= » and ( «;
$sep = «»;
foreach ( $mas_words as $one_word )
{
$db_query_stext .= $sep . » ( »
.» advert.text LIKE ‘%».$one_word.»%’ »
.» or advert.name_adv LIKE ‘%».$one_word.»%’ »
// .» or advert.key_words LIKE ‘%».$one_word.»%’ »
.» ) «;
$sep = » or «;
}
$db_query_stext .= » ) «;
}

}
*/

$p_cost = » cost «;

global $init_base_currency,$init_use_currency,$init_course_currency,$init_currency;

if ( sizeof( $init_use_currency ) > 1 )
{
$p_cost = » ( «;
$p_cost .= «(( currency = ‘».$this->mas_inbox[«currency»].»‘ ) * cost )»;

foreach ( $init_use_currency as $one_currency )
{
if ( $one_currency == $this->mas_inbox[«currency»] ) continue;
$p_cost .= » + ((currency = ‘».$one_currency.»‘) * cost * »
.$init_course_currency[ $this->mas_inbox[«currency»] ].» / «.$init_course_currency[$one_currency].») «;
}

$p_cost .= «)»;
}

if ( $this->mas_inbox[«min_cost»] )
{
$this->data_light_search[«min_cost»] = $this->mas_inbox[«min_cost»] — 0;
$db_query_cost .= » and ( «.$p_cost.» >= «.$this->data_light_search[«min_cost»].» ) «;

$this->add_param_url[«s_min_cost»] = $this->data_light_search[«min_cost»];
$this->add_param_url[«s_currency»] = $this->data_light_search[«currency»];
}

if ( $this->mas_inbox[«max_cost»] )
{
$this->data_light_search[«max_cost»] = $this->mas_inbox[«max_cost»] — 0;
$db_query_cost .= » and ( «.$p_cost.» <= «.$this->data_light_search[«max_cost»].» ) «;

$this->add_param_url[«s_max_cost»] = $this->data_light_search[«max_cost»];
$this->add_param_url[«s_currency»] = $this->data_light_search[«currency»];
}

$this->data_light_search[«exists_images»] = «off»;
if ( $this->status_inbox[«exists_images»] == «set» )
{
$this->data_light_search[«exists_images»] = «on»;
$db_query_exists_images = » and advert.image != » «;
$this->add_param_url[«s_exists_images»] = «on»;
}

$q_where_dynamic_tab_data=» «;

/*
if ( $this->podcategory_search > 0 && $this->search_part_query_db_dynamic_data )
{
$q_where_dynamic_tab_data.=» and advert.id_advert = ALL ( select n_advert from »
.DB_PREF.»board_data
where n_category = «.$this->podcategory_search.» «.$this->search_part_query_db_dynamic_data.» ) «;

}
*/

if ( sizeof( $this->mas_query_data_dynamic_search ) > 0 )
{
foreach ( $this->mas_query_data_dynamic_search as $one_query )
{
$q_where_dynamic_tab_data.=» and EXISTS ( select * from «.DB_PREF.»board_data tab_dynamic
where «//.» tab_dynamic.n_category = «.$this->open_num_podcategory.» »
.» advert.id_advert = tab_dynamic.n_advert «. $one_query . » »
.») «;
}

}

//echo($q_where_dynamic_tab_data);

$db_query=»select count(*)
from «.DB_PREF.»advert advert
where »
//.» n_category » . ( $list_num_category_query !== «» ? ( » IN («.$list_num_category_query.») » ) : » = » . $one_num_category_query )
.( $t_db_query_category ? » ( «.$t_db_query_category.» ) and » : «» )
.» hide=’show’ and end_putdate>».$GLOBALS[«timeGlobal»].» »
.$db_query_stext.$db_query_cost
.$db_query_exists_images
.$this->add_db_query_country().$this->add_db_query_region().$this->add_db_query_city()
.$q_where_dynamic_tab_data;

$vsego_kolvo=obr_db_query_count($db_query);

$this->kolvo_adv_vsego_to_category=$vsego_kolvo;

if ( $this->status_inbox[«sort»] == «set» )
{
$this->name_sort = $this->mas_inbox[«sort»];
$this->type_sort = $this->mas_inbox[«tsort»];

}

if ($vsego_kolvo==0)
{
if ($this->open_num_page!=1)
return (false);
}
else
{

global $init_sort_doska;

$db_query=»select * from «.DB_PREF.»advert advert where »

.( $t_db_query_category ? » ( «.$t_db_query_category.» ) and » : «» ).» hide=’show’ and end_putdate>».$GLOBALS[«timeGlobal»].» »

.$db_query_stext.$db_query_cost.$db_query_exists_images.$this->add_db_query_country().$this->add_db_query_region().$this->add_db_query_city().$q_where_dynamic_tab_data

.» order by».

( $this->name_sort ? » «.$init_sort_doska[$this->name_sort].» «.$this->type_sort.» » : ( $this->mas_inbox[«s_text»] ? » premium_adv DESC » : » premium_adv DESC, sort_time DESC «))

.» limit «.($this->open_num_page-1)*KOL_SYNOPSIS_ADVERT.» , «.KOL_SYNOPSIS_ADVERT;

list($kolvo_adv,$this->data_synopsis_advert)=obr_db_query_select_assoc($db_query);

if ($kolvo_adv==0) return (false);

}

//$this->base_url_page = $this->dir_http.»/category».($this->open_num_podcategory ? $this->open_num_podcategory : $this->open_num_category).»/»;
$this->base_url_page = ($this->open_num_podcategory ? $this->forming_all_name_url_category( $this->open_num_podcategory, «inferior») : $this->forming_all_name_url_category( $this->open_num_category,»high») );

$korekParam = true;