mirror of
https://github.com/claradex/nativegallery.git
synced 2025-03-31 13:48:11 +03:00
update core
This commit is contained in:
parent
36093b54d2
commit
8672508efb
4 changed files with 289 additions and 19 deletions
|
@ -15,18 +15,17 @@ Options -Indexes
|
||||||
Deny from all
|
Deny from all
|
||||||
</Files>
|
</Files>
|
||||||
|
|
||||||
<Files .yml>
|
<Files *.yml>
|
||||||
Order allow,deny
|
Order allow,deny
|
||||||
Deny from all
|
Deny from all
|
||||||
</Files>
|
</Files>
|
||||||
|
|
||||||
<Files .yaml>
|
<Files *.yaml>
|
||||||
Order allow,deny
|
Order allow,deny
|
||||||
Deny from all
|
Deny from all
|
||||||
</Files>
|
</Files>
|
||||||
|
|
||||||
|
|
||||||
RedirectMatch 404 /\.git
|
RedirectMatch 404 /\.git
|
||||||
RedirectMatch 404 /\.yml
|
RedirectMatch 404 /\*.yml
|
||||||
RedirectMatch 404 /\.yaml
|
RedirectMatch 404 /\*.yaml
|
||||||
RedirectMatch 404 /\..*$
|
RedirectMatch 404 /\..*$
|
|
@ -22,7 +22,9 @@
|
||||||
"chriskonnertz/bbcode": "^1.1",
|
"chriskonnertz/bbcode": "^1.1",
|
||||||
"paquettg/php-html-parser": "^2.2",
|
"paquettg/php-html-parser": "^2.2",
|
||||||
"phpmailer/phpmailer": "^6.9",
|
"phpmailer/phpmailer": "^6.9",
|
||||||
"beeyev/disposable-email-filter-php": "^1.3"
|
"beeyev/disposable-email-filter-php": "^1.3",
|
||||||
|
"latte/latte": "^3.0",
|
||||||
|
"symfony/http-foundation": "^7.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpstan/phpstan": "*"
|
"phpstan/phpstan": "*"
|
||||||
|
|
241
composer.lock
generated
241
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "844a94a4ce9ce290e30dd5845c27ed3f",
|
"content-hash": "da68f7d816d4b35d8b2259d57d235833",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "aws/aws-crt-php",
|
"name": "aws/aws-crt-php",
|
||||||
|
@ -721,6 +721,92 @@
|
||||||
],
|
],
|
||||||
"time": "2023-12-03T20:05:35+00:00"
|
"time": "2023-12-03T20:05:35+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "latte/latte",
|
||||||
|
"version": "v3.0.20",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/nette/latte.git",
|
||||||
|
"reference": "4db7a5502f8cef02fffa84fc9c34a635d9c79d4d"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/nette/latte/zipball/4db7a5502f8cef02fffa84fc9c34a635d9c79d4d",
|
||||||
|
"reference": "4db7a5502f8cef02fffa84fc9c34a635d9c79d4d",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-json": "*",
|
||||||
|
"ext-tokenizer": "*",
|
||||||
|
"php": "8.0 - 8.4"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"nette/application": "<3.1.7",
|
||||||
|
"nette/caching": "<3.1.4"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"nette/php-generator": "^4.0",
|
||||||
|
"nette/tester": "^2.5",
|
||||||
|
"nette/utils": "^4.0",
|
||||||
|
"phpstan/phpstan": "^1",
|
||||||
|
"tracy/tracy": "^2.10"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-fileinfo": "to use filter |datastream",
|
||||||
|
"ext-iconv": "to use filters |reverse, |substring",
|
||||||
|
"ext-intl": "to use Latte\\Engine::setLocale()",
|
||||||
|
"ext-mbstring": "to use filters like lower, upper, capitalize, ...",
|
||||||
|
"nette/php-generator": "to use tag {templatePrint}",
|
||||||
|
"nette/utils": "to use filter |webalize"
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"bin/latte-lint"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "3.0-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"classmap": [
|
||||||
|
"src/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause",
|
||||||
|
"GPL-2.0-only",
|
||||||
|
"GPL-3.0-only"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "David Grudl",
|
||||||
|
"homepage": "https://davidgrudl.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Nette Community",
|
||||||
|
"homepage": "https://nette.org/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "☕ Latte: the intuitive and fast template engine for those who want the most secure PHP sites. Introduces context-sensitive escaping.",
|
||||||
|
"homepage": "https://latte.nette.org",
|
||||||
|
"keywords": [
|
||||||
|
"context-sensitive",
|
||||||
|
"engine",
|
||||||
|
"escaping",
|
||||||
|
"html",
|
||||||
|
"nette",
|
||||||
|
"security",
|
||||||
|
"template",
|
||||||
|
"twig"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/nette/latte/issues",
|
||||||
|
"source": "https://github.com/nette/latte/tree/v3.0.20"
|
||||||
|
},
|
||||||
|
"time": "2024-10-08T00:58:27+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "mtdowling/jmespath.php",
|
"name": "mtdowling/jmespath.php",
|
||||||
"version": "2.7.0",
|
"version": "2.7.0",
|
||||||
|
@ -1722,6 +1808,83 @@
|
||||||
],
|
],
|
||||||
"time": "2024-04-18T09:32:20+00:00"
|
"time": "2024-04-18T09:32:20+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/http-foundation",
|
||||||
|
"version": "v7.1.7",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/http-foundation.git",
|
||||||
|
"reference": "5183b61657807099d98f3367bcccb850238b17a9"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/5183b61657807099d98f3367bcccb850238b17a9",
|
||||||
|
"reference": "5183b61657807099d98f3367bcccb850238b17a9",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=8.2",
|
||||||
|
"symfony/polyfill-mbstring": "~1.1",
|
||||||
|
"symfony/polyfill-php83": "^1.27"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"doctrine/dbal": "<3.6",
|
||||||
|
"symfony/cache": "<6.4"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"doctrine/dbal": "^3.6|^4",
|
||||||
|
"predis/predis": "^1.1|^2.0",
|
||||||
|
"symfony/cache": "^6.4|^7.0",
|
||||||
|
"symfony/dependency-injection": "^6.4|^7.0",
|
||||||
|
"symfony/expression-language": "^6.4|^7.0",
|
||||||
|
"symfony/http-kernel": "^6.4|^7.0",
|
||||||
|
"symfony/mime": "^6.4|^7.0",
|
||||||
|
"symfony/rate-limiter": "^6.4|^7.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Component\\HttpFoundation\\": ""
|
||||||
|
},
|
||||||
|
"exclude-from-classmap": [
|
||||||
|
"/Tests/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Fabien Potencier",
|
||||||
|
"email": "fabien@symfony.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Defines an object-oriented layer for the HTTP specification",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/http-foundation/tree/v7.1.7"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-11-06T09:02:46+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/polyfill-ctype",
|
"name": "symfony/polyfill-ctype",
|
||||||
"version": "v1.30.0",
|
"version": "v1.30.0",
|
||||||
|
@ -1881,6 +2044,82 @@
|
||||||
],
|
],
|
||||||
"time": "2024-06-19T12:30:46+00:00"
|
"time": "2024-06-19T12:30:46+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/polyfill-php83",
|
||||||
|
"version": "v1.31.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/polyfill-php83.git",
|
||||||
|
"reference": "2fb86d65e2d424369ad2905e83b236a8805ba491"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/polyfill-php83/zipball/2fb86d65e2d424369ad2905e83b236a8805ba491",
|
||||||
|
"reference": "2fb86d65e2d424369ad2905e83b236a8805ba491",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.2"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"thanks": {
|
||||||
|
"url": "https://github.com/symfony/polyfill",
|
||||||
|
"name": "symfony/polyfill"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Polyfill\\Php83\\": ""
|
||||||
|
},
|
||||||
|
"classmap": [
|
||||||
|
"Resources/stubs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nicolas Grekas",
|
||||||
|
"email": "p@tchwork.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Symfony polyfill backporting some PHP 8.3+ features to lower PHP versions",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"compatibility",
|
||||||
|
"polyfill",
|
||||||
|
"portable",
|
||||||
|
"shim"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/polyfill-php83/tree/v1.31.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-09-09T11:45:10+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/process",
|
"name": "symfony/process",
|
||||||
"version": "v7.1.1",
|
"version": "v7.1.1",
|
||||||
|
|
52
index.php
52
index.php
|
@ -1,19 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
// Prevent worker script termination when a client connection is interrupted
|
require __DIR__ . '/vendor/autoload.php';
|
||||||
require __DIR__.'/vendor/autoload.php';
|
|
||||||
|
|
||||||
use App\Core\{Routes, Page};
|
use App\Core\{Routes, Page};
|
||||||
use App\Services\DB;
|
use App\Services\{DB, APIResponse};
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
use Tracy\Debugger;
|
use Tracy\Debugger;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
|
||||||
class App
|
class App
|
||||||
{
|
{
|
||||||
public static function start()
|
public static function start()
|
||||||
{
|
{
|
||||||
error_reporting(E_ALL & ~E_WARNING);
|
error_reporting(E_ALL & ~E_WARNING);
|
||||||
|
$latte = new Latte\Engine;
|
||||||
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/ngallery.yaml')) {
|
$request = Request::createFromGlobals();
|
||||||
|
$problems = [];
|
||||||
|
if (!version_compare(PHP_VERSION, "8.3.0", ">=")) {
|
||||||
|
$problems[] = "Incompatible PHP version: " . PHP_VERSION . "";
|
||||||
|
}
|
||||||
|
if (!is_dir(__DIR__ . "/vendor")) {
|
||||||
|
$problems[] = "Composer dependencies missing";
|
||||||
|
}
|
||||||
|
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/ngallery.yaml')) {
|
||||||
|
$problems[] = "Missing ngallery.yaml (create from ngallery-example.yaml)";
|
||||||
|
}
|
||||||
|
if (sizeof($problems) === 0) {
|
||||||
define("NGALLERY", Yaml::parse(file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/ngallery.yaml'))['ngallery']);
|
define("NGALLERY", Yaml::parse(file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/ngallery.yaml'))['ngallery']);
|
||||||
define("NGALLERY_TASKS", Yaml::parse(file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/app/Controllers/Exec/Tasks/ngallery-tasks.yaml'))['tasks']);
|
define("NGALLERY_TASKS", Yaml::parse(file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/app/Controllers/Exec/Tasks/ngallery-tasks.yaml'))['tasks']);
|
||||||
if (NGALLERY['root']['debug'] === true) {
|
if (NGALLERY['root']['debug'] === true) {
|
||||||
|
@ -24,16 +36,34 @@ class App
|
||||||
DB::connect();
|
DB::connect();
|
||||||
Routes::init();
|
Routes::init();
|
||||||
} else {
|
} else {
|
||||||
Page::set('Errors/ServerDown');
|
$latte->render($_SERVER['DOCUMENT_ROOT'] . "/views/pages/Errors/ServerDown.latte");
|
||||||
}
|
}
|
||||||
} catch (PDOException $ex) {
|
|
||||||
echo '<details><summary class="p20 s5" style="border:none; margin:0 -20px"><b>Произошла ошибка MySQL</b></summary>'.nl2br($ex).'</details>';
|
|
||||||
|
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
echo '<details><summary class="p20 s5" style="border:none; margin:0 -20px"><b>Произошла скриптовая ошибка PHP</b></summary>'.nl2br($ex).'</details>';
|
http_response_code(500);
|
||||||
|
|
||||||
|
$errorCodes = [
|
||||||
|
'PDOException' => ['code' => '10120', 'type' => 'MYSQL_ERROR', 'message' => 'Произошла ошибка MySQL'],
|
||||||
|
'Exception' => ['code' => '10121', 'type' => 'SCRIPT_ERROR', 'message' => 'Произошла ошибка PHP']
|
||||||
|
];
|
||||||
|
|
||||||
|
$exceptionType = $ex instanceof PDOException ? 'PDOException' : 'Exception';
|
||||||
|
$errorDetails = $errorCodes[$exceptionType];
|
||||||
|
|
||||||
|
$errorResponse = NGALLERY['root']['debug'] === true
|
||||||
|
? ['errorcode' => $errorDetails['code'], 'error' => 1, 'errormsg' => $ex, 'errortype' => $errorDetails['type']]
|
||||||
|
: ['errorcode' => '1', 'error' => 1, 'errormsg' => 'Internal Server Error', 'errortype' => $errorDetails['type']];
|
||||||
|
|
||||||
|
if ($request->isXmlHttpRequest() && !isset($_SERVER['HTTP_USER_AGENT'])) {
|
||||||
|
APIResponse::data($errorResponse, 500)->send();
|
||||||
|
} else {
|
||||||
|
echo NGALLERY['root']['debug'] === true
|
||||||
|
? '<details><summary class="p20 s5" style="border:none; margin:0 -20px"><b>' . $errorDetails['message'] . '</b></summary>' . nl2br($ex) . '</details>'
|
||||||
|
: $errorDetails['message'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Page::set('Errors/Problems');
|
$params['problems'] = $problems;
|
||||||
|
$latte->render($_SERVER['DOCUMENT_ROOT'] . "/views/pages/Errors/Problems.latte", $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue