public function update($values, $prefix = '') { $id = $this->id; $options = array(); foreach (self::$_properties as $k => $v) { if ($k == 'street') { $v = clearTextData($values[$k]); $db_res = Street::getListLink('name="' . $v . '" AND city_id=' . intval($values['city_id']) . ' AND status=1'); $row = $db_res->fetchRow(); if ($row) { $options['street_id'] = $row['id']; } else { $street_id = Street::createStatic(array('name' => $v, 'status' => 0)); $options['street_id'] = $street_id; } } elseif ($k != 'city') { $options[$k] = $values[$prefix . $k]; } } parent::update($options, ''); }
function sales($s,$user_id=NULL,$status=REALTY_STATUS_SALE) { $page = isset($_GET['page']) ? intval($_GET['page']) : 1; $res = _filter($status); $add_sql = $res['sql']; $filter = $res['filter']; if (isset($_GET['sort'])) { $sort_by = clearTextData($_GET['sort']); } elseif (isset($_SESSION['sort_by'])) { $sort_by = $_SESSION['sort_by']; } else { $sort_by = 'updated_on'; } if (isset($_GET['sort']) && isset($_SESSION['sort_by']) && $_GET['sort']==$_SESSION['sort_by']) { if (isset($_SESSION['direction']) && $_SESSION['direction']=='ASC') $direction = 'DESC'; else if (isset($_SESSION['direction']) && $_SESSION['direction']=='DESC') $direction = 'ASC'; } else { $direction = (isset($_SESSION['direction'])) ? $_SESSION['direction'] : 'DESC'; } if ($user_id) { $add_sql .= " AND f.user_id=".$_SESSION['user_id']; } $_SESSION['direction'] = $direction; $_SESSION['sort_by'] = $sort_by; $filter_html = Html::getLandFilter($filter,$user_id,$status); if (in_array($status,array(REALTY_STATUS_SALE,REALTY_STATUS_NEW,REALTY_STATUS_SOLD))) { $action = 'sales'; if ($user_id) $action = 'userSales'; } else { $action = 'rent'; if ($user_id) $action = 'userRent'; } //Объявления не старше месяца $add_sql .= " AND f.updated_on>'".getNextDate(date('Y-m-d'),-31)."'"; $content = Html::getLandList("$add_sql", $sort_by,$direction,PER_PAGE,$page, $action,$user_id); $act = ($status == REALTY_STATUS_SALE) ? 'Продажа' : 'Аренда'; if (!$user_id) { $block_name = $act.' земельных участков в Марий Эл - последние объявления'; } else { $block_name = $act.' земельных участков в Марий Эл - мои объявления'; } $s->assign("block_html",Html::getBlock($block_name,$filter_html.$content['html'])); if ((!isset($_SESSION['admin']) || !isset($user_id)) && count($content['ids'])>0) { Land::incQuickMassVisitorCount($content['ids']); } $s->assign("title","Продажа земельных участков в Йошкар-Оле и Марий Эл"); $s->display("land_sales.tpl"); }
include_once $config['smarty']; include_once "functions_general.php"; function __autoload($class_name) { require_once SITE_PATH . "classes/{$class_name}.php"; } $s = new Smarty(); $s->compile_check = true; $s->debugging = false; $s->force_compile = true; $s->template_dir = $config["template_dir"]; $s->compile_dir = $config["compile_dir"]; $s->cache_dir = $config["cache_dir"]; $s->config_dir = $config["config_dir"]; $s->assign("config", $config); $s->assign("CONTACTS", CONTACTS); $db = new DB($config['dbserver'], $config['dbname'], $config['dbuser'], $config['dbpassword']); $s->assign("title", "Недвижимость в Йошкар-Оле - продажа квартир, домов, земельных участков"); $s->assign("keywords", "Недвижимость в Йошкар-Оле, Продажа квартир,Йошкар-Ола, недвижимость, дома"); $s->assign("meta_description", "Мой Новый Дом - каталог квартир Йошкар-Олы с подробным описанием, удобным фильтром и актуальной базой."); $s->assign("author", "Мой Новый Дом, Йошкар-Ола"); $s->assign("meta_revisit", "1"); if (isset($_COOKIE['hx']) && $_COOKIE['hx'] != '') { $hash = clearTextData($_COOKIE['hx']); User::autorizeByHash($hash); } if (isset($_SESSION['user_id']) && $_SESSION['user_id'] > 0) { $s->assign("hello", "Здравствуйте, " . $_SESSION['user_name'] . '!'); } $s->assign("_SESSION", $_SESSION); $s->assign("top_img_num", rand(1, 3));
public static function getHouseList($where, $order, $direction, $per_page = 10, $current_page = 1, $action = 'sales', $user_id = NULL) { $start_pos = ($current_page - 1) * $per_page; $limit = " LIMIT {$start_pos},{$per_page}"; $sort = $order == '' ? "f.updated_on" : $order; $where_param = $where . " GROUP BY f.id ORDER BY " . $sort . " " . $direction . $limit; $params = ''; $price_min = 0; $price_max = 0; if (isset($_REQUEST['f_price'])) { $f_price = intval($_REQUEST['f_price']); $params .= '&f_price=' . $f_price; switch ($f_price) { case 1: $price_max = 1000000; break; case 2: $price_min = 1000000; $price_max = 1500000; break; case 3: $price_min = 1500000; $price_max = 2000000; break; case 4: $price_min = 2000000; $price_max = 3000000; break; case 5: $price_min = 3000000; break; } } else { if (isset($_REQUEST['price_min']) && $_REQUEST['price_min'] > 0) { $price_min = intval($_REQUEST['price_min']); } else { $price_min = 0; } if (isset($_REQUEST['price_max']) && $_REQUEST['price_max'] > 0) { $price_max = intval($_REQUEST['price_max']); } else { $price_max = 0; } if ($price_min > 0) { $params .= '&price_min=' . $price_min; } if ($price_max > 0) { $params .= '&price_max=' . $price_max; } } if (isset($_REQUEST['f_price_sq'])) { $params .= '&f_price_sq=' . intval($_REQUEST['f_price_sq']); } if (isset($_REQUEST['f_radius'])) { $params .= '&f_radius=' . intval($_REQUEST['f_radius']); } if (isset($_REQUEST['f_house'])) { $params .= '&f_house=' . intval($_REQUEST['f_house']); } if (isset($_REQUEST['f_total_area'])) { $params .= '&f_total_area=' . intval($_REQUEST['f_total_area']); } if (isset($_REQUEST['f_city']) && isset($_REQUEST['f_city_id'])) { $params .= '&f_city=' . clearTextData($_REQUEST['f_city']); $params .= '&f_city_id=' . intval($_REQUEST['f_city_id']); } if (isset($_REQUEST['f_photo'])) { $params .= '&f_photo=' . intval($_REQUEST['f_photo']); } if (isset($_SESSION['direction'])) { $direction = $_SESSION['direction'] == 'ASC' ? 'ASC' : 'DESC'; $arrow = $direction == 'ASC' ? '↓' : '↑'; $direction = 'direction=' . $direction; } else { $direction = ''; $arrow = ''; } $arrow_date = ''; $arrow_price = ''; if ($sort == 'updated_on') { $arrow_date = $arrow; } else { if ($sort == 'price') { $arrow_price = $arrow; } } $amount = House::getAmountInList($where . " GROUP BY f.id"); $paginator = self::paginator("house.html?action={$action}" . $params, $amount, $per_page, $current_page); $html = "\n\t\tНайдено {$amount} объявлений:\n\t\t<br>\t\t\t\t\t\t\n\t\t<table class='table table-striped table-bordered table-condensed'>\n\t\t<thead>\n\t\t <tr>\n\t\t <th>Адрес</th>\n\t\t <th><a href='/house.html?action={$action}&sort=price" . $params . "'><b>Цена(руб.)</b></a>{$arrow_price}<br>руб./м<sup>2</sup></th>\n\t\t <th>Этажей</th>\t\t \t\t \t\t \t\t \n\t\t <th>Фото</th>\t\t \t\t \n\t\t <th>Общая м<sup>2</sup></th>\n\t\t <th>Удаленность</th>\t\t \t\t \n\t\t <th>Описание</th>\n\t\t <th><a href='/house.html?action={$action}&sort=updated_on" . $params . "'><b>Дата</b></a>{$arrow_date}</th>\t\t \n\t\t <th></th>\n\t\t </tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t"; $ids = array(); $db_res = House::getFullListLink($where_param); $tenement_icons = array('derevo', 'kirpich', 'monolit', 'block'); while ($row = $db_res->fetchRow()) { $ids[] = $row['id']; $type_name = House::$TYPE[$row['type_id']]; $type = $tenement_icons[$row['type_id']]; $type = "<img src='/images/icon_{$type}.png' title='{$type_name}'>"; $price = number_format($row['price'], 0); $price_m = number_format($row['price_m'], 0); //$city = ($row['city_id']==0) ? '' : $row['city'].','; //$addr = "{$row['city']} {$row['street']}"; $addr = "{$row['city']}"; //$hr = ($desc_all!='') ? '<hr>' : ''; //$description = $desc_all.$hr.$row['contacts']; $is_owner = $row['is_owner'] ? '<br><b>Собственник</b>' : ''; $description = textReduce($row['description']) . $is_owner; $flat_url = "/house.html?action=view&id={$row['id']}"; $photo_html = $row['photo'] != '' ? "<a href='{$flat_url}'><img src='/" . PHOTOS_WEBPATH . HOUSE . "/" . $row['id'] . "/" . $row['photo'] . "_prev'></a>" : 'Нет фото'; $date = explode(' ', $row['updated_on']); $dates = explode('-', $date[0]); $date = $dates[2] . '.' . $dates[1]; //.'.'.$dates[0] $url_del = !isset($_SESSION['admin']) ? '' : '<br><br><a href="javascript:delObject(' . $row['id'] . ');">Удалить</a>'; if ($user_id) { $url_del .= ' <a href="javascript:update(' . $row['id'] . ');" title="Обновить дату на текущую"><img src="/images/icon_update.png" title="Обновить дату на сегодняшнюю"></a>'; $url_del .= ' <a href="house.html?action=edit&id=' . $row['id'] . '"><img src="/images/icon_edit.png" title="Редактировать"></a>'; $url_del .= ' <a href="javascript:remove(' . $row['id'] . ');"><img src="/images/icon_delete.png" title="Снять"></a>'; $url_del .= ' <a href="javascript:sold(' . $row['id'] . ');"><img src="/images/icon_sold.png" title="Продано"></a>'; } $dist = $row['dist'] > 0 ? $row['dist'] . ' км' : ''; $html .= "<tr>\n\t\t\t<td><a href='{$flat_url}'>{$addr}</a></td>\t\t\t\t\t\t\n\t\t\t<td><b>{$price}</b><br><br>{$price_m}</td>\n\t\t\t<td>{$row['storeys']}<br>{$type}</td>\t\t\t\n\t\t\t<td>{$photo_html}</td>\t\t\t\n\t\t\t<td>{$row['total_area']}</td>\n\t\t\t<td>{$dist}</td>\t\t\t\t\n\t\t\t<td>{$description}</td>\n\t\t\t<td>{$date}</td>\n\t\t\t<td><a href='{$flat_url}'><img src='/images/icon_view.png' title='Смотреть'></a>{$url_del}</td>\n\t\t\t</tr>\t\t\t\n\t\t\t"; } $html .= "</tbody></table>\n\t\t<div>{$paginator}</div>\t\t\n\t\t"; return array('html' => $html, 'ids' => $ids); }
function sales($s,$user_id=NULL,$status=REALTY_STATUS_SALE) { $s->assign("top_img_num",1); $page = isset($_GET['page']) ? intval($_GET['page']) : 1; $res = _filter($status); $tenement_status = ($status!=REALTY_STATUS_IMPORT_SALE && $status!=REALTY_STATUS_IMPORT_RENT) ? "t.status='".REALTY_STATUS_ACTIVE."' AND " : ''; $add_sql = $tenement_status.$res['sql']; $filter = $res['filter']; if (isset($_GET['sort'])) { $sort_by = clearTextData($_GET['sort']); } elseif (isset($_SESSION['sort_by'])) { $sort_by = $_SESSION['sort_by']; } else { $sort_by = 'updated_on'; } if (isset($_GET['sort']) && isset($_SESSION['sort_by']) && $_GET['sort']==$_SESSION['sort_by']) { if (isset($_SESSION['direction']) && $_SESSION['direction']=='ASC') $direction = 'DESC'; else if (isset($_SESSION['direction']) && $_SESSION['direction']=='DESC') $direction = 'ASC'; } else { $direction = (isset($_SESSION['direction'])) ? $_SESSION['direction'] : 'DESC'; } if ($user_id) { $add_sql .= " AND f.user_id=".$_SESSION['user_id']; } $_SESSION['direction'] = $direction; $_SESSION['sort_by'] = $sort_by; $filter_html = Html::getFlatFilter($filter,$user_id,$status); if (in_array($status,array(REALTY_STATUS_SALE,REALTY_STATUS_NEW,REALTY_STATUS_SOLD,REALTY_STATUS_IMPORT_SALE,REALTY_STATUS_IMPORT_RENT))) { $action = 'sales'; if ($user_id && $status!=REALTY_STATUS_IMPORT_SALE) $action = 'userSales'; elseif ($status==REALTY_STATUS_IMPORT_SALE) $action = 'userImportSales'; } else { $action = 'rent'; if ($user_id && $status!=REALTY_STATUS_IMPORT_RENT) $action = 'userRent'; elseif ($status==REALTY_STATUS_IMPORT_RENT) $action = 'userImportRent'; } //Объявления не старше месяца $add_sql .= " AND f.updated_on>'".getNextDate(date('Y-m-d'),-61)."'"; $content = Html::getFlatList("$add_sql",$sort_by,$direction,PER_PAGE,$page,$action,$user_id); if ($status == REALTY_STATUS_SALE || $status == REALTY_STATUS_IMPORT_SALE) { $act = 'Продажа'; } else if ($status == REALTY_STATUS_RENT || $status == REALTY_STATUS_IMPORT_RENT) { $act = 'Аренда'; } if ($status == REALTY_STATUS_IMPORT_SALE || $status == REALTY_STATUS_IMPORT_RENT) { $add = ' (импортированные)'; } else { $add = ''; } if (!$user_id) { $block_name = $act.' квартир в Йошкар-Оле - последние объявления'; } else { $block_name = $act.' квартир - мои объявления'.$add; } $s->assign("block_name",$block_name); $s->assign("block_html",$filter_html.$content['html']); if ((!isset($_SESSION['admin']) || !isset($user_id)) && count($content['ids'])>0) { Flat::incQuickMassVisitorCount($content['ids']); } $s->display("flat_sales.tpl"); }
<?php include_once "./include/common.php"; /* Note: This thumbnail creation script requires the GD PHP Extension. If GD is not installed correctly PHP does not render this page correctly and SWFUpload will get "stuck" never calling uploadSuccess or uploadError */ // Get the session Id passed from SWFUpload. We have to do this to work-around the Flash Player Cookie Bug if (isset($_POST["PHPSESSID"])) { session_id($_POST["PHPSESSID"]); } ini_set("html_errors", "0"); if (isset($_POST['kind'])) { $kind = clearTextData($_POST['kind']); if (!in_array($kind, array(TENEMENT, FLAT, HOUSE, LAND, NEW_TENEMENT, GARAGE, COMPANY, LOGO, COMMERCIAL))) { exit(0); } } else { exit(0); } // Check the upload if (!isset($_FILES["Filedata"]) || !is_uploaded_file($_FILES["Filedata"]["tmp_name"]) || $_FILES["Filedata"]["error"] != 0) { echo "ERROR:invalid upload"; file_put_contents("error.log", "ERROR:invalid upload", FILE_APPEND); exit(0); } try { if ($kind != LOGO && $kind != COMPANY) { $img_prev = Photo::setSize($_FILES["Filedata"]["tmp_name"], 150, 100); $img_prev = Photo::createWatermark($img_prev, WATERMARK, "arial.ttf", 255, 255, 255, 90); $img_org = Photo::setSize($_FILES["Filedata"]["tmp_name"], 800, 600);
public function editPhoto($fname, $data) { $photo = new Photo(); if (isset($data['photo_type_' . $fname])) { $tag = clearTextData($data['photo_type_' . $fname]); $title = clearTextData($data['photo_title_' . $fname]); $description = clearTextData($data['photo_desc_' . $fname]); $values = array('tag' => $tag, 'title' => $title, 'description' => $description, 'updated_on' => date("Y-m-d H:i:s"), 'status' => 0); $photo->updateBy("name='{$fname}'", $values); } }
public function update($values) { $id = $this->id; $options = array(); $values['price_m'] = intval($values['price'] / $values['total_area']); foreach (self::$_properties as $k => $v) { if ($k != 'city' && $k != 'street' && $k != 'number') { $options[$k] = $values[$k]; } else { if ($k == 'number') { $options[$k] = clearTextData(strtolower($values[$k])); } } } parent::update($options); }
function delPhoto($param) { $name = clearTextData($param['name']); $num_deleted = Photo::delete($name); echo $name; }
<?php include_once "./include/common2.php"; echo clearTextData("тест функции");
function edit($s) { if (!isset($_SESSION['admin']) && !isset($_SESSION['user_id'])) { header("Location: /index.html"); exit(); } $id = intval($_GET['id']); $tenement = new Tenement(); $tenement->getFull($id); if ($tenement->status!=REALTY_STATUS_NEW && !isset($_SESSION['admin'])) { header("Location: /index.html"); exit(); } if (empty($_POST) && $tenement->id>0) { $block_html = Html::pageTenementEdit($tenement); $s->assign("block_html",$block_html); $s->assign("YANDEX_KEY",YANDEX_KEY); $s->assign("LAT_CENTER_REGION",LAT_CENTER_REGION); $s->assign("LON_CENTER_REGION",LON_CENTER_REGION); $s->assign("city_id",$tenement->city_id); $s->assign("city",$tenement->city); $s->assign("street_id",$tenement->street_id); $s->assign("street",$tenement->street); if (isset($_SESSION['admin'])) $s->assign("is_admin",$_SESSION['admin']); $s->display("tenement_edit.tpl"); } //Смена адреса на существующий дом elseif (isset($_POST['id']) && $_POST['id']>0 && (isset($_SESSION['admin']) || (isset($_SESSION['user_id']) && $tenement->user_id==$_SESSION['user_id']))) { $tenement_id = intval($_POST['id']); $tenement->find($tenement_id); if (!$tenement->id) { echo "Дом не найден"; exit(); } //дом есть, переводим все кв в него, старый удаляем Flat::changeTenement($id,$tenement_id); if ($id != $tenement_id) { //Tenement::delete($id); //echo "delete $id"; } header("Location: /tenement.html?action=view&id=".$tenement_id); exit(); } elseif($id>0 && !empty($_POST) && (isset($_SESSION['admin']) || (isset($_SESSION['user_id']) && $tenement->user_id==$_SESSION['user_id']))) { if ($_REQUEST['city_id']>1) { Tenement::$_properties['street']['required']=null; Tenement::$_properties['street_id']['required']=null; Tenement::$_properties['number']['required']=null; } $errors = $tenement->checkForm($_REQUEST); if (!isset($errors['is_error']) && $tenement->id > 0) { $tenement->update($_POST); $photo_path = $tenement->getPhotoPath(); if (!is_dir($photo_path)) { mkdir($photo_path,0777); chmod($photo_path,0777); } //добавляем новые фото if (isset($_POST['photo_tenement']) && is_array($_POST['photo_tenement'])) { foreach ($_POST['photo_tenement'] as $fname) { $fname = clearTextData($fname); if ($fname!='') $tenement->addPhoto($fname,$_POST); } } //редактируем существующие фото if (isset($_POST['photo_'.TENEMENT.'_exist']) && is_array($_POST['photo_'.TENEMENT.'_exist'])) { foreach ($_POST['photo_'.TENEMENT.'_exist'] as $fname) { $fname = clearTextData($fname); if ($fname!='') $tenement->editPhoto($fname,$_POST); } } header("Location: /tenement.html?action=view&id=".$tenement->id); exit(); } else { print_r($errors); } } else { //$block_html = Html::pageTenementEdit($tenement); $s->assign("YANDEX_KEY",YANDEX_KEY); if (isset($_SESSION['admin'])) $s->assign("is_admin",$_SESSION['admin']); $s->assign("block_html",'Дом не найден'); $s->display("tenement_edit.tpl"); } }
function import($s) { if (!isset($_SESSION['user_id'])) { header("Location: index.html"); exit(); } $amount=-1; $num_updated_all = 0; if (isset($_FILES["userfile"])) { if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { $filename = $_FILES['userfile']['tmp_name']; $rows = file($filename); unset($rows[0]); $amount=0; foreach ($rows as $row) { $row = iconv("windows-1251", "utf-8", $row); $el = explode('|',$row); $date = $el[33];//дата объявления //if ($date<date('d.m.Y')) $type_deal = $el[0];//1 - продажа, 2 - аренда $status = ($el[0]==1) ? REALTY_STATUS_IMPORT_SALE : REALTY_STATUS_IMPORT_RENT; $is_city = $el[1];//1-город 2-республика if ($is_city != 1) continue; $rooms = $el[2];//11-комната 22-дом 27-участок 28-уч. под застройку 41-гараж if ($rooms>11) continue; $phone = $el[6]; $an_name = $el[7]; $phone2 = $el[8]; $name2 = $el[9]; $street = $el[10]; //echo "\n$street _\n"; if(!preg_match("/[0-9]+[а-яА-Я]*$/", $street)) { //нет номера дома //continue; } //echo "\n$street\n"; preg_match("/[0-9]+[а-яА-Я]*$/", $street,$nums_tenement); $num = mb_strtolower($nums_tenement[0],'UTF-8');//strtolower($nums_tenement[0]); $street_name = str_replace($num,'',$street); $street_name = trim(str_replace(' ',' ',$street_name)); $street_clear2 = str_replace('ул','',$street_name); $street_clear2 = str_replace('.','',$street_clear2); $street_arr = explode(' ',$street_clear2); //находим самую длинную строку в названии улицы $i = 0; $max_len = ''; $last_len = 0; if(count($street_arr)) { foreach ($street_arr as $c) { if (strlen($c)>$last_len) { $max_len = $c; $last_len = strlen($c); } $i++; } } if ($max_len=='') continue; //echo "\nmax_len=$max_len"; $row = Street::findBy("name LIKE '%$max_len%'"); if (!$row) { $street_id = Street::createStatic(array('name'=>$street_name,'city_id'=>0, 'status'=>0)); } else { $street_id = $row['id']; $street_name = $row['name']; } $storey = $el[12]; $stores = $el[13]; $tenement_type = $el[15]; if ($tenement_type=='КИРП') $type_id=0; elseif ($tenement_type=='ПАН') $type_id=1; elseif ($tenement_type=='БЛОК') $type_id=3; elseif ($tenement_type=='ДЕР') $type_id=4; else $type_id=2; $total_area = str_replace(',','.',$el[16]); //if ($total_area=='') continue; $living_area = str_replace(',','.',$el[17]); $kitchen_area = str_replace(',','.',$el[18]); if (!$kitchen_area) $kitchen_area=9; $description = $el[26]; $price = str_replace(',','.',$el[27]); //if (!($price>0)) continue; $price_k = $el[28];//1-тыс. 2-млн. 5-руб/м 6-у.е./м if ($price_k==1) $price *= 1000; elseif ($price_k==2) $price *= 1000000; elseif ($price_k==5) $price *= $total_area; $haggle = $el[29];//торг/чистая продажа $date_end = $el[31];//срок сдачи дома $row = Tenement::findBy("street_id='$street_id' AND number='$num'"); if ($row) { $tenement_id=$row['id']; } else { $num = clearTextData($num); $options = array( 'city_id'=>0, 'street_id'=>$street_id, 'number'=>$num, 'type_id'=>clearTextData($type_id), 'storeys'=>clearTextData($stores), 'hot_water'=>1, 'type_energy'=>0, 'type_heating'=>0, 'user_id'=>$_SESSION['user_id'], 'status'=>REALTY_STATUS_NEW ); $address = urlencode('Йошкар-Ола, '.$street_name.', д.'.$num); $geo_url = 'http://psearch-maps.yandex.ru/1.x/?text='.$address.'&key='.YANDEX_KEY.'&format=json'; $json = file_get_contents($geo_url); $d = json_decode($json); if (isset($d->{'response'}->{'GeoObjectCollection'}->{'featureMember'}[0]->{'GeoObject'}->{'Point'}->{'pos'})) { $coords = explode(' ',$d->{'response'}->{'GeoObjectCollection'}->{'featureMember'}[0]->{'GeoObject'}->{'Point'}->{'pos'}); $options['lon'] = $coords[0]; $options['lat'] = $coords[1]; } $tenement_id = Tenement::addStatic($options); } if (!$tenement_id) continue; $num_updated = Flat::updateByCondition("tenement_id='$tenement_id' AND rooms='$rooms' AND storey='$storey' AND price='$price' AND user_id='{$_SESSION['user_id']}'",array('updated_on'=>date('Y-m-d H:i:s'))); $num_updated_all += $num_updated; if ($num_updated>0) continue; $contacts = ($phone2!='') ? $phone2.' '.$name2 : $phone.' '.$an_name; $options = array( 'tenement_id'=>$tenement_id, 'price'=>clearTextData($price), 'rooms'=>clearTextData($rooms), 'storey'=>clearTextData($storey), 'total_area'=>clearTextData($total_area), 'kitchen_area'=>clearTextData($kitchen_area), 'living_area'=>clearTextData($living_area), 'description'=>clearTextData($description,1000), 'contacts'=>clearTextData($contacts), 'user_id'=>$_SESSION['user_id'], 'status'=>$status ); Flat::addStatic($options); $amount++; } $dest = IMPORT_PATH.$_SESSION['user_id'].'_'.date('d').'_'.date('m').'_'.date('H').'_'.date('i').'_'.date('s').'.txt'; move_uploaded_file($filename,$dest); } } $s->assign("amount",$amount); $s->assign("num_updated_all",$num_updated_all); $s->display("import.tpl"); }
public function update($values) { $id = $this->id; $options = array(); $values['price_m'] = intval($values['price'] / $values['total_area']); foreach (self::$_properties as $k => $v) { if ($k == 'street') { $v = clearTextData($values[$k]); $db_res = Street::getListLink('name="' . $v . '" AND city_id=' . intval($values['city_id']) . ' AND status=' . REALTY_STATUS_ACTIVE); $row = $db_res->fetchRow(); if ($row) { $options['street_id'] = $row['id']; } else { $street_id = Street::create(array('name' => $v, 'status' => 0)); $options['street_id'] = $street_id; } } elseif ($k != 'city') { $options[$k] = $values[$k]; } } parent::update($options); }