Merge branch 'sergix44:master' into master

This commit is contained in:
lsgd 2024-04-30 15:49:54 +02:00 committed by GitHub
commit 1193c96966
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 616 additions and 356 deletions

View file

@ -5,6 +5,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## Unreleased
## [3.7.0] - 2024-01-14
### Added
- Added support for vanity urls.
- Added KDE integration for linux script.
### Changed
- Updated translations.
- File preview is now clickable to open the file.
### Fixed
- Fixes for LDAP authentication.
## [3.6.3] - 2023-05-27
### Fixed
- Fix LDAP for php >= 8.1

View file

@ -27,7 +27,7 @@ abstract class AuthController extends Controller
/**
* Connects to LDAP server and logs in with service account (if configured)
* @return resource|false
* @return \LDAP\Connection|resource|false
*/
public function ldapConnect()
{
@ -48,14 +48,14 @@ abstract class AuthController extends Controller
ldap_set_option($server, LDAP_OPT_REFERRALS, 0);
ldap_set_option($server, LDAP_OPT_NETWORK_TIMEOUT, 10);
} else {
$this->logger->error(ldap_error($server));
$this->logger->error('LDAP-URI was not parseable');
return false;
}
// Upgrade to StartTLS
$useStartTLS = @is_bool($this->config['ldap']['useStartTLS']) ? $this->config['ldap']['useStartTLS'] : false;
if (($useStartTLS === true) && (ldap_start_tls($server) === false)) {
$this->logger-debug(ldap_error($server));
$this->logger->debug(ldap_error($server));
$this->logger->error("Failed to establish secure LDAP swith StartTLS");
return false;
}
@ -77,7 +77,7 @@ abstract class AuthController extends Controller
/**
* Returns User's LDAP DN
* @param string $username
* @param resource $server LDAP Server Resource
* @param \LDAP\Connection|resource $server LDAP Server Resource
* @return string|null
*/
protected function getLdapRdn(string $username, $server)
@ -85,7 +85,7 @@ abstract class AuthController extends Controller
//Dynamic LDAP User Binding
if (@is_string($this->config['ldap']['search_filter'])) {
//Replace ???? with username
$searchFilter = str_replace('????', ldap_escape($username, null, LDAP_ESCAPE_FILTER), $this->config['ldap']['search_filter']);
$searchFilter = str_replace('????', ldap_escape($username, '', LDAP_ESCAPE_FILTER), $this->config['ldap']['search_filter']);
$ldapAddributes = array('dn');
$this->logger->debug("LDAP Search filter: $searchFilter");
$ldapSearchResp = ldap_search(

View file

@ -114,4 +114,35 @@ class ClientController extends Controller
]
);
}
/**
* @param Request $request
* @param Response $response
* @param int $id
*
* @return Response
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
*/
public function getKDEScript(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'));
}
return view()->render(
$response->withHeader('Content-Disposition', 'attachment;filename="xbackbone_uploader_'.$user->username.'.sh"'),
'scripts/xbackbone_kde_uploader.sh.twig',
[
'username' => $user->username,
'upload_url' => route('upload'),
'token' => $user->token,
]
);
}
}

View file

