Fixed installed bad path check

This commit is contained in:
Sergio Brighenti 2019-09-04 21:43:43 +02:00
parent 42883417e8
commit 111f220629
11 changed files with 28 additions and 23 deletions

View file

@ -1,5 +1,6 @@
## v2.6.1
+ Fixed bad redirects on the web installer (#62).
+ Fixed login page with dark themes.
+ Improved shell commands.
+ Added alert if required extensions are not loaded.
+ Updated translations.

View file

@ -38,7 +38,7 @@ class ThemeController extends Controller
return redirect($response, 'system')
->withAddedHeader('Cache-Control', 'no-cache, no-store, must-revalidate')
->withAddedHeader('Pragma', 'no-cache')
->withAddedHeader('Expire', '0');
->withAddedHeader('Expire', 'Mon, 26 Jul 1997 05:00:00 GMT');
}
}

View file

@ -1,6 +1,6 @@
#!/usr/bin/env php
<?php
(PHP_MAJOR_VERSION >= 7 && PHP_MINOR_VERSION >= 1) ?: die('Sorry, PHP 7.1 or above is required to run XBackBone.');
if (php_sapi_name() !== 'cli') {
die();
}

View file

@ -1,6 +1,6 @@
#!/usr/bin/env php
<?php
(PHP_MAJOR_VERSION >= 7 && PHP_MINOR_VERSION >= 1) ?: die('Sorry, PHP 7.1 or above is required to run XBackBone.');
if (php_sapi_name() !== 'cli') {
die();
}

View file

@ -1,6 +1,6 @@
#!/usr/bin/env php
<?php
(PHP_MAJOR_VERSION >= 7 && PHP_MINOR_VERSION >= 1) ?: die('Sorry, PHP 7.1 or above is required to run XBackBone.');
if (php_sapi_name() !== 'cli') {
die();
}

View file

