Kaydet (Commit) 5a495f88 authored tarafından mertcelen's avatar mertcelen

Logs implemented.

Fixed #23
Signed-off-by: 's avatarmertcelen <mcelen94@gmail.com>
üst 76c26a67
......@@ -2,11 +2,14 @@ APP_NAME=Liman
APP_ENV=local
APP_KEY=base64:pmdymYQB3XC0ExvCZ9zFERFriXai4HIFsF2v3cr74MU=
APP_DEBUG=true
APP_URL=https://limantest.pardus.lab
APP_NOTIFICATION_EMAIL=bildirim@limantest.pardus.lab
APP_URL=https://liman.dev
APP_NOTIFICATION_EMAIL=mert@liman.dev
APP_VERSION=0.06.10-1100
LOG_CHANNEL=syslog
LOG_CHANNEL=single
LOG_LEVEL=debug
LOG_PATH=/liman/logs/liman.log
LOG_ERROR_PATH=/liman/logs/error.log
DB_CONNECTION=mongodb
DB_HOST=localhost
......@@ -20,11 +23,9 @@ CACHE_DRIVER=array
SESSION_DRIVER=file
SESSION_LIFETIME=120
DEBUGBAR_ENABLED = FALSE
QUEUE_DRIVER=database
SERVER_CONNECTION_TIMEOUT = 5000
LOG_PATH=/liman/logs/liman.log
SERVER_PATH=/liman/server/
SANDBOX_PATH=/liman/sandbox/
......
......@@ -3,7 +3,9 @@
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Carbon\Carbon;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
/**
* Class LoginController
......@@ -25,4 +27,24 @@ class LoginController extends Controller
{
$this->middleware('guest')->except('logout');
}
public function authenticated(Request $request, $user)
{
$user->last_login_at = Carbon::now()->toDateTimeString();
$user->last_login_ip = $request->ip();
$user->save();
system_log(7,"LOGIN_SUCCESS");
}
public function attemptLogin(Request $request)
{
$flag = $this->guard()->attempt(
$this->credentials($request), $request->filled('remember')
);
if(!$flag){
system_log(5,"LOGIN_FAILED");
}
return $flag;
}
}
......@@ -16,6 +16,7 @@ class LogoutController extends Controller
*/
public function logout()
{
system_log(7,"LOGOUT_SUCCESS");
//Logout User
Auth::logout();
session()->flush();
......
......@@ -32,7 +32,9 @@ class MainController extends Controller
// Extract Cities of the Servers.
$cities = array_values(objectToArray($servers, "city", "city"));
system_log(7,"EXTENSION_SERVERS_INDEX",[
"extension_id" => extension()->_id
]);
// Render View with Cities
return view('extension_pages.index', [
"cities" => implode(',', $cities)
......@@ -97,6 +99,10 @@ class MainController extends Controller
// Close/Compress zip
$zip->close();
system_log(6,"EXTENSION_DOWNLOAD",[
"extension_id" => extension()->_id
]);
// Return zip as download and delete it after sent.
return response()->download($exportedFile . '.lmne', extension()->name . "-" . extension()->version . ".lmne")->deleteFileAfterSend();
}
......@@ -112,6 +118,9 @@ class MainController extends Controller
// Try to open zip file.
if (!$zip->open(request()->file('extension'))) {
system_log(7,"EXTENSION_UPLOAD_FAILED_CORRUPTED",[
"extension_id" => extension()->_id
]);
return respond("Eklenti Dosyası Açılamıyor.", 201);
}
......@@ -134,6 +143,9 @@ class MainController extends Controller
if ($extension) {
if ($extension->version == $json["version"]) {
system_log(7,"EXTENSION_UPLOAD_FAILED_ALREADY_INSTALLED",[
"extension_id" => extension()->_id
]);
return respond("Eklentinin bu sürümü zaten yüklü", 201);
}
}
......@@ -201,6 +213,10 @@ class MainController extends Controller
}
}
}
system_log(3,"EXTENSION_UPLOAD",[
"extension_id" => extension()->_id
]);
return respond(route('extension_one', $new->_id), 300);
}
......@@ -247,6 +263,10 @@ class MainController extends Controller
shell_exec('sudo chown liman-' . $ext->_id . ':liman "' . trim($folder) . '/functions.php"');
shell_exec('sudo chmod 664 "' . trim($folder) . '/functions.php"');
system_log(6,"EXTENSION_CREATE",[
"extension_id" => extension()->_id
]);
return respond(route('extension_one', $ext->_id), 300);
}
}
......@@ -25,6 +25,7 @@ class HomeController extends Controller
*/
public function index()
{
system_log(7,"HOMEPAGE");
$widgets = Widget::where('user_id',auth()->id())->get();
foreach($widgets as $widget){
$widget->server_name = Server::where('_id',$widget->server_id)->first()->name;
......@@ -35,6 +36,7 @@ class HomeController extends Controller
}
public function setLocale(){
system_log(7,"SET_LOCALE");
$languages = ["tr","en"];
if(request()->has('locale') && in_array(request('locale'),$languages)){
\Session::put('locale', request('locale'));
......
......@@ -46,13 +46,44 @@ if (!function_exists('notifications')) {
}
}
if (!function_exists('liman_log')) {
if (!function_exists('system_log')) {
/**
* @param $level
* @param $message
* @param array $array
*/
function liman_log($message)
function system_log($level, $message, $array = [])
{
Log::info(auth()->id() . ":" . $message);
$array["user_id"] = auth()->id();
$array["ip_address"] = request()->ip();
switch ($level){
case 1:
Log::emergency($message,$array);
break;
case 2:
Log::alert($message,$array);
break;
case 3:
Log::critical($message,$array);
break;
case 4:
Log::error($message,$array);
break;
case 5:
Log::warning($message,$array);
break;
case 6:
Log::notice($message,$array);
break;
case 7:
Log::info($message,$array);
break;
default:
Log::debug($message,$array);
break;
}
}
}
......@@ -304,3 +335,5 @@ if(!function_exists('cities')){
}
}
......@@ -41,8 +41,8 @@ return [
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'path' => env('LOG_PATH'),
'level' => env('LOG_LEVEL'),
],
'daily' => [
......
......@@ -44,9 +44,14 @@
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="hidden-xs">{{auth()->user()->name}}</span>
</a>
<ul class="dropdown-menu">
<!-- Menu Footer-->
<li class="user-footer">
<div>
{{__("Giriş Yapılan son ip adresi : ") . auth()->user()->last_login_ip}}
{{__("Giriş Tarihi : " . auth()->user()->last_login_at)}}<br><br>
</div>
<div class="pull-left">
<a href="{{route('my_profile')}}"
class="btn btn-default btn-flat">{{__("Profil")}}</a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment