PageRenderTime 56ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/common/libraries/plugin/pear/PEAR/Registry.php

https://bitbucket.org/ywarnier/chamilo-dev
PHP | 2610 lines | 1912 code | 204 blank | 494 comment | 393 complexity | a22f9e7415925e80b657f83d587d1779 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, LGPL-2.1, LGPL-3.0, GPL-3.0, MIT

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * PEAR_Registry
  4. *
  5. * PHP versions 4 and 5
  6. *
  7. * LICENSE: This source file is subject to version 3.0 of the PHP license
  8. * that is available through the world-wide-web at the following URI:
  9. * http://www.php.net/license/3_0.txt. If you did not receive a copy of
  10. * the PHP License and are unable to obtain it through the web, please
  11. * send a note to license@php.net so we can mail you a copy immediately.
  12. *
  13. * @category pear
  14. * @package PEAR
  15. * @author Stig Bakken <ssb@php.net>
  16. * @author Tomas V. V. Cox <cox@idecnet.com>
  17. * @author Greg Beaver <cellog@php.net>
  18. * @copyright 1997-2008 The PHP Group
  19. * @license http://www.php.net/license/3_0.txt PHP License 3.0
  20. * @version CVS: $Id: Registry.php 137 2009-11-09 13:24:37Z vanpouckesven $
  21. * @link http://pear.php.net/package/PEAR
  22. * @since File available since Release 0.1
  23. */
  24. /**
  25. * for PEAR_Error
  26. */
  27. require_once 'PEAR.php';
  28. require_once 'PEAR/DependencyDB.php';
  29. define('PEAR_REGISTRY_ERROR_LOCK', - 2);
  30. define('PEAR_REGISTRY_ERROR_FORMAT', - 3);
  31. define('PEAR_REGISTRY_ERROR_FILE', - 4);
  32. define('PEAR_REGISTRY_ERROR_CONFLICT', - 5);
  33. define('PEAR_REGISTRY_ERROR_CHANNEL_FILE', - 6);
  34. /**
  35. * Administration class used to maintain the installed package database.
  36. * @category pear
  37. * @package PEAR
  38. * @author Stig Bakken <ssb@php.net>
  39. * @author Tomas V. V. Cox <cox@idecnet.com>
  40. * @author Greg Beaver <cellog@php.net>
  41. * @copyright 1997-2008 The PHP Group
  42. * @license http://www.php.net/license/3_0.txt PHP License 3.0
  43. * @version Release: 1.7.2
  44. * @link http://pear.php.net/package/PEAR
  45. * @since Class available since Release 1.4.0a1
  46. */
  47. class PEAR_Registry extends PEAR
  48. {
  49. // {{{ properties
  50. /**
  51. * File containing all channel information.
  52. * @var string
  53. */
  54. var $channels = '';
  55. /** Directory where registry files are stored.
  56. * @var string
  57. */
  58. var $statedir = '';
  59. /** File where the file map is stored
  60. * @var string
  61. */
  62. var $filemap = '';
  63. /** Directory where registry files for channels are stored.
  64. * @var string
  65. */
  66. var $channelsdir = '';
  67. /** Name of file used for locking the registry
  68. * @var string
  69. */
  70. var $lockfile = '';
  71. /** File descriptor used during locking
  72. * @var resource
  73. */
  74. var $lock_fp = null;
  75. /** Mode used during locking
  76. * @var int
  77. */
  78. var $lock_mode = 0; // XXX UNUSED
  79. /** Cache of package information. Structure:
  80. * array(
  81. * 'package' => array('id' => ... ),
  82. * ... )
  83. * @var array
  84. */
  85. var $pkginfo_cache = array();
  86. /** Cache of file map. Structure:
  87. * array( '/path/to/file' => 'package', ... )
  88. * @var array
  89. */
  90. var $filemap_cache = array();
  91. /**
  92. * @var false|PEAR_ChannelFile
  93. */
  94. var $_pearChannel;
  95. /**
  96. * @var false|PEAR_ChannelFile
  97. */
  98. var $_peclChannel;
  99. /**
  100. * @var PEAR_DependencyDB
  101. */
  102. var $_dependencyDB;
  103. /**
  104. * @var PEAR_Config
  105. */
  106. var $_config;
  107. // }}}
  108. // {{{ constructor
  109. /**
  110. * PEAR_Registry constructor.
  111. *
  112. * @param string (optional) PEAR install directory (for .php files)
  113. * @param PEAR_ChannelFile PEAR_ChannelFile object representing the PEAR channel, if
  114. * default values are not desired. Only used the very first time a PEAR
  115. * repository is initialized
  116. * @param PEAR_ChannelFile PEAR_ChannelFile object representing the PECL channel, if
  117. * default values are not desired. Only used the very first time a PEAR
  118. * repository is initialized
  119. *
  120. * @access public
  121. */
  122. function __construct($pear_install_dir = PEAR_INSTALL_DIR, $pear_channel = false, $pecl_channel = false)
  123. {
  124. parent :: __construct();
  125. $this->setInstallDir($pear_install_dir);
  126. $this->_pearChannel = $pear_channel;
  127. $this->_peclChannel = $pecl_channel;
  128. $this->_config = false;
  129. }
  130. function setInstallDir($pear_install_dir = PEAR_INSTALL_DIR)
  131. {
  132. $ds = DIRECTORY_SEPARATOR;
  133. $this->install_dir = $pear_install_dir;
  134. $this->channelsdir = $pear_install_dir . $ds . '.channels';
  135. $this->statedir = $pear_install_dir . $ds . '.registry';
  136. $this->filemap = $pear_install_dir . $ds . '.filemap';
  137. $this->lockfile = $pear_install_dir . $ds . '.lock';
  138. }
  139. function hasWriteAccess()
  140. {
  141. if (! file_exists($this->install_dir))
  142. {
  143. $dir = $this->install_dir;
  144. while ($dir && $dir != '.')
  145. {
  146. $olddir = $dir;
  147. $dir = dirname($dir); // cd ..
  148. if ($dir != '.' && file_exists($dir))
  149. {
  150. if (is_writeable($dir))
  151. {
  152. return true;
  153. }
  154. else
  155. {
  156. return false;
  157. }
  158. }
  159. if ($dir == $olddir)
  160. { // this can happen in safe mode
  161. return @is_writable($dir);
  162. }
  163. }
  164. return false;
  165. }
  166. return is_writeable($this->install_dir);
  167. }
  168. function setConfig(&$config, $resetInstallDir = true)
  169. {
  170. $this->_config = &$config;
  171. if ($resetInstallDir)
  172. {
  173. $this->setInstallDir($config->get('php_dir'));
  174. }
  175. }
  176. function _initializeChannelDirs()
  177. {
  178. static $running = false;
  179. if (! $running)
  180. {
  181. $running = true;
  182. $ds = DIRECTORY_SEPARATOR;
  183. 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 . '__uri.reg'))
  184. {
  185. if (! file_exists($this->channelsdir . $ds . 'pear.php.net.reg'))
  186. {
  187. $pear_channel = $this->_pearChannel;
  188. if (! is_a($pear_channel, 'PEAR_ChannelFile') || ! $pear_channel->validate())
  189. {
  190. if (! class_exists('PEAR_ChannelFile'))
  191. {
  192. require_once 'PEAR/ChannelFile.php';
  193. }
  194. $pear_channel = new PEAR_ChannelFile();
  195. $pear_channel->setName('pear.php.net');
  196. $pear_channel->setAlias('pear');
  197. $pear_channel->setServer('pear.php.net');
  198. $pear_channel->setSummary('PHP Extension and Application Repository');
  199. $pear_channel->setDefaultPEARProtocols();
  200. $pear_channel->setBaseURL('REST1.0', 'http://pear.php.net/rest/');
  201. $pear_channel->setBaseURL('REST1.1', 'http://pear.php.net/rest/');
  202. }
  203. else
  204. {
  205. $pear_channel->setName('pear.php.net');
  206. $pear_channel->setAlias('pear');
  207. }
  208. $pear_channel->validate();
  209. $this->_addChannel($pear_channel);
  210. }
  211. if (! file_exists($this->channelsdir . $ds . 'pecl.php.net.reg'))
  212. {
  213. $pecl_channel = $this->_peclChannel;
  214. if (! is_a($pecl_channel, 'PEAR_ChannelFile') || ! $pecl_channel->validate())
  215. {
  216. if (! class_exists('PEAR_ChannelFile'))
  217. {
  218. require_once 'PEAR/ChannelFile.php';
  219. }
  220. $pecl_channel = new PEAR_ChannelFile();
  221. $pecl_channel->setName('pecl.php.net');
  222. $pecl_channel->setAlias('pecl');
  223. $pecl_channel->setServer('pecl.php.net');
  224. $pecl_channel->setSummary('PHP Extension Community Library');
  225. $pecl_channel->setDefaultPEARProtocols();
  226. $pecl_channel->setBaseURL('REST1.0', 'http://pecl.php.net/rest/');
  227. $pecl_channel->setBaseURL('REST1.1', 'http://pecl.php.net/rest/');
  228. $pecl_channel->setValidationPackage('PEAR_Validator_PECL', '1.0');
  229. }
  230. else
  231. {
  232. $pecl_channel->setName('pecl.php.net');
  233. $pecl_channel->setAlias('pecl');
  234. }
  235. $pecl_channel->validate();
  236. $this->_addChannel($pecl_channel);
  237. }
  238. if (! file_exists($this->channelsdir . $ds . '__uri.reg'))
  239. {
  240. if (! class_exists('PEAR_ChannelFile'))
  241. {
  242. require_once 'PEAR/ChannelFile.php';
  243. }
  244. $private = new PEAR_ChannelFile();
  245. $private->setName('__uri');
  246. $private->addFunction('xmlrpc', '1.0', '****');
  247. $private->setSummary('Pseudo-channel for static packages');
  248. $this->_addChannel($private);
  249. }
  250. $this->_rebuildFileMap();
  251. }
  252. $running = false;
  253. }
  254. }
  255. function _initializeDirs()
  256. {
  257. $ds = DIRECTORY_SEPARATOR;
  258. // XXX Compatibility code should be removed in the future
  259. // rename all registry files if any to lowercase
  260. if (! OS_WINDOWS && file_exists($this->statedir) && is_dir($this->statedir) && $handle = opendir($this->statedir))
  261. {
  262. $dest = $this->statedir . $ds;
  263. while (false !== ($file = readdir($handle)))
  264. {
  265. if (preg_match('/^.*[A-Z].*\.reg\\z/', $file))
  266. {
  267. rename($dest . $file, $dest . strtolower($file));
  268. }
  269. }
  270. closedir($handle);
  271. }
  272. $this->_initializeChannelDirs();
  273. if (! file_exists($this->filemap))
  274. {
  275. $this->_rebuildFileMap();
  276. }
  277. $this->_initializeDepDB();
  278. }
  279. function _initializeDepDB()
  280. {
  281. if (! isset($this->_dependencyDB))
  282. {
  283. static $initializing = false;
  284. if (! $initializing)
  285. {
  286. $initializing = true;
  287. if (! $this->_config)
  288. { // never used?
  289. if (OS_WINDOWS)
  290. {
  291. $file = 'pear.ini';
  292. }
  293. else
  294. {
  295. $file = '.pearrc';
  296. }
  297. $this->_config = &new PEAR_Config($this->statedir . DIRECTORY_SEPARATOR . $file);
  298. $this->_config->setRegistry($this);
  299. $this->_config->set('php_dir', $this->install_dir);
  300. }
  301. $this->_dependencyDB = &PEAR_DependencyDB :: singleton($this->_config);
  302. if (PEAR :: isError($this->_dependencyDB))
  303. {
  304. // attempt to recover by removing the dep db
  305. if (file_exists($this->_config->get('php_dir', null, 'pear.php.net') . DIRECTORY_SEPARATOR . '.depdb'))
  306. {
  307. @unlink($this->_config->get('php_dir', null, 'pear.php.net') . DIRECTORY_SEPARATOR . '.depdb');
  308. }
  309. $this->_dependencyDB = &PEAR_DependencyDB :: singleton($this->_config);
  310. if (PEAR :: isError($this->_dependencyDB))
  311. {
  312. echo $this->_dependencyDB->getMessage();
  313. echo 'Unrecoverable error';
  314. exit(1);
  315. }
  316. }
  317. $initializing = false;
  318. }
  319. }
  320. }
  321. // }}}
  322. // {{{ destructor
  323. /**
  324. * PEAR_Registry destructor. Makes sure no locks are forgotten.
  325. *
  326. * @access private
  327. */
  328. function _PEAR_Registry()
  329. {
  330. parent :: _PEAR();
  331. if (is_resource($this->lock_fp))
  332. {
  333. $this->_unlock();
  334. }
  335. }
  336. // }}}
  337. // {{{ _assertStateDir()
  338. /**
  339. * Make sure the directory where we keep registry files exists.
  340. *
  341. * @return bool TRUE if directory exists, FALSE if it could not be
  342. * created
  343. *
  344. * @access private
  345. */
  346. function _assertStateDir($channel = false)
  347. {
  348. if ($channel && $this->_getChannelFromAlias($channel) != 'pear.php.net')
  349. {
  350. return $this->_assertChannelStateDir($channel);
  351. }
  352. static $init = false;
  353. if (! file_exists($this->statedir))
  354. {
  355. if (! $this->hasWriteAccess())
  356. {
  357. return false;
  358. }
  359. require_once 'System.php';
  360. if (! System :: mkdir(array('-p', $this->statedir)))
  361. {
  362. return $this->raiseError("could not create directory '{$this->statedir}'");
  363. }
  364. $init = true;
  365. }
  366. elseif (! is_dir($this->statedir))
  367. {
  368. return $this->raiseError('Cannot create directory ' . $this->statedir . ', ' . 'it already exists and is not a directory');
  369. }
  370. $ds = DIRECTORY_SEPARATOR;
  371. if (! file_exists($this->channelsdir))
  372. {
  373. if (! file_exists($this->channelsdir . $ds . 'pear.php.net.reg') || ! file_exists($this->channelsdir . $ds . 'pecl.php.net.reg') || ! file_exists($this->channelsdir . $ds . '__uri.reg'))
  374. {
  375. $init = true;
  376. }
  377. }
  378. elseif (! is_dir($this->channelsdir))
  379. {
  380. return $this->raiseError('Cannot create directory ' . $this->channelsdir . ', ' . 'it already exists and is not a directory');
  381. }
  382. if ($init)
  383. {
  384. static $running = false;
  385. if (! $running)
  386. {
  387. $running = true;
  388. $this->_initializeDirs();
  389. $running = false;
  390. $init = false;
  391. }
  392. }
  393. else
  394. {
  395. $this->_initializeDepDB();
  396. }
  397. return true;
  398. }
  399. // }}}
  400. // {{{ _assertChannelStateDir()
  401. /**
  402. * Make sure the directory where we keep registry files exists for a non-standard channel.
  403. *
  404. * @param string channel name
  405. * @return bool TRUE if directory exists, FALSE if it could not be
  406. * created
  407. *
  408. * @access private
  409. */
  410. function _assertChannelStateDir($channel)
  411. {
  412. $ds = DIRECTORY_SEPARATOR;
  413. if (! $channel || $this->_getChannelFromAlias($channel) == 'pear.php.net')
  414. {
  415. if (! file_exists($this->channelsdir . $ds . 'pear.php.net.reg'))
  416. {
  417. $this->_initializeChannelDirs();
  418. }
  419. return $this->_assertStateDir($channel);
  420. }
  421. $channelDir = $this->_channelDirectoryName($channel);
  422. if (! is_dir($this->channelsdir) || ! file_exists($this->channelsdir . $ds . 'pear.php.net.reg'))
  423. {
  424. $this->_initializeChannelDirs();
  425. }
  426. if (! file_exists($channelDir))
  427. {
  428. if (! $this->hasWriteAccess())
  429. {
  430. return false;
  431. }
  432. require_once 'System.php';
  433. if (! System :: mkdir(array('-p', $channelDir)))
  434. {
  435. return $this->raiseError("could not create directory '" . $channelDir . "'");
  436. }
  437. }
  438. elseif (! is_dir($channelDir))
  439. {
  440. return $this->raiseError("could not create directory '" . $channelDir . "', already exists and is not a directory");
  441. }
  442. return true;
  443. }
  444. // }}}
  445. // {{{ _assertChannelDir()
  446. /**
  447. * Make sure the directory where we keep registry files for channels exists
  448. *
  449. * @return bool TRUE if directory exists, FALSE if it could not be
  450. * created
  451. *
  452. * @access private
  453. */
  454. function _assertChannelDir()
  455. {
  456. if (! file_exists($this->channelsdir))
  457. {
  458. if (! $this->hasWriteAccess())
  459. {
  460. return false;
  461. }
  462. require_once 'System.php';
  463. if (! System :: mkdir(array('-p', $this->channelsdir)))
  464. {
  465. return $this->raiseError("could not create directory '{$this->channelsdir}'");
  466. }
  467. }
  468. elseif (! is_dir($this->channelsdir))
  469. {
  470. return $this->raiseError("could not create directory '{$this->channelsdir}" . "', it already exists and is not a directory");
  471. }
  472. if (! file_exists($this->channelsdir . DIRECTORY_SEPARATOR . '.alias'))
  473. {
  474. if (! $this->hasWriteAccess())
  475. {
  476. return false;
  477. }
  478. require_once 'System.php';
  479. if (! System :: mkdir(array('-p', $this->channelsdir . DIRECTORY_SEPARATOR . '.alias')))
  480. {
  481. return $this->raiseError("could not create directory '{$this->channelsdir}/.alias'");
  482. }
  483. }
  484. elseif (! is_dir($this->channelsdir . DIRECTORY_SEPARATOR . '.alias'))
  485. {
  486. return $this->raiseError("could not create directory '{$this->channelsdir}" . "/.alias', it already exists and is not a directory");
  487. }
  488. return true;
  489. }
  490. // }}}
  491. // {{{ _packageFileName()
  492. /**
  493. * Get the name of the file where data for a given package is stored.
  494. *
  495. * @param string channel name, or false if this is a PEAR package
  496. * @param string package name
  497. *
  498. * @return string registry file name
  499. *
  500. * @access public
  501. */
  502. function _packageFileName($package, $channel = false)
  503. {
  504. if ($channel && $this->_getChannelFromAlias($channel) != 'pear.php.net')
  505. {
  506. return $this->_channelDirectoryName($channel) . DIRECTORY_SEPARATOR . strtolower($package) . '.reg';
  507. }
  508. return $this->statedir . DIRECTORY_SEPARATOR . strtolower($package) . '.reg';
  509. }
  510. // }}}
  511. // {{{ _channelFileName()
  512. /**
  513. * Get the name of the file where data for a given channel is stored.
  514. * @param string channel name
  515. * @return string registry file name
  516. */
  517. function _channelFileName($channel, $noaliases = false)
  518. {
  519. if (! $noaliases)
  520. {
  521. if (file_exists($this->_getChannelAliasFileName($channel)))
  522. {
  523. $channel = implode('', file($this->_getChannelAliasFileName($channel)));
  524. }
  525. }
  526. return $this->channelsdir . DIRECTORY_SEPARATOR . str_replace('/', '_', strtolower($channel)) . '.reg';
  527. }
  528. // }}}
  529. // {{{ getChannelAliasFileName()
  530. /**
  531. * @param string
  532. * @return string
  533. */
  534. function _getChannelAliasFileName($alias)
  535. {
  536. return $this->channelsdir . DIRECTORY_SEPARATOR . '.alias' . DIRECTORY_SEPARATOR . str_replace('/', '_', strtolower($alias)) . '.txt';
  537. }
  538. // }}}
  539. // {{{ _getChannelFromAlias()
  540. /**
  541. * Get the name of a channel from its alias
  542. */
  543. function _getChannelFromAlias($channel)
  544. {
  545. if (! $this->_channelExists($channel))
  546. {
  547. if ($channel == 'pear.php.net')
  548. {
  549. return 'pear.php.net';
  550. }
  551. if ($channel == 'pecl.php.net')
  552. {
  553. return 'pecl.php.net';
  554. }
  555. if ($channel == '__uri')
  556. {
  557. return '__uri';
  558. }
  559. return false;
  560. }
  561. $channel = strtolower($channel);
  562. if (file_exists($this->_getChannelAliasFileName($channel)))
  563. {
  564. // translate an alias to an actual channel
  565. return implode('', file($this->_getChannelAliasFileName($channel)));
  566. }
  567. else
  568. {
  569. return $channel;
  570. }
  571. }
  572. // }}}
  573. // {{{ _getChannelFromAlias()
  574. /**
  575. * Get the alias of a channel from its alias or its name
  576. */
  577. function _getAlias($channel)
  578. {
  579. if (! $this->_channelExists($channel))
  580. {
  581. if ($channel == 'pear.php.net')
  582. {
  583. return 'pear';
  584. }
  585. if ($channel == 'pecl.php.net')
  586. {
  587. return 'pecl';
  588. }
  589. return false;
  590. }
  591. $channel = $this->_getChannel($channel);
  592. if (PEAR :: isError($channel))
  593. {
  594. return $channel;
  595. }
  596. return $channel->getAlias();
  597. }
  598. // }}}
  599. // {{{ _channelDirectoryName()
  600. /**
  601. * Get the name of the file where data for a given package is stored.
  602. *
  603. * @param string channel name, or false if this is a PEAR package
  604. * @param string package name
  605. *
  606. * @return string registry file name
  607. *
  608. * @access public
  609. */
  610. function _channelDirectoryName($channel)
  611. {
  612. if (! $channel || $this->_getChannelFromAlias($channel) == 'pear.php.net')
  613. {
  614. return $this->statedir;
  615. }
  616. else
  617. {
  618. $ch = $this->_getChannelFromAlias($channel);
  619. if (! $ch)
  620. {
  621. $ch = $channel;
  622. }
  623. return $this->statedir . DIRECTORY_SEPARATOR . strtolower('.channel.' . str_replace('/', '_', $ch));
  624. }
  625. }
  626. // }}}
  627. // {{{ _openPackageFile()
  628. function _openPackageFile($package, $mode, $channel = false)
  629. {
  630. if (! $this->_assertStateDir($channel))
  631. {
  632. return null;
  633. }
  634. if (! in_array($mode, array('r', 'rb')) && ! $this->hasWriteAccess())
  635. {
  636. return null;
  637. }
  638. $file = $this->_packageFileName($package, $channel);
  639. if (! file_exists($file) && $mode == 'r' || $mode == 'rb')
  640. {
  641. return null;
  642. }
  643. $fp = @fopen($file, $mode);
  644. if (! $fp)
  645. {
  646. return null;
  647. }
  648. return $fp;
  649. }
  650. // }}}
  651. // {{{ _closePackageFile()
  652. function _closePackageFile($fp)
  653. {
  654. fclose($fp);
  655. }
  656. // }}}
  657. // {{{ _openChannelFile()
  658. function _openChannelFile($channel, $mode)
  659. {
  660. if (! $this->_assertChannelDir())
  661. {
  662. return null;
  663. }
  664. if (! in_array($mode, array('r', 'rb')) && ! $this->hasWriteAccess())
  665. {
  666. return null;
  667. }
  668. $file = $this->_channelFileName($channel);
  669. if (! file_exists($file) && $mode == 'r' || $mode == 'rb')
  670. {
  671. return null;
  672. }
  673. $fp = @fopen($file, $mode);
  674. if (! $fp)
  675. {
  676. return null;
  677. }
  678. return $fp;
  679. }
  680. // }}}
  681. // {{{ _closePackageFile()
  682. function _closeChannelFile($fp)
  683. {
  684. fclose($fp);
  685. }
  686. // }}}
  687. // {{{ _rebuildFileMap()
  688. function _rebuildFileMap()
  689. {
  690. if (! class_exists('PEAR_Installer_Role'))
  691. {
  692. require_once 'PEAR/Installer/Role.php';
  693. }
  694. $channels = $this->_listAllPackages();
  695. $files = array();
  696. foreach ($channels as $channel => $packages)
  697. {
  698. foreach ($packages as $package)
  699. {
  700. $version = $this->_packageInfo($package, 'version', $channel);
  701. $filelist = $this->_packageInfo($package, 'filelist', $channel);
  702. if (! is_array($filelist))
  703. {
  704. continue;
  705. }
  706. foreach ($filelist as $name => $attrs)
  707. {
  708. if (isset($attrs['attribs']))
  709. {
  710. $attrs = $attrs['attribs'];
  711. }
  712. // it is possible for conflicting packages in different channels to
  713. // conflict with data files/doc files
  714. if ($name == 'dirtree')
  715. {
  716. continue;
  717. }
  718. if (isset($attrs['role']) && ! in_array($attrs['role'], PEAR_Installer_Role :: getInstallableRoles()))
  719. {
  720. // these are not installed
  721. continue;
  722. }
  723. if (isset($attrs['role']) && ! in_array($attrs['role'], PEAR_Installer_Role :: getBaseinstallRoles()))
  724. {
  725. $attrs['baseinstalldir'] = $package;
  726. }
  727. if (isset($attrs['baseinstalldir']))
  728. {
  729. $file = $attrs['baseinstalldir'] . DIRECTORY_SEPARATOR . $name;
  730. }
  731. else
  732. {
  733. $file = $name;
  734. }
  735. $file = preg_replace(',^/+,', '', $file);
  736. if ($channel != 'pear.php.net')
  737. {
  738. if (! isset($files[$attrs['role']]))
  739. {
  740. $files[$attrs['role']] = array();
  741. }
  742. $files[$attrs['role']][$file] = array(strtolower($channel), strtolower($package));
  743. }
  744. else
  745. {
  746. if (! isset($files[$attrs['role']]))
  747. {
  748. $files[$attrs['role']] = array();
  749. }
  750. $files[$attrs['role']][$file] = strtolower($package);
  751. }
  752. }
  753. }
  754. }
  755. $this->_assertStateDir();
  756. if (! $this->hasWriteAccess())
  757. {
  758. return false;
  759. }
  760. $fp = @fopen($this->filemap, 'wb');
  761. if (! $fp)
  762. {
  763. return false;
  764. }
  765. $this->filemap_cache = $files;
  766. fwrite($fp, serialize($files));
  767. fclose($fp);
  768. return true;
  769. }
  770. // }}}
  771. // {{{ _readFileMap()
  772. function _readFileMap()
  773. {
  774. if (! file_exists($this->filemap))
  775. {
  776. return array();
  777. }
  778. $fp = @fopen($this->filemap, 'r');
  779. if (! $fp)
  780. {
  781. return $this->raiseError('PEAR_Registry: could not open filemap "' . $this->filemap . '"', PEAR_REGISTRY_ERROR_FILE, null, null, $php_errormsg);
  782. }
  783. clearstatcache();
  784. $rt = get_magic_quotes_runtime();
  785. set_magic_quotes_runtime(0);
  786. $fsize = filesize($this->filemap);
  787. fclose($fp);
  788. $data = file_get_contents($this->filemap);
  789. set_magic_quotes_runtime($rt);
  790. $tmp = unserialize($data);
  791. if (! $tmp && $fsize > 7)
  792. {
  793. return $this->raiseError('PEAR_Registry: invalid filemap data', PEAR_REGISTRY_ERROR_FORMAT, null, null, $data);
  794. }
  795. $this->filemap_cache = $tmp;
  796. return true;
  797. }
  798. // }}}
  799. // {{{ _lock()
  800. /**
  801. * Lock the registry.
  802. *
  803. * @param integer lock mode, one of LOCK_EX, LOCK_SH or LOCK_UN.
  804. * See flock manual for more information.
  805. *
  806. * @return bool TRUE on success, FALSE if locking failed, or a
  807. * PEAR error if some other error occurs (such as the
  808. * lock file not being writable).
  809. *
  810. * @access private
  811. */
  812. function _lock($mode = LOCK_EX)
  813. {
  814. if (! eregi('Windows 9', php_uname()))
  815. {
  816. if ($mode != LOCK_UN && is_resource($this->lock_fp))
  817. {
  818. // XXX does not check type of lock (LOCK_SH/LOCK_EX)
  819. return true;
  820. }
  821. if (! $this->_assertStateDir())
  822. {
  823. if ($mode == LOCK_EX)
  824. {
  825. return $this->raiseError('Registry directory is not writeable by the current user');
  826. }
  827. else
  828. {
  829. return true;
  830. }
  831. }
  832. $open_mode = 'w';
  833. // XXX People reported problems with LOCK_SH and 'w'
  834. if ($mode === LOCK_SH || $mode === LOCK_UN)
  835. {
  836. if (! file_exists($this->lockfile))
  837. {
  838. touch($this->lockfile);
  839. }
  840. $open_mode = 'r';
  841. }
  842. if (! is_resource($this->lock_fp))
  843. {
  844. $this->lock_fp = @fopen($this->lockfile, $open_mode);
  845. }
  846. if (! is_resource($this->lock_fp))
  847. {
  848. $this->lock_fp = null;
  849. return $this->raiseError("could not create lock file" . (isset($php_errormsg) ? ": " . $php_errormsg : ""));
  850. }
  851. if (! (int) flock($this->lock_fp, $mode))
  852. {
  853. switch ($mode)
  854. {
  855. case LOCK_SH :
  856. $str = 'shared';
  857. break;
  858. case LOCK_EX :
  859. $str = 'exclusive';
  860. break;
  861. case LOCK_UN :
  862. $str = 'unlock';
  863. break;
  864. default :
  865. $str = 'unknown';
  866. break;
  867. }
  868. //is resource at this point, close it on error.
  869. fclose($this->lock_fp);
  870. $this->lock_fp = null;
  871. return $this->raiseError("could not acquire $str lock ($this->lockfile)", PEAR_REGISTRY_ERROR_LOCK);
  872. }
  873. }
  874. return true;
  875. }
  876. // }}}
  877. // {{{ _unlock()
  878. function _unlock()
  879. {
  880. $ret = $this->_lock(LOCK_UN);
  881. if (is_resource($this->lock_fp))
  882. {
  883. fclose($this->lock_fp);
  884. }
  885. $this->lock_fp = null;
  886. return $ret;
  887. }
  888. // }}}
  889. // {{{ _packageExists()
  890. function _packageExists($package, $channel = false)
  891. {
  892. return file_exists($this->_packageFileName($package, $channel));
  893. }
  894. // }}}
  895. // {{{ _channelExists()
  896. /**
  897. * Determine whether a channel exists in the registry
  898. * @param string Channel name
  899. * @param bool if true, then aliases will be ignored
  900. * @return boolean
  901. */
  902. function _channelExists($channel, $noaliases = false)
  903. {
  904. $a = file_exists($this->_channelFileName($channel, $noaliases));
  905. if (! $a && $channel == 'pear.php.net')
  906. {
  907. return true;
  908. }
  909. if (! $a && $channel == 'pecl.php.net')
  910. {
  911. return true;
  912. }
  913. return $a;
  914. }
  915. // }}}
  916. // {{{ _addChannel()
  917. /**
  918. * @param PEAR_ChannelFile Channel object
  919. * @param donotuse
  920. * @param string Last-Modified HTTP tag from remote request
  921. * @return boolean|PEAR_Error True on creation, false if it already exists
  922. */
  923. function _addChannel($channel, $update = false, $lastmodified = false)
  924. {
  925. if (! is_a($channel, 'PEAR_ChannelFile'))
  926. {
  927. return false;
  928. }
  929. if (! $channel->validate())
  930. {
  931. return false;
  932. }
  933. if (file_exists($this->_channelFileName($channel->getName())))
  934. {
  935. if (! $update)
  936. {
  937. return false;
  938. }
  939. $checker = $this->_getChannel($channel->getName());
  940. if (PEAR :: isError($checker))
  941. {
  942. return $checker;
  943. }
  944. if ($channel->getAlias() != $checker->getAlias())
  945. {
  946. if (file_exists($this->_getChannelAliasFileName($checker->getAlias())))
  947. {
  948. @unlink($this->_getChannelAliasFileName($checker->getAlias()));
  949. }
  950. }
  951. }
  952. else
  953. {
  954. if ($update && ! in_array($channel->getName(), array('pear.php.net', 'pecl.php.net')))
  955. {
  956. return false;
  957. }
  958. }
  959. $ret = $this->_assertChannelDir();
  960. if (PEAR :: isError($ret))
  961. {
  962. return $ret;
  963. }
  964. $ret = $this->_assertChannelStateDir($channel->getName());
  965. if (PEAR :: isError($ret))
  966. {
  967. return $ret;
  968. }
  969. if ($channel->getAlias() != $channel->getName())
  970. {
  971. if (file_exists($this->_getChannelAliasFileName($channel->getAlias())) && $this->_getChannelFromAlias($channel->getAlias()) != $channel->getName())
  972. {
  973. $channel->setAlias($channel->getName());
  974. }
  975. if (! $this->hasWriteAccess())
  976. {
  977. return false;
  978. }
  979. $fp = @fopen($this->_getChannelAliasFileName($channel->getAlias()), 'w');
  980. if (! $fp)
  981. {
  982. return false;
  983. }
  984. fwrite($fp, $channel->getName());
  985. fclose($fp);
  986. }
  987. if (! $this->hasWriteAccess())
  988. {
  989. return false;
  990. }
  991. $fp = @fopen($this->_channelFileName($channel->getName()), 'wb');
  992. if (! $fp)
  993. {
  994. return false;
  995. }
  996. $info = $channel->toArray();
  997. if ($lastmodified)
  998. {
  999. $info['_lastmodified'] = $lastmodified;
  1000. }
  1001. else
  1002. {
  1003. $info['_lastmodified'] = date('r');
  1004. }
  1005. fwrite($fp, serialize($info));
  1006. fclose($fp);
  1007. return true;
  1008. }
  1009. // }}}
  1010. // {{{ _deleteChannel()
  1011. /**
  1012. * Deletion fails if there are any packages installed from the channel
  1013. * @param string|PEAR_ChannelFile channel name
  1014. * @return boolean|PEAR_Error True on deletion, false if it doesn't exist
  1015. */
  1016. function _deleteChannel($channel)
  1017. {
  1018. if (! is_string($channel))
  1019. {
  1020. if (is_a($channel, 'PEAR_ChannelFile'))
  1021. {
  1022. if (! $channel->validate())
  1023. {
  1024. return false;
  1025. }
  1026. $channel = $channel->getName();
  1027. }
  1028. else
  1029. {
  1030. return false;
  1031. }
  1032. }
  1033. if ($this->_getChannelFromAlias($channel) == '__uri')
  1034. {
  1035. return false;
  1036. }
  1037. if ($this->_getChannelFromAlias($channel) == 'pecl.php.net')
  1038. {
  1039. return false;
  1040. }
  1041. if (! $this->_channelExists($channel))
  1042. {
  1043. return false;
  1044. }
  1045. if (! $channel || $this->_getChannelFromAlias($channel) == 'pear.php.net')
  1046. {
  1047. return false;
  1048. }
  1049. $channel = $this->_getChannelFromAlias($channel);
  1050. if ($channel == 'pear.php.net')
  1051. {
  1052. return false;
  1053. }
  1054. $test = $this->_listChannelPackages($channel);
  1055. if (count($test))
  1056. {
  1057. return false;
  1058. }
  1059. $test = @rmdir($this->_channelDirectoryName($channel));
  1060. if (! $test)
  1061. {
  1062. return false;
  1063. }
  1064. $file = $this->_getChannelAliasFileName($this->_getAlias($channel));
  1065. if (file_exists($file))
  1066. {
  1067. $test = @unlink($file);
  1068. if (! $test)
  1069. {
  1070. return false;
  1071. }
  1072. }
  1073. $file = $this->_channelFileName($channel);
  1074. $ret = true;
  1075. if (file_exists($file))
  1076. {
  1077. $ret = @unlink($file);
  1078. }
  1079. return $ret;
  1080. }
  1081. // }}}
  1082. // {{{ _isChannelAlias()
  1083. /**
  1084. * Determine whether a channel exists in the registry
  1085. * @param string Channel Alias
  1086. * @return boolean
  1087. */
  1088. function _isChannelAlias($alias)
  1089. {
  1090. return file_exists($this->_getChannelAliasFileName($alias));
  1091. }
  1092. // }}}
  1093. // {{{ _packageInfo()
  1094. /**
  1095. * @param string|null
  1096. * @param string|null
  1097. * @param string|null
  1098. * @return array|null
  1099. * @access private
  1100. */
  1101. function _packageInfo($package = null, $key = null, $channel = 'pear.php.net')
  1102. {
  1103. if ($package === null)
  1104. {
  1105. if ($channel === null)
  1106. {
  1107. $channels = $this->_listChannels();
  1108. $ret = array();
  1109. foreach ($channels as $channel)
  1110. {
  1111. $channel = strtolower($channel);
  1112. $ret[$channel] = array();
  1113. $packages = $this->_listPackages($channel);
  1114. foreach ($packages as $package)
  1115. {
  1116. $ret[$channel][] = $this->_packageInfo($package, null, $channel);
  1117. }
  1118. }
  1119. return $ret;
  1120. }
  1121. $ps = $this->_listPackages($channel);
  1122. if (! count($ps))
  1123. {
  1124. return array();
  1125. }
  1126. return array_map(array(&$this, '_packageInfo'), $ps, array_fill(0, count($ps), null), array_fill(0, count($ps), $channel));
  1127. }
  1128. $fp = $this->_openPackageFile($package, 'r', $channel);
  1129. if ($fp === null)
  1130. {
  1131. return null;
  1132. }
  1133. $rt = get_magic_quotes_runtime();
  1134. set_magic_quotes_runtime(0);
  1135. clearstatcache();
  1136. $this->_closePackageFile($fp);
  1137. $data = file_get_contents($this->_packageFileName($package, $channel));
  1138. set_magic_quotes_runtime($rt);
  1139. $data = unserialize($data);
  1140. if ($key === null)
  1141. {
  1142. return $data;
  1143. }
  1144. // compatibility for package.xml version 2.0
  1145. if (isset($data['old'][$key]))
  1146. {
  1147. return $data['old'][$key];
  1148. }
  1149. if (isset($data[$key]))
  1150. {
  1151. return $data[$key];
  1152. }
  1153. return null;
  1154. }
  1155. // }}}
  1156. // {{{ _channelInfo()
  1157. /**
  1158. * @param string Channel name
  1159. * @param bool whether to strictly retrieve info of channels, not just aliases
  1160. * @return array|null
  1161. */
  1162. function _channelInfo($channel, $noaliases = false)
  1163. {
  1164. if (! $this->_channelExists($channel, $noaliases))
  1165. {
  1166. return null;
  1167. }
  1168. $fp = $this->_openChannelFile($channel, 'r');
  1169. if ($fp === null)
  1170. {
  1171. return null;
  1172. }
  1173. $rt = get_magic_quotes_runtime();
  1174. set_magic_quotes_runtime(0);
  1175. clearstatcache();
  1176. $this->_closeChannelFile($fp);
  1177. $data = file_get_contents($this->_channelFileName($channel));
  1178. set_magic_quotes_runtime($rt);
  1179. $data = unserialize($data);
  1180. return $data;
  1181. }
  1182. // }}}
  1183. // {{{ _listChannels()
  1184. function _listChannels()
  1185. {
  1186. $channellist = array();
  1187. if (! file_exists($this->channelsdir) || ! is_dir($this->channelsdir))
  1188. {
  1189. return array('pear.php.net', 'pecl.php.net', '__uri');
  1190. }
  1191. $dp = opendir($this->channelsdir);
  1192. while ($ent = readdir($dp))
  1193. {
  1194. if ($ent{0} == '.' || substr($ent, - 4) != '.reg')
  1195. {
  1196. continue;
  1197. }
  1198. if ($ent == '__uri.reg')
  1199. {
  1200. $channellist[] = '__uri';
  1201. continue;
  1202. }
  1203. $channellist[] = str_replace('_', '/', substr($ent, 0, - 4));
  1204. }
  1205. closedir($dp);
  1206. if (! in_array('pear.php.net', $channellist))
  1207. {
  1208. $channellist[] = 'pear.php.net';
  1209. }
  1210. if (! in_array('pecl.php.net', $channellist))
  1211. {
  1212. $channellist[] = 'pecl.php.net';
  1213. }
  1214. if (! in_array('__uri', $channellist))
  1215. {
  1216. $channellist[] = '__uri';
  1217. }
  1218. natsort($channellist);
  1219. return $channellist;
  1220. }
  1221. // }}}
  1222. // {{{ _listPackages()
  1223. function _listPackages($channel = false)
  1224. {
  1225. if ($channel && $this->_getChannelFromAlias($channel) != 'pear.php.net')
  1226. {
  1227. return $this->_listChannelPackages($channel);
  1228. }
  1229. if (! file_exists($this->statedir) || ! is_dir($this->statedir))
  1230. {
  1231. return array();
  1232. }
  1233. $pkglist = array();
  1234. $dp = opendir($this->statedir);
  1235. if (! $dp)
  1236. {
  1237. return $pkglist;
  1238. }
  1239. while ($ent = readdir($dp))
  1240. {
  1241. if ($ent{0} == '.' || substr($ent, - 4) != '.reg')
  1242. {
  1243. continue;
  1244. }
  1245. $pkglist[] = substr($ent, 0, - 4);
  1246. }
  1247. closedir($dp);
  1248. return $pkglist;
  1249. }
  1250. // }}}
  1251. // {{{ _listChannelPackages()
  1252. function _listChannelPackages($channel)
  1253. {
  1254. $pkglist = array();
  1255. if (! file_exists($this->_channelDirectoryName($channel)) || ! is_dir($this->_channelDirectoryName($channel)))
  1256. {
  1257. return array();
  1258. }
  1259. $dp = opendir($this->_channelDirectoryName($channel));
  1260. if (! $dp)
  1261. {
  1262. return $pkglist;
  1263. }
  1264. while ($ent = readdir($dp))
  1265. {
  1266. if ($ent{0} == '.' || substr($ent, - 4) != '.reg')
  1267. {
  1268. continue;
  1269. }
  1270. $pkglist[] = substr($ent, 0, - 4);
  1271. }
  1272. closedir($dp);
  1273. return $pkglist;
  1274. }
  1275. // }}}
  1276. function _listAllPackages()
  1277. {
  1278. $ret = array();
  1279. foreach ($this->_listChannels() as $channel)
  1280. {
  1281. $ret[$channel] = $this->_listPackages($channel);
  1282. }
  1283. return $ret;
  1284. }
  1285. /**
  1286. * Add an installed package to the registry
  1287. * @param string package name
  1288. * @param array package info (parsed by PEAR_Common::infoFrom*() methods)
  1289. * @return bool success of saving
  1290. * @access private
  1291. */
  1292. function _addPackage($package, $info)
  1293. {
  1294. if ($this->_packageExists($package))
  1295. {
  1296. return false;
  1297. }
  1298. $fp = $this->_openPackageFile($package, 'wb');
  1299. if ($fp === null)
  1300. {
  1301. return false;
  1302. }
  1303. $info['_lastmodified'] = time();
  1304. fwrite($fp, serialize($info));
  1305. $this->_closePackageFile($fp);
  1306. if (isset($info['filelist']))
  1307. {
  1308. $this->_rebuildFileMap();
  1309. }
  1310. return true;
  1311. }
  1312. /**
  1313. * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
  1314. * @return bool
  1315. * @access private
  1316. */
  1317. function _addPackage2($info)
  1318. {
  1319. if (! is_a($info, 'PEAR_PackageFile_v1') && ! is_a($info, 'PEAR_PackageFile_v2'))
  1320. {
  1321. return false;
  1322. }
  1323. if (! $info->validate())
  1324. {
  1325. if (class_exists('PEAR_Common'))
  1326. {
  1327. $ui = PEAR_Frontend :: singleton();
  1328. if ($ui)
  1329. {
  1330. foreach ($info->getValidationWarnings() as $err)
  1331. {
  1332. $ui->log($err['message'], true);
  1333. }
  1334. }
  1335. }
  1336. return false;
  1337. }
  1338. $channel = $info->getChannel();
  1339. $package = $info->getPackage();
  1340. $save = $info;
  1341. if ($this->_packageExists($package, $channel))
  1342. {
  1343. return false;
  1344. }
  1345. if (! $this->_channelExists($channel, true))
  1346. {
  1347. return false;
  1348. }
  1349. $info = $info->toArray(true);
  1350. if (! $info)
  1351. {
  1352. return false;
  1353. }
  1354. $fp = $this->_openPackageFile($package, 'wb', $channel);
  1355. if ($fp === null)
  1356. {
  1357. return false;
  1358. }
  1359. $info['_lastmodified'] = time();
  1360. fwrite($fp, serialize($info));
  1361. $this->_closePackageFile($fp);
  1362. $this->_rebuildFileMap();
  1363. return true;
  1364. }
  1365. /**
  1366. * @param string Package name
  1367. * @param array parsed package.xml 1.0
  1368. * @param bool this parameter is only here for BC. Don't use it.
  1369. * @access private
  1370. */
  1371. function _updatePackage($package, $info, $merge = true)
  1372. {
  1373. $oldinfo = $this->_packageInfo($package);
  1374. if (empty($oldinfo))
  1375. {
  1376. return false;
  1377. }
  1378. $fp = $this->_openPackageFile($package, 'w');
  1379. if ($fp === null)
  1380. {
  1381. return false;
  1382. }
  1383. if (is_object($info))
  1384. {
  1385. $info = $info->toArray();
  1386. }
  1387. $info['_lastmodified'] = time();
  1388. $newinfo = $info;
  1389. if ($merge)
  1390. {
  1391. $info = array_merge($oldinfo, $info);
  1392. }
  1393. else
  1394. {
  1395. $diff = $info;
  1396. }
  1397. fwrite($fp, serialize($info));
  1398. $this->_closePackageFile($fp);
  1399. if (isset($newinfo['filelist']))
  1400. {
  1401. $this->_rebuildFileMap();
  1402. }
  1403. return true;
  1404. }
  1405. /**
  1406. * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
  1407. * @return bool
  1408. * @access private
  1409. */
  1410. function _updatePackage2($info)
  1411. {
  1412. if (! $this->_packageExists($info->getPackage(), $info->getChannel()))
  1413. {
  1414. return false;
  1415. }
  1416. $fp = $this->_openPackageFile($info->getPackage(), 'w', $info->getChannel());
  1417. if ($fp === null)
  1418. {
  1419. return false;
  1420. }
  1421. $save = $info;
  1422. $info = $save->getArray(true);
  1423. $info['_lastmodified'] = time();
  1424. fwrite($fp, serialize($info));
  1425. $this->_closePackageFile($fp);
  1426. $this->_rebuildFileMap();
  1427. return true;
  1428. }
  1429. /**
  1430. * @param string Package name
  1431. * @param string Channel name
  1432. * @return PEAR_PackageFile_v1|PEAR_PackageFile_v2|null
  1433. * @access private
  1434. */
  1435. function &_getPackage($package, $channel = 'pear.php.net')
  1436. {
  1437. $info = $this->_packageInfo($package, null, $channel);
  1438. if ($info === null)
  1439. {
  1440. return $info;
  1441. }
  1442. $a = $this->_config;
  1443. if (! $a)
  1444. {
  1445. $this->_config = &new PEAR_Config();
  1446. $this->_config->set('php_dir', $this->statedir);
  1447. }
  1448. if (! class_exists('PEAR_PackageFile'))
  1449. {
  1450. require_once 'PEAR/PackageFile.php';
  1451. }
  1452. $pkg = &new PEAR_PackageFile($this->_config);
  1453. $pf = &$pkg->fromArray($info);
  1454. return $pf;
  1455. }
  1456. /**
  1457. * @param string channel name
  1458. * @param bool whether to strictly retrieve channel names
  1459. * @return PEAR_ChannelFile|PEAR_Error
  1460. * @access private
  1461. */
  1462. function &_getChannel($channel, $noaliases = false)
  1463. {
  1464. $ch = false;
  1465. if ($this->_channelExists($channel, $noaliases))
  1466. {
  1467. $chinfo = $this->_channelInfo($channel, $noaliases);
  1468. if ($chinfo)
  1469. {
  1470. if (! class_exists('PEAR_ChannelFile'))
  1471. {
  1472. require_once 'PEAR/ChannelFile.php';
  1473. }
  1474. $ch = &PEAR_ChannelFile :: fromArrayWithErrors($chinfo);
  1475. }
  1476. }
  1477. if ($ch)
  1478. {
  1479. if ($ch->validate())
  1480. {
  1481. return $ch;
  1482. }
  1483. foreach ($ch->getErrors(true) as $err)
  1484. {
  1485. $message = $err['message'] . "\n";
  1486. }
  1487. $ch = PEAR :: raiseError($message);
  1488. return $ch;
  1489. }
  1490. if ($this->_getChannelFromAlias($channel) == 'pear.php.net')
  1491. {
  1492. // the registry is not properly set up, so use defaults
  1493. if (! class_exists('PEAR_ChannelFile'))
  1494. {
  1495. require_once 'PEAR/ChannelFile.php';
  1496. }
  1497. $pear_channel = new PEAR_ChannelFile();
  1498. $pear_channel->setName('pear.php.net');
  1499. $pear_channel->setAlias('pear');
  1500. $pear_channel->setSummary('PHP Extension and Application Repository');
  1501. $pear_channel->setDefaultPEARProtocols();
  1502. $pear_channel->setBaseURL('REST1.0', 'http://pear.php.net/rest/');
  1503. $pear_channel->setBaseURL('REST1.1', 'http://pear.php.net/rest/');
  1504. return $pear_channel;
  1505. }
  1506. if ($this->_getChannelFromAlias($channel) == 'pecl.php.net')
  1507. {
  1508. // the registry is not properly set up, so use defaults
  1509. if (! class_exists('PEAR_ChannelFile'))
  1510. {
  1511. require_once 'PEAR/ChannelFile.php';
  1512. }
  1513. $

Large files files are truncated, but you can click here to view the full file