Applied fixes from StyleCI

This commit is contained in:
flash 2015-10-30 12:43:09 -04:00
parent 9cbe15b06a
commit 40e4cfafe4
26 changed files with 3 additions and 244 deletions

View file

@ -40,11 +40,9 @@ class Bans
'reason' => $ban['ban_reason'], 'reason' => $ban['ban_reason'],
]; ];
} }
// Else just return false // Else just return false
return false; return false;
} }
} }

View file

@ -35,7 +35,6 @@ class Comments
// Feed them into the sorter // Feed them into the sorter
$this->comments = $this->sortComments($comments); $this->comments = $this->sortComments($comments);
} }
// Sorting // Sorting
@ -91,7 +90,6 @@ class Comments
} }
return $layer; return $layer;
} }
// Getting a single comment // Getting a single comment
@ -102,7 +100,6 @@ class Comments
return Database::fetch('comments', false, [ return Database::fetch('comments', false, [
'comment_id' => [$cid, '='], 'comment_id' => [$cid, '='],
]); ]);
} }
// Getting comment votes // Getting comment votes
@ -113,7 +110,6 @@ class Comments
return Database::fetch('comment_votes', true, [ return Database::fetch('comment_votes', true, [
'vote_comment' => [$cid, '='], 'vote_comment' => [$cid, '='],
]); ]);
} }
// Creating // Creating
@ -141,7 +137,6 @@ class Comments
// Return success // Return success
return [1, 'SUCCESS']; return [1, 'SUCCESS'];
} }
// Voting // Voting
@ -185,7 +180,6 @@ class Comments
} }
return true; return true;
} }
// Deleting // Deleting
@ -196,6 +190,5 @@ class Comments
return Database::delete('comments', [ return Database::delete('comments', [
'comment_id' => [$cid, '='], 'comment_id' => [$cid, '='],
]); ]);
} }
} }

View file

