Code
Publisium
A modern, fast CMS for building article and blog websites.
Version history
Version 2.0.0.4 2026-11-07
Browse filesFiles changed6
Lines added+147
Lines removed-27
.htaccess
- Options -Indexes - - RewriteEngine On - RewriteRule ^llms\.txt$ llms.php [L] - RewriteRule ^manifest\.json$ manifest.php [L] - RewriteRule ^sw\.js$ sw.php [L] - RewriteRule ^([a-f0-9]{32})\.txt$ indexnow.php?key=$1 [L] - RewriteCond %{REQUEST_FILENAME} !-d - RewriteRule ^([a-z]{2,3}(?:-[a-z]{2,4})?)/$ index.php?publisium_lang=$1 [L,QSA] - RewriteCond %{REQUEST_FILENAME} !-f - RewriteCond %{REQUEST_FILENAME} !-d - RewriteRule ^([a-z]{2,3}(?:-[a-z]{2,4})?)/(.+\.[A-Za-z0-9]+)$ $2?publisium_lang=$1 [L,QSA] - RewriteCond %{REQUEST_FILENAME} !-f - RewriteCond %{REQUEST_FILENAME} !-d - RewriteRule ^([a-z]{2,3}(?:-[a-z]{2,4})?)/(.+)$ article.php?slug=$2&publisium_lang=$1 [L,QSA] - RewriteCond %{REQUEST_FILENAME} !-f - RewriteCond %{REQUEST_FILENAME} !-d - RewriteRule ^(.+)$ article.php?slug=$1 [L,QSA] + Options -Indexes -MultiViews + DirectoryIndex index.php <IfModule mod_headers.c> - Header set X-Content-Type-Options "nosniff" - Header set X-Frame-Options "SAMEORIGIN" - Header set Referrer-Policy "strict-origin-when-cross-origin" + Header always set X-Content-Type-Options "nosniff" + Header always set X-Frame-Options "SAMEORIGIN" + Header always set Referrer-Policy "strict-origin-when-cross-origin" </IfModule> - <FilesMatch "\.(sql|env|md)$"> + <FilesMatch "(?i)\.(sql|env|md|log|bak|ini|sh)$"> Require all denied </FilesMatch> <Files "cron-update.php"> Require all denied </Files> + + <IfModule mod_rewrite.c> + RewriteEngine On + + RewriteRule (^|/)\.(?!well-known/) - [F,L] + RewriteRule ^(includes|dashboard-actions|dashboard-views|sql|env-template|translations)(/|$) - [F,L] + + RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)$ + RewriteCond %{THE_REQUEST} \s(/[^?\s]*?/)index(\.php)?[?\s] [NC] + RewriteRule ^ %1 [R=301,L] + + RewriteRule ^llms\.txt$ llms.php [L] + RewriteRule ^manifest\.json$ manifest.php [L] + RewriteRule ^sw\.js$ sw.php [L] + RewriteRule ^sitemap\.xml$ sitemap.php [L] + RewriteRule ^([a-f0-9]{32})\.txt$ indexnow.php?key=$1 [L] + + RewriteCond %{REQUEST_FILENAME} -f [OR] + RewriteCond %{REQUEST_FILENAME} -d + RewriteRule ^ - [L] + + RewriteRule ^([a-z]{2,3}(?:-[a-z]{2,4})?)/$ index.php?publisium_lang=$1 [L,QSA] + RewriteRule ^([a-z]{2,3}(?:-[a-z]{2,4})?)/(.+\.[A-Za-z0-9]+)$ $2?publisium_lang=$1 [L,QSA] + RewriteRule ^([a-z]{2,3}(?:-[a-z]{2,4})?)/([^.]+)$ article.php?slug=$2&publisium_lang=$1 [L,QSA] + + RewriteRule ^([^.]+)$ article.php?slug=$1 [L,QSA] + </IfModule>
assets/block-editor.js
⋮ 1482 unchanged lines ⋮ break; } case 'video': { - container.appendChild(this.buildInput('Video link', block.data.src, (val) => update({ src: val }), true)); + container.appendChild(this.buildInput('Video file or link (YouTube, X, Facebook, Instagram, TikTok, Vimeo...)', block.data.src, (val) => update({ src: val }), true)); container.appendChild(this.buildUploadButton('video', (url) => { block.data.src = url; this.render(); })); container.appendChild(this.buildInput('Caption', block.data.caption, (val) => update({ caption: val }))); - if (block.data.src) { + if (block.data.src && !/^https?:\/\/([^/]+\.)?(youtube\.com|youtu\.be|youtube-nocookie\.com|vimeo\.com|x\.com|twitter\.com|facebook\.com|fb\.watch|instagram\.com|tiktok\.com|dailymotion\.com|dai\.ly|twitch\.tv|spotify\.com|soundcloud\.com|streamable\.com)\//i.test(block.data.src)) { const preview = document.createElement('video'); preview.src = block.data.src; preview.controls = true; ⋮ 287 unchanged lines ⋮
assets/site.css
Not shown (binary file or too large to diff).
assets/site.js
⋮ 746 unchanged lines ⋮ }); })(); + (function () { + window.addEventListener('message', function (event) { + if (event.origin !== 'https://platform.twitter.com') { + return; + } + var data = event.data; + if (typeof data === 'string') { + try { data = JSON.parse(data); } catch (e) { return; } + } + var embed = data && data['twttr.embed']; + if (!embed || embed.method !== 'twttr.private.resize' || !embed.params || !embed.params[0]) { + return; + } + var height = parseInt(embed.params[0].height, 10); + if (!height) { + return; + } + document.querySelectorAll('.embed-wrapper.embed-post iframe').forEach(function (frame) { + if (frame.contentWindow === event.source) { + frame.parentNode.style.height = height + 'px'; + } + }); + }); + })(); +
includes/block-editor.php
⋮ 404 unchanged lines ⋮ 'heading3' => '<h3>' . htmlspecialchars((string) ($data['text'] ?? '')) . '</h3>', 'image' => '<figure><img src="' . htmlspecialchars((string) ($data['src'] ?? '')) . '" alt="' . htmlspecialchars((string) ($data['alt'] ?? '')) . '">' . (($data['caption'] ?? '') !== '' ? '<figcaption>' . htmlspecialchars((string) $data['caption']) . '</figcaption>' : '') . '</figure>', - 'video' => '<figure><video controls src="' . htmlspecialchars((string) ($data['src'] ?? '')) . '"></video>' . + 'video' => '<figure>' . self::renderVideo((string) ($data['src'] ?? '')) . (($data['caption'] ?? '') !== '' ? '<figcaption>' . htmlspecialchars((string) $data['caption']) . '</figcaption>' : '') . '</figure>', 'list' => self::renderList($data), 'code' => self::renderCode($data), ⋮ 1 unchanged line ⋮ 'checklist' => self::renderChecklist($data), 'callout' => '<div class="callout callout-' . htmlspecialchars((string) ($data['style'] ?? 'info')) . '">' . htmlspecialchars((string) ($data['text'] ?? '')) . '</div>', - 'embed' => '<div class="embed-wrapper"><iframe src="' . htmlspecialchars((string) ($data['url'] ?? '')) . '" loading="lazy"></iframe></div>', + 'embed' => self::renderEmbed((string) ($data['url'] ?? '')), 'separator' => '<hr>', 'contact_form' => self::renderContactForm(), default => '', }; + } + + private static function renderVideo(string $src): string + { + $embed = self::embedInfo($src); + if ($embed !== null) { + return self::embedFrame($embed); + } + + return '<video controls playsinline preload="metadata" src="' . htmlspecialchars($src) . '"></video>'; + } + + private static function renderEmbed(string $url): string + { + $embed = self::embedInfo($url) ?? ['src' => $url, 'kind' => 'wide']; + + return self::embedFrame($embed); + } + + private static function embedFrame(array $embed): string + { + return '<div class="embed-wrapper embed-' . htmlspecialchars($embed['kind']) . '"><iframe src="' . htmlspecialchars($embed['src']) . '" loading="lazy" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen referrerpolicy="strict-origin-when-cross-origin"></iframe></div>'; + } + + public static function embedInfo(string $url): ?array + { + $url = trim($url); + if (!preg_match('#^https?://#i', $url)) { + return null; + } + $host = strtolower((string) parse_url($url, PHP_URL_HOST)); + $host = preg_replace('/^(www\.|m\.|mobile\.)/', '', $host); + $path = (string) parse_url($url, PHP_URL_PATH); + parse_str((string) parse_url($url, PHP_URL_QUERY), $query); + + if (in_array($host, ['youtube.com', 'youtube-nocookie.com', 'music.youtube.com'], true)) { + $id = ''; + if (isset($query['v'])) { + $id = (string) $query['v']; + } elseif (preg_match('#^/(?:embed|shorts|live|v)/([\w-]{6,})#', $path, $m)) { + $id = $m[1]; + } + if ($id !== '' && preg_match('/^[\w-]+$/', $id)) { + return ['src' => 'https://www.youtube-nocookie.com/embed/' . $id, 'kind' => str_contains($path, '/shorts/') ? 'tall' : 'wide']; + } + return null; + } + if ($host === 'youtu.be' && preg_match('#^/([\w-]{6,})#', $path, $m)) { + return ['src' => 'https://www.youtube-nocookie.com/embed/' . $m[1], 'kind' => 'wide']; + } + if (in_array($host, ['vimeo.com', 'player.vimeo.com'], true) && preg_match('#/(\d+)#', $path, $m)) { + return ['src' => 'https://player.vimeo.com/video/' . $m[1], 'kind' => 'wide']; + } + if (in_array($host, ['x.com', 'twitter.com'], true) && preg_match('#/status(?:es)?/(\d+)#', $path, $m)) { + return ['src' => 'https://platform.twitter.com/embed/Tweet.html?id=' . $m[1] . '&dnt=true', 'kind' => 'post']; + } + if (in_array($host, ['facebook.com', 'fb.watch', 'web.facebook.com'], true)) { + $isVideo = $host === 'fb.watch' || preg_match('#/(videos|watch|reel|share/v|share/r)#', $path . '?' . http_build_query($query)); + $plugin = $isVideo ? 'video.php' : 'post.php'; + return ['src' => 'https://www.facebook.com/plugins/' . $plugin . '?show_text=false&href=' . rawurlencode($url), 'kind' => $isVideo && !str_contains($path, '/reel') ? 'wide' : 'post']; + } + if ($host === 'instagram.com' && preg_match('#^/(p|reel|reels|tv)/([\w-]+)#', $path, $m)) { + return ['src' => 'https://www.instagram.com/' . ($m[1] === 'reels' ? 'reel' : $m[1]) . '/' . $m[2] . '/embed', 'kind' => 'tall']; + } + if ($host === 'tiktok.com' && preg_match('#/video/(\d+)#', $path, $m)) { + return ['src' => 'https://www.tiktok.com/embed/v2/' . $m[1], 'kind' => 'tall']; + } + if (in_array($host, ['dailymotion.com', 'dai.ly'], true) && preg_match('#^/(?:video/)?([a-zA-Z0-9]+)#', $path, $m)) { + return ['src' => 'https://www.dailymotion.com/embed/video/' . $m[1], 'kind' => 'wide']; + } + if ($host === 'twitch.tv' && preg_match('#^/videos/(\d+)#', $path, $m)) { + return ['src' => 'https://player.twitch.tv/?video=' . $m[1] . '&parent=' . rawurlencode((string) ($_SERVER['HTTP_HOST'] ?? 'localhost')), 'kind' => 'wide']; + } + if ($host === 'open.spotify.com' && preg_match('#^/(track|album|playlist|episode|show)/(\w+)#', $path, $m)) { + return ['src' => 'https://open.spotify.com/embed/' . $m[1] . '/' . $m[2], 'kind' => 'audio']; + } + if ($host === 'soundcloud.com') { + return ['src' => 'https://w.soundcloud.com/player/?url=' . rawurlencode($url), 'kind' => 'audio']; + } + if ($host === 'streamable.com' && preg_match('#^/(?:e/)?(\w+)#', $path, $m)) { + return ['src' => 'https://streamable.com/e/' . $m[1], 'kind' => 'wide']; + } + + return null; } private static function renderContactForm(): string ⋮ 52 unchanged lines ⋮
version.txt
- 2.0.0.1 + 2.0.0.4