Example #1
0
/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP version 4                                                        |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group                                |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available at through the world-wide-web at                           |
// | http://www.php.net/license/2_02.txt.                                 |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to          |
// | license@php.net so we can mail you a copy immediately.               |
// +----------------------------------------------------------------------+
// | Authors: Davey Shafik <*****@*****.**>                   |
// +----------------------------------------------------------------------+
//
// $Id: pear_info.php,v 1.5 2003/05/12 11:40:57 davey Exp $
/* May be required on slower (dial-up) connections
ini_set('default_socket_timeout',600);
ini_set('max_execution_time',600);
ini_set('max_input_time',600); */
// require the PEAR_Info file
require_once 'PEAR/Info.php';
// If you need to set a http_proxy uncomment the line below
// PEAR_Info::setProxy('your.proxy.here');
// Create PEAR_Info object
$info = new PEAR_Info();
// Display PEAR_Info output
$info->show();
Example #2
0
 /**
  * ZE2 Constructor
  *
  * @since  1.8.0
  */
 function __construct()
 {
     $this->opts = array('php-dir' => array('short' => 'pd', 'desc' => 'PEAR directory', 'default' => '', 'min' => 0, 'max' => 1), 'usr-cfg' => array('short' => 'uc', 'desc' => 'User Configuration File', 'default' => '', 'min' => 0, 'max' => 1), 'sys-cfg' => array('short' => 'sc', 'desc' => 'System Configuration File', 'default' => '', 'min' => 0, 'max' => 1), 'http-proxy' => array('short' => 'hp', 'desc' => 'HTTP Proxy Server Address', 'default' => '', 'min' => 0, 'max' => 1), 'all' => array('short' => 'a', 'desc' => 'Display informations for installed packages', 'default' => PEAR_INFO_ALL, 'min' => 0, 'max' => 1), 'allchannels' => array('short' => 'A', 'desc' => 'List packages from all channels, ' . 'not just the default one', 'max' => 0), 'channel' => array('short' => 'c', 'desc' => 'Specify which channel', 'default' => '', 'min' => 0, 'max' => 1), 'version' => array('short' => 'V', 'desc' => 'Print version information', 'max' => 0), 'help' => array('short' => 'h', 'desc' => 'Show this help', 'max' => 0));
     $this->args =& Console_Getargs::factory($this->opts);
     if (PEAR::isError($this->args)) {
         if ($this->args->getCode() === CONSOLE_GETARGS_HELP) {
             $this->error = '';
         } else {
             $this->error = $this->args->getMessage();
         }
         return;
     }
     $options = array('channels' => array('pear.php.net'), 'resume' => PEAR_INFO_ALL);
     // php-dir
     if ($this->args->isDefined('pd')) {
         $pear_dir = $this->args->getValue('pd');
     } else {
         $pear_dir = '';
     }
     // usr-cfg
     if ($this->args->isDefined('uc')) {
         $user_file = $this->args->getValue('uc');
         if (!file_exists($user_file)) {
             $this->error = 'Failed opening PEAR user configuration file "' . $user_file . '". Please check your spelling and try again.';
             return;
         }
     } else {
         $user_file = '';
     }
     // sys-cfg
     if ($this->args->isDefined('sc')) {
         $system_file = $this->args->getValue('sc');
         if (!file_exists($system_file)) {
             $this->error = 'Failed opening PEAR system configuration file "' . $system_file . '". Please check your spelling and try again.';
             return;
         }
     } else {
         $system_file = '';
     }
     // http-proxy
     if ($this->args->isDefined('hp')) {
         $proxy = $this->args->getValue('hp');
         $res = PEAR_Info::setProxy($proxy);
         if ($res === false) {
             $this->error = 'Failed define Proxy Server Address.' . ' Please check your spelling and try again.';
             return;
         }
     }
     // all
     if ($this->args->isDefined('a')) {
         $a = $this->args->getValue('a');
         if (is_numeric($a)) {
             $options['resume'] = intval($a);
         } else {
             $this->error = "No valid 'resume' option for argument all." . ' Please check your spelling and try again.';
             return;
         }
     }
     // allchannels
     $A = $this->args->getValue('A');
     if (isset($A)) {
         $options['channels'] = array();
     }
     // channel
     if ($this->args->isDefined('c')) {
         $chan = $this->args->getValue('c');
         if (is_string($chan)) {
             $options['channels'] = explode(',', $chan);
         } else {
             $this->error = 'No valid channel list provided.' . ' Please check your spelling and try again.';
             return;
         }
     }
     // version
     $V = $this->args->getValue('V');
     if (isset($V)) {
         $this->error = 'PEAR_Info (cli) version 1.9.2' . ' (http://pear.php.net/package/PEAR_Info)';
         return;
     }
     parent::__construct($pear_dir, $user_file, $system_file, $options);
 }
