Commit 36a0a5b4 authored by Patrick Schmalstig's avatar Patrick Schmalstig
Browse files

Add support for when homesite is using anti-leech

parent 9e3d75e2
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -668,6 +668,9 @@ class Module_admin_addons

        require_code('uploads');
        require_code('global4');
        require_code('telemetry');

        $homesite_session = get_brand_session(true);

        $url_map = ['page' => '_SELF', 'type' => 'multi_action'];

@@ -676,6 +679,9 @@ class Module_admin_addons
        foreach ($_urls as $i => $url) {
            if (is_numeric($url) || (looks_like_guid($url))) {
                $_POST['url'] = get_brand_base_url() . '/site/dload.php?id=' . strval($url);
                if ($homesite_session !== null) {
                    $_POST['url'] .= '&for_session=' . $homesite_session;
                }
            } else {
                $_POST['url'] = $url; // In case it was submitted in array form, which is possible on some UAs (based on an automated bug report)
            }
+10 −1
Original line number Diff line number Diff line
@@ -452,6 +452,7 @@ class Module_admin_setupwizard
    {
        require_code('addons2');
        require_lang('addons');
        require_code('telemetry');

        $post_url = build_url(['page' => '_SELF', 'type' => 'step5'], '_SELF');
        $text = do_lang_tempcode('SETUPWIZARD_4_DESCRIBE');
@@ -462,6 +463,8 @@ class Module_admin_setupwizard
        $_addons_not_installed = find_available_addons(false, false);
        $addons_not_installed = list_to_map('name', $_addons_not_installed);

        $homesite_session = get_brand_session(true);

        $fields = [];
        $fields_advanced = '';

@@ -616,9 +619,15 @@ class Module_admin_setupwizard
                $remote_addons = find_remote_addons();
                $_mentioned_addon = titleify($mentioned_addon);
                if (array_key_exists($_mentioned_addon, $remote_addons)) {
                    $id = $remote_addons[$_mentioned_addon];
                    require_code('uploads');

                    $id = $remote_addons[$_mentioned_addon];

                    $_POST['url'] = get_brand_base_url() . '/site/dload.php?id=' . strval($id);
                    if ($homesite_session !== null) {
                        $_POST['url'] .= '&for_session=' . $homesite_session;
                    }

                    get_url('url', 'file', 'imports/addons', OBFUSCATE_NEVER, CMS_UPLOAD_ANYTHING, false, '', '', true); // Download it
                }
            }
+9 −1
Original line number Diff line number Diff line
@@ -78,6 +78,10 @@ class Hook_ajax_tree_choose_homesite_addon
     */
    public function simple(?string $id, array $options, ?string $it = null, string $prefix = '') : object
    {
        require_code('telemetry');

        $homesite_session = get_brand_session(true);

        $file = $this->get_file($id, $it);

        $it_exp = ($it === null) ? [] : explode(',', $it);
@@ -88,7 +92,11 @@ class Hook_ajax_tree_choose_homesite_addon

        $num_matches = preg_match_all('#<entry id="([0-9]+)" serverid="([0-9a-fA-F\-]+)"[^<>]* title="([^"]+)"#', $file, $matches);
        for ($i = 0; $i < $num_matches; $i++) {
            $list->attach(form_input_list_entry(get_brand_base_url() . '/site/dload.php?id=' . urlencode($matches[2][$i]), in_array($matches[2][$i], $it_exp), $prefix . $matches[3][$i]));
            $url = get_brand_base_url() . '/site/dload.php?id=' . urlencode($matches[2][$i]);
            if ($homesite_session !== null) {
                $url .= '&for_session=' . urlencode($homesite_session);
            }
            $list->attach(form_input_list_entry($url, in_array($matches[2][$i], $it_exp), $prefix . $matches[3][$i]));
        }

        $num_matches = preg_match_all('#<category id="(\d+)" title="([^"]+)"#', $file, $matches);