2020-07-30 00:55:37 +00:00
|
|
|
<?php
|
2022-02-04 20:30:52 +00:00
|
|
|
namespace Makai;
|
|
|
|
|
2022-02-05 03:35:42 +00:00
|
|
|
$router->get('/about', mkiRedirect('/'));
|
|
|
|
$router->get('/about.html', mkiRedirect('/'));
|
|
|
|
$router->get('/about.php', mkiRedirect('/'));
|
|
|
|
$router->get('/index.php', mkiRedirect('/'));
|
|
|
|
$router->get('/index.html', mkiRedirect('/'));
|
2020-07-30 00:55:37 +00:00
|
|
|
|
2022-02-05 03:35:42 +00:00
|
|
|
$router->get('/365', mkiRedirect('/?fw365'));
|
|
|
|
|
|
|
|
$router->get('/donate', mkiRedirect('https://paypal.me/flashwave'));
|
|
|
|
|
|
|
|
$router->get('/header-bgs.json', function() {
|
|
|
|
return json_encode(FM_BGS);
|
|
|
|
});
|
|
|
|
|
|
|
|
$router->get('/now-listening', function() {
|
2020-07-30 00:55:37 +00:00
|
|
|
$offset = (int)filter_input(INPUT_GET, 'offset', FILTER_SANITIZE_NUMBER_INT);
|
|
|
|
|
2022-02-05 03:35:42 +00:00
|
|
|
$body = fm_component('header', [
|
2020-07-30 00:55:37 +00:00
|
|
|
'title' => 'flash.moe / now listening',
|
|
|
|
'do_fullscreen_header' => true,
|
2020-10-30 13:43:48 +00:00
|
|
|
'is_now_playing' => true,
|
2020-07-30 00:55:37 +00:00
|
|
|
'offset' => $offset,
|
|
|
|
]);
|
2022-02-05 03:35:42 +00:00
|
|
|
|
|
|
|
$body .= fm_component('footer', [
|
2020-07-30 00:55:37 +00:00
|
|
|
'hide' => true,
|
2020-10-30 13:43:48 +00:00
|
|
|
'onload' => [
|
|
|
|
['fm.initIndex', 10],
|
|
|
|
],
|
2020-07-30 00:55:37 +00:00
|
|
|
]);
|
|
|
|
|
2022-02-05 03:35:42 +00:00
|
|
|
return $body;
|
|
|
|
});
|
2020-07-30 00:55:37 +00:00
|
|
|
|
2022-02-05 03:35:42 +00:00
|
|
|
$router->get('/now-listening.json', function() {
|
|
|
|
$lfmInfo = cache_output('lastfm', 10, function() {
|
|
|
|
return json_decode(file_get_contents('https://now.flash.moe/get.php?u=flashwave_'));
|
|
|
|
});
|
2020-08-21 00:33:19 +00:00
|
|
|
|
2022-02-05 03:35:42 +00:00
|
|
|
if(empty($lfmInfo[0]->name))
|
|
|
|
return [];
|
|
|
|
|
|
|
|
$lfmInfo = $lfmInfo[0];
|
|
|
|
|
|
|
|
return [
|
|
|
|
'name' => strval($lfmInfo->name),
|
|
|
|
'now_playing' => !empty($lfmInfo->nowplaying),
|
|
|
|
'url' => strval($lfmInfo->url),
|
|
|
|
'cover' => !empty($lfmInfo->images->large) ? strval($lfmInfo->images->large) : '',
|
|
|
|
'artist' => [
|
|
|
|
'name' => !empty($lfmInfo->artist->name) ? strval($lfmInfo->artist->name) : '',
|
|
|
|
'url' => explode('/_/', strval($lfmInfo->url))[0],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
|
|
|
$router->get('/home', function() {
|
|
|
|
$body = fm_component('header', [
|
2020-08-21 00:33:19 +00:00
|
|
|
'title' => 'flash.moe / homepage',
|
|
|
|
'do_fullscreen_header' => true,
|
|
|
|
]);
|
2022-02-05 03:35:42 +00:00
|
|
|
|
|
|
|
$body .= <<<HTML
|
2020-08-21 00:33:19 +00:00
|
|
|
<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>
|
2020-09-08 21:09:02 +00:00
|
|
|
<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>
|
2020-08-21 00:33:19 +00:00
|
|
|
</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>
|
2022-02-05 03:35:42 +00:00
|
|
|
HTML;
|
|
|
|
|
|
|
|
$body .= fm_component('footer', [
|
2020-08-21 00:33:19 +00:00
|
|
|
'hide' => true,
|
2020-10-25 22:11:05 +00:00
|
|
|
'skip_analytics' => true,
|
2020-10-30 13:43:48 +00:00
|
|
|
'onload' => [
|
|
|
|
['fm.initClock'],
|
|
|
|
['fm.initIndex', 10],
|
|
|
|
],
|
2020-08-21 00:33:19 +00:00
|
|
|
]);
|
|
|
|
|
2022-02-05 03:35:42 +00:00
|
|
|
return $body;
|
|
|
|
});
|
2022-02-04 04:25:57 +00:00
|
|
|
|
2022-02-05 03:35:42 +00:00
|
|
|
$router->get('/', function() use ($db) {
|
2022-02-04 20:30:52 +00:00
|
|
|
$legacyPage = (string)filter_input(INPUT_GET, 'p');
|
2020-07-30 00:55:37 +00:00
|
|
|
if(!empty($legacyPage)) {
|
|
|
|
$legacyPages = [
|
|
|
|
'projects' => '/projects',
|
|
|
|
'contact' => '/contact',
|
|
|
|
'about' => '/',
|
|
|
|
'etc' => '/etc',
|
|
|
|
'hosted' => '/etc',
|
|
|
|
'friends' => '/related',
|
|
|
|
];
|
2022-02-05 03:35:42 +00:00
|
|
|
|
2020-07-30 00:55:37 +00:00
|
|
|
if(isset($legacyPages[$legacyPage])) {
|
|
|
|
header('Location: ' . $legacyPages[$legacyPage]);
|
2022-02-05 03:35:42 +00:00
|
|
|
return 302;
|
2020-07-30 00:55:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-05 03:35:42 +00:00
|
|
|
$is365 = isset($_GET['fw365']);
|
2020-07-30 00:55:37 +00:00
|
|
|
|
2022-02-05 03:35:42 +00:00
|
|
|
$blogInfo = json_decode(file_get_contents(MKI_DIR_PUB . '/old_blog_posts.json'));
|
|
|
|
|
|
|
|
$projects = (new Projects($db))->getFeatured();
|
|
|
|
$languages = new Languages($db);
|
2020-07-30 00:55:37 +00:00
|
|
|
|
|
|
|
$contact = [
|
|
|
|
[
|
|
|
|
'id' => 'email',
|
|
|
|
'name' => 'E-mail',
|
2020-08-19 01:20:25 +00:00
|
|
|
'icon' => 'fmi fmi-email',
|
2020-10-25 22:11:05 +00:00
|
|
|
'display' => 'contact@flash.moe',
|
|
|
|
'link' => 'mailto:contact@flash.moe',
|
2020-07-30 00:55:37 +00:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'id' => 'flashii',
|
|
|
|
'name' => 'Flashii',
|
2020-08-19 01:20:25 +00:00
|
|
|
'icon' => 'fmi fmi-flashii',
|
2020-07-30 00:55:37 +00:00
|
|
|
'display' => 'flash',
|
|
|
|
'link' => '//flashii.net/profile.php?u=1',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'id' => 'twitter',
|
|
|
|
'name' => 'Twitter',
|
2020-08-19 01:20:25 +00:00
|
|
|
'icon' => 'fmi fmi-twitter',
|
2020-07-30 00:55:37 +00:00
|
|
|
'display' => '@smugwave',
|
|
|
|
'link' => '//twitter.com/smugwave',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'id' => 'github',
|
|
|
|
'name' => 'Github',
|
2020-08-19 01:20:25 +00:00
|
|
|
'icon' => 'fmi fmi-github',
|
2020-07-30 00:55:37 +00:00
|
|
|
'display' => 'flashwave',
|
|
|
|
'link' => '//github.com/flashwave',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
2022-02-05 03:35:42 +00:00
|
|
|
$body = fm_component('header', [
|
2020-07-30 00:55:37 +00:00
|
|
|
'title' => 'flash.moe',
|
|
|
|
'is_index' => true,
|
2022-02-04 04:25:57 +00:00
|
|
|
'is_365' => $is365,
|
2020-07-30 00:55:37 +00:00
|
|
|
]);
|
2022-02-05 03:35:42 +00:00
|
|
|
|
|
|
|
$body .= '<div class="index-menu">';
|
|
|
|
|
|
|
|
for($i = 1; $i < count(FM_NAV); ++$i) {
|
|
|
|
$link = FM_NAV[$i];
|
|
|
|
$body .= "<a href=\"{$link['link']}\"";
|
|
|
|
|
|
|
|
if($link['link'][0] === '/' && substr($link['link'], 0, 2) !== '//')
|
|
|
|
$body .= ' data-fm-dynload=""';
|
|
|
|
|
|
|
|
$body .= ">{$link['title']}</a>";
|
|
|
|
}
|
|
|
|
|
|
|
|
$body .= <<<HTML
|
|
|
|
</div>
|
|
|
|
<div class="index-featured">
|
|
|
|
<div class="index-feature">
|
|
|
|
<div class="index-feature-header">
|
2022-02-05 03:39:56 +00:00
|
|
|
<a href="/old-blog" class="index-feature-header-link" data-fm-dynload=""></a>
|
2022-02-05 03:35:42 +00:00
|
|
|
<div class="index-feature-header-title">Blog</div>
|
|
|
|
<div class="index-feature-header-more">More</div>
|
2020-07-30 00:55:37 +00:00
|
|
|
</div>
|
2022-02-05 03:35:42 +00:00
|
|
|
<div class="index-blog">
|
|
|
|
HTML;
|
|
|
|
|
|
|
|
$blogCount = 0;
|
|
|
|
foreach($blogInfo as $blogPost) {
|
|
|
|
if($blogCount++ >= 5)
|
|
|
|
break;
|
|
|
|
|
|
|
|
$dateTimeC = date('c', $blogPost->post_published);
|
|
|
|
$dateTimeR = date('r', $blogPost->post_published);
|
|
|
|
$timeElapsed = time_elapsed($blogPost->post_published);
|
|
|
|
$paragraph = first_paragraph($blogPost->post_text);
|
|
|
|
|
|
|
|
$body .= <<<HTML
|
|
|
|
<div class="index-blog-post">
|
2022-02-05 03:39:56 +00:00
|
|
|
<a href="/old-blog/{$blogPost->post_id}" class="index-blog-post-link" data-fm-dynload=""></a>
|
2022-02-05 03:35:42 +00:00
|
|
|
<div class="index-blog-post-header">
|
|
|
|
<div class="index-blog-post-title">{$blogPost->post_title}</div>
|
|
|
|
<div class="index-blog-post-published"><time datetime="{$dateTimeC}" title="<{$dateTimeR}">{$timeElapsed}</time></div>
|
2020-07-30 00:55:37 +00:00
|
|
|
</div>
|
2022-02-05 03:35:42 +00:00
|
|
|
<div class="index-blog-post-content">
|
|
|
|
{$paragraph}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
HTML;
|
|
|
|
}
|
|
|
|
|
|
|
|
$body .= <<<HTML
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="index-feature">
|
|
|
|
<div class="index-feature-header">
|
|
|
|
<a href="/projects" class="index-feature-header-link" data-fm-dynload=""></a>
|
|
|
|
<div class="index-feature-header-title">Projects</div>
|
|
|
|
<div class="index-feature-header-more">More</div>
|
|
|
|
</div>
|
|
|
|
HTML;
|
|
|
|
|
|
|
|
foreach($projects as $project) {
|
|
|
|
$links = [];
|
|
|
|
if($project->hasHomePageUrl())
|
|
|
|
$links[] = ['class' => 'homepage', 'text' => 'Homepage', 'url' => $project->getHomePageUrl()];
|
|
|
|
if($project->hasSourceUrl())
|
|
|
|
$links[] = ['class' => 'repository', 'text' => 'Source', 'url' => $project->getSourceUrl()];
|
|
|
|
if($project->hasDiscussionUrl())
|
|
|
|
$links[] = ['class' => 'forum', 'text' => 'Discussion', 'url' => $project->getDiscussionUrl()];
|
|
|
|
|
|
|
|
$colour = $project->hasColour() ? $project->getColour() : $languages->getProjectColour($project);
|
|
|
|
$colour = str_pad(dechex($colour), 6, '0', STR_PAD_LEFT);
|
|
|
|
|
|
|
|
$body .= <<<HTML
|
|
|
|
<div class="index-project" style="background-color: #{$colour};">
|
|
|
|
<a href="/projects#{$project->getCleanName()}" class="index-project-anchor" data-fm-dynload=""></a>
|
|
|
|
<div class="index-project-content">
|
|
|
|
<div class="index-project-name">{$project->getName()}</div>
|
|
|
|
HTML;
|
|
|
|
|
|
|
|
if($project->hasSummary())
|
|
|
|
$body .= "<div class=\"index-project-summary\">{$project->getSummary()}</div>";
|
|
|
|
|
|
|
|
$body .= '</div>';
|
|
|
|
|
|
|
|
if(!empty($links)) {
|
|
|
|
$body .= '<div class="index-project-links">';
|
|
|
|
|
|
|
|
foreach($links as $link)
|
|
|
|
$body .= "<a class=\"index-project-link index-project-link-{$link['class']}\" href=\"{$link['url']}\" rel=\"noopener\" target=\"_blank\">{$link['text']}</a>";
|
|
|
|
|
|
|
|
$body .= '</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$body .= '</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$body .= <<<HTML
|
|
|
|
</div>
|
|
|
|
<div class="index-feature">
|
|
|
|
<div class="index-feature-header">
|
|
|
|
<a href="/contact" class="index-feature-header-link" data-fm-dynload=""></a>
|
|
|
|
<div class="index-feature-header-title">Contact</div>
|
|
|
|
<div class="index-feature-header-more">More</div>
|
|
|
|
</div>
|
|
|
|
<div class="index-contact">
|
|
|
|
HTML;
|
|
|
|
|
|
|
|
foreach($contact as $social) {
|
|
|
|
$body .= "<div class=\"social social-{$social['id']}\">";
|
|
|
|
|
|
|
|
if(isset($social['link'])) {
|
|
|
|
$body .= "<a href=\"{$social['link']}\" class=\"social-background\" target=\"_blank\" rel=\"noopener\"></a>";
|
|
|
|
} else {
|
|
|
|
$body .= "<div class=\"social-background\" onclick=\"fm.selectTextInElement(this.parentNode.querySelector('.social-handle')); fm.copySelectedText();\"></div>";
|
|
|
|
}
|
|
|
|
|
|
|
|
$body .= <<<HTML
|
|
|
|
<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>
|
|
|
|
HTML;
|
|
|
|
}
|
|
|
|
|
|
|
|
$body .= '</div></div></div>';
|
|
|
|
|
|
|
|
$body .= fm_component('footer', [
|
2020-07-30 00:55:37 +00:00
|
|
|
'is_index' => true,
|
2020-10-30 13:43:48 +00:00
|
|
|
'onload' => [
|
|
|
|
['fm.initIndex'],
|
|
|
|
],
|
2020-07-30 00:55:37 +00:00
|
|
|
]);
|
|
|
|
|
2022-02-05 03:35:42 +00:00
|
|
|
return $body;
|
|
|
|
});
|