diff --git a/_sakura/changelog.json b/_sakura/changelog.json index 6ef6bd0..dc52f93 100644 --- a/_sakura/changelog.json +++ b/_sakura/changelog.json @@ -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." + } + ] } diff --git a/_sakura/components/Main.php b/_sakura/components/Main.php index b7d79d5..6e152db 100644 --- a/_sakura/components/Main.php +++ b/_sakura/components/Main.php @@ -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; + + } + } diff --git a/_sakura/components/SockChat.php b/_sakura/components/SockChat.php index 67809c5..dcde07f 100644 --- a/_sakura/components/SockChat.php +++ b/_sakura/components/SockChat.php @@ -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; + + } + } diff --git a/_sakura/components/database/mysql.php b/_sakura/components/database/mysql.php index f2ff765..5a08431 100644 --- a/_sakura/components/database/mysql.php +++ b/_sakura/components/database/mysql.php @@ -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)) { diff --git a/_sakura/manage.php b/_sakura/manage.php new file mode 100644 index 0000000..7bfbefd --- /dev/null +++ b/_sakura/manage.php @@ -0,0 +1,10 @@ + +
+
+ Frequently Asked Questions +
+
+ {% for question in page.questions %} + {{ question.question }} + {% endfor %} +
+
+
+ {% for question in page.questions %} +
+ {{ question.question }} + +
+

{{ question.answer }}

+ {% endfor %} +
+
+ +{% include 'global/footer.tpl' %} diff --git a/_sakura/templates/yuuno/main/index.tpl b/_sakura/templates/yuuno/main/index.tpl index ec70e8f..4dcf791 100644 --- a/_sakura/templates/yuuno/main/index.tpl +++ b/_sakura/templates/yuuno/main/index.tpl @@ -25,7 +25,7 @@ We have {{ stats.userCount }}, {{ stats.newestUser.username }} is the newest user, it has been {{ stats.lastRegDate }} since the last user registered and - there are {{ stats.chatOnline }} in chat right now. + there's {{ stats.chatOnline }} in chat right now.
Online Users
{% if stats.onlineUsers %} All active users in the past 5 minutes:
diff --git a/main/.htaccess b/main/.htaccess index 906d924..c26d38c 100644 --- a/main/.htaccess +++ b/main/.htaccess @@ -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 diff --git a/main/faq.php b/main/faq.php new file mode 100644 index 0000000..bd06cd2 --- /dev/null +++ b/main/faq.php @@ -0,0 +1,19 @@ + 'Frequently Asked Questions', + 'questions' => Main::getFaqData() +]; + +// Print page contents +print Templates::render('main/faq.tpl', $renderData); diff --git a/main/index.php b/main/index.php index bb83544..5d969bc 100644 --- a/main/index.php +++ b/main/index.php @@ -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() ]; diff --git a/manage/index.html b/manage/index.html deleted file mode 100644 index 9cf7462..0000000 --- a/manage/index.html +++ /dev/null @@ -1 +0,0 @@ -

broom closet

\ No newline at end of file diff --git a/manage/index.php b/manage/index.php new file mode 100644 index 0000000..7e16eff --- /dev/null +++ b/manage/index.php @@ -0,0 +1,13 @@ +