From f77933dd8620c1a988150388e5746d870f9dc0b5 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sat, 17 Oct 2015 22:58:51 +0200 Subject: [PATCH] r20151017 Signed-off-by: Flashwave --- _sakura/components/Sessions.php | 12 ++-- _sakura/components/User.php | 40 +++++++++++- _sakura/components/Users.php | 33 ++++------ _sakura/sakura.php | 2 +- _sakura/templates/misaki/main/news.tpl | 0 _sakura/templates/yuuno/global/master.tpl | 5 +- _sakura/templates/yuuno/main/profile.tpl | 25 ++++++-- public/content/data/misaki/css/misaki.css | 22 ++++++- public/content/data/misaki/images/spinner.svg | 62 +++++++++++++++++++ public/content/data/misaki/js/misaki.js | 19 +++++- public/content/data/yuuno/css/yuuno.css | 55 +++++++++++++++- 11 files changed, 233 insertions(+), 42 deletions(-) create mode 100644 _sakura/templates/misaki/main/news.tpl create mode 100644 public/content/data/misaki/images/spinner.svg diff --git a/_sakura/components/Sessions.php b/_sakura/components/Sessions.php index 16d496b..35e193f 100755 --- a/_sakura/components/Sessions.php +++ b/_sakura/components/Sessions.php @@ -66,7 +66,7 @@ class Session // Check if we actually got something in return if (!count($session)) { - return false; + return 0; } $session = $session[0]; @@ -77,7 +77,7 @@ class Session self::deleteSession($session['session_id']); // ...and return false - return false; + return 0; } // Origin checking @@ -94,14 +94,14 @@ class Session // 000.xxx.xxx.xxx case 3: if ($userIP[3] !== $sessionIP[3]) { - return false; + return 0; } // xxx.000.xxx.xxx case 2: case 3: if ($userIP[2] !== $sessionIP[2]) { - return false; + return 0; } // xxx.xxx.000.xxx @@ -109,7 +109,7 @@ class Session case 2: case 3: if ($userIP[1] !== $sessionIP[1]) { - return false; + return 0; } // xxx.xxx.xxx.000 @@ -118,7 +118,7 @@ class Session case 2: case 3: if ($userIP[0] !== $sessionIP[0]) { - return false; + return 0; } } } diff --git a/_sakura/components/User.php b/_sakura/components/User.php index a047022..f9fd7fd 100755 --- a/_sakura/components/User.php +++ b/_sakura/components/User.php @@ -410,10 +410,48 @@ class User { // Do the database query - $warnings = Database::fetch('warnings', true, [ + $getWarnings = Database::fetch('warnings', true, [ 'user_id' => [$this->data['user_id'], '='], ]); + // Storage array + $warnings = []; + + // Add special stuff + foreach ($getWarnings as $warning) { + // Check if it hasn't expired + if ($warning['warning_expires'] < time()) { + Database::delete('warnings', ['warning_id' => [$warning['warning_id'], '=']]); + continue; + } + + // Text action + switch ($warning['warning_action']) { + default: + case '0': + $warning['warning_action_text'] = 'Warning'; + break; + case '1': + $warning['warning_action_text'] = 'Silence'; + break; + case '2': + $warning['warning_action_text'] = 'Restriction'; + break; + case '3': + $warning['warning_action_text'] = 'Ban'; + break; + case '4': + $warning['warning_action_text'] = 'Abyss'; + break; + } + + // Text expiration + $warning['warning_length'] = round(($warning['warning_expires'] - $warning['warning_issued']) / 60); + + // Add to array + $warnings[$warning['warning_id']] = $warning; + } + // Return all the warnings return $warnings; diff --git a/_sakura/components/Users.php b/_sakura/components/Users.php index 3ded1a8..1e3a464 100755 --- a/_sakura/components/Users.php +++ b/_sakura/components/Users.php @@ -45,31 +45,22 @@ class Users ]; // Check if a user is logged in - public static function checkLogin($uid = null, $sid = null, $bypassCookies = false) + public static function checkLogin($uid = null, $sid = null) { - // Set $uid and $sid if they're null - if ($uid == null) { - $uid = Session::$userId; - } + // Assign $uid and $sid + $uid = $uid ? $uid : (isset($_COOKIE[Configuration::getConfig('cookie_prefix') . 'id']) + ? $_COOKIE[Configuration::getConfig('cookie_prefix') . 'id'] + : 0); + $sid = $sid ? $sid : (isset($_COOKIE[Configuration::getConfig('cookie_prefix') . 'session']) + ? $_COOKIE[Configuration::getConfig('cookie_prefix') . 'session'] + : 0); - // ^ - if ($sid == null) { - $sid = Session::$sessionId; - } - - // Check if cookie bypass is false - if (!$bypassCookies) { - // Check if the cookies are set - if (!isset($_COOKIE[Configuration::getConfig('cookie_prefix') . 'id']) || - !isset($_COOKIE[Configuration::getConfig('cookie_prefix') . 'session'])) { - return false; - } - } + // Get session + $session = Session::checkSession($uid, $sid); // Check if the session exists and check if the user is activated - if (!$session = Session::checkSession($uid, $sid) - || Permissions::check('SITE', 'DEACTIVATED', $uid, 1)) { + if ($session == 0 || Permissions::check('SITE', 'DEACTIVATED', $uid, 1)) { // Unset User ID setcookie( Configuration::getConfig('cookie_prefix') . 'id', @@ -92,7 +83,7 @@ class Users } // Extend the cookie times if the remember flag is set - if ($session == 2 && !$bypassCookies) { + if ($session == 2) { // User ID cookie setcookie( Configuration::getConfig('cookie_prefix') . 'id', diff --git a/_sakura/sakura.php b/_sakura/sakura.php index 9b83c7d..26a7fb5 100755 --- a/_sakura/sakura.php +++ b/_sakura/sakura.php @@ -8,7 +8,7 @@ namespace Sakura; // Define Sakura version -define('SAKURA_VERSION', '20151016'); +define('SAKURA_VERSION', '20151017'); define('SAKURA_VLABEL', 'Eminence'); define('SAKURA_COLOUR', '#6C3082'); define('SAKURA_STABLE', false); diff --git a/_sakura/templates/misaki/main/news.tpl b/_sakura/templates/misaki/main/news.tpl new file mode 100644 index 0000000..e69de29 diff --git a/_sakura/templates/yuuno/global/master.tpl b/_sakura/templates/yuuno/global/master.tpl index 4e20b64..263ac51 100755 --- a/_sakura/templates/yuuno/global/master.tpl +++ b/_sakura/templates/yuuno/global/master.tpl @@ -302,8 +302,7 @@ // Create changelog table var changelogTable = document.createElement('table'); - changelogTable.style.fontSize = '.8em'; - changelogTable.style.lineHeight = '1.5em'; + changelogTable.className = 'panelTable'; // Create and append all changelog entries for (var i in changelog) { @@ -314,8 +313,6 @@ // Set data changelogColumnAction.appendChild(document.createTextNode(changelog[i]['change_action']['action_name'])); - changelogColumnAction.style.textAlign = 'center'; - changelogColumnAction.style.padding = '0 2px'; changelogColumnAction.style.background = changelogColours[changelog[i]['change_action']['action_id']]; changelogColumnMessage.appendChild(document.createTextNode(changelog[i]['change_message'])); diff --git a/_sakura/templates/yuuno/main/profile.tpl b/_sakura/templates/yuuno/main/profile.tpl index e93c262..caabfa6 100755 --- a/_sakura/templates/yuuno/main/profile.tpl +++ b/_sakura/templates/yuuno/main/profile.tpl @@ -102,13 +102,26 @@

