Added support .env files

Basic settings have been moved to .env
This commit is contained in:
Sergei Solovev 2024-03-15 04:47:14 +03:00
parent a8bb43a2cd
commit d26088ab28
6 changed files with 187 additions and 14 deletions

21
.env Normal file
View file

@ -0,0 +1,21 @@
# Basic Settings
# Site protocol http:// or https://
APP_PROTOCOL="http://"
# The URL of the site
APP_URL="example.com"
# The name of the site
APP_NAME="EngineGP"
# Site Description
APP_DESCRIPTION="EngineGP"
# Database Connection Settings
DB_HOST="127.0.0.1"
DB_DATABASE="enginegp_db"
DB_USERNAME="enginegp_usr"
DB_PASSWORD="enginegp_pwd"
# Settings of the "Control" service
# The IP address of the site
APP_IP="127.0.0.1"
# Site subnet
APP_SUBNET="127.0.0.1.0/23"

View file

@ -16,6 +16,11 @@ RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(?!acp).* index.php [L]
<Files .env>
Order allow,deny
Deny from all
</Files>
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html

View file

@ -1,6 +1,7 @@
{
"require": {
"symfony/polyfill": "1.28.0",
"symfony/dotenv": "5.4.35",
"filp/whoops": "2.15.4",
"monolog/monolog": "2.9.2",
"xpaw/php-source-query-class": "2.1.0",

142
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "9fe541d20000bad8bcc7a6f093bd89a1",
"content-hash": "06f4af2d7e9531adb777efd893131ba8",
"packages": [
{
"name": "filp/whoops",
@ -229,6 +229,144 @@
},
"time": "2021-05-03T11:20:27+00:00"
},
{
"name": "symfony/deprecation-contracts",
"version": "v2.5.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66",
"reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
}
},
"autoload": {
"files": [
"function.php"
]
},
"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": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2"
},
"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": "2022-01-02T09:53:40+00:00"
},
{
"name": "symfony/dotenv",
"version": "v5.4.35",
"source": {
"type": "git",
"url": "https://github.com/symfony/dotenv.git",
"reference": "4de488440104b99d2e7c0717ee432e760b061e32"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dotenv/zipball/4de488440104b99d2e7c0717ee432e760b061e32",
"reference": "4de488440104b99d2e7c0717ee432e760b061e32",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1|^3"
},
"require-dev": {
"symfony/console": "^4.4|^5.0|^6.0",
"symfony/process": "^4.4|^5.0|^6.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Dotenv\\": ""
},
"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": "Registers environment variables from a .env file",
"homepage": "https://symfony.com",
"keywords": [
"dotenv",
"env",
"environment"
],
"support": {
"source": "https://github.com/symfony/dotenv/tree/v5.4.35"
},
"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-01-23T13:51:25+00:00"
},
{
"name": "symfony/polyfill",
"version": "v1.28.0",
@ -478,5 +616,5 @@
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.3.0"
"plugin-api-version": "2.6.0"
}

View file

@ -2,14 +2,18 @@
if (!DEFINED('EGP'))
exit(header('Refresh: 0; URL=http://' . $_SERVER['HTTP_HOST'] . '/404'));
// Загружаем .env
$dotenv = new Symfony\Component\Dotenv\Dotenv();
$dotenv->load(ROOT.'.env');
$cfg = array(
'name' => 'EngineGP', // Название сайта
'graph' => 'EngineGP', // Описание сайта
'url' => 'IPADDR', // Тут ваш IP или Домен, пример: 127.0.0.1
'http' => 'http://IPADDR/', // Тут ваш IP или Домен с указанием http, пример: http://127.0.0.1
'plugins' => 'http://IPADDR/files/plugins/', // Путь к плагинам
'ip' => 'IPADDR', // IP-Адрес сайта прмер: 127.0.0.1
'subnet' => 'IPADDR.0/23', // Подсеть сайта пример: 127.0.0.1.0/23 .0/23(не стирать)
'name' => $_ENV['APP_NAME'],
'graph' => $_ENV['APP_NAME'],
'url' => $_ENV['APP_URL'],
'http' => $_ENV['APP_PROTOCOL'] . $_ENV['APP_URL'] . '/',
'plugins' => $_ENV['APP_PROTOCOL'] . $_ENV['APP_URL'] . '/files/plugins/',
'ip' => $_ENV['APP_IP'],
'subnet' => $_ENV['APP_IP'],
// Данные для пополнения баланса пользователям
'freekassa_id' => '', // Номер кассы

View file

@ -2,8 +2,12 @@
if (!DEFINED('EGP'))
exit(header('Refresh: 0; URL=http://' . $_SERVER['HTTP_HOST'] . '/404'));
DEFINE('USER_DATABASE', 'root');
DEFINE('PASSWORD_DATABASE', 'SQLPASS'); // пароль mysql
DEFINE('NAME_DATABASE', 'enginegp');
DEFINE('CONNECT_DATABASE', 'localhost');
DEFINE('ERROR_DATABASE', FALSE);
// Загружаем .env
$dotenv = new Symfony\Component\Dotenv\Dotenv();
$dotenv->load(ROOT.'.env');
define('USER_DATABASE', $_ENV['DB_USERNAME']);
define('PASSWORD_DATABASE', $_ENV['DB_PASSWORD']);
define('NAME_DATABASE', $_ENV['DB_DATABASE']);
define('CONNECT_DATABASE', $_ENV['DB_HOST']);
define('ERROR_DATABASE', false);