diff --git a/.gitignore b/.gitignore index ba85e71ad..4a264e1e1 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,7 @@ test.php *.orig /.idea/ -/app/libraries/* +/app/Libraries/* /app/resources/tmp/* /nntmux/config/settings.php /nntmux/config/ircscraper_settings.php diff --git a/Changelog b/Changelog index 6519b3122..cf4140e0e 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ -2017-17-16 DariusIII +2017-07-17 DariusIII + * Chg: Change folder names in app to upper case first letter * Chg: Replace app with App in classes used * Chg: Update composer.lock 2017-07-14 DariusIII diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php new file mode 100644 index 000000000..622e774b3 --- /dev/null +++ b/app/Console/Kernel.php @@ -0,0 +1,40 @@ +command('inspire') + // ->hourly(); + } + + /** + * Register the Closure based commands for the application. + * + * @return void + */ + protected function commands() + { + require base_path('routes/console.php'); + } +} diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php new file mode 100644 index 000000000..a747e31b8 --- /dev/null +++ b/app/Exceptions/Handler.php @@ -0,0 +1,65 @@ +expectsJson()) { + return response()->json(['error' => 'Unauthenticated.'], 401); + } + + return redirect()->guest(route('login')); + } +} diff --git a/app/extensions/command/Update.php b/app/Extensions/command/Update.php similarity index 100% rename from app/extensions/command/Update.php rename to app/Extensions/command/Update.php diff --git a/app/extensions/command/Verify.php b/app/Extensions/command/Verify.php similarity index 98% rename from app/extensions/command/Verify.php rename to app/Extensions/command/Verify.php index f5d93535c..f4e979cf8 100644 --- a/app/extensions/command/Verify.php +++ b/app/Extensions/command/Verify.php @@ -19,7 +19,7 @@ namespace App\extensions\command; use App\extensions\console\Command; -use App\models\Settings; +use App\Models\Settings; /** diff --git a/app/extensions/command/Version.php b/app/Extensions/command/Version.php similarity index 100% rename from app/extensions/command/Version.php rename to app/Extensions/command/Version.php diff --git a/app/extensions/command/empty b/app/Extensions/command/empty similarity index 100% rename from app/extensions/command/empty rename to app/Extensions/command/empty diff --git a/app/extensions/console/Command.php b/app/Extensions/console/Command.php similarity index 77% rename from app/extensions/console/Command.php rename to app/Extensions/console/Command.php index 9e99334d3..7fce36e5e 100755 --- a/app/extensions/console/Command.php +++ b/app/Extensions/console/Command.php @@ -16,13 +16,15 @@ * * @link . * @author niel - * @copyright 2014 nZEDb + * @edited by DariusIII + * @copyright 2014 nZEDb, 2017 NNTmux */ namespace App\extensions\console; use Symfony\Component\Console\Output\ConsoleOutput; +use Illuminate\Console\Command as LaravelCommand; -class Command extends \Illuminate\Console\Command +class Command extends LaravelCommand { /** * Command constructor. @@ -36,7 +38,11 @@ class Command extends \Illuminate\Console\Command $this->output = new ConsoleOutput(); } - public function info($text, $verbosity = null) + /** + * @param string $text + * @param null $verbosity + */ + public function info($text, $verbosity = null): void { if ($this->output->isQuiet()) { return; @@ -44,6 +50,9 @@ class Command extends \Illuminate\Console\Command $this->output->writeln('' . $text . '', $verbosity); } + /** + * @param $text + */ public function primary($text) { if ($this->output->isQuiet()) { @@ -52,7 +61,11 @@ class Command extends \Illuminate\Console\Command $this->output->writeln('' . $text . ''); } - public function error($text, $verbosity = null) + /** + * @param string $text + * @param null $verbosity + */ + public function error($text, $verbosity = null): void { if ($this->output->isQuiet()) { return; diff --git a/app/extensions/helper/empty b/app/Extensions/helper/empty similarity index 100% rename from app/extensions/helper/empty rename to app/Extensions/helper/empty diff --git a/app/extensions/helper/helpers.php b/app/Extensions/helper/helpers.php similarity index 100% rename from app/extensions/helper/helpers.php rename to app/Extensions/helper/helpers.php diff --git a/app/extensions/util/Git.php b/app/Extensions/util/Git.php similarity index 100% rename from app/extensions/util/Git.php rename to app/Extensions/util/Git.php diff --git a/app/extensions/util/Versions.php b/app/Extensions/util/Versions.php similarity index 99% rename from app/extensions/util/Versions.php rename to app/Extensions/util/Versions.php index d6b25c3a3..81ce3b181 100644 --- a/app/extensions/util/Versions.php +++ b/app/Extensions/util/Versions.php @@ -18,7 +18,7 @@ */ namespace App\extensions\util; -use App\models\Settings; +use App\Models\Settings; use Illuminate\Database\Eloquent\Collection; use nntmux\utility\Utility; diff --git a/app/extensions/util/Yenc.php b/app/Extensions/util/Yenc.php similarity index 100% rename from app/extensions/util/Yenc.php rename to app/Extensions/util/Yenc.php diff --git a/app/extensions/util/yenc/adapter/NzedbYenc.php b/app/Extensions/util/yenc/adapter/NzedbYenc.php similarity index 100% rename from app/extensions/util/yenc/adapter/NzedbYenc.php rename to app/Extensions/util/yenc/adapter/NzedbYenc.php diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php new file mode 100644 index 000000000..6a247fefd --- /dev/null +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -0,0 +1,32 @@ +middleware('guest'); + } +} diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php new file mode 100644 index 000000000..b2ea669a0 --- /dev/null +++ b/app/Http/Controllers/Auth/LoginController.php @@ -0,0 +1,39 @@ +middleware('guest')->except('logout'); + } +} diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php new file mode 100644 index 000000000..ed8d1b774 --- /dev/null +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -0,0 +1,71 @@ +middleware('guest'); + } + + /** + * Get a validator for an incoming registration request. + * + * @param array $data + * @return \Illuminate\Contracts\Validation\Validator + */ + protected function validator(array $data) + { + return Validator::make($data, [ + 'name' => 'required|string|max:255', + 'email' => 'required|string|email|max:255|unique:users', + 'password' => 'required|string|min:6|confirmed', + ]); + } + + /** + * Create a new user instance after a valid registration. + * + * @param array $data + * @return User + */ + protected function create(array $data) + { + return User::create([ + 'name' => $data['name'], + 'email' => $data['email'], + 'password' => bcrypt($data['password']), + ]); + } +} diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php new file mode 100644 index 000000000..cf726eecd --- /dev/null +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -0,0 +1,39 @@ +middleware('guest'); + } +} diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php new file mode 100644 index 000000000..03e02a23e --- /dev/null +++ b/app/Http/Controllers/Controller.php @@ -0,0 +1,13 @@ + [ + \App\Http\Middleware\EncryptCookies::class, + \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, + \Illuminate\Session\Middleware\StartSession::class, + // \Illuminate\Session\Middleware\AuthenticateSession::class, + \Illuminate\View\Middleware\ShareErrorsFromSession::class, + \App\Http\Middleware\VerifyCsrfToken::class, + \Illuminate\Routing\Middleware\SubstituteBindings::class, + ], + + 'api' => [ + 'throttle:60,1', + 'bindings', + ], + ]; + + /** + * The application's route middleware. + * + * These middleware may be assigned to groups or used individually. + * + * @var array + */ + protected $routeMiddleware = [ + 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, + 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, + 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, + 'can' => \Illuminate\Auth\Middleware\Authorize::class, + 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, + ]; +} diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php new file mode 100644 index 000000000..3aa15f8dd --- /dev/null +++ b/app/Http/Middleware/EncryptCookies.php @@ -0,0 +1,17 @@ +check()) { + return redirect('/home'); + } + + return $next($request); + } +} diff --git a/app/Http/Middleware/TrimStrings.php b/app/Http/Middleware/TrimStrings.php new file mode 100644 index 000000000..943e9a4da --- /dev/null +++ b/app/Http/Middleware/TrimStrings.php @@ -0,0 +1,18 @@ + 'App\Policies\ModelPolicy', + ]; + + /** + * Register any authentication / authorization services. + * + * @return void + */ + public function boot() + { + $this->registerPolicies(); + + // + } +} diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php new file mode 100644 index 000000000..352cce44a --- /dev/null +++ b/app/Providers/BroadcastServiceProvider.php @@ -0,0 +1,21 @@ + [ + 'App\Listeners\EventListener', + ], + ]; + + /** + * Register any events for your application. + * + * @return void + */ + public function boot() + { + parent::boot(); + + // + } +} diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php new file mode 100644 index 000000000..5ea48d39d --- /dev/null +++ b/app/Providers/RouteServiceProvider.php @@ -0,0 +1,73 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + + // + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + * + * @return void + */ + protected function mapWebRoutes() + { + Route::middleware('web') + ->namespace($this->namespace) + ->group(base_path('routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + * + * @return void + */ + protected function mapApiRoutes() + { + Route::prefix('api') + ->middleware('api') + ->namespace($this->namespace) + ->group(base_path('routes/api.php')); + } +} diff --git a/artisan b/artisan new file mode 100755 index 000000000..44dc07b0e --- /dev/null +++ b/artisan @@ -0,0 +1,51 @@ +#!/usr/bin/env php +make(Illuminate\Contracts\Console\Kernel::class); + +$status = $kernel->handle( + $input = new Symfony\Component\Console\Input\ArgvInput, + new Symfony\Component\Console\Output\ConsoleOutput +); + +/* +|-------------------------------------------------------------------------- +| Shutdown The Application +|-------------------------------------------------------------------------- +| +| Once Artisan has finished running, we will fire off the shutdown events +| so that any final work may be done by the application before we shut +| down the process. This is the last thing to happen to the request. +| +*/ + +$kernel->terminate($input, $status); + +exit($status); diff --git a/bootstrap/app.php b/bootstrap/app.php new file mode 100644 index 000000000..f2801adf6 --- /dev/null +++ b/bootstrap/app.php @@ -0,0 +1,55 @@ +singleton( + Illuminate\Contracts\Http\Kernel::class, + App\Http\Kernel::class +); + +$app->singleton( + Illuminate\Contracts\Console\Kernel::class, + App\Console\Kernel::class +); + +$app->singleton( + Illuminate\Contracts\Debug\ExceptionHandler::class, + App\Exceptions\Handler::class +); + +/* +|-------------------------------------------------------------------------- +| Return The Application +|-------------------------------------------------------------------------- +| +| This script returns the application instance. The instance is given to +| the calling script so we can separate the building of the instances +| from the actual running of the application and sending responses. +| +*/ + +return $app; diff --git a/bootstrap/bootstrap.php b/bootstrap/bootstrap.php index bb15e9d69..ea9def729 100644 --- a/bootstrap/bootstrap.php +++ b/bootstrap/bootstrap.php @@ -10,4 +10,4 @@ if (!defined('NN_ROOT')) { define('NN_ROOT', dirname(NN_APP_PATH, 2)); } -require_once NN_APP_PATH . DS . 'libraries' . DS . 'autoload.php'; +require_once NN_APP_PATH . DS . 'Libraries' . DS . 'autoload.php'; diff --git a/bootstrap/cache/.gitignore b/bootstrap/cache/.gitignore new file mode 100644 index 000000000..d6b7ef32c --- /dev/null +++ b/bootstrap/cache/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/composer.json b/composer.json index 1f6f7d2b3..04772a8ef 100755 --- a/composer.json +++ b/composer.json @@ -6,8 +6,8 @@ ], "autoload": { "files": [ - "app/libraries/laravel/framework/src/Illuminate/Support/helpers.php", - "app/extensions/helper/helpers.php" + "app/Libraries/laravel/framework/src/Illuminate/Support/helpers.php", + "app/Extensions/helper/helpers.php" ], "psr-4": { "nntmux\\": "nntmux/", @@ -24,13 +24,15 @@ "preferred-install": { "*": "source" }, + "sort-packages": true, + "optimize-autoloader": true, "fxp-asset" : { "installer-paths": { "npm-asset-library": "www/themes/shared/assets", "bower-asset-library": "www/themes/shared/assets" } }, - "vendor-dir": "app/libraries" + "vendor-dir": "app/Libraries" }, "description": "A Usenet Indexer", "extra": { @@ -140,6 +142,12 @@ }, "scripts": { + "post-install-cmd": [ + "Illuminate\\Foundation\\ComposerScripts::postInstall" + ], + "post-update-cmd": [ + "Illuminate\\Foundation\\ComposerScripts::postUpdate" + ] }, "suggest": { "ext-xdebug": "For developement work", diff --git a/configuration/database.php b/configuration/database.php index 31cee1182..577f07802 100644 --- a/configuration/database.php +++ b/configuration/database.php @@ -1,5 +1,5 @@ require_once dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'bootstrap.php'; -use App\models\Settings; +use App\Models\Settings; use nntmux\db\DB; use nntmux\NZB; diff --git a/misc/update/nix/multiprocessing/.do_not_run/switch.php b/misc/update/nix/multiprocessing/.do_not_run/switch.php index f7020ef54..81d0cdcfc 100644 --- a/misc/update/nix/multiprocessing/.do_not_run/switch.php +++ b/misc/update/nix/multiprocessing/.do_not_run/switch.php @@ -6,7 +6,7 @@ if (!isset($argv[1])) { require_once dirname(__DIR__, 5) . DIRECTORY_SEPARATOR . 'bootstrap.php'; -use App\models\Settings; +use App\Models\Settings; use \nntmux\db\DB; use \nntmux\processing\PostProcess; use \nntmux\processing\ProcessReleases; diff --git a/misc/update/nix/tmux/bin/groupfixrelnames.php b/misc/update/nix/tmux/bin/groupfixrelnames.php index 247776c3d..77228bef3 100644 --- a/misc/update/nix/tmux/bin/groupfixrelnames.php +++ b/misc/update/nix/tmux/bin/groupfixrelnames.php @@ -1,7 +1,7 @@ users->isLoggedIn()) $page->show403(); diff --git a/www/pages/api.php b/www/pages/api.php index a04947904..463366f2e 100644 --- a/www/pages/api.php +++ b/www/pages/api.php @@ -1,6 +1,6 @@ users->isLoggedIn()) { diff --git a/www/pages/getnzb.php b/www/pages/getnzb.php index 3bfd90b21..1480ee9af 100644 --- a/www/pages/getnzb.php +++ b/www/pages/getnzb.php @@ -1,6 +1,6 @@ title = "Terms and Conditions"; $page->meta_title = Settings::value('site.main.title')." - Terms and conditions";