diff --git a/config.example.php b/config.example.php index 5610754..c74cb50 100644 --- a/config.example.php +++ b/config.example.php @@ -16,7 +16,8 @@ return [ 'auth' => true ], 'quickupload' => [ - 'auth' => true + 'auth' => true, + 'alias' => ['share'] ], 'logator' => [ 'alias' => ['logme'] diff --git a/configure_nginx.php b/configure_nginx.php index 9837f79..87df4ff 100644 --- a/configure_nginx.php +++ b/configure_nginx.php @@ -13,17 +13,25 @@ if (!file_exists($path)) { require('./load_config.php'); $template = file_get_contents('./nginx.conf.template'); -$phpSocket = '/var/run/php/php8.0-fpm.sock'; +$phpSocket = $argv[1] ?? '/var/run/php/php8.0-fpm.sock'; foreach ($config['modules'] as $moduleName => $moduleConfig) { $domains = array_merge([$moduleName], $moduleConfig['alias'] ?? []); $domains = array_map(fn ($d) => $d . '.' . $config['domain'], $domains); $serverName = implode(' ', $domains); + $nginxConfPath = './modules/' . $moduleName . '/nginx_' . $moduleName . '.conf'; + $customConfig = ''; + if (file_exists($nginxConfPath)) { + $customConfig = file_get_contents($nginxConfPath); + $customConfig = str_replace('{{ROOT_PATH}}', $appBasePath, $customConfig); + } + $nginxConfig = $template; $nginxConfig = str_replace('{{ROOT_PATH}}', $appBasePath, $nginxConfig); $nginxConfig = str_replace('{{SERVER_NAME}}', $serverName, $nginxConfig); $nginxConfig = str_replace('{{PHP_SOCKET}}', $phpSocket, $nginxConfig); + $nginxConfig = str_replace('{{CUSTOM_CONFIG}}', $customConfig, $nginxConfig); file_put_contents($path . '/' . $domains[0], $nginxConfig); echo "> Wrote " . strlen($nginxConfig) . " bytes in " . $path . '/' . $domains[0] . "\n"; diff --git a/modules/quickupload/nginx_quickupload.conf b/modules/quickupload/nginx_quickupload.conf new file mode 100644 index 0000000..34f1ee3 --- /dev/null +++ b/modules/quickupload/nginx_quickupload.conf @@ -0,0 +1,4 @@ +location /file/ { + alias {{ROOT_PATH}}/tmp/quickupload; + autoindex off; +} diff --git a/modules/quickupload/quickupload.php b/modules/quickupload/quickupload.php index dc6bd6f..541a828 100644 --- a/modules/quickupload/quickupload.php +++ b/modules/quickupload/quickupload.php @@ -28,19 +28,55 @@ if ($_SERVER['REQUEST_URI'] === '/list') { exit(); } -if (isset($_FILES['file'])) { - $f = $_FILES['file']; - copy($f['tmp_name'], $path . '/' . uniqid() . '_' . slugify($f['name'])); +$file = null; +$isAutoGeneratedFileName = false; +if (isset($_POST['name']) && !empty($_POST['name'])) { + $fileName = $_POST['name']; +} else { + $fileName = generateRandomString(6); + $isAutoGeneratedFileName = true; +} + + +if (isset($_POST['text']) && !empty($_POST['text'])) { + if ($isAutoGeneratedFileName) $fileName .= '.txt'; + file_put_contents($path . '/' . $fileName, $_POST['text']); + $file = true; +} +else if (isset($_FILES['file'])) { + $file = $_FILES['file']; + if ($isAutoGeneratedFileName) $fileName .= '_' . slugify($file['name']); + copy($file['tmp_name'], $path . '/' . $fileName); +} + +if ($file !== null) { ?>
- File uploaded! + File uploaded! Click here to find it
-

QuickUpload

+ + + +QuickUpload + + +

QuickUpload

- - - -
\ No newline at end of file + Upload a direct file + +
+
+ Or paste your data: +
+ + +
+
+ + + + diff --git a/nginx.conf.template b/nginx.conf.template index c3d69b4..09297ea 100644 --- a/nginx.conf.template +++ b/nginx.conf.template @@ -5,6 +5,7 @@ server { location / { try_files $uri $uri/ /index.php?$args; } + {{CUSTOM_CONFIG}} location ^~ /wp-admin { return 403; }