Forgot to commit yesterday

This commit is contained in:
Pachira 2015-04-30 14:12:49 +00:00
parent b43cdb4844
commit bf7b7bc8b9
15 changed files with 155 additions and 27 deletions

View file

@ -17,7 +17,9 @@
"20150427.6",
"20150427.7",
"20150427.8",
"20150428"
"20150428",
"20150429",
"20150430"
]
@ -822,6 +824,28 @@
"change": "Move Sock Chat permissioning to database as opposed to a static file."
}
],
"20150429": [
{
"type": "FIX",
"change": "Fix chat online users counter on frontpage."
},
{
"type": "ADD",
"change": "Added FAQ page."
}
],
"20150430": [
{
"type": "ADD",
"change": "Begin work on management panel."
}
]
}

View file

@ -497,4 +497,15 @@ class Main {
}
// Get FAQ data
public static function getFaqData() {
// Do database call
$faq = Database::fetch('faq', true, null, ['id']);
// Return FAQ data
return $faq;
}
}

View file

@ -26,7 +26,7 @@ class SockChat {
// Parse permission string
foreach($perms as $id => $perm)
$perms[$id]['perms'] = self::parsePerms($perm['perms']);
$perms[$id]['perms'] = self::decodePerms($perm['perms']);
// Return the permission data
return $perms;
@ -49,7 +49,7 @@ class SockChat {
}
// Parse permission string
$perms = self::parsePerms($perms['perms']);
$perms = self::decodePerms($perms['perms']);
// Return the permission data
return $perms;
@ -74,15 +74,15 @@ class SockChat {
}
// Parse permission string
$perms = self::parsePerms($perms['perms']);
$perms = self::decodePerms($perms['perms']);
// Return the permission data
return $perms;
}
// Parse permission string
public static function parsePerms($perms) {
// Decode permission string
public static function decodePerms($perms) {
// Explode the commas
$exploded = is_array($perms) ? $perms : explode(',', $perms);
@ -103,4 +103,40 @@ class SockChat {
}
// Encode permission string
public static function encodePerms($perms) {
// Create array
$encoded = array();
// Put the data in the correct order
$encoded[ self::$_PERMS_ACCESS_INDEX ] = empty($perms['access']) ? 0 : $perms['access'];
$encoded[ self::$_PERMS_RANK_INDEX ] = empty($perms['rank']) ? 0 : $perms['rank'];
$encoded[ self::$_PERMS_TYPE_INDEX ] = empty($perms['type']) ? 0 : $perms['type'];
$encoded[ self::$_PERMS_LOGS_INDEX ] = empty($perms['logs']) ? 0 : $perms['logs'];
$encoded[ self::$_PERMS_NICK_INDEX ] = empty($perms['nick']) ? 0 : $perms['nick'];
$encoded[ self::$_PERMS_CHANNEL_INDEX ] = empty($perms['channel']) ? 0 : $perms['channel'];
// Implode the array
$perms = implode(',', $encoded);
// Return formatted permissions array
return $perms;
}
// Get online users
public static function getOnlineUsers() {
// If the sock chat extensions are disabled return an empty array
if(!Configuration::getLocalConfig('sock', 'enable'))
return [];
// Get contents of the table
$sockUsers = Database::fetch('online_users', true, null, null, null, null, false, '*', Configuration::getLocalConfig('sock', 'sqlpref'));
return $sockUsers;
}
}

View file

@ -82,10 +82,10 @@ class Database {
}
// Fetch array from database
public static function fetch($table, $fetchAll = true, $data = null, $order = null, $limit = null, $group = null, $distinct = false, $column = '*') {
public static function fetch($table, $fetchAll = true, $data = null, $order = null, $limit = null, $group = null, $distinct = false, $column = '*', $prefix = null) {
// Begin preparation of the statement
$prepare = 'SELECT '. ($distinct ? 'DISTINCT ' : '') . ($column == '*' ? '' : '`') . $column . ($column == '*' ? '' : '`') .' FROM `' . Configuration::getLocalConfig('db', 'prefix') . $table . '`';
$prepare = 'SELECT '. ($distinct ? 'DISTINCT ' : '') . ($column == '*' ? '' : '`') . $column . ($column == '*' ? '' : '`') .' FROM `' . ($prefix ? $prefix : Configuration::getLocalConfig('db', 'prefix')) . $table . '`';
// If $data is set and is an array continue
if(is_array($data)) {
@ -172,10 +172,10 @@ class Database {
}
// Insert data to database
public static function insert($table, $data) {
public static function insert($table, $data, $prefix = null) {
// Begin preparation of the statement
$prepare = 'INSERT INTO `' . Configuration::getLocalConfig('db', 'prefix') . $table . '` ';
$prepare = 'INSERT INTO `' . ($prefix ? $prefix : Configuration::getLocalConfig('db', 'prefix')) . $table . '` ';
// Run the foreach statement twice for (`stuff`) VALUES (:stuff)
for($i = 0; $i < 2; $i++) {
@ -214,10 +214,10 @@ class Database {
}
// Update data in the database
public static function update($table, $data) {
public static function update($table, $data, $prefix = null) {
// Begin preparation of the statement
$prepare = 'UPDATE `' . Configuration::getLocalConfig('db', 'prefix') . $table . '`';
$prepare = 'UPDATE `' . ($prefix ? $prefix : Configuration::getLocalConfig('db', 'prefix')) . $table . '`';
// Run a foreach on $data and complete the statement
foreach($data as $key => $values) {
@ -272,10 +272,10 @@ class Database {
}
// Delete data from the database
public static function delete($table, $data) {
public static function delete($table, $data, $prefix = null) {
// Begin preparation of the statement
$prepare = 'DELETE FROM `' . Configuration::getLocalConfig('db', 'prefix') . $table . '`';
$prepare = 'DELETE FROM `' . ($prefix ? $prefix : Configuration::getLocalConfig('db', 'prefix')) . $table . '`';
// If $data is set and is an array continue
if(is_array($data)) {

10
_sakura/manage.php Normal file
View file

@ -0,0 +1,10 @@
<?php
/*
* Sakura Manage Loader
*/
// Declare namespace
namespace Sakura;
// Require Global loader
require_once 'sakura.php';

View file

@ -8,7 +8,7 @@
namespace Sakura;
// Define Sakura version
define('SAKURA_VERSION', '20150428');
define('SAKURA_VERSION', '20150430');
define('SAKURA_VLABEL', 'Heliotrope');
define('SAKURA_VTYPE', 'Development');
define('SAKURA_COLOUR', '#DF73FF');

View file

@ -1,9 +0,0 @@
#
# Sakura Manage Panel
#
# Sets name of this template
NAME = Broomcloset
# Is this style intended for manage?
MANAGE = 1

View file

@ -0,0 +1,24 @@
{% include 'global/header.tpl' %}
<div class="content settings">
<div class="content-right content-column">
<div class="head">
Frequently Asked Questions
</div>
<div class="right-menu-nav">
{% for question in page.questions %}
<a href="#{{ question.short }}" class="default">{{ question.question }}</a>
{% endfor %}
</div>
</div>
<div class="content-left content-column">
{% for question in page.questions %}
<div class="head" id="{{ question.short }}">
{{ question.question }}
<a href="#{{ question.short }}" class="fa fa-quote-right news-rss default"></a>
</div>
<p>{{ question.answer }}</p>
{% endfor %}
</div>
<div class="clear"></div>
</div>
{% include 'global/footer.tpl' %}

View file

@ -25,7 +25,7 @@
We have <b>{{ stats.userCount }}</b>,
<b><a href="/u/{{ stats.newestUser.id }}" class="default">{{ stats.newestUser.username }}</a></b> is the newest user,
it has been <b>{{ stats.lastRegDate }}</b> since the last user registered and
there are <b>{{ stats.chatOnline }}</b> in chat right now.
there's <b>{{ stats.chatOnline }}</b> in chat right now.
<div class="head">Online Users</div>
{% if stats.onlineUsers %}
All active users in the past 5 minutes:<br />

View file

@ -21,6 +21,7 @@ RewriteRule ^login?/?$|logout?/?$|activate?/?$|register?/?$|forgotpassword?/?|au
RewriteRule ^donate?/?$|support?/?$ support.php
RewriteRule ^contact?/?$ infopage.php?r=contact
RewriteRule ^changelog?/?$ changelog.php
RewriteRule ^faq?/?$ faq.php
## Info pages
RewriteRule ^r/([a-z]+)$ infopage.php?r=$1

19
main/faq.php Normal file
View file

@ -0,0 +1,19 @@
<?php
/*
* Sakura FAQ Page
*/
// Declare Namespace
namespace Sakura;
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sakura.php';
// Add page specific things
$renderData['page'] = [
'title' => 'Frequently Asked Questions',
'questions' => Main::getFaqData()
];
// Print page contents
print Templates::render('main/faq.tpl', $renderData);

View file

@ -19,7 +19,7 @@ $renderData['stats'] = [
'userCount' => ($userCount = count($users = Users::getAllUsers(false))) .' user'. ($userCount == 1 ? '' : 's'),
'newestUser' => max($users),
'lastRegDate' => ($lastRegDate = date_diff(date_create(date('Y-m-d', max($users)['regdate'])), date_create(date('Y-m-d')))->format('%a')) .' day'. ($lastRegDate == 1 ? '' : 's'),
'chatOnline' => ($chatOnline = 0) .' user'. ($chatOnline == 1 ? '' : 's'),
'chatOnline' => ($chatOnline = count(SockChat::getOnlineUsers())) .' user'. ($chatOnline == 1 ? '' : 's'),
'onlineUsers' => Users::checkAllOnline()
];

View file

@ -1 +0,0 @@
<h1>broom closet</h1>

13
manage/index.php Normal file
View file

@ -0,0 +1,13 @@
<?php
/*
* Sakura Management
*/
// Declare Namespace
namespace Sakura;
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/manage.php';
// Print page contents
print Templates::render('login.tpl', $renderData);