update phpdocs

This commit is contained in:
flash 2016-08-05 04:35:37 +02:00
parent f7276d6d9a
commit 99788b2539
63 changed files with 863 additions and 651 deletions

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the action code handling class.
*
* @package Sakura
*/
@ -9,7 +8,6 @@ namespace Sakura;
/**
* Used to generate one-time keys for user automatic user actions e.g. account activation.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -17,11 +15,9 @@ class ActionCode
{
/**
* Generate an Action Code.
*
* @param string $action The identifier of the action.
* @param int $user The user this action code is intended for (leave 0 for universal).
*
* @return string The action code given to the user.
* @param string $action
* @param int $user
* @return string
*/
public static function generate($action, $user = 0)
{
@ -44,13 +40,11 @@ class ActionCode
/**
* Validate an action code.
*
* @param string $action The action identifier.
* @param string $code The action code.
* @param int $user The id of the user validating this code.
* @param bool $invalidate Set if the code should be invalidated once validated.
*
* @return bool Boolean indicating success.
* @param string $action
* @param string $code
* @param int $user
* @param bool $invalidate
* @return bool
*/
public static function validate($action, $code, $user = 0, $invalidate = true)
{
@ -72,8 +66,7 @@ class ActionCode
/**
* Make a code invalid.
*
* @param string $code The code that is being invalidated.
* @param string $code
*/
public static function invalidate($code)
{

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds information about the currently active session
*
* @package Sakura
*/
@ -11,15 +10,28 @@ use Sakura\Perms\Site;
/**
* Information about the current active user and session.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class ActiveUser
{
/**
* The user object of the currently active user.
* @var User
*/
public static $user = null;
/**
* The currently active session object.
* @var Session
*/
public static $session = null;
/**
* Attempt to validate a session.
* @param int $userId
* @param string $sessionId
*/
public static function init($userId, $sessionId)
{
// Create a session object

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the BBcode handler.
*
* @package Sakura
*/
@ -9,15 +8,13 @@ namespace Sakura;
/**
* BBcode handler.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class BBcode
{
/**
* Holds the bbcode parsers
*
* Holds the bbcode parsers.
* @var array
*/
public static $parsers = [
@ -140,7 +137,6 @@ class BBcode
/**
* Parse the emoticons.
*
* @param string $text
* @return string
*/
@ -163,7 +159,6 @@ class BBcode
/**
* Convert the parsed text to HTML.
*
* @param string $text
* @return string
*/

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the CSRF token handler.
*
* @package Sakura
*/
@ -9,7 +8,6 @@ namespace Sakura;
/**
* Used to generate and validate CSRF tokens.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -27,10 +25,8 @@ class CSRF
/**
* Create a new CSRF token.
*
* @param mixed $id The ID for this token.
*
* @return string The token.
* @param mixed $id
* @return string
*/
public static function create($id)
{
@ -49,8 +45,7 @@ class CSRF
/**
* Generate a CSRF token.
*
* @return string Cryptographically secure random string.
* @return string
*/
public static function generate()
{
@ -59,11 +54,9 @@ class CSRF
/**
* Validate a CSRF token.
*
* @param mixed $token The token.
* @param mixed $id The ID.
*
* @return bool Indicator if it was right or not.
* @param string $token
* @param string $id
* @return bool
*/
public static function validate($token, $id)
{

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the comment object.
*
* @package Sakura
*/
@ -9,23 +8,75 @@ namespace Sakura;
/**
* Comment object.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Comment
{
/**
* The comment identifier.
* @var int
*/
public $id = 0;
/**
* The category this comment belongs to.
* @var string
*/
public $category = "";
/**
* The timestamp this comment was posted at.
* @var int
*/
public $time = 0;
/**
* The Id of the user that posted this comment.
* @var int
*/
public $user = 0;
/**
* The Id of the comment this comment is replying to.
* @var int
*/
public $reply = 0;
/**
* The content of this comment.
* @var string
*/
public $text = "";
/**
* The upvotes this comment has received.
* @var int
*/
public $upvotes = 0;
/**
* The downvotes this comment has received.
* @var int
*/
public $downvotes = 0;
/**
* A cache of reply objects.
* @var array
*/
private $replyCache = [];
/**
* A cache of the parsed text content.
* @var string
*/
private $parsedCache = "";
/**
* Constructor.
* @var int $id
*/
public function __construct($id = 0)
{
// Get comment data from the database
@ -48,6 +99,9 @@ class Comment
}
}
/**
* Saving changes made to this comment.
*/
public function save()
{
// Create submission data, insert and update take the same format
@ -70,6 +124,9 @@ class Comment
}
}
/**
* Delete this comment.
*/
public function delete()
{
foreach ($this->replies() as $reply) {
@ -83,6 +140,9 @@ class Comment
$this->id = 0;
}
/**
* Gets and caches the upvotes.
*/
private function getVotes()
{
$votes = DB::table('comment_votes')
@ -101,6 +161,10 @@ class Comment
}
}
/**
* Gets the parsed comment text
* @return string
*/
public function parsed()
{
if (!$this->parsedCache) {
@ -110,6 +174,10 @@ class Comment
return $this->parsedCache;
}
/**
* Get the replies to this comment.
* @return array
*/
public function replies()
{
if (!$this->replyCache) {
@ -127,11 +195,20 @@ class Comment
return $this->replyCache;
}
/**
* Gets the user object of the poster.
* @return User
*/
public function userData()
{
return User::construct($this->user);
}
/**
* Casts a vote on a comment.
* @param int $user
* @param bool $vote
*/
public function vote($user, $vote)
{
$vote = $vote ? '1' : '0';

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the configuration manager.
*
* @package Sakura
*/
@ -9,23 +8,20 @@ namespace Sakura;
/**
* Handles the configuration settings of Sakura.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Config
{
/**
* Storage for the parsed config file
*
* Storage for the parsed config file.
* @var array
*/
private static $config = [];
/**
* Initialiser, parses the configuration.
*
* @param string $path Path to the configuration file.
* @param string $path
*/
public static function init($path)
{
@ -46,11 +42,9 @@ class Config
/**
* Get a value from the configuration.
*
* @param string $key Configuration section.
* @param string $subkey Configuration key.
*
* @return array|string Configuration value.
* @param string $section
* @param string $key
* @return array|string
*/
public static function get($section, $key = null)
{

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the console application meta.
*
* @package Sakura
*/
@ -9,24 +8,24 @@ namespace Sakura\Console;
/**
* Command line interface main.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Application extends \CLIFramework\Application
{
/**
* CLI Application name
* CLI Application name.
*/
const NAME = 'Sakura';
/**
* CLI Application version
* CLI Application version.
*/
const VERSION = SAKURA_VERSION;
/*
* Enable command autoloading
/**
* Enable command autoloading.
* @var bool
*/
protected $commandAutoloadEnabled = true;
}

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the migration repository installer command controller.
*
* @package Sakura
*/
@ -12,13 +11,25 @@ use Illuminate\Database\Migrations\Migrator;
use Illuminate\Filesystem\Filesystem;
use Sakura\DB;
/**
* Installs the database migration repository.
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class DatabaseInstallCommand extends Command
{
/**
* A quick description of this command.
* @return string.
*/
public function brief()
{
return 'Create the migration repository';
}
/**
* Does the repository installing.
*/
public function execute()
{
$repository = DB::getMigrationRepository();

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the migration command controller.
*
* @package Sakura
*/
@ -12,15 +11,30 @@ use Illuminate\Database\Migrations\Migrator;
use Illuminate\Filesystem\Filesystem;
use Sakura\DB;
/**
* Brings the database up to speed with the ones in the database folder.
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class DatabaseMigrateCommand extends Command
{
/**
* The database migrations directory.
*/
const MIGRATIONS = "database/";
/**
* A quick description of this command.
* @return string.
*/
public function brief()
{
return 'Run the database migrations';
}
/**
* Does the migrating.
*/
public function execute()
{
$repository = DB::getMigrationRepository();

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the migration reset command controller.
*
* @package Sakura
*/
@ -12,13 +11,25 @@ use Illuminate\Database\Migrations\Migrator;
use Illuminate\Filesystem\Filesystem;
use Sakura\DB;
/**
* Resets the entire database.
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class DatabaseResetCommand extends Command
{
/**
* A quick description of this command.
* @return string.
*/
public function brief()
{
return 'Rollback all database migrations';
}
/**
* Does the resetting.
*/
public function execute()
{
$repository = DB::getMigrationRepository();

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the migration rollback command controller.
*
* @package Sakura
*/
@ -12,13 +11,25 @@ use Illuminate\Database\Migrations\Migrator;
use Illuminate\Filesystem\Filesystem;
use Sakura\DB;
/**
* Rolls back the last database migration action.
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class DatabaseRollbackCommand extends Command
{
/**
* A quick description of this command.
* @return string.
*/
public function brief()
{
return 'Rollback the last database migration';
}
/**
* Does the rolling back.
*/
public function execute()
{
$repository = DB::getMigrationRepository();

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the migration status command controller.
*
* @package Sakura
*/
@ -13,15 +12,30 @@ use Illuminate\Database\Migrations\Migrator;
use Illuminate\Filesystem\Filesystem;
use Sakura\DB;
/**
* Returns the status of the database migrations.
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class DatabaseStatusCommand extends Command
{
/**
* The database migrations directory.
*/
const MIGRATIONS = "database/";
/**
* A quick description of this command.
* @return string.
*/
public function brief()
{
return 'Show the status of each migration';
}
/**
* Fulfills the purpose of what is described above this class.
*/
public function execute()
{
$repository = DB::getMigrationRepository();

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the serve command controller.
*
* @package Sakura
*/
@ -9,13 +8,25 @@ namespace Sakura\Console\Command;
use CLIFramework\Command;
/**
* Starts up a development server.
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class ServeCommand extends Command
{
/**
* A quick description of this command.
* @return string.
*/
public function brief()
{
return 'Sets up a local development server.';
}
/**
* Sends the php serve command via the exec command.
*/
public function execute()
{
$document_root = addslashes(ROOT . 'public/');

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the setup command controller.
*
* @package Sakura
*/
@ -12,13 +11,25 @@ use Sakura\DB;
use Sakura\Net;
use Sakura\User;
/**
* The command that handles setting up the base data.
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class SetupCommand extends Command
{
/**
* A quick description of this command.
* @return string.
*/
public function brief()
{
return 'Adds the required data to the tables, only needed once after the initial migration.';
}
/**
* Adds data to the database required to get everything running.
*/
public function execute()
{
// Check if the users table has user with id 1

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the auth controllers.
*
* @package Sakura
*/
@ -20,7 +19,6 @@ use Sakura\User;
/**
* Authentication controllers.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -28,7 +26,6 @@ class AuthController extends Controller
{
/**
* Touch the login rate limit.
*
* @param $user int The ID of the user that attempted to log in.
* @param $sucess bool Whether the login attempt was successful.
*/
@ -45,7 +42,6 @@ class AuthController extends Controller
/**
* End the current session.
*
* @return string
*/
public function logout()
@ -75,7 +71,6 @@ class AuthController extends Controller
/**
* Get the login page.
*
* @return string
*/
public function loginGet()
@ -85,7 +80,6 @@ class AuthController extends Controller
/**
* Do a login attempt.
*
* @return string
*/
public function loginPost()
@ -189,7 +183,6 @@ class AuthController extends Controller
/**
* Get the registration page.
*
* @return string
*/
public function registerGet()
@ -212,7 +205,6 @@ class AuthController extends Controller
/**
* Do a registration attempt.
*
* @return string
*/
public function registerPost()
@ -342,7 +334,6 @@ class AuthController extends Controller
/**
* Do a activation attempt.
*
* @return string
*/
public function activate()
@ -405,7 +396,6 @@ class AuthController extends Controller
/**
* Get the reactivation request form.
*
* @return string
*/
public function reactivateGet()
@ -415,7 +405,6 @@ class AuthController extends Controller
/**
* Do a reactivation preparation attempt.
*
* @return string
*/
public function reactivatePost()
@ -476,7 +465,6 @@ class AuthController extends Controller
/**
* Get the password reset forum.
*
* @return string
*/
public function resetPasswordGet()
@ -486,7 +474,6 @@ class AuthController extends Controller
/**
* Do a password reset attempt.
*
* @return string
*/
public function resetPasswordPost()
@ -571,7 +558,6 @@ class AuthController extends Controller
/**
* Send the activation e-mail
*
* @param User $user
*/
private function sendActivationMail($user)
@ -606,7 +592,6 @@ class AuthController extends Controller
/**
* Send the activation e-mail
*
* @param User $user
*/
private function sendPasswordMail($user)

View file

@ -1,7 +1,6 @@
<?php
/**
* Hold the controller for chat related pages.
*
* @package Sakura
*/
@ -9,17 +8,23 @@ namespace Sakura\Controllers;
/**
* Chat related controller.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class ChatController extends Controller
{
/**
* Redirects the user to the chat client.
*/
public function redirect()
{
return;
}
/**
* Serves the settings for a Sakurako chat.
* @return string
*/
public function settings()
{
return;

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the comments controller.
*
* @package Sakura
*/
@ -14,12 +13,17 @@ use Sakura\Perms\Site;
/**
* Handles comment stuff.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class CommentsController extends Controller
{
/**
* Posts a comment.
* @param string $category
* @param int $reply
* @return string
*/
public function post($category = '', $reply = 0)
{
$session = $_POST['session'] ?? '';
@ -64,6 +68,11 @@ class CommentsController extends Controller
return $this->json($comment);
}
/**
* Delete a comment.
* @param int $id
* @return string
*/
public function delete($id = 0)
{
// Check if the user can delete comments
@ -91,6 +100,11 @@ class CommentsController extends Controller
return $this->json(compact('deleted'));
}
/**
* Cast a vote.
* @param int $id
* @return string
*/
public function vote($id = 0)
{
$vote = $_REQUEST['vote'] ?? 0;

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the base controller.
*
* @package Sakura
*/
@ -9,20 +8,28 @@ namespace Sakura\Controllers;
/**
* Base controller (which other controllers should extend on).
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Controller
{
// Middleware to execute upon creating this class
/**
* Middleware to execute upon creating this class.
* @var array
*/
protected $middleware = [
'UpdateLastOnline',
];
// Used to except middleware in controllers that extend this one
/**
* Used to except middleware in controllers that extend this one.
* @var array
*/
protected $exceptMiddleware = [];
/**
* Constructor.
*/
public function __construct()
{
// filter excepted middlewares
@ -34,6 +41,12 @@ class Controller
}
}
/**
* Encodes json.
* @param array|\stdObject $object
* @param int $operators
* @return string
*/
public function json($object, $operators = null)
{
header('Content-Type: application/json; charset=utf-8');

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the file controller.
*
* @package Sakura
*/
@ -15,7 +14,6 @@ use Sakura\User;
/**
* File controller, handles user uploads like avatars.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -23,7 +21,9 @@ class FileController extends Controller
{
/**
* The base for serving a file.
*
* @param string $data
* @param string $mime
* @param string $name
* @return string
*/
private function serve($data, $mime, $name)
@ -40,7 +40,7 @@ class FileController extends Controller
/**
* Attempt to get an avatar.
*
* @param int $id
* @return string
*/
public function avatar($id = 0)
@ -88,7 +88,7 @@ class FileController extends Controller
/**
* Attempt to get a background.
*
* @param int $id
* @return string
*/
public function background($id = 0)
@ -123,7 +123,7 @@ class FileController extends Controller
/**
* Attempt to get a profile header.
*
* @param int $id
* @return string
*/
public function header($id = 0)

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the base controller for forums.
*
* @package Sakura
*/
@ -11,7 +10,6 @@ use Sakura\Controllers\Controller as BaseController;
/**
* Base forum controller (which other controllers should extend on).
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the forum pages controllers.
*
* @package Sakura
*/
@ -18,12 +17,15 @@ use Sakura\User;
/**
* Forum page controllers.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class ForumController extends Controller
{
/**
* Renders the forum index
* @return string
*/
public function index()
{
// Get the most active topics
@ -104,6 +106,10 @@ class ForumController extends Controller
return view('forum/index', compact('forum', 'activeTopics', 'latestPosts', 'activePoster'));
}
/**
* Renders a forum.
* @return string
*/
public function forum($id = 0)
{
$forum = new Forum($id);
@ -133,6 +139,11 @@ class ForumController extends Controller
return view('forum/forum', compact('forum'));
}
/**
* Marks an entire forum as read.
* @param int $id
* @return string
*/
public function markRead($id = 0)
{
$redirect = route('forums.index');

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the controller for posts.
*
* @package Sakura
*/
@ -17,12 +16,16 @@ use Sakura\Perms\Forum as ForumPerms;
/**
* Topic controller.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class PostController extends Controller
{
/**
* Finds the topic a post is associated with.
* @param int $id
* @return string
*/
public function find($id = 0)
{
$post = new Post($id);
@ -58,6 +61,11 @@ class PostController extends Controller
return header("Location: {$topicLink}#p{$post->id}");
}
/**
* Gets the raw contents of a post.
* @param int $id
* @return string
*/
public function raw($id = 0)
{
$post = new Post($id);
@ -74,6 +82,11 @@ class PostController extends Controller
return $post->text;
}
/**
* Edit a post.
* @param int $id
* @return string
*/
public function edit($id = 0)
{
$title = $_POST['title'] ?? null;
@ -177,6 +190,11 @@ class PostController extends Controller
return header("Location: {$postLink}");
}
/**
* Deletes a post.
* @param int $id
* @return string
*/
public function delete($id = 0)
{
$post = new Post($id);

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the controller for topics.
*
* @package Sakura
*/
@ -15,12 +14,16 @@ use Sakura\Perms\Forum as ForumPerms;
/**
* Topic controller.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class TopicController extends Controller
{
/**
* Views a topic.
* @param int $id
* @return string
*/
public function view($id = 0)
{
$topic = new Topic($id);
@ -41,6 +44,11 @@ class TopicController extends Controller
return view('forum/topic', compact('forum', 'topic'));
}
/**
* Checks if a user can moderate the topic.
* @param int $id
* @return array
*/
private function modBase($id)
{
$topic = new Topic($id);
@ -55,6 +63,11 @@ class TopicController extends Controller
return false;
}
/**
* Sticky a topic.
* @param int $id
* @return string
*/
public function sticky($id)
{
$modBase = $this->modBase($id);
@ -78,6 +91,11 @@ class TopicController extends Controller
return view('global/information', compact('message', 'redirect'));
}
/**
* Announce a topic.
* @param int $id
* @return string
*/
public function announce($id)
{
$modBase = $this->modBase($id);
@ -101,6 +119,11 @@ class TopicController extends Controller
return view('global/information', compact('message', 'redirect'));
}
/**
* Lock a topic.
* @param int $id
* @return string
*/
public function lock($id)
{
$modBase = $this->modBase($id);
@ -123,6 +146,11 @@ class TopicController extends Controller
return view('global/information', compact('message', 'redirect'));
}
/**
* Delete an entire topic.
* @param int $id
* @return string
*/
public function delete($id)
{
$modBase = $this->modBase($id);
@ -157,6 +185,11 @@ class TopicController extends Controller
return view('global/information', compact('message', 'redirect'));
}
/**
* Restore a topic to its previous location.
* @param int $id
* @return string
*/
public function restore($id)
{
$modBase = $this->modBase($id);
@ -183,6 +216,11 @@ class TopicController extends Controller
return view('global/information', compact('message', 'redirect'));
}
/**
* Move a topic.
* @param int $id
* @return string
*/
public function move($id)
{
$modBase = $this->modBase($id);
@ -212,6 +250,11 @@ class TopicController extends Controller
return view('global/information', compact('message', 'redirect'));
}
/**
* Reply to a topic.
* @param int $id
* @return string
*/
public function reply($id = 0)
{
$text = $_POST['text'] ?? null;
@ -290,6 +333,11 @@ class TopicController extends Controller
return header("Location: {$postLink}");
}
/**
* Create a topic.
* @param int $id
* @return string
*/
public function create($id = 0)
{
$title = $_POST['title'] ?? null;

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the friends controller.
*
* @package Sakura
*/
@ -15,12 +14,18 @@ use Sakura\User;
/**
* Friendly controller.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class FriendsController extends Controller
{
/**
* Add a notification.
* @param User $friend
* @param User $user
* @param string $title
* @param string $text
*/
private function addNotification($friend, $user, $title, $text = "")
{
$alert = new Notification;
@ -36,6 +41,11 @@ class FriendsController extends Controller
$alert->save();
}
/**
* Add a friend.
* @param int $id
* @return string
*/
public function add($id = 0)
{
$user = ActiveUser::$user;
@ -95,6 +105,11 @@ class FriendsController extends Controller
return $this->json(compact('message', 'level'));
}
/**
* Removes a friend.
* @param int $id
* @return string
*/
public function remove($id = 0)
{
$user = ActiveUser::$user;

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds helpers for JavaScript.
*
* @package Sakura
*/
@ -11,23 +10,17 @@ use Sakura\BBcode;
/**
* Helper controller.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class HelperController extends Controller
{
/**
* Parsed BBcode from a post request
*
* @return string The parsed BBcode
* Parsed BBcode from a post request.
* @return string
*/
public function bbcodeParse()
{
$text = isset($_POST['text']) ? $_POST['text'] : '';
$text = BBcode::toHTML($text);
return $text;
return BBcode::toHTML(htmlentities($_POST['text'] ?? ''));
}
}

View file

@ -1,7 +1,6 @@
<?php
/**
* Hold the controller for informational pages.
*
* @package Sakura
*/
@ -9,22 +8,33 @@ namespace Sakura\Controllers;
/**
* Informational controller.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class InfoController extends Controller
{
/**
* Renders the terms of service.
* @return string
*/
public function terms()
{
return view('info/terms');
}
/**
* Renders the privacy policy.
* @return string
*/
public function privacy()
{
return view('info/privacy');
}
/**
* Renders the contact page.
* @return string
*/
public function contact()
{
$contact = config('contact');
@ -32,11 +42,19 @@ class InfoController extends Controller
return view('info/contact', compact('contact'));
}
/**
* Renders the rules page.
* @return string
*/
public function rules()
{
return view('info/rules');
}
/**
* Renders the welcome page.
* @return string
*/
public function welcome()
{
return view('info/welcome');

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the base controller for manage.
*
* @package Sakura
*/
@ -12,19 +11,24 @@ use Sakura\Template;
/**
* Base management controller (which other controllers should extend on).
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Controller extends BaseController
{
/**
* Constructor.
*/
public function __construct()
{
$navigation = $this->navigation();
Template::vars(compact('navigation'));
}
/**
* Generates the navigation.
* @return array
*/
public function navigation()
{
$nav = [];

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the overview controller.
*
* @package Sakura
*/
@ -11,17 +10,24 @@ use Sakura\DB;
/**
* Overview controller.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class OverviewController extends Controller
{
/**
* Renders the base overview page.
* @return string
*/
public function index()
{
return view('manage/overview/index');
}
/**
* Gets the data for the overview page.
* @return string
*/
public function data()
{
$data = new \stdClass;

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the meta page controllers.
*
* @package Sakura
*/
@ -15,7 +14,6 @@ use Sakura\User;
/**
* Meta page controllers (sections that aren't big enough to warrant a dedicated controller).
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -23,8 +21,7 @@ class MetaController extends Controller
{
/**
* Serves the site index.
*
* @return mixed HTML for the index.
* @return string
*/
public function index()
{
@ -86,8 +83,7 @@ class MetaController extends Controller
/**
* Displays the FAQ.
*
* @return mixed HTML for the FAQ.
* @return string
*/
public function faq()
{
@ -109,9 +105,8 @@ class MetaController extends Controller
}
/**
* Search page
*
* @return mixed HTML for the search page.
* Search page.
* @return string
*/
public function search()
{

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the news controller.
*
* @package Sakura
*/
@ -14,12 +13,16 @@ use Sakura\Template;
/**
* News controller.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class NewsController extends Controller
{
/**
* Shows all posts in a specific category.
* @param string $category
* @return string
*/
public function category($category = '')
{
// Check if the category is set
@ -44,6 +47,11 @@ class NewsController extends Controller
return Template::render('news/category');
}
/**
* Returns a news post.
* @param int $id
* @return string
*/
public function post($id = 0)
{
// Create the post object

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the notification controllers.
*
* @package Sakura
*/
@ -13,7 +12,6 @@ use Sakura\Perms\Site;
/**
* Notification stuff.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -21,8 +19,7 @@ class NotificationsController extends Controller
{
/**
* Get the notification JSON object for the currently authenticated user.
*
* @return string The JSON object.
* @return string
*/
public function notifications()
{
@ -31,10 +28,9 @@ class NotificationsController extends Controller
/**
* Mark a notification as read.
*
* @param int The ID of the notification.
*
* @return string Not entirely set on this one yet but 1 for success and 0 for fail.
* Not entirely set on this one yet but 1 for success and 0 for fail.
* @param int
* @return string
*/
public function mark($id = 0)
{

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the premium pages controllers.
*
* @package Sakura
*/
@ -17,7 +16,6 @@ use Sakura\Template;
/**
* Premium pages controller.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -34,14 +32,12 @@ class PremiumController extends Controller
public function __construct()
{
parent::__construct();
Payments::init();
}
/**
* Returns the premium purchase index.
*
* @return mixed
* @return string
*/
public function index()
{
@ -55,8 +51,7 @@ class PremiumController extends Controller
/**
* Handles a purchase request.
*
* @return mixed
* @return string
*/
public function purchase()
{
@ -132,8 +127,7 @@ class PremiumController extends Controller
/**
* Handles the data returned by PayPal.
*
* @return mixed
* @return string
*/
public function handle()
{
@ -170,8 +164,7 @@ class PremiumController extends Controller
/**
* Presents the user with a thank you <3.
*
* @return mixed
* @return string
*/
public function complete()
{

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the account section controller.
*
* @package Sakura
*/
@ -13,12 +12,15 @@ use Sakura\Perms\Site;
/**
* Account settings.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class AccountController extends Controller
{
/**
* Renders the profile changing page.
* @return string
*/
public function profile()
{
// Check permission
@ -87,6 +89,10 @@ class AccountController extends Controller
return view('settings/account/profile');
}
/**
* Renders the e-mail changing page.
* @return string
*/
public function email()
{
// Check permission
@ -131,6 +137,10 @@ class AccountController extends Controller
return view('settings/account/email');
}
/**
* Renders the username changing page.
* @return string
*/
public function username()
{
// Check permission
@ -191,6 +201,10 @@ class AccountController extends Controller
return view('settings/account/username');
}
/**
* Renders the user title changing page.
* @return string
*/
public function title()
{
// Check permission
@ -229,6 +243,10 @@ class AccountController extends Controller
return view('settings/account/title');
}
/**
* Renders the password changing page.
* @return string
*/
public function password()
{
// Check permission
@ -265,6 +283,10 @@ class AccountController extends Controller
return view('settings/account/password');
}
/**
* Renders the rank management page.
* @return string
*/
public function ranks()
{
// Check permission

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the advanced section controller.
*
* @package Sakura
*/
@ -13,12 +12,15 @@ use Sakura\Perms\Site;
/**
* Advanced settings.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class AdvancedController extends Controller
{
/**
* Renders the session management page.
* @return string
*/
public function sessions()
{
// Check permission
@ -70,6 +72,10 @@ class AdvancedController extends Controller
return view('settings/advanced/sessions', compact('sessions', 'active'));
}
/**
* Renders the deactivation page.
* @return string
*/
public function deactivate()
{
// Check permission

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the appearance section controller.
*
* @package Sakura
*/
@ -14,12 +13,17 @@ use Sakura\Perms\Site;
/**
* Appearance settings.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class AppearanceController extends Controller
{
/**
* Handles file uploads.
* @param string $mode
* @param array $file
* @return array
*/
private function handleUpload($mode, $file)
{
// Handle errors
@ -104,6 +108,10 @@ class AppearanceController extends Controller
return null;
}
/**
* Deletes a file.
* @param string $mode
*/
public function deleteFile($mode)
{
$fileId = ActiveUser::$user->{$mode};
@ -113,6 +121,10 @@ class AppearanceController extends Controller
}
}
/**
* Renders the avatar changing page
* @return string
*/
public function avatar()
{
// Check permission
@ -140,6 +152,10 @@ class AppearanceController extends Controller
return view('settings/appearance/avatar');
}
/**
* Renders the background changing page.
* @return string
*/
public function background()
{
// Check permission
@ -167,6 +183,10 @@ class AppearanceController extends Controller
return view('settings/appearance/background');
}
/**
* Renders the banner changing page.
* @return string
*/
public function header()
{
// Check permission
@ -194,6 +214,9 @@ class AppearanceController extends Controller
return view('settings/appearance/header');
}
/**
* Renders the userpage editing page.
*/
public function userpage()
{
// Check permission
@ -230,6 +253,10 @@ class AppearanceController extends Controller
return view('settings/appearance/userpage', compact('maxLength'));
}
/**
* Renders the signature changing page.
* @return string
*/
public function signature()
{
// Check permission

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the base settings controller.
*
* @package Sakura
*/
@ -15,17 +14,23 @@ use Sakura\Template;
/**
* Base controller (which other controllers should extend on).
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Controller extends BaseController
{
/**
* Constructor.
*/
public function __construct()
{
Template::vars(['navigation' => $this->navigation()]);
}
/**
* Generates the navigation.
* @return array
*/
public function navigation()
{
$nav = [];

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the friends section controller.
*
* @package Sakura
*/
@ -12,12 +11,15 @@ use Sakura\Perms\Site;
/**
* Friends settings.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class FriendsController extends Controller
{
/**
* Gets friends listing
* @return string
*/
public function listing()
{
// Check permission
@ -30,6 +32,10 @@ class FriendsController extends Controller
return view('settings/friends/listing');
}
/**
* Gets friend requests listing
* @return string
*/
public function requests()
{
// Check permission

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the notifications section controller.
*
* @package Sakura
*/
@ -9,12 +8,15 @@ namespace Sakura\Controllers\Settings;
/**
* Notification settings.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class NotificationsController extends Controller
{
/**
* Get the notification history.
* @return string
*/
public function history()
{
return view('settings/notifications/history');

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the status controller.
*
* @package Sakura
*/
@ -9,12 +8,15 @@ namespace Sakura\Controllers;
/**
* The status page and related stuff.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class StatusController extends Controller
{
/**
* Renders the base status page.
* @return string
*/
public function index()
{
return view('status/index');

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the user page controllers.
*
* @package Sakura
*/
@ -18,7 +17,6 @@ use Sakura\User;
/**
* Everything that is just for serving user data.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -26,10 +24,8 @@ class UserController extends Controller
{
/**
* Display the profile of a user.
*
* @param mixed $id The user ID.
*
* @return bool|string The profile page.
* @param int $id
* @return string
*/
public function profile($id = 0)
{
@ -65,10 +61,8 @@ class UserController extends Controller
/**
* Display the memberlist.
*
* @param int $rank Optional rank ID.
*
* @return bool|string The memberlist.
* @param int $rank
* @return string
*/
public function members($rank = null)
{
@ -105,6 +99,10 @@ class UserController extends Controller
return Template::render('user/members');
}
/**
* Report a user.
* @param int $id
*/
public function report($id = 0)
{
return Template::render('user/report');

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the alias class for the Illuminate database thing.
*
* @package Sakura
*/
@ -13,12 +12,15 @@ use Illuminate\Database\Migrations\DatabaseMigrationRepository;
/**
* The Illuminate (Laravel) database wrapper.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class DB extends Manager
{
/**
* Gets the migration repository (surprise surprise).
* @return DatabaseMigrationRepository
*/
public static function getMigrationRepository()
{
$resolver = new ConnectionResolver(['database' => self::connection()]);
@ -27,6 +29,10 @@ class DB extends Manager
return $repository;
}
/**
* Get the migration schema builder.
* @return \Illuminate\Database\Schema\Builder
*/
public static function getSchemaBuilder()
{
return self::connection()->getSchemaBuilder();

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the Exception class.
*
* @package Sakura
*/
@ -9,7 +8,6 @@ namespace Sakura;
/**
* Sakura Exception class.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the file server.
*
* @package Sakura
*/
@ -11,7 +10,6 @@ use finfo;
/**
* Used for storing files served through Sakura.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -25,55 +23,47 @@ class File
/**
* User instance of the user that uploaded this file.
*
* @var User
*/
public $user = null;
/**
* Data of the file.
*
* @var string
*/
public $data = null;
/**
* Original filename of the file.
*
* @var string
*/
public $name = null;
/**
* Mime type of the file.
*
* @var string
*/
public $mime = null;
/**
* The UNIX timestamp of when this file was created.
*
* The timestamp of when this file was created.
* @var int
*/
public $time = 0;
/**
* The UNIX timestamp of when this file should automatically remove itself (currently unused).
*
* @var int
*/
public $expire = 0;
/**
* Create a new file.
*
* @param string $data Contents of the file.
* @param string $name Name of the file.
* @param User $user User instance of the user creating this file.
* @param int $expire UNIX timestamp of when this file should automatically remove itself.
*
* @return File The created file instance for the file.
* @param string $data
* @param string $name
* @param User $user
* @param int $expire
* @return File
*/
public static function create($data, $name, User $user, $expire = 0)
{
@ -99,8 +89,7 @@ class File
/**
* Constructor.
*
* @param int $fileId ID of the file that should be constructed.
* @param int $fileId
*/
public function __construct($fileId)
{

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the forum object class.
*
* @package Sakura
*/
@ -12,7 +11,6 @@ use Sakura\Perms;
/**
* Used to serve forums.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -20,28 +18,24 @@ class Forum
{
/**
* The ID of the forum.
*
* @var int
*/
public $id = 0;
/**
* The order of the forum.
*
* @var int
*/
public $order = 0;
/**
* The name of the forum.
*
* @var string
*/
public $name = "Forum";
/**
* The description of the forum.
*
* @var string
*/
public $description = "";
@ -54,64 +48,55 @@ class Forum
/**
* The ID of the parent forum.
*
* @var int
*/
public $category = 0;
/**
* The type of forum.
*
* @var int
*/
public $type = 0;
/**
* The icon of this forum.
*
* @var string
*/
public $icon = "";
/**
* A cached instance of the first post in this forum.
*
* @var Post
*/
private $firstPostCache = null;
/**
* A cached instance of the last post in this forum.
*
* @var Post
*/
private $lastPostCache = null;
/**
* Cached instances of the subforums.
*
* @var array
*/
private $forumsCache = [];
/**
* Cached instances of the topics in this forum.
*
* @var array
*/
private $topicsCache = [];
/**
* The permission container.
*
* @var Perms
*/
private $permissionsCache;
/**
* Constructor.
*
* @param int $forumId The ID of the forum that should be constructed.
* @param int $forumId
*/
public function __construct(int $forumId = 0)
{
@ -141,12 +126,10 @@ class Forum
/**
* Checking a permission flag.
*
* @param int $flag Forum permission flag.
* @param int $user The ID of the user that is being checked.
* @param bool $raw Whether the raw full permission flag should be returned.
*
* @return bool|int Either a bool indicating the permission or the full flag.
* @param int $flag
* @param int $user
* @param bool $raw
* @return bool|int
*/
public function permission($flag, $user, $raw = false)
{
@ -166,8 +149,7 @@ class Forum
/**
* Gets all subforums of this forum.
*
* @return array Array containing forum objects.
* @return array
*/
public function forums()
{
@ -198,8 +180,7 @@ class Forum
/**
* Gets the topics in this forum.
*
* @return array Array containing all topics.
* @return array
*/
public function topics()
{
@ -231,8 +212,7 @@ class Forum
/**
* Gets the first post in this forum.
*
* @return Post The object of the first post.
* @return Post
*/
public function firstPost()
{
@ -260,8 +240,7 @@ class Forum
/**
* Gets the last post in this forum.
*
* @return Post The object of the last post.
* @return Post
*/
public function lastPost()
{
@ -289,8 +268,7 @@ class Forum
/**
* Counts the amount of topics in this forum.
*
* @return int Number of topics in this forum.
* @return int
*/
public function topicCount()
{
@ -301,8 +279,7 @@ class Forum
/**
* Counts the amount of posts in this forum.
*
* @return int Number of posts in this forum.
* @return int
*/
public function postCount()
{
@ -313,10 +290,8 @@ class Forum
/**
* Checks if a user has read every post in the specified forum.
*
* @param int $user Id of the user in question.
*
* @return bool Indicator if read or not.
* @param int $user
* @return bool
*/
public function unread($user)
{
@ -345,8 +320,7 @@ class Forum
/**
* Update the read status of all topics in this forum at once.
*
* @param int $user The id of the user in question.
* @param int $user
*/
public function trackUpdateAll($user)
{

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the post object class.
*
* @package Sakura
*/
@ -15,7 +14,6 @@ use Sakura\User;
/**
* Used to serve, create and update posts.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -23,92 +21,79 @@ class Post
{
/**
* The ID of the post.
*
* @var int
*/
public $id = 0;
/**
* The id of the topic this post is a part of.
*
* @var int
*/
public $topic = 0;
/**
* The id of the forum this post is a part of.
*
* @var int
*/
public $forum = 0;
/**
* The User object of the poster.
*
* @var User
*/
public $poster = null;
/**
* The IP address from which this post was created.
*
* @var string
*/
public $ip = "";
/**
* The UNIX timestamp from when this post was created.
*
* @var int
*/
public $time = 0;
/**
* The subject of this post.
*
* @var string
*/
public $subject = "";
/**
* The raw contents of this post.
*
* @var string
*/
public $text = "";
/**
* The parsed contents of this post.
*
* @var string
*/
public $parsed = "";
/**
* The UNIX timestamp of the last time this post was edited.
*
* @var int
*/
public $editTime = 0;
/**
* The reason why this post was edited.
*
* @var string
*/
public $editReason = "";
/**
* The User object of the user that last edited this post.
*
* @var User
*/
public $editUser = null;
/**
* Constructor.
*
* @param int $postId ID of the post that should be constructed.
* @param int $postId
*/
public function __construct($postId)
{
@ -146,14 +131,12 @@ class Post
/**
* Creating a new post.
*
* @param string $subject The subject of the topic.
* @param string $text The raw contents of the post.
* @param User $poster The User object of the poster.
* @param int $topic The ID of the topic this post is a reply to.
* @param mixed $forum The forum this post is a reply in.
*
* @return null|self Either null, indicating a failure, or the Post object.
* @param string $subject
* @param string $text
* @param User $poster
* @param int $topic
* @param int $forum
* @return Post
*/
public static function create($subject, $text, User $poster, $topic = 0, $forum = 0)
{
@ -190,8 +173,7 @@ class Post
/**
* Commit the changes to the Database.
*
* @return null|Post Either null, indicating a failure, or the Post object.
* @return Post
*/
public function update()
{
@ -218,6 +200,9 @@ class Post
return new Post($this->id);
}
/**
* delete this.
*/
public function delete()
{
DB::table('posts')
@ -227,10 +212,8 @@ class Post
/**
* Check if a user has read this post before.
*
* @param mixed $user The id of the user in question.
*
* @return bool A boolean indicating the read status.
* @param mixed $user
* @return bool
*/
public function unread($user)
{

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the topic object class.
*
* @package Sakura
*/
@ -11,7 +10,6 @@ use Sakura\DB;
/**
* Used to serve, create and update topics.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -19,49 +17,42 @@ class Topic
{
/**
* The ID of this topic.
*
* @var int
*/
public $id = 0;
/**
* The ID of the forum this topic is a part of.
*
* @var int
*/
public $forum = 0;
/**
* Is this forum hidden from the listing?
*
* @var bool
*/
public $hidden = false;
/**
* The title of the topic.
*
* @var string
*/
public $title = "";
/**
* The UNIX timestamp of when this topic was created.
*
* @var int
*/
public $time = 0;
/**
* The UNIX timestamp of when this topic should be autolocked (currently unused).
*
* @var int
*/
public $timeLimit = 0;
/**
* The amount of times this topic has been viewed.
*
* @var int
*/
public $views = 0;
@ -70,14 +61,12 @@ class Topic
* The status of this topic.
* 0 - Unlocked
* 1 - Locked
*
* @var int
*/
public $status = 0;
/**
* The UNIX timestamp of when the status was last changed.
*
* @var int
*/
public $statusChange = 0;
@ -87,43 +76,37 @@ class Topic
* 0 - Normal topic
* 1 - Sticky topic
* 2 - Announcement
*
* @var int
*/
public $type = 0;
/**
* The ID of the forum this topic was a part of before the last move.
*
* @var int
*/
public $oldForum = 0;
/**
* The post object cache.
*
* @var array
*/
private $postsCache = [];
/**
* A cached instance of opening post.
*
* @var Post
*/
private $firstPostCache = null;
/**
* A cached instance of the last reply.
*
* @var Post
*/
private $lastPostCache = null;
/**
* Constructor.
*
* @param mixed $topicId ID of the topic that should be constructed.
* @param int $topicId
*/
public function __construct($topicId)
{
@ -151,13 +134,11 @@ class Topic
/**
* Create a new topic.
*
* @param mixed $forum ID of the forum this topic is part of.
* @param mixed $title Title of the topic.
* @param mixed $status Status of the topic.
* @param mixed $type Type of topic.
*
* @return self The new topic instance.
* @param int $forum
* @param string $title
* @param int $status
* @param int $type
* @return Topic
*/
public static function create($forum, $title, $status = 0, $type = 0)
{
@ -193,9 +174,8 @@ class Topic
/**
* Move the topic.
*
* @param mixed $forum The new forum ID.
* @param mixed $setOld Remember the forum ID prior to the move for restoration.
* @param int $forum
* @param bool $setOld
*/
public function move($forum, $setOld = true)
{
@ -215,8 +195,7 @@ class Topic
/**
* Update the topic data.
*
* @return self The updated topic.
* @return Topic
*/
public function update()
{
@ -239,8 +218,7 @@ class Topic
/**
* Get the replies to this topic.
*
* @return array Array containing Post instances.
* @return array
*/
public function posts()
{
@ -270,8 +248,7 @@ class Topic
/**
* Get the opening post.
*
* @return Post A Post instance of the opening post.
* @return Post
*/
public function firstPost()
{
@ -299,8 +276,7 @@ class Topic
/**
* Get the latest reply.
*
* @return Post A Post instance of the latest reply.
* @return Post
*/
public function lastPost()
{
@ -328,8 +304,7 @@ class Topic
/**
* Get the amount of replies.
*
* @return int The number of replies to this topic.
* @return int
*/
public function replyCount()
{
@ -340,10 +315,8 @@ class Topic
/**
* Check if a user has read this topic before.
*
* @param mixed $user The id of the user in question.
*
* @return bool A boolean indicating the read status.
* @param int $user
* @return bool
*/
public function unread($user)
{
@ -370,8 +343,7 @@ class Topic
/**
* Update the read status.
*
* @param mixed $user The id of the user in question.
* @param int $user
*/
public function trackUpdate($user)
{

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the middleware interface.
*
* @package Sakura
*/
@ -9,11 +8,13 @@ namespace Sakura\Middleware;
/**
* Middleware interface.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
interface Middleware
{
/**
* Runs the middleware task.
*/
public function run();
}

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the last online update middleware.
*
* @package Sakura
*/
@ -11,12 +10,14 @@ use Sakura\ActiveUser;
/**
* Updates when the last online time of a user.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class UpdateLastOnline implements Middleware
{
/**
* Update the last online information for the active user.
*/
public function run()
{
if (ActiveUser::$user->id !== 0) {

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the everything networking.
*
* @package Sakura
*/
@ -9,7 +8,6 @@ namespace Sakura;
/**
* Networking methods.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -17,8 +15,7 @@ class Net
{
/**
* Returns the connecting IP.
*
* @return string The IP.
* @return string
*/
public static function ip()
{
@ -27,10 +24,8 @@ class Net
/**
* Detect the version of an IP.
*
* @param string $ipAddr The IP.
*
* @return int Either 0, 4 or 6.
* @param string $ipAddr
* @return int
*/
public static function detectIPVersion($ipAddr)
{
@ -53,12 +48,9 @@ class Net
/**
* Converts a printable IP address into an unpacked binary string.
*
* @param string $ip Printable IP string.
*
* @throws Exception Thrown if an invalid IP is supplied.
*
* @return string Unpacked IP address.
* @param string $ip
* @throws Exception
* @return string
*/
public static function pton($ip)
{
@ -81,12 +73,9 @@ class Net
/**
* Converts a binary unpacked IP to a printable packed IP.
*
* @param string $bin The unpacked IP.
*
* @throws Exception Thrown if the unpacked IP is invalid.
*
* @return string The packed IP.
* @param string $bin
* @throws Exception
* @return string
*/
public static function ntop($bin)
{
@ -102,6 +91,12 @@ class Net
return inet_ntop(pack("A{$len}", $bin));
}
/**
* Matches an IP to a CIDR range.
* @param string $ip
* @param string $range
* @return bool
*/
public static function matchCIDR($ip, $range)
{
// Break the range up in parts
@ -131,13 +126,11 @@ class Net
}
/**
* Match an IPv4 CIDR
*
* @param string $ip The IP address to match.
* @param string $net The Net address to match.
* @param string $mask The Mask to match.
*
* @return bool Returns true if it matches.
* Match an IPv4 CIDR.
* @param string $ip
* @param string $net
* @param string $mask
* @return bool
*/
private static function matchCIDRv4($ip, $net, $mask)
{
@ -153,11 +146,9 @@ class Net
}
/**
* Converts an IPv6 mask to a byte array
*
* @param int $mask The mask.
*
* @return string The byte array.
* Converts an IPv6 mask to a byte array.
* @param int $mask
* @return string
*/
private static function maskToByteArray($mask)
{
@ -190,13 +181,11 @@ class Net
}
/**
* Match an IPv6 CIDR
*
* @param string $ip The IP address to match.
* @param string $net The Net address to match.
* @param int $mask The net mask.
*
* @return bool Returns true if it's a successful match.
* Match an IPv6 CIDR.
* @param string $ip
* @param string $net
* @param int $mask
* @return bool
*/
private static function matchCIDRv6($ip, $net, $mask)
{
@ -212,11 +201,9 @@ class Net
}
/**
* Fetch a remote file
*
* @param string $url The location of the file
*
* @return mixed The contents of the remote file
* Fetch a remote file.
* @param string $url
* @return mixed
*/
public static function fetch($url)
{

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the news category object.
*
* @package Sakura
*/
@ -11,19 +10,30 @@ use Sakura\DB;
/**
* News category object.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Category
{
/**
* The name over this news category.
* @var string
*/
public $name = "";
/**
* Constructor.
* @param string $name
*/
public function __construct($name)
{
$this->name = $name;
}
/**
* Gets the news posts in this category.
* @param int $limit
*/
public function posts($limit = 0)
{
$postIds = DB::table('news')

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the news post object.
*
* @package Sakura
*/
@ -13,23 +12,68 @@ use Sakura\User;
/**
* News post object.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Post
{
/**
* The format the comment categories should follow.
*/
const COMMENT_CATEGORY_FORMAT = "news-%s-%u";
/**
* The id of this news post.
* @var int
*/
public $id = 0;
/**
* The category this post is part of.
* @var string
*/
public $category = "";
/**
* The user who made this post.
* @var int
*/
public $user = 0;
/**
* The timestamp when this post was made.
* @var int
*/
public $time = 0;
/**
* The title of this news post.
* @var string
*/
public $title = "";
/**
* The content of this news post.
* @var string
*/
public $text = "";
/**
* A cache of the amount of comments this post has.
* @var int
*/
private $commentCountCache = 0;
/**
* A cache of comments.
* @var array
*/
private $commentsCache = [];
/**
* Constructor.
* @param int $id
*/
public function __construct($id = 0)
{
// Get comment data from the database
@ -50,6 +94,9 @@ class Post
}
}
/**
* Saving changes to this news post.
*/
public function save()
{
// Create submission data, insert and update take the same format
@ -72,6 +119,9 @@ class Post
}
}
/**
* Deleting this news post.
*/
public function delete()
{
DB::table('news')
@ -81,11 +131,19 @@ class Post
$this->id = 0;
}
/**
* Get the user object of the poster.
* @return User
*/
public function userData()
{
return User::construct($this->user);
}
/**
* Count the amount of comments this post has.
* @return int
*/
public function commentCount()
{
if (!$this->commentCountCache) {
@ -97,6 +155,10 @@ class Post
return $this->commentCountCache;
}
/**
* Get the comments on this post.
* @return array
*/
public function comments()
{
if (!$this->commentsCache) {

View file

@ -1,7 +1,6 @@
<?php
/**
* Notification object.
*
* @package Sakura
*/
@ -9,22 +8,69 @@ namespace Sakura;
/**
* Notification!
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Notification
{
/**
* The identifier.
* @var int
*/
public $id = 0;
/**
* The id of the user this notification is intended for.
* @var int
*/
public $user = 0;
/**
* The timestamp when this notification was created.
* @var int
*/
public $time = 0;
/**
* Whether the user has already read this notification.
* @var bool
*/
public $read = false;
/**
* Title of the notification.
* @var string
*/
public $title = "Notification";
/**
* The rest of the content
* @var string
*/
public $text = "";
/**
* The url this notification should link to when clicked on.
* @var string
*/
public $link = "";
/**
* The image url to display.
* @var string
*/
public $image = "";
/**
* The amount of time this notification should be displayed for
* @var int
*/
public $timeout = 0;
/**
* The constructor.
* @param int $id
*/
public function __construct($id = 0)
{
// Get notification data from the database
@ -48,6 +94,9 @@ class Notification
}
}
/**
* Saving changes to this notification.
*/
public function save()
{
// Create submission data, insert and update take the same format
@ -73,12 +122,19 @@ class Notification
}
}
/**
* Toggle the read status
*/
public function toggleRead()
{
// Set read to the negative value of itself
$this->read = !$this->read;
}
/**
* Get the user object.
* @return User
*/
public function userData()
{
return User::construct($this->user);

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the payments handler.
*
* @package Sakura
*/
@ -19,7 +18,6 @@ use \PayPal\Api\Transaction;
/**
* Sakura PayPal API wrapper.
*
* @package Sakura
* @author Kamil Rakowski <admin@krakow.pw>
* @author Julian van de Groep <me@flash.moe>
@ -28,19 +26,16 @@ class Payments
{
/**
* Container for the PayPal API
*
* @var \PayPal\Rest\ApiContext
*/
private static $paypal;
/**
* Initialise the wrapper.
*
* @return bool Always true.
* @return bool
*/
public static function init()
{
// Set PayPal object
try {
self::$paypal = new \PayPal\Rest\ApiContext(
@ -63,17 +58,14 @@ class Payments
/**
* Create a new transaction.
*
* @param float $total The total amount of money.
* @param string $itemName The name of the item being purchased.
* @param string $transDescription The description of the item.
* @param string $returnUrl The URL that PayPal will redirect back to.
*
* @return bool|null|string If successful; the PayPal approval link.
* @param float $total
* @param string $itemName
* @param string $transDescription
* @param string $returnUrl
* @return bool|null|string
*/
public static function createTransaction($total, $itemName, $transDescription, $returnUrl)
{
// Create the payer object
$payer = new Payer();
@ -147,15 +139,12 @@ class Payments
/**
* Complete the PayPal transaction.
*
* @param string $paymentId ID of the payment.
* @param string $payerId ID of the payer.
*
* @return bool Success indicator.
* @param string $paymentId
* @param string $payerId
* @return bool
*/
public static function completeTransaction($paymentId, $payerId)
{
// Attempt to get the payment
$payment = Payment::get($paymentId, self::$paypal);

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the global permissions handler.
*
* @package Sakura
*/
@ -9,7 +8,6 @@ namespace Sakura;
/**
* Global permissions handler.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -32,22 +30,19 @@ class Perms
/**
* The table containing the permissions.
*
* @var string
*/
protected $table = '';
/**
* The column containing the permissions.
*
* @var string
*/
protected $column = '';
/**
* Constructor.
*
* @param string $mode One of the modes above.
* @param string $mode
*/
public function __construct($mode)
{
@ -56,8 +51,7 @@ class Perms
/**
* Set a permission mode.
*
* @param string $mode One of the modes above.
* @param string $mode
*/
public function mode($mode)
{
@ -71,11 +65,9 @@ class Perms
/**
* Compare a permission flag.
*
* @param int $flag The permission flag.
* @param int $perm The permissions of the user.
*
* @return bool Success indicator.
* @param int $flag
* @param int $perm
* @return bool
*/
public function check($flag, $perm)
{
@ -84,12 +76,10 @@ class Perms
/**
* Get the permissions from a rank.
*
* @param int $rid The ID of the rank in question.
* @param array $conditions Additional SQL conditions.
* @param int $perm A permission flag to append to.
*
* @return int A permission flag.
* @param int $rid
* @param array $conditions
* @param int $perm
* @return int
*/
public function rank($rid, $conditions = [], $perm = 0)
{
@ -122,12 +112,10 @@ class Perms
/**
* Get the permissions from a user.
*
* @param int $uid The ID of the user in question.
* @param array $conditions Additional SQL conditions.
* @param int $perm A permission flag to append to.
*
* @return int A permission flag.
* @param int $uid
* @param array $conditions
* @param int $perm
* @return int
*/
public function user($uid, $conditions = [], $perm = 0)
{

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the forum permission flags.
*
* @package Sakura
*/
@ -9,7 +8,6 @@ namespace Sakura\Perms;
/**
* All forum permission flags.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the site management permission flags.
*
* @package Sakura
*/
@ -9,7 +8,6 @@ namespace Sakura\Perms;
/**
* All site management permission flags.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the global site permission flags.
*
* @package Sakura
*/
@ -9,7 +8,6 @@ namespace Sakura\Perms;
/**
* All global site permissions.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the rank object class.
*
* @package Sakura
*/
@ -12,7 +11,6 @@ use Sakura\Perms\Site;
/**
* Serves Rank data.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -20,81 +18,69 @@ class Rank
{
/**
* ID of the rank.
*
* @var int
*/
public $id = 0;
/**
* Name of the rank.
*
* @var string
*/
public $name = 'Rank';
/**
* Global hierarchy of the rank.
*
* @var int
*/
public $hierarchy = 0;
/**
* Text that should be append to the name to make it address multiple.
*
* @var string
*/
public $multiple = '';
/**
* The rank's username colour.
*
* @var string
*/
public $colour = 'inherit';
/**
* Description of the rank.
*
* @var string
*/
public $description = '';
/**
* User title of the rank.
*
* @var string
*/
public $title = '';
/**
* Indicates if this rank should be hidden.
*
* @var bool
*/
private $hidden = true;
/**
* Permission container.
*
* @var Perms
*/
private $permissions;
/**
* Instance cache container.
*
* @var array
*/
protected static $rankCache = [];
/**
* Cached constructor.
*
* @param int $rid ID of the rank.
* @param bool $forceRefresh Force a cache refresh.
*
* @return Rank The requested rank object.
* @param int $rid
* @param bool $forceRefresh
* @return Rank
*/
public static function construct($rid, $forceRefresh = false)
{
@ -110,8 +96,7 @@ class Rank
/**
* Constructor.
*
* @param int $rankId ID of the rank that should be constructed.
* @param int $rankId
*/
private function __construct($rankId)
{
@ -139,10 +124,8 @@ class Rank
/**
* Get the name of the rank.
*
* @param bool $multi Should the multiple sense be appended?
*
* @return string The rank's name.
* @param bool $multi
* @return string
*/
public function name($multi = false)
{
@ -151,8 +134,7 @@ class Rank
/**
* Indicates if the rank is hidden.
*
* @return bool Hidden status.
* @return bool
*/
public function hidden()
{
@ -161,10 +143,8 @@ class Rank
/**
* Check permissions.
*
* @param int $flag Permission flag that should be checked.
*
* @return bool Success indicator.
* @param int $flag
* @return bool
*/
public function permission($flag)
{
@ -179,10 +159,8 @@ class Rank
/**
* Returns all users that are part of this rank.
*
* @param bool $justIds Makes this function only return the user ids when set to a positive value.
*
* @return array Either just the user IDs of the users or with objects.
* @param bool $justIds
* @return array
*/
public function users($justIds = false)
{

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the router class.
*
* @package Sakura
*/
@ -14,36 +13,31 @@ use Phroute\Phroute\RouteCollector;
/**
* Sakura Wrapper for Phroute.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Router
{
/**
* Container for RouteCollector
*
* Container for RouteCollector.
* @var RouteCollector
*/
protected static $router = null;
/**
* Base path of the router.
*
* @var string
*/
protected static $basePath = null;
/**
* Container for the Dispatcher
*
* Container for the Dispatcher.
* @var Dispatcher
*/
protected static $dispatcher = null;
/**
* Collection of handled HTTP request types.
*
* @var array
*/
protected static $methods = [
@ -59,9 +53,8 @@ class Router
/**
* Method aliases for adding routes.
*
* @param string $name A HTTP method.
* @param array $args The arguments.
* @param string $name
* @param array $args
*/
public static function __callStatic($name, $args)
{
@ -89,8 +82,7 @@ class Router
/**
* Initialisation.
*
* @param string $basePath The base path of the router.
* @param string $basePath
*/
public static function init($basePath = '/')
{
@ -103,8 +95,7 @@ class Router
/**
* Set the base path.
*
* @param string $basePath The base path of the router.
* @param string $basePath
*/
public static function setBasePath($basePath)
{
@ -113,10 +104,8 @@ class Router
/**
* Parse a URL.
*
* @param string $url The URL that is to be parsed.
*
* @return string THe parsed URL.
* @param string $url
* @return string
*/
private static function parseUrl($url)
{
@ -125,11 +114,9 @@ class Router
/**
* Generate the URI of a route using names.
*
* @param string $name The identifier of the route.
* @param string|array $args The route arguments.
*
* @return string The generated URI.
* @param string $name
* @param string|array $args
* @return string
*/
public static function route($name, $args = null)
{
@ -145,9 +132,8 @@ class Router
/**
* Create group.
*
* @param array $filters The filters for this group.
* @param \Closure $callback The containers
* @param array $filters
* @param \Closure $callback
*/
public static function group($filters, $callback)
{
@ -157,9 +143,8 @@ class Router
/**
* Create filter.
*
* string $name Identifier of the filter
* \Closure $method
* @param string $name
* @param \Closure $method
*/
public static function filter($name, $method)
{
@ -168,11 +153,9 @@ class Router
/**
* Handle requests.
*
* @param string $method The HTTP method used to make the request.
* @param string $url The URL the request is made to.
*
* @return mixed The response.
* @param string $method
* @param string $url
* @return mixed
*/
public static function handle($method, $url)
{

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the session handler.
*
* @package Sakura
*/
@ -9,7 +8,6 @@ namespace Sakura;
/**
* User session handler.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -17,23 +15,20 @@ class Session
{
/**
* The ID of the user this session is from.
*
* @var int
*/
public $userId = 0;
/**
* The ID of the session.
*
* @var string
*/
public $sessionId = "";
/**
* Constructor.
*
* @param int $userId The ID of the user.
* @param int $sessionId The active session ID.
* @param int $userId
* @param int $sessionId
*/
public function __construct($userId, $sessionId = null)
{
@ -83,10 +78,8 @@ class Session
/**
* Create a new session.
*
* @param boolean $permanent Is this a permanent session?
*
* @return string The session key.
* @param boolean $permanent
* @return string
*/
public function create($permanent)
{
@ -111,8 +104,8 @@ class Session
/**
* Validate the session.
*
* @return int Success indicator; 0 = false, 1 = active, 2 = permanent.
* 0 = false, 1 = active, 2 = permanent.
* @return int
*/
public function validate()
{

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the templating engine class.
*
* @package Sakura
*/
@ -15,7 +14,6 @@ use Twig_SimpleFunction;
/**
* Sakura wrapper for Twig.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -23,33 +21,29 @@ class Template
{
/**
* The variables passed on to the templating engine.
*
* @var array
*/
private static $vars = [];
/**
* The templating engine.
*
* @var Twig_Environment
*/
private static $engine;
/**
* The template name.
*
* @var string
*/
public static $name;
/**
* The file extension used by template files
* The file extension used by template files.
*/
const FILE_EXT = '.twig';
/**
* List of utility functions to add to templating
*
* List of utility functions to add to templating.
* @var array
*/
protected static $utilityFunctions = [
@ -59,8 +53,7 @@ class Template
];
/**
* List of utility filters to add to templating
*
* List of utility filters to add to templating.
* @var array
*/
protected static $utilityFilters = [
@ -70,8 +63,7 @@ class Template
/**
* Set the template name.
*
* @param string $name The name of the template directory.
* @param string $name
*/
public static function set($name)
{
@ -130,8 +122,7 @@ class Template
/**
* Merge the parse variables.
*
* @param array $vars The new variables.
* @param array $vars
*/
public static function vars($vars)
{
@ -140,10 +131,8 @@ class Template
/**
* Render a template file.
*
* @param string $file The filename/path
*
* @return bool|string An error or the HTML.
* @param string $file
* @return bool|string
*/
public static function render($file)
{

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the extension manager.
*
* @package Sakura
*/
@ -9,7 +8,6 @@ namespace Sakura;
/**
* Extension manager.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/

View file

@ -1,7 +1,6 @@
<?php
/**
* Holds the user object class.
*
* @package Sakura
*/
@ -14,7 +13,6 @@ use stdClass;
/**
* Everything you'd ever need from a specific user.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -22,248 +20,213 @@ class User
{
/**
* The User's ID.
*
* @var int
*/
public $id = 0;
/**
* The user's username.
*
* @var string
*/
public $username = 'User';
/**
* A cleaned version of the username.
*
* @var string
*/
public $usernameClean = 'user';
/**
* The user's password hash.
*
* @var string
*/
public $password = '';
/**
* UNIX timestamp of last time the password was changed.
*
* @var int
*/
public $passwordChan = 0;
/**
* The user's e-mail address.
*
* @var string
*/
public $email = 'user@sakura';
/**
* The rank object of the user's main rank.
*
* @var Rank
*/
public $mainRank = null;
/**
* The ID of the main rank.
*
* @var int
*/
public $mainRankId = 1;
/**
* The index of rank objects.
*
* @var array
*/
public $ranks = [];
/**
* The user's username colour.
*
* @var string
*/
public $colour = '';
/**
* The IP the user registered from.
*
* @var string
*/
public $registerIp = '0.0.0.0';
/**
* The IP the user was last active from.
*
* @var string
*/
public $lastIp = '0.0.0.0';
/**
* A user's title.
*
* @var string
*/
public $title = '';
/**
* The UNIX timestamp of when the user registered.
*
* @var int
*/
public $registered = 0;
/**
* The UNIX timestamp of when the user was last online.
*
* @var int
*/
public $lastOnline = 0;
/**
* The 2 character country code of a user.
*
* @var string
*/
public $country = 'XX';
/**
* The File id of the user's avatar.
*
* @var int
*/
public $avatar = 0;
/**
* The File id of the user's background.
*
* @var int
*/
public $background = 0;
/**
* The File id of the user's header.
* @var mixed
* @var int
*/
public $header = 0;
/**
* The raw userpage of the user.
*
* @var string
*/
public $page = '';
/**
* The raw signature of the user.
*
* @var string
*/
public $signature = '';
/**
* Whether the user's background should be displayed sitewide.
*
* @var bool
*/
public $backgroundSitewide = false;
/**
* The user's website url.
*
* @var string
*/
public $website = '';
/**
* The user's twitter handle.
*
* @var string
*/
public $twitter = '';
/**
* The user's github username.
*
* @var string
*/
public $github = '';
/**
* The user's skype username.
*
* @var string
*/
public $skype = '';
/**
* The user's discord tag.
*
* @var string
*/
public $discord = '';
/**
* The user's youtube channel id/name.
*
* @var string
*/
public $youtube = '';
/**
* The user's steam community username.
*
* @var string
*/
public $steam = '';
/**
* The user's osu! username.
*
* @var string
*/
public $osu = '';
/**
* The user's lastfm username.
*
* @var string
*/
public $lastfm = '';
/**
* The user's birthday.
*
* @var string
*/
private $birthday = '0000-00-00';
/**
* The user's permission container.
*
* @var Perms
*/
private $permissions;
/**
* The User instance cache array.
*
* @var array
*/
protected static $userCache = [];
/**
* Cached constructor.
*
* @param int|string $uid The user ID or clean username.
* @param bool $forceRefresh Force a recreation.
*
* @return User Returns a user object.
* @param int|string $uid
* @param bool $forceRefresh
* @return User
*/
public static function construct($uid, $forceRefresh = false)
{
@ -279,13 +242,11 @@ class User
/**
* Create a new user.
*
* @param string $username The username of the user.
* @param string $password The password of the user.
* @param string $email The e-mail, used primarily for activation.
* @param array $ranks The ranks assigned to the user on creation.
*
* @return User The newly created user's object.
* @param string $username
* @param string $password
* @param string $email
* @param array $ranks
* @return User
*/
public static function create($username, $password, $email, $ranks = [2])
{
@ -323,9 +284,8 @@ class User
}
/**
* The actual constructor
*
* @param int|string $userId The user ID or clean username.
* The actual constructor.
* @param int|string $userId
*/
private function __construct($userId)
{
@ -430,8 +390,7 @@ class User
}
/**
* Get a Carbon object of the registration date
*
* Get a Carbon object of the registration date.
* @return Carbon
*/
public function registerDate()
@ -440,8 +399,7 @@ class User
}
/**
* Get a Carbon object of the last online date
*
* Get a Carbon object of the last online date.
* @return Carbon
*/
public function lastDate()
@ -451,10 +409,8 @@ class User
/**
* Get the user's birthday.
*
* @param bool $age Just get the age.
*
* @return int|string Return the birthday.
* @param bool $age
* @return int|string
*/
public function birthday($age = false)
{
@ -477,10 +433,8 @@ class User
/**
* Get the user's country.
*
* @param bool $long Get the full country name.
*
* @return string The country.
* @param bool $long
* @return string
*/
public function country($long = false)
{
@ -489,8 +443,7 @@ class User
/**
* Check if a user is online.
*
* @return bool Are they online?
* @return bool
*/
public function isOnline()
{
@ -509,7 +462,7 @@ class User
}
/**
* Updates the last IP and online time of the user
* Updates the last IP and online time of the user.
*/
public function updateOnline()
{
@ -526,8 +479,7 @@ class User
/**
* Runs some checks to see if this user is activated.
*
* @return bool Are they activated?
* @return bool
*/
public function isActive()
{
@ -536,8 +488,7 @@ class User
/**
* Get a few forum statistics.
*
* @return array Post and topic counts.
* @return array
*/
public function forumStats()
{
@ -560,8 +511,7 @@ class User
/**
* Add ranks to a user.
*
* @param array $ranks Array containing the rank IDs.
* @param array $ranks
*/
public function addRanks($ranks)
{
@ -588,8 +538,7 @@ class User
/**
* Remove a set of ranks from a user.
*
* @param array $ranks Array containing the IDs of ranks to remove.
* @param array $ranks
*/
public function removeRanks($ranks)
{
@ -607,10 +556,8 @@ class User
/**
* Change the main rank of a user.
*
* @param int $rank The ID of the new main rank.
*
* @return bool Always true.
* @param int $rank
* @return bool
*/
public function setMainRank($rank)
{
@ -627,10 +574,8 @@ class User
/**
* Check if a user has a certain set of rank.
*
* @param array $ranks Ranks IDs to check.
*
* @return bool Successful?
* @param array $ranks
* @return bool
*/
public function hasRanks($ranks)
{
@ -653,8 +598,7 @@ class User
/**
* Add a new friend.
*
* @param int $uid The ID of the friend.
* @param int $uid
*/
public function addFriend($uid)
{
@ -669,9 +613,8 @@ class User
/**
* Remove a friend.
*
* @param int $uid The friend Id
* @param bool $deleteRequest Delete the open request as well (remove you from their friends list).
* @param int $uid
* @param bool $deleteRequest
*/
public function removeFriend($uid, $deleteRequest = false)
{
@ -692,10 +635,9 @@ class User
/**
* Check if this user is friends with another user.
*
* @param int $with ID of the other user.
*
* @return int 0 = no, 1 = pending request, 2 = mutual
* 0 = no, 1 = pending request, 2 = mutual.
* @param int $with
* @return int
*/
public function isFriends($with)
{
@ -723,11 +665,9 @@ class User
/**
* Get all the friends from this user.
*
* @param int $level Friend level; (figure out what the levels are at some point)
* @param bool $noObj Just return IDs.
*
* @return array The array with either the objects or the ids.
* @param int $level
* @param bool $noObj
* @return array
*/
public function friends($level = 0, $noObj = false)
{
@ -821,11 +761,9 @@ class User
/**
* Check if the user has a certaing permission flag.
*
* @param int $flag The permission flag.
* @param string $mode The permission mode.
*
* @return bool Success?
* @param int $flag
* @param string $mode
* @return bool
*/
public function permission($flag, $mode = null)
{
@ -843,8 +781,7 @@ class User
/**
* Get the comments from the user's profile.
*
* @return Comments
* @return array
*/
public function profileComments()
{
@ -866,10 +803,8 @@ class User
/**
* Add premium in seconds.
*
* @param int $seconds The amount of seconds.
*
* @return int The new expiry date.
* @param int $seconds
* @return int
*/
public function addPremium($seconds)
{
@ -904,8 +839,7 @@ class User
/**
* Does this user have premium?
*
* @return int Returns the premium expiration date.
* @return int
*/
public function isPremium()
{
@ -944,6 +878,10 @@ class User
return $expire;
}
/**
* Gets the start and end date of this user's premium tag.
* @return stdClass
*/
public function premiumInfo()
{
// Attempt to retrieve the premium record from the database
@ -962,8 +900,7 @@ class User
/**
* Parse the user's userpage.
*
* @return string The parsed page.
* @return string
*/
public function userPage()
{
@ -971,9 +908,8 @@ class User
}
/**
* Parse a user's signature
*
* @return string The parsed signature.
* Parse a user's signature.
* @return string
*/
public function signature()
{
@ -982,8 +918,7 @@ class User
/**
* Get a user's username history.
*
* @return array The history.
* @return array
*/
public function getUsernameHistory()
{
@ -994,10 +929,9 @@ class User
}
/**
* Alter the user's username
*
* @param string $username The new username.
* @param string $username_clean The new (clean) username.
* Alter the user's username.
* @param string $username
* @param string $username_clean
*/
public function setUsername($username, $username_clean)
{
@ -1022,9 +956,8 @@ class User
}
/**
* Alter a user's e-mail address
*
* @param string $email The new e-mail address.
* Alter a user's e-mail address.
* @param string $email
*/
public function setMail($email)
{
@ -1037,9 +970,8 @@ class User
}
/**
* Change the user's password
*
* @param string $password The new password.
* Change the user's password.
* @param string $password
*/
public function setPassword($password)
{
@ -1056,8 +988,7 @@ class User
}
/**
* Check if password expired
*
* Check if password expired.
* @return bool
*/
public function passwordExpired()
@ -1066,10 +997,8 @@ class User
}
/**
* Verify the user's password
*
* Verify the user's password.
* @param string $password
*
* @return bool
*/
public function verifyPassword($password)
@ -1079,11 +1008,9 @@ class User
/**
* Get all the notifications for this user.
*
* @param int $timeDifference The timeframe of alerts that should be fetched.
* @param bool $excludeRead Whether alerts that are marked as read should be included.
*
* @return array An array with Notification objects.
* @param int $timeDifference
* @param bool $excludeRead
* @return array
*/
public function notifications($timeDifference = 0, $excludeRead = true)
{