@ -38,7 +38,6 @@ class Configuration
E_USER_ERROR E_USER_ERROR
); );
} }
} }
/* /*
@ -62,7 +61,6 @@ class Configuration
// Assign the temporary array to the static one // Assign the temporary array to the static one
self::$database = $_DBCN; self::$database = $_DBCN;
} }
// Get values from the configuration on the file system // Get values from the configuration on the file system
@ -85,7 +83,6 @@ class Configuration
'Unable to get local configuration value "' . $key . '"', 'Unable to get local configuration value "' . $key . '"',
E_USER_ERROR E_USER_ERROR
); );
} }
// Dynamically set local configuration values, does not update the configuration file // Dynamically set local configuration values, does not update the configuration file
@ -105,7 +102,6 @@ class Configuration
// Otherwise we just straight up assign it // Otherwise we just straight up assign it
self::$local[$key] = $value; self::$local[$key] = $value;
} }
// Get values from the configuration in the database // Get values from the configuration in the database
@ -126,6 +122,5 @@ class Configuration
'Unable to get configuration value "' . $key . '"', 'Unable to get configuration value "' . $key . '"',
E_USER_ERROR E_USER_ERROR
); );
} }
} }

View file

@ -28,62 +28,47 @@ class Database
// Initialise SQL wrapper // Initialise SQL wrapper
self::$database = new $wrapper; self::$database = new $wrapper;
} }
// Select from database // Select from database
public static function select($table, $data = null, $order = null, $limit = null, $group = null, $distinct = false, $column = '*', $prefix = null) public static function select($table, $data = null, $order = null, $limit = null, $group = null, $distinct = false, $column = '*', $prefix = null)
{ {
return self::$database->select($table, $data, $order, $limit, $group, $distinct, $column, $prefix); return self::$database->select($table, $data, $order, $limit, $group, $distinct, $column, $prefix);
} }
// Fetch from database // Fetch from database
public static function fetch($table, $fetchAll = true, $data = null, $order = null, $limit = null, $group = null, $distinct = false, $column = '*', $prefix = null) public static function fetch($table, $fetchAll = true, $data = null, $order = null, $limit = null, $group = null, $distinct = false, $column = '*', $prefix = null)
{ {
return self::$database->fetch($table, $fetchAll, $data, $order, $limit, $group, $distinct, $column, $prefix); return self::$database->fetch($table, $fetchAll, $data, $order, $limit, $group, $distinct, $column, $prefix);
} }
// Insert into database // Insert into database
public static function insert($table, $data, $prefix = null) public static function insert($table, $data, $prefix = null)
{ {
return self::$database->insert($table, $data, $prefix); return self::$database->insert($table, $data, $prefix);
} }
// Update in database // Update in database
public static function update($table, $data, $prefix = null) public static function update($table, $data, $prefix = null)
{ {
return self::$database->update($table, $data, $prefix); return self::$database->update($table, $data, $prefix);
} }
// Delete from database // Delete from database
public static function delete($table, $data, $prefix = null) public static function delete($table, $data, $prefix = null)
{ {
return self::$database->delete($table, $data, $prefix); return self::$database->delete($table, $data, $prefix);
} }
// Count from database // Count from database
public static function count($table, $data = null, $prefix = null) public static function count($table, $data = null, $prefix = null)
{ {
return self::$database->count($table, $data, $prefix); return self::$database->count($table, $data, $prefix);
} }
// Get the ID of the last inserted item // Get the ID of the last inserted item
public static function lastInsertID($name = null) public static function lastInsertID($name = null)
{ {
return self::$database->lastInsertID($name); return self::$database->lastInsertID($name);
} }
} }

View file

@ -77,7 +77,6 @@ class Forum
// Return the resorted data // Return the resorted data
return $return; return $return;
} }
// Get a forum or category // Get a forum or category
@ -137,7 +136,6 @@ class Forum
// Return the forum/category // Return the forum/category
return $forum; return $forum;
} }
// Getting all topics from a forum // Getting all topics from a forum
@ -182,7 +180,6 @@ class Forum
} }
return $topics; return $topics;
} }
// Get posts of a thread // Get posts of a thread
@ -272,7 +269,6 @@ class Forum
// Return the compiled topic data // Return the compiled topic data
return $topic; return $topic;
} }
// Get a forum ID from a topic ID // Get a forum ID from a topic ID
@ -291,7 +287,6 @@ class Forum
// Return the forum id // Return the forum id
return $topic['forum_id']; return $topic['forum_id'];
} }
// Get a topic ID from a post ID // Get a topic ID from a post ID
@ -310,7 +305,6 @@ class Forum
// Return the topic id // Return the topic id
return $post['topic_id']; return $post['topic_id'];
} }
// Parse different markup flavours // Parse different markup flavours
@ -337,7 +331,6 @@ class Forum
default: default:
return $text; return $text;
} }
} }
// Get forum statistics of a user // Get forum statistics of a user
@ -359,7 +352,6 @@ class Forum
['topic_id'] ['topic_id']
)), )),
]; ];
} }
// Creating a new post // Creating a new post
@ -416,6 +408,5 @@ class Forum
// Return success // Return success
return [1, 'SUCCESS', $getPost['forum_id'], $getPost['topic_id'], $getPost['post_id']]; return [1, 'SUCCESS', $getPost['forum_id'], $getPost['topic_id'], $getPost['post_id']];
} }
} }

View file

@ -46,7 +46,6 @@ class Hashing
// Returns an array formatted like: [algorithm, iterations, salt, hash] // Returns an array formatted like: [algorithm, iterations, salt, hash]
public static function createHash($pass) public static function createHash($pass)
{ {
$salt = base64_encode( $salt = base64_encode(
\mcrypt_create_iv( \mcrypt_create_iv(
self::$saltBytes, self::$saltBytes,
@ -73,13 +72,11 @@ class Hashing
]; ];
return $passwordData; return $passwordData;
} }
// Validates hashed password // Validates hashed password
public static function validatePassword($password, $params) public static function validatePassword($password, $params)
{ {
if (count($params) < 4) { if (count($params) < 4) {
return false; return false;
} }
@ -99,13 +96,11 @@ class Hashing
); );
return $validate; return $validate;
} }
// Compares two strings $a and $b in length-constant time. // Compares two strings $a and $b in length-constant time.
public static function slowEquals($a, $b) public static function slowEquals($a, $b)
{ {
$diff = strlen($a) ^ strlen($b); $diff = strlen($a) ^ strlen($b);
for ($i = 0; $i < strlen($a) && $i < strlen($b); $i++) { for ($i = 0; $i < strlen($a) && $i < strlen($b); $i++) {
@ -113,7 +108,6 @@ class Hashing
} }
return $diff === 0; return $diff === 0;
} }
/* /*
@ -134,7 +128,6 @@ class Hashing
private static function pbkdf2($algorithm, $password, $salt, $count, $key_length, $raw_output = false) private static function pbkdf2($algorithm, $password, $salt, $count, $key_length, $raw_output = false)
{ {
$algorithm = strtolower($algorithm); $algorithm = strtolower($algorithm);
if (!in_array($algorithm, hash_algos(), true)) { if (!in_array($algorithm, hash_algos(), true)) {
@ -185,6 +178,5 @@ class Hashing
return bin2hex(substr($output, 0, $key_length)); return bin2hex(substr($output, 0, $key_length));
} }
} }
} }

View file

@ -26,27 +26,22 @@ class Main
// "Dynamic" Configuration // "Dynamic" Configuration
Configuration::initDB(); Configuration::initDB();
} }
// Parse markdown // Parse markdown
public static function mdParse($text, $escape = false) public static function mdParse($text, $escape = false)
{ {
$pd = new Parsedown(); $pd = new Parsedown();
return $escape ? return $escape ?
$pd->setMarkupEscaped(true)->text($text) : $pd->setMarkupEscaped(true)->text($text) :
$pd->text($text); $pd->text($text);
} }
// Get bbcodes // Get bbcodes
public static function getBBcodes() public static function getBBcodes()
{ {
return Database::fetch('bbcodes'); return Database::fetch('bbcodes');
} }
// Parse bbcodes // Parse bbcodes
@ -71,15 +66,12 @@ class Main
// Return the parsed text // Return the parsed text
return $text; return $text;
} }
// Get emoticons // Get emoticons
public static function getEmotes() public static function getEmotes()
{ {
return Database::fetch('emoticons'); return Database::fetch('emoticons');
} }
// Parsing emoticons // Parsing emoticons
@ -100,7 +92,6 @@ class Main
// Return the parsed text // Return the parsed text
return $text; return $text;
} }
// Verify ReCAPTCHA // Verify ReCAPTCHA
@ -125,7 +116,6 @@ class Main
// Return shit // Return shit
return $resp; return $resp;
} }
// Error Handler // Error Handler
@ -171,7 +161,6 @@ class Main
]); ]);
} }
} }
switch ($errno) { switch ($errno) {
@ -263,7 +252,6 @@ class Main
$errorPage .= '</pre>'; $errorPage .= '</pre>';
} }
} }
$errorPage .= '</div> $errorPage .= '</div>
@ -276,7 +264,6 @@ class Main
// Die and display error message // Die and display error message
die($errorPage); die($errorPage);
} }
// Send emails // Send emails
@ -351,7 +338,6 @@ class Main
// Else just return whatever // Else just return whatever
return $send; return $send;
} }
// Cleaning strings // Cleaning strings
@ -375,7 +361,6 @@ class Main
// Return clean string // Return clean string
return $string; return $string;
} }
// Loading info pages // Loading info pages
@ -387,7 +372,6 @@ class Main
// Return the data if there is any else just return false // Return the data if there is any else just return false
return count($infopage) ? $infopage : false; return count($infopage) ? $infopage : false;
} }
// Validate MX records // Validate MX records
@ -402,7 +386,6 @@ class Main
// Return the record data // Return the record data
return $record; return $record;
} }
// Check IP version // Check IP version
@ -424,7 +407,6 @@ class Main
// Not an IP or unknown type // Not an IP or unknown type
return 0; return 0;
} }
// Convert inet_pton to string with bits // Convert inet_pton to string with bits
@ -447,7 +429,6 @@ class Main
// Return IP // Return IP
return $binaryIP; return $binaryIP;
} }
// Match IP subnets // Match IP subnets
@ -493,7 +474,6 @@ class Main
return 0; return 0;
} }
} }
// Check if IP is a CloudFlare IP // Check if IP is a CloudFlare IP
@ -526,7 +506,6 @@ class Main
// Return false if fails // Return false if fails
return false; return false;
} }
// Gets IP of current visitor // Gets IP of current visitor
@ -546,7 +525,6 @@ class Main
// Return the correct IP // Return the correct IP
return $ip; return $ip;
} }
// Get country code from CloudFlare header (which just returns XX if not found) // Get country code from CloudFlare header (which just returns XX if not found)
@ -560,7 +538,6 @@ class Main
// Return XX as a fallback // Return XX as a fallback
return 'XX'; return 'XX';
} }
// Create a new action code // Create a new action code
@ -588,7 +565,6 @@ class Main
// Return the key // Return the key
return $key; return $key;
} }
// Use an action code // Use an action code
@ -620,7 +596,6 @@ class Main
// Return success // Return success
return [1, 'SUCCESS', $keyRow['instruction']]; return [1, 'SUCCESS', $keyRow['instruction']];
} }
// Calculate password entropy // Calculate password entropy
@ -632,7 +607,6 @@ class Main
// Count the amount of unique characters in the password string and calculate the entropy // Count the amount of unique characters in the password string and calculate the entropy
return count(count_chars($pw, 1)) * log(256, 2); return count(count_chars($pw, 1)) * log(256, 2);
} }
// Get country name from ISO 3166 code // Get country name from ISO 3166 code
@ -656,7 +630,6 @@ class Main
// Else return unknown // Else return unknown
return 'Unknown'; return 'Unknown';
} }
// Get FAQ data // Get FAQ data
@ -668,7 +641,6 @@ class Main
// Return FAQ data // Return FAQ data
return $faq; return $faq;
} }
// Get log type string // Get log type string
@ -685,7 +657,6 @@ class Main
// Return the string // Return the string
return $return['string']; return $return['string'];
} }
// Get formatted logs // Get formatted logs
@ -713,7 +684,6 @@ class Main
// Return new logs // Return new logs
return $logs; return $logs;
} }
// Time elapsed // Time elapsed
@ -750,7 +720,6 @@ class Main
return $round . ' ' . $times[$secs] . ($round == 1 ? '' : 's') . $append; return $round . ' ' . $times[$secs] . ($round == 1 ? '' : 's') . $append;
} }
} }
} }
// Get the byte symbol from a value // Get the byte symbol from a value
@ -773,7 +742,6 @@ class Main
// Return the formatted string // Return the formatted string
return $bytes; return $bytes;
} }
// Get Premium tracker data // Get Premium tracker data
@ -808,13 +776,11 @@ class Main
// Return the data // Return the data
return $data; return $data;
} }
// Update donation tracker // Update donation tracker
public static function updatePremiumTracker($id, $amount, $comment) public static function updatePremiumTracker($id, $amount, $comment)
{ {
Database::insert('premium_log', [ Database::insert('premium_log', [
'user_id' => $id, 'user_id' => $id,
@ -823,6 +789,5 @@ class Main
'transaction_comment' => $comment, 'transaction_comment' => $comment,
]); ]);
} }
} }

View file

@ -11,5 +11,4 @@ namespace Sakura;
*/ */
class Manage class Manage
{ {
} }

