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/elite/coordParser/commimParse.php
<?php

use coordParser\CommimAddress;
use coordParser\CommimParser;

ini_set('max_execution_time', '-1');
ini_set('display_errors', '1');

require __DIR__ . '/../vendor/autoload.php';

try {
    $commimAddress = new CommimAddress();
} catch (Throwable $exception) {
    print_r($exception->getMessage() . PHP_EOL);
    die;
}

$commimParser = new CommimParser();

$header = [
    'obj_id' => 'int',
    'addr_print' => 'string',
    'obj_type_name' => 'string',
    'prf_name' => 'string',
    'addr_whole_nmb' => 'string',
    'addr_build' => 'string',
    'addr_letter' => 'string',
    'flat_number' => 'string',
    'obj_kd_nmb' => 'string',
    'reg_name' => 'string',
    'obj_area' => 'float',
    'obj_reestr_num' => 'string',
    'obj_reestr_num_date' => 'string',
    'pravo' => 'string',
    'purpose_name' => 'string',
    'encumbrance_name' => 'string',
    'city_part' => 'string',
    'land_cadastr_cost' => 'string',
    'book_cost_value' => 'string',
    'residual_cost_value' => 'string',
    'residual_cost_date' => 'string',
    'details' => 'string',
    'longitude' => 'float',
    'latitude' => 'float',
    'choice' => 'bool',
    'images' => 'string',
];
$map = [
    'obj_id' => 'objId',
    'addr_print' => 'addrPrint',
    'obj_type_name' => 'objTypeName',
    'prf_name' => 'prfName',
    'addr_whole_nmb' => 'addrWholeNmb',
    'addr_build' => 'addrBuild',
    'addr_letter' => 'addrLetter',
    'flat_number' => 'flatNumber',
    'obj_kd_nmb' => 'objKdNmb',
    'reg_name' => 'regName',
    'obj_area' => 'objArea',
    'obj_reestr_num' => 'objReestrNum',
    'obj_reestr_num_date' => 'objReestrNumDate',
    'pravo' => 'pravo',
    'purpose_name' => 'purposeName',
    'encumbrance_name' => 'encumbranceName',
    'city_part' => 'cityPart',
    'land_cadastr_cost' => 'landCadastrCost',
    'book_cost_value' => 'bookCostValue',
    'residual_cost_value' => 'residualCostValue',
    'residual_cost_date' => 'residualCostDate',
    'details' => 'details',
];
$data = $commimParser->getData();
$count = $data->filtered;
$offset = 20;
print_r('Найдено: ' . $count . PHP_EOL);
$totalPages = round($count / $offset);
print_r('Всего страниц: ' . $totalPages . PHP_EOL);
$page = 8990;
$items = $data->items;
do {
    print_r('Страница: ' . $page . '/' . $totalPages . PHP_EOL);
    foreach ($items as $item) {
        $row = [];
        foreach ($item as $key => $value) {
            $row[] = $value ?? ' ';
        }
        $table[] = $row;
    }
    $data = $commimParser->getData(++$page);
    $items = $data->items;
    try {
        foreach ($items as $index => $row) {
            $fieldIndex = 0;
            $newRow = [];
            foreach ($header as $key => $type) {
                $field = $map[$key];
                switch ($type) {
                    case 'int':
                        $newRow[$fieldIndex] = (int) $row->$field;
                        break;
                    case 'float':
                        $newRow[$fieldIndex] = (float) str_replace(',', '.', $row->$field);
                        break;
                    case 'bool':
                        $newRow[$fieldIndex] = (bool) $row->$field;
                        break;
                    case 'string':
                    default:
                        $newRow[$fieldIndex] = (string) $row->$field;
                        break;
                }

                $fieldIndex++;
            }
            $item = array_combine(array_keys($header), $newRow);
            $commimAddress->add($item);
        }
    } catch (Throwable $exception) {
        print_r($exception->getMessage());
    }
} while (!empty($items));


$indices = array_flip($header);

array_shift($table);