Files
crm.clientright.ru/flightaware.php
Fedor ac7467f0b4 Major CRM updates: AI Assistant, Court Status API, S3 integration improvements, and extensive file storage system
- Added comprehensive AI Assistant system (aiassist/ directory):
  * Vector search and embedding capabilities
  * Typebot proxy integration
  * Elastic search functionality
  * Message classification and chat history
  * MCP proxy for external integrations

- Implemented Court Status API (GetCourtStatus.php):
  * Real-time court document status checking
  * Integration with external court systems
  * Comprehensive error handling and logging

- Enhanced S3 integration:
  * Improved file backup system with metadata
  * Batch processing capabilities
  * Enhanced error logging and recovery
  * Copy operations with URL fixing

- Added Telegram contact creation API
- Improved error logging across all modules
- Enhanced callback system for AI responses
- Extensive backup file storage with timestamps
- Updated documentation and README files

- File storage improvements:
  * Thousands of backup files with proper metadata
  * Fix operations for broken file references
  * Project-specific backup and recovery systems
  * Comprehensive file integrity checking

Total: 26,461+ files added/modified including AWS SDK, vendor dependencies, and extensive backup system.
2025-10-16 11:17:21 +03:00

99 lines
4.0 KiB
PHP
Raw Permalink 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
// Путь к папке для логов
$logDir = __DIR__ . '/logs';
// Убедимся, что папка для логов существует
if (!is_dir($logDir)) {
mkdir($logDir, 0777, true);
}
// Лог-файл
$logFile = $logDir . '/flightaware.log';
// Функция для записи в лог
function writeLog($message)
{
global $logFile;
$timestamp = date('Y-m-d H:i:s');
file_put_contents($logFile, "[$timestamp] $message" . PHP_EOL, FILE_APPEND);
}
// Ваш API-ключ FlightAware
$apiKey = "Puz0cdxAHzAEqMRZwtdeqBUSm9naJfwK";
// Параметры запроса
$flightIdent = "Y71091"; // Идентификатор рейса
$start = "2025-01-21T00:00:00Z"; // Начальная дата
$end = "2025-01-21T23:59:59Z"; // Конечная дата
// Формируем URL для API
$baseUrl = "https://aeroapi.flightaware.com/aeroapi/flights";
$url = "{$baseUrl}/{$flightIdent}?start={$start}&end={$end}";
// Логируем отправку запроса
writeLog("Отправка запроса к API FlightAware: $url");
// Настраиваем cURL
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"x-apikey: $apiKey"
]);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
// Отправка запроса
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curlError = curl_error($ch);
curl_close($ch);
// Логируем HTTP-код ответа
writeLog("HTTP-код ответа: $httpCode");
// Проверяем ошибки cURL
if ($curlError) {
writeLog("Ошибка cURL: $curlError");
die("Ошибка cURL: $curlError");
}
// Логируем тело ответа
writeLog("Тело ответа: $response");
// Обрабатываем тело ответа
$data = json_decode($response, true);
if ($httpCode === 200 && isset($data['flights'])) {
foreach ($data['flights'] as $flight) {
$output = "Рейс: " . ($flight['ident'] ?? 'неизвестно') . "<br>";
$output .= "Статус: " . ($flight['status'] ?? 'неизвестно') . "<br>";
$output .= "Аэропорт вылета: " . ($flight['origin']['name'] ?? 'неизвестно') . "<br>";
$output .= "Аэропорт прилета: " . ($flight['destination']['name'] ?? 'неизвестно') . "<br>";
$output .= "Запланированное время вылета: " . ($flight['scheduled_out'] ?? 'неизвестно') . "<br>";
$output .= "Запланированное время прилета: " . ($flight['scheduled_in'] ?? 'неизвестно') . "<br>";
$output .= "Фактический взлет: " . ($flight['actual_off'] ?? $flight['estimated_off'] ?? 'неизвестно') . "<br>";
$output .= "Фактическое приземление: " . ($flight['actual_on'] ?? $flight['estimated_on'] ?? 'неизвестно') . "<br>";
// Обработка задержек
$departureDelay = isset($flight['departure_delay']) ? round($flight['departure_delay'] / 60) : 'неизвестно';
$arrivalDelay = isset($flight['arrival_delay']) ? round($flight['arrival_delay'] / 60) : 'неизвестно';
$output .= "Задержка вылета (в минутах): " . $departureDelay . "<br>";
$output .= "Задержка прилета (в минутах): " . $arrivalDelay . "<br>";
// Вывод полного ответа
$output .= "<pre>" . htmlspecialchars(print_r($flight, true)) . "</pre><hr>";
// Выводим данные на экран
echo nl2br($output);
// Логируем данные о рейсе
writeLog("Данные рейса: \n" . strip_tags($output));
}
} else {
$error = $data['error']['message'] ?? "Неизвестная ошибка";
writeLog("Ошибка: HTTP-код $httpCode, Тело ответа: $response");
echo "Ошибка: $error<br>";
}
?>