⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 package.php

📁 php-4.4.7学习linux时下载的源代码
💻 PHP
📖 第 1 页 / 共 5 页
字号:
    /**     * For simpler unit-testing     * @param PEAR_Config     * @param int     * @param string     */    function &getPackagefileObject(&$c, $d, $t = false)    {        $a = &new PEAR_PackageFile($c, $d, $t);        return $a;    }    /**     * This will retrieve from a local file if possible, and parse out     * a group name as well.  The original parameter will be modified to reflect this.     * @param string|array can be a parsed package name as well     * @access private     */    function _fromFile(&$param)    {        if (is_string($param) && !@is_file($param)) {            $test = explode('#', $param);            $group = array_pop($test);            if (@is_file(implode('#', $test))) {                $this->setGroup($group);                $param = implode('#', $test);                $this->_explicitGroup = true;            }        }        if (@is_file($param)) {            $this->_type = 'local';            $options = $this->_downloader->getOptions();            if (isset($options['downloadonly'])) {                $pkg = &$this->getPackagefileObject($this->_config,                    $this->_downloader->_debug);            } else {                $pkg = &$this->getPackagefileObject($this->_config,                    $this->_downloader->_debug, $this->_downloader->getDownloadDir());            }            PEAR::pushErrorHandling(PEAR_ERROR_RETURN);            $pf = &$pkg->fromAnyFile($param, PEAR_VALIDATE_INSTALLING);            PEAR::popErrorHandling();            if (PEAR::isError($pf)) {                $this->_valid = false;                return $pf;            }            $this->_packagefile = &$pf;            if (!$this->getGroup()) {                $this->setGroup('default'); // install the default dependency group            }            return $this->_valid = true;        }        return $this->_valid = false;    }    function _fromUrl($param, $saveparam = '')    {        if (!is_array($param) &&              (preg_match('#^(http|ftp)://#', $param))) {            $options = $this->_downloader->getOptions();            $this->_type = 'url';            $callback = $this->_downloader->ui ?                array(&$this->_downloader, '_downloadCallback') : null;            $this->_downloader->pushErrorHandling(PEAR_ERROR_RETURN);            $file = $this->_downloader->downloadHttp($param, $this->_downloader->ui,                $this->_downloader->getDownloadDir(), $callback);            $this->_downloader->popErrorHandling();            if (PEAR::isError($file)) {                if (!empty($saveparam)) {                    $saveparam = ", cannot download \"$saveparam\"";                }                $err = PEAR::raiseError('Could not download from "' . $param .                    '"' . $saveparam);                    return $err;            }            if ($this->_rawpackagefile) {                require_once 'Archive/Tar.php';                $tar = &new Archive_Tar($file);                $packagexml = $tar->extractInString('package2.xml');                if (!$packagexml) {                    $packagexml = $tar->extractInString('package.xml');                }                if (str_replace(array("\n", "\r"), array('',''), $packagexml) !=                      str_replace(array("\n", "\r"), array('',''), $this->_rawpackagefile)) {                    if ($this->getChannel() == 'pear.php.net') {                        // be more lax for the existing PEAR packages that have not-ok                        // characters in their package.xml                        $this->_downloader->log(0, 'CRITICAL WARNING: The "' .                            $this->getPackage() . '" package has invalid characters in its ' .                            'package.xml.  The next version of PEAR may not be able to install ' .                            'this package for security reasons.  Please open a bug report at ' .                            'http://pear.php.net/package/' . $this->getPackage() . '/bugs');                    } else {                        return PEAR::raiseError('CRITICAL ERROR: package.xml downloaded does ' .                            'not match value returned from xml-rpc');                    }                }            }            // whew, download worked!            if (isset($options['downloadonly'])) {                $pkg = &$this->getPackagefileObject($this->_config, $this->_downloader->debug);            } else {                $pkg = &$this->getPackagefileObject($this->_config, $this->_downloader->debug,                    $this->_downloader->getDownloadDir());            }            PEAR::pushErrorHandling(PEAR_ERROR_RETURN);            $pf = &$pkg->fromAnyFile($file, PEAR_VALIDATE_INSTALLING);            PEAR::popErrorHandling();            if (PEAR::isError($pf)) {                if (is_array($pf->getUserInfo())) {                    foreach ($pf->getUserInfo() as $err) {                        if (is_array($err)) {                            $err = $err['message'];                        }                        if (!isset($options['soft'])) {                            $this->_downloader->log(0, "Validation Error: $err");                        }                    }                }                if (!isset($options['soft'])) {                    $this->_downloader->log(0, $pf->getMessage());                }                $err = PEAR::raiseError('Download of "' . ($saveparam ? $saveparam :                    $param) . '" succeeded, but it is not a valid package archive');                $this->_valid = false;                return $err;            }            $this->_packagefile = &$pf;            $this->setGroup('default'); // install the default dependency group            return $this->_valid = true;        }        return $this->_valid = false;    }    /**     *     * @param string|array pass in an array of format     *                     array(     *                      'package' => 'pname',     *                     ['channel' => 'channame',]     *                     ['version' => 'version',]     *                     ['state' => 'state',])     *                     or a string of format [channame/]pname[-version|-state]     */    function _fromString($param)    {        $options = $this->_downloader->getOptions();        PEAR::pushErrorHandling(PEAR_ERROR_RETURN);        $pname = $this->_registry->parsePackageName($param,            $this->_config->get('default_channel'));        PEAR::popErrorHandling();        if (PEAR::isError($pname)) {            if ($pname->getCode() == 'invalid') {                $this->_valid = false;                return false;            }            if ($pname->getCode() == 'channel') {                $parsed = $pname->getUserInfo();                if ($this->_downloader->discover($parsed['channel'])) {                    if ($this->_config->get('auto_discover')) {                        PEAR::pushErrorHandling(PEAR_ERROR_RETURN);                        $pname = $this->_registry->parsePackageName($param,                            $this->_config->get('default_channel'));                        PEAR::popErrorHandling();                    } else {                        if (!isset($options['soft'])) {                            $this->_downloader->log(0, 'Channel "' . $parsed['channel'] .                                '" is not initialized, use ' .                                '"pear channel-discover ' . $parsed['channel'] . '" to initialize' .                                'or pear config-set auto_discover 1');                        }                    }                }                if (PEAR::isError($pname)) {                    if (!isset($options['soft'])) {                        $this->_downloader->log(0, $pname->getMessage());                    }                    if (is_array($param)) {                        $param = $this->_registry->parsedPackageNameToString($param);                    }                    $err = PEAR::raiseError('invalid package name/package file "' .                        $param . '"');                    $this->_valid = false;                    return $err;                }            } else {                if (!isset($options['soft'])) {                    $this->_downloader->log(0, $pname->getMessage());                }                $err = PEAR::raiseError('invalid package name/package file "' .                    $param . '"');                $this->_valid = false;                return $err;            }        }        if (!isset($this->_type)) {            $this->_type = 'xmlrpc';        }        $this->_parsedname = $pname;        if (isset($pname['state'])) {            $this->_explicitState = $pname['state'];        } else {            $this->_explicitState = false;        }        if (isset($pname['group'])) {            $this->_explicitGroup = true;        } else {            $this->_explicitGroup = false;        }        $info = $this->_downloader->_getPackageDownloadUrl($pname);        if (PEAR::isError($info)) {            if ($pname['channel'] == 'pear.php.net') {                // try pecl                $pname['channel'] = 'pecl.php.net';                if ($test = $this->_downloader->_getPackageDownloadUrl($pname)) {                    if (!PEAR::isError($test)) {                        $info = PEAR::raiseError($info->getMessage() . ' - package ' .                            $this->_registry->parsedPackageNameToString($pname, true) .                            ' can be installed with "pecl install ' . $pname['package'] .                            '"');                    } else {                        $pname['channel'] = 'pear.php.net';                    }                } else {                    $pname['channel'] = 'pear.php.net';                }            }            return $info;        }        $this->_rawpackagefile = $info['raw'];        $ret = $this->_analyzeDownloadURL($info, $param, $pname);        if (PEAR::isError($ret)) {            return $ret;        }        if ($ret) {            $this->_downloadURL = $ret;            return $this->_valid = (bool) $ret;        }    }    /**     * @param array output of package.getDownloadURL     * @param string|array|object information for detecting packages to be downloaded, and     *                            for errors     * @param array name information of the package     * @param array|null packages to be downloaded     * @param bool is this an optional dependency?     * @access private     */    function _analyzeDownloadURL($info, $param, $pname, $params = null, $optional = false)    {        if (!is_string($param) && PEAR_Downloader_Package::willDownload($param, $params)) {            return false;        }        if (!$info) {            if (!is_string($param)) {                $saveparam = ", cannot download \"$param\"";            } else {                $saveparam = '';            }            // no releases exist            return PEAR::raiseError('No releases for package "' .                $this->_registry->parsedPackageNameToString($pname, true) . '" exist' . $saveparam);        }        if (strtolower($info['info']->getChannel()) != strtolower($pname['channel'])) {            $err = false;            if ($pname['channel'] == 'pecl.php.net') {                if ($info['info']->getChannel() != 'pear.php.net') {                    $err = true;                }            } elseif ($info['info']->getChannel() == 'pecl.php.net') {                if ($pname['channel'] != 'pear.php.net') {                    $err = true;                }            } else {                $err = true;            }            if ($err) {                return PEAR::raiseError('SECURITY ERROR: package in channel "' . $pname['channel'] .                    '" retrieved another channel\'s name for download! ("' .                    $info['info']->getChannel() . '")');            }        }        if (!isset($info['url'])) {            $instead =  ', will instead download version ' . $info['version'] .                        ', stability "' . $info['info']->getState() . '"';            // releases exist, but we failed to get any            if (isset($this->_downloader->_options['force'])) {                if (isset($pname['version'])) {                    $vs = ', version "' . $pname['version'] . '"';                } elseif (isset($pname['state'])) {                    $vs = ', stability "' . $pname['state'] . '"';                } elseif ($param == 'dependency') {                    if (!class_exists('PEAR_Common')) {                        require_once 'PEAR/Common.php';                    }                    if (!in_array($info['info']->getState(),                          PEAR_Common::betterStates($this->_config->get('preferred_state'), true))) {                        if ($optional) {                            // don't spit out confusing error message                            return $this->_downloader->_getPackageDownloadUrl(                                array('package' => $pname['package'],                                      'channel' => $pname['channel'],                                      'version' => $info['version']));                        }                        $vs = ' within preferred state "' . $this->_config->get('preferred_state') .                            '"';                    } else {                        if (!class_exists('PEAR_Dependency2')) {                            require_once 'PEAR/Dependency2.php';                        }                        if ($optional) {                            // don't spit out confusing error message                            return $this->_downloader->_getPackageDownloadUrl(                                array('package' => $pname['package'],                                      'channel' => $pname['channel'],                                      'version' => $info['version']));                        }                        $vs = PEAR_Dependency2::_getExtraString($pname);                        $instead = '';                    }                } else {                    $vs = ' within preferred state "' . $this->_config->get(                        'preferred_state') . '"';           

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -