function processLinks($text) {
// Экранируем HTML, чтобы предотвратить XSS
$text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8');

// Жирный: текст
$text = preg_replace('/\*\*(.+?)\*\*/', '<b>$1</b>', $text);

// Курсив: *текст*
$text = preg_replace('/\*(.+?)\*/', '<i>$1</i>', $text);

// Ссылки: [текст](url)
$text = preg_replace('/\[(.+?)\]\((https?:\/\/[^\s\)]+)\)/', '<a href="$2" target="_blank" rel="noopener">$1</a>', $text);

// Автоматические ссылки: http://... или https://...
$text = preg_replace(
'/(?<!href=")(https?:\/\/[^\s<>"\'()]+)/',
'<a href="$1" target="_blank" rel="noopener">$1</a>',
$text
);

// Автоматические email: user@domain.com
$text = preg_replace(
'/([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/',
'<a href="mailto:$1">$1</a>',
$text
);

return $text;
}
?>

[file-name 000277_2025-10-29_17-27-35.txt]