Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 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
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
define('PEAR_INFO_GENERAL', 1);
55
/**
56
 * PEAR Credits
57
 *
58
 * @var        integer
59
 * @since      1.7.0RC1
60
 */
61
define('PEAR_INFO_CREDITS', 2);
62
/**
63
 * All PEAR settings.
64
 *
65
 * @var        integer
66
 * @since      1.7.0RC1
67
 */
68
define('PEAR_INFO_CONFIGURATION', 4);
69
/**
70
 * Information on PEAR channels.
71
 *
72
 * @var        integer
73
 * @since      1.7.0RC1
74
 */
75
define('PEAR_INFO_CHANNELS', 8);
76
/**#@+
77
 * Information on PEAR packages.
78
 *
79
 * @var        integer
80
 * @since      1.7.0RC1
81
 */
82
define('PEAR_INFO_PACKAGES', 4080);
83
define('PEAR_INFO_PACKAGES_CHANNEL', 2048);
84
define('PEAR_INFO_PACKAGES_SUMMARY', 1024);
85
define('PEAR_INFO_PACKAGES_VERSION', 512);
86
define('PEAR_INFO_PACKAGES_LICENSE', 256);
87
define('PEAR_INFO_PACKAGES_DESCRIPTION', 128);
88
define('PEAR_INFO_PACKAGES_DEPENDENCIES', 64);
89
define('PEAR_INFO_PACKAGES_XML', 32);
90
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
define('PEAR_INFO_ALL', 4095);
99
/**#@+
100
 * Information on PEAR credits.
101
 *
102
 * @var        integer
103
 * @since      1.7.0RC3
104
 */
105
define('PEAR_INFO_CREDITS_GROUP', 4096);
106
define('PEAR_INFO_CREDITS_DOCS', 8192);
107
define('PEAR_INFO_CREDITS_WEBSITE', 16384);
108
define('PEAR_INFO_CREDITS_PACKAGES', 32768);
109
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
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: 1.9.2
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
{
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
        $this->__construct($pear_dir, $user_file, $system_file, $options);
198
    }
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
        $this->options = array('channels' => array('pear.php.net'),
219
            'resume' => PEAR_INFO_ALL | PEAR_INFO_FULLPAGE);
220
        if (isset($options)) {
221
            // overwrite one to all defaults
222
            $this->options = array_merge($this->options, $options);
223
        }
224
 
225
        // to keep compatibility with version less or equal than 1.6.1
226
        if (!empty($pear_dir) && empty($user_file) && empty($system_file)) {
227
            $p_available           = (is_dir($pear_dir));
228
            $this->cfg['pear_dir'] = array($pear_dir, $p_available);
229
 
230
            if (!$p_available) {
231
                $e = '<p class="error">No valid PEAR directory</p>';
232
 
233
                $this->info = $e;
234
                return;
235
            }
236
 
237
            // try to find a PEAR user-defined config file into $pear_dir
238
            $user_file = $pear_dir . DIRECTORY_SEPARATOR;
239
            if (OS_WINDOWS) {
240
                $user_file .= 'pear.ini';
241
            } else {
242
                $user_file .= '.pearrc';
243
            }
244
            $u_available            = file_exists($user_file);
245
            $this->cfg['user_file'] = array($user_file, $u_available);
246
 
247
            // try to find a PEAR system-wide config file into $pear_dir
248
            $system_file = $pear_dir . DIRECTORY_SEPARATOR;
249
            if (OS_WINDOWS) {
250
                $system_file .= 'pearsys.ini';
251
            } else {
252
                $system_file .= 'pear.conf';
253
            }
254
            $s_available              = file_exists($system_file);
255
            $this->cfg['system_file'] = array($system_file, $s_available);
256
 
257
            if ($u_available) {
258
                if (!$s_available) {
259
                    $system_file = '';
260
                }
261
            } else {
262
                if (!$s_available) {
263
                    $e = '<p class="error">No PEAR configuration files ('
264
                        . basename($user_file) . ' or ' . basename($system_file)
265
                        . ") found into '$pear_dir' directory</p>";
266
 
267
                    $this->info = $e;
268
                    return;
269
                }
270
                $user_file = '';
271
            }
272
        }
273
 
274
        $this->config =& PEAR_Config::singleton($user_file, $system_file);
275
 
276
        // look for default PEAR installation
