diff --git a/bootstrap/secure.php b/bootstrap/secure.php index a8baf09..b57765e 100644 --- a/bootstrap/secure.php +++ b/bootstrap/secure.php @@ -1,7 +1,7 @@ 'email_code', // login_password, email_code + 'web_auth_type' => 'login_password', // login_password, email_code 'token_type' => 'hash', // random_bytes, md5, crypt, hash, JWT 'token_expired_time' => "+30 days", // +1 day ]; diff --git a/kernel/console/controllers/KernelController.php b/kernel/console/controllers/KernelController.php index 13efa75..e6a3a2a 100644 --- a/kernel/console/controllers/KernelController.php +++ b/kernel/console/controllers/KernelController.php @@ -27,7 +27,7 @@ class KernelController extends ConsoleController if (file_exists(ROOT_DIR . $this->argv['path'])) { $tmpKernelDirFull = RESOURCES_DIR . '/tmp/ad/kernel/kernel'; - $this->files->copy_folder(ROOT_DIR . $this->argv['path'], $tmpKernelDirFull); + $this->files->copyKernelFolder(ROOT_DIR . $this->argv['path'], $tmpKernelDirFull); $this->out->r("Ядро скопировано во временную папку", 'green'); } else { $this->out->r("Ядро не найдено", 'red'); @@ -35,7 +35,7 @@ class KernelController extends ConsoleController if (file_exists(ROOT_DIR . '/bootstrap')) { $tmpBootstrapDirFull = RESOURCES_DIR . '/tmp/ad/kernel/bootstrap'; - $this->files->copy_folder(ROOT_DIR . '/bootstrap', $tmpBootstrapDirFull); + $this->files->copyKernelFolder(ROOT_DIR . '/bootstrap', $tmpBootstrapDirFull); $this->out->r("/bootstrap скопирован во временную папку", 'green'); } else { $this->out->r("/bootstrap не найден", 'red'); @@ -99,11 +99,11 @@ class KernelController extends ConsoleController $zip->extractTo($tmpKernelDirFull); $zip->close(); $this->files->recursiveRemoveKernelDir(); - $this->files->copy_folder($tmpKernelDirFull . 'kernel' , ROOT_DIR . "/kernel"); + $this->files->copyKernelFolder($tmpKernelDirFull . 'kernel' , ROOT_DIR . "/kernel"); if (isset($this->argv['bootstrap'])) { $this->files->recursiveRemoveDir(ROOT_DIR . '/bootstrap'); - $this->files->copy_folder($tmpKernelDirFull . 'bootstrap' , ROOT_DIR . '/bootstrap'); + $this->files->copyKernelFolder($tmpKernelDirFull . 'bootstrap' , ROOT_DIR . '/bootstrap'); copy($tmpKernelDirFull . '/bootstrap.php' , ROOT_DIR . '/bootstrap.php'); } diff --git a/kernel/helpers/Files.php b/kernel/helpers/Files.php index e05a3a1..5f6daf7 100644 --- a/kernel/helpers/Files.php +++ b/kernel/helpers/Files.php @@ -7,11 +7,33 @@ use ZipArchive; class Files { - public function copy_folder($d1, $d2): void + public function copy_folder($d1, $d2, int $permissions = 0774, bool $recursive = true): void { if (is_dir($d1)) { if (!file_exists($d2)){ - $_d2 = mkdir($d2, permissions: 0774, recursive: true); + $_d2 = mkdir($d2, permissions: $permissions, recursive: $recursive); + if (!$_d2) { + return; + } + } + + $d = dir($d1); + while (false !== ($entry = $d->read())) { + if ($entry != '.' && $entry != '..') { + $this->copy_folder("$d1/$entry", "$d2/$entry"); + } + } + $d->close(); + } else { + copy($d1, $d2); + } + } + + public function copyKernelFolder($d1, $d2, int $permissions = 0774, bool $recursive = true): void + { + if (is_dir($d1)) { + if (!file_exists($d2)){ + $_d2 = mkdir($d2, permissions: $permissions, recursive: $recursive); if (!$_d2) { return; } @@ -20,7 +42,7 @@ class Files $d = dir($d1); while (false !== ($entry = $d->read())) { if ($entry != '.' && $entry != '..' && $entry != 'app_modules') { - $this->copy_folder("$d1/$entry", "$d2/$entry"); + $this->copyKernelFolder("$d1/$entry", "$d2/$entry"); } } $d->close(); diff --git a/kernel/helpers/Version.php b/kernel/helpers/Version.php new file mode 100644 index 0000000..3380436 --- /dev/null +++ b/kernel/helpers/Version.php @@ -0,0 +1,16 @@ + intval($version) * 100, + 2 => intval($version) * 10, + 3 => intval($version), + }; + } +} \ No newline at end of file diff --git a/kernel/services/KernelService.php b/kernel/services/KernelService.php index 3caf8ec..2eebee9 100644 --- a/kernel/services/KernelService.php +++ b/kernel/services/KernelService.php @@ -6,6 +6,7 @@ use kernel\helpers\Debug; use kernel\helpers\Files; use kernel\helpers\Manifest; use kernel\helpers\RESTClient; +use kernel\helpers\Version; use kernel\Request; use ZipArchive; @@ -42,8 +43,12 @@ class KernelService $modules_info = json_decode($modules_info->getBody()->getContents(), true); $kernel_info = $this->getKernelInfo(); + + $kernelVersion = Version::getIntVersionByString($kernel_info['version']); + foreach ($modules_info as $mod) { - if ($mod['slug'] === $kernel_info['slug'] && $mod['version'] === $kernel_info['version']) { + $modVersion = Version::getIntVersionByString($mod['version']); + if ($mod['slug'] === $kernel_info['slug'] && $modVersion <= $kernelVersion) { return true; } } @@ -66,12 +71,12 @@ class KernelService $zip->extractTo($tmpKernelDirFull); $zip->close(); $this->files->recursiveRemoveKernelDir(); - $this->files->copy_folder($tmpKernelDirFull . 'kernel' , ROOT_DIR . "/kernel"); + $this->files->copyKernelFolder($tmpKernelDirFull . 'kernel' , ROOT_DIR . "/kernel"); foreach ($files as $file) { if ($file === 'bootstrap') { $this->files->recursiveRemoveDir(ROOT_DIR . '/bootstrap'); - $this->files->copy_folder($tmpKernelDirFull . 'bootstrap' , ROOT_DIR . '/bootstrap'); + $this->files->copyKernelFolder($tmpKernelDirFull . 'bootstrap' , ROOT_DIR . '/bootstrap'); } copy($tmpKernelDirFull . $file , ROOT_DIR . '/' . $file); } diff --git a/kernel/services/ModuleService.php b/kernel/services/ModuleService.php index 7beb721..3d769fa 100644 --- a/kernel/services/ModuleService.php +++ b/kernel/services/ModuleService.php @@ -9,6 +9,7 @@ use kernel\helpers\Debug; use kernel\helpers\Files; use kernel\helpers\Manifest; use kernel\helpers\RESTClient; +use kernel\helpers\Version; use kernel\models\Option; use ZipArchive; @@ -449,8 +450,11 @@ class ModuleService $modules_info = json_decode($modules_info->getBody()->getContents(), true); $mod_info = $this->getModuleInfoBySlug($slug); + + $currentVersion = Version::getIntVersionByString($mod_info['version']); foreach ($modules_info as $mod) { - if ($mod['slug'] === $mod_info['slug'] && $mod['version'] === $mod_info['version']) { + $modVersion = Version::getIntVersionByString($mod['version']); + if ($mod['slug'] === $mod_info['slug'] && $modVersion <= $currentVersion) { return true; } }