$license_data['limit']) { ui_print_warning_message( __( 'You cannot use update manager %s. You are exceding monitoring limits by %s elements. Please update your license or disable enterprise section by moving enterprise directory to another location and try again.', $mode_str, ($limit - $license_data['limit']) ) ); return; } if ($days_to_expiry < 0) { ui_print_warning_message( __( 'You cannot use update manager %s. This license has expired %d days ago. Please update your license or disable enterprise section by moving enterprise directory to another location and try again.', $mode_str, abs($days_to_expiry) ) ); return; } if (rtrim($license_data['licensed_to']) === Manager::PANDORA_TRIAL_ISSUER) { $product_name = get_product_name(); ui_print_info_message( __( 'You cannot use update manager %s. This license is a trial license to test all %s features. Please update your license to unlock all %s features.', $mode_str, $product_name, $product_name ) ); return; } } else { $license_data = []; $license_data['count_enabled'] = db_get_value( 'count(*)', 'tagente', 'disabled', 0 ); } // Set dbh. $dbh = (object) $config['dbconnection']; // Retrieve current definition. if ($dbh !== null) { $stm = $dbh->query( 'SELECT `value` FROM `tconfig` WHERE `token`="current_package"' ); if ($stm !== false) { $current_package = $stm->fetch_array(); if ($current_package !== null) { $current_package = $current_package[0]; } } if (empty($current_package) === true) { // If no current_package is present, use current_package_enterprise. $stm = $dbh->query( 'SELECT MAX(`value`) FROM `tconfig` WHERE `token`="current_package_enterprise"' ); if ($stm !== false) { $current_package = $stm->fetch_array(); if ($current_package !== null) { $current_package = $current_package[0]; } } } $mr = 0; $stm = $dbh->query( 'SELECT MAX(`value`) FROM `tconfig` WHERE `token`="MR" OR `token`="minor_release"' ); if ($stm !== false) { $mr = $stm->fetch_array(); if ($mr !== null) { $mr = $mr[0]; } } $puid = null; $stm = $dbh->query( 'SELECT `value` FROM `tconfig` WHERE `token`="pandora_uid"' ); if ($stm !== false) { $puid = $stm->fetch_array(); if ($puid !== null) { $puid = $puid[0]; } } } else { $current_package = 0; $mr = 0; $puid = null; } if (is_ajax() !== true) { ?> 0 ) { if ((float) $matches[1] !== floor((float) $current_package)) { ui_print_warning_message( __( 'Master server version %s does not match console version %s.', (float) $matches[1], $pandora_version ) ); } } } $PHPmemory_limit_min = config_return_in_bytes('800M'); $PHPmemory_limit = config_return_in_bytes(ini_get('memory_limit')); if ($PHPmemory_limit < $PHPmemory_limit_min && $PHPmemory_limit !== -1) { $msg = __( '\'%s\' recommended value is %s or greater. Please, change it on your PHP configuration file (php.ini) or contact with administrator', 'memory_limit', '800M' ); ui_print_warning_message($msg); } } // Load styles. ui_require_css_file('pandora', '/vendor/articapfms/update_manager_client/resources/styles/'); if (isset($mode) === false) { $mode = Manager::MODE_ONLINE; if (function_exists('get_parameter') === true) { $mode = (int) get_parameter('mode', null); } else { $mode = ($_REQUEST['mode'] ?? Manager::MODE_ONLINE); } } if (is_int($mode) === false) { switch ($mode) { case 'offline': $mode = Manager::MODE_OFFLINE; break; case 'register': $mode = Manager::MODE_REGISTER; break; case 'online': default: $mode = Manager::MODE_ONLINE; break; } } $dbhHistory = null; if (is_array($config) === true && (bool) $config['history_db_enabled'] === true ) { ob_start(); $dbhHistory = db_connect( $config['history_db_host'], $config['history_db_name'], $config['history_db_user'], io_output_password($config['history_db_pass']), $config['history_db_port'] ); ob_get_clean(); if ($dbhHistory === false) { $dbhHistory = null; } } $url_update_manager = null; $homedir = sys_get_temp_dir(); $dbconnection = null; $remote_config = null; $insecure = false; $pandora_url = ui_get_full_url('update_manager_client/', false, false, false); if (is_array($config) === true) { $allowOfflinePatches = false; if (isset($config['allow_offline_patches']) === true) { $allowOfflinePatches = (bool) $config['allow_offline_patches']; } if (isset($config['secure_update_manager']) === false) { $config['secure_update_manager'] = null; } if ($config['secure_update_manager'] === '' || $config['secure_update_manager'] === null ) { $insecure = false; } else { // Directive defined. $insecure = !$config['secure_update_manager']; } if ((bool) is_ajax() === false) { if ($mode === Manager::MODE_ONLINE && ($puid === null || $puid === 'OFFLINE') ) { ui_print_error_message(__('Update online requires registration.')); } if ($mode === Manager::MODE_OFFLINE) { ui_print_warning_message( __('Applying offline patches may make your console unusable, we recommend to completely backup your files before applying any patch.') ); } } $url_update_manager = $config['url_update_manager']; $homedir = $config['homedir']; $dbconnection = $config['dbconnection']; $remote_config = $config['remote_config']; if (is_metaconsole() === false) { // Node. if ((bool) $config['node_metaconsole'] === true) { $url_update_manager = $config['metaconsole_base_url']; $url_update_manager .= 'godmode/um_client/api.php'; } } else { // MC. $sc = new Synchronizer(); $url_meta_base = ui_get_full_url('/', false, false, false); $sc->apply( function ($node, $sync) use ($url_meta_base) { try { global $config; $sync->connect($node); $config['metaconsole_base_url'] = db_get_value( 'value', 'tconfig', 'token', 'metaconsole_base_url' ); if ($config['metaconsole_base_url'] === false) { // Unset to create new value if does not exist previously. $config['metaconsole_base_url'] = null; } config_update_value( 'metaconsole_base_url', $url_meta_base ); $sync->disconnect(); } catch (Exception $e) { ui_print_error_message( 'Cannot update node settings: ', $e->getMessage() ); } } ); } } $proxy = null; if (empty($config['update_manager_proxy_server']) === false || empty($config['update_manager_proxy_port']) === false || empty($config['update_manager_proxy_user']) === false || empty($config['update_manager_proxy_password']) === false ) { $proxy = [ 'host' => $config['update_manager_proxy_server'], 'port' => $config['update_manager_proxy_port'], 'user' => $config['update_manager_proxy_user'], 'password' => $config['update_manager_proxy_password'], ]; } $ui = new Manager( $pandora_url, ui_get_full_url('ajax.php'), 'godmode/um_client/index', [ 'lts' => (bool) $config['lts_updates'], 'url' => $url_update_manager, 'insecure' => $insecure, 'license' => $license, 'limit_count' => ((is_array($license_data) === true) ? $license_data['count_enabled'] : null), 'language' => $config['language'], 'timezone' => $config['timezone'], 'homedir' => $homedir, 'dbconnection' => $dbconnection, 'historydb' => $dbhHistory, 'current_package' => $current_package, 'MR' => $mr, 'registration_code' => $puid, 'remote_config' => $remote_config, 'propagate_updates' => is_metaconsole(), 'proxy' => $proxy, 'allowOfflinePatches' => $allowOfflinePatches, 'set_maintenance_mode' => function () { config_update_value('maintenance_mode', 1); }, 'clear_maintenance_mode' => function () { config_update_value('maintenance_mode', 0); }, 'on_update' => function ($version, $type) use ($mode) { register_upgrade($version, $type, $mode); }, ], $mode ); $ui->run();