flash.moe/public/2019/index.php

237 lines
8.6 KiB
PHP
Raw Normal View History

2020-08-20 00:02:37 +00:00
<?php
require_once __DIR__ . '/../_v4/includes.php';
define('FWH_STYLE', FWH_2019);
$accounts = [
[
'icon' => 'fas fa-at',
'title' => 'E-mail',
'url' => 'mailto:me@flash.moe',
],
[
'icon' => 'fas fa-bolt',
'title' => 'Flashii',
'url' => 'https://flashii.net/profile.php?u=1',
],
[
'icon' => 'fab fa-github',
'title' => 'Github',
'url' => 'https://github.com/flashwave',
],
[
'icon' => 'fab fa-youtube',
'title' => 'YouTube',
'url' => 'https://youtube.com/c/flashwave',
],
[
'icon' => 'fab fa-twitch',
'title' => 'Twitch',
'url' => 'https://twitch.tv/flashwave0',
],
[
'icon' => 'fab fa-steam',
'title' => 'Steam',
'url' => 'https://steamcommunity.com/id/flashwave_',
],
[
'icon' => 'fab fa-twitter',
'title' => 'Twitter',
'url' => 'javascript:confirm(\'Proceed with caution.\') ? location.assign(\'https://twitter.com/smugwave\') : void(0);',
],
[
'icon' => 'fab fa-lastfm',
'title' => 'last.fm',
'url' => 'https://www.last.fm/user/flashwave_',
],
[
'icon' => 'fab fa-nintendo-switch',
'title' => 'Switch',
'url' => 'javascript:alert(\'SW-7446-8163-4902\');',
],
[
'icon' => 'fab fa-paypal',
'title' => 'Donate',
'url' => 'https://paypal.me/flashwave',
],
];
$getBlogPosts = $pdo->prepare('
SELECT `post_id`, `post_title`, `post_text`, `post_published`
FROM `fm_blog_posts` AS bp
WHERE `post_published` IS NOT NULL
AND `post_published` < CURRENT_TIMESTAMP
AND `post_deleted` IS NULL
ORDER BY `post_published` DESC
');
$getBlogPosts->execute();
$blogPosts = $getBlogPosts->fetchAll(PDO::FETCH_OBJ);
echo html_open()
. '<head>'
. html_head('flash.moe', HEAD_FLASHWAVE)
. '</head><body class="index">';
if(html_old_ie())
echo '<bgsound src="/assets/SMS-JBIOS-Demo.mid" loop="infinite"/>';
if(html_netscape())
echo '<embed src="/assets/SMS-JBIOS-Demo.mid" autostart="true" hidden="true" loop="true"></embed>';
echo '<div class="wrapper">';
?>
<div class="index__side">
<div class="index__header">
<img src="//flashii.net/user-assets.php?m=avatar&u=1&r=120" width="60" height="60" alt="avatar" class="index__header__avatar"/>
<div class="index__header__text">
<div class="index__header__name">flash<span class="index__header__name__highlight">wave</span></div>
<div class="index__header__slogan">if it ain't broke, i'll break it</div>
</div>
</div>
<div class="index__accounts">
<?php foreach($accounts as $account): ?>
<a href="<?=$account['url'];?>" class="index__account" rel="noreferrer noopener">
<div class="index__account__icon"><i class="<?=$account['icon'];?> fa-fw"></i></div>
<div class="index__account__title"><?=$account['title'];?></div>
</a>
<?php endforeach; ?>
</div>
<a href="/2019/projects.php" class="index__affil">
<div class="index__affil__name">Projects</div>
<div class="index__affil__desc">List of things I've made or am making.</div>
</a>
<a href="https://flashii.net" class="index__affil index__affil--flashii">
<div class="index__affil__name">Flashii</div>
<div class="index__affil__desc">Community site I run and develop.</div>
</a>
<a href="https://railgun.sh" class="index__affil index__affil--railgun">
<div class="index__affil__name">Railgun</div>
<div class="index__affil__desc">Chat server and chat protocols I work on.</div>
</a>
<?php if(!html_netscape()): ?>
<div class="index__playing">
<div class="index__playing__header" id="np-header">Loading...</div>
<div class="index__playing__content index__playing__content--hidden" id="np-content">
<div class="index__playing__cover" id="np-cover"></div>
<div class="index__playing__text">
<a class="index__playing__title" id="np-title"></a>
<a class="index__playing__artist" id="np-artist"></a>
</div>
</div>
</div>
<?php endif; ?>
</div>
<div class="index__main">
<?php foreach($blogPosts as $post) { ?>
<div class="index__blog">
<h1 class="index__blog__title"><?=$post->post_title;?></h1>
<p class="index__blog__paragraph"><?=trim(explode("\n", $post->post_text)[0]);?></p>
<a href="/2019/blog.php?p=<?=$post->post_id;?>" class="index__blog__continue">Continue reading</a>
<span class="index__blog__continue">Posted <?=$post->post_published;?></span>
</div>
<?php } ?>
</div>
<?php if(!html_netscape()): ?>
<script type="text/javascript">
function createXHR() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
return null;
}
function getNowListening(username, cb) {
var xhr = createXHR();
xhr.onreadystatechange = function() {
if (xhr.readyState !== 4)
return;
var xml = null;
if(window.DOMParser) {
var parser = new DOMParser();
xml = parser.parseFromString(xhr.responseText, 'text/xml');
} else {
xml = new ActiveXObject('Microsoft.XMLDOM');
xml.async = 'false';
xml.loadXML(xhr.responseText);
xml = xml.childNodes[1];
}
cb(xml.getElementsByTagName('Track')[0]);
};
xhr.open('GET', '/np.php?u=' + username, true);
xhr.send();
}
function getNodeText(node) {
if (typeof node.textContent === 'undefined') {
return node.text;
} else {
return node.textContent;
}
}
function setNodeText(node, text) {
if (typeof node.textContent === 'undefined') {
node.innerText = text;
} else {
node.textContent = text;
}
}
function setNowListening(track) {
var cover = document.getElementById('np-cover'),
title = document.getElementById('np-title'),
artist = document.getElementById('np-artist'),
header = document.getElementById('np-header'),
content = document.getElementById('np-content'),
coverUrl = getNodeText(track.getElementsByTagName('Medium')[0]);
if (content.className.indexOf('index__playing__content--hidden') >= 0)
content.className = content.className.replace('index__playing__content--hidden', '');
setNodeText(header, getNodeText(track.getElementsByTagName('IsPlaying')[0]) != '0' ? 'Now Listening' : 'Last Listened');
cover.style.backgroundImage = coverUrl.length < 1 ? '' : "url('$')".replace('$', coverUrl);
setNodeText(title, getNodeText(track.getElementsByTagName('Name')[0]));
title.href = getNodeText(track.getElementsByTagName('Url')[0]);
setNodeText(artist, getNodeText(track.getElementsByTagName('Name')[1]));
artist.href = title.href.substring(0, title.href.indexOf('/_/'));
}
window.onload = function() {
var lastFmUsername = '';
var links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; i++)
if(links[i].href.substring(0, 25) == 'https://www.last.fm/user/') {
lastFmUsername = links[i].href.substring(25);
break;
}
if(lastFmUsername) {
setInterval(function() { getNowListening(lastFmUsername, function(track) { setNowListening(track); }); }, 60000);
getNowListening(lastFmUsername, function(track) { setNowListening(track); });
}
};
</script>
<?php
endif;
echo '</div>'
. html_footer()
. '</body>'
. html_close();