Revert previous CI hell

This commit is contained in:
SergiX44 2019-11-21 18:00:47 +01:00
parent f82d61a129
commit 6c004f8f96
46 changed files with 407 additions and 1305 deletions

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Controllers; namespace App\Controllers;
use League\Flysystem\FileNotFoundException; use League\Flysystem\FileNotFoundException;
@ -54,7 +34,7 @@ class AdminController extends Controller
$totalSize += $filesystem->getSize($media->storage_path); $totalSize += $filesystem->getSize($media->storage_path);
} }
return view()->render($response, 'dashboard/system.twig', array( return view()->render($response, 'dashboard/system.twig', [
'usersCount' => $usersCount, 'usersCount' => $usersCount,
'mediasCount' => $mediasCount, 'mediasCount' => $mediasCount,
'orphanFilesCount' => $orphanFilesCount, 'orphanFilesCount' => $orphanFilesCount,
@ -63,7 +43,7 @@ class AdminController extends Controller
'upload_max_filesize' => ini_get('upload_max_filesize'), 'upload_max_filesize' => ini_get('upload_max_filesize'),
'installed_lang' => $this->lang->getList(), 'installed_lang' => $this->lang->getList(),
'forced_lang' => $request->getAttribute('forced_lang'), 'forced_lang' => $request->getAttribute('forced_lang'),
)); ]);
} }
/** /**
@ -89,7 +69,7 @@ class AdminController extends Controller
$this->database->query('DELETE FROM `uploads` WHERE `user_id` IS NULL'); $this->database->query('DELETE FROM `uploads` WHERE `user_id` IS NULL');
$this->session->alert(lang('deleted_orphans', array($deleted))); $this->session->alert(lang('deleted_orphans', [$deleted]));
return redirect($response, route('system')); return redirect($response, route('system'));
} }
@ -112,7 +92,7 @@ class AdminController extends Controller
$this->database->query('DELETE FROM `settings` WHERE `key` = \'lang\''); $this->database->query('DELETE FROM `settings` WHERE `key` = \'lang\'');
} }
$this->session->alert(lang('lang_set', array(param($request, 'lang')))); $this->session->alert(lang('lang_set', [param($request, 'lang')]));
return redirect($response, route('system')); return redirect($response, route('system'));
} }

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Controllers; namespace App\Controllers;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;
@ -49,19 +29,19 @@ class ClientController extends Controller
return redirect($response, $request->getHeaderLine('Referer')); return redirect($response, $request->getHeaderLine('Referer'));
} }
$json = array( $json = [
'DestinationType' => 'ImageUploader, TextUploader, FileUploader', 'DestinationType' => 'ImageUploader, TextUploader, FileUploader',
'RequestURL' => route('upload'), 'RequestURL' => route('upload'),
'FileFormName' => 'upload', 'FileFormName' => 'upload',
'Arguments' => array( 'Arguments' => [
'file' => '$filename$', 'file' => '$filename$',
'text' => '$input$', 'text' => '$input$',
'token' => $user->token, 'token' => $user->token,
), ],
'URL' => '$json:url$', 'URL' => '$json:url$',
'ThumbnailURL' => '$json:url$/raw', 'ThumbnailURL' => '$json:url$/raw',
'DeletionURL' => '$json:url$/delete/'.$user->token, 'DeletionURL' => '$json:url$/delete/'.$user->token,
); ];
return json($response, $json, 200, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) 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="'.$user->username.'-ShareX.sxcu"');
@ -92,11 +72,11 @@ class ClientController extends Controller
return view()->render($response->withHeader('Content-Disposition', 'attachment;filename="xbackbone_uploader_'.$user->username.'.sh"'), return view()->render($response->withHeader('Content-Disposition', 'attachment;filename="xbackbone_uploader_'.$user->username.'.sh"'),
'scripts/xbackbone_uploader.sh.twig', 'scripts/xbackbone_uploader.sh.twig',
array( [
'username' => $user->username, 'username' => $user->username,
'upload_url' => route('upload'), 'upload_url' => route('upload'),
'token' => $user->token, 'token' => $user->token,
) ]
); );
} }
} }

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Controllers; namespace App\Controllers;
use App\Database\DB; use App\Database\DB;
@ -86,7 +66,7 @@ abstract class Controller
try { try {
$totalSize += $filesystem->getSize($media->storage_path); $totalSize += $filesystem->getSize($media->storage_path);
} catch (FileNotFoundException $e) { } catch (FileNotFoundException $e) {
$this->logger->error('Error calculating file size', array('exception' => $e)); $this->logger->error('Error calculating file size', ['exception' => $e]);
} }
} }

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Controllers; namespace App\Controllers;
use App\Database\Queries\MediaQuery; use App\Database\Queries\MediaQuery;
@ -83,12 +63,12 @@ class DashboardController extends Controller
return view()->render( return view()->render(
$response, $response,
($this->session->get('admin', false) && $this->session->get('gallery_view', true)) ? 'dashboard/list.twig' : 'dashboard/grid.twig', ($this->session->get('admin', false) && $this->session->get('gallery_view', true)) ? 'dashboard/list.twig' : 'dashboard/grid.twig',
array( [
'medias' => $query->getMedia(), 'medias' => $query->getMedia(),
'next' => $page < floor($query->getPages()), 'next' => $page < floor($query->getPages()),
'previous' => $page >= 1, 'previous' => $page >= 1,
'current_page' => ++$page, 'current_page' => ++$page,
) ]
); );
} }

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Controllers; namespace App\Controllers;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;
@ -56,7 +36,7 @@ class LoginController extends Controller
public function login(Request $request, Response $response): Response public function login(Request $request, Response $response): Response
{ {
$username = param($request, 'username'); $username = param($request, 'username');
$result = $this->database->query('SELECT `id`, `email`, `username`, `password`,`is_admin`, `active` FROM `users` WHERE `username` = ? OR `email` = ? LIMIT 1', array($username, $username))->fetch(); $result = $this->database->query('SELECT `id`, `email`, `username`, `password`,`is_admin`, `active` FROM `users` WHERE `username` = ? OR `email` = ? LIMIT 1', [$username, $username])->fetch();
if (!$result || !password_verify(param($request, 'password'), $result->password)) { if (!$result || !password_verify(param($request, 'password'), $result->password)) {
$this->session->alert(lang('bad_login'), 'danger'); $this->session->alert(lang('bad_login'), 'danger');
@ -82,7 +62,7 @@ class LoginController extends Controller
$this->session->set('admin', $result->is_admin); $this->session->set('admin', $result->is_admin);
$this->session->set('used_space', humanFileSize($this->getUsedSpaceByUser($result->id))); $this->session->set('used_space', humanFileSize($this->getUsedSpaceByUser($result->id)));
$this->session->alert(lang('welcome', array($result->username)), 'info'); $this->session->alert(lang('welcome', [$result->username]), 'info');
$this->logger->info("User $result->username logged in."); $this->logger->info("User $result->username logged in.");
if (param($request, 'remember') === 'on') { if (param($request, 'remember') === 'on') {
@ -90,22 +70,22 @@ class LoginController extends Controller
$token = bin2hex(random_bytes(32)); $token = bin2hex(random_bytes(32));
$expire = time() + 604800; // a week $expire = time() + 604800; // a week
$this->database->query('UPDATE `users` SET `remember_selector`=?, `remember_token`=?, `remember_expire`=? WHERE `id`=?', array( $this->database->query('UPDATE `users` SET `remember_selector`=?, `remember_token`=?, `remember_expire`=? WHERE `id`=?', [
$selector, $selector,
password_hash($token, PASSWORD_DEFAULT), password_hash($token, PASSWORD_DEFAULT),
date('Y-m-d\TH:i:s', $expire), date('Y-m-d\TH:i:s', $expire),
$result->id, $result->id,
)); ]);
// Workaround for php <= 7.3 // Workaround for php <= 7.3
if (PHP_VERSION_ID < 70300) { if (PHP_VERSION_ID < 70300) {
setcookie('remember', "{$selector}:{$token}", $expire, '; SameSite=Lax', '', false, true); setcookie('remember', "{$selector}:{$token}", $expire, '; SameSite=Lax', '', false, true);
} else { } else {
setcookie('remember', "{$selector}:{$token}", array( setcookie('remember', "{$selector}:{$token}", [
'expires' => $expire, 'expires' => $expire,
'httponly' => true, 'httponly' => true,
'samesite' => 'Lax', 'samesite' => 'Lax',
)); ]);
} }
} }

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Controllers; namespace App\Controllers;
use GuzzleHttp\Psr7\Stream; use GuzzleHttp\Psr7\Stream;
@ -36,19 +16,19 @@ use Slim\Exception\HttpUnauthorizedException;
class MediaController extends Controller class MediaController extends Controller
{ {
/** /**
* @param Request $request * @param Request $request
* @param Response $response * @param Response $response
* @param string $userCode * @param string $userCode
* @param string $mediaCode * @param string $mediaCode
* @param string|null $token * @param string|null $token
* *
* @return Response
* @throws HttpNotFoundException * @throws HttpNotFoundException
* @throws \Twig\Error\LoaderError * @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError * @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError * @throws \Twig\Error\SyntaxError
* @throws FileNotFoundException * @throws FileNotFoundException
* *
* @return Response
*/ */
public function show(Request $request, Response $response, string $userCode, string $mediaCode, string $token = null): Response public function show(Request $request, Response $response, string $userCode, string $mediaCode, string $token = null): Response
{ {
@ -86,23 +66,23 @@ class MediaController extends Controller
throw new HttpNotFoundException($request); throw new HttpNotFoundException($request);
} }
return view()->render($response, 'upload/public.twig', array( return view()->render($response, 'upload/public.twig', [
'delete_token' => $token, 'delete_token' => $token,
'media' => $media, 'media' => $media,
'type' => $type, 'type' => $type,
'url' => urlFor("/{$userCode}/{$mediaCode}"), 'url' => urlFor("/{$userCode}/{$mediaCode}"),
)); ]);
} }
/** /**
* @param Request $request * @param Request $request
* @param Response $response * @param Response $response
* @param int $id * @param int $id
*
* @throws HttpNotFoundException
* @throws FileNotFoundException
* *
* @return Response * @return Response
* @throws HttpNotFoundException
*
* @throws FileNotFoundException
*/ */
public function getRawById(Request $request, Response $response, int $id): Response public function getRawById(Request $request, Response $response, int $id): Response
{ {
@ -116,17 +96,17 @@ class MediaController extends Controller
} }
/** /**
* @param Request $request * @param Request $request
* @param Response $response * @param Response $response
* @param string $userCode * @param string $userCode
* @param string $mediaCode * @param string $mediaCode
* @param string|null $ext * @param string|null $ext
*
* @throws HttpBadRequestException
* @throws HttpNotFoundException
* @throws FileNotFoundException
* *
* @return Response * @return Response
* @throws HttpBadRequestException
* @throws HttpNotFoundException
*
* @throws FileNotFoundException
*/ */
public function getRaw(Request $request, Response $response, string $userCode, string $mediaCode, ?string $ext = null): Response public function getRaw(Request $request, Response $response, string $userCode, string $mediaCode, ?string $ext = null): Response
{ {
@ -144,15 +124,15 @@ class MediaController extends Controller
} }
/** /**
* @param Request $request * @param Request $request
* @param Response $response * @param Response $response
* @param string $userCode * @param string $userCode
* @param string $mediaCode * @param string $mediaCode
*
* @throws HttpNotFoundException
* @throws FileNotFoundException
* *
* @return Response * @return Response
* @throws HttpNotFoundException
*
* @throws FileNotFoundException
*/ */
public function download(Request $request, Response $response, string $userCode, string $mediaCode): Response public function download(Request $request, Response $response, string $userCode, string $mediaCode): Response
{ {
@ -166,40 +146,40 @@ class MediaController extends Controller
} }
/** /**
* @param Request $request * @param Request $request
* @param Response $response * @param Response $response
* @param int $id * @param int $id
*
* @throws HttpNotFoundException
* *
* @return Response * @return Response
* @throws HttpNotFoundException
*
*/ */
public function togglePublish(Request $request, Response $response, int $id): Response public function togglePublish(Request $request, Response $response, int $id): Response
{ {
if ($this->session->get('admin')) { if ($this->session->get('admin')) {
$media = $this->database->query('SELECT * FROM `uploads` WHERE `id` = ? LIMIT 1', $id)->fetch(); $media = $this->database->query('SELECT * FROM `uploads` WHERE `id` = ? LIMIT 1', $id)->fetch();
} else { } else {
$media = $this->database->query('SELECT * FROM `uploads` WHERE `id` = ? AND `user_id` = ? LIMIT 1', array($id, $this->session->get('user_id')))->fetch(); $media = $this->database->query('SELECT * FROM `uploads` WHERE `id` = ? AND `user_id` = ? LIMIT 1', [$id, $this->session->get('user_id')])->fetch();
} }
if (!$media) { if (!$media) {
throw new HttpNotFoundException($request); throw new HttpNotFoundException($request);
} }
$this->database->query('UPDATE `uploads` SET `published`=? WHERE `id`=?', array($media->published ? 0 : 1, $media->id)); $this->database->query('UPDATE `uploads` SET `published`=? WHERE `id`=?', [$media->published ? 0 : 1, $media->id]);
return $response; return $response;
} }
/** /**
* @param Request $request * @param Request $request
* @param Response $response * @param Response $response
* @param int $id * @param int $id
*
* @throws HttpUnauthorizedException
* @throws HttpNotFoundException
* *
* @return Response * @return Response
* @throws HttpUnauthorizedException
*
* @throws HttpNotFoundException
*/ */
public function delete(Request $request, Response $response, int $id): Response public function delete(Request $request, Response $response, int $id): Response
{ {
@ -211,7 +191,7 @@ class MediaController extends Controller
if ($this->session->get('admin', false) || $media->user_id === $this->session->get('user_id')) { if ($this->session->get('admin', false) || $media->user_id === $this->session->get('user_id')) {
$this->deleteMedia($request, $media->storage_path, $id); $this->deleteMedia($request, $media->storage_path, $id);
$this->logger->info('User '.$this->session->get('username').' deleted a media.', array($id)); $this->logger->info('User '.$this->session->get('username').' deleted a media.', [$id]);
$this->session->set('used_space', humanFileSize($this->getUsedSpaceByUser($this->session->get('user_id')))); $this->session->set('used_space', humanFileSize($this->getUsedSpaceByUser($this->session->get('user_id'))));
} else { } else {
throw new HttpUnauthorizedException($request); throw new HttpUnauthorizedException($request);
@ -225,16 +205,16 @@ class MediaController extends Controller
} }
/** /**
* @param Request $request * @param Request $request
* @param Response $response * @param Response $response
* @param string $userCode * @param string $userCode
* @param string $mediaCode * @param string $mediaCode
* @param string $token * @param string $token
*
* @throws HttpUnauthorizedException
* @throws HttpNotFoundException
* *
* @return Response * @return Response
* @throws HttpUnauthorizedException
*
* @throws HttpNotFoundException
*/ */
public function deleteByToken(Request $request, Response $response, string $userCode, string $mediaCode, string $token): Response public function deleteByToken(Request $request, Response $response, string $userCode, string $mediaCode, string $token): Response
{ {
@ -260,7 +240,7 @@ class MediaController extends Controller
if ($this->session->get('admin', false) || $user->id === $media->user_id) { if ($this->session->get('admin', false) || $user->id === $media->user_id) {
$this->deleteMedia($request, $media->storage_path, $media->mediaId); $this->deleteMedia($request, $media->storage_path, $media->mediaId);
$this->logger->info('User '.$user->username.' deleted a media via token.', array($media->mediaId)); $this->logger->info('User '.$user->username.' deleted a media via token.', [$media->mediaId]);
} else { } else {
throw new HttpUnauthorizedException($request); throw new HttpUnauthorizedException($request);
} }
@ -269,9 +249,9 @@ class MediaController extends Controller
} }
/** /**
* @param Request $request * @param Request $request
* @param string $storagePath * @param string $storagePath
* @param int $id * @param int $id
* *
* @throws HttpNotFoundException * @throws HttpNotFoundException
*/ */
@ -296,24 +276,24 @@ class MediaController extends Controller
{ {
$mediaCode = pathinfo($mediaCode)['filename']; $mediaCode = pathinfo($mediaCode)['filename'];
$media = $this->database->query('SELECT `uploads`.*, `users`.*, `users`.`id` AS `userId`, `uploads`.`id` AS `mediaId` FROM `uploads` INNER JOIN `users` ON `uploads`.`user_id` = `users`.`id` WHERE `user_code` = ? AND `uploads`.`code` = ? LIMIT 1', array( $media = $this->database->query('SELECT `uploads`.*, `users`.*, `users`.`id` AS `userId`, `uploads`.`id` AS `mediaId` FROM `uploads` INNER JOIN `users` ON `uploads`.`user_id` = `users`.`id` WHERE `user_code` = ? AND `uploads`.`code` = ? LIMIT 1', [
$userCode, $userCode,
$mediaCode, $mediaCode,
))->fetch(); ])->fetch();
return $media; return $media;
} }
/** /**
* @param Request $request * @param Request $request
* @param Response $response * @param Response $response
* @param Filesystem $storage * @param Filesystem $storage
* @param $media * @param $media
* @param string $disposition * @param string $disposition
*
* @throws FileNotFoundException
* *
* @return Response * @return Response
* @throws FileNotFoundException
*
*/ */
protected function streamMedia(Request $request, Response $response, Filesystem $storage, $media, string $disposition = 'inline'): Response protected function streamMedia(Request $request, Response $response, Filesystem $storage, $media, string $disposition = 'inline'): Response
{ {
@ -325,7 +305,7 @@ class MediaController extends Controller
} else { } else {
$stream = new Stream($storage->readStream($media->storage_path)); $stream = new Stream($storage->readStream($media->storage_path));
if (!in_array(explode('/', $mime)[0], array('image', 'video', 'audio')) || $disposition === 'attachment') { if (!in_array(explode('/', $mime)[0], ['image', 'video', 'audio']) || $disposition === 'attachment') {
return $response->withHeader('Content-Type', $mime) return $response->withHeader('Content-Type', $mime)
->withHeader('Content-Disposition', $disposition.'; filename="'.$media->filename.'"') ->withHeader('Content-Disposition', $disposition.'; filename="'.$media->filename.'"')
->withHeader('Content-Length', $stream->getSize()) ->withHeader('Content-Length', $stream->getSize())
@ -344,15 +324,15 @@ class MediaController extends Controller
} }
/** /**
* @param Filesystem $storage * @param Filesystem $storage
* @param $media * @param $media
* @param null $width * @param null $width
* @param null $height * @param null $height
* @param string $disposition * @param string $disposition
*
* @throws FileNotFoundException
* *
* @return Response * @return Response
* @throws FileNotFoundException
*
*/ */
protected function makeThumbnail(Filesystem $storage, $media, $width = null, $height = null, string $disposition = 'inline') protected function makeThumbnail(Filesystem $storage, $media, $width = null, $height = null, string $disposition = 'inline')
{ {
@ -366,10 +346,10 @@ class MediaController extends Controller
} }
/** /**
* @param Response $response * @param Response $response
* @param Stream $stream * @param Stream $stream
* @param string $range * @param string $range
* @param string $disposition * @param string $disposition
* @param $media * @param $media
* @param $mime * @param $mime
* *

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Controllers; namespace App\Controllers;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;
@ -36,7 +16,7 @@ class ThemeController extends Controller
{ {
$apiJson = json_decode(file_get_contents('https://bootswatch.com/api/4.json')); $apiJson = json_decode(file_get_contents('https://bootswatch.com/api/4.json'));
$out = array(); $out = [];
$out['Default - Bootstrap 4 default theme'] = 'https://bootswatch.com/_vendor/bootstrap/dist/css/bootstrap.min.css'; $out['Default - Bootstrap 4 default theme'] = 'https://bootswatch.com/_vendor/bootstrap/dist/css/bootstrap.min.css';
foreach ($apiJson->themes as $theme) { foreach ($apiJson->themes as $theme) {

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Controllers; namespace App\Controllers;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;
@ -120,11 +100,11 @@ class UpgradeController extends Controller
*/ */
public function checkForUpdates(Request $request, Response $response): Response public function checkForUpdates(Request $request, Response $response): Response
{ {
$jsonResponse = array( $jsonResponse = [
'status' => null, 'status' => null,
'message' => null, 'message' => null,
'upgrade' => false, 'upgrade' => false,
); ];
$acceptPrerelease = param($request, 'prerelease', 'false') === 'true'; $acceptPrerelease = param($request, 'prerelease', 'false') === 'true';
@ -155,15 +135,15 @@ class UpgradeController extends Controller
protected function getApiJson() protected function getApiJson()
{ {
$opts = array( $opts = [
'http' => array( 'http' => [
'method' => 'GET', 'method' => 'GET',
'header' => array( 'header' => [
'User-Agent: XBackBone-App', 'User-Agent: XBackBone-App',
'Accept: application/vnd.github.v3+json', 'Accept: application/vnd.github.v3+json',
), ],
), ],
); ];
$data = @file_get_contents(self::GITHUB_SOURCE_API, false, stream_context_create($opts)); $data = @file_get_contents(self::GITHUB_SOURCE_API, false, stream_context_create($opts));

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Controllers; namespace App\Controllers;
use League\Flysystem\FileExistsException; use League\Flysystem\FileExistsException;
@ -29,14 +9,14 @@ use Psr\Http\Message\ServerRequestInterface as Request;
class UploadController extends Controller class UploadController extends Controller
{ {
/** /**
* @param Request $request * @param Request $request
* @param Response $response * @param Response $response
*
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
* @throws \Twig\Error\LoaderError
* *
* @return Response * @return Response
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
*
* @throws \Twig\Error\LoaderError
*/ */
public function webUpload(Request $request, Response $response): Response public function webUpload(Request $request, Response $response): Response
{ {
@ -48,25 +28,25 @@ class UploadController extends Controller
return redirect($response, $request->getHeaderLine('Referer')); return redirect($response, $request->getHeaderLine('Referer'));
} }
return view()->render($response, 'upload/web.twig', array( return view()->render($response, 'upload/web.twig', [
'user' => $user, 'user' => $user,
)); ]);
} }
/** /**
* @param Request $request * @param Request $request
* @param Response $response * @param Response $response
*
* @throws FileExistsException
* *
* @return Response * @return Response
* @throws FileExistsException
*
*/ */
public function upload(Request $request, Response $response): Response public function upload(Request $request, Response $response): Response
{ {
$json = array( $json = [
'message' => null, 'message' => null,
'version' => PLATFORM_VERSION, 'version' => PLATFORM_VERSION,
); ];
if ($this->config['maintenance']) { if ($this->config['maintenance']) {
$json['message'] = 'Endpoint under maintenance.'; $json['message'] = 'Endpoint under maintenance.';
@ -125,17 +105,17 @@ class UploadController extends Controller
$this->storage->writeStream($storagePath, $file->getStream()->detach()); $this->storage->writeStream($storagePath, $file->getStream()->detach());
$this->database->query('INSERT INTO `uploads`(`user_id`, `code`, `filename`, `storage_path`) VALUES (?, ?, ?, ?)', array( $this->database->query('INSERT INTO `uploads`(`user_id`, `code`, `filename`, `storage_path`) VALUES (?, ?, ?, ?)', [
$user->id, $user->id,
$code, $code,
$file->getClientFilename(), $file->getClientFilename(),
$storagePath, $storagePath,
)); ]);
$json['message'] = 'OK.'; $json['message'] = 'OK.';
$json['url'] = urlFor("/{$user->user_code}/{$code}.{$fileInfo['extension']}"); $json['url'] = urlFor("/{$user->user_code}/{$code}.{$fileInfo['extension']}");
$this->logger->info("User $user->username uploaded new media.", array($this->database->getPdo()->lastInsertId())); $this->logger->info("User $user->username uploaded new media.", [$this->database->getPdo()->lastInsertId()]);
return json($response, $json, 201); return json($response, $json, 201);
} }

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Controllers; namespace App\Controllers;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;
@ -45,18 +25,18 @@ class UserController extends Controller
{ {
$page = max(0, --$page); $page = max(0, --$page);
$users = $this->database->query('SELECT * FROM `users` LIMIT ? OFFSET ?', array(self::PER_PAGE, $page * self::PER_PAGE))->fetchAll(); $users = $this->database->query('SELECT * FROM `users` LIMIT ? OFFSET ?', [self::PER_PAGE, $page * self::PER_PAGE])->fetchAll();
$pages = $this->database->query('SELECT COUNT(*) AS `count` FROM `users`')->fetch()->count / self::PER_PAGE; $pages = $this->database->query('SELECT COUNT(*) AS `count` FROM `users`')->fetch()->count / self::PER_PAGE;
return view()->render($response, return view()->render($response,
'user/index.twig', 'user/index.twig',
array( [
'users' => $users, 'users' => $users,
'next' => $page < floor($pages), 'next' => $page < floor($pages),
'previous' => $page >= 1, 'previous' => $page >= 1,
'current_page' => ++$page, 'current_page' => ++$page,
) ]
); );
} }
@ -118,7 +98,7 @@ class UserController extends Controller
$token = $this->generateNewToken(); $token = $this->generateNewToken();
$this->database->query('INSERT INTO `users`(`email`, `username`, `password`, `is_admin`, `active`, `user_code`, `token`) VALUES (?, ?, ?, ?, ?, ?, ?)', array( $this->database->query('INSERT INTO `users`(`email`, `username`, `password`, `is_admin`, `active`, `user_code`, `token`) VALUES (?, ?, ?, ?, ?, ?, ?)', [
param($request, 'email'), param($request, 'email'),
param($request, 'username'), param($request, 'username'),
password_hash(param($request, 'password'), PASSWORD_DEFAULT), password_hash(param($request, 'password'), PASSWORD_DEFAULT),
@ -126,10 +106,10 @@ class UserController extends Controller
param($request, 'is_active') !== null ? 1 : 0, param($request, 'is_active') !== null ? 1 : 0,
$userCode, $userCode,
$token, $token,
)); ]);
$this->session->alert(lang('user_created', array(param($request, 'username'))), 'success'); $this->session->alert(lang('user_created', [param($request, 'username')]), 'success');
$this->logger->info('User '.$this->session->get('username').' created a new user.', array(array_diff_key($request->getParsedBody(), array_flip(array('password'))))); $this->logger->info('User '.$this->session->get('username').' created a new user.', [array_diff_key($request->getParsedBody(), array_flip(['password']))]);
return redirect($response, route('user.index')); return redirect($response, route('user.index'));
} }
@ -151,10 +131,10 @@ class UserController extends Controller
{ {
$user = $this->getUser($request, $id, false); $user = $this->getUser($request, $id, false);
return view()->render($response, 'user/edit.twig', array( return view()->render($response, 'user/edit.twig', [
'profile' => false, 'profile' => false,
'user' => $user, 'user' => $user,
)); ]);
} }
/** /**
@ -174,57 +154,57 @@ class UserController extends Controller
if (param($request, 'email') === null) { if (param($request, 'email') === null) {
$this->session->alert(lang('email_required'), 'danger'); $this->session->alert(lang('email_required'), 'danger');
return redirect($response, route('user.edit', array('id' => $id))); return redirect($response, route('user.edit', ['id' => $id]));
} }
if ($this->database->query('SELECT COUNT(*) AS `count` FROM `users` WHERE `email` = ? AND `email` <> ?', array(param($request, 'email'), $user->email))->fetch()->count > 0) { if ($this->database->query('SELECT COUNT(*) AS `count` FROM `users` WHERE `email` = ? AND `email` <> ?', [param($request, 'email'), $user->email])->fetch()->count > 0) {
$this->session->alert(lang('email_taken'), 'danger'); $this->session->alert(lang('email_taken'), 'danger');
return redirect($response, route('user.edit', array('id' => $id))); return redirect($response, route('user.edit', ['id' => $id]));
} }
if (param($request, 'username') === null) { if (param($request, 'username') === null) {
$this->session->alert(lang('username_required'), 'danger'); $this->session->alert(lang('username_required'), 'danger');
return redirect($response, route('user.edit', array('id' => $id))); return redirect($response, route('user.edit', ['id' => $id]));
} }
if ($this->database->query('SELECT COUNT(*) AS `count` FROM `users` WHERE `username` = ? AND `username` <> ?', array(param($request, 'username'), $user->username))->fetch()->count > 0) { if ($this->database->query('SELECT COUNT(*) AS `count` FROM `users` WHERE `username` = ? AND `username` <> ?', [param($request, 'username'), $user->username])->fetch()->count > 0) {
$this->session->alert(lang('username_taken'), 'danger'); $this->session->alert(lang('username_taken'), 'danger');
return redirect($response, route('user.edit', array('id' => $id))); return redirect($response, route('user.edit', ['id' => $id]));
} }
if ($user->id === $this->session->get('user_id') && param($request, 'is_admin') === null) { if ($user->id === $this->session->get('user_id') && param($request, 'is_admin') === null) {
$this->session->alert(lang('cannot_demote'), 'danger'); $this->session->alert(lang('cannot_demote'), 'danger');
return redirect($response, route('user.edit', array('id' => $id))); return redirect($response, route('user.edit', ['id' => $id]));
} }
if (param($request, 'password') !== null && !empty(param($request, 'password'))) { if (param($request, 'password') !== null && !empty(param($request, 'password'))) {
$this->database->query('UPDATE `users` SET `email`=?, `username`=?, `password`=?, `is_admin`=?, `active`=? WHERE `id` = ?', array( $this->database->query('UPDATE `users` SET `email`=?, `username`=?, `password`=?, `is_admin`=?, `active`=? WHERE `id` = ?', [
param($request, 'email'), param($request, 'email'),
param($request, 'username'), param($request, 'username'),
password_hash(param($request, 'password'), PASSWORD_DEFAULT), password_hash(param($request, 'password'), PASSWORD_DEFAULT),
param($request, 'is_admin') !== null ? 1 : 0, param($request, 'is_admin') !== null ? 1 : 0,
param($request, 'is_active') !== null ? 1 : 0, param($request, 'is_active') !== null ? 1 : 0,
$user->id, $user->id,
)); ]);
} else { } else {
$this->database->query('UPDATE `users` SET `email`=?, `username`=?, `is_admin`=?, `active`=? WHERE `id` = ?', array( $this->database->query('UPDATE `users` SET `email`=?, `username`=?, `is_admin`=?, `active`=? WHERE `id` = ?', [
param($request, 'email'), param($request, 'email'),
param($request, 'username'), param($request, 'username'),
param($request, 'is_admin') !== null ? 1 : 0, param($request, 'is_admin') !== null ? 1 : 0,
param($request, 'is_active') !== null ? 1 : 0, param($request, 'is_active') !== null ? 1 : 0,
$user->id, $user->id,
)); ]);
} }
$this->session->alert(lang('user_updated', array(param($request, 'username'))), 'success'); $this->session->alert(lang('user_updated', [param($request, 'username')]), 'success');
$this->logger->info('User '.$this->session->get('username')." updated $user->id.", array( $this->logger->info('User '.$this->session->get('username')." updated $user->id.", [
array_diff_key((array) $user, array_flip(array('password'))), array_diff_key((array) $user, array_flip(['password'])),
array_diff_key($request->getParsedBody(), array_flip(array('password'))), array_diff_key($request->getParsedBody(), array_flip(['password'])),
)); ]);
return redirect($response, route('user.index')); return redirect($response, route('user.index'));
} }
@ -273,10 +253,10 @@ class UserController extends Controller
{ {
$user = $this->getUser($request, $this->session->get('user_id'), true); $user = $this->getUser($request, $this->session->get('user_id'), true);
return view()->render($response, 'user/edit.twig', array( return view()->render($response, 'user/edit.twig', [
'profile' => true, 'profile' => true,
'user' => $user, 'user' => $user,
)); ]);
} }
/** /**
@ -299,23 +279,23 @@ class UserController extends Controller
$user = $this->getUser($request, $id, true); $user = $this->getUser($request, $id, true);
if ($this->database->query('SELECT COUNT(*) AS `count` FROM `users` WHERE `email` = ? AND `email` <> ?', array(param($request, 'email'), $user->email))->fetch()->count > 0) { if ($this->database->query('SELECT COUNT(*) AS `count` FROM `users` WHERE `email` = ? AND `email` <> ?', [param($request, 'email'), $user->email])->fetch()->count > 0) {
$this->session->alert(lang('email_taken'), 'danger'); $this->session->alert(lang('email_taken'), 'danger');
return redirect($response, route('profile')); return redirect($response, route('profile'));
} }
if (param($request, 'password') !== null && !empty(param($request, 'password'))) { if (param($request, 'password') !== null && !empty(param($request, 'password'))) {
$this->database->query('UPDATE `users` SET `email`=?, `password`=? WHERE `id` = ?', array( $this->database->query('UPDATE `users` SET `email`=?, `password`=? WHERE `id` = ?', [
param($request, 'email'), param($request, 'email'),
password_hash(param($request, 'password'), PASSWORD_DEFAULT), password_hash(param($request, 'password'), PASSWORD_DEFAULT),
$user->id, $user->id,
)); ]);
} else { } else {
$this->database->query('UPDATE `users` SET `email`=? WHERE `id` = ?', array( $this->database->query('UPDATE `users` SET `email`=? WHERE `id` = ?', [
param($request, 'email'), param($request, 'email'),
$user->id, $user->id,
)); ]);
} }
$this->session->alert(lang('profile_updated'), 'success'); $this->session->alert(lang('profile_updated'), 'success');
@ -340,10 +320,10 @@ class UserController extends Controller
$token = $this->generateNewToken(); $token = $this->generateNewToken();
$this->database->query('UPDATE `users` SET `token`=? WHERE `id` = ?', array( $this->database->query('UPDATE `users` SET `token`=? WHERE `id` = ?', [
$token, $token,
$user->id, $user->id,
)); ]);
$this->logger->info('User '.$this->session->get('username')." refreshed token of user $user->id."); $this->logger->info('User '.$this->session->get('username')." refreshed token of user $user->id.");

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Database; namespace App\Database;
use PDO; use PDO;
@ -47,10 +27,10 @@ class DB
} }
} }
public function query(string $query, $parameters = array()) public function query(string $query, $parameters = [])
{ {
if (!is_array($parameters)) { if (!is_array($parameters)) {
$parameters = array($parameters); $parameters = [$parameters];
} }
$query = $this->pdo->prepare($query); $query = $this->pdo->prepare($query);

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Database; namespace App\Database;
use PDOException; use PDOException;
@ -99,13 +79,13 @@ class Migrator
try { try {
$this->db->getPdo()->exec($sql); $this->db->getPdo()->exec($sql);
if (!$exists) { if (!$exists) {
$this->db->query('INSERT INTO `migrations` VALUES (?,?)', array(basename($file), 1)); $this->db->query('INSERT INTO `migrations` VALUES (?,?)', [basename($file), 1]);
} else { } else {
$this->db->query('UPDATE `migrations` SET `migrated`=? WHERE `name`=?', array(1, basename($file))); $this->db->query('UPDATE `migrations` SET `migrated`=? WHERE `name`=?', [1, basename($file)]);
} }
} catch (PDOException $exception) { } catch (PDOException $exception) {
if (!$exists) { if (!$exists) {
$this->db->query('INSERT INTO `migrations` VALUES (?,?)', array(basename($file), 0)); $this->db->query('INSERT INTO `migrations` VALUES (?,?)', [basename($file), 0]);
} }
throw $exception; throw $exception;

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Database\Queries; namespace App\Database\Queries;
use App\Database\DB; use App\Database\DB;
@ -132,7 +112,7 @@ class MediaQuery
} }
$orderAndSearch = ''; $orderAndSearch = '';
$params = array(); $params = [];
if ($this->text !== null) { if ($this->text !== null) {
$orderAndSearch = $this->isAdmin ? 'WHERE `uploads`.`filename` LIKE ? ' : 'AND `uploads`.`filename` LIKE ? '; $orderAndSearch = $this->isAdmin ? 'WHERE `uploads`.`filename` LIKE ? ' : 'AND `uploads`.`filename` LIKE ? ';
@ -153,11 +133,11 @@ class MediaQuery
$queryMedia = sprintf($queryMedia, $orderAndSearch); $queryMedia = sprintf($queryMedia, $orderAndSearch);
if ($this->isAdmin) { if ($this->isAdmin) {
$this->media = $this->db->query($queryMedia, array_merge($params, array(self::PER_PAGE_ADMIN, $page * self::PER_PAGE_ADMIN)))->fetchAll(); $this->media = $this->db->query($queryMedia, array_merge($params, [self::PER_PAGE_ADMIN, $page * self::PER_PAGE_ADMIN]))->fetchAll();
$this->pages = $this->db->query($queryPages, $params)->fetch()->count / self::PER_PAGE_ADMIN; $this->pages = $this->db->query($queryPages, $params)->fetch()->count / self::PER_PAGE_ADMIN;
} else { } else {
$this->media = $this->db->query($queryMedia, array_merge(array($this->userId), $params, array(self::PER_PAGE, $page * self::PER_PAGE)))->fetchAll(); $this->media = $this->db->query($queryMedia, array_merge([$this->userId], $params, [self::PER_PAGE, $page * self::PER_PAGE]))->fetchAll();
$this->pages = $this->db->query($queryPages, array_merge(array($this->userId), $params))->fetch()->count / self::PER_PAGE; $this->pages = $this->db->query($queryPages, array_merge([$this->userId], $params))->fetch()->count / self::PER_PAGE;
} }
foreach ($this->media as $media) { foreach ($this->media as $media) {
@ -186,7 +166,7 @@ class MediaQuery
$offset = $page * self::PER_PAGE_ADMIN; $offset = $page * self::PER_PAGE_ADMIN;
$limit = self::PER_PAGE_ADMIN; $limit = self::PER_PAGE_ADMIN;
} else { } else {
$userCode = $this->db->query('SELECT `user_code` FROM `users` WHERE `id` = ?', array($this->userId))->fetch()->user_code; $userCode = $this->db->query('SELECT `user_code` FROM `users` WHERE `id` = ?', [$this->userId])->fetch()->user_code;
$files = $this->storage->listFiles($userCode); $files = $this->storage->listFiles($userCode);
$this->pages = count($files) / self::PER_PAGE; $this->pages = count($files) / self::PER_PAGE;
@ -198,9 +178,9 @@ class MediaQuery
if ($this->text !== null) { if ($this->text !== null) {
if ($this->isAdmin) { if ($this->isAdmin) {
$medias = $this->db->query('SELECT `uploads`.*, `users`.`user_code`, `users`.`username` FROM `uploads` LEFT JOIN `users` ON `uploads`.`user_id` = `users`.`id` WHERE `uploads`.`filename` LIKE ? ', array('%'.htmlentities($this->text).'%'))->fetchAll(); $medias = $this->db->query('SELECT `uploads`.*, `users`.`user_code`, `users`.`username` FROM `uploads` LEFT JOIN `users` ON `uploads`.`user_id` = `users`.`id` WHERE `uploads`.`filename` LIKE ? ', ['%'.htmlentities($this->text).'%'])->fetchAll();
} else { } else {
$medias = $this->db->query('SELECT `uploads`.*, `users`.`user_code`, `users`.`username` FROM `uploads` LEFT JOIN `users` ON `uploads`.`user_id` = `users`.`id` WHERE `user_id` = ? AND `uploads`.`filename` LIKE ? ', array($this->userId, '%'.htmlentities($this->text).'%'))->fetchAll(); $medias = $this->db->query('SELECT `uploads`.*, `users`.`user_code`, `users`.`username` FROM `uploads` LEFT JOIN `users` ON `uploads`.`user_id` = `users`.`id` WHERE `user_id` = ? AND `uploads`.`filename` LIKE ? ', [$this->userId, '%'.htmlentities($this->text).'%'])->fetchAll();
} }
$paths = array_column($files, 'path'); $paths = array_column($files, 'path');
@ -216,7 +196,7 @@ class MediaQuery
$paths[$media->storage_path] = $media; $paths[$media->storage_path] = $media;
} }
$this->media = array(); $this->media = [];
foreach ($files as $file) { foreach ($files as $file) {
$media = $paths[$file['path']]; $media = $paths[$file['path']];
if (!is_object($media)) { if (!is_object($media)) {

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Exception\Handlers; namespace App\Exception\Handlers;
use Slim\Handlers\ErrorHandler; use Slim\Handlers\ErrorHandler;

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Exception\Handlers\Renderers; namespace App\Exception\Handlers\Renderers;
use App\Exceptions\UnderMaintenanceException; use App\Exceptions\UnderMaintenanceException;
@ -65,6 +45,6 @@ class HtmlErrorRenderer implements ErrorRendererInterface
return view()->string('errors/400.twig'); return view()->string('errors/400.twig');
} }
return view()->string('errors/500.twig', array('exception' => $displayErrorDetails ? $exception : null)); return view()->string('errors/500.twig', ['exception' => $displayErrorDetails ? $exception : null]);
} }
} }

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Exceptions; namespace App\Exceptions;
use Slim\Exception\HttpSpecializedException; use Slim\Exception\HttpSpecializedException;

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Factories; namespace App\Factories;
use App\Web\View; use App\Web\View;
@ -36,12 +16,12 @@ class ViewFactory
$config = $container->get('config'); $config = $container->get('config');
$loader = new FilesystemLoader(BASE_DIR.'resources/templates'); $loader = new FilesystemLoader(BASE_DIR.'resources/templates');
$twig = new Environment($loader, array( $twig = new Environment($loader, [
'cache' => BASE_DIR.'resources/cache/twig', 'cache' => BASE_DIR.'resources/cache/twig',
'autoescape' => 'html', 'autoescape' => 'html',
'debug' => $config['debug'], 'debug' => $config['debug'],
'auto_reload' => $config['debug'], 'auto_reload' => $config['debug'],
)); ]);
$request = ServerRequestCreatorFactory::determineServerRequestCreator()->createServerRequestFromGlobals(); $request = ServerRequestCreatorFactory::determineServerRequestCreator()->createServerRequestFromGlobals();
@ -67,14 +47,14 @@ class ViewFactory
public static function createInstallerInstance(Container $container) public static function createInstallerInstance(Container $container)
{ {
$config = $container->get('config'); $config = $container->get('config');
$loader = new FilesystemLoader(array(BASE_DIR.'install/templates', BASE_DIR.'resources/templates')); $loader = new FilesystemLoader([BASE_DIR.'install/templates', BASE_DIR.'resources/templates']);
$twig = new Environment($loader, array( $twig = new Environment($loader, [
'cache' => false, 'cache' => false,
'autoescape' => 'html', 'autoescape' => 'html',
'debug' => $config['debug'], 'debug' => $config['debug'],
'auto_reload' => $config['debug'], 'auto_reload' => $config['debug'],
)); ]);
$request = ServerRequestCreatorFactory::determineServerRequestCreator()->createServerRequestFromGlobals(); $request = ServerRequestCreatorFactory::determineServerRequestCreator()->createServerRequestFromGlobals();

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Middleware; namespace App\Middleware;
use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Response;
@ -40,7 +20,7 @@ class AdminMiddleware extends Middleware
*/ */
public function __invoke(Request $request, RequestHandler $handler): ResponseInterface public function __invoke(Request $request, RequestHandler $handler): ResponseInterface
{ {
if (!$this->database->query('SELECT `id`, `is_admin` FROM `users` WHERE `id` = ? LIMIT 1', array($this->session->get('user_id')))->fetch()->is_admin) { if (!$this->database->query('SELECT `id`, `is_admin` FROM `users` WHERE `id` = ? LIMIT 1', [$this->session->get('user_id')])->fetch()->is_admin) {
$this->session->set('admin', false); $this->session->set('admin', false);
throw new HttpUnauthorizedException($request); throw new HttpUnauthorizedException($request);

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Middleware; namespace App\Middleware;
use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Response;
@ -43,7 +23,7 @@ class AuthMiddleware extends Middleware
return redirect(new Response(), route('login.show')); return redirect(new Response(), route('login.show'));
} }
if (!$this->database->query('SELECT `id`, `active` FROM `users` WHERE `id` = ? LIMIT 1', array($this->session->get('user_id')))->fetch()->active) { if (!$this->database->query('SELECT `id`, `active` FROM `users` WHERE `id` = ? LIMIT 1', [$this->session->get('user_id')])->fetch()->active) {
$this->session->alert(lang('account_disabled'), 'danger'); $this->session->alert(lang('account_disabled'), 'danger');
$this->session->set('logged', false); $this->session->set('logged', false);

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Middleware; namespace App\Middleware;
use App\Exceptions\UnderMaintenanceException; use App\Exceptions\UnderMaintenanceException;
@ -39,7 +19,7 @@ class CheckForMaintenanceMiddleware extends Middleware
*/ */
public function __invoke(Request $request, RequestHandler $handler): Response public function __invoke(Request $request, RequestHandler $handler): Response
{ {
if (isset($this->config['maintenance']) && $this->config['maintenance'] && !$this->database->query('SELECT `id`, `is_admin` FROM `users` WHERE `id` = ? LIMIT 1', array($this->session->get('user_id')))->fetch()->is_admin) { if (isset($this->config['maintenance']) && $this->config['maintenance'] && !$this->database->query('SELECT `id`, `is_admin` FROM `users` WHERE `id` = ? LIMIT 1', [$this->session->get('user_id')])->fetch()->is_admin) {
throw new UnderMaintenanceException($request); throw new UnderMaintenanceException($request);
} }

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Middleware; namespace App\Middleware;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Middleware; namespace App\Middleware;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Middleware; namespace App\Middleware;
use App\Controllers\Controller; use App\Controllers\Controller;

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Middleware; namespace App\Middleware;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;
@ -40,7 +20,7 @@ class RememberMiddleware extends Middleware
list($selector, $token) = explode(':', $request->getCookieParams()['remember']); list($selector, $token) = explode(':', $request->getCookieParams()['remember']);
$result = $this->database->query('SELECT `id`, `email`, `username`,`is_admin`, `active`, `remember_token` FROM `users` WHERE `remember_selector` = ? AND `remember_expire` > ? LIMIT 1', $result = $this->database->query('SELECT `id`, `email`, `username`,`is_admin`, `active`, `remember_token` FROM `users` WHERE `remember_selector` = ? AND `remember_expire` > ? LIMIT 1',
array($selector, date('Y-m-d\TH:i:s', time())) [$selector, date('Y-m-d\TH:i:s', time())]
)->fetch(); )->fetch();
if ($result && password_verify($token, $result->remember_token) && $result->active) { if ($result && password_verify($token, $result->remember_token) && $result->active) {

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Web; namespace App\Web;
class Lang class Lang
@ -37,7 +17,7 @@ class Lang
protected static $instance; protected static $instance;
/** @var array */ /** @var array */
protected $cache = array(); protected $cache = [];
/** /**
* @return Lang * @return Lang
@ -105,7 +85,7 @@ class Lang
*/ */
public static function getList() public static function getList()
{ {
$languages = array(); $languages = [];
$default = count(include self::$langPath.self::DEFAULT_LANG.'.lang.php') - 1; $default = count(include self::$langPath.self::DEFAULT_LANG.'.lang.php') - 1;
@ -131,7 +111,7 @@ class Lang
* *
* @return string * @return string
*/ */
public function get($key, $args = array()): string public function get($key, $args = []): string
{ {
return $this->getString($key, self::$lang, $args); return $this->getString($key, self::$lang, $args);
} }
@ -158,7 +138,7 @@ class Lang
$transDict = include self::$langPath.$redLang.'.lang.php'; $transDict = include self::$langPath.$redLang.'.lang.php';
$this->cache[$lang] = $transDict; $this->cache[$lang] = $transDict;
} else { } else {
$transDict = array(); $transDict = [];
} }
} }
} }

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Web; namespace App\Web;
use Exception; use Exception;
@ -53,13 +33,13 @@ class Session
); );
} }
$started = @session_start(array( $started = @session_start([
'name' => $name, 'name' => $name,
'save_path' => $path, 'save_path' => $path,
'cookie_httponly' => true, 'cookie_httponly' => true,
'gc_probability' => 25, 'gc_probability' => 25,
'cookie_samesite' => 'Lax', // works only for php >= 7.3 'cookie_samesite' => 'Lax', // works only for php >= 7.3
)); ]);
if (!$started) { if (!$started) {
throw new Exception("Cannot start the HTTP session. That the session path '{$path}' is writable and your PHP settings."); throw new Exception("Cannot start the HTTP session. That the session path '{$path}' is writable and your PHP settings.");
@ -90,7 +70,7 @@ class Session
*/ */
public function clear(): void public function clear(): void
{ {
$_SESSION = array(); $_SESSION = [];
} }
/** /**
@ -147,7 +127,7 @@ class Session
*/ */
public function alert($message, string $type = 'info'): void public function alert($message, string $type = 'info'): void
{ {
$_SESSION['_flash'][] = array($type => $message); $_SESSION['_flash'][] = [$type => $message];
} }
/** /**
@ -158,7 +138,7 @@ class Session
public function getAlert(): ?array public function getAlert(): ?array
{ {
$flash = self::get('_flash'); $flash = self::get('_flash');
self::set('_flash', array()); self::set('_flash', []);
return $flash; return $flash;
} }

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
namespace App\Web; namespace App\Web;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;
@ -56,7 +36,7 @@ class View
* *
* @return Response * @return Response
*/ */
public function render(Response $response, string $view, ?array $parameters = array()) public function render(Response $response, string $view, ?array $parameters = [])
{ {
$body = $this->twig->render($view, $parameters); $body = $this->twig->render($view, $parameters);
$response->getBody()->write($body); $response->getBody()->write($body);
@ -74,7 +54,7 @@ class View
* *
* @return string * @return string
*/ */
public function string(string $view, ?array $parameters = array()) public function string(string $view, ?array $parameters = [])
{ {
return $this->twig->render($view, $parameters); return $this->twig->render($view, $parameters);
} }

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\ServerRequestCreatorFactory; use Slim\Factory\ServerRequestCreatorFactory;
@ -42,7 +22,7 @@ if (!function_exists('humanFileSize')) {
for ($i = 0; ($size / 1024) > 0.9; $i++, $size /= 1024) { for ($i = 0; ($size / 1024) > 0.9; $i++, $size /= 1024) {
} }
return round($size, $precision).' '.array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB')[$i]; return round($size, $precision).' '.['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'][$i];
} }
} }
@ -75,7 +55,7 @@ if (!function_exists('isDisplayableImage')) {
*/ */
function isDisplayableImage(string $mime): bool function isDisplayableImage(string $mime): bool
{ {
return in_array($mime, array( return in_array($mime, [
'image/apng', 'image/apng',
'image/bmp', 'image/bmp',
'image/gif', 'image/gif',
@ -86,7 +66,7 @@ if (!function_exists('isDisplayableImage')) {
'image/svg+xml', 'image/svg+xml',
'image/tiff', 'image/tiff',
'image/webp', 'image/webp',
)); ]);
} }
} }
@ -241,7 +221,7 @@ if (!function_exists('route')) {
* *
* @return string * @return string
*/ */
function route(string $path, array $args = array(), string $append = ''): string function route(string $path, array $args = [], string $append = ''): string
{ {
global $app; global $app;
$uri = $app->getRouteCollector()->getRouteParser()->relativeUrlFor($path, $args); $uri = $app->getRouteCollector()->getRouteParser()->relativeUrlFor($path, $args);
@ -304,7 +284,7 @@ if (!function_exists('lang')) {
* *
* @return string * @return string
*/ */
function lang(string $key, $args = array()): string function lang(string $key, $args = []): string
{ {
return resolve('lang')->get($key, $args); return resolve('lang')->get($key, $args);
} }
@ -318,7 +298,7 @@ if (!function_exists('isBot')) {
*/ */
function isBot(string $userAgent) function isBot(string $userAgent)
{ {
$bots = array( $bots = [
'TelegramBot', 'TelegramBot',
'facebookexternalhit/', 'facebookexternalhit/',
'Discordbot/', 'Discordbot/',
@ -326,7 +306,7 @@ if (!function_exists('isBot')) {
'Facebot', 'Facebot',
'curl/', 'curl/',
'wget/', 'wget/',
); ];
foreach ($bots as $bot) { foreach ($bots as $bot) {
if (stripos($userAgent, $bot) !== false) { if (stripos($userAgent, $bot) !== false) {
@ -348,7 +328,7 @@ if (!function_exists('mime2font')) {
*/ */
function mime2font($mime) function mime2font($mime)
{ {
$classes = array( $classes = [
'image' => 'fa-file-image', 'image' => 'fa-file-image',
'audio' => 'fa-file-audio', 'audio' => 'fa-file-audio',
'video' => 'fa-file-video', 'video' => 'fa-file-video',
@ -370,7 +350,7 @@ if (!function_exists('mime2font')) {
'application/gzip' => 'fa-file-archive', 'application/gzip' => 'fa-file-archive',
'application/zip' => 'fa-file-archive', 'application/zip' => 'fa-file-archive',
'application/octet-stream' => 'fa-file-alt', 'application/octet-stream' => 'fa-file-alt',
); ];
foreach ($classes as $fullMime => $class) { foreach ($classes as $fullMime => $class) {
if (strpos($mime, $fullMime) === 0) { if (strpos($mime, $fullMime) === 0) {
@ -405,7 +385,7 @@ if (!function_exists('queryParams')) {
* *
* @return string * @return string
*/ */
function queryParams(array $replace = array()) function queryParams(array $replace = [])
{ {
$request = ServerRequestCreatorFactory::determineServerRequestCreator()->createServerRequestFromGlobals(); $request = ServerRequestCreatorFactory::determineServerRequestCreator()->createServerRequestFromGlobals();

View file

@ -1,25 +1,6 @@
<?php <?php
/* // Auth routes
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
use App\Controllers\AdminController; use App\Controllers\AdminController;
use App\Controllers\ClientController; use App\Controllers\ClientController;
use App\Controllers\DashboardController; use App\Controllers\DashboardController;
@ -36,58 +17,58 @@ use Slim\Routing\RouteCollectorProxy;
global $app; global $app;
$app->group('', function (RouteCollectorProxy $group) { $app->group('', function (RouteCollectorProxy $group) {
$group->get('/home[/page/{page}]', array(DashboardController::class, 'home'))->setName('home'); $group->get('/home[/page/{page}]', [DashboardController::class, 'home'])->setName('home');
$group->get('/upload', array(UploadController::class, 'webUpload'))->setName('upload.web'); $group->get('/upload', [UploadController::class, 'webUpload'])->setName('upload.web');
$group->group('', function (RouteCollectorProxy $group) { $group->group('', function (RouteCollectorProxy $group) {
$group->get('/home/switchView', array(DashboardController::class, 'switchView'))->setName('switchView'); $group->get('/home/switchView', [DashboardController::class, 'switchView'])->setName('switchView');
$group->get('/system/deleteOrphanFiles', array(AdminController::class, 'deleteOrphanFiles'))->setName('system.deleteOrphanFiles'); $group->get('/system/deleteOrphanFiles', [AdminController::class, 'deleteOrphanFiles'])->setName('system.deleteOrphanFiles');
$group->get('/system/themes', array(ThemeController::class, 'getThemes'))->setName('theme'); $group->get('/system/themes', [ThemeController::class, 'getThemes'])->setName('theme');
$group->post('/system/theme/apply', array(ThemeController::class, 'applyTheme'))->setName('theme.apply'); $group->post('/system/theme/apply', [ThemeController::class, 'applyTheme'])->setName('theme.apply');
$group->post('/system/lang/apply', array(AdminController::class, 'applyLang'))->setName('lang.apply'); $group->post('/system/lang/apply', [AdminController::class, 'applyLang'])->setName('lang.apply');
$group->post('/system/customHead', array(AdminController::class, 'applyCustomHead'))->setName('customHead.apply'); $group->post('/system/customHead', [AdminController::class, 'applyCustomHead'])->setName('customHead.apply');
$group->post('/system/upgrade', array(UpgradeController::class, 'upgrade'))->setName('system.upgrade'); $group->post('/system/upgrade', [UpgradeController::class, 'upgrade'])->setName('system.upgrade');
$group->get('/system/checkForUpdates', array(UpgradeController::class, 'checkForUpdates'))->setName('system.checkForUpdates'); $group->get('/system/checkForUpdates', [UpgradeController::class, 'checkForUpdates'])->setName('system.checkForUpdates');
$group->get('/system', array(AdminController::class, 'system'))->setName('system'); $group->get('/system', [AdminController::class, 'system'])->setName('system');
$group->get('/users[/page/{page}]', array(UserController::class, 'index'))->setName('user.index'); $group->get('/users[/page/{page}]', [UserController::class, 'index'])->setName('user.index');
})->add(AdminMiddleware::class); })->add(AdminMiddleware::class);
$group->group('/user', function (RouteCollectorProxy $group) { $group->group('/user', function (RouteCollectorProxy $group) {
$group->get('/create', array(UserController::class, 'create'))->setName('user.create'); $group->get('/create', [UserController::class, 'create'])->setName('user.create');
$group->post('/create', array(UserController::class, 'store'))->setName('user.store'); $group->post('/create', [UserController::class, 'store'])->setName('user.store');
$group->get('/{id}/edit', array(UserController::class, 'edit'))->setName('user.edit'); $group->get('/{id}/edit', [UserController::class, 'edit'])->setName('user.edit');
$group->post('/{id}', array(UserController::class, 'update'))->setName('user.update'); $group->post('/{id}', [UserController::class, 'update'])->setName('user.update');
$group->get('/{id}/delete', array(UserController::class, 'delete'))->setName('user.delete'); $group->get('/{id}/delete', [UserController::class, 'delete'])->setName('user.delete');
})->add(AdminMiddleware::class); })->add(AdminMiddleware::class);
$group->get('/profile', array(UserController::class, 'profile'))->setName('profile'); $group->get('/profile', [UserController::class, 'profile'])->setName('profile');
$group->post('/profile/{id}', array(UserController::class, 'profileEdit'))->setName('profile.update'); $group->post('/profile/{id}', [UserController::class, 'profileEdit'])->setName('profile.update');
$group->post('/user/{id}/refreshToken', array(UserController::class, 'refreshToken'))->setName('refreshToken'); $group->post('/user/{id}/refreshToken', [UserController::class, 'refreshToken'])->setName('refreshToken');
$group->get('/user/{id}/config/sharex', array(ClientController::class, 'getShareXConfig'))->setName('config.sharex'); $group->get('/user/{id}/config/sharex', [ClientController::class, 'getShareXConfig'])->setName('config.sharex');
$group->get('/user/{id}/config/script', array(ClientController::class, 'getBashScript'))->setName('config.script'); $group->get('/user/{id}/config/script', [ClientController::class, 'getBashScript'])->setName('config.script');
$group->post('/upload/{id}/publish', array(MediaController::class, 'togglePublish'))->setName('upload.publish'); $group->post('/upload/{id}/publish', [MediaController::class, 'togglePublish'])->setName('upload.publish');
$group->post('/upload/{id}/unpublish', array(MediaController::class, 'togglePublish'))->setName('upload.unpublish'); $group->post('/upload/{id}/unpublish', [MediaController::class, 'togglePublish'])->setName('upload.unpublish');
$group->get('/upload/{id}/raw', array(MediaController::class, 'getRawById'))->add(AdminMiddleware::class)->setName('upload.raw'); $group->get('/upload/{id}/raw', [MediaController::class, 'getRawById'])->add(AdminMiddleware::class)->setName('upload.raw');
$group->map(array('GET', 'POST'), '/upload/{id}/delete', array(MediaController::class, 'delete'))->setName('upload.delete'); $group->map(['GET', 'POST'],'/upload/{id}/delete', [MediaController::class, 'delete'])->setName('upload.delete');
})->add(App\Middleware\CheckForMaintenanceMiddleware::class)->add(AuthMiddleware::class); })->add(App\Middleware\CheckForMaintenanceMiddleware::class)->add(AuthMiddleware::class);
$app->get('/', array(DashboardController::class, 'redirects'))->setName('root'); $app->get('/', [DashboardController::class, 'redirects'])->setName('root');
$app->get('/login', array(LoginController::class, 'show'))->setName('login.show'); $app->get('/login', [LoginController::class, 'show'])->setName('login.show');
$app->post('/login', array(LoginController::class, 'login'))->setName('login'); $app->post('/login', [LoginController::class, 'login'])->setName('login');
$app->map(array('GET', 'POST'), '/logout', array(LoginController::class, 'logout'))->setName('logout'); $app->map(['GET', 'POST'], '/logout', [LoginController::class, 'logout'])->setName('logout');
$app->post('/upload', array(UploadController::class, 'upload'))->setName('upload'); $app->post('/upload', [UploadController::class, 'upload'])->setName('upload');
$app->get('/{userCode}/{mediaCode}', array(MediaController::class, 'show'))->setName('public'); $app->get('/{userCode}/{mediaCode}', [MediaController::class, 'show'])->setName('public');
$app->get('/{userCode}/{mediaCode}/delete/{token}', array(MediaController::class, 'show'))->setName('public.delete.show')->add(CheckForMaintenanceMiddleware::class); $app->get('/{userCode}/{mediaCode}/delete/{token}', [MediaController::class, 'show'])->setName('public.delete.show')->add(CheckForMaintenanceMiddleware::class);
$app->post('/{userCode}/{mediaCode}/delete/{token}', array(MediaController::class, 'deleteByToken'))->setName('public.delete')->add(CheckForMaintenanceMiddleware::class); $app->post('/{userCode}/{mediaCode}/delete/{token}', [MediaController::class, 'deleteByToken'])->setName('public.delete')->add(CheckForMaintenanceMiddleware::class);
$app->get('/{userCode}/{mediaCode}/raw[.{ext}]', array(MediaController::class, 'getRaw'))->setName('public.raw'); $app->get('/{userCode}/{mediaCode}/raw[.{ext}]', [MediaController::class, 'getRaw'])->setName('public.raw');
$app->get('/{userCode}/{mediaCode}/download', array(MediaController::class, 'download'))->setName('public.download'); $app->get('/{userCode}/{mediaCode}/download', [MediaController::class, 'download'])->setName('public.download');

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
use App\Exception\Handlers\AppErrorHandler; use App\Exception\Handlers\AppErrorHandler;
use App\Exception\Handlers\Renderers\HtmlErrorRenderer; use App\Exception\Handlers\Renderers\HtmlErrorRenderer;
use App\Factories\ViewFactory; use App\Factories\ViewFactory;
@ -46,22 +26,22 @@ if (!file_exists('config.php') && is_dir('install/')) {
} }
// Load the config // Load the config
$config = array_replace_recursive(array( $config = array_replace_recursive([
'app_name' => 'XBackBone', 'app_name' => 'XBackBone',
'base_url' => isset($_SERVER['HTTPS']) ? 'https://'.$_SERVER['HTTP_HOST'] : 'http://'.$_SERVER['HTTP_HOST'], 'base_url' => isset($_SERVER['HTTPS']) ? 'https://'.$_SERVER['HTTP_HOST'] : 'http://'.$_SERVER['HTTP_HOST'],
'debug' => false, 'debug' => false,
'maintenance' => false, 'maintenance' => false,
'db' => array( 'db' => [
'connection' => 'sqlite', 'connection' => 'sqlite',
'dsn' => BASE_DIR.'resources/database/xbackbone.db', 'dsn' => BASE_DIR.'resources/database/xbackbone.db',
'username' => null, 'username' => null,
'password' => null, 'password' => null,
), ],
'storage' => array( 'storage' => [
'driver' => 'local', 'driver' => 'local',
'path' => realpath(__DIR__.'/').DIRECTORY_SEPARATOR.'storage', 'path' => realpath(__DIR__.'/').DIRECTORY_SEPARATOR.'storage',
), ],
), require BASE_DIR.'config.php'); ], require BASE_DIR.'config.php');
$builder = new ContainerBuilder(); $builder = new ContainerBuilder();
@ -70,13 +50,13 @@ if (!$config['debug']) {
$builder->writeProxiesToFile(true, BASE_DIR.'/resources/cache/proxies'); $builder->writeProxiesToFile(true, BASE_DIR.'/resources/cache/proxies');
} }
$builder->addDefinitions(array( $builder->addDefinitions([
'config' => value($config), 'config' => value($config),
View::class => factory(function (Container $container) { View::class => factory(function (Container $container) {
return ViewFactory::createAppInstance($container); return ViewFactory::createAppInstance($container);
}), }),
'view' => get(View::class), 'view' => get(View::class),
)); ]);
$builder->addDefinitions(__DIR__.'/container.php'); $builder->addDefinitions(__DIR__.'/container.php');

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
use App\Database\DB; use App\Database\DB;
use App\Web\Lang; use App\Web\Lang;
use App\Web\Session; use App\Web\Session;
@ -39,7 +19,7 @@ use Spatie\Dropbox\Client as DropboxClient;
use Spatie\FlysystemDropbox\DropboxAdapter; use Spatie\FlysystemDropbox\DropboxAdapter;
use Superbalist\Flysystem\GoogleStorage\GoogleStorageAdapter; use Superbalist\Flysystem\GoogleStorage\GoogleStorageAdapter;
return array( return [
Logger::class => factory(function () { Logger::class => factory(function () {
$logger = new Logger('app'); $logger = new Logger('app');
@ -74,22 +54,22 @@ return array(
case 'local': case 'local':
return new Filesystem(new Local($config['storage']['path'])); return new Filesystem(new Local($config['storage']['path']));
case 's3': case 's3':
$client = new S3Client(array( $client = new S3Client([
'credentials' => array( 'credentials' => [
'key' => $config['storage']['key'], 'key' => $config['storage']['key'],
'secret' => $config['storage']['secret'], 'secret' => $config['storage']['secret'],
), ],
'region' => $config['storage']['region'], 'region' => $config['storage']['region'],
'version' => 'latest', 'version' => 'latest',
)); ]);
return new Filesystem(new AwsS3Adapter($client, $config['storage']['bucket'], $config['storage']['path'])); return new Filesystem(new AwsS3Adapter($client, $config['storage']['bucket'], $config['storage']['path']));
case 'dropbox': case 'dropbox':
$client = new DropboxClient($config['storage']['token']); $client = new DropboxClient($config['storage']['token']);
return new Filesystem(new DropboxAdapter($client), array('case_sensitive' => false)); return new Filesystem(new DropboxAdapter($client), ['case_sensitive' => false]);
case 'ftp': case 'ftp':
return new Filesystem(new FtpAdapter(array( return new Filesystem(new FtpAdapter([
'host' => $config['storage']['host'], 'host' => $config['storage']['host'],
'username' => $config['storage']['username'], 'username' => $config['storage']['username'],
'password' => $config['storage']['password'], 'password' => $config['storage']['password'],
@ -98,12 +78,12 @@ return array(
'passive' => $config['storage']['passive'], 'passive' => $config['storage']['passive'],
'ssl' => $config['storage']['ssl'], 'ssl' => $config['storage']['ssl'],
'timeout' => 30, 'timeout' => 30,
))); ]));
case 'google-cloud': case 'google-cloud':
$client = new StorageClient(array( $client = new StorageClient([
'projectId' => $config['storage']['project_id'], 'projectId' => $config['storage']['project_id'],
'keyFilePath' => $config['storage']['key_path'], 'keyFilePath' => $config['storage']['key_path'],
)); ]);
return new Filesystem(new GoogleStorageAdapter($client, $client->bucket($config['storage']['bucket']))); return new Filesystem(new GoogleStorageAdapter($client, $client->bucket($config['storage']['bucket'])));
default: default:
@ -116,4 +96,4 @@ return array(
return Lang::build(Lang::recognize(), BASE_DIR.'resources/lang/'); return Lang::build(Lang::recognize(), BASE_DIR.'resources/lang/');
}), }),
'lang' => get(Lang::class), 'lang' => get(Lang::class),
); ];

View file

@ -1,35 +1,15 @@
<?php <?php
/* return [
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
return array(
'base_url' => 'https://localhost', // no trailing slash 'base_url' => 'https://localhost', // no trailing slash
'db' => array( 'db' => [
'connection' => 'sqlite', 'connection' => 'sqlite',
'dsn' => 'resources/database/xbackbone.db', 'dsn' => 'resources/database/xbackbone.db',
'username' => null, 'username' => null,
'password' => null, 'password' => null,
), ],
'storage' => array( 'storage' => [
'driver' => 'local', 'driver' => 'local',
'path' => './storage', 'path' => './storage',
), ],
); ];

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
(PHP_MAJOR_VERSION >= 7 && PHP_MINOR_VERSION >= 1) ?: die('Sorry, PHP 7.1 or above is required to run XBackBone.'); (PHP_MAJOR_VERSION >= 7 && PHP_MINOR_VERSION >= 1) ?: die('Sorry, PHP 7.1 or above is required to run XBackBone.');
require __DIR__.'/vendor/autoload.php'; require __DIR__.'/vendor/autoload.php';

View file

@ -1,25 +1,5 @@
<?php <?php
/*
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
(PHP_MAJOR_VERSION >= 7 && PHP_MINOR_VERSION >= 1) ?: die('Sorry, PHP 7.1 or above is required to run XBackBone.'); (PHP_MAJOR_VERSION >= 7 && PHP_MINOR_VERSION >= 1) ?: die('Sorry, PHP 7.1 or above is required to run XBackBone.');
require __DIR__.'/../vendor/autoload.php'; require __DIR__.'/../vendor/autoload.php';
@ -43,20 +23,20 @@ define('PLATFORM_VERSION', json_decode(file_get_contents(__DIR__.'/../composer.j
define('BASE_DIR', realpath(__DIR__.'/../').DIRECTORY_SEPARATOR); define('BASE_DIR', realpath(__DIR__.'/../').DIRECTORY_SEPARATOR);
// default config // default config
$config = array( $config = [
'base_url' => str_replace('/install/', '', (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http')."://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), 'base_url' => str_replace('/install/', '', (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http')."://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
'debug' => true, 'debug' => true,
'db' => array( 'db' => [
'connection' => 'sqlite', 'connection' => 'sqlite',
'dsn' => realpath(__DIR__.'/../').implode(DIRECTORY_SEPARATOR, array('resources', 'database', 'xbackbone.db')), 'dsn' => realpath(__DIR__.'/../').implode(DIRECTORY_SEPARATOR, ['resources', 'database', 'xbackbone.db']),
'username' => null, 'username' => null,
'password' => null, 'password' => null,
), ],
'storage' => array( 'storage' => [
'driver' => 'local', 'driver' => 'local',
'path' => realpath(__DIR__.'/../').DIRECTORY_SEPARATOR.'storage', 'path' => realpath(__DIR__.'/../').DIRECTORY_SEPARATOR.'storage',
), ],
); ];
if (file_exists(__DIR__.'/../config.php')) { if (file_exists(__DIR__.'/../config.php')) {
$config = array_replace_recursive($config, require __DIR__.'/../config.php'); $config = array_replace_recursive($config, require __DIR__.'/../config.php');
@ -64,13 +44,13 @@ if (file_exists(__DIR__.'/../config.php')) {
$builder = new ContainerBuilder(); $builder = new ContainerBuilder();
$builder->addDefinitions(array( $builder->addDefinitions([
'config' => value($config), 'config' => value($config),
View::class => factory(function (Container $container) { View::class => factory(function (Container $container) {
return ViewFactory::createInstallerInstance($container); return ViewFactory::createInstallerInstance($container);
}), }),
'view' => get(View::class), 'view' => get(View::class),
)); ]);
$builder->addDefinitions(__DIR__.'/../bootstrap/container.php'); $builder->addDefinitions(__DIR__.'/../bootstrap/container.php');
$app = Bridge::create($builder->build()); $app = Bridge::create($builder->build());
@ -108,9 +88,9 @@ $app->get('/', function (Response $response, View $view, Session $session) use (
$installed = file_exists(__DIR__.'/../config.php'); $installed = file_exists(__DIR__.'/../config.php');
return $view->render($response, 'install.twig', array( return $view->render($response, 'install.twig', [
'installed' => $installed, 'installed' => $installed,
)); ]);
})->setName('install'); })->setName('install');
$app->post('/', function (Request $request, Response $response, Filesystem $storage, Session $session) use (&$config) { $app->post('/', function (Request $request, Response $response, Filesystem $storage, Session $session) use (&$config) {
@ -215,7 +195,7 @@ $app->post('/', function (Request $request, Response $response, Filesystem $stor
// if not installed, create the default admin account // if not installed, create the default admin account
if (!$installed) { if (!$installed) {
$db->query("INSERT INTO `users` (`email`, `username`, `password`, `is_admin`, `user_code`) VALUES (?, 'admin', ?, 1, ?)", array(param($request, 'email'), password_hash(param($request, 'password'), PASSWORD_DEFAULT), humanRandomString(5))); $db->query("INSERT INTO `users` (`email`, `username`, `password`, `is_admin`, `user_code`) VALUES (?, 'admin', ?, 1, ?)", [param($request, 'email'), password_hash(param($request, 'password'), PASSWORD_DEFAULT), humanRandomString(5)]);
} }
// post install cleanup // post install cleanup

View file

@ -1,26 +1,6 @@
<?php <?php
/* return [
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
return array(
'lang' => 'Bulgarian', 'lang' => 'Bulgarian',
'enforce_language' => 'Изберете език', 'enforce_language' => 'Изберете език',
'yes' => 'Да', 'yes' => 'Да',
@ -90,4 +70,4 @@ return array(
'user_deleted' => 'Потребителят бе изтрит.', 'user_deleted' => 'Потребителят бе изтрит.',
'cannot_delete' => 'Не можете да изтриете себе си.', 'cannot_delete' => 'Не можете да изтриете себе си.',
'gallery' => 'Галерия', 'gallery' => 'Галерия',
); ];

View file

@ -1,26 +1,6 @@
<?php <?php
/* return [
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
return array(
'lang' => 'Danish', 'lang' => 'Danish',
'yes' => 'Ja', 'yes' => 'Ja',
'no' => 'Nej', 'no' => 'Nej',
@ -64,4 +44,4 @@ return array(
'is_active' => 'Er aktiv', 'is_active' => 'Er aktiv',
'is_admin' => 'Er administrator', 'is_admin' => 'Er administrator',
'your_profile' => 'Din Profil', 'your_profile' => 'Din Profil',
); ];

View file

@ -1,26 +1,6 @@
<?php <?php
/* return [
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
return array(
'lang' => 'German', 'lang' => 'German',
'yes' => 'Ja', 'yes' => 'Ja',
'no' => 'Nein', 'no' => 'Nein',
@ -134,4 +114,4 @@ return array(
'remember_me' => 'Erinnere mich daran', 'remember_me' => 'Erinnere mich daran',
'please_wait' => 'Bitte warten…', 'please_wait' => 'Bitte warten…',
'dont_close' => 'Schließen Sie diesen Tab erst, wenn Sie fertig sind.', 'dont_close' => 'Schließen Sie diesen Tab erst, wenn Sie fertig sind.',
); ];

View file

@ -1,26 +1,6 @@
<?php <?php
/* return [
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
return array(
'lang' => 'English', 'lang' => 'English',
'enforce_language' => 'Enforce language', 'enforce_language' => 'Enforce language',
'yes' => 'Yes', 'yes' => 'Yes',
@ -131,4 +111,4 @@ return array(
'remember_me' => 'Remember me', 'remember_me' => 'Remember me',
'please_wait' => 'Please wait…', 'please_wait' => 'Please wait…',
'dont_close' => 'Do not close this tab until completion.', 'dont_close' => 'Do not close this tab until completion.',
); ];

View file

@ -1,26 +1,6 @@
<?php <?php
/* return [
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
return array(
'lang' => 'Spanish', 'lang' => 'Spanish',
'yes' => 'Si', 'yes' => 'Si',
'no' => 'No', 'no' => 'No',
@ -120,4 +100,4 @@ return array(
'lang_name' => 'nombre del lenguaje', 'lang_name' => 'nombre del lenguaje',
'default_lang_behavior' => 'XBackBone tratará de coincidir con el lenguaje predeterminado del navegador (recurrimos al Inglés automáticamente).', 'default_lang_behavior' => 'XBackBone tratará de coincidir con el lenguaje predeterminado del navegador (recurrimos al Inglés automáticamente).',
'lang_set' => 'Lenguaje del sistema impuesto a "%s"', 'lang_set' => 'Lenguaje del sistema impuesto a "%s"',
); ];

View file

@ -1,26 +1,6 @@
<?php <?php
/* return [
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
return array(
'lang' => 'French', 'lang' => 'French',
'yes' => 'Oui', 'yes' => 'Oui',
'no' => 'Non', 'no' => 'Non',
@ -113,4 +93,4 @@ return array(
'remember_me' => 'Se souvenir de moi', 'remember_me' => 'Se souvenir de moi',
'please_wait' => 'Veuillez patienter…', 'please_wait' => 'Veuillez patienter…',
'dont_close' => 'Ne fermez pas cette fenêtre jusqu\'à complétion.', 'dont_close' => 'Ne fermez pas cette fenêtre jusqu\'à complétion.',
); ];

View file

@ -1,134 +1,114 @@
<?php <?php
/* return [
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me> 'lang' => 'Italian',
* 'yes' => 'Sì',
* @author Sergio Brighenti <sergio@brighenti.me> 'no' => 'No',
* 'send' => 'Invia',
* @license AGPL-3.0 'no_media' => 'Nessun media trovato.',
* 'login.username' => 'Username o E-Mail',
* This code is free software: you can redistribute it and/or modify 'password' => 'Password',
* it under the terms of the GNU Affero General Public License, version 3, 'login' => 'Accedi',
* as published by the Free Software Foundation. 'username' => 'Username',
* 'home' => 'Home',
* This program is distributed in the hope that it will be useful, 'users' => 'Utenti',
* but WITHOUT ANY WARRANTY; without even the implied warranty of 'system' => 'Sistema',
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 'profile' => 'Profilo',
* GNU Affero General Public License for more details. 'logout' => 'Esci',
* 'pager.next' => 'Avanti',
* You should have received a copy of the GNU Affero General Public License, version 3, 'pager.previous' => 'Indietro',
* along with this program. If not, see <http://www.gnu.org/licenses/> 'copy_link' => 'Copia link',
*/ 'public.telegram' => 'Condividi su Telegram',
'public.delete_text' => 'Sei sicuro di voler eliminare questo elemento? Andrà perso per sempre!',
return array( 'preview' => 'Anteprima',
'lang' => 'Italian', 'filename' => 'Nome file',
'yes' => 'Sì', 'size' => 'Dimensione',
'no' => 'No', 'public' => 'Pubblico',
'send' => 'Invia', 'owner' => 'Proprietario',
'no_media' => 'Nessun media trovato.', 'date' => 'Data',
'login.username' => 'Username o E-Mail', 'raw' => 'Vedi raw',
'password' => 'Password', 'download' => 'Scarica',
'login' => 'Accedi', 'upload' => 'Carica',
'username' => 'Username', 'delete' => 'Elimina',
'home' => 'Home', 'publish' => 'Pubblica',
'users' => 'Utenti', 'hide' => 'Nascondi',
'system' => 'Sistema', 'files' => 'File',
'profile' => 'Profilo', 'orphaned_files' => 'File orfani',
'logout' => 'Esci', 'theme' => 'Tema',
'pager.next' => 'Avanti', 'click_to_load' => 'Clicca per caricare...',
'pager.previous' => 'Indietro', 'apply' => 'Applica',
'copy_link' => 'Copia link', 'save' => 'Salva',
'public.telegram' => 'Condividi su Telegram', 'used' => 'Usato',
'public.delete_text' => 'Sei sicuro di voler eliminare questo elemento? Andrà perso per sempre!', 'system_info' => 'Informazioni di Sistema',
'preview' => 'Anteprima', 'user.create' => 'Crea Utente',
'filename' => 'Nome file', 'user.edit' => 'Modifica Utente',
'size' => 'Dimensione', 'is_active' => 'Attivo',
'public' => 'Pubblico', 'is_admin' => 'Amministratore',
'owner' => 'Proprietario', 'your_profile' => 'Il tuo profilo',
'date' => 'Data', 'token' => 'Token',
'raw' => 'Vedi raw', 'copy' => 'Copia',
'download' => 'Scarica', 'update' => 'Aggiorna',
'upload' => 'Carica', 'edit' => 'Modifica',
'delete' => 'Elimina', 'client_config' => 'Config. client',
'publish' => 'Pubblica', 'user_code' => 'Codice Utente',
'hide' => 'Nascondi', 'active' => 'Attivo',
'files' => 'File', 'admin' => 'Amministratore',
'orphaned_files' => 'File orfani', 'reg_date' => 'Data Registrazione',
'theme' => 'Tema', 'none' => 'Nessuno',
'click_to_load' => 'Clicca per caricare...', 'open' => 'Apri',
'apply' => 'Applica', 'confirm' => 'Conferma',
'save' => 'Salva', 'confirm_string' => 'Sei sicuro?',
'used' => 'Usato', 'installed' => 'Installazione completata!',
'system_info' => 'Informazioni di Sistema', 'bad_login' => 'Credenziali errate.',
'user.create' => 'Crea Utente', 'account_disabled' => 'Il tuo account è disattivato.',
'user.edit' => 'Modifica Utente', 'welcome' => 'Benvenuto, %s!',
'is_active' => 'Attivo', 'goodbye' => 'Arrivederci!',
'is_admin' => 'Amministratore', 'token_not_found' => 'Il token specificato non è stato trovato.',
'your_profile' => 'Il tuo profilo', 'email_required' => 'Email obbligatoria.',
'token' => 'Token', 'email_taken' => 'Email già in uso.',
'copy' => 'Copia', 'username_required' => 'Username obbligatorio.',
'update' => 'Aggiorna', 'username_taken' => 'Username già in uso.',
'edit' => 'Modifica', 'password_required' => 'Password obbligatoria.',
'client_config' => 'Config. client', 'user_created' => 'L\'utente "%s" è stato creato!',
'user_code' => 'Codice Utente', 'user_updated' => 'L\'utente "%s" è stato aggiornato!',
'active' => 'Attivo', 'profile_updated' => 'Profilo aggiornato con successo!',
'admin' => 'Amministratore', 'user_deleted' => 'Utente rimosso.',
'reg_date' => 'Data Registrazione', 'cannot_delete' => 'Non puoi eliminare te stesso.',
'none' => 'Nessuno', 'cannot_demote' => 'Non puoi degradare te stesso.',
'open' => 'Apri', 'cannot_write_file' => 'Il percorso di destinazione non è scrivibile.',
'confirm' => 'Conferma', 'deleted_orphans' => 'Eliminati %d file orfani.',
'confirm_string' => 'Sei sicuro?', 'switch_to' => 'Vedi come',
'installed' => 'Installazione completata!', 'gallery' => 'Galleria',
'bad_login' => 'Credenziali errate.', 'table' => 'Tabella',
'account_disabled' => 'Il tuo account è disattivato.', 'dotted_search' => 'Cerca...',
'welcome' => 'Benvenuto, %s!', 'order_by' => 'Ordina per...',
'goodbye' => 'Arrivederci!', 'time' => 'Data',
'token_not_found' => 'Il token specificato non è stato trovato.', 'name' => 'Nome',
'email_required' => 'Email obbligatoria.', 'maintenance' => 'Manutenzione',
'email_taken' => 'Email già in uso.', 'clean_orphaned_uploads' => 'Pulisci upload orfani',
'username_required' => 'Username obbligatorio.', 'path_not_writable' => 'Il percorso di output non è scrivibile.',
'username_taken' => 'Username già in uso.', 'already_latest_version' => 'Hai già l\'ultima versione disponibile.',
'password_required' => 'Password obbligatoria.', 'new_version_available' => 'Nuova versione disponibile: %s',
'user_created' => 'L\'utente "%s" è stato creato!', 'cannot_retrieve_file' => 'Impossibile scaricare il file.',
'user_updated' => 'L\'utente "%s" è stato aggiornato!', 'file_size_no_match' => 'La dimensione del file scaricato non è corretta.',
'profile_updated' => 'Profilo aggiornato con successo!', 'check_for_updates' => 'Controllo aggiornamenti',
'user_deleted' => 'Utente rimosso.', 'upgrade' => 'Upgrade',
'cannot_delete' => 'Non puoi eliminare te stesso.', 'updates' => 'Aggiornamenti',
'cannot_demote' => 'Non puoi degradare te stesso.',
'cannot_write_file' => 'Il percorso di destinazione non è scrivibile.',
'deleted_orphans' => 'Eliminati %d file orfani.',
'switch_to' => 'Vedi come',
'gallery' => 'Galleria',
'table' => 'Tabella',
'dotted_search' => 'Cerca...',
'order_by' => 'Ordina per...',
'time' => 'Data',
'name' => 'Nome',
'maintenance' => 'Manutenzione',
'clean_orphaned_uploads' => 'Pulisci upload orfani',
'path_not_writable' => 'Il percorso di output non è scrivibile.',
'already_latest_version' => 'Hai già l\'ultima versione disponibile.',
'new_version_available' => 'Nuova versione disponibile: %s',
'cannot_retrieve_file' => 'Impossibile scaricare il file.',
'file_size_no_match' => 'La dimensione del file scaricato non è corretta.',
'check_for_updates' => 'Controllo aggiornamenti',
'upgrade' => 'Upgrade',
'updates' => 'Aggiornamenti',
'maintenance_in_progress' => 'Manutenzione in corso, riprova più tardi.', 'maintenance_in_progress' => 'Manutenzione in corso, riprova più tardi.',
'cancel' => 'Annulla', 'cancel' => 'Annulla',
'enforce_language' => 'Imponi lingua', 'enforce_language' => 'Imponi lingua',
'auto_set' => 'Imposta automaticamente', 'auto_set' => 'Imposta automaticamente',
'default_lang_behavior' => 'Per impostazione predefinita, XBackbone cercherà di abbinare la lingua del browser (il fallback è l\'Inglese).', 'default_lang_behavior' => 'Per impostazione predefinita, XBackbone cercherà di abbinare la lingua del browser (il fallback è l\'Inglese).',
'lang_set' => 'Lingua di sistema applicata a "%s"', 'lang_set' => 'Lingua di sistema applicata a "%s"',
'prerelease_channel' => 'Canale prerelease', 'prerelease_channel' => 'Canale prerelease',
'no_upload_token' => 'Non hai un token personale per l\'upload associato. (Generane uno e riprova)', 'no_upload_token' => 'Non hai un token personale per l\'upload associato. (Generane uno e riprova)',
'drop_to_upload' => 'Clicca o lascia i tuoi file qui per caricarli.', 'drop_to_upload' => 'Clicca o lascia i tuoi file qui per caricarli.',
'donation' => 'Donazione', 'donation' => 'Donazione',
'donate_text' => 'Se ti piace XBackBone, prendi in considerazione una donazione per sostenere lo sviluppo!', 'donate_text' => 'Se ti piace XBackBone, prendi in considerazione una donazione per sostenere lo sviluppo!',
'custom_head_html' => 'Contenuto Head HTML personalizzato', 'custom_head_html' => 'Contenuto Head HTML personalizzato',
'custom_head_html_hint' => 'Questo contenuto sarà aggiunto al tag <head> in ogni pagina.', 'custom_head_html_hint' => 'Questo contenuto sarà aggiunto al tag <head> in ogni pagina.',
'custom_head_set' => 'Custom Head HTML applicato con successo.', 'custom_head_set' => 'Custom Head HTML applicato con successo.',
'remember_me' => 'Ricordami', 'remember_me' => 'Ricordami',
'please_wait' => 'Attendere prego…', 'please_wait' => 'Attendere prego...',
'dont_close' => 'Non chiudere questa scheda fino al completamento.', 'dont_close' => 'Non chiudere questa scheda fino al completamento.',
); ];

View file

@ -0,0 +1 @@
<?php

View file

@ -1,26 +1,6 @@
<?php <?php
/* return [
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
return array(
'theme' => 'Drakt', 'theme' => 'Drakt',
'username_taken' => 'Brukernavnet er i bruk.', 'username_taken' => 'Brukernavnet er i bruk.',
'file_size_no_match' => 'Nedlastet fil samsvarer ikke med riktig filstørrelse.', 'file_size_no_match' => 'Nedlastet fil samsvarer ikke med riktig filstørrelse.',
@ -130,4 +110,4 @@ return array(
'custom_head_set' => 'Egendefinert HTML-hode lagt til.', 'custom_head_set' => 'Egendefinert HTML-hode lagt til.',
'remember_me' => 'Husk meg', 'remember_me' => 'Husk meg',
'please_wait' => 'Vent…', 'please_wait' => 'Vent…',
); ];

View file

@ -1,26 +1,6 @@
<?php <?php
/* return [
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
return array(
'lang' => 'Dutch', 'lang' => 'Dutch',
'yes' => 'Ja', 'yes' => 'Ja',
'no' => 'Nee', 'no' => 'Nee',
@ -122,4 +102,4 @@ return array(
'lang_name' => 'Taal', 'lang_name' => 'Taal',
'default_lang_behavior' => 'XBackBone probeert standaard de taal van de browser te matchen (fallback is Engels).', 'default_lang_behavior' => 'XBackBone probeert standaard de taal van de browser te matchen (fallback is Engels).',
'lang_set' => 'Systeemtaal "%s" afgedwongen', 'lang_set' => 'Systeemtaal "%s" afgedwongen',
); ];

View file

@ -1,26 +1,6 @@
<?php <?php
/* return [
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
return array(
'lang' => 'Portuguese', 'lang' => 'Portuguese',
'yes' => 'Sim', 'yes' => 'Sim',
'no' => 'Não', 'no' => 'Não',
@ -64,4 +44,4 @@ return array(
'your_profile' => 'O teu perfil', 'your_profile' => 'O teu perfil',
'token' => 'Token', 'token' => 'Token',
'copy' => 'Copiar', 'copy' => 'Copiar',
); ];

View file

@ -1,26 +1,6 @@
<?php <?php
/* return [
* @copyright Copyright (c) 2019 Sergio Brighenti <sergio@brighenti.me>
*
* @author Sergio Brighenti <sergio@brighenti.me>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
return array(
'lang' => 'Russian', 'lang' => 'Russian',
'yes' => 'Да', 'yes' => 'Да',
'no' => 'Нет', 'no' => 'Нет',
@ -122,4 +102,4 @@ return array(
'lang_name' => 'язык', 'lang_name' => 'язык',
'default_lang_behavior' => 'XBackBone попробует выбрать язык вашего браузера по умолчанию, иначе будет выбран Английский.', 'default_lang_behavior' => 'XBackBone попробует выбрать язык вашего браузера по умолчанию, иначе будет выбран Английский.',
'lang_set' => 'Выбран следующий язык: "%s"', 'lang_set' => 'Выбран следующий язык: "%s"',
); ];