diff --git a/~dev_rating/deploy.php b/~dev_rating/deploy.php index e712f596e18a49a9536f447954d349877e30b1a5..10cffd60e071830ec4f4804648c952b2c56f0f33 100644 --- a/~dev_rating/deploy.php +++ b/~dev_rating/deploy.php @@ -1,20 +1,20 @@ <?php defined('SYSPATH') OR die('No direct access allowed.'); -if (!is_dir(APPPATH . 'config')) { - mkdir(APPPATH . 'config'); +$config = 'config/'; - $arr = ['database.php', 'security.php', 'twig.php', 'session.php', 'general.json']; +$dirs = [$config, 'logs/', 'cache/', 'cache/twig/']; - foreach ($arr as $name) { - if (!copy(CFGPATH . $name, APPPATH . 'config/' . $name)) - echo 'Беда!'; - } +foreach ($dirs as $dir) { + if (!file_exists(APPPATH . $dir)) + mkdir(APPPATH . $dir); } -if (!is_dir(APPPATH . 'logs/')) - mkdir(APPPATH . 'logs'); +$files = ['database.php', 'security.php', 'twig.php', 'session.php', 'general.json']; -if (!is_dir(APPPATH . 'cache/')) { - mkdir(APPPATH . 'cache'); - mkdir(APPPATH . 'cache/twig'); -} \ No newline at end of file +foreach ($files as $name) { + if (!file_exists(APPPATH . $config . $name)) + if (!copy(CFGPATH . $name, APPPATH . $config . $name)) + Log::instance()->add(Log::CRITICAL, "Cannot copy `$name` file to config!"); +} + +unset($config, $dirs, $dir, $files, $name); \ No newline at end of file