HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/limestate-api/Models/BitrixApi.php
<?php

class BitrixApi {
	const apiUrl = 'https://bitrix.limestate.ru/api/v2/';
    //const apiUrl = 'http://95.216.223.77/api/v2/';
    const domainUrl = 'https://bitrix.limestate.ru';

	public static function getComplex($id) {
		$url = self::apiUrl . 'complex/' . $id;

		return self::request($url);
	}

	public static function getComplexes() {
	    $url = self::domainUrl . '/buy2/simple.php';
        return self::request($url);
    }

    public static function getBuildings($complexId, $sectionId = 17) {
        $url = self::domainUrl . '/buy2/simple.php?action=buildings&id=' . $complexId . '&section_id=' . $sectionId;
        return self::request($url);
    }

    public static function getBuilding($buildingId) {
        $url = self::apiUrl . 'objects/search?id=' . $buildingId;
        return self::request($url);
    }

    public static function getUsedBuildings() {
	    return self::getBuildings(0, 12);
    }

    public static function getFlats($buildingId) {
        $url = self::domainUrl . '/buy2/simple.php?action=flats&id='.$buildingId;
        return self::request($url);
    }

    public static function getFlat($id) {
        $url = self::apiUrl . 'objects/getOffer/' . $id;

        return self::request($url);
    }

	public static function request($url) {
		$ch = curl_init($url);
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

		$response = curl_exec($ch);
		curl_close($ch);

		$result = json_decode($response);

		if (!is_null($result)) {
		    return $result;
        } else {
		    throw new Exception('Ошибка выполнения запроса: ' . $url);
        }
	}
}