✨ Features: - Migrated ALL files to new S3 structure (Projects, Contacts, Accounts, HelpDesk, Invoice, etc.) - Added Nextcloud folder buttons to ALL modules - Fixed Nextcloud editor integration - WebSocket server for real-time updates - Redis Pub/Sub integration - File path manager for organized storage - Redis caching for performance (Functions.php) 📁 New Structure: Documents/Project/ProjectName_ID/file_docID.ext Documents/Contacts/FirstName_LastName_ID/file_docID.ext Documents/Accounts/AccountName_ID/file_docID.ext 🔧 Technical: - FilePathManager for standardized paths - S3StorageService integration - WebSocket server (Node.js + Docker) - Redis cache for getBasicModuleInfo() - Predis library for Redis connectivity 📝 Scripts: - Migration scripts for all modules - Test pages for WebSocket/SSE/Polling - Documentation (MIGRATION_*.md, REDIS_*.md) 🎯 Result: 15,000+ files migrated successfully!
69 lines
1.6 KiB
PHP
69 lines
1.6 KiB
PHP
<?php
|
||
/**
|
||
* SSE endpoint с принудительной отправкой данных
|
||
*/
|
||
|
||
// Отключаем буферизацию СРАЗУ
|
||
while (@ob_end_flush());
|
||
|
||
// Настройки SSE
|
||
header('Content-Type: text/event-stream');
|
||
header('Cache-Control: no-cache');
|
||
header('Connection: keep-alive');
|
||
header('Access-Control-Allow-Origin: *');
|
||
header('X-Accel-Buffering: no');
|
||
|
||
// Отключаем лимит времени
|
||
@ini_set('zlib.output_compression', 0);
|
||
@ini_set('implicit_flush', 1);
|
||
set_time_limit(0);
|
||
ignore_user_abort(false);
|
||
|
||
// Отправляем начальный padding для Nginx
|
||
echo str_repeat(' ', 4096);
|
||
echo "\n\n";
|
||
flush();
|
||
|
||
// Функция для отправки события
|
||
function send($type, $data) {
|
||
echo "data: " . json_encode([
|
||
'type' => $type,
|
||
'data' => $data,
|
||
'time' => date('H:i:s')
|
||
]) . "\n\n";
|
||
flush();
|
||
}
|
||
|
||
// Отправляем начальное событие
|
||
send('connected', ['message' => 'Подключено']);
|
||
|
||
// Основной цикл
|
||
$lastBeat = time();
|
||
|
||
while (connection_status() == 0) {
|
||
// Heartbeat каждые 15 секунд
|
||
if (time() - $lastBeat >= 15) {
|
||
send('heartbeat', ['time' => time()]);
|
||
$lastBeat = time();
|
||
}
|
||
|
||
// Проверяем события
|
||
$file = '/tmp/crm_sse_events.json';
|
||
if (file_exists($file) && filesize($file) > 0) {
|
||
$events = json_decode(file_get_contents($file), true);
|
||
if ($events) {
|
||
foreach ($events as $ev) {
|
||
send($ev['type'], $ev['data']);
|
||
}
|
||
file_put_contents($file, '');
|
||
}
|
||
}
|
||
|
||
sleep(1);
|
||
}
|
||
?>
|
||
|
||
|
||
|
||
|