View file

@ -41,31 +41,24 @@ class News
// Add post to posts array // Add post to posts array
$this->posts[$post['news_id']] = $post; $this->posts[$post['news_id']] = $post;
} }
} }
// Get the amount of posts // Get the amount of posts
public function getCount() public function getCount()
{ {
return count($this->posts); return count($this->posts);
} }
// Get the amount of posts // Get the amount of posts
public function postExists($pid) public function postExists($pid)
{ {
return array_key_exists($pid, $this->posts) ? $pid : 0; return array_key_exists($pid, $this->posts) ? $pid : 0;
} }
// Get a single post // Get a single post
public function getPost($pid) public function getPost($pid)
{ {
return array_key_exists($pid, $this->posts) ? $this->posts[$pid] : 0; return array_key_exists($pid, $this->posts) ? $this->posts[$pid] : 0;
} }
// Getting posts // Getting posts
@ -85,6 +78,5 @@ class News
} }
return $posts; return $posts;
} }
} }

View file

@ -41,7 +41,6 @@ class Payments
} }
return true; return true;
} }
// Create transaction // Create transaction
@ -117,7 +116,6 @@ class Payments
// Return the approval link if everything is gucci // Return the approval link if everything is gucci
return $payment->getApprovalLink(); return $payment->getApprovalLink();
} }
// Complete the PayPal transaction // Complete the PayPal transaction
@ -142,6 +140,5 @@ class Payments
// If everything was cute return true // If everything was cute return true
return true; return true;
} }
} }

View file

