Changed to permlainks only
This commit is contained in:
parent
66c741200a
commit
c120f624df
6 changed files with 76 additions and 8 deletions
23
index.php
23
index.php
|
|
@ -112,6 +112,12 @@ function article_og_image_url($articleId){
|
|||
return 'https://bubulescu.org/out-dir/' . rawurlencode($articleId . '_og.jpg');
|
||||
}
|
||||
|
||||
function render_404_page(){
|
||||
http_response_code(404);
|
||||
include __DIR__ . '/404.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
function video_metadata($path){
|
||||
$base = pathinfo($path, PATHINFO_FILENAME);
|
||||
$meta = [
|
||||
|
|
@ -223,6 +229,9 @@ usort($videos, function($a, $b) use ($videoCache) {
|
|||
});
|
||||
|
||||
$articleId = trim((string)($_GET['id'] ?? ''));
|
||||
if ($articleId === '' || !preg_match('/^[0-9]{14}[a-f0-9]{16}$/', $articleId) || count(array_diff_key($_GET, ['id' => true])) > 0) {
|
||||
render_404_page();
|
||||
}
|
||||
|
||||
if ($articleId !== '') {
|
||||
$videos = array_values(array_filter($videos, function($v) use ($articleId, $config) {
|
||||
|
|
@ -289,6 +298,9 @@ $total = count($videos);
|
|||
$pages = max(1, (int)ceil($total / $per));
|
||||
$page = min($page, $pages);
|
||||
$slice = array_slice($videos, ($page - 1) * $per, $per);
|
||||
if (!$slice) {
|
||||
render_404_page();
|
||||
}
|
||||
|
||||
$activeFilterCount = ($keywordValue !== '') ? 1 : 0;
|
||||
$baseParams = ($rawKeyword !== '') ? ['q' => $rawKeyword] : [];
|
||||
|
|
@ -347,6 +359,7 @@ $headerTitles = [
|
|||
'My Vices Last',
|
||||
];
|
||||
$siteHeaderTitle = $headerTitles[array_rand($headerTitles)];
|
||||
$brandUrl = '?id=' . rawurlencode($articleId);
|
||||
?>
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
|
@ -430,12 +443,14 @@ $siteHeaderTitle = $headerTitles[array_rand($headerTitles)];
|
|||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($articleId === ''): ?>
|
||||
<p class="filter-summary">
|
||||
Showing <?=h((string)$total)?> article(s)
|
||||
<?php if($activeFilterCount > 0): ?> with <?=h((string)$activeFilterCount)?> active filter(s)<?php endif; ?>
|
||||
</p>
|
||||
|
||||
<?php if(!$slice): ?><p>No videos found for current filter.</p><?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="video-list">
|
||||
<?php foreach($slice as $v):
|
||||
|
|
@ -453,8 +468,8 @@ $siteHeaderTitle = $headerTitles[array_rand($headerTitles)];
|
|||
<div class="video-row-head video-row-head-mobile">
|
||||
<h2 class="video-row-title"><?php if($permalinkUrl !== ''): ?><a href="<?=h($permalinkUrl)?>"><?=h($m['title'])?></a><?php else: ?><?=h($m['title'])?><?php endif; ?></h2>
|
||||
<p class="meta">
|
||||
<span><a href="<?=h($dateFilterUrl)?>"><?=h($m['date'])?></a></span>
|
||||
<?php if(!empty($m['location'])): ?><span><a href="<?=h($locFilterUrl)?>"><?=h($m['location'])?></a></span><?php endif; ?>
|
||||
<span><?=h($m['date'])?></span>
|
||||
<?php if(!empty($m['location'])): ?><span><?=h($m['location'])?></span><?php endif; ?>
|
||||
</p>
|
||||
<?php if(!empty($m['teaser'])): ?><p class="description-teaser description-teaser-mobile"><?=h((string)$m['teaser'])?></p><?php endif; ?>
|
||||
</div>
|
||||
|
|
@ -471,8 +486,8 @@ $siteHeaderTitle = $headerTitles[array_rand($headerTitles)];
|
|||
<div class="video-info">
|
||||
<h2 class="video-row-title video-row-title-desktop"><?php if($permalinkUrl !== ''): ?><a href="<?=h($permalinkUrl)?>"><?=h($m['title'])?></a><?php else: ?><?=h($m['title'])?><?php endif; ?></h2>
|
||||
<p class="meta meta-desktop">
|
||||
<span><a href="<?=h($dateFilterUrl)?>"><?=h($m['date'])?></a></span>
|
||||
<?php if(!empty($m['location'])): ?><span><a href="<?=h($locFilterUrl)?>"><?=h($m['location'])?></a></span><?php endif; ?>
|
||||
<span><?=h($m['date'])?></span>
|
||||
<?php if(!empty($m['location'])): ?><span><?=h($m['location'])?></span><?php endif; ?>
|
||||
</p>
|
||||
<?php if(!empty($m['teaser'])): ?><p class="description-teaser description-teaser-desktop"><?=h((string)$m['teaser'])?></p><?php endif; ?>
|
||||
<?php if(!empty($m['description'])): ?><p class="description"><?=nl2br(h($m['description']), false)?></p><?php endif; ?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue