diff --git a/_developer_data/structure.sql b/_developer_data/structure.sql index 8308d5f..5991643 100644 --- a/_developer_data/structure.sql +++ b/_developer_data/structure.sql @@ -94,7 +94,8 @@ INSERT INTO `fii_profilefields` (`id`, `name`, `formtype`, `description`, `addit (8, 'osu!', 'text', 'Your osu! Username', ''), (9, 'Origin', 'text', 'Your Origin User ID', ''), (10, 'Xbox Live', 'text', 'Your Xbox User ID', ''), -(11, 'PSN', 'text', 'Your PSN User ID', ''); +(11, 'PSN', 'text', 'Your PSN User ID', '') +ON DUPLICATE KEY UPDATE `id` = VALUES(`id`), `name` = VALUES(`name`), `formtype` = VALUES(`formtype`), `description` = VALUES(`description`), `additional` = VALUES(`additional`); DROP TABLE IF EXISTS `fii_ranks`; CREATE TABLE `fii_ranks` ( @@ -108,15 +109,16 @@ CREATE TABLE `fii_ranks` ( ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; INSERT INTO `fii_ranks` (`id`, `name`, `multi`, `colour`, `description`, `title`) VALUES -(1, 'Deactivated', 0, '555', 'Users that are yet to be activated or that deactivated their own account.', 'Deactivated'), -(2, 'Regular user', 1, '', 'Regular users with regular permissions.', 'Regular user'), -(3, 'Site moderator', 1, '0A0', 'Users with special permissions like being able to ban and modify users if needed.', 'Staff'), -(4, 'Administrator', 1, 'C00', 'Users that manage the server and everything around that.', 'Administrator'), -(5, 'Developer', 1, '824CA0', 'Users that either create or test new features of the site.', 'Staff'), -(6, 'Bot', 1, '9E8DA7', 'Reserved user accounts for services.', 'Bot'), -(7, 'Chat moderator', 1, '09F', 'Moderators of the chat room.', 'Staff'), -(8, 'Tenshi', 0, 'EE9400', 'Users that donated $5.00 or more in order to keep the site and it\'s services alive!', 'Tenshi'), -(9, 'Alumnii', 0, 'FF69B4', 'People who have contributed to the community but have moved on or resigned.', 'Alumnii'); +(1, 'Deactivated', 0, '#555', 'Users that are yet to be activated or that deactivated their own account.', 'Deactivated'), +(2, 'Regular user', 1, 'inherit', 'Regular users with regular permissions.', 'Regular user'), +(3, 'Site moderator', 1, '#0A0', 'Users with special permissions like being able to ban and modify users if needed.', 'Staff'), +(4, 'Administrator', 1, '#C00', 'Users that manage the server and everything around that.', 'Administrator'), +(5, 'Developer', 1, '#824CA0', 'Users that either create or test new features of the site.', 'Staff'), +(6, 'Bot', 1, '#9E8DA7', 'Reserved user accounts for services.', 'Bot'), +(7, 'Chat moderator', 1, '#09F', 'Moderators of the chat room.', 'Staff'), +(8, 'Tenshi', 0, '#EE9400', 'Users that donated $5.00 or more in order to keep the site and it\'s services alive!', 'Tenshi'), +(9, 'Alumnii', 0, '#FF69B4', 'People who have contributed to the community but have moved on or resigned.', 'Alumnii') +ON DUPLICATE KEY UPDATE `id` = VALUES(`id`), `name` = VALUES(`name`), `multi` = VALUES(`multi`), `colour` = VALUES(`colour`), `description` = VALUES(`description`), `title` = VALUES(`title`); DROP TABLE IF EXISTS `fii_regcodes`; CREATE TABLE `fii_regcodes` ( @@ -138,8 +140,9 @@ CREATE TABLE `fii_sessions` ( `skey` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'Session key, allow direct access to the user''s account. ', `started` int(64) unsigned NOT NULL COMMENT 'The timestamp for when the session was started. ', `expire` int(64) unsigned NOT NULL COMMENT 'The timestamp for when this session should end, -1 for permanent. ', + `remember` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'If set to 1 session will be extended each time a page is loaded.', PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; DROP TABLE IF EXISTS `fii_tenshi`; @@ -177,6 +180,7 @@ CREATE TABLE `fii_users` ( `lastdate` int(16) unsigned NOT NULL COMMENT 'Last time anything was done on this account.', `lastunamechange` int(16) unsigned NOT NULL COMMENT 'Last username change.', `birthday` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT 'Birthdate of the user.', + `country` varchar(4) COLLATE utf8_bin NOT NULL COMMENT 'Contains ISO 3166 country code of user''s registration location.', `profile_data` text COLLATE utf8_bin NOT NULL COMMENT 'Modular array containing profile data.', PRIMARY KEY (`id`), UNIQUE KEY `username_clean` (`username_clean`) @@ -195,4 +199,4 @@ CREATE TABLE `fii_warnings` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; --- 2015-04-12 01:50:57 +-- 2015-04-13 10:06:13 diff --git a/_sakura/components/Users.php b/_sakura/components/Users.php index ebb1c07..20910ae 100644 --- a/_sakura/components/Users.php +++ b/_sakura/components/Users.php @@ -96,6 +96,14 @@ class Users { } + // Logout and kill the session + public static function logout() { + + // Remove the active session from the database + // Session::deleteSession($id, $key); + + } + // Check if a user exists public static function userExists($user, $id = true) { diff --git a/_sakura/components/database/mysql.php b/_sakura/components/database/mysql.php index aa40e4e..5564609 100644 --- a/_sakura/components/database/mysql.php +++ b/_sakura/components/database/mysql.php @@ -1,270 +1,274 @@ -SQL Driver: PDO extension not loaded.', E_USER_ERROR); - } - - // Initialise connection - self::initConnect( - ( - Configuration::getLocalConfig('db', 'unixsocket') ? - self::prepareSock( - Configuration::getLocalConfig('db', 'host'), - Configuration::getLocalConfig('db', 'database') - ) : - self::prepareHost( - Configuration::getLocalConfig('db', 'host'), - Configuration::getLocalConfig('db', 'database'), - ( - Configuration::getLocalConfig('db', 'port') !== null ? - Configuration::getLocalConfig('db', 'port') : - 3306 - ) - ) - ), - Configuration::getLocalConfig('db', 'username'), - Configuration::getLocalConfig('db', 'password') - ); - - } - - // Regular IP/Hostname connection method prepare function - private static function prepareHost($dbHost, $dbName, $dbPort = 3306) { - - $DSN = 'mysql:host=' . $dbHost . ';port=' . $dbPort . ';dbname=' . $dbName; - - return $DSN; - - } - - // Unix Socket connection method prepare function - private static function prepareSock($dbHost, $dbName) { - - $DSN = 'mysql:unix_socket=' . $dbHost . ';dbname=' . $dbName; - - return $DSN; - - } - - // Initialise connection using default PDO stuff - private static function initConnect($DSN, $dbUname, $dbPword) { - - try { - // Connect to SQL server using PDO - self::$sql = new PDO($DSN, $dbUname, $dbPword); - } catch(PDOException $e) { - // Catch connection errors - trigger_error('SQL Driver: '. $e->getMessage(), E_USER_ERROR); - } - - return true; - - } - - // Fetch array from database - public static function fetch($table, $fetchAll = true, $data = null, $order = null, $limit = null, $group = null, $distinct = false, $column = '*') { - - // Begin preparation of the statement - $prepare = 'SELECT '. ($distinct ? 'DISTINCT ' : '') . ($column == '*' ? '' : '`') . $column . ($column == '*' ? '' : '`') .' FROM `' . Configuration::getLocalConfig('db', 'prefix') . $table . '`'; - - // If $data is set and is an array continue - if(is_array($data)) { - - $prepare .= ' WHERE'; - - foreach($data as $key => $value) { - $prepare .= ' `'. $key .'` '. $value[1] .' :'. $key . ($key == key(array_slice($data, -1, 1, true)) ? '' : ' AND'); - - // Unset variables to be safe - unset($key); - unset($value); - } - - } - - // If $order is set and is an array continue - if(is_array($order)) { - - $prepare .= ' ORDER BY `'. $order[0] .'`'. (!empty($order[1]) && $order[1] ? ' DESC' : ''); - - } - - // If $group is set and is an array continue - if(is_array($group)) { - - $prepare .= ' GROUP BY'; - - foreach($group as $key => $value) { - $prepare .= ' `'. $value .'`'. ($key == key(array_slice($group, -1, 1, true)) ? '' : ','); - - // Unset variables to be safe - unset($key); - unset($value); - } - - } - - // If $limit is set and is an array continue - if(is_array($limit)) { - - $prepare .= ' LIMIT'; - - foreach($limit as $key => $value) { - $prepare .= ' '. $value . ($key == key(array_slice($limit, -1, 1, true)) ? '' : ','); - - // Unset variables to be safe - unset($key); - unset($value); - } - - } - - // Add the finishing semicolon - $prepare .= ';'; - - // Actually prepare the preration - $query = self::$sql->prepare($prepare); - - // Bind those parameters if $data is an array that is - if(is_array($data)) { - foreach($data as $key => $value) { - $query->bindParam(':'. $key, $value[0]); - - // Unset variables to be safe - unset($key); - unset($value); - } - } - - // Execute the prepared statements with parameters bound - $query->execute(); - - // Do fetch or fetchAll - if($fetchAll) - $result = $query->fetchAll(PDO::FETCH_BOTH); - else - $result = $query->fetch(PDO::FETCH_BOTH); - - - // And return the output - return $result; - - } - - // Insert data to database - public static function insert($table, $data) { - - // Begin preparation of the statement - $prepare = 'INSERT INTO `' . Configuration::getLocalConfig('db', 'prefix') . $table . '` '; - - // Run the foreach statement twice for (`stuff`) VALUES (:stuff) - for($i = 0; $i < 2; $i++) { - - $prepare .= '('; - - // Do more shit, don't feel like describing this so yeah - foreach($data as $key => $value) { - if(strlen($value)) - $prepare .= ($i ? ':' : '`') . $key . ($i ? '' : '`') . ($key == key(array_slice($data, -1, 1, true)) ? '' : ', '); - } - - $prepare .= ')' . ($i ? ';' : ' VALUES '); - - } - - // Actually prepare the preration - $query = self::$sql->prepare($prepare); - - // Bind those parameters - foreach($data as $key => $value) { - if(strlen($value)) - $query->bindParam(':'. $key, $value); - - // Unset variables to be safe - unset($key); - unset($value); - } - - // Execute the prepared statements with parameters bound - $result = $query->execute(); - - // Return whatever can be returned - return $result; - - } - - // Update data in the database - public static function update($table, $data) { - - // Begin preparation of the statement - $prepare = 'UPDATE `' . Configuration::getLocalConfig('db', 'prefix') . $table . '`'; - - // Run a foreach on $data and complete the statement - foreach($data as $key => $values) { - - // Append WHERE or SET depending on where we are - $prepare .= ' '. ($key ? 'WHERE' : 'SET'); - - // Do this complicated shit, I barely know what's going on anymore but it works - foreach($values as $column => $column_data) { - $prepare .= ' `'. $column .'` '. ($key ? $column_data[1] : '=') .' :'. ($key ? 'w' : 's') .'_'. $column . ($column == key(array_slice($values, -1, 1, true)) ? ($key ? ';' : '') : ($key ? ' AND' : ',')); - } - - } - - // Actually prepare the preration - $query = self::$sql->prepare($prepare); - - // Seperate the foreaches for the SET and WHERE clauses because it's fucking it up for some odd reason - // Bind Set Clauses - foreach($data[0] as $key => $value) { - // Do the binding - $query->bindParam(':s_'. $key, $value); - - // Unset variables to be safe - unset($key); - unset($value); - } - // Bind Where Clauses - foreach($data[1] as $key => $values) { - // Assign the array entry to a variable because fuck strict standards - $value = $values[0]; - - // Binding two electrifying memes - $query->bindParam(':w_'. $key, $value); - - // Unset variables to be safe - unset($key); - unset($value); - unset($values); - } - - // Execute the prepared statements with parameters bound - $result = $query->execute(); - - // Return whatever can be returned - return $result; - - } - -} +SQL Driver: PDO extension not loaded.', E_USER_ERROR); + } + + // Initialise connection + self::initConnect( + ( + Configuration::getLocalConfig('db', 'unixsocket') ? + self::prepareSock( + Configuration::getLocalConfig('db', 'host'), + Configuration::getLocalConfig('db', 'database') + ) : + self::prepareHost( + Configuration::getLocalConfig('db', 'host'), + Configuration::getLocalConfig('db', 'database'), + ( + Configuration::getLocalConfig('db', 'port') !== null ? + Configuration::getLocalConfig('db', 'port') : + 3306 + ) + ) + ), + Configuration::getLocalConfig('db', 'username'), + Configuration::getLocalConfig('db', 'password') + ); + + } + + // Regular IP/Hostname connection method prepare function + private static function prepareHost($dbHost, $dbName, $dbPort = 3306) { + + $DSN = 'mysql:host=' . $dbHost . ';port=' . $dbPort . ';dbname=' . $dbName; + + return $DSN; + + } + + // Unix Socket connection method prepare function + private static function prepareSock($dbHost, $dbName) { + + $DSN = 'mysql:unix_socket=' . $dbHost . ';dbname=' . $dbName; + + return $DSN; + + } + + // Initialise connection using default PDO stuff + private static function initConnect($DSN, $dbUname, $dbPword) { + + try { + // Connect to SQL server using PDO + self::$sql = new PDO($DSN, $dbUname, $dbPword); + } catch(PDOException $e) { + // Catch connection errors + trigger_error('SQL Driver: '. $e->getMessage(), E_USER_ERROR); + } + + return true; + + } + + // Fetch array from database + public static function fetch($table, $fetchAll = true, $data = null, $order = null, $limit = null, $group = null, $distinct = false, $column = '*') { + + // Begin preparation of the statement + $prepare = 'SELECT '. ($distinct ? 'DISTINCT ' : '') . ($column == '*' ? '' : '`') . $column . ($column == '*' ? '' : '`') .' FROM `' . Configuration::getLocalConfig('db', 'prefix') . $table . '`'; + + // If $data is set and is an array continue + if(is_array($data)) { + + $prepare .= ' WHERE'; + + foreach($data as $key => $value) { + $prepare .= ' `'. $key .'` '. $value[1] .' :'. $key . ($key == key(array_slice($data, -1, 1, true)) ? '' : ' AND'); + + // Unset variables to be safe + unset($key); + unset($value); + } + + } + + // If $order is set and is an array continue + if(is_array($order)) { + + $prepare .= ' ORDER BY `'. $order[0] .'`'. (!empty($order[1]) && $order[1] ? ' DESC' : ''); + + } + + // If $group is set and is an array continue + if(is_array($group)) { + + $prepare .= ' GROUP BY'; + + foreach($group as $key => $value) { + $prepare .= ' `'. $value .'`'. ($key == key(array_slice($group, -1, 1, true)) ? '' : ','); + + // Unset variables to be safe + unset($key); + unset($value); + } + + } + + // If $limit is set and is an array continue + if(is_array($limit)) { + + $prepare .= ' LIMIT'; + + foreach($limit as $key => $value) { + $prepare .= ' '. $value . ($key == key(array_slice($limit, -1, 1, true)) ? '' : ','); + + // Unset variables to be safe + unset($key); + unset($value); + } + + } + + // Add the finishing semicolon + $prepare .= ';'; + + // Actually prepare the preration + $query = self::$sql->prepare($prepare); + + // Bind those parameters if $data is an array that is + if(is_array($data)) { + foreach($data as $key => $value) { + $query->bindParam(':'. $key, $value[0]); + + // Unset variables to be safe + unset($key); + unset($value); + } + } + + // Execute the prepared statements with parameters bound + $query->execute(); + + // Do fetch or fetchAll + if($fetchAll) + $result = $query->fetchAll(PDO::FETCH_BOTH); + else + $result = $query->fetch(PDO::FETCH_BOTH); + + + // And return the output + return $result; + + } + + // Insert data to database + public static function insert($table, $data) { + + // Begin preparation of the statement + $prepare = 'INSERT INTO `' . Configuration::getLocalConfig('db', 'prefix') . $table . '` '; + + // Run the foreach statement twice for (`stuff`) VALUES (:stuff) + for($i = 0; $i < 2; $i++) { + + $prepare .= '('; + + // Do more shit, don't feel like describing this so yeah + foreach($data as $key => $value) { + if(strlen($value)) + $prepare .= ($i ? ':' : '`') . $key . ($i ? '' : '`') . ($key == key(array_slice($data, -1, 1, true)) ? '' : ', '); + } + + $prepare .= ')' . ($i ? ';' : ' VALUES '); + + } + + // Actually prepare the preration + $query = self::$sql->prepare($prepare); + + // Bind those parameters + foreach($data as $key => $value) { + if(strlen($value)) + $query->bindParam(':'. $key, $value); + + // Unset variables to be safe + unset($key); + unset($value); + } + + // Execute the prepared statements with parameters bound + $result = $query->execute(); + + // Return whatever can be returned + return $result; + + } + + // Update data in the database + public static function update($table, $data) { + + // Begin preparation of the statement + $prepare = 'UPDATE `' . Configuration::getLocalConfig('db', 'prefix') . $table . '`'; + + // Run a foreach on $data and complete the statement + foreach($data as $key => $values) { + + // Append WHERE or SET depending on where we are + $prepare .= ' '. ($key ? 'WHERE' : 'SET'); + + // Do this complicated shit, I barely know what's going on anymore but it works + foreach($values as $column => $column_data) + $prepare .= ' `'. $column .'` '. ($key ? $column_data[1] : '=') .' :'. ($key ? 'w' : 's') .'_'. $column . ($column == key(array_slice($values, -1, 1, true)) ? ($key ? ';' : '') : ($key ? ' AND' : ',')); + + } + + // Actually prepare the preration + $query = self::$sql->prepare($prepare); + + // Seperate the foreaches for the SET and WHERE clauses because it's fucking it up for some odd reason + // Bind Set Clauses + foreach($data[0] as $key => $value) { + + // Do the binding + $query->bindParam(':s_'. $key, $value); + + // Unset variables to be safe + unset($key); + unset($value); + + } + + // Bind Where Clauses + foreach($data[1] as $key => $values) { + + // Assign the array entry to a variable because fuck strict standards + $value = $values[0]; + + // Binding two electrifying memes + $query->bindParam(':w_'. $key, $value); + + // Unset variables to be safe + unset($key); + unset($value); + unset($values); + + } + + // Execute the prepared statements with parameters bound + $result = $query->execute(); + + // Return whatever can be returned + return $result; + + } + +} diff --git a/_sakura/sakura.php b/_sakura/sakura.php index 8c3f392..1be4c28 100644 --- a/_sakura/sakura.php +++ b/_sakura/sakura.php @@ -55,7 +55,8 @@ $renderData = array( 'urls' => Configuration::getLocalConfig('urls'), 'charset' => Configuration::getConfig('charset'), 'currentpage' => $_SERVER['PHP_SELF'], - 'recaptcha_public' => Configuration::getConfig('recaptcha_public') + 'recaptcha_public' => Configuration::getConfig('recaptcha_public'), + 'resources' => '//'. Configuration::getLocalConfig('urls')['content'] .'/data/'. strtolower(Templates::$_TPL) ], 'php' => [ 'sessionid' => \session_id(), diff --git a/_sakura/templates/yuuno/errors/http404.tpl b/_sakura/templates/yuuno/errors/http404.tpl index 5020798..3da1954 100644 --- a/_sakura/templates/yuuno/errors/http404.tpl +++ b/_sakura/templates/yuuno/errors/http404.tpl @@ -1,51 +1,51 @@ - - - - - Cannot find page - - - - -
-

- - The page cannot be found -

-

- The page you are looking for might have been removed, had its - name changed, or is temporarily unavailable. -

-
-

- Please try the following: -

- -

- HTTP 404 - File not found -
- Internet Explorer -

-
- - + + + + + Cannot find page + + + + +
+

+ + The page cannot be found +

+

+ The page you are looking for might have been removed, had its + name changed, or is temporarily unavailable. +

+
+

+ Please try the following: +

+ +

+ HTTP 404 - File not found +
+ Internet Explorer +

+
+ + diff --git a/_sakura/templates/yuuno/global/header.tpl b/_sakura/templates/yuuno/global/header.tpl index 8c9106a..78b2bc4 100644 --- a/_sakura/templates/yuuno/global/header.tpl +++ b/_sakura/templates/yuuno/global/header.tpl @@ -12,10 +12,10 @@ {% endif %} - + - +