当前位置: 首页>>代码示例>>PHP>>正文


PHP PEAR_Registry::getChannel方法代码示例

本文整理汇总了PHP中PEAR_Registry::getChannel方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Registry::getChannel方法的具体用法?PHP PEAR_Registry::getChannel怎么用?PHP PEAR_Registry::getChannel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PEAR_Registry的用法示例。


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

示例1: packageInfo

 /**
  * (non-PHPdoc)
  * @see lib/Faett/Core/Interfaces/Faett_Core_Interfaces_Service#packageInfo($packageName, $channel)
  */
 public function packageInfo($packageName, $channel)
 {
     // store the default channel
     $savechannel = $this->_config->get('default_channel');
     // check if the cannel already exists
     if ($this->_registry->channelExists($channel)) {
         $this->_config->set('default_channel', $channel);
     } else {
         // throw a new exception
         throw Faett_Core_Exceptions_UnknownChannelException::create('Channel ' . $channel . ' does not exist');
     }
     // load the channel from the registry
     $chan = $this->_registry->getChannel($channel);
     // initialize a REST command for checking the channel's state
     $cmd = new PEAR_Command_Remote($this->_ui, $this->_config);
     if (PEAR::isError($e = $cmd->_checkChannelForStatus($channel, $chan))) {
         // reset the default channel
         $this->_config->set('default_channel', $savechannel);
         // throw a new exception
         throw Faett_Core_Exceptions_UnknownChannelStateException::create($e->getMessage());
     }
     // get the channel's base URL
     $base = $chan->getBaseURL('REST1.0', $this->_config->get('preferred_mirror'));
     // check if the channel's server is REST enabled
     $restSupport = $chan->supportsREST($this->_config->get('preferred_mirror'));
     // check if the channel is REST enabled
     if ($restSupport && $base) {
         // load the channel data and the package information
         $rest = $this->_config->getREST('1.0', array());
         $info = $rest->packageInfo($base, $packageName);
     } else {
         $r = $this->_config->getRemote();
         $info = $r->call('package.info', $packageName);
     }
     // check if the package information was loaded successfully
     if (PEAR::isError($info)) {
         // reset the default channel
         $this->_config->set('default_channel', $savechannel);
         // throw a new exception
         throw Faett_Core_Exceptions_PackageInfoException::create($info->getMessage());
     }
     // if no packge name was found log an error message
     if (!isset($info['name'])) {
         // reset the default channel
         $this->_config->set('default_channel', $savechannel);
         // throw a new exception
         throw Faett_Core_Exceptions_PackageInfoException::create('Can\'t find a package name');
     }
     // check if the package is installed
     $installed = $this->_registry->packageInfo($info['name'], null, $channel);
     // if yes, set the information
     $info['installed'] = $installed['version'] ? $installed['version'] : '';
     if (is_array($info['installed'])) {
         $info['installed'] = $info['installed']['release'];
     }
     // return the package information
     return $info;
 }
开发者ID:BGCX067,项目名称:faett-core-svn-to-git,代码行数:62,代码来源:Service.php

示例2: getPackageDownloadUrl

 /**
  * @deprecated in favor of _getPackageDownloadUrl
  */
 function getPackageDownloadUrl($package, $version = null, $channel = false)
 {
     if ($version) {
         $package .= "-{$version}";
     }
     if ($this === null || $this->_registry === null) {
         $package = "http://pear.php.net/get/{$package}";
     } else {
         $chan = $this->_registry->getChannel($channel);
         $package = "http://" . $chan->getServer() . "/get/{$package}";
     }
     if (!extension_loaded("zlib")) {
         $package .= '?uncompress=yes';
     }
     return $package;
 }
开发者ID:BackupTheBerlios,项目名称:rheinaufcms-svn,代码行数:19,代码来源:Downloader.php

示例3: validate


