Source for file Info.php
Documentation is available at Info.php
* This package generate phpinfo() style PEAR information.
* LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
* @author Davey Shafik <davey@pixelated-dreams.com>
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: Info.php,v 1.54 2007/12/30 17:08:19 farell Exp $
* @link http://pear.php.net/package/PEAR_Info
* @since File available since Release 1.0.1
require_once 'PEAR/Config.php';
* PEAR_INFO_* is a bit-field. Or each number up to get desired information.
* require_once 'PEAR/Info.php';
* // will display for each channel (list displayed),
* // a quick package list with only its name and version
* $options = array('resume' => PEAR_INFO_CHANNELS | PEAR_INFO_PACKAGES_VERSION);
* $info = new PEAR_Info('', 'c:\wamp\php\pear.ini', '', $options);
* - Show all informations, except for credits
* $options = array('resume' => PEAR_INFO_ALL & ~PEAR_INFO_CREDITS);
* - Show only credits and configuration
* $options = array('resume' => PEAR_INFO_CONFIGURATION | PEAR_INFO_CREDITS);
* The configuration line, pear.ini | .pearrc location, and more.
define('PEAR_INFO_GENERAL', 1 );
define('PEAR_INFO_CREDITS', 2 );
define('PEAR_INFO_CONFIGURATION', 4 );
* Information on PEAR channels.
define('PEAR_INFO_CHANNELS', 8 );
* Information on PEAR packages.
define('PEAR_INFO_PACKAGES', 4080 );
define('PEAR_INFO_PACKAGES_CHANNEL', 2048 );
define('PEAR_INFO_PACKAGES_SUMMARY', 1024 );
define('PEAR_INFO_PACKAGES_VERSION', 512 );
define('PEAR_INFO_PACKAGES_LICENSE', 256 );
define('PEAR_INFO_PACKAGES_DESCRIPTION', 128 );
define('PEAR_INFO_PACKAGES_DEPENDENCIES', 64 );
define('PEAR_INFO_PACKAGES_XML', 32 );
define('PEAR_INFO_PACKAGES_UPDATE', 16 );
* Shows all of the above. This is the default value.
define('PEAR_INFO_ALL', 4095 );
* Information on PEAR credits.
define('PEAR_INFO_CREDITS_GROUP', 4096 );
define('PEAR_INFO_CREDITS_DOCS', 8192 );
define('PEAR_INFO_CREDITS_WEBSITE', 16384 );
define('PEAR_INFO_CREDITS_PACKAGES', 32768 );
define('PEAR_INFO_CREDITS_ALL', 61440 );
* Indicates that a complete stand-alone HTML page needs to be printed
* including the information indicated by the other flags.
define('PEAR_INFO_FULLPAGE', 65536 );
* The PEAR_Info class generate phpinfo() style PEAR information.
* @author Davey Shafik <davey@pixelated-dreams.com>
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: @package_version@
* @link http://pear.php.net/package/PEAR_Info
* @since Class available since Release 1.0.1
* Html code for phpinfo() style PEAR information
* Style sheet for the custom layout
* instance of PEAR_config
* instance of PEAR_Registry
* PHP 4 style constructor (ZE1)
* @param string $pear_dir (optional) The PEAR base install directory
* @param string $user_file (optional) file to read PEAR user-defined
* @param string $system_file (optional) file to read PEAR system-wide
* @param array $options (optional) configure PEAR information output
* @since version 1.0.1 (2003-04-24)
function PEAR_Info($pear_dir = '', $user_file = '', $system_file = '',
$this->__construct ($pear_dir, $user_file, $system_file, $options);
* PHP 5 style constructor (ZE2)
* @param string $pear_dir (optional) The PEAR base install directory
* @param string $user_file (optional) file to read PEAR user-defined
* @param string $system_file (optional) file to read PEAR system-wide
* @param array $options (optional) configure PEAR information output
* @since version 1.7.0RC1 (2007-07-01)
function __construct ($pear_dir = '', $user_file = '', $system_file = '',
// options defined at run-time (default)
$this->options = array ('channels' => array ('pear.php.net'),
// overwrite one to all defaults
$this->options = array_merge($this->options, $options);
// to keep compatibility with version less or equal than 1.6.1
if (!empty ($pear_dir) && empty ($user_file) && empty ($system_file)) {
// try to find a PEAR user-defined config file into $pear_dir
$user_file = $pear_dir . DIRECTORY_SEPARATOR;
$user_file .= 'pear.ini';
// try to find a PEAR system-wide config file into $pear_dir
$system_file = $pear_dir . DIRECTORY_SEPARATOR;
$system_file .= 'pearsys.ini';
$system_file .= 'pear.conf';
$e = '<p class="error">No PEAR configuration files ('
. " ) found into '$pear_dir' directory</p>";
$this->config = & PEAR_Config ::singleton ($user_file, $system_file);
// to keep compatibility with version less or equal than 1.6.1
$this->config->set ('http_proxy', PEAR_INFO_PROXY );
if (empty ($system_file) || !file_exists($system_file)) {
$user_file = $this->config->getConfFile ('user');
$system_file = $this->config->getConfFile ('system');
// prevent unexpected result if PEAR config file does not exist
$e = '<p class="error">PEAR configuration files "'
. $user_file . '", "' . $system_file . '" does not exist</p>';
// Get the config's registry object.
// Get list of all channels in your PEAR install,
// when 'channels' option is empty
if (isset ($this->options['channels'])
&& empty ($this->options['channels'])) {
$channels = $this->reg->listChannels ();
if (PEAR ::isError ($channels)) {
$this->options['channels'] = array ('pear.php.net');
$this->options['channels'] = $channels;
// show general informations such as PEAR version, PEAR logo,
$pear = $this->reg->getPackage ("PEAR");
$pear_version = $pear->getVersion ();
<a href="http://pear.php.net/">
<img src="{phpself}?pear_image=true" alt="PEAR Logo" />
<h1 class="p">PEAR {pearversion}</h1>
// Loaded configuration file
<td class="e">Loaded Configuration File</td>
$this->config->getConfFile ($layer),
isset ($_GET['credits'])) {
$this->info .= $this->getCredits ();
<h1><a href="{phpself}?credits=true">PEAR Credits</a></h1>
$this->info .= $this->getConfig ();
$this->info .= $this->getChannels ();
$this->info .= $this->getPackages ();
* Sets PEAR HTTP Proxy Server Address
* Sets http_proxy config setting at runtime
* @param string $proxy PEAR HTTP Proxy Server Address
* @since version 1.0.6 (2003-05-11)
$res = define('PEAR_INFO_PROXY', $proxy);
* Returns the custom style sheet to use for presentation
* Default behavior is to return css string contents.
* Sets $content parameter to false will return css filename reference
* (defined by setStyleSheet function).
* Easy for a <link rel="stylesheet" type="text/css" href="" />
* html tag integration (see example pear_info3.php).
* @param bool $content (optional) Either return css filename or string contents
* @since version 1.7.0RC1 (2007-07-01)
* Sets the custom style sheet to use your own styles
* Sets the custom style sheet (colors, sizes) to applied to PEAR_Info output.
* If you don't give any parameter, you'll then apply again the default style.
* @param string $css (optional) File to read user-defined styles from
* @return bool True if custom styles, false if default styles applied
* @since version 1.7.0RC1 (2007-07-01)
// default stylesheet is into package data directory
$this->css = '@data_dir@' . DIRECTORY_SEPARATOR
. '@package_name@' . DIRECTORY_SEPARATOR
* Retrieve and format PEAR Packages info
* @since version 1.0.1 (2003-04-24)
$available = $this->reg->listAllPackages ();
if (PEAR ::isError ($available)) {
$e = '<p class="error">An Error occured while fetching the package list.'
. ' Please try again.</p>';
$e = '<p class="error">The package list could not be fetched'
. ' from the remote server. Please try again.</p>';
// list of channels to scan
$channel_allowed = $this->options['channels'];
// check if there are new versions available for packages installed
foreach ($channel_allowed as $channel) {
$chan = & $this->reg->getChannel ($channel);
if (PEAR ::isError ($chan)) {
$e = '<p class="error">An error has occured. '
. ' Please try again.</p>';
if ($chan->supportsREST ($channel) &&
$base = $chan->getBaseURL ('REST1.0', $channel)) {
$rest = & $this->config->getREST ('1.0', array ());
$pref_state = $this->config->get ('preferred_state');
$l = $rest->listLatestUpgrades ($base, $pref_state,
$installed, $channel, $this->reg);
$r = & $this->config->getRemote ();
$l = @$r->call ('package.listLatestReleases');
if ((PEAR ::isError ($latest)) || (!is_array($latest))) {
$anchor_suffix = 0; // make page XHTML compliant
foreach ($available as $channel => $pkg) {
if (!in_array($channel, $channel_allowed)) {
// sort package by alphabetic order
foreach ($pkg as $name) {
// show general package informations
$info = &$this->reg->getPackage ($name, $channel);
continue; // should never arrive, if package is really installed
$__info = $info->getArray ();
$installed['package'] = $info->getPackage ();
$installed['channel'] = $channel;
$installed['summary'] = $info->getSummary ();
$installed['version'] = $info->getVersion ();
$installed['current_release'] = $installed['version']
. ' (' . $info->getState () . ') was released on '
$installed['license'] = $info->getLicense ();
if ($info->getPackagexmlVersion () == '1.0' ) {
$installed['lastmodified']
= $info->packageInfo ('_lastmodified');
$installed['packagexml'] = $info->getPackagexmlVersion ();
if (isset ($__info['packagerversion'])) {
$installed['packagerversion']
= $__info['packagerversion'];
$uri = $info->getLicenseLocation ();
if (isset ($uri['uri'])) {
$installed['license'] = '<a href="'
. $info->getLicense () . '</a>';
$installed['lastmodified'] = $info->getLastModified ();
$installed['packagexml'] = $info->getPackagexmlVersion ();
$installed['packagerversion']
= $__info['attribs']['packagerversion'];
$installed['description'] = $info->getDescription ();
$deps = $info->getDeps ();
static $_deps_rel_trans = array (
static $_deps_type_trans = array (
foreach ($deps as $dep) {
if (!isset ($dep['optional'])) {
$dependencies .= str_replace (array ('{dep_required}',
array (($dep['optional'] == 'no') ? 'Yes' : 'No',
$_deps_type_trans[$dep['type']],
isset ($dep['name']) ? $dep['name'] : '',
$_deps_rel_trans[$dep['rel']],
isset ($dep['version']) ? $dep['version'] : ''
$dependencies = $ptpl . $dependencies;
if (!isset ($old_index)) {
$current_index = $name{0 };
$packages .= '<a id="' . $current_index . $anchor_suffix
$old_index = $current_index;
$index[] = $current_index;
// prepare package informations template
<h2><a id="pkg_{package}">{package}</a></h2>
trim($installed['package']),
trim($installed['channel']),
trim($installed['current_release']),
trim($installed['license']),
if (!empty ($dependencies)) {
if (isset ($latest[$installed['package']])) {
$latestInstalledPkg = $latest[$installed['package']];
$installed['version'], '>')) {
<a href="http://{channel}/get/{package}">{latest_version}</a>({latest_state})
array (trim($installed['package']),
$latestInstalledPkg['version'],
$latestInstalledPkg['state'],
$packagexml = $installed['packagexml'];
if (isset ($installed['packagerversion'])) {
$packagexml .= ' packaged with PEAR version '
. $installed['packagerversion'];
date('Y-m-d', $installed['lastmodified']),
<td colspan="2" class="v"><a href="#{top}">Top</a></td>
$packages = str_replace('{top}', 'top'. $anchor_suffix, $packages);
<h2><a id="{top}">Installed Packages, Channel {channel}</a></h2>
<td class ="v" style="text-align: center">
$index_header = str_replace(array ('{channel}', '{top}'),
array ($channel, 'top'. $anchor_suffix), $index_header);
$index_header .= ' | <a href="#'. $i. $anchor_suffix. '">'
$s .= $index_header . $packages;
* Retrieves and formats the PEAR Config data
* @since version 1.0.1 (2003-04-24)
$keys = $this->config->getKeys ();
<h2>PEAR Configuration</h2>
foreach ($keys as $key) {
if ( ($key != 'password')
&& ($key != 'http_proxy')) {
array ($key, $this->config->get ($key)),
$html_pear_config .= $html_config;
return $html_pear_config;
* Retrieves and formats the PEAR Channel data
* @since version 1.7.0RC1 (2007-07-01)
$channels = $this->reg->listChannels ();
if (PEAR ::isError ($channels)) {
$e = '<p class="error">An Error occured while fetching the channel list.'
. ' Please try again.</p>';
$channel_allowed = $this->options ['channels'];
foreach ($channels as $channel) {
if (!in_array($channel, $channel_allowed)) {
$info = $this->reg->channelInfo ($channel);
if (PEAR ::isError ($info) || is_null($info)) {
$e = '<p class="error">An Error occured while fetching '
. $channel . ' channel data.'
. ' Please try again.</p>';
$data = array ('name' => $info['name']);
if (isset ($info['suggestedalias'])) {
$data['alias'] = $info['suggestedalias'];
$data['summary'] = $info['summary'];
foreach ($data as $key => $value) {
$value = '<a href="#top' . $anchor_suffix . '">'
$html_pear_channel .= $html_channel;
return $html_pear_channel;
* Retrieves and formats the PEAR Credits
* @since version 1.0.1 (2003-04-24)
$html_pear_credits = '<h1>PEAR Credits</h1>';
isset ($_GET['credits'])) {
foreach ($teams['president'] as $handle => $name) {
= '<a href="http://pear.php.net/account-info.php?handle='
. $handle . '">'. $name . '</a>,';
$html_member, $html_pear_credits);
foreach ($teams['group'] as $handle => $name) {
= '<a href="http://pear.php.net/account-info.php?handle='
. $handle . '">'. $name . '</a>,';
$html_pear_credits .= $html_member;
isset ($_GET['credits'])) {
if (count($teams['docs']) > 0 ) {
foreach ($teams['docs'] as $handle => $name) {
= '<a href="http://pear.php.net/account-info.php?handle='
. $handle . '">'. $name . '</a>,';
$html_pear_credits .= $html_member;
isset ($_GET['credits'])) {
if (count($teams['website']) > 0 ) {
foreach ($teams['website'] as $handle => $name) {
= '<a href="http://pear.php.net/account-info.php?handle='
. $handle . '">'. $name . '</a>,';
$html_pear_credits .= $html_member;
!isset ($_GET['credits'])) {
return $html_pear_credits;
// Credits authors of packages group by channels
$channel_allowed = $this->options ['channels'];
$available = $this->reg->listAllPackages ();
if (PEAR ::isError ($available)) {
$e = '<p class="error">An Error occured while fetching the credits'
. ' from the remote server. Please try again.</p>';
$e = '<p class="error">The credits could not be fetched'
. ' from the remote server. Please try again.</p>';
foreach ($available as $channel => $pkg) {
if (!in_array($channel, $channel_allowed)) {
<table border="0" cellpadding="3" width="600">
<tr class="hc"><td colspan="2">Channel {channel}</td></tr>
<tr class="h"><td>Package</td><td>Maintainers</td></tr>';
$html_pear_credits = str_replace('{channel}', $channel,
// sort package by alphabetic order
foreach ($pkg as $name) {
$info = &$this->reg->getPackage ($name, $channel);
$installed['package'] = $info->getPackage ();
$installed['maintainers'] = $info->getMaintainers ();
<a href="http://{channel}/{packageURI}">{package}</a>
foreach ($installed['maintainers'] as $i) {
= '<a href="http://pear.php.net/account-info.php?handle='
. (isset ($i['active']) && $i['active'] === 'no'
$maintainers = implode(', ', $maintainers);
$html_pear_credits .= str_replace(array ('{packageURI}',
trim($installed['package']),
return $html_pear_credits;
* Display the PEAR logo (gif image) on browser output
* @since version 1.0.1 (2003-04-24)
= 'R0lGODlhaAAyAMT/AMDAwP3+/TWaAvD47Pj89vz++zebBDmcBj6fDEek'
. 'FluvKmu3PvX68ujz4XvBS8LgrNXqxeHw1ZnPaa/dgvv9+cLqj8LmltD2msnuls'
. '3xmszwmf7+/f///wAAAAAAAAAAACH5BAEAAAAALAAAAABoADIAQAX/IC'
. 'COZGmeaKqubOtWWjwJphLLgH1XUu//C1Jisfj9YLEKQnSY3GaixWQqQTkYHM4'
. 'AMulNLJFC9pEwIW/odKU8cqTfsWoTTtcomU4ZjbR4ZP+AgYKCG0EiZ1A'
. 'uiossEhwEXRMEg5SVWQ6MmZqKWD0QlqCUEHubpaYlExwRPRZioZZVp7KzKQoS'
. 'DxANDLsNXA5simd2FcQYb4YAc2jEU80TmAAIztPCMcjKdg4OEsZJmwIW'
. 'WQPQ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m80oHs1CAgMoBxzRq'
. 'vzs9CIKECC1JBp7enUpfXHApwVYNAfo16c4IrYPLVdSAJVob7IAtCBFQ'
. 'GHcs/RRdiUDPHA33oADEAIAOw==';
header('content-type: image/gif');
* Returns a members list depending of its category (group, docs, website)
* Retrieve the members list of PEAR group, PEAR doc team, or PEAR website team
* @param string $group (optional) Member list category.
* Either president, group, docs or website
* @param bool $sort (optional) Return a member list sorted
* @since version 1.7.0RC3 (2007-07-10)
'president' => array ('cellog' => 'Gregory Beaver'),
'davidc' => 'David Coallier',
'arnaud' => 'Arnaud Limbourg',
'jeichorn' => 'Joshua Eichorn',
'cweiske' => 'Christian Weiske',
'dufuz' => 'Helgi þormar',
'pmjones' => 'Paul M. Jones',
$list = $members[$group];
* Displays PEAR_Info output depending of style applied (style sheet).
* @since version 1.0.1 (2003-04-24)
* @deprecated use display() instead
* Displays PEAR_Info output
* Displays PEAR_Info output depending of style applied (style sheet).
* @since version 1.7.0RC1 (2007-07-01)
* Returns PEAR_Info output (html code)
* Returns html code. This code is XHTML 1.1 compliant since version 1.7.0
* A stand-alone HTML page will be printed only if PEAR_INFO_FULLPAGE
* @since version 1.7.0RC1 (2007-07-01)
* @see setStyleSheet(), getStyleSheet()
if (!isset ($this->css)) {
// when no user-styles defined, used the default values
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<title>PEAR :: PEAR_Info()</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
* Check if a package is installed
* Simple function to check if a package is installed under user
* or system PEAR installation. Minimal version and channel info are supported.
* @param string $name Package name
* @param string $version (optional) The minimal version
* that should be installed
* @param string $channel (optional) The package channel distribution
* @param string $user_file (optional) file to read PEAR user-defined
* @param string $system_file (optional) file to read PEAR system-wide
* @since version 1.6.0 (2005-01-03)
$user_file = '', $system_file = '')
$config = & PEAR_Config ::singleton ($user_file, $system_file);
$reg = & $config->getRegistry ();
return $reg->packageExists ($name, $channel);
$info = &$reg->getPackage ($name, $channel);
$installed['version'] = $info->getVersion ();
if (isset ($_GET['pear_image'])) {
Documentation generated on Fri, 18 Apr 2008 16:30:08 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.
|