r20160126

This commit is contained in:
Pachira 2016-01-26 19:09:18 +01:00
parent 9fb540daf8
commit 7d23f1b6c7
11 changed files with 425 additions and 15 deletions

View file

@ -17,13 +17,12 @@ if (function_exists('posix_getuid')) {
// Define that this page won't require templating
define('SAKURA_NO_TPL', true);
// To prevent the CLI from showing up
define('SAKURA_CRON', true);
// Include components
require_once 'sakura.php';
// Override expiration variables
ignore_user_abort(true);
set_time_limit(0);
// Clean expired sessions
Database::delete('sessions', [
'session_expire' => [time(), '<'],

24
libraries/DB.php Normal file
View file

@ -0,0 +1,24 @@
<?php
/*
* Database wrapper (v2)
*/
namespace Sakura;
use PDO;
use PDOException;
/**
* Class DB
* @package Sakura
*/
class DB
{
// Database container
private static $pdo;
// Initialisation function
public static function init($wrapper)
{
}
}

View file

@ -485,6 +485,7 @@ a:active {
display: flex;
align-items: flex-end;
box-shadow: 0 2px 6px rgba(0, 0, 0, .75);
background: no-repeat center center / cover transparent;
}
#profileHeader.floating {

View file

@ -1319,6 +1319,212 @@ a.default:active {
}
/*
* New profile page styling
*/
.new-profile {
background: rgba(211, 191, 255, .8) !important;
}
.new-profile .new-profile-header {
height: 200px;
background: no-repeat center center / cover transparent;
width: 100%;
display: flex;
align-items: center;
border-bottom: 1px solid #9475b2;
}
.new-profile .new-profile-info {
height: 100%;
width: 100%;
background: linear-gradient(0deg, rgba(211, 191, 255, .8), rgba(211, 191, 255, .8) 52px, transparent 52px, transparent);
width: 100%;
display: flex;
align-items: center;
}
.new-profile .new-profile-avatar {
margin: 0;
height: 190px;
width: 190px;
margin: 0 2px;
flex-grow: 0;
flex-shrink: 0;
background: no-repeat center center / cover transparent;
}
.new-profile .new-profile-username {
align-self: flex-end;
margin-left: 4px;
}
.new-profile .new-profile-dates {
font-size: .8em;
line-height: 1.4em;
text-align: right;
align-self: flex-end;
flex-grow: 5;
height: 45px;
}
.new-profile .new-profile-interactions {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 2.5em;
line-height: 1.4em;
border-bottom: 1px solid #9475b2;
}
.new-profile .new-profile-interactions a {
color: #8364A1;
text-decoration: none;
text-shadow: 0 0 2px #9475B2;
transition: all .2s;
}
.new-profile .new-profile-interactions a:hover {
text-shadow: 0 0 6px #9475B2;
}
.new-profile .new-profile-interactions a:active {
color: #725390;
text-shadow: 0 0 8px #8364A1;
}
.new-profile .new-profile-navigation {
margin-left: 5px;
}
.new-profile .new-profile-actions {
border-left: 1px solid #9475b2;
min-width: 345px;
text-align: right;
margin-right: 5px;
}
.new-profile .new-profile-content {
display: flex;
justify-content: space-between;
}
.new-profile .new-profile-data {
display: block;
width: 350px;
border-left: 1px solid #9475b2;
flex-shrink: 0;
text-align: center;
}
.new-profile .new-profile-mode {
width: 100%;
flex-grow: 0;
margin-right: 2px;
overflow: auto;
}
.new-profile .new-profile-mode-title {
padding-bottom: 2px;
border-bottom: 1px solid #9475b2;
margin-bottom: 2px;
}
@media (max-width: 1032px) {
.new-profile .new-profile-info {
background: rgba(211, 191, 255, .5);
flex-flow: column;
}
.new-profile .new-profile-avatar {
height: 120px;
width: 120px;
margin: 2px;
}
.new-profile .new-profile-dates,
.new-profile .new-profile-username {
flex-grow: 6;
width: 100%;
text-align: center;
}
.new-profile .new-profile-dates br {
content: "";
}
.new-profile .new-profile-dates br:before {
content: "- ";
}
.new-profile .new-profile-interactions {
flex-flow: column;
}
.new-profile .new-profile-navigation,
.new-profile .new-profile-actions {
border: 0;
width: 100%;
text-align: center;
margin: 0;
}
.new-profile .new-profile-content {
flex-flow: column-reverse;
}
.new-profile .new-profile-data {
width: 100%;
border-bottom: 1px solid #9475b2;
border-left: 0;
}
.new-profile .new-profile-mode {
margin: 0;
}
}
@media (max-width: 500px) {
.new-profile .new-profile-dates {
display: none;
}
}
/*
* Friends section
*/
.profile-friends {
text-align: center;
}
.profile-friends > div:not(:last-child) {
display: inline-block;
border: 1px solid #9475B2;
text-align: center;
width: 200px;
margin: 4px 0;
border-radius: 3px;
box-shadow: inset 0 0 1px #9475B2;
background: #E4CFFF;
transition: background .2s, box-shadow .2s;
}
.profile-friends > div:not(:last-child):hover {
background: #C2AFFE;
box-shadow: inset 0 0 2px #9475B2;
}
.profile-friends > div > .friends-list-data {
display: block;
}
.profile-friends > div > .friends-list-data > .friends-list-name {
font-size: 1.2em;
line-height: 1.5em;
padding-bottom: 4px;
}
/*
* Panel table
*/

View file

@ -21,10 +21,11 @@ $profile = User::construct(isset($_GET['u']) ? $_GET['u'] : 0);
// Views array
$views = [
'index',
/*'friends',
'threads',
'posts',*/
'friends',
//'threads',
//'posts',
'comments',
//'groups',
];
// Assign the object to a renderData variable

View file

@ -8,7 +8,7 @@
namespace Sakura;
// Define Sakura version
define('SAKURA_VERSION', '20160122');
define('SAKURA_VERSION', '20160126');
define('SAKURA_VLABEL', 'Amethyst');
define('SAKURA_COLOUR', '#9966CC');
@ -18,6 +18,10 @@ define('ROOT', __DIR__ . '/');
// Turn error reporting on for the initial startup sequence
error_reporting(-1);
// Override expiration variables
ignore_user_abort(true);
set_time_limit(0);
// Set internal encoding method
mb_internal_encoding('utf-8');
@ -38,6 +42,7 @@ require_once ROOT . 'libraries/BBcode.php';
require_once ROOT . 'libraries/Comments.php';
require_once ROOT . 'libraries/Config.php';
require_once ROOT . 'libraries/CSRF.php';
require_once ROOT . 'libraries/DB.php';
require_once ROOT . 'libraries/Database.php';
require_once ROOT . 'libraries/File.php';
require_once ROOT . 'libraries/Hashing.php';
@ -86,7 +91,7 @@ Config::initDB();
Whois::setServers(ROOT . Config::local('data', 'whoisservers'));
// Check if we're using console
if (php_sapi_name() === 'cli') {
if (php_sapi_name() === 'cli' && !defined('SAKURA_CRON')) {
$console = new Console\Application;
$console->run($argv);
exit;

View file

@ -22,10 +22,10 @@
</ul>
</div>
</div>
{% else %}
{% elseif get.old %}
<div class="content profile">
<div class="content-right content-column">
<div style="text-align: center;{% if profile.header %} background: url({{ urls.format('IMAGE_HEADER', [profile.id]) }}) no-repeat center top; background-size: 336px;{% endif %}">
<div style="text-align: center;">
<img src="{{ urls.format('IMAGE_AVATAR', [profile.id]) }}" alt="{{ profile.username }}'s Avatar" class="default-avatar-setting" style="box-shadow: 0 3px 7px #{% if profile.isOnline %}484{% else %}844{% endif %};" /><br />
{% if profile.mainRankId > 1 and profile.checkBan|length < 1 %}
<span style="font-size: .8em;">{{ profile.title }}</span>
@ -46,8 +46,8 @@
<hr class="default" />
<a class="fa fa-file-text-o" title="View {{ profile.username }}'s user page" href="{{ urls.format('USER_PROFILE', [profile.id]) }}"></a>
{#<a class="fa fa-list" title="View {{ profile.username }}'s threads" href="{{ urls.format('USER_THREADS', [profile.id]) }}"></a>
<a class="fa fa-reply" title="View {{ profile.username }}'s posts" href="{{ urls.format('USER_POSTS', [profile.id]) }}"></a>
<a class="fa fa-star" title="View {{ profile.username }}'s friends" href="{{ urls.format('USER_FRIENDS', [profile.id]) }}"></a> shh #}
<a class="fa fa-reply" title="View {{ profile.username }}'s posts" href="{{ urls.format('USER_POSTS', [profile.id]) }}"></a> shh #}
<a class="fa fa-star" title="View {{ profile.username }}'s friends" href="{{ urls.format('USER_FRIENDS', [profile.id]) }}"></a>
{#<a class="fa fa-users" title="View {{ profile.username }}'s groups" href="{{ urls.format('USER_GROUPS', [profile.id]) }}"></a>#}
{% if not noUserpage %}
<a class="fa fa-comments-o" title="View {{ profile.username }}'s profile comments" href="{{ urls.format('USER_COMMENTS', [profile.id]) }}"></a>
@ -149,5 +149,152 @@
</div>
<div class="clear"></div>
</div>
{% else %}
<div class="content new-profile">
<div class="new-profile-container">
<div class="new-profile-header" style="background-image: url({{ urls.format('IMAGE_HEADER', [profile.id]) }});">
<div class="new-profile-info">
<div class="default-avatar-setting new-profile-avatar" style="background-image: url({{ urls.format('IMAGE_AVATAR', [profile.id]) }}); box-shadow: 0 0 5px #{% if profile.isOnline %}484{% else %}844{% endif %};"></div>
<div class="new-profile-username">
<h1 style="color: {{ profile.colour }}; text-shadow: 0 0 7px {% if profile.colour != 'inherit' %}{{ profile.colour }}{% else %}#222{% endif %}; padding: 0 0 2px;" {% if profile.getUsernameHistory %} title="Known as {{ profile.getUsernameHistory[0]['username_old'] }} before {{ profile.getUsernameHistory[0]['change_time']|date(sakura.dateFormat) }}." {% endif %}>{{ profile.username }}</h1>
{% if profile.isPremium[0] %}<img src="{{ sakura.contentPath }}/images/tenshi.png" alt="Tenshi" style="vertical-align: middle;" /> {% endif %}<img src="{{ sakura.contentPath }}/images/flags/{{ profile.country|lower }}.png" alt="{{ profile.country }}" style="vertical-align: middle;" title="{{ profile.country(true) }}" /> <span style="font-size: .8em;">{{ profile.title }}</span>
</div>
<div class="new-profile-dates">
<b>Joined</b> <span title="{{ profile.registered|date(sakura.dateFormat) }}">{{ profile.elapsed.joined }}</span>
<br />
{% if profile.lastOnline < 1 %}
<b>{{ profile.username }} hasn't logged in yet.</b>
{% else %}
<b>Last online</b> <span title="{{ profile.lastOnline|date(sakura.dateFormat) }}">{{ profile.elapsed.lastOnline }}</span>
{% endif %}
{% if profile.birthday != '0000-00-00' and profile.birthday|split('-')[0] > 0 %}
<br /><b>Age</b> <span title="{{ profile.birthday }}">{{ profile.birthday(true) }} years old</span>&nbsp;
{% endif %}
</div>
</div>
</div>
<div class="new-profile-interactions">
<div class="new-profile-navigation">
<a class="fa fa-file-text-o" title="View {{ profile.username }}'s user page" href="{{ urls.format('USER_PROFILE', [profile.id]) }}"></a>
{#<a class="fa fa-list" title="View {{ profile.username }}'s threads" href="{{ urls.format('USER_THREADS', [profile.id]) }}"></a>
<a class="fa fa-reply" title="View {{ profile.username }}'s posts" href="{{ urls.format('USER_POSTS', [profile.id]) }}"></a>#}
<a class="fa fa-star" title="View {{ profile.username }}'s friends" href="{{ urls.format('USER_FRIENDS', [profile.id]) }}"></a>
{#<a class="fa fa-users" title="View {{ profile.username }}'s groups" href="{{ urls.format('USER_GROUPS', [profile.id]) }}"></a>#}
{% if not noUserpage %}
<a class="fa fa-comments-o" title="View {{ profile.username }}'s profile comments" href="{{ urls.format('USER_COMMENTS', [profile.id]) }}"></a>
{% endif %}
</div>
{% if session.checkLogin %}
<div class="new-profile-actions">
{% if user.id == profile.id %}
<a class="fa fa-pencil-square-o" title="Edit your profile" href="{{ urls.format('SETTING_MODE', ['general', 'profile']) }}"></a>
{% else %}
{% if user.isFriends(profile.id) != 0 %}<a class="fa fa-{% if user.isFriends(profile.id) == 2 %}heart{% else %}star{% endif %}" title="You are friends"></a>{% endif %}
<a class="fa fa-user-{% if user.isFriends(profile.id) == 0 %}plus{% else %}times{% endif %}" title="{% if user.isFriends(profile.id) == 0 %}Add {{ profile.username }} as a friend{% else %}Remove friend{% endif %}" href="{% if user.isFriends(profile.id) == 0 %}{{ urls.format('FRIEND_ADD', [profile.id, php.sessionid, php.time, sakura.currentPage]) }}{% else %}{{ urls.format('FRIEND_REMOVE', [profile.id, php.sessionid, php.time, sakura.currentPage]) }}{% endif %}" id="profileFriendToggle"></a>
{#<a class="fa fa-exclamation-circle" title="Report {{ profile.username }}" href="{{ urls.format('USER_REPORT', [profile.id]) }}"></a>#}
{% endif %}
{% if user.permission(constant('Sakura\\Perms\\Manage::CAN_RESTRICT_USERS'), constant('Sakura\\Perms::MANAGE')) %}
<a class="fa fa-trash" title="Restrict {{ profile.username }}" href="?restrict={{ php.sessionid }}"></a>
{% endif %}
</div>
{% endif %}
</div>
<div class="new-profile-content">
<div class="new-profile-mode">
<div>
{% include 'profile/' ~ profileView ~ '.twig' %}
</div>
</div>
<div class="new-profile-data">
<table style="width: 100%;">
<tr>
<td style="text-align: left; font-weight: bold;">Threads</td>
<td style="text-align: right;">{{ profile.forumStats.topics }}</td>
</tr>
<tr>
<td style="text-align: left; font-weight: bold;">Posts</td>
<td style="text-align: right;">{{ profile.forumStats.posts }}</td>
</tr>
<tr>
<td style="text-align: left; font-weight: bold;">Friends</td>
<td style="text-align: right;">{{ profile.friends(2)|length }}</td>
</tr>
</table>
<hr class="default" />
{% if profile.profileFields or user.permission(constant('Sakura\\Perms\\Manage::USE_MANAGE'), constant('Sakura\\Perms::MANAGE')) %}
{% if session.checkLogin %}
<table style="width: 100%;">
{% for name,field in profile.profileFields %}
<tr>
<td style="text-align: left; font-weight: bold;">
{{ field.name }}
</td>
<td style="text-align: right;">
{% if name == 'youtube' %}
<a href="https://youtube.com/{% if field.youtubetype == true %}channel{% else %}user{% endif %}/{{ field.value }}" class="default">{% if field.youtubetype == true %}{{ profile.username }}'s Channel{% else %}{{ field.value }}{% endif %}</a>
{% else %}
{% if field.islink %}
<a href="{{ field.link }}" class="default">
{% endif %}
{{ field.value }}
{% if field.islink %}
</a>
{% endif %}
{% endif %}
</td>
</tr>
{% endfor %}
{% if user.permission(constant('Sakura\\Perms\\Manage::USE_MANAGE'), constant('Sakura\\Perms::MANAGE')) %}
<tr>
<td style="text-align: left; font-weight: bold;">E-mail address</td>
<td style="text-align: right;"><a href="mailto:{{ profile.email }}" class="default">{{ profile.email }}</a></td>
</tr>
<tr>
<td style="text-align: left; font-weight: bold;">Register IP</td>
<td style="text-align: right;">{{ profile.registerIp }}</td>
</tr>
<tr>
<td style="text-align: left; font-weight: bold;">Last IP</td>
<td style="text-align: right;">{{ profile.lastIp }}</td>
</tr>
{% endif %}
</table>
{% else %}
<b>Log in to view the full profile!</b>
{% endif %}
{% endif %}
<hr class="default" />
<b>Account Standing</b>
{% if profile.permission(constant('Sakura\\Perms\\Site::DEACTIVATED')) %}
<h2 style="color: #888; text-shadow: 0 0 7px #888; margin-top: 0;">Deactivated</h2>
{% elseif profile.checkBan %}
<h2 style="color: #222; text-shadow: 0 0 7px #222; margin-top: 0;">Banned</h2>
{% elseif profile.permission(constant('Sakura\\Perms\\Site::RESTRICTED')) %}
<h2 style="color: #800; text-shadow: 0 0 7px #800; margin-top: 0;">Restricted</h2>
{% elseif profile.getWarnings %}
<h2 style="color: #A00; text-shadow: 0 0 7px #A00; margin-top: 0;">Bad</h2>
{% else %}
<h2 style="color: #080; text-shadow: 0 0 7px #080; margin-top: 0;">Good</h2>
{% endif %}
{% if profile.getWarnings %}
<table class="panelTable">
<tr>
<th>Action</th>
<th>Duration</th>
<th>Reason</th>
</tr>
{% for warning in profile.getWarnings %}
<tr class="{{ warning.warning_action_text|lower }}">
<td>{{ warning.warning_action_text }}</td>
<td>{{ warning.warning_length }} minute{% if warning.warning_length != 1 %}s{% endif %}</td>
<td>{{ warning.warning_reason }}</td>
</tr>
{% endfor %}
</table>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
{% endblock %}

View file

@ -1,3 +1,6 @@
{% set comments = profile.profileComments.comments %}
{% set commentsCategory = 'profile-' ~ profile.id %}
<div class="new-profile-mode-title">
<h1 class="stylised">Comments</h1>
</div>
{% include 'elements/comments.twig' %}

View file

@ -0,0 +1,24 @@
{% set friends = profile.friends(2)|batch(12) %}
{% set paginationPages = friends %}
{% set paginationUrl %}{{ urls.format('SETTING_MODE', ['friends', 'listing']) }}{% endset %}
<div class="new-profile-mode-title">
<h1 class="stylised">Friends</h1>
</div>
<div class="profile-friends">
{% for friend in friends[get.page|default(1) - 1] %}
<div class="friend-container" id="friendslist-friend-{{ friend.id }}">
<a class="friends-list-data clean" href="{{ urls.format('USER_PROFILE', [friend.id]) }}">
<img src="{{ urls.format('IMAGE_AVATAR', [friend.id]) }}" alt="{{ friend.username }}" class="friends-list-avatar default-avatar-setting" style="width: 150px; height: 150px;" />
<div class="friends-list-name" style="color: {{ friend.colour }};">{{ friend.username }}</div>
</a>
</div>
{% endfor %}
<div class="clear"></div>
{% if friends|length > 1 %}
<div>
{% include 'elements/pagination.twig' %}
</div>
{% endif %}
</div>

View file

@ -27,7 +27,7 @@ window.addEventListener("load", function() {
<div class="friends-list">
{% for friend in friends[get.page|default(1) - 1] %}
<div class="friend-container" id="friendslist-friend-{{ friend.id }}">
<a class="friends-list-data clean" href="/u/{{ friend.id }}">
<a class="friends-list-data clean" href="{{ urls.format('USER_PROFILE', [friend.id]) }}">
<img src="/a/{{ friend.id }}" alt="{{ friend.username }}" class="friends-list-avatar default-avatar-setting" style="width: 150px; height: 150px;" />
<div class="friends-list-name" style="color: {{ friend.colour }};">{{ friend.username }}</div>
</a>

View file

@ -27,7 +27,7 @@ window.addEventListener("load", function() {
<div class="friends-list">
{% for friend in friends[get.page|default(1) - 1] %}
<div class="friend-container" id="friend-{{ friend.id }}">
<a class="friends-list-data clean" href="/u/{{ friend.id }}">
<a class="friends-list-data clean" href="{{ urls.format('USER_PROFILE', [friend.id]) }}">
<img src="/a/{{ friend.id }}" alt="{{ friend.username }}" class="friends-list-avatar default-avatar-setting" style="width: 150px; height: 150px;" />
<div class="friends-list-name" style="color: {{ friend.colour }};">{{ friend.username }}</div>
</a>