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.0 of the PHP license
  8. * that is available through the world-wide-web at the following URI:
  9. * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  10. * the PHP License and are unable to obtain it through the web, please
  11. * send a note to license@php.net so we can mail you a copy immediately.
  12. *
  13. * @category   PEAR
  14. * @package    PEAR_Info
  15. * @author     Davey Shafik <davey@pixelated-dreams.com>
  16. * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  17. * @version    CVS: $Id:$
  18. * @since      File available since Release 1.0.1
  19. */
  20.  
  21. require_once 'PEAR/Remote.php';
  22. require_once 'PEAR/Registry.php';
  23.  
  24. /**
  25. * The PEAR_Info class generate phpinfo() style PEAR information.
  26. *
  27. * @category   PEAR
  28. * @package    PEAR_Info
  29. * @author     Davey Shafik <davey@pixelated-dreams.com>
  30. * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  31. * @version    Release: @package_version@
  32. * @since      Class available since Release 1.0.1
  33. */
  34.  
  35. class PEAR_Info
  36. {
  37.     /**
  38.      * Html code for phpinfo() style PEAR information
  39.      *
  40.      * @var    string
  41.      * @access public
  42.      * @since  1.0.1
  43.      */
  44.     var $info;
  45.  
  46.     /**
  47.      * Style sheet for the custom layout
  48.      *
  49.      * @var    string
  50.      * @access public
  51.      * @since  1.7.0
  52.      */
  53.     var $css;
  54.  
  55.     /**
  56.      * instance of PEAR_config
  57.      *
  58.      * @var    object
  59.      * @access public
  60.      * @since  1.0.1
  61.      */
  62.     var $config;
  63.  
  64.     /**
  65.      * instance of PEAR_Registry
  66.      *
  67.      * @var    object
  68.      * @access public
  69.      * @since  1.0.1
  70.      */
  71.     var $reg;
  72.  
  73.     /**
  74.      * instance of PEAR_Remote
  75.      *
  76.      * @var    object
  77.      * @access private
  78.      * @since  1.0.1
  79.      */
  80.     var $r;
  81.  
  82.     /**
  83.      * PHP 4 style constructor (ZE1)
  84.      *
  85.      * @param  string  $pear_dir         (optional) The PEAR base install directory
  86.      * @param  string  $pear_user_config (optional) File to read user-defined options from
  87.      * @return void
  88.      * @access public
  89.      * @since  1.0.1
  90.      */
  91.     function PEAR_Info($pear_dir = false, $pear_user_config = false)
  92.     {
  93.         $this->__construct($pear_dir, $pear_user_config);
  94.     }
  95.  
  96.     /**
  97.      * PHP 5 style constructor (ZE2)
  98.      *
  99.      * @param  string  $pear_dir         (optional) The PEAR base install directory
  100.      * @param  string  $pear_user_config (optional) File to read user-defined options from
  101.      * @return void
  102.      * @access private
  103.      * @since  1.7.0
  104.      */
  105.     function __construct($pear_dir = false, $pear_user_config = false)
  106.     {
  107.         if ($pear_user_config === false) {
  108.             $this->config = new PEAR_Config();
  109.         } else {
  110.             $this->config = new PEAR_Config($pear_user_config);
  111.         }
  112.         if ($pear_dir != false) {
  113.             $this->config->set('php_dir',$pear_dir);
  114.         }
  115.         if (defined('PEAR_INFO_PROXY')) {
  116.             $this->config->set('http_proxy', PEAR_INFO_PROXY);
  117.         }
  118.         $this->r = new PEAR_Remote($this->config);
  119.         $this->reg = new PEAR_Registry($this->config->get('php_dir'));
  120.         // get PEARs packageInfo to show version number at the top of the HTML
  121.         if (method_exists($this->reg, 'getPackage')) {
  122.             $pear = $this->reg->getPackage("PEAR");
  123.             $pear_version = $pear->getVersion();
  124.         } else {
  125.             $pear = $this->reg->packageInfo('PEAR');
  126.             $pear_version = $pear['version'];
  127.         }
  128.         $this->index = array();
  129.         $this->list_options = false;
  130.         if ($this->config->get('preferred_state') == 'stable') {
  131.             $this->list_options = true;
  132.         }
  133.         $this->info = '
  134. <table>
  135. <tr class="h">
  136.     <td>
  137.         <a href="http://pear.php.net/"><img src="{phpself}?pear_image=true" alt="PEAR Logo" /></a><h1 class="p">PEAR {pearversion}</h1>
  138.     </td>
  139. </tr>
  140. </table>
  141. ';
  142.         $this->info = str_replace(
  143.             array('{phpself}', '{pearversion}'),
  144.             array(htmlentities($_SERVER['PHP_SELF']), $pear_version),
  145.             $this->info
  146.             );
  147.  
  148.         if (!isset($_GET['credits'])) {
  149.             $this->info .= '
  150. <h1><a href="{phpself}?credits=true">PEAR Credits</a></h1>
  151. ';
  152.             $this->info = str_replace(
  153.                 '{phpself}', htmlentities($_SERVER['PHP_SELF']),
  154.                 $this->info
  155.                 );
  156.  
  157.             $this->info .= $this->getConfig();
  158.             $this->info .= $this->getPackages();
  159.  
  160.         } else {
  161.             $this->info .= $this->getCredits();
  162.         }
  163.     }
  164.  
  165.     /**
  166.      * Set PEAR http_proxy for remote calls
  167.      *
  168.      * @param  string  $proxy  HTTP Proxy Server Address
  169.      * @static
  170.      * @return bool
  171.      * @access public
  172.      * @since  1.0.6
  173.      */
  174.     function setProxy($proxy)
  175.     {
  176.         $res = define('PEAR_INFO_PROXY', $proxy);
  177.         return $res;
  178.     }
  179.  
  180.     /**
  181.      * Returns the custom style sheet to use for layout
  182.      *
  183.      * @param  bool  $content (optional) Either return css filename or string contents
  184.      * @return string
  185.      * @access public
  186.      * @since  1.7.0
  187.      */
  188.     function getStyleSheet($content = true)
  189.     {
  190.         if ($content) {
  191.             $styles = file_get_contents($this->css);
  192.         } else {
  193.             $styles = $this->css;
  194.         }
  195.         return $styles;
  196.     }
  197.  
  198.     /**
  199.      * Set the custom style sheet to use your own styles
  200.      *
  201.      * @param  string  $css (optional) File to read user-defined styles from
  202.      * @return bool    True if custom styles, false if default styles applied
  203.      * @access public
  204.      * @since  1.7.0
  205.      */
  206.     function setStyleSheet($css = null)
  207.     {
  208.         // default stylesheet is into package data directory
  209.         if (!isset($css)) {
  210.             $this->css = '@data_dir@' . DIRECTORY_SEPARATOR
  211.                  . '@package_name@' . DIRECTORY_SEPARATOR
  212.                  . 'pearinfo.css';
  213.         }
  214.  
  215.         $res = isset($css) && file_exists($css);
  216.         if ($res) {
  217.             $this->css = $css;
  218.         }
  219.         return $res;
  220.     }
  221.  
  222.     /**
  223.      * Retrieve and format PEAR Packages info
  224.      *
  225.      * @return string
  226.      * @access private
  227.      * @since  1.0.1
  228.      */
  229.     function getPackages()
  230.     {
  231.         $latest = @$this->r->call('package.listLatestReleases');
  232.         $available = $this->reg->listAllPackages();
  233.         if (PEAR::isError($available)) {
  234.             $e = '<p class="error">An Error occured while fetching the package list.'
  235.                . ' Please try again.</p>';
  236.             return $e;
  237.         }
  238.         if (!is_array($available)) {
  239.             $e = '<p class="error">The package list could not be fetched from the remote server.'
  240.                . ' Please try again.</p>';
  241.             return $e;
  242.         }
  243.         if ((PEAR::isError($latest)) || (!is_array($latest))) {
  244.             $latest = false;
  245.         }
  246.  
  247.         $packages = '';
  248.         foreach ($available as $channel => $pkg) {
  249.             foreach ($pkg as $name) {
  250.                 $info = &$this->reg->getPackage($name, $channel);
  251.                 if (is_object($info)) {
  252.                     $installed['package'] = $info->getPackage();
  253.                     $installed['channel'] = $channel;
  254.                     $installed['summary'] = $info->getSummary();
  255.                     $installed['version'] = $info->getVersion();
  256.                     $installed['current_release'] = $installed['version']
  257.                         . ' (' . $info->getState() . ') was released on '
  258.                         . $info->getDate();
  259.                     $installed['license'] = $info->getLicense();
  260.                     if ($info->getPackagexmlVersion() == '2.0' ) {
  261.                         $uri = $info->getLicenseLocation();
  262.                         if ($uri) {
  263.                             if (isset($uri['uri'])) {
  264.                                 $installed['license'] = '<a href="' . $uri['uri'] . '">'
  265.                                     . $info->getLicense() . '</a>';
  266.                             }
  267.                         }
  268.                     }
  269.                     $installed['description'] = $info->getDescription();
  270.                 } else {
  271.                     $installed = $info;
  272.                     $installed['channel'] = 'pear.php.net';
  273.                     $installed['current_release'] = $info['version']
  274.                         . ' (' . $info['release_state'] . ') was released on '
  275.                         . $info['release_date'];
  276.                 }
  277.  
  278.                 $deps = $info->getDeps();
  279.                 if (is_array($deps)) {
  280.                     static $_deps_rel_trans = array(
  281.                                  'lt' => '<',
  282.                                  'le' => '<=',
  283.                                  'eq' => '=',
  284.                                  'ne' => '!=',
  285.                                  'gt' => '>',
  286.                                  'ge' => '>=',
  287.                                  'has' => 'has'
  288.                                  );
  289.                     static $_deps_type_trans = array(
  290.                                  'pkg' => 'Package',
  291.                                  'ext' => 'Extension',
  292.                                  'php' => 'PHP'
  293.                                  );
  294.  
  295.                     $dependencies = '';
  296.                     $ptpl = '
  297. <tr class="w">
  298.     <td>
  299.         {dep_required}
  300.     </td>
  301.     <td>
  302.         {dep_type}
  303.     </td>
  304.     <td>
  305.         {dep_name}
  306.     </td>
  307.     <td>
  308.         {dep_rel}
  309.     </td>
  310.     <td>
  311.         {dep_version}
  312.     </td>
  313. </tr>
  314. ';
  315.                     foreach($deps as $dep) {
  316.                         $dependencies .= str_replace(
  317.                             array('{dep_required}',
  318.                                 '{dep_type}',
  319.                                 '{dep_name}',
  320.                                 '{dep_rel}',
  321.                                 '{dep_version}',
  322.                                 ),
  323.                             array(($dep['optional'] == 'no') ? 'Yes' : 'No',
  324.                                 $_deps_type_trans[$dep['type']],
  325.                                 $dep['name'],
  326.                                 $_deps_rel_trans[$dep['rel']],
  327.                                 $dep['version']
  328.                                 ),
  329.                             $ptpl
  330.                         );
  331.                     }
  332.                     $ptpl = '
  333. <tr class="w">
  334.     <td class="f">
  335.         Required
  336.     </td>
  337.     <td class="f">
  338.         Type
  339.     </td>
  340.     <td class="f">
  341.         Name
  342.     </td>
  343.     <td class="f">
  344.         Relation
  345.     </td>
  346.     <td class="f">
  347.         Version
  348.     </td>
  349. </tr>
  350. ';
  351.                     $dependencies = $ptpl . $dependencies;
  352.                 }
  353.  
  354.                 if (!isset($old_index)) {
  355.                     $old_index = '';
  356.                 }
  357.                 $current_index = $name{0};
  358.                 if (strtolower($current_index) != strtolower($old_index)) {
  359.                     $packages .= '<a name="' .$current_index. '"></a>';
  360.                     $old_index = $current_index;
  361.                     $this->index[] = $current_index;
  362.                 }
  363.                 $ptpl = '
  364. <h2><a name="pkg_{package}">{package}</a></h2>
  365. <table>
  366. <tr class="v">
  367.     <td class="e">
  368.         Channel
  369.     </td>
  370.     <td>
  371.         {channel}
  372.     </td>
  373. </tr>
  374. <tr class="v">
  375.     <td class="e">
  376.         Summary
  377.     </td>
  378.     <td>
  379.         {summary}
  380.     </td>
  381. </tr>
  382. <tr class="v">
  383.     <td class="e">
  384.         Version
  385.     </td>
  386.     <td>
  387.         {version}
  388.     </td>
  389. </tr>
  390. <tr class="v">
  391.     <td class="e">
  392.         License
  393.     </td>
  394.     <td>
  395.         {license}
  396.     </td>
  397. </tr>
  398. <tr class="v">
  399.     <td class="e">
  400.         Description
  401.     </td>
  402.     <td>
  403.         {description}
  404.     </td>
  405. </tr>';
  406.  
  407.                 if (!empty($dependencies)) {
  408.                     $ptpl .= '
  409. <tr class="v">
  410.     <td class="e">
  411.         Dependencies
  412.     </td>
  413.     <td>
  414.         <table class="d">
  415.         {dependencies}
  416.         </table>
  417.     </td>
  418. </tr>';
  419.                 }
  420.  
  421.                 $packages .= str_replace(
  422.                     array('{package}',
  423.                         '{channel}',
  424.                         '{summary}',
  425.                         '{version}',
  426.                         '{license}',
  427.                         '{description}',
  428.                         '{dependencies}'
  429.                         ),
  430.                     array(trim($installed['package']),
  431.                         trim($installed['channel']),
  432.                         nl2br(htmlentities(trim($installed['summary']))),
  433.                         trim($installed['current_release']),
  434.                         trim($installed['license']),
  435.                         nl2br(htmlentities(trim($installed['description']))),
  436.                         $dependencies
  437.                         ),
  438.                     $ptpl
  439.                 );
  440.  
  441.                 if ($latest != false) {
  442.                     if (isset($latest[$installed['package']])) {
  443.                         if (version_compare($latest[$installed['package']]['version'],
  444.                             $installed['version'], '>')) {
  445.                             $ptpl = '
  446. <tr class="v">
  447.     <td class="e">
  448.         Latest Version
  449.     </td>
  450.     <td>
  451.         <a href="http://pear.php.net/get/{package}">{latest_version}</a>({latest_state})
  452.     </td>
  453. </tr>';
  454.                             $packages .= str_replace(
  455.                                 array('{package}',
  456.                                     '{latest_version}',
  457.                                     '{latest_state}'
  458.                                     ),
  459.                                 array(trim($installed['package']),
  460.                                     $latest[$installed['package']]['version'],
  461.                                     $latest[$installed['package']]['state']
  462.                                     ),
  463.                                 $ptpl
  464.                                 );
  465.                         }
  466.                     }
  467.                 }
  468.                 $packages .= '
  469. <tr>
  470.     <td colspan="2" class="v"><a href="#top">Top</a></td>
  471. </tr>
  472. </table>
  473. ';
  474.             }
  475.         }
  476.  
  477.         $index = '
  478. <h2><a name="top">PEAR Packages</a></h2>
  479. <table>
  480. <tr>
  481.     <td class="e">
  482.         Index
  483.     </td>
  484. </tr>
  485. <tr>
  486.     <td class ="v" style="text-align: center">
  487. ';
  488.         foreach ($this->index as $i) {
  489.             $index .= ' | <a href="#'.$i.'">'.strtoupper($i).'</a>';
  490.         }
  491.         $index .= ' |
  492.     </td>
  493. </tr>
  494. </table>
  495. ';
  496.         $s = $index . $packages;
  497.         return $s;
  498.     }
  499.  
  500.     /**
  501.      * Retrieves and formats the PEAR Config data
  502.      *
  503.      * @return string
  504.      * @access private
  505.      * @since  1.0.1
  506.      */
  507.     function getConfig()
  508.     {
  509.         $keys = $this->config->getKeys();
  510.         sort($keys);
  511.  
  512.         $html_pear_config = '
  513. <h2>PEAR Config</h2>
  514. <table>';
  515.         foreach ($keys as $key) {
  516.             if (($key != 'password') && ($key != 'username') && ($key != 'sig_keyid') && ($key != 'http_proxy')) {
  517.                 $html_config = '
  518. <tr class="v">
  519.     <td class="e">{key}</td>
  520.     <td>{value}</td>
  521. </tr>';
  522.                 $html_config = str_replace(
  523.                     array('{key}', '{value}'),
  524.                     array($key, $this->config->get($key)),
  525.                     $html_config
  526.                     );
  527.                 $html_pear_config .= $html_config;
  528.             }
  529.         }
  530.         $html_pear_config .= '
  531. </table>
  532. ';
  533.         return $html_pear_config;
  534.     }
  535.  
  536.     /**
  537.      * Retrieves and formats the PEAR Credits
  538.      *
  539.      * @return string
  540.      * @access private
  541.      * @since  1.0.1
  542.      */
  543.     function getCredits()
  544.     {
  545.         $html_pear_credits = '
  546. <h1>PEAR Credits</h1>
  547. <table>
  548.     <tr class="h">
  549.         <td>
  550.             PEAR Website Team
  551.         </td>
  552.     </tr>
  553.     <tr class="v">
  554.         <td>
  555.             <a href="http://pear.php.net/account-info.php?handle=ssb">Stig Bakken</a>,
  556.             <a href="http://pear.php.net/account-info.php?handle=cox">Thomas V.V.Cox</a>,
  557.             <a href="http://pear.php.net/account-info.php?handle=mj">Martin Jansen</a>,
  558.             <a href="http://pear.php.net/account-info.php?handle=cmv">Colin Viebrock</a>,
  559.             <a href="http://pear.php.net/account-info.php?handle=richard">Richard Heyes</a>
  560.         </td>
  561.     </tr>
  562. </table>
  563. <table>
  564. <tr class="h">
  565.     <td>
  566.         PEAR documentation team
  567.     </td>
  568. </tr>
  569. <tr class="v">
  570.     <td>
  571.         <a href="http://pear.php.net/account-info.php?handle=cox">Thomas V.V.Cox</a>,
  572.         <a href="http://pear.php.net/account-info.php?handle=mj">Martin Jansen</a>,
  573.         <a href="http://pear.php.net/account-info.php?handle=alexmerz">Alexander Merz</a>
  574.     </td>
  575. </tr>
  576. </table>
  577. ';
  578.         $available = $this->reg->listAllPackages();
  579.         if (PEAR::isError($available)) {
  580.             $e = '<p class="error">An Error occured while fetching the credits from the remote server.'
  581.                . ' Please try again.</p>';
  582.             return $e;
  583.         }
  584.         if (!is_array($available)) {
  585.             $e = '<p class="error">The credits could not be fetched from the remote server.'
  586.                . ' Please try again.</p>';
  587.             return $e;
  588.         }
  589.         $html_pear_credits .= '
  590. <table border="0" cellpadding="3" width="600">
  591. <tr class="h"><td>Package</td><td>Maintainers</td></tr>
  592. ';
  593.         foreach ($available as $channel => $pkg) {
  594.             foreach ($pkg as $name) {
  595.                 $info = &$this->reg->getPackage($name, $channel);
  596.                 if (is_object($info)) {
  597.                     $installed['package'] = $info->getPackage();
  598.                     $installed['maintainers'] = $info->getMaintainers();
  599.                 } else {
  600.                     $installed = $info;
  601.                 }
  602.  
  603.                 $ptpl = '
  604. <tr>
  605.     <td class="e">
  606.         <a href="http://pear.php.net/{packageURI}">{package}</a>
  607.     </td>
  608.     <td class="v">
  609.         {maintainers}
  610.     </td>
  611. </tr>';
  612.                 $maintainers = array();
  613.                 foreach ($installed['maintainers'] as $i) {
  614.                     $maintainers[] = '<a href="http://pear.php.net/account-info.php?handle='
  615.                                    . $i['handle']. '">'
  616.                                    . htmlentities($i['name'])
  617.                                    . '</a>'
  618.                                    .' (' . $i['role'] . ')';
  619.                 }
  620.                 $maintainers = implode(', ',$maintainers);
  621.  
  622.                 $html_pear_credits .= str_replace(
  623.                     array('{packageURI}',
  624.                         '{package}',
  625.                         '{maintainers}'
  626.                         ),
  627.                     array(trim(strtolower($installed['package'])),
  628.                         trim($installed['package']),
  629.                         $maintainers
  630.                         ),
  631.                     $ptpl
  632.                 );
  633.             }
  634.         }
  635.         $html_pear_credits .= '</table>';
  636.         return $html_pear_credits;
  637.     }
  638.  
  639.     /**
  640.      * outputs the PEAR logo
  641.      *
  642.      * @return void
  643.      * @access public
  644.      * @since  1.0.1
  645.      */
  646.     function pearImage()
  647.     {
  648.         $pear_image = 'R0lGODlhaAAyAMT/AMDAwP3+/TWaAvD47Pj89vz++zebBDmcBj6fDEekFluvKmu3PvX68ujz4XvBS8LgrNXqxeHw1ZnPaa/dgvv9+cLqj8LmltD2msnuls';
  649.         $pear_image .= '3xmszwmf7+/f///wAAAAAAAAAAACH5BAEAAAAALAAAAABoADIAQAX/ICCOZGmeaKqubOtWWjwJphLLgH1XUu//C1Jisfj9YLEKQnSY3GaixWQqQTkYHM4';
  650.         $pear_image .= 'AMulNLJFC9pEwIW/odKU8cqTfsWoTTtcomU4ZjbR4ZP+AgYKCG0EiZ1AuiossEhwEXRMEg5SVWQ6MmZqKWD0QlqCUEHubpaYlExwRPRZioZZVp7KzKQoS';
  651.         $pear_image .= 'DxANDLsNXA5simd2FcQYb4YAc2jEU80TmAAIztPCMcjKdg4OEsZJmwIWWQPQI4ikIwtoVQnddgrv8PFlCWgYCwkI+fp5dkvJ/IlUKMCy6tYrDhNIIKLFE';
  652.         $pear_image .= 'AWCTxse+ABD4SClWA0zovAjcUJFi6EwahxZwoGqHhFA/4IqoICkyxQSKkbo0gDkuBXV4FRAJkRCnTgi2P28IcEfk5xpWppykFJVuScmEvDTEETAVJ6bEp';
  653.         $pear_image .= 'ypcADPkz3pvKVAICHChkC7siQ08zVqu4Q6hgIFEFZuEn/KMgRUkaBmAQs+cEHgIiHVH5EAFpIgW4+NT6LnaqhDwe/Ov7YOmWZp4MkiAWBIl0kAVsJWuzc';
  654.         $pear_image .= 'YpdiNgddc0E8cKBAu/FElBwagMb88ZZKDRAkWJtkWhHh3wwUbKHQJN3wQAaXGR2LpArv5oFHRR34C7Mf6oLXZNfqBgNI7oOLhj1f8PaGpygHQ0xtP8MDV';
  655.         $pear_image .= 'KwYTSKcgxr9/hS6/pCCAAg5M4B9/sWh1YP9/XSgQWRML/idBfKUc4IBET9lFjggKhDYZAELZJYEBI2BDB3ouNBEABwE8gAwiCcSYgAKqPdEVAG7scM8BP';
  656.         $pear_image .= 'PZ4AIlM+OgjAgpMhRE24OVoBwsIFEGFA7ZkQQBWienWxmRa7XDjKZXhBdAeSmKQwgLuUVLICa6VEKIGcK2mQWoVZHCBXJblJUFkY06yAXlGsPIHBEYdYi';
  657.         $pear_image .= 'WHb+WQBgaIJqqoHFNpgMGB7dT5ZQuG/WbBAIAUEEFNfwxAWpokTIXJAWdgoJ9kRFG2g5eDRpXSBpEIF0oEQFaZhDbaSFANRgqcJoEDRARLREtxOQpsPO9';
  658.         $pear_image .= '06ZUeJgjQB6dZUPBAdwcF8KLXXRVQaKFcsRRLJ6vMiiCNKxRE8ECZKgUA3Va4arOAAqdGRWO7uMZH5AL05gvsjQbg6y4NCjQ1kw8TVGcbdoKGKx8j3bGH';
  659.         $pear_image .= '7nARBArqwi0gkFJBrZiXBQRbHoIgnhSjcEBKfD7c3HMhz+JIQSY3t8GGKW+SUhfUajxGzKd0IoHBNkNQK86ZYEqdzYA8AHQpqXRUm80oHs1CAgMoBxzRq';
  660.         $pear_image .= 'vzs9CIKECC1JBp7enUpfXHApwVYNAfo16c4IrYPLVdSAJVob7IAtCBFQGHcs/RRdiUDPHA33oADEAIAOw==';
  661.         header('content-type: image/gif');
  662.         echo base64_decode($pear_image);
  663.     }
  664.  
  665.     /**
  666.      * Shows PEAR_Info output
  667.      *
  668.      * @return void
  669.      * @access public
  670.      * @since  1.0.1
  671.      * @deprecated  use display() instead
  672.      */
  673.     function show()
  674.     {
  675.          $this->display();
  676.     }
  677.  
  678.     /**
  679.      * Displays PEAR_Info output
  680.      *
  681.      * @return void
  682.      * @access public
  683.      * @since  1.7.0
  684.      */
  685.     function display()
  686.     {
  687.          echo $this->toHtml();
  688.     }
  689.  
  690.     /**
  691.      * Returns PEAR_Info output (html code)
  692.      *
  693.      * @return string
  694.      * @access public
  695.      * @since  1.7.0
  696.      */
  697.     function toHtml()
  698.     {
  699.         if (!isset($this->css)) {
  700.             // when no user-styles defined, used the default values
  701.             $this->setStyleSheet();
  702.         }
  703.         $styles = $this->getStyleSheet();
  704.  
  705.         $body = $this->info;
  706.  
  707.         $html = <<<HTML
  708. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  709. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  710. <head>
  711. <title>PEAR :: PEAR_Info()</title>
  712. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  713. <style type="text/css">
  714. <!--
  715. $styles
  716.  -->
  717. </style>
  718. </head>
  719. <body>
  720. $body
  721. </body>
  722. </html>
  723. HTML;
  724.         return $html;
  725.     }
  726.  
  727.     /**
  728.      * Check if a package is installed
  729.      *
  730.      * @param  string  $name                        Package name
  731.      * @param  string  $version (optional)          The minimal version that should be installed
  732.      * @param  string  $channel (optional)          The package channel distribution
  733.      * @param  string  $pear_user_config (optional) File to read user-defined options from
  734.      * @static
  735.      * @return bool
  736.      * @access public
  737.      * @since  1.6.0
  738.      */
  739.     function packageInstalled($name, $version = null, $channel = null, $pear_user_config = null)
  740.     {
  741.         $config = new PEAR_Config($pear_user_config);
  742.         $reg = new PEAR_Registry($config->get('php_dir'));
  743.  
  744.         if (is_null($version)) {
  745.             return $reg->packageExists($name, $channel);
  746.         } else {
  747.             $info = &$reg->getPackage($name, $channel);
  748.             if (is_object($info)) {
  749.                 $installed['version'] = $info->getVersion();
  750.             } else {
  751.                 $installed = $info;
  752.             }
  753.             return version_compare($version, $installed['version'], '<=');
  754.         }
  755.     }
  756. }
  757.  
  758. if (isset($_GET['pear_image'])) {
  759.     PEAR_Info::pearImage();
  760.     exit;
  761. }
  762. ?>