@ -1,6 +1,6 @@
{
"name": "sergix44/xbackbone",
"version": "2.6",
"version": "2.6.1",
"description": "A lightweight ShareX PHP backend",
"type": "project",
"require": {

View file

@ -202,7 +202,10 @@ $app->get('/', function (Request $request, Response $response) {
$installed = file_exists(__DIR__ . '/../config.php');
return $this->view->render($response, 'install.twig', ['installed' => $installed]);
return $this->view->render($response, 'install.twig', [
'installed' => $installed,
'default_local' => realpath(__DIR__ . '/../') . DIRECTORY_SEPARATOR . 'storage',
]);
});
$app->post('/', function (Request $request, Response $response) use (&$config) {
@ -255,17 +258,18 @@ $app->post('/', function (Request $request, Response $response) use (&$config) {
}
// check if the storage is valid
$storageTestFile = 'storage_test.xbackbone.txt';
try {
try {
$success = $this->storage->write('storage_test.xbackbone.txt', 'XBACKBONE_TEST_FILE');
$success = $this->storage->write($storageTestFile, 'XBACKBONE_TEST_FILE');
} catch (FileExistsException $fileExistsException) {
$success = $this->storage->update('storage_test.xbackbone.txt', 'XBACKBONE_TEST_FILE');
$success = $this->storage->update($storageTestFile, 'XBACKBONE_TEST_FILE');
}
if (!$success) {
throw new Exception('The storage is not writable.');
}
$this->storage->readAndDelete('test.install.txt');
$this->storage->readAndDelete($storageTestFile);
} catch (Exception $e) {
$this->session->alert("Storage setup error: {$e->getMessage()} [{$e->getCode()}]", 'danger');
return redirect($response, '/install');
@ -323,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 redirect($response, '/../?afterInstall=true');
});
$app->run();

View file

@ -80,7 +80,7 @@
<div class="form-group row hook-storage">
<label for="storage_path" class="col-sm-3 col-form-label">Storage path root</label>
<div class="col-sm-9">
<input type="text" class="form-control hook-storage-input" id="storage_path" name="storage_path" autocomplete="off">
<input type="text" class="form-control hook-storage-input" id="storage_path" name="storage_path" autocomplete="off" data-default-local="{{ default_local }}">
</div>
</div>
<div class="form-group row hook-storage">

View file

@ -19,7 +19,6 @@
-webkit-box-pack: center;
justify-content: center;
padding-bottom: 40px;
background-color: #f5f5f5;
margin-bottom: 0;
}
</style>

View file

@ -4,7 +4,7 @@
<title>{% block title %}Default{% endblock %} | {{ config.app_name }}</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="XBackBone is a simple and lightweight PHP backend for ShareX">
<meta name="description" content="XBackBone File Manager">
<link rel="shortcut icon" href="{{ urlFor('/favicon.ico') }}" type="image/x-icon">
<link rel="icon" href="{{ urlFor('/favicon.ico') }}" type="image/x-icon">
<link rel="preload" href="{{ urlFor('/static/bootstrap/css/bootstrap.min.css') }}" as="style">
@ -17,14 +17,6 @@
<link href="{{ urlFor('/static/highlightjs/styles/monokai.css') }}" rel="stylesheet">
<link href="{{ urlFor('/static/videojs/video-js.min.css') }}" rel="stylesheet">
<link href="{{ urlFor('/static/app/app.css') }}" rel="stylesheet">
<script src="{{ urlFor('/static/jquery/jquery.min.js') }}"></script>
<script src="{{ urlFor('/static/bootstrap/js/bootstrap.bundle.min.js') }}"></script>
<script src="{{ urlFor('/static/fontawesome/js/all.min.js') }}"></script>
<script src="{{ urlFor('/static/highlightjs/highlight.pack.min.js') }}"></script>
<script src="{{ urlFor('/static/clipboardjs/clipboard.min.js') }}"></script>
<script src="{{ urlFor('/static/videojs/video.min.js') }}"></script>
<script src="{{ urlFor('/static/app/app.js') }}"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script>window.AppConfig = {'base_url': '{{ config.base_url }}', 'lang': {'publish': '{{ lang('publish') }}', 'hide': '{{ lang('hide') }}'}}</script>
{% block head %}{% endblock %}
</head>
@ -33,8 +25,17 @@
{% block footer %}
<div class="container-fluid footer" style="display: none; font-size: 0.8rem">
<div class="text-muted">Proudly powered by <a href="https://github.com/SergiX44/XBackBone">XBackBone{% if session.admin %} v{{ PLATFORM_VERSION }}{% endif %}</a>
— <i class="fas fa-fw fa-balance-scale"></i> AGPL v3.0</div>
— <i class="fas fa-fw fa-balance-scale"></i> AGPL v3.0
</div>
</div>
{% endblock %}
<script src="{{ urlFor('/static/jquery/jquery.min.js') }}"></script>
<script src="{{ urlFor('/static/bootstrap/js/bootstrap.bundle.min.js') }}"></script>
<script src="{{ urlFor('/static/fontawesome/js/all.min.js') }}"></script>
<script src="{{ urlFor('/static/highlightjs/highlight.pack.min.js') }}"></script>
<script src="{{ urlFor('/static/clipboardjs/clipboard.min.js') }}"></script>
<script src="{{ urlFor('/static/videojs/video.min.js') }}"></script>
<script src="{{ urlFor('/static/app/app.js') }}"></script>
<script>hljs.initHighlightingOnLoad();</script>
</body>
</html>

View file

@ -27,7 +27,7 @@ $(document).ready(function () {
$all_storage_inputs.prop('required', '');
switch ($(this).val()) {
case 'local':
$('#storage_path').val('./storage').prop('required', 'required').parent().parent().show();
$('#storage_path').val($('#storage_path').data('default-local')).prop('required', 'required').parent().parent().show();
break;
case 'ftp':
$('#storage_path').val('/storage').prop('required', 'required').parent().parent().show();