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

📄 channelfile.php

📁 php-4.4.7学习linux时下载的源代码
💻 PHP
📖 第 1 页 / 共 4 页
字号:
                    }                } else {                    $this->_channelInfo['servers']['mirror']['attribs']['ssl'] = 'yes';                }                $this->_isValid = false;                return true;            }        }        if ($ssl) {            $this->_channelInfo['servers']['primary']['attribs']['ssl'] = 'yes';        } else {            if (isset($this->_channelInfo['servers']['primary']['attribs']['ssl'])) {                unset($this->_channelInfo['servers']['primary']['attribs']['ssl']);            }        }        $this->_isValid = false;        return true;    }    /**     * Set the socket number (port) that is used to connect to this channel     * @param integer     * @param string|false name of the mirror server, or false for the primary     */    function setPath($protocol, $path, $mirror = false)    {        if (!in_array($protocol, array('xmlrpc', 'soap'))) {            return false;        }        if ($mirror) {            if (!isset($this->_channelInfo['servers']['mirror'])) {                $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,                    array('mirror' => $mirror));                return false;            }            $setmirror = false;            if (isset($this->_channelInfo['servers']['mirror'][0])) {                foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {                    if ($mirror == $mir['attribs']['host']) {                        $this->_channelInfo['servers']['mirror'][$i][$protocol]['attribs']['path'] =                            $path;                        return true;                    }                }                $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,                    array('mirror' => $mirror));                return false;            } elseif ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) {                $this->_channelInfo['servers']['mirror'][$protocol]['attribs']['path'] = $path;                $this->_isValid = false;                return true;            }        }        $this->_channelInfo['servers']['primary'][$protocol]['attribs']['path'] = $path;        $this->_isValid = false;        return true;    }    /**     * @param string     * @return string|false     * @error PEAR_CHANNELFILE_ERROR_NO_SERVER     * @error PEAR_CHANNELFILE_ERROR_INVALID_SERVER     */    function setServer($server, $mirror = false)    {        if (empty($server)) {            $this->_validateError(PEAR_CHANNELFILE_ERROR_NO_SERVER);            return false;        } elseif (!$this->validChannelServer($server)) {            $this->_validateError(PEAR_CHANNELFILE_ERROR_INVALID_NAME,                array('tag' => 'name', 'name' => $server));            return false;        }        if ($mirror) {            $found = false;            foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {                if ($mirror == $mir['attribs']['host']) {                    $found = true;                    break;                }            }            if (!$found) {                $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,                    array('mirror' => $mirror));                return false;            }            $this->_channelInfo['mirror'][$i]['attribs']['host'] = $server;            return true;        }        $this->_channelInfo['name'] = $server;        return true;    }    /**     * @param string     * @return boolean success     * @error PEAR_CHANNELFILE_ERROR_NO_SUMMARY     * @warning PEAR_CHANNELFILE_ERROR_MULTILINE_SUMMARY     */    function setSummary($summary)    {        if (empty($summary)) {            $this->_validateError(PEAR_CHANNELFILE_ERROR_NO_SUMMARY);            return false;        } elseif (strpos(trim($summary), "\n") !== false) {            $this->_validateWarning(PEAR_CHANNELFILE_ERROR_MULTILINE_SUMMARY,                array('summary' => $summary));        }        $this->_channelInfo['summary'] = $summary;        return true;    }    /**     * @param string     * @param boolean determines whether the alias is in channel.xml or local     * @return boolean success     */    function setAlias($alias, $local = false)    {        if (!$this->validChannelServer($alias)) {            $this->_validateError(PEAR_CHANNELFILE_ERROR_INVALID_NAME,                array('tag' => 'suggestedalias', 'name' => $alias));            return false;        }        if ($local) {            $this->_channelInfo['localalias'] = $alias;        } else {            $this->_channelInfo['suggestedalias'] = $alias;        }        return true;    }    /**     * @return string     */    function getAlias()    {        if (isset($this->_channelInfo['localalias'])) {            return $this->_channelInfo['localalias'];        }        if (isset($this->_channelInfo['suggestedalias'])) {            return $this->_channelInfo['suggestedalias'];        }        if (isset($this->_channelInfo['name'])) {            return $this->_channelInfo['name'];        }    }    /**     * Set the package validation object if it differs from PEAR's default     * The class must be includeable via changing _ in the classname to path separator,     * but no checking of this is made.     * @param string|false pass in false to reset to the default packagename regex     * @return boolean success     */    function setValidationPackage($validateclass, $version)    {        if (empty($validateclass)) {            unset($this->_channelInfo['validatepackage']);        }        $this->_channelInfo['validatepackage'] = array('_content' => $validateclass);        $this->_channelInfo['validatepackage']['attribs'] = array('version' => $version);    }    /**     * Add a protocol to the provides section     * @param string protocol type     * @param string protocol version     * @param string protocol name, if any     * @param string mirror name, if this is a mirror's protocol     * @return bool     */    function addFunction($type, $version, $name = '', $mirror = false)    {        if ($mirror) {            return $this->addMirrorFunction($mirror, $type, $version, $name);        }        $set = array('attribs' => array('version' => $version), '_content' => $name);        if (!isset($this->_channelInfo['servers']['primary'][$type]['function'])) {            $this->_channelInfo['servers']['primary'][$type]['function'] = $set;            $this->_isValid = false;            return true;        } elseif (!isset($this->_channelInfo['servers']['primary'][$type]['function'][0])) {            $this->_channelInfo['servers']['primary'][$type]['function'] = array(                $this->_channelInfo['servers']['primary'][$type]['function']);        }        $this->_channelInfo['servers']['primary'][$type]['function'][] = $set;        return true;    }    /**     * Add a protocol to a mirror's provides section     * @param string mirror name (server)     * @param string protocol type     * @param string protocol version     * @param string protocol name, if any     */    function addMirrorFunction($mirror, $type, $version, $name = '')    {        $found = false;        if (!isset($this->_channelInfo['servers']['mirror'])) {            $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,                array('mirror' => $mirror));            return false;        }        $setmirror = false;        if (isset($this->_channelInfo['servers']['mirror'][0])) {            foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {                if ($mirror == $mir['attribs']['host']) {                    $setmirror = &$this->_channelInfo['servers']['mirror'][$i];                    break;                }            }        } else {            if ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) {                $setmirror = &$this->_channelInfo['servers']['mirror'];            }        }        if (!$setmirror) {            $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,                array('mirror' => $mirror));            return false;        }        $set = array('attribs' => array('version' => $version), '_content' => $name);        if (!isset($setmirror[$type]['function'])) {            $setmirror[$type]['function'] = $set;            $this->_isValid = false;            return true;        } elseif (!isset($setmirror[$type]['function'][0])) {            $setmirror[$type]['function'] = array($setmirror[$type]['function']);        }        $setmirror[$type]['function'][] = $set;        $this->_isValid = false;        return true;    }    /**     * @param string Resource Type this url links to     * @param string URL     * @param string|false mirror name, if this is not a primary server REST base URL     */    function setBaseURL($resourceType, $url, $mirror = false)    {        if ($mirror) {            $found = false;            if (!isset($this->_channelInfo['servers']['mirror'])) {                $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,                    array('mirror' => $mirror));                return false;            }            $setmirror = false;            if (isset($this->_channelInfo['servers']['mirror'][0])) {                foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {                    if ($mirror == $mir['attribs']['host']) {                        $setmirror = &$this->_channelInfo['servers']['mirror'][$i];                        break;                    }                }            } else {                if ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) {                    $setmirror = &$this->_channelInfo['servers']['mirror'];                }            }        } else {            $setmirror = &$this->_channelInfo['servers']['primary'];        }        $set = array('attribs' => array('type' => $resourceType), '_content' => $url);        if (!isset($setmirror['rest']['baseurl'])) {            $setmirror['rest']['baseurl'] = $set;            $this->_isValid = false;            return true;        } elseif (!isset($setmirror['rest']['baseurl'][0])) {            $setmirror['rest']['baseurl'] = array($setmirror['rest']['baseurl']);        }        foreach ($setmirror['rest']['baseurl'] as $i => $url) {            if ($url['attribs']['type'] == $resourceType) {                $this->_isValid = false;                $setmirror['rest']['baseurl'][$i] = $set;                return true;            }        }        $setmirror['rest']['baseurl'][] = $set;        $this->_isValid = false;        return true;    }    /**     * @param string mirror server     * @param int mirror http port     * @return boolean     */    function addMirror($server, $port = null)    {        if ($this->_channelInfo['name'] == '__uri') {            return false; // the __uri channel cannot have mirrors by definition        }        $set = array('attribs' => array('host' => $server));        if (is_numeric($port)) {            $set['attribs']['port'] = $port;        }        if (!isset($this->_channelInfo['servers']['mirror'])) {            $this->_channelInfo['servers']['mirror'] = $set;            return true;        } else {            if (!isset($this->_channelInfo['servers']['mirror'][0])) {                $this->_channelInfo['servers']['mirror'] =                    array($this->_channelInfo['servers']['mirror']);            }        }        $this->_channelInfo['servers']['mirror'][] = $set;        return true;    }    /**     * Retrieve the name of the validation package for this channel     * @return string|false     */    function getValidationPackage()    {        if (!$this->_isValid && !$this->validate()) {            return false;        }        if (!isset($this->_channelInfo['validatepackage'])) {            return array('attribs' => array('version' => 'default'),                '_content' => 'PEAR_Validate');        }        return $this->_channelInfo['validatepackage'];    }    /**     * Retrieve the object that can be used for custom validation     * @param string|false the name of the package to validate.  If the package is     *                     the channel validation package, PEAR_Validate is returned     * @return PEAR_Validate|false false is returned if the validation package     *         cannot be located     */    function &getValidationObject($package = false)    {        if (!class_exists('PEAR_Validate')) {            require_once 'PEAR/Validate.php';        }        if (!$this->_isValid) {            if (!$this->validate()) {                $a = false;                return $a;            }        }        if (isset($this->_channelInfo['validatepackage'])) {            if ($package == $this->_channelInfo['validatepackage']) {                // channel validation packages are always validated by PEAR_Validate                $val = &new PEAR_Validate;                return $val;            }            if (!class_exists(str_replace('.', '_',                  $this->_channelInfo['validatepackage']['_content']))) {                if ($this->isIncludeable(str_replace('_', '/',                      $this->_channelInfo['validatepackage']['_content']) . '.php')) {                    include_once str_replace('_', '/',                        $this->_channelInfo['validatepackage']['_content']) . '.php';                    $vclass = str_replace('.', '_',                        $this->_channelInfo['validatepackage']['_content']);                    $val = &new $vclass;                } else {                    $a = false;                    return $a;                }            } else {                $vclass = str_replace('.', '_',                    $this->_channelInfo['validatepackage']['_content']);                $val = &new $vclass;            }        } else {            $val = &new PEAR_Validate;        }        return $val;    }    function isIncludeable($path)    {        $possibilities = explode(PATH_SEPARATOR, ini_get('include_path'));        foreach ($possibilities as $dir) {            if (file_exists($dir . DIRECTORY_SEPARATOR . $path)                  && is_readable($dir . DIRECTORY_SEPARATOR . $path)) {                return true;            }        }        return false;    }    /**     * This function is used by the channel updater and retrieves a value set by     * the registry, or the current time if it has not been set     * @return string     */    function lastModified()    {        if (isset($this->_channelInfo['_lastmodified'])) {            return $this->_channelInfo['_lastmodified'];        }        return time();    }}?>

⌨️ 快捷键说明

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