Files
crm.clientright.ru/check_project_398027.php

159 lines
6.7 KiB
PHP
Raw Permalink Normal View History

<?php
/**
* Проверка документов проекта 398027
*/
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once '/var/www/fastuser/data/www/crm.clientright.ru/vendor/autoload.php';
$config = require '/var/www/fastuser/data/www/crm.clientright.ru/crm_extensions/file_storage/config.php';
$projectId = 398027;
$s3Bucket = $config['s3']['bucket'];
$projectPrefix = 'crm2/CRM_Active_Files/Documents/Project/Храмов_ООО_НЕТОЛОГИЯ_398027/';
// Документы проекта из БД
$documents = [
398030 => [
'current_path' => 'crm2/CRM_Active_Files/Documents/398030/8_Договора_оказание_услуг_11-14-2025-16-00-51_Храмов_1_CTP#realfile.pdf',
'should_be' => $projectPrefix . '8_Договора_оказание_услуг_398030.pdf',
],
398032 => [
'current_path' => 'crm2/CRM_Active_Files/Documents/398032/9_Подтверждение_оплаты_пооговору_11-14-2025-16-00-03_Храмов_1_CTP#realfile.pdf',
'should_be' => $projectPrefix . '9_Подтверждение_оплаты_пооговору_398032.pdf',
],
398034 => [
'current_path' => 'crm2/CRM_Active_Files/Documents/398034/10_2_Скрин_личногоабинетастца_и_программа_обучения_11-14-2025-15-47-26_Храмов_41_CTP#realfile.pdf',
'should_be' => $projectPrefix . '10_2_Скрин_личногоабинетастца_и_программа_обучения_398034.pdf',
],
398036 => [
'current_path' => 'crm2/CRM_Active_Files/Documents/398036/10_1_Скрин_личногоабинетастца_и_программа_обучения_11-14-2025-15-49-59_Храмов_1_CTP#realfile.pdf',
'should_be' => $projectPrefix . '10_1_Скрин_личногоабинетастца_и_программа_обучения_398036.pdf',
],
398038 => [
'current_path' => 'crm2/CRM_Active_Files/Documents/398038/Прочиеокументы_11-14-2025-16-06-07_Храмов_3_CTP#realfile.pdf',
'should_be' => $projectPrefix . рочиеокументы_398038.pdf',
],
398040 => [
'current_path' => 'crm2/CRM_Active_Files/Documents/398040/7_zayavlenie_potrebitelya_Hramov.pdf',
'should_be' => $projectPrefix . '7_заявление_потребителя_398040.pdf',
],
398063 => [
'current_path' => 'crm2/CRM_Active_Files/Documents/398063/napravleniya_pretenzii.pdf',
'should_be' => $projectPrefix . 'Направление_претензии_398063.pdf',
],
398584 => [
'current_path' => 'crm2/CRM_Active_Files/Documents/Project/Храмов_ООО_НЕТОЛОГИЯ_398027/8_Договора_оказание_услуг_398584.pdf',
'should_be' => $projectPrefix . '8_Договора_оказание_услуг_398584.pdf',
],
399067 => [
'current_path' => 'clientright/0/1763997676315.pdf',
'should_be' => $projectPrefix . окумент_399067.pdf',
],
399068 => [
'current_path' => 'clientright/0/1763997790309.pdf',
'should_be' => $projectPrefix . окумент_399068.pdf',
],
];
echo "=== ПРОВЕРКА ДОКУМЕНТОВ ПРОЕКТА {$projectId} ===\n";
echo str_repeat("=", 80) . "\n\n";
try {
$s3Client = new \Aws\S3\S3Client([
'version' => 'latest',
'region' => $config['s3']['region'],
'endpoint' => $config['s3']['endpoint'],
'use_path_style_endpoint' => true,
'credentials' => [
'key' => $config['s3']['key'],
'secret' => $config['s3']['secret'],
],
'suppress_php_deprecation_warning' => true
]);
$stats = [
'total' => count($documents),
'exists_correct' => 0,
'exists_wrong' => 0,
'missing' => 0,
'wrong_place_files' => [],
'missing_files' => [],
];
foreach ($documents as $docId => $paths) {
$currentPath = $paths['current_path'];
$shouldBe = $paths['should_be'];
$filename = basename($shouldBe);
echo "Документ ID: {$docId}\n";
echo " Файл: {$filename}\n";
echo " Текущий путь: {$currentPath}\n";
echo " Должен быть: {$shouldBe}\n";
$existsCurrent = $s3Client->doesObjectExist($s3Bucket, $currentPath);
$existsCorrect = $s3Client->doesObjectExist($s3Bucket, $shouldBe);
if ($existsCorrect) {
$object = $s3Client->headObject(['Bucket' => $s3Bucket, 'Key' => $shouldBe]);
$size = round($object['ContentLength'] / 1024, 2);
echo " ✅ Файл уже в правильном месте (размер: {$size} KB)\n";
$stats['exists_correct']++;
} elseif ($existsCurrent) {
$object = $s3Client->headObject(['Bucket' => $s3Bucket, 'Key' => $currentPath]);
$size = round($object['ContentLength'] / 1024, 2);
echo " ⚠️ Файл существует, но в неправильном месте (размер: {$size} KB)\n";
$stats['exists_wrong']++;
$stats['wrong_place_files'][] = [
'doc_id' => $docId,
'current_path' => $currentPath,
'should_be' => $shouldBe,
];
} else {
echo " ❌ Файл отсутствует\n";
$stats['missing']++;
$stats['missing_files'][] = [
'doc_id' => $docId,
'path' => $currentPath,
];
}
echo "\n";
}
// Итоги
echo str_repeat("=", 80) . "\n";
echo "ИТОГИ:\n";
echo "Всего документов: {$stats['total']}\n";
echo "На месте: {$stats['exists_correct']}\n";
echo "⚠️ В неправильном месте: {$stats['exists_wrong']}\n";
echo "❌ Отсутствуют: {$stats['missing']}\n\n";
if (!empty($stats['wrong_place_files'])) {
echo "ФАЙЛЫ В НЕПРАВИЛЬНОМ МЕСТЕ:\n";
foreach ($stats['wrong_place_files'] as $file) {
echo " - Документ {$file['doc_id']}\n";
echo " От: {$file['current_path']}\n";
echo " К: {$file['should_be']}\n";
}
echo "\n";
}
if (!empty($stats['missing_files'])) {
echo "ОТСУТСТВУЮЩИЕ ФАЙЛЫ:\n";
foreach ($stats['missing_files'] as $file) {
echo " - Документ {$file['doc_id']}: {$file['path']}\n";
}
echo "\n";
}
echo "=== ГОТОВО ===\n";
} catch (Exception $e) {
echo "❌ Ошибка: " . $e->getMessage() . "\n";
exit(1);
}