@ -103,7 +103,6 @@ class Permissions
// Else just return false // Else just return false
return false; return false;
} }
// Get permission data of a rank from the database // Get permission data of a rank from the database
@ -150,7 +149,6 @@ class Permissions
// Return the compiled permission strings // Return the compiled permission strings
return $perms; return $perms;
} }
// Get permission data for a user // Get permission data for a user
@ -191,6 +189,5 @@ class Permissions
// Return permissions // Return permissions
return $rankPerms; return $rankPerms;
} }
} }

View file

@ -32,70 +32,53 @@ class Rank
// If not assign as the fallback rank // If not assign as the fallback rank
$this->data = Users::$emptyRank; $this->data = Users::$emptyRank;
} }
} }
// Get the rank id // Get the rank id
public function id() public function id()
{ {
return $this->data['rank_id']; return $this->data['rank_id'];
} }
// Get the rank hierarchy // Get the rank hierarchy
public function hierarchy() public function hierarchy()
{ {
return $this->data['rank_hierarchy']; return $this->data['rank_hierarchy'];
} }
// Get the rank name // Get the rank name
public function name($multi = false) public function name($multi = false)
{ {
return $this->data['rank_name'] . ($multi ? $this->data['rank_multiple'] : null); return $this->data['rank_name'] . ($multi ? $this->data['rank_multiple'] : null);
} }
// Get the rank title // Get the rank title
public function title() public function title()
{ {
return $this->data['rank_title']; return $this->data['rank_title'];
} }
// Get the rank description // Get the rank description
public function description() public function description()
{ {
return $this->data['rank_description']; return $this->data['rank_description'];
} }
// Get the rank colour // Get the rank colour
public function colour() public function colour()
{ {
return $this->data['rank_colour']; return $this->data['rank_colour'];
} }
// Check if the rank is hidden // Check if the rank is hidden
public function hidden() public function hidden()
{ {
return $this->data['rank_hidden'] || $this->checkPermission('SITE', 'DEACTIVATED') || $this->checkPermission('SITE', 'RESTRICTED'); return $this->data['rank_hidden'] || $this->checkPermission('SITE', 'DEACTIVATED') || $this->checkPermission('SITE', 'RESTRICTED');
} }
// Check if the rank has the proper permissions // Check if the rank has the proper permissions
public function checkPermission($layer, $action) public function checkPermission($layer, $action)
{ {
return Permissions::check($layer, $action, [$this->id()], 2); return Permissions::check($layer, $action, [$this->id()], 2);
} }
} }

View file

@ -27,7 +27,6 @@ class Session
if (session_status() != PHP_SESSION_ACTIVE) { if (session_status() != PHP_SESSION_ACTIVE) {
session_start(); session_start();
} }
} }
// Destroy this session // Destroy this session
@ -48,7 +47,6 @@ class Session
if (session_status() == PHP_SESSION_ACTIVE) { if (session_status() == PHP_SESSION_ACTIVE) {
session_destroy(); session_destroy();
} }
} }
// Create a new session // Create a new session
@ -71,7 +69,6 @@ class Session
// Return the session key // Return the session key
return $session; return $session;
} }
// Validate an apparently existing session // Validate an apparently existing session
@ -155,6 +152,5 @@ class Session
// Return 2 if the remember flag is set and return 1 if not // Return 2 if the remember flag is set and return 1 if not
return $session['session_remember'] ? 2 : 1; return $session['session_remember'] ? 2 : 1;
} }
} }

View file

@ -11,5 +11,4 @@ namespace Sakura;
*/ */
class Template class Template
{ {
} }

View file

@ -45,7 +45,6 @@ class Templates
// Start Twig // Start Twig
self::twigLoader(); self::twigLoader();
} }
// Twig Loader // Twig Loader
@ -68,18 +67,15 @@ class Templates
// Load String template loader // Load String template loader
self::$engine->addExtension(new Twig_Extension_StringLoader()); self::$engine->addExtension(new Twig_Extension_StringLoader());
} }
// Render template // Render template
public static function render($file, $tags) public static function render($file, $tags)
{ {
try { try {
return self::$engine->render($file, $tags); return self::$engine->render($file, $tags);
} catch (\Exception $e) { } catch (\Exception $e) {
trigger_error($e->getMessage(), E_USER_ERROR); trigger_error($e->getMessage(), E_USER_ERROR);
} }
} }
} }

View file

@ -11,5 +11,4 @@ namespace Sakura;
*/ */
class Trick class Trick
{ {
} }

View file

@ -11,5 +11,4 @@ namespace Sakura;
*/ */
class Upload class Upload
{ {
} }

View file

@ -291,6 +291,5 @@ class Urls
// Return the formatted url // Return the formatted url
return $formatted; return $formatted;
} }
} }

View file

