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 @@ + +
{{ question.answer }}
+ {% endfor %} +