- 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.
115 lines
4.3 KiB
PHP
115 lines
4.3 KiB
PHP
<?php
|
||
/**
|
||
* Fix broken links in Project 391604
|
||
*/
|
||
|
||
$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 "=== Исправление битых ссылок проекта 391604 ===\n\n";
|
||
|
||
// Список ID файлов с битыми ссылками
|
||
$broken_file_ids = [391613, 391611, 391609];
|
||
|
||
$fixed_count = 0;
|
||
$error_count = 0;
|
||
|
||
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 " Текущий URL: " . substr($current_filename, 0, 80) . "...\n";
|
||
|
||
// Создаем правильный URL с правильной кодировкой S3 ключа
|
||
$encoded_key = implode('/', array_map('rawurlencode', explode('/', $s3_key)));
|
||
$correct_url = "https://s3.twcstorage.ru/$s3_bucket/$encoded_key";
|
||
|
||
echo " Правильный URL: " . substr($correct_url, 0, 80) . "...\n";
|
||
|
||
// Проверяем доступность правильного URL
|
||
$headers = @get_headers($correct_url, 1);
|
||
if ($headers && strpos($headers[0], '200') !== false) {
|
||
echo " ✅ Файл доступен\n";
|
||
|
||
// Создаем резервную копию
|
||
$backup_dir = $ROOT . 'crm_extensions/file_storage/backups/';
|
||
if (!is_dir($backup_dir)) mkdir($backup_dir, 0755, true);
|
||
|
||
$backup_file = $backup_dir . 'fix_391604_backup_' . $notesid . '_' . date('Ymd_His') . '.json';
|
||
$backup = [
|
||
'notesid' => $notesid,
|
||
'title' => $row['title'],
|
||
'original_filename' => $current_filename,
|
||
'corrected_filename' => $correct_url,
|
||
's3_key' => $s3_key,
|
||
's3_bucket' => $s3_bucket,
|
||
'timestamp' => date('c'),
|
||
'reason' => 'Fixed S3 URL encoding for #realfile files in project 391604'
|
||
];
|
||
file_put_contents($backup_file, json_encode($backup, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
||
|
||
// Обновляем URL в базе данных
|
||
$update_query = "UPDATE vtiger_notes SET filename = ? WHERE notesid = ?";
|
||
$update_stmt = $mysqli->prepare($update_query);
|
||
$update_stmt->bind_param('si', $correct_url, $notesid);
|
||
|
||
if ($update_stmt->execute()) {
|
||
echo " ✅ URL исправлен в базе данных\n";
|
||
$fixed_count++;
|
||
} else {
|
||
echo " ❌ Ошибка обновления БД: " . $update_stmt->error . "\n";
|
||
$error_count++;
|
||
}
|
||
$update_stmt->close();
|
||
|
||
} else {
|
||
echo " ❌ Файл недоступен даже с правильной кодировкой\n";
|
||
$error_count++;
|
||
}
|
||
|
||
} else {
|
||
echo " ❌ Файл не найден в БД\n";
|
||
$error_count++;
|
||
}
|
||
|
||
$stmt->close();
|
||
echo "---\n";
|
||
}
|
||
|
||
echo "\n=== РЕЗУЛЬТАТ ===\n";
|
||
echo "✅ Исправлено файлов: $fixed_count\n";
|
||
echo "❌ Ошибок: $error_count\n";
|
||
echo "📊 Всего обработано: " . count($broken_file_ids) . "\n";
|
||
|
||
if ($fixed_count > 0) {
|
||
echo "\n🎉 Битые ссылки в проекте 391604 исправлены!\n";
|
||
echo "📁 Резервные копии сохранены в: crm_extensions/file_storage/backups/\n";
|
||
}
|
||
|
||
$mysqli->close();
|
||
echo "\n=== Исправление завершено ===\n";
|
||
?>
|
||
|