277
        if (empty($pear_dir)) {
278
            $php_dir               = $this->config->get('php_dir');
279
            $p_available           = (is_dir($php_dir));
280
            $this->cfg['pear_dir'] = array($php_dir, $p_available);
281
 
282
            $pear_user_file         = $this->config->getConfFile('user');
283
            $u_available            = file_exists($pear_user_file);
284
            $this->cfg['user_file'] = array($pear_user_file, $u_available);
285
 
286
            $pear_system_file         = $this->config->getConfFile('system');
287
            $s_available              = file_exists($pear_system_file);
288
            $this->cfg['system_file'] = array($pear_system_file, $s_available);
289
        }
290
 
291
        // to keep compatibility with version less or equal than 1.6.1
292
        if (defined('PEAR_INFO_PROXY')) {
293
            $this->config->set('http_proxy', PEAR_INFO_PROXY);
294
        }
295
 
296
        if (empty($user_file) || !file_exists($user_file)) {
297
            if (empty($system_file) || !file_exists($system_file)) {
298
                $user_file = $this->config->getConfFile('user');
299
                if (file_exists($user_file)) {
300
                    $layer = 'user';
301
                } else {
302
                    $system_file = $this->config->getConfFile('system');
303
                    $layer       = 'system';
304
                }
305
            } else {
306
                $layer = 'system';
307
            }
308
        } else {
309
            $layer = 'user';
310
        }
311
        // prevent unexpected result if PEAR config file does not exist
312
        if (!file_exists($user_file) && !file_exists($system_file)) {
313
            $e = '<p class="error">PEAR configuration files "'
314
                . $user_file . '", "' . $system_file . '" does not exist</p>';
315
 
316
            $this->info = $e;
317
            return;
318
        }
319
        // Get the config's registry object.
320
        $this->reg = &$this->config->getRegistry();
321
 
322
        // Get list of all channels in your PEAR install,
323
        // when 'channels' option is empty
324
        if (isset($this->options['channels'])
325
            && empty($this->options['channels'])) {
326
            $channels = $this->reg->listChannels();
327
            if (PEAR::isError($channels)) {
328
                $this->options['channels'] = array('pear.php.net');
329
            } else {
330
                $this->options['channels'] = $channels;
331
            }
332
        }
333
 
334
        // show general informations such as PEAR version, PEAR logo,
335
        // and config file used
336
        if ($this->options['resume'] & PEAR_INFO_GENERAL) {
337
            $pear         = $this->reg->getPackage("PEAR");
338
            $pear_version = $pear->getVersion();
339
            $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
            $this->info   = str_replace(array('{phpself}', '{pearversion}'),
352
                array(htmlentities($_SERVER['PHP_SELF']), $pear_version),
353
                $this->info);
354
 
355
            // Loaded configuration file
356
            $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
            $alt = '<dl>';
371
 
372
            $found = $this->cfg['user_file'][1];
373
            if ($found) {
374
                $class = 'cfg_found';
375
            } else {
376
                $class = 'cfg_notfound';
377
            }
378
            $alt .= '<dt>USER file </dt>';
379
            $alt .= '<dd class="' . $class . '">'
380
                 . $this->cfg['user_file'][0] .'</dd>';
381
 
382
            $found = $this->cfg['system_file'][1];
383
            if ($found) {
384
                $class = 'cfg_found';
385
            } else {
386
                $class = 'cfg_notfound';
387
            }
388
 
389
            $alt .= '<dt>SYSTEM file </dt>';
390
            $alt .= '<dd class="' . $class . '">'
391
                 . $this->cfg['system_file'][0] .'</dd>';
392
 
393
            $alt .= '</dl>';
394
 
395
            $this->info = str_replace(array('{value}','{alt}'),
396
                array($this->config->getConfFile($layer), $alt),
397
                $this->info);
398
        }
399
 
400
        if (($this->options['resume'] & PEAR_INFO_CREDITS_ALL) ||
401
            isset($_GET['credits'])) {
402
            $this->info .= $this->getCredits();
403
        } else {
404
            if ($this->options['resume'] & PEAR_INFO_CREDITS) {
405
                $this->info .= '
406
<h1><a href="{phpself}?credits=true">PEAR Credits</a></h1>
407
';
408
                $this->info  = str_replace('{phpself}',
409
                    htmlentities($_SERVER['PHP_SELF']),
410
                    $this->info);
411
            }
412
            if ($this->options['resume'] & PEAR_INFO_CONFIGURATION) {
413
                $this->info .= $this->getConfig();
414
            }
415
            if ($this->options['resume'] & PEAR_INFO_CHANNELS) {
416
                $this->info .= $this->getChannels();
417
            }
418
            if ($this->options['resume'] & PEAR_INFO_PACKAGES) {
419
                $this->info .= $this->getPackages();
420
            }
421
        }