<?php

/**
 * Generate phpinfo() style PEAR information, with a custom blue skin
 *
 * PHP versions 4 and 5
 *
 * @category PEAR
 * @package  PEAR_Info
 * @author   Laurent Laville <*****@*****.**>
 * @license  http://www.php.net/license/3_01.txt  PHP License 3.01
 * @version  CVS: $Id: pear_info2.php,v 1.2 2007/12/15 16:27:23 farell Exp $
 * @link     http://pear.php.net/package/PEAR_Info
 * @ignore
 */
// require the PEAR_Info file
require_once 'PEAR/Info.php';
// Create PEAR_Info object
$info = new PEAR_Info();
// set your own styles, rather than use the default stylesheet
$info->setStyleSheet(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'blueskin.css');
// Display PEAR_Info output
$info->display();
<?php

set_time_limit(0);
require_once 'PEAR/Info.php';
$info = new PEAR_Info('', '', '', array('channels' => array('pear.php.net', 'zend.googlecode.com/svn')));
$info->display();
Example #5
0
    /**
     * Retrieves and formats the PEAR Credits
     *
     * @return string
     * @access private
     * @since  version 1.0.1 (2003-04-24)
     */
    function getCredits()
    {
        $html_pear_credits = '<h1>PEAR Credits</h1>';
        $teams = PEAR_Info::getMembers();
        if ($this->options['resume'] & PEAR_INFO_CREDITS_GROUP || isset($_GET['credits'])) {
            $html_pear_credits .= '
<table>
    <tr class="hc">
        <td colspan="2">
            PEAR Group
        </td>
    </tr>
    <tr class="v">
        <td class="e">
            President
        </td>
        <td>
            {president}
        </td>
    </tr>
    <tr class="v">
        <td colspan="2">
';
            foreach ($teams['president'] as $handle => $name) {
                $html_member = '<a href="http://pear.php.net/account-info.php?handle=' . $handle . '">' . $name . '</a>,';
                $html_pear_credits = str_replace('{president}', $html_member, $html_pear_credits);
            }
            foreach ($teams['group'] as $handle => $name) {
                $html_member = '<a href="http://pear.php.net/account-info.php?handle=' . $handle . '">' . $name . '</a>,';
                $html_pear_credits .= $html_member;
            }
            $html_pear_credits .= '
        </td>
    </tr>
</table>
<br />
';
        }
        if ($this->options['resume'] & PEAR_INFO_CREDITS_DOCS || isset($_GET['credits'])) {
            if (count($teams['docs']) > 0) {
                $html_pear_credits .= '
<table>
    <tr class="hc">
        <td>
            PEAR Documentation Team
        </td>
    </tr>
    <tr class="v">
        <td>
';
                foreach ($teams['docs'] as $handle => $name) {
                    $html_member = '<a href="http://pear.php.net/account-info.php?handle=' . $handle . '">' . $name . '</a>,';
                    $html_pear_credits .= $html_member;
                }
                $html_pear_credits .= '
        </td>
    </tr>
</table>
<br />
';
            }
        }
        if ($this->options['resume'] & PEAR_INFO_CREDITS_WEBSITE || isset($_GET['credits'])) {
            if (count($teams['website']) > 0) {
                $html_pear_credits .= '
<table>
    <tr class="hc">
        <td>
            PEAR Website Team
        </td>
    </tr>
    <tr class="v">
        <td>
';
                foreach ($teams['website'] as $handle => $name) {
                    $html_member = '<a href="http://pear.php.net/account-info.php?handle=' . $handle . '">' . $name . '</a>,';
                    $html_pear_credits .= $html_member;
                }
                $html_pear_credits .= '
        </td>
    </tr>
</table>
<br />
';
            }
        }
        if (!($this->options['resume'] & PEAR_INFO_CREDITS_PACKAGES) && !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>';
            return $e;
        }
        if (!is_array($available)) {
            $e = '<p class="error">The credits could not be fetched' . ' from the remote server. Please try again.</p>';
            return $e;
        }
        foreach ($available as $channel => $pkg) {
            if (!in_array($channel, $channel_allowed)) {
                continue;
            }
            if (count($pkg) == 0) {
                // improve render and did not display channel without package
                continue;
            }
            $html_pear_credits .= '
<br />
<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, $html_pear_credits);
            // sort package by alphabetic order
            sort($pkg);
            //
            foreach ($pkg as $name) {
                $info =& $this->reg->getPackage($name, $channel);
                if (is_object($info)) {
                    $installed['package'] = $info->getPackage();
                    $installed['maintainers'] = $info->getMaintainers();
                } else {
                    $installed = $info;
                }
                $ptpl = '
<tr>
    <td class="e">
        <a href="http://{channel}/{packageURI}">{package}</a>
    </td>
    <td class="v">
        {maintainers}
    </td>
</tr>';
                $maintainers = array();
                foreach ($installed['maintainers'] as $i) {
                    $maintainers[] = '<a href="http://pear.php.net/account-info.php?handle=' . $i['handle'] . '">' . htmlentities(html_entity_decode(utf8_decode($i['name']))) . '</a>' . ' (' . $i['role'] . (isset($i['active']) && $i['active'] === 'no' ? ', inactive' : '') . ')';
                }
                $maintainers = implode(', ', $maintainers);
                $html_pear_credits .= str_replace(array('{packageURI}', '{package}', '{channel}', '{maintainers}'), array(trim(strtolower($installed['package'])), trim($installed['package']), $channel, $maintainers), $ptpl);
            }
            $html_pear_credits .= '
</table>
';
        }
        return $html_pear_credits;
    }
Example #6
0
     * Shows PEAR_Info output
     * @return void
     * @access public
     */
    function show()
    {
        echo $this->info;
    }
    /**
     * Check if a package is installed
     */
    function packageInstalled($package_name, $version = null, $pear_user_config = null)
    {
        if (is_null($pear_user_config)) {
            $config = new PEAR_Config();
        } else {
            $config = new PEAR_Config($pear_user_config);
        }
        $reg = new PEAR_Registry($config->get('php_dir'));
        if (is_null($version)) {
            return $reg->packageExists($package_name);
        } else {
            $installed = $reg->packageInfo($package_name);
            return version_compare($version, $installed['version'], '<=');
        }
    }
}
if (isset($_GET['pear_image'])) {
    PEAR_Info::pearImage();
    exit;
}
<?php

/**
 * Check packages installed
 *
 * PHP versions 4 and 5
 *
 * @category PEAR
 * @package  PEAR_Info
 * @author   Laurent Laville <*****@*****.**>
 * @license  http://www.php.net/license/3_01.txt  PHP License 3.01
 * @version  CVS: $Id: pear_info4.php,v 1.2 2007/12/15 16:27:23 farell Exp $
 * @link     http://pear.php.net/package/PEAR_Info
 * @ignore
 */
// require the PEAR_Info file
require_once 'PEAR/Info.php';
$res = PEAR_Info::packageInstalled('Role_Web', '1.1.0', 'pearified');
var_dump($res);
$res = PEAR_Info::packageInstalled('PEAR_PackageFileManager', '1.6.0');
var_dump($res);