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

📄 channels.php

📁 php-4.4.7学习linux时下载的源代码
💻 PHP
📖 第 1 页 / 共 3 页
字号:
                if ($channel->getName() != $save) {                    $this->ui->outputData('ERROR: Security risk - downloaded channel ' .                        'definition file for channel "'                        . $channel->getName() . ' from channel "' . $save .                        '".  To use anyway, use channel-update', $command);                    continue;                }                $reg->updateChannel($channel, $lastmodified);            } else {                if ($reg->isAlias($channel)) {                    $temp = &$reg->getChannel($channel);                    $temp->setAlias($temp->getName(), true); // set the alias to the channel name                    if ($reg->channelExists($temp->getName())) {                        $this->ui->outputData('ERROR: existing channel "' . $temp->getName() .                            '" is aliased to "' . $channel . '" already and cannot be ' .                            're-aliased to "' . $temp->getName() . '" because a channel with ' .                            'that name or alias already exists!  Please re-alias and try ' .                            'again.', $command);                        continue;                    }                }                $this->ui->outputData("Adding new channel \"$channel\"", $command);                PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);                $contents = $dl->downloadHttp('http://' . $channel . '/channel.xml',                    $this->ui, $tmpdir, null, false);                PEAR::staticPopErrorHandling();                if (PEAR::isError($contents)) {                    $this->ui->outputData('ERROR: Cannot retrieve channel.xml for channel "' .                        $channel . '"', $command);                    continue;                }                list($contents, $lastmodified) = $contents;                $info = implode('', file($contents));                if (!class_exists('PEAR_ChannelFile')) {                    require_once 'PEAR/ChannelFile.php';                }                $channelinfo = new PEAR_Channelfile;                $channelinfo->fromXmlString($info);                if ($channelinfo->getErrors()) {                    $this->ui->outputData("Downloaded channel data from channel \"$channel\"" .                        ' is corrupt, skipping', $command);                    continue;                }                $channel = $channelinfo;                if ($channel->getName() != $save) {                    $this->ui->outputData('ERROR: Security risk - downloaded channel ' .                        'definition file for channel "'                        . $channel->getName() . '" from channel "' . $save .                        '".  To use anyway, use channel-update', $command);                    continue;                }                $reg->addChannel($channel, $lastmodified);            }        }        $this->config->set('default_channel', $savechannel);        $this->ui->outputData('update-channels complete', $command);        return true;    }        function doInfo($command, $options, $params)    {        if (sizeof($params) != 1) {            return $this->raiseError("No channel specified");        }        $reg = &$this->config->getRegistry();        $channel = strtolower($params[0]);        if ($reg->channelExists($channel)) {            $chan = $reg->getChannel($channel);        } else {            if (strpos($channel, '://')) {                $downloader = &$this->getDownloader();                if (!class_exists('System')) {                    require_once 'System.php';                }                $tmpdir = System::mktemp(array('-d'));                PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);                $loc = $downloader->downloadHttp($channel, $this->ui, $tmpdir);                PEAR::staticPopErrorHandling();                if (PEAR::isError($loc)) {                    return $this->raiseError('Cannot open "' . $channel . '"');                } else {                    $contents = implode('', file($loc));                }            } else {                $fp = @fopen($params[0], 'r');                if (!$fp) {                    if (@file_exists($params[0])) {                        return $this->raiseError('Cannot open "' . $params[0] . '"');                    } else {                        return $this->raiseError('Unknown channel "' . $channel . '"');                    }                }                $contents = '';                while (!feof($fp)) {                    $contents .= fread($fp, 1024);                }                fclose($fp);            }            if (!class_exists('PEAR_ChannelFile')) {                require_once 'PEAR/ChannelFile.php';            }            $chan = new PEAR_ChannelFile;            $chan->fromXmlString($contents);            $chan->validate();            if ($errs = $chan->getErrors(true)) {                foreach ($errs as $err) {                    $this->ui->outputData($err['level'] . ': ' . $err['message']);                }                return $this->raiseError('Channel file "' . $params[0] . '" is not valid');            }        }        if ($chan) {            $channel = $chan->getName();            $caption = 'Channel ' . $channel . ' Information:';            $data1 = array(                'caption' => $caption,                'border' => true);            $data1['data']['server'] = array('Name and Server', $chan->getName());            if ($chan->getAlias() != $chan->getName()) {                $data1['data']['alias'] = array('Alias', $chan->getAlias());            }            $data1['data']['summary'] = array('Summary', $chan->getSummary());            $validate = $chan->getValidationPackage();            $data1['data']['vpackage'] = array('Validation Package Name', $validate['_content']);            $data1['data']['vpackageversion'] =                array('Validation Package Version', $validate['attribs']['version']);            $d = array();            $d['main'] = $data1;            $data['data'] = array();            $data['caption'] = 'Server Capabilities';            $data['headline'] = array('Type', 'Version/REST type', 'Function Name/REST base');            $capabilities = $chan->getFunctions('xmlrpc');            $soaps = $chan->getFunctions('soap');            if ($capabilities || $soaps || $chan->supportsREST()) {                if ($capabilities) {                    if (!isset($capabilities[0])) {                        $capabilities = array($capabilities);                    }                    foreach ($capabilities as $protocol) {                        $data['data'][] = array('xmlrpc', $protocol['attribs']['version'],                            $protocol['_content']);                    }                }                if ($soaps) {                    if (!isset($soaps[0])) {                        $soaps = array($soaps);                    }                    foreach ($soaps as $protocol) {                        $data['data'][] = array('soap', $protocol['attribs']['version'],                            $protocol['_content']);                    }                }                if ($chan->supportsREST()) {                    $funcs = $chan->getFunctions('rest');                    if (!isset($funcs[0])) {                        $funcs = array($funcs);                    }                    foreach ($funcs as $protocol) {                        $data['data'][] = array('rest', $protocol['attribs']['type'],                            $protocol['_content']);                     }                }            } else {                $data['data'][] = array('No supported protocols');            }            $d['protocols'] = $data;            $data['data'] = array();            $mirrors = $chan->getMirrors();            if ($mirrors) {                $data['caption'] = 'Channel ' . $channel . ' Mirrors:';                unset($data['headline']);                foreach ($mirrors as $mirror) {                    $data['data'][] = array($mirror['attribs']['host']);                    $d['mirrors'] = $data;                }                foreach ($mirrors as $mirror) {                    $data['data'] = array();                    $data['caption'] = 'Mirror ' . $mirror['attribs']['host'] . ' Capabilities';                    $data['headline'] = array('Type', 'Version/REST type', 'Function Name/REST base');                    $capabilities = $chan->getFunctions('xmlrpc', $mirror['attribs']['host']);                    $soaps = $chan->getFunctions('soap', $mirror['attribs']['host']);                    if ($capabilities || $soaps || $chan->supportsREST($mirror['attribs']['host'])) {                        if ($capabilities) {                            if (!isset($capabilities[0])) {                                $capabilities = array($capabilities);                            }                            foreach ($capabilities as $protocol) {                                $data['data'][] = array('xmlrpc', $protocol['attribs']['version'],                                    $protocol['_content']);                            }                        }                        if ($soaps) {                            if (!isset($soaps[0])) {                                $soaps = array($soaps);                            }                            foreach ($soaps as $protocol) {                                $data['data'][] = array('soap', $protocol['attribs']['version'],                                    $protocol['_content']);                            }                        }                        if ($chan->supportsREST($mirror['attribs']['host'])) {                            $funcs = $chan->getFunctions('rest', $mirror['attribs']['host']);                            if (!isset($funcs[0])) {                                $funcs = array($funcs);                            }                            foreach ($funcs as $protocol) {                                $data['data'][] = array('rest', $protocol['attribs']['type'],                                    $protocol['_content']);                             }                        }                    } else {                        $data['data'][] = array('No supported protocols');                    }                    $d['mirrorprotocols'] = $data;                }            }            $this->ui->outputData($d, 'channel-info');        } else {            return $this->raiseError('Serious error: Channel "' . $params[0] .                '" has a corrupted registry entry');        }    }    // }}}        function doDelete($command, $options, $params)    {        if (sizeof($params) != 1) {            return $this->raiseError('channel-delete: no channel specified');        }        $reg = &$this->config->getRegistry();        if (!$reg->channelExists($params[0])) {            return $this->raiseError('channel-delete: channel "' . $params[0] . '" does not exist');        }        $channel = $reg->channelName($params[0]);        if ($channel == 'pear.php.net') {            return $this->raiseError('Cannot delete the pear.php.net channel');        }        if ($channel == 'pecl.php.net') {            return $this->raiseError('Cannot delete the pecl.php.net channel');        }        if ($channel == '__uri') {            return $this->raiseError('Cannot delete the __uri pseudo-channel');        }        if (PEAR::isError($err = $reg->listPackages($channel))) {            return $err;        }        if (count($err)) {            return $this->raiseError('Channel "' . $channel .                '" has installed packages, cannot delete');        }        if (!$reg->deleteChannel($channel)) {            return $this->raiseError('Channel "' . $channel . '" deletion failed');        } else {            $this->config->deleteChannel($channel);            $this->ui->outputData('Channel "' . $channel . '" deleted', $command);

⌨️ 快捷键说明

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