@ -60,7 +60,6 @@ class User
$this->data['rank_main'] : $this->data['rank_main'] :
array_keys($this->ranks)[0] array_keys($this->ranks)[0]
]; ];
} }
// Check if the user has the specified ranks // Check if the user has the specified ranks
@ -82,52 +81,41 @@ class User
// If all fails return false // If all fails return false
return false; return false;
} }
// Get the user's colour // Get the user's colour
public function colour() public function colour()
{ {
return empty($this->data['user_colour']) ? $this->mainRank->colour() : $this->data['user_colour']; return empty($this->data['user_colour']) ? $this->mainRank->colour() : $this->data['user_colour'];
} }
// Get the user's title // Get the user's title
public function userTitle() public function userTitle()
{ {
return empty($this->data['user_title']) ? $this->mainRank->title() : $this->data['user_title']; return empty($this->data['user_title']) ? $this->mainRank->title() : $this->data['user_title'];
} }
// Get the user's long and short country names // Get the user's long and short country names
public function country() public function country()
{ {
return [ return [
'long' => Main::getCountryName($this->data['user_country']), 'long' => Main::getCountryName($this->data['user_country']),
'short' => $this->data['user_country'], 'short' => $this->data['user_country'],
]; ];
} }
// Check if a user is online // Check if a user is online
public function checkOnline() public function checkOnline()
{ {
return $this->data['user_last_online'] > (time() - Configuration::getConfig('max_online_time')); return $this->data['user_last_online'] > (time() - Configuration::getConfig('max_online_time'));
} }
// Get user's forum statistics // Get user's forum statistics
public function forumStats() public function forumStats()
{ {
return Forum::getUserStats($this->data['user_id']); return Forum::getUserStats($this->data['user_id']);
} }
// Add a new friend // Add a new friend
@ -159,7 +147,6 @@ class User
// Return true because yay // Return true because yay
return [1, $check == 2 ? 'FRIENDS' : 'NOT_MUTUAL']; return [1, $check == 2 ? 'FRIENDS' : 'NOT_MUTUAL'];
} }
// Remove a friend // Remove a friend
@ -195,7 +182,6 @@ class User
// Return true because yay // Return true because yay
return [1, 'REMOVED']; return [1, 'REMOVED'];
} }
// Check if the user is friends with the currently authenticated // Check if the user is friends with the currently authenticated
@ -220,45 +206,35 @@ class User
// Return true if all went through // Return true if all went through
return 0; return 0;
} }
// Get all the friend of this user // Get all the friend of this user
public function getFriends($timestamps = false, $getData = false, $checkOnline = false) public function getFriends($timestamps = false, $getData = false, $checkOnline = false)
{ {
return Users::getFriends($this->data['user_id'], $timestamps, $getData, $checkOnline); return Users::getFriends($this->data['user_id'], $timestamps, $getData, $checkOnline);
} }
// Check if the user is banned // Check if the user is banned
public function checkBan() public function checkBan()
{ {
return Bans::checkBan($this->data['user_id']); return Bans::checkBan($this->data['user_id']);
} }
// Check if the user has the proper permissions // Check if the user has the proper permissions
public function checkPermission($layer, $action) public function checkPermission($layer, $action)
{ {
return Permissions::check($layer, $action, $this->data['user_id'], 1); return Permissions::check($layer, $action, $this->data['user_id'], 1);
} }
// Get a user's profile comments // Get a user's profile comments
public function profileComments() public function profileComments()
{ {
return new Comments('profile-' . $this->data['user_id']); return new Comments('profile-' . $this->data['user_id']);
} }
// Get amount of time since user events // Get amount of time since user events
public function elapsed($append = ' ago', $none = 'Just now') public function elapsed($append = ' ago', $none = 'Just now')
{ {
return [ return [
'joined' => Main::timeElapsed($this->data['user_registered'], $append, $none), 'joined' => Main::timeElapsed($this->data['user_registered'], $append, $none),
@ -266,7 +242,6 @@ class User
'birth' => Main::timeElapsed(strtotime($this->data['user_birthday']), $append, $none), 'birth' => Main::timeElapsed(strtotime($this->data['user_birthday']), $append, $none),
]; ];
} }
// Get the user's profile fields // Get the user's profile fields
@ -334,7 +309,6 @@ class User
// Return appropiate profile data // Return appropiate profile data
return $profile; return $profile;
} }
// Get the user's option fields // Get the user's option fields
@ -375,7 +349,6 @@ class User
// Return appropiate profile data // Return appropiate profile data
return $options; return $options;
} }
// Check if user has Premium // Check if user has Premium
@ -406,7 +379,6 @@ class User
// Else return the start and expiration date // Else return the start and expiration date
return [1, $getRecord['premium_start'], $getRecord['premium_expire']]; return [1, $getRecord['premium_start'], $getRecord['premium_expire']];
} }
// Get all warnings issued to the user // Get all warnings issued to the user
@ -458,13 +430,11 @@ class User
// Return all the warnings // Return all the warnings
return $warnings; return $warnings;
} }
// Get a user's userpage // Get a user's userpage
public function userPage() public function userPage()
{ {
return isset($this->data['user_data']['userPage']) ? return isset($this->data['user_data']['userPage']) ?
Main::mdParse( Main::mdParse(
base64_decode( base64_decode(
@ -473,13 +443,11 @@ class User
true true
) : ) :
null; null;
} }
// Get a user's signature // Get a user's signature
public function signature() public function signature()
{ {
return isset($this->data['user_data']['signature']) ? return isset($this->data['user_data']['signature']) ?
Main::bbParse( Main::bbParse(
Main::parseEmotes( Main::parseEmotes(
@ -489,7 +457,6 @@ class User
) )
) : ) :
null; null;
} }
// Get username change history // Get username change history
@ -503,7 +470,6 @@ class User
// Return all the warnings // Return all the warnings
return $changes; return $changes;
} }
// Set a new username // Set a new username
@ -567,7 +533,6 @@ class User
// Return success // Return success
return [1, 'SUCCESS', $username]; return [1, 'SUCCESS', $username];
} }
// Set a new e-mail address // Set a new e-mail address
@ -601,7 +566,6 @@ class User
// Return success // Return success
return [1, 'SUCCESS', $email]; return [1, 'SUCCESS', $email];
} }
// Set a new password // Set a new password
@ -655,6 +619,5 @@ class User
// Return success // Return success
return [1, 'SUCCESS']; return [1, 'SUCCESS'];
} }
} }

View file