@ -57,6 +57,7 @@ $app->group('', function (RouteCollectorProxy $group) {
$group->post('/user/{id}/refreshToken', [UserController::class, 'refreshToken'])->setName('refreshToken');
$group->get('/user/{id}/config/sharex', [ClientController::class, 'getShareXConfig'])->setName('config.sharex');
$group->get('/user/{id}/config/script', [ClientController::class, 'getBashScript'])->setName('config.script');
$group->get('/user/{id}/config/kde_script', [ClientController::class, 'getKDEScript'])->setName('kde_config.script');
$group->get('/user/{id}/export', [ExportController::class, 'downloadData'])->setName('export.data');

View file

@ -1,7 +1,7 @@
{
"name": "sergix44/xbackbone",
"license": "AGPL-3.0-only",
"version": "3.6.3",
"version": "3.7.0",
"description": "A lightweight ShareX PHP backend",
"type": "project",
"require": {

781
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -5,6 +5,18 @@ nav_order: 9
---
# Changelog
## [3.7.0] - 2024-01-14
### Added
- Added support for vanity urls.
- Added KDE integration for linux script.
### Changed
- Updated translations.
- File preview is now clickable to open the file.
### Fixed
- Fixes for LDAP authentication.
## [3.6.3] - 2023-05-27
### Fixed
- Fix LDAP for php >= 8.1

View file

@ -54,7 +54,7 @@ return [
'reg_date' => 'Registrierungsdatum',
'none' => 'keine',
'open' => 'Öffnen',
'confirm' => 'Bestätigung',
'confirm' => 'Bestätigen',
'confirm_string' => 'Bist du sicher?',
'installed' => 'Installation erfolgreich abgeschlossen!',
'bad_login' => 'Falsche Anmeldeinformationen.',

View file

@ -54,7 +54,7 @@ return [
'reg_date' => 'Fecha de Registración',
'none' => 'Ninguno',
'open' => 'Abrir',
'confirm' => 'Confirmación',
'confirm' => 'Confirmar',
'confirm_string' => '¿Está seguro?',
'installed' => '¡Instalación completa!',
'bad_login' => 'Credenciales incorrectas.',
@ -129,8 +129,8 @@ return [
'upload_max_file_size' => 'El tamaño máximo del archivo es actualmente %s.',
'ldap_cant_connect' => 'No se puede conectar con el servidor de autentificación LDAP.',
'user_create_password' => 'Si se deja vacío, es posible que desee enviar una notificación a la dirección de correo electrónico del usuario.',
'mail.new_account_text_with_pw' => 'Hola %s!<br>se ha creado una nueva cuenta para ti en %s (<a href="%s">%s</a>), haz clic en el siguiente enlace para establecer una contraseña y activarla:<br><br><a href="%s">%s</a>',
'mail.new_account_text_with_reset' => 'Hola %s!<br>se ha creado una nueva cuenta para ti en %s (<a href="%s">%s</a>), haz clic en el siguiente enlace para establecer una contraseña y activarla:<br><br><a href="%s">%s</a>',
'mail.new_account_text_with_pw' => '¡Hola %s!<br>se ha creado una nueva cuenta para ti en %s (<a href="%s">%s</a>), haz clic en el siguiente enlace para establecer una contraseña y activarla:<br><br><a href="%s">%s</a>',
'mail.new_account_text_with_reset' => '¡Hola, %s!<br>Se creó una nueva cuenta para ti en %s (<a href="%s">%s</a>), haz clic en el siguiente enlace para establecer una contraseña y activarla:<br ><br><a href="%s">%s</a>',
'recaptcha_enabled' => 'reCAPTCHA activado',
'account_media_deleted' => 'Se han eliminado todos los archivos de la cuenta.',
'clear_account' => 'Limpiar cuenta',
@ -165,4 +165,5 @@ return [
'recaptcha_site_key' => 'Clave del sitio reCAPTCHA',
'only_recaptcha_v3' => 'Solo reCAPTCHA v3 está soportado.',
'custom_head_set' => 'Cabecera HTML personalizada aplicada.',
'vanity_url' => 'URL personalizada',
];

View file

@ -35,7 +35,7 @@ return [
'bad_login' => 'Väärät kirjautumistiedot.',
'installed' => 'Asennus suoritettu loppuun onnistuneesti!',
'confirm_string' => 'Oletko varma?',
'confirm' => 'Vahvistus',
'confirm' => 'Vahvista',
'open' => 'Auki',
'none' => 'Ei mitään',
'reg_date' => 'Rekisteröitymis päivä',
@ -160,4 +160,5 @@ return [
'invalid_quota' => 'Virheelliset arvot oletuskäyttäjäkiintiönä.',
'mail.recover_text' => 'Hei %s, <br>tilillesi on pyydetty salasanan palautusta. Suorita toimenpide napsauttamalla seuraavaa linkkiä:<br><br><a href="%s">%s</a><br><br>Jos et ollut sinä, joka pyysit salasanan vaihtamista, ohita tämä sähköposti.',
'quota_enabled' => 'Käyttäjäkiintiön ottaminen käyttöön',
'vanity_url' => 'Mukautettu URL',
];

View file

@ -54,7 +54,7 @@ return [
'reg_date' => 'Date d\'inscription',
'none' => 'Aucun',
'open' => 'Ouvrir',
'confirm' => 'Confirmation',
'confirm' => 'Confirmer',
'confirm_string' => 'Êtes-vous sûr·e ?',
'installed' => 'L\'installation s\'est déroulée avec succès!',
'bad_login' => 'Identifiant ou mot de passe incorrect.',
@ -162,4 +162,5 @@ return [
'zip_ext_not_loaded' => 'L\'extension zip requise n\'est pas chargée',
'copied' => 'Copié dans le presse-papier !',
'image_embeds' => 'Intégrer des images',
'vanity_url' => 'URL personnalisée',
];

View file

@ -107,7 +107,7 @@ return [
'lang' => 'Français (Canada)',
'mail.new_account_text_with_pw' => 'Bonjour %s! <br> un nouveau compte a été créé pour vous sur %s (<a href="%s">% s</a>), avec les informations d\'identification suivantes : <br> <br> Nom d\'utilisateur :%s <br> Mot de passe :%s <br> <br> Cliquez sur le lien suivant pour accéder à la page de connexion : <br> <a href="%s">%s </a>',
'maintenance' => 'Maintenance',
'confirm' => 'Confirmation',
'confirm' => 'Confirmer',
'user_create_password' => 'Si laissé vide, vous souhaiterez peut-être envoyer une notification à l\'utilisateur par courriel.',
'mail.new_account' => '%s Création d\'un nouveau compte',
'mail.recover_password' => '%s Récupération de mot de passe',
@ -160,4 +160,5 @@ return [
'enforce_language' => 'Forcer la langue',
'copied' => 'Copié dans le presse-papier!',
'image_embeds' => 'Intégrer des images',
'vanity_url' => 'URL personnalisée',
];

View file

@ -160,4 +160,5 @@ return [
'custom_head_set' => 'Head HTML khusus diterapkan.',
'path_not_writable' => 'Destinasi berkas tidak dapat ditulis.',
'image_embeds' => 'Sematkan gambar',
'vanity_url' => 'URL kostum',
];

View file

@ -162,4 +162,5 @@ return [
'show_changelog' => 'Mostra registro dei cambiamenti',
'copied' => 'Copiato negli appunti!',
'image_embeds' => 'Incorpora immagini',
'vanity_url' => 'URL personalizzato',
];

View file

@ -54,7 +54,7 @@ return [
'reg_date' => 'Registratiedatum',
'none' => 'Geen',
'open' => 'Open',
'confirm' => 'Bevestiging',
'confirm' => 'Bevestigen',
'confirm_string' => 'Weet je het zeker?',
'installed' => 'Installatie succesvol voltooid!',
'bad_login' => 'Verkeerde verificatiegegevens.',
@ -164,4 +164,6 @@ return [
'php_info' => 'PHP Informatie',
'upload' => 'Uploaden',
'copied' => 'Gekopieerd naar klembord!',
'vanity_url' => 'Aangepaste URL',
'image_embeds' => 'Ingesloten afbeeldingen',
];

View file

@ -54,7 +54,7 @@ return [
'reg_date' => 'Data de registo',
'none' => 'Nenhum',
'open' => 'Abrir',
'confirm' => 'Confirmação',
'confirm' => 'Confirmar',
'confirm_string' => 'Tem a certeza?',
'installed' => 'Instalação completa com sucesso!',
'bad_login' => 'Login inválido.',
@ -161,4 +161,5 @@ return [
'register' => 'Registar',
'settings_saved' => 'Definições de sistema guardadas!',
'image_embeds' => 'Embutir imagens',
'vanity_url' => 'URL personalizado',
];

View file

@ -45,16 +45,16 @@ return [
'your_profile' => 'Ваш профиль',
'token' => 'Ключ',
'copy' => 'Копировать',
'update' => 'Обновить',
'update' => 'Обновление',
'edit' => 'Редактировать',
'client_config' => 'Конфигурация клиента',
'user_code' => 'Код пользователя',
'active' => 'Активен',
'active' => 'Активный',
'admin' => 'Админ',
'reg_date' => 'Дата регистрации',
'none' => 'Нет',
'none' => 'Никак',
'open' => 'Открыть',
'confirm' => 'Подтверждение',
'confirm' => 'Потвердить',
'confirm_string' => 'Вы уверены?',
'installed' => 'Установка успешно завершена!',
'bad_login' => 'Неверные учетные данные.',
@ -165,4 +165,5 @@ return [
'upload' => 'Выгрузить',
'php_info' => 'Инфо о PHP',
'image_embeds' => 'Встроенные изображения',
'vanity_url' => 'Пользовательский URL',
];

View file

@ -155,9 +155,10 @@ return [
'cannot_write_file' => 'Destinationens sökväg är ej skrivbar.',
'cannot_demote' => 'Du kan inte degradera dig själv.',
'token_not_found' => 'Den token som angavs hittades inte.',
'confirm' => 'Bekräftelse',
'confirm' => 'Bekräfta',
'copied' => 'Kopierat till urklipp!',
'token' => 'Token',
'orphaned_files' => 'Föräldralösa Filer',
'image_embeds' => 'Inbäddade bilder',
'vanity_url' => 'Anpassad URL',
];

View file

@ -15,7 +15,7 @@ return [
'filename' => 'Dosya adı',
'preview' => 'Ön izleme',
'public.delete_text' => 'Bu ögeyi silmek istediğinizden emin misiniz? Geri dönüşü olmayacaktır',
'public.telegram' => 'Telegram\'da paylaş !',
'public.telegram' => 'Telegram\'da paylaş',
'copy_link' => 'Bağlantıyı kopyala',
'pager.previous' => 'Önceki',
'pager.next' => 'Sonraki',
@ -148,7 +148,7 @@ return [
'zip_ext_not_loaded' => 'Gereken "zip" eklentisi yüklenmedi',
'changelog' => 'Değişiklik Günlüğü (Yama Notları)',
'show_changelog' => 'Değişiklik günlüğünü göster',
'confirm' => 'Onay',
'confirm' => 'Onayla',
'user_created' => '"%s" kullanıcısı oluşturuldu!',
'user_updated' => '"%s" kullanıcısı güncellendi!',
'profile_updated' => 'Profil başarıyla güncellendi!',
@ -160,4 +160,5 @@ return [
'custom_head_set' => 'Özel HTML başlığı uygulandı.',
'mail.activate_text' => 'Merhaba %s!<br>%s (<a href="%s">%s</a>) hesabınızı oluşturduğunuz için teşekkür ederiz, etkinleştirmek için aşağıdaki bağlantıya tıklayın:<br><br><a href="%s">%s</a>',
'switch_to' => 'Şuna geç',
'vanity_url' => 'Özel URL',
];

View file

@ -5,7 +5,7 @@ return [
'yes' => '是',
'enforce_language' => '默认语言',
'no' => '否',
'lang' => '英语',
'lang' => '中文(简体)',
'copy_link' => '复制链接',
'size' => '大小',
'download' => '下载',
@ -152,4 +152,13 @@ return [
'no_tags' => '未添加标签',
'mail.recover_text' => 'Hi %s,<br>已为您的帐户请求重置密码。要完成该过程,请单击以下链接:<br><br><a href="%s">%s</a><br><br>如果不是您要求重置密码,请忽略此电子邮件。',
'used' => '使用中',
'recaptcha_site_key' => 'reCAPTCHA 站点密钥',
'only_recaptcha_v3' => '只支持reCAPTCHA v3.',
'vanity_url' => '自定义网址',
'mail.new_account' => '新帐户创建',
'recaptcha_failed' => '验证失败',
'recaptcha_enabled' => '验证码启用',
'recaptcha_secret_key' => 'reCAPTCHA 密钥',
'prerelease_channel' => '预发布渠道',
'recaptcha_keys_required' => '所有 reCAPTCHA 密钥都是必需的。',
];

View file

@ -33,7 +33,7 @@
{% for media in medias %}
<tr id="media_{{ media.id }}" class="bulk-selector" data-id="{{ media.id }}">
<td class="text-center">
<a href="{{ urlFor('/' ~ media.user_code ~ '/' ~ media.code ~ '.' ~ media.extension) }}" target="_blank">
<a href="{{ urlFor('/' ~ media.user_code ~ '/' ~ media.code ~ '.' ~ media.extension) }}" target="_blank" class="text-dark">
{% if isDisplayableImage(media.mimetype) %}
{% if media.username is not null %}
<img src="{{ urlFor('/' ~ media.user_code ~ '/' ~ media.code ~ '.' ~ media.extension ~ '/raw?width=84&height=42') }}" class="img-fluid rounded">

View file

@ -0,0 +1,52 @@
#!/bin/bash
create_desktop_entry() {
cat << "EOF" > "$HOME/.local/share/kio/servicemenus/xbackbone-uploader.desktop"
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
Icon=imaga
X-KDE-StartupNotify=false
X-KDE-Priority=TopLevel
MimeType=image/*;
Actions=xbackbone_upload
[Desktop Action xbackbone_upload]
Name=Upload with XBackBone
Exec=sh -c 'RESPONSE="$(curl -s -F "token={{ token }}" -F "upload=@%u" {{ upload_url }})"; if [ "$(echo "${RESPONSE}" | jq -r ".message")" = "OK" ]; then URL="$(echo "${RESPONSE}" | jq -r ".url")"; if [ "${DESKTOP_SESSION}" != "" ]; then echo "${URL}" | xclip -selection c; notify-send "Upload completed!" "${URL}"; else echo "${URL}"; fi; exit 0; else MESSAGE="$(echo "${RESPONSE}" | jq -r ".message")"; if [ $? -ne 0 ]; then echo "Unexpected response:"; echo "${RESPONSE}"; exit 1; fi; if [ "${DESKTOP_SESSION}" != "" ]; then notify-send "Error!" "${MESSAGE}"; else echo "Error! ${MESSAGE}"; fi; exit 1; fi'
Icon=image
EOF
echo "Service menu created!";
}
check() {
ERRORS=0;
if [ ! -x "$(command -v jq)" ]; then
echo "jq command not found.";
ERRORS=1;
fi
if [ ! -x "$(command -v curl)" ]; then
echo "curl command not found.";
ERRORS=1;
fi
if [ ! -x "$(command -v xclip)" ] && [ "${DESKTOP_SESSION}" != "" ]; then
echo "xclip command not found.";
ERRORS=1;
fi
if [ ! -x "$(command -v notify-send)" ] && [ "${DESKTOP_SESSION}" != "" ]; then
echo "notify-send command not found.";
ERRORS=1;
fi
if [ "${ERRORS}" -eq 1 ]; then
exit 1;
fi
}
check
create_desktop_entry

View file

@ -66,7 +66,11 @@
<div class="btn-group">
<a href="{{ route('config.sharex', {'id': user.id}) }}" class="btn btn-lg btn-outline-dark"><i class="fas fa-fw fa-download"></i> ShareX</a>
<a href="javascript:alert('{{ lang('copied') }}')" data-clipboard-text="{{ route('config.screencloud', {'token': user.token}) }}" class="btn btn-lg btn-outline-info btn-clipboard"><i class="fas fa-fw fa-download"></i> Screencloud</a>
<a href="{{ route('config.script', {'id': user.id}) }}" class="btn btn-lg btn-outline-danger"><i class="fas fa-fw fa-download"></i> Linux Script</a>
<a href="{{ route('config.script', {'id': user.id}) }}" type="button" class="btn btn-lg btn-outline-danger"><i class="fas fa-fw fa-download"></i> Linux Script</a>
<button type="button" class="btn btn-outline-danger dropdown-toggle dropdown-toggle-split" id="userDropdown" data-toggle="dropdown" aria-expanded="false"></button>
<ul class="dropdown-menu">
<li><a class="dropdown-item text-danger" href="{{ route('kde_config.script', {'id': user.id}) }}"><i class="fas fa-fw fa-download"></i> KDE Linux Script</a></li>
</ul>
</div>
</div>
</div>