- 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.
111 lines
4.2 KiB
PHP
111 lines
4.2 KiB
PHP
<?php
|
||
/**
|
||
* Fix broken links in Project 390657
|
||
* Removes #realfile from S3 URLs
|
||
*/
|
||
|
||
$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 "=== Исправление битых ссылок проекта 390657 ===\n\n";
|
||
|
||
// Список ID файлов с битыми ссылками
|
||
$broken_file_ids = [390668, 390666, 390664, 390662, 390660];
|
||
|
||
$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()) {
|
||
$current_filename = $row['filename'];
|
||
$s3_key = $row['s3_key'];
|
||
$s3_bucket = $row['s3_bucket'];
|
||
|
||
echo " Текущий URL: " . substr($current_filename, 0, 80) . "...\n";
|
||
|
||
// Проверяем, есть ли #realfile в URL
|
||
if (strpos($current_filename, '#realfile') !== false) {
|
||
// Убираем #realfile из URL
|
||
$fixed_filename = str_replace('#realfile', '', $current_filename);
|
||
|
||
echo " Исправленный URL: " . substr($fixed_filename, 0, 80) . "...\n";
|
||
|
||
// Проверяем доступность исправленного файла
|
||
$headers = @get_headers($fixed_filename, 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_390657_backup_' . $notesid . '_' . date('Ymd_His') . '.json';
|
||
$backup = [
|
||
'notesid' => $notesid,
|
||
'title' => $row['title'],
|
||
'original_filename' => $current_filename,
|
||
'fixed_filename' => $fixed_filename,
|
||
'timestamp' => date('c')
|
||
];
|
||
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', $fixed_filename, $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 " ℹ️ Файл не содержит #realfile\n";
|
||
}
|
||
|
||
} else {
|
||
echo " ❌ Файл с ID $notesid не найден\n";
|
||
$error_count++;
|
||
}
|
||
|
||
$stmt->close();
|
||
echo "---\n";
|
||
}
|
||
|
||
echo "\n=== РЕЗУЛЬТАТ ===\n";
|
||
echo "Исправлено файлов: $fixed_count\n";
|
||
echo "Ошибок: $error_count\n";
|
||
echo "Всего обработано: " . count($broken_file_ids) . "\n";
|
||
|
||
$mysqli->close();
|
||
echo "\n=== Исправление завершено ===\n";
|
||
?>
|
||
|