422
    }
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
        $res = define('PEAR_INFO_PROXY', $proxy);
439
        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
        if ($content) {
460
            $styles = file_get_contents($this->css);
461
        } else {
462
            $styles = $this->css;
463
        }
464
        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
        if (!isset($css)) {
483
            $this->css = '/var/www/pear' . DIRECTORY_SEPARATOR
484
                 . 'PEAR_Info' . DIRECTORY_SEPARATOR
485
                 . 'pearinfo.css';
486
        }
487
 
488
        $res = isset($css) && file_exists($css);
489
        if ($res) {
490
            $this->css = $css;
491
        }
492
        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
        $available = $this->reg->listAllPackages();
505
        if (PEAR::isError($available)) {
506
            $e = '<p class="error">An Error occured while fetching the package list.'
507
               . ' Please try again.</p>';
508
            return $e;
509
        }
510
        if (!is_array($available)) {
511
            $e = '<p class="error">The package list could not be fetched'
512
               . ' from the remote server. Please try again.</p>';
513
            return $e;
514
        }
515
 
516
        // list of channels to scan
517
        $channel_allowed = $this->options['channels'];
518
 
519
        // check if there are new versions available for packages installed
520
        if ($this->options['resume'] & PEAR_INFO_PACKAGES_UPDATE) {
521
 
522
            $latest = array();
523
            foreach ($channel_allowed as $channel) {
524
                // Get a channel object.
525
                $chan =& $this->reg->getChannel($channel);
526
                if (PEAR::isError($chan)) {
527
                    $e = '<p class="error">An error has occured. '
528
                       . $chan->getMessage()
529
                       . ' Please try again.</p>';
530
                    return $e;
531
                }
532
 
533
                if ($chan->supportsREST($channel) &&
534
                    $base = $chan->getBaseURL('REST1.0', $channel)) {
535
 
536
                    $rest =& $this->config->getREST('1.0', array());
537
                    if (is_object($rest)) {
538
                        $pref_state = $this->config->get('preferred_state');
539
                        $installed  = array_flip($available[$channel]);
540
 
541
                        $l = $rest->listLatestUpgrades($base, $pref_state,
542
                                 $installed, $channel, $this->reg);
543
                    } else {
544
                        $l = false;
545
                    }
546
                } else {
547
                    $r =& $this->config->getRemote();
548
                    $l = @$r->call('package.listLatestReleases');
549
                }
550
                if (is_array($l)) {
551
                    $latest = array_merge($latest, $l);
552
                }
553
            }
554
        } else {
555
            $latest = false;
556
        }
557
 
558
        if ((PEAR::isError($latest)) || (!is_array($latest))) {
559
            $latest = false;
560
        }
561
 
562
        $s             = '';
563
        $anchor_suffix = 0;  // make page XHTML compliant
564
        foreach ($available as $channel => $pkg) {
565
            if (!in_array($channel, $channel_allowed)) {
566
                continue;
567
            }
568
            // sort package by alphabetic order
569
            sort($pkg);
570
            //
571
            $packages = '';
572
            $index    = array();
573
            foreach ($pkg as $name) {
574
                // show general package informations
575
                $info = &$this->reg->getPackage($name, $channel);
576
                if (!is_object($info)) {
577
                    continue; // should never arrive, if package is really installed
578
                }
579
                $__info               = $info->getArray();
580
                $installed['package'] = $info->getPackage();
581
                if ($this->options['resume'] & PEAR_INFO_PACKAGES_CHANNEL) {
582
                    $installed['channel'] = $channel;
583
                }
584
                if ($this->options['resume'] & PEAR_INFO_PACKAGES_SUMMARY) {
585
                    $installed['summary'] = $info->getSummary();
586
                }
587
                $installed['version'] = $info->getVersion();
588
                if ($this->options['resume'] & PEAR_INFO_PACKAGES_VERSION) {
589
                    $installed['current_release'] = $installed['version']
590
                        . ' (' . $info->getState() . ') was released on '
591
                        . $info->getDate();
592
                }
593
                if ($this->options['resume'] & PEAR_INFO_PACKAGES_LICENSE) {
594
                    $installed['license'] = $info->getLicense();
595
                }
596
                if ($info->getPackagexmlVersion() == '1.0' ) {
597
                    if ($this->options['resume'] & PEAR_INFO_PACKAGES_UPDATE) {
598
                        $installed['lastmodified']
599
                            = $info->packageInfo('_lastmodified');
600
                    }
601
                    if ($this->options['resume'] & PEAR_INFO_PACKAGES_XML) {
602
                        $installed['packagexml'] = $info->getPackagexmlVersion();
603
                        if (isset($__info['packagerversion'])) {
604
                            $installed['packagerversion']
605
                                = $__info['packagerversion'];
606
                        }
607
                    }
608
                } else {
609
                    if ($this->options['resume'] & PEAR_INFO_PACKAGES_LICENSE) {
610
                        $uri = $info->getLicenseLocation();
611
                        if ($uri) {
612
                            if (isset($uri['uri'])) {
613
                                $installed['license'] = '<a href="'
614
                                    . $uri['uri'] . '">'
615
                                    . $info->getLicense() . '</a>';
616
                            }
617
                        }
618
                    }
619
                    if ($this->options['resume'] & PEAR_INFO_PACKAGES_UPDATE) {
620
                        $installed['lastmodified'] = $info->getLastModified();
621
                    }
622
                    if ($this->options['resume'] & PEAR_INFO_PACKAGES_XML) {
623
                        $installed['packagexml'] = $info->getPackagexmlVersion();
624
                        $installed['packagerversion']
625
                            = $__info['attribs']['packagerversion'];
626
                    }
627
                }
628
                if ($this->options['resume'] & PEAR_INFO_PACKAGES_DESCRIPTION) {
629
                    $installed['description'] = $info->getDescription();
630
                }
631
 
632
                // show dependency list
633
                $dependencies = '';
634
                if ($this->options['resume'] & PEAR_INFO_PACKAGES_DEPENDENCIES) {
635
                    $deps = $info->getDeps();
636
                    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
                                     );
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
                                     );
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
';
676
                        foreach ($deps as $dep) {
677
                            if (!isset($dep['optional'])) {
678
                                $dep['optional'] = '';
679
                            }
680
                            if (isset($dep['name'])) {
681
                                if (isset($dep['channel'])) {
682
                                    $dep_name = '<a href="http://'
683
                                              . $dep['channel'] . '/' . $dep['name']
684
                                              . '">' . $dep['name'] . '</a>';
685
                                } else {
686
                                    $dep_name = $dep['name'];
687
                                }
688
                            } else {
689
                                $dep_name = '';
690
                            }
691
                            $dependencies .= str_replace(array('{dep_required}',
692
                                    '{dep_type}',
693
                                    '{dep_name}',
694
                                    '{dep_rel}',
695
                                    '{dep_version}',
696
                                    ),
697
                                array(($dep['optional'] == 'no') ? 'Yes' : 'No',
698
                                    $_deps_type_trans[$dep['type']],
699
                                    $dep_name,
700
                                    $_deps_rel_trans[$dep['rel']],
701
                                    isset($dep['version']) ? $dep['version'] : ''
702
                                    ),
703
                                $ptpl);
704
                        }
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
';
724
 
725
                        $dependencies = $ptpl . $dependencies;
726
                    }
727
                } // end deps-list
728
 
729
                if (!isset($old_index)) {
730
                    $old_index = '';
731
                }
732
                $current_index = $name{0};
733
                if (strtolower($current_index) != strtolower($old_index)) {
734
                    $packages .= '<a id="' . $current_index . $anchor_suffix
735
                              . '"></a>';
736
                    $old_index = $current_index;
737
                    $index[]   = $current_index;
738
                }
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
';
745
 
746
                $packages .= str_replace(array('{package_name}',
747
                                               '{package}','{channel}'),
748
                    array(trim($installed['package']), $name, $channel),
749
                    $ptpl);
750
 
751
                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
';
762
 
763
                    $packages .= str_replace('{channel}',
764
                        trim($installed['channel']),
765
                        $ptpl);
766
                }
767
                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
';
778
 
779
                    $packages .= str_replace('{summary}',
780
                        nl2br(htmlentities(trim($installed['summary']))),
781
                        $ptpl);
782
                }
783
                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
';
794
 
795
                    $packages .= str_replace('{version}',
796
                        trim($installed['current_release']),
797
                        $ptpl);
