Update to PEAR 1.7.2, Image_Canvas 0.3.1, Image_Color 1.0.3, Image_Graph 0.7.2, XML_Parser 1.3.1.
Removed PHP_Compat, and references to it. Removed ionCube/Zend/mmCache compatibility checks in test.php script. Changed minimum PHP requirement to 5.0 in test.php script.
This commit is contained in:
@@ -16,9 +16,9 @@
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Channels.php,v 1.42 2005/05/11 19:44:16 cellog Exp $
|
||||
* @version CVS: $Id: Channels.php,v 1.57 2008/01/03 20:26:36 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 1.4.0a1
|
||||
*/
|
||||
@@ -34,9 +34,9 @@ require_once 'PEAR/Command/Common.php';
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.4.5
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 1.4.0a1
|
||||
*/
|
||||
@@ -132,8 +132,13 @@ alias.
|
||||
'function' => 'doDiscover',
|
||||
'shortcut' => 'di',
|
||||
'options' => array(),
|
||||
'doc' => '<package>
|
||||
List the files in an installed package.
|
||||
'doc' => '[<channel.xml>|<channel name>]
|
||||
Initialize a channel from its server and create a local channel.xml.
|
||||
If <channel name> is in the format "<username>:<password>@<channel>" then
|
||||
<username> and <password> will be set as the login username/password for
|
||||
<channel>. Use caution when passing the username/password in this way, as
|
||||
it may allow other users on your computer to briefly view your username/
|
||||
password via the system\'s process list.
|
||||
'
|
||||
),
|
||||
);
|
||||
@@ -185,133 +190,24 @@ List the files in an installed package.
|
||||
function doUpdateAll($command, $options, $params)
|
||||
{
|
||||
$reg = &$this->config->getRegistry();
|
||||
$savechannel = $this->config->get('default_channel');
|
||||
if (isset($options['channel'])) {
|
||||
if (!$reg->channelExists($options['channel'])) {
|
||||
return $this->raiseError('Unknown channel "' . $options['channel'] . '"');
|
||||
}
|
||||
$this->config->set('default_channel', $options['channel']);
|
||||
} else {
|
||||
$this->config->set('default_channel', 'pear.php.net');
|
||||
}
|
||||
$remote = &$this->config->getRemote();
|
||||
$channels = $remote->call('channel.listAll');
|
||||
if (PEAR::isError($channels)) {
|
||||
$this->config->set('default_channel', $savechannel);
|
||||
return $channels;
|
||||
}
|
||||
if (!is_array($channels) || isset($channels['faultCode'])) {
|
||||
$this->config->set('default_channel', $savechannel);
|
||||
return $this->raiseError("Incorrect channel listing returned from channel '$chan'");
|
||||
}
|
||||
if (!count($channels)) {
|
||||
$data = 'no updates available';
|
||||
}
|
||||
$dl = &$this->getDownloader();
|
||||
if (!class_exists('System')) {
|
||||
require_once 'System.php';
|
||||
}
|
||||
$tmpdir = System::mktemp(array('-d'));
|
||||
$channels = $reg->getChannels();
|
||||
|
||||
$success = true;
|
||||
foreach ($channels as $channel) {
|
||||
$channel = $channel[0];
|
||||
$save = $channel;
|
||||
if ($reg->channelExists($channel, true)) {
|
||||
$this->ui->outputData("Updating channel \"$channel\"", $command);
|
||||
$test = $reg->getChannel($channel, true);
|
||||
if (!$test) {
|
||||
$this->ui->outputData("Channel '$channel' is corrupt in registry!", $command);
|
||||
$lastmodified = false;
|
||||
if ($channel->getName() != '__uri') {
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$err = $this->doUpdate('channel-update',
|
||||
$options,
|
||||
array($channel->getName()));
|
||||
if (PEAR::isError($err)) {
|
||||
$this->ui->outputData($err->getMessage(), $command);
|
||||
$success = false;
|
||||
} else {
|
||||
$lastmodified = $test->lastModified();
|
||||
|
||||
$success &= $err;
|
||||
}
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$contents = $dl->downloadHttp('http://' . $test->getName() . '/channel.xml',
|
||||
$this->ui, $tmpdir, null, $lastmodified);
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (PEAR::isError($contents)) {
|
||||
$this->ui->outputData('ERROR: Cannot retrieve channel.xml for channel "' .
|
||||
$test->getName() . '"', $command);
|
||||
continue;
|
||||
}
|
||||
if (!$contents) {
|
||||
$this->ui->outputData("Channel \"$channel\" is up-to-date", $command);
|
||||
continue;
|
||||
}
|
||||
list($contents, $lastmodified) = $contents;
|
||||
$info = implode('', file($contents));
|
||||
if (!$info) {
|
||||
$this->ui->outputData("Channel \"$channel\" is up-to-date", $command);
|
||||
continue;
|
||||
}
|
||||
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->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;
|
||||
return $success;
|
||||
}
|
||||
|
||||
function doInfo($command, $options, $params)
|
||||
@@ -323,29 +219,30 @@ List the files in an installed package.
|
||||
$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();
|
||||
if (!class_exists('System')) {
|
||||
require_once 'System.php';
|
||||
}
|
||||
$tmpdir = System::mktemp(array('-d'));
|
||||
$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 . '"');
|
||||
return $this->raiseError('Cannot open "' . $channel .
|
||||
'" (' . $loc->getMessage() . ')');
|
||||
} else {
|
||||
$contents = implode('', file($loc));
|
||||
}
|
||||
} else {
|
||||
$fp = @fopen($params[0], 'r');
|
||||
if (!$fp) {
|
||||
if (@file_exists($params[0])) {
|
||||
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 . '"');
|
||||
}
|
||||
} else {
|
||||
return $this->raiseError('Unknown channel "' . $channel . '"');
|
||||
}
|
||||
$contents = '';
|
||||
while (!feof($fp)) {
|
||||
@@ -431,7 +328,7 @@ List the files in an installed package.
|
||||
$data['data'][] = array($mirror['attribs']['host']);
|
||||
$d['mirrors'] = $data;
|
||||
}
|
||||
foreach ($mirrors as $mirror) {
|
||||
foreach ($mirrors as $i => $mirror) {
|
||||
$data['data'] = array();
|
||||
$data['caption'] = 'Mirror ' . $mirror['attribs']['host'] . ' Capabilities';
|
||||
$data['headline'] = array('Type', 'Version/REST type', 'Function Name/REST base');
|
||||
@@ -469,7 +366,7 @@ List the files in an installed package.
|
||||
} else {
|
||||
$data['data'][] = array('No supported protocols');
|
||||
}
|
||||
$d['mirrorprotocols'] = $data;
|
||||
$d['mirrorprotocols' . $i] = $data;
|
||||
}
|
||||
}
|
||||
$this->ui->outputData($d, 'channel-info');
|
||||
@@ -522,22 +419,38 @@ List the files in an installed package.
|
||||
}
|
||||
if (strpos($params[0], '://')) {
|
||||
$downloader = &$this->getDownloader();
|
||||
if (!class_exists('System')) {
|
||||
$tmpdir = $this->config->get('temp_dir');
|
||||
if (!file_exists($tmpdir)) {
|
||||
require_once 'System.php';
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$err = System::mkdir(array('-p', $tmpdir));
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (PEAR::isError($err)) {
|
||||
return $this->raiseError('channel-add: temp_dir does not exist: "' .
|
||||
$tmpdir .
|
||||
'" - You can change this location with "pear config-set temp_dir"');
|
||||
}
|
||||
}
|
||||
if (!is_writable($tmpdir)) {
|
||||
return $this->raiseError('channel-add: temp_dir is not writable: "' .
|
||||
$tmpdir .
|
||||
'" - You can change this location with "pear config-set temp_dir"');
|
||||
}
|
||||
$tmpdir = System::mktemp(array('-d'));
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$loc = $downloader->downloadHttp($params[0], $this->ui, $tmpdir, null, false);
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (PEAR::isError($loc)) {
|
||||
return $this->raiseError('channel-add: Cannot open "' . $params[0] . '"');
|
||||
return $this->raiseError('channel-add: Cannot open "' . $params[0] .
|
||||
'" (' . $loc->getMessage() . ')');
|
||||
} else {
|
||||
list($loc, $lastmodified) = $loc;
|
||||
$contents = implode('', file($loc));
|
||||
}
|
||||
} else {
|
||||
$lastmodified = false;
|
||||
$fp = @fopen($params[0], 'r');
|
||||
$lastmodified = $fp = false;
|
||||
if (file_exists($params[0])) {
|
||||
$fp = fopen($params[0], 'r');
|
||||
}
|
||||
if (!$fp) {
|
||||
return $this->raiseError('channel-add: cannot open "' . $params[0] . '"');
|
||||
}
|
||||
@@ -588,10 +501,23 @@ List the files in an installed package.
|
||||
|
||||
function doUpdate($command, $options, $params)
|
||||
{
|
||||
if (!class_exists('System')) {
|
||||
$tmpdir = $this->config->get('temp_dir');
|
||||
if (!file_exists($tmpdir)) {
|
||||
require_once 'System.php';
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$err = System::mkdir(array('-p', $tmpdir));
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (PEAR::isError($err)) {
|
||||
return $this->raiseError('channel-add: temp_dir does not exist: "' .
|
||||
$tmpdir .
|
||||
'" - You can change this location with "pear config-set temp_dir"');
|
||||
}
|
||||
}
|
||||
if (!is_writable($tmpdir)) {
|
||||
return $this->raiseError('channel-add: temp_dir is not writable: "' .
|
||||
$tmpdir .
|
||||
'" - You can change this location with "pear config-set temp_dir"');
|
||||
}
|
||||
$tmpdir = System::mktemp(array('-d'));
|
||||
$reg = &$this->config->getRegistry();
|
||||
if (sizeof($params) != 1) {
|
||||
return $this->raiseError("No channel file specified");
|
||||
@@ -600,7 +526,10 @@ List the files in an installed package.
|
||||
if ((!file_exists($params[0]) || is_dir($params[0]))
|
||||
&& $reg->channelExists(strtolower($params[0]))) {
|
||||
$c = $reg->getChannel(strtolower($params[0]));
|
||||
$this->ui->outputData('Retrieving channel.xml from remote server');
|
||||
if (PEAR::isError($c)) {
|
||||
return $this->raiseError($c);
|
||||
}
|
||||
$this->ui->outputData("Updating channel \"$params[0]\"", $command);
|
||||
$dl = &$this->getDownloader(array());
|
||||
// if force is specified, use a timestamp of "1" to force retrieval
|
||||
$lastmodified = isset($options['force']) ? false : $c->lastModified();
|
||||
@@ -610,11 +539,11 @@ List the files in an installed package.
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (PEAR::isError($contents)) {
|
||||
return $this->raiseError('Cannot retrieve channel.xml for channel "' .
|
||||
$c->getName() . '"');
|
||||
$c->getName() . '" (' . $contents->getMessage() . ')');
|
||||
}
|
||||
list($contents, $lastmodified) = $contents;
|
||||
if (!$contents) {
|
||||
$this->ui->outputData("Channel $params[0] channel.xml is up to date");
|
||||
$this->ui->outputData("Channel \"$params[0]\" is up to date");
|
||||
return;
|
||||
}
|
||||
$contents = implode('', file($contents));
|
||||
@@ -645,13 +574,17 @@ List the files in an installed package.
|
||||
$this->ui, $tmpdir, null, $lastmodified);
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (PEAR::isError($loc)) {
|
||||
return $this->raiseError("Cannot open " . $params[0]);
|
||||
return $this->raiseError("Cannot open " . $params[0] .
|
||||
' (' . $loc->getMessage() . ')');
|
||||
} else {
|
||||
list($loc, $lastmodified) = $loc;
|
||||
$contents = implode('', file($loc));
|
||||
}
|
||||
} else {
|
||||
$fp = @fopen($params[0], 'r');
|
||||
$fp = false;
|
||||
if (file_exists($params[0])) {
|
||||
$fp = fopen($params[0], 'r');
|
||||
}
|
||||
if (!$fp) {
|
||||
return $this->raiseError("Cannot open " . $params[0]);
|
||||
}
|
||||
@@ -729,9 +662,9 @@ List the files in an installed package.
|
||||
'already aliased to "' . strtolower($params[1]) . '", cannot re-alias');
|
||||
}
|
||||
$chan = &$reg->getChannel($params[0]);
|
||||
if (!$chan) {
|
||||
if (PEAR::isError($chan)) {
|
||||
return $this->raiseError('Corrupt registry? Error retrieving channel "' . $params[0] .
|
||||
'" information');
|
||||
'" information (' . $chan->getMessage() . ')');
|
||||
}
|
||||
// make it a local alias
|
||||
if (!$chan->setAlias(strtolower($params[1]), true)) {
|
||||
@@ -743,28 +676,62 @@ List the files in an installed package.
|
||||
strtolower($params[1]) . '"');
|
||||
}
|
||||
|
||||
/**
|
||||
* The channel-discover command
|
||||
*
|
||||
* @param string $command command name
|
||||
* @param array $options option_name => value
|
||||
* @param array $params list of additional parameters.
|
||||
* $params[0] should contain a string with either:
|
||||
* - <channel name> or
|
||||
* - <username>:<password>@<channel name>
|
||||
* @return null|PEAR_Error
|
||||
*/
|
||||
function doDiscover($command, $options, $params)
|
||||
{
|
||||
$reg = &$this->config->getRegistry();
|
||||
if (sizeof($params) != 1) {
|
||||
return $this->raiseError("No channel server specified");
|
||||
}
|
||||
if ($reg->channelExists($params[0])) {
|
||||
if ($reg->isAlias($params[0])) {
|
||||
return $this->raiseError("A channel alias named \"$params[0]\" " .
|
||||
'already exists, aliasing channel "' . $reg->channelName($params[0])
|
||||
|
||||
// Look for the possible input format "<username>:<password>@<channel>"
|
||||
if (preg_match('/^(.+):(.+)@(.+)\\z/', $params[0], $matches)) {
|
||||
$username = $matches[1];
|
||||
$password = $matches[2];
|
||||
$channel = $matches[3];
|
||||
} else {
|
||||
$channel = $params[0];
|
||||
}
|
||||
|
||||
if ($reg->channelExists($channel)) {
|
||||
if ($reg->isAlias($channel)) {
|
||||
return $this->raiseError("A channel alias named \"$channel\" " .
|
||||
'already exists, aliasing channel "' . $reg->channelName($channel)
|
||||
. '"');
|
||||
} else {
|
||||
return $this->raiseError("Channel \"$params[0]\" is already initialized");
|
||||
return $this->raiseError("Channel \"$channel\" is already initialized");
|
||||
}
|
||||
}
|
||||
$this->pushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$err = $this->doAdd($command, $options, array('http://' . $params[0] . '/channel.xml'));
|
||||
$err = $this->doAdd($command, $options, array('http://' . $channel . '/channel.xml'));
|
||||
$this->popErrorHandling();
|
||||
if (PEAR::isError($err)) {
|
||||
return $this->raiseError("Discovery of channel \"$params[0]\" failed");
|
||||
return $this->raiseError("Discovery of channel \"$channel\" failed (" .
|
||||
$err->getMessage() . ')');
|
||||
}
|
||||
$this->ui->outputData("Discovery of channel \"$params[0]\" succeeded", $command);
|
||||
|
||||
// Store username/password if they were given
|
||||
// Arguably we should do a logintest on the channel here, but since
|
||||
// that's awkward on a REST-based channel (even "pear login" doesn't
|
||||
// do it for those), and XML-RPC is deprecated, it's fairly pointless.
|
||||
if (isset($username)) {
|
||||
$this->config->set('username', $username, 'user', $channel);
|
||||
$this->config->set('password', $password, 'user', $channel);
|
||||
$this->config->store();
|
||||
$this->ui->outputData("Stored login for channel \"$channel\" using username \"$username\"", $command);
|
||||
}
|
||||
|
||||
$this->ui->outputData("Discovery of channel \"$channel\" succeeded", $command);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user