Banned

{% elseif profile.checkPermission('SITE', 'RESTRICTED') %}

Restricted

+ {% elseif profile.getWarnings %} +

Bad

{% else %} - {% if profile.getWarnings %} -

Bad

- This user has {{ profile.getWarnings|length }} warning{% if profile.getWarnings|length != 1 %}s{% endif %}.
After 5 to 10 warnings (depending on what they are for) this user may be permanently banned.
- {% else %} -

Good

- {% endif %} +

Good

+ {% endif %} + {% if profile.getWarnings %} + + + + + + + {% for warning in profile.getWarnings %} + + + + + + {% endfor %} +
ActionDurationReason
{{ warning.warning_action_text }}{{ warning.warning_length }} minute{% if warning.warning_length != 1 %}s{% endif %}{{ warning.warning_reason }}
{% endif %} diff --git a/public/content/data/misaki/css/misaki.css b/public/content/data/misaki/css/misaki.css index 407d4bb..14f2d73 100755 --- a/public/content/data/misaki/css/misaki.css +++ b/public/content/data/misaki/css/misaki.css @@ -22,6 +22,18 @@ */ @import url('markdown.css'); +/* + * Keyframe definitions + */ +@keyframes spin { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(360deg); + } +} + /* * Reset margin and padding */ @@ -200,6 +212,12 @@ a:active { margin: auto; } +#header .logo.loading { + transform-origin: 50% 50.5%; + animation: spin 2s infinite linear; + background-image: url('../images/spinner.svg'); +} + #header .social { z-index: 1; font-size: 2.5em; @@ -273,6 +291,7 @@ a:active { margin-bottom: 5px; position: relative; z-index: 900; + max-width: 1018px; } #content > #navigation > ul > li { @@ -281,7 +300,8 @@ a:active { } #content > #navigation > ul > li > a:not(.ignore) { - min-width: 80px; + height: 30px; + line-height: 30px; display: inline-block; text-align: center; color: inherit; diff --git a/public/content/data/misaki/images/spinner.svg b/public/content/data/misaki/images/spinner.svg new file mode 100644 index 0000000..1550bd4 --- /dev/null +++ b/public/content/data/misaki/images/spinner.svg @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/content/data/misaki/js/misaki.js b/public/content/data/misaki/js/misaki.js index 5abd0f7..606db58 100755 --- a/public/content/data/misaki/js/misaki.js +++ b/public/content/data/misaki/js/misaki.js @@ -73,9 +73,26 @@ function convertParallaxPositionValue(pos, dir, neg) { } // Subtract another 2.5 to make the element not go all over the place - position = position - 2.5; + position = position - 2.5; // Return the proper position value return position; } + +// Menu bar +window.addEventListener("scroll", function(e) { + if(e.pageY > 123) { + var content = document.getElementById('content'); + var navigation = document.getElementById('navigation'); + navigation.style.position = 'fixed'; + navigation.style.top = '0'; + content.style.paddingTop = '37px'; + } else { + var content = document.getElementById('content'); + var navigation = document.getElementById('navigation'); + navigation.style.position = null; + navigation.style.top = null; + content.style.paddingTop = null; + } +}); diff --git a/public/content/data/yuuno/css/yuuno.css b/public/content/data/yuuno/css/yuuno.css index 67923f9..ee0ab84 100755 --- a/public/content/data/yuuno/css/yuuno.css +++ b/public/content/data/yuuno/css/yuuno.css @@ -1237,6 +1237,50 @@ a.default:active { } +/* + * Panel table + */ +.panelTable { + width: 100%; + font-size: .8em; + line-height: 1.5em; + border-spacing: 1px; +} + +.panelTable th { + background: #9475B2; + color: #306; +} + +.panelTable td:first-child { + padding: 0 2px; + text-align: center; +} + +.panelTable .warning td { + background: #A22; + color: #FFF; +} + +.panelTable .silence td { + background: #A22; + color: #FFF; +} + +.panelTable .restriction td { + background: #822; + color: #FFF; +} + +.panelTable .ban td { + background: #444; + color: #FFF; +} + +.panelTable .abyss td { + background: #888; +} + /* * User Background */ @@ -1509,7 +1553,7 @@ a.default:active { color: #503170; } -@media (min-width: 840px) { +@media (min-width: 1024px) { .support .featureBox.final { width: 818px; @@ -1523,10 +1567,19 @@ a.default:active { @media (max-width: 840px) { + .support .featureBox, + .support .featureBox.final { + width: 380px; + } + .support .featureBox.final .featureBoxDesc { line-height: 25px; } + .support .featureBox .right { + display: none; + } + } .support .featureBoxIcon.right {