Skip to content

Commit fcf2e8f

Browse files
committed
init
0 parents  commit fcf2e8f

File tree

6 files changed

+248
-0
lines changed

6 files changed

+248
-0
lines changed

Plugin.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace App\Vito\Plugins\Vitodeploy\TinyFileManager;
4+
5+
use App\DTOs\DynamicField;
6+
use App\DTOs\DynamicForm;
7+
use App\Plugins\AbstractPlugin;
8+
use App\Plugins\RegisterSiteType;
9+
use App\Plugins\RegisterViews;
10+
11+
class Plugin extends AbstractPlugin
12+
{
13+
protected string $name = 'Tiny File Manager Plugin';
14+
15+
protected string $description = 'Tiny File Manager plugin for VitoDeploy';
16+
17+
public function boot(): void
18+
{
19+
RegisterViews::make('vitodeploy-tiny-file-manager')
20+
->path(__DIR__.'/views')
21+
->register();
22+
23+
RegisterSiteType::make(TinyFileManager::id())
24+
->label('Tiny File Manager')
25+
->handler(TinyFileManager::class)
26+
->form(DynamicForm::make([
27+
DynamicField::make('php_version')
28+
->component()
29+
->label('PHP Version'),
30+
DynamicField::make('password')
31+
->text()
32+
->label('Admin Password'),
33+
DynamicField::make('root_path')
34+
->text()
35+
->label('Wich path you want the file manager to have access to?')
36+
->default('/home/vito'),
37+
]))
38+
->register();
39+
}
40+
}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Tiny File Manager plugin for VitoDeploy
2+
3+
[Documentation](https://vitodeploy.com/docs/plugins/tiny-file-manager)

TinyFileManager.php

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
namespace App\Vito\Plugins\Vitodeploy\TinyFileManager;
4+
5+
use App\SiteTypes\PHPBlank;
6+
use Illuminate\Validation\Rule;
7+
8+
class TinyFileManager extends PHPBlank
9+
{
10+
public static function id(): string
11+
{
12+
return 'tiny-file-manager';
13+
}
14+
15+
public function createRules(array $input): array
16+
{
17+
return [
18+
'php_version' => [
19+
'required',
20+
Rule::in($this->site->server->installedPHPVersions()),
21+
],
22+
'password' => [
23+
'required',
24+
],
25+
'root_path' => [
26+
'nullable',
27+
],
28+
];
29+
}
30+
31+
public function createFields(array $input): array
32+
{
33+
return [
34+
'web_directory' => '',
35+
'php_version' => $input['php_version'] ?? '',
36+
];
37+
}
38+
39+
public function data(array $input): array
40+
{
41+
return [
42+
'password' => password_hash($input['password'], PASSWORD_DEFAULT) ?? '',
43+
'root_path' => $input['root_path'] ?? '/home/'.$this->site->user,
44+
];
45+
}
46+
47+
/**
48+
* @throws SSHError
49+
*/
50+
public function install(): void
51+
{
52+
parent::install();
53+
54+
$download = view('vitodeploy-tiny-file-manager::download', [
55+
'path' => $this->site->getWebDirectoryPath(),
56+
]);
57+
$this->site->server->ssh($this->site->user)->exec(
58+
$download,
59+
'download-tinyfilemanager',
60+
$this->site->id
61+
);
62+
63+
$config = '<?php'."\n".view('vitodeploy-tiny-file-manager::config', [
64+
'password' => $this->site->type_data['password'],
65+
'rootPath' => $this->site->type_data['root_path'],
66+
]);
67+
$this->site->server->ssh($this->site->user)->write(
68+
$this->site->getWebDirectoryPath().'/config.php',
69+
$config,
70+
$this->site->user
71+
);
72+
}
73+
}

config.blade.php

Whitespace-only changes.

views/config.blade.php

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*
2+
#################################################################################################################
3+
This is an OPTIONAL configuration file. rename this file into config.php to use this configuration
4+
The role of this file is to make updating of "tinyfilemanager.php" easier.
5+
So you can:
6+
-Feel free to remove completely this file and configure "tinyfilemanager.php" as a single file application.
7+
or
8+
-Put inside this file all the static configuration you want and forgot to configure "tinyfilemanager.php".
9+
#################################################################################################################
10+
*/
11+
12+
// Auth with login/password
13+
// set true/false to enable/disable it
14+
// Is independent from IP white- and blacklisting
15+
$use_auth = true;
16+
17+
// Login user name and password
18+
// Users: array('Username' => 'Password', 'Username2' => 'Password2', ...)
19+
// Generate secure password hash - https://tinyfilemanager.github.io/docs/pwd.html
20+
$auth_users = array(
21+
'admin' => '{{ $password }}',
22+
);
23+
24+
// Readonly users
25+
// e.g. array('users', 'guest', ...)
26+
$readonly_users = array(
27+
'user'
28+
);
29+
30+
// Enable highlight.js (https://highlightjs.org/) on view's page
31+
$use_highlightjs = true;
32+
33+
// highlight.js style
34+
// for dark theme use 'ir-black'
35+
$highlightjs_style = 'vs';
36+
37+
// Enable ace.js (https://ace.c9.io/) on view's page
38+
$edit_files = true;
39+
40+
// Default timezone for date() and time()
41+
// Doc - http://php.net/manual/en/timezones.php
42+
$default_timezone = 'Etc/UTC'; // UTC
43+
44+
// Root path for file manager
45+
// use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder'
46+
$root_path = '{{ $rootPath }}';
47+
48+
// Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder'
49+
// Will not working if $root_path will be outside of server document root
50+
$root_url = '';
51+
52+
// Server hostname. Can set manually if wrong
53+
$http_host = $_SERVER['HTTP_HOST'];
54+
55+
// user specific directories
56+
// array('Username' => 'Directory path', 'Username2' => 'Directory path', ...)
57+
$directories_users = array();
58+
59+
// input encoding for iconv
60+
$iconv_input_encoding = 'UTF-8';
61+
62+
// date() format for file modification date
63+
// Doc - https://www.php.net/manual/en/datetime.format.php
64+
$datetime_format = 'd.m.y H:i:s';
65+
66+
// Allowed file extensions for create and rename files
67+
// e.g. 'txt,html,css,js'
68+
$allowed_file_extensions = '';
69+
70+
// Allowed file extensions for upload files
71+
// e.g. 'gif,png,jpg,html,txt'
72+
$allowed_upload_extensions = '';
73+
74+
// Favicon path. This can be either a full url to an .PNG image, or a path based on the document root.
75+
// full path, e.g http://example.com/favicon.png
76+
// local path, e.g images/icons/favicon.png
77+
$favicon_path = '';
78+
79+
// Files and folders to excluded from listing
80+
// e.g. array('myfile.html', 'personal-folder', '*.php', ...)
81+
$exclude_items = array('');
82+
83+
// Online office Docs Viewer
84+
// Availabe rules are 'google', 'microsoft' or false
85+
// google => View documents using Google Docs Viewer
86+
// microsoft => View documents using Microsoft Web Apps Viewer
87+
// false => disable online doc viewer
88+
$online_viewer = 'google';
89+
90+
// Sticky Nav bar
91+
// true => enable sticky header
92+
// false => disable sticky header
93+
$sticky_navbar = true;
94+
95+
// Path display mode when viewing file information
96+
// 'full' => show full path
97+
// 'relative' => show path relative to root_path
98+
// 'host' => show path on the host
99+
$path_display_mode = 'full';
100+
101+
// max upload file size
102+
$max_upload_size_bytes = 5000;
103+
104+
// Possible rules are 'OFF', 'AND' or 'OR'
105+
// OFF => Don't check connection IP, defaults to OFF
106+
// AND => Connection must be on the whitelist, and not on the blacklist
107+
// OR => Connection must be on the whitelist, or not on the blacklist
108+
$ip_ruleset = 'OFF';
109+
110+
// Should users be notified of their block?
111+
$ip_silent = true;
112+
113+
// IP-addresses, both ipv4 and ipv6
114+
$ip_whitelist = array(
115+
'127.0.0.1', // local ipv4
116+
'::1' // local ipv6
117+
);
118+
119+
// IP-addresses, both ipv4 and ipv6
120+
$ip_blacklist = array(
121+
'0.0.0.0', // non-routable meta ipv4
122+
'::' // non-routable meta ipv6
123+
);
124+
125+
?>

views/download.blade.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
curl -L -o tinyfilemanager.php \
2+
$(curl -s https://api.github.com/repos/prasathmani/tinyfilemanager/releases/latest \
3+
| grep '"tag_name"' \
4+
| cut -d '"' -f 4 \
5+
| xargs -I {} echo https://raw.githubusercontent.com/prasathmani/tinyfilemanager/{}/tinyfilemanager.php)
6+
7+
mv tinyfilemanager.php {{ $path }}/index.php

0 commit comments

Comments
 (0)