本文整理汇总了PHP中PEAR_ChannelFile::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_ChannelFile::validate方法的具体用法?PHP PEAR_ChannelFile::validate怎么用?PHP PEAR_ChannelFile::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR_ChannelFile
的用法示例。
在下文中一共展示了PEAR_ChannelFile::validate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function _initializeChannelDirs()
{
static $running = false;
if (!$running) {
$running = true;
$ds = DIRECTORY_SEPARATOR;
if (!is_dir($this->channelsdir) || !file_exists($this->channelsdir . $ds . 'pear.php.net.reg') || !file_exists($this->channelsdir . $ds . 'pecl.php.net.reg') || !file_exists($this->channelsdir . $ds . 'doc.php.net.reg') || !file_exists($this->channelsdir . $ds . '__uri.reg')) {
if (!file_exists($this->channelsdir . $ds . 'pear.php.net.reg')) {
$pear_channel = $this->_pearChannel;
if (!is_a($pear_channel, 'PEAR_ChannelFile') || !$pear_channel->validate()) {
if (!class_exists('PEAR_ChannelFile')) {
require_once 'PEAR/ChannelFile.php';
}
$pear_channel = new PEAR_ChannelFile();
$pear_channel->setAlias('pear');
$pear_channel->setServer('pear.php.net');
$pear_channel->setSummary('PHP Extension and Application Repository');
$pear_channel->setDefaultPEARProtocols();
$pear_channel->setBaseURL('REST1.0', 'http://pear.php.net/rest/');
$pear_channel->setBaseURL('REST1.1', 'http://pear.php.net/rest/');
$pear_channel->setBaseURL('REST1.3', 'http://pear.php.net/rest/');
//$pear_channel->setBaseURL('REST1.4', 'http://pear.php.net/rest/');
} else {
$pear_channel->setServer('pear.php.net');
$pear_channel->setAlias('pear');
}
$pear_channel->validate();
$this->_addChannel($pear_channel);
}
if (!file_exists($this->channelsdir . $ds . 'pecl.php.net.reg')) {
$pecl_channel = $this->_peclChannel;
if (!is_a($pecl_channel, 'PEAR_ChannelFile') || !$pecl_channel->validate()) {
if (!class_exists('PEAR_ChannelFile')) {
require_once 'PEAR/ChannelFile.php';
}
$pecl_channel = new PEAR_ChannelFile();
$pecl_channel->setAlias('pecl');
$pecl_channel->setServer('pecl.php.net');
$pecl_channel->setSummary('PHP Extension Community Library');
$pecl_channel->setDefaultPEARProtocols();
$pecl_channel->setBaseURL('REST1.0', 'http://pecl.php.net/rest/');
$pecl_channel->setBaseURL('REST1.1', 'http://pecl.php.net/rest/');
$pecl_channel->setValidationPackage('PEAR_Validator_PECL', '1.0');
} else {
$pecl_channel->setServer('pecl.php.net');
$pecl_channel->setAlias('pecl');
}
$pecl_channel->validate();
$this->_addChannel($pecl_channel);
}
if (!file_exists($this->channelsdir . $ds . 'doc.php.net.reg')) {
$doc_channel = $this->_docChannel;
if (!is_a($doc_channel, 'PEAR_ChannelFile') || !$doc_channel->validate()) {
if (!class_exists('PEAR_ChannelFile')) {
require_once 'PEAR/ChannelFile.php';
}
$doc_channel = new PEAR_ChannelFile();
$doc_channel->setAlias('phpdocs');
$doc_channel->setServer('doc.php.net');
$doc_channel->setSummary('PHP Documentation Team');
$doc_channel->setDefaultPEARProtocols();
$doc_channel->setBaseURL('REST1.0', 'http://doc.php.net/rest/');
$doc_channel->setBaseURL('REST1.1', 'http://doc.php.net/rest/');
$doc_channel->setBaseURL('REST1.3', 'http://doc.php.net/rest/');
} else {
$doc_channel->setServer('doc.php.net');
$doc_channel->setAlias('doc');
}
$doc_channel->validate();
$this->_addChannel($doc_channel);
}
if (!file_exists($this->channelsdir . $ds . '__uri.reg')) {
if (!class_exists('PEAR_ChannelFile')) {
require_once 'PEAR/ChannelFile.php';
}
$private = new PEAR_ChannelFile();
$private->setName('__uri');
$private->setDefaultPEARProtocols();
$private->setBaseURL('REST1.0', '****');
$private->setSummary('Pseudo-channel for static packages');
$this->_addChannel($private);
}
$this->_rebuildFileMap();
}
$running = false;
}
}
示例2:
/**
* @param array
* @static
* @return PEAR_ChannelFile|false false if invalid
*/
function &fromArray($data, $compatibility = false, $stackClass = 'PEAR_ErrorStack')
{
$a = new PEAR_ChannelFile($compatibility, $stackClass);
$a->_fromArray($data);
if (!$a->validate()) {
$a = false;
return $a;
}
return $a;
}
示例3: validate
/** A method to validate a channel */
static function validate(HTTP_Request2 $req, PEAR_ChannelFile $chan)
{
$response = $req->send();
if ($response->getStatus() != 200) {
throw new Exception("Invalid channel site");
}
if (!$response->getBody()) {
throw new Exception("Empty channel.xml");
}
if (strlen($response->getBody()) > 100000) {
throw new Exception("Channel.xml too large");
}
if (!$chan->fromXmlString($response->getBody())) {
throw new Exception("Invalid xml");
}
if (!$chan->validate()) {
throw new Exception("Invalid channel file");
}
return true;
}
示例4: doInfo
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);
if (PEAR::isError($chan)) {
return $this->raiseError($chan);
}
} else {
if (strpos($channel, '://')) {
$downloader =& $this->getDownloader();
$tmpdir = $this->config->get('temp_dir');
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$loc = $downloader->downloadHttp($channel, $this->ui, $tmpdir);
PEAR::staticPopErrorHandling();
if (PEAR::isError($loc)) {
return $this->raiseError('Cannot open "' . $channel . '" (' . $loc->getMessage() . ')');
} else {
$contents = implode('', file($loc));
}
} else {
if (file_exists($params[0])) {
$fp = fopen($params[0], 'r');
if (!$fp) {
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');
}
//.........这里部分代码省略.........
示例5:
<?php
require_once "HTTP/Request.php";
require_once "Net/URL2.php";
$url =& new Net_URL2("http://mediawiki.googlecode.com/svn");
echo "url protocol: " . $url->protocol . "\n";
echo "url host: " . $url->host . "\n";
echo "url port: " . $url->port . "\n";
$req =& new HTTP_Request();
$req->setURL($url->protocol . "://" . $url->host . ":" . $url->port . "/channel.xml");
$req->sendRequest();
echo $req->getResponseCode();
require_once 'PEAR/ChannelFile.php';
$chan = new PEAR_ChannelFile();
echo 'XML: ';
if (!$chan->fromXmlString($req->getResponseBody())) {
echo 'channel.xml invalid';
die;
}
echo "OK \n";
echo "CHANNEL SEMANTIC: ";
if (!$chan->validate()) {
echo 'channel.xml invalid';
die;
}
echo "OK \n";
echo "server: " . $chan->getServer();