(int)$_SESSION['timeout']) {
return false;
}
return true;
}
/**
* تنظيف المحتوى من الـ HTML مع الحفاظ على فواصل الأسطر
*/
public function cleanContent(string $content): string
{
$content = nl2br($content);
$content = preg_replace('#(?: \s*?){2,}#', ' ', $content);
return trim(strip_tags($content));
}
public function htmlToText(string $content): string
{
return trim(strip_tags($content));
}
/**
* إزالة وسوم معينة من HTML لكن ترك الباقي مصقولاً
*/
public function cleanHtml(string $content): string
{
return trim(preg_replace(
'/<\/?(figure|table|tbody|thead|tr|td)([^>]*)>/i',
'',
$content
));
}
function sanitizeHtml(string $html): string
{
// قائمة الوسوم المسموحة
$allowedTags = '