798
                }
799
                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
';
810
 
811
                    $packages .= str_replace('{license}',
812
                        trim($installed['license']),
813
                        $ptpl);
814
                }
815
                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
';
826
 
827
                    $packages .= str_replace('{description}',
828
                        nl2br(htmlentities(trim($installed['description']))),
829
                        $ptpl);
830
                }
831
                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
</tr>';
843
 
844
                    $packages .= str_replace('{dependencies}',
845
                        $dependencies,
846
                        $ptpl);
847
                }
848
 
849
                if ($this->options['resume'] & PEAR_INFO_PACKAGES_UPDATE) {
850
                    if ($latest != false) {
851
                        if (isset($latest[$installed['package']])) {
852
                            $latestInstalledPkg = $latest[$installed['package']];
853
                            if (version_compare($latestInstalledPkg['version'],
854
                                $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
</tr>';
864
 
865
                                $packages .= str_replace(array('{package}',
866
                                        '{latest_version}',
867
                                        '{latest_state}',
868
                                        '{channel}'
869
                                        ),
870
                                    array(trim($installed['package']),
871
                                        $latestInstalledPkg['version'],
872
                                        $latestInstalledPkg['state'],
873
                                        $channel
874
                                        ),
875
                                    $ptpl);
876
                            }
877
                        }
878
                    }
879
 
880
                    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
</tr>';
890
 
891
                        $packagexml = $installed['packagexml'];
892
                        if (isset($installed['packagerversion'])) {
893
                            $packagexml .= ' packaged with PEAR version '
894
                                . $installed['packagerversion'];
895
                        }
896
                        $packages .= str_replace('{packagexml}',
897
                            $packagexml,
898
                            $ptpl);
899
                    }
900
                    $ptpl = '
901
<tr class="v">
902
    <td class="e">
903
        Last Modified
904
    </td>
905
    <td>
906
        {lastmodified}
907
    </td>
908
</tr>';
909
 
910
                    $packages .= str_replace('{lastmodified}',
911
                        date('Y-m-d', $installed['lastmodified']),
912
                        $ptpl);
913
 
914
                }
915
 
916
                $packages .= '
917
<tr>
918
    <td colspan="2" class="v"><a href="#{top}">Top</a></td>
919
</tr>
920
</table>
921
';
922
                $packages  = str_replace('{top}', 'top'.$anchor_suffix, $packages);
923
            }
924
 
925
            $index_header = '
926
<h2><a id="{top}">{count} Installed Packages, Channel {channel}</a></h2>
927
';
928
 
929
            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
';
941
            }
942
            $index_header = str_replace(array('{channel}', '{top}', '{count}'),
943
                array($channel, 'top'.$anchor_suffix, count($pkg)), $index_header);
944
            foreach ($index as $i) {
945
                $index_header .= ' | <a href="#'.$i.$anchor_suffix.'">'
946
                              . strtoupper($i) . '</a>';
947
            }
948
            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
';
956
            }
957
            $s .= $index_header . $packages;
958
            $anchor_suffix++;
959
        }
960
        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
        $keys = $this->config->getKeys();
973
        sort($keys);
974
 
975
        $html_pear_config = '
976
<h2>PEAR Configuration</h2>
977
<table>';
978
        foreach ($keys as $key) {
979
            if (   ($key != 'password')
980
                && ($key != 'username')
981
                && ($key != 'sig_keyid')
982
                && ($key != 'http_proxy')) {
983
                $html_config = '
984
<tr class="v">
985
    <td class="e">{key}</td>
986
    <td>{value}</td>
987
</tr>';
988
 
989
                $html_config = str_replace(array('{key}', '{value}'),
990
                    array($key, $this->config->get($key)),
991
                    $html_config);
992
 
993
                $html_pear_config .= $html_config;
994
            }
995
        }
996
        $html_pear_config .= '
997
</table>
998
 
999
';
1000
        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
        $channels = $this->reg->listChannels();
1013
        if (PEAR::isError($channels)) {
1014
            $e = '<p class="error">An Error occured while fetching the channel list.'
1015
               . ' Please try again.</p>';
1016
            return $e;
1017
        }
1018
        $channel_allowed = $this->options['channels'];
1019
 
1020
        $html_pear_channel = '
1021
<h2>PEAR Channels</h2>';
1022
 
1023
        $anchor_suffix = 0;
1024
        foreach ($channels as $channel) {
1025
            if (!in_array($channel, $channel_allowed)) {
1026
                continue;
1027
            }
1028
            $html_pear_channel .= '
1029
<table>';
1030
 
1031
            $info = $this->reg->channelInfo($channel);
1032
            if (PEAR::isError($info) || is_null($info)) {
1033
                $e = '<p class="error">An Error occured while fetching '
1034
                   . $channel . ' channel data.'
1035
                   . ' Please try again.</p>';
1036
                return $e;
1037
            }
1038
 
1039
            $data = array('name' => $info['name']);
1040
            if (isset($info['suggestedalias'])) {
1041
                $data['alias'] = $info['suggestedalias'];
1042
            }
1043
            $data['summary'] = $info['summary'];
1044
 
1045
            foreach ($data as $key => $value) {
1046
                $html_channel = '
1047
<tr class="v">
1048
    <td class="e">{key}</td>
1049
    <td>{value}</td>
1050
</tr>';
1051
                if ($key == 'name') {
1052
                    $value = '<a href="#top' . $anchor_suffix . '">'
1053
                        . $value . '</a>';
1054
                }
1055
                $html_channel = str_replace(array('{key}', '{value}'),
1056
                    array(ucfirst($key), $value),
1057
                    $html_channel);
1058
 
1059
                $html_pear_channel .= $html_channel;
1060
            }
1061
            $html_pear_channel .= '
1062
</table>
1063
<br />
1064
 
1065
';
1066
            $anchor_suffix++;
1067
        }
1068
 
1069
        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
        $html_pear_credits = '<h1>PEAR Credits</h1>';
1082
 
1083
        $teams = PEAR_Info::getMembers();
1084
 
1085
        if (($this->options['resume'] & PEAR_INFO_CREDITS_GROUP) ||
1086
            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
';
1105
            foreach ($teams['president'] as $handle => $name) {
1106
                $html_member
1107
                    = '<a href="http://pear.php.net/account-info.php?handle='
1108
                    . $handle .'">'. $name .'</a>,';
1109
 
1110
                $html_pear_credits = str_replace('{president}',
1111
                    $html_member, $html_pear_credits);
1112
            }
1113
 
1114
            foreach ($teams['group'] as $handle => $name) {
1115
                $html_member
1116
                    = '<a href="http://pear.php.net/account-info.php?handle='
1117
                    . $handle .'">'. $name .'</a>,';
1118
 
1119
                $html_pear_credits .= $html_member;
1120
            }
1121
 
1122
            $html_pear_credits .= '
1123
        </td>
1124
    </tr>
1125
</table>
1126
<br />
1127
';
1128
        }
1129
 
1130
        if (($this->options['resume'] & PEAR_INFO_CREDITS_DOCS) ||
1131
            isset($_GET['credits'])) {
1132
            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
';
1143
                foreach ($teams['docs'] as $handle => $name) {
1144
                    $html_member
1145
                        = '<a href="http://pear.php.net/account-info.php?handle='
1146
                        . $handle .'">'. $name .'</a>,';
1147
 
1148
                    $html_pear_credits .= $html_member;
1149
                }
1150
 
1151
                $html_pear_credits .= '
1152
        </td>
1153
    </tr>
1154
</table>
1155
<br />
1156
';
1157
            }
1158
        }
1159
 
1160
        if (($this->options['resume'] & PEAR_INFO_CREDITS_WEBSITE) ||
1161
            isset($_GET['credits'])) {
1162
            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
';
1173
                foreach ($teams['website'] as $handle => $name) {
1174
                    $html_member
1175
                        = '<a href="http://pear.php.net/account-info.php?handle='
1176
                        . $handle .'">'. $name .'</a>,';
1177
 
1178
                    $html_pear_credits .= $html_member;
1179
                }
1180
 
1181
                $html_pear_credits .= '
1182
        </td>
1183
    </tr>
1184
</table>
1185
<br />
1186
';
1187
            }
1188
        }
1189
 
1190
        if (!($this->options['resume'] & PEAR_INFO_CREDITS_PACKAGES) &&
1191
            !isset($_GET['credits'])) {
1192
            return $html_pear_credits;
1193
        }
1194
 
1195
        // Credits authors of packages group by channels
1196
        $channel_allowed = $this->options['channels'];
1197
 
1198
        $available = $this->reg->listAllPackages();
