= 0){ $time_zone = '+'.$gmtmsk.' hour'; } else { $time_zone = '-'.$gmtmsk.' hour'; } $sql = "SELECT * FROM objects WHERE id = $objectId"; $res = mysql_query($sql); $obj = mysql_fetch_assoc($res); $parentRegion = '2'; $parentRegionName = ''; $sqlRegion = "SELECT parent, name FROM rf_regions WHERE id=$obj[id_rf_region] or parent=$obj[id_rf_region]"; $resRegion = mysql_query($sqlRegion); if (mysql_num_rows($resRegion) > 0) { while($row = mysql_fetch_assoc($resRegion)){ if ($row['parent']) { $parentRegion = $row['parent']; } } } $sqlParentRegion = "SELECT name FROM rf_regions WHERE id=$parentRegion"; $resParentRegion = mysql_query($sqlParentRegion); if (mysql_num_rows($resParentRegion)) { $parentReg = mysql_fetch_assoc($resParentRegion); $parentRegionName = $parentReg['name']; } $komnSql = ""; if ($obj['komnat']) { $komnSql = "AND komnat=$obj[komnat]"; } if (!preg_match('~\d~', $obj['adres']) && $obj['dom']) { $obj['adres'] = $obj['adres'] . " " . $obj['dom']; } $adres_search = getAdresSearch($obj['adres']); $adres_mas = explode(" ", $adres_search); $ausl_mas = array(); for ($a = 0; $a < count($adres_mas); $a++) { if ($adres_mas[$a]) { $ausl_mas[] = trim($adres_mas[$a]); } } $latitude = null; $longitude = null; $sqlLocationInfo = "SELECT * FROM object_location WHERE object_id=$objectId"; $rezLocationInfo = mysql_query($sqlLocationInfo); if (mysql_num_rows($rezLocationInfo) > 0) { $objLocationInfo = mysql_fetch_assoc($rezLocationInfo); $latitude = $objLocationInfo['latitude']; $longitude = $objLocationInfo['longitude']; } $coordinatesSql = ""; if ($latitude != null && $longitude != null) { $coordinatesSql = " | (@(id_rf_region,parent) $parentRegion @latitude $latitude @longitude $longitude)"; } $strSph = ''; for ($a = 0; $a < count($ausl_mas); $a++) { if (strlen($strSph) > 1) { $strSph = $strSph . ' '; } $strSph = $strSph . '@adres ' . trim(str_replace("/","-",$ausl_mas[$a])); } //$strSph = $strSph . ')'; $adres_usl = "MATCH ('(@(id_rf_region,parent) $parentRegion $strSph) $coordinatesSql')"; $sqlCount = "SELECT count(*) as total FROM objects, objects_delta WHERE archive = 0 AND black = 0 AND moder = 0 AND id <> $obj[id] AND operation_type = $obj[operation_type] AND type=$obj[type] $komnSql AND $adres_usl OPTION max_matches=1000000"; if ($_SESSION['id'] == 93) { echo $sqlCount; } $res = $db->fetch_assoc($db->query($sqlCount)); $vsego = $res['total']; if ($vsego > 0) { $isModal = true; $from = ($pageNumber - 1) * $numOnPage; $all_pages = ceil($vsego / $numOnPage); $sqlSearch = "SELECT * FROM objects, objects_delta WHERE archive = 0 AND black = 0 AND moder = 0 AND id <> $obj[id] AND operation_type = $obj[operation_type] AND type=$obj[type] $komnSql AND $adres_usl ORDER BY date_add DESC LIMIT $from, $numOnPage OPTION max_matches=1000000"; if ($_SESSION['id'] == 93) { echo $sqlSearch; } $rezSearch = $db->query($sqlSearch); if ($db->num_rows($rezSearch) > 0) { $user = new User; $user->get($_SESSION['id']); if (!isset($user->agencyId)) { $user->agencyId = $_SESSION['id']; $user->agencyName = $user->agency_name; $user->fio = trim($user->last_name . ' ' . $user->first_name . ' ' . $user->middle_name); } while ($obj = $db->fetch_assoc($rezSearch)) { $sqlPhotoInfo = "SELECT oop.sort_order, p.photo FROM objects_object_photo oop, object_photo p WHERE p.id = oop.object_photo_id AND oop.object_id = $obj[id] ORDER BY oop.sort_order"; $rezPhotoInfo = mysql_query($sqlPhotoInfo); if (mysql_num_rows($rezPhotoInfo) > 0) { while ($photoInfo = mysql_fetch_assoc($rezPhotoInfo)) { $obj['photo' . $photoInfo['sort_order']] = $photoInfo['photo']; } } $use_advert_budget = ($_SESSION['use_advert_budget']); include($_SERVER['DOCUMENT_ROOT'] . "/templates/system__object_new.php"); } echo '
'; } else { echo "Объекты не найдены."; } } else { echo "Объекты не найдены."; } } function paging($page, $all_pages, $objId) { if ($page == 1) { echo "
  • 1
  • "; } else { $prev = $page - 1; echo "
  • «
  • "; echo "
  • 1
  • "; } if ($all_pages > 8) { if ($page > 4) { $ot = $page - 3; echo "
  • ...
  • "; } else { $ot = 2; } if ($page < $all_pages - 4) { $do = $page + 3; } else { $do = $all_pages; } } else { $ot = 2; $do = $all_pages; } for ($i = $ot; $i < $do; $i++) { if ($i == $page) $cl = "active"; else $cl = ""; echo "
  • $i
  • "; } if ($all_pages > 8 and $page < $all_pages - 4) { echo "
  • ...
  • "; } if ($page == $all_pages) echo "
  • $all_pages
  • "; else { echo "
  • $all_pages
  • "; $nxt = $page + 1; echo "
  • »
  • "; } } ?>