r20150915 (the last commit that claimed to be *15 was actually *14)

Signed-off-by: Flashwave <me@flash.moe>
This commit is contained in:
flash 2015-09-15 22:37:29 +02:00
parent 59c21289a1
commit c7670d2816
13 changed files with 260 additions and 26 deletions

View file

@ -2743,6 +2743,27 @@
"user": "Flashwave"
}
],
"20150915": [
"eminence",
{
"type": "FIX",
"change": "Fixed session cookies remaining after session dying, a more wholesome fix would require refactoring the session system so that's on the todo list now.",
"user": "Flashwave"
},
{
"type": "FIX",
"change": "Fixed friendslisting on Settings frontpage being broken.",
"user": "Flashwave"
},
{
"type": "FIX",
"change": "Fixed news page explosions.",
"user": "Flashwave"
}
]
}

View file

@ -7,5 +7,9 @@ namespace Sakura;
class Comments
{
// Constructor
public function ___construct()
{
//
}
}

View file

@ -0,0 +1,24 @@
<?php
/*
* User session container
*/
namespace Sakura;
class Session
{
// Current user data
public $userId;
public $sessionId;
// Initialise new session
public function ___construct()
{
// Check if a PHP session was already started and if not start one
if (session_status() != PHP_SESSION_ACTIVE) {
session_start();
}
}
}

View file

@ -0,0 +1,11 @@
<?php
/*
* File uploads handler
*/
namespace Sakura;
class Upload
{
}

View file

