Files
crm.clientright.ru/crm_extensions/file_storage/check_s3_access.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

107 lines
4.3 KiB
PHP
Raw 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
/**
* Check S3 access for broken files in project 390657
*/
$ROOT = '/var/www/fastuser/data/www/crm.clientright.ru/';
require_once $ROOT . 'config.inc.php';
// Database connection
$mysqli = new mysqli($dbconfig['db_server'], $dbconfig['db_username'], $dbconfig['db_password'], $dbconfig['db_name']);
if ($mysqli->connect_error) {
die("Connection failed: " . $mysqli->connect_error);
}
$mysqli->set_charset("utf8");
echo "=== Проверка доступа к S3 файлам проекта 390657 ===\n\n";
// Список ID файлов с битыми ссылками
$broken_file_ids = [390668, 390666, 390664, 390662, 390660];
foreach ($broken_file_ids as $notesid) {
echo "Проверка файла ID: $notesid\n";
// Получаем данные файла
$query = "SELECT notesid, title, filename, s3_key, s3_bucket
FROM vtiger_notes
WHERE notesid = ?";
$stmt = $mysqli->prepare($query);
$stmt->bind_param('i', $notesid);
$stmt->execute();
$result = $stmt->get_result();
if ($row = $result->fetch_assoc()) {
$s3_key = $row['s3_key'];
$s3_bucket = $row['s3_bucket'];
$current_filename = $row['filename'];
echo " Название: " . $row['title'] . "\n";
echo " S3 Key: " . $s3_key . "\n";
echo " S3 Bucket: " . $s3_bucket . "\n";
echo " Текущий URL: " . substr($current_filename, 0, 100) . "...\n";
// Пробуем разные варианты URL
$base_url = "https://s3.twcstorage.ru/$s3_bucket/";
// 1. URL с правильной кодировкой
$encoded_key = implode('/', array_map('rawurlencode', explode('/', $s3_key)));
$url1 = $base_url . $encoded_key;
// 2. URL без #realfile
$clean_key = str_replace('#realfile', '', $s3_key);
$encoded_clean_key = implode('/', array_map('rawurlencode', explode('/', $clean_key)));
$url2 = $base_url . $encoded_clean_key;
// 3. URL с простой кодировкой
$url3 = $base_url . urlencode($s3_key);
echo " Тест 1 (правильная кодировка): " . substr($url1, 0, 100) . "...\n";
$headers1 = @get_headers($url1, 1);
if ($headers1 && strpos($headers1[0], '200') !== false) {
echo " ✅ Доступен (200)\n";
} elseif ($headers1 && strpos($headers1[0], '403') !== false) {
echo " ❌ Запрещен (403)\n";
} elseif ($headers1 && strpos($headers1[0], '404') !== false) {
echo "Не найден (404)\n";
} else {
echo " ❓ Неизвестная ошибка: " . ($headers1[0] ?? 'Нет ответа') . "\n";
}
echo " Тест 2 (без #realfile): " . substr($url2, 0, 100) . "...\n";
$headers2 = @get_headers($url2, 1);
if ($headers2 && strpos($headers2[0], '200') !== false) {
echo " ✅ Доступен (200)\n";
} elseif ($headers2 && strpos($headers2[0], '403') !== false) {
echo " ❌ Запрещен (403)\n";
} elseif ($headers2 && strpos($headers2[0], '404') !== false) {
echo "Не найден (404)\n";
} else {
echo " ❓ Неизвестная ошибка: " . ($headers2[0] ?? 'Нет ответа') . "\n";
}
echo " Тест 3 (простая кодировка): " . substr($url3, 0, 100) . "...\n";
$headers3 = @get_headers($url3, 1);
if ($headers3 && strpos($headers3[0], '200') !== false) {
echo " ✅ Доступен (200)\n";
} elseif ($headers3 && strpos($headers3[0], '403') !== false) {
echo " ❌ Запрещен (403)\n";
} elseif ($headers3 && strpos($headers3[0], '404') !== false) {
echo "Не найден (404)\n";
} else {
echo " ❓ Неизвестная ошибка: " . ($headers3[0] ?? 'Нет ответа') . "\n";
}
} else {
echo " ❌ Файл не найден в БД\n";
}
$stmt->close();
echo "---\n";
}
$mysqli->close();
echo "\n=== Проверка завершена ===\n";
?>