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

Config files added

üst c7d97632
......@@ -76,7 +76,7 @@ class PHPSandbox implements Sandbox
if (!user()->isAdmin()) {
$extensionJson = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -112,7 +112,7 @@ class PHPSandbox implements Sandbox
];
$functionsPath =
env('EXTENSIONS_PATH') .
"/liman/extensions/" .
strtolower(extension()->name) .
"/views/functions.php";
......
......@@ -67,7 +67,7 @@ class PythonSandbox implements Sandbox
if (!user()->isAdmin()) {
$extensionJson = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -103,7 +103,7 @@ class PythonSandbox implements Sandbox
];
$functionsPath =
env('EXTENSIONS_PATH') .
"/liman/extensions/" .
strtolower(extension()->name) .
"/views/functions.py";
......
......@@ -61,15 +61,15 @@ class LoginController extends Controller
$request->filled('remember')
);
if (!$flag) {
event('login_attempt', $credientials);
}
Event::listen('login_attempt_success', function ($data) {
Event::listen('login_attempt_success', function ($data) use(&$flag){
$this->guard()->login($data, request()->filled('remember'));
$flag = true;
});
if (!$flag) {
event('login_attempt', $credientials);
}
return $flag;
}
......
......@@ -53,7 +53,7 @@ class MainController extends Controller
public function download()
{
// Generate Extension Folder Path
$path = env("EXTENSIONS_PATH") . strtolower(extension()->name);
$path = "/liman/extensions/" . strtolower(extension()->name);
$tempPath = "/tmp/" . Str::random() . ".zip";
// Zip the current extension
......@@ -204,7 +204,7 @@ class MainController extends Controller
shell_exec('sudo useradd -r -s /bin/sh ' . cleanDash($new->id));
}
$extension_folder = env('EXTENSIONS_PATH') . strtolower($json["name"]);
$extension_folder = "/liman/extensions/" . strtolower($json["name"]);
$passPath = env('KEYS_PATH') . DIRECTORY_SEPARATOR . $new->id;
file_put_contents($passPath, Str::random(32));
......@@ -255,7 +255,7 @@ class MainController extends Controller
public function newExtension()
{
$name = trim(request('name'));
$folder = env('EXTENSIONS_PATH') . strtolower($name);
$folder = "/liman/extensions/" . strtolower($name);
preg_match('/[A-Za-z]+/', request("name"), $output);
if (empty($output) || $output[0] != $name) {
......
......@@ -26,7 +26,7 @@ class OneController extends Controller
{
$extension = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -194,7 +194,7 @@ class OneController extends Controller
{
$extension = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -243,7 +243,7 @@ class OneController extends Controller
try {
shell_exec(
"sudo rm -r " .
env('EXTENSIONS_PATH') .
"/liman/extensions/" .
strtolower(extension()->name)
);
} catch (\Exception $exception) {
......@@ -277,7 +277,7 @@ class OneController extends Controller
public function publicFolder()
{
$basePath =
env('EXTENSIONS_PATH') . strtolower(extension()->name) . "/public/";
"/liman/extensions/" . strtolower(extension()->name) . "/public/";
$targetPath = $basePath . base64_decode(request('path'));
......
......@@ -154,7 +154,7 @@ class InternalController extends Controller
public function runScript()
{
$filePath =
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
"/scripts/" .
request("scriptName");
......@@ -316,10 +316,10 @@ class InternalController extends Controller
*/
public function addProxyConfig()
{
if (!is_dir(env("KEYS_PATH") . "vnc")) {
mkdir(env("KEYS_PATH") . "vnc", 0700);
if (!is_dir("/liman/keys/" . "vnc")) {
mkdir("/liman/keys/" . "vnc", 0700);
}
$writer = fopen(env("KEYS_PATH") . "vnc/config", "a+");
$writer = fopen("/liman/keys/" . "vnc/config", "a+");
$hostname = request('hostname');
$port = request('port');
$token = Str::uuid();
......
......@@ -6,8 +6,10 @@ use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\UserSettings;
use App\Permission;
use App\Server;
use App\Classes\Sandbox\PHPSandbox;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
class MainController extends Controller
{
......@@ -25,7 +27,7 @@ class MainController extends Controller
{
$this->extension = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -87,10 +89,17 @@ class MainController extends Controller
: "info",
]);
}
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()
]);
}
}
......@@ -140,7 +149,7 @@ class MainController extends Controller
$function = request("function_name");
$extensionJson = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -188,4 +197,57 @@ class MainController extends Controller
$output = shell_exec($command);
return [$output, $before->diffInMilliseconds(Carbon::now()) / 1000];
}
private function getNavigationServers()
{
$navServers = DB::select(
"SELECT * FROM \"server_groups\" WHERE \"servers\" LIKE \"%" .
server()->id .
"%\""
);
$cleanServers = [];
foreach ($navServers as $rawServers) {
$servers = explode(",", $rawServers->servers);
foreach ($servers as $server) {
if (Permission::can(user()->id, "server", "id", $server)) {
array_push($cleanServers, $server);
}
}
}
$cleanServers = array_unique($cleanServers);
$cleanExtensions = [];
$serverObjects = Server::find($cleanServers);
unset($cleanServers);
foreach ($serverObjects as $server) {
$cleanExtensions[$server->id . ":" . $server->name] = $server
->extensions()
->pluck('name', 'id')
->toArray();
}
if (empty($cleanExtensions)) {
$cleanExtensions[server()->id . ":" . server()->name] = server()
->extensions()
->pluck('name', 'id')
->toArray();
}
$last = [];
foreach ($cleanExtensions as $serverobj => $extensions) {
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] : [];
array_push($current, [
"id" => $server_id,
"name" => $server_name,
]);
$last[$prefix] = $current;
}
}
return $last;
}
}
......@@ -23,9 +23,7 @@ class SettingsController extends Controller
public function saveSettings()
{
if (intval(request('ext_count')) > 0) {
setEnv([
"NAV_EXTENSION_HIDE_COUNT" => request('ext_count'),
]);
config(['liman.nav_extension_hide_count' => request('ext_count')]);
return respond('Ayarlar başarıyla kaydedildi.');
} else {
return respond('Bu ayar minimum 1 olmalıdır.', 201);
......@@ -41,7 +39,7 @@ class SettingsController extends Controller
{
// Go through all files and list them as tree style in array.
$files = $this->tree(
env('EXTENSIONS_PATH') . strtolower(extension()->name)
"/liman/extensions/" . strtolower(extension()->name)
);
system_log(7, "EXTENSION_SETTINGS_PAGE", [
......@@ -53,7 +51,7 @@ class SettingsController extends Controller
]);
$extension = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -62,7 +60,7 @@ class SettingsController extends Controller
);
$extension["language"] = "php";
file_put_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json",
......@@ -122,7 +120,7 @@ class SettingsController extends Controller
{
$extension = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -169,7 +167,7 @@ class SettingsController extends Controller
$extension["version_code"] = 1;
}
file_put_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json",
......@@ -188,7 +186,7 @@ class SettingsController extends Controller
{
$extension = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -224,7 +222,7 @@ class SettingsController extends Controller
}
file_put_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json",
......@@ -243,7 +241,7 @@ class SettingsController extends Controller
{
$extension = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -268,7 +266,7 @@ class SettingsController extends Controller
}
file_put_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json",
......@@ -288,7 +286,7 @@ class SettingsController extends Controller
$function_name = request('function_name');
$extension = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -320,7 +318,7 @@ class SettingsController extends Controller
$function_name = request('function_name');
$extension = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -350,7 +348,7 @@ class SettingsController extends Controller
}
file_put_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json",
......@@ -371,7 +369,7 @@ class SettingsController extends Controller
$extension = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -402,7 +400,7 @@ class SettingsController extends Controller
$extension["version_code"] = 1;
}
file_put_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json",
......@@ -424,7 +422,7 @@ class SettingsController extends Controller
{
$extension = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -451,7 +449,7 @@ class SettingsController extends Controller
$extension["version_code"] = 1;
}
file_put_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json",
......@@ -470,7 +468,7 @@ class SettingsController extends Controller
{
$extension = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -505,7 +503,7 @@ class SettingsController extends Controller
$extension["version_code"] = 1;
}
file_put_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json",
......@@ -524,7 +522,7 @@ class SettingsController extends Controller
{
$extension = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -555,7 +553,7 @@ class SettingsController extends Controller
$extension["version_code"] = 1;
}
file_put_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json",
......
......@@ -17,7 +17,7 @@ class MainController extends Controller
request('port'),
$errno,
$errstr,
intval(env('SERVER_CONNECTION_TIMEOUT')) / 1000
intval(config('liman.server_connection_timeout')) / 1000
);
if (is_resource($status)) {
return respond("Sunucuya başarıyla erişim sağlandı.", 200);
......
......@@ -80,7 +80,7 @@ class OneController extends Controller
extension()->service,
$errno,
$errstr,
intval(env('SERVER_CONNECTION_TIMEOUT')) / 1000
intval(config('liman.server_connection_timeout')) / 1000
);
$flag = is_resource($status);
} else {
......
......@@ -151,7 +151,7 @@ class MainController extends Controller
{
$extension = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -163,7 +163,7 @@ class MainController extends Controller
: [];
$lang = session('locale');
$file =
env('EXTENSIONS_PATH') .
"/liman/extensions/" .
strtolower(extension()->name) .
"/lang/" .
$lang .
......@@ -280,7 +280,7 @@ class MainController extends Controller
{
$extension = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(request('extension_name')) .
DIRECTORY_SEPARATOR .
"db.json"
......
......@@ -15,7 +15,7 @@ class MainController extends Controller
->user()
->isAdmin() &&
Widget::where("user_id", auth()->user()->id)->count() >
env("USER_WIDGET_COUNT")
intval(config('liman.user_widget_count'))
) {
return respond(
"Bileşen kotanızı aştınız, yeni widget ekleyemezsiniz"
......
......@@ -25,7 +25,7 @@ class OneController extends Controller
$extension = Extension::one($widget->extension_id);
$extensionData = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension($widget->extension_id)->name) .
DIRECTORY_SEPARATOR .
"db.json"
......@@ -111,7 +111,7 @@ class OneController extends Controller
{
$extension = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower(extension()->name) .
DIRECTORY_SEPARATOR .
"db.json"
......
......@@ -193,7 +193,7 @@ if (!function_exists('retrieveCertificate')) {
"ssl://" . $hostname . ":" . $port,
$errno,
$errstr,
intval(env('SERVER_CONNECTION_TIMEOUT')),
intval(config('liman.server_connection_timeout')),
STREAM_CLIENT_CONNECT,
$get
);
......@@ -207,7 +207,7 @@ if (!function_exists('retrieveCertificate')) {
"tlsv1.1://" . $hostname . ":" . $port,
$errno,
$errstr,
intval(env('SERVER_CONNECTION_TIMEOUT')),
intval(config('liman.server_connection_timeout')),
STREAM_CLIENT_CONNECT,
$get
);
......
......@@ -32,7 +32,7 @@ class Server
server()->control_port,
$errno,
$errstr,
intval(env('SERVER_CONNECTION_TIMEOUT')) / 1000
intval(config('liman.server_connection_timeout')) / 1000
);
if (is_resource($status)) {
return $next($request);
......
......@@ -13,7 +13,7 @@ class ServerApi
server()->control_port,
$errno,
$errstr,
intval(env('SERVER_CONNECTION_TIMEOUT')) / 1000
intval(config('liman.server_connection_timeout')) / 1000
);
if (is_resource($status)) {
return $next($request);
......
......@@ -110,11 +110,11 @@ class ExtensionJob implements ShouldQueue
$extensionDb = null
) {
$functions =
env('EXTENSIONS_PATH') .
"/liman/extensions/" .
strtolower($extensionObj["name"]) .
"/views/functions.php";
$combinerFile = env('SANDBOX_PATH') . "index.php";
$combinerFile = "/liman/sandbox/php/index.php";
$server = json_encode($serverObj->toArray());
......@@ -166,7 +166,7 @@ class ExtensionJob implements ShouldQueue
if (!$this->user->isAdmin()) {
$extensionJson = json_decode(
file_get_contents(
env("EXTENSIONS_PATH") .
"/liman/extensions/" .
strtolower($extensionObj->name) .
DIRECTORY_SEPARATOR .
"db.json"
......
......@@ -39,7 +39,7 @@ class RouteServiceProvider extends ServiceProvider
$this->mapWebRoutes();
if (env("EXTENSION_DEVELOPER_MODE")) {
if (config('liman.extension_developer_mode') == true) {
$this->mapExtensionDeveloperRoutes();
}
}
......
......@@ -112,7 +112,7 @@ class Server extends Model
$this->control_port,
$errno,
$errstr,
env('SERVER_CONNECTION_TIMEOUT')
intval(config('liman.server_connection_timeout'))
)
);
}
......@@ -138,7 +138,7 @@ class Server extends Model
$this->control_port,
$errno,
$errstr,
env('SERVER_CONNECTION_TIMEOUT')
intval(config('liman.server_connection_timeout'))
)
)
) {
......
......@@ -14,7 +14,7 @@ return [
|
*/
'default' => env('BROADCAST_DRIVER', 'null'),
'default' => env('BROADCAST_DRIVER', 'pusher'),
/*
|--------------------------------------------------------------------------
......
......@@ -16,7 +16,7 @@ return [
|
*/
'default' => env('CACHE_DRIVER', 'file'),
'default' => env('CACHE_DRIVER', 'array'),
/*
|--------------------------------------------------------------------------
......
......@@ -12,7 +12,7 @@ return [
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
'default' => env('DB_CONNECTION', 'sqlite'),
/*
|--------------------------------------------------------------------------
......@@ -33,7 +33,7 @@ return [
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', env('DB_PATH')),
'database' => '/liman/database/liman.sqlite',
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
......
<?php
return [
"version" => "1.0",
"server_connection_timeout" => 5000, //ms
"user_widget_count" => 10,
"extension_developer_mode" => true,
"nav_extension_hide_count" => 10,
"widget_refresh_time" => 30000, //ms
"liman_restricted" => false
];
\ No newline at end of file
......@@ -26,7 +26,7 @@
"target_id" => "extensionUpload",
"text" => "Yükle"
])
@if(env("EXTENSION_DEVELOPER_MODE"))
@if(config('liman.extension_developer_mode') == true)
@include('modal-button',[
"class" => "btn-secondary",
"target_id" => "extensionExport",
......@@ -63,7 +63,7 @@
"icon" => " context-menu-icon-delete"
]
],
"onclick" => env("EXTENSION_DEVELOPER_MODE") ? "details" : ""
"onclick" => config('liman.extension_developer_mode') ? "details" : ""
])
</div>
</div>
......@@ -90,7 +90,7 @@
],
"submit_text" => "Yükle"
])
@if(env("EXTENSION_DEVELOPER_MODE"))
@if(config('liman.extension_developer_mode') == true)
@php
$input_extensions = [];
foreach(extensions() as $extension){
......@@ -142,7 +142,7 @@
])
<script>
$('input[name=ext_count]').val('{{env('NAV_EXTENSION_HIDE_COUNT', 10)}}');
$('input[name=ext_count]').val('{{intval(config('liman.nav_extension_hide_count'))}}');
function downloadFile(form){
window.location.assign('/indir/eklenti/' + form.getElementsByTagName('select')[0].value);
setTimeout(function(){
......@@ -200,7 +200,7 @@
return false;
}
@if(env("EXTENSION_DEVELOPER_MODE"))
@if(config('liman.extension_developer_mode') == true)
function details(element){
let extension_id = element.querySelector('#extension_id').innerHTML;
window.location.href = "/eklentiler/" + extension_id
......
@extends('layouts.app')
@section('content')
@php($extension = json_decode(file_get_contents(env("EXTENSIONS_PATH") .strtolower(extension()->name) . DIRECTORY_SEPARATOR . "db.json"),true))
@php($extension = json_decode(file_get_contents("/liman/extensions/" .strtolower(extension()->name) . DIRECTORY_SEPARATOR . "db.json"),true))
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
......
@if(env('LIMAN_RESTRICTED') == true && !user()->isAdmin())
@include('extension_pages.server_restricted',["view" => $view]);
@php(die())
@endif
@php