1 : <?php
2 : /**
3 : * This package generate phpinfo() style PEAR information.
4 : *
5 : * PHP versions 4 and 5
6 : *
7 : * LICENSE: This source file is subject to version 3.01 of the PHP license
8 : * that is available through the world-wide-web at the following URI:
9 : * http://www.php.net/license/3_01.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_Info
15 : * @author Davey Shafik <davey@pixelated-dreams.com>
16 : * @author Laurent Laville <pear@laurent-laville.org>
17 : * @license http://www.php.net/license/3_01.txt PHP License 3.01
18 : * @version CVS: $Id: Info.php,v 1.60 2009/02/18 17:29:43 farell Exp $
19 : * @link http://pear.php.net/package/PEAR_Info
20 : * @since File available since Release 1.0.1
21 : */
22 :
23 4 : require_once 'PEAR/Config.php';
24 :
25 : /**
26 : * PEAR_INFO_* is a bit-field. Or each number up to get desired information.
27 : *
28 : * Examples:
29 : * <code>
30 : * <?php
31 : * require_once 'PEAR/Info.php';
32 : * // will display for each channel (list displayed),
33 : * // a quick package list with only its name and version
34 : * $options = array('resume' => PEAR_INFO_CHANNELS | PEAR_INFO_PACKAGES_VERSION);
35 : * $info = new PEAR_Info('', 'c:\wamp\php\pear.ini', '', $options);
36 : * $info->display();
37 : * ?>
38 : * </code>
39 : *
40 : * - Show all informations, except for credits
41 : *
42 : * $options = array('resume' => PEAR_INFO_ALL & ~PEAR_INFO_CREDITS);
43 : *
44 : * - Show only credits and configuration
45 : *
46 : * $options = array('resume' => PEAR_INFO_CONFIGURATION | PEAR_INFO_CREDITS);
47 : */
48 : /**
49 : * The configuration line, pear.ini | .pearrc location, and more.
50 : *
51 : * @var integer
52 : * @since 1.7.0RC1
53 : */
54 4 : define('PEAR_INFO_GENERAL', 1);
55 : /**
56 : * PEAR Credits
57 : *
58 : * @var integer
59 : * @since 1.7.0RC1
60 : */
61 4 : define('PEAR_INFO_CREDITS', 2);
62 : /**
63 : * All PEAR settings.
64 : *
65 : * @var integer
66 : * @since 1.7.0RC1
67 : */
68 4 : define('PEAR_INFO_CONFIGURATION', 4);
69 : /**
70 : * Information on PEAR channels.
71 : *
72 : * @var integer
73 : * @since 1.7.0RC1
74 : */
75 4 : define('PEAR_INFO_CHANNELS', 8);
76 : /**#@+
77 : * Information on PEAR packages.
78 : *
79 : * @var integer
80 : * @since 1.7.0RC1
81 : */
82 4 : define('PEAR_INFO_PACKAGES', 4080);
83 4 : define('PEAR_INFO_PACKAGES_CHANNEL', 2048);
84 4 : define('PEAR_INFO_PACKAGES_SUMMARY', 1024);
85 4 : define('PEAR_INFO_PACKAGES_VERSION', 512);
86 4 : define('PEAR_INFO_PACKAGES_LICENSE', 256);
87 4 : define('PEAR_INFO_PACKAGES_DESCRIPTION', 128);
88 4 : define('PEAR_INFO_PACKAGES_DEPENDENCIES', 64);
89 4 : define('PEAR_INFO_PACKAGES_XML', 32);
90 4 : define('PEAR_INFO_PACKAGES_UPDATE', 16);
91 : /**#@-*/
92 : /**
93 : * Shows all of the above. This is the default value.
94 : *
95 : * @var integer
96 : * @since 1.7.0RC1
97 : */
98 4 : define('PEAR_INFO_ALL', 4095);
99 : /**#@+
100 : * Information on PEAR credits.
101 : *
102 : * @var integer
103 : * @since 1.7.0RC3
104 : */
105 4 : define('PEAR_INFO_CREDITS_GROUP', 4096);
106 4 : define('PEAR_INFO_CREDITS_DOCS', 8192);
107 4 : define('PEAR_INFO_CREDITS_WEBSITE', 16384);
108 4 : define('PEAR_INFO_CREDITS_PACKAGES', 32768);
109 4 : define('PEAR_INFO_CREDITS_ALL', 61440);
110 : /**#@-*/
111 : /**
112 : * Indicates that a complete stand-alone HTML page needs to be printed
113 : * including the information indicated by the other flags.
114 : *
115 : * @var integer
116 : * @since 1.7.0RC3
117 : */
118 4 : define('PEAR_INFO_FULLPAGE', 65536);
119 :
120 : /**
121 : * The PEAR_Info class generate phpinfo() style PEAR information.
122 : *
123 : * @category PEAR
124 : * @package PEAR_Info
125 : * @author Davey Shafik <davey@pixelated-dreams.com>
126 : * @author Laurent Laville <pear@laurent-laville.org>
127 : * @license http://www.php.net/license/3_01.txt PHP License 3.01
128 : * @version Release: @package_version@
129 : * @link http://pear.php.net/package/PEAR_Info
130 : * @since Class available since Release 1.0.1
131 : */
132 :
133 : class PEAR_Info
134 4 : {
135 : /**
136 : * Html code for phpinfo() style PEAR information
137 : *
138 : * @var string
139 : * @access public
140 : * @since 1.0.1
141 : */
142 : var $info;
143 :
144 : /**
145 : * Style sheet for the custom layout
146 : *
147 : * @var string
148 : * @access public
149 : * @since 1.7.0RC1
150 : */
151 : var $css;
152 :
153 : /**
154 : * instance of PEAR_config
155 : *
156 : * @var object
157 : * @access public
158 : * @since 1.0.1
159 : */
160 : var $config;
161 :
162 : /**
163 : * Alternative config files
164 : *
165 : * @var array
166 : * @access public
167 : * @since 1.9.0
168 : */
169 : var $cfg;
170 :
171 : /**
172 : * instance of PEAR_Registry
173 : *
174 : * @var object
175 : * @access public
176 : * @since 1.0.1
177 : */
178 : var $reg;
179 :
180 : /**
181 : * PHP 4 style constructor (ZE1)
182 : *
183 : * @param string $pear_dir (optional) The PEAR base install directory
184 : * @param string $user_file (optional) file to read PEAR user-defined
185 : * options from
186 : * @param string $system_file (optional) file to read PEAR system-wide
187 : * defaults from
188 : * @param array $options (optional) configure PEAR information output
189 : *
190 : * @return void
191 : * @access public
192 : * @since version 1.0.1 (2003-04-24)
193 : */
194 : function PEAR_Info($pear_dir = '', $user_file = '', $system_file = '',
195 : $options = null)
196 : {
197 0 : $this->__construct($pear_dir, $user_file, $system_file, $options);
198 0 : }
199 :
200 : /**
201 : * PHP 5 style constructor (ZE2)
202 : *
203 : * @param string $pear_dir (optional) The PEAR base install directory
204 : * @param string $user_file (optional) file to read PEAR user-defined
205 : * options from
206 : * @param string $system_file (optional) file to read PEAR system-wide
207 : * defaults from
208 : * @param array $options (optional) configure PEAR information output
209 : *
210 : * @return void
211 : * @access private
212 : * @since version 1.7.0RC1 (2007-07-01)
213 : */
214 : function __construct($pear_dir = '', $user_file = '', $system_file = '',
215 : $options = null)
216 : {
217 : // options defined at run-time (default)
218 3 : $this->options = array('channels' => array('pear.php.net'),
219 3 : 'resume' => PEAR_INFO_ALL | PEAR_INFO_FULLPAGE);
220 3 : if (isset($options)) {
221 : // overwrite one to all defaults
222 2 : $this->options = array_merge($this->options, $options);
223 2 : }
224 :
225 : // to keep compatibility with version less or equal than 1.6.1
226 3 : if (!empty($pear_dir) && empty($user_file) && empty($system_file)) {
227 2 : $p_available = (is_dir($pear_dir));
228 2 : $this->cfg['pear_dir'] = array($pear_dir, $p_available);
229 :
230 2 : if (!$p_available) {
231 1 : $e = '<p class="error">No valid PEAR directory</p>';
232 :
233 1 : $this->info = $e;
234 1 : return;
235 : }
236 :
237 : // try to find a PEAR user-defined config file into $pear_dir
238 2 : $user_file = $pear_dir . DIRECTORY_SEPARATOR;
239 2 : if (OS_WINDOWS) {
240 2 : $user_file .= 'pear.ini';
241 2 : } else {
242 0 : $user_file .= '.pearrc';
243 : }
244 2 : $u_available = file_exists($user_file);
245 2 : $this->cfg['user_file'] = array($user_file, $u_available);
246 :
247 : // try to find a PEAR system-wide config file into $pear_dir
248 2 : $system_file = $pear_dir . DIRECTORY_SEPARATOR;
249 2 : if (OS_WINDOWS) {
250 2 : $system_file .= 'pearsys.ini';
251 2 : } else {
252 0 : $system_file .= 'pear.conf';
253 : }
254 2 : $s_available = file_exists($system_file);
255 2 : $this->cfg['system_file'] = array($system_file, $s_available);
256 :
257 2 : if ($u_available) {
258 0 : if (!$s_available) {
259 0 : $system_file = '';
260 0 : }
261 0 : } else {
262 2 : if (!$s_available) {
263 : $e = '<p class="error">No PEAR configuration files ('
264 1 : . basename($user_file) . ' or ' . basename($system_file)
265 1 : . ") found into '$pear_dir' directory</p>";
266 :
267 1 : $this->info = $e;
268 1 : return;
269 : }
270 2 : $user_file = '';
271 : }
272 2 : }
273 :
274 3 : $this->config =& PEAR_Config::singleton($user_file, $system_file);
275 :
276 : // look for default PEAR installation
277 3 : if (empty($pear_dir)) {
278 2 : $php_dir = $this->config->get('php_dir');
279 2 : $p_available = (is_dir($php_dir));
280 2 : $this->cfg['pear_dir'] = array($php_dir, $p_available);
281 :
282 2 : $pear_user_file = $this->config->getConfFile('user');
283 2 : $u_available = file_exists($pear_user_file);
284 2 : $this->cfg['user_file'] = array($pear_user_file, $u_available);
285 :
286 2 : $pear_system_file = $this->config->getConfFile('system');
287 2 : $s_available = file_exists($pear_system_file);
288 2 : $this->cfg['system_file'] = array($pear_system_file, $s_available);
289 2 : }
290 :
291 : // to keep compatibility with version less or equal than 1.6.1
292 3 : if (defined('PEAR_INFO_PROXY')) {
293 0 : $this->config->set('http_proxy', PEAR_INFO_PROXY);
294 0 : }
295 :
296 3 : if (empty($user_file) || !file_exists($user_file)) {
297 3 : if (empty($system_file) || !file_exists($system_file)) {
298 2 : $user_file = $this->config->getConfFile('user');
299 2 : if (file_exists($user_file)) {
300 0 : $layer = 'user';
301 0 : } else {
302 2 : $system_file = $this->config->getConfFile('system');
303 2 : $layer = 'system';
304 : }
305 2 : } else {
306 2 : $layer = 'system';
307 : }
308 3 : } else {
309 0 : $layer = 'user';
310 : }
311 : // prevent unexpected result if PEAR config file does not exist
312 3 : if (!file_exists($user_file) && !file_exists($system_file)) {
313 : $e = '<p class="error">PEAR configuration files "'
314 1 : . $user_file . '", "' . $system_file . '" does not exist</p>';
315 :
316 1 : $this->info = $e;
317 1 : return;
318 : }
319 : // Get the config's registry object.
320 3 : $this->reg = &$this->config->getRegistry();
321 :
322 : // Get list of all channels in your PEAR install,
323 : // when 'channels' option is empty
324 3 : if (isset($this->options['channels'])
325 3 : && empty($this->options['channels'])) {
326 2 : $channels = $this->reg->listChannels();
327 2 : if (PEAR::isError($channels)) {
328 0 : $this->options['channels'] = array('pear.php.net');
329 0 : } else {
330 2 : $this->options['channels'] = $channels;
331 : }
332 2 : }
333 :
334 : // show general informations such as PEAR version, PEAR logo,
335 : // and config file used
336 3 : if ($this->options['resume'] & PEAR_INFO_GENERAL) {
337 3 : $pear = $this->reg->getPackage("PEAR");
338 3 : $pear_version = $pear->getVersion();
339 3 : $this->info = '
340 : <table>
341 : <tr class="h">
342 : <td>
343 : <a href="http://pear.php.net/">
344 : <img src="{phpself}?pear_image=true" alt="PEAR Logo" />
345 : </a>
346 : <h1 class="p">PEAR {pearversion}</h1>
347 : </td>
348 : </tr>
349 : </table>
350 : ';
351 3 : $this->info = str_replace(array('{phpself}', '{pearversion}'),
352 3 : array(htmlentities($_SERVER['PHP_SELF']), $pear_version),
353 3 : $this->info);
354 :
355 : // Loaded configuration file
356 3 : $this->info .= '
357 : <table>
358 : <tr class="v">
359 : <td class="e">Loaded Configuration File</td>
360 : <td>{value}</td>
361 : </tr>
362 : <tr class="v">
363 : <td class="e">Alternative Configuration Files</td>
364 : <td>{alt}</td>
365 : </tr>
366 : </table>
367 :
368 : ';
369 :
370 3 : $alt = '<dl>';
371 :
372 3 : $found = $this->cfg['user_file'][1];
373 3 : if ($found) {
374 0 : $class = 'cfg_found';
375 0 : } else {
376 3 : $class = 'cfg_notfound';
377 : }
378 3 : $alt .= '<dt>USER file </dt>';
379 3 : $alt .= '<dd class="' . $class . '">'
380 3 : . $this->cfg['user_file'][0] .'</dd>';
381 :
382 3 : $found = $this->cfg['system_file'][1];
383 3 : if ($found) {
384 3 : $class = 'cfg_found';
385 3 : } else {
386 1 : $class = 'cfg_notfound';
387 : }
388 :
389 3 : $alt .= '<dt>SYSTEM file </dt>';
390 3 : $alt .= '<dd class="' . $class . '">'
391 3 : . $this->cfg['system_file'][0] .'</dd>';
392 :
393 3 : $alt .= '</dl>';
394 :
395 3 : $this->info = str_replace(array('{value}','{alt}'),
396 3 : array($this->config->getConfFile($layer), $alt),
397 3 : $this->info);
398 3 : }
399 :
400 3 : if (($this->options['resume'] & PEAR_INFO_CREDITS_ALL) ||
401 3 : isset($_GET['credits'])) {
402 2 : $this->info .= $this->getCredits();
403 2 : } else {
404 3 : if ($this->options['resume'] & PEAR_INFO_CREDITS) {
405 3 : $this->info .= '
406 : <h1><a href="{phpself}?credits=true">PEAR Credits</a></h1>
407 : ';
408 3 : $this->info = str_replace('{phpself}',
409 3 : htmlentities($_SERVER['PHP_SELF']),
410 3 : $this->info);
411 3 : }
412 3 : if ($this->options['resume'] & PEAR_INFO_CONFIGURATION) {
413 3 : $this->info .= $this->getConfig();
414 3 : }
415 3 : if ($this->options['resume'] & PEAR_INFO_CHANNELS) {
416 3 : $this->info .= $this->getChannels();
417 3 : }
418 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES) {
419 3 : $this->info .= $this->getPackages();
420 3 : }
421 : }
422 3 : }
423 :
424 : /**
425 : * Sets PEAR HTTP Proxy Server Address
426 : *
427 : * Sets http_proxy config setting at runtime
428 : *
429 : * @param string $proxy PEAR HTTP Proxy Server Address
430 : *
431 : * @static
432 : * @return bool
433 : * @access public
434 : * @since version 1.0.6 (2003-05-11)
435 : */
436 : function setProxy($proxy)
437 : {
438 0 : $res = define('PEAR_INFO_PROXY', $proxy);
439 0 : return $res;
440 : }
441 :
442 : /**
443 : * Returns the custom style sheet to use for presentation
444 : *
445 : * Default behavior is to return css string contents.
446 : * Sets $content parameter to false will return css filename reference
447 : * (defined by setStyleSheet function).
448 : * Easy for a <link rel="stylesheet" type="text/css" href="" />
449 : * html tag integration (see example pear_info3.php).
450 : *
451 : * @param bool $content (optional) Either return css filename or string contents
452 : *
453 : * @return string
454 : * @access public
455 : * @since version 1.7.0RC1 (2007-07-01)
456 : */
457 : function getStyleSheet($content = true)
458 : {
459 1 : if ($content) {
460 1 : $styles = file_get_contents($this->css);
461 1 : } else {
462 0 : $styles = $this->css;
463 : }
464 1 : return $styles;
465 : }
466 :
467 : /**
468 : * Sets the custom style sheet to use your own styles
469 : *
470 : * Sets the custom style sheet (colors, sizes) to applied to PEAR_Info output.
471 : * If you don't give any parameter, you'll then apply again the default style.
472 : *
473 : * @param string $css (optional) File to read user-defined styles from
474 : *
475 : * @return bool True if custom styles, false if default styles applied
476 : * @access public
477 : * @since version 1.7.0RC1 (2007-07-01)
478 : */
479 : function setStyleSheet($css = null)
480 : {
481 : // default stylesheet is into package data directory
482 1 : if (!isset($css)) {
483 1 : $this->css = 'C:\wamp\bin\php\php5.2.8\data' . DIRECTORY_SEPARATOR
484 1 : . 'PEAR_Info' . DIRECTORY_SEPARATOR
485 1 : . 'pearinfo.css';
486 1 : }
487 :
488 1 : $res = isset($css) && file_exists($css);
489 1 : if ($res) {
490 1 : $this->css = $css;
491 1 : }
492 1 : return $res;
493 : }
494 :
495 : /**
496 : * Retrieve and format PEAR Packages info
497 : *
498 : * @return string
499 : * @access private
500 : * @since version 1.0.1 (2003-04-24)
501 : */
502 : function getPackages()
503 : {
504 3 : $available = $this->reg->listAllPackages();
505 3 : if (PEAR::isError($available)) {
506 : $e = '<p class="error">An Error occured while fetching the package list.'
507 0 : . ' Please try again.</p>';
508 0 : return $e;
509 : }
510 3 : if (!is_array($available)) {
511 : $e = '<p class="error">The package list could not be fetched'
512 0 : . ' from the remote server. Please try again.</p>';
513 0 : return $e;
514 : }
515 :
516 : // list of channels to scan
517 3 : $channel_allowed = $this->options['channels'];
518 :
519 : // check if there are new versions available for packages installed
520 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_UPDATE) {
521 :
522 3 : $latest = array();
523 3 : foreach ($channel_allowed as $channel) {
524 : // Get a channel object.
525 3 : $chan =& $this->reg->getChannel($channel);
526 3 : if (PEAR::isError($chan)) {
527 : $e = '<p class="error">An error has occured. '
528 0 : . $chan->getMessage()
529 0 : . ' Please try again.</p>';
530 0 : return $e;
531 : }
532 :
533 3 : if ($chan->supportsREST($channel) &&
534 3 : $base = $chan->getBaseURL('REST1.0', $channel)) {
535 :
536 3 : $rest =& $this->config->getREST('1.0', array());
537 3 : if (is_object($rest)) {
538 3 : $pref_state = $this->config->get('preferred_state');
539 3 : $installed = array_flip($available[$channel]);
540 :
541 3 : $l = $rest->listLatestUpgrades($base, $pref_state,
542 3 : $installed, $channel, $this->reg);
543 3 : } else {
544 0 : $l = false;
545 : }
546 3 : } else {
547 0 : $r =& $this->config->getRemote();
548 0 : $l = @$r->call('package.listLatestReleases');
549 : }
550 3 : if (is_array($l)) {
551 0 : $latest = array_merge($latest, $l);
552 0 : }
553 3 : }
554 3 : } else {
555 1 : $latest = false;
556 : }
557 :
558 3 : if ((PEAR::isError($latest)) || (!is_array($latest))) {
559 1 : $latest = false;
560 1 : }
561 :
562 3 : $s = '';
563 3 : $anchor_suffix = 0; // make page XHTML compliant
564 3 : foreach ($available as $channel => $pkg) {
565 3 : if (!in_array($channel, $channel_allowed)) {
566 3 : continue;
567 : }
568 : // sort package by alphabetic order
569 3 : sort($pkg);
570 : //
571 3 : $packages = '';
572 3 : $index = array();
573 3 : foreach ($pkg as $name) {
574 : // show general package informations
575 3 : $info = &$this->reg->getPackage($name, $channel);
576 3 : if (!is_object($info)) {
577 0 : continue; // should never arrive, if package is really installed
578 : }
579 3 : $__info = $info->getArray();
580 3 : $installed['package'] = $info->getPackage();
581 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_CHANNEL) {
582 3 : $installed['channel'] = $channel;
583 3 : }
584 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_SUMMARY) {
585 3 : $installed['summary'] = $info->getSummary();
586 3 : }
587 3 : $installed['version'] = $info->getVersion();
588 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_VERSION) {
589 3 : $installed['current_release'] = $installed['version']
590 3 : . ' (' . $info->getState() . ') was released on '
591 3 : . $info->getDate();
592 3 : }
593 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_LICENSE) {
594 3 : $installed['license'] = $info->getLicense();
595 3 : }
596 3 : if ($info->getPackagexmlVersion() == '1.0' ) {
597 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_UPDATE) {
598 3 : $installed['lastmodified']
599 3 : = $info->packageInfo('_lastmodified');
600 3 : }
601 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_XML) {
602 3 : $installed['packagexml'] = $info->getPackagexmlVersion();
603 3 : if (isset($__info['packagerversion'])) {
604 3 : $installed['packagerversion']
605 3 : = $__info['packagerversion'];
606 3 : }
607 3 : }
608 3 : } else {
609 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_LICENSE) {
610 3 : $uri = $info->getLicenseLocation();
611 3 : if ($uri) {
612 3 : if (isset($uri['uri'])) {
613 3 : $installed['license'] = '<a href="'
614 3 : . $uri['uri'] . '">'
615 3 : . $info->getLicense() . '</a>';
616 3 : }
617 3 : }
618 3 : }
619 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_UPDATE) {
620 3 : $installed['lastmodified'] = $info->getLastModified();
621 3 : }
622 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_XML) {
623 3 : $installed['packagexml'] = $info->getPackagexmlVersion();
624 3 : $installed['packagerversion']
625 3 : = $__info['attribs']['packagerversion'];
626 3 : }
627 : }
628 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_DESCRIPTION) {
629 3 : $installed['description'] = $info->getDescription();
630 3 : }
631 :
632 : // show dependency list
633 3 : $dependencies = '';
634 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_DEPENDENCIES) {
635 3 : $deps = $info->getDeps();
636 3 : if (is_array($deps)) {
637 : static $_deps_rel_trans = array(
638 : 'lt' => '<',
639 : 'le' => '<=',
640 : 'eq' => '=',
641 : 'ne' => '!=',
642 : 'gt' => '>',
643 : 'ge' => '>=',
644 : 'has' => 'has',
645 : 'not' => 'not'
646 3 : );
647 : static $_deps_type_trans = array(
648 : 'pkg' => 'Package',
649 : 'ext' => 'Extension',
650 : 'php' => 'PHP',
651 : 'prog'=> 'Prog',
652 : 'os' => 'OS',
653 : 'sapi'=> 'SAPI',
654 : 'zend'=> 'Zend'
655 3 : );
656 :
657 : $ptpl = '
658 : <tr class="w">
659 : <td>
660 : {dep_required}
661 : </td>
662 : <td>
663 : {dep_type}
664 : </td>
665 : <td>
666 : {dep_name}
667 : </td>
668 : <td>
669 : {dep_rel}
670 : </td>
671 : <td>
672 : {dep_version}
673 : </td>
674 : </tr>
675 3 : ';
676 3 : foreach ($deps as $dep) {
677 3 : if (!isset($dep['optional'])) {
678 3 : $dep['optional'] = '';
679 3 : }
680 3 : if (isset($dep['name'])) {
681 3 : if (isset($dep['channel'])) {
682 : $dep_name = '<a href="http://'
683 3 : . $dep['channel'] . '/' . $dep['name']
684 3 : . '">' . $dep['name'] . '</a>';
685 3 : } else {
686 3 : $dep_name = $dep['name'];
687 : }
688 3 : } else {
689 3 : $dep_name = '';
690 : }
691 3 : $dependencies .= str_replace(array('{dep_required}',
692 3 : '{dep_type}',
693 3 : '{dep_name}',
694 3 : '{dep_rel}',
695 3 : '{dep_version}',
696 3 : ),
697 3 : array(($dep['optional'] == 'no') ? 'Yes' : 'No',
698 3 : $_deps_type_trans[$dep['type']],
699 3 : $dep_name,
700 3 : $_deps_rel_trans[$dep['rel']],
701 3 : isset($dep['version']) ? $dep['version'] : ''
702 3 : ),
703 3 : $ptpl);
704 3 : }
705 : $ptpl = '
706 : <tr class="w">
707 : <td class="f">
708 : Required
709 : </td>
710 : <td class="f">
711 : Type
712 : </td>
713 : <td class="f">
714 : Name
715 : </td>
716 : <td class="f">
717 : Relation
718 : </td>
719 : <td class="f">
720 : Version
721 : </td>
722 : </tr>
723 3 : ';
724 :
725 3 : $dependencies = $ptpl . $dependencies;
726 3 : }
727 3 : } // end deps-list
728 :
729 3 : if (!isset($old_index)) {
730 3 : $old_index = '';
731 3 : }
732 3 : $current_index = $name{0};
733 3 : if (strtolower($current_index) != strtolower($old_index)) {
734 3 : $packages .= '<a id="' . $current_index . $anchor_suffix
735 3 : . '"></a>';
736 3 : $old_index = $current_index;
737 3 : $index[] = $current_index;
738 3 : }
739 :
740 : // prepare package informations template
741 : $ptpl = '
742 : <h2><a id="pkg_{package_name}"></a><a href="http://{channel}/{package}">{package_name}</a></h2>
743 : <table>
744 3 : ';
745 :
746 3 : $packages .= str_replace(array('{package_name}',
747 3 : '{package}','{channel}'),
748 3 : array(trim($installed['package']), $name, $channel),
749 3 : $ptpl);
750 :
751 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_CHANNEL) {
752 : $ptpl = '
753 : <tr class="v">
754 : <td class="e">
755 : Channel
756 : </td>
757 : <td>
758 : {channel}
759 : </td>
760 : </tr>
761 3 : ';
762 :
763 3 : $packages .= str_replace('{channel}',
764 3 : trim($installed['channel']),
765 3 : $ptpl);
766 3 : }
767 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_SUMMARY) {
768 : $ptpl = '
769 : <tr class="v">
770 : <td class="e">
771 : Summary
772 : </td>
773 : <td>
774 : {summary}
775 : </td>
776 : </tr>
777 3 : ';
778 :
779 3 : $packages .= str_replace('{summary}',
780 3 : nl2br(htmlentities(trim($installed['summary']))),
781 3 : $ptpl);
782 3 : }
783 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_VERSION) {
784 : $ptpl = '
785 : <tr class="v">
786 : <td class="e">
787 : Version
788 : </td>
789 : <td>
790 : {version}
791 : </td>
792 : </tr>
793 3 : ';
794 :
795 3 : $packages .= str_replace('{version}',
796 3 : trim($installed['current_release']),
797 3 : $ptpl);
798 3 : }
799 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_LICENSE) {
800 : $ptpl = '
801 : <tr class="v">
802 : <td class="e">
803 : License
804 : </td>
805 : <td>
806 : {license}
807 : </td>
808 : </tr>
809 3 : ';
810 :
811 3 : $packages .= str_replace('{license}',
812 3 : trim($installed['license']),
813 3 : $ptpl);
814 3 : }
815 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_DESCRIPTION) {
816 : $ptpl = '
817 : <tr class="v">
818 : <td class="e">
819 : Description
820 : </td>
821 : <td>
822 : {description}
823 : </td>
824 : </tr>
825 3 : ';
826 :
827 3 : $packages .= str_replace('{description}',
828 3 : nl2br(htmlentities(trim($installed['description']))),
829 3 : $ptpl);
830 3 : }
831 3 : if (!empty($dependencies)) {
832 : $ptpl = '
833 : <tr class="v">
834 : <td class="e">
835 : Dependencies
836 : </td>
837 : <td>
838 : <table class="d">
839 : {dependencies}
840 : </table>
841 : </td>
842 3 : </tr>';
843 :
844 3 : $packages .= str_replace('{dependencies}',
845 3 : $dependencies,
846 3 : $ptpl);
847 3 : }
848 :
849 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_UPDATE) {
850 3 : if ($latest != false) {
851 0 : if (isset($latest[$installed['package']])) {
852 0 : $latestInstalledPkg = $latest[$installed['package']];
853 0 : if (version_compare($latestInstalledPkg['version'],
854 0 : $installed['version'], '>')) {
855 : $ptpl = '
856 : <tr class="v">
857 : <td class="e">
858 : Latest Version
859 : </td>
860 : <td>
861 : <a href="http://{channel}/get/{package}">{latest_version}</a>({latest_state})
862 : </td>
863 0 : </tr>';
864 :
865 0 : $packages .= str_replace(array('{package}',
866 0 : '{latest_version}',
867 0 : '{latest_state}',
868 : '{channel}'
869 0 : ),
870 0 : array(trim($installed['package']),
871 0 : $latestInstalledPkg['version'],
872 0 : $latestInstalledPkg['state'],
873 : $channel
874 0 : ),
875 0 : $ptpl);
876 0 : }
877 0 : }
878 0 : }
879 :
880 3 : if ($this->options['resume'] & PEAR_INFO_PACKAGES_XML) {
881 : $ptpl = '
882 : <tr class="v">
883 : <td class="e">
884 : Package XML version
885 : </td>
886 : <td>
887 : {packagexml}
888 : </td>
889 3 : </tr>';
890 :
891 3 : $packagexml = $installed['packagexml'];
892 3 : if (isset($installed['packagerversion'])) {
893 : $packagexml .= ' packaged with PEAR version '
894 3 : . $installed['packagerversion'];
895 3 : }
896 3 : $packages .= str_replace('{packagexml}',
897 3 : $packagexml,
898 3 : $ptpl);
899 3 : }
900 : $ptpl = '
901 : <tr class="v">
902 : <td class="e">
903 : Last Modified
904 : </td>
905 : <td>
906 : {lastmodified}
907 : </td>
908 3 : </tr>';
909 :
910 3 : $packages .= str_replace('{lastmodified}',
911 3 : date('Y-m-d', $installed['lastmodified']),
912 3 : $ptpl);
913 :
914 3 : }
915 :
916 : $packages .= '
917 : <tr>
918 : <td colspan="2" class="v"><a href="#{top}">Top</a></td>
919 : </tr>
920 : </table>
921 3 : ';
922 3 : $packages = str_replace('{top}', 'top'.$anchor_suffix, $packages);
923 3 : }
924 :
925 : $index_header = '
926 : <h2><a id="{top}">{count} Installed Packages, Channel {channel}</a></h2>
927 3 : ';
928 :
929 3 : if (count($pkg) > 0) {
930 : // improve render and display index only when there are packages
931 : $index_header .= '
932 : <table>
933 : <tr>
934 : <td class="e">
935 : Index
936 : </td>
937 : </tr>
938 : <tr>
939 : <td class ="v" style="text-align: center">
940 3 : ';
941 3 : }
942 3 : $index_header = str_replace(array('{channel}', '{top}', '{count}'),
943 3 : array($channel, 'top'.$anchor_suffix, count($pkg)), $index_header);
944 3 : foreach ($index as $i) {
945 3 : $index_header .= ' | <a href="#'.$i.$anchor_suffix.'">'
946 3 : . strtoupper($i) . '</a>';
947 3 : }
948 3 : if (count($pkg) > 0) {
949 : // improve render and display index only when there are packages
950 : $index_header .= ' |
951 : </td>
952 : </tr>
953 : </table>
954 :
955 3 : ';
956 3 : }
957 3 : $s .= $index_header . $packages;
958 3 : $anchor_suffix++;
959 3 : }
960 3 : return $s;
961 : }
962 :
963 : /**
964 : * Retrieves and formats the PEAR Config data
965 : *
966 : * @return string
967 : * @access private
968 : * @since version 1.0.1 (2003-04-24)
969 : */
970 : function getConfig()
971 : {
972 3 : $keys = $this->config->getKeys();
973 3 : sort($keys);
974 :
975 : $html_pear_config = '
976 : <h2>PEAR Configuration</h2>
977 3 : <table>';
978 3 : foreach ($keys as $key) {
979 3 : if ( ($key != 'password')
980 3 : && ($key != 'username')
981 3 : && ($key != 'sig_keyid')
982 3 : && ($key != 'http_proxy')) {
983 : $html_config = '
984 : <tr class="v">
985 : <td class="e">{key}</td>
986 : <td>{value}</td>
987 3 : </tr>';
988 :
989 3 : $html_config = str_replace(array('{key}', '{value}'),
990 3 : array($key, $this->config->get($key)),
991 3 : $html_config);
992 :
993 3 : $html_pear_config .= $html_config;
994 3 : }
995 3 : }
996 : $html_pear_config .= '
997 : </table>
998 :
999 3 : ';
1000 3 : return $html_pear_config;
1001 : }
1002 :
1003 : /**
1004 : * Retrieves and formats the PEAR Channel data
1005 : *
1006 : * @return string
1007 : * @access private
1008 : * @since version 1.7.0RC1 (2007-07-01)
1009 : */
1010 : function getChannels()
1011 : {
1012 3 : $channels = $this->reg->listChannels();
1013 3 : if (PEAR::isError($channels)) {
1014 : $e = '<p class="error">An Error occured while fetching the channel list.'
1015 0 : . ' Please try again.</p>';
1016 0 : return $e;
1017 : }
1018 3 : $channel_allowed = $this->options['channels'];
1019 :
1020 : $html_pear_channel = '
1021 3 : <h2>PEAR Channels</h2>';
1022 :
1023 3 : $anchor_suffix = 0;
1024 3 : foreach ($channels as $channel) {
1025 3 : if (!in_array($channel, $channel_allowed)) {
1026 3 : continue;
1027 : }
1028 : $html_pear_channel .= '
1029 3 : <table>';
1030 :
1031 3 : $info = $this->reg->channelInfo($channel);
1032 3 : if (PEAR::isError($info) || is_null($info)) {
1033 : $e = '<p class="error">An Error occured while fetching '
1034 0 : . $channel . ' channel data.'
1035 0 : . ' Please try again.</p>';
1036 0 : return $e;
1037 : }
1038 :
1039 3 : $data = array('name' => $info['name']);
1040 3 : if (isset($info['suggestedalias'])) {
1041 3 : $data['alias'] = $info['suggestedalias'];
1042 3 : }
1043 3 : $data['summary'] = $info['summary'];
1044 :
1045 3 : foreach ($data as $key => $value) {
1046 : $html_channel = '
1047 : <tr class="v">
1048 : <td class="e">{key}</td>
1049 : <td>{value}</td>
1050 3 : </tr>';
1051 3 : if ($key == 'name') {
1052 3 : $value = '<a href="#top' . $anchor_suffix . '">'
1053 3 : . $value . '</a>';
1054 3 : }
1055 3 : $html_channel = str_replace(array('{key}', '{value}'),
1056 3 : array(ucfirst($key), $value),
1057 3 : $html_channel);
1058 :
1059 3 : $html_pear_channel .= $html_channel;
1060 3 : }
1061 : $html_pear_channel .= '
1062 : </table>
1063 : <br />
1064 :
1065 3 : ';
1066 3 : $anchor_suffix++;
1067 3 : }
1068 :
1069 3 : return $html_pear_channel;
1070 : }
1071 :
1072 : /**
1073 : * Retrieves and formats the PEAR Credits
1074 : *
1075 : * @return string
1076 : * @access private
1077 : * @since version 1.0.1 (2003-04-24)
1078 : */
1079 : function getCredits()
1080 : {
1081 2 : $html_pear_credits = '<h1>PEAR Credits</h1>';
1082 :
1083 2 : $teams = PEAR_Info::getMembers();
1084 :
1085 2 : if (($this->options['resume'] & PEAR_INFO_CREDITS_GROUP) ||
1086 2 : isset($_GET['credits'])) {
1087 : $html_pear_credits .= '
1088 : <table>
1089 : <tr class="hc">
1090 : <td colspan="2">
1091 : PEAR Group
1092 : </td>
1093 : </tr>
1094 : <tr class="v">
1095 : <td class="e">
1096 : President
1097 : </td>
1098 : <td>
1099 : {president}
1100 : </td>
1101 : </tr>
1102 : <tr class="v">
1103 : <td colspan="2">
1104 1 : ';
1105 1 : foreach ($teams['president'] as $handle => $name) {
1106 : $html_member
1107 : = '<a href="http://pear.php.net/account-info.php?handle='
1108 1 : . $handle .'">'. $name .'</a>,';
1109 :
1110 1 : $html_pear_credits = str_replace('{president}',
1111 1 : $html_member, $html_pear_credits);
1112 1 : }
1113 :
1114 1 : foreach ($teams['group'] as $handle => $name) {
1115 : $html_member
1116 : = '<a href="http://pear.php.net/account-info.php?handle='
1117 1 : . $handle .'">'. $name .'</a>,';
1118 :
1119 1 : $html_pear_credits .= $html_member;
1120 1 : }
1121 :
1122 : $html_pear_credits .= '
1123 : </td>
1124 : </tr>
1125 : </table>
1126 : <br />
1127 1 : ';
1128 1 : }
1129 :
1130 2 : if (($this->options['resume'] & PEAR_INFO_CREDITS_DOCS) ||
1131 2 : isset($_GET['credits'])) {
1132 1 : if (count($teams['docs']) > 0) {
1133 : $html_pear_credits .= '
1134 : <table>
1135 : <tr class="hc">
1136 : <td>
1137 : PEAR Documentation Team
1138 : </td>
1139 : </tr>
1140 : <tr class="v">
1141 : <td>
1142 0 : ';
1143 0 : foreach ($teams['docs'] as $handle => $name) {
1144 : $html_member
1145 : = '<a href="http://pear.php.net/account-info.php?handle='
1146 0 : . $handle .'">'. $name .'</a>,';
1147 :
1148 0 : $html_pear_credits .= $html_member;
1149 0 : }
1150 :
1151 : $html_pear_credits .= '
1152 : </td>
1153 : </tr>
1154 : </table>
1155 : <br />
1156 0 : ';
1157 0 : }
1158 1 : }
1159 :
1160 2 : if (($this->options['resume'] & PEAR_INFO_CREDITS_WEBSITE) ||
1161 2 : isset($_GET['credits'])) {
1162 1 : if (count($teams['website']) > 0) {
1163 : $html_pear_credits .= '
1164 : <table>
1165 : <tr class="hc">
1166 : <td>
1167 : PEAR Website Team
1168 : </td>
1169 : </tr>
1170 : <tr class="v">
1171 : <td>
1172 0 : ';
1173 0 : foreach ($teams['website'] as $handle => $name) {
1174 : $html_member
1175 : = '<a href="http://pear.php.net/account-info.php?handle='
1176 0 : . $handle .'">'. $name .'</a>,';
1177 :
1178 0 : $html_pear_credits .= $html_member;
1179 0 : }
1180 :
1181 : $html_pear_credits .= '
1182 : </td>
1183 : </tr>
1184 : </table>
1185 : <br />
1186 0 : ';
1187 0 : }
1188 1 : }
1189 :
1190 2 : if (!($this->options['resume'] & PEAR_INFO_CREDITS_PACKAGES) &&
1191 2 : !isset($_GET['credits'])) {
1192 0 : return $html_pear_credits;
1193 : }
1194 :
1195 : // Credits authors of packages group by channels
1196 2 : $channel_allowed = $this->options['channels'];
1197 :
1198 2 : $available = $this->reg->listAllPackages();
1199 2 : if (PEAR::isError($available)) {
1200 : $e = '<p class="error">An Error occured while fetching the credits'
1201 0 : . ' from the remote server. Please try again.</p>';
1202 0 : return $e;
1203 : }
1204 2 : if (!is_array($available)) {
1205 : $e = '<p class="error">The credits could not be fetched'
1206 0 : . ' from the remote server. Please try again.</p>';
1207 0 : return $e;
1208 : }
1209 :
1210 2 : foreach ($available as $channel => $pkg) {
1211 2 : if (!in_array($channel, $channel_allowed)) {
1212 0 : continue;
1213 : }
1214 2 : if (count($pkg) == 0) {
1215 : // improve render and did not display channel without package
1216 2 : continue;
1217 : }
1218 : $html_pear_credits .= '
1219 : <br />
1220 : <table border="0" cellpadding="3" width="600">
1221 : <tr class="hc"><td colspan="2">Channel {channel}</td></tr>
1222 2 : <tr class="h"><td>Package</td><td>Maintainers</td></tr>';
1223 :
1224 2 : $html_pear_credits = str_replace('{channel}', $channel,
1225 2 : $html_pear_credits);
1226 :
1227 : // sort package by alphabetic order
1228 2 : sort($pkg);
1229 : //
1230 2 : foreach ($pkg as $name) {
1231 2 : $info = &$this->reg->getPackage($name, $channel);
1232 2 : if (is_object($info)) {
1233 2 : $installed['package'] = $info->getPackage();
1234 2 : $installed['maintainers'] = $info->getMaintainers();
1235 2 : } else {
1236 0 : $installed = $info;
1237 : }
1238 :
1239 : $ptpl = '
1240 : <tr>
1241 : <td class="e">
1242 : <a href="http://{channel}/{packageURI}">{package}</a>
1243 : </td>
1244 : <td class="v">
1245 : {maintainers}
1246 : </td>
1247 2 : </tr>';
1248 :
1249 2 : $maintainers = array();
1250 2 : foreach ($installed['maintainers'] as $i) {
1251 2 : $maintainers[]
1252 : = '<a href="http://pear.php.net/account-info.php?handle='
1253 2 : . $i['handle']. '">'
1254 2 : . htmlentities(html_entity_decode(utf8_decode($i['name'])))
1255 2 : . '</a>'
1256 2 : .' (' . $i['role']
1257 2 : . (isset($i['active']) && $i['active'] === 'no'
1258 2 : ? ', inactive' : '')
1259 2 : . ')';
1260 2 : }
1261 2 : $maintainers = implode(', ', $maintainers);
1262 :
1263 2 : $html_pear_credits .= str_replace(array('{packageURI}',
1264 2 : '{package}',
1265 2 : '{channel}',
1266 : '{maintainers}'
1267 2 : ),
1268 2 : array(trim(strtolower($installed['package'])),
1269 2 : trim($installed['package']),
1270 2 : $channel,
1271 : $maintainers
1272 2 : ),
1273 2 : $ptpl);
1274 2 : }
1275 : $html_pear_credits .= '
1276 : </table>
1277 2 : ';
1278 2 : }
1279 2 : return $html_pear_credits;
1280 : }
1281 :
1282 : /**
1283 : * Display the PEAR logo
1284 : *
1285 : * Display the PEAR logo (gif image) on browser output
1286 : *
1287 : * @return void
1288 : * @access public
1289 : * @since version 1.0.1 (2003-04-24)
1290 : */
1291 : function pearImage()
1292 : {
1293 : $pear_image
1294 : = 'R0lGODlhaAAyAMT/AMDAwP3+/TWaAvD47Pj89vz++zebBDmcBj6fDEek'
1295 : . 'FluvKmu3PvX68ujz4XvBS8LgrNXqxeHw1ZnPaa/dgvv9+cLqj8LmltD2msnuls'
1296 0 : . '3xmszwmf7+/f///wAAAAAAAAAAACH5BAEAAAAALAAAAABoADIAQAX/IC'
1297 0 : . 'COZGmeaKqubOtWWjwJphLLgH1XUu//C1Jisfj9YLEKQnSY3GaixWQqQTkYHM4'
1298 0 : . 'AMulNLJFC9pEwIW/odKU8cqTfsWoTTtcomU4ZjbR4ZP+AgYKCG0EiZ1A'
1299 0 : . 'uiossEhwEXRMEg5SVWQ6MmZqKWD0QlqCUEHubpaYlExwRPRZioZZVp7KzKQoS'
1300 0 : . 'DxANDLsNXA5simd2FcQYb4YAc2jEU80TmAAIztPCMcjKdg4OEsZJmwIW'
1301 0 : . 'WQPQI4ikIwtoVQnddgrv8PFlCWgYCwkI+fp5dkvJ/IlUKMCy6tYrDhNIIKLFE'
1302 0 : . 'AWCTxse+ABD4SClWA0zovAjcUJFi6EwahxZwoGqHhFA/4IqoICkyxQSK'
1303 0 : . 'kbo0gDkuBXV4FRAJkRCnTgi2P28IcEfk5xpWppykFJVuScmEvDTEETAVJ6bEp'
1304 0 : . 'ypcADPkz3pvKVAICHChkC7siQ08zVqu4Q6hgIFEFZuEn/KMgRUkaBmAQ'
1305 0 : . 's+cEHgIiHVH5EAFpIgW4+NT6LnaqhDwe/Ov7YOmWZp4MkiAWBIl0kAVsJWuzc'
1306 0 : . 'YpdiNgddc0E8cKBAu/FElBwagMb88ZZKDRAkWJtkWhHh3wwUbKHQJN3w'
1307 0 : . 'QAaXGR2LpArv5oFHRR34C7Mf6oLXZNfqBgNI7oOLhj1f8PaGpygHQ0xtP8MDV'
1308 0 : . 'KwYTSKcgxr9/hS6/pCCAAg5M4B9/sWh1YP9/XSgQWRML/idBfKUc4IBE'
1309 0 : . 'T9lFjggKhDYZAELZJYEBI2BDB3ouNBEABwE8gAwiCcSYgAKqPdEVAG7scM8BP'
1310 0 : . 'PZ4AIlM+OgjAgpMhRE24OVoBwsIFEGFA7ZkQQBWienWxmRa7XDjKZXhB'
1311 0 : . 'dAeSmKQwgLuUVLICa6VEKIGcK2mQWoVZHCBXJblJUFkY06yAXlGsPIHBEYdYi'
1312 0 : . 'WHb+WQBgaIJqqoHFNpgMGB7dT5ZQuG/WbBAIAUEEFNfwxAWpokTIXJAW'
1313 0 : . 'dgoJ9kRFG2g5eDRpXSBpEIF0oEQFaZhDbaSFANRgqcJoEDRARLREtxOQpsPO9'
1314 0 : . '06ZUeJgjQB6dZUPBAdwcF8KLXXRVQaKFcsRRLJ6vMiiCNKxRE8ECZKgU'
1315 0 : . 'A3Va4arOAAqdGRWO7uMZH5AL05gvsjQbg6y4NCjQ1kw8TVGcbdoKGKx8j3bGH'
1316 0 : . '7nARBArqwi0gkFJBrZiXBQRbHoIgnhSjcEBKfD7c3HMhz+JIQSY3t8GG'
1317 0 : . 'KW+SUhfUajxGzKd0IoHBNkNQK86ZYEqdzYA8AHQpqXRUm80oHs1CAgMoBxzRq'
1318 0 : . 'vzs9CIKECC1JBp7enUpfXHApwVYNAfo16c4IrYPLVdSAJVob7IAtCBFQ'
1319 0 : . 'GHcs/RRdiUDPHA33oADEAIAOw==';
1320 0 : header('content-type: image/gif');
1321 0 : echo base64_decode($pear_image);
1322 0 : }
1323 :
1324 : /**
1325 : * Returns a members list depending of its category (group, docs, website)
1326 : *
1327 : * Retrieve the members list of PEAR group, PEAR doc team, or PEAR website team
1328 : *
1329 : * @param string $group (optional) Member list category.
1330 : * Either president, group, docs or website
1331 : * @param bool $sort (optional) Return a member list sorted
1332 : * in alphabetic order
1333 : *
1334 : * @static
1335 : * @return array
1336 : * @access public
1337 : * @since version 1.7.0RC3 (2007-07-10)
1338 : */
1339 : function getMembers($group = 'all', $sort = true)
1340 : {
1341 : $members = array(
1342 2 : 'president' => array('davidc' => 'David Coallier'),
1343 : 'group' => array(
1344 2 : 'jeichorn' => 'Joshua Eichorn',
1345 2 : 'dufuz' => 'Helgi þormar',
1346 2 : 'jstump' => 'Joe Stump',
1347 2 : 'cweiske' => 'Christian Weiske',
1348 2 : 'ashnazg' => 'Chuck Burgess',
1349 2 : 'tswicegood' => 'Travis Swicegood',
1350 2 : 'saltybeagle' => 'Brett Bieber',
1351 2 : ),
1352 : 'docs' => array(
1353 2 : ),
1354 : 'website' => array(
1355 2 : )
1356 2 : );
1357 :
1358 2 : if ($group === 'all') {
1359 2 : $list = $members;
1360 2 : if ($sort === true) {
1361 2 : asort($list['group']);
1362 2 : asort($list['docs']);
1363 2 : asort($list['website']);
1364 2 : }
1365 2 : } elseif (in_array($group, array_keys($members))) {
1366 0 : $list = $members[$group];
1367 0 : if ($sort === true) {
1368 0 : asort($list);
1369 0 : }
1370 0 : } else {
1371 0 : $list = false;
1372 : }
1373 2 : return $list;
1374 : }
1375 :
1376 : /**
1377 : * Shows PEAR_Info output
1378 : *
1379 : * Displays PEAR_Info output depending of style applied (style sheet).
1380 : *
1381 : * @return void
1382 : * @access public
1383 : * @since version 1.0.1 (2003-04-24)
1384 : * @see setStyleSheet()
1385 : * @deprecated use display() instead
1386 : */
1387 : function show()
1388 : {
1389 1 : $this->display();
1390 1 : }
1391 :
1392 : /**
1393 : * Displays PEAR_Info output
1394 : *
1395 : * Displays PEAR_Info output depending of style applied (style sheet).
1396 : *
1397 : * @return void
1398 : * @access public
1399 : * @since version 1.7.0RC1 (2007-07-01)
1400 : * @see setStyleSheet()
1401 : */
1402 : function display()
1403 : {
1404 1 : echo $this->toHtml();
1405 1 : }
1406 :
1407 : /**
1408 : * Returns PEAR_Info output (html code)
1409 : *
1410 : * Returns html code. This code is XHTML 1.1 compliant since version 1.7.0
1411 : * A stand-alone HTML page will be printed only if PEAR_INFO_FULLPAGE
1412 : * resume options is set.
1413 : *
1414 : * @return string
1415 : * @access public
1416 : * @since version 1.7.0RC1 (2007-07-01)
1417 : * @see setStyleSheet(), getStyleSheet()
1418 : */
1419 : function toHtml()
1420 : {
1421 1 : $body = $this->info;
1422 :
1423 1 : if (!($this->options['resume'] & PEAR_INFO_FULLPAGE)) {
1424 0 : return $body;
1425 : }
1426 :
1427 1 : if (!isset($this->css)) {
1428 : // when no user-styles defined, used the default values
1429 1 : $this->setStyleSheet();
1430 1 : }
1431 1 : $styles = $this->getStyleSheet();
1432 :
1433 : $html = <<<HTML
1434 1 : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
1435 : "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1436 : <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
1437 : <head>
1438 : <title>PEAR :: PEAR_Info()</title>
1439 : <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
1440 : <style type="text/css">
1441 : <!--
1442 1 : $styles
1443 : -->
1444 : </style>
1445 : </head>
1446 : <body>
1447 : <div>
1448 1 : $body
1449 : </div>
1450 : </body>
1451 1 : </html>
1452 1 : HTML;
1453 1 : return $html;
1454 : }
1455 :
1456 : /**
1457 : * Check if a package is installed
1458 : *
1459 : * Simple function to check if a package is installed under user
1460 : * or system PEAR installation. Minimal version and channel info are supported.
1461 : *
1462 : * @param string $name Package name
1463 : * @param string $version (optional) The minimal version
1464 : * that should be installed
1465 : * @param string $channel (optional) The package channel distribution
1466 : * @param string $user_file (optional) file to read PEAR user-defined
1467 : * options from
1468 : * @param string $system_file (optional) file to read PEAR system-wide
1469 : * defaults from
1470 : *
1471 : * @static
1472 : * @return bool
1473 : * @access public
1474 : * @since version 1.6.0 (2005-01-03)
1475 : */
1476 : function packageInstalled($name, $version = null, $channel = null,
1477 : $user_file = '', $system_file = '')
1478 : {
1479 1 : $config =& PEAR_Config::singleton($user_file, $system_file);
1480 1 : $reg =& $config->getRegistry();
1481 :
1482 1 : if (is_null($version)) {
1483 1 : return $reg->packageExists($name, $channel);
1484 : } else {
1485 1 : $info = &$reg->getPackage($name, $channel);
1486 1 : if (is_object($info)) {
1487 1 : $installed['version'] = $info->getVersion();
1488 1 : } else {
1489 0 : $installed = $info;
1490 : }
1491 1 : return version_compare($version, $installed['version'], '<=');
1492 : }
1493 : }
1494 : }
1495 :
1496 4 : if (isset($_GET['pear_image'])) {
1497 0 : PEAR_Info::pearImage();
1498 0 : exit();
1499 : }
|