$section) { foreach ($section as $key => $value) { self::setConfig($header, $key, $value); } } foreach ($customConfig as $header => $section) { foreach ($section as $key => $value) { self::setConfig($header, $key, $value); } } if (file_exists(__DIR__ . '/../DEBUG')) { // The debug mode has been moved to config. Preserve existing installs which has this DEBUG file. self::setConfig('system', 'enable_debug_mode', true); $debug = trim(file_get_contents(__DIR__ . '/../DEBUG')); if ($debug) { self::setConfig('system', 'debug_mode_whitelist', explode("\n", str_replace("\r", '', $debug))); } } if (file_exists(__DIR__ . '/../whitelist.txt')) { $enabledBridges = trim(file_get_contents(__DIR__ . '/../whitelist.txt')); if ($enabledBridges === '*') { self::setConfig('system', 'enabled_bridges', ['*']); } else { self::setConfig('system', 'enabled_bridges', array_filter(array_map('trim', explode("\n", $enabledBridges)))); } } foreach ($env as $envName => $envValue) { $nameParts = explode('_', $envName); if ($nameParts[0] === 'RSSBRIDGE') { if (count($nameParts) < 3) { // Invalid env name continue; } // The variable is named $header but it's actually the section in config.ini.php $header = $nameParts[1]; // Recombine the key if it had multiple underscores $key = implode('_', array_slice($nameParts, 2)); $key = strtolower($key); // Handle this specifically because it's an array if ($key === 'enabled_bridges') { $envValue = explode(',', $envValue); $envValue = array_map('trim', $envValue); } if ($envValue === 'true' || $envValue === 'false') { $envValue = filter_var($envValue, FILTER_VALIDATE_BOOLEAN); } self::setConfig($header, $key, $envValue); } } if (Debug::isEnabled()) { self::setConfig('cache', 'type', 'array'); } if (!is_array(self::getConfig('system', 'enabled_bridges'))) { self::throwConfigError('system', 'enabled_bridges', 'Is not an array'); } if ( !is_string(self::getConfig('system', 'timezone')) || !in_array(self::getConfig('system', 'timezone'), timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)) ) { self::throwConfigError('system', 'timezone'); } if (!is_bool(self::getConfig('system', 'enable_debug_mode'))) { self::throwConfigError('system', 'enable_debug_mode', 'Is not a valid Boolean'); } if (!is_array(self::getConfig('system', 'debug_mode_whitelist') ?: [])) { self::throwConfigError('system', 'debug_mode_whitelist', 'Is not a valid array'); } if (!is_string(self::getConfig('proxy', 'url'))) { self::throwConfigError('proxy', 'url', 'Is not a valid string'); } if (!is_bool(self::getConfig('proxy', 'by_bridge'))) { self::throwConfigError('proxy', 'by_bridge', 'Is not a valid Boolean'); } if (!is_string(self::getConfig('proxy', 'name'))) { /** Name of the proxy server */ self::throwConfigError('proxy', 'name', 'Is not a valid string'); } if (!is_string(self::getConfig('cache', 'type'))) { self::throwConfigError('cache', 'type', 'Is not a valid string'); } if (!is_bool(self::getConfig('cache', 'custom_timeout'))) { self::throwConfigError('cache', 'custom_timeout', 'Is not a valid Boolean'); } if (!is_bool(self::getConfig('authentication', 'enable'))) { self::throwConfigError('authentication', 'enable', 'Is not a valid Boolean'); } if (!is_string(self::getConfig('authentication', 'username'))) { self::throwConfigError('authentication', 'username', 'Is not a valid string'); } if (!is_string(self::getConfig('authentication', 'password'))) { self::throwConfigError('authentication', 'password', 'Is not a valid string'); } if ( !empty(self::getConfig('admin', 'email')) && !filter_var(self::getConfig('admin', 'email'), FILTER_VALIDATE_EMAIL) ) { self::throwConfigError('admin', 'email', 'Is not a valid email address'); } if (!is_bool(self::getConfig('admin', 'donations'))) { self::throwConfigError('admin', 'donations', 'Is not a valid Boolean'); } if (!is_string(self::getConfig('error', 'output'))) { self::throwConfigError('error', 'output', 'Is not a valid String'); } if (!in_array(self::getConfig('error', 'output'), ['feed', 'http', 'none'])) { self::throwConfigError('error', 'output', 'Invalid output'); } if ( !is_numeric(self::getConfig('error', 'report_limit')) || self::getConfig('error', 'report_limit') < 1 ) { self::throwConfigError('admin', 'report_limit', 'Value is invalid'); } } public static function getConfig(string $section, string $key, $default = null) { if (self::$config === []) { throw new \Exception('Config has not been loaded'); } return self::$config[strtolower($section)][strtolower($key)] ?? $default; } /** * @internal Please avoid usage */ public static function setConfig(string $section, string $key, $value): void { self::$config[strtolower($section)][strtolower($key)] = $value; } public static function getVersion() { $headFile = __DIR__ . '/../.git/HEAD'; if (@is_readable($headFile)) { $revisionHashFile = '.git/' . substr(file_get_contents($headFile), 5, -1); $parts = explode('/', $revisionHashFile); if (isset($parts[3])) { $branchName = $parts[3]; if (file_exists($revisionHashFile)) { return sprintf('%s (git.%s.%s)', self::VERSION, $branchName, substr(file_get_contents($revisionHashFile), 0, 7)); } } } return self::VERSION; } private static function throwConfigError($section, $key, $message = '') { throw new \Exception("Config [$section] => [$key] is invalid. $message"); } } value='feat/fonts-granular-preload'>feat/fonts-granular-preload Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/assets/social (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2022-01-11Fix renderer-solid (fix #2336) (#2359)Gravatar toSayNothing 2-1/+6
2022-01-11[ci] collect statsGravatar FredKSchott 1-0/+1
2022-01-10Use smooth scrolling with reduced motion has no preference (#2355)Gravatar Jonathan Neal 1-3/+7
2022-01-10move changeset to run after build, no test required (#2341)Gravatar Fred K. Schott 1-2/+2
2022-01-10Note that Astro also supports `<Fragment>` syntax (#2354)Gravatar Zade Viggers 1-16/+18
2022-01-10smooth scroll behavior property added (#2256)Gravatar Divyamrit 1-1/+3
2022-01-10Add Astro Blog RSS feed (#2301)Gravatar Rafael Bardini 2-3/+20
2022-01-10Update Cloudflare Pages guide (#2345)Gravatar Jacob Rask 1-2/+2
2022-01-10[ci] update lockfile (#2351)Gravatar Fred K. Schott 1-116/+116
2022-01-10Update instructions for the monorepo (#2274)Gravatar Caleb Jasik 1-5/+12
2022-01-10Fix Astro Preview Pathing Issues (#2338)Gravatar Jonathan Neal 5-144/+150
2022-01-10[ci] collect statsGravatar FredKSchott 1-0/+1
2022-01-09[ci] collect statsGravatar FredKSchott 1-0/+1
2022-01-08[ci] update lockfile (#2344)Gravatar Fred K. Schott 1-33/+33
2022-01-08Fix sitemap.xml page urls (#2335)Gravatar Jonathan Neal 4-4/+8
2022-01-08[ci] collect statsGravatar FredKSchott 1-0/+1
2022-01-07Create .git-blame-ignore-revs (#2254)Gravatar Jonathan Neal 2-0/+8
2022-01-07Fix issue with plugins running twice in dev and build (#2323)Gravatar Jonathan Neal 2-2/+5
2022-01-07[ci] yarn formatGravatar matthewp 1-8/+8
2022-01-07[ci] release (#2339)astro@0.22.9Gravatar github-actions[bot] 28-39/+40
2022-01-07[ci] yarn formatGravatar matthewp 3-7/+8
2022-01-07Handle loading the Code package in the static build (#2337)Gravatar Matthew Phillips 8-4/+87
2022-01-07[ci] update lockfile (#2334)Gravatar Fred K. Schott 1-154/+154
2022-01-07[ci] yarn formatGravatar matthewp 1-8/+8
2022-01-07[ci] release (#2333)astro@0.22.8Gravatar github-actions[bot] 28-39/+40
2022-01-07[ci] collect statsGravatar FredKSchott 1-0/+1
2022-01-06[ci] yarn formatGravatar matthewp 4-54/+54
2022-01-06[ci] update lockfile (#2327)Gravatar Fred K. Schott 1-58/+64
2022-01-06Fix subpath support regressions (#2330)Gravatar Matthew Phillips 12-22/+566
2022-01-06[ci] yarn formatGravatar natemoo-re 1-2/+2
2022-01-06Added "IntelliSense for TypeScript" (#2326)astro@0.22.7Gravatar Morritz 1-0/+17
2022-01-06[ci] collect statsGravatar FredKSchott 1-0/+1
2022-01-06[ci] yarn formatGravatar FredKSchott 1-8/+8
2022-01-05[ci] release (#2320)Gravatar github-actions[bot] 31-54/+46
2022-01-05chore: update compiler (#2324)Gravatar Nate Moore 3-5/+10