forked from GithubBackups/vichan
commit
3781a10776
@ -12,10 +12,10 @@ defined('TINYBOARD') or exit;
|
|||||||
class Cache {
|
class Cache {
|
||||||
private static function buildCache(): CacheDriver {
|
private static function buildCache(): CacheDriver {
|
||||||
global $config;
|
global $config;
|
||||||
// Determine if Redis is configured via environment variables
|
// Determine if the cache engine is configured via environment variables.
|
||||||
getenv('VICHAN_CACHE_ENGINE') && $config['cache']['enabled'] = getenv('VICHAN_CACHE_ENGINE');
|
$engine = \getenv('VICHAN_CACHE_ENGINE') ?: $config['cache']['enabled'];
|
||||||
|
|
||||||
switch ($config['cache']['enabled']) {
|
switch ($engine) {
|
||||||
case 'memcached':
|
case 'memcached':
|
||||||
return new MemcachedCacheDriver(
|
return new MemcachedCacheDriver(
|
||||||
$config['cache']['prefix'],
|
$config['cache']['prefix'],
|
||||||
|
|||||||
@ -142,7 +142,8 @@ class Tinyboard extends Twig\Extension\AbstractExtension
|
|||||||
new Twig\TwigFunction('ratio', 'twig_ratio_function'),
|
new Twig\TwigFunction('ratio', 'twig_ratio_function'),
|
||||||
new Twig\TwigFunction('secure_link_confirm', 'twig_secure_link_confirm'),
|
new Twig\TwigFunction('secure_link_confirm', 'twig_secure_link_confirm'),
|
||||||
new Twig\TwigFunction('secure_link', 'twig_secure_link'),
|
new Twig\TwigFunction('secure_link', 'twig_secure_link'),
|
||||||
new Twig\TwigFunction('link_for', 'link_for')
|
new Twig\TwigFunction('link_for', 'link_for'),
|
||||||
|
new Twig\TwigFunction('check_container', 'twig_check_container')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,18 +227,18 @@ function twig_secure_link($href) {
|
|||||||
return $href . '/' . make_secure_link_token($href);
|
return $href . '/' . make_secure_link_token($href);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /*
|
/*
|
||||||
// * ====================
|
* ====================
|
||||||
// * Container Detection
|
* Container Detection
|
||||||
// * ===================
|
* ===================
|
||||||
// */
|
*/
|
||||||
|
|
||||||
function twig_check_container() {
|
function twig_check_container() {
|
||||||
global $config;
|
static $is_container = null;
|
||||||
$isDocker = is_file("/.dockerenv") || is_file("/run/.containerenv");
|
if ($is_container === null) {
|
||||||
$isKubernetes = is_file("/var/run/secrets/kubernetes.io/serviceaccount/namespace");
|
$is_docker = \is_file("/.dockerenv") || \is_file("/run/.containerenv");
|
||||||
$config['is_container'] = $isDocker || $isKubernetes ? true : false;
|
$is_kubernetes = \is_file("/var/run/secrets/kubernetes.io/serviceaccount/namespace");
|
||||||
$config['is_docker'] = $isDocker;
|
$is_container = $is_docker || $is_kubernetes;
|
||||||
$config['is_kubernetes'] = $isKubernetes;
|
}
|
||||||
return $config['is_container'];
|
return $is_container;
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user