Exemplo n.º 1
0
function PackageGBrowse()
{
    global $txt, $boardurl, $context, $scripturl, $boarddir, $sourcedir, $forum_version, $context, $db_prefix;
    if (isset($_GET['server'])) {
        if ($_GET['server'] == '') {
            redirectexit('action=packageget');
        }
        $server = (int) $_GET['server'];
        // Query the server list to find the current server.
        $request = db_query("\n\t\t\tSELECT name, url\n\t\t\tFROM {$db_prefix}package_servers\n\t\t\tWHERE ID_SERVER = {$server}\n\t\t\tLIMIT 1", __FILE__, __LINE__);
        list($name, $url) = mysql_fetch_row($request);
        mysql_free_result($request);
        // If the server does not exist, dump out.
        if (empty($url)) {
            fatal_lang_error('smf191', false);
        }
        // If there is a relative link, append to the stored server url.
        if (isset($_GET['relative'])) {
            $url = $url . (substr($url, -1) == '/' ? '' : '/') . $_GET['relative'];
        }
        // Clear any "absolute" URL.  Since "server" is present, "absolute" is garbage.
        unset($_GET['absolute']);
    } elseif (isset($_GET['absolute']) && $_GET['absolute'] != '') {
        // Initialize the requried variables.
        $server = '';
        $url = $_GET['absolute'];
        $name = '';
        $_GET['package'] = $url . '/packages.xml?language=' . $context['user']['language'];
        // Clear any "relative" URL.  Since "server" is not present, "relative" is garbage.
        unset($_GET['relative']);
        $token = checkConfirm('get_absolute_url');
        if ($token !== true) {
            $context['sub_template'] = 'package_confirm';
            $context['page_title'] = $txt['smf183'];
            $context['confirm_message'] = sprintf($txt['package_confirm_view_package_content'], htmlspecialchars($_GET['absolute']));
            $context['proceed_href'] = $scripturl . '?action=packageget;sa=browse;absolute=' . urlencode($_GET['absolute']) . ';confirm=' . $token;
            return;
        }
    } else {
        fatal_lang_error('smf191', false);
    }
    // In safe mode or on lycos?  Try this URL. (includes package-list for informational purposes ;).)
    //if (@ini_get('safe_mode'))
    //	redirectexit($url . '/index.php?package-list&language=' . $context['user']['language'] . '&ref=' . $boardurl);
    // Attempt to connect.  If unsuccessful... try the URL.
    if (!isset($_GET['package']) || file_exists($_GET['package'])) {
        $_GET['package'] = $url . '/packages.xml?language=' . $context['user']['language'];
    }
    // Check to be sure the packages.xml file actually exists where it is should be... or dump out.
    if ((isset($_GET['absolute']) || isset($_GET['relative'])) && !url_exists($_GET['package'])) {
        fatal_lang_error('packageget_unable', false, array($url . '/index.php'));
    }
    // Read packages.xml and parse into xmlArray. (the true tells it to trim things ;).)
    $listing = new xmlArray(fetch_web_data($_GET['package']), true);
    // Errm.... empty file?  Try the URL....
    if (!$listing->exists('package-list')) {
        fatal_lang_error('packageget_unable', false, array($url . '/index.php'));
    }
    // List out the packages...
    $context['package_list'] = array();
    $listing = $listing->path('package-list[0]');
    // Use the package list's name if it exists.
    if ($listing->exists('list-title')) {
        $name = $listing->fetch('list-title');
    }
    // Pick the correct template.
    $context['sub_template'] = 'package_list';
    $context['page_title'] = $txt['smf183'] . ($name != '' ? ' - ' . $name : '');
    $context['package_server'] = $server;
    $instmods = loadInstalledPackages();
    // Look through the list of installed mods...
    foreach ($instmods as $installed_mod) {
        $installed_mods[$installed_mod['id']] = $installed_mod['version'];
    }
    // Get default author and email if they exist.
    if ($listing->exists('default-author')) {
        $default_author = htmlspecialchars($listing->fetch('default-author'));
        if ($listing->exists('default-author/@email')) {
            $default_email = $listing->fetch('default-author/@email');
        }
    }
    // Get default web site if it exists.
    if ($listing->exists('default-website')) {
        $default_website = $listing->fetch('default-website');
        if ($listing->exists('default-website/@title')) {
            $default_title = htmlspecialchars($listing->fetch('default-website/@title'));
        }
    }
    $the_version = strtr($forum_version, array('SMF ' => ''));
    if (!empty($_SESSION['version_emulate'])) {
        $the_version = $_SESSION['version_emulate'];
    }
    $packageNum = 0;
    $sections = $listing->set('section');
    foreach ($sections as $i => $section) {
        $packages = $section->set('title|heading|text|remote|rule|modification|language|avatar-pack|theme|smiley-set');
        foreach ($packages as $thisPackage) {
            $package =& $context['package_list'][];
            $package['type'] = $thisPackage->name();
            // It's a Title, Heading, Rule or Text.
            if (in_array($package['type'], array('title', 'heading', 'text', 'rule'))) {
                $package['name'] = htmlspecialchars($thisPackage->fetch('.'));
            } elseif ($package['type'] == 'remote') {
                $remote_type = $thisPackage->exists('@type') ? $thisPackage->fetch('@type') : 'relative';
                if ($remote_type == 'relative' && substr($thisPackage->fetch('@href'), 0, 7) != 'http://') {
                    if (isset($_GET['absolute'])) {
                        $current_url = $_GET['absolute'] . '/';
                    } elseif (isset($_GET['relative'])) {
                        $current_url = $_GET['relative'] . '/';
                    } else {
                        $current_url = '';
                    }
                    $current_url .= $thisPackage->fetch('@href');
                    if (isset($_GET['absolute'])) {
                        $package['href'] = $scripturl . '?action=packageget;sa=browse;absolute=' . $current_url;
                    } else {
                        $package['href'] = $scripturl . '?action=packageget;sa=browse;server=' . $context['package_server'] . ';relative=' . $current_url;
                    }
                } else {
                    $current_url = $thisPackage->fetch('@href');
                    $package['href'] = $scripturl . '?action=packageget;sa=browse;absolute=' . $current_url;
                }
                $package['name'] = htmlspecialchars($thisPackage->fetch('.'));
                $package['link'] = '<a href="' . $package['href'] . '">' . $package['name'] . '</a>';
            } else {
                if (isset($_GET['absolute'])) {
                    $current_url = $_GET['absolute'] . '/';
                } elseif (isset($_GET['relative'])) {
                    $current_url = $_GET['relative'] . '/';
                } else {
                    $current_url = '';
                }
                $server_att = $server != '' ? ';server=' . $server : '';
                $package += $thisPackage->to_array();
                if (isset($package['website'])) {
                    unset($package['website']);
                }
                $package['author'] = array();
                if ($package['description'] == '') {
                    $package['description'] = $txt['pacman8'];
                } else {
                    $package['description'] = parse_bbc(preg_replace('~\\[[/]?html\\]~i', '', htmlspecialchars($package['description'])));
                }
                $package['is_installed'] = isset($installed_mods[$package['id']]);
                $package['is_current'] = $package['is_installed'] && $installed_mods[$package['id']] == $package['version'];
                $package['is_newer'] = $package['is_installed'] && $installed_mods[$package['id']] > $package['version'];
                // This package is either not installed, or installed but old.  Is it supported on this version of SMF?
                if (!$package['is_installed'] || !$package['is_current'] && !$package['is_newer']) {
                    if ($thisPackage->exists('version/@for')) {
                        $package['can_install'] = matchPackageVersion($the_version, $thisPackage->fetch('version/@for'));
                    }
                } else {
                    $package['can_install'] = false;
                }
                $already_exists = getPackageInfo(basename($package['filename']));
                $package['download_conflict'] = !empty($already_exists) && $already_exists['id'] == $package['id'] && $already_exists['version'] != $package['version'];
                $package['href'] = $url . '/' . $package['filename'];
                $package['name'] = htmlspecialchars($package['name']);
                $package['link'] = '<a href="' . $package['href'] . '">' . $package['name'] . '</a>';
                $package['download']['href'] = $scripturl . '?action=packageget;sa=download' . $server_att . ';package=' . $current_url . $package['filename'] . ($package['download_conflict'] ? ';conflict' : '') . ';sesc=' . $context['session_id'];
                $package['download']['link'] = '<a href="' . $package['download']['href'] . '">' . $package['name'] . '</a>';
                if ($thisPackage->exists('author') || isset($default_author)) {
                    if ($thisPackage->exists('author/@email')) {
                        $package['author']['email'] = htmlspecialchars($thisPackage->fetch('author/@email'));
                    } elseif (isset($default_email)) {
                        $package['author']['email'] = $default_email;
                    }
                    if ($thisPackage->exists('author') && $thisPackage->fetch('author') != '') {
                        $package['author']['name'] = htmlspecialchars($thisPackage->fetch('author'));
                    } else {
                        $package['author']['name'] = $default_author;
                    }
                    if (!empty($package['author']['email'])) {
                        // Only put the "mailto:" if it looks like a valid email address.  Some may wish to put a link to an SMF IM Form or other web mail form.
                        $package['author']['href'] = preg_match('~^[\\w\\.\\-]+@[\\w][\\w\\-\\.]+[\\w]$~', $package['author']['email']) != 0 ? 'mailto:' . $package['author']['email'] : $package['author']['email'];
                        $package['author']['link'] = '<a href="' . $package['author']['href'] . '">' . $package['author']['name'] . '</a>';
                    }
                }
                if ($thisPackage->exists('website') || isset($default_website)) {
                    if ($thisPackage->exists('website') && $thisPackage->exists('website/@title')) {
                        $package['author']['website']['name'] = htmlspecialchars($thisPackage->fetch('website/@title'));
                    } elseif (isset($default_title)) {
                        $package['author']['website']['name'] = $default_title;
                    } elseif ($thisPackage->exists('website')) {
                        $package['author']['website']['name'] = htmlspecialchars($thisPackage->fetch('website'));
                    } else {
                        $package['author']['website']['name'] = $default_website;
                    }
                    if ($thisPackage->exists('website') && $thisPackage->fetch('website') != '') {
                        $authorhompage = $thisPackage->fetch('website');
                    } else {
                        $authorhompage = $default_website;
                    }
                    if (strpos(strtolower($authorhompage), 'a href') === false) {
                        $package['author']['website']['href'] = $authorhompage;
                        $package['author']['website']['link'] = '<a href="' . $authorhompage . '">' . $package['author']['website']['name'] . '</a>';
                    } else {
                        if (preg_match('/a href="(.+?)"/', $authorhompage, $match) == 1) {
                            $package['author']['website']['href'] = $match[1];
                        } else {
                            $package['author']['website']['href'] = '';
                        }
                        $package['author']['website']['link'] = $authorhompage;
                    }
                } else {
                    $package['author']['website']['href'] = '';
                    $package['author']['website']['link'] = '';
                }
            }
            $package['is_remote'] = $package['type'] == 'remote';
            $package['is_title'] = $package['type'] == 'title';
            $package['is_heading'] = $package['type'] == 'heading';
            $package['is_text'] = $package['type'] == 'text';
            $package['is_line'] = $package['type'] == 'rule';
            $packageNum = in_array($package['type'], array('title', 'heading', 'text', 'remote', 'rule')) ? 0 : $packageNum + 1;
            $package['count'] = $packageNum;
        }
    }
    // Lets make sure we get a nice new spiffy clean $package to work with.  Otherwise we get PAIN!
    unset($package);
    foreach ($context['package_list'] as $i => $package) {
        if ($package['count'] == 0 || isset($package['can_install'])) {
            continue;
        }
        $context['package_list'][$i]['can_install'] = false;
        $packageInfo = getPackageInfo($url . '/' . $package['filename']);
        if (!empty($packageInfo) && $packageInfo['xml']->exists('install')) {
            $installs = $packageInfo['xml']->set('install');
            foreach ($installs as $install) {
                if (!$install->exists('@for') || matchPackageVersion($the_version, $install->fetch('@for'))) {
                    // Okay, this one is good to go.
                    $context['package_list'][$i]['can_install'] = true;
                    break;
                }
            }
        }
    }
}
 /**
  * Browse a server's list of packages.
  *
  * - Accessed by action=admin;area=packageservers;sa=browse
  */
 public function action_browse()
 {
     global $txt, $scripturl, $forum_version, $context;
     // Load our subs worker.
     require_once SUBSDIR . '/PackageServers.subs.php';
     // Browsing the packages from a server
     if (isset($_GET['server'])) {
         if ($_GET['server'] == '') {
             redirectexit('action=admin;area=packageservers');
         }
         $server = (int) $_GET['server'];
         // Query the server list to find the current server.
         $packageserver = fetchPackageServers($server);
         $url = $packageserver[0]['url'];
         $name = $packageserver[0]['name'];
         // If the server does not exist, dump out.
         if (empty($url)) {
             fatal_lang_error('couldnt_connect', false);
         }
         // If there is a relative link, append to the stored server url.
         if (isset($_GET['relative'])) {
             $url = $url . (substr($url, -1) == '/' ? '' : '/') . $_GET['relative'];
         }
         // Clear any "absolute" URL.  Since "server" is present, "absolute" is garbage.
         unset($_GET['absolute']);
     } elseif (isset($_GET['absolute']) && $_GET['absolute'] != '') {
         // Initialize the required variables.
         $server = '';
         $url = $_GET['absolute'];
         $name = '';
         $_GET['package'] = $url . '/packages.xml?language=' . $context['user']['language'];
         // Clear any "relative" URL.  Since "server" is not present, "relative" is garbage.
         unset($_GET['relative']);
         $token = checkConfirm('get_absolute_url');
         if ($token !== true) {
             $context['sub_template'] = 'package_confirm';
             $context['page_title'] = $txt['package_servers'];
             $context['confirm_message'] = sprintf($txt['package_confirm_view_package_content'], htmlspecialchars($_GET['absolute'], ENT_COMPAT, 'UTF-8'));
             $context['proceed_href'] = $scripturl . '?action=admin;area=packageservers;sa=browse;absolute=' . urlencode($_GET['absolute']) . ';confirm=' . $token;
             return;
         }
     } else {
         fatal_lang_error('couldnt_connect', false);
     }
     // Attempt to connect.  If unsuccessful... try the URL.
     if (!isset($_GET['package']) || file_exists($_GET['package'])) {
         $_GET['package'] = $url . '/packages.xml?language=' . $context['user']['language'];
     }
     // Check to be sure the packages.xml file actually exists where it is should be... or dump out.
     if ((isset($_GET['absolute']) || isset($_GET['relative'])) && !url_exists($_GET['package'])) {
         fatal_lang_error('packageget_unable', false, array($url . '/index.php'));
     }
     // Might take some time.
     @set_time_limit(600);
     // Read packages.xml and parse into Xml_Array. (the true tells it to trim things ;).)
     require_once SUBSDIR . '/XmlArray.class.php';
     $listing = new Xml_Array(fetch_web_data($_GET['package']), true);
     // Errm.... empty file?  Try the URL....
     if (!$listing->exists('package-list')) {
         fatal_lang_error('packageget_unable', false, array($url . '/index.php'));
     }
     // List out the packages...
     $context['package_list'] = array();
     $listing = $listing->path('package-list[0]');
     // Use the package list's name if it exists.
     if ($listing->exists('list-title')) {
         $name = Util::htmlspecialchars($listing->fetch('list-title'));
     }
     // Pick the correct template.
     $context['sub_template'] = 'package_list';
     $context['page_title'] = $txt['package_servers'] . ($name != '' ? ' - ' . $name : '');
     $context['package_server'] = $server;
     // By default we use an unordered list, unless there are no lists with more than one package.
     $context['list_type'] = 'ul';
     // Load the installed packages
     // We'll figure out if what they select a package they already have installed.
     $instadds = loadInstalledPackages();
     // Look through the list of installed mods...
     $installed_adds = array();
     foreach ($instadds as $installed_add) {
         $installed_adds[$installed_add['package_id']] = $installed_add['version'];
     }
     // Get default author and email if they exist.
     if ($listing->exists('default-author')) {
         $default_author = Util::htmlspecialchars($listing->fetch('default-author'));
         if ($listing->exists('default-author/@email')) {
             $default_email = Util::htmlspecialchars($listing->fetch('default-author/@email'));
         }
     }
     // Get default web site if it exists.
     if ($listing->exists('default-website')) {
         $default_website = Util::htmlspecialchars($listing->fetch('default-website'));
         if ($listing->exists('default-website/@title')) {
             $default_title = Util::htmlspecialchars($listing->fetch('default-website/@title'));
         }
     }
     $the_version = strtr($forum_version, array('ElkArte ' => ''));
     if (!empty($_SESSION['version_emulate'])) {
         $the_version = $_SESSION['version_emulate'];
     }
     $packageNum = 0;
     $packageSection = 0;
     $sections = $listing->set('section');
     foreach ($sections as $i => $section) {
         $context['package_list'][$packageSection] = array('title' => '', 'text' => '', 'items' => array());
         $packages = $section->set('title|heading|text|remote|rule|modification|language|avatar-pack|theme|smiley-set');
         foreach ($packages as $thisPackage) {
             $package = array('type' => $thisPackage->name());
             if (in_array($package['type'], array('title', 'text'))) {
                 $context['package_list'][$packageSection][$package['type']] = Util::htmlspecialchars($thisPackage->fetch('.'));
             } elseif (in_array($package['type'], array('heading', 'rule'))) {
                 $package['name'] = Util::htmlspecialchars($thisPackage->fetch('.'));
             } elseif ($package['type'] == 'remote') {
                 $remote_type = $thisPackage->exists('@type') ? $thisPackage->fetch('@type') : 'relative';
                 if ($remote_type == 'relative' && (substr($thisPackage->fetch('@href'), 0, 7) !== 'http://' || substr($thisPackage->fetch('@href'), 0, 8) !== 'https://')) {
                     if (isset($_GET['absolute'])) {
                         $current_url = $_GET['absolute'] . '/';
                     } elseif (isset($_GET['relative'])) {
                         $current_url = $_GET['relative'] . '/';
                     } else {
                         $current_url = '';
                     }
                     $current_url .= $thisPackage->fetch('@href');
                     if (isset($_GET['absolute'])) {
                         $package['href'] = $scripturl . '?action=admin;area=packageservers;sa=browse;absolute=' . $current_url;
                     } else {
                         $package['href'] = $scripturl . '?action=admin;area=packageservers;sa=browse;server=' . $context['package_server'] . ';relative=' . $current_url;
                     }
                 } else {
                     $current_url = $thisPackage->fetch('@href');
                     $package['href'] = $scripturl . '?action=admin;area=packageservers;sa=browse;absolute=' . $current_url;
                 }
                 $package['name'] = Util::htmlspecialchars($thisPackage->fetch('.'));
                 $package['link'] = '<a href="' . $package['href'] . '">' . $package['name'] . '</a>';
             } else {
                 if (isset($_GET['absolute'])) {
                     $current_url = $_GET['absolute'] . '/';
                 } elseif (isset($_GET['relative'])) {
                     $current_url = $_GET['relative'] . '/';
                 } else {
                     $current_url = '';
                 }
                 $server_att = $server != '' ? ';server=' . $server : '';
                 $package += $thisPackage->to_array();
                 if (isset($package['website'])) {
                     unset($package['website']);
                 }
                 $package['author'] = array();
                 if ($package['description'] == '') {
                     $package['description'] = $txt['package_no_description'];
                 } else {
                     $package['description'] = parse_bbc(preg_replace('~\\[[/]?html\\]~i', '', Util::htmlspecialchars($package['description'])));
                 }
                 $package['is_installed'] = isset($installed_adds[$package['id']]);
                 $package['is_current'] = $package['is_installed'] && $installed_adds[$package['id']] == $package['version'];
                 $package['is_newer'] = $package['is_installed'] && $installed_adds[$package['id']] > $package['version'];
                 // This package is either not installed, or installed but old.  Is it supported on this version?
                 if (!$package['is_installed'] || !$package['is_current'] && !$package['is_newer']) {
                     if ($thisPackage->exists('version/@for')) {
                         $package['can_install'] = matchPackageVersion($the_version, $thisPackage->fetch('version/@for'));
                     }
                 } else {
                     $package['can_install'] = false;
                 }
                 $already_exists = getPackageInfo(basename($package['filename']));
                 $package['download_conflict'] = is_array($already_exists) && $already_exists['id'] == $package['id'] && $already_exists['version'] != $package['version'];
                 $package['href'] = $url . '/' . $package['filename'];
                 $package['name'] = Util::htmlspecialchars($package['name']);
                 $package['link'] = '<a href="' . $package['href'] . '">' . $package['name'] . '</a>';
                 $package['download']['href'] = $scripturl . '?action=admin;area=packageservers;sa=download' . $server_att . ';package=' . $current_url . $package['filename'] . ($package['download_conflict'] ? ';conflict' : '') . ';' . $context['session_var'] . '=' . $context['session_id'];
                 $package['download']['link'] = '<a href="' . $package['download']['href'] . '">' . $package['name'] . '</a>';
                 // Author name, email
                 if ($thisPackage->exists('author') || isset($default_author)) {
                     if ($thisPackage->exists('author/@email')) {
                         $package['author']['email'] = $thisPackage->fetch('author/@email');
                     } elseif (isset($default_email)) {
                         $package['author']['email'] = $default_email;
                     }
                     if ($thisPackage->exists('author') && $thisPackage->fetch('author') != '') {
                         $package['author']['name'] = Util::htmlspecialchars($thisPackage->fetch('author'));
                     } else {
                         $package['author']['name'] = $default_author;
                     }
                     if (!empty($package['author']['email'])) {
                         // Only put the "mailto:" if it looks like a valid email address.  Some may wish to put a link to an IM Form or other web mail form.
                         $package['author']['href'] = preg_match('~^[\\w\\.\\-]+@[\\w][\\w\\-\\.]+[\\w]$~', $package['author']['email']) != 0 ? 'mailto:' . $package['author']['email'] : $package['author']['email'];
                         $package['author']['link'] = '<a href="' . $package['author']['href'] . '">' . $package['author']['name'] . '</a>';
                     }
                 }
                 // Author website
                 if ($thisPackage->exists('website') || isset($default_website)) {
                     if ($thisPackage->exists('website') && $thisPackage->exists('website/@title')) {
                         $package['author']['website']['name'] = Util::htmlspecialchars($thisPackage->fetch('website/@title'));
                     } elseif (isset($default_title)) {
                         $package['author']['website']['name'] = $default_title;
                     } elseif ($thisPackage->exists('website')) {
                         $package['author']['website']['name'] = Util::htmlspecialchars($thisPackage->fetch('website'));
                     } else {
                         $package['author']['website']['name'] = $default_website;
                     }
                     if ($thisPackage->exists('website') && $thisPackage->fetch('website') != '') {
                         $authorhomepage = Util::htmlspecialchars($thisPackage->fetch('website'));
                     } else {
                         $authorhomepage = $default_website;
                     }
                     if (stripos($authorhomepage, 'a href') === false) {
                         $package['author']['website']['href'] = $authorhomepage;
                         $package['author']['website']['link'] = '<a href="' . $authorhomepage . '">' . $package['author']['website']['name'] . '</a>';
                     } else {
                         if (preg_match('/a href="(.+?)"/', $authorhomepage, $match) == 1) {
                             $package['author']['website']['href'] = $match[1];
                         } else {
                             $package['author']['website']['href'] = '';
                         }
                         $package['author']['website']['link'] = $authorhomepage;
                     }
                 } else {
                     $package['author']['website']['href'] = '';
                     $package['author']['website']['link'] = '';
                 }
             }
             $package['is_remote'] = $package['type'] == 'remote';
             $package['is_title'] = $package['type'] == 'title';
             $package['is_heading'] = $package['type'] == 'heading';
             $package['is_text'] = $package['type'] == 'text';
             $package['is_line'] = $package['type'] == 'rule';
             $packageNum = in_array($package['type'], array('title', 'heading', 'text', 'remote', 'rule')) ? 0 : $packageNum + 1;
             $package['count'] = $packageNum;
             if (!in_array($package['type'], array('title', 'text'))) {
                 $context['package_list'][$packageSection]['items'][] = $package;
             }
             if ($package['count'] > 1) {
                 $context['list_type'] = 'ol';
             }
         }
         $packageSection++;
     }
     // Lets make sure we get a nice new spiffy clean $package to work with.  Otherwise we get PAIN!
     unset($package);
     foreach ($context['package_list'] as $ps_id => $packageSection) {
         foreach ($packageSection['items'] as $i => $package) {
             if ($package['count'] == 0 || isset($package['can_install'])) {
                 continue;
             }
             $context['package_list'][$ps_id]['items'][$i]['can_install'] = false;
             $packageInfo = getPackageInfo($url . '/' . $package['filename']);
             if (is_array($packageInfo) && $packageInfo['xml']->exists('install')) {
                 $installs = $packageInfo['xml']->set('install');
                 foreach ($installs as $install) {
                     if (!$install->exists('@for') || matchPackageVersion($the_version, $install->fetch('@for'))) {
                         // Okay, this one is good to go.
                         $context['package_list'][$ps_id]['items'][$i]['can_install'] = true;
                         break;
                     }
                 }
             }
         }
     }
 }