1199
        if (PEAR::isError($available)) {
1200
            $e = '<p class="error">An Error occured while fetching the credits'
1201
               . ' from the remote server. Please try again.</p>';
1202
            return $e;
1203
        }
1204
        if (!is_array($available)) {
1205
            $e = '<p class="error">The credits could not be fetched'
1206
               . ' from the remote server. Please try again.</p>';
1207
            return $e;
1208
        }
1209
 
1210
        foreach ($available as $channel => $pkg) {
1211
            if (!in_array($channel, $channel_allowed)) {
1212
                continue;
1213
            }
1214
            if (count($pkg) == 0) {
1215
                // improve render and did not display channel without package
1216
                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
<tr class="h"><td>Package</td><td>Maintainers</td></tr>';
1223
 
1224
            $html_pear_credits = str_replace('{channel}', $channel,
1225
                                     $html_pear_credits);
1226
 
1227
            // sort package by alphabetic order
1228
            sort($pkg);
1229
            //
1230
            foreach ($pkg as $name) {
1231
                $info = &$this->reg->getPackage($name, $channel);
1232
                if (is_object($info)) {
1233
                    $installed['package']     = $info->getPackage();
1234
                    $installed['maintainers'] = $info->getMaintainers();
1235
                } else {
1236
                    $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
</tr>';
1248
 
1249
                $maintainers = array();
1250
                foreach ($installed['maintainers'] as $i) {
1251
                    $maintainers[]
1252
                        = '<a href="http://pear.php.net/account-info.php?handle='
1253
                        . $i['handle']. '">'
1254
                        . htmlentities(html_entity_decode(utf8_decode($i['name'])))
1255
                        . '</a>'
1256
                        .' (' . $i['role']
1257
                        . (isset($i['active']) && $i['active'] === 'no'
1258
                            ? ', inactive' : '')
1259
                        . ')';
1260
                }
1261
                $maintainers = implode(', ', $maintainers);
1262
 
1263
                $html_pear_credits .= str_replace(array('{packageURI}',
1264
                        '{package}',
1265
                        '{channel}',
1266
                        '{maintainers}'
1267
                        ),
1268
                    array(trim(strtolower($installed['package'])),
1269
                        trim($installed['package']),
1270
                        $channel,
1271
                        $maintainers
1272
                        ),
1273
                    $ptpl);
1274
            }
1275
            $html_pear_credits .= '
1276
</table>
1277
';
1278
        }
1279
        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
            . '3xmszwmf7+/f///wAAAAAAAAAAACH5BAEAAAAALAAAAABoADIAQAX/IC'
1297
            . 'COZGmeaKqubOtWWjwJphLLgH1XUu//C1Jisfj9YLEKQnSY3GaixWQqQTkYHM4'
1298
            . 'AMulNLJFC9pEwIW/odKU8cqTfsWoTTtcomU4ZjbR4ZP+AgYKCG0EiZ1A'
1299
            . 'uiossEhwEXRMEg5SVWQ6MmZqKWD0QlqCUEHubpaYlExwRPRZioZZVp7KzKQoS'
1300
            . 'DxANDLsNXA5simd2FcQYb4YAc2jEU80TmAAIztPCMcjKdg4OEsZJmwIW'
1301
            . 'WQPQI4ikIwtoVQnddgrv8PFlCWgYCwkI+fp5dkvJ/IlUKMCy6tYrDhNIIKLFE'
1302
            . 'AWCTxse+ABD4SClWA0zovAjcUJFi6EwahxZwoGqHhFA/4IqoICkyxQSK'
1303
            . 'kbo0gDkuBXV4FRAJkRCnTgi2P28IcEfk5xpWppykFJVuScmEvDTEETAVJ6bEp'
1304
            . 'ypcADPkz3pvKVAICHChkC7siQ08zVqu4Q6hgIFEFZuEn/KMgRUkaBmAQ'
1305
            . 's+cEHgIiHVH5EAFpIgW4+NT6LnaqhDwe/Ov7YOmWZp4MkiAWBIl0kAVsJWuzc'
1306
            . 'YpdiNgddc0E8cKBAu/FElBwagMb88ZZKDRAkWJtkWhHh3wwUbKHQJN3w'
1307
            . 'QAaXGR2LpArv5oFHRR34C7Mf6oLXZNfqBgNI7oOLhj1f8PaGpygHQ0xtP8MDV'
1308
            . 'KwYTSKcgxr9/hS6/pCCAAg5M4B9/sWh1YP9/XSgQWRML/idBfKUc4IBE'
1309
            . 'T9lFjggKhDYZAELZJYEBI2BDB3ouNBEABwE8gAwiCcSYgAKqPdEVAG7scM8BP'
1310
            . 'PZ4AIlM+OgjAgpMhRE24OVoBwsIFEGFA7ZkQQBWienWxmRa7XDjKZXhB'
1311
            . 'dAeSmKQwgLuUVLICa6VEKIGcK2mQWoVZHCBXJblJUFkY06yAXlGsPIHBEYdYi'
1312
            . 'WHb+WQBgaIJqqoHFNpgMGB7dT5ZQuG/WbBAIAUEEFNfwxAWpokTIXJAW'
1313
            . 'dgoJ9kRFG2g5eDRpXSBpEIF0oEQFaZhDbaSFANRgqcJoEDRARLREtxOQpsPO9'
1314
            . '06ZUeJgjQB6dZUPBAdwcF8KLXXRVQaKFcsRRLJ6vMiiCNKxRE8ECZKgU'
1315
            . 'A3Va4arOAAqdGRWO7uMZH5AL05gvsjQbg6y4NCjQ1kw8TVGcbdoKGKx8j3bGH'
1316
            . '7nARBArqwi0gkFJBrZiXBQRbHoIgnhSjcEBKfD7c3HMhz+JIQSY3t8GG'
1317
            . 'KW+SUhfUajxGzKd0IoHBNkNQK86ZYEqdzYA8AHQpqXRUm80oHs1CAgMoBxzRq'
1318
            . 'vzs9CIKECC1JBp7enUpfXHApwVYNAfo16c4IrYPLVdSAJVob7IAtCBFQ'
1319
            . 'GHcs/RRdiUDPHA33oADEAIAOw==';
1320
        header('content-type: image/gif');
1321
        echo base64_decode($pear_image);
1322
    }
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
            'president' => array('davidc' => 'David Coallier'),
1343
            'group'     => array(
1344
                'jeichorn' => 'Joshua Eichorn',
1345
                'dufuz' => 'Helgi &thorn;ormar',
1346
                'jstump' => 'Joe Stump',
1347
                'cweiske' => 'Christian Weiske',
1348
                'ashnazg' => 'Chuck Burgess',
1349
                'tswicegood' => 'Travis Swicegood',
1350
                'saltybeagle' => 'Brett Bieber',
1351
                ),
1352
            'docs'      => array(
1353
                ),
1354
            'website'   => array(
1355
                )
1356
            );
