Git inicializacia
This commit is contained in:
42
app/Console/Kernel.php
Normal file
42
app/Console/Kernel.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command('inspire')
|
||||
// ->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
53
app/Exceptions/Handler.php
Normal file
53
app/Exceptions/Handler.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $exception)
|
||||
{
|
||||
parent::report($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
{
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
}
|
||||
32
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
32
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
||||
39
app/Http/Controllers/Auth/LoginController.php
Normal file
39
app/Http/Controllers/Auth/LoginController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
}
|
||||
71
app/Http/Controllers/Auth/RegisterController.php
Normal file
71
app/Http/Controllers/Auth/RegisterController.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users as well as their
|
||||
| validation and creation. By default this controller uses a trait to
|
||||
| provide this functionality without requiring any additional code.
|
||||
|
|
||||
*/
|
||||
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->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 \App\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => bcrypt($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
39
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
39
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
||||
13
app/Http/Controllers/Controller.php
Normal file
13
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
76
app/Http/Controllers/Logging.php
Normal file
76
app/Http/Controllers/Logging.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Logging extends Controller
|
||||
{
|
||||
|
||||
private $_items = [ 'netstat_sent' => 'i', 'netstat_recv' => 'i', 'memory_free' => 'f', 'memory_total' => 'f', 'memory_used' => 'f', 'disk_free' => 'B', 'disk_percent' => 'f', 'disk_used' => 'B', 'disk_total' => 'B', 'processes' => 'i', 'temp' => 'i', 'username' =>'s', 'computer' => 's'];
|
||||
|
||||
private $_values = [];
|
||||
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
function conv_bytes($v) {
|
||||
$units = explode(' ', ' K M G T P E Z Y');
|
||||
|
||||
preg_match('/([0-9]+)([GKMTgkmT])?B/',$v,$vu);
|
||||
$v1 = $vu[1];
|
||||
if (count($vu) == 3)
|
||||
$v2 = $vu[2];
|
||||
else
|
||||
$v2 = '';
|
||||
|
||||
$pos = array_search($v2,$units);
|
||||
|
||||
$num = floatval($v1) * pow(1024,$pos);
|
||||
|
||||
return $num;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function parse($vals) {
|
||||
foreach ($vals as $k => $v)
|
||||
{
|
||||
if (is_array($k)) {
|
||||
foreach ($v as $k2 => $v2) {
|
||||
$this->_values["$k"."_"."$k2"] = $v2;
|
||||
}
|
||||
} else {
|
||||
$this->_values[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->_items as $k => $v) {
|
||||
$t = $this->_items[$k];
|
||||
if ($t == 's') continue;
|
||||
|
||||
if ($t == 'B') $v = $this->conv_bytes($v);
|
||||
|
||||
if ($t == 'f') $v = floatval($v);
|
||||
if ($t == 'i') $v = intval($v);
|
||||
|
||||
$this->_values[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
public function log(Request $request) {
|
||||
$data = json_decode($request->getContent(), true);
|
||||
$v = $data["values"];
|
||||
$i = $data["items"];
|
||||
var_export($v);
|
||||
// $this->parse($v);
|
||||
|
||||
// var_dump($this->_values);
|
||||
|
||||
return "OK";
|
||||
//DB::insert('insert into values (user,computer,recv,send) values (?, ?, ?, ?)', [$u, $c, $r, $s]);
|
||||
}
|
||||
}
|
||||
99
app/Http/Controllers/Network.php
Normal file
99
app/Http/Controllers/Network.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Response;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Network extends Controller
|
||||
{
|
||||
public function csv(Request $request){
|
||||
$headers = [
|
||||
'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0'
|
||||
, 'Content-type' => 'text/csv'
|
||||
, 'Content-Disposition' => 'attachment; filename=network.csv'
|
||||
, 'Expires' => '0'
|
||||
, 'Pragma' => 'public'
|
||||
];
|
||||
|
||||
$sd = $request->input("start");
|
||||
$ed = $request->input("end");
|
||||
$u = $request->input("user");
|
||||
$c = $request->input("computer");
|
||||
|
||||
$wh = [];
|
||||
|
||||
if ($u != '') $wh[] = ['user', '=', $u];
|
||||
if ($sd != '') $wh[] = ['date', '>=', $sd];
|
||||
if ($sd != '') $wh[] = ['date', '<=', $ed];
|
||||
$queries = DB::table('network')->where($wh)->get();
|
||||
|
||||
$list = $queries->toArray();
|
||||
|
||||
$callback = function() use ($list)
|
||||
{
|
||||
$FH = fopen('php://output', 'w');
|
||||
fputcsv($FH, ['Date','User','Computer','Recv','Send']);
|
||||
$first = true;
|
||||
$recv = 0;
|
||||
$send = 0;
|
||||
|
||||
foreach ($list as $r) {
|
||||
|
||||
$in = $r->recv - $recv;
|
||||
$out = $r->send - $send;
|
||||
|
||||
if ($in > 1000000000 || $in < 0 ||
|
||||
$out > 1000000000 || $out < 0 ||
|
||||
$first == true) {
|
||||
$in = $out = 0;
|
||||
}
|
||||
// date - r->date > 300 -> date + 300 = 0
|
||||
if (!$first) {
|
||||
$d1 = new \DateTime($r->date);
|
||||
$d2 = new \DateTime($date);
|
||||
|
||||
$diff = $d1->getTimestamp() - $d2->getTimestamp();
|
||||
|
||||
$in = $in / $diff;
|
||||
$out = $out / $diff;
|
||||
|
||||
if ($diff > 500) {
|
||||
$in = $out = 0;
|
||||
$ts = $d2->getTimestamp() + 300;
|
||||
$ndate = new \DateTime();
|
||||
$ndate->setTimestamp($ts);
|
||||
$ndate = $ndate->format('Y-m-d H:i:s');
|
||||
fputcsv($FH, [$ndate,$r->user,$r->computer,$in,$out]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fputcsv($FH, [$r->date,$r->user,$r->computer,$in,$out]);
|
||||
|
||||
$recv = $r->recv;
|
||||
$send = $r->send;
|
||||
$date = $r->date;
|
||||
$first = false;
|
||||
}
|
||||
fclose($FH);
|
||||
};
|
||||
|
||||
|
||||
return Response::stream($callback, 200, $headers);
|
||||
|
||||
}
|
||||
|
||||
public function search(Request $request){
|
||||
|
||||
$sd = $request->input("start_date");
|
||||
$ed = $request->input("end_date");
|
||||
$u = $request->input("user");
|
||||
$c = $request->input("computer");
|
||||
|
||||
return view('graph', ['start' => $sd, 'end' => $ed, 'user'=> $u]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
29
app/Http/Controllers/Push.php
Normal file
29
app/Http/Controllers/Push.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Push extends Controller
|
||||
{
|
||||
|
||||
public function data(Request $request) {
|
||||
#$data = json_decode($request->getContent(), true);
|
||||
#$v = $data["values"];
|
||||
#$i = $data["items"];
|
||||
|
||||
curl_setopt_array($ch = curl_init(), array(
|
||||
CURLOPT_URL => "https://api.pushover.net/1/messages",
|
||||
CURLOPT_POSTFIELDS => array(
|
||||
"token" => "aihmja456inobzd4pmkrds3x1qrvrh",
|
||||
"user" => "uzuoxsj7o6nitdvvqg5veuraacpnrp",
|
||||
"message" => "hello world",
|
||||
)));
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
return "OK";
|
||||
//DB::insert('insert into values (user,computer,recv,send) values (?, ?, ?, ?)', [$u, $c, $r, $s]);
|
||||
}
|
||||
}
|
||||
28
app/Http/Controllers/Search.php
Normal file
28
app/Http/Controllers/Search.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
#use Illuminate\Http\Request;
|
||||
use Request;
|
||||
use Response;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Search extends Controller
|
||||
{
|
||||
public function autocomplete(){
|
||||
$term = Request::input('term');
|
||||
$results = array();
|
||||
|
||||
$queries = DB::table('network')
|
||||
->select('user')->distinct()
|
||||
->where('user', 'LIKE', $term.'%')
|
||||
->get();
|
||||
|
||||
foreach ($queries as $query)
|
||||
{
|
||||
$results[] = $query->user ;
|
||||
}
|
||||
return Response::json($results);
|
||||
}
|
||||
|
||||
}
|
||||
99
app/Http/Controllers/Temperature.php
Normal file
99
app/Http/Controllers/Temperature.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Response;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Temperature extends Controller
|
||||
{
|
||||
public function csvtemp(Request $request){
|
||||
$headers = [
|
||||
'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0'
|
||||
, 'Content-type' => 'text/csv'
|
||||
, 'Content-Disposition' => 'attachment; filename=temp.csv'
|
||||
, 'Expires' => '0'
|
||||
, 'Pragma' => 'public'
|
||||
];
|
||||
|
||||
$sd = $request->input("start");
|
||||
$ed = $request->input("end");
|
||||
$u = $request->input("user");
|
||||
$c = $request->input("computer");
|
||||
|
||||
$wh = [];
|
||||
|
||||
if ($u != '') $wh[] = ['user', '=', $u];
|
||||
if ($sd != '') $wh[] = ['date', '>=', $sd];
|
||||
if ($sd != '') $wh[] = ['date', '<=', $ed];
|
||||
$queries = DB::table('temp')->where($wh)->get();
|
||||
|
||||
$list = $queries->toArray();
|
||||
|
||||
$callback = function() use ($list)
|
||||
{
|
||||
$FH = fopen('php://output', 'w');
|
||||
fputcsv($FH, ['Date','User','Computer','Recv','Send']);
|
||||
$first = true;
|
||||
$recv = 0;
|
||||
$send = 0;
|
||||
|
||||
foreach ($list as $r) {
|
||||
|
||||
$in = $r->recv - $recv;
|
||||
$out = $r->send - $send;
|
||||
|
||||
if ($in > 1000000000 || $in < 0 ||
|
||||
$out > 1000000000 || $out < 0 ||
|
||||
$first == true) {
|
||||
$in = $out = 0;
|
||||
}
|
||||
// date - r->date > 300 -> date + 300 = 0
|
||||
if (!$first) {
|
||||
$d1 = new \DateTime($r->date);
|
||||
$d2 = new \DateTime($date);
|
||||
|
||||
$diff = $d1->getTimestamp() - $d2->getTimestamp();
|
||||
|
||||
$in = $in / $diff;
|
||||
$out = $out / $diff;
|
||||
|
||||
if ($diff > 500) {
|
||||
$in = $out = 0;
|
||||
$ts = $d2->getTimestamp() + 300;
|
||||
$ndate = new \DateTime();
|
||||
$ndate->setTimestamp($ts);
|
||||
$ndate = $ndate->format('Y-m-d H:i:s');
|
||||
fputcsv($FH, [$ndate,$r->user,$r->computer,$in,$out]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fputcsv($FH, [$r->date,$r->user,$r->computer,$in,$out]);
|
||||
|
||||
$recv = $r->recv;
|
||||
$send = $r->send;
|
||||
$date = $r->date;
|
||||
$first = false;
|
||||
}
|
||||
fclose($FH);
|
||||
};
|
||||
|
||||
|
||||
return Response::stream($callback, 200, $headers);
|
||||
|
||||
}
|
||||
|
||||
public function search(Request $request){
|
||||
|
||||
$sd = $request->input("start_date");
|
||||
$ed = $request->input("end_date");
|
||||
$u = $request->input("user");
|
||||
$c = $request->input("computer");
|
||||
|
||||
return view('graph', ['start' => $sd, 'end' => $ed, 'user'=> $u]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
61
app/Http/Kernel.php
Normal file
61
app/Http/Kernel.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\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,
|
||||
];
|
||||
}
|
||||
17
app/Http/Middleware/EncryptCookies.php
Normal file
17
app/Http/Middleware/EncryptCookies.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
26
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
26
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect('/home');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
18
app/Http/Middleware/TrimStrings.php
Normal file
18
app/Http/Middleware/TrimStrings.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
||||
29
app/Http/Middleware/TrustProxies.php
Normal file
29
app/Http/Middleware/TrustProxies.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The current proxy header mappings.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $headers = [
|
||||
Request::HEADER_FORWARDED => 'FORWARDED',
|
||||
Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
|
||||
Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
|
||||
Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
|
||||
Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
|
||||
];
|
||||
}
|
||||
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'/log'
|
||||
];
|
||||
}
|
||||
7
app/Http/routes.php
Normal file
7
app/Http/routes.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
Route::get('/log',function () {
|
||||
echo "TEST";
|
||||
});
|
||||
|
||||
|
||||
29
app/Providers/AppServiceProvider.php
Normal file
29
app/Providers/AppServiceProvider.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Schema::defaultStringLength(191);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
30
app/Providers/AuthServiceProvider.php
Normal file
30
app/Providers/AuthServiceProvider.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The policy mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
'App\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
21
app/Providers/BroadcastServiceProvider.php
Normal file
21
app/Providers/BroadcastServiceProvider.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
||||
32
app/Providers/EventServiceProvider.php
Normal file
32
app/Providers/EventServiceProvider.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event listener mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
'App\Events\Event' => [
|
||||
'App\Listeners\EventListener',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
73
app/Providers/RouteServiceProvider.php
Normal file
73
app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* This namespace is applied to your controller routes.
|
||||
*
|
||||
* In addition, it is set as the URL generator's root namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'App\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
$this->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'));
|
||||
}
|
||||
}
|
||||
29
app/User.php
Normal file
29
app/User.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user