Use SharpConfig format for the pre-database config.
This commit is contained in:
parent
c2836719c7
commit
5f57e3fdf4
6 changed files with 72 additions and 69 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -11,6 +11,8 @@
|
|||
/composer.local.json
|
||||
|
||||
# Configuration
|
||||
/config/config.cfg
|
||||
/config/github.cfg
|
||||
/config/config.ini
|
||||
/config/github.ini
|
||||
/.debug
|
||||
|
|
91
composer.lock
generated
91
composer.lock
generated
|
@ -293,16 +293,16 @@
|
|||
},
|
||||
{
|
||||
"name": "egulias/email-validator",
|
||||
"version": "4.0.1",
|
||||
"version": "4.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/egulias/EmailValidator.git",
|
||||
"reference": "3a85486b709bc384dae8eb78fb2eec649bdb64ff"
|
||||
"reference": "ebaaf5be6c0286928352e054f2d5125608e5405e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/egulias/EmailValidator/zipball/3a85486b709bc384dae8eb78fb2eec649bdb64ff",
|
||||
"reference": "3a85486b709bc384dae8eb78fb2eec649bdb64ff",
|
||||
"url": "https://api.github.com/repos/egulias/EmailValidator/zipball/ebaaf5be6c0286928352e054f2d5125608e5405e",
|
||||
"reference": "ebaaf5be6c0286928352e054f2d5125608e5405e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -311,8 +311,8 @@
|
|||
"symfony/polyfill-intl-idn": "^1.26"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.5.27",
|
||||
"vimeo/psalm": "^4.30"
|
||||
"phpunit/phpunit": "^10.2",
|
||||
"vimeo/psalm": "^5.12"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation"
|
||||
|
@ -348,7 +348,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/egulias/EmailValidator/issues",
|
||||
"source": "https://github.com/egulias/EmailValidator/tree/4.0.1"
|
||||
"source": "https://github.com/egulias/EmailValidator/tree/4.0.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -356,7 +356,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-01-14T14:17:03+00:00"
|
||||
"time": "2023-10-06T06:47:41+00:00"
|
||||
},
|
||||
{
|
||||
"name": "erusev/parsedown",
|
||||
|
@ -414,7 +414,7 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.flash.moe/flash/index.git",
|
||||
"reference": "f71f3fcf9eb916420f3e8217f99e616149aedc76"
|
||||
"reference": "82a350a5c719cc83aa22382201683a68a2629f2a"
|
||||
},
|
||||
"require": {
|
||||
"ext-mbstring": "*",
|
||||
|
@ -452,7 +452,7 @@
|
|||
],
|
||||
"description": "Composer package for the common library for my projects.",
|
||||
"homepage": "https://railgun.sh/index",
|
||||
"time": "2023-09-11T20:34:16+00:00"
|
||||
"time": "2023-09-15T22:44:36+00:00"
|
||||
},
|
||||
{
|
||||
"name": "flashwave/sasae",
|
||||
|
@ -852,16 +852,16 @@
|
|||
},
|
||||
{
|
||||
"name": "matomo/device-detector",
|
||||
"version": "6.1.5",
|
||||
"version": "6.1.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/matomo-org/device-detector.git",
|
||||
"reference": "40ca2990dba2c1719e5c62168e822e0b86c167d4"
|
||||
"reference": "5cbea85106e561c7138d03603eb6e05128480409"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/matomo-org/device-detector/zipball/40ca2990dba2c1719e5c62168e822e0b86c167d4",
|
||||
"reference": "40ca2990dba2c1719e5c62168e822e0b86c167d4",
|
||||
"url": "https://api.github.com/repos/matomo-org/device-detector/zipball/5cbea85106e561c7138d03603eb6e05128480409",
|
||||
"reference": "5cbea85106e561c7138d03603eb6e05128480409",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -917,7 +917,7 @@
|
|||
"source": "https://github.com/matomo-org/matomo",
|
||||
"wiki": "https://dev.matomo.org/"
|
||||
},
|
||||
"time": "2023-08-17T16:17:41+00:00"
|
||||
"time": "2023-10-02T10:01:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "mustangostang/spyc",
|
||||
|
@ -1459,16 +1459,16 @@
|
|||
},
|
||||
{
|
||||
"name": "psr/http-client",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/http-client.git",
|
||||
"reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31"
|
||||
"reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/http-client/zipball/0955afe48220520692d2d09f7ab7e0f93ffd6a31",
|
||||
"reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31",
|
||||
"url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90",
|
||||
"reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1505,9 +1505,9 @@
|
|||
"psr-18"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-fig/http-client/tree/1.0.2"
|
||||
"source": "https://github.com/php-fig/http-client"
|
||||
},
|
||||
"time": "2023-04-10T20:12:12+00:00"
|
||||
"time": "2023-09-23T14:17:50+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/http-factory",
|
||||
|
@ -2093,16 +2093,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/http-client",
|
||||
"version": "v6.3.2",
|
||||
"version": "v6.3.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/http-client.git",
|
||||
"reference": "15f9f4bad62bfcbe48b5dedd866f04a08fc7ff00"
|
||||
"reference": "ab8446f997efb9913627e9da10fa784d2182fe92"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/http-client/zipball/15f9f4bad62bfcbe48b5dedd866f04a08fc7ff00",
|
||||
"reference": "15f9f4bad62bfcbe48b5dedd866f04a08fc7ff00",
|
||||
"url": "https://api.github.com/repos/symfony/http-client/zipball/ab8446f997efb9913627e9da10fa784d2182fe92",
|
||||
"reference": "ab8446f997efb9913627e9da10fa784d2182fe92",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2165,7 +2165,7 @@
|
|||
"http"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/http-client/tree/v6.3.2"
|
||||
"source": "https://github.com/symfony/http-client/tree/v6.3.6"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -2181,7 +2181,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-07-05T08:41:27+00:00"
|
||||
"time": "2023-10-06T10:08:56+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/http-client-contracts",
|
||||
|
@ -2263,16 +2263,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/mailer",
|
||||
"version": "v6.3.0",
|
||||
"version": "v6.3.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/mailer.git",
|
||||
"reference": "7b03d9be1dea29bfec0a6c7b603f5072a4c97435"
|
||||
"reference": "d89611a7830d51b5e118bca38e390dea92f9ea06"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/mailer/zipball/7b03d9be1dea29bfec0a6c7b603f5072a4c97435",
|
||||
"reference": "7b03d9be1dea29bfec0a6c7b603f5072a4c97435",
|
||||
"url": "https://api.github.com/repos/symfony/mailer/zipball/d89611a7830d51b5e118bca38e390dea92f9ea06",
|
||||
"reference": "d89611a7830d51b5e118bca38e390dea92f9ea06",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2323,7 +2323,7 @@
|
|||
"description": "Helps sending emails",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/mailer/tree/v6.3.0"
|
||||
"source": "https://github.com/symfony/mailer/tree/v6.3.5"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -2339,20 +2339,20 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-05-29T12:49:39+00:00"
|
||||
"time": "2023-09-06T09:47:15+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/mime",
|
||||
"version": "v6.3.3",
|
||||
"version": "v6.3.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/mime.git",
|
||||
"reference": "9a0cbd52baa5ba5a5b1f0cacc59466f194730f98"
|
||||
"reference": "d5179eedf1cb2946dbd760475ebf05c251ef6a6e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/mime/zipball/9a0cbd52baa5ba5a5b1f0cacc59466f194730f98",
|
||||
"reference": "9a0cbd52baa5ba5a5b1f0cacc59466f194730f98",
|
||||
"url": "https://api.github.com/repos/symfony/mime/zipball/d5179eedf1cb2946dbd760475ebf05c251ef6a6e",
|
||||
"reference": "d5179eedf1cb2946dbd760475ebf05c251ef6a6e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2407,7 +2407,7 @@
|
|||
"mime-type"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/mime/tree/v6.3.3"
|
||||
"source": "https://github.com/symfony/mime/tree/v6.3.5"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -2423,7 +2423,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-07-31T07:08:24+00:00"
|
||||
"time": "2023-09-29T06:59:36+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/options-resolver",
|
||||
|
@ -3208,16 +3208,16 @@
|
|||
"packages-dev": [
|
||||
{
|
||||
"name": "phpstan/phpstan",
|
||||
"version": "1.10.33",
|
||||
"version": "1.10.39",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpstan.git",
|
||||
"reference": "03b1cf9f814ba0863c4e9affea49a4d1ed9a2ed1"
|
||||
"reference": "d9dedb0413f678b4d03cbc2279a48f91592c97c4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/03b1cf9f814ba0863c4e9affea49a4d1ed9a2ed1",
|
||||
"reference": "03b1cf9f814ba0863c4e9affea49a4d1ed9a2ed1",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/d9dedb0413f678b4d03cbc2279a48f91592c97c4",
|
||||
"reference": "d9dedb0413f678b4d03cbc2279a48f91592c97c4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3266,14 +3266,15 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-09-04T12:20:53+00:00"
|
||||
"time": "2023-10-17T15:46:26+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "dev",
|
||||
"stability-flags": {
|
||||
"flashwave/index": 20,
|
||||
"flashwave/sasae": 20
|
||||
"flashwave/sasae": 20,
|
||||
"flashwave/syokuhou": 20
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"prefer-lowest": false,
|
||||
|
|
8
config/config.example.cfg
Normal file
8
config/config.example.cfg
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Example configuration for Misuzu
|
||||
# and ; can be used at the start of a line for comments.
|
||||
|
||||
database:dsn mariadb://<user>:<pass>@<host>/<name>?charset=utf8mb4
|
||||
|
||||
;sentry:dsn https://sentry dsn here
|
||||
;sentry:tracesRate 1.0
|
||||
;sentry:profilesRate 1.0
|
|
@ -1,10 +0,0 @@
|
|||
; Example configuration for Misuzu
|
||||
|
||||
[Database]
|
||||
driver = mysql
|
||||
host = localhost
|
||||
port = 3306
|
||||
username = username
|
||||
password = password
|
||||
dbname = database
|
||||
charset = utf8mb4
|
26
misuzu.php
26
misuzu.php
|
@ -4,6 +4,7 @@ namespace Misuzu;
|
|||
use Index\Environment;
|
||||
use Index\Data\DbTools;
|
||||
use Syokuhou\DbConfig;
|
||||
use Syokuhou\SharpConfig;
|
||||
|
||||
define('MSZ_STARTUP', microtime(true));
|
||||
define('MSZ_ROOT', __DIR__);
|
||||
|
@ -22,21 +23,22 @@ Environment::setDebug(MSZ_DEBUG);
|
|||
mb_internal_encoding('utf-8');
|
||||
date_default_timezone_set('utc');
|
||||
|
||||
$cfg = parse_ini_file(MSZ_CONFIG . '/config.ini', true, INI_SCANNER_TYPED);
|
||||
$cfg = SharpConfig::fromFile(MSZ_CONFIG . '/config.cfg');
|
||||
|
||||
if(!empty($cfg['sentry-dsn'])) {
|
||||
\Sentry\init([
|
||||
'dsn' => $cfg['sentry-dsn'],
|
||||
'traces_sample_rate' => $cfg['sentry-traces-rate'] ?? 0.2,
|
||||
'profiles_sample_rate' => $cfg['sentry-profiles-rate'] ?? 0.2,
|
||||
]);
|
||||
if($cfg->hasValues('sentry:dsn'))
|
||||
(function($cfg) {
|
||||
\Sentry\init([
|
||||
'dsn' => $cfg->getString('dsn'),
|
||||
'traces_sample_rate' => $cfg->getFloat('tracesRate', 0.2),
|
||||
'profiles_sample_rate' => $cfg->getFloat('profilesRate', 0.2),
|
||||
]);
|
||||
|
||||
set_exception_handler(function(\Throwable $ex) {
|
||||
\Sentry\captureException($ex);
|
||||
});
|
||||
}
|
||||
set_exception_handler(function(\Throwable $ex) {
|
||||
\Sentry\captureException($ex);
|
||||
});
|
||||
})($cfg->scopeTo('sentry'));
|
||||
|
||||
$db = DbTools::create($cfg['dsn'] ?? 'null:');
|
||||
$db = DbTools::create($cfg->getString('database:dsn', 'null:'));
|
||||
$db->execute('SET SESSION time_zone = \'+00:00\', sql_mode = \'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\';');
|
||||
|
||||
$cfg = new DbConfig($db, 'msz_config');
|
||||
|
|
|
@ -43,11 +43,11 @@ header('Content-Type: text/plain; charset=utf-8');
|
|||
if($_SERVER['REQUEST_METHOD'] !== 'POST')
|
||||
die('no');
|
||||
|
||||
$config = MSZ_ROOT . '/config/github.ini';
|
||||
$config = MSZ_CONFIG . '/github.ini';
|
||||
if(!is_file($config))
|
||||
die('config missing');
|
||||
|
||||
$config = parse_ini_file(MSZ_ROOT . '/config/github.ini', true);
|
||||
$config = parse_ini_file($config, true);
|
||||
if(empty($config['tokens']['token']))
|
||||
die('config invalid');
|
||||
|
||||
|
|
Loading…
Reference in a new issue