assign('pagetekst','Нет такого вида транспорта!'); $smarty->display('blank_error.tpl'); require("../inc/bottom.php"); exit; } if ($vehicle=='truck') { $vehicle_rus='грузовиков'; $smarty->assign('kuzov_type_mas',$truck_kuzov_type_mas); } elseif ($vehicle=='bus') { $vehicle_rus='автобусов'; $smarty->assign('kuzov_type_mas',$bus_kuzov_type_mas); } elseif ($vehicle=='moto') { $vehicle_rus='мотоциклов'; $smarty->assign('kuzov_type_mas',$moto_kuzov_type_mas); } elseif ($vehicle=='spec') { $vehicle_rus='спецтехники'; $smarty->assign('kuzov_type_mas',$spec_kuzov_type_mas); } elseif ($vehicle=='water') { $vehicle_rus='водного транспорта'; $smarty->assign('kuzov_type_mas',$water_kuzov_type_mas); } $smarty->assign('vehicle',$vehicle); $smarty->assign('vehicle_rus',$vehicle_rus); $smarty->assign('link_img_s','/upload/'.$vehicle.'/sale_s/'); $smarty->assign('link_img_m','/upload/'.$vehicle.'/sale_l/'); //$smarty->assign('link_img_l','/upload/'.$vehicle.'/sale_l/'); //обратная навигация $mas_back_nav=array(); $mas_back_nav[]=array('name'=>'Объявления','link'=>'/'.$vehicle.'/'); $smarty->assign('toptitle','Объявления о продаже '.$vehicle_rus.' - '._SHOT_TOP_DESC_); $qr_str=$_SERVER['QUERY_STRING']; if ($qr_str == 'pst=/') $qr_str = "vehicle.php?action=search&vehicle=".$vehicle."&show_popular_vendors=1®ionid[]=".$reg."&cost_from=&cost_to=&power_from=&power_to=&god_from=&god_to=&probeg=&dealerid=0&sale_type=0&extended_open=0"; $s=array("/&page=[0-9]*/","/&sort=[_a-zA-Z0-9]*/","/&asc=[0-9]/","/pst=\//","/&dealerid=[0-9]*/","/&vehicle=[a-z]*/","/vehicle=[a-z]*/"); $r=array(); $qr_str=preg_replace($s,$r,$qr_str); $qr_str='/vehicle.php?vehicle='.$vehicle.'&'.$qr_str.'&'; $action=@$_GET['action']; if (intval(@$pst[0])>0) { $action='car'; $id=$pst[0]; } elseif (intval(@$pst[2])>0) { $action='car'; $id=$pst[2]; } //быстрый выбор по производителю и модели elseif (@$pst[0]<>'') { $action='search'; //смотрим что за производитель $vendor=get_vehicle_vendor_by_name($vehicle,$pst[0],0); $_GET['vendorid']=array($vendor['id']); $mas_back_nav[]=array('name'=>$vendor['name'],'link'=>'/'.$vehicle.'/'.$vendor['link'].'/'); $smarty->assign('toptitle','Объявления о продаже автомобилей '.$vendor['name'].' - '._SHOT_TOP_DESC_); $qr_str='/'.$vehicle.'/'.$vendor['link'].'/&'; if (@$pst[1]<>'') { //смотрим что за модель $model=get_vehicle_model_by_name($vehicle,$vendor['id'],$pst[1]); $_GET['modelid']=array($model['id']); $mas_back_nav[]=array('name'=>$model['name'],'link'=>'/'.$vehicle.'/'.$vendor['link'].'/'.$model['link'].'/'); $smarty->assign('toptitle','Объявления о продаже '.$vehicle_rus.' '.$vendor['name'].' '.$model['link'].' - '._SHOT_TOP_DESC_); $qr_str='/'.$vehicle.'/'.$vendor['link'].'/'.$model['link'].'/&'; } $smarty->assign('tit_no_link',1); $smarty->assign('mas_back_nav',$mas_back_nav); } $sql_sale_type=''; if (isset($_GET['sale_type'])) { if ($_GET['sale_type']==5) $sql_sale_type=' AND sale_type=0'; elseif ($_GET['sale_type']!=0) $sql_sale_type=' AND sale_type='.intval($_GET['sale_type']); } $user = new users_class(); $smarty->assign('bit',$user->load()); $smarty->assign('mas_user_settings',$user->mas_user_settings); // ---------- Выводим форум ----------------- // $resultforum=get_sibnet_do_forum(5); $smarty->assign('mas_forum',$resultforum); $smarty->assign('mas_do',get_sibnet_do(6)); //$smarty->assign('mas_ct_types',get_types_count()); $smarty->assign('mas_newcomments',get_new_sale_comments(12)); $smarty->assign('mas_vendors',list_vehicle_vendors_in_sale($vehicle)); //сотрировка $sort=@$_GET['sort']; $asc=intval(@$_GET['asc']); $pagenamb=intval(@$_GET['page']); if (!($pagenamb>0)) { $pagenamb=1; } if ($sort=='') { $sort='date'; } if ($asc==1) { $q_asc=" ASC "; } else { $q_asc=" DESC "; } $q_sort=''; if ($sort=='date') { $q_sort=" ORDER BY car.updated desc, car.date ".$q_asc; } elseif ($sort=='name') { $q_sort=" ORDER BY vendor ".$q_asc.",model ".$q_asc; } elseif ($sort=='god') { $q_sort=" ORDER BY car.god ".$q_asc; } //elseif ($sort=='val') { $q_sort=" ORDER BY car.engine_volume ".$q_asc; } //elseif ($sort=='trans') { $q_sort=" ORDER BY car.transmission ".$q_asc; } elseif ($sort=='probeg') { $q_sort=" ORDER BY car.probeg ".$q_asc; } elseif ($sort=='color') { $q_sort=" ORDER BY car.color ".$q_asc; } elseif ($sort=='cost') { $q_sort=" ORDER BY car.cost ".$q_asc; } elseif ($sort=='view') { $q_sort=" ORDER BY car.ctview ".$q_asc; } elseif ($sort=='engine_volume') { $q_sort=" ORDER BY car.engine_volume ".$q_asc; } elseif ($sort=='transmission' and $vehicle<>'water' and $vehicle<>'moto') { $q_sort=" ORDER BY car.transmission ".$q_asc; } elseif ($sort=='color') { $q_sort=" ORDER BY car.color ".$q_asc; } elseif ($sort=='kuzov') { $q_sort=" ORDER BY car.kuzov ".$q_asc; } elseif ($sort=='cityid') { $q_sort=" ORDER BY car.cityid ".$q_asc; } elseif ($sort=='power') { $q_sort=" ORDER BY car.power ".$q_asc; } elseif ($sort=='drive_type' and $vehicle<>'water' and $vehicle<>'moto') { $q_sort=" ORDER BY car.drive_type ".$q_asc; } elseif ($sort=='wheel' and $vehicle<>'water' and $vehicle<>'moto') { $q_sort=" ORDER BY car.wheel ".$q_asc; } elseif ($sort=='fuel_type' and $vehicle<>'water' and $vehicle<>'moto') { $q_sort=" ORDER BY car.fuel_type ".$q_asc; } elseif ($sort=='climate' and $vehicle<>'water' and $vehicle<>'moto') { $q_sort=" ORDER BY car.climate ".$q_asc; } $qr_str_forpage=$qr_str.'sort='.$sort.'&asc='.$asc.'&'; $qr_str_sort=$qr_str.'page='.$pagenamb.'&'; if (isset($_GET['dealerid'])) {$qr_str_sort.='dealerid='.intval($_GET['dealerid']).'&';} $smarty->assign('q_string',$qr_str_sort); $smarty->assign('sort',$sort); $smarty->assign('share',get_share(1)); switch ($action) { default: $title_cities=''; $title_pcities=''; $title_regs=''; if ( ( count($_GET)==2 ) ) { // задает регион поиска по выборку селектора $_GET['regionid'][]=$reg; $title_regs = "е".$mas_region[$_GET['regionid'][0]]['name']; } else { if (!isset($_GET['cityid'])){ if (!isset($_GET['regionid'])){ $title_cities=''; $title_pcities=''; } else{ $region_ct=count($_GET['regionid']); for($i=0;$i<$region_ct;$i++){ if (isset($mas_region[$_GET['regionid'][$i]]['name'])) $title_regs.=', '.$mas_region[$_GET['regionid'][$i]]['name']; } } } else{ $region_ct=count($_GET['cityid']); for($i=0;$i<$region_ct;$i++){ if (isset($mas_city_by_id[$_GET['cityid'][$i]])){ $title_cities.=', '.$mas_city_by_id[$_GET['cityid'][$i]]; $title_pcities.=', '.$mas_city_by_pname[$_GET['cityid'][$i]]; } } } } //End if (count($_GET)==1) echo $title_cities; if ($title_cities<>'') $title_cities=' г. '.substr($title_cities,1); if ($title_pcities<>'') $title_pcities=substr($title_pcities,1); if ($title_regs<>'') {$title_cities='рег. '.substr($title_regs,1);$title_pcities=$title_cities;} if ($title_cities=='') $title_cities='Сибири'; if ($title_pcities=='') $title_pcities='Сибири'; $smarty->assign('toptitle','Авторынок '.$title_cities.': продажа автомобилей в '.$title_pcities); $smarty->assign('topdes','Весь авторынок '.$title_cities.' на одном сайте. Продажа автомобилей в '.$title_pcities.'. Автомобили с пробегом и новые авто в '.$title_pcities.'.'); if ($title_cities=='Сибири') $smarty->assign('h1_title','Россия'); else $smarty->assign('h1_title',''.substr($title_cities,4).''); $cat_filtr=new cat_filtr; $cat_filtr->type='do'; $cat_filtr->param=$_GET; $cat_filtr->mas_city=$mas_city; $cat_filtr->ct_region=count($mas_region); $sql=$cat_filtr->cars(); if (isset($_GET['dealerid']) and $_GET['dealerid']>0) { $dealerid=intval($_GET['dealerid']); $qr_str_forpage.='dealerid='.$dealerid.'&'; $sql.=' AND userid='.$dealerid; if (isset($_GET['vendid'])) $sql.=' AND car.vendorid='.intval($_GET['vendid']); $q_d="SELECT id,surname,cityid,email,site,address,tel,login,description,status,logo FROM users WHERE id=".$dealerid." LIMIT 1"; $res_d=$DB->query($q_d); $row_d=$DB->nextRow($res_d); if(!empty($row_d['site'])) { $row_d['site_link'] = trim($row_d['site'], "/"); $protocol = substr($row_d['site'], 0,7); if(!($protocol == "http://")) { $row_d['site_link'] = 'http://' . $row_d['site']; } } if (@$row_d['status']<3) { $smarty->display('dealers/dealer_error.tpl'); break; } $q_ven="SELECT rdv.vendorid,vendors.name,vendors.link FROM rel_dealer_vendor AS rdv " . " INNER JOIN ".$vehicle."_vendors AS vendors ON (vendors.id=rdv.vendorid) " . " WHERE rdv.dealerid=".$dealerid; $res_ven=$DB->query($q_ven); $mas_dealer_vendors=array(); while ($row_ven=$DB->nextRow($res_ven)){ $mas_dealer_vendors[]=$row_ven; } $row_d['vendors']=$mas_dealer_vendors; $smarty->assign('toptitle',$row_d['surname'].' - объявления о продаже автомобилей на '._SHOT_TOP_DESC_); $smarty->assign('dealerinfo',$row_d); $mas_back_nav=array(); $mas_back_nav[]=array('name'=>'Дилеры','link'=>'/dealers/'); $mas_back_nav[]=array('name'=>$mas_city_by_id[$row_d['cityid']],'link'=>''); $smarty->assign('mas_back_nav',$mas_back_nav); } // ------- постраничная ------------------ // $qt="SELECT COUNT(*) AS total FROM ".$vehicle."_sale AS car WHERE publ>0 ".$sql." ".$sql_sale_type." LIMIT 1"; $maspage=pagebegin($qt,20,$pagenamb,$qr_str_forpage); $pagesqllim=$maspage['pagelim']; $smarty->assign('pagenav',$maspage["maspage"]); $smarty->assign('total',$maspage["total"]); $mas=array(); $q="SELECT vendors.name AS vendor,car_model.name AS model,car.* FROM ".$vehicle."_sale AS car INNER JOIN ".$vehicle."_vendors AS vendors ON (vendors.id=car.vendorid) INNER JOIN ".$vehicle."_model AS car_model ON (car_model.id=car.modelid) WHERE publ>0 ".$sql." ".$sql_sale_type." ".$q_sort." ".$pagesqllim; $res=$DB->query($q); $i=0; $region_check=$user->stcRegionCheck($_SERVER['REMOTE_ADDR']); while ($row=$DB->nextRow($res)) { $q_u="SELECT id,status,surname FROM users WHERE id=".$row['userid']; $res_u=$DB->query($q_u); $row_u=$DB->nextRow($res_u); $mas[$i]=$row; if ($row_u['status']>=3) { $mas[$i]['dealer']=$row_u['surname']; $mas[$i]['dealerid']=$row_u['id']; } // redirection for bibika.ru cars if not siberian client if ($row['userid']==635540 and $row['external_url']<>'' and $region_check['id_places']<2){ $mas[$i]['redirect'] = 'http://'.$row['external_url']; } $i++; } $smarty->assign('mas_cars',$mas); $smarty->display('vehicle/search.tpl'); break; // ---------------------------------------------------------------------------- // // ------------------------- Вывод автомобиля конкретного --------------------- // case 'car': $id=intval($id); $q="SELECT vendors.name AS vendor,vendors.link AS vendor_link,model.name AS model,model.link AS model_link, car.*,users.status AS dealer,users.surname, users.site, users.id AS usrid FROM ".$vehicle."_sale AS car INNER JOIN ".$vehicle."_vendors AS vendors ON (vendors.id=car.vendorid) INNER JOIN ".$vehicle."_model AS model ON (model.id=car.modelid) INNER JOIN users ON (users.id=car.userid) WHERE car.id=".$id." LIMIT 1"; $res=$DB->query($q); $row=$DB->nextRow($res); if(empty($row)) { $id=intval($id); $q="SELECT vendors.name AS vendor,vendors.link AS vendor_link,model.name AS model,model.link AS model_link, car.*,users.status AS dealer,users.surname, users.site, users.id AS usrid FROM ".$vehicle."_sale_archive AS car INNER JOIN ".$vehicle."_vendors AS vendors ON (vendors.id=car.vendorid) INNER JOIN ".$vehicle."_model AS model ON (model.id=car.modelid) INNER JOIN users ON (users.id=car.userid) WHERE car.id=".$id." LIMIT 1"; $res=$DB->query($q); $row=$DB->nextRow($res); $smarty->assign('archive',true); } if ($row['dealer']>=3) {$row['user_name']=''.$row['surname'].'';} if ($row['id']>0) { //выводим фотки $mas_fotos=array(); $qf="SELECT * FROM ".$vehicle."_sale_img WHERE recid=".intval($row['id'])." ORDER BY sort DESC"; $resf=$DB->query($qf); while ($rowf=$DB->nextRow($resf)) { $mas_fotos[]=$rowf; } //массив инфы о модели $mas_model=array('modelid'=>$row['modelid'],'model'=>$row['model'],'model_link'=>$row['model_link'],'vendorid'=>$row['vendorid'],'vendor'=>$row['vendor'],'vendor_link'=>$row['vendor_link']); $smarty->assign('model_block_info',$mas_model); $mas_back_nav[]=array('name'=>$row['vendor'],'link'=>'/'.$vehicle.'/'.$row['vendor_link'].'/'); $mas_back_nav[]=array('name'=>$row['model'],'link'=>'/'.$vehicle.'/'.$row['vendor_link'].'/'.$row['model_link'].'/'); if ($row['god']<1970) $back_nav_god='<1970'; else $back_nav_god=$row['god']; $mas_back_nav[]=array('name'=>$row['vendor'].' '.$row['model'].' '.$back_nav_god.' года','link'=>''); $smarty->assign('mas_back_nav',$mas_back_nav); $row['region']=$mas_region[get_region_by_cityid($row['cityid'],$mas_city)]['name']; $smarty->assign('car',$row); $smarty->assign('mas_foto',$mas_fotos); $smarty->assign('toptitle','Продажа '.$row['vendor'].' '.$row['model'].' ('.$row['god'].') / '.$mas_city_by_id[$row['cityid']]); $smarty->assign('topdes','Продажа '.$row['vendor'].' '.$row['model'].' ('.$row['god'].'), '.$mas_city_by_id[$row['cityid']].','.$row['cost'].' руб. Описание, фотографии. Объявления о продаже автомобилей в '.$mas_city_by_pname[$row['cityid']].'.'); $smarty->assign('topkeyw','Продажа,'.$row['vendor'].','.$row['model'].','.$row['god'].','.$mas_city_by_id[$row['cityid']]); //комментарии с постраничной $pagenamb=@$_GET['page']; $smarty->assign('pagenamb',$pagenamb); $mas_comments=show_comments($row['commentsid'],$row['ctcomments'],10,$pagenamb,'/'.$vehicle.'/'.$row['id'].'/&'); $smarty->assign('pagenav',$mas_comments["maspage"]); $smarty->assign('mas_comments',$mas_comments['comments']); $smarty->assign('review',$row); $smarty->assign('mas_similar_cars',get_similar_vehicles($vehicle,$row['id'],$row['modelid'],$row['kuzov'],$row['god'],$row['cost'],4)); $smarty->display('vehicle/show.tpl'); add_one_views($vehicle.'_sale',$row['id']); } else { $mas_back_nav[]=array('name'=>'Объявления не существует','link'=>''); $smarty->assign('mas_back_nav',$mas_back_nav); $smarty->display('cars/car_error.tpl'); } break; } include("../inc/bottom.php"); ?>