diff --git a/app/ActionCode.php b/app/ActionCode.php index 6fa0c68..fd80c0c 100644 --- a/app/ActionCode.php +++ b/app/ActionCode.php @@ -1,7 +1,6 @@ */ @@ -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) { diff --git a/app/ActiveUser.php b/app/ActiveUser.php index 37a60e6..2ea513b 100644 --- a/app/ActiveUser.php +++ b/app/ActiveUser.php @@ -1,7 +1,6 @@ */ 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 diff --git a/app/BBcode.php b/app/BBcode.php index b5b5235..86365dd 100644 --- a/app/BBcode.php +++ b/app/BBcode.php @@ -1,7 +1,6 @@ */ 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 */ diff --git a/app/CSRF.php b/app/CSRF.php index 047e830..f1a97ea 100644 --- a/app/CSRF.php +++ b/app/CSRF.php @@ -1,7 +1,6 @@ */ @@ -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) { diff --git a/app/Comment.php b/app/Comment.php index a3a1463..0dd9c7c 100644 --- a/app/Comment.php +++ b/app/Comment.php @@ -1,7 +1,6 @@ */ 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'; diff --git a/app/Config.php b/app/Config.php index 831470c..824d2f3 100644 --- a/app/Config.php +++ b/app/Config.php @@ -1,7 +1,6 @@ */ 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) { diff --git a/app/Console/Application.php b/app/Console/Application.php index 856daef..130ae03 100644 --- a/app/Console/Application.php +++ b/app/Console/Application.php @@ -1,7 +1,6 @@ */ 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; } diff --git a/app/Console/Command/DatabaseInstallCommand.php b/app/Console/Command/DatabaseInstallCommand.php index 9f6a790..fd52b88 100644 --- a/app/Console/Command/DatabaseInstallCommand.php +++ b/app/Console/Command/DatabaseInstallCommand.php @@ -1,7 +1,6 @@ + */ 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(); diff --git a/app/Console/Command/DatabaseMigrateCommand.php b/app/Console/Command/DatabaseMigrateCommand.php index 01e4519..ecf2965 100644 --- a/app/Console/Command/DatabaseMigrateCommand.php +++ b/app/Console/Command/DatabaseMigrateCommand.php @@ -1,7 +1,6 @@ + */ 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(); diff --git a/app/Console/Command/DatabaseResetCommand.php b/app/Console/Command/DatabaseResetCommand.php index bd7bcfa..f1acba2 100644 --- a/app/Console/Command/DatabaseResetCommand.php +++ b/app/Console/Command/DatabaseResetCommand.php @@ -1,7 +1,6 @@ + */ 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(); diff --git a/app/Console/Command/DatabaseRollbackCommand.php b/app/Console/Command/DatabaseRollbackCommand.php index c202711..b19781f 100644 --- a/app/Console/Command/DatabaseRollbackCommand.php +++ b/app/Console/Command/DatabaseRollbackCommand.php @@ -1,7 +1,6 @@ + */ 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(); diff --git a/app/Console/Command/DatabaseStatusCommand.php b/app/Console/Command/DatabaseStatusCommand.php index 285dc48..73d524f 100644 --- a/app/Console/Command/DatabaseStatusCommand.php +++ b/app/Console/Command/DatabaseStatusCommand.php @@ -1,7 +1,6 @@ + */ 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(); diff --git a/app/Console/Command/ServeCommand.php b/app/Console/Command/ServeCommand.php index 3699d6f..c989a27 100644 --- a/app/Console/Command/ServeCommand.php +++ b/app/Console/Command/ServeCommand.php @@ -1,7 +1,6 @@ + */ 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/'); diff --git a/app/Console/Command/SetupCommand.php b/app/Console/Command/SetupCommand.php index 7ff8408..c4f99d6 100644 --- a/app/Console/Command/SetupCommand.php +++ b/app/Console/Command/SetupCommand.php @@ -1,7 +1,6 @@ + */ 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 diff --git a/app/Controllers/AuthController.php b/app/Controllers/AuthController.php index 5b510b5..d5cbaaf 100644 --- a/app/Controllers/AuthController.php +++ b/app/Controllers/AuthController.php @@ -1,7 +1,6 @@ */ @@ -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) diff --git a/app/Controllers/ChatController.php b/app/Controllers/ChatController.php index 1cd0045..5f0a1c5 100644 --- a/app/Controllers/ChatController.php +++ b/app/Controllers/ChatController.php @@ -1,7 +1,6 @@ */ 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; diff --git a/app/Controllers/CommentsController.php b/app/Controllers/CommentsController.php index 4cc9d68..2b56eb1 100644 --- a/app/Controllers/CommentsController.php +++ b/app/Controllers/CommentsController.php @@ -1,7 +1,6 @@ */ 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; diff --git a/app/Controllers/Controller.php b/app/Controllers/Controller.php index 193b0de..bf9d716 100644 --- a/app/Controllers/Controller.php +++ b/app/Controllers/Controller.php @@ -1,7 +1,6 @@ */ 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'); diff --git a/app/Controllers/FileController.php b/app/Controllers/FileController.php index 5a6066f..643c2e0 100644 --- a/app/Controllers/FileController.php +++ b/app/Controllers/FileController.php @@ -1,7 +1,6 @@ */ @@ -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) diff --git a/app/Controllers/Forum/Controller.php b/app/Controllers/Forum/Controller.php index 396edc7..a7262e6 100644 --- a/app/Controllers/Forum/Controller.php +++ b/app/Controllers/Forum/Controller.php @@ -1,7 +1,6 @@ */ diff --git a/app/Controllers/Forum/ForumController.php b/app/Controllers/Forum/ForumController.php index 9f23267..e379d11 100644 --- a/app/Controllers/Forum/ForumController.php +++ b/app/Controllers/Forum/ForumController.php @@ -1,7 +1,6 @@ */ 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'); diff --git a/app/Controllers/Forum/PostController.php b/app/Controllers/Forum/PostController.php index 7f1e87d..402a05f 100644 --- a/app/Controllers/Forum/PostController.php +++ b/app/Controllers/Forum/PostController.php @@ -1,7 +1,6 @@ */ 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); diff --git a/app/Controllers/Forum/TopicController.php b/app/Controllers/Forum/TopicController.php index d319f82..a3f705f 100644 --- a/app/Controllers/Forum/TopicController.php +++ b/app/Controllers/Forum/TopicController.php @@ -1,7 +1,6 @@ */ 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; diff --git a/app/Controllers/FriendsController.php b/app/Controllers/FriendsController.php index d3ab57a..0b3e7fe 100644 --- a/app/Controllers/FriendsController.php +++ b/app/Controllers/FriendsController.php @@ -1,7 +1,6 @@ */ 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; diff --git a/app/Controllers/HelperController.php b/app/Controllers/HelperController.php index fd01ea9..7d431e3 100644 --- a/app/Controllers/HelperController.php +++ b/app/Controllers/HelperController.php @@ -1,7 +1,6 @@ */ 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'] ?? '')); } } diff --git a/app/Controllers/InfoController.php b/app/Controllers/InfoController.php index 9d98296..d61d0aa 100644 --- a/app/Controllers/InfoController.php +++ b/app/Controllers/InfoController.php @@ -1,7 +1,6 @@ */ 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'); diff --git a/app/Controllers/Manage/Controller.php b/app/Controllers/Manage/Controller.php index 6dec189..4e2cc61 100644 --- a/app/Controllers/Manage/Controller.php +++ b/app/Controllers/Manage/Controller.php @@ -1,7 +1,6 @@ */ class Controller extends BaseController { + /** + * Constructor. + */ public function __construct() { $navigation = $this->navigation(); - Template::vars(compact('navigation')); } + /** + * Generates the navigation. + * @return array + */ public function navigation() { $nav = []; diff --git a/app/Controllers/Manage/OverviewController.php b/app/Controllers/Manage/OverviewController.php index 1ac340a..22782c7 100644 --- a/app/Controllers/Manage/OverviewController.php +++ b/app/Controllers/Manage/OverviewController.php @@ -1,7 +1,6 @@ */ 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; diff --git a/app/Controllers/MetaController.php b/app/Controllers/MetaController.php index 70b33d3..763d95b 100644 --- a/app/Controllers/MetaController.php +++ b/app/Controllers/MetaController.php @@ -1,7 +1,6 @@ */ @@ -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() { diff --git a/app/Controllers/NewsController.php b/app/Controllers/NewsController.php index a375443..250d8f8 100644 --- a/app/Controllers/NewsController.php +++ b/app/Controllers/NewsController.php @@ -1,7 +1,6 @@ */ 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 diff --git a/app/Controllers/NotificationsController.php b/app/Controllers/NotificationsController.php index 0eec923..af5f099 100644 --- a/app/Controllers/NotificationsController.php +++ b/app/Controllers/NotificationsController.php @@ -1,7 +1,6 @@ */ @@ -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) { diff --git a/app/Controllers/PremiumController.php b/app/Controllers/PremiumController.php index 1f099a8..2eea210 100644 --- a/app/Controllers/PremiumController.php +++ b/app/Controllers/PremiumController.php @@ -1,7 +1,6 @@ */ @@ -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() { diff --git a/app/Controllers/Settings/AccountController.php b/app/Controllers/Settings/AccountController.php index cee7359..fc21c31 100644 --- a/app/Controllers/Settings/AccountController.php +++ b/app/Controllers/Settings/AccountController.php @@ -1,7 +1,6 @@ */ 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 diff --git a/app/Controllers/Settings/AdvancedController.php b/app/Controllers/Settings/AdvancedController.php index f46e642..aa4a208 100644 --- a/app/Controllers/Settings/AdvancedController.php +++ b/app/Controllers/Settings/AdvancedController.php @@ -1,7 +1,6 @@ */ 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 diff --git a/app/Controllers/Settings/AppearanceController.php b/app/Controllers/Settings/AppearanceController.php index 4131518..8fe08f3 100644 --- a/app/Controllers/Settings/AppearanceController.php +++ b/app/Controllers/Settings/AppearanceController.php @@ -1,7 +1,6 @@ */ 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 diff --git a/app/Controllers/Settings/Controller.php b/app/Controllers/Settings/Controller.php index 107e841..b810437 100644 --- a/app/Controllers/Settings/Controller.php +++ b/app/Controllers/Settings/Controller.php @@ -1,7 +1,6 @@ */ class Controller extends BaseController { + /** + * Constructor. + */ public function __construct() { Template::vars(['navigation' => $this->navigation()]); } + /** + * Generates the navigation. + * @return array + */ public function navigation() { $nav = []; diff --git a/app/Controllers/Settings/FriendsController.php b/app/Controllers/Settings/FriendsController.php index 4dac568..9aa07c6 100644 --- a/app/Controllers/Settings/FriendsController.php +++ b/app/Controllers/Settings/FriendsController.php @@ -1,7 +1,6 @@ */ 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 diff --git a/app/Controllers/Settings/NotificationsController.php b/app/Controllers/Settings/NotificationsController.php index 8131622..4653140 100644 --- a/app/Controllers/Settings/NotificationsController.php +++ b/app/Controllers/Settings/NotificationsController.php @@ -1,7 +1,6 @@ */ class NotificationsController extends Controller { + /** + * Get the notification history. + * @return string + */ public function history() { return view('settings/notifications/history'); diff --git a/app/Controllers/StatusController.php b/app/Controllers/StatusController.php index 871ae51..e529975 100644 --- a/app/Controllers/StatusController.php +++ b/app/Controllers/StatusController.php @@ -1,7 +1,6 @@ */ class StatusController extends Controller { + /** + * Renders the base status page. + * @return string + */ public function index() { return view('status/index'); diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index 9cc43da..9ad5c1b 100644 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -1,7 +1,6 @@ */ @@ -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'); diff --git a/app/DB.php b/app/DB.php index fc408c7..324b73e 100644 --- a/app/DB.php +++ b/app/DB.php @@ -1,7 +1,6 @@ */ 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(); diff --git a/app/Exception.php b/app/Exception.php index 05b985e..ee23015 100644 --- a/app/Exception.php +++ b/app/Exception.php @@ -1,7 +1,6 @@ */ diff --git a/app/File.php b/app/File.php index 0070b09..a82572f 100644 --- a/app/File.php +++ b/app/File.php @@ -1,7 +1,6 @@ */ @@ -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) { diff --git a/app/Forum/Forum.php b/app/Forum/Forum.php index 6f439a1..058a196 100644 --- a/app/Forum/Forum.php +++ b/app/Forum/Forum.php @@ -1,7 +1,6 @@ */ @@ -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) { diff --git a/app/Forum/Post.php b/app/Forum/Post.php index 54a452a..8b2f0dd 100644 --- a/app/Forum/Post.php +++ b/app/Forum/Post.php @@ -1,7 +1,6 @@ */ @@ -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) { diff --git a/app/Forum/Topic.php b/app/Forum/Topic.php index c1c3859..491dfa4 100644 --- a/app/Forum/Topic.php +++ b/app/Forum/Topic.php @@ -1,7 +1,6 @@ */ @@ -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) { diff --git a/app/Middleware/Middleware.php b/app/Middleware/Middleware.php index 74169a1..6682f16 100644 --- a/app/Middleware/Middleware.php +++ b/app/Middleware/Middleware.php @@ -1,7 +1,6 @@ */ interface Middleware { + /** + * Runs the middleware task. + */ public function run(); } diff --git a/app/Middleware/UpdateLastOnline.php b/app/Middleware/UpdateLastOnline.php index 7983145..aa36a0f 100644 --- a/app/Middleware/UpdateLastOnline.php +++ b/app/Middleware/UpdateLastOnline.php @@ -1,7 +1,6 @@ */ class UpdateLastOnline implements Middleware { + /** + * Update the last online information for the active user. + */ public function run() { if (ActiveUser::$user->id !== 0) { diff --git a/app/Net.php b/app/Net.php index a8048ef..3d05caa 100644 --- a/app/Net.php +++ b/app/Net.php @@ -1,7 +1,6 @@ */ @@ -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) { diff --git a/app/News/Category.php b/app/News/Category.php index dafa3dc..8656112 100644 --- a/app/News/Category.php +++ b/app/News/Category.php @@ -1,7 +1,6 @@ */ 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') diff --git a/app/News/Post.php b/app/News/Post.php index 3958d8b..07c1c6e 100644 --- a/app/News/Post.php +++ b/app/News/Post.php @@ -1,7 +1,6 @@ */ 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) { diff --git a/app/Notification.php b/app/Notification.php index d619324..afbeeff 100644 --- a/app/Notification.php +++ b/app/Notification.php @@ -1,7 +1,6 @@ */ 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); diff --git a/app/Payments.php b/app/Payments.php index c8ad8af..949617b 100644 --- a/app/Payments.php +++ b/app/Payments.php @@ -1,7 +1,6 @@ * @author Julian van de Groep @@ -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); diff --git a/app/Perms.php b/app/Perms.php index bff6a76..965e2d1 100644 --- a/app/Perms.php +++ b/app/Perms.php @@ -1,7 +1,6 @@ */ @@ -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) { diff --git a/app/Perms/Forum.php b/app/Perms/Forum.php index b6263b9..23bad66 100644 --- a/app/Perms/Forum.php +++ b/app/Perms/Forum.php @@ -1,7 +1,6 @@ */ diff --git a/app/Perms/Manage.php b/app/Perms/Manage.php index 12065ab..abb02e3 100644 --- a/app/Perms/Manage.php +++ b/app/Perms/Manage.php @@ -1,7 +1,6 @@ */ diff --git a/app/Perms/Site.php b/app/Perms/Site.php index 00d5359..86dc815 100644 --- a/app/Perms/Site.php +++ b/app/Perms/Site.php @@ -1,7 +1,6 @@ */ diff --git a/app/Rank.php b/app/Rank.php index f002a74..dea47ba 100644 --- a/app/Rank.php +++ b/app/Rank.php @@ -1,7 +1,6 @@ */ @@ -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) { diff --git a/app/Router.php b/app/Router.php index 782f743..1903b85 100644 --- a/app/Router.php +++ b/app/Router.php @@ -1,7 +1,6 @@ */ 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) { diff --git a/app/Session.php b/app/Session.php index 3336845..58aac5b 100644 --- a/app/Session.php +++ b/app/Session.php @@ -1,7 +1,6 @@ */ @@ -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() { diff --git a/app/Template.php b/app/Template.php index 8e2b023..09a8e07 100644 --- a/app/Template.php +++ b/app/Template.php @@ -1,7 +1,6 @@ */ @@ -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) { diff --git a/app/Trick.php b/app/Trick.php index 11c626f..6a6575f 100644 --- a/app/Trick.php +++ b/app/Trick.php @@ -1,7 +1,6 @@ */ diff --git a/app/User.php b/app/User.php index ba01ed0..7d343f9 100644 --- a/app/User.php +++ b/app/User.php @@ -1,7 +1,6 @@ */ @@ -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) {