Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Shift PEAR_RemoteInstaller to seperate package

  • Loading branch information...
commit 48e9a4d52e400c42a725c7c25acf7917e2e07750 1 parent d74b149
Daniel O'Connor CloCkWeRX authored
360 PEAR/Command/Remoteinstall.php
... ... @@ -1,360 +0,0 @@
1   -<?php
2   -/**
3   - * PEAR_Command_Install (remote-install, remote-upgrade, remote-upgrade-all, remote-uninstall commands)
4   - *
5   - * PHP versions 4 and 5
6   - *
7   - * @category pear
8   - * @package PEAR
9   - * @author Stig Bakken <ssb@php.net>
10   - * @author Greg Beaver <cellog@php.net>
11   - * @copyright 1997-2009 The Authors
12   - * @license http://opensource.org/licenses/bsd-license.php New BSD License
13   - * @version CVS: $Id$
14   - * @link http://pear.php.net/package/PEAR
15   - * @since File available since Release 0.1
16   - */
17   -
18   -/**
19   - * base class
20   - */
21   -require_once 'PEAR/Command/Install.php';
22   -
23   -define('PEAR_REMOTEINSTALL_OK', 1);
24   -/**
25   - * PEAR commands for installation or deinstallation/upgrading of
26   - * packages.
27   - *
28   - * @category pear
29   - * @package PEAR
30   - * @author Stig Bakken <ssb@php.net>
31   - * @author Greg Beaver <cellog@php.net>
32   - * @copyright 1997-2009 The Authors
33   - * @license http://opensource.org/licenses/bsd-license.php New BSD License
34   - * @version Release: @package_version@
35   - * @link http://pear.php.net/package/PEAR
36   - * @since Class available since Release 0.1
37   - */
38   -class PEAR_Command_RemoteInstall extends PEAR_Command_Install
39   -{
40   - var $commands = array(
41   - 'remote-install' => array(
42   - 'summary' => 'Install Package',
43   - 'function' => 'doInstall',
44   - 'shortcut' => 'inr',
45   - 'options' => array(
46   - 'force' => array(
47   - 'shortopt' => 'f',
48   - 'doc' => 'will overwrite newer installed packages',
49   - ),
50   - 'nodeps' => array(
51   - 'shortopt' => 'n',
52   - 'doc' => 'ignore dependencies, install anyway',
53   - ),
54   - 'register-only' => array(
55   - 'shortopt' => 'r',
56   - 'doc' => 'do not install files, only register the package as installed',
57   - ),
58   - 'soft' => array(
59   - 'shortopt' => 's',
60   - 'doc' => 'soft install, fail silently, or upgrade if already installed',
61   - ),
62   - 'nobuild' => array(
63   - 'shortopt' => 'B',
64   - 'doc' => 'don\'t build C extensions',
65   - ),
66   - 'nocompress' => array(
67   - 'shortopt' => 'Z',
68   - 'doc' => 'request uncompressed files when downloading',
69   - ),
70   - 'installroot' => array(
71   - 'shortopt' => 'R',
72   - 'arg' => 'DIR',
73   - 'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
74   - ),
75   - 'ignore-errors' => array(
76   - 'doc' => 'force install even if there were errors',
77   - ),
78   - 'alldeps' => array(
79   - 'shortopt' => 'a',
80   - 'doc' => 'install all required and optional dependencies',
81   - ),
82   - 'onlyreqdeps' => array(
83   - 'shortopt' => 'o',
84   - 'doc' => 'install all required dependencies',
85   - ),
86   - 'remoteconfig' => array(
87   - 'shortopt' => 'F',
88   - 'arg' => 'URL',
89   - 'doc' => 'also install to ftp site using remote config file (ftp://host.com/pear.conf)'
90   - ),
91   - 'offline' => array(
92   - 'shortopt' => 'O',
93   - 'doc' => 'do not attempt to download any urls or contact channels',
94   - ),
95   - 'pretend' => array(
96   - 'shortopt' => 'p',
97   - 'doc' => 'Only list the packages that would be downloaded',
98   - ),
99   - ),
100   - 'doc' => '[channel/]<package> ...
101   -Installs one or more PEAR packages. You can specify a package to
102   -install in four ways:
103   -
104   -"Package-1.0.tgz" : installs from a local file
105   -
106   -"http://example.com/Package-1.0.tgz" : installs from
107   -anywhere on the net.
108   -
109   -"package.xml" : installs the package described in
110   -package.xml. Useful for testing, or for wrapping a PEAR package in
111   -another package manager such as RPM.
112   -
113   -"Package[-version/state][.tar]" : queries your default channel\'s server
114   -({config master_server}) and downloads the newest package with
115   -the preferred quality/state ({config preferred_state}).
116   -
117   -To retrieve Package version 1.1, use "Package-1.1," to retrieve
118   -Package state beta, use "Package-beta." To retrieve an uncompressed
119   -file, append .tar (make sure there is no file by the same name first)
120   -
121   -To download a package from another channel, prefix with the channel name like
122   -"channel/Package"
123   -
124   -More than one package may be specified at once. It is ok to mix these
125   -four ways of specifying packages.
126   -'),
127   - 'remote-upgrade' => array(
128   - 'summary' => 'Upgrade Package',
129   - 'function' => 'doInstall',
130   - 'shortcut' => 'upr',
131   - 'options' => array(
132   - 'force' => array(
133   - 'shortopt' => 'f',
134   - 'doc' => 'overwrite newer installed packages',
135   - ),
136   - 'nodeps' => array(
137   - 'shortopt' => 'n',
138   - 'doc' => 'ignore dependencies, upgrade anyway',
139   - ),
140   - 'register-only' => array(
141   - 'shortopt' => 'r',
142   - 'doc' => 'do not install files, only register the package as upgraded',
143   - ),
144   - 'nobuild' => array(
145   - 'shortopt' => 'B',
146   - 'doc' => 'don\'t build C extensions',
147   - ),
148   - 'nocompress' => array(
149   - 'shortopt' => 'Z',
150   - 'doc' => 'request uncompressed files when downloading',
151   - ),
152   - 'installroot' => array(
153   - 'shortopt' => 'R',
154   - 'arg' => 'DIR',
155   - 'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
156   - ),
157   - 'ignore-errors' => array(
158   - 'doc' => 'force install even if there were errors',
159   - ),
160   - 'alldeps' => array(
161   - 'shortopt' => 'a',
162   - 'doc' => 'install all required and optional dependencies',
163   - ),
164   - 'onlyreqdeps' => array(
165   - 'shortopt' => 'o',
166   - 'doc' => 'install all required dependencies',
167   - ),
168   - 'remoteconfig' => array(
169   - 'shortopt' => 'F',
170   - 'arg' => 'URL',
171   - 'doc' => 'also upgrade on ftp site using remote config file (ftp://host.com/pear.conf)'
172   - ),
173   - 'offline' => array(
174   - 'shortopt' => 'O',
175   - 'doc' => 'do not attempt to download any urls or contact channels',
176   - ),
177   - 'pretend' => array(
178   - 'shortopt' => 'p',
179   - 'doc' => 'Only list the packages that would be downloaded',
180   - ),
181   - ),
182   - 'doc' => '<package> ...
183   -Upgrades one or more PEAR packages. See documentation for the
184   -"install" command for ways to specify a package.
185   -
186   -When upgrading, your package will be updated if the provided new
187   -package has a higher version number (use the -f option if you need to
188   -upgrade anyway).
189   -
190   -More than one package may be specified at once.
191   -'),
192   - 'remote-upgrade-all' => array(
193   - 'summary' => 'Upgrade All Packages',
194   - 'function' => 'doInstall',
195   - 'shortcut' => 'uar',
196   - 'options' => array(
197   - 'nodeps' => array(
198   - 'shortopt' => 'n',
199   - 'doc' => 'ignore dependencies, upgrade anyway',
200   - ),
201   - 'register-only' => array(
202   - 'shortopt' => 'r',
203   - 'doc' => 'do not install files, only register the package as upgraded',
204   - ),
205   - 'nobuild' => array(
206   - 'shortopt' => 'B',
207   - 'doc' => 'don\'t build C extensions',
208   - ),
209   - 'nocompress' => array(
210   - 'shortopt' => 'Z',
211   - 'doc' => 'request uncompressed files when downloading',
212   - ),
213   - 'installroot' => array(
214   - 'shortopt' => 'R',
215   - 'arg' => 'DIR',
216   - 'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
217   - ),
218   - 'ignore-errors' => array(
219   - 'doc' => 'force install even if there were errors',
220   - ),
221   - 'remoteconfig' => array(
222   - 'shortopt' => 'F',
223   - 'arg' => 'URL',
224   - 'doc' => 'also upgrade on ftp site using remote config file (ftp://host.com/pear.conf)'
225   - ),
226   - ),
227   - 'doc' => '
228   -Upgrades all packages that have a newer release available. Upgrades are
229   -done only if there is a release available of the state specified in
230   -"preferred_state" (currently {config preferred_state}), or a state considered
231   -more stable.
232   -'),
233   - 'remote-uninstall' => array(
234   - 'summary' => 'Un-install Package',
235   - 'function' => 'doUninstall',
236   - 'shortcut' => 'unr',
237   - 'options' => array(
238   - 'nodeps' => array(
239   - 'shortopt' => 'n',
240   - 'doc' => 'ignore dependencies, uninstall anyway',
241   - ),
242   - 'register-only' => array(
243   - 'shortopt' => 'r',
244   - 'doc' => 'do not remove files, only register the packages as not installed',
245   - ),
246   - 'installroot' => array(
247   - 'shortopt' => 'R',
248   - 'arg' => 'DIR',
249   - 'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
250   - ),
251   - 'ignore-errors' => array(
252   - 'doc' => 'force install even if there were errors',
253   - ),
254   - 'remoteconfig' => array(
255   - 'shortopt' => 'F',
256   - 'arg' => 'URL',
257   - 'doc' => 'also uninstall on ftp site using remote config file (ftp://host.com/pear.conf)'
258   - ),
259   - 'offline' => array(
260   - 'shortopt' => 'O',
261   - 'doc' => 'do not attempt to uninstall remotely',
262   - ),
263   - ),
264   - 'doc' => '[channel/]<package> ...
265   -Uninstalls one or more PEAR packages. More than one package may be
266   -specified at once. Prefix with channel name to uninstall from a
267   -channel not in your default channel ({config default_channel})
268   -'),
269   - );
270   -
271   - /**
272   - * PEAR_Command_Install constructor.
273   - *
274   - * @access public
275   - */
276   - function PEAR_Command_Remoteinstall(&$ui, &$config)
277   - {
278   - parent::PEAR_Command_Install($ui, $config);
279   - }
280   -
281   - /**
282   - * For unit testing purposes
283   - */
284   - function &getDownloader(&$ui, $options, &$config)
285   - {
286   - if (!class_exists('PEAR_Downloader')) {
287   - require_once 'PEAR/Downloader.php';
288   - }
289   - $a = &new PEAR_Downloader($ui, $options, $config);
290   - return $a;
291   - }
292   -
293   - /**
294   - * For unit testing purposes
295   - */
296   - function &getInstaller(&$ui)
297   - {
298   - if (!class_exists('PEAR_RemoteInstaller')) {
299   - require_once 'PEAR/RemoteInstaller.php';
300   - }
301   - $a = &new PEAR_RemoteInstaller($ui);
302   - return $a;
303   - }
304   -
305   - function doInstall($command, $options, $params)
306   - {
307   - if (empty($this->installer)) {
308   - $this->installer = &$this->getInstaller($this->ui);
309   - }
310   -
311   - if (isset($options['remoteconfig'])) {
312   - $e = $this->config->readFTPConfigFile($options['remoteconfig']);
313   - if (!PEAR::isError($e)) {
314   - $this->installer->setConfig($this->config);
315   - }
316   - } elseif (!$this->config->get('remote_config')) {
317   - return $this->raiseError('Error: ' . $command . ' expects either option ' .
318   - '"remoteconfig" be set, or remote_config configuration variable be used');
319   - } else {
320   - $e = $this->config->readFTPConfigFile($this->config->get('remote_config'));
321   - if (!PEAR::isError($e)) {
322   - $this->installer->setConfig($this->config);
323   - }
324   - }
325   -
326   - $command = str_replace('remote-', '', $command); // fool parent
327   - return parent::doInstall($command, $options, $params);
328   - }
329   -
330   - function doUninstall($command, $options, $params)
331   - {
332   - if (empty($this->installer)) {
333   - $this->installer = &$this->getInstaller($this->ui);
334   - }
335   -
336   - if (isset($options['remoteconfig'])) {
337   - $e = $this->config->readFTPConfigFile($options['remoteconfig']);
338   - if (!PEAR::isError($e)) {
339   - $this->installer->setConfig($this->config);
340   - }
341   - } elseif (!$this->config->get('remote_config')) {
342   - return $this->raiseError('Error: ' . $command . ' expects either option ' .
343   - '"remoteconfig" be set, or remote_config configuration variable be used');
344   - } else {
345   - $e = $this->config->readFTPConfigFile($this->config->get('remote_config'));
346   - if (!PEAR::isError($e)) {
347   - $this->installer->setConfig($this->config);
348   - }
349   - }
350   -
351   - $command = 'uninstall'; // fool parent
352   - return parent::doUninstall($command, $options, $params);
353   - }
354   -}
355   -
356   -/**
357   - * This is a hack for PEAR 1.4.x to work
358   - * @ignore
359   - */
360   -class Net_FTP {}
238 PEAR/Command/Remoteinstall.xml
... ... @@ -1,238 +0,0 @@
1   -<commands version="1.0">
2   - <remote-install>
3   - <summary>Install Package</summary>
4   - <function>doInstall</function>
5   - <shortcut>inr</shortcut>
6   - <options>
7   - <force>
8   - <shortopt>f</shortopt>
9   - <doc>will overwrite newer installed packages</doc>
10   - </force>
11   - <nodeps>
12   - <shortopt>n</shortopt>
13   - <doc>ignore dependencies, install anyway</doc>
14   - </nodeps>
15   - <register-only>
16   - <shortopt>r</shortopt>
17   - <doc>do not install files, only register the package as installed</doc>
18   - </register-only>
19   - <soft>
20   - <shortopt>s</shortopt>
21   - <doc>soft install, fail silently, or upgrade if already installed</doc>
22   - </soft>
23   - <nobuild>
24   - <shortopt>B</shortopt>
25   - <doc>don&#039;t build C extensions</doc>
26   - </nobuild>
27   - <nocompress>
28   - <shortopt>Z</shortopt>
29   - <doc>request uncompressed files when downloading</doc>
30   - </nocompress>
31   - <installroot>
32   - <shortopt>R</shortopt>
33   - <doc>root directory used when installing files (ala PHP&#039;s INSTALL_ROOT)</doc>
34   - <arg>DIR</arg>
35   - </installroot>
36   - <ignore-errors>
37   - <shortopt></shortopt>
38   - <doc>force install even if there were errors</doc>
39   - </ignore-errors>
40   - <alldeps>
41   - <shortopt>a</shortopt>
42   - <doc>install all required and optional dependencies</doc>
43   - </alldeps>
44   - <onlyreqdeps>
45   - <shortopt>o</shortopt>
46   - <doc>install all required dependencies</doc>
47   - </onlyreqdeps>
48   - <remoteconfig>
49   - <shortopt>F</shortopt>
50   - <doc>also install to ftp site using remote config file (ftp://host.com/pear.conf)</doc>
51   - <arg>URL</arg>
52   - </remoteconfig>
53   - <offline>
54   - <shortopt>O</shortopt>
55   - <doc>do not attempt to download any urls or contact channels</doc>
56   - </offline>
57   - <pretend>
58   - <shortopt>p</shortopt>
59   - <doc>Only list the packages that would be downloaded</doc>
60   - </pretend>
61   - </options>
62   - <doc>[channel/]&lt;package&gt; ...
63   -Installs one or more PEAR packages. You can specify a package to
64   -install in four ways:
65   -
66   -&quot;Package-1.0.tgz&quot; : installs from a local file
67   -
68   -&quot;http://example.com/Package-1.0.tgz&quot; : installs from
69   -anywhere on the net.
70   -
71   -&quot;package.xml&quot; : installs the package described in
72   -package.xml. Useful for testing, or for wrapping a PEAR package in
73   -another package manager such as RPM.
74   -
75   -&quot;Package[-version/state][.tar]&quot; : queries your default channel&#039;s server
76   -({config master_server}) and downloads the newest package with
77   -the preferred quality/state ({config preferred_state}).
78   -
79   -To retrieve Package version 1.1, use &quot;Package-1.1,&quot; to retrieve
80   -Package state beta, use &quot;Package-beta.&quot; To retrieve an uncompressed
81   -file, append .tar (make sure there is no file by the same name first)
82   -
83   -To download a package from another channel, prefix with the channel name like
84   -&quot;channel/Package&quot;
85   -
86   -More than one package may be specified at once. It is ok to mix these
87   -four ways of specifying packages.
88   -</doc>
89   - </remote-install>
90   - <remote-upgrade>
91   - <summary>Upgrade Package</summary>
92   - <function>doInstall</function>
93   - <shortcut>upr</shortcut>
94   - <options>
95   - <force>
96   - <shortopt>f</shortopt>
97   - <doc>overwrite newer installed packages</doc>
98   - </force>
99   - <nodeps>
100   - <shortopt>n</shortopt>
101   - <doc>ignore dependencies, upgrade anyway</doc>
102   - </nodeps>
103   - <register-only>
104   - <shortopt>r</shortopt>
105   - <doc>do not install files, only register the package as upgraded</doc>
106   - </register-only>
107   - <nobuild>
108   - <shortopt>B</shortopt>
109   - <doc>don&#039;t build C extensions</doc>
110   - </nobuild>
111   - <nocompress>
112   - <shortopt>Z</shortopt>
113   - <doc>request uncompressed files when downloading</doc>
114   - </nocompress>
115   - <installroot>
116   - <shortopt>R</shortopt>
117   - <doc>root directory used when installing files (ala PHP&#039;s INSTALL_ROOT)</doc>
118   - <arg>DIR</arg>
119   - </installroot>
120   - <ignore-errors>
121   - <shortopt></shortopt>
122   - <doc>force install even if there were errors</doc>
123   - </ignore-errors>
124   - <alldeps>
125   - <shortopt>a</shortopt>
126   - <doc>install all required and optional dependencies</doc>
127   - </alldeps>
128   - <onlyreqdeps>
129   - <shortopt>o</shortopt>
130   - <doc>install all required dependencies</doc>
131   - </onlyreqdeps>
132   - <remoteconfig>
133   - <shortopt>F</shortopt>
134   - <doc>also upgrade on ftp site using remote config file (ftp://host.com/pear.conf)</doc>
135   - <arg>URL</arg>
136   - </remoteconfig>
137   - <offline>
138   - <shortopt>O</shortopt>
139   - <doc>do not attempt to download any urls or contact channels</doc>
140   - </offline>
141   - <pretend>
142   - <shortopt>p</shortopt>
143   - <doc>Only list the packages that would be downloaded</doc>
144   - </pretend>
145   - </options>
146   - <doc>&lt;package&gt; ...
147   -Upgrades one or more PEAR packages. See documentation for the
148   -&quot;install&quot; command for ways to specify a package.
149   -
150   -When upgrading, your package will be updated if the provided new
151   -package has a higher version number (use the -f option if you need to
152   -upgrade anyway).
153   -
154   -More than one package may be specified at once.
155   -</doc>
156   - </remote-upgrade>
157   - <remote-upgrade-all>
158   - <summary>Upgrade All Packages</summary>
159   - <function>doInstall</function>
160   - <shortcut>uar</shortcut>
161   - <options>
162   - <nodeps>
163   - <shortopt>n</shortopt>
164   - <doc>ignore dependencies, upgrade anyway</doc>
165   - </nodeps>
166   - <register-only>
167   - <shortopt>r</shortopt>
168   - <doc>do not install files, only register the package as upgraded</doc>
169   - </register-only>
170   - <nobuild>
171   - <shortopt>B</shortopt>
172   - <doc>don&#039;t build C extensions</doc>
173   - </nobuild>
174   - <nocompress>
175   - <shortopt>Z</shortopt>
176   - <doc>request uncompressed files when downloading</doc>
177   - </nocompress>
178   - <installroot>
179   - <shortopt>R</shortopt>
180   - <doc>root directory used when installing files (ala PHP&#039;s INSTALL_ROOT)</doc>
181   - <arg>DIR</arg>
182   - </installroot>
183   - <ignore-errors>
184   - <shortopt></shortopt>
185   - <doc>force install even if there were errors</doc>
186   - </ignore-errors>
187   - <remoteconfig>
188   - <shortopt>F</shortopt>
189   - <doc>also upgrade on ftp site using remote config file (ftp://host.com/pear.conf)</doc>
190   - <arg>URL</arg>
191   - </remoteconfig>
192   - </options>
193   - <doc>
194   -Upgrades all packages that have a newer release available. Upgrades are
195   -done only if there is a release available of the state specified in
196   -&quot;preferred_state&quot; (currently {config preferred_state}), or a state considered
197   -more stable.
198   -</doc>
199   - </remote-upgrade-all>
200   - <remote-uninstall>
201   - <summary>Un-install Package</summary>
202   - <function>doUninstall</function>
203   - <shortcut>unr</shortcut>
204   - <options>
205   - <nodeps>
206   - <shortopt>n</shortopt>
207   - <doc>ignore dependencies, uninstall anyway</doc>
208   - </nodeps>
209   - <register-only>
210   - <shortopt>r</shortopt>
211   - <doc>do not remove files, only register the packages as not installed</doc>
212   - </register-only>
213   - <installroot>
214   - <shortopt>R</shortopt>
215   - <doc>root directory used when installing files (ala PHP&#039;s INSTALL_ROOT)</doc>
216   - <arg>DIR</arg>
217   - </installroot>
218   - <ignore-errors>
219   - <shortopt></shortopt>
220   - <doc>force install even if there were errors</doc>
221   - </ignore-errors>
222   - <remoteconfig>
223   - <shortopt>F</shortopt>
224   - <doc>also uninstall on ftp site using remote config file (ftp://host.com/pear.conf)</doc>
225   - <arg>URL</arg>
226   - </remoteconfig>
227   - <offline>
228   - <shortopt>O</shortopt>
229   - <doc>do not attempt to uninstall remotely</doc>
230   - </offline>
231   - </options>
232   - <doc>[channel/]&lt;package&gt; ...
233   -Uninstalls one or more PEAR packages. More than one package may be
234   -specified at once. Prefix with channel name to uninstall from a
235   -channel not in your default channel ({config default_channel})
236   -</doc>
237   - </remote-uninstall>
238   -</commands>
260 PEAR/FTP.php
... ... @@ -1,260 +0,0 @@
1   -<?php
2   -/**
3   - * PEAR_FTP
4   - *
5   - * PHP versions 4 and 5
6   - *
7   - * @category pear
8   - * @package PEAR
9   - * @author Greg Beaver <cellog@php.net>
10   - * @copyright 1997-2009 The Authors
11   - * @license http://opensource.org/licenses/bsd-license.php New BSD License
12   - * @version CVS: $Id$
13   - * @link http://pear.php.net/package/PEAR
14   - * @since File available since Release 1.4.0a1
15   - */
16   -
17   -/**
18   - * FTP class used for PEAR's remote installation feature
19   - * @category pear
20   - * @package PEAR
21   - * @author Greg Beaver <cellog@php.net>
22   - * @copyright 1997-2009 The Authors
23   - * @license http://opensource.org/licenses/bsd-license.php New BSD License
24   - * @version Release: @package_version@
25   - * @link http://pear.php.net/package/PEAR
26   - * @since Class available since Release 1.4.0a1
27   - */
28   -class PEAR_FTP extends PEAR
29   -{
30   - /**
31   - * @var array
32   - * @access private
33   - */
34   - protected $_parsed;
35   -
36   - /**
37   - * URI to prepend to all paths
38   - * @var string
39   - */
40   - protected $_uri;
41   -
42   - /**
43   - * Value to prepend to relative paths
44   - * @var string|null
45   - */
46   - protected $_pathprepend = null;
47   - /**
48   - * Resource needed for ssh2 action
49   - * @var resource
50   - */
51   - protected $_ssh2connection;
52   -
53   - /**
54   - * @param string full url to remote config file
55   - * @return true|PEAR_Error
56   - */
57   - public function init($url = null)
58   - {
59   - if ($url !== null) {
60   - $this->_parsed = @parse_url($url);
61   - } else {
62   - return;
63   - }
64   - if (!isset($this->_parsed['host'])) {
65   - return PEAR::raiseError('No FTP Host specified');
66   - }
67   - if (!isset($this->_parsed['scheme'])) {
68   - return PEAR::raiseError('No FTP Scheme (ftp/ftps/ssh2.sftp) specified');
69   - }
70   - if (!in_array($this->_parsed['scheme'], array('ftp', 'ftps', 'ssh2.sftp'), true)) {
71   - return PEAR::raiseError('Only ftp/ftps/ssh2.sftp is supported for remote config');
72   - }
73   - if (!in_array($this->_parsed['scheme'], stream_get_wrappers(), true)) {
74   - if ($this->_parsed['scheme'] == 'ftps' && !extension_loaded('openssl')) {
75   - if (OS_WINDOWS) {
76   - return PEAR::raiseError('In order to use ftps, you must ' .
77   - 'put "extension=php_openssl.dll" into php.ini and ' .
78   - 'copy libeay32.dll and ssleay32.dll to \windows\system32');
79   - } else {
80   - return PEAR::raiseError('In order to use ftps, you must ' .
81   - 'enable the "openssl" extension in php.ini');
82   - }
83   - }
84   - if ($this->_parsed['scheme'] == 'ssh2.sftp') {
85   - if (OS_WINDOWS) {
86   - return PEAR::raiseError('In order to use ssh2.sftp, you must ' .
87   - 'enable the "php_ssh2.dll" extension in php.ini');
88   - } else {
89   - return PEAR::raiseError('In order to use ssh2.sftp, you must ' .
90   - 'install ssh2 via "pecl install ssh2" and enable the "ssh2" ' .
91   - 'extension in php.ini');
92   - }
93   - }
94   - return PEAR::raiseError('Your PHP does not support this wrapper: ' .
95   - $this->_parsed['scheme']);
96   - }
97   - if (!isset($this->_parsed['path'])) {
98   - return PEAR::raiseError('No FTP file path to remote config specified');
99   - }
100   - $host = $this->_parsed['host'];
101   - $pass = isset($this->_parsed['pass']) ? ':' . $this->_parsed['pass'] : '';
102   - $user = isset($this->_parsed['user']) ? $this->_parsed['user'] . "$pass@" : '';
103   - $port = isset($this->_parsed['port']) ? ':' . $this->_parsed['port'] : '';
104   - $path = dirname($this->_parsed['path']);
105   - if ($path[strlen($path) - 1] == '/') {
106   - $path = substr($path, 0, strlen($path) - 1);
107   - }
108   - if ($this->_parsed['scheme'] == 'ssh2.sftp') {
109   - $connection = @ssh2_connect($host, isset($this->_parsed['port']) ?
110   - $this->_parsed['port'] : 22);
111   - if (!$connection) {
112   - return PEAR::raiseError('Unable to connect to remote host: ' .
113   - $php_errormsg);
114   - }
115   - $a = @ssh2_auth_password($connection, urldecode($this->_parsed['user']),
116   - urldecode($this->_parsed['pass']));
117   - if (!$a) {
118   - return PEAR::raiseError('Unable to authenticate to remote host: ' .
119   - $php_errormsg);
120   - }
121   -
122   - $sftp = @ssh2_sftp($connection);
123   - if (!$sftp) {
124   - return PEAR::raiseError('Unable to initiate sftp session: ' .
125   - $php_errormsg);
126   - }
127   - $this->_uri = $this->_parsed['scheme'] . '://' . $sftp;
128   - $this->_pathprepend = $path;
129   - $this->_ssh2connection = $sftp;
130   - } else {
131   - $this->_uri = $this->_parsed['scheme'] . '://' . $user . $host;
132   - $this->_pathprepend = $path;
133   - }
134   - return true;
135   - }
136   -
137   - /**
138   - * This works similar to the mkdir-command on your local machine. You can either give
139   - * it an absolute or relative path. The relative path will be completed with the actual
140   - * selected server-path. (see: pwd())
141   - *
142   - * @access public
143   - * @param string $dir relative dir-path
144   - * @param bool $recursive (optional) Create all needed directories
145   - * @return mixed True on success, otherwise PEAR::Error
146   - * @see NET_FTP_ERR_CREATEDIR_FAILED
147   - */
148   - public function mkdir($dir, $recursive = false)
149   - {
150   - if (method_exists($this, '_testftp_mkdir')) {
151   - $res = $this->_testftp_mkdir($this->_prepend($dir), 0755, $recursive);
152   - } else {
153   - $res = @mkdir($this->_prepend($dir), 0755, $recursive);
154   - }
155   - if (!$res) {
156   - return $this->raiseError("Creation of '$dir' failed");
157   - } else {
158   - return true;
159   - }
160   - }
161   -
162   - /**
163   - * @param string full path to local file
164   - * @param string full path to remote file
165   - */
166   - public function installFile($local, $remote)
167   - {
168   - $this->pushErrorHandling(PEAR_ERROR_RETURN);
169   - $this->mkdir(dirname($remote), true);
170   - $this->popErrorHandling();
171   - return $this->put($local, $remote, true);
172   - }
173   -
174   - /**
175   - * Retrieve a file from the remote server
176   - *
177   - * @param string $relfile relative path of the remote file
178   - * @param string $localfile full local path to save the file in
179   - */
180   - public function get($relfile, $localfile, $binary = true)
181   - {
182   - $local = @fopen($localfile, 'w' . ($binary ? 'b' : ''));
183   - $remote = @fopen($this->_prepend($relfile), 'r' . ($binary ? 'b' : ''));
184   - if (!$remote) {
185   - return PEAR::raiseError('Could not open remote file ' .
186   - $this->_prepend($relfile) . ' for retrieval');
187   - }
188   - if (!$local) {
189   - return PEAR::raiseError('Could not open local file ' .
190   - $this->_prepend($relfile) . ' for retrieving remote file ' .
191   - $this->_prepend($relfile));
192   - }
193   - $ret = @stream_copy_to_stream($remote, $local);
194   - if ($local) {
195   - @fclose($local);
196   - }
197   - if ($remote) {
198   - @fclose($remote);
199   - }
200   - return $ret ? $ret : PEAR::raiseError('FTP get of ' . $this->_prepend($relfile) .
201   - ' failed');
202   - }
203   -
204   - public function put($localfile, $remotefile, $overwrite = false, $binary = true)
205   - {
206   - // sometimes we get the wrong size for files, this might fix it
207   - clearstatcache();
208   - $local = @fopen($localfile, 'r' . ($binary ? 'b' : ''));
209   - if (!$local) {
210   - return PEAR::raiseError('Could not put local file ' . $localfile .
211   - 'opening the file failed');
212   - }
213   - $opts = array('ftp' => array('overwrite' => $overwrite));
214   - $context = stream_context_create($opts);
215   - $remote = @fopen($this->_prepend($remotefile), 'w' . ($binary ? 'b' : ''), false,
216   - $context);
217   - if (!$remote) {
218   - return PEAR::raiseError('Could not open remote file ' .
219   - $this->_prepend($remotefile) . ' for saving a copy of local file ' . $localfile);
220   - }
221   - $ret = @stream_copy_to_stream($local, $remote);
222   - if ($local) {
223   - @fclose($local);
224   - }
225   - if ($remote) {
226   - @fclose($remote);
227   - }
228   - return $ret ? $ret : PEAR::raiseError('FTP put of ' . $this->_prepend($remotefile) .
229   - ' failed');
230   - }
231   -
232   - public function disconnect()
233   - {
234   - // does nothing here
235   - }
236   -
237   - public function rm($path, $recursive = false)
238   - {
239   - if (@unlink($this->_prepend($path))) {
240   - return true;
241   - }
242   - return PEAR::raiseError('rm of ' . $this->_prepend($path) . ' failed');
243   - }
244   -
245   - /**
246   - * Return a ftp URI for usage with filesystem functions directly
247   - *
248   - * @param string $path relative path to the on the FTP server
249   - * @return string full path to the ftp server including ftp[s]://...
250   - */
251   - private function _prepend($path)
252   - {
253   - if ($path[0] == '/') {
254   - return $this->_uri . $path;
255   - } else {
256   - return $this->_uri . $this->_pathprepend . '/' . $path;
257   - }
258   - }
259   -}
260   -?>
233 PEAR/RemoteInstaller.php
... ... @@ -1,233 +0,0 @@
1   -<?php
2   -/**
3   - * PEAR_Installer
4   - *
5   - * PHP versions 4 and 5
6   - *
7   - * @category pear
8   - * @package PEAR
9   - * @author Stig Bakken <ssb@php.net>
10   - * @author Tomas V.V. Cox <cox@idecnet.com>
11   - * @author Martin Jansen <mj@php.net>
12   - * @author Greg Beaver <cellog@php.net>
13   - * @copyright 2005-2009 The Authors
14   - * @license http://opensource.org/licenses/bsd-license.php New BSD License
15   - * @version CVS: $Id$
16   - * @link http://pear.php.net/package/PEAR
17   - * @since File available since Release 0.1.0
18   - */
19   -
20   -/**
21   - * parent class
22   - */
23   -require_once 'PEAR/Installer.php';
24   -
25   -/**
26   - * Administration class used to install PEAR packages and maintain the
27   - * installed package database.
28   - *
29   - * @category pear
30   - * @package PEAR
31   - * @author Greg Beaver <cellog@php.net>
32   - * @copyright 2005-2009 The Authors
33   - * @license http://opensource.org/licenses/bsd-license.php New BSD License
34   - * @version Release: @package_version@
35   - * @link http://pear.php.net/package/PEAR
36   - * @since Class available since Release 0.1.0
37   - */
38   -class PEAR_RemoteInstaller extends PEAR_Installer
39   -{
40   -
41   - /**
42   - * Delete a package's installed files, does not remove empty directories.
43   - *
44   - * @param string package name
45   - * @param string channel name
46   - * @param bool if true, then files are backed up first
47   - * @return bool TRUE on success, or a PEAR error on failure
48   - * @access protected
49   - */
50   - function _deletePackageFiles($package, $channel = false, $backup = false)
51   - {
52   - if (!$channel) {
53   - $channel = 'pear.php.net';
54   - }
55   - if (!strlen($package)) {
56   - return $this->raiseError("No package to uninstall given");
57   - }
58   - if (strtolower($package) == 'pear' && $channel == 'pear.php.net') {
59   - // to avoid race conditions, include all possible needed files
60   - require_once 'PEAR/Task/Common.php';
61   - require_once 'PEAR/Task/Replace.php';
62   - require_once 'PEAR/Task/Unixeol.php';
63   - require_once 'PEAR/Task/Windowseol.php';
64   - require_once 'PEAR/PackageFile/v1.php';
65   - require_once 'PEAR/PackageFile/v2.php';
66   - require_once 'PEAR/PackageFile/Generator/v1.php';
67   - require_once 'PEAR/PackageFile/Generator/v2.php';
68   - }
69   - $filelist = $this->_registry->packageInfo($package, 'filelist', $channel);
70   - if ($filelist == null) {
71   - return $this->raiseError("$channel/$package not installed");
72   - }
73   - $ret = array();
74   - if ($this->config->isDefinedLayer('ftp') && isset($this->_options['upgrade'])) {
75   - $pkg = $this->_registry->getPackage($package, $channel);
76   - $this->ftpUninstall($pkg); // no error checking
77   - }
78   - return parent::_deletePackageFiles($package, $channel, $backup);
79   - }
80   -
81   - /**
82   - * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
83   - */
84   - public function ftpUninstall($pkg)
85   - {
86   - $ftp = &$this->config->getFTP();
87   - if (!$ftp) {
88   - return $this->raiseError('FTP client not initialized');
89   - }
90   - $this->log(2, 'Connect to FTP server');
91   - $e = $ftp->init();
92   - if (PEAR::isError($e)) {
93   - return $e;
94   - }
95   - PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
96   - foreach ($pkg->getFilelist() as $file => $atts) {
97   - if ($pkg->getPackagexmlVersion() == '1.0') {
98   - $channel = 'pear.php.net';
99   - switch ($atts['role']) {
100   - case 'doc':
101   - case 'data':
102   - case 'test':
103   - $dest_dir = $this->config->get($atts['role'] . '_dir', 'ftp', $channel) .
104   - DIRECTORY_SEPARATOR . $pkg->getPackage();
105   - unset($atts['baseinstalldir']);
106   - break;
107   - case 'ext':
108   - case 'php':
109   - $dest_dir = $this->config->get($atts['role'] . '_dir', 'ftp', $channel);
110   - break;
111   - case 'script':
112   - $dest_dir = $this->config->get('bin_dir', 'ftp', $channel);
113   - break;
114   - default:
115   - continue 2;
116   - }
117   - $save_destdir = $dest_dir;
118   - if (!empty($atts['baseinstalldir'])) {
119   - $dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
120   - }
121   - if (dirname($file) != '.' && empty($atts['install-as'])) {
122   - $dest_dir .= DIRECTORY_SEPARATOR . dirname($file);
123   - }
124   - if (empty($atts['install-as'])) {
125   - $dest_file = $dest_dir . DIRECTORY_SEPARATOR . basename($file);
126   - } else {
127   - $dest_file = $dest_dir . DIRECTORY_SEPARATOR . $atts['install-as'];
128   - }
129   -
130   - // Clean up the DIRECTORY_SEPARATOR mess
131   - $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
132   - $dest_file = preg_replace(array('!\\\\+!', '!/!', "!$ds2+!"),
133   - array('/', '/', '/'),
134   - $dest_file);
135   - } else {
136   - $role = &PEAR_Installer_Role::factory($pkg, $atts['role'], $this->config);
137   - $role->setup($this, $pkg, $atts, $file);
138   - if (!$role->isInstallable()) {
139   - continue; // this shouldn't happen
140   - }
141   - $tmp_path = ''; // unused
142   - list($save_destdir, $dest_dir, $dest_file, $orig_file) =
143   - $role->processInstallation($pkg, $atts, $file, $tmp_path, 'ftp');
144   - $dest_file = str_replace(DIRECTORY_SEPARATOR, '/', $dest_file);
145   - }
146   - $this->log(2, 'Deleting "' . $dest_file . '"');
147   - $ftp->rm($dest_file);
148   - }
149   - PEAR::staticPopErrorHandling();
150   - $this->log(2, 'Disconnect from FTP server');
151   - return $ftp->disconnect();
152   - }
153   -
154   - /**
155   - * Upload an installed package - does not work with register-only packages!
156   - * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
157   - */
158   - public function ftpInstall($pkg)
159   - {
160   - if ($pkg->getPackageType() != 'php') {
161   - return PEAR::raiseError('Error: can only install PHP scripts remotely,' .
162   - ' no PHP extensions can be compiled remotely');
163   - }
164   - $ftp = &$this->config->getFTP();
165   - if (!$ftp) {
166   - return PEAR::raiseError('FTP client not initialized');
167   - }
168   - $this->log(2, 'Connect to FTP server');
169   - $e = $ftp->init();
170   - if (PEAR::isError($e)) {
171   - return $e;
172   - }
173   - $pf = &$this->_registry->getPackage($pkg->getPackage(), $pkg->getChannel());
174   - foreach ($pf->getFilelist() as $file => $atts) {
175   - if ($pf->getPackagexmlVersion() == '1.0') {
176   - $channel = 'pear.php.net';
177   - switch ($atts['role']) {
178   - case 'doc':
179   - case 'data':
180   - case 'test':
181   - $dest_dir = $this->config->get($atts['role'] . '_dir', 'ftp', $channel) .
182   - DIRECTORY_SEPARATOR . $pf->getPackage();
183   - unset($atts['baseinstalldir']);
184   - break;
185   - case 'ext':
186   - case 'php':
187   - $dest_dir = $this->config->get($atts['role'] . '_dir', 'ftp', $channel);
188   - break;
189   - case 'script':
190   - $dest_dir = $this->config->get('bin_dir', 'ftp', $channel);
191   - break;
192   - default:
193   - continue 2;
194   - }
195   - $save_destdir = $dest_dir;
196   - if (!empty($atts['baseinstalldir'])) {
197   - $dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
198   - }
199   - if (dirname($file) != '.' && empty($atts['install-as'])) {
200   - $dest_dir .= DIRECTORY_SEPARATOR . dirname($file);
201   - }
202   - if (empty($atts['install-as'])) {
203   - $dest_file = $dest_dir . DIRECTORY_SEPARATOR . basename($file);
204   - } else {
205   - $dest_file = $dest_dir . DIRECTORY_SEPARATOR . $atts['install-as'];
206   - }
207   -
208   - // Clean up the DIRECTORY_SEPARATOR mess
209   - $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
210   - $dest_file = preg_replace(array('!\\+!', '!/!', "!$ds2+!"),
211   - array('/', '/', '/'),
212   - $dest_file);
213   - } else {
214   - $role = &PEAR_Installer_Role::factory($pf, $atts['role'], $this->config);
215   - $role->setup($this, $pf, $atts, $file);
216   - if (!$role->isInstallable()) {
217   - continue; // this shouldn't happen
218   - }
219   - list($save_destdir, $dest_dir, $dest_file, $orig_file) =
220   - $role->processInstallation($pkg, $atts, $file, $file /* not used */, 'ftp');
221   - $dest_file = str_replace(DIRECTORY_SEPARATOR, '/', $dest_file);
222   - }
223   - $installedas = $atts['installed_as'];
224   - $this->log(2, 'Uploading "' . $installedas . '" to "' . $dest_file . '"');
225   - if (PEAR::isError($e = $ftp->installFile($installedas, $dest_file))) {
226   - return $e;
227   - }
228   - }
229   - $this->log(2, 'Disconnect from FTP server');
230   - return $ftp->disconnect();
231   - }
232   -}
233   -?>
155 package-RemoteInstall.xml
... ... @@ -1,155 +0,0 @@
1   -<?xml version="1.0"?>
2   -<package version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
3   -http://pear.php.net/dtd/tasks-1.0.xsd
4   -http://pear.php.net/dtd/package-2.0
5   -http://pear.php.net/dtd/package-2.0.xsd">
6   - <name>PEAR_RemoteInstaller</name>
7   - <channel>pear.php.net</channel>
8   - <summary>PEAR Remote installation plugin through FTP, SFTP, and FTPS</summary>
9   - <description>Originally part of the 1.4.0 new features,
10   -remote installation through FTP, FTPS and SFTP is now its own package.
11   -This package adds the commands &quot;remote-install&quot; &quot;remote-upgrade&quot;
12   -&quot;remote-uninstall&quot; and &quot;remote-upgrade-all&quot; to the PEAR core.
13   -
14   -To take advantage, you must have a config file on the remote
15   -ftp server and full access to the server to create and remove
16   -files. The config-create command can be used to get started,
17   -and the remote_config configuration variable is set to the
18   -full URL as in &quot;ftp://ftp.example.com/path/to/pear.ini&quot; or
19   -&quot;ftps://user:pass@ftp.example.com/path/to/pear.ini&quot; or
20   -&quot;ssh2.sftp://user:pass@ftp.example.com/path/to/pear.ini&quot;
21   -
22   -After this is done, install/upgrade as normal using the
23   -remote* commands as if they were local.
24   - </description>
25   - <lead>
26   - <name>Greg Beaver</name>
27   - <user>cellog</user>
28   - <email>cellog@php.net</email>
29   - <active>yes</active>
30   - </lead>
31   - <date>2006-12-15</date>
32   - <version>
33   - <release>0.3.2</release>
34   - <api>0.1.0</api>
35   - </version>
36   - <stability>
37   - <release>alpha</release>
38   - <api>alpha</api>
39   - </stability>
40   - <license uri="http://www.php.net/license">PHP License</license>
41   - <notes>
42   - * fix Bug #9768: notice error raised with remote-uninstall
43   - </notes>
44   - <contents>
45   - <dir name="/">
46   - <dir name="PEAR">
47   - <dir name="Command">
48   - <file name="Remoteinstall.xml" role="php"/>
49   - <file name="Remoteinstall.php" role="php">
50   - <tasks:replace from="@package_version@" to="version" type="package-info" />
51   - </file>
52   - </dir> <!-- /PEAR/Command -->
53   - <file name="FTP.php" role="php">
54   - <tasks:replace from="@package_version@" to="version" type="package-info" />
55   - </file>
56   - <file name="RemoteInstaller.php" role="php">
57   - <tasks:replace from="@package_version@" to="version" type="package-info" />
58   - </file>
59   - </dir> <!-- /PEAR -->
60   - </dir> <!-- / -->
61   - </contents>
62   - <dependencies>
63   - <required>
64   - <php>
65   - <min>5.0.0</min>
66   - </php>
67   - <pearinstaller>
68   - <min>1.5.0RC1</min>
69   - </pearinstaller>
70   - <package>
71   - <name>PEAR</name>
72   - <channel>pear.php.net</channel>
73   - <min>1.4.3</min>
74   - </package>
75   - </required>
76   - <optional>
77   - <package>
78   - <name>ssh2</name>
79   - <channel>pecl.php.net</channel>
80   - <providesextension>ssh2</providesextension>
81   - </package>
82   - </optional>
83   - </dependencies>
84   - <phprelease/>
85   - <changelog>
86   - <release>
87   - <version>
88   - <release>0.1.0</release>
89   - <api>0.1.0</api>
90   - </version>
91   - <stability>
92   - <release>alpha</release>
93   - <api>alpha</api>
94   - </stability>
95   - <date>2005-08-20</date>
96   - <license uri="http://www.php.net/license/3_0.txt">PHP License</license>
97   - <notes>
98   - initial separate release from PEAR
99   - </notes>