diff --git a/CHANGELOG.md b/CHANGELOG.md index 81111a38..6ef81079 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v2.6.1 ++ Fixed bad redirects on the web installer (#62). ++ Improved shell commands. ++ Added alert if required extensions are not loaded. ++ Updated translations. + ## v2.6 + Added support to use AWS S3, Google Cloud Storage, Dropbox and FTP(s) accounts as storage location. + Fixed missing icon. diff --git a/README.md b/README.md index e4c39cdc..53f18825 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,11 @@ XBackBone is a simple, self-hosted, lightweight PHP backend for the instant shar ## Features + Supports every upload type from ShareX. ++ Low memory footprint. ++ Multiple backends support: Local storage, AWS S3, Google Cloud, Dropbox, FTP. + Code uploads syntax highlighting. + Video uploads player. -+ Files upload download page. ++ Files preview page. + Multi language support. + User management, multi user features and roles. + Public and private uploads. @@ -16,9 +18,15 @@ XBackBone is a simple, self-hosted, lightweight PHP backend for the instant shar + Auto config generator for ShareX. + Share to Telegram. + Linux client tools supported via a custom script. ++ Direct downloads using curl or wget commands. ## How to Install -XBackBone require PHP >= `7.1`, writable storage path and PDO, with installed the required extensions (ex. `php-sqlite3` for SQLite, `php-gd` and `php-json`). +XBackBone require PHP >= `7.1`, writable storage path and PDO, with installed the required extensions: ++ `php-sqlite3` for SQLite ++ `php-mysql` for MariaDB/MySQL ++ `php-gd` ++ `php-json` ++ `php-intl` ### Web installation + **[release, stable]** Download latest release from GitHub: [Latest Release](https://github.com/SergiX44/XBackBone/releases/latest) @@ -56,6 +64,7 @@ return [ ```sh php bin/migrate --install ``` ++ Delete the `/install` directory. + Now just login with `admin/admin`, **be sure to change these credentials after your first login**. ## How to update diff --git a/app/helpers.php b/app/helpers.php index 45dff362..ecfe3265 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -92,7 +92,7 @@ function cleanDirectory($path) */ function redirect(\Slim\Http\Response $response, string $path, $args = [], $status = null) { - if ($path === '/' || $path === './' || substr($path, 0, 1) === '/') { + if (substr($path, 0, 1) === '/' || substr($path, 0, 3) === '../' || substr($path, 0, 2) === './') { $url = urlFor($path); } else { $url = route($path, $args); diff --git a/bin/clean b/bin/clean index 5724a7ac..4fd81b53 100644 --- a/bin/clean +++ b/bin/clean @@ -1,12 +1,12 @@ #!/usr/bin/env php name && $migration->migrated) { $continue = true; break; - } elseif (basename($file) === $migration->name && !$migration->migrated) { + } else if (basename($file) === $migration->name && !$migration->migrated) { $exists = true; break; } @@ -86,4 +88,11 @@ if (isset($argv[1]) && $argv[1] === '--install') { DB::doQuery("INSERT INTO `users` (`email`, `username`, `password`, `is_admin`, `user_code`) VALUES ('admin@example.com', 'admin', ?, 1, ?)", [password_hash('admin', PASSWORD_DEFAULT), substr(md5(microtime()), rand(0, 26), 5)]); } +if (file_exists(__DIR__ . '/../install')) { + removeDirectory(__DIR__ . '/../install'); +} + +include __DIR__ . '/clean'; + echo 'Done.' . PHP_EOL; +exit(0); \ No newline at end of file diff --git a/bin/theme b/bin/theme index 6a600dad..f44dd251 100644 --- a/bin/theme +++ b/bin/theme @@ -1,12 +1,14 @@ #!/usr/bin/env php =5.5.0", "pimple/pimple": "^3.0", @@ -1358,25 +1361,25 @@ "MIT" ], "authors": [ - { - "name": "Rob Allen", - "email": "rob@akrabat.com", - "homepage": "http://akrabat.com" - }, { "name": "Josh Lockhart", "email": "hello@joshlockhart.com", "homepage": "https://joshlockhart.com" }, - { - "name": "Gabriel Manricks", - "email": "gmanricks@me.com", - "homepage": "http://gabrielmanricks.com" - }, { "name": "Andrew Smith", "email": "a.smith@silentworks.co.uk", "homepage": "http://silentworks.co.uk" + }, + { + "name": "Rob Allen", + "email": "rob@akrabat.com", + "homepage": "http://akrabat.com" + }, + { + "name": "Gabriel Manricks", + "email": "gmanricks@me.com", + "homepage": "http://gabrielmanricks.com" } ], "description": "Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs", @@ -1387,7 +1390,7 @@ "micro", "router" ], - "time": "2019-04-16T16:47:29+00:00" + "time": "2019-08-20T18:46:05+00:00" }, { "name": "slim/twig-view", @@ -1532,9 +1535,9 @@ "authors": [ { "name": "Alex Vanderbist", - "role": "Developer", "email": "alex.vanderbist@gmail.com", - "homepage": "https://spatie.be" + "homepage": "https://spatie.be", + "role": "Developer" } ], "description": "Flysystem Adapter for the Dropbox v2 API", @@ -2402,16 +2405,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.2.3", + "version": "v4.2.4", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "e612609022e935f3d0337c1295176505b41188c8" + "reference": "97e59c7a16464196a8b9c77c47df68e4a39a45c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/e612609022e935f3d0337c1295176505b41188c8", - "reference": "e612609022e935f3d0337c1295176505b41188c8", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/97e59c7a16464196a8b9c77c47df68e4a39a45c4", + "reference": "97e59c7a16464196a8b9c77c47df68e4a39a45c4", "shasum": "" }, "require": { @@ -2449,7 +2452,7 @@ "parser", "php" ], - "time": "2019-08-12T20:17:41+00:00" + "time": "2019-09-01T07:51:21+00:00" }, { "name": "ocramius/package-versions", @@ -2625,16 +2628,16 @@ }, { "name": "symfony/console", - "version": "v4.3.3", + "version": "v4.3.4", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "8b0ae5742ce9aaa8b0075665862c1ca397d1c1d9" + "reference": "de63799239b3881b8a08f8481b22348f77ed7b36" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/8b0ae5742ce9aaa8b0075665862c1ca397d1c1d9", - "reference": "8b0ae5742ce9aaa8b0075665862c1ca397d1c1d9", + "url": "https://api.github.com/repos/symfony/console/zipball/de63799239b3881b8a08f8481b22348f77ed7b36", + "reference": "de63799239b3881b8a08f8481b22348f77ed7b36", "shasum": "" }, "require": { @@ -2696,20 +2699,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2019-07-24T17:13:59+00:00" + "time": "2019-08-26T08:26:39+00:00" }, { "name": "symfony/finder", - "version": "v4.3.3", + "version": "v4.3.4", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "9638d41e3729459860bb96f6247ccb61faaa45f2" + "reference": "86c1c929f0a4b24812e1eb109262fc3372c8e9f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/9638d41e3729459860bb96f6247ccb61faaa45f2", - "reference": "9638d41e3729459860bb96f6247ccb61faaa45f2", + "url": "https://api.github.com/repos/symfony/finder/zipball/86c1c929f0a4b24812e1eb109262fc3372c8e9f2", + "reference": "86c1c929f0a4b24812e1eb109262fc3372c8e9f2", "shasum": "" }, "require": { @@ -2745,7 +2748,7 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2019-06-28T13:16:30+00:00" + "time": "2019-08-14T12:26:46+00:00" }, { "name": "symfony/polyfill-php73", @@ -2807,16 +2810,16 @@ }, { "name": "symfony/service-contracts", - "version": "v1.1.5", + "version": "v1.1.6", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "f391a00de78ec7ec8cf5cdcdae59ec7b883edb8d" + "reference": "ea7263d6b6d5f798b56a45a5b8d686725f2719a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f391a00de78ec7ec8cf5cdcdae59ec7b883edb8d", - "reference": "f391a00de78ec7ec8cf5cdcdae59ec7b883edb8d", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/ea7263d6b6d5f798b56a45a5b8d686725f2719a3", + "reference": "ea7263d6b6d5f798b56a45a5b8d686725f2719a3", "shasum": "" }, "require": { @@ -2861,7 +2864,7 @@ "interoperability", "standards" ], - "time": "2019-06-13T11:15:36+00:00" + "time": "2019-08-20T14:44:19+00:00" } ], "aliases": [], diff --git a/install/index.php b/install/index.php index 38adedc8..53d4b966 100644 --- a/install/index.php +++ b/install/index.php @@ -9,6 +9,7 @@ use League\Flysystem\Adapter\Local; use League\Flysystem\AwsS3v3\AwsS3Adapter; use League\Flysystem\Adapter\Ftp as FtpAdapter; +use League\Flysystem\FileExistsException; use Spatie\Dropbox\Client as DropboxClient; use League\Flysystem\Filesystem; use Slim\App; @@ -175,6 +176,18 @@ function migrate($config) $app->get('/', function (Request $request, Response $response) { + if (!extension_loaded('gd')) { + $this->session->alert('The required "gd" extension is not loaded.', 'danger'); + } + + if (!extension_loaded('intl')) { + $this->session->alert('The required "intl" extension is not loaded.', 'danger'); + } + + if (!extension_loaded('json')) { + $this->session->alert('The required "json" extension is not loaded.', 'danger'); + } + if (!is_writable(__DIR__ . '/../resources/cache')) { $this->session->alert('The cache folder is not writable (' . __DIR__ . '/../resources/cache' . ')', 'danger'); } @@ -243,20 +256,25 @@ function migrate($config) // check if the storage is valid try { - $success = $this->storage->write('storage_test.xbackbone.txt', 'XBACKBONE_TEST_FILE'); + try { + $success = $this->storage->write('storage_test.xbackbone.txt', 'XBACKBONE_TEST_FILE'); + } catch (FileExistsException $fileExistsException) { + $success = $this->storage->update('storage_test.xbackbone.txt', 'XBACKBONE_TEST_FILE'); + } + if (!$success) { throw new Exception('The storage is not writable.'); } $this->storage->readAndDelete('test.install.txt'); } catch (Exception $e) { - $this->session->alert("Storage setup error: {$e->getMessage()} [{$e->getTraceAsString()}]", 'danger'); - return redirect($response, $request->getUri()); + $this->session->alert("Storage setup error: {$e->getMessage()} [{$e->getCode()}]", 'danger'); + return redirect($response, '/install'); } $ret = file_put_contents(__DIR__ . '/../config.php', 'session->alert('The config folder is not writable (' . __DIR__ . '/../config.php' . ')', 'danger'); - return redirect($response, $request->getUri()); + return redirect($response, '/install'); } } @@ -276,9 +294,9 @@ function migrate($config) DB::setDsn($config['db']['connection'] . ':' . $dsn, $config['db']['username'], $config['db']['password']); migrate($config); - } catch (PDOException $exception) { - $this->session->alert("Cannot connect to the database: {$exception->getMessage()} [{$exception->getCode()}]", 'danger'); - return redirect($response, $request->getUri()); + } catch (PDOException $e) { + $this->session->alert("Cannot connect to the database: {$e->getMessage()} [{$e->getCode()}]", 'danger'); + return redirect($response, '/install'); } // if not installed, create the default admin account @@ -299,11 +317,13 @@ function migrate($config) $ret = file_put_contents(__DIR__ . '/../config.php', 'session->alert('The config folder is not writable (' . __DIR__ . '/../config.php' . ')', 'danger'); - return redirect($response, $request->getUri()); + return redirect($response, '/install'); } } - return $response->withRedirect('../?afterInstall=true'); + // Installed successfully, destroy the installer session + session_destroy(); + return redirect($response, '../?afterInstall=true'); }); $app->run(); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a30cd53d..cf0a281e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,9 +11,9 @@ } }, "@fortawesome/fontawesome-free": { - "version": "5.8.2", - "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.8.2.tgz", - "integrity": "sha512-E4fDUF4fbu9AxKpaQQqCN3XBnNzb/5e0Gvd9OaQsYkK574LVI57v/EqqPfIm/mC7jYbxaPNrhvT5AF+Yzwyizg==" + "version": "5.10.2", + "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.10.2.tgz", + "integrity": "sha512-9pw+Nsnunl9unstGEHQ+u41wBEQue6XPBsILXtJF/4fNN1L3avJcMF/gGF86rIjeTAgfLjTY9ndm68/X4f4idQ==" }, "abbrev": { "version": "1.1.1", diff --git a/package.json b/package.json index bf929fd5..ba9f52fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "@fortawesome/fontawesome-free": "^5.8.2", + "@fortawesome/fontawesome-free": "^5.10.2", "bootstrap": "^4.3.1", "clipboard": "^2.0.4", "highlightjs": "^9.12.0",