Skip to content

Commit

Permalink
Fixed installed bad path check
Browse files Browse the repository at this point in the history
  • Loading branch information
sergix44 committed Sep 4, 2019
1 parent 4288341 commit 111f220
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion app/Controllers/ThemeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function applyTheme(Request $request, Response $response): Response
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');
}

}
2 changes: 1 addition & 1 deletion bin/clean
Original file line number Diff line number Diff line change
@@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion bin/migrate
Original file line number Diff line number Diff line change
@@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion bin/theme
Original file line number Diff line number Diff line change
@@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sergix44/xbackbone",
"version": "2.6",
"version": "2.6.1",
"description": "A lightweight ShareX PHP backend",
"type": "project",
"require": {
Expand Down
14 changes: 9 additions & 5 deletions install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ function migrate($config)

$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) {
Expand Down Expand Up @@ -255,17 +258,18 @@ function migrate($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');
Expand Down Expand Up @@ -323,7 +327,7 @@ function migrate($config)

// Installed successfully, destroy the installer session
session_destroy();
return redirect($response, '../?afterInstall=true');
return redirect($response, '/../?afterInstall=true');
});

$app->run();
2 changes: 1 addition & 1 deletion install/templates/install.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
1 change: 0 additions & 1 deletion resources/templates/auth/login.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
-webkit-box-pack: center;
justify-content: center;
padding-bottom: 40px;
background-color: #f5f5f5;
margin-bottom: 0;
}
</style>
Expand Down
21 changes: 11 additions & 10 deletions resources/templates/base.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -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>
Expand All @@ -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>
2 changes: 1 addition & 1 deletion src/js/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 111f220

Please sign in to comment.