diff --git a/libraries/Controllers/AuthController.php b/libraries/Controllers/AuthController.php
index 5fe9703..09fc7e6 100644
--- a/libraries/Controllers/AuthController.php
+++ b/libraries/Controllers/AuthController.php
@@ -197,10 +197,12 @@ class AuthController extends Controller
->orWhere('last_ip', Net::pton(Net::IP()))
->get();
- Template::vars([
- 'haltRegistration' => count($getUserIP) > 1,
- 'haltName' => $getUserIP[array_rand($getUserIP)]->username,
- ]);
+ if ($getUserIP) {
+ Template::vars([
+ 'haltRegistration' => count($getUserIP) > 1,
+ 'haltName' => $getUserIP[array_rand($getUserIP)]->username,
+ ]);
+ }
return Template::render('main/register');
}
diff --git a/libraries/Controllers/ForumController.php b/libraries/Controllers/ForumController.php
index 68b7410..542e94a 100644
--- a/libraries/Controllers/ForumController.php
+++ b/libraries/Controllers/ForumController.php
@@ -16,7 +16,6 @@ use Sakura\Perms\Forum as ForumPerms;
use Sakura\Router;
use Sakura\Template;
use Sakura\User;
-use Sakura\Users;
/**
* Forum page controllers.
@@ -33,24 +32,85 @@ class ForumController extends Controller
*/
public function index()
{
- // Merge index specific stuff with the global render data
- Template::vars([
- 'forum' => (new Forum()),
- 'stats' => [
- 'userCount' => DB::table('users')
- ->where('password_algo', '!=', 'disabled')
- ->whereNotIn('rank_main', [1, 10])
- ->count(),
- 'newestUser' => User::construct(Users::getNewestUserId()),
- 'lastRegDate' => date_diff(
- date_create(date('Y-m-d', User::construct(Users::getNewestUserId())->registered)),
- date_create(date('Y-m-d'))
- )->format('%a'),
- 'topicCount' => DB::table('topics')->count(),
- 'postCount' => DB::table('posts')->count(),
- 'onlineUsers' => Users::checkAllOnline(),
- ],
- ]);
+ global $currentUser;
+
+ // Get the most active threads
+ $activeThreadsIds = DB::table('posts')
+ ->groupBy('topic_id')
+ ->orderByRaw('COUNT(*) DESC')
+ ->limit(10)
+ ->get(['topic_id']);
+ $activeThreads = [];
+
+ while (list($_n, $_t) = each($activeThreadsIds)) {
+ // Create the thread object
+ $thread = new Thread($_t->topic_id);
+
+ // Create a forum object
+ $forum = new Forum($thread->forum);
+
+ // Check if we have permission to view it
+ if (!$forum->permission(ForumPerms::VIEW, $currentUser->id)) {
+ $fetch = DB::table('posts')
+ ->groupBy('topic_id')
+ ->orderByRaw('COUNT(*) DESC')
+ ->skip(11 + $_n)
+ ->take(1)
+ ->get(['topic_id']);
+
+ if ($fetch) {
+ $activeThreadsIds[] = $fetch[0];
+ }
+ continue;
+ }
+
+ $activeThreads[$thread->id] = $thread;
+ }
+
+ // Get the latest posts
+ $latestPostsIds = DB::table('posts')
+ ->orderBy('post_id', 'desc')
+ ->limit(10)
+ ->get(['post_id']);
+ $latestPosts = [];
+
+ while (list($_n, $_p) = each($latestPostsIds)) {
+ // Create new post object
+ $post = new Post($_p->post_id);
+
+ // Forum id
+ $forum = new Forum($post->forum);
+
+ // Check if we have permission to view it
+ if (!$forum->permission(ForumPerms::VIEW, $currentUser->id)) {
+ $fetch = DB::table('posts')
+ ->orderBy('post_id', 'desc')
+ ->skip(11 + $_n)
+ ->take(1)
+ ->get(['post_id']);
+
+ if ($fetch) {
+ $latestPostsIds[] = $fetch[0];
+ }
+ continue;
+ }
+
+ $latestPosts[$post->id] = $post;
+ }
+
+ // Get the most active poster
+ $activePosterId = DB::table('posts')
+ ->where('post_time', '>', time() - (24 * 60 * 60))
+ ->groupBy('poster_id')
+ ->orderByRaw('COUNT(*) DESC')
+ ->limit(1)
+ ->get(['poster_id']);
+ $activePoster = User::construct($activePosterId[0]->poster_id);
+
+ // Create the forum object
+ $forum = new Forum;
+
+ Template::vars(compact('forum', 'activeThreads', 'latestPosts', 'activePoster'));
// Return the compiled page
return Template::render('forum/index');
diff --git a/libraries/Controllers/UserController.php b/libraries/Controllers/UserController.php
index ed36e76..f60e95a 100644
--- a/libraries/Controllers/UserController.php
+++ b/libraries/Controllers/UserController.php
@@ -109,8 +109,6 @@ class UserController extends Controller
}
// Get all ranks
-
- // Execute query
$getRanks = DB::table('ranks')
->get(['rank_id']);
diff --git a/libraries/Forum/Post.php b/libraries/Forum/Post.php
index 16d2665..0e08ac1 100644
--- a/libraries/Forum/Post.php
+++ b/libraries/Forum/Post.php
@@ -233,4 +233,29 @@ class Post
->where('post_id', $this->id)
->delete();
}
+
+ /**
+ * Check if a user has read this post before.
+ *
+ * @param mixed $user The id of the user in question.
+ *
+ * @return bool A boolean indicating the read status.
+ */
+ public function unread($user)
+ {
+ // Attempt to get track row from the database
+ $track = DB::table('topics_track')
+ ->where('user_id', $user)
+ ->where('topic_id', $this->thread)
+ ->where('mark_time', '>', $this->time)
+ ->count();
+
+ // If nothing was returned it's obvious that the status is unread
+ if (!$track) {
+ return true;
+ }
+
+ // Else just return false meaning everything is read
+ return false;
+ }
}
diff --git a/libraries/Rank.php b/libraries/Rank.php
index b5e21c3..6350ca5 100644
--- a/libraries/Rank.php
+++ b/libraries/Rank.php
@@ -190,6 +190,7 @@ class Rank
// Fetch all users part of this rank
$get = DB::table('user_ranks')
->where('rank_id', $this->id)
+ ->orderBy('user_id')
->get(['user_id']);
// Filter the user ids into one array
diff --git a/public/content/data/yuuno/css/yuuno.css b/public/content/data/yuuno/css/yuuno.css
index 07dd7ff..45ec906 100644
--- a/public/content/data/yuuno/css/yuuno.css
+++ b/public/content/data/yuuno/css/yuuno.css
@@ -251,14 +251,8 @@ a.default:active {
width: 334px;
}
-.content-left .head,
-.news .head,
-.support .head,
-.viewforum .head,
-.viewtopic .head,
-.posting .head,
-.loginPage .head,
-.messages .head {
+.content .head,
+.loginPage .head {
margin: -1px -2px;
padding: 4px 5px 5px;
font-weight: 700;
@@ -1321,13 +1315,12 @@ a.default:active {
}
.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;
+ background: no-repeat center center / cover #FFF;
}
.new-profile .new-profile-username {
@@ -2517,3 +2510,27 @@ button.forumbtn {
#comments ul > li > ul .comment > textarea.comment-content {
height: 40px;
}
+
+/*
+ * User container
+ */
+.user-container {
+ display: flex;
+ align-items: center;
+ background: no-repeat center center / cover transparent;
+}
+
+.user-container-avatar {
+ height: 100px;
+ width: 100px;
+ margin: 0 2px;
+ flex-grow: 0;
+ flex-shrink: 0;
+ background: no-repeat center center / cover #FFF;
+}
+
+.user-container-info {
+ background: rgba(211, 191, 255, .8);
+ width: 100%;
+ padding: 0 5px;
+}
diff --git a/sakura.php b/sakura.php
index 69e2835..b77199a 100644
--- a/sakura.php
+++ b/sakura.php
@@ -8,7 +8,7 @@
namespace Sakura;
// Define Sakura version
-define('SAKURA_VERSION', '20160320');
+define('SAKURA_VERSION', 20160324);
// Define Sakura Path
define('ROOT', __DIR__ . '/');
@@ -103,7 +103,7 @@ $currentUser = User::construct($authCheck[0]);
// Create the Urls object
$urls = new Urls();
-// Prepare the name of the template to load (outside of SAKURA_NO_TPL because it's used in imageserve.php)
+// Prepare the name of the template to load
$templateName =
!defined('SAKURA_MANAGE')
&& isset($currentUser->optionFields()['useMisaki'])
diff --git a/templates/yuuno/elements/indexPanel.twig b/templates/yuuno/elements/indexPanel.twig
index 1f2c221..d225cf2 100644
--- a/templates/yuuno/elements/indexPanel.twig
+++ b/templates/yuuno/elements/indexPanel.twig
@@ -1,12 +1,15 @@
{% if session.checkLogin %}
-
Hi, {{ user.username }}!
-
-
-
+
{% else %}
{% if sakura.lockAuth %}
Whoops!
diff --git a/templates/yuuno/forum/index.twig b/templates/yuuno/forum/index.twig
index f0f2f33..6fb733a 100644
--- a/templates/yuuno/forum/index.twig
+++ b/templates/yuuno/forum/index.twig
@@ -7,7 +7,54 @@
{% block content %}
- {% include 'elements/indexPanel.twig' %}
+
+
Popular threads
+
+
+ Title |
+ Last reply |
+
+ {% for _t in activeThreads %}
+
+
+ {{ _t.title }}
+ |
+ |
+
+ {% endfor %}
+
+
+
+
{% include 'forum/forum.twig' %}
@@ -15,7 +62,3 @@
{% endblock %}
-
-{% block js %}
-
-{% endblock %}