//.........这里部分代码省略.........
     }
     if (!empty($info['release_deps'])) {
         $i = 1;
         foreach ($info['release_deps'] as $d) {
             if (!isset($d['type']) || empty($d['type'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPTYPE, array('index' => $i, 'types' => PEAR_Common::getDependencyTypes()));
                 continue;
             }
             if (!isset($d['rel']) || empty($d['rel'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPREL, array('index' => $i, 'rels' => PEAR_Common::getDependencyRelations()));
                 continue;
             }
             if (!empty($d['optional'])) {
                 if (!in_array($d['optional'], array('yes', 'no'))) {
                     $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_DEPOPTIONAL, array('index' => $i, 'opt' => $d['optional']));
                 }
             }
             if ($d['rel'] != 'has' && $d['rel'] != 'not' && empty($d['version'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPVERSION, array('index' => $i));
             } elseif (($d['rel'] == 'has' || $d['rel'] == 'not') && !empty($d['version'])) {
                 $this->_validateWarning(PEAR_PACKAGEFILE_ERROR_DEPVERSION_IGNORED, array('index' => $i, 'rel' => $d['rel']));
             }
             if ($d['type'] == 'php' && !empty($d['name'])) {
                 $this->_validateWarning(PEAR_PACKAGEFILE_ERROR_DEPNAME_IGNORED, array('index' => $i, 'name' => $d['name']));
             } elseif ($d['type'] != 'php' && empty($d['name'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPNAME, array('index' => $i));
             }
             if ($d['type'] == 'php' && empty($d['version'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPPHPVERSION, array('index' => $i));
             }
             if ($d['rel'] == 'not' && $d['type'] == 'php') {
                 $this->_validateError(PEAR_PACKAGEFILE_PHP_NO_NOT, array('index' => $i));
             }
             $i++;
         }
     }
     if (!empty($info['configure_options'])) {
         $i = 1;
         foreach ($info['configure_options'] as $c) {
             if (empty($c['name'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_CONFNAME, array('index' => $i));
             }
             if (empty($c['prompt'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_CONFPROMPT, array('index' => $i));
             }
             $i++;
         }
     }
     if (empty($info['filelist'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_FILES);
         $errors[] = 'no files';
     } else {
         foreach ($info['filelist'] as $file => $fa) {
             if (empty($fa['role'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_FILEROLE, array('file' => $file, 'roles' => PEAR_Common::getFileRoles()));
                 continue;
             } elseif (!in_array($fa['role'], PEAR_Common::getFileRoles())) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILEROLE, array('file' => $file, 'role' => $fa['role'], 'roles' => PEAR_Common::getFileRoles()));
             }
             if (preg_match('~/\\.\\.?(/|\\z)|^\\.\\.?/~', str_replace('\\', '/', $file))) {
                 // file contains .. parent directory or . cur directory references
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILENAME, array('file' => $file));
             }
             if (isset($fa['install-as']) && preg_match('~/\\.\\.?(/|\\z)|^\\.\\.?/~', str_replace('\\', '/', $fa['install-as']))) {
                 // install-as contains .. parent directory or . cur directory references
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILENAME, array('file' => $file . ' [installed as ' . $fa['install-as'] . ']'));
             }
             if (isset($fa['baseinstalldir']) && preg_match('~/\\.\\.?(/|\\z)|^\\.\\.?/~', str_replace('\\', '/', $fa['baseinstalldir']))) {
                 // install-as contains .. parent directory or . cur directory references
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILENAME, array('file' => $file . ' [baseinstalldir ' . $fa['baseinstalldir'] . ']'));
             }
         }
     }
     if (isset($this->_registry) && $this->_isValid) {
         $chan = $this->_registry->getChannel('pear.php.net');
         if (PEAR::isError($chan)) {
             $this->_validateError(PEAR_PACKAGEFILE_ERROR_CHANNELVAL, $chan->getMessage());
             return $this->_isValid = 0;
         }
         $validator = $chan->getValidationObject();
         $validator->setPackageFile($this);
         $validator->validate($state);
         $failures = $validator->getFailures();
         foreach ($failures['errors'] as $error) {
             $this->_validateError(PEAR_PACKAGEFILE_ERROR_CHANNELVAL, $error);
         }
         foreach ($failures['warnings'] as $warning) {
             $this->_validateWarning(PEAR_PACKAGEFILE_ERROR_CHANNELVAL, $warning);
         }
     }
     if ($this->_isValid && $state == PEAR_VALIDATE_PACKAGING && !$nofilechecking) {
         if ($this->_analyzePhpFiles()) {
             $this->_isValid = true;
         }
     }
     if ($this->_isValid) {
         return $this->_isValid = $state;
     }
     return $this->_isValid = 0;
 }
开发者ID:michabbb,项目名称:pear-core,代码行数:101,代码来源:v1.php

示例4: elseif

 function call_epi($method)
 {
     if (!extension_loaded("xmlrpc")) {
         return $this->raiseError("xmlrpc extension is not loaded");
     }
     $server_channel = $this->config->get('default_channel');
     $channel = $this->_registry->getChannel($server_channel);
     if (!PEAR::isError($channel)) {
         $mirror = $this->config->get('preferred_mirror');
         if ($channel->getMirror($mirror)) {
             if ($channel->supports('xmlrpc', $method, $mirror)) {
                 $server_channel = $server_host = $mirror;
                 // use the preferred mirror
                 $server_port = $channel->getPort($mirror);
             } elseif (!$channel->supports('xmlrpc', $method)) {
                 return $this->raiseError("Channel {$server_channel} does not " . "support xml-rpc method {$method}");
             }
         }
         if (!isset($server_host)) {
             if (!$channel->supports('xmlrpc', $method)) {
                 return $this->raiseError("Channel {$server_channel} does not support " . "xml-rpc method {$method}");
             } else {
                 $server_host = $server_channel;
                 $server_port = $channel->getPort();
             }
         }
     } else {
         return $this->raiseError("Unknown channel '{$server_channel}'");
     }
     $params = func_get_args();
     array_shift($params);
     $method = str_replace("_", ".", $method);
     $request = xmlrpc_encode_request($method, $params);
     if ($http_proxy = $this->config->get('http_proxy')) {
         $proxy = parse_url($http_proxy);
         $proxy_host = $proxy_port = $proxy_user = $proxy_pass = '';
         $proxy_host = isset($proxy['host']) ? $proxy['host'] : null;
         if (isset($proxy['scheme']) && $proxy['scheme'] == 'https') {
             $proxy_host = 'https://' . $proxy_host;
         }
         $proxy_port = isset($proxy['port']) ? $proxy['port'] : null;
         $proxy_user = isset($proxy['user']) ? urldecode($proxy['user']) : null;
         $proxy_pass = isset($proxy['pass']) ? urldecode($proxy['pass']) : null;
         $fp = @fsockopen($proxy_host, $proxy_port);
         $use_proxy = true;
         if ($channel->getSSL()) {
             $server_host = "https://{$server_host}";
         }
     } else {
         $use_proxy = false;
         $ssl = $channel->getSSL();
         $fp = @fsockopen(($ssl ? 'ssl://' : '') . $server_host, $server_port);
         if (!$fp) {
             $server_host = "{$ssl}{$server_host}";
             // for error-reporting
         }
     }
     if (!$fp && $http_proxy) {
         return $this->raiseError("PEAR_Remote::call: fsockopen(`{$proxy_host}', {$proxy_port}) failed");
     } elseif (!$fp) {
         return $this->raiseError("PEAR_Remote::call: fsockopen(`{$server_host}', {$server_port}) failed");
     }
     $len = strlen($request);
     $req_headers = "Host: {$server_host}:{$server_port}\r\n" . "Content-type: text/xml\r\n" . "Content-length: {$len}\r\n";
     $username = $this->config->get('username');
     $password = $this->config->get('password');
     if ($username && $password) {
         $req_headers .= "Cookie: PEAR_USER={$username}; PEAR_PW={$password}\r\n";
         $tmp = base64_encode("{$username}:{$password}");
         $req_headers .= "Authorization: Basic {$tmp}\r\n";
     }
     if ($this->cache !== null) {
         $maxAge = '?maxAge=' . $this->cache['lastChange'];
     } else {
         $maxAge = '';
     }
     if ($use_proxy && $proxy_host != '' && $proxy_user != '') {
         $req_headers .= 'Proxy-Authorization: Basic ' . base64_encode($proxy_user . ':' . $proxy_pass) . "\r\n";
     }
     if ($this->config->get('verbose') > 3) {
         print "XMLRPC REQUEST HEADERS:\n";
         var_dump($req_headers);
         print "XMLRPC REQUEST BODY:\n";
         var_dump($request);
     }
     if ($use_proxy && $proxy_host != '') {
         $post_string = "POST http://" . $server_host;
         if ($proxy_port > '') {
             $post_string .= ':' . $server_port;
         }
     } else {
         $post_string = "POST ";
     }
     $path = '/' . $channel->getPath('xmlrpc');
     fwrite($fp, $post_string . $path . "{$maxAge} HTTP/1.0\r\n{$req_headers}\r\n{$request}");
     $response = '';
     $line1 = fgets($fp, 2048);
     if (!preg_match('!^HTTP/[0-9\\.]+ (\\d+) (.*)!', $line1, $matches)) {
         return $this->raiseError("PEAR_Remote: invalid HTTP response from XML-RPC server");
     }
//.........这里部分代码省略.........
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:101,代码来源:Remote.php


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