![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| Pear Pear programming, this is a very complex subject as with using pear with php can be a difficult task for some, so lets talk pear. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| cellog Sun May 20 00:25:55 2007 UTC Modified files: /pear-core/PEAR/Command Channels.xml Channels.php Log: re-implement Request #10579 channel-discover should support inline username/password [timj] http://cvs.php.net/viewvc.cgi/pear-c...&diff_format=u Index: pear-core/PEAR/Command/Channels.xml diff -u pear-core/PEAR/Command/Channels.xml:1.2 pear-core/PEAR/Command/Channels.xml:1.3 --- pear-core/PEAR/Command/Channels.xml:1.2 Mon Jul 17 18:19:25 2006 +++ pear-core/PEAR/Command/Channels.xml Sun May 20 00:25:55 2007 @@ -87,7 +87,12 @@ <shortcut>di</shortcut> <options /> <doc>[<channel.xml>|<channel name>] -Initialize a Channel from its server and create the local channel.xml. +Initialize a channel from its server and create a local channel.xml. +If <channel name> is in the format "<username>:<password>@<channe l>" 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. </doc> </channel-discover> </commands> http://cvs.php.net/viewvc.cgi/pear-c...&diff_format=u Index: pear-core/PEAR/Command/Channels.php diff -u pear-core/PEAR/Command/Channels.php:1.54 pear-core/PEAR/Command/Channels.php:1.55 --- pear-core/PEAR/Command/Channels.php:1.54 Sun May 6 23:31:51 2007 +++ pear-core/PEAR/Command/Channels.php Sun May 20 00:25:55 2007 @@ -18,7 +18,7 @@ * @author Greg Beaver <cellog@php.net> * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Channels.php,v 1.54 2007/05/06 23:31:51 cellog Exp $ + * @version CVS: $Id: Channels.php,v 1.55 2007/05/20 00:25:55 cellog Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 1.4.0a1 */ @@ -133,7 +133,12 @@ 'shortcut' => 'di', 'options' => array(), 'doc' => '[<channel.xml>|<channel name>] -Initialize a Channel from its server and creates the local channel.xml. +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. ' ), ); @@ -671,29 +676,62 @@ 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('/^(.+) + $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); } } ?> | |||
| Featured Websites | ||||
|
![]() |
| Tags: channelsphp, channelsxml, cvs, pearcommand, pearcore |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| cvs: pear-core /PEAR/Command Remote.php | Greg Beaver | Pear | 0 | 05-20-2007 7:42 PM |
| cvs: pear-core /PEAR/Command Auth.php | Greg Beaver | Pear | 0 | 05-20-2007 7:42 PM |
| cvs: pear-core /PEAR/Command Install.php | Greg Beaver | Pear | 0 | 05-20-2007 7:42 PM |
| cvs: pear-core / package-PEAR.xml package2.xml /PEAR/PackageFile/Generator v2.php | Greg Beaver | Pear | 0 | 05-20-2007 7:42 PM |
| cvs: pear-core / package-PEAR.xml package2.xml /PEAR Installer.php /PEAR/PackageFile v1.php /PEAR/PackageFile/v2 Validator.php | Greg Beaver | Pear | 0 | 05-20-2007 7:42 PM |
| Featured Websites | ||||
|