1357
 
1358
        if ($group === 'all') {
1359
            $list = $members;
1360
            if ($sort === true) {
1361
                asort($list['group']);
1362
                asort($list['docs']);
1363
                asort($list['website']);
1364
            }
1365
        } elseif (in_array($group, array_keys($members))) {
1366
            $list = $members[$group];
1367
            if ($sort === true) {
1368
                asort($list);
1369
            }
1370
        } else {
1371
            $list = false;
1372
        }
1373
        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
         $this->display();
1390
    }
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
         echo $this->toHtml();
1405
    }
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
        $body = $this->info;
1422
 
1423
        if (!($this->options['resume'] & PEAR_INFO_FULLPAGE)) {
1424
            return $body;
1425
        }
1426
 
1427
        if (!isset($this->css)) {
1428
            // when no user-styles defined, used the default values
1429
            $this->setStyleSheet();
1430
        }
1431
        $styles = $this->getStyleSheet();
1432
 
1433
        $html = <<<HTML
1434
<!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
$styles
1443
 -->
1444
</style>
1445
</head>
1446
<body>
1447
<div>
1448
$body
1449
</div>
1450
</body>
1451
</html>
1452
HTML;
1453
        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
        $config =& PEAR_Config::singleton($user_file, $system_file);
1480
        $reg    =& $config->getRegistry();
1481
 
1482
        if (is_null($version)) {
1483
            return $reg->packageExists($name, $channel);
1484
        } else {
1485
            $info = &$reg->getPackage($name, $channel);
1486
            if (is_object($info)) {
1487
                $installed['version'] = $info->getVersion();
1488
            } else {
1489
                $installed = $info;
1490
            }
1491
            return version_compare($version, $installed['version'], '<=');
1492
        }
1493
    }
1494
}
1495
 
1496
if (isset($_GET['pear_image'])) {
1497
    PEAR_Info::pearImage();
1498
    exit();
1499
}
1500
?>