From 9ea335ab9c8f9e17e8ce8b6a7e76962bec7ed418 Mon Sep 17 00:00:00 2001 From: horus Date: Mon, 17 Feb 2020 13:17:18 +0100 Subject: Initial commit. --- app/Console/Kernel.php | 42 +++++++++ app/Exceptions/Handler.php | 55 +++++++++++ .../Controllers/Auth/ConfirmPasswordController.php | 40 ++++++++ .../Controllers/Auth/ForgotPasswordController.php | 22 +++++ app/Http/Controllers/Auth/LoginController.php | 40 ++++++++ app/Http/Controllers/Auth/RegisterController.php | 73 +++++++++++++++ .../Controllers/Auth/ResetPasswordController.php | 30 ++++++ .../Controllers/Auth/VerificationController.php | 42 +++++++++ app/Http/Controllers/Controller.php | 13 +++ app/Http/Controllers/IndexController.php | 18 ++++ app/Http/Controllers/iCalController.php | 46 +++++++++ app/Http/Kernel.php | 82 ++++++++++++++++ app/Http/Middleware/Authenticate.php | 21 +++++ app/Http/Middleware/CheckForMaintenanceMode.php | 17 ++++ app/Http/Middleware/EncryptCookies.php | 17 ++++ app/Http/Middleware/RedirectIfAuthenticated.php | 27 ++++++ app/Http/Middleware/TrimStrings.php | 18 ++++ app/Http/Middleware/TrustProxies.php | 23 +++++ app/Http/Middleware/VerifyCsrfToken.php | 24 +++++ app/Libraries/.Zeitumstellung.php.swp | Bin 0 -> 12288 bytes app/Libraries/Zeitumstellung.php | 104 +++++++++++++++++++++ app/Providers/AppServiceProvider.php | 28 ++++++ app/Providers/AuthServiceProvider.php | 30 ++++++ app/Providers/BroadcastServiceProvider.php | 21 +++++ app/Providers/EventServiceProvider.php | 34 +++++++ app/Providers/RouteServiceProvider.php | 80 ++++++++++++++++ app/User.php | 39 ++++++++ 27 files changed, 986 insertions(+) create mode 100644 app/Console/Kernel.php create mode 100644 app/Exceptions/Handler.php create mode 100644 app/Http/Controllers/Auth/ConfirmPasswordController.php create mode 100644 app/Http/Controllers/Auth/ForgotPasswordController.php create mode 100644 app/Http/Controllers/Auth/LoginController.php create mode 100644 app/Http/Controllers/Auth/RegisterController.php create mode 100644 app/Http/Controllers/Auth/ResetPasswordController.php create mode 100644 app/Http/Controllers/Auth/VerificationController.php create mode 100644 app/Http/Controllers/Controller.php create mode 100644 app/Http/Controllers/IndexController.php create mode 100644 app/Http/Controllers/iCalController.php create mode 100644 app/Http/Kernel.php create mode 100644 app/Http/Middleware/Authenticate.php create mode 100644 app/Http/Middleware/CheckForMaintenanceMode.php create mode 100644 app/Http/Middleware/EncryptCookies.php create mode 100644 app/Http/Middleware/RedirectIfAuthenticated.php create mode 100644 app/Http/Middleware/TrimStrings.php create mode 100644 app/Http/Middleware/TrustProxies.php create mode 100644 app/Http/Middleware/VerifyCsrfToken.php create mode 100644 app/Libraries/.Zeitumstellung.php.swp create mode 100644 app/Libraries/Zeitumstellung.php create mode 100644 app/Providers/AppServiceProvider.php create mode 100644 app/Providers/AuthServiceProvider.php create mode 100644 app/Providers/BroadcastServiceProvider.php create mode 100644 app/Providers/EventServiceProvider.php create mode 100644 app/Providers/RouteServiceProvider.php create mode 100644 app/User.php (limited to 'app') diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php new file mode 100644 index 0000000..a8c5158 --- /dev/null +++ b/app/Console/Kernel.php @@ -0,0 +1,42 @@ +command('inspire') + // ->hourly(); + } + + /** + * Register the commands for the application. + * + * @return void + */ + protected function commands() + { + $this->load(__DIR__.'/Commands'); + + require base_path('routes/console.php'); + } +} diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php new file mode 100644 index 0000000..364621e --- /dev/null +++ b/app/Exceptions/Handler.php @@ -0,0 +1,55 @@ +middleware('auth'); + } +} diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php new file mode 100644 index 0000000..465c39c --- /dev/null +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -0,0 +1,22 @@ +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 0000000..c6a6de6 --- /dev/null +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -0,0 +1,73 @@ +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:8', 'confirmed'], + ]); + } + + /** + * Create a new user instance after a valid registration. + * + * @param array $data + * @return \App\User + */ + protected function create(array $data) + { + return User::create([ + 'name' => $data['name'], + 'email' => $data['email'], + 'password' => Hash::make($data['password']), + ]); + } +} diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php new file mode 100644 index 0000000..b1726a3 --- /dev/null +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -0,0 +1,30 @@ +middleware('auth'); + $this->middleware('signed')->only('verify'); + $this->middleware('throttle:6,1')->only('verify', 'resend'); + } +} diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php new file mode 100644 index 0000000..a0a2a8a --- /dev/null +++ b/app/Http/Controllers/Controller.php @@ -0,0 +1,13 @@ + $tc ]); + } +} diff --git a/app/Http/Controllers/iCalController.php b/app/Http/Controllers/iCalController.php new file mode 100644 index 0000000..928976e --- /dev/null +++ b/app/Http/Controllers/iCalController.php @@ -0,0 +1,46 @@ +getData(); + + $vCalendar = new Calendar('zeitumstellung.iamfabulous.de'); + $vCalendar->setName('Zeitumstellung'); + $vCalendar->setTimezone('Europe/Berlin'); + + $vEvent = new Event(); + $vEvent + ->setDtStart(new \DateTime($tc->dateText)) + ->setDtEnd(new \DateTime($tc->dateText)) + ->setNoTime(true) + ->setSummary('Zeitumstellung') + ->setDescription($tc->description) + ->setDescriptionHTML($tc->descriptionHTML); + + $vCalendar->addComponent($vEvent); + + header('Content-Type: text/calendar; charset=utf-8'); + + if ( '0' != $request->input('download') ) { + header('Content-Disposition: attachment; filename="zeitumstellung.ics"'); + } + + echo $vCalendar->render(); + } +} diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php new file mode 100644 index 0000000..deb65e8 --- /dev/null +++ b/app/Http/Kernel.php @@ -0,0 +1,82 @@ + [ + \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', + \Illuminate\Routing\Middleware\SubstituteBindings::class, + ], + ]; + + /** + * The application's route middleware. + * + * These middleware may be assigned to groups or used individually. + * + * @var array + */ + protected $routeMiddleware = [ + 'auth' => \App\Http\Middleware\Authenticate::class, + 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, + 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, + 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, + 'can' => \Illuminate\Auth\Middleware\Authorize::class, + 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, + 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, + 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, + 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + ]; + + /** + * The priority-sorted list of middleware. + * + * This forces non-global middleware to always be in the given order. + * + * @var array + */ + protected $middlewarePriority = [ + \Illuminate\Session\Middleware\StartSession::class, + \Illuminate\View\Middleware\ShareErrorsFromSession::class, + \App\Http\Middleware\Authenticate::class, + \Illuminate\Routing\Middleware\ThrottleRequests::class, + \Illuminate\Session\Middleware\AuthenticateSession::class, + \Illuminate\Routing\Middleware\SubstituteBindings::class, + \Illuminate\Auth\Middleware\Authorize::class, + ]; +} diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php new file mode 100644 index 0000000..704089a --- /dev/null +++ b/app/Http/Middleware/Authenticate.php @@ -0,0 +1,21 @@ +expectsJson()) { + return route('login'); + } + } +} diff --git a/app/Http/Middleware/CheckForMaintenanceMode.php b/app/Http/Middleware/CheckForMaintenanceMode.php new file mode 100644 index 0000000..35b9824 --- /dev/null +++ b/app/Http/Middleware/CheckForMaintenanceMode.php @@ -0,0 +1,17 @@ +check()) { + return redirect(RouteServiceProvider::HOME); + } + + return $next($request); + } +} diff --git a/app/Http/Middleware/TrimStrings.php b/app/Http/Middleware/TrimStrings.php new file mode 100644 index 0000000..5a50e7b --- /dev/null +++ b/app/Http/Middleware/TrimStrings.php @@ -0,0 +1,18 @@ +now = Carbon::now()->startOfDay(); + + $this->year = $this->now->year; + + # detect if next time change is next year + if ( $this->now->gt( Carbon::parse('last sunday of october')->startOfDay() ) ){ + $this->year = $this->year+1; + } + + $this->tc_march = Carbon::parse('last sunday of march ' . $this->year )->startOfDay(); + $this->tc_oct = Carbon::parse('last sunday of october ' . $this->year)->startOfDay(); + + if ( $this->now->lte($this->tc_march) ){ + # next time change is in march this year, (last sunday in october) + + $this->date = $this->tc_march; + $this->description = 'Die Uhr wird von 2 Uhr auf 3 Uhr vorgestellt, sodass wir 1 Stunde weniger schlafen.'; + $this->descriptionHTML = 'Die Uhr wird von 2 Uhr auf 3 Uhr vorgestellt, sodass wir 1 Stunde weniger schlafen.'; + + # detect if last time change was last year + if ( $this->now->lt( Carbon::parse('last sunday of march ') ) ) { + $this->year = $this->now->year - 1; + $this->daysago = Carbon::parse('last sunday of october' . $this->year)->diffInDays( $this->now ); + } else { + $this->daysago = $this->tc_oct->diffInDays( $this->now ); + } + + } else { + # next time change is in october this year, (last sunday in october) + + $this->date = $this->tc_oct; + $this->description = 'Die Uhr wird von 3 Uhr auf 2 Uhr zurückgestellt, sodass wir 1 Stunde länger schlafen.'; + $this->descriptionHTML = 'Die Uhr wird von 3 Uhr auf 2 Uhr zurückgestellt, sodass wir 1 Stunde länger schlafen.'; + + $this->daysago = $this->tc_march->diffInDays( $this->now ); + } + + $this->dateText = $this->date->toDateString(); + + $this->daysuntil = $this->date->diffInDays($this->now); + + $this->day = $this->date->day; + $this->month = $this->date->month; + $this->year = $this->date->year; + + if ( 3 == $this->month ) { + $this->monthText = "März"; + } else { + $this->monthText = "Oktober"; + } + } + + public function getData(){ + $result = array(); + + $result["date"] = $this->date->toDateString(); + $result["day"] = $this->date->day; + $result["month"] = $this->date->month; + $result["monthText"] = $this->monthText; + $result["year"] = $this->date->year; + $result["daysuntil"] = $this->daysuntil; + $result["daysago"] = $this->daysago; + $result["now"] = $this->now->toDateString(); + + return $result; + } + public function getJSON(){ + return json_encode( $this->getData() ); + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php new file mode 100644 index 0000000..ee8ca5b --- /dev/null +++ b/app/Providers/AppServiceProvider.php @@ -0,0 +1,28 @@ + '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 0000000..395c518 --- /dev/null +++ b/app/Providers/BroadcastServiceProvider.php @@ -0,0 +1,21 @@ + [ + SendEmailVerificationNotification::class, + ], + ]; + + /** + * 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 0000000..527eee3 --- /dev/null +++ b/app/Providers/RouteServiceProvider.php @@ -0,0 +1,80 @@ +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/app/User.php b/app/User.php new file mode 100644 index 0000000..e79dab7 --- /dev/null +++ b/app/User.php @@ -0,0 +1,39 @@ + 'datetime', + ]; +} -- cgit v1.2.3