hajime/public/changelog.php

333 lines
8.4 KiB
PHP
Raw Normal View History

2023-08-11 22:16:32 +00:00
<?php
$changesfile = json_decode(file_get_contents(__DIR__ . '/../private/changelog.json'), true);
$changelog = array();
foreach($changesfile as $time => $data) {
$data = array_reverse($data, true);
$changelog[$time] = array();
foreach($data as $id => $change) {
if(isset($_GET['branch']) && $change['branch'] != $_GET['branch'])
continue;
if(isset($_GET['user']) && $change['userid'] != $_GET['user'])
continue;
if(!(int)$change['public'])
continue;
$changelog[$time][$id] = $change;
}
if(empty($changelog[$time][0]))
unset($changelog[$time]);
}
if(isset($_GET['xml'])) {
print '<?xml version="1.0" encoding="UTF-8"?>';
print '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">';
print '<channel>';
print '<title>Flashii Changelog</title>';
print '<link>https://retro.flash.moe/</link>';
print '<description>Changelog of Flashii.</description>';
print '<language>en-gb</language>';
print '<language><webMaster>devs@flashii.net (Flashii Developers)</webMaster></language>';
print '<pubDate>'. date('D, d M Y G:i:s O') .'</pubDate>';
print '<lastBuildDate>'. date('D, d M Y G:i:s O') .'</lastBuildDate>';
foreach($changelog as $timestamp => $data) {
foreach($data as $id => $change) {
print '<item>';
print '<title>';
switch($change['type']) {
case 'ADD':
print 'Added to';
break;
case 'REM':
print 'Removed from';
break;
case 'FIX':
print 'Fixed in';
break;
case 'UPD':
print 'Updated in';
break;
default:
print 'Did something to';
}
print ' ';
switch($change['branch']) {
case 'STB':
print 'Stable';
break;
case 'DEV':
print 'Development';
break;
case 'CHAT':
print 'Chat';
break;
default:
print 'an unknown';
}
print ' branch';
print '</title>';
print '<link>https://retro.flash.moe/changelog.php#c' . $timestamp . 's' . $id . '</link>';
print '<guid>https://retro.flash.moe/changelog.php#c' . $timestamp . 's' . $id . '</guid>';
print '<pubDate>'. date('D, d M Y G:i:s O', $timestamp) .'</pubDate>';
print '<dc:publisher>'. $change['user'] .'</dc:publisher>';
print '<description><![CDATA['. $change['change'] .']]></description>';
print '</item>';
}
}
print '</channel>';
print '</rss>';
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Flashii Changelog</title>
<link href="//fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
margin: 0px 10px;
padding: 0px;
font: 12px/20px "Open Sans", sans-serif;
background: #171717;
color: #FFF;
}
a {
color: inherit;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
hr {
height: 1px;
background: #FFF;
border: 0px;
}
h1 {
float: left;
}
h2 {
margin: 0px;
padding: 5px 0px 7px;
background: #222;
}
h3 {
float: right;
}
.changelog-day {
margin: 20px 0px;
border: 1px solid #222;
}
.changelog-day > div:not(:last-child) {
border-bottom: 1px #222 solid;
}
.changelog-day > div > span.tag {
display: inline-block;
min-width: 100px;
text-align: center;
background: #222;
font-weight: 500;
letter-spacing: 2px;
border-right: 1px solid #222;
}
.changelog-day > div > span.addition-tag {
background: #2A2;
}
.changelog-day > div > span.removal-tag {
background: #A22;
}
.changelog-day > div > span.fixed-tag {
background: #2AA;
}
.changelog-day > div > span.update-tag {
background: #2AA;
}
.changelog-day > div > span.branch {
display: inline-block;
min-width: 150px;
text-align: center;
background: #222;
font-weight: 500;
border-right: 1px solid #222;
}
.changelog-day > div > span.brn-stable {
background: #62C;
}
.changelog-day > div > span.brn-development {
background: #C26;
}
.changelog-day > div > span.brn-chat {
background: #09F;
}
.changelog-day > div > span.tag {
display: inline-block;
min-width: 100px;
text-align: center;
background: #222;
font-weight: 500;
letter-spacing: 2px;
}
.changelog-day > div > span.addition-tag {
background: #2A2;
}
.changelog-day > div > span.removal-tag {
background: #A22;
}
.changelog-day > div > span.fixed-tag {
background: #2AA;
}
.changelog-day > div > span.update-tag {
background: #2AA;
}
.changelog-day > div > span.changeuser {
display: inline-block;
min-width: 100px;
max-width: 150px;
text-align: center;
background: #222;
font-weight: 500;
}
.changelog-day > div > span.changedesc {
padding: 0px 5px;
}
</style>
</head>
<body>
<div>
<h1>Flashii Changelog</h1>
<h3>
<a href="/changelog.php?xml">XML Feed</a> /
<a href="https://flashii.net">Flashii.net</a> /
<a href="https://flash.moe">Flash.moe</a> /
Copyright &copy; Flashii Media
</h3>
<div style="clear: both;"></div>
</div>
<hr />
<div class="changelog-day" id="legend">
<h2>&#160;&#160;&#187; Legend</h2>
<div>
<span class="tag">Action</span><span class="branch">Branch</span><span class="changeuser">User</span><span class="changedesc">Description</span>
</div>
</div>
<?php
foreach($changelog as $timestamp => $data) {
print '<div class="changelog-day" id="c';
print $timestamp;
print '">';
print '<h2>&#160;&#160;&#187; <a href="#c';
print $timestamp;
print '">Changes on ';
print date('l Y-m-d', $timestamp);
print '</a></h2>';
foreach($data as $id => $change) {
print '<div id="c' . $timestamp . 's' . $id . '">';
switch($change['type']) {
case 'ADD':
print '<span class="tag addition-tag">Added</span>';
break;
case 'REM':
print '<span class="tag removal-tag">Removed</span>';
break;
case 'FIX':
print '<span class="tag fixed-tag">Fixed</span>';
break;
case 'UPD':
print '<span class="tag update-tag">Updated</span>';
break;
default:
print '<span class="tag">Unknown</span>';
}
switch($change['branch']) {
case 'STB':
print '<span class="branch brn-stable"><a href="' . $_SERVER['PHP_SELF'] . '?branch=STB">Stable</a></span>';
break;
case 'DEV':
print '<span class="branch brn-development"><a href="' . $_SERVER['PHP_SELF'] . '?branch=DEV">Development</a></span>';
break;
case 'CHAT':
print '<span class="branch brn-chat"><a href="' . $_SERVER['PHP_SELF'] . '?branch=CHAT">Chat</a></span>';
break;
default:
print '<span class="branch">Other</span>';
}
print '<span class="changeuser"><a href="/u/';
print $change['userid'];
print '" target="_blank">';
print $change['user'];
print '</a></span>';
print '<span class="changedesc">';
print $change['change'];
print '</span>';
print '</div>';
}
print '</div>';
}
?>
</body>
</html>