Kaydet (Commit) 5f773d69 authored tarafından Baran Sekin's avatar Baran Sekin

Applied pretty format

üst b0aefb03
......@@ -243,7 +243,7 @@ class OneController extends Controller
try {
shell_exec(
"sudo rm -r " .
"/liman/extensions/" .
"/liman/extensions/" .
strtolower(extension()->name)
);
} catch (\Exception $exception) {
......
......@@ -90,16 +90,19 @@ class MainController extends Controller
]);
}
if(config('liman.liman_restricted')== true && !user()->isAdmin()){
return view('extension_pages.server_restricted',[
"view" => $output
if (
config('liman.liman_restricted') == true &&
!user()->isAdmin()
) {
return view('extension_pages.server_restricted', [
"view" => $output,
]);
}
return view('extension_pages.server', [
"viewName" => "",
"view" => $output,
"timestamp" => $timestamp,
"last" => $this->getNavigationServers()
"last" => $this->getNavigationServers(),
]);
}
}
......@@ -202,8 +205,8 @@ class MainController extends Controller
{
$navServers = DB::select(
"SELECT * FROM \"server_groups\" WHERE \"servers\" LIKE \"%" .
server()->id .
"%\""
server()->id .
"%\""
);
$cleanServers = [];
foreach ($navServers as $rawServers) {
......@@ -239,7 +242,9 @@ class MainController extends Controller
list($server_id, $server_name) = explode(":", $serverobj);
foreach ($extensions as $extension_id => $extension_name) {
$prefix = $extension_id . ":" . $extension_name;
$current = array_key_exists($prefix, $last) ? $last[$prefix] : [];
$current = array_key_exists($prefix, $last)
? $last[$prefix]
: [];
array_push($current, [
"id" => $server_id,
"name" => $server_name,
......
......@@ -7,5 +7,5 @@ return [
"extension_developer_mode" => true,
"nav_extension_hide_count" => 10,
"widget_refresh_time" => 30000, //ms
"liman_restricted" => false
];
\ No newline at end of file
"liman_restricted" => false,
];
<?php
use Illuminate\Http\Request;
\ No newline at end of file
use Illuminate\Http\Request;
......@@ -8,22 +8,28 @@ use Illuminate\Support\Carbon;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Hash;
Artisan::command('administrator',function (){
Artisan::command('administrator', function () {
// Generate Password
do{
$pool = str_shuffle('abcdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ234567890!$@%^&!$%^&');
$password = substr($pool,0,10);
}while(!preg_match("/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{10,}$/", $password));
do {
$pool = str_shuffle(
'abcdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ234567890!$@%^&!$%^&'
);
$password = substr($pool, 0, 10);
} while (
!preg_match(
"/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{10,}$/",
$password
)
);
$user = User::where([
"name" => "Administrator",
"email" => "administrator@liman.app"
"email" => "administrator@liman.app",
])->first();
if($user){
if ($user) {
$user->update([
"password" => Hash::make($password)
"password" => Hash::make($password),
]);
}else{
} else {
$user = new User();
$user->fill([
"name" => "Administrator",
......@@ -39,112 +45,127 @@ Artisan::command('administrator',function (){
$this->comment("Parola : " . $password . "");
})->describe('Create administrator account to use');
Artisan::command('scan:translations',function (){
if(config('liman.extension_developer_mode') != true){
return $this->error("You need to open extension developer mode for use this function.");
Artisan::command('scan:translations', function () {
if (config('liman.extension_developer_mode') != true) {
return $this->error(
"You need to open extension developer mode for use this function."
);
}
$extension_path = "/liman/extensions/";
$extensions = glob($extension_path.'/*', GLOB_ONLYDIR);
$extensions = glob($extension_path . '/*', GLOB_ONLYDIR);
$this->info("Started to scanning extension folders.");
foreach($extensions as $extension){
$this->comment("Scanning: ".$extension);
foreach ($extensions as $extension) {
$this->comment("Scanning: " . $extension);
$output = "$extension/lang/en.json";
$translations = scanTranslations($extension);
if (!is_dir(dirname($output))) {
mkdir(dirname($output));
}
if(is_file($output)){
$translations = array_merge($translations, (array)json_decode(file_get_contents($output)));
if (is_file($output)) {
$translations = array_merge(
$translations,
(array) json_decode(file_get_contents($output))
);
}
file_put_contents($output, json_encode($translations, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
$this->info("Scanned and saved to ".$output);
file_put_contents(
$output,
json_encode(
$translations,
JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT
)
);
$this->info("Scanned and saved to " . $output);
}
$this->info("Finished scanning extension folders.");
$this->info("Started to scanning server files.");
$server_path = "/liman/server";
$this->comment("Scanning: ".$server_path);
$this->comment("Scanning: " . $server_path);
$output = "$server_path/resources/lang/en.json";
$translations = scanTranslations($server_path);
if(is_file($output)){
$translations = array_merge($translations, (array)json_decode(file_get_contents($output)));
if (is_file($output)) {
$translations = array_merge(
$translations,
(array) json_decode(file_get_contents($output))
);
}
file_put_contents($output, json_encode($translations, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
$this->comment("Scanned and saved to ".$output);
file_put_contents(
$output,
json_encode($translations, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)
);
$this->comment("Scanned and saved to " . $output);
})->describe('Scan missing translation strings');
Artisan::command('module:add {module_name}',function($module_name){
Artisan::command('module:add {module_name}', function ($module_name) {
// Check if files are exists.
if(!is_dir("/liman/modules/$module_name")){
if (!is_dir("/liman/modules/$module_name")) {
return $this->error("Modul klasoru bulunamadi!");
}
// if(!is_file("/liman/modules/$module_name/main") || !is_file("/liman/modules/$module_name/template.json")){
// return $this->error("Modul gecerli degil.");
// }
//
// $this->info("$module_name modulu ekleniyor.");
//
// //Let's read the template.
// $template = file_get_contents("/liman/modules/$module_name/template.json");
// $template = json_decode($template,true);
//
// if(json_last_error() != JSON_ERROR_NONE){
// return $this->error("Modul ayar dosyasi anlasilmadi, lutfen modul yoneticisiyle iletisime gecin");
// }
//
// // Check if module already exists.
// if(Module::where('name',$module_name)->exists()){
// return $this->error("Bu isimde bir modul zaten ekli.");
// }
// if(!is_file("/liman/modules/$module_name/main") || !is_file("/liman/modules/$module_name/template.json")){
// return $this->error("Modul gecerli degil.");
// }
//
// $this->info("$module_name modulu ekleniyor.");
//
// //Let's read the template.
// $template = file_get_contents("/liman/modules/$module_name/template.json");
// $template = json_decode($template,true);
//
// if(json_last_error() != JSON_ERROR_NONE){
// return $this->error("Modul ayar dosyasi anlasilmadi, lutfen modul yoneticisiyle iletisime gecin");
// }
//
// // Check if module already exists.
// if(Module::where('name',$module_name)->exists()){
// return $this->error("Bu isimde bir modul zaten ekli.");
// }
$module = Module::create(["name" => $module_name, "enabled" => true]);
// // Let's check module hooks.
// $listen = $template["hooks"]["listen"];
// $dbArray = [];
//
// $now = Carbon::now('utc')->toDateTimeString();
//
// foreach ($listen as $value) {
// array_push($dbArray,[
// "hook" => $value,
// "id" => Str::uuid(),
// "module_id" => $module->id,
// "module_name" => $module->name,
// "enabled" => false,
// "created_at" => $now,
// "updated_at" => $now
// ]);
// }
//
// $flag = ModuleHook::insert($dbArray);
// // Let's check module hooks.
// $listen = $template["hooks"]["listen"];
// $dbArray = [];
//
// $now = Carbon::now('utc')->toDateTimeString();
//
// foreach ($listen as $value) {
// array_push($dbArray,[
// "hook" => $value,
// "id" => Str::uuid(),
// "module_id" => $module->id,
// "module_name" => $module->name,
// "enabled" => false,
// "created_at" => $now,
// "updated_at" => $now
// ]);
// }
//
// $flag = ModuleHook::insert($dbArray);
$notification = new AdminNotification([
"title" => "Yeni Modül Eklendi",
"type" => "new_module",
"message" => "$module->name isminde bir modül sisteme eklendi.",
"level" => 3
"level" => 3,
]);
$notification->save();
$this->info("Modul basariyla yuklendi, lutfen liman arayuzunden yetkilerini onaylayin.");
$this->info(
"Modul basariyla yuklendi, lutfen liman arayuzunden yetkilerini onaylayin."
);
})->describe("New module add");
Artisan::command('module:remove {module_name}',function($module_name){
$module = Module::where('name',$module_name)->first();
Artisan::command('module:remove {module_name}', function ($module_name) {
$module = Module::where('name', $module_name)->first();
if(!$module){
if (!$module) {
return $this->error("Modul bulunamadi!");
}
$flag = $module->delete();
if($flag){
if ($flag) {
$this->info("Modul basariyla silindi.");
}else{
} else {
$this->error("Modul silinemedi.$flag");
}
})->describe("Module remove");
\ No newline at end of file
})->describe("Module remove");
<?php
Route::post('/eklenti/yeni', 'Extension\MainController@newExtension')->name('extension_new')->middleware('admin');
Route::get('/eklentiler/{extension_id}/{page_name}', 'Extension\OneController@page')->middleware('admin')->name('extension_page_edit_view');
Route::post('/ayar/eklenti/guncelle', 'Extension\SettingsController@update')->middleware('admin')->name('extension_settings_update');
Route::post('/ayar/eklenti/ekle', 'Extension\SettingsController@add')->middleware('admin')->name('extension_settings_add');
Route::post('/ayar/eklenti/sil', 'Extension\SettingsController@remove')->middleware('admin')->name('extension_settings_remove');
Route::post('/ayar/eklenti/kod', 'Extension\OneController@updateCode')->middleware('admin')->name('extension_code_update');
Route::post('/ayar/eklenti/yeni/sayfa', 'Extension\MainController@newExtensionPage')->middleware('admin')->name('extension_new_page');
Route::post('/eklenti/yeni', 'Extension\MainController@newExtension')
->name('extension_new')
->middleware('admin');
Route::get(
'/eklentiler/{extension_id}/{page_name}',
'Extension\OneController@page'
)
->middleware('admin')
->name('extension_page_edit_view');
Route::post('/ayar/eklenti/guncelle', 'Extension\SettingsController@update')
->middleware('admin')
->name('extension_settings_update');
Route::post('/ayar/eklenti/ekle', 'Extension\SettingsController@add')
->middleware('admin')
->name('extension_settings_add');
Route::post('/ayar/eklenti/sil', 'Extension\SettingsController@remove')
->middleware('admin')
->name('extension_settings_remove');
Route::post('/ayar/eklenti/kod', 'Extension\OneController@updateCode')
->middleware('admin')
->name('extension_code_update');
Route::post(
'/ayar/eklenti/yeni/sayfa',
'Extension\MainController@newExtensionPage'
)
->middleware('admin')
->name('extension_new_page');
// Extension Download Page
Route::get('/indir/eklenti/{extension_id}', 'Extension\MainController@download')->name('extension_download');
Route::get(
'/indir/eklenti/{extension_id}',
'Extension\MainController@download'
)->name('extension_download');
<?php
// Auth Routes
require_once(app_path('Http/Controllers/Auth/_routes.php'));
require_once app_path('Http/Controllers/Auth/_routes.php');
Route::group(['middleware' => ['auth', 'permissions']], function () {
// Extension Routes
require_once(app_path('Http/Controllers/Extension/_routes.php'));
require_once app_path('Http/Controllers/Extension/_routes.php');
// Notification Routes
require_once(app_path('Http/Controllers/Notification/_routes.php'));
require_once app_path('Http/Controllers/Notification/_routes.php');
// Permission Routes
require_once(app_path('Http/Controllers/Permission/_routes.php'));
require_once app_path('Http/Controllers/Permission/_routes.php');
// Server Routes
require_once(app_path('Http/Controllers/Server/_routes.php'));
require_once app_path('Http/Controllers/Server/_routes.php');
// Certificate Routes
require_once(app_path('Http/Controllers/Certificate/_routes.php'));
require_once app_path('Http/Controllers/Certificate/_routes.php');
// Server Routes
require_once(app_path('Http/Controllers/Settings/_routes.php'));
require_once app_path('Http/Controllers/Settings/_routes.php');
// Widgets Routes
require_once(app_path('Http/Controllers/Widgets/_routes.php'));
require_once app_path('Http/Controllers/Widgets/_routes.php');
// Modules Routes
require_once(app_path('Http/Controllers/Module/_routes.php'));
require_once app_path('Http/Controllers/Module/_routes.php');
// Role Routes
require_once(app_path('Http/Controllers/Roles/_routes.php'));
require_once app_path('Http/Controllers/Roles/_routes.php');
// Internal Sandbox Routes
require_once(app_path('Http/Controllers/Extension/Sandbox/_routes.php'));
require_once app_path('Http/Controllers/Extension/Sandbox/_routes.php');
// Change the language
Route::get('/locale', 'HomeController@setLocale')->name('set_locale');
......@@ -60,13 +58,17 @@ Route::group(['middleware' => ['auth', 'permissions']], function () {
Route::get('/', 'HomeController@index')->name('home');
Route::post('/', 'HomeController@getLimanStats')->name('liman_stats')->middleware('admin');
Route::post('/', 'HomeController@getLimanStats')
->name('liman_stats')
->middleware('admin');
// Vault Route
Route::get('/kasa', 'UserController@userKeyList')->name('keys');
Route::post('/onbellek_temizle', 'UserController@cleanSessions')->name('clean_sessions');
Route::post('/onbellek_temizle', 'UserController@cleanSessions')->name(
'clean_sessions'
);
// Add Key Route
Route::post('/kasa/ekle', 'UserController@addKey')->name('key_add');
......@@ -91,13 +93,19 @@ Route::group(['middleware' => ['auth', 'permissions']], function () {
Route::view('/logs/{log_id}', 'logs.one');
// User Add
Route::post('/kullanici/ekle', 'UserController@add')->name('user_add')->middleware('admin');
Route::post('/kullanici/ekle', 'UserController@add')
->name('user_add')
->middleware('admin');
// User Remove
Route::post('/kullanici/sil', 'UserController@remove')->name('user_remove')->middleware('admin');
Route::post('/kullanici/sil', 'UserController@remove')
->name('user_remove')
->middleware('admin');
// User Remove
Route::post('/kullanici/parola/sifirla', 'UserController@passwordReset')->name('user_password_reset')->middleware('admin');
Route::post('/kullanici/parola/sifirla', 'UserController@passwordReset')
->name('user_password_reset')
->middleware('admin');
Route::view('/logs/{log_id}', 'logs.one');
......@@ -105,19 +113,45 @@ Route::group(['middleware' => ['auth', 'permissions']], function () {
Route::post('/profil', 'UserController@selfUpdate')->name('profile_update');
Route::post('/user/update', 'UserController@adminUpdate')->name('update_user')->middleware('admin');
Route::post('/user/setting/delete', 'UserController@removeSetting')->name('user_setting_remove');
Route::post('/user/setting/update', 'UserController@updateSetting')->name('user_setting_update');
Route::post('/ayar/bildirimKanali/ekle', 'ExternalNotificationController@create')->name('add_notification_channel')->middleware('admin');
Route::post('/ayar/bildirimKanali/duzenle', 'ExternalNotificationController@edit')->name('edit_notification_channel')->middleware('admin');
Route::post('/ayar/bildirimKanali/sil', 'ExternalNotificationController@revoke')->name('revoke_notification_channel')->middleware('admin');
Route::post('/ayar/bildirimKanali/yenile', 'ExternalNotificationController@renew')->name('renew_notification_channel')->middleware('admin');
Route::post('/user/update', 'UserController@adminUpdate')
->name('update_user')
->middleware('admin');
Route::post('/user/setting/delete', 'UserController@removeSetting')->name(
'user_setting_remove'
);
Route::post('/user/setting/update', 'UserController@updateSetting')->name(
'user_setting_update'
);
Route::post(
'/ayar/bildirimKanali/ekle',
'ExternalNotificationController@create'
)
->name('add_notification_channel')
->middleware('admin');
Route::post(
'/ayar/bildirimKanali/duzenle',
'ExternalNotificationController@edit'
)
->name('edit_notification_channel')
->middleware('admin');
Route::post(
'/ayar/bildirimKanali/sil',
'ExternalNotificationController@revoke'
)
->name('revoke_notification_channel')
->middleware('admin');
Route::post(
'/ayar/bildirimKanali/yenile',
'ExternalNotificationController@renew'
)
->name('renew_notification_channel')
->middleware('admin');
});
Route::any('/upload/{any?}', function () {
......@@ -131,17 +165,25 @@ Route::any('/upload/{any?}', function () {
}
if (!file_exists($path . "/uploads")) {
mkdir($path . "/uploads");
shell_exec("sudo chown " . cleanDash($extension_id) . ":liman " . $path . "/uploads");
shell_exec(
"sudo chown " .
cleanDash($extension_id) .
":liman " .
$path .
"/uploads"
);
shell_exec("sudo chmod 770 " . $path . "/uploads");
}
$server->setUploadDir($path . "/uploads");
$response = $server->serve();
return $response->send();
})->where('any', '.*')->middleware(['auth', 'permissions']);
})
->where('any', '.*')
->middleware(['auth', 'permissions']);
Route::post('/upload_info', function () {
request()->validate([
'key' => 'required'
'key' => 'required',
]);
$key = request('key');
$server = app('tus-server');
......@@ -149,11 +191,20 @@ Route::post('/upload_info', function () {
$extension_id = request("extension_id");
if ($extension_id) {
$extension_path = explode("/uploads/", $info['file_path'], 2)[0];
$info['file_path'] = str_replace($extension_path, '', $info['file_path']);
shell_exec("sudo chown " . cleanDash($extension_id) . ":liman " . $info['file_path']);
$info['file_path'] = str_replace(
$extension_path,
'',
$info['file_path']
);
shell_exec(
"sudo chown " .
cleanDash($extension_id) .
":liman " .
$info['file_path']
);
shell_exec("sudo chmod 770 " . $info['file_path']);
}
return $info;
})->middleware(['auth', 'permissions']);
registerModuleRoutes();
\ No newline at end of file
registerModuleRoutes();
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