@ -11,7 +11,6 @@ namespace Sakura;
*/ */
class Users class Users
{ {
// Empty user template // Empty user template
public static $emptyUser = [ public static $emptyUser = [
'user_id' => 0, 'user_id' => 0,
@ -126,7 +125,6 @@ class Users
// If everything went through return true // If everything went through return true
return [$uid, $sid]; return [$uid, $sid];
} }
// Log a user in // Log a user in
@ -210,7 +208,6 @@ class Users
// Successful login! (also has a thing for the legacy password system) // Successful login! (also has a thing for the legacy password system)
return [1, 'LOGIN_SUCCESS', $user['user_id']]; return [1, 'LOGIN_SUCCESS', $user['user_id']];
} }
// Logout and kill the session // Logout and kill the session
@ -245,7 +242,6 @@ class Users
// Return true indicating a successful logout // Return true indicating a successful logout
return true; return true;
} }
// Register user // Register user
@ -361,7 +357,6 @@ class Users
// Return true with a specific message if needed // Return true with a specific message if needed
return [1, ($requireActive ? 'EMAILSENT' : 'SUCCESS')]; return [1, ($requireActive ? 'EMAILSENT' : 'SUCCESS')];
} }
// Check if a user exists and then send the password forgot email // Check if a user exists and then send the password forgot email
@ -419,7 +414,6 @@ class Users
// Return success // Return success
return [1, 'SUCCESS']; return [1, 'SUCCESS'];
} }
// Reset password with key // Reset password with key
@ -469,7 +463,6 @@ class Users
// Return success // Return success
return [1, 'SUCCESS']; return [1, 'SUCCESS'];
} }
// Check if a user exists and then resend the activation e-mail // Check if a user exists and then resend the activation e-mail
@ -506,7 +499,6 @@ class Users
// Return success // Return success
return [1, 'SUCCESS']; return [1, 'SUCCESS'];
} }
// Send the activation e-mail and do other required stuff // Send the activation e-mail and do other required stuff
@ -557,7 +549,6 @@ class Users
// Return true indicating that the things have been sent // Return true indicating that the things have been sent
return true; return true;
} }
// Activating a user // Activating a user
@ -611,7 +602,6 @@ class Users
// Return success // Return success
return [1, 'SUCCESS']; return [1, 'SUCCESS'];
} }
// Deactivating a user // Deactivating a user
@ -644,7 +634,6 @@ class Users
// Return success // Return success
return [1, 'SUCCESS']; return [1, 'SUCCESS'];
} }
// Check if registration code is valid // Check if registration code is valid
@ -656,7 +645,6 @@ class Users
// Check if it exists and return it // Check if it exists and return it
return count($keyRow) ? $keyRow[0]['id'] : false; return count($keyRow) ? $keyRow[0]['id'] : false;
} }
// Mark registration code as used // Mark registration code as used
@ -681,7 +669,6 @@ class Users
// Return true because yeah // Return true because yeah
return true; return true;
} }
// Create new registration code // Create new registration code
@ -715,7 +702,6 @@ class Users
// Return the code // Return the code
return $code; return $code;
} }
// Set the default rank of a user // Set the default rank of a user
@ -745,7 +731,6 @@ class Users
// Return true if everything was successful // Return true if everything was successful
return true; return true;
} }
// Add a rank to a user // Add a rank to a user
@ -781,7 +766,6 @@ class Users
// Return true because // Return true because
return true; return true;
} }
// Removing ranks from a user // Removing ranks from a user
@ -817,15 +801,12 @@ class Users
// Return true // Return true
return true; return true;
} }
// Check if a user has these ranks // Check if a user has these ranks
public static function checkIfUserHasRanks($ranks, $userid, $userIdIsUserData = false) public static function checkIfUserHasRanks($ranks, $userid, $userIdIsUserData = false)
{ {
return $userIdIsUserData ? $userid->checkIfUserHasRanks($ranks) : (new User($userid))->checkIfUserHasRanks($ranks); return $userIdIsUserData ? $userid->checkIfUserHasRanks($ranks) : (new User($userid))->checkIfUserHasRanks($ranks);
} }
// Check if a user exists // Check if a user exists
@ -840,7 +821,6 @@ class Users
// Return count (which would return 0, aka false, if nothing was found) // Return count (which would return 0, aka false, if nothing was found)
return count($user) ? $user[0]['user_id'] : false; return count($user) ? $user[0]['user_id'] : false;
} }
// Get the available profile fields // Get the available profile fields
@ -867,7 +847,6 @@ class Users
// Return the yeahs // Return the yeahs
return $fields; return $fields;
} }
// Get the available option fields // Get the available option fields
@ -896,7 +875,6 @@ class Users
// Return the yeahs // Return the yeahs
return $fields; return $fields;
} }
// Get user's profile fields // Get user's profile fields
@ -966,7 +944,6 @@ class Users
// Return appropiate profile data // Return appropiate profile data
return $profile; return $profile;
} }
// Updating the profile data of a user // Updating the profile data of a user
@ -991,7 +968,6 @@ class Users
'user_id' => [$id, '='], 'user_id' => [$id, '='],
], ],
]); ]);
} }
// Check if a user is online // Check if a user is online
@ -1008,7 +984,6 @@ class Users
// Return true if the user was online in the last 5 minutes // Return true if the user was online in the last 5 minutes
return ($user['user_last_online'] > (time() - 500)); return ($user['user_last_online'] > (time() - 500));
} }
// Get all online users // Get all online users
@ -1023,7 +998,6 @@ class Users
// Return all the online users // Return all the online users
return $getAll; return $getAll;
} }
// Add premium to a user // Add premium to a user
@ -1059,17 +1033,14 @@ class Users
// Return the expiration timestamp // Return the expiration timestamp
return $expire; return $expire;
} }
// Remove the premium status of a user // Remove the premium status of a user
public static function removeUserPremium($id) public static function removeUserPremium($id)
{ {
Database::delete('premium', [ Database::delete('premium', [
'user_id' => [$id, '='], 'user_id' => [$id, '='],
]); ]);
} }
// Check if user has Premium // Check if user has Premium
@ -1100,7 +1071,6 @@ class Users
// Else return the start and expiration date // Else return the start and expiration date
return [1, $getRecord['premium_start'], $getRecord['premium_expire']]; return [1, $getRecord['premium_start'], $getRecord['premium_expire']];
} }
// Update the premium data // Update the premium data
@ -1126,7 +1096,6 @@ class Users
// Else remove the rank from them // Else remove the rank from them
self::removeRanksFromUser([$premiumRank], $id); self::removeRanksFromUser([$premiumRank], $id);
} }
} }
// Get user data by id // Get user data by id
@ -1135,7 +1104,6 @@ class Users
// If user was found return user data // If user was found return user data
return (new User($id))->data; return (new User($id))->data;
} }
// Get rank data by id // Get rank data by id
@ -1144,7 +1112,6 @@ class Users
// If rank was found return rank data // If rank was found return rank data
return (new Rank($id))->data; return (new Rank($id))->data;
} }
// Get user(s) by IP // Get user(s) by IP
@ -1162,7 +1129,6 @@ class Users
// Return the array with users // Return the array with users
return $users; return $users;
} }
// Get users in rank // Get users in rank
@ -1188,7 +1154,6 @@ class Users
// Then return the array with the user rows // Then return the array with the user rows
return $rank; return $rank;
} }
// Get all users // Get all users
@ -1218,7 +1183,6 @@ class Users
// and return an array with the users // and return an array with the users
return $users; return $users;
} }
// Get all ranks // Get all ranks
@ -1238,7 +1202,6 @@ class Users
// and return an array with the ranks // and return an array with the ranks
return $ranks; return $ranks;
} }
// Get all warnings issued to a user (or all warnings a user issued) // Get all warnings issued to a user (or all warnings a user issued)
@ -1252,7 +1215,6 @@ class Users
// Return all the warnings // Return all the warnings
return $warnings; return $warnings;
} }
// Get a user's notifications // Get a user's notifications
@ -1290,7 +1252,6 @@ class Users
// Return the notifications // Return the notifications
return $notifications; return $notifications;
} }
// Marking notifications as read // Marking notifications as read
@ -1306,7 +1267,6 @@ class Users
'alert_id' => [$id, '='], 'alert_id' => [$id, '='],
], ],
]); ]);
} }
// Adding a new notification // Adding a new notification
@ -1328,7 +1288,6 @@ class Users
'alert_img' => $img, 'alert_img' => $img,
'alert_timeout' => $timeout, 'alert_timeout' => $timeout,
]); ]);
} }
// Getting a user's PMs // Getting a user's PMs
@ -1357,7 +1316,6 @@ class Users
// Return store array // Return store array
return $store; return $store;
} }
// Get friends // Get friends
@ -1400,7 +1358,6 @@ class Users
// Return formatted array // Return formatted array
return $friends; return $friends;
} }
// Get non-mutual friends // Get non-mutual friends
@ -1438,14 +1395,11 @@ class Users
// Return the pending friends // Return the pending friends
return $pending; return $pending;
} }
// Get the ID of the newest user // Get the ID of the newest user
public static function getNewestUserId() public static function getNewestUserId()
{ {
return Database::fetch('users', false, ['password_algo' => ['nologin', '!=']], ['user_id', true], ['1'])['user_id']; return Database::fetch('users', false, ['password_algo' => ['nologin', '!=']], ['user_id', true], ['1'])['user_id'];
} }
} }

View file

@ -64,7 +64,6 @@ class Whois
// If everything is gucci set self::$servers // If everything is gucci set self::$servers
self::$servers = $servers; self::$servers = $servers;
} }
// Query the whois servers // Query the whois servers
@ -83,7 +82,6 @@ class Whois
default: // ...a false is returned by this function default: // ...a false is returned by this function
return false; return false;
} }
} }
// Validates an address // Validates an address
@ -102,7 +100,6 @@ class Whois
// If unsuccessful return 0 // If unsuccessful return 0
return 0; return 0;
} }
// Look up a domain // Look up a domain
@ -154,7 +151,6 @@ class Whois
// If all is good return the return variable // If all is good return the return variable
return $return; return $return;
} }
// Look up an IP // Look up an IP
@ -194,7 +190,6 @@ class Whois
// Return results // Return results
return $return; return $return;
} }
// Query whois server // Query whois server
@ -230,6 +225,5 @@ class Whois
// Return results // Return results
return $out; return $out;
} }
} }

View file

@ -13,7 +13,7 @@ use \Sakura\Configuration;
* Class MySQL * Class MySQL
* @package Sakura\DBWrapper * @package Sakura\DBWrapper
*/ */
class MySQL class mysql
{ {
// Variable that will contain the SQL connection // Variable that will contain the SQL connection
// Please refrain from referring to this, unless it's for your personal branch/purpose, despite it being public // Please refrain from referring to this, unless it's for your personal branch/purpose, despite it being public
@ -23,7 +23,6 @@ class MySQL
// Constructor // Constructor
public function __construct() public function __construct()
{ {
if (!extension_loaded('PDO')) { if (!extension_loaded('PDO')) {
// Return error and die // Return error and die
trigger_error('PDO extension not loaded.', E_USER_ERROR); trigger_error('PDO extension not loaded.', E_USER_ERROR);
@ -50,33 +49,27 @@ class MySQL
Configuration::getLocalConfig('database', 'username'), Configuration::getLocalConfig('database', 'username'),
Configuration::getLocalConfig('database', 'password') Configuration::getLocalConfig('database', 'password')
); );
} }
// Regular IP/Hostname connection method prepare function // Regular IP/Hostname connection method prepare function
private function prepareHost($dbHost, $dbName, $dbPort = 3306) private function prepareHost($dbHost, $dbName, $dbPort = 3306)
{ {
$dsn = 'mysql:host=' . $dbHost . ';port=' . $dbPort . ';dbname=' . $dbName; $dsn = 'mysql:host=' . $dbHost . ';port=' . $dbPort . ';dbname=' . $dbName;
return $dsn; return $dsn;
} }
// Unix Socket connection method prepare function // Unix Socket connection method prepare function
private function prepareSock($dbHost, $dbName) private function prepareSock($dbHost, $dbName)
{ {
$dsn = 'mysql:unix_socket=' . $dbHost . ';dbname=' . $dbName; $dsn = 'mysql:unix_socket=' . $dbHost . ';dbname=' . $dbName;
return $dsn; return $dsn;
} }
// Initialise connection using default PDO stuff // Initialise connection using default PDO stuff
private function initConnect($dsn, $dbUname, $dbPword) private function initConnect($dsn, $dbUname, $dbPword)
{ {
try { try {
// Connect to SQL server using PDO // Connect to SQL server using PDO
$this->sql = new PDO($dsn, $dbUname, $dbPword, [ $this->sql = new PDO($dsn, $dbUname, $dbPword, [
@ -89,7 +82,6 @@ class MySQL
} }
return true; return true;
} }
public function select($table, $data = null, $order = null, $limit = null, $group = null, $distinct = false, $column = '*', $prefix = null) public function select($table, $data = null, $order = null, $limit = null, $group = null, $distinct = false, $column = '*', $prefix = null)
@ -121,9 +113,7 @@ class MySQL
// Unset variables to be safe // Unset variables to be safe
unset($key); unset($key);
unset($value); unset($value);
} }
} }
// If $group is set and is an array continue // If $group is set and is an array continue
@ -192,7 +182,6 @@ class MySQL
// Return the query // Return the query
return $query; return $query;
} }
// Fetch array from database // Fetch array from database
@ -204,7 +193,6 @@ class MySQL
// Return the output // Return the output
return $fetchAll ? $query->fetchAll(PDO::FETCH_ASSOC) : $query->fetch(PDO::FETCH_ASSOC); return $fetchAll ? $query->fetchAll(PDO::FETCH_ASSOC) : $query->fetch(PDO::FETCH_ASSOC);
} }
// Insert data to database // Insert data to database
@ -222,7 +210,6 @@ class MySQL
if (strlen($value)) { if (strlen($value)) {
$prepare .= ($i ? ':' : '`') . $key . ($i ? '' : '`') . ($key == key(array_slice($data, -1, 1, true)) ? '' : ', '); $prepare .= ($i ? ':' : '`') . $key . ($i ? '' : '`') . ($key == key(array_slice($data, -1, 1, true)) ? '' : ', ');
} }
} }
$prepare .= ')' . ($i ? ';' : ' VALUES '); $prepare .= ')' . ($i ? ';' : ' VALUES ');
@ -247,7 +234,6 @@ class MySQL
// Return whatever can be returned // Return whatever can be returned
return $result; return $result;
} }
// Update data in the database // Update data in the database
@ -301,7 +287,6 @@ class MySQL
// Return whatever can be returned // Return whatever can be returned
return $result; return $result;
} }
// Delete data from the database // Delete data from the database
@ -341,7 +326,6 @@ class MySQL
// Return whatever can be returned // Return whatever can be returned
return $result; return $result;
} }
// Count data from the database // Count data from the database
@ -386,14 +370,12 @@ class MySQL
// Return the output // Return the output
return $query->fetch(PDO::FETCH_BOTH); return $query->fetch(PDO::FETCH_BOTH);
} }
// Get the ID of the last inserted item // Get the ID of the last inserted item
public function lastInsertID($name = null) public function lastInsertID($name = null)
{ {
return $this->sql->lastInsertID($name);
return $this->sql->lastInsertID($name);; ;
} }
} }

