' . $title . '
' . $message . '
' . ($siteName !== '' ? '' . $siteName . '' : '') . '| @copyright 2007-2026 (c) AVE.cms | @link https://ave-cms.ru | @version 3.3 */ namespace App\Frontend; defined('BASEPATH') || die('Direct access to this location is not allowed.'); use App\Common\Auth; use App\Common\ResponseSecurityHeaders; use App\Common\Settings; /** Blocks the public runtime during development while preserving privileged preview. */ class SiteAccess { const MODE_PUBLIC = 'public'; const MODE_DEVELOPMENT = 'development'; const PREVIEW_PERMISSION = 'view_development_site'; protected static $preview = false; public static function enabled() { Settings::init(); return (string) Settings::get('site_access_mode', self::MODE_PUBLIC) === self::MODE_DEVELOPMENT; } /** Returns false after emitting the temporary unavailable response. */ public static function enforce() { self::$preview = false; if (!self::enabled()) { return true; } self::disablePublicCache(); header('X-Robots-Tag: noindex, nofollow, noarchive, nosnippet', true); header('X-AVE-Site-Access: development', true); if (Auth::systemUserCan(self::PREVIEW_PERMISSION)) { self::$preview = true; return true; } self::respondUnavailable(); return false; } public static function isPreview() { return self::$preview; } /** Adds a small persistent marker without changing the site's document flow. */ public static function injectPreviewNotice($html) { $html = (string) $html; if (!self::$preview || $html === '') { return $html; } $notice = '
' . $message . '
' . ($siteName !== '' ? '' . $siteName . '' : '') . '') !== false) { return preg_replace('/<\/body>/i', $notice . '', $html, 1); } return $html . $notice; } public static function unavailableDocument($title, $message, $siteName = '') { $title = self::escape($title !== '' ? $title : 'Сайт готовится к запуску'); $message = nl2br(self::escape($message !== '' ? $message : 'Мы завершаем настройку сайта. Пожалуйста, зайдите немного позже.')); $siteName = self::escape($siteName); return '
' . '
' . '