50, 'name' => 'Ленинградская обл', 'kladr' => '4700000000000', 'parent' => 2, 'code' => 47 ); $region[1] =array( 'id' => 81, 'name' => 'Санкт-Петербург', 'kladr' => '7800000000000', 'parent' => 2, 'code' => 78 ); } $sqlForRequiredClient = "SELECT id FROM `users` WHERE company_id IN (7507, 93, 9954, 13386, 14134, 14794, 18724, 19111, 19894, 14548, 19794)"; $rezForRequiredClient = mysql_query($sqlForRequiredClient); while($userId = mysql_fetch_assoc($rezForRequiredClient)) { if ($userId['id'] == $_SESSION['id']) { $clientRequired = true; break; } } $post = null; if(isset($_POST) && isset($_POST['add_object'])) { $result = SelectelApi::getTokenAndUrl(); $token = $result[0]; $storageUrl = $result[1]; $sql = "SELECT * FROM users WHERE id = $_SESSION[id]"; $rez = mysql_query($sql); $user = mysql_fetch_assoc($rez); $agency = new User; $agency->get($user['id']); if (!isset($agency->agencyId)) { $agency->agencyId = $_SESSION['id']; if (!empty($agency->agency_name) && $agency->agency) $agency->agencyName = $agency->agency_name; elseif (!empty($agency->agency_name) && $agency->agency) $agency->agencyName = $agency->agency_name; } $post = clearInputData($_POST); if ($_POST['metroWithOrder']) { $_POST['metro'] = explode(",", $_POST['metroWithOrder']); } $selected_region = $post['id_rf_region'] ? $post['id_rf_region'] :( $region[0]['kladr'] == $post['kladr_type'] ? $region[0]['id'] : $region[1]['id']); if(isset($post['id_country']) && $post['id_country'] != 171){ $selected_region = 0; } if (!isset($post['lo_city_id']) || $post['lo_city_id'] == -1) { $post['lo_city_id'] = 0; } if (!isset($post['city_town_id']) || $post['city_town_id'] == -1) { $post['city_town_id'] = 0; } if(isset($post['commercial_object_id'])){ $post['type_category'] = $post['commercial_object_id']; } $oldPathList = []; /** PLAN IMG WORK */ $newP = ''; $planList = json_decode($_POST['fileuploader-list-img_plan'],true); foreach($planList as $plan){ if(strpos($plan['file'], "https://") !== false){ $newP = $plan['file']; }else{ if(strpos($plan['file'], "0:/") !== false){ $originalName = str_replace("0:/", "", $plan['file']); $strArray = explode(".", $originalName); $ext = end($strArray); if ($ext == "pjpeg") { $ext = "jpeg"; } $ext = mb_strtolower($ext); $name = md5($originalName . time()) . "_pl." . $ext; $one = mb_substr($name, 0, 1); if (!is_dir($_SERVER['DOCUMENT_ROOT'] . "/photos/$one")) mkdir($_SERVER['DOCUMENT_ROOT'] . "/photos/$one"); $two = mb_substr($name, 1, 1); if (!is_dir($_SERVER['DOCUMENT_ROOT'] . "/photos/$one/$two")) mkdir($_SERVER['DOCUMENT_ROOT'] . "/photos/$one/$two"); $three = mb_substr($name, 3, 1); if (!is_dir($_SERVER['DOCUMENT_ROOT'] . "/photos/$one/$two/$three")) mkdir($_SERVER['DOCUMENT_ROOT'] . "/photos/$one/$two/$three"); $new_path = "$one/$two/$three/$name"; $photo = "/photos/".$new_path; $oldPath = $_SERVER['DOCUMENT_ROOT']."/photos/obj_temp/".$_SESSION['id']."/".$originalName; try { copy($oldPath, $_SERVER['DOCUMENT_ROOT'] . $photo); $oldPathList[] = $oldPath; if (isset($filePos['editor'])) { $editor = $filePos['editor']; } else { $editor = []; } resize($_SERVER['DOCUMENT_ROOT'] . $photo, null, null, null, (isset($editor['crop']) ? $editor['crop'] : null), 100, (isset($editor['rotation']) ? $editor['rotation'] : null)); $image = new Imagick(); $image->readImage($_SERVER['DOCUMENT_ROOT'] . $photo); $resolution = 1024; if ($agency->agencyId == 10919 || $agency->agencyId == 8826 || $agency->agencyId == 12482 || $agency->agencyId == 11916 || $agency->agencyId == 13735 || $agency->agencyId == 16490) { $resolution = 1920; } if ($image->getImageWidth() > $resolution) { $image->scaleImage($resolution, $resolution, true); } $image->writeImage(); //загрузка в Selectel $fp = $_SERVER['DOCUMENT_ROOT'] . "/photos/" . $new_path; $r = SelectelApi::uploadFile($storageUrl, $token, $fp, $new_path, 'image/'.$ext); //если выложили в Selectel if ($r) { //заменяем путь на новый $new_path = "https://data.joywork.ru/" . $new_path; //удаляем файл с локального сервера unlink($fp); } $newP = $new_path; } catch (Exception $e) { $err = "Проблема загрузки плана, возможно, фото повреждено или его формат не соответствует расширению"; } } } } $post['img_plan'] = $newP; $err = ""; $newPhotos = array(); //порядок сортировки файлов $fileSortList = json_decode($_POST['fileuploader-list-photo'], true); //старые фото foreach ($fileSortList as $filePos) { if (strpos($filePos['file'], "https://") !== false) { $newPhotos[$filePos['index']] = $filePos['file']; } else { if (strpos($filePos['file'], "0:/") !== false) { $originalName = str_replace("0:/", "", $filePos['file']); $strArray = explode(".", $originalName); $ext = end($strArray); if ($ext == "pjpeg") { $ext = "jpeg"; } $ext = mb_strtolower($ext); $name = md5($originalName . time()) . "." . $ext; $one = mb_substr($name, 0, 1); if (!is_dir($_SERVER['DOCUMENT_ROOT'] . "/photos/$one")) { mkdir($_SERVER['DOCUMENT_ROOT'] . "/photos/$one"); } $two = mb_substr($name, 1, 1); if (!is_dir($_SERVER['DOCUMENT_ROOT'] . "/photos/$one/$two")) { mkdir($_SERVER['DOCUMENT_ROOT'] . "/photos/$one/$two"); } $three = mb_substr($name, 3, 1); if (!is_dir($_SERVER['DOCUMENT_ROOT'] . "/photos/$one/$two/$three")) { mkdir($_SERVER['DOCUMENT_ROOT'] . "/photos/$one/$two/$three"); } $new_path = "$one/$two/$three/$name"; $photo = "/photos/" . $new_path; $oldPath = $_SERVER['DOCUMENT_ROOT'] . "/photos/obj_temp/" . $_SESSION['id'] . "/" . $originalName; try { copy($oldPath, $_SERVER['DOCUMENT_ROOT'] . $photo); $oldPathList[] = $oldPath; $index = $filePos['index']; if (isset($filePos['editor'])) { $editor = $filePos['editor']; } else { $editor = []; } $imageToFix = new Imagick(); $imageToFix->readImage($_SERVER['DOCUMENT_ROOT'] . $photo); fix_image_orientation($imageToFix); $imageToFix->writeImage(); resize($_SERVER['DOCUMENT_ROOT'] . $photo, null, null, null, (isset($editor['crop']) ? $editor['crop'] : null), 100, (isset($editor['rotation']) ? $editor['rotation'] : null)); $image = new Imagick(); $image->readImage($_SERVER['DOCUMENT_ROOT'] . $photo); $resolution = 1024; if ($agency->agencyId == 22289 || $agency->agencyId == 10919 || $agency->agencyId == 8826 || $agency->agencyId == 12482 || $agency->agencyId == 11916 || $agency->agencyId == 4 || $agency->agencyId == 13735 || $agency->agencyId == 16490) { $resolution = 1920; } if ($image->getImageWidth() > $resolution) { $image->scaleImage($resolution, $resolution, true); } if (isset($post['addWaterMark'])) { $watermark = new Imagick(); $sqlWaterCheck = "SELECT watermark FROM agency_watermark WHERE agency_id = $agency->agencyId"; $rezWaterCheck = mysql_query($sqlWaterCheck); if (mysql_num_rows($rezWaterCheck) > 0) { $wmark = mysql_fetch_assoc($rezWaterCheck)['watermark']; $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/photos/agency/watermark/' . $wmark); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else { //для 7507 if ($agency->agencyId == 7507) { $width = round($image->getImageWidth() / 2); $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/stamp-midom-one.png'); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $width - 107, $image->getImageHeight() - 80); } else { if ($agency->agencyId == 8826) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/trend_logo.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 12482) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/estate_logo.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 11397) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/const_logo.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 12556) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/utrielt_logo.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 11965) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/cap_gar_logo.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($_SESSION['id'] == 13357) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/13357_logo.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 11584) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/stimul56_logo.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 13596) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/th_logo.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 12259) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/lion_logo.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 10638) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/gr_est_logo.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 11325) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/p_city_logo.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 4) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/ag_4.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 10041) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_rk.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 14794) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_souz.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 13058) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_nplus.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 14942) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_comfort.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 15401) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_mega.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 15710) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_metrics.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($_SESSION['id'] == 15276) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/15276_logo.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 15704) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/ruy.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 14568) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/vme_logo.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 16785) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/kristall_logo.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 17627) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/white_test.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($_SESSION['id'] == 17733) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_17733.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 17596) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/IMG_1080.PNG'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 17145) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/17145_logo.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($_SESSION['id'] == 18354) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_saz.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($_SESSION['id'] == 16795) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_kve.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($_SESSION['id'] == 18748) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_telex.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 13735) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_PL.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 18846) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/18846_logo.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($_SESSION['id'] == 19608) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/19608_logo.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($_SESSION['id'] == 21208) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_21208.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($_SESSION['id'] == 6027) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_6027.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($agency->agencyId == 22289) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_22289.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($_SESSION['id'] == 22173) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_22173.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($_SESSION['id'] == 21238) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_21238.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($_SESSION['id'] == 22924) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_22924.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($_SESSION['id'] == 17266) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_17266.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } else if ($_SESSION['id'] == 22680) { $watermark->readImage($_SERVER['DOCUMENT_ROOT'] . '/images/logo_22680.png'); $width = round($image->getImageWidth() / 2); $xPos = $width - round($watermark->getImageWidth() / 2); $yPos = round($image->getImageHeight() / 2) - round($watermark->getImageHeight() / 2); $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $xPos, $yPos); } } } } $image->writeImage(); //загрузка в Selectel $fp = $_SERVER['DOCUMENT_ROOT'] . "/photos/" . $new_path; $r = SelectelApi::uploadFile($storageUrl, $token, $fp, $new_path, 'image/'.$ext); //если выложили в Selectel if ($r) { //заменяем путь на новый $new_path = "https://data.joywork.ru/" . $new_path; //удаляем файл с локального сервера unlink($fp); } if ($index >= 0) { $newPhotos[$index] = $new_path; } else { $newPhotos[] = $new_path; } } catch (Exception $e) { $err = "Проблема загрузки фотографии " . $originalName . ", возможно, фото повреждено или его формат не соответствует расширению"; } } } } if (count($newPhotos) > 40) { $err = "Количество фотографий объекта не может быть больше 40"; } else { //перераспределяем фотографии for($num=1;$num<=40;$num++) { if (isset($newPhotos[$num - 1]) && $newPhotos[$num - 1]) { $post['photo' . $num] = $newPhotos[$num - 1]; } else { $post['photo' . $num] = ""; } } } if (!isset($post['operation_type'])) { if (strlen($err) > 0) { $err = $err."
"; } $err = "Необходимо указать раздел"; } if (!$post['type']) { if (strlen($err) > 0) { $err = $err."
"; } $err = $err."Необходимо указать тип объекта"; } if ($post['type'] && ($post['type'] == 3 || $post['type'] == 5 || $post['type'] == 7)) { if (!$post['land_usage_type_id']) { if (strlen($err) > 0) { $err = $err."
"; } if ($post['type'] == 2) { $err = $err."Необходимо заполнить поле Использование земли"; } } } if ($post['type'] && ($post['type'] == 1 || $post['type'] == 2)) { if (!$post['komnat']) { if (strlen($err) > 0) { $err = $err."
"; } if ($post['type'] == 2) { $err = $err."Необходимо заполнить поле Всего комнат в квартире"; } else { $err = $err."Необходимо заполнить поле Комнат"; } } if (!$post['ploshad_komn']) { if (strlen($err) > 0) { $err = $err."
"; } $err = $err."Необходимо заполнить поле Площадь комнат"; } } if ($post['type'] && $post['type'] == 2) { if (!$post['vsego_komn']) { if (strlen($err) > 0) { $err = $err."
"; } $err = $err."Необходимо заполнить поле Кол-во комнат в сделке"; } } if ($post['type'] && $post['komnat'] && $post['type'] == 1 && $post['komnat'] == 1) { //может быть студия } else { if ($post['studio_flag']) { if (strlen($err) > 0) { $err = $err."
"; } $err = $err."Признак квартиры-студии можно установить только для типа квартира и количества комнат 1"; } } // срок нужен только для аренды if (isset($post['operation_type']) && $post['operation_type'] == 0) { if (!$post['srok']) { if (strlen($err) > 0) { $err = $err . "
"; } $err = $err . "Необходимо указать срок"; } } else { $post['srok'] = 0; } if (!$post['adres']) { if (strlen($err) > 0) { $err = $err."
"; } $err = $err."Необходимо указать адрес объекта"; } if (!isset($post['type']) || ($post['type'] && $post['type'] != 3 && $post['type'] != 5 && $post['type'] != 7 && $post['commercial_object_id'] != 9 && $post['commercial_object_id'] != 7 && $post['commercial_object_id'] != 6)) { if (!$post['etazh']) { if (strlen($err) > 0) { $err = $err . "
"; } $err = $err . "Необходимо указать этаж объекта"; } } else { if (!$post['etazh']) { $post['etazh'] = 0; } } if (isset($post['type']) && $post['type'] && $post['type'] == 3) { if (!$post['ploshad']) { if (strlen($err) > 0) { $err = $err . "
"; } $err = $err . "Необходимо указать общую площадь"; } if (!$post['house_category']) { if (strlen($err) > 0) { $err = $err . "
"; } $err = $err . "Необходимо указать тип дома"; } } if (isset($post['type']) && $post['type'] && ($post['type'] == 7 || $post['type'] == 3)) { if (!$post['land_area']) { if (strlen($err) > 0) { $err = $err . "
"; } $err = $err . "Необходимо указать площадь участка"; } } if (!$post['etazhnost'] && $post['type'] != 7 && $post['commercial_object_id'] != 9 && $post['commercial_object_id'] != 7) { if (strlen($err) > 0) { $err = $err."
"; } $err = $err."Необходимо указать общее количество этажей объекта"; } if (!$post['stoim_ot']) { if (strlen($err) > 0) { $err = $err."
"; } $err = $err."Необходимо указать цену"; } $localClientRequired = $clientRequired; if ($post['deal_type'] && $post['deal_type'] == 6) { $localClientRequired = false; } if($localClientRequired && (!isset($_POST['sobstv_object']) || empty(json_decode($_POST['sobstv_object'])))) { if (strlen($err) > 0) { $err = $err."
"; } $err = $err."Необходимо указать клиента-собственника"; } if (isset($post['operation_type']) && $post['operation_type'] == 0) { if (!isset($post['type']) || ($post['type'] && ($post['type'] == 1 || $post['type'] == 2))) { if (!$post['rent_house_type_id'] || $post['rent_house_type_id'] == -1) { if (strlen($err) > 0) { $err = $err . "
"; } $err = $err . "Необходимо указать тип дома"; } } } if (isset($post['operation_type']) && $post['operation_type'] == 1) { if (!isset($post['type']) || ($post['type'] && $post['type'] != 3 && $post['type'] != 5 && $post['type'] != 7 && $post['type'] != 4)) { if (!$post['house_type'] || $post['house_type'] == -1) { if (strlen($err) > 0) { $err = $err . "
"; } $err = $err . "Необходимо указать тип дома"; } if (!$post['house_material'] || $post['house_material'] == -1) { if (strlen($err) > 0) { $err = $err . "
"; } $err = $err . "Необходимо указать материал дома"; } } if (!$post['deal_type'] || $post['deal_type'] == -1) { if (strlen($err) > 0) { $err = $err . "
"; } $err = $err . "Необходимо указать тип сделки"; } } if (isset($post['type']) && $post['type'] == 1) { if (!$post['avito_room_type_id'] || $post['avito_room_type_id'] == 0) { if (strlen($err) > 0) { $err = $err . "
"; } $err = $err . "Необходимо указать Тип комнат"; } } if (isset($post['type']) && $post['type'] == 4 && isset($post['commercial_object_id']) && $post['commercial_object_id'] == 1) { if (!$post['layout_id'] || $post['layout_id'] == 0) { if (strlen($err) > 0) { $err = $err . "
"; } $err = $err . "Необходимо указать Планировку"; } } // check required if(isset($post['deal_type'])){ $reqTypes = array(4,5,6); // Переуступка, Новостройка, Первичная продажа вторички if(in_array($post['deal_type'], $reqTypes)){ if(isset($post['newbuilding_id'])) if(empty($post['newbuilding_id']) && !isset($post['complex_id'])) $err = $err . "
Необходимо указать ЖК".$post['complex_id']; if(isset($post['nb_end_date'])) if(empty($post['nb_end_date'])) $err = $err . "
Необходимо указать Срок сдачи"; } } if (strlen($err) == 0) { if ($post['studio_flag']) { $post['studio_flag'] = 1; } if ($post['free_plan']) { $post['free_plan'] = 1; } if ($post['is_penthouse']) { $post['is_penthouse'] = 1; } if ($post['operation_type'] == 0) { if (isset($post['stoim_prim']) && $post['stoim_prim']) { $post['stoim_prim'] = "+ КУ"; } else { $post['stoim_prim'] = ''; } } else { if ($post['operation_type'] == 1) { if (isset($post['stoim_prim']) && $post['stoim_prim']) { $post['stoim_prim'] = "Возможна ипотека"; } else { $post['stoim_prim'] = ''; } } } if (!$post['nazv']) { switch ($post['type']) { case 1: if ($post['komnat'] == 1 && $post['studio_flag']) { $post['nazv'] = "Квартира-студия"; } else { $post['nazv'] = "$post[komnat]-комнатная квартира"; } break; case 2: $post['nazv'] = "Комната в $post[komnat]-комнатной квартире"; break; case 3: $post['nazv'] = "$post[komnat]-комнатный дом"; break; case 4: switch ($post['type_category']){ case 1: $post['nazv'] = "Офис"; break; case 2: $post['nazv'] = "Склад"; break; case 3: $post['nazv'] = "Торговая площадь"; break; case 4: $post['nazv'] = "Производство"; break; case 5: $post['nazv'] = "Помещение свободного назначения"; break; case 6: $post['nazv'] = "Здание"; break; case 7: $post['nazv'] = "Гараж"; break; case 8: $post['nazv'] = "Готовый бизнес"; break; case 9: $post['nazv'] = "Коммерческая земля"; break; default: $type = "Помещение"; } break; case 5: $post['nazv'] = "Часть дома"; break; case 6: $post['nazv'] = "Комплекс"; break; case 7: $post['nazv'] = "Участок"; break; default: $post['nazv'] = "$post[komnat]-комнатная квартира"; } } $post['date_add'] = date("Y-m-d H:i:s"); if ($post['minut_t'] == 'peshkom') { $post['peshkom'] = $post['minut']; } else { $post['transport'] = $post['minut']; } $post['opis'] = cleanHtml($post['opis'], '