Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
@include("modal-button", [
"text" => "Örnek Modal Aç",
"class" => "btn-primary",
"target_id" => "exampleModalWindow"
])// Modal göster
$("#<MODAL_IDSI>").modal("show");
// Modal gizle
$("#<MODAL_IDSI>").modal("hide");@component("modal-component", [
"id" => "exampleModalWindow",
"title" => "Örnek Modal",
"notSized" => true,
"modalDialogClasses" => "classExample",
"footer" => [
"class" => "btn-danger",
"onclick" => "modalDialogEvent()",
"text" => "What to do"
]
])
<input type="text" name="username" id="username_field" class="form-control">
<small>Eklemek istediğiniz kullanıcı adını giriniz</small>
<div class="mb-3"></div>
<input type="password" name="password" id="password_field" class="form-control">
<small>Kullanıcı şifresini giriniz</small>
@endcomponentfunction modalDialogEvent() {
showSwal("{{__('Yükleniyor...')}}", 'info');
let data = new FormData();
// exampleModalWindow modalının içerisinden username_field idsine sahip
// inputtan değeri alıyor ve gönderdiğimiz requestin içerisine ekliyoruz.
data.append("username", $("#exampleModalWindow").find("#username_field").val());
// benzer bir işlemi şifre için de yapıyoruz
// bu gönderdiğimiz değişkenlere controller tarafında
// request() yardımcı fonksiyonu ile erişeceğiz.
// örnek: request("password");
data.append("password", $("#exampleModalWindow").find("#password_field").val());
request("{{API('add_user')}}", data, function(response){
// işlem yapıldıktan sonra modal penceresini gizle.
$("#exampleModalWindow").modal("hide");
// Yükleniyor mesajını işlem bittiği için kapatıyoruz.
Swal.close();
// modal içerisindeki input değerlerini eski haline getiriyoruz.
$("#exampleModalWindow").find("input").val("");
response = JSON.parse(response);
// Başarılı olduğuna dair 2.5 saniyelik bir mesaj gösteriyoruz.
showSwal(response.message, 'success', 2500);
}, function(error){
error = JSON.parse(error);
showSwal(error.message, 'error');
});
}Geliştirdiğiniz eklentiyi çalıştırmak için Liman sunucusuna paket kurmanız gerekiyorsa, bu paketleri Liman'a nasıl otomatik kurdurabileceğinizi öğreneceğiz.
Liman eklentilerinizde belirli protokole nasıl bağlanabileceğinizi öğreneceğiz.
Liman eklentilerinin dizin yapısından ve klasörlerin ne işe yaradığını öğreneceğiz.

