From 3aa9df520476cbdaa8af432c136c2d6413560f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=9C=D0=B0=D1=85?= =?UTF-8?q?=D0=BD=D1=8E=D0=BA?= Date: Wed, 20 Dec 2017 23:05:25 +0500 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20=D0=BE=D0=BF=D1=80=D0=B5=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81=D0=B5=D0=BA=D1=80=D0=B5?= =?UTF-8?q?=D1=82=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=81=D0=BB=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?,=20=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D0=BE=D0=B5=20=D0=B1=D1=83?= =?UTF-8?q?=D0=B4=D0=B5=D1=82=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=D1=81=D1=8F=20=D0=B2=20=D0=BA?= =?UTF-8?q?=D0=B0=D1=87=D0=B5=D1=81=D1=82=D0=B2=D0=B5=20=D0=BE=D0=BF=D1=86?= =?UTF-8?q?=D0=B8=D0=BE=D0=BD=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D0=B9=20=D1=81?= =?UTF-8?q?=D0=BE=D0=BB=D0=B8=20=D0=B4=D0=BB=D1=8F=20=D0=B3=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20=D0=B8=D0=B4=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B8=D1=84=D0=B8=D0=BA=D0=B0=D1=82=D0=BE=D1=80=D0=B0=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/base/CApplication.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/framework/base/CApplication.php b/framework/base/CApplication.php index 5d891bd5d4..78707a1d34 100644 --- a/framework/base/CApplication.php +++ b/framework/base/CApplication.php @@ -102,6 +102,10 @@ abstract class CApplication extends CModule * @var string the class used to get locale data. Defaults to 'CLocale'. */ public $localeClass='CLocale'; + /** + * @var string + */ + public $secret=''; private $_id; private $_basePath; @@ -160,6 +164,7 @@ public function __construct($config=null) $this->preinit(); + $this->initEnvironment(); $this->initSystemHandlers(); $this->registerCoreComponents(); @@ -234,7 +239,7 @@ public function getId() if($this->_id!==null) return $this->_id; else - return $this->_id=sprintf('%x',crc32($this->getBasePath().$this->name)); + return $this->_id=sprintf('%x',crc32($this->getBasePath().$this->name.$this->secret)); } /** @@ -954,6 +959,27 @@ public function displayException($exception) } } + protected function initEnvironment() + { + // Загрузка переменных окружения + if (false !== $environment = @parse_ini_file($this->getBasePath().DIRECTORY_SEPARATOR.'.env', INI_SCANNER_RAW)) { + foreach ($environment as $param => $value) { + // Если проект запущен под apache используя mod_php и переопределяет наше значение + if (true === function_exists('apache_setenv') && false !== apache_getenv($param)) { + apache_setenv($param, $param); + } + // Для FastCGI используется другой способ + if (true === function_exists('putenv')) { + putenv("{$param}={$value}"); + } + // Ну и для пущей уверенности + $_ENV[$param] = $value; + } + } else { + die('Опаньки! Отсутствует файл .env-файл. Подробности в README.md'); + } + } + /** * Initializes the error handlers. */