@ -67,13 +67,27 @@ class Users
}
}
// Check if the session exists
if (!$session = Session::checkSession($uid, $sid)) {
return false;
}
// Check if the session exists and check if the user is activated
if (!$session = Session::checkSession($uid, $sid)
|| Permissions::check('SITE', 'DEACTIVATED', $uid, 1)) {
// Unset User ID
setcookie(
Configuration::getConfig('cookie_prefix') . 'id',
0,
time() - 60,
Configuration::getConfig('cookie_path'),
Configuration::getConfig('cookie_domain')
);
// Unset Session ID
setcookie(
Configuration::getConfig('cookie_prefix') . 'session',
'',
time() - 60,
Configuration::getConfig('cookie_path'),
Configuration::getConfig('cookie_domain')
);
// Check if the user is activated
if (Permissions::check('SITE', 'DEACTIVATED', $uid, 1)) {
return false;
}
@ -200,8 +214,7 @@ class Users
return false;
}
// Set cookies
// User ID
// Unset User ID
setcookie(
Configuration::getConfig('cookie_prefix') . 'id',
0,
@ -210,7 +223,7 @@ class Users
Configuration::getConfig('cookie_domain')
);
// Session ID
// Unset Session ID
setcookie(
Configuration::getConfig('cookie_prefix') . 'session',
'',

View file

@ -8,7 +8,7 @@
namespace Sakura;
// Define Sakura version
define('SAKURA_VERSION', '20150914');
define('SAKURA_VERSION', '20150915');
define('SAKURA_VLABEL', 'Eminence');
define('SAKURA_COLOUR', '#6C3082');
define('SAKURA_STABLE', false);

View file

@ -0,0 +1,83 @@
<div class="comments">
<div class="comment-input-section">
{% if session.checkLogin %}
<form action="" method="post">
<input type="hidden" name="sessid" value="{{ php.sessionid }}" />
<input type="hidden" name="timestamp" value="{{ php.time }}" />
<input type="hidden" name="mode" value="comment" />
<div class="comment">
<div class="comment-avatar" style="background-image: url('{{ urls.format('IMAGE_AVATAR', [user.data.id]) }}');"></div>
<div class="comment-pointer"></div>
<textarea class="comment-text" class="comment" placeholder="Join the conversation..."></textarea>
<input class="comment-submit" name="submit" type="submit" value="&#xf1d8;" />
</div>
</form>
{% else %}
<h1 class="stylised" style="text-align: center;">Log in to comment!</h1>
{% endif %}
</div>
<div class="comments-discussion">
<ul class="comments-list">
<li>
<div class="comment">
<div class="comment-avatar" style="background-image: url('{{ urls.format('IMAGE_AVATAR', [user.data.id]) }}');"></div>
<div class="comment-pointer"></div>
<div class="comment-text">
aaaaaaaaaa
</div>
</div>
<ul>
<li>
<div class="comment">
<div class="comment-avatar" style="background-image: url('{{ urls.format('IMAGE_AVATAR', [1]) }}');"></div>
<div class="comment-pointer"></div>
<div class="comment-text">
aaaaaaaaaa
</div>
</div>
<ul>
<li>
<div class="comment">
<div class="comment-avatar" style="background-image: url('{{ urls.format('IMAGE_AVATAR', [user.data.id]) }}');"></div>
<div class="comment-pointer"></div>
<div class="comment-text">
aaaaaaaaaa
</div>
</div>
<ul>
<li>
<div class="comment">
<div class="comment-avatar" style="background-image: url('{{ urls.format('IMAGE_AVATAR', [3]) }}');"></div>
<div class="comment-pointer"></div>
<div class="comment-text">
aaaaaaaaaa
</div>
</div>
</li>
</ul>
</li>
<li>
<div class="comment">
<div class="comment-avatar" style="background-image: url('{{ urls.format('IMAGE_AVATAR', [1]) }}');"></div>
<div class="comment-pointer"></div>
<div class="comment-text">
aaaaaaaaaa
</div>
</div>
</li>
</ul>
</li>
<li>
<div class="comment">
<div class="comment-avatar" style="background-image: url('{{ urls.format('IMAGE_AVATAR', [2]) }}');"></div>
<div class="comment-pointer"></div>
<div class="comment-text">
aaaaaaaaaa
</div>
</div>
</li>
</ul>
</li>
</ul>
</div>
</div>

View file

@ -1,4 +1,4 @@
{% if not viewPost %}<a href="{{ urls.format('SITE_NEWS_POST', [post.id]) }}" class="news-head" id="{{ post.category }}_{{ post.id }}">{{ post.title }}</a>{% endif %}
{% if not (viewPost and postExists) %}<a href="{{ urls.format('SITE_NEWS_POST', [post.id]) }}" class="news-head" id="{{ post.category }}_{{ post.id }}">{{ post.title }}</a>{% endif %}
<div class="news-body">
<a class="no-underline" href="{{ urls.format('USER_PROFILE', [post.poster.data.id]) }}">
<div class="news-poster">
@ -12,5 +12,5 @@
</div>
<div class="clear"></div>
<div class="news-post-time">
Posted on {{ post.date|date(sakura.dateFormat) }}{% if not viewPost %} <a class="default" href="{{ urls.format('SITE_NEWS_POST', [post.id]) }}">X comments</a>{% endif %}
Posted on {{ post.date|date(sakura.dateFormat) }}{% if not (viewPost and postExists) %} <a class="default" href="{{ urls.format('SITE_NEWS_POST', [post.id]) }}">X comments</a>{% endif %}
</div>

View file

@ -248,7 +248,7 @@
{% block content %}
<h1 class="stylised" style="text-align: center; margin: 2em auto;">{{ php.self }} is now printing!</h1>
{% endblock %}
{#}
{#
<div id="chat">
<div id="chatOnlineUsers">
<div class="chatOnlineListTitle">

View file

@ -1,11 +1,11 @@
{% extends 'global/master.tpl' %}
{% set newsPosts = viewPost ? [news.getPost(postExists)] : news.getPosts(postsPerPage)[currentPage] %}
{% set newsPosts = viewPost and postExists ? [news.getPost(postExists)] : news.getPosts(postsPerPage)[currentPage] %}
{% set pagination = {'page': currentPage, 'pages': news.getPosts(postsPerPage), 'urlPattern': 'SITE_NEWS_PAGE'} %}
{% set title %}
{% if not newsPosts|length %}Post does not exist!{% elseif viewPost %}{{ newsPosts[0].title }}{% else %}News{% endif %}
{% if not (viewPost ? postExists : newsPosts|length) %}Post does not exist!{% elseif viewPost and postExists %}{{ newsPosts[0].title }}{% else %}News{% endif %}
{% endset %}
{% block title %}{{ title }}{% endblock %}
@ -21,17 +21,18 @@
{% block content %}
<div class="content">
<div class="content-column news">
<div class="head">{{ title }}{% if not viewPost %}<a href="{{ urls.format('SITE_NEWS_RSS') }}" class="fa fa-rss news-rss default"></a>{% endif %}</div>
{% if newsPosts|length %}
<div class="head">{{ title }}{% if not (viewPost and postExists) %}<a href="{{ urls.format('SITE_NEWS_RSS') }}" class="fa fa-rss news-rss default"></a>{% endif %}</div>
{% if (viewPost ? postExists : newsPosts|length) %}
{% for post in newsPosts %}
{% include 'elements/newsPost.tpl' %}
{% endfor %}
{% if not viewPost and news.getPosts(postsPerPage)|length > 1 %}
{% if not (viewPost and postExists) and news.getPosts(postsPerPage)|length > 1 %}
<div>
{% include 'elements/pagination.tpl' %}
<div class="clear"></div>
</div>
{% endif %}
{% include 'elements/comments.tpl' %}
{% else %}
<div style="padding: 20px;">
<h1>The requested news post does not exist!</h1>

View file

@ -30,7 +30,7 @@
<h2 style="color: #080;">Online</h2>
{% if user.getFriends(true, true, true).online %}
{% for key,friend in user.getFriends(true, true, true).online %}
<a href="/u/{{ friend.user.username }}" class="default" style="color: {% if friend.user.name_colour %}{{ friend.user.name_colour }}{% else %}{{ friend.rank.colour }}{% endif %}">{{ friend.user.username }}</a>{% if key + 1 != settings.friends.online|length %},{% endif %}
<a href="/u/{{ friend.user.username }}" class="default" style="color: {% if friend.user.name_colour %}{{ friend.user.name_colour }}{% else %}{{ friend.rank.colour }}{% endif %}">{{ friend.user.username }}</a>{% if key + 1 != user.getFriends(true, true, true).online|length %},{% endif %}
{% endfor %}
{% else %}
<h4>No friends are online.</h4>
@ -38,7 +38,7 @@
<h2 style="color: #800;">Offline</h2>
{% if user.getFriends(true, true, true).offline %}
{% for key,friend in user.getFriends(true, true, true).offline %}
<a href="/u/{{ friend.user.username }}" class="default" style="color: {% if friend.user.name_colour %}{{ friend.user.name_colour }}{% else %}{{ friend.rank.colour }}{% endif %}">{{ friend.user.username }}</a>{% if key + 1 != settings.friends.offline|length %},{% endif %}
<a href="/u/{{ friend.user.username }}" class="default" style="color: {% if friend.user.name_colour %}{{ friend.user.name_colour }}{% else %}{{ friend.rank.colour }}{% endif %}">{{ friend.user.username }}</a>{% if key + 1 != user.getFriends(true, true, true).offline|length %},{% endif %}
{% endfor %}
{% else %}
<h4>No friends are offline.</h4>

View file

@ -30,9 +30,9 @@ RewriteRule ^p/([a-z]+)/?$ index.php?p=$1 [L,QSA]
RewriteRule ^news/?$ news.php [L,QSA]
RewriteRule ^news/p([0-9]+)/?$ news.php?page=$1 [L,QSA]
RewriteRule ^news/([0-9]+)/?$ news.php?id=$1 [L,QSA]
RewriteRule ^news/([a-z]+)/?$ news.php?cat=$1 [L,QSA]
RewriteRule ^news/([a-z]+)/p([0-9]+)/?$ news.php?cat=$1&page=$2 [L,QSA]
RewriteRule ^news/([a-z]+)/([0-9]+)/?$ news.php?cat=$1&id=$2 [L,QSA]
RewriteRule ^news/([a-z\-]+)/?$ news.php?cat=$1 [L,QSA]
RewriteRule ^news/([a-z\-]+)/p([0-9]+)/?$ news.php?cat=$1&page=$2 [L,QSA]
RewriteRule ^news/([a-z\-]+)/([0-9]+)/?$ news.php?cat=$1&id=$2 [L,QSA]
RewriteRule ^news.xml$ news.php?xml [L,QSA]
# Settings

View file

@ -181,7 +181,7 @@ img {
max-height: 100%;
}
img.default-avatar-setting {
.default-avatar-setting {
max-width: 200px;
max-height: 200px;
border: 3px solid #EEE;
@ -591,7 +591,7 @@ a.default:active {
#chatUserList > div > .avatar {
width: 50px;
height: 50px;
background: transparent url("/pixel.png") no-repeat scroll left center / contain;
background: transparent url("/content/pixel.png") no-repeat scroll left center / contain;
border-radius: 5px;
}
@ -2094,3 +2094,80 @@ textarea.inputStyling {
padding: 6px 10px;
border-radius: 3px;
}
/*
* Comments
*/
.comments {
}
.comments .comment-input-section {
border-top: 1px solid #9475B2;
border-bottom: 1px solid #9475B2;
}
.comments .comment {
display: flex;
align-items: stretch;
margin: 2px 0;
}
.comments .comment > .comment-avatar {
height: 58px;
width: 58px;
background: url("/content/pixel.png") no-repeat scroll left center / contain;
flex-shrink: 0;
margin-right: 2px;
border-radius: 4px;
border: 1px solid #9475B2;
}
.comments .comment > .comment-pointer {
width: 0px;
height: 0px;
border-style: solid;
border-width: 0px 15px 15px 0px;
border-color: transparent #FFF transparent transparent;
}
.comments .comment > .comment-text {
border-radius: 0 5px 5px 5px;
border: 0;
min-height: 50px;
height: 50px;
flex-grow: 2;
padding: 5px;
font: 12px/20px "SegoeUI", "Segoe UI", sans-serif;
background: #FFF;
}
.comments .comment > .comment-submit {
flex-shrink: 0;
font-family: FontAwesome;
height: 60px;
width: 60px;
border-radius: 4px;
margin-left: 2px;
border: 0;
background: #9475B2;
color: #FFF;
font-size: 2em;
}
.comments ul {
list-style: none;
}
.comments ul > li > ul {
margin-left: 40px;
}
.comments ul > li > ul .comment > .comment-avatar {
height: 48px;
width: 48px;
}
.comments ul > li > ul .comment > .comment-text {
min-height: 40px;
height: 40px;
}