View file

@ -83,9 +83,7 @@ if (Configuration::getConfig('no_cron_service')) {
'config_name' => ['no_cron_last', '='], 'config_name' => ['no_cron_last', '='],
], ],
]); ]);
} }
} }
// Start output buffering // Start output buffering

View file

@ -281,7 +281,6 @@ if (isset($_REQUEST['mode'])) {
break; break;
} }
} }
// Print page contents or if the AJAX request is set only display the render data // Print page contents or if the AJAX request is set only display the render data

View file

@ -710,7 +710,6 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
'user_id' => [$currentUser->data['user_id'], '='], 'user_id' => [$currentUser->data['user_id'], '='],
], ],
]); ]);
} }
break; break;
@ -979,7 +978,6 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
break; break;
} }
} }
// Print page contents or if the AJAX request is set only display the render data // Print page contents or if the AJAX request is set only display the render data
@ -991,7 +989,6 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
) : ) :
Templates::render('global/information.tpl', $renderData); Templates::render('global/information.tpl', $renderData);
exit; exit;
} }
if (Users::checkLogin()) { if (Users::checkLogin()) {

View file

@ -67,7 +67,6 @@ if (isset($_REQUEST['mode'])
} else { } else {
header('Location: ' . $urls->format('SITE_PREMIUM') . '?fail=true'); header('Location: ' . $urls->format('SITE_PREMIUM') . '?fail=true');
} }
} }
break; break;
@ -128,11 +127,9 @@ if (isset($_REQUEST['mode'])
break; break;
} }
} }
exit; exit;
} }
// Premium tracker // Premium tracker