283 lines
11 KiB
PHP
283 lines
11 KiB
PHP
<?php
|
|
if($reqPath === '/about' || $reqPath === '/about.html' || $reqPath === '/about.php'
|
|
|| $reqPath === '/index.php' || $reqPath === '/index.html') {
|
|
if($reqMethod !== 'GET')
|
|
return FM_ERR | 405;
|
|
header('Location: /');
|
|
return FM_HIT | 302;
|
|
}
|
|
|
|
if($reqPath === '/header-bgs.json') {
|
|
if($reqMethod !== 'GET')
|
|
return FM_ERR | 405;
|
|
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
if($reqHead)
|
|
return FM_HIT;
|
|
echo json_encode(FM_BGS);
|
|
|
|
return FM_HIT;
|
|
}
|
|
|
|
if($reqPath === '/now-listening') {
|
|
if($reqMethod !== 'GET')
|
|
return FM_ERR | 405;
|
|
if($reqHead)
|
|
return FM_HIT;
|
|
|
|
$offset = (int)filter_input(INPUT_GET, 'offset', FILTER_SANITIZE_NUMBER_INT);
|
|
|
|
fm_component('header', [
|
|
'title' => 'flash.moe / now listening',
|
|
'do_fullscreen_header' => true,
|
|
'is_now_playing' => true,
|
|
'offset' => $offset,
|
|
]);
|
|
fm_component('footer', [
|
|
'hide' => true,
|
|
'onload' => [
|
|
['fm.initIndex', 10],
|
|
],
|
|
]);
|
|
|
|
return FM_HIT;
|
|
}
|
|
|
|
if($reqPath === '/home') {
|
|
if($reqMethod !== 'GET')
|
|
return FM_ERR | 405;
|
|
if($reqHead)
|
|
return FM_HIT;
|
|
|
|
fm_component('header', [
|
|
'title' => 'flash.moe / homepage',
|
|
'do_fullscreen_header' => true,
|
|
]);
|
|
?>
|
|
<div class="php">
|
|
<div class="php-time">
|
|
<div class="php-time-analog">
|
|
<div class="clock">
|
|
<div class="clock-background"></div>
|
|
<div class="clock-center"></div>
|
|
<div class="clock-hand clock-hand-hours"><div class="clock-hand-display"></div></div>
|
|
<div class="clock-hand clock-hand-minutes"><div class="clock-hand-display"></div></div>
|
|
<div class="clock-hand clock-hand-seconds"><div class="clock-hand-display"></div></div>
|
|
<div class="clock-number clock-number-3"><div class="clock-number-display"></div></div>
|
|
<div class="clock-number clock-number-6"><div class="clock-number-display"></div></div>
|
|
<div class="clock-number clock-number-9"><div class="clock-number-display"></div></div>
|
|
<div class="clock-number clock-number-12"><div class="clock-number-display"></div></div>
|
|
</div>
|
|
</div>
|
|
<div class="php-time-alter">
|
|
<div class="php-time-digital">
|
|
<div class="php-time-digital-hours">--</div>
|
|
<div class="php-time-digital-separator">:</div>
|
|
<div class="php-time-digital-minutes">--</div>
|
|
</div>
|
|
<div class="php-time-date">
|
|
<span class="php-date-label">Week</span>
|
|
<span class="php-date-week">--</span>
|
|
<span class="php-date-label"> — </span>
|
|
<span class="php-date-year">----</span><span class="php-date-label">-</span><span class="php-date-month">---</span><span class="php-date-label">-</span><span class="php-date-day">--</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<form class="php-search" method="get" action="https://duckduckgo.com/">
|
|
<div class="php-search-input">
|
|
<input type="search" name="q" placeholder="Search using DuckDuckGo..."/>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<?php
|
|
fm_component('footer', [
|
|
'hide' => true,
|
|
'skip_analytics' => true,
|
|
'onload' => [
|
|
['fm.initClock'],
|
|
['fm.initIndex', 10],
|
|
],
|
|
]);
|
|
|
|
return FM_HIT;
|
|
}
|
|
|
|
if($reqPath === '/test') {
|
|
if($reqMethod !== 'GET')
|
|
return FM_ERR | 405;
|
|
if($reqHead)
|
|
return FM_HIT;
|
|
|
|
header('Content-Type: text/plain');
|
|
|
|
var_dump(FmProject::byFeatured());
|
|
|
|
return FM_HIT;
|
|
}
|
|
|
|
if($reqPath === '/') {
|
|
if($reqMethod !== 'GET')
|
|
return FM_ERR | 405;
|
|
if($reqHead)
|
|
return FM_HIT;
|
|
|
|
$legacyPage = filter_input(INPUT_GET, 'p', FILTER_SANITIZE_STRING);
|
|
if(!empty($legacyPage)) {
|
|
$legacyPages = [
|
|
'projects' => '/projects',
|
|
'contact' => '/contact',
|
|
'about' => '/',
|
|
'etc' => '/etc',
|
|
'hosted' => '/etc',
|
|
'friends' => '/related',
|
|
];
|
|
if(isset($legacyPages[$legacyPage])) {
|
|
header('Location: ' . $legacyPages[$legacyPage]);
|
|
return FM_HIT | 302;
|
|
}
|
|
}
|
|
|
|
$blogInfo = cache_output('blog', 600, function() {
|
|
return json_decode(file_get_contents('https://flash.moe/2020/?blog_dump'));
|
|
});
|
|
$projInfo = cache_output('projects-featured', 300, function() {
|
|
return json_decode(file_get_contents('https://flash.moe/2020/projects.php?dump_that_shit&rf'));
|
|
});
|
|
|
|
shuffle($projInfo);
|
|
|
|
$contact = [
|
|
[
|
|
'id' => 'email',
|
|
'name' => 'E-mail',
|
|
'icon' => 'fmi fmi-email',
|
|
'display' => 'contact@flash.moe',
|
|
'link' => 'mailto:contact@flash.moe',
|
|
],
|
|
[
|
|
'id' => 'flashii',
|
|
'name' => 'Flashii',
|
|
'icon' => 'fmi fmi-flashii',
|
|
'display' => 'flash',
|
|
'link' => '//flashii.net/profile.php?u=1',
|
|
],
|
|
[
|
|
'id' => 'twitter',
|
|
'name' => 'Twitter',
|
|
'icon' => 'fmi fmi-twitter',
|
|
'display' => '@smugwave',
|
|
'link' => '//twitter.com/smugwave',
|
|
],
|
|
[
|
|
'id' => 'github',
|
|
'name' => 'Github',
|
|
'icon' => 'fmi fmi-github',
|
|
'display' => 'flashwave',
|
|
'link' => '//github.com/flashwave',
|
|
],
|
|
];
|
|
|
|
fm_component('header', [
|
|
'title' => 'flash.moe',
|
|
'is_index' => true,
|
|
]);
|
|
?>
|
|
<div class="index-menu">
|
|
<?php for($i = 1; $i < count(FM_NAV); ++$i): ?>
|
|
<a href="<?=(FM_NAV[$i]['link']);?>"<?php if(FM_NAV[$i]['link'][0] === '/' && substr(FM_NAV[$i]['link'], 0, 2) !== '//') { echo ' data-fm-dynload=""'; } ?>><?=(FM_NAV[$i]['title']);?></a>
|
|
<?php endfor; ?>
|
|
</div>
|
|
<div class="index-featured">
|
|
<div class="index-feature">
|
|
<div class="index-feature-header">
|
|
<a href="//blog.flash.moe" class="index-feature-header-link"></a>
|
|
<div class="index-feature-header-title">Blog</div>
|
|
<div class="index-feature-header-more">More</div>
|
|
</div>
|
|
<div class="index-blog">
|
|
<?php $blogCount = 0; foreach($blogInfo as $blogPost): if($blogCount++ >= 5) break; ?>
|
|
<div class="index-blog-post">
|
|
<a href="//flash.moe/blog/<?=$blogPost->post_id;?>" class="index-blog-post-link"></a>
|
|
<div class="index-blog-post-header">
|
|
<div class="index-blog-post-title"><?=$blogPost->post_title;?></div>
|
|
<div class="index-blog-post-published"><time datetime="<?=date('c', $blogPost->post_published);?>" title="<?=date('r', $blogPost->post_published);?>"><?=time_elapsed($blogPost->post_published);?></time></div>
|
|
</div>
|
|
<div class="index-blog-post-content">
|
|
<?=first_paragraph($blogPost->post_text);?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
<div class="index-feature">
|
|
<div class="index-feature-header">
|
|
<a href="/projects" class="index-feature-header-link"></a>
|
|
<div class="index-feature-header-title">Projects</div>
|
|
<div class="index-feature-header-more">More</div>
|
|
</div>
|
|
<?php
|
|
$projCount = 0;
|
|
foreach($projInfo as $proj):
|
|
if($projCount++ >= 3)
|
|
break;
|
|
|
|
$links = [];
|
|
if(isset($proj->homepage))
|
|
$links[] = ['class' => 'homepage', 'text' => 'Homepage', 'url' => $proj->homepage];
|
|
if(isset($proj->repository))
|
|
$links[] = ['class' => 'repository', 'text' => 'Source', 'url' => $proj->repository];
|
|
if(isset($proj->forum))
|
|
$links[] = ['class' => 'forum', 'text' => 'Discussion', 'url' => $proj->forum];
|
|
?>
|
|
<div class="index-project" style="background-color: #<?=str_pad(dechex($proj->colour), 6, '0', STR_PAD_LEFT);?>;">
|
|
<a href="/projects#<?=$proj->name_clean;?>" class="index-project-anchor"></a>
|
|
<div class="index-project-content">
|
|
<div class="index-project-name"><?=$proj->name;?></div>
|
|
<div class="index-project-summary"><?=$proj->summary;?></div>
|
|
</div>
|
|
<?php if(!empty($links)): ?>
|
|
<div class="index-project-links">
|
|
<?php foreach($links as $link): ?>
|
|
<a class="index-project-link index-project-link-<?=$link['class'];?>" href="<?=$link['url'];?>" rel="noopener" target="_blank">
|
|
<?=$link['text'];?>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<div class="index-feature">
|
|
<div class="index-feature-header">
|
|
<a href="/contact" class="index-feature-header-link"></a>
|
|
<div class="index-feature-header-title">Contact</div>
|
|
<div class="index-feature-header-more">More</div>
|
|
</div>
|
|
<div class="index-contact">
|
|
<?php foreach($contact as $social): ?>
|
|
<div class="social social-<?=$social['id'];?>">
|
|
<?php if(isset($social['link'])): ?>
|
|
<a href="<?=$social['link'];?>" class="social-background" target="_blank" rel="noopener"></a>
|
|
<?php else: ?>
|
|
<div class="social-background" onclick="fm.selectTextInElement(this.parentNode.querySelector('.social-handle')); fm.copySelectedText();"></div>
|
|
<?php endif; ?>
|
|
<div class="social-icon <?=$social['icon'];?>"></div>
|
|
<div class="social-content">
|
|
<div class="social-name"><?=$social['name'];?></div>
|
|
<div class="social-handle"><?=$social['display'];?></div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
fm_component('footer', [
|
|
'is_index' => true,
|
|
'onload' => [
|
|
['fm.initIndex'],
|
|
],
|
|
]);
|
|
|
|
return FM_HIT;
|
|
}
|