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

124 lines
5.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 and fix files in Project 394492 (PDFmaker issues)
*/
$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 "=== Анализ проекта 394492 (PDFmaker проблемы) ===\n\n";
// 1. Ищем файлы, связанные с проектом 394492
echo "1. Поиск файлов проекта 394492...\n";
$query = "SELECT n.notesid, n.title, n.filename, n.filetype, n.filesize, n.s3_key, n.s3_bucket
FROM vtiger_notes n
LEFT JOIN vtiger_senotesrel snr ON n.notesid = snr.notesid
LEFT JOIN vtiger_crmentity ce ON snr.crmid = ce.crmid
WHERE ce.deleted = 0
AND (n.filename LIKE '%394492%' OR ce.crmid = 394492)
AND n.filelocationtype = 'E'
ORDER BY n.notesid DESC";
$result = $mysqli->query($query);
if ($result && $result->num_rows > 0) {
echo "Найдено файлов: " . $result->num_rows . "\n\n";
$broken_files = [];
$total_files = 0;
while ($row = $result->fetch_assoc()) {
$total_files++;
echo "Файл ID: " . $row['notesid'] . "\n";
echo "Название: " . $row['title'] . "\n";
echo "URL: " . substr($row['filename'], 0, 100) . "...\n";
echo "Тип: " . $row['filetype'] . "\n";
echo "Размер: " . $row['filesize'] . " байт\n";
echo "S3 Key: " . ($row['s3_key'] ?: 'NULL') . "\n";
echo "S3 Bucket: " . ($row['s3_bucket'] ?: 'NULL') . "\n";
// Проверяем доступность файла
if (!empty($row['filename']) && strpos($row['filename'], 'https://s3.twcstorage.ru') !== false) {
$headers = @get_headers($row['filename'], 1);
if ($headers && strpos($headers[0], '200') !== false) {
echo "✅ Файл доступен\n";
} else {
echo "❌ Файл недоступен (битая ссылка)\n";
$broken_files[] = $row;
// Определяем тип проблемы
if (strpos($row['filename'], '#realfile') !== false) {
echo "Проблема: #realfile в URL\n";
} elseif (strpos($row['filename'], '%D0%B') !== false) {
echo "Проблема: Обрезанная ссылка\n";
} elseif (preg_match('/[А-Яа-я]/', $row['filename']) && strpos($row['filename'], '%') === false) {
echo "Проблема: Русские символы без кодировки\n";
} elseif (strpos($row['filename'], 'PDFmaker') !== false || strpos($row['title'], 'PDFmaker') !== false) {
echo "Проблема: PDFmaker ошибка\n";
} else {
echo "Проблема: Неправильная кодировка URL\n";
}
}
} else {
echo "⚠️ Нестандартный URL\n";
}
echo "---\n";
}
echo "\n=== СТАТИСТИКА ===\n";
echo "Всего файлов: $total_files\n";
echo "Битых ссылок: " . count($broken_files) . "\n";
if (!empty($broken_files)) {
echo "\n=== БИТЫЕ ФАЙЛЫ ===\n";
foreach ($broken_files as $file) {
echo "ID: " . $file['notesid'] . " - " . $file['title'] . "\n";
echo "URL: " . substr($file['filename'], 0, 80) . "...\n";
echo "S3 Key: " . ($file['s3_key'] ?: 'NULL') . "\n\n";
}
// Сохраняем список битых файлов для исправления
$broken_file_ids = array_column($broken_files, 'notesid');
echo "=== СПИСОК ID ДЛЯ ИСПРАВЛЕНИЯ ===\n";
echo "ID файлов: " . implode(', ', $broken_file_ids) . "\n";
}
} else {
echo "Файлы проекта 394492 не найдены.\n";
// Попробуем найти файлы с PDFmaker в названии или содержании
echo "\n2. Поиск файлов с PDFmaker...\n";
$pdfmaker_query = "SELECT notesid, title, filename, s3_key, s3_bucket
FROM vtiger_notes
WHERE (title LIKE '%PDFmaker%' OR filename LIKE '%PDFmaker%')
AND filelocationtype = 'E'
ORDER BY notesid DESC
LIMIT 10";
$pdfmaker_result = $mysqli->query($pdfmaker_query);
if ($pdfmaker_result && $pdfmaker_result->num_rows > 0) {
echo "Найдено файлов с PDFmaker: " . $pdfmaker_result->num_rows . "\n";
while ($row = $pdfmaker_result->fetch_assoc()) {
echo "ID: " . $row['notesid'] . " - " . $row['title'] . "\n";
echo "URL: " . substr($row['filename'], 0, 80) . "...\n";
echo "---\n";
}
} else {
echo "Файлов с PDFmaker не найдено.\n";
}
}
$mysqli->close();
echo "\n=== Проверка завершена ===\n";
?>