From a950ec9af35bda1c16c0490bd2025cbb70f5e6d6 Mon Sep 17 00:00:00 2001 From: Sergio Brighenti Date: Mon, 19 Nov 2018 19:04:43 +0100 Subject: [PATCH] Completed multilang Routes rework --- CHANGELOG.md | 6 ++ app/Controllers/DashboardController.php | 7 +- app/Controllers/LoginController.php | 18 ++--- app/Controllers/UploadController.php | 6 +- app/Controllers/UserController.php | 83 ++++++++++++--------- app/Middleware/AuthMiddleware.php | 4 +- app/helpers.php | 37 +++++++++- app/routes.php | 56 +++++++-------- bootstrap/app.php | 7 +- composer.json | 2 +- resources/lang/en.lang.php | 82 +++++++++++++++++++++ resources/lang/it.lang.php | 87 +++++++++++++++++++++++ resources/schemas/mysql/mysql.2.sql | 1 + resources/schemas/sqlite/sqlite.2.sql | 2 + resources/templates/auth/login.twig | 14 ++-- resources/templates/base.twig | 22 +++--- resources/templates/comp/navbar.twig | 20 +++--- resources/templates/comp/pager.twig | 11 ++- resources/templates/dashboard/admin.twig | 31 ++++---- resources/templates/dashboard/home.twig | 76 ++++++++++---------- resources/templates/dashboard/system.twig | 20 +++--- resources/templates/upload/public.twig | 28 ++++---- resources/templates/user/create.twig | 22 +++--- resources/templates/user/edit.twig | 30 ++++---- resources/templates/user/index.twig | 32 ++++----- 25 files changed, 465 insertions(+), 239 deletions(-) create mode 100644 resources/lang/it.lang.php create mode 100644 resources/schemas/mysql/mysql.2.sql create mode 100644 resources/schemas/sqlite/sqlite.2.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 51f8c27..11c9080 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v2.2 ++ Added multi-language support. ++ Improved routing. ++ Fixed HTTP/2 push is resetting the current session. ++ Minor improvements and bug fixes. + ## v2.1 + Improved theme style. + Improved page redirecting. diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index b3a974c..bc3be8a 100644 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -23,11 +23,11 @@ class DashboardController extends Controller { if ($request->getParam('afterInstall') !== null && is_dir('install')) { - Session::alert('Installation completed successfully!', 'success'); + Session::alert(lang('installed'), 'success'); removeDirectory('install'); } - return redirect($response, '/home'); + return redirect($response, 'home'); } /** @@ -117,6 +117,7 @@ class DashboardController extends Controller $out = []; + $out['Default - Bootstrap 4 default theme'] = 'https://bootswatch.com/_vendor/bootstrap/dist/css/bootstrap.min.css'; foreach ($apiJson->themes as $theme) { $out["{$theme->name} - {$theme->description}"] = $theme->cssMin; } @@ -128,6 +129,6 @@ class DashboardController extends Controller public function applyTheme(Request $request, Response $response): Response { file_put_contents('static/bootstrap/css/bootstrap.min.css', file_get_contents($request->getParam('css'))); - return redirect($response, '/system')->withAddedHeader('Cache-Control', 'no-cache, must-revalidate'); + return redirect($response, 'system')->withAddedHeader('Cache-Control', 'no-cache, must-revalidate'); } } \ No newline at end of file diff --git a/app/Controllers/LoginController.php b/app/Controllers/LoginController.php index 1d5593f..fd0d34c 100644 --- a/app/Controllers/LoginController.php +++ b/app/Controllers/LoginController.php @@ -19,7 +19,7 @@ class LoginController extends Controller public function show(Request $request, Response $response): Response { if (Session::get('logged', false)) { - return redirect($response, '/home'); + return redirect($response, 'home'); } return $this->view->render($response, 'auth/login.twig'); } @@ -35,13 +35,13 @@ class LoginController extends Controller $result = DB::query('SELECT `id`, `email`, `username`, `password`,`is_admin`, `active` FROM `users` WHERE `username` = ? OR `email` = ? LIMIT 1', [$request->getParam('username'), $request->getParam('username')])->fetch(); if (!$result || !password_verify($request->getParam('password'), $result->password)) { - Session::alert('Wrong credentials', 'danger'); - return redirect($response, '/login'); + Session::alert(lang('bad_login'), 'danger'); + return redirect($response, 'login'); } if (!$result->active) { - Session::alert('Your account is disabled.', 'danger'); - return redirect($response, '/login'); + Session::alert(lang('account_disabled'), 'danger'); + return redirect($response, 'login'); } Session::set('logged', true); @@ -50,14 +50,14 @@ class LoginController extends Controller Session::set('admin', $result->is_admin); Session::set('used_space', humanFileSize($this->getUsedSpaceByUser($result->id))); - Session::alert("Welcome, $result->username!", 'info'); + Session::alert(lang('welcome', [$result->username]), 'info'); $this->logger->info("User $result->username logged in."); if (Session::has('redirectTo')) { return $response->withRedirect(Session::get('redirectTo')); } - return redirect($response, '/home'); + return redirect($response, 'home'); } /** @@ -69,8 +69,8 @@ class LoginController extends Controller { Session::clear(); Session::set('logged', false); - Session::alert('Goodbye!', 'warning'); - return redirect($response, '/login'); + Session::alert(lang('goodbye'), 'warning'); + return redirect($response, 'login.show'); } } \ No newline at end of file diff --git a/app/Controllers/UploadController.php b/app/Controllers/UploadController.php index 4ffe960..9c65503 100644 --- a/app/Controllers/UploadController.php +++ b/app/Controllers/UploadController.php @@ -139,12 +139,12 @@ class UploadController extends Controller $user = $this->database->query('SELECT `id`, `active` FROM `users` WHERE `token` = ? LIMIT 1', $args['token'])->fetch(); if (!$user) { - Session::alert('Token specified not found.', 'danger'); + Session::alert(lang('token_not_found'), 'danger'); return $response->withRedirect($request->getHeaderLine('HTTP_REFERER')); } if (!$user->active) { - Session::alert('Account disabled.', 'danger'); + Session::alert(lang('account_disabled'), 'danger'); return $response->withRedirect($request->getHeaderLine('HTTP_REFERER')); } @@ -163,7 +163,7 @@ class UploadController extends Controller throw new UnauthorizedException(); } - return redirect($response, '/home'); + return redirect($response, 'home'); } /** diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index 1cdf501..93f64a8 100644 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -57,23 +57,28 @@ class UserController extends Controller public function store(Request $request, Response $response): Response { if ($request->getParam('email') === null) { - Session::alert('The email is required.', 'danger'); - return redirect($response, '/user/create'); + Session::alert(lang('email_required'), 'danger'); + return redirect($response, 'user.create'); + } + + if ($this->database->query('SELECT COUNT(*) AS `count` FROM `users` WHERE `email` = ?', $request->getParam('email'))->fetch()->count > 0) { + Session::alert(lang('email_taken'), 'danger'); + return redirect($response, 'user.create'); } if ($request->getParam('username') === null) { - Session::alert('The username is required.', 'danger'); - return redirect($response, '/user/create'); + Session::alert(lang('username_required'), 'danger'); + return redirect($response, 'user.create'); } if ($request->getParam('password') === null) { - Session::alert('The password is required.', 'danger'); - return redirect($response, '/user/create'); + Session::alert(lang('password_required'), 'danger'); + return redirect($response, 'user.create'); } if ($this->database->query('SELECT COUNT(*) AS `count` FROM `users` WHERE `username` = ?', $request->getParam('username'))->fetch()->count > 0) { - Session::alert('The username already taken.', 'danger'); - return redirect($response, '/user/create'); + Session::alert(lang('username_taken'), 'danger'); + return redirect($response, 'user.create'); } do { @@ -86,16 +91,16 @@ class UserController extends Controller $request->getParam('email'), $request->getParam('username'), password_hash($request->getParam('password'), PASSWORD_DEFAULT), - $request->getParam('is_admin') !== null, - $request->getParam('is_active') !== null, + $request->getParam('is_admin') !== null ? 1 : 0, + $request->getParam('is_active') !== null ? 1 : 0, $userCode, $token, ]); - Session::alert("User '{$request->getParam('username')}' created!", 'success'); + Session::alert(lang('user_created', [$request->getParam('username')]), 'success'); $this->logger->info('User ' . Session::get('username') . ' created a new user.', [array_diff($request->getParams(), ['password'])]); - return redirect($response, '/users'); + return redirect($response, 'user.index'); } /** @@ -135,23 +140,28 @@ class UserController extends Controller } if ($request->getParam('email') === null) { - Session::alert('The email is required.', 'danger'); - return redirect($response, '/user/' . $args['id'] . '/edit'); + Session::alert(lang('email_required'), 'danger'); + return redirect($response, 'user.edit', ['id' => $args['id']]); + } + + if ($this->database->query('SELECT COUNT(*) AS `count` FROM `users` WHERE `email` = ? AND `email` <> ?', [$request->getParam('email'), $user->email])->fetch()->count > 0) { + Session::alert(lang('email_taken'), 'danger'); + return redirect($response, 'user.edit', ['id' => $args['id']]); } if ($request->getParam('username') === null) { - Session::alert('The username is required.', 'danger'); - return redirect($response, '/user/' . $args['id'] . '/edit'); + Session::alert(lang('username_required'), 'danger'); + return redirect($response, 'user.edit', ['id' => $args['id']]); } if ($this->database->query('SELECT COUNT(*) AS `count` FROM `users` WHERE `username` = ? AND `username` <> ?', [$request->getParam('username'), $user->username])->fetch()->count > 0) { - Session::alert('The username already taken.', 'danger'); - return redirect($response, '/user/' . $args['id'] . '/edit'); + Session::alert(lang('username_taken'), 'danger'); + return redirect($response, 'user.edit', ['id' => $args['id']]); } if ($user->id === Session::get('user_id') && $request->getParam('is_admin') === null) { - Session::alert('You cannot demote yourself.', 'danger'); - return redirect($response, '/user/' . $args['id'] . '/edit'); + Session::alert(lang('cannot_demote'), 'danger'); + return redirect($response, 'user.edit', ['id' => $args['id']]); } if ($request->getParam('password') !== null && !empty($request->getParam('password'))) { @@ -159,24 +169,24 @@ class UserController extends Controller $request->getParam('email'), $request->getParam('username'), password_hash($request->getParam('password'), PASSWORD_DEFAULT), - $request->getParam('is_admin') !== null, - $request->getParam('is_active') !== null, + $request->getParam('is_admin') !== null ? 1 : 0, + $request->getParam('is_active') !== null ? 1 : 0, $user->id, ]); } else { $this->database->query('UPDATE `users` SET `email`=?, `username`=?, `is_admin`=?, `active`=? WHERE `id` = ?', [ $request->getParam('email'), $request->getParam('username'), - $request->getParam('is_admin') !== null, - $request->getParam('is_active') !== null, + $request->getParam('is_admin') !== null ? 1 : 0, + $request->getParam('is_active') !== null ? 1 : 0, $user->id, ]); } - Session::alert("User '{$request->getParam('username')}' updated!", 'success'); + Session::alert(lang('user_updated', [$request->getParam('username')]), 'success'); $this->logger->info('User ' . Session::get('username') . " updated $user->id.", [$user, array_diff($request->getParams(), ['password'])]); - return redirect($response, '/users'); + return redirect($response, 'user.index'); } @@ -196,16 +206,16 @@ class UserController extends Controller } if ($user->id === Session::get('user_id')) { - Session::alert('You cannot delete yourself.', 'danger'); - return redirect($response, '/users'); + Session::alert(lang('cannot_delete'), 'danger'); + return redirect($response, 'user.index'); } $this->database->query('DELETE FROM `users` WHERE `id` = ?', $user->id); - Session::alert('User deleted.', 'success'); + Session::alert(lang('user_deleted'), 'success'); $this->logger->info('User ' . Session::get('username') . " deleted $user->id."); - return redirect($response, '/users'); + return redirect($response, 'user.index'); } /** @@ -254,8 +264,13 @@ class UserController extends Controller } if ($request->getParam('email') === null) { - Session::alert('The email is required.', 'danger'); - return redirect($response, '/profile'); + Session::alert(lang('email_required'), 'danger'); + return redirect($response, 'profile'); + } + + if ($this->database->query('SELECT COUNT(*) AS `count` FROM `users` WHERE `email` = ? AND `email` <> ?', [$request->getParam('email'), $user->email])->fetch()->count > 0) { + Session::alert(lang('email_taken'), 'danger'); + return redirect($response, 'profile'); } if ($request->getParam('password') !== null && !empty($request->getParam('password'))) { @@ -271,10 +286,10 @@ class UserController extends Controller ]); } - Session::alert('Profile updated successfully!', 'success'); + Session::alert(lang('profile_updated'), 'success'); $this->logger->info('User ' . Session::get('username') . " updated profile of $user->id."); - return redirect($response, '/profile'); + return redirect($response, 'profile'); } /** diff --git a/app/Middleware/AuthMiddleware.php b/app/Middleware/AuthMiddleware.php index 37ecb5a..8b16f82 100644 --- a/app/Middleware/AuthMiddleware.php +++ b/app/Middleware/AuthMiddleware.php @@ -27,14 +27,14 @@ class AuthMiddleware { if (!Session::get('logged', false)) { Session::set('redirectTo', (isset($_SERVER['HTTPS']) ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"); - return redirect($response, '/login'); + return redirect($response, 'login.show'); } if (!$this->container->database->query('SELECT `id`, `active` FROM `users` WHERE `id` = ? LIMIT 1', [Session::get('user_id')])->fetch()->active) { Session::alert('Your account is not active anymore.', 'danger'); Session::set('logged', false); Session::set('redirectTo', (isset($_SERVER['HTTPS']) ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"); - return redirect($response, '/login'); + return redirect($response, 'login.show'); } return $next($request, $response); diff --git a/app/helpers.php b/app/helpers.php index e4c3de7..5ea30d2 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -55,12 +55,19 @@ if (!function_exists('redirect')) { * Set the redirect response * @param \Slim\Http\Response $response * @param string $path + * @param array $args * @param null $status * @return \Slim\Http\Response */ - function redirect(\Slim\Http\Response $response, string $path, $status = null) + function redirect(\Slim\Http\Response $response, string $path, $args = [], $status = null) { - return $response->withRedirect(urlFor($path), $status); + if ($path === '/' || substr($path, 0, 1) === '/') { + $url = urlFor($path); + } else { + $url = route($path, $args); + } + + return $response->withRedirect($url, $status); } } @@ -78,3 +85,29 @@ if (!function_exists('urlFor')) { } } +if (!function_exists('route')) { + /** + * Generate the app url given a path + * @param string $path + * @param array $args + * @return string + */ + function route(string $path, array $args = []) + { + global $app; + $uri = $app->getContainer()->get('router')->pathFor($path, $args); + return urlFor($uri); + } +} + +if (!function_exists('lang')) { + /** + * @param string $key + * @param array $args + * @return string + */ + function lang(string $key, $args = []) + { + return \App\Web\Lang::getInstance()->get($key, $args); + } +} \ No newline at end of file diff --git a/app/routes.php b/app/routes.php index 48fd2e0..845239b 100644 --- a/app/routes.php +++ b/app/routes.php @@ -1,41 +1,41 @@ group('', function () { - $this->get('/home[/page/{page}]', \App\Controllers\DashboardController::class . ':home'); - $this->get('/system', \App\Controllers\DashboardController::class . ':system')->add(\App\Middleware\AdminMiddleware::class); - $this->get('/system/themes', \App\Controllers\DashboardController::class . ':getThemes')->add(\App\Middleware\AdminMiddleware::class); - $this->post('/system/theme/apply', \App\Controllers\DashboardController::class . ':applyTheme')->add(\App\Middleware\AdminMiddleware::class); + $this->get('/home[/page/{page}]', \App\Controllers\DashboardController::class . ':home')->setName('home'); + $this->get('/system', \App\Controllers\DashboardController::class . ':system')->add(\App\Middleware\AdminMiddleware::class)->setName('system'); + $this->get('/system/themes', \App\Controllers\DashboardController::class . ':getThemes')->add(\App\Middleware\AdminMiddleware::class)->setName('theme'); + $this->post('/system/theme/apply', \App\Controllers\DashboardController::class . ':applyTheme')->add(\App\Middleware\AdminMiddleware::class)->setName('theme.apply'); $this->group('', function () { - $this->get('/users[/page/{page}]', \App\Controllers\UserController::class . ':index'); - $this->get('/user/create', \App\Controllers\UserController::class . ':create'); - $this->post('/user/create', \App\Controllers\UserController::class . ':store'); - $this->get('/user/{id}/edit', \App\Controllers\UserController::class . ':edit'); - $this->post('/user/{id}', \App\Controllers\UserController::class . ':update'); - $this->get('/user/{id}/delete', \App\Controllers\UserController::class . ':delete'); + $this->get('/users[/page/{page}]', \App\Controllers\UserController::class . ':index')->setName('user.index'); + $this->get('/user/create', \App\Controllers\UserController::class . ':create')->setName('user.create'); + $this->post('/user/create', \App\Controllers\UserController::class . ':store')->setName('user.store'); + $this->get('/user/{id}/edit', \App\Controllers\UserController::class . ':edit')->setName('user.edit'); + $this->post('/user/{id}', \App\Controllers\UserController::class . ':update')->setName('user.update'); + $this->get('/user/{id}/delete', \App\Controllers\UserController::class . ':delete')->setName('user.delete'); })->add(\App\Middleware\AdminMiddleware::class); - $this->get('/profile', \App\Controllers\UserController::class . ':profile'); - $this->post('/profile/{id}', \App\Controllers\UserController::class . ':profileEdit'); - $this->post('/user/{id}/refreshToken', \App\Controllers\UserController::class . ':refreshToken'); - $this->get('/user/{id}/config/sharex', \App\Controllers\UserController::class . ':getShareXconfigFile'); + $this->get('/profile', \App\Controllers\UserController::class . ':profile')->setName('profile'); + $this->post('/profile/{id}', \App\Controllers\UserController::class . ':profileEdit')->setName('profile.update'); + $this->post('/user/{id}/refreshToken', \App\Controllers\UserController::class . ':refreshToken')->setName('refreshToken'); + $this->get('/user/{id}/config/sharex', \App\Controllers\UserController::class . ':getShareXconfigFile')->setName('config.sharex'); - $this->post('/upload/{id}/publish', \App\Controllers\UploadController::class . ':togglePublish'); - $this->post('/upload/{id}/unpublish', \App\Controllers\UploadController::class . ':togglePublish'); - $this->get('/upload/{id}/raw', \App\Controllers\UploadController::class . ':getRawById')->add(\App\Middleware\AdminMiddleware::class); - $this->post('/upload/{id}/delete', \App\Controllers\UploadController::class . ':delete'); + $this->post('/upload/{id}/publish', \App\Controllers\UploadController::class . ':togglePublish')->setName('upload.publish'); + $this->post('/upload/{id}/unpublish', \App\Controllers\UploadController::class . ':togglePublish')->setName('upload.unpublish'); + $this->get('/upload/{id}/raw', \App\Controllers\UploadController::class . ':getRawById')->add(\App\Middleware\AdminMiddleware::class)->setName('upload.raw'); + $this->post('/upload/{id}/delete', \App\Controllers\UploadController::class . ':delete')->setName('upload.delete'); })->add(\App\Middleware\AuthMiddleware::class); -$app->get('/', \App\Controllers\DashboardController::class . ':redirects'); -$app->get('/login', \App\Controllers\LoginController::class . ':show'); -$app->post('/login', \App\Controllers\LoginController::class . ':login'); -$app->map(['GET', 'POST'], '/logout', \App\Controllers\LoginController::class . ':logout'); +$app->get('/', \App\Controllers\DashboardController::class . ':redirects')->setName('root'); +$app->get('/login', \App\Controllers\LoginController::class . ':show')->setName('login.show'); +$app->post('/login', \App\Controllers\LoginController::class . ':login')->setName('login'); +$app->map(['GET', 'POST'], '/logout', \App\Controllers\LoginController::class . ':logout')->setName('logout'); -$app->post('/upload', \App\Controllers\UploadController::class . ':upload'); +$app->post('/upload', \App\Controllers\UploadController::class . ':upload')->setName('upload'); -$app->get('/{userCode}/{mediaCode}', \App\Controllers\UploadController::class . ':show'); -$app->get('/{userCode}/{mediaCode}/delete/{token}', \App\Controllers\UploadController::class . ':show'); -$app->post('/{userCode}/{mediaCode}/delete/{token}', \App\Controllers\UploadController::class . ':deleteByToken'); -$app->get('/{userCode}/{mediaCode}/raw', \App\Controllers\UploadController::class . ':showRaw'); -$app->get('/{userCode}/{mediaCode}/download', \App\Controllers\UploadController::class . ':download'); \ No newline at end of file +$app->get('/{userCode}/{mediaCode}', \App\Controllers\UploadController::class . ':show')->setName('public'); +$app->get('/{userCode}/{mediaCode}/delete/{token}', \App\Controllers\UploadController::class . ':show')->setName('public.delete.show'); +$app->post('/{userCode}/{mediaCode}/delete/{token}', \App\Controllers\UploadController::class . ':deleteByToken')->setName('public.delete'); +$app->get('/{userCode}/{mediaCode}/raw', \App\Controllers\UploadController::class . ':showRaw')->setName('public.raw'); +$app->get('/{userCode}/{mediaCode}/download', \App\Controllers\UploadController::class . ':download')->setName('public.download'); \ No newline at end of file diff --git a/bootstrap/app.php b/bootstrap/app.php index 37eb4fe..5af7076 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -28,7 +28,6 @@ $config = array_replace_recursive([ 'username' => null, 'password' => null, ], - 'lang' => 'en', ], require __DIR__ . '/../config.php'); if (!$config['displayErrorDetails']) { @@ -59,7 +58,7 @@ $container['database'] = function ($container) use (&$config) { return DB::getInstance(); }; -Lang::build($config['lang'], __DIR__. '/../resources/lang/'); +Lang::build(substr(@$_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2), __DIR__. '/../resources/lang/'); $container['lang'] = function ($container) { return Lang::getInstance(); @@ -85,6 +84,10 @@ $container['view'] = function ($container) use (&$config) { $view->getEnvironment()->addGlobal('session', Session::all()); $view->getEnvironment()->addGlobal('lang', $container->get('lang')); $view->getEnvironment()->addGlobal('PLATFORM_VERSION', PLATFORM_VERSION); + + $view->getEnvironment()->addFunction(new Twig_Function('route', 'route')); + $view->getEnvironment()->addFunction(new Twig_Function('lang', 'lang')); + $view->getEnvironment()->addFunction(new Twig_Function('urlFor', 'urlFor')); return $view; }; diff --git a/composer.json b/composer.json index 63bc32e..5c177be 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "sergix44/xbackbone", - "version": "2.1", + "version": "2.2", "description": "A lightweight ShareX PHP backend", "type": "project", "require": { diff --git a/resources/lang/en.lang.php b/resources/lang/en.lang.php index 25058db..cd0f902 100644 --- a/resources/lang/en.lang.php +++ b/resources/lang/en.lang.php @@ -2,4 +2,86 @@ return [ + 'lang' => 'English', + + 'yes' => 'Yes', + 'no' => 'No', + 'send' => 'Send', + 'no_media' => 'No media found.', + + 'login.username' => 'Username or E-Mail', + 'password' => 'Password', + 'login' => 'Login', + 'username' => 'Username', + + 'home' => 'Home', + 'users' => 'Users', + 'system' => 'System', + 'profile' => 'Profile', + 'logout' => 'Logout', + + 'pager.next' => 'Next', + 'pager.previous' => 'Previous', + + 'copy_link' => 'Copy link', + 'public.telegram' => 'Share on Telegram', + 'public.delete_text' => 'Are you sure you want to delete this item? It will be gone forever!', + + 'preview' => 'Preview', + 'filename' => 'Filename', + 'size' => 'Size', + 'public' => 'Public', + 'owner' => 'Owner', + 'date' => 'Date', + 'raw' => 'Show raw', + 'download' => 'Download', + 'delete' => 'Delete', + 'publish' => 'Publish', + 'hide' => 'Hide', + + 'files' => 'Files', + 'orphaned_files' => 'Orphaned Files', + 'theme' => 'Theme', + 'click_to_load' => 'Click to load...', + 'apply' => 'Apply', + 'save' => 'Save', + 'used' => 'Used', + 'system_info' => 'System Information', + + 'user.create' => 'Create User', + 'user.edit' => 'Edit User', + 'is_active' => 'Is active', + 'is_admin' => 'Is administrator', + 'your_profile' => 'Your Profile', + 'token' => 'Token', + 'copy' => 'Copy', + 'update' => 'Update', + 'edit' => 'Edit', + 'client_config' => 'Client Configuration', + 'user_code' => 'User Code', + 'active' => 'Active', + 'admin' => 'Admin', + 'reg_date' => 'Registration Date', + 'none' => 'None', + 'open' => 'Open', + 'confirm' => 'Confirmation', + 'confirm_string' => 'Are you sure?', + + 'installed' => 'Installation completed successfully!', + 'bad_login' => 'Wrong credentials.', + 'account_disabled' => 'Your account is disabled.', + 'welcome' => 'Welcome, %s!', + 'goodbye' => 'Goodbye!', + 'token_not_found' => 'Token specified not found.', + 'email_required' => 'The email is required.', + 'email_taken' => 'The email is already taken.', + 'username_required' => 'The username is required.', + 'username_taken' => 'The username is already taken.', + 'password_required' => 'The password is required.', + 'user_created' => 'User "%s" created!', + 'user_updated' => 'User "%s" updated!', + 'profile_updated' => 'Profile updated successfully!', + 'user_deleted' => 'User deleted.', + 'cannot_delete' => 'You cannot delete yourself.', + 'cannot_demote' => 'You cannot demote yourself', ]; \ No newline at end of file diff --git a/resources/lang/it.lang.php b/resources/lang/it.lang.php new file mode 100644 index 0000000..8f2fcd0 --- /dev/null +++ b/resources/lang/it.lang.php @@ -0,0 +1,87 @@ + 'Italian', + + 'yes' => 'Sì', + 'no' => 'No', + 'send' => 'Invia', + 'no_media' => 'Nessun media trovato.', + + 'login.username' => 'Username o E-Mail', + 'password' => 'Password', + 'login' => 'Accedi', + 'username' => 'Username', + + 'home' => 'Home', + 'users' => 'Utenti', + 'system' => 'Sistema', + 'profile' => 'Profilo', + 'logout' => 'Esci', + + 'pager.next' => 'Avanti', + 'pager.previous' => 'Indietro', + + 'copy_link' => 'Copia link', + 'public.telegram' => 'Condividi su Telegram', + 'public.delete_text' => 'Sei sicuro di voler eliminare questo elemento? Andrà perso per sempre!', + + 'preview' => 'Anteprima', + 'filename' => 'Filename', + 'size' => 'Dimensione', + 'public' => 'Pubblico', + 'owner' => 'Proprietario', + 'date' => 'Data', + 'raw' => 'Vedi raw', + 'download' => 'Download', + 'delete' => 'Elimina', + 'publish' => 'Pubblica', + 'hide' => 'Nascondi', + + 'files' => 'File', + 'orphaned_files' => 'File orfani', + 'theme' => 'Tema', + 'click_to_load' => 'Clicca per caricare...', + 'apply' => 'Applica', + 'save' => 'Salva', + 'used' => 'Usato', + 'system_info' => 'Informazioni di Sistema', + + 'user.create' => 'Crea Utente', + 'user.edit' => 'Modifica Utente', + 'is_active' => 'Attivo', + 'is_admin' => 'Amministratore', + 'your_profile' => 'Il tuo profilo', + 'token' => 'Token', + 'copy' => 'Copia', + 'update' => 'Aggiorna', + 'edit' => 'Modifica', + 'client_config' => 'Configurazione del Client', + 'user_code' => 'Codice Utente', + 'active' => 'Attivo', + 'admin' => 'Amministratore', + 'reg_date' => 'Data Registrazione', + 'none' => 'Nessuno', + 'open' => 'Apri', + 'confirm' => 'Conferma', + 'confirm_string' => 'Sei sicuro?', + + 'installed' => 'Installazione completata!', + 'bad_login' => 'Credenziali errate.', + 'account_disabled' => 'Il tuo account è disattivato.', + 'welcome' => 'Benvenuto, %s!', + 'goodbye' => 'Arrivederci!', + 'token_not_found' => 'Il token specificato non è stato trovato.', + 'email_required' => 'Email obbligatoria.', + 'email_taken' => 'Email già in uso.', + 'username_required' => 'Username obbligatorio.', + 'username_taken' => 'Username già in uso.', + 'password_required' => 'Password obbligatoria.', + 'user_created' => 'L\'utente "%s" è stato creato!', + 'user_updated' => 'L\'utente "%s" è stato aggiornato!', + 'profile_updated' => 'Profilo aggiornato con successo!', + 'user_deleted' => 'Utente rimosso.', + 'cannot_delete' => 'Non puoi eliminare te stesso.', + 'cannot_demote' => 'Non puoi degradare te stesso. ', +]; \ No newline at end of file diff --git a/resources/schemas/mysql/mysql.2.sql b/resources/schemas/mysql/mysql.2.sql new file mode 100644 index 0000000..c33d806 --- /dev/null +++ b/resources/schemas/mysql/mysql.2.sql @@ -0,0 +1 @@ +ALTER TABLE `users` ADD UNIQUE INDEX (`email`); \ No newline at end of file diff --git a/resources/schemas/sqlite/sqlite.2.sql b/resources/schemas/sqlite/sqlite.2.sql new file mode 100644 index 0000000..c1b3da6 --- /dev/null +++ b/resources/schemas/sqlite/sqlite.2.sql @@ -0,0 +1,2 @@ +CREATE UNIQUE INDEX IF NOT EXISTS `username_email` + ON `users` (`email`); \ No newline at end of file diff --git a/resources/templates/auth/login.twig b/resources/templates/auth/login.twig index 6c40e53..d1d002c 100644 --- a/resources/templates/auth/login.twig +++ b/resources/templates/auth/login.twig @@ -1,6 +1,6 @@ {% extends 'base.twig' %} -{% block title %}Login{% endblock %} +{% block title %}{{ lang('login') }}{% endblock %} {% block head %}