541 lines
20 KiB
PHP
541 lines
20 KiB
PHP
|
|
<?php
|
|||
|
|
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
|
|||
|
|
ini_set('display_errors', 'On');
|
|||
|
|
|
|||
|
|
require_once($_SERVER['DOCUMENT_ROOT']."/config.php");
|
|||
|
|
require_once(__DIR__ . '/vendor/autoload.php');
|
|||
|
|
require_once(__DIR__ . '/engine/pdf_functions.php');
|
|||
|
|
require_once(__DIR__ . '/engine/props.php');
|
|||
|
|
require_once(__DIR__ . '/Prince.php');
|
|||
|
|
include 'createPennyLane.php';
|
|||
|
|
use Prince\Prince;
|
|||
|
|
set_time_limit(0);
|
|||
|
|
ini_set('memory_limit', '320M');
|
|||
|
|
|
|||
|
|
/** GET ID */
|
|||
|
|
if(isset($_GET['el'])) {
|
|||
|
|
if (count($_SESSION['to_send']) == 0) {
|
|||
|
|
echo "no_el";
|
|||
|
|
} else {
|
|||
|
|
$closes_contact = [];
|
|||
|
|
$prices = [];
|
|||
|
|
|
|||
|
|
if(isset($_GET['closes'])){
|
|||
|
|
$closes_contact = json_decode($_GET['closes'], true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(isset($_GET['priсes'])){
|
|||
|
|
$prices = json_decode($_GET['priсes'], true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$num = $_GET['el'];
|
|||
|
|
$id = $_SESSION['to_send'][$num];
|
|||
|
|
if(isset($closes_contact) && isset($closes_contact[$id])){
|
|||
|
|
$closes_c = $closes_contact[$id];
|
|||
|
|
}
|
|||
|
|
if (count($_SESSION['to_send']) > $num + 1 and !isset($_GET['view'])) {
|
|||
|
|
echo ++$num;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
$id = $_GET['id'];
|
|||
|
|
if(isset($_GET['view']) && $_GET['view'] == 2){
|
|||
|
|
$closes_c = 1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** BUILD QUERIES */
|
|||
|
|
$sql = "SELECT objects.id, objects.operation_type, objects.nazv, objects.etazh, objects.etazh_iz, objects.stoim,
|
|||
|
|
objects.peshkom, objects.transport, objects.adres, objects.dom, objects.korpus, objects.litera,
|
|||
|
|
objects.id_rf_region, rayon.rayon, objects.ploshad, objects.ploshad_komn, objects.ploshad_k, objects.srok, objects.opis,
|
|||
|
|
objects.type, objects.type_category, object_prices.currency, objects.land_area
|
|||
|
|
FROM objects
|
|||
|
|
LEFT JOIN rayon rayon on objects.rayon = rayon.id
|
|||
|
|
LEFT JOIN object_prices ON objects.id = object_prices.object_id
|
|||
|
|
WHERE objects.id = $id";
|
|||
|
|
|
|||
|
|
$rez = mysql_query($sql);
|
|||
|
|
$obj = mysql_fetch_assoc($rez);
|
|||
|
|
|
|||
|
|
/** PREPARE DATA TO FIRST TOP PAGE */
|
|||
|
|
$arrTop = array();
|
|||
|
|
$arrTop['type'] = $obj['type'];
|
|||
|
|
if($obj['type'] == 4){
|
|||
|
|
$sqlCommerce = "SELECT * FROM commercial_object";
|
|||
|
|
$resultCommerce = mysql_query($sqlCommerce);
|
|||
|
|
$arrTypeCommerc = array();
|
|||
|
|
while ($rCommerc = mysql_fetch_assoc($resultCommerce)) {
|
|||
|
|
$arrTypeCommerc[$rCommerc['id']] = $rCommerc['name'];
|
|||
|
|
}
|
|||
|
|
if(isset($arrTypeCommerc[$obj['type_category']])){
|
|||
|
|
$arrTop['commerce_type'] = $arrTypeCommerc[$obj['type_category']];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
$arrTop['operation_type'] = $obj['operation_type'];
|
|||
|
|
$arrTop['nazv'] = Filter::name($obj['nazv']);
|
|||
|
|
$arrTop['komnat'] = $obj['komnat'];
|
|||
|
|
/** ETAZHNOST */
|
|||
|
|
if($obj['etazh']*1 != 0){
|
|||
|
|
$arrTop['etazh'] = $obj['etazh'];
|
|||
|
|
}
|
|||
|
|
$currency = $obj['currency'];
|
|||
|
|
$domNum = $obj['dom'];
|
|||
|
|
if($obj['etazh_iz']*1 != 0)
|
|||
|
|
$arrTop['etazh_iz'] = $obj['etazh_iz'];
|
|||
|
|
if(!$obj['etazh'])
|
|||
|
|
$arrTop['etazh'] = Filter::getFloorFromName($arrTop['nazv'],true);
|
|||
|
|
else
|
|||
|
|
Filter::getFloorFromName($arrTop['nazv'],true);
|
|||
|
|
|
|||
|
|
if(!$obj['etazh_iz'])
|
|||
|
|
$arrTop['etazh_iz'] = Filter::getMaxFloorFromName($arrTop['nazv'],true);
|
|||
|
|
else
|
|||
|
|
Filter::getMaxFloorFromName($arrTop['nazv'],true);
|
|||
|
|
|
|||
|
|
Filter::getSpaceFromName($arrTop['nazv'],true);
|
|||
|
|
/** STOIMOST */
|
|||
|
|
$arrTop['stoim'] = number_format($obj['stoim'], 0, ',', ' ');
|
|||
|
|
$arrTop['currency'] = $obj['currency'];
|
|||
|
|
if(isset($_GET['cena'])){
|
|||
|
|
$arrTop['stoim'] = number_format($_GET['cena'], 0, ',', ' ');
|
|||
|
|
} else if(isset($prices[$obj['id']]) && $prices[$obj['id']] > 0){
|
|||
|
|
$arrTop['stoim'] = number_format($prices[$obj['id']], 0, ',', ' ');
|
|||
|
|
}
|
|||
|
|
/** METRO */
|
|||
|
|
$mtr = array();
|
|||
|
|
$sql = "SELECT metro.metro FROM metro, sp_metro
|
|||
|
|
WHERE sp_metro.id_metro = metro.id AND sp_metro.id_obj = $obj[id]";
|
|||
|
|
$result = mysql_query($sql);
|
|||
|
|
while($m = mysql_fetch_row($result)) $mtr[] = $m[0];
|
|||
|
|
$metro_str = implode(", ",$mtr);
|
|||
|
|
$do_metro = '';
|
|||
|
|
if($obj['peshkom'])
|
|||
|
|
$do_metro = $obj['peshkom']." минут пешком";
|
|||
|
|
if($obj['peshkom'] and $obj['transport'])
|
|||
|
|
$do_metro .= " или ";
|
|||
|
|
if($obj['transport'])
|
|||
|
|
$do_metro .= $obj['transport']." минут на транспорте";
|
|||
|
|
|
|||
|
|
$arrTop['metrostr'] = $metro_str;
|
|||
|
|
$arrTop['way'] = $do_metro;
|
|||
|
|
/** ADDRESS */
|
|||
|
|
|
|||
|
|
if(!isset($_GET['hide_address'])){
|
|||
|
|
$sqlLocationInfo = "SELECT * FROM object_location WHERE object_id=".$obj['id'];
|
|||
|
|
$rezLocationInfo = mysql_query($sqlLocationInfo);
|
|||
|
|
|
|||
|
|
if (mysql_num_rows($rezLocationInfo) > 0) {
|
|||
|
|
$objLocationInfo = mysql_fetch_assoc($rezLocationInfo);
|
|||
|
|
$latitude = $objLocationInfo['latitude'];
|
|||
|
|
$longitude = $objLocationInfo['longitude'];
|
|||
|
|
$street = $objLocationInfo['street'];
|
|||
|
|
$adr = $objLocationInfo['address'];
|
|||
|
|
} else {
|
|||
|
|
$address = $obj['adres'];
|
|||
|
|
|
|||
|
|
$adr = '';
|
|||
|
|
if($obj['id_rf_region'] == 81){
|
|||
|
|
if(strpos($address, "Санкт-Петербург") === false){
|
|||
|
|
$adr .= "Санкт-Петербург, ";
|
|||
|
|
}
|
|||
|
|
if($obj['rayon']){
|
|||
|
|
$arrTop['rayon'] = str_replace([' район', 'район', ' р-н', 'р-н'], '', $obj['rayon']).' район';
|
|||
|
|
}else{
|
|||
|
|
$arrTop['rayon'] = '';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
$adr .= $address;
|
|||
|
|
}
|
|||
|
|
$arrTop['address'] = $adr;
|
|||
|
|
} else {
|
|||
|
|
$arrTop['address'] = '';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*if ($obj['dom']) {
|
|||
|
|
$address = $address . ", " . $obj['dom'];
|
|||
|
|
}
|
|||
|
|
if ($obj['korpus']) {
|
|||
|
|
$address = $address . ", корпус " . $obj['korpus'];
|
|||
|
|
}
|
|||
|
|
if ($obj['litera']) {
|
|||
|
|
$address = $address . ", литера" . $obj['litera'];
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
/** SQUARE */
|
|||
|
|
if($obj['ploshad']*1 != 0){
|
|||
|
|
$obj['ploshad'] *= 1;
|
|||
|
|
$arrTop['ploshad'] = $obj['ploshad'];
|
|||
|
|
}else{
|
|||
|
|
$arrTop['ploshad'] = '';
|
|||
|
|
}
|
|||
|
|
if($obj['ploshad_komn']*1 != 0){
|
|||
|
|
if(stripos($obj['ploshad_komn'],"+") == false)
|
|||
|
|
$obj['ploshad_komn'] *= 1;
|
|||
|
|
$arrTop['ploshad_komn'] = $obj['ploshad_komn'];
|
|||
|
|
}else{
|
|||
|
|
$arrTop['ploshad_komn'] = '';
|
|||
|
|
}
|
|||
|
|
if($obj['ploshad_k']*1 != 0){
|
|||
|
|
$obj['ploshad_k'] *= 1;
|
|||
|
|
$arrTop['ploshad_k'] = $obj['ploshad_k'];
|
|||
|
|
}else{
|
|||
|
|
$arrTop['ploshad_k'] = '';
|
|||
|
|
}
|
|||
|
|
if($obj['operation_type']==0){
|
|||
|
|
$arrTop['sdelka'] = 'Сдается '.$SROK_ARENDY["$obj[srok]"];
|
|||
|
|
}else{
|
|||
|
|
$arrTop['sdelka'] = 'Продажа';
|
|||
|
|
}
|
|||
|
|
if ($obj['land_area']*1 != 0) {
|
|||
|
|
$arrTop['land_area'] = $obj['land_area'] * 1;
|
|||
|
|
} else {
|
|||
|
|
$arrTop['land_area'] = '';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** END OF GET TOP FIRST PAGE */
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
$useLocalPhoto = true;
|
|||
|
|
|
|||
|
|
if ($useLocalPhoto) {
|
|||
|
|
/* GET PHOTOS */
|
|||
|
|
$photos = array();
|
|||
|
|
$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 = $id ORDER BY oop.sort_order";
|
|||
|
|
$rezPhotoInfo = mysql_query($sqlPhotoInfo);
|
|||
|
|
|
|||
|
|
if (mysql_num_rows($rezPhotoInfo) > 0) {
|
|||
|
|
while ($photoInfo = mysql_fetch_assoc($rezPhotoInfo)) {
|
|||
|
|
$p = $photoInfo['photo'];
|
|||
|
|
if (stripos($photoInfo['photo'], "http://") === false && stripos($photoInfo['photo'], "https://") === false) {
|
|||
|
|
$p = "https://joywork.ru/photos/" . $photoInfo['photo'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
array_push($photos, $p);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($_SESSION["agency_id"] == 13735) {
|
|||
|
|
$allPhoto = array_slice($photos, 1);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** GET PLAN FROM DB */
|
|||
|
|
$arrTop['replace_plan'] = false;
|
|||
|
|
$sql = "SELECT * FROM objects_plan WHERE object_id = $id";
|
|||
|
|
$rez_plan = mysql_query($sql);
|
|||
|
|
if(mysql_num_rows($rez_plan) > 0){
|
|||
|
|
$obj_plan = mysql_fetch_assoc($rez_plan);
|
|||
|
|
if($obj_plan['img_plan'] != ''){
|
|||
|
|
if (stripos($obj_plan['img_plan'], "http://") === false && stripos($obj_plan['img_plan'], "https://") === false) {
|
|||
|
|
$obj_plan['img_plan'] = "https://joywork.ru/photos/" . $obj_plan['img_plan'];
|
|||
|
|
}
|
|||
|
|
$arrTop['plan'] = $obj_plan['img_plan'];
|
|||
|
|
if ($_SESSION["agency_id"] == 13735) {
|
|||
|
|
$fotoOne = array_shift($photos);
|
|||
|
|
}
|
|||
|
|
}else{ // если все же там пусто
|
|||
|
|
if(is_array($photos) && count($photos) > 0){
|
|||
|
|
$arrTop['replace_plan'] = true;
|
|||
|
|
$arrTop['plan'] = array_shift($photos); // вместо плана берем первую фотографию из всех фото
|
|||
|
|
$fotoOne = $arrTop['plan'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}else{
|
|||
|
|
if(is_array($photos) && count($photos) > 0){
|
|||
|
|
$arrTop['replace_plan'] = true;
|
|||
|
|
$arrTop['plan'] = array_shift($photos); // вместо плана берем первую фотографию из всех фото
|
|||
|
|
$fotoOne = $arrTop['plan'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/** END OF GET PLAN */
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/* GET ADDITIONAL DESCRIPTION FROM DB */
|
|||
|
|
$sqlComment = "SELECT * FROM user_object_comments WHERE user_id = '$_SESSION[id]' AND object_id='$id'";
|
|||
|
|
$rezComment = mysql_query($sqlComment);
|
|||
|
|
if (mysql_num_rows($rezComment) > 0) {
|
|||
|
|
$commentRow = mysql_fetch_assoc($rezComment);
|
|||
|
|
$obj['opis'] = $commentRow['comment'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$opis = cleanHtml($obj['opis'], '<p><br><strong><em><ul><ol><li>');
|
|||
|
|
$opis = replaceEmojiWithImages($opis);
|
|||
|
|
|
|||
|
|
|
|||
|
|
$closeHeader = 0;
|
|||
|
|
if(isset($closes_c)){
|
|||
|
|
$closeHeader = $closes_c;
|
|||
|
|
}
|
|||
|
|
//echo $closeHeader;
|
|||
|
|
|
|||
|
|
$common = [];
|
|||
|
|
|
|||
|
|
if ($agency_id = User::getUserAgencyID()) {
|
|||
|
|
$sql = "SELECT `fields`.`id` AS `id`,
|
|||
|
|
`fields`.`name` AS `name`,
|
|||
|
|
`fields`.`type` AS `type`,
|
|||
|
|
`fields`.`title` AS `title`,
|
|||
|
|
`fields`.`params` AS `params`,
|
|||
|
|
`data`.`value` AS `value`
|
|||
|
|
FROM `object_data` AS `data`
|
|||
|
|
LEFT JOIN `object_fields` AS `fields` ON `data`.`field_id` = `fields`.`id`
|
|||
|
|
WHERE `data`.`object_id`='$obj[id]' AND
|
|||
|
|
`fields`.`agency_id`='$agency_id' AND
|
|||
|
|
`fields`.`is_presentation`='1' AND
|
|||
|
|
`fields`.`is_active`='1'
|
|||
|
|
ORDER BY `fields`.`order`";
|
|||
|
|
|
|||
|
|
$query = mysql_query($sql);
|
|||
|
|
while ($row = mysql_fetch_assoc($query)) {
|
|||
|
|
if (isset($row['value'])) {
|
|||
|
|
$field_name = $row['name'];
|
|||
|
|
$field_title = $row['title'];
|
|||
|
|
if ($row['type'] == 2 || $row['type'] == 3) {
|
|||
|
|
$values = json_decode($row['value']);
|
|||
|
|
$params = json_decode($row['params'], true);
|
|||
|
|
if (count($values) > 0) {
|
|||
|
|
$values_str = '';
|
|||
|
|
foreach ($values as $value) {
|
|||
|
|
foreach ($params['items'] as $item) {
|
|||
|
|
if ($item['value'] == $value) {
|
|||
|
|
if (!empty($values_str))
|
|||
|
|
$values_str .= ", " . $item['name'];
|
|||
|
|
else
|
|||
|
|
$values_str .= $item['name'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($values_str)) {
|
|||
|
|
$common[$field_title] = $values_str;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} else if ($row['type'] == 4) {
|
|||
|
|
$common[$field_title] = (boolval($row['value'])) ? 'Да' : 'Нет';
|
|||
|
|
} else {
|
|||
|
|
if ($row['value']) {
|
|||
|
|
$common[$field_title] = $row['value'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/* END OF GET */
|
|||
|
|
|
|||
|
|
/* GET IMAGE FOR DESCRIPTION */
|
|||
|
|
if(isset($photos) && is_array($photos)){
|
|||
|
|
if(count($photos) > 0){
|
|||
|
|
$imgDesc = array_shift($photos);
|
|||
|
|
}else{
|
|||
|
|
$imgDesc = '';
|
|||
|
|
}
|
|||
|
|
}else{
|
|||
|
|
$imgDesc = '';
|
|||
|
|
}
|
|||
|
|
/* END OF GET */
|
|||
|
|
|
|||
|
|
|
|||
|
|
/* GET PROPS */
|
|||
|
|
$arrProps = getProps($id);
|
|||
|
|
|
|||
|
|
|
|||
|
|
/** CREATE PDF ENGINE */
|
|||
|
|
/* INCLUDE FONTS */
|
|||
|
|
$defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
|
|||
|
|
$fontDirs = $defaultConfig['fontDir'];
|
|||
|
|
$defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
|
|||
|
|
$fontData = $defaultFontConfig['fontdata'];
|
|||
|
|
|
|||
|
|
/* PDF SETTINGS */
|
|||
|
|
$settings = [
|
|||
|
|
'mode' => 'utf-8', 'format' => 'A4', 'orientation' => 'L',
|
|||
|
|
'margin_left'=> 5,'margin_right'=> 5,'margin_top'=> 27,'margin_bottom'=> 5,'margin_header'=> 2,'margin_footer'=> 5,
|
|||
|
|
'fontDir' => array_merge($fontDirs, [__DIR__ . '/engine/fonts']),
|
|||
|
|
'fontdata' => $fontData + [
|
|||
|
|
'lato' => [
|
|||
|
|
'R' => 'Lato-Regular.ttf',
|
|||
|
|
'B' => 'Lato-Bold.ttf',
|
|||
|
|
]
|
|||
|
|
],
|
|||
|
|
'default_font' => 'lato'
|
|||
|
|
];
|
|||
|
|
$sql = "SELECT * FROM objects_additional_information WHERE object_id = $id";
|
|||
|
|
$objAddinfo = mysql_query($sql);
|
|||
|
|
while ($rowObjinfo = mysql_fetch_assoc($objAddinfo)) {
|
|||
|
|
$complex_title = $rowObjinfo['complex_title'];
|
|||
|
|
$additional_heading = $rowObjinfo['additional_heading'];
|
|||
|
|
$presentationValue = $rowObjinfo['presentationValue'];
|
|||
|
|
$wcs = intval($rowObjinfo["combined_wcs"]) + intval($rowObjinfo["separate_wcs"]);
|
|||
|
|
$renovationVaue = $rowObjinfo['renovation'];
|
|||
|
|
$number_of_parking = $rowObjinfo['number_of_parking'];
|
|||
|
|
$location = $rowObjinfo['location'];
|
|||
|
|
$description_of_complex = $rowObjinfo['description_of_complex'];
|
|||
|
|
$url_obj = $rowObjinfo['url_obj'];
|
|||
|
|
$arrTop['commerc_site'] = $rowObjinfo['commerc_site'];
|
|||
|
|
}
|
|||
|
|
if($renovationVaue == 4 || $renovationVaue == 6){
|
|||
|
|
$renovation = 'без отделки';
|
|||
|
|
}else{
|
|||
|
|
$renovation = 'с отделкой';
|
|||
|
|
}
|
|||
|
|
$sqlKomnat = "SELECT komnat FROM objects WHERE id = $id";
|
|||
|
|
$objsqlKomnat = mysql_query($sqlKomnat);
|
|||
|
|
$objKomnat = mysql_fetch_assoc($objsqlKomnat);
|
|||
|
|
$komnat = $objKomnat['komnat'];
|
|||
|
|
$phone = $_SESSION["phone"];
|
|||
|
|
$photosChunks = array_chunk($photos, 4);
|
|||
|
|
$stylenone = 1;
|
|||
|
|
if ($_SESSION["agency_id"] == 13735) {
|
|||
|
|
if ($arrTop['plan'] == $fotoOne){
|
|||
|
|
$arrTop['plan'] = $_SERVER['DOCUMENT_ROOT']. '/images/belyy-kvadrat_184928579_orig_.jpg';
|
|||
|
|
$stylenone = 2;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if($_GET['view'] == 2){
|
|||
|
|
$rezult = creationPDFnoContact($complex_title,$additional_heading,$arrTop["ploshad"],$komnat,$arrTop["etazh"],$wcs,$arrTop['nazv'],$obj['opis'],$renovation,$komnat,$number_of_parking,$arrTop['plan'],$location,$latitude,$longitude,$description_of_complex,$arrTop["stoim"],$url_obj,$fotoOne,$phone,$id,$allPhoto,$currency,$street,$domNum,$stylenone);
|
|||
|
|
$prince = new Prince('/usr/bin/prince');
|
|||
|
|
$prince->setLog($_SERVER['DOCUMENT_ROOT'].'/new_pdf/log.txt');
|
|||
|
|
$prince->addStyleSheet($_SERVER['DOCUMENT_ROOT'].'/new_pdf/css/main.css');
|
|||
|
|
$prince->setPageSize("495mm 375.2mm");
|
|||
|
|
$x = $prince->convertFile($_SERVER['DOCUMENT_ROOT'].'/new_pdf/id'.$id.'.html');
|
|||
|
|
if($x == 1){
|
|||
|
|
$file = 'id'.$id.'.pdf';
|
|||
|
|
$filen = 'newid'.$id.'.pdf';
|
|||
|
|
$pathname = $_SERVER['DOCUMENT_ROOT'].'/new_pdf/'.$filen;
|
|||
|
|
exec('/usr/bin/pdftk '.$_SERVER['DOCUMENT_ROOT'].'/new_pdf/'.$file .' cat 2-r2 output '.$_SERVER['DOCUMENT_ROOT'].'/new_pdf/'.$filen);
|
|||
|
|
header('Content-type: application/pdf');
|
|||
|
|
header('Content-Disposition: inline; filename="'.$filen.'"');
|
|||
|
|
header('Content-Transfer-Encoding: binary');
|
|||
|
|
header('Content-Length: ' . filesize($pathname));
|
|||
|
|
header('Accept-Ranges: bytes');
|
|||
|
|
readfile($pathname);
|
|||
|
|
}
|
|||
|
|
unlink($_SERVER['DOCUMENT_ROOT'].'/new_pdf/id'.$id.'.html');
|
|||
|
|
unlink($_SERVER['DOCUMENT_ROOT'].'/new_pdf/id'.$id.'.pdf');
|
|||
|
|
}else{
|
|||
|
|
$rezult = creationPDF($complex_title,$additional_heading,$arrTop["ploshad"],$komnat,$arrTop["etazh"],$wcs,$arrTop['nazv'],$obj['opis'],$renovation,$komnat,$number_of_parking,$arrTop['plan'],$location,$latitude,$longitude,$description_of_complex,$arrTop["stoim"],$url_obj,$fotoOne,$phone,$id,$allPhoto,$currency,$street,$domNum,$stylenone);
|
|||
|
|
$prince = new Prince('/usr/bin/prince');
|
|||
|
|
$prince->setLog($_SERVER['DOCUMENT_ROOT'].'/new_pdf/log.txt');
|
|||
|
|
$prince->addStyleSheet($_SERVER['DOCUMENT_ROOT'].'/new_pdf/css/main.css');
|
|||
|
|
$prince->setPageSize("495mm 375.2mm");
|
|||
|
|
$x = $prince->convertFile($_SERVER['DOCUMENT_ROOT'].'/new_pdf/id'.$id.'.html');
|
|||
|
|
if($x == 1){
|
|||
|
|
$file = 'id'.$id.'.pdf';
|
|||
|
|
$filen = 'newid'.$id.'.pdf';
|
|||
|
|
$pathname = $_SERVER['DOCUMENT_ROOT'].'/new_pdf/'.$filen;
|
|||
|
|
exec('/usr/bin/pdftk '.$_SERVER['DOCUMENT_ROOT'].'/new_pdf/'.$file .' cat 2-end output '.$_SERVER['DOCUMENT_ROOT'].'/new_pdf/'.$filen);
|
|||
|
|
header('Content-type: application/pdf');
|
|||
|
|
header('Content-Disposition: inline; filename="'.$filen.'"');
|
|||
|
|
header('Content-Transfer-Encoding: binary');
|
|||
|
|
header('Content-Length: ' . filesize($pathname));
|
|||
|
|
header('Accept-Ranges: bytes');
|
|||
|
|
readfile($pathname);
|
|||
|
|
}
|
|||
|
|
unlink($_SERVER['DOCUMENT_ROOT'].'/new_pdf/id'.$id.'.html');
|
|||
|
|
unlink($_SERVER['DOCUMENT_ROOT'].'/new_pdf/id'.$id.'.pdf');
|
|||
|
|
}
|
|||
|
|
}else{
|
|||
|
|
/* CREATE PDF OBJECT */
|
|||
|
|
try{
|
|||
|
|
$mpdf = new \Mpdf\Mpdf($settings);
|
|||
|
|
/* ADD STYLESHEET */
|
|||
|
|
$stylesheet = file_get_contents(__DIR__.'/engine/style.css');
|
|||
|
|
$mpdf->WriteHTML($stylesheet,\Mpdf\HTMLParserMode::HEADER_CSS);
|
|||
|
|
/* ADD HEADER */
|
|||
|
|
$mpdf->SetHTMLHeader(pdf_header(getHeaderData($closeHeader)));
|
|||
|
|
/* ADD FIRST PAGE */
|
|||
|
|
$mpdf->WriteHTML(pdf_body_first($arrTop, $arrProps, $obj['type'], $obj['type_category']));
|
|||
|
|
/* ADD DESCRIPTION PAGE */
|
|||
|
|
if(!empty($opis) || count($common) > 0){
|
|||
|
|
$mpdf->AddPage();
|
|||
|
|
$html = pdf_body_second($opis, $imgDesc, $common);
|
|||
|
|
$mpdf->WriteHTML($html);
|
|||
|
|
}
|
|||
|
|
/* ADD PHOTO PAGE(S) */
|
|||
|
|
if(is_array($photos)){
|
|||
|
|
if(count($photos) > 0){
|
|||
|
|
$mpdf->AddPage();
|
|||
|
|
$mpdf->WriteHTML(pdf_body_third($photos));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/* OUTPUT PDF */
|
|||
|
|
if($_GET['view'])
|
|||
|
|
$mpdf->Output();
|
|||
|
|
else
|
|||
|
|
$mpdf->Output($_SERVER['DOCUMENT_ROOT']."/pdf/$obj[id]-$_SESSION[id].pdf", \Mpdf\Output\Destination::FILE);
|
|||
|
|
} catch(\Mpdf\MpdfException $e) {
|
|||
|
|
//echo $e->getMessage();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
function curl_request($url)
|
|||
|
|
{
|
|||
|
|
$ch = curl_init($url);
|
|||
|
|
curl_setopt($ch, CURLOPT_CERTINFO, 1);
|
|||
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // запретить проверку сертификата удаленного сервера
|
|||
|
|
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0");
|
|||
|
|
curl_setopt($ch, CURLOPT_REFERER, "https://joywork.ru/");
|
|||
|
|
curl_setopt($ch, CURLOPT_HEADER, 0); // При установке этого параметра в 1 результат будет включать полученные заголовки.
|
|||
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // При установке этого параметра в ненулевое значение CURL будет возвращать результат, а не выводить его.
|
|||
|
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //при получении HTTP заголовка "Location: " будет происходить перенаправление на указанный этим заголовком URL
|
|||
|
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
|||
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
|||
|
|
$content = curl_exec($ch);
|
|||
|
|
curl_close($ch);
|
|||
|
|
return $content;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function replaceEmojiWithImages($text) {
|
|||
|
|
|
|||
|
|
if (!mb_check_encoding($text, 'UTF-8')) {
|
|||
|
|
$text = mb_convert_encoding($text, 'UTF-8', 'auto');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$result = '';
|
|||
|
|
$len = mb_strlen($text, 'UTF-8');
|
|||
|
|
|
|||
|
|
for ($i = 0; $i < $len; $i++) {
|
|||
|
|
$char = mb_substr($text, $i, 1, 'UTF-8');
|
|||
|
|
$ord = _utf8_to_codepoint($char);
|
|||
|
|
$code = strtolower(sprintf('%04x', $ord));
|
|||
|
|
|
|||
|
|
$isEmoji = (
|
|||
|
|
($ord >= 0x1F300 && $ord <= 0x1F6FF) ||
|
|||
|
|
($ord >= 0x1F900 && $ord <= 0x1F9FF) ||
|
|||
|
|
($ord >= 0x2600 && $ord <= 0x26FF) ||
|
|||
|
|
($ord >= 0x2700 && $ord <= 0x27BF)
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
if ($isEmoji) {
|
|||
|
|
$localPath = $_SERVER['DOCUMENT_ROOT'] . "/images/emoji/{$code}.png";
|
|||
|
|
if (file_exists($localPath)) {
|
|||
|
|
$img = file_get_contents($localPath);
|
|||
|
|
if ($img !== false) {
|
|||
|
|
$b64 = base64_encode($img);
|
|||
|
|
$result .= '<img src="data:image/png;base64,' . $b64 . '" width="16" height="16" style="vertical-align:middle;margin:0 2px;">';
|
|||
|
|
} else {
|
|||
|
|
$result .= $char;
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
$result .= $char;
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
$result .= $char;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return $result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function _utf8_to_codepoint($char) {
|
|||
|
|
$bytes = unpack('C*', $char);
|
|||
|
|
if (count($bytes) === 1) return $bytes[1];
|
|||
|
|
if (count($bytes) === 2) return (($bytes[1] & 0x1F) << 6) + ($bytes[2] & 0x3F);
|
|||
|
|
if (count($bytes) === 3) return (($bytes[1] & 0x0F) << 12) + (($bytes[2] & 0x3F) << 6) + ($bytes[3] & 0x3F);
|
|||
|
|
if (count($bytes) === 4) return (($bytes[1] & 0x07) << 18) + (($bytes[2] & 0x3F) << 12) + (($bytes[3] & 0x3F) << 6) + ($bytes[4] & 0x3F);
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
?>
|