Files
crm.clientright.ru/crm_extensions/file_storage/check_document.php

91 lines
3.2 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 Document 391552
*/
$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 "=== Checking Document 391552 ===\n\n";
$query = "SELECT notesid, filename, filesize, filetype, filelocationtype, s3_key, s3_bucket, s3_etag
FROM vtiger_notes
WHERE notesid = 391552";
$result = $mysqli->query($query);
if ($result && $result->num_rows > 0) {
$row = $result->fetch_assoc();
echo "Document ID: " . $row['notesid'] . "\n";
echo "Filename: " . $row['filename'] . "\n";
echo "File size: " . $row['filesize'] . " bytes\n";
echo "File type: " . $row['filetype'] . "\n";
echo "Location type: " . ($row['filelocationtype'] ?: 'NULL') . "\n";
echo "S3 Key: " . ($row['s3_key'] ?: 'NULL') . "\n";
echo "S3 Bucket: " . ($row['s3_bucket'] ?: 'NULL') . "\n";
echo "S3 ETag: " . ($row['s3_etag'] ?: 'NULL') . "\n\n";
// Analysis
if ($row['filelocationtype'] === 'E') {
echo "✅ SUCCESS: Document is stored in S3 (External)\n";
if (!empty($row['s3_key'])) {
echo "✅ S3 metadata is present\n";
// Check if filename is S3 URL
if (strpos($row['filename'], 'https://s3.twcstorage.ru') !== false) {
echo "✅ Filename contains S3 URL\n";
} else {
echo "⚠️ Filename does not contain S3 URL\n";
}
} else {
echo "❌ S3 metadata is missing\n";
}
} elseif ($row['filelocationtype'] === 'I') {
echo "⚠️ Document is stored locally (Internal)\n";
if (!empty($row['s3_key'])) {
echo "⚠️ Has S3 metadata but not switched to External\n";
} else {
echo " No S3 metadata (normal for local files)\n";
}
} else {
echo "❓ Unknown location type: " . ($row['filelocationtype'] ?: 'NULL') . "\n";
}
} else {
echo "❌ Document 391552 not found in vtiger_notes\n";
}
// Check recent documents for comparison
echo "\n=== Recent Documents (for comparison) ===\n";
$recent_query = "SELECT notesid, LEFT(filename, 40) as filename_short, filetype, filelocationtype,
CASE WHEN s3_key IS NOT NULL THEN 'YES' ELSE 'NO' END as has_s3_key
FROM vtiger_notes
WHERE notesid >= 391550
ORDER BY notesid DESC
LIMIT 5";
$recent_result = $mysqli->query($recent_query);
if ($recent_result && $recent_result->num_rows > 0) {
echo "ID\t\tType\t\tLocation\tS3\tFilename\n";
echo "---------------------------------------------------------------\n";
while ($row = $recent_result->fetch_assoc()) {
printf("%-8s\t%-8s\t%-8s\t%-3s\t%s\n",
$row['notesid'],
$row['filetype'] ?: 'N/A',
$row['filelocationtype'] ?: 'NULL',
$row['has_s3_key'],
$row['filename_short']);
}
}
$mysqli->close();
echo "\n=== Check Complete ===\n";