Joywork/cron/copyToDev.php
2026-05-22 21:21:54 +03:00

141 lines
13 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
set_time_limit(0);
require_once($_SERVER['DOCUMENT_ROOT']."/config.php");
ini_set('display_errors', 1);
error_reporting(E_ALL);
define("jw_hst", "n01.sql.dev.joywork.ru.flops.dc.ext");
define("jw_user", "u0305746_jw");
define("jw_pass", "BzDIdQh3V");
define("jw_ndb", "u0305746_jw");
//копирование всех вариантов с JW
$size = 50;
$jwdb = mysql_connect(jw_hst, jw_user, jw_pass);
if (!$jwdb) {
die("No connect JW dev database...");
}
if (!mysql_select_db(jw_ndb, $jwdb)) {
die("No selected JW dev database...");
}
$sql = "SET NAMES 'utf8'";
mysql_query($sql, $jwdb);
$sqlObjectsAp = "SELECT * FROM objects WHERE id in (select ao.obj_id from ads_objects ao where ao.ads_source = 5) order by id DESC LIMIT $size";
$rezObjectsAp = mysql_query($sqlObjectsAp, $mdb);
while($object = mysql_fetch_assoc($rezObjectsAp)) {
//вставляем
echo "Добавляем объект " . $object['id'] . "<br/>";
$sqlInsObjects = "INSERT INTO `objects`(`type`, `rayon`, `adres`, `dom`, `korpus`, `litera`, `srok`, `komnat`, `etazh`, `etaz_first_type`, `ploshad`, `ploshad_k`, `holod`, `stirka`, `tv`, `mebel`, `stoim`, `date_add`, `ploshad_komn`, `etazh_iz`, `stoim_prim`, `peshkom`, `transport`, `nazv`, `opis`, `phone`, `archive`, `sobstv`, `phone_search`, `id_user`, `date_really_add`, `prim_srok`, `black`, `vsego_komn`, `moder`, `id_kv`, `id_add_user`, `commission`, `add_to_yandex_feed`, `add_from_archive`, `initial_object_id`, `initial_object_phone`, `initial_object_sobstv`, `type_category`, `use_in_advert`, `initial_object_stoim`, `operation_type`, `studio_flag`, `cadastral_number`, `add_to_avito_feed`, `add_to_emls_feed`, `property_type_id`, `land_area`, `rent_house_type_id`, `country_wall_type_id`, `stoim_ky`, `lo_city_id`, `lease_deposit_id`, `add_to_bn_feed`, `kladr_id`, `add_to_zipal`, `add_to_domclick_feed`, `no_pets`, `no_child`, `land_purpose_id`, `land_distance`, `land_burden`, `electricity_type_id`, `gas_type_id`, `plumbing_type_id`, `sewerage_type_id`, `relief_type_id`, `shape_type_id`, `land_usage_type_id`, `lease`, `add_to_cian_feed`, `city_town_id`, `bath_type_id`, `hot_water_id`, `rubbish_chute`, `parking_type_id`, `id_rf_region`, `fbn_id`) VALUES ('$object[type]','$object[rayon]','$object[adres]','$object[dom]','$object[korpus]','$object[litera]','$object[srok]','$object[komnat]','$object[etazh]','$object[etaz_first_type]','$object[ploshad]','$object[ploshad_k]','$object[holod]','$object[stirka]','$object[tv]','$object[mebel]','$object[stoim]','$object[date_add]','$object[ploshad_komn]','$object[etazh_iz]','$object[stoim_prim]','$object[peshkom]','$object[transport]','$object[nazv]','$object[opis]','$object[phone]','$object[archive]','$object[sobstv]','$object[phone_search]','$object[id_user]','$object[date_really_add]','$object[prim_srok]','$object[black]','$object[vsego_komn]','$object[moder]','$object[id]','$object[id_add_user]','$object[commission]','$object[add_to_yandex_feed]','$object[add_from_archive]','$object[initial_object_id]','$object[initial_object_phone]','$object[initial_object_sobstv]','$object[type_category]','$object[use_in_advert]','$object[initial_object_stoim]','$object[operation_type]','$object[studio_flag]','$object[cadastral_number]','$object[add_to_avito_feed]','$object[add_to_emls_feed]','$object[property_type_id]','$object[land_area]','$object[rent_house_type_id]','$object[country_wall_type_id]','$object[stoim_ky]','$object[lo_city_id]','$object[lease_deposit_id]','$object[add_to_bn_feed]','$object[kladr_id]','$object[add_to_zipal]','$object[add_to_domclick_feed]','$object[no_pets]','$object[no_child]','$object[land_purpose_id]','$object[land_distance]','$object[land_burden]','$object[electricity_type_id]','$object[gas_type_id]','$object[plumbing_type_id]','$object[sewerage_type_id]','$object[relief_type_id]','$object[shape_type_id]','$object[land_usage_type_id]','$object[lease]','$object[add_to_cian_feed]','$object[city_town_id]','$object[bath_type_id]','$object[hot_water_id]','$object[rubbish_chute]','$object[parking_type_id]','$object[id_rf_region]','$object[fbn_id]')";
if (mysql_query($sqlInsObjects, $jwdb)) {
$id = mysql_insert_id($jwdb);
$sqlObjectsAddInfo = "SELECT * FROM objects_additional_information WHERE object_id = $object[id]";
$rezObjectsAddInfo = mysql_query($sqlObjectsAddInfo, $mdb);
if (mysql_num_rows($rezObjectsAddInfo) > 0) {
$objectAddInf = mysql_fetch_assoc($rezObjectsAddInfo);
echo "Добавляем доп. информацию по объекту " . $objectAddInf['id'] . "<br/>";
$sqlInsObjectsAddInf = "INSERT INTO `objects_additional_information`(`object_id`, `ceiling_height`, `bathroom_unit`, `balcony`, `renovation`, `window_view`, `apartments`, `video_url`, `loggias`, `separate_wcs`, `combined_wcs`, `passenger_lifts`, `cargo_lifts`, `vat_type_id`, `house_category`, `commercial_object_id`, `isPartsEnabled`, `parts_area`, `legal_address`, `isOccupied`, `is_occupied_month`, `is_occupied_year`, `layout_id`, `number_wet_spots`, `electricity_power`, `commer_condition`, `isFurniture`, `commer_access`, `parking_price`, `parkingIsFree`, `building_nazv`, `commerc_year`, `commerc_building_type_id`, `commerc_building_class_id`, `building_area`, `commerc_site`, `commerc_owned`, `commerc_building_category_id`, `building_developer`, `building_management_company`, `commerc_building_ventilation`, `commerc_building_conditioning`, `commerc_building_heating`, `commerc_building_fire`, `commerc_houseLineType_id`, `commerc_opened_id`, `commerc_infrastructure`, `column_grid`, `tax_number`, `floor_material_id`, `commerc_portal_id`, `commerc_purpose`, `gsk_nazv`, `commerc_specifications`, `commerc_land_category_id`, `can_land_category_change`, `commerc_permitted_use_id`, `can_permitted_use_change`, `commerc_investproject`, `is_encumbrances`, `commerc_electricity_id`, `can_electricity`, `commerc_gas_id`, `can_gas`, `commerc_water_id`, `can_water`, `commerc_sewage_id`, `can_sewage`, `commerc_driveways_id`, `garage_type_id`, `commerc_lift1`, `lift1_carrying`, `commerc_lift2`, `lift2_carrying`, `commerc_lift3`, `lift3_carrying`, `commerc_crane1`, `crane1_carrying`, `commerc_crane2`, `crane2_carrying`, `commerc_crane3`, `crane3_carrying`, `commerc_crane4`, `crane4_carrying`, `parking_id`, `commerc_services`, `garage_vid_id`, `boks_vid_id`, `commerc_status_id`, `flat_number`) VALUES ($id,'$objectAddInf[ceiling_height]','$objectAddInf[bathroom_unit]','$objectAddInf[balcony]','$objectAddInf[renovation]','$objectAddInf[window_view]','$objectAddInf[apartments]','$objectAddInf[video_url]','$objectAddInf[loggias]','$objectAddInf[separate_wcs]','$objectAddInf[combined_wcs]','$objectAddInf[passenger_lifts]','$objectAddInf[cargo_lifts]','$objectAddInf[vat_type_id]','$objectAddInf[house_category]','$objectAddInf[commercial_object_id]','$objectAddInf[isPartsEnabled]','$objectAddInf[parts_area]','$objectAddInf[legal_address]','$objectAddInf[isOccupied]','$objectAddInf[is_occupied_month]','$objectAddInf[is_occupied_year]','$objectAddInf[layout_id]','$objectAddInf[number_wet_spots]','$objectAddInf[electricity_power]','$objectAddInf[commer_condition]','$objectAddInf[isFurniture]','$objectAddInf[commer_access]','$objectAddInf[parking_price]','$objectAddInf[parkingIsFree]','$objectAddInf[building_nazv]','$objectAddInf[commerc_year]','$objectAddInf[commerc_building_type_id]','$objectAddInf[commerc_building_class_id]','$objectAddInf[building_area]','$objectAddInf[commerc_site]','$objectAddInf[commerc_owned]','$objectAddInf[commerc_building_category_id]','$objectAddInf[building_developer]','$objectAddInf[building_management_company]','$objectAddInf[commerc_building_ventilation]','$objectAddInf[commerc_building_conditioning]','$objectAddInf[commerc_building_heating]','$objectAddInf[commerc_building_fire]','$objectAddInf[commerc_houseLineType_id]','$objectAddInf[commerc_opened_id]','$objectAddInf[commerc_infrastructure]','$objectAddInf[column_grid]','$objectAddInf[tax_number]','$objectAddInf[floor_material_id]','$objectAddInf[commerc_portal_id]','$objectAddInf[commerc_purpose]','$objectAddInf[gsk_nazv]','$objectAddInf[commerc_specifications]','$objectAddInf[commerc_land_category_id]','$objectAddInf[can_land_category_change]','$objectAddInf[commerc_permitted_use_id]','$objectAddInf[can_permitted_use_change]','$objectAddInf[commerc_investproject]','$objectAddInf[is_encumbrances]','$objectAddInf[commerc_electricity_id]','$objectAddInf[can_electricity]','$objectAddInf[commerc_gas_id]','$objectAddInf[can_gas]','$objectAddInf[commerc_water_id]','$objectAddInf[can_water]','$objectAddInf[commerc_sewage_id]','$objectAddInf[can_sewage]','$objectAddInf[commerc_driveways_id]','$objectAddInf[garage_type_id]','$objectAddInf[commerc_lift1]','$objectAddInf[lift1_carrying]','$objectAddInf[commerc_lift2]','$objectAddInf[lift2_carrying]','$objectAddInf[commerc_lift3]','$objectAddInf[lift3_carrying]','$objectAddInf[commerc_crane1]','$objectAddInf[crane1_carrying]','$objectAddInf[commerc_crane2]','$objectAddInf[crane2_carrying]','$objectAddInf[commerc_crane3]','$objectAddInf[crane3_carrying]','$objectAddInf[commerc_crane4]','$objectAddInf[crane4_carrying]','$objectAddInf[parking_id]','$objectAddInf[commerc_services]','$objectAddInf[garage_vid_id]','$objectAddInf[boks_vid_id]','$objectAddInf[commerc_status_id]','$objectAddInf[flat_number]')";
mysql_query($sqlInsObjectsAddInf, $jwdb);
}
$sqlSelectPhoto = "select * from objects_object_photo oop where oop.object_id = $object[id]";
$rezSelectPhoto = mysql_query($sqlSelectPhoto, $mdb);
if (mysql_num_rows($rezSelectPhoto) > 0) {
while ($ph = mysql_fetch_assoc($rezSelectPhoto)) {
$sqlPh = "SELECT * FROM object_photo WHERE id = $ph[object_photo_id]";
$rezPh = mysql_query($sqlPh, $mdb);
if (mysql_num_rows($rezPh) > 0) {
$photo = mysql_fetch_assoc($rezPh);
echo "Добавляем фото по объекту " . $photo['id'] . "<br/>";
$sqlInsPhoto = "INSERT INTO `object_photo`(`photo`) VALUES ('$photo[photo]')";
mysql_query($sqlInsPhoto, $jwdb);
$photoId = mysql_insert_id($jwdb);
$sqlInsPhotoLink = "INSERT INTO objects_object_photo(object_id, object_photo_id, sort_order) VALUES($id, $photoId, $ph[sort_order])";
mysql_query($sqlInsPhotoLink, $jwdb);
}
}
}
$sqlSpMetro = "SELECT * FROM sp_metro WHERE id_obj = $object[id]";
$rezSpMetro = mysql_query($sqlSpMetro, $mdb);
if (mysql_num_rows($rezSpMetro) > 0) {
while ($spMetro = mysql_fetch_assoc($rezSpMetro)) {
echo "Добавляем метро по объекту " . $spMetro['id'] . "<br/>";
$sqlInsSpMetro = "INSERT INTO `sp_metro`(`id_metro`, `id_obj`) VALUES ($spMetro[id_metro],$id)";
mysql_query($sqlInsSpMetro, $jwdb);
}
}
$sqlSaleObjects = "SELECT * FROM sale_objects WHERE object_id = $object[id]";
$rezSaleObjects = mysql_query($sqlSaleObjects, $mdb);
if (mysql_num_rows($rezSaleObjects) > 0) {
$saleObjects = mysql_fetch_assoc($rezSaleObjects);
echo "Добавляем данные по объекту продажи " . $saleObjects['id'] . "<br/>";
$sqlInsSaleObjects = "INSERT INTO `sale_objects`(`object_id`, `house_material`, `house_type`, `deal_type`, `build_year`) VALUES ($id,$saleObjects[house_material],$saleObjects[house_type],$saleObjects[deal_type],$saleObjects[build_year])";
mysql_query($sqlInsSaleObjects, $jwdb);
}
$sqlAdsObjects = "SELECT * FROM ads_objects WHERE obj_id = $object[id]";
$rezAdsObjects = mysql_query($sqlAdsObjects, $mdb);
if (mysql_num_rows($rezAdsObjects) > 0) {
$adsObjects = mysql_fetch_assoc($rezAdsObjects);
echo "Добавляем данные по объекту ADS " . $adsObjects['id'] . "<br/>";
$sqlInsAdsObjects = "INSERT INTO `ads_objects`(`ads_id`, `ads_source`, `ads_source_id`, `ads_agent`, `ads_url`, `obj_id`) VALUES ('$adsObjects[ads_id]','$adsObjects[ads_source]','$adsObjects[ads_source_id]','$adsObjects[ads_agent]','$adsObjects[ads_url]',$id)";
mysql_query($sqlInsAdsObjects, $jwdb);
}
$sqlObjectLocation = "SELECT * FROM object_location WHERE object_id = $object[id]";
$rezObjectLocation = mysql_query($sqlObjectLocation, $mdb);
if (mysql_num_rows($rezObjectLocation) > 0) {
$objectLocation = mysql_fetch_assoc($rezObjectLocation);
echo "Добавляем данные по метонахождению объекта " . $objectLocation['id'] . "<br/>";
$sqlInsObjectLocation = "INSERT INTO `object_location`(`object_id`, `address`, `latitude`, `longitude`, `street`, `rf_region_rayon`, `city`, `deleted`) VALUES ($id,'$objectLocation[address]','$objectLocation[latitude]','$objectLocation[longitude]','$objectLocation[street]','$objectLocation[rf_region_rayon]','$objectLocation[city]','$objectLocation[deleted]')";
mysql_query($sqlInsObjectLocation, $jwdb);
}
}
}