Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
92ec357
Add optional code param in upload request
nickhnsn Aug 9, 2024
3815c19
Merge pull request #588 from nickhnsn/patch-1
sergix44 Aug 29, 2024
c1ff48d
Bump twig/twig from 2.16.0 to 2.16.1
dependabot[bot] Sep 9, 2024
da356da
enable custom sender via config
Mainfrezzer Oct 11, 2024
6b8558c
Merge pull request #605 from sergix44/dependabot/composer/twig/twig-2…
sergix44 Oct 12, 2024
eef26b9
Translated using Weblate (Serbian)
Reportiv Oct 9, 2024
8ef247c
Merge pull request #608 from weblate/weblate-xbackbone-xbackbone
sergix44 Oct 12, 2024
92549a2
Bump bootstrap from 4.6.1 to 5.0.0
dependabot[bot] Oct 12, 2024
4d7005e
Merge branch 'sergix44:master' into master
Mainfrezzer Oct 18, 2024
e596428
Bump twig/twig from 2.16.1 to 3.11.2
dependabot[bot] Nov 6, 2024
7a880be
Merge pull request #612 from sergix44/dependabot/composer/twig/twig-3…
sergix44 Dec 1, 2024
8a468f0
Merge branch 'sergix44:master' into master
Mainfrezzer Dec 16, 2024
99dd555
Exporting ShareX Settings Fix
Jan 16, 2025
bf89b09
Merge pull request #617 from SenkaWolf/master
sergix44 Jan 17, 2025
c6ff921
Merge pull request #616 from Mainfrezzer/master
sergix44 Jan 17, 2025
fd1fbb1
Apply fixes from StyleCI
StyleCIBot Jan 17, 2025
064e946
Merge pull request #619 from sergix44/analysis-VBVyBP
sergix44 Jan 17, 2025
3d15d18
Merge pull request #609 from sergix44/dependabot/npm_and_yarn/bootstr…
sergix44 Jan 17, 2025
fc83e1c
Revert "Bump twig/twig from 2.16.1 to 3.11.2"
sergix44 Jan 17, 2025
2470cec
Merge pull request #620 from sergix44/revert-612-dependabot/composer/…
sergix44 Jan 17, 2025
57a78e6
Bump twig/twig from 2.16.1 to 3.11.2
dependabot[bot] Jan 17, 2025
0814e11
Merge pull request #621 from sergix44/dependabot/composer/twig/twig-3…
sergix44 Jan 18, 2025
291e80a
Translated using Weblate (Russian)
dyrkuwu Nov 2, 2024
7528d23
Added translation using Weblate (Tamil)
Nov 4, 2024
cd6b404
Translated using Weblate (Tamil)
Nov 4, 2024
2797be7
Translated using Weblate (Portuguese)
Nov 13, 2024
016ff7e
Translated using Weblate (Finnish)
Ricky-Tigg Nov 28, 2024
aa7f8eb
Translated using Weblate (Indonesian)
rezaalmanda Dec 23, 2024
238ad65
Merge pull request #610 from weblate/weblate-xbackbone-xbackbone
sergix44 Jan 18, 2025
8e3128c
Fix mail retrieval
sergix44 Jan 18, 2025
115e1eb
update for php 8.4
sergix44 Jan 18, 2025
bdf9d14
update changelog
sergix44 Jan 18, 2025
bbef8b5
update dependencies
sergix44 Jan 18, 2025
0cc4f26
update site changelog
sergix44 Jan 18, 2025
b137f25
temporary hide deprecations to avoid breaking sessions
sergix44 Jan 18, 2025
4b27c4d
Discord Embed Minor Change
Jan 18, 2025
cbd0744
Havbar Help Dropdown Added
Jan 19, 2025
d131bd3
Accidental duplicated system on nav
Jan 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ["7.3", "7.4", "8.0", "8.1", "8.2"]
php-versions: ["7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"]

steps:
- uses: actions/checkout@v2
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased

