403Webshell
Server IP : 188.114.96.3  /  Your IP : 216.73.216.143
Web Server : Apache
System : Linux sv058.home.net.pl 6.8.2 husak_dirty_pages_fix #1 SMP PREEMPT_DYNAMIC Tue Apr 2 22:06:51 CEST 2024 x86_64
User :  ( 3194769)
PHP Version : 8.5.12
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /polana/includes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /polana/includes/seasonal_visual.php
<?php
declare(strict_types=1);

function visual_rotation_mode(): string
{
    return setting('visual_rotation_mode', 'pot');
}

function visual_motion_enabled(): bool
{
    return setting('visual_motion_enabled', '1') !== '0';
}

function visual_parallax_enabled(): bool
{
    return setting('visual_parallax_enabled', '1') !== '0';
}

function visual_motion_speed(): int
{
    $speed = (int)setting('visual_motion_speed', '16');
    return max(10, min($speed, 30));
}

function seasonal_visual_root(): string
{
    return dirname(__DIR__) . '/assets/img/seasonal';
}

function seasonal_visual_supported_extensions(): array
{
    return ['jpg', 'jpeg', 'png', 'webp', 'avif', 'gif', 'mp4', 'webm'];
}

function seasonal_visual_is_video(string $path): bool
{
    return in_array(strtolower(pathinfo($path, PATHINFO_EXTENSION)), ['mp4', 'webm'], true);
}

function seasonal_visual_context_dirs(string $context): array
{
    $context = trim($context);

    return array_values(array_filter([
        seasonal_visual_root() . '/' . $context,
        seasonal_visual_root() . '/common',
    ]));
}

function seasonal_visual_candidates(string $context): array
{
    $files = [];

    foreach (seasonal_visual_context_dirs($context) as $dir) {
        if (!is_dir($dir)) {
            continue;
        }

        foreach (seasonal_visual_supported_extensions() as $ext) {
            foreach (glob($dir . '/*.' . $ext) ?: [] as $path) {
                if (is_file($path)) {
                    $files[] = $path;
                }
            }

            foreach (glob($dir . '/*.' . strtoupper($ext)) ?: [] as $path) {
                if (is_file($path)) {
                    $files[] = $path;
                }
            }
        }
    }

    $files = array_values(array_unique($files));
    sort($files, SORT_NATURAL | SORT_FLAG_CASE);

    return $files;
}

function seasonal_visual_public_url(string $absolutePath): string
{
    $absolutePath = str_replace('\\', '/', $absolutePath);
    $assetsRoot = str_replace('\\', '/', dirname(__DIR__) . '/assets/');
    $relative = ltrim(str_replace($assetsRoot, '', $absolutePath), '/');

    return asset_v($relative);
}

function seasonal_visual_seed(string $mode, string $context): string
{
    $context = trim($context) ?: 'common';

    if ($mode === 'month') {
        return date('Y-m') . ':' . $context;
    }

    if ($mode === 'quarter') {
        $quarter = (int)floor(((int)date('n') - 1) / 3) + 1;
        return date('Y') . '-Q' . $quarter . ':' . $context;
    }

    return microtime(true) . ':' . $context . ':' . random_int(1000, 999999);
}

function seasonal_visual_pick(string $context): ?array
{
    $mode = visual_rotation_mode();

    if (in_array($mode, ['pot', 'seasonal'], true)) {
        return null;
    }

    $candidates = seasonal_visual_candidates($context);

    if (!$candidates) {
        return null;
    }

    if ($mode === 'random') {
        $index = random_int(0, count($candidates) - 1);
    } else {
        $seed = seasonal_visual_seed($mode, $context);
        $index = abs((int)crc32($seed)) % count($candidates);
    }

    $path = $candidates[$index];

    return [
        'path' => $path,
        'url' => seasonal_visual_public_url($path),
        'name' => pathinfo($path, PATHINFO_FILENAME),
        'context' => $context,
        'mode' => $mode,
        'count' => count($candidates),
        'index' => $index,
        'is_video' => seasonal_visual_is_video($path),
    ];
}

function seasonal_visual_counts(): array
{
    $contexts = ['common', 'home', 'menu', 'splash', 'home_feature', 'menu_splash'];
    $out = [];

    foreach ($contexts as $context) {
        $out[$context] = count(seasonal_visual_candidates($context));
    }

    return $out;
}

function render_showcase_visual(string $context, string $class = '', string $alt = ''): void
{
    if (visual_rotation_mode() === 'seasonal') {
        render_seasonal_illustration($context, $class);
        return;
    }

    $picked = seasonal_visual_pick($context);

    if ($picked) {
        $motionClass = 'motion-' . (($picked['index'] % 3) + 1);
        $motionEnabled = visual_motion_enabled();
        $parallaxEnabled = visual_parallax_enabled();
        $speed = visual_motion_speed();
        ?>
        <figure
            class="showcase-visual showcase-visual-image <?= e($class) ?> <?= $motionEnabled ? 'motion-enabled' : 'motion-disabled' ?> <?= $picked['is_video'] ? 'has-video' : 'has-image' ?>"
            data-seasonal-visual
            data-parallax="<?= $parallaxEnabled ? '1' : '0' ?>"
            style="--motion-duration: <?= (int)$speed ?>s"
        >
            <div class="showcase-visual-frame">
                <?php if ($picked['is_video']): ?>
                    <video
                        class="seasonal-media seasonal-video"
                        autoplay
                        muted
                        loop
                        playsinline
                        preload="metadata"
                        aria-label="<?= e($alt !== '' ? $alt : setting('site_name', APP_NAME)) ?>"
                    >
                        <source src="<?= e($picked['url']) ?>">
                    </video>
                <?php else: ?>
                    <img
                        class="seasonal-media <?= e($motionClass) ?>"
                        src="<?= e($picked['url']) ?>"
                        alt="<?= e($alt !== '' ? $alt : setting('site_name', APP_NAME)) ?>"
                        loading="eager"
                        decoding="async"
                    >
                <?php endif; ?>
            </div>
        </figure>
        <?php
        return;
    }

    render_pot_visual($class);
}

Youez - 2016 - github.com/yon3zu
LinuXploit