function _load_apps($checks = CHECK_ALL_UPDATES) { if (phpversion() > PHP_MIN_VERSION_UPDATES) { global $CONFIG; if ($checks & CHECK_KERNEL) { $this->apps[] = new Application('kernel', get_ulang(), APPLICATION_TYPE__KERNEL, phpboost_version(), PHPBOOST_OFFICIAL_REPOSITORY); } if ($checks & CHECK_MODULES) { global $MODULES; $kModules = array_keys($MODULES); foreach ($kModules as $module) { $infos = load_ini_file(PATH_TO_ROOT . '/' . $module . '/lang/', get_ulang()); $repository = !empty($infos['repository']) ? $infos['repository'] : PHPBOOST_OFFICIAL_REPOSITORY; if (!empty($infos['repository'])) { $this->apps[] = new Application($module, get_ulang(), APPLICATION_TYPE__MODULE, $infos['version'], $repository); } } } if ($checks & CHECK_THEMES) { global $THEME_CONFIG; $kThemes = array_keys($THEME_CONFIG); foreach ($kThemes as $theme) { $infos = get_ini_config(PATH_TO_ROOT . '/templates/' . $theme . '/config/', get_ulang()); if (!empty($infos['repository'])) { $this->apps[] = new Application($theme, get_ulang(), APPLICATION_TYPE__TEMPLATE, $infos['version'], $infos['repository']); } } } } }
function _get_installed_version() { global $CONFIG; switch ($this->type) { case APPLICATION_TYPE__KERNEL: return $CONFIG['version']; case APPLICATION_TYPE__MODULE: $infos = get_ini_config(PATH_TO_ROOT . '/' . $this->id . '/lang/', get_ulang()); return !empty($infos['version']) ? $infos['version'] : '0'; case APPLICATION_TYPE__THEME: $infos = get_ini_config(PATH_TO_ROOT . '/templates/' . $this->id . '/config/', get_ulang()); return !empty($infos['version']) ? $infos['version'] : '0'; default: return '0'; } }
function install_module($module_identifier, $enable_module = true, $generate_cache = GENERATE_CACHE_AFTER_THE_OPERATION) { global $Cache, $Sql, $CONFIG, $MODULES; if (empty($module_identifier) || !is_dir(PATH_TO_ROOT . '/' . $module_identifier)) { return UNEXISTING_MODULE; } $check_module = (int) $Sql->query("SELECT COUNT(*) FROM " . DB_TABLE_MODULES . " WHERE name = '" . strprotect($module_identifier) . "'", __LINE__, __FILE__); if ($check_module > 0) { return MODULE_ALREADY_INSTALLED; } $info_module = load_ini_file(PATH_TO_ROOT . '/' . $module_identifier . '/lang/', get_ulang()); if (empty($info_module)) { return UNEXISTING_MODULE; } if (!empty($info_module['php_version'])) { $phpversion = phpversion(); if (strpos(phpversion(), '-') !== FALSE) { $phpversion = substr($phpversion, 0, strpos(phpversion(), '-')); } if (version_compare($phpversion, $info_module['php_version'], 'lt')) { return PHP_VERSION_CONFLICT; } } $dir_db_module = get_ulang(); $dir = PATH_TO_ROOT . '/' . $module_identifier . '/db'; if (!is_dir($dir . '/' . $dir_db_module)) { import('io/filesystem/folder'); $db_scripts_folder = new Folder($dir); $existing_db_files = $db_scripts_folder->get_folders('`[a-z_-]+`i'); $dir_db_module = count($existing_db_files) > 0 ? $existing_db_files[0]->get_name() : ''; } $config = get_ini_config(PATH_TO_ROOT . '/' . $module_identifier . '/lang/', get_ulang()); if (!empty($config)) { $check_config = $Sql->query("SELECT COUNT(*) FROM " . DB_TABLE_CONFIGS . " WHERE name = '" . $module_identifier . "'", __LINE__, __FILE__); if (empty($check_config)) { $Sql->query_inject("INSERT INTO " . DB_TABLE_CONFIGS . " (name, value) VALUES ('" . $module_identifier . "', '" . addslashes($config) . "');", __LINE__, __FILE__); } else { return CONFIG_CONFLICT; } } $sql_file = PATH_TO_ROOT . '/' . $module_identifier . '/db/' . $dir_db_module . '/' . $module_identifier . '.' . DBTYPE . '.sql'; if (file_exists($sql_file)) { $Sql->parse($sql_file, PREFIX); } $module_identifier = strprotect($module_identifier); import('core/menu_service'); MenuService::add_mini_module($module_identifier); $Sql->query_inject("INSERT INTO " . DB_TABLE_MODULES . " (name, version, auth, activ) VALUES ('" . $module_identifier . "', '" . addslashes($info_module['version']) . "', 'a:4:{s:3:\"r-1\";i:1;s:2:\"r0\";i:1;s:2:\"r1\";i:1;s:2:\"r2\";i:1;}', '" . (int) $enable_module . "')", __LINE__, __FILE__); $php_file = PATH_TO_ROOT . '/' . $module_identifier . '/db/' . $dir_db_module . '/' . $module_identifier . '.php'; if (file_exists($php_file)) { if (!DEBUG) { @(include_once $php_file); } else { include_once $php_file; } } if ($generate_cache) { $Cache->Generate_file('modules'); $Cache->load('modules', RELOAD_CACHE); $Cache->Generate_file('css'); MenuService::generate_cache(); if ($CONFIG['rewrite'] == 1 && !empty($info_module['url_rewrite'])) { $Cache->Generate_file('htaccess'); } } $Cache->generate_module_file($module_identifier, NO_FATAL_ERROR_CACHE); return MODULE_INSTALLED; }