• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP matchPackageVersion函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中matchPackageVersion函数的典型用法代码示例。如果您正苦于以下问题:PHP matchPackageVersion函数的具体用法?PHP matchPackageVersion怎么用?PHP matchPackageVersion使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了matchPackageVersion函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: findSearchAPI

/**
 * Creates a search API and returns the object.
 *
 * @package Search
 */
function findSearchAPI()
{
    global $modSettings, $search_versions, $searchAPI, $txt;
    require_once SUBSDIR . '/Package.subs.php';
    // Load up the search API we are going to use.
    $modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index'];
    if (!file_exists(SUBSDIR . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.class.php')) {
        fatal_lang_error('search_api_missing');
    }
    require_once SUBSDIR . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.class.php';
    // Create an instance of the search API and check it is valid for this version of the software.
    $search_class_name = $modSettings['search_index'] . '_search';
    $searchAPI = new $search_class_name();
    // An invalid Search API.
    if (!$searchAPI || $searchAPI->supportsMethod('isValid') && !$searchAPI->isValid() || !matchPackageVersion($search_versions['forum_version'], $searchAPI->min_elk_version . '-' . $searchAPI->version_compatible)) {
        // Log the error.
        loadLanguage('Errors');
        log_error(sprintf($txt['search_api_not_compatible'], 'SearchAPI-' . ucwords($modSettings['search_index']) . '.class.php'), 'critical');
        require_once SUBSDIR . '/SearchAPI-Standard.class.php';
        $searchAPI = new Standard_Search();
    }
    return $searchAPI;
}
开发者ID:KeiroD,项目名称:Elkarte,代码行数:28,代码来源:Search.subs.php


示例2: PackageGBrowse


//.........这里部分代码省略.........
                        $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)) {
开发者ID:alencarmo,项目名称:OCF,代码行数:67,代码来源:PackageGet.php


示例3: parsePackageInfo

function parsePackageInfo(&$packageXML, $testing_only = true, $method = 'install', $previous_version = '')
{
    global $boarddir, $forum_version, $context, $temp_path, $language;
    // Mayday!  That action doesn't exist!!
    if (empty($packageXML) || !$packageXML->exists($method)) {
        return array();
    }
    // We haven't found the package script yet...
    $script = false;
    $the_version = strtr($forum_version, array('SMF ' => ''));
    // Emulation support...
    if (!empty($_SESSION['version_emulate'])) {
        $the_version = $_SESSION['version_emulate'];
    }
    // Get all the versions of this method and find the right one.
    $these_methods = $packageXML->set($method);
    foreach ($these_methods as $this_method) {
        // They specified certain versions this part is for.
        if ($this_method->exists('@for')) {
            // Don't keep going if this won't work for this version of SMF.
            if (!matchPackageVersion($the_version, $this_method->fetch('@for'))) {
                continue;
            }
        }
        // Upgrades may go from a certain old version of the mod.
        if ($method == 'upgrade' && $this_method->exists('@from')) {
            // Well, this is for the wrong old version...
            if (!matchPackageVersion($previous_version, $this_method->fetch('@from'))) {
                continue;
            }
        }
        // We've found it!
        $script = $this_method;
        break;
    }
    // Bad news, a matching script wasn't found!
    if ($script === false) {
        return array();
    }
    // Find all the actions in this method - in theory, these should only be allowed actions. (* means all.)
    $actions = $script->set('*');
    $return = array();
    $temp_auto = 0;
    $temp_path = $boarddir . '/Packages/temp/' . (isset($context['base_path']) ? $context['base_path'] : '');
    $context['readmes'] = array();
    // This is the testing phase... nothing shall be done yet.
    foreach ($actions as $action) {
        $actionType = $action->name();
        if ($actionType == 'readme' || $actionType == 'code' || $actionType == 'database' || $actionType == 'modification' || $actionType == 'redirect') {
            // Allow for translated readme files.
            if ($actionType == 'readme') {
                if ($action->exists('@lang')) {
                    // Auto-select a readme language based on either request variable or current language.
                    if (isset($_REQUEST['readme']) && $action->fetch('@lang') == $_REQUEST['readme'] || !isset($_REQUEST['readme']) && $action->fetch('@lang') == $language) {
                        // In case the user put the readme blocks in the wrong order.
                        if (isset($context['readmes']['selected']) && $context['readmes']['selected'] == 'default') {
                            $context['readmes'][] = 'default';
                        }
                        $context['readmes']['selected'] = htmlspecialchars($action->fetch('@lang'));
                    } else {
                        // We don't want this readme now, but we'll allow the user to select to read it.
                        $context['readmes'][] = htmlspecialchars($action->fetch('@lang'));
                        continue;
                    }
                } else {
                    // Already selected a readme.
                    if (isset($context['readmes']['selected'])) {
                        $context['readmes'][] = 'default';
                        continue;
                    } else {
                        $context['readmes']['selected'] = 'default';
                    }
                }
            }
            // !!! TODO: Make sure the file actually exists?  Might not work when testing?
            if ($action->exists('@type') && $action->fetch('@type') == 'inline') {
                $filename = $temp_path . '$auto_' . $temp_auto++ . ($actionType == 'readme' || $actionType == 'redirect' ? '.txt' : ($actionType == 'code' || $actionType == 'database' ? '.php' : '.mod'));
                package_put_contents($filename, $action->fetch('.'));
                $filename = strtr($filename, array($temp_path => ''));
            } else {
                $filename = $action->fetch('.');
            }
            $return[] = array('type' => $actionType, 'filename' => $filename, 'description' => '', 'reverse' => $action->exists('@reverse') && $action->fetch('@reverse') == 'true', 'boardmod' => $action->exists('@format') && $action->fetch('@format') == 'boardmod', 'redirect_url' => $action->exists('@url') ? $action->fetch('@url') : '', 'redirect_timeout' => $action->exists('@timeout') ? (int) $action->fetch('@timeout') : '', 'parse_bbc' => $action->exists('@parsebbc') && $action->fetch('@parsebbc') == 'true', 'language' => $actionType == 'readme' && $action->exists('@lang') && $action->fetch('@lang') == $language ? $language : '');
            continue;
        } elseif ($actionType == 'error') {
            $return = array('type' => 'error');
        }
        $this_action =& $return;
        $this_action = array('type' => $actionType, 'filename' => $action->fetch('@name'), 'description' => $action->fetch('.'));
        // If there is a destination, make sure it makes sense.
        if (substr($actionType, 0, 6) != 'remove') {
            $this_action['unparsed_destination'] = $action->fetch('@destination');
            $this_action['destination'] = parse_path($action->fetch('@destination')) . '/' . basename($this_action['filename']);
        } else {
            $this_action['unparsed_filename'] = $this_action['filename'];
            $this_action['filename'] = parse_path($this_action['filename']);
        }
        // If we're moving or requiring (copying) a file.
        if (substr($actionType, 0, 4) == 'move' || substr($actionType, 0, 7) == 'require') {
            if ($action->exists('@from')) {
//.........这里部分代码省略.........
开发者ID:norv,项目名称:EosAlpha,代码行数:101,代码来源:Subs-Package.php


示例4: list_packages


//.........这里部分代码省略.........
                 }
                 $dirs[] = $package;
             } elseif (substr(strtolower($package), -7) == '.tar.gz') {
                 if (in_array(substr($package, 0, -7), $dirs)) {
                     continue;
                 }
                 $dirs[] = substr($package, 0, -7);
             } elseif (substr(strtolower($package), -4) == '.zip' || substr(strtolower($package), -4) == '.tgz') {
                 if (in_array(substr($package, 0, -4), $dirs)) {
                     continue;
                 }
                 $dirs[] = substr($package, 0, -4);
             }
             $packageInfo = getPackageInfo($package);
             if (!is_array($packageInfo)) {
                 continue;
             }
             if (!empty($packageInfo)) {
                 $packageInfo['installed_id'] = isset($installed_adds[$packageInfo['id']]) ? $installed_adds[$packageInfo['id']]['id'] : 0;
                 $packageInfo['sort_id'] = isset($sort_id[$packageInfo['type']]) ? $sort_id[$packageInfo['type']] : $sort_id['unknown'];
                 $packageInfo['is_installed'] = isset($installed_adds[$packageInfo['id']]);
                 $packageInfo['is_current'] = $packageInfo['is_installed'] && $installed_adds[$packageInfo['id']]['version'] == $packageInfo['version'];
                 $packageInfo['is_newer'] = $packageInfo['is_installed'] && $installed_adds[$packageInfo['id']]['version'] > $packageInfo['version'];
                 $packageInfo['can_install'] = false;
                 $packageInfo['can_uninstall'] = false;
                 $packageInfo['can_upgrade'] = false;
                 $packageInfo['can_emulate_install'] = false;
                 $packageInfo['can_emulate_uninstall'] = false;
                 // This package is currently NOT installed.  Check if it can be.
                 if (!$packageInfo['is_installed'] && $packageInfo['xml']->exists('install')) {
                     // Check if there's an install for *THIS* version
                     $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.
                             $packageInfo['can_install'] = true;
                             break;
                         }
                     }
                     // no install found for our version, lets see if one exists for another
                     if ($packageInfo['can_install'] === false && $install->exists('@for') && empty($_SESSION['version_emulate'])) {
                         $reset = true;
                         // Get the highest install version that is available from the package
                         foreach ($installs as $install) {
                             $packageInfo['can_emulate_install'] = matchHighestPackageVersion($install->fetch('@for'), $reset, $the_version);
                             $reset = false;
                         }
                     }
                 } elseif ($packageInfo['is_installed'] && !$packageInfo['is_current'] && $packageInfo['xml']->exists('upgrade')) {
                     $upgrades = $packageInfo['xml']->set('upgrade');
                     // First go through, and check against the current version of ElkArte.
                     foreach ($upgrades as $upgrade) {
                         // Even if it is for this ElkArte, is it for the installed version of the mod?
                         if (!$upgrade->exists('@for') || matchPackageVersion($the_version, $upgrade->fetch('@for'))) {
                             if (!$upgrade->exists('@from') || matchPackageVersion($installed_adds[$packageInfo['id']]['version'], $upgrade->fetch('@from'))) {
                                 $packageInfo['can_upgrade'] = true;
                                 break;
                             }
                         }
                     }
                 } elseif ($packageInfo['is_installed'] && $packageInfo['is_current'] && $packageInfo['xml']->exists('uninstall')) {
                     $uninstalls = $packageInfo['xml']->set('uninstall');
                     // Can we find any uninstallation methods that work for this ElkArte version?
                     foreach ($uninstalls as $uninstall) {
                         if (!$uninstall->exists('@for') || matchPackageVersion($the_version, $uninstall->fetch('@for'))) {
                             $packageInfo['can_uninstall'] = true;
开发者ID:scripple,项目名称:Elkarte,代码行数:67,代码来源:Packages.controller.php


示例5: PackageBrowse

function PackageBrowse()
{
    global $txt, $boarddir, $scripturl, $context, $forum_version;
    $context['page_title'] .= ' - ' . $txt['browse_packages'];
    $context['sub_template'] = 'browse';
    $context['forum_version'] = $forum_version;
    $instmods = loadInstalledPackages();
    $installed_mods = array();
    // Look through the list of installed mods...
    foreach ($instmods as $installed_mod) {
        $installed_mods[$installed_mod['package_id']] = array('id' => $installed_mod['id'], 'version' => $installed_mod['version']);
    }
    $the_version = strtr($forum_version, array('SMF ' => ''));
    // Here we have a little code to help those who class themselves as something of gods, version emulation ;)
    if (isset($_GET['version_emulate'])) {
        if ($_GET['version_emulate'] === 0 && isset($_SESSION['version_emulate'])) {
            unset($_SESSION['version_emulate']);
        } elseif ($_GET['version_emulate'] !== 0) {
            $_SESSION['version_emulate'] = strtr($_GET['version_emulate'], array('-' => ' ', '+' => ' ', 'SMF ' => ''));
        }
    }
    if (!empty($_SESSION['version_emulate'])) {
        $context['forum_version'] = 'SMF ' . $_SESSION['version_emulate'];
        $the_version = $_SESSION['version_emulate'];
    }
    // Get a list of all the ids installed, so the latest packages won't include already installed ones.
    $context['installed_mods'] = array_keys($installed_mods);
    // Empty lists for now.
    $context['available_mods'] = array();
    $context['available_avatars'] = array();
    $context['available_languages'] = array();
    $context['available_other'] = array();
    $context['available_all'] = array();
    // We need the packages directory to be writable for this.
    if (!@is_writable($boarddir . '/Packages')) {
        create_chmod_control(array($boarddir . '/Packages'), array('destination_url' => $scripturl . '?action=admin;area=packages', 'crash_on_error' => true));
    }
    if ($dir = @opendir($boarddir . '/Packages')) {
        $dirs = array();
        while ($package = readdir($dir)) {
            if ($package == '.' || $package == '..' || $package == 'temp' || !(is_dir($boarddir . '/Packages/' . $package) && file_exists($boarddir . '/Packages/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip') {
                continue;
            }
            // Skip directories or files that are named the same.
            if (is_dir($boarddir . '/Packages/' . $package)) {
                if (in_array($package, $dirs)) {
                    continue;
                }
                $dirs[] = $package;
            } elseif (substr(strtolower($package), -7) == '.tar.gz') {
                if (in_array(substr($package, 0, -7), $dirs)) {
                    continue;
                }
                $dirs[] = substr($package, 0, -7);
            } elseif (substr(strtolower($package), -4) == '.zip' || substr(strtolower($package), -4) == '.tgz') {
                if (in_array(substr($package, 0, -4), $dirs)) {
                    continue;
                }
                $dirs[] = substr($package, 0, -4);
            }
            $packageInfo = getPackageInfo($package);
            if (!is_array($packageInfo)) {
                continue;
            }
            $packageInfo['installed_id'] = isset($installed_mods[$packageInfo['id']]) ? $installed_mods[$packageInfo['id']]['id'] : 0;
            $packageInfo['is_installed'] = isset($installed_mods[$packageInfo['id']]);
            $packageInfo['is_current'] = $packageInfo['is_installed'] && $installed_mods[$packageInfo['id']]['version'] == $packageInfo['version'];
            $packageInfo['is_newer'] = $packageInfo['is_installed'] && $installed_mods[$packageInfo['id']]['version'] > $packageInfo['version'];
            $packageInfo['can_install'] = false;
            $packageInfo['can_uninstall'] = false;
            $packageInfo['can_upgrade'] = false;
            // This package is currently NOT installed.  Check if it can be.
            if (!$packageInfo['is_installed'] && $packageInfo['xml']->exists('install')) {
                // Check if there's an install for *THIS* version of SMF.
                $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.
                        $packageInfo['can_install'] = true;
                        break;
                    }
                }
            } elseif ($packageInfo['is_installed'] && !$packageInfo['is_current'] && $packageInfo['xml']->exists('upgrade')) {
                $upgrades = $packageInfo['xml']->set('upgrade');
                // First go through, and check against the current version of SMF.
                foreach ($upgrades as $upgrade) {
                    // Even if it is for this SMF, is it for the installed version of the mod?
                    if (!$upgrade->exists('@for') || matchPackageVersion($the_version, $upgrade->fetch('@for'))) {
                        if (!$upgrade->exists('@from') || matchPackageVersion($installed_mods[$packageInfo['id']]['version'], $upgrade->fetch('@from'))) {
                            $packageInfo['can_upgrade'] = true;
                            break;
                        }
                    }
                }
            } elseif ($packageInfo['is_installed'] && $packageInfo['is_current'] && $packageInfo['xml']->exists('uninstall')) {
                $uninstalls = $packageInfo['xml']->set('uninstall');
                // Can we find any uninstallation methods that work for this SMF version?
                foreach ($uninstalls as $uninstall) {
                    if (!$uninstall->exists('@for') || matchPackageVersion($the_version, $uninstall->fetch('@for'))) {
                        $packageInfo['can_uninstall'] = true;
//.........这里部分代码省略.........
开发者ID:norv,项目名称:EosAlpha,代码行数:101,代码来源:Packages.php


示例6: PlushSearch2

function PlushSearch2()
{
    global $scripturl, $modSettings, $sourcedir, $txt, $db_connection;
    global $user_info, $context, $options, $messages_request, $boards_can;
    global $excludedWords, $participants, $smcFunc, $search_versions, $searchAPI;
    if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) {
        fatal_lang_error('loadavg_search_disabled', false);
    }
    // No, no, no... this is a bit hard on the server, so don't you go prefetching it!
    if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
        ob_end_clean();
        header('HTTP/1.1 403 Forbidden');
        die;
    }
    $weight_factors = array('frequency', 'age', 'length', 'subject', 'first_message', 'sticky');
    $weight = array();
    $weight_total = 0;
    foreach ($weight_factors as $weight_factor) {
        $weight[$weight_factor] = empty($modSettings['search_weight_' . $weight_factor]) ? 0 : (int) $modSettings['search_weight_' . $weight_factor];
        $weight_total += $weight[$weight_factor];
    }
    // Zero weight.  Weightless :P.
    if (empty($weight_total)) {
        fatal_lang_error('search_invalid_weights');
    }
    // These vars don't require an interface, they're just here for tweaking.
    $recentPercentage = 0.3;
    $humungousTopicPosts = 200;
    $maxMembersToSearch = 500;
    $maxMessageResults = empty($modSettings['search_max_results']) ? 0 : $modSettings['search_max_results'] * 5;
    // Start with no errors.
    $context['search_errors'] = array();
    // Number of pages hard maximum - normally not set at all.
    $modSettings['search_max_results'] = empty($modSettings['search_max_results']) ? 200 * $modSettings['search_results_per_page'] : (int) $modSettings['search_max_results'];
    // Maximum length of the string.
    $context['search_string_limit'] = 100;
    loadLanguage('Search');
    if (!isset($_REQUEST['xml'])) {
        loadTemplate('Search');
    } else {
        $context['sub_template'] = 'results';
    }
    // Are you allowed?
    isAllowedTo('search_posts');
    require_once $sourcedir . '/Display.php';
    require_once $sourcedir . '/Subs-Package.php';
    // Search has a special database set.
    db_extend('search');
    // Load up the search API we are going to use.
    $modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index'];
    if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) {
        fatal_lang_error('search_api_missing');
    }
    loadClassFile('SearchAPI-' . ucwords($modSettings['search_index']) . '.php');
    // Create an instance of the search API and check it is valid for this version of SMF.
    $search_class_name = $modSettings['search_index'] . '_search';
    $searchAPI = new $search_class_name();
    if (!$searchAPI || $searchAPI->supportsMethod('isValid') && !$searchAPI->isValid() || !matchPackageVersion($search_versions['forum_version'], $searchAPI->min_smf_version . '-' . $searchAPI->version_compatible)) {
        // Log the error.
        loadLanguage('Errors');
        log_error(sprintf($txt['search_api_not_compatible'], 'SearchAPI-' . ucwords($modSettings['search_index']) . '.php'), 'critical');
        loadClassFile('SearchAPI-Standard.php');
        $searchAPI = new standard_search();
    }
    // $search_params will carry all settings that differ from the default search parameters.
    // That way, the URLs involved in a search page will be kept as short as possible.
    $search_params = array();
    if (isset($_REQUEST['params'])) {
        // Due to IE's 2083 character limit, we have to compress long search strings
        $temp_params = base64_decode(str_replace(array('-', '_', '.'), array('+', '/', '='), $_REQUEST['params']));
        // Test for gzuncompress failing
        $temp_params2 = @gzuncompress($temp_params);
        $temp_params = explode('|"|', !empty($temp_params2) ? $temp_params2 : $temp_params);
        foreach ($temp_params as $i => $data) {
            @(list($k, $v) = explode('|\'|', $data));
            $search_params[$k] = $v;
        }
        if (isset($search_params['brd'])) {
            $search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']);
        }
    }
    // Store whether simple search was used (needed if the user wants to do another query).
    if (!isset($search_params['advanced'])) {
        $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1;
    }
    // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'.
    if (!empty($search_params['searchtype']) || !empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2) {
        $search_params['searchtype'] = 2;
    }
    // Minimum age of messages. Default to zero (don't set param in that case).
    if (!empty($search_params['minage']) || !empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0) {
        $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage'];
    }
    // Maximum age of messages. Default to infinite (9999 days: param not set).
    if (!empty($search_params['maxage']) || !empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999) {
        $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage'];
    }
    // Searching a specific topic?
    if (!empty($_REQUEST['topic'])) {
        $search_params['topic'] = (int) $_REQUEST['topic'];
//.........这里部分代码省略.........
开发者ID:chenhao6593,项目名称:smf,代码行数:101,代码来源:Search.php


示例7: action_browse


//.........这里部分代码省略.........
                         $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')) {
开发者ID:scripple,项目名称:Elkarte,代码行数:67,代码来源:PackageServers.controller.php


示例8: action_browse

 /**
  * 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';
     $server = '';
     $url = '';
     $name = '';
     // Browsing the packages from a server
     if (isset($_GET['server'])) {
         list($name, $url, $server) = $this->_package_server();
     } else {
         fatal_lang_error('couldnt_connect', false);
     }
     // Might take some time.
     @set_time_limit(60);
     // Fetch the package listing from the server and json decode
     $listing = json_decode(fetch_web_data($url));
     // List out the packages...
     $context['package_list'] = array();
     // Pick the correct template.
     $context['sub_template'] = 'package_list';
     $context['page_title'] = $txt['package_servers'] . ($name != '' ? ' - ' . $name : '');
     $context['package_server'] = $server;
     // If we received data
     if (!empty($listing)) {
         // Load the installed packages
         $instadds = loadInstalledPackages();
         // Look through the list of installed mods and get version information for the compare
         $installed_adds = array();
         foreach ($instadds as $installed_add) {
             $installed_adds[$installed_add['package_id']] = $installed_add['version'];
         }
         $the_version = strtr($forum_version, array('ElkArte ' => ''));
         if (!empty($_SESSION['version_emulate'])) {
             $the_version = $_SESSION['version_emulate'];
         }
         // Parse the json file, each section contains a category of addons
         $packageNum = 0;
         foreach ($listing as $packageSection => $section_items) {
             // Section title / header for the category
             $context['package_list'][$packageSection] = array('title' => Util::htmlspecialchars(ucwords($packageSection)), 'text' => '', 'items' => array());
             // Load each package array as an item
             $section_count = 0;
             foreach ($section_items as $thisPackage) {
                 // Read in the package info from the fetched data
                 $package = $this->_load_package_json($thisPackage, $packageSection);
                 // Check the install status
                 $package['can_install'] = false;
                 $is_installed = array_intersect(array_keys($installed_adds), $package['id']);
                 $package['is_installed'] = !empty($is_installed);
                 // Set the ID from our potential list should the ID not be provided in the package .yaml
                 $package['id'] = $package['is_installed'] ? array_shift($is_installed) : $package['id'][0];
                 // Version installed vs version available
                 $package['is_current'] = !empty($package['is_installed']) && $installed_adds[$package['id']] == $package['version'];
                 $package['is_newer'] = !empty($package['is_installed']) && $installed_adds[$package['id']] > $package['version'];
                 // Set the package filename for downloading and pre-existence checking
                 $base_name = $this->_rename_master($package['server']['download']);
                 $package['filename'] = basename($package['server']['download']);
                 // This package is either not installed, or installed but old.
                 if (!$package['is_installed'] || !$package['is_current'] && !$package['is_newer']) {
                     // Does it claim to install on this version of ElkArte?
                     $path_parts = pathinfo($base_name);
                     if (!empty($thisPackage->elkversion) && isset($path_parts['extension']) && in_array($path_parts['extension'], array('zip', 'tar', 'gz', 'tar.gz'))) {
                         // No install range given, then set one, it will all work out in the end.
                         $for = strpos($thisPackage->elkversion, '-') === false ? $thisPackage->elkversion . '-' . $the_version : $thisPackage->elkversion;
                         $package['can_install'] = matchPackageVersion($the_version, $for);
                     }
                 }
                 // See if this filename already exists on the server
                 $already_exists = getPackageInfo($base_name);
                 $package['download_conflict'] = is_array($already_exists) && $already_exists['id'] == $package['id'] && $already_exists['version'] != $package['version'];
                 $package['count'] = ++$packageNum;
                 // Build the download to server link
                 $server_att = $server != '' ? ';server=' . $server : '';
                 $current_url = ';section=' . $packageSection . ';num=' . $section_count;
                 $package['download']['href'] = $scripturl . '?action=admin;area=packageservers;sa=download' . $server_att . $current_url . ';package=' . $package['filename'] . ($package['download_conflict'] ? ';conflict' : '') . ';' . $context['session_var'] . '=' . $context['session_id'];
                 $package['download']['link'] = '<a href="' . $package['download']['href'] . '">' . $package['name'] . '</a>';
                 // Add this package to the list
                 $context['package_list'][$packageSection]['items'][$packageNum] = $package;
                 $section_count++;
             }
             $context['package_list'][$packageSection]['text'] = sprintf($txt['mod_section_count'], $section_count);
         }
     }
     // Good time to sort the categories, the packages inside each category will be by last modification date.
     asort($context['package_list']);
 }
开发者ID:KeiroD,项目名称:Elkarte,代码行数:93,代码来源:PackageServers.controller.php



注:本文中的matchPackageVersion函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP match_cidr函数代码示例发布时间:2022-05-15
下一篇:
PHP match函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap