diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dc1650..18b0b35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## v2.6.3 ++ Fixed #67. ++ Fixed bad preload statement. ++ Fixed wrong redirect after install in subdirs. + ## v2.6.2 + Use the font awesome web font for better performances. + Changed background default color. diff --git a/app/Controllers/Controller.php b/app/Controllers/Controller.php index 048a519..eca8a11 100644 --- a/app/Controllers/Controller.php +++ b/app/Controllers/Controller.php @@ -48,7 +48,7 @@ abstract class Controller */ protected function getUsedSpaceByUser($id): int { - $medias = $this->database->query('SELECT `uploads`.`storage_path` FROM `uploads` WHERE `user_id` = ?', $id)->fetchAll(); + $medias = $this->database->query('SELECT `uploads`.`storage_path` FROM `uploads` WHERE `user_id` = ?', $id); $totalSize = 0; diff --git a/app/Controllers/UploadController.php b/app/Controllers/UploadController.php index b284068..adc53dd 100644 --- a/app/Controllers/UploadController.php +++ b/app/Controllers/UploadController.php @@ -29,18 +29,18 @@ class UploadController extends Controller 'version' => PLATFORM_VERSION, ]; - if ($this->settings['maintenance'] && !$this->database->query('SELECT `id`, `is_admin` FROM `users` WHERE `id` = ? LIMIT 1', [$this->session->get('user_id')])->fetch()->is_admin) { + if ($this->settings['maintenance']) { $json['message'] = 'Endpoint under maintenance.'; return $response->withJson($json, 503); } if ($request->getServerParam('CONTENT_LENGTH') > stringToBytes(ini_get('post_max_size'))) { - $json['message'] = 'File too large (post_max_size too low).'; + $json['message'] = 'File too large (post_max_size too low?).'; return $response->withJson($json, 400); } if (isset($request->getUploadedFiles()['upload']) && $request->getUploadedFiles()['upload']->getError() === UPLOAD_ERR_INI_SIZE) { - $json['message'] = 'File too large (upload_max_filesize too low).'; + $json['message'] = 'File too large (upload_max_filesize too low?).'; return $response->withJson($json, 400); } diff --git a/app/helpers.php b/app/helpers.php index 920d07c..4f61174 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -140,7 +140,7 @@ if (!function_exists('route')) { function route(string $path, array $args = [], string $append = ''): string { global $app; - $uri = $app->getContainer()->get('router')->pathFor($path, $args); + $uri = $app->getContainer()->get('router')->relativePathFor($path, $args); return urlFor($uri, $append); } } diff --git a/bootstrap/app.php b/bootstrap/app.php index 7b7eb91..4e67f4b 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -47,6 +47,7 @@ $config = array_replace_recursive([ ], 'storage' => [ 'driver' => 'local', + 'path' => realpath(__DIR__ . '/') . DIRECTORY_SEPARATOR . 'storage', ], ], require BASE_DIR . 'config.php'); diff --git a/composer.json b/composer.json index 56ac57f..624cf34 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "sergix44/xbackbone", - "version": "2.6.2", + "version": "2.6.3", "description": "A lightweight ShareX PHP backend", "type": "project", "require": { diff --git a/index.php b/index.php index a284fca..668c5b7 100644 --- a/index.php +++ b/index.php @@ -2,7 +2,7 @@ (PHP_MAJOR_VERSION >= 7 && PHP_MINOR_VERSION >= 1) ?: die('Sorry, PHP 7.1 or above is required to run XBackBone.'); require __DIR__ . '/vendor/autoload.php'; -define('BASE_DIR', __DIR__ . DIRECTORY_SEPARATOR); +define('BASE_DIR', realpath(__DIR__) . DIRECTORY_SEPARATOR); define('PLATFORM_VERSION', json_decode(file_get_contents('composer.json'))->version); $app = require_once __DIR__ . '/bootstrap/app.php'; diff --git a/install/index.php b/install/index.php index 660f6f5..2f45cfc 100644 --- a/install/index.php +++ b/install/index.php @@ -24,17 +24,19 @@ use Superbalist\Flysystem\GoogleStorage\GoogleStorageAdapter; define('PLATFORM_VERSION', json_decode(file_get_contents(__DIR__ . '/../composer.json'))->version); +// default config $config = [ - 'base_url' => isset($_SERVER['HTTPS']) ? 'https://' . $_SERVER['HTTP_HOST'] : 'http://' . $_SERVER['HTTP_HOST'], + 'base_url' => str_replace('/install/', '', (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), 'displayErrorDetails' => true, 'db' => [ 'connection' => 'sqlite', - 'dsn' => 'resources/database/xbackbone.db', + 'dsn' => realpath(__DIR__ . '/../') . implode(DIRECTORY_SEPARATOR, ['resources', 'database', 'xbackbone.db']), 'username' => null, 'password' => null, ], 'storage' => [ 'driver' => 'local', + 'path' => realpath(__DIR__ . '/../') . DIRECTORY_SEPARATOR . 'storage', ], ]; @@ -110,8 +112,7 @@ $container['storage'] = function ($container) use (&$config) { } }; -function migrate($config) -{ +function migrate($config) { $firstMigrate = false; if ($config['db']['connection'] === 'sqlite' && !file_exists(__DIR__ . '/../' . $config['db']['dsn'])) { touch(__DIR__ . '/../' . $config['db']['dsn']); @@ -204,7 +205,6 @@ $app->get('/', function (Request $request, Response $response) { return $this->view->render($response, 'install.twig', [ 'installed' => $installed, - 'default_local' => realpath(__DIR__ . '/../') . DIRECTORY_SEPARATOR . 'storage', ]); }); @@ -327,7 +327,7 @@ $app->post('/', function (Request $request, Response $response) use (&$config) { // Installed successfully, destroy the installer session session_destroy(); - return redirect($response, '/../?afterInstall=true'); + return $response->withRedirect("{$config['base_url']}/?afterInstall=true"); }); $app->run(); \ No newline at end of file diff --git a/install/templates/install.twig b/install/templates/install.twig index c52de74..e0770c6 100644 --- a/install/templates/install.twig +++ b/install/templates/install.twig @@ -80,7 +80,7 @@
- +
diff --git a/resources/templates/base.twig b/resources/templates/base.twig index 54e9545..2198ac8 100644 --- a/resources/templates/base.twig +++ b/resources/templates/base.twig @@ -4,11 +4,11 @@ {% block title %}Default{% endblock %} | {{ config.app_name }} - + - +