$connection = ldap_connect('ldaps://' . server()->ip_address); //eklentinin eklendiği sunucunun ip adresi ile LDAPS protokolünü kullanarak bağlantı açıyoruz.
ldap_bind($connection, extensionDb('clientUsername'), extensionDb('clientPassword')); //eklenti veritabanına yazdığımız keylere göre kullanıcının LDAP kullanıcı adı ve şifresiyle bind oluyoruz.
$result = ldap_search($connection, "DC=baran,DC=lab", "(cn=*)"); //base dn'e göre arama yapıyoruz.
$data = ldap_get_entries($connection, $result); //arama sonuçlarını alıyoruz.
dd($data); //dönen sonuçları debug etmek için dd helperını kullanıyoruz. composer require icewind/smb$options = new Options();
$options->setTimeOut(5);
$serverFactory = new ServerFactory($options);
$auth = new BasicAuth(extensionDb('clientUsername'), 'workgroup', extensionDb('clientPassword'));
$server = $serverFactory->createServer(server()->ip_address, $auth);
$share = $server->getShare('SYSVOL');
dd($smb->read('ORNEK_PATH'));liman@pardus:/liman/extensions/ornekeklentim$ tree
├── routes.php
├── composer.json
├── db.json
├── app
│ ├── Controllers
│ ├── Helpers
│ └── Tasks
├── lang
├── public
│ ├── css
│ └── js
├── scripts
├── vendor
└── views
├── hostname
├── layouts
├── runscript
├── sandbox
├── systeminfo
├── taskview
├── index.blade.php
└── scripts.blade.php<?php
namespace App\Controllers;
class HomeController
{
public function index()
{
return view('index');
}
}<?php
namespace App\Controllers;
use Liman\Toolkit\Shell\Command;
class UserController
{
public function add()
{
$command = Command::runSudo("useradd -p $(echo @{:password} | openssl passwd -1 -stdin) -s /bin/bash -g users @{:username}", [
"username" => request("username"),
"password" => request("password")
]);
Command::runSudo("mkhomedir_helper @{:username}", [
"username" => request("username")
]);
return respond(__("Başarıyla eklendi"), 200);
}
}Distro::debian('apt install nano -y')
->centos('yum install nano -y')
->runSudo();Distro::debian("echo 'debian'")
->centos("echo 'centos'")
->centos6("echo 'centos6'")
->centos7("echo 'centos7'")
->pardus19("echo 'pardus19'")
->pardus192("echo 'pardus19.2'")
->pardus193("echo 'pardus19.3'")
->ubuntu("echo 'ubuntu'")
->ubuntu1804("echo 'ubuntu18.04'")
->ubuntu2004("echo 'ubuntu20.04'")
->ubuntu2010("echo 'ubuntu20.10'")
->default("echo 'Hiçbiri değil'")
->run();use Liman\Toolkit\Shell\Command;echo Command::run('hostname');Command::runSudo('hostnamectl set-hostname @{:hostname}', [
'hostname' => request('hostname')
]);use Liman\Toolkit\Shell\SSHEngine;SSHEngine::init(
request('ipAddress'),
request('username'),
request('password')
);
Command::bindEngine(SSHEngine::class);
echo Command::run('hostname');use Liman\Toolkit\Formatter;echo Formatter::run('hostnamectl set-hostname @{:hostname}', [
'hostname' => request('hostname')
]);
//output: hostnamectl set-hostname pardusvalidate([
'hostname' => 'required|string'
]);{{ __("Türkçe string") }}showSwal("{{__('Yükleniyor...')}}", 'info', 2000);{
"Sandbox Elemanları": "Sandbox Components",
"Kullanıcı Ayarları": "Kullanıcı Ayarları",
"Grup Ayarları": "Grup Ayarları",
"Merhaba Dünya!": "Hello World!",
"Hostname Değiştir": "Change Hostname",
"Durdur": "Stop",
"Task çalıştırılıyor...": "Running task...",
"Görev İşleniyor": "Executing Task"
}{"message": "pardus", "status": 200}return respond("pardus", 200);return view("table", [
"value" => $files,
"title" => ["İsim", "İzinler", "Sahip", "Grup", "Dosya Boyutu", "Son Değiştirilme"],
"display" => ["name", "permissions", "user", "group", "size", "date"]
]);validate([
'username' => 'required|string',
'password' => 'required|string'
]);<?php
namespace App\Controllers;
class WidgetController
{
public function exampleWidget()
{
return respond(5);
}
}<?php
return [
"index" => "HomeController@index",
"verify" => "HomeController@verify",
"load" => "HomeController@load",
"example_widget" => "WidgetController@exampleWidget"
];showSwal("Yükleniyor...", "info", 2500);
composer require illuminate/database
composer require illuminate/events
composer require doctrine/dbalAPI("get_files")let data = new FormData()
request("url", data, function(response) {
console.log(response);
}, function(error) {
console.log(error);
});showSwal("{{__('Yükleniyor...')}}", 'info');
let data = new FormData();
request("{{API('list_files')}}", data, function(response){
$("#filesTable").html(response).find("table").dataTable(dataTablePresets("normal"));
Swal.close();
}, function(response){
response = JSON.parse(response);
showSwal(response.message, 'error');
});<?php
namespace App\Helpers;
use Illuminate\Container\Container;
use Illuminate\Database\Events\StatementPrepared;
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Events\Dispatcher;
use Illuminate\Pagination\Paginator;
use Illuminate\Pagination\LengthAwarePaginator;
use PDO;
class DB extends Capsule
{
private static $customContainer;
private static $capsule;
private static $initialized = false;
public static function init()
{
self::$customContainer = new Container();
self::$capsule = new self(self::$customContainer);
self::$capsule->addConnection([
'driver' => 'pgsql',
'port' => extensionDb('postgrePort'),
'host' => extensionDb('postgreHost'),
'username' => extensionDb('postgreUsername'),
'password' => extensionDb('postgrePassword'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => ''
]);
self::$capsule->setEventDispatcher($dispatcher = new Dispatcher());
$dispatcher->listen(StatementPrepared::class, function ($event) {
$event->statement->setFetchMode(PDO::FETCH_ASSOC);
});
self::$capsule->setAsGlobal();
self::$initialized = true;
}
public static function database(string $dbName)
{
if (!self::$initialized) {
self::init();
}
$connections = self::$customContainer['config']['database.connections'];
$connections['default']['database'] = $dbName;
self::$customContainer['config']['database.connections'] = $connections;
return self::$capsule;
}
public function __call($method, $parameters)
{
return self::$capsule::connection()->$method(...$parameters);
}
public static function __callStatic($method, $parameters)
{
return self::$capsule::connection()->$method(...$parameters);
}
}
use App\Helpers\DB;$users = DB::database('example_application')->table('users')->get();
dd($users);echo extensionDb('username');
<?php
namespace App\Tasks;
use Liman\Toolkit\Formatter;
use Liman\Toolkit\RemoteTask\Task;
class InstallPackage extends Task
{
protected $command = "DEBIAN_FRONTEND=noninteractive apt install @{:package} -qqy";
protected $sudoRequired = true;
protected $control = "apt\|dpkg";
public function __construct(array $attributes = []){
if(!isset($attributes["package"])){
throw new \Exception("Package name is required");
}
$this->attributes = $attributes;
$this->logFile = Formatter::run(
"/tmp/install-package-{:package}.txt",
["package" => $attributes["package"]]
);
$this->checkCommand = Formatter::run(
"apt list --installed | grep {:package}",
["package" => $attributes["package"]]
);
}
} public function installPackage()
{
validate([
'package_name' => 'required|string',
]);
return respond(
view('task', [
'tasks' => [
0 => [
'name' => 'InstallPackage',
'attributes' => [
'package' => request('package')
]
]
]
]),
200
);
}@component('modal-component',[
"id" => "taskModal",
"title" => "Görev İşleniyor",
])
@endcomponent function installPackage(package_name){
showSwal('{{__("Yükleniyor...")}}', 'info');
let formData = new FormData();
formData.append("package_name", package_name);
request("{{API('install_package')}}", formData, function(response){
$('#taskModal').find('.modal-body').html(JSON.parse(response).message);
$('#taskModal').modal("show");
Swal.close();
}, function(response){
let error = JSON.parse(response);
showSwal(error.message, 'error', 2000);
});
}







"<ROTA_ISMI>" => "<CONTROLLER_ISMI>@<CAGIRILACAK_FONKSIYON>"return [
"index" => "HomeController@index",
// Hostname Settings
"get_hostname" => "HostnameController@get",
"set_hostname" => "HostnameController@set",
// Systeminfo
"get_system_info" => "SystemInfoController@get",
"install_lshw" => "SystemInfoController@install",
];

sudo passwd limansudo usermod --shell /bin/bash limanssh liman@<SUNUCU_IP_ADRESINIZ>


@include("table", [
"value" => $exampleTableData,
"display" => ["name", "surname", "email", "phone", "id:id"],
"title" => ["İsim", "Soyisim", "Eposta", "Telefon", "*hidden*"],
"onclick" => "rowOnClickEvent",
"menu" => [
"Example Right Click" => [
"target" => "exampleRightClickEvent",
"icon" => "fa-file-export"
],
]
])$exampleTableData = [
[
"id" => "1",
"name" => "Havelsan",
"surname" => "Aciklab",
"email" => "aciklab.org",
"phone" => "00000000"
],
[
"id" => "2",
"name" => "Havelsan",
"surname" => "Pardus",
"email" => "pardus.org",
"phone" => "00000000"
]
];"display" => ["name", "surname", "email", "phone", "id:id"]"title" => ["İsim", "Soyisim", "Eposta", "Telefon", "*hidden*"]function lineOnClickEvent(node) {
// node satır için bize gönderilen JavaScript seçicisidir(selector)
console.log(node)
// satırımızdaki gizli olan id sütununun içeriğini almak
console.log($(node).children("#id").html())
// bu id ile örnek bir işlem gerçekleştirmek
Swal.fire(`${$(node).children("#id").html()} idli elemente tıkladınız!`)
}"menu" => [
"Kopyala" => [
"target" => "copyEvent",
"icon" => "fa-copy"
],
"Kes" => [
"target" => "cutEvent",
"icon" => "fa-cut"
],
"Yapıştır" => [
"target" => "pasteEvent",
"icon" => "fa-paste"
],
]function deleteUser(node) {
showSwal("{{__('Yükleniyor...')}}", 'info');
let data = new FormData();
data.append("username", $(node).find("#user").html());
request("{{API('delete_user')}}", data, function(response){
Swal.close();
response = JSON.parse(response);
showSwal(response.messsage, "success", 2500);
getUsers();
}, function(response){
response = JSON.parse(response);
showSwal(response.message, "error");
});
}public function list()
{
$command = Command::runSudo("ls -lah /home/liman");
$files = explode("\n", $command);
array_splice($files, 0, 1);
foreach ($files as &$file) {
$file = preg_replace('/\s+/', ' ', $file);
$file = explode(" ", $file);
$file = [
"permissions" => $file[0],
"user" => $file[2],
"group" => $file[3],
"size" => $file[4],
"date" => $file[5] . " " . $file[6] . " " . $file[7],
"name" => $file[8]
];
}
return view("table", [
"value" => $files,
"title" => ["İsim", "İzinler", "Sahip", "Grup", "Dosya Boyutu", "Son Değiştirilme"],
"display" => ["name", "permissions", "user", "group", "size", "date"]
]);
}function listFiles() {
showSwal("{{__('Yükleniyor...')}}", 'info');
let data = new FormData();
request("{{API('list_files')}}", data, function(response){
$("#filesTable").html(response).find("table").dataTable(dataTablePresets("normal"));
Swal.close();
}, function(response){
response = JSON.parse(response);
showSwal(response.message, 'error');
});
}$("#exTable").html(response).find("table").dataTable(dataTablePresets("normal"));Eklentinizi eklediğiniz sunucu üzerinde nasıl komut çalıştırır ve çıktılarını nasıl alırsınız detaylıca bahsedeceğiz.

use Liman\Toolkit\Shell\Command;$command = Command::run("hostname");$command = Command::runSudo("cat /etc/network/interfaces");Command::runSudo("touch /home/liman/@{:filename}", [
"filename" => request("filename")
]);









public function run()
{
// runScript function
// 1st parameter: filename under scripts folder STRING
// 2nd parameter: parameters STRING
// 3nd parameter: run as sudo BOOL
$script = runScript("example.py", "", false);
return respond($script, 200);
}#!/usr/bin/python3
print("Hello world!")
