mirror of
https://github.com/axeloz/filesharing.git
synced 2025-05-06 10:03:55 +02:00
Adding two settings : expiry and title of the bundle
This commit is contained in:
parent
554426eabc
commit
a5b51dcb1e
12 changed files with 103 additions and 23 deletions
|
@ -171,4 +171,23 @@ class Upload {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getExpirySeconds($expiry) {
|
||||||
|
$unit_multipliers = [
|
||||||
|
'h' => 3600,
|
||||||
|
'd' => 86400,
|
||||||
|
'w' => 604800,
|
||||||
|
'm' => 2592000
|
||||||
|
];
|
||||||
|
|
||||||
|
$unit = strtolower(substr(trim($expiry), -1));
|
||||||
|
$value = (int)substr($expiry, 0, -1);
|
||||||
|
|
||||||
|
if (empty($unit_multipliers[$unit]) || $value <= 0) {
|
||||||
|
// 24h by default
|
||||||
|
return $unit_multipliers['d'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($value * $unit_multipliers[$unit]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,18 +96,21 @@ class UploadController extends Controller
|
||||||
if (! $metadata = Upload::getMetadata($request->header('X-Upload-Bundle'))) {
|
if (! $metadata = Upload::getMetadata($request->header('X-Upload-Bundle'))) {
|
||||||
$metadata = [
|
$metadata = [
|
||||||
'created_at' => time(),
|
'created_at' => time(),
|
||||||
'expires_at' => time()+60*60*24*15, # TODO : make this editable in the FRONT
|
'expires_at' => time()+$request->expiry,
|
||||||
'bundle_id' => $request->header('X-Upload-Bundle'),
|
'bundle_id' => $request->header('X-Upload-Bundle'),
|
||||||
'view-auth' => substr(sha1(uniqid('', true)), 0, rand(6, 10)),
|
'view-auth' => substr(sha1(uniqid('', true)), 0, rand(6, 10)),
|
||||||
'delete-auth' => substr(sha1(uniqid('', true)), 0, rand(6, 10)),
|
'delete-auth' => substr(sha1(uniqid('', true)), 0, rand(6, 10)),
|
||||||
'fullsize' => 0,
|
'fullsize' => 0,
|
||||||
'files' => $bundle['files']
|
'files' => $bundle['files'],
|
||||||
|
'title' => $request->title
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
// The metadata file already exists
|
// The metadata file already exists
|
||||||
else {
|
else {
|
||||||
// Adding bundle files to metadata
|
// Adding bundle files to metadata
|
||||||
$metadata['files'] = array_merge($metadata['files'], $bundle['files']);
|
$metadata['files'] = array_merge($metadata['files'], $bundle['files']);
|
||||||
|
$metadata['title'] = $request->title;
|
||||||
|
$metadata['expires_at'] = time()+$request->expiry;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Processing size
|
// Processing size
|
||||||
|
|
|
@ -4,6 +4,8 @@ return [
|
||||||
|
|
||||||
'max_filesize' => env('UPLOAD_MAX_FILESIZE', '5M'),
|
'max_filesize' => env('UPLOAD_MAX_FILESIZE', '5M'),
|
||||||
'max_files' => env('UPLOAD_MAX_FILES', 100),
|
'max_files' => env('UPLOAD_MAX_FILES', 100),
|
||||||
|
'expiry_values' => ['1H', '2H', '6H', '12H', '24H', '48H', '1W', '2W', '1M', '6M'],
|
||||||
|
'default_expiry' => '6H',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
** IP v4 access limitations
|
** IP v4 access limitations
|
||||||
|
@ -13,5 +15,6 @@ return [
|
||||||
** 3. CIDR Format (192.168.10/24) OR 1.2.3.4/255.255.255.0
|
** 3. CIDR Format (192.168.10/24) OR 1.2.3.4/255.255.255.0
|
||||||
** 4. Start-end IP (192.168.10.0-192.168.10.10)
|
** 4. Start-end IP (192.168.10.0-192.168.10.10)
|
||||||
*/
|
*/
|
||||||
'upload_ip_limit' => env('UPLOAD_LIMIT_IPS', null)
|
'upload_ip_limit' => env('UPLOAD_LIMIT_IPS', null),
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
16
public/css/app.css
vendored
16
public/css/app.css
vendored
|
@ -15,7 +15,7 @@ body #content {
|
||||||
padding: 10px 10px 10px 10px;
|
padding: 10px 10px 10px 10px;
|
||||||
background-size: 16px 16px;
|
background-size: 16px 16px;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
background-color: rgba(56, 76, 65, 0.84);
|
background-color: rgba(56, 76, 65, 0.95);
|
||||||
border: 1px solid #45574d;
|
border: 1px solid #45574d;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
|
@ -33,7 +33,7 @@ body h2 {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
color: rgba(255, 255, 255, 0.877);
|
color: rgba(255, 255, 255, 0.877);
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
font-size: 1.7rem;
|
font-size: 1.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
body .spacer {
|
body .spacer {
|
||||||
|
@ -63,6 +63,18 @@ body label:last-child {
|
||||||
margin: 10px 0 0 0;
|
margin: 10px 0 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body#upload #upload-settings label {
|
||||||
|
float: left;
|
||||||
|
width: 45%;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
body#upload #upload-settings input,
|
||||||
|
body#upload #upload-settings select {
|
||||||
|
width: 45% !important;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
body#upload div#upload-column {
|
body#upload div#upload-column {
|
||||||
float: left;
|
float: left;
|
||||||
width: 190px;
|
width: 190px;
|
||||||
|
|
BIN
public/img/files.png
Normal file
BIN
public/img/files.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 940 B |
BIN
public/img/settings.png
Normal file
BIN
public/img/settings.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1 KiB |
2
public/js/vendor.js
vendored
2
public/js/vendor.js
vendored
File diff suppressed because one or more lines are too long
|
@ -14,7 +14,7 @@ return [
|
||||||
'preview-link' => 'Preview link: ',
|
'preview-link' => 'Preview link: ',
|
||||||
'direct-link' => 'Direct download link: ',
|
'direct-link' => 'Direct download link: ',
|
||||||
'delete-link' => 'Deletion link: ',
|
'delete-link' => 'Deletion link: ',
|
||||||
'upload-files-title' => 'Files upload',
|
'upload-files-title' => 'Files',
|
||||||
'bundle-preview-title' => 'Files download',
|
'bundle-preview-title' => 'Files download',
|
||||||
'download-all-or-one' => 'You can download each file individually or download the entire bundle at once',
|
'download-all-or-one' => 'You can download each file individually or download the entire bundle at once',
|
||||||
'files-list' => 'Uploaded files list',
|
'files-list' => 'Uploaded files list',
|
||||||
|
@ -28,6 +28,9 @@ return [
|
||||||
'cannot-upload-no-password' => 'You must provide a valid password in order to upload on this application',
|
'cannot-upload-no-password' => 'You must provide a valid password in order to upload on this application',
|
||||||
'password' => 'Password: ',
|
'password' => 'Password: ',
|
||||||
'upload-disabled' => 'Upload is disabled on this application',
|
'upload-disabled' => 'Upload is disabled on this application',
|
||||||
'start-new-upload' => 'Click here to start a new upload'
|
'start-new-upload' => 'Click here to start a new upload',
|
||||||
|
'upload-settings' => 'Settings',
|
||||||
|
'upload-expiry' => 'Expiration of the bundle:',
|
||||||
|
'upload-title' => 'Title of the bundle:'
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -28,5 +28,8 @@ return [
|
||||||
'cannot-upload-no-password' => 'Vous devez saisir un mot de passe pour pouvoir téléverser sur cette application',
|
'cannot-upload-no-password' => 'Vous devez saisir un mot de passe pour pouvoir téléverser sur cette application',
|
||||||
'password' => 'Mot de passe : ',
|
'password' => 'Mot de passe : ',
|
||||||
'upload-disabled' => 'Le téléversement est désactivé sur cette application',
|
'upload-disabled' => 'Le téléversement est désactivé sur cette application',
|
||||||
'start-new-upload' => 'Cliquez ici pour démarrer un nouveau téléversement'
|
'start-new-upload' => 'Cliquez ici pour démarrer un nouveau téléversement',
|
||||||
|
'upload-settings' => 'Paramètres :',
|
||||||
|
'upload-expiry' => 'Expiration du téléchargement :',
|
||||||
|
'upload-title' => 'Titre du téléchargement :'
|
||||||
];
|
];
|
||||||
|
|
16
resources/themes/default/assets/sass/app.scss
vendored
16
resources/themes/default/assets/sass/app.scss
vendored
|
@ -16,7 +16,7 @@ body {
|
||||||
padding: 10px 10px 10px 10px;
|
padding: 10px 10px 10px 10px;
|
||||||
background-size:16px 16px;
|
background-size:16px 16px;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
background-color:rgba(56, 76, 65, 0.84);
|
background-color:rgba(56, 76, 65, 0.95);
|
||||||
border: 1px solid rgb(69, 87, 77);
|
border: 1px solid rgb(69, 87, 77);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
|
@ -36,7 +36,7 @@ body {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
color: rgba(255, 255, 255, 0.877);
|
color: rgba(255, 255, 255, 0.877);
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
font-size: 1.7rem;
|
font-size: 1.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.spacer {
|
.spacer {
|
||||||
|
@ -67,6 +67,18 @@ body {
|
||||||
|
|
||||||
&#upload {
|
&#upload {
|
||||||
|
|
||||||
|
#upload-settings {
|
||||||
|
label {
|
||||||
|
float: left;
|
||||||
|
width: 45%;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
input, select {
|
||||||
|
width: 45% !important;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
div#upload-column {
|
div#upload-column {
|
||||||
float: left;
|
float: left;
|
||||||
width: 190px;
|
width: 190px;
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
@lang('app.bundle-preview-intro')<br />
|
@lang('app.bundle-preview-intro')<br />
|
||||||
@lang('app.download-all-or-one')<br /><br />
|
@lang('app.download-all-or-one')<br /><br />
|
||||||
|
|
||||||
|
@if (! empty($metadata['title']))
|
||||||
|
<h2>{{ $metadata['title'] }}</h2>
|
||||||
|
@endif
|
||||||
|
|
||||||
<ul id="files-list">
|
<ul id="files-list">
|
||||||
@foreach ($metadata['files'] as $f)
|
@foreach ($metadata['files'] as $f)
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -4,7 +4,25 @@
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<h1>{{ config('app.name') }}</h1>
|
<h1>{{ config('app.name') }}</h1>
|
||||||
<h2>@lang('app.upload-files-title')</h2>
|
|
||||||
|
<br />
|
||||||
|
<h2><img src="{{ asset('img/settings.png') }}" width="21" alt="" /> @lang('app.upload-settings')</h2>
|
||||||
|
<div id="upload-settings" class="wide">
|
||||||
|
<label>@lang('app.upload-title')</label>
|
||||||
|
<input type="text" name="title" id="upload-title" />
|
||||||
|
<p class="spacer"> </p>
|
||||||
|
|
||||||
|
<label>@lang('app.upload-expiry')</label>
|
||||||
|
<select name="expiry" id="upload-expiry">
|
||||||
|
@foreach (config('sharing.expiry_values') as $e)
|
||||||
|
<option value="{{ Upload::getExpirySeconds($e) }}" {{ $e == config('sharing.default_expiry') ? 'selected' : '' }}>{{ $e }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
<p class="spacer"> </p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
<h2><img src="{{ asset('img/files.png') }}" width="21" alt="" /> @lang('app.upload-files-title')</h2>
|
||||||
|
|
||||||
<div id="upload-column" class="wide">
|
<div id="upload-column" class="wide">
|
||||||
<form action="{{ route('upload.store') }}" class="dropzone" id="upload-form">
|
<form action="{{ route('upload.store') }}" class="dropzone" id="upload-form">
|
||||||
|
@ -90,8 +108,11 @@
|
||||||
'X-Upload-Bundle': '{{ $bundle_id }}'
|
'X-Upload-Bundle': '{{ $bundle_id }}'
|
||||||
},
|
},
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '{{ route('upload.complete') }}'
|
url: '{{ route('upload.complete') }}',
|
||||||
|
data: {
|
||||||
|
title: $('#upload-title').val(),
|
||||||
|
expiry: $('#upload-expiry').val()
|
||||||
|
}
|
||||||
}).done(function (data) {
|
}).done(function (data) {
|
||||||
if (data.result == true) {
|
if (data.result == true) {
|
||||||
$('#preview-link').attr('href', data.bundle_url).html(data.bundle_url);
|
$('#preview-link').attr('href', data.bundle_url).html(data.bundle_url);
|
||||||
|
|
Loading…
Add table
Reference in a new issue