## [3.8.0] - 2025-01-18
### Added
- Support for PHP 8.4
- Add an `app_email` option to the config (#616)
- Exporting ShareX settings now work for the latest version of ShareX 16.1.0 (#617)
- Option to upload file with a custom name (#588)
- Upload from clipboard (#572)

### Changed
- Updated translations.
- Updated dependencies.

### Fixed
- Page count calculation (#586)

## [3.7.0] - 2024-01-14
### Added
- Added support for vanity urls.
Expand Down
30 changes: 19 additions & 11 deletions app/Controllers/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,38 @@ class ClientController extends Controller
public function getShareXConfig(Request $request, Response $response, int $id): Response
{
$user = make(UserRepository::class)->get($request, $id, true);

if (!$user->token) {
$this->session->alert(lang('no_upload_token'), 'danger');

return redirect($response, $request->getHeaderLine('Referer'));
}


$fileBaseName = $user->username . '-ShareX'; // Base file name without extension
$fileName = $fileBaseName . '.sxcu'; // Full file name with extension

$json = [
'Version' => '16.1.0',
'Name' => $fileBaseName,
'DestinationType' => 'ImageUploader, TextUploader, FileUploader',
'RequestMethod' => 'POST',
'RequestURL' => route('upload'),
'FileFormName' => 'upload',
'Body' => 'MultipartFormData',
'Arguments' => [
'file' => '$filename$',
'text' => '$input$',
'file' => '{filename}',
'text' => '{input}',
'token' => $user->token,
],
'URL' => '$json:url$',
'ThumbnailURL' => '$json:url$/raw',
'DeletionURL' => '$json:url$/delete/'.$user->token,
'FileFormName' => 'upload',
'URL' => '{json:url}',
'ThumbnailURL' => '{json:url}/raw',
'DeletionURL' => '{json:url}/delete/' . $user->token,
];

return json($response, $json, 200, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)
->withHeader('Content-Disposition', 'attachment;filename="'.$user->username.'-ShareX.sxcu"');
->withHeader('Content-Disposition', 'attachment;filename="' . $fileName . '"');
}


/**
* @param Request $request
Expand Down
19 changes: 14 additions & 5 deletions app/Controllers/UploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function uploadEndpoint(Request $request, Response $response): Response
}

try {
$response = $this->saveMedia($response, $file, $user);
$response = $this->saveMedia($response, $file, $user, param($request, 'code'));
} catch (Exception $e) {
$this->updateUserQuota($request, $user->id, $file->getSize(), true);
throw $e;
Expand All @@ -118,6 +118,7 @@ public function uploadEndpoint(Request $request, Response $response): Response
/**
* @param Request $request
* @param Response $response
* @param $code
* @return UploadedFileInterface
* @throws ValidationException
*/
Expand Down Expand Up @@ -182,11 +183,19 @@ protected function validateUser(Request $request, Response $response, UploadedFi
* @throws \League\Flysystem\FileExistsException
* @throws \League\Flysystem\FileNotFoundException
*/
protected function saveMedia(Response $response, UploadedFileInterface $file, $user)
protected function saveMedia(Response $response, UploadedFileInterface $file, $user, $code)
{
do {
$code = humanRandomString();
} while ($this->database->query('SELECT COUNT(*) AS `count` FROM `uploads` WHERE `code` = ?', $code)->fetch()->count > 0);
if ($code === null) {
do {
$code = humanRandomString();
} while ($this->database->query('SELECT COUNT(*) AS `count` FROM `uploads` WHERE `code` = ?', $code)->fetch()->count > 0);
} else {
$existingCodeCount = $this->database->query('SELECT COUNT(*) AS `count` FROM `uploads` WHERE `code` = ?', $code)->fetch()->count;
if ($existingCodeCount > 0) {
$this->json['message'] = 'Custom url code already exists.';
return json($response, $this->json, 409);
}
}

$fileInfo = pathinfo($file->getClientFilename());
$storagePath = "$user->user_code/$code.$fileInfo[extension]";
Expand Down
6 changes: 6 additions & 0 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,12 @@ function dsnFromConfig(array $config): string
*/
function platform_mail($mailbox = 'no-reply'): string
{
$config = resolve('config');

if (isset($config['app_email'])) {
return $config['app_email'];
}

return $mailbox.'@'.str_ireplace('www.', '', parse_url(resolve('config')['base_url'], PHP_URL_HOST));
}
}
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sergix44/xbackbone",
"license": "AGPL-3.0-only",
"version": "3.7.0",
"version": "3.8.0",
"description": "A lightweight ShareX PHP backend",
"type": "project",
"require": {
Expand All @@ -25,7 +25,7 @@
"slim/slim": "^4.0",
"spatie/flysystem-dropbox": "^1.0",
"superbalist/flysystem-google-storage": "^7.2",
"twig/twig": "^2.14"
"twig/twig": "^3.11"
},
"config": {
"optimize-autoloader": true,
Expand Down
Loading