diff --git a/_sakura/changelog.json b/_sakura/changelog.json index f8bfaa6..f6d8277 100644 --- a/_sakura/changelog.json +++ b/_sakura/changelog.json @@ -2061,6 +2061,31 @@ "type": "UPD", "change": "Converted profile.php to the new user API.", "user": "Flashwave" + }, + { + "type": "ADD", + "change": "Added OR statement capabilities to the database library.", + "user": "Flashwave" + }, + { + "type": "UPD", + "change": "Make it possible to initialise a User object with the username_clean of that user.", + "user": "Flashwave" + }, + { + "type": "UPD", + "change": "Switched currently logged in user data to the new API and fixed some references to checkLogin.", + "user": "Flashwave" + }, + { + "type": "ADD", + "change": "Added expirimental site wide profile background feature.", + "user": "Flashwave" + }, + { + "type": "FIX", + "change": "Clean up unneeded things from profile.php.", + "user": "Flashwave" } ] diff --git a/_sakura/components/User.php b/_sakura/components/User.php index f727b62..184fa15 100644 --- a/_sakura/components/User.php +++ b/_sakura/components/User.php @@ -16,7 +16,7 @@ class User { function __construct($id) { // Get the user database row - $this->data = Database::fetch('users', false, ['id' => [$id, '=']]); + $this->data = Database::fetch('users', false, ['id' => [$id, '=', true], 'username_clean' => [$id, '=']]); // Check if the user actually exists if(empty($this->data)) { diff --git a/_sakura/components/database/mysql.php b/_sakura/components/database/mysql.php index 6a14b0a..a157115 100644 --- a/_sakura/components/database/mysql.php +++ b/_sakura/components/database/mysql.php @@ -94,7 +94,7 @@ class MySQL { $prepare .= ' WHERE'; foreach($data as $key => $value) { - $prepare .= ' `'. $key .'` '. $value[1] .' :'. $key . ($key == key(array_slice($data, -1, 1, true)) ? '' : ' AND'); + $prepare .= ' `'. $key .'` '. $value[1] .' :'. $key . ($key == key(array_slice($data, -1, 1, true)) ? '' : ' '. (isset($value[2]) && $value[2] ? 'OR' : 'AND')); // Unset variables to be safe unset($key); @@ -223,7 +223,7 @@ class MySQL { // 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' : ',')); + $prepare .= ' `'. $column .'` '. ($key ? $column_data[1] : '=') .' :'. ($key ? 'w' : 's') .'_'. $column . ($column == key(array_slice($values, -1, 1, true)) ? ($key ? ';' : '') : ($key ? ' '. (isset($value[2]) && $value[2] ? 'OR' : 'AND') : ',')); } @@ -279,7 +279,7 @@ class MySQL { $prepare .= ' WHERE'; foreach($data as $key => $value) { - $prepare .= ' `'. $key .'` '. $value[1] .' :'. $key . ($key == key(array_slice($data, -1, 1, true)) ? '' : ' AND'); + $prepare .= ' `'. $key .'` '. $value[1] .' :'. $key . ($key == key(array_slice($data, -1, 1, true)) ? '' : ' '. (isset($value[2]) && $value[2] ? 'OR' : 'AND')); // Unset variables to be safe unset($key); @@ -320,7 +320,7 @@ class MySQL { $prepare .= ' WHERE'; foreach($data as $key => $value) { - $prepare .= ' `'. $key .'` '. $value[1] .' :'. $key . ($key == key(array_slice($data, -1, 1, true)) ? '' : ' AND'); + $prepare .= ' `'. $key .'` '. $value[1] .' :'. $key . ($key == key(array_slice($data, -1, 1, true)) ? '' : ' '. (isset($value[2]) && $value[2] ? 'OR' : 'AND')); // Unset variables to be safe unset($key); diff --git a/_sakura/sakura.php b/_sakura/sakura.php index 17ebe5d..b487473 100644 --- a/_sakura/sakura.php +++ b/_sakura/sakura.php @@ -111,15 +111,15 @@ if(!defined('SAKURA_NO_TPL')) { ], - 'user' => [ + 'session' => [ - 'checklogin' => Users::checkLogin(), - 'session' => Session::$sessionId, - 'data' => ($_init_udata = Users::getUser(Session::$userId)), - 'rank' => ($_init_rdata = Users::getRank($_init_udata['rank_main'])), - 'colour' => ($_init_udata['name_colour'] == null ? $_init_rdata['colour'] : $_init_udata['name_colour']) + 'checkLogin' => Users::checkLogin(), + 'sessionId' => Session::$sessionId, + 'userId' => Session::$userId - ] + ], + + 'user' => new User(Session::$userId) ]; diff --git a/_sakura/templates/yuuno/elements/indexPanel.tpl b/_sakura/templates/yuuno/elements/indexPanel.tpl index 0e90943..a3a3b6b 100644 --- a/_sakura/templates/yuuno/elements/indexPanel.tpl +++ b/_sakura/templates/yuuno/elements/indexPanel.tpl @@ -1,4 +1,4 @@ -{% if user.checklogin %} +{% if session.checkLogin %}