@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | protected function category(string $countryId, ArticleCategory $category, int $categoryPage, int $start): Response |
| 57 | 57 | { |
| 58 | - $articles = Article::where('id', '>=', $start)->limit(10)->orderBy('id', 'DESC')->get()->filter(function ($item) use ($category) { |
|
| 58 | + $articles = Article::where('id', '>=', $start)->limit(10)->orderBy('id', 'DESC')->get()->filter(function($item) use ($category) { |
|
| 59 | 59 | return $category->name == 'all' || in_array($category, $item->categories); |
| 60 | 60 | }); |
| 61 | 61 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | return response()->json(null, 404); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $related = ($latest = Article::all())->filter(function ($item) use ($article) { |
|
| 83 | + $related = ($latest = Article::all())->filter(function($item) use ($article) { |
|
| 84 | 84 | return in_array($article->categories[0], $item->categories); |
| 85 | 85 | }); |
| 86 | 86 | |
@@ -1,18 +1,18 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Http\Controllers; |
|
| 3 | + namespace App\Http\Controllers; |
|
| 4 | 4 | |
| 5 | -use App\Models\Article; |
|
| 6 | -use App\Models\ArticleCategory; |
|
| 7 | -use Illuminate\Http\Response; |
|
| 8 | -use Laravel\Lumen\Routing\Controller as BaseController; |
|
| 5 | + use App\Models\Article; |
|
| 6 | + use App\Models\ArticleCategory; |
|
| 7 | + use Illuminate\Http\Response; |
|
| 8 | + use Laravel\Lumen\Routing\Controller as BaseController; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Class ArticleController. |
| 12 | 12 | */ |
| 13 | -class ArticleController extends BaseController |
|
| 14 | -{ |
|
| 15 | - /** |
|
| 13 | + class ArticleController extends BaseController |
|
| 14 | + { |
|
| 15 | + /** |
|
| 16 | 16 | * Render a specific view of Article set. |
| 17 | 17 | * |
| 18 | 18 | * @param string $countryId |
@@ -20,28 +20,28 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @return Response |
| 22 | 22 | */ |
| 23 | - public function many(string $countryId, string $articleCategory): Response |
|
| 24 | - { |
|
| 25 | - $category = ArticleCategory::find(strstr(($articleCategory = |
|
| 26 | - str_replace('.html', '', $articleCategory)), '_', true)); |
|
| 23 | + public function many(string $countryId, string $articleCategory): Response |
|
| 24 | + { |
|
| 25 | + $category = ArticleCategory::find(strstr(($articleCategory = |
|
| 26 | + str_replace('.html', '', $articleCategory)), '_', true)); |
|
| 27 | 27 | |
| 28 | - $categoryPage = strstr(strrev($articleCategory), '_', true); |
|
| 28 | + $categoryPage = strstr(strrev($articleCategory), '_', true); |
|
| 29 | 29 | |
| 30 | - return $articleCategory == 'front' ? $this->front() : $this->category($countryId, $category, $categoryPage, |
|
| 31 | - $categoryPage == 1 ? 0 : (10 * ($categoryPage - 1))); |
|
| 32 | - } |
|
| 30 | + return $articleCategory == 'front' ? $this->front() : $this->category($countryId, $category, $categoryPage, |
|
| 31 | + $categoryPage == 1 ? 0 : (10 * ($categoryPage - 1))); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 34 | + /** |
|
| 35 | 35 | * Render the Front Page of the Articles Page. |
| 36 | 36 | * |
| 37 | 37 | * @return Response |
| 38 | 38 | */ |
| 39 | - protected function front(): Response |
|
| 40 | - { |
|
| 41 | - return response(view('habbo-web-news.articles-front', ['set' => Article::orderBy('id', 'DESC')->limit(10)->get()])); |
|
| 42 | - } |
|
| 39 | + protected function front(): Response |
|
| 40 | + { |
|
| 41 | + return response(view('habbo-web-news.articles-front', ['set' => Article::orderBy('id', 'DESC')->limit(10)->get()])); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 44 | + /** |
|
| 45 | 45 | * Render a specific Category Articles Page. |
| 46 | 46 | * |
| 47 | 47 | * @TODO: Proper Way to use Country ID |
@@ -53,18 +53,18 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return Response |
| 55 | 55 | */ |
| 56 | - protected function category(string $countryId, ArticleCategory $category, int $categoryPage, int $start): Response |
|
| 57 | - { |
|
| 58 | - $articles = Article::where('id', '>=', $start)->limit(10)->orderBy('id', 'DESC')->get()->filter(function ($item) use ($category) { |
|
| 59 | - return $category->name == 'all' || in_array($category, $item->categories); |
|
| 60 | - }); |
|
| 56 | + protected function category(string $countryId, ArticleCategory $category, int $categoryPage, int $start): Response |
|
| 57 | + { |
|
| 58 | + $articles = Article::where('id', '>=', $start)->limit(10)->orderBy('id', 'DESC')->get()->filter(function ($item) use ($category) { |
|
| 59 | + return $category->name == 'all' || in_array($category, $item->categories); |
|
| 60 | + }); |
|
| 61 | 61 | |
| 62 | - return response(view('habbo-web-news.articles-category', [ |
|
| 63 | - 'category' => $category, 'page' => $categoryPage, 'categories' => ArticleCategory::all(), 'articles' => $articles, |
|
| 64 | - ])); |
|
| 65 | - } |
|
| 62 | + return response(view('habbo-web-news.articles-category', [ |
|
| 63 | + 'category' => $category, 'page' => $categoryPage, 'categories' => ArticleCategory::all(), 'articles' => $articles, |
|
| 64 | + ])); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 67 | + /** |
|
| 68 | 68 | * Render a specific view of a specific Article. |
| 69 | 69 | * |
| 70 | 70 | * @TODO: Proper Way to use Country ID |
@@ -74,28 +74,28 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return Response |
| 76 | 76 | */ |
| 77 | - public function one(string $countryId, string $articleName): Response |
|
| 78 | - { |
|
| 79 | - if (($article = Article::find(strstr($articleName, '_', true))) == null) { |
|
| 80 | - return response()->json(null, 404); |
|
| 81 | - } |
|
| 77 | + public function one(string $countryId, string $articleName): Response |
|
| 78 | + { |
|
| 79 | + if (($article = Article::find(strstr($articleName, '_', true))) == null) { |
|
| 80 | + return response()->json(null, 404); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - $related = ($latest = Article::all())->filter(function ($item) use ($article) { |
|
| 84 | - return in_array($article->categories[0], $item->categories); |
|
| 85 | - }); |
|
| 83 | + $related = ($latest = Article::all())->filter(function ($item) use ($article) { |
|
| 84 | + return in_array($article->categories[0], $item->categories); |
|
| 85 | + }); |
|
| 86 | 86 | |
| 87 | - return response(view('habbo-web-news.articles-view', |
|
| 88 | - ['article' => $article, 'latest' => $latest->slice(0, 5), 'related' => $related->slice(0, 5)] |
|
| 89 | - )); |
|
| 90 | - } |
|
| 87 | + return response(view('habbo-web-news.articles-view', |
|
| 88 | + ['article' => $article, 'latest' => $latest->slice(0, 5), 'related' => $related->slice(0, 5)] |
|
| 89 | + )); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - /** |
|
| 92 | + /** |
|
| 93 | 93 | * Get All Habbo Articles as XML/RSS. |
| 94 | 94 | * |
| 95 | 95 | * @return Response |
| 96 | 96 | */ |
| 97 | - public function getRss() |
|
| 98 | - { |
|
| 99 | - return response(view('habbo-web-pages.habbo-rss', ['articles' => Article::limit(20)->get()]))->header('Content-Type', 'text/xml'); |
|
| 100 | - } |
|
| 97 | + public function getRss() |
|
| 98 | + { |
|
| 99 | + return response(view('habbo-web-pages.habbo-rss', ['articles' => Article::limit(20)->get()]))->header('Content-Type', 'text/xml'); |
|
| 100 | + } |
|
| 101 | 101 | } |
@@ -25,8 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function getUserHead(Request $request) |
| 27 | 27 | { |
| 28 | - return redirect(Config::get('chocolatey.imaging').'avatarimage?figure='.($request->has('figure') ? $request->input('figure') : |
|
| 29 | - User::where('username', $request->input('user'))->first()->figureString).'&size=l&headonly=1'); |
|
| 28 | + return redirect(Config::get('chocolatey.imaging') . 'avatarimage?figure=' . ($request->has('figure') ? $request->input('figure') : User::where('username', $request->input('user'))->first()->figureString) . '&size=l&headonly=1'); |
|
| 30 | 29 | } |
| 31 | 30 | |
| 32 | 31 | /** |
@@ -39,7 +38,7 @@ discard block |
||
| 39 | 38 | */ |
| 40 | 39 | public function getUserBody(string $figure) |
| 41 | 40 | { |
| 42 | - return redirect(Config::get('chocolatey.imaging')."avatar/{$figure}"); |
|
| 41 | + return redirect(Config::get('chocolatey.imaging') . "avatar/{$figure}"); |
|
| 43 | 42 | } |
| 44 | 43 | |
| 45 | 44 | /** |
@@ -1,21 +1,21 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Http\Controllers; |
|
| 3 | + namespace App\Http\Controllers; |
|
| 4 | 4 | |
| 5 | -use App\Models\EmulatorSettings; |
|
| 6 | -use App\Models\User; |
|
| 7 | -use Illuminate\Http\Request; |
|
| 8 | -use Illuminate\Support\Facades\Config; |
|
| 9 | -use Intervention\Image\Facades\Image; |
|
| 10 | -use Laravel\Lumen\Http\Redirector; |
|
| 11 | -use Laravel\Lumen\Routing\Controller as BaseController; |
|
| 5 | + use App\Models\EmulatorSettings; |
|
| 6 | + use App\Models\User; |
|
| 7 | + use Illuminate\Http\Request; |
|
| 8 | + use Illuminate\Support\Facades\Config; |
|
| 9 | + use Intervention\Image\Facades\Image; |
|
| 10 | + use Laravel\Lumen\Http\Redirector; |
|
| 11 | + use Laravel\Lumen\Routing\Controller as BaseController; |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Class ImagingController. |
| 15 | 15 | */ |
| 16 | -class ImagingController extends BaseController |
|
| 17 | -{ |
|
| 18 | - /** |
|
| 16 | + class ImagingController extends BaseController |
|
| 17 | + { |
|
| 18 | + /** |
|
| 19 | 19 | * Get User Figure for Big Header |
| 20 | 20 | * based on User Name or Figure. |
| 21 | 21 | * |
@@ -23,13 +23,13 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return Redirector |
| 25 | 25 | */ |
| 26 | - public function getUserHead(Request $request) |
|
| 27 | - { |
|
| 28 | - return redirect(Config::get('chocolatey.imaging').'avatarimage?figure='.($request->has('figure') ? $request->input('figure') : |
|
| 29 | - User::where('username', $request->input('user'))->first()->figureString).'&size=l&headonly=1'); |
|
| 30 | - } |
|
| 26 | + public function getUserHead(Request $request) |
|
| 27 | + { |
|
| 28 | + return redirect(Config::get('chocolatey.imaging').'avatarimage?figure='.($request->has('figure') ? $request->input('figure') : |
|
| 29 | + User::where('username', $request->input('user'))->first()->figureString).'&size=l&headonly=1'); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - /** |
|
| 32 | + /** |
|
| 33 | 33 | * Get User Figure for Body |
| 34 | 34 | * based on User Figure. |
| 35 | 35 | * |
@@ -37,36 +37,36 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @return Redirector |
| 39 | 39 | */ |
| 40 | - public function getUserBody(string $figure) |
|
| 41 | - { |
|
| 42 | - return redirect(Config::get('chocolatey.imaging')."avatar/{$figure}"); |
|
| 43 | - } |
|
| 40 | + public function getUserBody(string $figure) |
|
| 41 | + { |
|
| 42 | + return redirect(Config::get('chocolatey.imaging')."avatar/{$figure}"); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 45 | + /** |
|
| 46 | 46 | * Get Youtube Thumbnail. |
| 47 | 47 | * |
| 48 | 48 | * @param Request $request |
| 49 | 49 | * |
| 50 | 50 | * @return string |
| 51 | 51 | */ |
| 52 | - public function getYoutubeThumbnail(Request $request) |
|
| 53 | - { |
|
| 54 | - return Image::make($request->input('url'))->response('jpg'); |
|
| 55 | - } |
|
| 52 | + public function getYoutubeThumbnail(Request $request) |
|
| 53 | + { |
|
| 54 | + return Image::make($request->input('url'))->response('jpg'); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 57 | + /** |
|
| 58 | 58 | * Return Group Badge. |
| 59 | 59 | * |
| 60 | 60 | * @param string $badgeCode |
| 61 | 61 | * |
| 62 | 62 | * @return mixed |
| 63 | 63 | */ |
| 64 | - public function getGroupBadge(string $badgeCode) |
|
| 65 | - { |
|
| 66 | - $imagePath = EmulatorSettings::where('key', 'imager.location.output.badges')->first(); |
|
| 64 | + public function getGroupBadge(string $badgeCode) |
|
| 65 | + { |
|
| 66 | + $imagePath = EmulatorSettings::where('key', 'imager.location.output.badges')->first(); |
|
| 67 | 67 | |
| 68 | - $badgeCode = str_replace('.gif', '', $badgeCode); |
|
| 68 | + $badgeCode = str_replace('.gif', '', $badgeCode); |
|
| 69 | 69 | |
| 70 | - return Image::make("{$imagePath->value}/{$badgeCode}.png")->response('gif'); |
|
| 71 | - } |
|
| 70 | + return Image::make("{$imagePath->value}/{$badgeCode}.png")->response('gif'); |
|
| 71 | + } |
|
| 72 | 72 | } |
@@ -122,7 +122,7 @@ |
||
| 122 | 122 | */ |
| 123 | 123 | public function hasSession() |
| 124 | 124 | { |
| 125 | - return (bool) Session::get(Config::get('chocolatey.security.session')); |
|
| 125 | + return (bool)Session::get(Config::get('chocolatey.security.session')); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -1,44 +1,44 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Helpers; |
|
| 3 | + namespace App\Helpers; |
|
| 4 | 4 | |
| 5 | -use App\Facades\Session; |
|
| 6 | -use App\Models\ChocolateyId; |
|
| 7 | -use App\Models\User as UserModel; |
|
| 8 | -use App\Singleton; |
|
| 9 | -use Illuminate\Http\Request; |
|
| 10 | -use Illuminate\Support\Facades\Config; |
|
| 5 | + use App\Facades\Session; |
|
| 6 | + use App\Models\ChocolateyId; |
|
| 7 | + use App\Models\User as UserModel; |
|
| 8 | + use App\Singleton; |
|
| 9 | + use Illuminate\Http\Request; |
|
| 10 | + use Illuminate\Support\Facades\Config; |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * Class User. |
| 14 | 14 | */ |
| 15 | -final class User extends Singleton |
|
| 16 | -{ |
|
| 17 | - /** |
|
| 15 | + final class User extends Singleton |
|
| 16 | + { |
|
| 17 | + /** |
|
| 18 | 18 | * Update User Data without overwriting Session. |
| 19 | 19 | * |
| 20 | 20 | * @param array $parameters |
| 21 | 21 | * |
| 22 | 22 | * @return UserModel |
| 23 | 23 | */ |
| 24 | - public function updateSession(array $parameters) |
|
| 25 | - { |
|
| 26 | - return $this->setSession($this->updateUser($this->getUser(), $parameters)); |
|
| 27 | - } |
|
| 24 | + public function updateSession(array $parameters) |
|
| 25 | + { |
|
| 26 | + return $this->setSession($this->updateUser($this->getUser(), $parameters)); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 29 | + /** |
|
| 30 | 30 | * Set User Data on Session. |
| 31 | 31 | * |
| 32 | 32 | * @param UserModel $user |
| 33 | 33 | * |
| 34 | 34 | * @return UserModel |
| 35 | 35 | */ |
| 36 | - public function setSession(UserModel $user) |
|
| 37 | - { |
|
| 38 | - return Session::set(Config::get('chocolatey.security.session'), $user); |
|
| 39 | - } |
|
| 36 | + public function setSession(UserModel $user) |
|
| 37 | + { |
|
| 38 | + return Session::set(Config::get('chocolatey.security.session'), $user); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 41 | + /** |
|
| 42 | 42 | * Update User Data by User Model. |
| 43 | 43 | * |
| 44 | 44 | * @param UserModel $user |
@@ -46,25 +46,25 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return UserModel |
| 48 | 48 | */ |
| 49 | - public function updateUser($user, array $parameters) |
|
| 50 | - { |
|
| 51 | - $user->update($parameters); |
|
| 49 | + public function updateUser($user, array $parameters) |
|
| 50 | + { |
|
| 51 | + $user->update($parameters); |
|
| 52 | 52 | |
| 53 | - return $user; |
|
| 54 | - } |
|
| 53 | + return $user; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 56 | + /** |
|
| 57 | 57 | * Get User Data from Session |
| 58 | 58 | * If User Session doesn't exists, return null. |
| 59 | 59 | * |
| 60 | 60 | * @return UserModel|null |
| 61 | 61 | */ |
| 62 | - public function getUser() |
|
| 63 | - { |
|
| 64 | - return Session::get(Config::get('chocolatey.security.session')) ?? null; |
|
| 65 | - } |
|
| 62 | + public function getUser() |
|
| 63 | + { |
|
| 64 | + return Session::get(Config::get('chocolatey.security.session')) ?? null; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 67 | + /** |
|
| 68 | 68 | * Retrieve Non Banned Users (If all Users are Banned, return the Banned user Also). |
| 69 | 69 | * |
| 70 | 70 | * @param Request $request |
@@ -72,20 +72,20 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return UserModel |
| 74 | 74 | */ |
| 75 | - private function checkForBanAlternative(Request $request, ChocolateyId $chocolateyId) |
|
| 76 | - { |
|
| 77 | - $temporaryUsers = UserModel::where('mail', $request->json()->get('email'))->get(); |
|
| 75 | + private function checkForBanAlternative(Request $request, ChocolateyId $chocolateyId) |
|
| 76 | + { |
|
| 77 | + $temporaryUsers = UserModel::where('mail', $request->json()->get('email'))->get(); |
|
| 78 | 78 | |
| 79 | - foreach ($temporaryUsers as $forUser) { |
|
| 80 | - if (!$forUser->isBanned) { |
|
| 81 | - return $forUser; |
|
| 82 | - } |
|
| 83 | - } |
|
| 79 | + foreach ($temporaryUsers as $forUser) { |
|
| 80 | + if (!$forUser->isBanned) { |
|
| 81 | + return $forUser; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - return $temporaryUsers->get(0); |
|
| 86 | - } |
|
| 85 | + return $temporaryUsers->get(0); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 88 | + /** |
|
| 89 | 89 | * Get Users. |
| 90 | 90 | * |
| 91 | 91 | * @param Request $request |
@@ -93,65 +93,65 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @return UserModel |
| 95 | 95 | */ |
| 96 | - private function retrieveUser(Request $request, ChocolateyId $chocolateyId) |
|
| 97 | - { |
|
| 98 | - if ($chocolateyId->last_logged_id != 0) { |
|
| 99 | - $temporaryUser = UserModel::find($chocolateyId->last_logged_id); |
|
| 96 | + private function retrieveUser(Request $request, ChocolateyId $chocolateyId) |
|
| 97 | + { |
|
| 98 | + if ($chocolateyId->last_logged_id != 0) { |
|
| 99 | + $temporaryUser = UserModel::find($chocolateyId->last_logged_id); |
|
| 100 | 100 | |
| 101 | - if ($temporaryUser->isBanned) { |
|
| 102 | - return $this->checkForBanAlternative($request, $chocolateyId); |
|
| 103 | - } |
|
| 101 | + if ($temporaryUser->isBanned) { |
|
| 102 | + return $this->checkForBanAlternative($request, $chocolateyId); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - return $temporaryUser; |
|
| 106 | - } |
|
| 105 | + return $temporaryUser; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - $temporaryUser = UserModel::where('mail', $request->json()->get('email'))->first(); |
|
| 108 | + $temporaryUser = UserModel::where('mail', $request->json()->get('email'))->first(); |
|
| 109 | 109 | |
| 110 | - if ($temporaryUser->isBanned) { |
|
| 111 | - return $this->checkForBanAlternative($request, $chocolateyId); |
|
| 112 | - } |
|
| 110 | + if ($temporaryUser->isBanned) { |
|
| 111 | + return $this->checkForBanAlternative($request, $chocolateyId); |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - return $temporaryUser; |
|
| 115 | - } |
|
| 114 | + return $temporaryUser; |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - /** |
|
| 117 | + /** |
|
| 118 | 118 | * Set Session From Login Credentials. |
| 119 | 119 | * |
| 120 | 120 | * @param Request $request |
| 121 | 121 | * |
| 122 | 122 | * @return UserModel |
| 123 | 123 | */ |
| 124 | - public function loginUser(Request $request) |
|
| 125 | - { |
|
| 126 | - $chocolateyId = ChocolateyId::find($request->json()->get('email')); |
|
| 124 | + public function loginUser(Request $request) |
|
| 125 | + { |
|
| 126 | + $chocolateyId = ChocolateyId::find($request->json()->get('email')); |
|
| 127 | 127 | |
| 128 | - if ($chocolateyId == null) { |
|
| 129 | - return; |
|
| 130 | - } |
|
| 128 | + if ($chocolateyId == null) { |
|
| 129 | + return; |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - $user = $this->retrieveUser($request, $chocolateyId); |
|
| 132 | + $user = $this->retrieveUser($request, $chocolateyId); |
|
| 133 | 133 | |
| 134 | - $chocolateyId->last_logged_id = $user->uniqueId; |
|
| 134 | + $chocolateyId->last_logged_id = $user->uniqueId; |
|
| 135 | 135 | |
| 136 | - return $chocolateyId->password == hash(Config::get('chocolatey.security.hash'), $request->json()->get('password')) |
|
| 137 | - ? $this->setSession($user) : null; |
|
| 138 | - } |
|
| 136 | + return $chocolateyId->password == hash(Config::get('chocolatey.security.hash'), $request->json()->get('password')) |
|
| 137 | + ? $this->setSession($user) : null; |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - /** |
|
| 140 | + /** |
|
| 141 | 141 | * Return if USer Session Exists. |
| 142 | 142 | * |
| 143 | 143 | * @return bool |
| 144 | 144 | */ |
| 145 | - public function hasSession() |
|
| 146 | - { |
|
| 147 | - return (bool) Session::get(Config::get('chocolatey.security.session')); |
|
| 148 | - } |
|
| 145 | + public function hasSession() |
|
| 146 | + { |
|
| 147 | + return (bool) Session::get(Config::get('chocolatey.security.session')); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /** |
|
| 150 | + /** |
|
| 151 | 151 | * Erase User Session. |
| 152 | 152 | */ |
| 153 | - public function eraseSession() |
|
| 154 | - { |
|
| 155 | - Session::erase(Config::get('chocolatey.security.session')); |
|
| 156 | - } |
|
| 153 | + public function eraseSession() |
|
| 154 | + { |
|
| 155 | + Session::erase(Config::get('chocolatey.security.session')); |
|
| 156 | + } |
|
| 157 | 157 | } |
@@ -1,30 +1,30 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Class FlatCat. |
| 7 | 7 | */ |
| 8 | -class FlatCat extends ChocolateyModel |
|
| 9 | -{ |
|
| 10 | - /** |
|
| 8 | + class FlatCat extends ChocolateyModel |
|
| 9 | + { |
|
| 10 | + /** |
|
| 11 | 11 | * Disable Timestamps. |
| 12 | 12 | * |
| 13 | 13 | * @var bool |
| 14 | 14 | */ |
| 15 | - public $timestamps = false; |
|
| 15 | + public $timestamps = false; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * The table associated with the model. |
| 19 | 19 | * |
| 20 | 20 | * @var string |
| 21 | 21 | */ |
| 22 | - protected $table = 'navigator_flatcats'; |
|
| 22 | + protected $table = 'navigator_flatcats'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | + /** |
|
| 25 | 25 | * Primary Key of the Table. |
| 26 | 26 | * |
| 27 | 27 | * @var string |
| 28 | 28 | */ |
| 29 | - protected $primaryKey = 'id'; |
|
| 29 | + protected $primaryKey = 'id'; |
|
| 30 | 30 | } |
@@ -1,85 +1,85 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Class ShopInventory. |
| 7 | 7 | */ |
| 8 | -class ShopInventory |
|
| 9 | -{ |
|
| 10 | - /** |
|
| 8 | + class ShopInventory |
|
| 9 | + { |
|
| 10 | + /** |
|
| 11 | 11 | * Payment Categories of the Country. |
| 12 | 12 | * |
| 13 | 13 | * @var PaymentCategory[] |
| 14 | 14 | */ |
| 15 | - public $paymentCategories = []; |
|
| 15 | + public $paymentCategories = []; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * Inventory Items. |
| 19 | 19 | * |
| 20 | 20 | * @var array |
| 21 | 21 | */ |
| 22 | - public $pricePoints = []; |
|
| 22 | + public $pricePoints = []; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | + /** |
|
| 25 | 25 | * If double Credits are Enabled. |
| 26 | 26 | * |
| 27 | 27 | * @var bool |
| 28 | 28 | */ |
| 29 | - public $doubleCredits = false; |
|
| 29 | + public $doubleCredits = false; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | + /** |
|
| 32 | 32 | * Country Meta Data. |
| 33 | 33 | * |
| 34 | 34 | * @var Country |
| 35 | 35 | */ |
| 36 | - public $country = null; |
|
| 36 | + public $country = null; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | + /** |
|
| 39 | 39 | * Create a Shop Inventory. |
| 40 | 40 | * |
| 41 | 41 | * @param Country $country |
| 42 | 42 | */ |
| 43 | - public function __construct(Country $country) |
|
| 44 | - { |
|
| 45 | - $this->setCountry($country); |
|
| 46 | - $this->setPaymentCategories($country->countryCode); |
|
| 47 | - $this->setPricePoints($country->countryCode); |
|
| 48 | - } |
|
| 43 | + public function __construct(Country $country) |
|
| 44 | + { |
|
| 45 | + $this->setCountry($country); |
|
| 46 | + $this->setPaymentCategories($country->countryCode); |
|
| 47 | + $this->setPricePoints($country->countryCode); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 50 | + /** |
|
| 51 | 51 | * Set the Country Metadata. |
| 52 | 52 | * |
| 53 | 53 | * @param Country $country |
| 54 | 54 | */ |
| 55 | - public function setCountry(Country $country) |
|
| 56 | - { |
|
| 57 | - $this->country = $country; |
|
| 58 | - } |
|
| 55 | + public function setCountry(Country $country) |
|
| 56 | + { |
|
| 57 | + $this->country = $country; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 60 | + /** |
|
| 61 | 61 | * Set the Payment Methods. |
| 62 | 62 | * |
| 63 | 63 | * @param string $countryCode |
| 64 | 64 | */ |
| 65 | - public function setPaymentCategories(string $countryCode) |
|
| 66 | - { |
|
| 67 | - $paymentMethods = []; |
|
| 65 | + public function setPaymentCategories(string $countryCode) |
|
| 66 | + { |
|
| 67 | + $paymentMethods = []; |
|
| 68 | 68 | |
| 69 | - foreach (PaymentCategory::where('country_code', $countryCode)->get(['payment_type']) as $paymentMethod) { |
|
| 70 | - $paymentMethods[] = $paymentMethod->payment_type; |
|
| 71 | - } |
|
| 69 | + foreach (PaymentCategory::where('country_code', $countryCode)->get(['payment_type']) as $paymentMethod) { |
|
| 70 | + $paymentMethods[] = $paymentMethod->payment_type; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - $this->paymentCategories = $paymentMethods; |
|
| 74 | - } |
|
| 73 | + $this->paymentCategories = $paymentMethods; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 76 | + /** |
|
| 77 | 77 | * Get All Shop Items from this Country Code. |
| 78 | 78 | * |
| 79 | 79 | * @param string $countryCode |
| 80 | 80 | */ |
| 81 | - public function setPricePoints(string $countryCode) |
|
| 82 | - { |
|
| 83 | - $this->pricePoints = ShopItem::where('countryCode', $countryCode)->get(); |
|
| 84 | - } |
|
| 81 | + public function setPricePoints(string $countryCode) |
|
| 82 | + { |
|
| 83 | + $this->pricePoints = ShopItem::where('countryCode', $countryCode)->get(); |
|
| 84 | + } |
|
| 85 | 85 | } |
@@ -1,109 +1,109 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Class UserProfile. |
| 7 | 7 | */ |
| 8 | -class UserProfile |
|
| 9 | -{ |
|
| 10 | - /** |
|
| 8 | + class UserProfile |
|
| 9 | + { |
|
| 10 | + /** |
|
| 11 | 11 | * User Data. |
| 12 | 12 | * |
| 13 | 13 | * @var User |
| 14 | 14 | */ |
| 15 | - public $user; |
|
| 15 | + public $user; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * User Friends. |
| 19 | 19 | * |
| 20 | 20 | * @var UserFriend[]|array |
| 21 | 21 | */ |
| 22 | - public $friends = []; |
|
| 22 | + public $friends = []; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | + /** |
|
| 25 | 25 | * User Badges. |
| 26 | 26 | * |
| 27 | 27 | * @var UserBadge[]|array |
| 28 | 28 | */ |
| 29 | - public $badges = []; |
|
| 29 | + public $badges = []; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | + /** |
|
| 32 | 32 | * User Groups. |
| 33 | 33 | * |
| 34 | 34 | * @var UserGroup[]|array |
| 35 | 35 | */ |
| 36 | - public $groups = []; |
|
| 36 | + public $groups = []; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | + /** |
|
| 39 | 39 | * User Rooms. |
| 40 | 40 | * |
| 41 | 41 | * @var Room[]|array |
| 42 | 42 | */ |
| 43 | - public $rooms = []; |
|
| 43 | + public $rooms = []; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 45 | + /** |
|
| 46 | 46 | * UserProfile constructor. |
| 47 | 47 | * |
| 48 | 48 | * @param User $userData |
| 49 | 49 | * |
| 50 | 50 | * @return UserProfile |
| 51 | 51 | */ |
| 52 | - public function __construct(User $userData) |
|
| 53 | - { |
|
| 54 | - $this->setUser($userData); |
|
| 52 | + public function __construct(User $userData) |
|
| 53 | + { |
|
| 54 | + $this->setUser($userData); |
|
| 55 | 55 | |
| 56 | - $this->setFriends(); |
|
| 57 | - $this->setBadges(); |
|
| 58 | - $this->setGroups(); |
|
| 59 | - $this->setRooms(); |
|
| 56 | + $this->setFriends(); |
|
| 57 | + $this->setBadges(); |
|
| 58 | + $this->setGroups(); |
|
| 59 | + $this->setRooms(); |
|
| 60 | 60 | |
| 61 | - return $this; |
|
| 62 | - } |
|
| 61 | + return $this; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 64 | + /** |
|
| 65 | 65 | * Set User Data. |
| 66 | 66 | * |
| 67 | 67 | * @param User $userData |
| 68 | 68 | */ |
| 69 | - protected function setUser(User $userData) |
|
| 70 | - { |
|
| 71 | - $this->user = $userData; |
|
| 72 | - } |
|
| 69 | + protected function setUser(User $userData) |
|
| 70 | + { |
|
| 71 | + $this->user = $userData; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 74 | + /** |
|
| 75 | 75 | * Set User Friends. |
| 76 | 76 | */ |
| 77 | - protected function setFriends() |
|
| 78 | - { |
|
| 79 | - $this->friends = UserFriend::where('user_one_id', $this->user->uniqueId)->get() ?? []; |
|
| 80 | - } |
|
| 77 | + protected function setFriends() |
|
| 78 | + { |
|
| 79 | + $this->friends = UserFriend::where('user_one_id', $this->user->uniqueId)->get() ?? []; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 82 | + /** |
|
| 83 | 83 | * Set User Badges. |
| 84 | 84 | */ |
| 85 | - protected function setBadges() |
|
| 86 | - { |
|
| 87 | - $this->badges = UserBadge::where('user_id', $this->user->uniqueId)->get() ?? []; |
|
| 88 | - } |
|
| 85 | + protected function setBadges() |
|
| 86 | + { |
|
| 87 | + $this->badges = UserBadge::where('user_id', $this->user->uniqueId)->get() ?? []; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 90 | + /** |
|
| 91 | 91 | * Set User Groups. |
| 92 | 92 | */ |
| 93 | - protected function setGroups() |
|
| 94 | - { |
|
| 95 | - $groups = GroupMember::where('user_id', $this->user->uniqueId)->get() ?? []; |
|
| 93 | + protected function setGroups() |
|
| 94 | + { |
|
| 95 | + $groups = GroupMember::where('user_id', $this->user->uniqueId)->get() ?? []; |
|
| 96 | 96 | |
| 97 | - foreach ($groups as $group) { |
|
| 98 | - $this->groups[] = $group->guild; |
|
| 99 | - } |
|
| 100 | - } |
|
| 97 | + foreach ($groups as $group) { |
|
| 98 | + $this->groups[] = $group->guild; |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 102 | + /** |
|
| 103 | 103 | * Set User Rooms. |
| 104 | 104 | */ |
| 105 | - public function setRooms() |
|
| 106 | - { |
|
| 107 | - $this->rooms = Room::where('owner_id', $this->user->uniqueId)->where('state', '!=', 'invisible')->get() ?? []; |
|
| 108 | - } |
|
| 105 | + public function setRooms() |
|
| 106 | + { |
|
| 107 | + $this->rooms = Room::where('owner_id', $this->user->uniqueId)->where('state', '!=', 'invisible')->get() ?? []; |
|
| 108 | + } |
|
| 109 | 109 | } |
@@ -1,61 +1,61 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Class Purse. |
| 7 | 7 | */ |
| 8 | -class Purse |
|
| 9 | -{ |
|
| 10 | - /** |
|
| 8 | + class Purse |
|
| 9 | + { |
|
| 10 | + /** |
|
| 11 | 11 | * User Credits Balance. |
| 12 | 12 | * |
| 13 | 13 | * @var int |
| 14 | 14 | */ |
| 15 | - public $creditBalance = 0; |
|
| 15 | + public $creditBalance = 0; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * User Builders Club Furniture Limit. |
| 19 | 19 | * |
| 20 | 20 | * @var int |
| 21 | 21 | */ |
| 22 | - public $buildersClubFurniLimit = 0; |
|
| 22 | + public $buildersClubFurniLimit = 0; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | + /** |
|
| 25 | 25 | * Remaining Builders Club Days. |
| 26 | 26 | * |
| 27 | 27 | * @var int |
| 28 | 28 | */ |
| 29 | - public $buildersClubDays = 0; |
|
| 29 | + public $buildersClubDays = 0; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | + /** |
|
| 32 | 32 | * User Habbo Club Days. |
| 33 | 33 | * |
| 34 | 34 | * @var int |
| 35 | 35 | */ |
| 36 | - public $habboClubDays = 0; |
|
| 36 | + public $habboClubDays = 0; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | + /** |
|
| 39 | 39 | * User Diamond Balance. |
| 40 | 40 | * |
| 41 | 41 | * @var int |
| 42 | 42 | */ |
| 43 | - public $diamondBalance = 0; |
|
| 43 | + public $diamondBalance = 0; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 45 | + /** |
|
| 46 | 46 | * Create an User Purse. |
| 47 | 47 | * |
| 48 | 48 | * @TODO: Get User Left Habbo Club Days |
| 49 | 49 | * |
| 50 | 50 | * @param int $userId |
| 51 | 51 | */ |
| 52 | - public function __construct(int $userId) |
|
| 53 | - { |
|
| 54 | - $userDiamonds = UserCurrency::where('user_id', $userId)->where('type', 5)->first(); |
|
| 55 | - $habboDays = floor(((UserSettings::where('user_id', $userId)->first()->club_expire_timestamp ?? 0) - time()) / 86400); |
|
| 56 | - |
|
| 57 | - $this->creditBalance = User::find($userId)->credits; |
|
| 58 | - $this->diamondBalance = $userDiamonds->amount ?? 0; |
|
| 59 | - $this->habboClubDays = $habboDays > 0 ? $habboDays : 0; |
|
| 60 | - } |
|
| 52 | + public function __construct(int $userId) |
|
| 53 | + { |
|
| 54 | + $userDiamonds = UserCurrency::where('user_id', $userId)->where('type', 5)->first(); |
|
| 55 | + $habboDays = floor(((UserSettings::where('user_id', $userId)->first()->club_expire_timestamp ?? 0) - time()) / 86400); |
|
| 56 | + |
|
| 57 | + $this->creditBalance = User::find($userId)->credits; |
|
| 58 | + $this->diamondBalance = $userDiamonds->amount ?? 0; |
|
| 59 | + $this->habboClubDays = $habboDays > 0 ? $habboDays : 0; |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -1,35 +1,35 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Class Question. |
| 7 | 7 | */ |
| 8 | -class Question |
|
| 9 | -{ |
|
| 10 | - /** |
|
| 8 | + class Question |
|
| 9 | + { |
|
| 10 | + /** |
|
| 11 | 11 | * Question Identifier (One or Two). |
| 12 | 12 | * |
| 13 | 13 | * @var int |
| 14 | 14 | */ |
| 15 | - public $questionId = 1; |
|
| 15 | + public $questionId = 1; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * Question Key (Translate Text). |
| 19 | 19 | * |
| 20 | 20 | * @var string |
| 21 | 21 | */ |
| 22 | - public $questionKey = ''; |
|
| 22 | + public $questionKey = ''; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | + /** |
|
| 25 | 25 | * Store a Question. |
| 26 | 26 | * |
| 27 | 27 | * @param int $questionId |
| 28 | 28 | * @param string $questionKey |
| 29 | 29 | */ |
| 30 | - public function __construct(int $questionId, string $questionKey) |
|
| 31 | - { |
|
| 32 | - $this->questionId = $questionId; |
|
| 33 | - $this->questionKey = $questionKey; |
|
| 34 | - } |
|
| 30 | + public function __construct(int $questionId, string $questionKey) |
|
| 31 | + { |
|
| 32 | + $this->questionId = $questionId; |
|
| 33 | + $this->questionKey = $questionKey; |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -1,26 +1,26 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Http\Controllers; |
|
| 3 | + namespace App\Http\Controllers; |
|
| 4 | 4 | |
| 5 | -use Illuminate\Http\Response; |
|
| 6 | -use Laravel\Lumen\Routing\Controller as BaseController; |
|
| 5 | + use Illuminate\Http\Response; |
|
| 6 | + use Laravel\Lumen\Routing\Controller as BaseController; |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Class LanguageController. |
| 10 | 10 | */ |
| 11 | -class LanguageController extends BaseController |
|
| 12 | -{ |
|
| 13 | - /** |
|
| 11 | + class LanguageController extends BaseController |
|
| 12 | + { |
|
| 13 | + /** |
|
| 14 | 14 | * Render Language View (jSON). |
| 15 | 15 | * |
| 16 | 16 | * @param $languageFile |
| 17 | 17 | * |
| 18 | 18 | * @return Response |
| 19 | 19 | */ |
| 20 | - public function render($languageFile): Response |
|
| 21 | - { |
|
| 22 | - $languageName = strstr($languageFile, '.json', true); |
|
| 20 | + public function render($languageFile): Response |
|
| 21 | + { |
|
| 22 | + $languageName = strstr($languageFile, '.json', true); |
|
| 23 | 23 | |
| 24 | - return response(view("habbo-web-l10n.{$languageName}"))->header('Content-Type', 'application/json'); |
|
| 25 | - } |
|
| 24 | + return response(view("habbo-web-l10n.{$languageName}"))->header('Content-Type', 'application/json'); |
|
| 25 | + } |
|
| 26 | 26 | } |