related issues.
Happy PHPing, we hope PEAR will be a great tool for your development work!
-
-$Id: INSTALL 313023 2011-07-06 19:17:11Z dufuz $
\ No newline at end of file
<?php
/**
- * PEAR's Mail:: interface.
+ * PEAR's Mail:: interface.
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @copyright 1997-2010 Chuck Hagenbuch
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Mail.php 294747 2010-02-08 08:18:33Z clockwerx $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/
*/
* mailers under the PEAR hierarchy, and provides supporting functions
* useful in multiple mailer backends.
*
- * @access public
- * @version $Revision: 294747 $
+ * @version $Revision$
* @package Mail
*/
class Mail
* Line terminator used for separating header lines.
* @var string
*/
- var $sep = "\r\n";
+ public $sep = "\r\n";
/**
* Provides an interface for generating Mail:: objects of various
*
* @param string $driver The kind of Mail:: object to instantiate.
* @param array $params The parameters to pass to the Mail:: object.
+ *
* @return object Mail a instance of the driver class or if fails a PEAR Error
- * @access public
*/
- function &factory($driver, $params = array())
+ public static function factory($driver, $params = array())
{
$driver = strtolower($driver);
@include_once 'Mail/' . $driver . '.php';
* containing a descriptive error message on
* failure.
*
- * @access public
* @deprecated use Mail_mail::send instead
*/
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
{
if (!is_array($headers)) {
return PEAR::raiseError('$headers must be an array');
* filter is to prevent mail injection attacks.
*
* @param array $headers The associative array of headers to sanitize.
- *
- * @access private
*/
- function _sanitizeHeaders(&$headers)
+ protected function _sanitizeHeaders(&$headers)
{
foreach ($headers as $key => $value) {
$headers[$key] =
* otherwise returns an array containing two
* elements: Any From: address found in the headers,
* and the plain text version of the headers.
- * @access private
*/
- function prepareHeaders($headers)
+ protected function prepareHeaders($headers)
{
$lines = array();
$from = null;
*
* @return mixed An array of forward paths (bare addresses) or a PEAR_Error
* object if the address list could not be parsed.
- * @access private
*/
- function parseRecipients($recipients)
+ protected function parseRecipients($recipients)
{
include_once 'Mail/RFC822.php';
// Parse recipients, leaving out all personal info. This is
// for smtp recipients, etc. All relevant personal information
// should already be in the headers.
- $addresses = Mail_RFC822::parseAddressList($recipients, 'localhost', false);
+ $Mail_RFC822 = new Mail_RFC822();
+ $addresses = $Mail_RFC822->parseAddressList($recipients, 'localhost', false);
// If parseAddressList() returned a PEAR_Error object, just return it.
if (is_a($addresses, 'PEAR_Error')) {
/**
* RFC 822 Email address list validation Utility
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
* @author Chuck Hagenbuch <chuck@horde.org
* @copyright 2001-2010 Richard Heyes
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: RFC822.php 294749 2010-02-08 08:22:25Z clockwerx $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/
*/
*
* @author Richard Heyes <richard@phpguru.org>
* @author Chuck Hagenbuch <chuck@horde.org>
- * @version $Revision: 294749 $
+ * @version $Revision$
* @license BSD
* @package Mail
*/
* Sets up the object. The address must either be set here or when
* calling parseAddressList(). One or the other.
*
- * @access public
* @param string $address The address(es) to validate.
* @param string $default_domain Default domain/host etc. If not supplied, will be set to localhost.
* @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing.
*
* @return object Mail_RFC822 A new Mail_RFC822 object.
*/
- function Mail_RFC822($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
+ public function __construct($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
{
if (isset($address)) $this->address = $address;
if (isset($default_domain)) $this->default_domain = $default_domain;
* Starts the whole process. The address must either be set here
* or when creating the object. One or the other.
*
- * @access public
* @param string $address The address(es) to validate.
* @param string $default_domain Default domain/host etc.
* @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing.
*
* @return array A structured array of addresses.
*/
- function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
+ public function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
{
if (!isset($this) || !isset($this->mailRFC822)) {
$obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit);
/**
* Splits an address into separate addresses.
*
- * @access private
* @param string $address The addresses to split.
* @return boolean Success or failure.
*/
- function _splitAddresses($address)
+ protected function _splitAddresses($address)
{
if (!empty($this->limit) && count($this->addresses) == $this->limit) {
return '';
/**
* Checks for a group at the start of the string.
*
- * @access private
* @param string $address The address to check.
* @return boolean Whether or not there is a group at the start of the string.
*/
- function _isGroup($address)
+ protected function _isGroup($address)
{
// First comma not in quotes, angles or escaped:
$parts = explode(',', $address);
/**
* A common function that will check an exploded string.
*
- * @access private
* @param array $parts The exloded string.
* @param string $char The char that was exploded on.
* @return mixed False if the string contains unclosed quotes/brackets, or the string on success.
*/
- function _splitCheck($parts, $char)
+ protected function _splitCheck($parts, $char)
{
$string = $parts[0];
/**
* Checks if a string has unclosed quotes or not.
*
- * @access private
* @param string $string The string to check.
* @return boolean True if there are unclosed quotes inside the string,
* false otherwise.
*/
- function _hasUnclosedQuotes($string)
+ protected function _hasUnclosedQuotes($string)
{
$string = trim($string);
$iMax = strlen($string);
* Checks if a string has an unclosed brackets or not. IMPORTANT:
* This function handles both angle brackets and square brackets;
*
- * @access private
* @param string $string The string to check.
* @param string $chars The characters to check for.
* @return boolean True if there are unclosed brackets inside the string, false otherwise.
*/
- function _hasUnclosedBrackets($string, $chars)
+ protected function _hasUnclosedBrackets($string, $chars)
{
$num_angle_start = substr_count($string, $chars[0]);
$num_angle_end = substr_count($string, $chars[1]);
/**
* Sub function that is used only by hasUnclosedBrackets().
*
- * @access private
* @param string $string The string to check.
* @param integer &$num The number of occurences.
* @param string $char The character to count.
* @return integer The number of occurences of $char in $string, adjusted for backslashes.
*/
- function _hasUnclosedBracketsSub($string, &$num, $char)
+ protected function _hasUnclosedBracketsSub($string, &$num, $char)
{
$parts = explode($char, $string);
for ($i = 0; $i < count($parts); $i++){
/**
* Function to begin checking the address.
*
- * @access private
* @param string $address The address to validate.
* @return mixed False on failure, or a structured array of address information on success.
*/
- function _validateAddress($address)
+ protected function _validateAddress($address)
{
$is_group = false;
$addresses = array();
$addresses[] = $address['address'];
}
- // Check that $addresses is set, if address like this:
- // Groupname:;
- // Then errors were appearing.
- if (!count($addresses)){
- $this->error = 'Empty group.';
- return false;
- }
-
// Trim the whitespace from all of the address strings.
array_map('trim', $addresses);
/**
* Function to validate a phrase.
*
- * @access private
* @param string $phrase The phrase to check.
* @return boolean Success or failure.
*/
- function _validatePhrase($phrase)
+ protected function _validatePhrase($phrase)
{
// Splits on one or more Tab or space.
$parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY);
* can split a list of addresses up before encoding personal names
* (umlauts, etc.), for example.
*
- * @access private
* @param string $atom The string to check.
* @return boolean Success or failure.
*/
- function _validateAtom($atom)
+ protected function _validateAtom($atom)
{
if (!$this->validate) {
// Validation has been turned off; assume the atom is okay.
* Function to validate quoted string, which is:
* quoted-string = <"> *(qtext/quoted-pair) <">
*
- * @access private
* @param string $qstring The string to check
* @return boolean Success or failure.
*/
- function _validateQuotedString($qstring)
+ protected function _validateQuotedString($qstring)
{
// Leading and trailing "
$qstring = substr($qstring, 1, -1);
* mailbox = addr-spec ; simple address
* / phrase route-addr ; name and route-addr
*
- * @access public
* @param string &$mailbox The string to check.
* @return boolean Success or failure.
*/
- function validateMailbox(&$mailbox)
+ public function validateMailbox(&$mailbox)
{
// A couple of defaults.
$phrase = '';
* Angle brackets have already been removed at the point of
* getting to this function.
*
- * @access private
* @param string $route_addr The string to check.
* @return mixed False on failure, or an array containing validated address/route information on success.
*/
- function _validateRouteAddr($route_addr)
+ protected function _validateRouteAddr($route_addr)
{
// Check for colon.
if (strpos($route_addr, ':') !== false) {
* Function to validate a route, which is:
* route = 1#("@" domain) ":"
*
- * @access private
* @param string $route The string to check.
* @return mixed False on failure, or the validated $route on success.
*/
- function _validateRoute($route)
+ protected function _validateRoute($route)
{
// Split on comma.
$domains = explode(',', trim($route));
*
* domain = sub-domain *("." sub-domain)
*
- * @access private
* @param string $domain The string to check.
* @return mixed False on failure, or the validated domain on success.
*/
- function _validateDomain($domain)
+ protected function _validateDomain($domain)
{
// Note the different use of $subdomains and $sub_domains
$subdomains = explode('.', $domain);
* Function to validate a subdomain:
* subdomain = domain-ref / domain-literal
*
- * @access private
* @param string $subdomain The string to check.
* @return boolean Success or failure.
*/
- function _validateSubdomain($subdomain)
+ protected function _validateSubdomain($subdomain)
{
if (preg_match('|^\[(.*)]$|', $subdomain, $arr)){
if (!$this->_validateDliteral($arr[1])) return false;
* Function to validate a domain literal:
* domain-literal = "[" *(dtext / quoted-pair) "]"
*
- * @access private
* @param string $dliteral The string to check.
* @return boolean Success or failure.
*/
- function _validateDliteral($dliteral)
+ protected function _validateDliteral($dliteral)
{
return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) && $matches[1] != '\\';
}
*
* addr-spec = local-part "@" domain
*
- * @access private
* @param string $addr_spec The string to check.
* @return mixed False on failure, or the validated addr-spec on success.
*/
- function _validateAddrSpec($addr_spec)
+ protected function _validateAddrSpec($addr_spec)
{
$addr_spec = trim($addr_spec);
* Function to validate the local part of an address:
* local-part = word *("." word)
*
- * @access private
* @param string $local_part
* @return mixed False on failure, or the validated local part on success.
*/
- function _validateLocalPart($local_part)
+ protected function _validateLocalPart($local_part)
{
$parts = explode('.', $local_part);
$words = array();
// Split the local_part into words.
- while (count($parts) > 0){
+ while (count($parts) > 0) {
$words[] = $this->_splitCheck($parts, '.');
for ($i = 0; $i < $this->index + 1; $i++) {
array_shift($parts);
// Validate each word.
foreach ($words as $word) {
+ // word cannot be empty (#17317)
+ if ($word === '') {
+ return false;
+ }
// If this word contains an unquoted space, it is invalid. (6.2.4)
if (strpos($word, ' ') && $word[0] !== '"')
{
* @param string $data Addresses to count
* @return int Approximate count
*/
- function approximateCount($data)
+ public function approximateCount($data)
{
return count(preg_split('/(?<!\\\\),/', $data));
}
* @return mixed False if it fails, an indexed array
* username/domain if it matches
*/
- function isValidInetAddress($data, $strict = false)
+ public function isValidInetAddress($data, $strict = false)
{
$regex = $strict ? '/^([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})$/i' : '/^([*+!.&#$|\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})$/i';
if (preg_match($regex, trim($data), $matches)) {
/**
* internal PHP-mail() implementation of the PEAR Mail:: interface.
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @copyright 2010 Chuck Hagenbuch
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: mail.php 294747 2010-02-08 08:18:33Z clockwerx $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/
*/
/**
* internal PHP-mail() implementation of the PEAR Mail:: interface.
* @package Mail
- * @version $Revision: 294747 $
+ * @version $Revision$
*/
class Mail_mail extends Mail {
*
* @param array $params Extra arguments for the mail() function.
*/
- function Mail_mail($params = null)
+ public function __construct($params = null)
{
// The other mail implementations accept parameters as arrays.
// In the interest of being consistent, explode an array into
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
- *
- * @access public
*/
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
{
if (!is_array($headers)) {
return PEAR::raiseError('$headers must be an array');
/**
* Mock implementation
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @copyright 2010 Chuck Hagenbuch
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: mock.php 294747 2010-02-08 08:18:33Z clockwerx $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/
*/
* Mock implementation of the PEAR Mail:: interface for testing.
* @access public
* @package Mail
- * @version $Revision: 294747 $
+ * @version $Revision$
*/
class Mail_mock extends Mail {
* Array of messages that have been sent with the mock.
*
* @var array
- * @access public
*/
- var $sentMessages = array();
+ public $sentMessages = array();
/**
* Callback before sending mail.
*
* @var callback
*/
- var $_preSendCallback;
+ protected $_preSendCallback;
/**
* Callback after sending mai.
*
* @var callback
*/
- var $_postSendCallback;
+ protected $_postSendCallback;
/**
* Constructor.
* postSendCallback Called after an email would have been sent.
*
* @param array Hash containing any parameters.
- * @access public
*/
- function Mail_mock($params)
+ public function __construct($params)
{
if (isset($params['preSendCallback']) &&
is_callable($params['preSendCallback'])) {
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
- * @access public
*/
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
{
if ($this->_preSendCallback) {
call_user_func_array($this->_preSendCallback,
/**
* Null implementation of the PEAR Mail interface
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
* @author Phil Kernick <philk@rotfl.com.au>
* @copyright 2010 Phil Kernick
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: null.php 294747 2010-02-08 08:18:33Z clockwerx $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/
*/
* Null implementation of the PEAR Mail:: interface.
* @access public
* @package Mail
- * @version $Revision: 294747 $
+ * @version $Revision$
*/
class Mail_null extends Mail {
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
- * @access public
*/
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
{
return true;
}
<?php
//
// +----------------------------------------------------------------------+
-// | PHP Version 4 |
+// | PHP Version 5 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
* Sendmail implementation of the PEAR Mail:: interface.
* @access public
* @package Mail
- * @version $Revision: 294744 $
+ * @version $Revision$
*/
class Mail_sendmail extends Mail {
*
* @param array $params Hash containing any parameters different from the
* defaults.
- * @access public
*/
- function Mail_sendmail($params)
+ public function __construct($params)
{
if (isset($params['sendmail_path'])) {
$this->sendmail_path = $params['sendmail_path'];
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
- * @access public
*/
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
{
if (!is_array($headers)) {
return PEAR::raiseError('$headers must be an array');
/**
* SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class.
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @copyright 2010 Chuck Hagenbuch
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: smtp.php 294747 2010-02-08 08:18:33Z clockwerx $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/
*/
* SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class.
* @access public
* @package Mail
- * @version $Revision: 294747 $
+ * @version $Revision$
*/
class Mail_smtp extends Mail {
* @var bool
*/
var $pipelining;
+
+ var $socket_options = array();
/**
* Constructor.
*
* @param array Hash containing any parameters different from the
* defaults.
- * @access public
*/
- function Mail_smtp($params)
+ public function __construct($params)
{
if (isset($params['host'])) $this->host = $params['host'];
if (isset($params['port'])) $this->port = $params['port'];
if (isset($params['debug'])) $this->debug = (bool)$params['debug'];
if (isset($params['persist'])) $this->persist = (bool)$params['persist'];
if (isset($params['pipelining'])) $this->pipelining = (bool)$params['pipelining'];
-
+ if (isset($params['socket_options'])) $this->socket_options = $params['socket_options'];
// Deprecated options
if (isset($params['verp'])) {
$this->addServiceExtensionParameter('XVERP', is_bool($params['verp']) ? null : $params['verp']);
}
-
- register_shutdown_function(array(&$this, '_Mail_smtp'));
}
/**
* Destructor implementation to ensure that we disconnect from any
* potentially-alive persistent SMTP connections.
*/
- function _Mail_smtp()
+ public function __destruct()
{
$this->disconnect();
}
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
- * @access public
*/
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
{
/* If we don't already have an SMTP object, create one. */
- $result = &$this->getSMTPObject();
+ $result = $this->getSMTPObject();
if (PEAR::isError($result)) {
return $result;
}
}
/* Send the message's headers and the body as SMTP data. */
- $res = $this->_smtp->data($textHeaders . "\r\n\r\n" . $body);
+ $res = $this->_smtp->data($body, $textHeaders);
list(,$args) = $this->_smtp->getResponse();
if (preg_match("/Ok: queued as (.*)/", $args, $queued)) {
* failure.
*
* @since 1.2.0
- * @access public
*/
- function &getSMTPObject()
+ public function getSMTPObject()
{
if (is_object($this->_smtp) !== false) {
return $this->_smtp;
}
include_once 'Net/SMTP.php';
- $this->_smtp = &new Net_SMTP($this->host,
+ $this->_smtp = new Net_SMTP($this->host,
$this->port,
- $this->localhost);
+ $this->localhost,
+ $this->pipelining,
+ 0,
+ $this->socket_options);
/* If we still don't have an SMTP object at this point, fail. */
if (is_object($this->_smtp) === false) {
* @param string Any value the keyword needs.
*
* @since 1.2.0
- * @access public
*/
- function addServiceExtensionParameter($keyword, $value = null)
+ public function addServiceExtensionParameter($keyword, $value = null)
{
$this->_extparams[$keyword] = $value;
}
* @return boolean True if the SMTP connection no longer exists.
*
* @since 1.1.9
- * @access public
*/
- function disconnect()
+ public function disconnect()
{
/* If we have an SMTP object, disconnect and destroy it. */
if (is_object($this->_smtp) && $this->_smtp->disconnect()) {
* @return string A string describing the current SMTP error.
*
* @since 1.1.7
- * @access private
*/
- function _error($text, &$error)
+ protected function _error($text, $error)
{
/* Split the SMTP response into a code and a response string. */
list($code, $response) = $this->_smtp->getResponse();
-<?PHP
+<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
*
* SMTP MX implementation of the PEAR Mail interface. Requires the Net_SMTP class.
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
* @author gERD Schaufelberger <gerd@php-tools.net>
* @copyright 2010 gERD Schaufelberger
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: smtpmx.php 294747 2010-02-08 08:18:33Z clockwerx $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/
*/
* @access public
* @author gERD Schaufelberger <gerd@php-tools.net>
* @package Mail
- * @version $Revision: 294747 $
+ * @version $Revision$
*/
class Mail_smtpmx extends Mail {
}
// Send data
- $res = $this->_smtp->data("$textHeaders\r\n$body");
+ $res = $this->_smtp->data($body, $textHeaders);
if (is_a($res, 'PEAR_Error')) {
$info = array('rcpt' => $rcpt);
return $this->_raiseError('failed_send_data', $info);
<?php
-/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
+/** vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
-// | PHP Version 4 |
+// | PHP Version 5 and 7 |
// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2003 The PHP Group |
+// | Copyright (c) 1997-2015 Jon Parise and Chuck Hagenbuch |
// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license, |
+// | This source file is subject to version 3.01 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. |
+// | 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 world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// | Jon Parise <jon@php.net> |
// | Damian Alejandro Fernandez Sosa <damlists@cnba.uba.ar> |
// +----------------------------------------------------------------------+
-//
-// $Id: SMTP.php 293948 2010-01-24 21:46:00Z jon $
require_once 'PEAR.php';
require_once 'Net/Socket.php';
/**
* Provides an implementation of the SMTP protocol using PEAR's
- * Net_Socket:: class.
+ * Net_Socket class.
*
* @package Net_SMTP
* @author Chuck Hagenbuch <chuck@horde.org>
* @author Jon Parise <jon@php.net>
* @author Damian Alejandro Fernandez Sosa <damlists@cnba.uba.ar>
*
- * @example basic.php A basic implementation of the Net_SMTP package.
+ * @example basic.php A basic implementation of the Net_SMTP package.
*/
class Net_SMTP
{
/**
* The server to connect to.
* @var string
- * @access public
*/
- var $host = 'localhost';
+ public $host = 'localhost';
/**
* The port to connect to.
* @var int
- * @access public
*/
- var $port = 25;
+ public $port = 25;
/**
* The value to give when sending EHLO or HELO.
* @var string
- * @access public
*/
- var $localhost = 'localhost';
+ public $localhost = 'localhost';
/**
* List of supported authentication methods, in preferential order.
* @var array
- * @access public
*/
- var $auth_methods = array('DIGEST-MD5', 'CRAM-MD5', 'LOGIN', 'PLAIN');
+ public $auth_methods = array();
/**
* Use SMTP command pipelining (specified in RFC 2920) if the SMTP
* SMTP server but return immediately.
*
* @var bool
- * @access public
*/
- var $pipelining = false;
+ public $pipelining = false;
/**
* Number of pipelined commands.
* @var int
- * @access private
*/
- var $_pipelined_commands = 0;
+ protected $pipelined_commands = 0;
/**
* Should debugging output be enabled?
* @var boolean
- * @access private
*/
- var $_debug = false;
+ protected $debug = false;
/**
* Debug output handler.
* @var callback
- * @access private
*/
- var $_debug_handler = null;
+ protected $debug_handler = null;
/**
* The socket resource being used to connect to the SMTP server.
* @var resource
- * @access private
*/
- var $_socket = null;
+ protected $socket = null;
+
+ /**
+ * Array of socket options that will be passed to Net_Socket::connect().
+ * @see stream_context_create()
+ * @var array
+ */
+ protected $socket_options = null;
+
+ /**
+ * The socket I/O timeout value in seconds.
+ * @var int
+ */
+ protected $timeout = 0;
/**
* The most recent server response code.
* @var int
- * @access private
*/
- var $_code = -1;
+ protected $code = -1;
/**
* The most recent server response arguments.
* @var array
- * @access private
*/
- var $_arguments = array();
+ protected $arguments = array();
/**
* Stores the SMTP server's greeting string.
* @var string
- * @access private
*/
- var $_greeting = null;
+ protected $greeting = null;
/**
* Stores detected features of the SMTP server.
* @var array
- * @access private
*/
- var $_esmtp = array();
+ protected $esmtp = array();
/**
* Instantiates a new Net_SMTP object, overriding any defaults
* $smtp = new Net_SMTP('ssl://mail.host.com', 465);
* $smtp->connect();
*
- * @param string $host The server to connect to.
- * @param integer $port The port to connect to.
- * @param string $localhost The value to give when sending EHLO or HELO.
- * @param boolean $pipeling Use SMTP command pipelining
+ * @param string $host The server to connect to.
+ * @param integer $port The port to connect to.
+ * @param string $localhost The value to give when sending EHLO or HELO.
+ * @param boolean $pipelining Use SMTP command pipelining
+ * @param integer $timeout Socket I/O timeout in seconds.
+ * @param array $socket_options Socket stream_context_create() options.
*
- * @access public
- * @since 1.0
+ * @since 1.0
*/
- function Net_SMTP($host = null, $port = null, $localhost = null, $pipelining = false)
- {
+ public function __construct($host = null, $port = null, $localhost = null,
+ $pipelining = false, $timeout = 0, $socket_options = null
+ ) {
if (isset($host)) {
$this->host = $host;
}
if (isset($localhost)) {
$this->localhost = $localhost;
}
- $this->pipelining = $pipelining;
- $this->_socket = new Net_Socket();
+ $this->pipelining = $pipelining;
+ $this->socket = new Net_Socket();
+ $this->socket_options = $socket_options;
+ $this->timeout = $timeout;
- /* Include the Auth_SASL package. If the package is not
- * available, we disable the authentication methods that
- * depend upon it. */
- if ((@include_once 'Auth/SASL.php') === false) {
- $pos = array_search('DIGEST-MD5', $this->auth_methods);
- unset($this->auth_methods[$pos]);
- $pos = array_search('CRAM-MD5', $this->auth_methods);
- unset($this->auth_methods[$pos]);
+ /* Include the Auth_SASL package. If the package is available, we
+ * enable the authentication methods that depend upon it. */
+ if (@include_once 'Auth/SASL.php') {
+ $this->setAuthMethod('CRAM-MD5', array($this, 'authCramMD5'));
+ $this->setAuthMethod('DIGEST-MD5', array($this, 'authDigestMD5'));
}
+
+ /* These standard authentication methods are always available. */
+ $this->setAuthMethod('LOGIN', array($this, 'authLogin'), false);
+ $this->setAuthMethod('PLAIN', array($this, 'authPlain'), false);
+ }
+
+ /**
+ * Set the socket I/O timeout value in seconds plus microseconds.
+ *
+ * @param integer $seconds Timeout value in seconds.
+ * @param integer $microseconds Additional value in microseconds.
+ *
+ * @since 1.5.0
+ */
+ public function setTimeout($seconds, $microseconds = 0)
+ {
+ return $this->socket->setTimeout($seconds, $microseconds);
}
/**
* Set the value of the debugging flag.
*
- * @param boolean $debug New value for the debugging flag.
+ * @param boolean $debug New value for the debugging flag.
+ * @param callback $handler Debug handler callback
*
- * @access public
- * @since 1.1.0
+ * @since 1.1.0
*/
- function setDebug($debug, $handler = null)
+ public function setDebug($debug, $handler = null)
{
- $this->_debug = $debug;
- $this->_debug_handler = $handler;
+ $this->debug = $debug;
+ $this->debug_handler = $handler;
}
/**
* Write the given debug text to the current debug output handler.
*
- * @param string $message Debug mesage text.
+ * @param string $message Debug mesage text.
*
- * @access private
- * @since 1.3.3
+ * @since 1.3.3
*/
- function _debug($message)
+ protected function debug($message)
{
- if ($this->_debug) {
- if ($this->_debug_handler) {
- call_user_func_array($this->_debug_handler,
- array(&$this, $message));
+ if ($this->debug) {
+ if ($this->debug_handler) {
+ call_user_func_array(
+ $this->debug_handler, array(&$this, $message)
+ );
} else {
echo "DEBUG: $message\n";
}
/**
* Send the given string of data to the server.
*
- * @param string $data The string of data to send.
+ * @param string $data The string of data to send.
*
- * @return mixed True on success or a PEAR_Error object on failure.
+ * @return mixed The number of bytes that were actually written,
+ * or a PEAR_Error object on failure.
*
- * @access private
- * @since 1.1.0
+ * @since 1.1.0
*/
- function _send($data)
+ protected function send($data)
{
- $this->_debug("Send: $data");
+ $this->debug("Send: $data");
- $error = $this->_socket->write($data);
- if ($error === false || PEAR::isError($error)) {
- $msg = ($error) ? $error->getMessage() : "unknown error";
+ $result = $this->socket->write($data);
+ if (!$result || PEAR::isError($result)) {
+ $msg = $result ? $result->getMessage() : "unknown error";
return PEAR::raiseError("Failed to write to socket: $msg");
}
- return true;
+ return $result;
}
/**
* arguments. A carriage return / linefeed (CRLF) sequence will
* be appended to each command string before it is sent to the
* SMTP server - an error will be thrown if the command string
- * already contains any newline characters. Use _send() for
+ * already contains any newline characters. Use send() for
* commands that must contain newlines.
*
- * @param string $command The SMTP command to send to the server.
- * @param string $args A string of optional arguments to append
- * to the command.
+ * @param string $command The SMTP command to send to the server.
+ * @param string $args A string of optional arguments to append
+ * to the command.
*
- * @return mixed The result of the _send() call.
+ * @return mixed The result of the send() call.
*
- * @access private
- * @since 1.1.0
+ * @since 1.1.0
*/
- function _put($command, $args = '')
+ protected function put($command, $args = '')
{
if (!empty($args)) {
$command .= ' ' . $args;
return PEAR::raiseError('Commands cannot contain newlines');
}
- return $this->_send($command . "\r\n");
+ return $this->send($command . "\r\n");
}
/**
* Read a reply from the SMTP server. The reply consists of a response
* code and a response message.
*
- * @param mixed $valid The set of valid response codes. These
- * may be specified as an array of integer
- * values or as a single integer value.
- * @param bool $later Do not parse the response now, but wait
- * until the last command in the pipelined
- * command group
+ * @param mixed $valid The set of valid response codes. These
+ * may be specified as an array of integer
+ * values or as a single integer value.
+ * @param bool $later Do not parse the response now, but wait
+ * until the last command in the pipelined
+ * command group
*
- * @return mixed True if the server returned a valid response code or
- * a PEAR_Error object is an error condition is reached.
+ * @return mixed True if the server returned a valid response code or
+ * a PEAR_Error object is an error condition is reached.
*
- * @access private
- * @since 1.1.0
+ * @since 1.1.0
*
- * @see getResponse
+ * @see getResponse
*/
- function _parseResponse($valid, $later = false)
+ protected function parseResponse($valid, $later = false)
{
- $this->_code = -1;
- $this->_arguments = array();
+ $this->code = -1;
+ $this->arguments = array();
if ($later) {
- $this->_pipelined_commands++;
+ $this->pipelined_commands++;
return true;
}
- for ($i = 0; $i <= $this->_pipelined_commands; $i++) {
- while ($line = $this->_socket->readLine()) {
- $this->_debug("Recv: $line");
+ for ($i = 0; $i <= $this->pipelined_commands; $i++) {
+ while ($line = $this->socket->readLine()) {
+ $this->debug("Recv: $line");
- /* If we receive an empty line, the connection has been closed. */
+ /* If we receive an empty line, the connection was closed. */
if (empty($line)) {
$this->disconnect();
- return PEAR::raiseError('Connection was unexpectedly closed');
+ return PEAR::raiseError('Connection was closed');
}
/* Read the code and store the rest in the arguments array. */
$code = substr($line, 0, 3);
- $this->_arguments[] = trim(substr($line, 4));
+ $this->arguments[] = trim(substr($line, 4));
/* Check the syntax of the response code. */
if (is_numeric($code)) {
- $this->_code = (int)$code;
+ $this->code = (int)$code;
} else {
- $this->_code = -1;
+ $this->code = -1;
break;
}
}
}
- $this->_pipelined_commands = 0;
+ $this->pipelined_commands = 0;
/* Compare the server's response code with the valid code/codes. */
- if (is_int($valid) && ($this->_code === $valid)) {
+ if (is_int($valid) && ($this->code === $valid)) {
return true;
- } elseif (is_array($valid) && in_array($this->_code, $valid, true)) {
+ } elseif (is_array($valid) && in_array($this->code, $valid, true)) {
return true;
}
- return PEAR::raiseError('Invalid response code received from server',
- $this->_code);
+ return PEAR::raiseError('Invalid response code received from server', $this->code);
+ }
+
+ /**
+ * Issue an SMTP command and verify its response.
+ *
+ * @param string $command The SMTP command string or data.
+ * @param mixed $valid The set of valid response codes. These
+ * may be specified as an array of integer
+ * values or as a single integer value.
+ *
+ * @return mixed True on success or a PEAR_Error object on failure.
+ *
+ * @since 1.6.0
+ */
+ public function command($command, $valid)
+ {
+ if (PEAR::isError($error = $this->put($command))) {
+ return $error;
+ }
+ if (PEAR::isError($error = $this->parseResponse($valid))) {
+ return $error;
+ }
+
+ return true;
}
/**
* Return a 2-tuple containing the last response from the SMTP server.
*
- * @return array A two-element array: the first element contains the
- * response code as an integer and the second element
- * contains the response's arguments as a string.
+ * @return array A two-element array: the first element contains the
+ * response code as an integer and the second element
+ * contains the response's arguments as a string.
*
- * @access public
- * @since 1.1.0
+ * @since 1.1.0
*/
- function getResponse()
+ public function getResponse()
{
- return array($this->_code, join("\n", $this->_arguments));
+ return array($this->code, join("\n", $this->arguments));
}
/**
* Return the SMTP server's greeting string.
*
- * @return string A string containing the greeting string, or null if a
- * greeting has not been received.
+ * @return string A string containing the greeting string, or null if
+ * a greeting has not been received.
*
- * @access public
- * @since 1.3.3
+ * @since 1.3.3
*/
- function getGreeting()
+ public function getGreeting()
{
- return $this->_greeting;
+ return $this->greeting;
}
/**
* Attempt to connect to the SMTP server.
*
- * @param int $timeout The timeout value (in seconds) for the
- * socket connection.
- * @param bool $persistent Should a persistent socket connection
- * be used?
+ * @param int $timeout The timeout value (in seconds) for the
+ * socket connection attempt.
+ * @param bool $persistent Should a persistent socket connection
+ * be used?
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
- * @access public
- * @since 1.0
+ * @since 1.0
*/
- function connect($timeout = null, $persistent = false)
+ public function connect($timeout = null, $persistent = false)
{
- $this->_greeting = null;
- $result = $this->_socket->connect($this->host, $this->port,
- $persistent, $timeout);
+ $this->greeting = null;
+
+ $result = $this->socket->connect(
+ $this->host, $this->port, $persistent, $timeout, $this->socket_options
+ );
+
if (PEAR::isError($result)) {
- return PEAR::raiseError('Failed to connect socket: ' .
- $result->getMessage());
+ return PEAR::raiseError(
+ 'Failed to connect socket: ' . $result->getMessage()
+ );
+ }
+
+ /*
+ * Now that we're connected, reset the socket's timeout value for
+ * future I/O operations. This allows us to have different socket
+ * timeout values for the initial connection (our $timeout parameter)
+ * and all other socket operations.
+ */
+ if ($this->timeout > 0) {
+ if (PEAR::isError($error = $this->setTimeout($this->timeout))) {
+ return $error;
+ }
}
- if (PEAR::isError($error = $this->_parseResponse(220))) {
+ if (PEAR::isError($error = $this->parseResponse(220))) {
return $error;
}
/* Extract and store a copy of the server's greeting string. */
- list(, $this->_greeting) = $this->getResponse();
+ list(, $this->greeting) = $this->getResponse();
- if (PEAR::isError($error = $this->_negotiate())) {
+ if (PEAR::isError($error = $this->negotiate())) {
return $error;
}
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
- * @access public
- * @since 1.0
+ * @since 1.0
*/
- function disconnect()
+ public function disconnect()
{
- if (PEAR::isError($error = $this->_put('QUIT'))) {
+ if (PEAR::isError($error = $this->put('QUIT'))) {
return $error;
}
- if (PEAR::isError($error = $this->_parseResponse(221))) {
+ if (PEAR::isError($error = $this->parseResponse(221))) {
return $error;
}
- if (PEAR::isError($error = $this->_socket->disconnect())) {
- return PEAR::raiseError('Failed to disconnect socket: ' .
- $error->getMessage());
+ if (PEAR::isError($error = $this->socket->disconnect())) {
+ return PEAR::raiseError(
+ 'Failed to disconnect socket: ' . $error->getMessage()
+ );
}
return true;
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
*
- * @access private
- * @since 1.1.0
+ * @since 1.1.0
*/
- function _negotiate()
+ protected function negotiate()
{
- if (PEAR::isError($error = $this->_put('EHLO', $this->localhost))) {
+ if (PEAR::isError($error = $this->put('EHLO', $this->localhost))) {
return $error;
}
- if (PEAR::isError($this->_parseResponse(250))) {
- /* If we receive a 503 response, we're already authenticated. */
- if ($this->_code === 503) {
- return true;
- }
-
+ if (PEAR::isError($this->parseResponse(250))) {
/* If the EHLO failed, try the simpler HELO command. */
- if (PEAR::isError($error = $this->_put('HELO', $this->localhost))) {
+ if (PEAR::isError($error = $this->put('HELO', $this->localhost))) {
return $error;
}
- if (PEAR::isError($this->_parseResponse(250))) {
- return PEAR::raiseError('HELO was not accepted: ', $this->_code);
+ if (PEAR::isError($this->parseResponse(250))) {
+ return PEAR::raiseError('HELO was not accepted', $this->code);
}
return true;
}
- foreach ($this->_arguments as $argument) {
- $verb = strtok($argument, ' ');
- $arguments = substr($argument, strlen($verb) + 1,
- strlen($argument) - strlen($verb) - 1);
- $this->_esmtp[$verb] = $arguments;
+ foreach ($this->arguments as $argument) {
+ $verb = strtok($argument, ' ');
+ $len = strlen($verb);
+ $arguments = substr($argument, $len + 1, strlen($argument) - $len - 1);
+ $this->esmtp[$verb] = $arguments;
}
- if (!isset($this->_esmtp['PIPELINING'])) {
+ if (!isset($this->esmtp['PIPELINING'])) {
$this->pipelining = false;
}
* Returns the name of the best authentication method that the server
* has advertised.
*
- * @return mixed Returns a string containing the name of the best
- * supported authentication method or a PEAR_Error object
- * if a failure condition is encountered.
- * @access private
- * @since 1.1.0
+ * @return mixed Returns a string containing the name of the best
+ * supported authentication method or a PEAR_Error object
+ * if a failure condition is encountered.
+ * @since 1.1.0
*/
- function _getBestAuthMethod()
+ protected function getBestAuthMethod()
{
- $available_methods = explode(' ', $this->_esmtp['AUTH']);
+ $available_methods = explode(' ', $this->esmtp['AUTH']);
- foreach ($this->auth_methods as $method) {
+ foreach ($this->auth_methods as $method => $callback) {
if (in_array($method, $available_methods)) {
return $method;
}
/**
* Attempt to do SMTP authentication.
*
- * @param string The userid to authenticate as.
- * @param string The password to authenticate with.
- * @param string The requested authentication method. If none is
- * specified, the best supported method will be used.
- * @param bool Flag indicating whether or not TLS should be attempted.
+ * @param string $uid The userid to authenticate as.
+ * @param string $pwd The password to authenticate with.
+ * @param string $method The requested authentication method. If none is
+ * specified, the best supported method will be used.
+ * @param bool $tls Flag indicating whether or not TLS should be attempted.
+ * @param string $authz An optional authorization identifier. If specified, this
+ * identifier will be used as the authorization proxy.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
- * @access public
- * @since 1.0
+ * @since 1.0
*/
- function auth($uid, $pwd , $method = '', $tls = true)
+ public function auth($uid, $pwd , $method = '', $tls = true, $authz = '')
{
/* We can only attempt a TLS connection if one has been requested,
- * we're running PHP 5.1.0 or later, have access to the OpenSSL
- * extension, are connected to an SMTP server which supports the
- * STARTTLS extension, and aren't already connected over a secure
+ * we're running PHP 5.1.0 or later, have access to the OpenSSL
+ * extension, are connected to an SMTP server which supports the
+ * STARTTLS extension, and aren't already connected over a secure
* (SSL) socket connection. */
- if ($tls && version_compare(PHP_VERSION, '5.1.0', '>=') &&
- extension_loaded('openssl') && isset($this->_esmtp['STARTTLS']) &&
- strncasecmp($this->host, 'ssl://', 6) !== 0) {
+ if ($tls && version_compare(PHP_VERSION, '5.1.0', '>=')
+ && extension_loaded('openssl') && isset($this->esmtp['STARTTLS'])
+ && strncasecmp($this->host, 'ssl://', 6) !== 0
+ ) {
/* Start the TLS connection attempt. */
- if (PEAR::isError($result = $this->_put('STARTTLS'))) {
+ if (PEAR::isError($result = $this->put('STARTTLS'))) {
return $result;
}
- if (PEAR::isError($result = $this->_parseResponse(220))) {
+ if (PEAR::isError($result = $this->parseResponse(220))) {
return $result;
}
- if (PEAR::isError($result = $this->_socket->enableCrypto(true, STREAM_CRYPTO_METHOD_TLS_CLIENT))) {
+ if (isset($this->socket_options['ssl']['crypto_method'])) {
+ $crypto_method = $this->socket_options['ssl']['crypto_method'];
+ } else {
+ /* STREAM_CRYPTO_METHOD_TLS_ANY_CLIENT constant does not exist
+ * and STREAM_CRYPTO_METHOD_SSLv23_CLIENT constant is
+ * inconsistent across PHP versions. */
+ $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT
+ | @STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT
+ | @STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
+ }
+ if (PEAR::isError($result = $this->socket->enableCrypto(true, $crypto_method))) {
return $result;
} elseif ($result !== true) {
return PEAR::raiseError('STARTTLS failed');
/* Send EHLO again to recieve the AUTH string from the
* SMTP server. */
- $this->_negotiate();
+ $this->negotiate();
}
- if (empty($this->_esmtp['AUTH'])) {
+ if (empty($this->esmtp['AUTH'])) {
return PEAR::raiseError('SMTP server does not support authentication');
}
/* If no method has been specified, get the name of the best
* supported method advertised by the SMTP server. */
if (empty($method)) {
- if (PEAR::isError($method = $this->_getBestAuthMethod())) {
+ if (PEAR::isError($method = $this->getBestAuthMethod())) {
/* Return the PEAR_Error object from _getBestAuthMethod(). */
return $method;
}
} else {
$method = strtoupper($method);
- if (!in_array($method, $this->auth_methods)) {
+ if (!array_key_exists($method, $this->auth_methods)) {
return PEAR::raiseError("$method is not a supported authentication method");
}
}
- switch ($method) {
- case 'DIGEST-MD5':
- $result = $this->_authDigest_MD5($uid, $pwd);
- break;
-
- case 'CRAM-MD5':
- $result = $this->_authCRAM_MD5($uid, $pwd);
- break;
-
- case 'LOGIN':
- $result = $this->_authLogin($uid, $pwd);
- break;
+ if (!isset($this->auth_methods[$method])) {
+ return PEAR::raiseError("$method is not a supported authentication method");
+ }
- case 'PLAIN':
- $result = $this->_authPlain($uid, $pwd);
- break;
+ if (!is_callable($this->auth_methods[$method], false)) {
+ return PEAR::raiseError("$method authentication method cannot be called");
+ }
- default:
- $result = PEAR::raiseError("$method is not a supported authentication method");
- break;
+ if (is_array($this->auth_methods[$method])) {
+ list($object, $method) = $this->auth_methods[$method];
+ $result = $object->{$method}($uid, $pwd, $authz, $this);
+ } else {
+ $func = $this->auth_methods[$method];
+ $result = $func($uid, $pwd, $authz, $this);
}
/* If an error was encountered, return the PEAR_Error object. */
return true;
}
+ /**
+ * Add a new authentication method.
+ *
+ * @param string $name The authentication method name (e.g. 'PLAIN')
+ * @param mixed $callback The authentication callback (given as the name of a
+ * function or as an (object, method name) array).
+ * @param bool $prepend Should the new method be prepended to the list of
+ * available methods? This is the default behavior,
+ * giving the new method the highest priority.
+ *
+ * @return mixed True on success or a PEAR_Error object on failure.
+ *
+ * @since 1.6.0
+ */
+ public function setAuthMethod($name, $callback, $prepend = true)
+ {
+ if (!is_string($name)) {
+ return PEAR::raiseError('Method name is not a string');
+ }
+
+ if (!is_string($callback) && !is_array($callback)) {
+ return PEAR::raiseError('Method callback must be string or array');
+ }
+
+ if (is_array($callback)) {
+ if (!is_object($callback[0]) || !is_string($callback[1])) {
+ return PEAR::raiseError('Bad mMethod callback array');
+ }
+ }
+
+ if ($prepend) {
+ $this->auth_methods = array_merge(
+ array($name => $callback), $this->auth_methods
+ );
+ } else {
+ $this->auth_methods[$name] = $callback;
+ }
+
+ return true;
+ }
+
/**
* Authenticates the user using the DIGEST-MD5 method.
*
- * @param string The userid to authenticate as.
- * @param string The password to authenticate with.
+ * @param string $uid The userid to authenticate as.
+ * @param string $pwd The password to authenticate with.
+ * @param string $authz The optional authorization proxy identifier.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
- * @access private
- * @since 1.1.0
+ * @since 1.1.0
*/
- function _authDigest_MD5($uid, $pwd)
+ protected function authDigestMD5($uid, $pwd, $authz = '')
{
- if (PEAR::isError($error = $this->_put('AUTH', 'DIGEST-MD5'))) {
+ if (PEAR::isError($error = $this->put('AUTH', 'DIGEST-MD5'))) {
return $error;
}
/* 334: Continue authentication request */
- if (PEAR::isError($error = $this->_parseResponse(334))) {
+ if (PEAR::isError($error = $this->parseResponse(334))) {
/* 503: Error: already authenticated */
- if ($this->_code === 503) {
+ if ($this->code === 503) {
return true;
}
return $error;
}
- $challenge = base64_decode($this->_arguments[0]);
- $digest = &Auth_SASL::factory('digestmd5');
- $auth_str = base64_encode($digest->getResponse($uid, $pwd, $challenge,
- $this->host, "smtp"));
+ $digest = Auth_SASL::factory('digest-md5');
+ $challenge = base64_decode($this->arguments[0]);
+ $auth_str = base64_encode(
+ $digest->getResponse($uid, $pwd, $challenge, $this->host, "smtp", $authz)
+ );
- if (PEAR::isError($error = $this->_put($auth_str))) {
+ if (PEAR::isError($error = $this->put($auth_str))) {
return $error;
}
/* 334: Continue authentication request */
- if (PEAR::isError($error = $this->_parseResponse(334))) {
+ if (PEAR::isError($error = $this->parseResponse(334))) {
return $error;
}
/* We don't use the protocol's third step because SMTP doesn't
* allow subsequent authentication, so we just silently ignore
* it. */
- if (PEAR::isError($error = $this->_put(''))) {
+ if (PEAR::isError($error = $this->put(''))) {
return $error;
}
/* 235: Authentication successful */
- if (PEAR::isError($error = $this->_parseResponse(235))) {
+ if (PEAR::isError($error = $this->parseResponse(235))) {
return $error;
}
}
/**
* Authenticates the user using the CRAM-MD5 method.
*
- * @param string The userid to authenticate as.
- * @param string The password to authenticate with.
+ * @param string $uid The userid to authenticate as.
+ * @param string $pwd The password to authenticate with.
+ * @param string $authz The optional authorization proxy identifier.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
- * @access private
- * @since 1.1.0
+ * @since 1.1.0
*/
- function _authCRAM_MD5($uid, $pwd)
+ protected function authCRAMMD5($uid, $pwd, $authz = '')
{
- if (PEAR::isError($error = $this->_put('AUTH', 'CRAM-MD5'))) {
+ if (PEAR::isError($error = $this->put('AUTH', 'CRAM-MD5'))) {
return $error;
}
/* 334: Continue authentication request */
- if (PEAR::isError($error = $this->_parseResponse(334))) {
+ if (PEAR::isError($error = $this->parseResponse(334))) {
/* 503: Error: already authenticated */
- if ($this->_code === 503) {
+ if ($this->code === 503) {
return true;
}
return $error;
}
- $challenge = base64_decode($this->_arguments[0]);
- $cram = &Auth_SASL::factory('crammd5');
- $auth_str = base64_encode($cram->getResponse($uid, $pwd, $challenge));
+ $challenge = base64_decode($this->arguments[0]);
+ $cram = Auth_SASL::factory('cram-md5');
+ $auth_str = base64_encode($cram->getResponse($uid, $pwd, $challenge));
- if (PEAR::isError($error = $this->_put($auth_str))) {
+ if (PEAR::isError($error = $this->put($auth_str))) {
return $error;
}
/* 235: Authentication successful */
- if (PEAR::isError($error = $this->_parseResponse(235))) {
+ if (PEAR::isError($error = $this->parseResponse(235))) {
return $error;
}
}
/**
* Authenticates the user using the LOGIN method.
*
- * @param string The userid to authenticate as.
- * @param string The password to authenticate with.
+ * @param string $uid The userid to authenticate as.
+ * @param string $pwd The password to authenticate with.
+ * @param string $authz The optional authorization proxy identifier.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
- * @access private
- * @since 1.1.0
+ * @since 1.1.0
*/
- function _authLogin($uid, $pwd)
+ protected function authLogin($uid, $pwd, $authz = '')
{
- if (PEAR::isError($error = $this->_put('AUTH', 'LOGIN'))) {
+ if (PEAR::isError($error = $this->put('AUTH', 'LOGIN'))) {
return $error;
}
/* 334: Continue authentication request */
- if (PEAR::isError($error = $this->_parseResponse(334))) {
+ if (PEAR::isError($error = $this->parseResponse(334))) {
/* 503: Error: already authenticated */
- if ($this->_code === 503) {
+ if ($this->code === 503) {
return true;
}
return $error;
}
- if (PEAR::isError($error = $this->_put(base64_encode($uid)))) {
+ if (PEAR::isError($error = $this->put(base64_encode($uid)))) {
return $error;
}
/* 334: Continue authentication request */
- if (PEAR::isError($error = $this->_parseResponse(334))) {
+ if (PEAR::isError($error = $this->parseResponse(334))) {
return $error;
}
- if (PEAR::isError($error = $this->_put(base64_encode($pwd)))) {
+ if (PEAR::isError($error = $this->put(base64_encode($pwd)))) {
return $error;
}
/* 235: Authentication successful */
- if (PEAR::isError($error = $this->_parseResponse(235))) {
+ if (PEAR::isError($error = $this->parseResponse(235))) {
return $error;
}
/**
* Authenticates the user using the PLAIN method.
*
- * @param string The userid to authenticate as.
- * @param string The password to authenticate with.
+ * @param string $uid The userid to authenticate as.
+ * @param string $pwd The password to authenticate with.
+ * @param string $authz The optional authorization proxy identifier.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
- * @access private
- * @since 1.1.0
+ * @since 1.1.0
*/
- function _authPlain($uid, $pwd)
+ protected function authPlain($uid, $pwd, $authz = '')
{
- if (PEAR::isError($error = $this->_put('AUTH', 'PLAIN'))) {
+ if (PEAR::isError($error = $this->put('AUTH', 'PLAIN'))) {
return $error;
}
/* 334: Continue authentication request */
- if (PEAR::isError($error = $this->_parseResponse(334))) {
+ if (PEAR::isError($error = $this->parseResponse(334))) {
/* 503: Error: already authenticated */
- if ($this->_code === 503) {
+ if ($this->code === 503) {
return true;
}
return $error;
}
- $auth_str = base64_encode(chr(0) . $uid . chr(0) . $pwd);
+ $auth_str = base64_encode($authz . chr(0) . $uid . chr(0) . $pwd);
- if (PEAR::isError($error = $this->_put($auth_str))) {
+ if (PEAR::isError($error = $this->put($auth_str))) {
return $error;
}
/* 235: Authentication successful */
- if (PEAR::isError($error = $this->_parseResponse(235))) {
+ if (PEAR::isError($error = $this->parseResponse(235))) {
return $error;
}
/**
* Send the HELO command.
*
- * @param string The domain name to say we are.
+ * @param string $domain The domain name to say we are.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
- * @access public
- * @since 1.0
+ * @since 1.0
*/
- function helo($domain)
+ public function helo($domain)
{
- if (PEAR::isError($error = $this->_put('HELO', $domain))) {
+ if (PEAR::isError($error = $this->put('HELO', $domain))) {
return $error;
}
- if (PEAR::isError($error = $this->_parseResponse(250))) {
+ if (PEAR::isError($error = $this->parseResponse(250))) {
return $error;
}
* Return the list of SMTP service extensions advertised by the server.
*
* @return array The list of SMTP service extensions.
- * @access public
* @since 1.3
*/
- function getServiceExtensions()
+ public function getServiceExtensions()
{
- return $this->_esmtp;
+ return $this->esmtp;
}
/**
* Send the MAIL FROM: command.
*
- * @param string $sender The sender (reverse path) to set.
- * @param string $params String containing additional MAIL parameters,
- * such as the NOTIFY flags defined by RFC 1891
- * or the VERP protocol.
+ * @param string $sender The sender (reverse path) to set.
+ * @param string $params String containing additional MAIL parameters,
+ * such as the NOTIFY flags defined by RFC 1891
+ * or the VERP protocol.
*
- * If $params is an array, only the 'verp' option
- * is supported. If 'verp' is true, the XVERP
- * parameter is appended to the MAIL command. If
- * the 'verp' value is a string, the full
- * XVERP=value parameter is appended.
+ * If $params is an array, only the 'verp' option
+ * is supported. If 'verp' is true, the XVERP
+ * parameter is appended to the MAIL command.
+ * If the 'verp' value is a string, the full
+ * XVERP=value parameter is appended.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
- * @access public
- * @since 1.0
+ * @since 1.0
*/
- function mailFrom($sender, $params = null)
+ public function mailFrom($sender, $params = null)
{
$args = "FROM:<$sender>";
/* Support the deprecated array form of $params. */
if (is_array($params) && isset($params['verp'])) {
- /* XVERP */
if ($params['verp'] === true) {
$args .= ' XVERP';
-
- /* XVERP=something */
} elseif (trim($params['verp'])) {
$args .= ' XVERP=' . $params['verp'];
}
- } elseif (is_string($params)) {
+ } elseif (is_string($params) && !empty($params)) {
$args .= ' ' . $params;
}
- if (PEAR::isError($error = $this->_put('MAIL', $args))) {
+ if (PEAR::isError($error = $this->put('MAIL', $args))) {
return $error;
}
- if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) {
+ if (PEAR::isError($error = $this->parseResponse(250, $this->pipelining))) {
return $error;
}
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
*
- * @access public
- * @since 1.0
+ * @since 1.0
*/
- function rcptTo($recipient, $params = null)
+ public function rcptTo($recipient, $params = null)
{
$args = "TO:<$recipient>";
if (is_string($params)) {
$args .= ' ' . $params;
}
- if (PEAR::isError($error = $this->_put('RCPT', $args))) {
+ if (PEAR::isError($error = $this->put('RCPT', $args))) {
return $error;
}
- if (PEAR::isError($error = $this->_parseResponse(array(250, 251), $this->pipelining))) {
+ if (PEAR::isError($error = $this->parseResponse(array(250, 251), $this->pipelining))) {
return $error;
}
* easier overloading for the cases where it is desirable to
* customize the quoting behavior.
*
- * @param string $data The message text to quote. The string must be passed
+ * @param string &$data The message text to quote. The string must be passed
* by reference, and the text will be modified in place.
*
- * @access public
- * @since 1.2
+ * @since 1.2
*/
- function quotedata(&$data)
+ public function quotedata(&$data)
{
- /* Change Unix (\n) and Mac (\r) linefeeds into
- * Internet-standard CRLF (\r\n) linefeeds. */
- $data = preg_replace(array('/(?<!\r)\n/','/\r(?!\n)/'), "\r\n", $data);
-
/* Because a single leading period (.) signifies an end to the
- * data, legitimate leading periods need to be "doubled"
- * (e.g. '..'). */
- $data = str_replace("\n.", "\n..", $data);
+ * data, legitimate leading periods need to be "doubled" ('..'). */
+ $data = preg_replace('/^\./m', '..', $data);
+
+ /* Change Unix (\n) and Mac (\r) linefeeds into CRLF's (\r\n). */
+ $data = preg_replace('/(?:\r\n|\n|\r(?!\n))/', "\r\n", $data);
}
/**
* Send the DATA command.
*
- * @param mixed $data The message data, either as a string or an open
+ * @param mixed $data The message data, either as a string or an open
* file resource.
* @param string $headers The message headers. If $headers is provided,
* $data is assumed to contain only body data.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
- * @access public
- * @since 1.0
+ * @since 1.0
*/
- function data($data, $headers = null)
+ public function data($data, $headers = null)
{
/* Verify that $data is a supported type. */
if (!is_string($data) && !is_resource($data)) {
return PEAR::raiseError('Expected a string or file resource');
}
- /* RFC 1870, section 3, subsection 3 states "a value of zero
- * indicates that no fixed maximum message size is in force".
- * Furthermore, it says that if "the parameter is omitted no
- * information is conveyed about the server's fixed maximum
- * message size". */
- if (isset($this->_esmtp['SIZE']) && ($this->_esmtp['SIZE'] > 0)) {
- /* Start by considering the size of the optional headers string.
- * We also account for the addition 4 character "\r\n\r\n"
- * separator sequence. */
- $size = (is_null($headers)) ? 0 : strlen($headers) + 4;
-
- if (is_resource($data)) {
- $stat = fstat($data);
- if ($stat === false) {
- return PEAR::raiseError('Failed to get file size');
- }
- $size += $stat['size'];
- } else {
- $size += strlen($data);
- }
+ /* Start by considering the size of the optional headers string. We
+ * also account for the addition 4 character "\r\n\r\n" separator
+ * sequence. */
+ $size = (is_null($headers)) ? 0 : strlen($headers) + 4;
- if ($size >= $this->_esmtp['SIZE']) {
- $this->disconnect();
- return PEAR::raiseError('Message size exceeds server limit');
+ if (is_resource($data)) {
+ $stat = fstat($data);
+ if ($stat === false) {
+ return PEAR::raiseError('Failed to get file size');
}
+ $size += $stat['size'];
+ } else {
+ $size += strlen($data);
+ }
+
+ /* RFC 1870, section 3, subsection 3 states "a value of zero indicates
+ * that no fixed maximum message size is in force". Furthermore, it
+ * says that if "the parameter is omitted no information is conveyed
+ * about the server's fixed maximum message size". */
+ $limit = (isset($this->esmtp['SIZE'])) ? $this->esmtp['SIZE'] : 0;
+ if ($limit > 0 && $size >= $limit) {
+ $this->disconnect();
+ return PEAR::raiseError('Message size exceeds server limit');
}
/* Initiate the DATA command. */
- if (PEAR::isError($error = $this->_put('DATA'))) {
+ if (PEAR::isError($error = $this->put('DATA'))) {
return $error;
}
- if (PEAR::isError($error = $this->_parseResponse(354))) {
+ if (PEAR::isError($error = $this->parseResponse(354))) {
return $error;
}
/* If we have a separate headers string, send it first. */
if (!is_null($headers)) {
$this->quotedata($headers);
- if (PEAR::isError($result = $this->_send($headers . "\r\n\r\n"))) {
+ if (PEAR::isError($result = $this->send($headers . "\r\n\r\n"))) {
return $result;
}
+
+ /* Subtract the headers size now that they've been sent. */
+ $size -= strlen($headers) + 4;
}
/* Now we can send the message body data. */
if (is_resource($data)) {
- /* Stream the contents of the file resource out over our socket
- * connection, line by line. Each line must be run through the
+ /* Stream the contents of the file resource out over our socket
+ * connection, line by line. Each line must be run through the
* quoting routine. */
- while ($line = fgets($data, 1024)) {
+ while (strlen($line = fread($data, 8192)) > 0) {
+ /* If the last character is an newline, we need to grab the
+ * next character to check to see if it is a period. */
+ while (!feof($data)) {
+ $char = fread($data, 1);
+ $line .= $char;
+ if ($char != "\n") {
+ break;
+ }
+ }
$this->quotedata($line);
- if (PEAR::isError($result = $this->_send($line))) {
+ if (PEAR::isError($result = $this->send($line))) {
return $result;
}
}
- /* Finally, send the DATA terminator sequence. */
- if (PEAR::isError($result = $this->_send("\r\n.\r\n"))) {
- return $result;
- }
+ $last = $line;
} else {
- /* Just send the entire quoted string followed by the DATA
- * terminator. */
- $this->quotedata($data);
- if (PEAR::isError($result = $this->_send($data . "\r\n.\r\n"))) {
- return $result;
+ /*
+ * Break up the data by sending one chunk (up to 512k) at a time.
+ * This approach reduces our peak memory usage.
+ */
+ for ($offset = 0; $offset < $size;) {
+ $end = $offset + 512000;
+
+ /*
+ * Ensure we don't read beyond our data size or span multiple
+ * lines. quotedata() can't properly handle character data
+ * that's split across two line break boundaries.
+ */
+ if ($end >= $size) {
+ $end = $size;
+ } else {
+ for (; $end < $size; $end++) {
+ if ($data[$end] != "\n") {
+ break;
+ }
+ }
+ }
+
+ /* Extract our chunk and run it through the quoting routine. */
+ $chunk = substr($data, $offset, $end - $offset);
+ $this->quotedata($chunk);
+
+ /* If we run into a problem along the way, abort. */
+ if (PEAR::isError($result = $this->send($chunk))) {
+ return $result;
+ }
+
+ /* Advance the offset to the end of this chunk. */
+ $offset = $end;
}
+
+ $last = $chunk;
+ }
+
+ /* Don't add another CRLF sequence if it's already in the data */
+ $terminator = (substr($last, -2) == "\r\n" ? '' : "\r\n") . ".\r\n";
+
+ /* Finally, send the DATA terminator sequence. */
+ if (PEAR::isError($result = $this->send($terminator))) {
+ return $result;
}
/* Verify that the data was successfully received by the server. */
- if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) {
+ if (PEAR::isError($error = $this->parseResponse(250, $this->pipelining))) {
return $error;
}
/**
* Send the SEND FROM: command.
*
- * @param string The reverse path to send.
+ * @param string $path The reverse path to send.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
- * @access public
- * @since 1.2.6
+ * @since 1.2.6
*/
- function sendFrom($path)
+ public function sendFrom($path)
{
- if (PEAR::isError($error = $this->_put('SEND', "FROM:<$path>"))) {
+ if (PEAR::isError($error = $this->put('SEND', "FROM:<$path>"))) {
return $error;
}
- if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) {
+ if (PEAR::isError($error = $this->parseResponse(250, $this->pipelining))) {
return $error;
}
return true;
}
- /**
- * Backwards-compatibility wrapper for sendFrom().
- *
- * @param string The reverse path to send.
- *
- * @return mixed Returns a PEAR_Error with an error message on any
- * kind of failure, or true on success.
- *
- * @access public
- * @since 1.0
- * @deprecated 1.2.6
- */
- function send_from($path)
- {
- return sendFrom($path);
- }
-
/**
* Send the SOML FROM: command.
*
- * @param string The reverse path to send.
+ * @param string $path The reverse path to send.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
- * @access public
- * @since 1.2.6
+ * @since 1.2.6
*/
- function somlFrom($path)
+ public function somlFrom($path)
{
- if (PEAR::isError($error = $this->_put('SOML', "FROM:<$path>"))) {
+ if (PEAR::isError($error = $this->put('SOML', "FROM:<$path>"))) {
return $error;
}
- if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) {
+ if (PEAR::isError($error = $this->parseResponse(250, $this->pipelining))) {
return $error;
}
return true;
}
- /**
- * Backwards-compatibility wrapper for somlFrom().
- *
- * @param string The reverse path to send.
- *
- * @return mixed Returns a PEAR_Error with an error message on any
- * kind of failure, or true on success.
- *
- * @access public
- * @since 1.0
- * @deprecated 1.2.6
- */
- function soml_from($path)
- {
- return somlFrom($path);
- }
-
/**
* Send the SAML FROM: command.
*
- * @param string The reverse path to send.
+ * @param string $path The reverse path to send.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
- * @access public
- * @since 1.2.6
+ * @since 1.2.6
*/
- function samlFrom($path)
+ public function samlFrom($path)
{
- if (PEAR::isError($error = $this->_put('SAML', "FROM:<$path>"))) {
+ if (PEAR::isError($error = $this->put('SAML', "FROM:<$path>"))) {
return $error;
}
- if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) {
+ if (PEAR::isError($error = $this->parseResponse(250, $this->pipelining))) {
return $error;
}
return true;
}
- /**
- * Backwards-compatibility wrapper for samlFrom().
- *
- * @param string The reverse path to send.
- *
- * @return mixed Returns a PEAR_Error with an error message on any
- * kind of failure, or true on success.
- *
- * @access public
- * @since 1.0
- * @deprecated 1.2.6
- */
- function saml_from($path)
- {
- return samlFrom($path);
- }
-
/**
* Send the RSET command.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
- * @access public
* @since 1.0
*/
- function rset()
+ public function rset()
{
- if (PEAR::isError($error = $this->_put('RSET'))) {
+ if (PEAR::isError($error = $this->put('RSET'))) {
return $error;
}
- if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) {
+ if (PEAR::isError($error = $this->parseResponse(250, $this->pipelining))) {
return $error;
}
/**
* Send the VRFY command.
*
- * @param string The string to verify
+ * @param string $string The string to verify
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
- * @access public
- * @since 1.0
+ * @since 1.0
*/
- function vrfy($string)
+ public function vrfy($string)
{
/* Note: 251 is also a valid response code */
- if (PEAR::isError($error = $this->_put('VRFY', $string))) {
+ if (PEAR::isError($error = $this->put('VRFY', $string))) {
return $error;
}
- if (PEAR::isError($error = $this->_parseResponse(array(250, 252)))) {
+ if (PEAR::isError($error = $this->parseResponse(array(250, 252)))) {
return $error;
}
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
- * @access public
- * @since 1.0
+ * @since 1.0
*/
- function noop()
+ public function noop()
{
- if (PEAR::isError($error = $this->_put('NOOP'))) {
+ if (PEAR::isError($error = $this->put('NOOP'))) {
return $error;
}
- if (PEAR::isError($error = $this->_parseResponse(250))) {
+ if (PEAR::isError($error = $this->parseResponse(250))) {
return $error;
}
* Backwards-compatibility method. identifySender()'s functionality is
* now handled internally.
*
- * @return boolean This method always return true.
+ * @return boolean This method always return true.
*
- * @access public
- * @since 1.0
+ * @since 1.0
*/
- function identifySender()
+ public function identifySender()
{
return true;
}
-
}
<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2003 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: Stig Bakken <ssb@php.net> |
-// | Chuck Hagenbuch <chuck@horde.org> |
-// +----------------------------------------------------------------------+
-//
-// $Id: Socket.php,v 1.38 2008/02/15 18:24:17 chagenbu Exp $
+/**
+ * Net_Socket
+ *
+ * PHP Version 4
+ *
+ * Copyright (c) 1997-2013 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: Stig Bakken <ssb@php.net>
+ * Chuck Hagenbuch <chuck@horde.org>
+ *
+ * @category Net
+ * @package Net_Socket
+ * @author Stig Bakken <ssb@php.net>
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @copyright 1997-2003 The PHP Group
+ * @license http://www.php.net/license/2_02.txt PHP 2.02
+ * @link http://pear.php.net/packages/Net_Socket
+ */
require_once 'PEAR.php';
-define('NET_SOCKET_READ', 1);
+define('NET_SOCKET_READ', 1);
define('NET_SOCKET_WRITE', 2);
define('NET_SOCKET_ERROR', 4);
/**
* Generalized Socket class.
*
- * @version 1.1
- * @author Stig Bakken <ssb@php.net>
- * @author Chuck Hagenbuch <chuck@horde.org>
+ * @category Net
+ * @package Net_Socket
+ * @author Stig Bakken <ssb@php.net>
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @copyright 1997-2003 The PHP Group
+ * @license http://www.php.net/license/2_02.txt PHP 2.02
+ * @link http://pear.php.net/packages/Net_Socket
*/
-class Net_Socket extends PEAR {
-
+class Net_Socket extends PEAR
+{
/**
* Socket file pointer.
* @var resource $fp
var $port = 0;
/**
- * Number of seconds to wait on socket connections before assuming
+ * Number of seconds to wait on socket operations before assuming
* there's no more data. Defaults to no timeout.
- * @var integer $timeout
+ * @var integer|float $timeout
*/
- var $timeout = false;
+ var $timeout = null;
/**
* Number of bytes to read at a time in readLine() and
*/
var $lineLength = 2048;
+ /**
+ * The string to use as a newline terminator. Usually "\r\n" or "\n".
+ * @var string $newline
+ */
+ var $newline = "\r\n";
+
/**
* Connect to the specified port. If called when the socket is
* already connected, it disconnects and connects again.
*
- * @param string $addr IP address or host name.
- * @param integer $port TCP port number.
- * @param boolean $persistent (optional) Whether the connection is
- * persistent (kept open between requests
- * by the web server).
- * @param integer $timeout (optional) How long to wait for data.
- * @param array $options See options for stream_context_create.
+ * @param string $addr IP address or host name (may be with protocol prefix).
+ * @param integer $port TCP port number.
+ * @param boolean $persistent (optional) Whether the connection is
+ * persistent (kept open between requests
+ * by the web server).
+ * @param integer $timeout (optional) Connection socket timeout.
+ * @param array $options See options for stream_context_create.
*
* @access public
*
- * @return boolean | PEAR_Error True on success or a PEAR_Error on failure.
+ * @return boolean|PEAR_Error True on success or a PEAR_Error on failure.
*/
- function connect($addr, $port = 0, $persistent = null, $timeout = null, $options = null)
+ function connect($addr, $port = 0, $persistent = null,
+ $timeout = null, $options = null)
{
if (is_resource($this->fp)) {
@fclose($this->fp);
if (!$addr) {
return $this->raiseError('$addr cannot be empty');
- } elseif (strspn($addr, '.0123456789') == strlen($addr) ||
- strstr($addr, '/') !== false) {
- $this->addr = $addr;
+ } else if (strspn($addr, ':.0123456789') == strlen($addr)) {
+ $this->addr = strpos($addr, ':') !== false ? '['.$addr.']' : $addr;
} else {
- $this->addr = @gethostbyname($addr);
+ $this->addr = $addr;
}
$this->port = $port % 65536;
$this->persistent = $persistent;
}
- if ($timeout !== null) {
- $this->timeout = $timeout;
- }
-
$openfunc = $this->persistent ? 'pfsockopen' : 'fsockopen';
- $errno = 0;
- $errstr = '';
+ $errno = 0;
+ $errstr = '';
+
$old_track_errors = @ini_set('track_errors', 1);
+
+ if ($timeout <= 0) {
+ $timeout = @ini_get('default_socket_timeout');
+ }
+
if ($options && function_exists('stream_context_create')) {
- if ($this->timeout) {
- $timeout = $this->timeout;
- } else {
- $timeout = 0;
- }
$context = stream_context_create($options);
// Since PHP 5 fsockopen doesn't allow context specification
if (function_exists('stream_socket_client')) {
- $flags = $this->persistent ? STREAM_CLIENT_PERSISTENT : STREAM_CLIENT_CONNECT;
+ $flags = STREAM_CLIENT_CONNECT;
+
+ if ($this->persistent) {
+ $flags = STREAM_CLIENT_PERSISTENT;
+ }
+
$addr = $this->addr . ':' . $this->port;
- $fp = stream_socket_client($addr, $errno, $errstr, $timeout, $flags, $context);
+ $fp = stream_socket_client($addr, $errno, $errstr,
+ $timeout, $flags, $context);
} else {
- $fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $timeout, $context);
+ $fp = @$openfunc($this->addr, $this->port, $errno,
+ $errstr, $timeout, $context);
}
} else {
- if ($this->timeout) {
- $fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $this->timeout);
- } else {
- $fp = @$openfunc($this->addr, $this->port, $errno, $errstr);
- }
+ $fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $timeout);
}
if (!$fp) {
- if ($errno == 0 && isset($php_errormsg)) {
+ if ($errno == 0 && !strlen($errstr) && isset($php_errormsg)) {
$errstr = $php_errormsg;
}
@ini_set('track_errors', $old_track_errors);
@ini_set('track_errors', $old_track_errors);
$this->fp = $fp;
-
+ $this->setTimeout();
return $this->setBlocking($this->blocking);
}
return true;
}
+ /**
+ * Set the newline character/sequence to use.
+ *
+ * @param string $newline Newline character(s)
+ * @return boolean True
+ */
+ function setNewline($newline)
+ {
+ $this->newline = $newline;
+ return true;
+ }
+
/**
* Find out if the socket is in blocking mode.
*
* if there is no data available, whereas it will block until there
* is data for blocking sockets.
*
- * @param boolean $mode True for blocking sockets, false for nonblocking.
+ * @param boolean $mode True for blocking sockets, false for nonblocking.
+ *
* @access public
* @return mixed true on success or a PEAR_Error instance otherwise
*/
}
$this->blocking = $mode;
- socket_set_blocking($this->fp, $this->blocking);
+ stream_set_blocking($this->fp, (int)$this->blocking);
return true;
}
* Sets the timeout value on socket descriptor,
* expressed in the sum of seconds and microseconds
*
- * @param integer $seconds Seconds.
- * @param integer $microseconds Microseconds.
+ * @param integer $seconds Seconds.
+ * @param integer $microseconds Microseconds, optional.
+ *
* @access public
- * @return mixed true on success or a PEAR_Error instance otherwise
+ * @return mixed True on success or false on failure or
+ * a PEAR_Error instance when not connected
*/
- function setTimeout($seconds, $microseconds)
+ function setTimeout($seconds = null, $microseconds = null)
{
if (!is_resource($this->fp)) {
return $this->raiseError('not connected');
}
- return socket_set_timeout($this->fp, $seconds, $microseconds);
+ if ($seconds === null && $microseconds === null) {
+ $seconds = (int) $this->timeout;
+ $microseconds = (int) (($this->timeout - $seconds) * 1000000);
+ } else {
+ $this->timeout = $seconds + $microseconds/1000000;
+ }
+
+ if ($this->timeout > 0) {
+ return stream_set_timeout($this->fp, (int) $seconds, (int) $microseconds);
+ }
+ else {
+ return false;
+ }
}
/**
* Sets the file buffering size on the stream.
* See php's stream_set_write_buffer for more information.
*
- * @param integer $size Write buffer size.
+ * @param integer $size Write buffer size.
+ *
* @access public
* @return mixed on success or an PEAR_Error object otherwise
*/
* </p>
*
* @access public
- * @return mixed Array containing information about existing socket resource or a PEAR_Error instance otherwise
+ * @return mixed Array containing information about existing socket
+ * resource or a PEAR_Error instance otherwise
*/
function getStatus()
{
return $this->raiseError('not connected');
}
- return socket_get_status($this->fp);
+ return stream_get_meta_data($this->fp);
}
/**
* Get a specified line of data
*
+ * @param int $size Reading ends when size - 1 bytes have been read,
+ * or a newline or an EOF (whichever comes first).
+ * If no size is specified, it will keep reading from
+ * the stream until it reaches the end of the line.
+ *
* @access public
- * @return $size bytes of data from the socket, or a PEAR_Error if
- * not connected.
+ * @return mixed $size bytes of data from the socket, or a PEAR_Error if
+ * not connected. If an error occurs, FALSE is returned.
*/
- function gets($size)
+ function gets($size = null)
{
if (!is_resource($this->fp)) {
return $this->raiseError('not connected');
}
- return @fgets($this->fp, $size);
+ if (is_null($size)) {
+ return @fgets($this->fp);
+ } else {
+ return @fgets($this->fp, $size);
+ }
}
/**
* chunk; if you know the size of the data you're getting
* beforehand, this is definitely the way to go.
*
- * @param integer $size The number of bytes to read from the socket.
+ * @param integer $size The number of bytes to read from the socket.
+ *
* @access public
* @return $size bytes of data from the socket, or a PEAR_Error if
* not connected.
/**
* Write a specified amount of data.
*
- * @param string $data Data to write.
- * @param integer $blocksize Amount of data to write at once.
- * NULL means all at once.
+ * @param string $data Data to write.
+ * @param integer $blocksize Amount of data to write at once.
+ * NULL means all at once.
*
* @access public
- * @return mixed If the socket is not connected, returns an instance of PEAR_Error
- * If the write succeeds, returns the number of bytes written
+ * @return mixed If the socket is not connected, returns an instance of
+ * PEAR_Error.
+ * If the write succeeds, returns the number of bytes written.
* If the write fails, returns false.
+ * If the socket times out, returns an instance of PEAR_Error.
*/
function write($data, $blocksize = null)
{
}
if (is_null($blocksize) && !OS_WINDOWS) {
- return @fwrite($this->fp, $data);
+ $written = @fwrite($this->fp, $data);
+
+ // Check for timeout or lost connection
+ if (!$written) {
+ $meta_data = $this->getStatus();
+
+ if (!is_array($meta_data)) {
+ return $meta_data; // PEAR_Error
+ }
+
+ if (!empty($meta_data['timed_out'])) {
+ return $this->raiseError('timed out');
+ }
+ }
+
+ return $written;
} else {
if (is_null($blocksize)) {
$blocksize = 1024;
}
- $pos = 0;
+ $pos = 0;
$size = strlen($data);
while ($pos < $size) {
$written = @fwrite($this->fp, substr($data, $pos, $blocksize));
- if ($written === false) {
- return false;
+
+ // Check for timeout or lost connection
+ if (!$written) {
+ $meta_data = $this->getStatus();
+
+ if (!is_array($meta_data)) {
+ return $meta_data; // PEAR_Error
+ }
+
+ if (!empty($meta_data['timed_out'])) {
+ return $this->raiseError('timed out');
+ }
+
+ return $written;
}
+
$pos += $written;
}
}
/**
- * Write a line of data to the socket, followed by a trailing "\r\n".
+ * Write a line of data to the socket, followed by a trailing newline.
+ *
+ * @param string $data Data to write
*
* @access public
- * @return mixed fputs result, or an error
+ * @return mixed fwrite() result, or PEAR_Error when not connected
*/
function writeLine($data)
{
return $this->raiseError('not connected');
}
- return fwrite($this->fp, $data . "\r\n");
+ return fwrite($this->fp, $data . $this->newline);
}
/**
}
$string = '';
- while (($char = @fread($this->fp, 1)) != "\x00") {
+ while (($char = @fread($this->fp, 1)) != "\x00") {
$string .= $char;
}
return $string;
}
$line = '';
+
$timeout = time() + $this->timeout;
+
while (!feof($this->fp) && (!$this->timeout || time() < $timeout)) {
$line .= @fgets($this->fp, $this->lineLength);
if (substr($line, -1) == "\n") {
- return rtrim($line, "\r\n");
+ return rtrim($line, $this->newline);
}
}
return $line;
* Runs the equivalent of the select() system call on the socket
* with a timeout specified by tv_sec and tv_usec.
*
- * @param integer $state Which of read/write/error to check for.
- * @param integer $tv_sec Number of seconds for timeout.
- * @param integer $tv_usec Number of microseconds for timeout.
+ * @param integer $state Which of read/write/error to check for.
+ * @param integer $tv_sec Number of seconds for timeout.
+ * @param integer $tv_usec Number of microseconds for timeout.
*
* @access public
* @return False if select fails, integer describing which of read/write/error
return $this->raiseError('not connected');
}
- $read = null;
- $write = null;
+ $read = null;
+ $write = null;
$except = null;
if ($state & NET_SOCKET_READ) {
$read[] = $this->fp;
if ($state & NET_SOCKET_ERROR) {
$except[] = $this->fp;
}
- if (false === ($sr = stream_select($read, $write, $except, $tv_sec, $tv_usec))) {
+ if (false === ($sr = stream_select($read, $write, $except,
+ $tv_sec, $tv_usec))) {
return false;
}
/**
* Turns encryption on/off on a connected socket.
*
- * @param bool $enabled Set this parameter to true to enable encryption
- * and false to disable encryption.
- * @param integer $type Type of encryption. See
- * http://se.php.net/manual/en/function.stream-socket-enable-crypto.php for values.
+ * @param bool $enabled Set this parameter to true to enable encryption
+ * and false to disable encryption.
+ * @param integer $type Type of encryption. See stream_socket_enable_crypto()
+ * for values.
*
+ * @see http://se.php.net/manual/en/function.stream-socket-enable-crypto.php
* @access public
- * @return false on error, true on success and 0 if there isn't enough data and the
- * user should try again (non-blocking sockets only). A PEAR_Error object
- * is returned if the socket is not connected
+ * @return false on error, true on success and 0 if there isn't enough data
+ * and the user should try again (non-blocking sockets only).
+ * A PEAR_Error object is returned if the socket is not
+ * connected
*/
function enableCrypto($enabled, $type)
{
}
return @stream_socket_enable_crypto($this->fp, $enabled, $type);
} else {
- return $this->raiseError('Net_Socket::enableCrypto() requires php version >= 5.1.0');
+ $msg = 'Net_Socket::enableCrypto() requires php version >= 5.1.0';
+ return $this->raiseError($msg);
}
}
* @author Gregory Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Guess.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since PEAR 0.1
*/
* @author Gregory Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
var $release;
var $extra;
- function OS_Guess($uname = null)
+ function __construct($uname = null)
{
list($this->sysname,
$this->release,
* indent-tabs-mode: nil
* c-basic-offset: 4
* End:
- */
\ No newline at end of file
+ */
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2010 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: PEAR.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
*/
define('PEAR_ERROR_EXCEPTION', 32);
/**#@-*/
-define('PEAR_ZE2', (function_exists('version_compare') &&
- version_compare(zend_version(), "2-dev", "ge")));
if (substr(PHP_OS, 0, 3) == 'WIN') {
define('OS_WINDOWS', true);
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2006 The PHP Group
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @see PEAR_Error
* @since Class available since PHP 4.0.2
*/
var $_expected_errors = array();
+ /**
+ * List of methods that can be called both statically and non-statically.
+ * @var array
+ */
+ protected static $bivalentMethods = array(
+ 'setErrorHandling' => true,
+ 'raiseError' => true,
+ 'throwError' => true,
+ 'pushErrorHandling' => true,
+ 'popErrorHandling' => true,
+ );
+
/**
* Constructor. Registers this object in
* $_PEAR_destructor_object_list for destructor emulation if a
* @access public
* @return void
*/
- function PEAR($error_class = null)
+ function __construct($error_class = null)
{
$classname = strtolower(get_class($this));
if ($this->_debug) {
}
}
+ /**
+ * Only here for backwards compatibility.
+ * E.g. Archive_Tar calls $this->PEAR() in its constructor.
+ *
+ * @param string $error_class Which class to use for error objects,
+ * defaults to PEAR_Error.
+ */
+ public function PEAR($error_class = null)
+ {
+ self::__construct($error_class);
+ }
+
/**
* Destructor (the emulated type of...). Does nothing right now,
* but is included for forward compatibility, so subclass
}
}
+ public function __call($method, $arguments)
+ {
+ if (!isset(self::$bivalentMethods[$method])) {
+ trigger_error(
+ 'Call to undefined method PEAR::' . $method . '()', E_USER_ERROR
+ );
+ }
+ return call_user_func_array(
+ array(get_class(), '_' . $method),
+ array_merge(array($this), $arguments)
+ );
+ }
+
+ public static function __callStatic($method, $arguments)
+ {
+ if (!isset(self::$bivalentMethods[$method])) {
+ trigger_error(
+ 'Call to undefined method PEAR::' . $method . '()', E_USER_ERROR
+ );
+ }
+ return call_user_func_array(
+ array(get_class(), '_' . $method),
+ array_merge(array(null), $arguments)
+ );
+ }
+
/**
* If you have a class that's mostly/entirely static, and you need static
* properties, you can use this method to simulate them. Eg. in your method(s)
* do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar');
* You MUST use a reference, or they will not persist!
*
- * @access public
* @param string $class The calling classname, to prevent clashes
* @param string $var The variable to retrieve.
* @return mixed A reference to the variable. If not set it will be
* auto initialised to NULL.
*/
- function &getStaticProperty($class, $var)
+ public static function &getStaticProperty($class, $var)
{
static $properties;
if (!isset($properties[$class])) {
* Use this function to register a shutdown method for static
* classes.
*
- * @access public
* @param mixed $func The function name (or array of class/method) to call
* @param mixed $args The arguments to pass to the function
+ *
* @return void
*/
- function registerShutdownFunc($func, $args = array())
+ public static function registerShutdownFunc($func, $args = array())
{
// if we are called statically, there is a potential
// that no shutdown func is registered. Bug #6445
* only if $code is a string and
* $obj->getMessage() == $code or
* $code is an integer and $obj->getCode() == $code
- * @access public
+ *
* @return bool true if parameter is an error
*/
- function isError($data, $code = null)
+ public static function isError($data, $code = null)
{
if (!is_a($data, 'PEAR_Error')) {
return false;
* PEAR objects. If called in an object, setErrorHandling sets
* the default behaviour for that object.
*
+ * @param object $object
+ * Object the method was called on (non-static mode)
+ *
* @param int $mode
* One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
* PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
*
* @since PHP 4.0.5
*/
- function setErrorHandling($mode = null, $options = null)
- {
- if (isset($this) && is_a($this, 'PEAR')) {
- $setmode = &$this->_default_error_mode;
- $setoptions = &$this->_default_error_options;
+ protected static function _setErrorHandling(
+ $object, $mode = null, $options = null
+ ) {
+ if ($object !== null) {
+ $setmode = &$object->_default_error_mode;
+ $setoptions = &$object->_default_error_options;
} else {
$setmode = &$GLOBALS['_PEAR_default_error_mode'];
$setoptions = &$GLOBALS['_PEAR_default_error_options'];
* @param bool $skipmsg If true, raiseError will only pass error codes,
* the error message parameter will be dropped.
*
- * @access public
* @return object a PEAR error object
* @see PEAR::setErrorHandling
* @since PHP 4.0.5
*/
- function &raiseError($message = null,
+ protected static function _raiseError($object,
+ $message = null,
$code = null,
$mode = null,
$options = null,
}
if (
- isset($this) &&
- isset($this->_expected_errors) &&
- count($this->_expected_errors) > 0 &&
- count($exp = end($this->_expected_errors))
+ $object !== null &&
+ isset($object->_expected_errors) &&
+ count($object->_expected_errors) > 0 &&
+ count($exp = end($object->_expected_errors))
) {
if ($exp[0] == "*" ||
(is_int(reset($exp)) && in_array($code, $exp)) ||
// No mode given, try global ones
if ($mode === null) {
// Class error handler
- if (isset($this) && isset($this->_default_error_mode)) {
- $mode = $this->_default_error_mode;
- $options = $this->_default_error_options;
+ if ($object !== null && isset($object->_default_error_mode)) {
+ $mode = $object->_default_error_mode;
+ $options = $object->_default_error_options;
// Global error handler
} elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
$mode = $GLOBALS['_PEAR_default_error_mode'];
if ($error_class !== null) {
$ec = $error_class;
- } elseif (isset($this) && isset($this->_error_class)) {
- $ec = $this->_error_class;
+ } elseif ($object !== null && isset($object->_error_class)) {
+ $ec = $object->_error_class;
} else {
$ec = 'PEAR_Error';
}
- if (intval(PHP_VERSION) < 5) {
- // little non-eval hack to fix bug #12147
- include 'PEAR/FixPHP5PEARWarnings.php';
- return $a;
- }
-
if ($skipmsg) {
$a = new $ec($code, $mode, $options, $userinfo);
} else {
* @param string $userinfo If you need to pass along for example debug
* information, this parameter is meant for that.
*
- * @access public
* @return object a PEAR error object
* @see PEAR::raiseError
*/
- function &throwError($message = null, $code = null, $userinfo = null)
+ protected static function _throwError($object, $message = null, $code = null, $userinfo = null)
{
- if (isset($this) && is_a($this, 'PEAR')) {
- $a = &$this->raiseError($message, $code, null, null, $userinfo);
+ if ($object !== null) {
+ $a = &$object->raiseError($message, $code, null, null, $userinfo);
return $a;
}
return $a;
}
- function staticPushErrorHandling($mode, $options = null)
+ public static function staticPushErrorHandling($mode, $options = null)
{
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
$def_mode = &$GLOBALS['_PEAR_default_error_mode'];
return true;
}
- function staticPopErrorHandling()
+ public static function staticPopErrorHandling()
{
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
$setmode = &$GLOBALS['_PEAR_default_error_mode'];
*
* @see PEAR::setErrorHandling
*/
- function pushErrorHandling($mode, $options = null)
+ protected static function _pushErrorHandling($object, $mode, $options = null)
{
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
- if (isset($this) && is_a($this, 'PEAR')) {
- $def_mode = &$this->_default_error_mode;
- $def_options = &$this->_default_error_options;
+ if ($object !== null) {
+ $def_mode = &$object->_default_error_mode;
+ $def_options = &$object->_default_error_options;
} else {
$def_mode = &$GLOBALS['_PEAR_default_error_mode'];
$def_options = &$GLOBALS['_PEAR_default_error_options'];
}
$stack[] = array($def_mode, $def_options);
- if (isset($this) && is_a($this, 'PEAR')) {
- $this->setErrorHandling($mode, $options);
+ if ($object !== null) {
+ $object->setErrorHandling($mode, $options);
} else {
PEAR::setErrorHandling($mode, $options);
}
*
* @see PEAR::pushErrorHandling
*/
- function popErrorHandling()
+ protected static function _popErrorHandling($object)
{
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
array_pop($stack);
list($mode, $options) = $stack[sizeof($stack) - 1];
array_pop($stack);
- if (isset($this) && is_a($this, 'PEAR')) {
- $this->setErrorHandling($mode, $options);
+ if ($object !== null) {
+ $object->setErrorHandling($mode, $options);
} else {
PEAR::setErrorHandling($mode, $options);
}
}
/**
- * OS independant PHP extension load. Remember to take care
+ * OS independent PHP extension load. Remember to take care
* on the correct extension name for case sensitive OSes.
*
* @param string $ext The extension name
* @return bool Success or not on the dl() call
*/
- function loadExtension($ext)
+ public static function loadExtension($ext)
{
if (extension_loaded($ext)) {
return true;
// if either returns true dl() will produce a FATAL error, stop that
if (
function_exists('dl') === false ||
- ini_get('enable_dl') != 1 ||
- ini_get('safe_mode') == 1
+ ini_get('enable_dl') != 1
) {
return false;
}
}
}
-if (PEAR_ZE2) {
- include_once 'PEAR5.php';
-}
-
function _PEAR_call_destructors()
{
global $_PEAR_destructor_object_list;
sizeof($_PEAR_destructor_object_list))
{
reset($_PEAR_destructor_object_list);
- if (PEAR_ZE2) {
- $destructLifoExists = PEAR5::getStaticProperty('PEAR', 'destructlifo');
- } else {
- $destructLifoExists = PEAR::getStaticProperty('PEAR', 'destructlifo');
- }
+
+ $destructLifoExists = PEAR::getStaticProperty('PEAR', 'destructlifo');
if ($destructLifoExists) {
$_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list);
* @author Gregory Beaver <cellog@php.net>
* @copyright 1997-2006 The PHP Group
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/manual/en/core.pear.pear-error.php
* @see PEAR::raiseError(), PEAR::throwError()
* @since Class available since PHP 4.0.2
* @access public
*
*/
- function PEAR_Error($message = 'unknown error', $code = null,
+ function __construct($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
if ($mode === null) {
$this->mode = $mode;
$this->userinfo = $userinfo;
- if (PEAR_ZE2) {
- $skiptrace = PEAR5::getStaticProperty('PEAR_Error', 'skiptrace');
- } else {
- $skiptrace = PEAR::getStaticProperty('PEAR_Error', 'skiptrace');
- }
+ $skiptrace = PEAR::getStaticProperty('PEAR_Error', 'skiptrace');
if (!$skiptrace) {
$this->backtrace = debug_backtrace();
}
}
+ /**
+ * Only here for backwards compatibility.
+ *
+ * Class "Cache_Error" still uses it, among others.
+ *
+ * @param string $message Message
+ * @param int $code Error code
+ * @param int $mode Error mode
+ * @param mixed $options See __construct()
+ * @param string $userinfo Additional user/debug info
+ */
+ public function PEAR_Error(
+ $message = 'unknown error', $code = null, $mode = null,
+ $options = null, $userinfo = null
+ ) {
+ self::__construct($message, $code, $mode, $options, $userinfo);
+ }
+
/**
* Get the error mode from an error object.
*
* @author Stig Bakken <ssb@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Autoloader.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/manual/en/core.ppm.php#core.ppm.pear-autoloader
* @since File available since Release 0.1
* @deprecated File deprecated in Release 1.4.0a1
* @author Stig Bakken <ssb@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/manual/en/core.ppm.php#core.ppm.pear-autoloader
* @since File available since Release 0.1
* @deprecated File deprecated in Release 1.4.0a1
$include_file = preg_replace('/[^a-z0-9]/i', '_', $classname);
include_once $include_file;
}
- $obj =& new $classname;
+ $obj = new $classname;
$methods = get_class_methods($classname);
foreach ($methods as $method) {
// don't import priviate methods and constructors
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Builder.php 313024 2011-07-06 19:51:24Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*
*/
require_once 'PEAR/Common.php';
require_once 'PEAR/PackageFile.php';
+require_once 'System.php';
/**
* Class to handle building (compiling) extensions.
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since PHP 4.0.2
* @see http://pear.php.net/manual/en/core.ppm.pear-builder.php
*
* @access public
*/
- function PEAR_Builder(&$ui)
+ function __construct(&$ui)
{
- parent::PEAR_Common();
+ parent::__construct();
$this->setFrontendObject($ui);
}
$pkg = $descfile;
$descfile = $pkg->getPackageFile();
} else {
- $pf = &new PEAR_PackageFile($this->config, $this->debug);
+ $pf = new PEAR_PackageFile($this->config, $this->debug);
$pkg = &$pf->fromPackageFile($descfile, PEAR_VALIDATE_NORMAL);
if (PEAR::isError($pkg)) {
return $pkg;
*/
function build($descfile, $callback = null)
{
- if (preg_match('/(\\/|\\\\|^)([^\\/\\\\]+)?php(.+)?$/',
+ if (preg_match('/(\\/|\\\\|^)([^\\/\\\\]+)?php([^\\/\\\\]+)?$/',
$this->config->get('php_bin'), $matches)) {
if (isset($matches[2]) && strlen($matches[2]) &&
trim($matches[2]) != trim($this->config->get('php_prefix'))) {
$this->addTempFile($dir);
}
} else {
- $pf = &new PEAR_PackageFile($this->config);
+ $pf = new PEAR_PackageFile($this->config);
$pkg = &$pf->fromPackageFile($descfile, PEAR_VALIDATE_NORMAL);
if (PEAR::isError($pkg)) {
return $pkg;
// {{{ start of interactive part
$configure_command = "$dir/configure";
+
+ $phpConfigName = $this->config->get('php_prefix')
+ . 'php-config'
+ . $this->config->get('php_suffix');
+ $phpConfigPath = System::which($phpConfigName);
+ if ($phpConfigPath !== false) {
+ $configure_command .= ' --with-php-config='
+ . $phpConfigPath;
+ }
+
$configure_options = $pkg->getConfigureOptions();
if ($configure_options) {
foreach ($configure_options as $o) {
if (!file_exists($build_dir) || !is_dir($build_dir) || !chdir($build_dir)) {
return $this->raiseError("could not chdir to $build_dir");
}
- putenv('PHP_PEAR_VERSION=1.9.4');
+ putenv('PHP_PEAR_VERSION=1.10.1');
foreach ($to_run as $cmd) {
$err = $this->_runCommand($cmd, $callback);
if (PEAR::isError($err)) {
return ($exitcode == 0);
}
- function log($level, $msg)
+ function log($level, $msg, $append_crlf = true)
{
if ($this->current_callback) {
if ($this->debug >= $level) {
}
return;
}
- return PEAR_Common::log($level, $msg);
+ return parent::log($level, $msg, $append_crlf);
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: ChannelFile.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
*/
var $_isValid = false;
- function PEAR_ChannelFile()
+ function __construct()
{
- $this->_stack = &new PEAR_ErrorStack('PEAR_ChannelFile');
+ $this->_stack = new PEAR_ErrorStack('PEAR_ChannelFile');
$this->_stack->setErrorMessageTemplate($this->_getErrorMessage());
$this->_isValid = false;
}
/**
* @param array
- * @static
+ *
* @return PEAR_ChannelFile|false false if invalid
*/
- function &fromArray($data, $compatibility = false, $stackClass = 'PEAR_ErrorStack')
- {
+ public static function &fromArray(
+ $data, $compatibility = false, $stackClass = 'PEAR_ErrorStack'
+ ) {
$a = new PEAR_ChannelFile($compatibility, $stackClass);
$a->_fromArray($data);
if (!$a->validate()) {
/**
* Unlike {@link fromArray()} this does not do any validation
+ *
* @param array
- * @static
+ *
* @return PEAR_ChannelFile
*/
- function &fromArrayWithErrors($data, $compatibility = false,
- $stackClass = 'PEAR_ErrorStack')
- {
+ public static function &fromArrayWithErrors(
+ $data, $compatibility = false, $stackClass = 'PEAR_ErrorStack'
+ ) {
$a = new PEAR_ChannelFile($compatibility, $stackClass);
$a->_fromArray($data);
return $a;
if (isset($this->_channelInfo['validatepackage'])) {
if ($package == $this->_channelInfo['validatepackage']) {
// channel validation packages are always validated by PEAR_Validate
- $val = &new PEAR_Validate;
+ $val = new PEAR_Validate;
return $val;
}
$this->_channelInfo['validatepackage']['_content']) . '.php';
$vclass = str_replace('.', '_',
$this->_channelInfo['validatepackage']['_content']);
- $val = &new $vclass;
+ $val = new $vclass;
} else {
$a = false;
return $a;
} else {
$vclass = str_replace('.', '_',
$this->_channelInfo['validatepackage']['_content']);
- $val = &new $vclass;
+ $val = new $vclass;
}
} else {
- $val = &new PEAR_Validate;
+ $val = new PEAR_Validate;
}
return $val;
return time();
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Parser.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Command.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
* @param object $config Instance of PEAR_Config object
*
* @return object the command object or a PEAR error
- *
- * @access public
- * @static
*/
- function &factory($command, &$config)
+ public static function &factory($command, &$config)
{
if (empty($GLOBALS['_PEAR_Command_commandlist'])) {
PEAR_Command::registerCommands();
return $a;
}
$ui =& PEAR_Command::getFrontendObject();
- $obj = &new $class($ui, $config);
+ $obj = new $class($ui, $config);
return $obj;
}
// }}}
// {{{ & getObject()
- function &getObject($command)
+ public static function &getObject($command)
{
$class = $GLOBALS['_PEAR_Command_commandlist'][$command];
if (!class_exists($class)) {
}
$ui =& PEAR_Command::getFrontendObject();
$config = &PEAR_Config::singleton();
- $obj = &new $class($ui, $config);
+ $obj = new $class($ui, $config);
return $obj;
}
* Get instance of frontend object.
*
* @return object|PEAR_Error
- * @static
*/
- function &getFrontendObject()
+ public static function &getFrontendObject()
{
$a = &PEAR_Frontend::singleton();
return $a;
* @param string $uiclass Name of class implementing the frontend
*
* @return object the frontend object, or a PEAR error
- * @static
*/
- function &setFrontendClass($uiclass)
+ public static function &setFrontendClass($uiclass)
{
$a = &PEAR_Frontend::setFrontendClass($uiclass);
return $a;
* @param string $uitype Name of the frontend type (for example "CLI")
*
* @return object the frontend object, or a PEAR error
- * @static
*/
- function setFrontendType($uitype)
+ public static function setFrontendType($uitype)
{
$uiclass = 'PEAR_Frontend_' . $uitype;
return PEAR_Command::setFrontendClass($uiclass);
* included.
*
* @return bool TRUE on success, a PEAR error on failure
- *
- * @access public
- * @static
*/
- function registerCommands($merge = false, $dir = null)
+ public static function registerCommands($merge = false, $dir = null)
{
$parser = new PEAR_XMLParser;
if ($dir === null) {
* classes implement them.
*
* @return array command => implementing class
- *
- * @access public
- * @static
*/
- function getCommands()
+ public static function getCommands()
{
if (empty($GLOBALS['_PEAR_Command_commandlist'])) {
PEAR_Command::registerCommands();
* Get the list of command shortcuts.
*
* @return array shortcut => command
- *
- * @access public
- * @static
*/
- function getShortcuts()
+ public static function getShortcuts()
{
if (empty($GLOBALS['_PEAR_Command_shortcuts'])) {
PEAR_Command::registerCommands();
* @param array $long_args (reference) long getopt format
*
* @return void
- *
- * @access public
- * @static
*/
- function getGetoptArgs($command, &$short_args, &$long_args)
+ public static function getGetoptArgs($command, &$short_args, &$long_args)
{
if (empty($GLOBALS['_PEAR_Command_commandlist'])) {
PEAR_Command::registerCommands();
* @param string $command Name of the command
*
* @return string command description
- *
- * @access public
- * @static
*/
- function getDescription($command)
+ public static function getDescription($command)
{
if (!isset($GLOBALS['_PEAR_Command_commanddesc'][$command])) {
return null;
* Get help for command.
*
* @param string $command Name of the command to return help for
- *
- * @access public
- * @static
*/
- function getHelp($command)
+ public static function getHelp($command)
{
$cmds = PEAR_Command::getCommands();
if (isset($GLOBALS['_PEAR_Command_shortcuts'][$command])) {
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Auth.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
* @deprecated since 1.8.0alpha1
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
* @deprecated since 1.8.0alpha1
*
* @access public
*/
- function PEAR_Command_Auth(&$ui, &$config)
+ function __construct(&$ui, &$config)
{
- parent::PEAR_Command_Channels($ui, $config);
+ parent::__construct($ui, $config);
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Build.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
*
* @access public
*/
- function PEAR_Command_Build(&$ui, &$config)
+ function __construct(&$ui, &$config)
{
- parent::PEAR_Command_Common($ui, $config);
+ parent::__construct($ui, $config);
}
function doBuild($command, $options, $params)
$params[0] = 'package.xml';
}
- $builder = &new PEAR_Builder($this->ui);
+ $builder = new PEAR_Builder($this->ui);
$this->debug = $this->config->get('verbose');
$err = $builder->build($params[0], array(&$this, 'buildCallback'));
if (PEAR::isError($err)) {
$this->ui->outputData(rtrim($data), 'build');
}
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Channels.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
*
* @access public
*/
- function PEAR_Command_Channels(&$ui, &$config)
+ function __construct(&$ui, &$config)
{
- parent::PEAR_Command_Common($ui, $config);
+ parent::__construct($ui, $config);
}
function _sortChannels($a, $b)
'already aliased to "' . strtolower($params[1]) . '", cannot re-alias');
}
- $chan = &$reg->getChannel($params[0]);
+ $chan = $reg->getChannel($params[0]);
if (PEAR::isError($chan)) {
return $this->raiseError('Corrupt registry? Error retrieving channel "' . $params[0] .
'" information (' . $chan->getMessage() . ')');
$this->config->store();
return true;
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Common.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
*
* @access public
*/
- function PEAR_Command_Common(&$ui, &$config)
+ function __construct(&$ui, &$config)
{
- parent::PEAR();
+ parent::__construct();
$this->config = &$config;
$this->ui = &$ui;
}
return $this->$func($command, $options, $params);
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Config.php 313024 2011-07-06 19:51:24Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
*
* @access public
*/
- function PEAR_Command_Config(&$ui, &$config)
+ function __construct(&$ui, &$config)
{
- parent::PEAR_Command_Common($ui, $config);
+ parent::__construct($ui, $config);
}
function doConfigShow($command, $options, $params)
}
$params[1] = realpath($params[1]);
- $config = &new PEAR_Config($params[1], '#no#system#config#', false, false);
+ $config = new PEAR_Config($params[1], '#no#system#config#', false, false);
if ($root{strlen($root) - 1} == '/') {
$root = substr($root, 0, strlen($root) - 1);
}
$config->set('download_dir', $windows ? "$root\\pear\\download" : "$root/pear/download");
$config->set('temp_dir', $windows ? "$root\\pear\\temp" : "$root/pear/temp");
$config->set('bin_dir', $windows ? "$root\\pear" : "$root/pear");
+ $config->set('man_dir', $windows ? "$root\\pear\\man" : "$root/pear/man");
$config->writeConfigFile();
$this->_showConfig($config);
$this->ui->outputData('Successfully created default configuration file "' . $params[1] . '"',
return false;
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Install.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
*
* @access public
*/
- function PEAR_Command_Install(&$ui, &$config)
+ function __construct(&$ui, &$config)
{
- parent::PEAR_Command_Common($ui, $config);
+ parent::__construct($ui, $config);
}
// }}}
if (!class_exists('PEAR_Downloader')) {
require_once 'PEAR/Downloader.php';
}
- $a = &new PEAR_Downloader($ui, $options, $config);
+ $a = new PEAR_Downloader($ui, $options, $config);
return $a;
}
if (!class_exists('PEAR_Installer')) {
require_once 'PEAR/Installer.php';
}
- $a = &new PEAR_Installer($ui);
+ $a = new PEAR_Installer($ui);
return $a;
}
$ts = preg_match('/Thread Safety.+enabled/', $info) ? '_ts' : '';
$zend_extension_line = 'zend_extension' . $debug . $ts;
$all = @file($filename);
- if (!$all) {
+ if ($all === false) {
return PEAR::raiseError('php.ini "' . $filename .'" could not be read');
}
$zend_extensions = $extensions = array();
$packrootphp_dir = $this->installer->_prependPath(
$this->config->get('php_dir', null, 'pear.php.net'),
$options['packagingroot']);
- $instreg = new PEAR_Registry($packrootphp_dir); // other instreg!
+ $metadata_dir = $this->config->get('metadata_dir', null, 'pear.php.net');
+ if ($metadata_dir) {
+ $metadata_dir = $this->installer->_prependPath(
+ $metadata_dir,
+ $options['packagingroot']);
+ }
+ $instreg = new PEAR_Registry($packrootphp_dir, false, false, $metadata_dir); // other instreg!
if ($this->config->get('verbose') > 2) {
$this->ui->outputData('using package root: ' . $options['packagingroot']);
if ($param->getPackageType() == 'extsrc' ||
$param->getPackageType() == 'extbin') {
$exttype = 'extension';
+ $extpath = $pinfo[1]['basename'];
} else {
- ob_start();
- phpinfo(INFO_GENERAL);
- $info = ob_get_contents();
- ob_end_clean();
- $debug = function_exists('leak') ? '_debug' : '';
- $ts = preg_match('/Thread Safety.+enabled/', $info) ? '_ts' : '';
- $exttype = 'zend_extension' . $debug . $ts;
+ $exttype = 'zend_extension';
+ $extpath = $atts['installed_as'];
}
$extrainfo[] = 'You should add "' . $exttype . '=' .
- $pinfo[1]['basename'] . '" to php.ini';
+ $extpath . '" to php.ini';
} else {
$extrainfo[] = 'Extension ' . $instpkg->getProvidesExtension() .
' enabled in php.ini';
$dest .= DIRECTORY_SEPARATOR . $pkgname;
$orig = $pkgname . '-' . $pkgversion;
- $tar = &new Archive_Tar($pkgfile->getArchiveFile());
+ $tar = new Archive_Tar($pkgfile->getArchiveFile());
if (!$tar->extractModify($dest, $orig)) {
return $this->raiseError('unable to unpack ' . $pkgfile->getArchiveFile());
}
if (!isset($latestReleases[$channel])) {
// fill in cache for this channel
- $chan = &$reg->getChannel($channel);
+ $chan = $reg->getChannel($channel);
if (PEAR::isError($chan)) {
return $this->raiseError($chan);
}
return $ret;
}
-}
\ No newline at end of file
+}
* @author Alexander Merz <alexmerz@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Mirror.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.2.0
*/
* @author Alexander Merz <alexmerz@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.2.0
*/
* @param object PEAR_Frontend a reference to an frontend
* @param object PEAR_Config a reference to the configuration data
*/
- function PEAR_Command_Mirror(&$ui, &$config)
+ function __construct(&$ui, &$config)
{
- parent::PEAR_Command_Common($ui, $config);
+ parent::__construct($ui, $config);
}
/**
* @param string $command the command
* @param array $options the command options before the command
* @param array $params the stuff after the command name
- * @return bool true if succesful
+ * @return bool true if successful
* @throw PEAR_Error
*/
function doDownloadAll($command, $options, $params)
return true;
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Package.php 313024 2011-07-06 19:51:24Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
*
* @access public
*/
- function PEAR_Command_Package(&$ui, &$config)
+ function __construct(&$ui, &$config)
{
- parent::PEAR_Command_Common($ui, $config);
+ parent::__construct($ui, $config);
}
function _displayValidationResults($err, $warn, $strict = false)
if (!class_exists('PEAR_Packager')) {
require_once 'PEAR/Packager.php';
}
- $a = &new PEAR_Packager;
+ $a = new PEAR_Packager;
return $a;
}
if (!class_exists('PEAR_PackageFile')) {
require_once 'PEAR/PackageFile.php';
}
- $a = &new PEAR_PackageFile($config, $debug);
+ $a = new PEAR_PackageFile($config, $debug);
$common = new PEAR_Common;
$common->ui = $this->ui;
$a->setLogger($common);
$info = $obj->fromPackageFile($params[0], PEAR_VALIDATE_NORMAL);
} else {
$archive = $info->getArchiveFile();
- $tar = &new Archive_Tar($archive);
+ $tar = new Archive_Tar($archive);
$tar->extract(dirname($info->getPackageFile()));
$info->setPackageFile(dirname($info->getPackageFile()) . DIRECTORY_SEPARATOR .
$info->getPackage() . '-' . $info->getVersion() . DIRECTORY_SEPARATOR .
'name' => 'modified',
'type' => 'yesno',
'default' => 'no',
- 'prompt' => 'You have files in your SVN checkout (' . $path['from'] . ') that have been modified but not commited, do you still want to tag ' . $version . '?',
+ 'prompt' => 'You have files in your SVN checkout (' . $path['from'] . ') that have been modified but not committed, do you still want to tag ' . $version . '?',
));
$answers = $this->ui->confirmDialog($params);
);
foreach ($deps as $type => $subd) {
$req = ($type == 'required') ? 'Yes' : 'No';
- if ($type == 'group') {
+ if ($type == 'group' && isset($subd['attribs']['name'])) {
$group = $subd['attribs']['name'];
} else {
$group = '';
if (!class_exists('PEAR_Installer')) {
require_once 'PEAR/Installer.php';
}
- $a = &new PEAR_Installer($ui);
+ $a = new PEAR_Installer($ui);
return $a;
}
}
if (class_exists('PEAR_Command_Packaging')) {
- $a = &new PEAR_Command_Packaging($ui, $config);
+ $a = new PEAR_Command_Packaging($ui, $config);
} else {
$a = null;
}
$this->ui->outputData('Wrote new version 2.0 package.xml to "' . $saved . '"');
return true;
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 2005-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Pickle.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 2005-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.1
*/
*
* @access public
*/
- function PEAR_Command_Pickle(&$ui, &$config)
+ function __construct(&$ui, &$config)
{
- parent::PEAR_Command_Common($ui, $config);
+ parent::__construct($ui, $config);
}
/**
require_once 'PEAR/Packager.php';
}
- $a = &new PEAR_Packager;
+ $a = new PEAR_Packager;
return $a;
}
require_once 'PEAR/PackageFile.php';
}
- $a = &new PEAR_PackageFile($config, $debug);
+ $a = new PEAR_PackageFile($config, $debug);
$common = new PEAR_Common;
$common->ui = $this->ui;
$a->setLogger($common);
$gen = &$pf->getDefaultGenerator();
$gen->toPackageFile('.');
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Registry.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
*
* @access public
*/
- function PEAR_Command_Registry(&$ui, &$config)
+ function __construct(&$ui, &$config)
{
- parent::PEAR_Command_Common($ui, $config);
+ parent::__construct($ui, $config);
}
function _sortinfo($a, $b)
require_once 'PEAR/PackageFile.php';
}
- $pkg = &new PEAR_PackageFile($this->config, $this->_debug);
+ $pkg = new PEAR_PackageFile($this->config, $this->_debug);
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$info = &$pkg->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL);
PEAR::staticPopErrorHandling();
require_once 'PEAR/PackageFile.php';
}
- $pkg = &new PEAR_PackageFile($this->config, $this->_debug);
+ $pkg = new PEAR_PackageFile($this->config, $this->_debug);
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$obj = &$pkg->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL);
PEAR::staticPopErrorHandling();
$data['raw'] = $obj->getArray(); // no validation needed
$this->ui->outputData($data, 'package-info');
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Remote.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
*
* @access public
*/
- function PEAR_Command_Remote(&$ui, &$config)
+ function __construct(&$ui, &$config)
{
- parent::PEAR_Command_Common($ui, $config);
+ parent::__construct($ui, $config);
}
function _checkChannelForStatus($channel, $chan)
if (!class_exists('PEAR_Downloader')) {
require_once 'PEAR/Downloader.php';
}
- $a = &new PEAR_Downloader($this->ui, $options, $this->config);
+ $a = new PEAR_Downloader($this->ui, $options, $this->config);
return $a;
}
$preferred_mirror = $this->config->get('preferred_mirror');
if ($chan->supportsREST($preferred_mirror) &&
(
- //($base2 = $chan->getBaseURL('REST1.4', $preferred_mirror)) ||
- ($base = $chan->getBaseURL('REST1.0', $preferred_mirror))
+ ($base2 = $chan->getBaseURL('REST1.3', $preferred_mirror))
+ || ($base = $chan->getBaseURL('REST1.0', $preferred_mirror))
)
) {
if ($base2) {
- $rest = &$this->config->getREST('1.4', array());
+ $rest = &$this->config->getREST('1.3', array());
$base = $base2;
} else {
$rest = &$this->config->getREST('1.0', array());
$this->ui->outputData(rtrim($output), $command);
return $num;
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Test.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
'shortopt' => 'x',
'doc' => 'Generate a code coverage report (requires Xdebug 2.0.0+)',
),
+ 'showdiff' => array(
+ 'shortopt' => 'd',
+ 'doc' => 'Output diff on test failure',
+ ),
),
'doc' => '[testfile|dir ...]
Run regression tests with PHP\'s regression testing script (run-tests.php).',
*
* @access public
*/
- function PEAR_Command_Test(&$ui, &$config)
+ function __construct(&$ui, &$config)
{
- parent::PEAR_Command_Common($ui, $config);
+ parent::__construct($ui, $config);
}
function doRunTests($command, $options, $params)
}
}
- return true;
+ if (count($failed) == 0) {
+ return true;
+ }
+ return $this->raiseError('Some tests failed');
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Common.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1.0
* @deprecated File deprecated since Release 1.4.0a1
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
* @deprecated This class will disappear, and its components will be spread
*
* @access public
*/
- function PEAR_Common()
+ function __construct()
{
- parent::PEAR();
+ parent::__construct();
$this->config = &PEAR_Config::singleton();
$this->debug = $this->config->get('verbose');
}
* @param string $msg message to write to the log
*
* @return void
- *
- * @access public
- * @static
*/
- function log($level, $msg, $append_crlf = true)
+ public function log($level, $msg, $append_crlf = true)
{
if ($this->debug >= $level) {
if (!class_exists('PEAR_Frontend')) {
* Get the valid roles for a PEAR package maintainer
*
* @return array
- * @static
*/
- function getUserRoles()
+ public static function getUserRoles()
{
return $GLOBALS['_PEAR_Common_maintainer_roles'];
}
* Get the valid package release states of packages
*
* @return array
- * @static
*/
- function getReleaseStates()
+ public static function getReleaseStates()
{
return $GLOBALS['_PEAR_Common_release_states'];
}
* Get the implemented dependency types (php, ext, pkg etc.)
*
* @return array
- * @static
*/
- function getDependencyTypes()
+ public static function getDependencyTypes()
{
return $GLOBALS['_PEAR_Common_dependency_types'];
}
* Get the implemented dependency relations (has, lt, ge etc.)
*
* @return array
- * @static
*/
- function getDependencyRelations()
+ public static function getDependencyRelations()
{
return $GLOBALS['_PEAR_Common_dependency_relations'];
}
* Get the implemented file roles
*
* @return array
- * @static
*/
- function getFileRoles()
+ public static function getFileRoles()
{
return $GLOBALS['_PEAR_Common_file_roles'];
}
* Get the implemented file replacement types in
*
* @return array
- * @static
*/
- function getReplacementTypes()
+ public static function getReplacementTypes()
{
return $GLOBALS['_PEAR_Common_replacement_types'];
}
* Get the implemented file replacement types in
*
* @return array
- * @static
*/
- function getProvideTypes()
+ public static function getProvideTypes()
{
return $GLOBALS['_PEAR_Common_provide_types'];
}
* Get the implemented file replacement types in
*
* @return array
- * @static
*/
- function getScriptPhases()
+ public static function getScriptPhases()
{
return $GLOBALS['_PEAR_Common_script_phases'];
}
/**
* @param string $path relative or absolute include path
* @return boolean
- * @static
*/
- function isIncludeable($path)
+ public static function isIncludeable($path)
{
if (file_exists($path) && is_readable($path)) {
return true;
*/
function infoFromTgzFile($file)
{
- $packagefile = &new PEAR_PackageFile($this->config);
+ $packagefile = new PEAR_PackageFile($this->config);
$pf = &$packagefile->fromTgzFile($file, PEAR_VALIDATE_NORMAL);
return $this->_postProcessChecks($pf);
}
*/
function infoFromDescriptionFile($descfile)
{
- $packagefile = &new PEAR_PackageFile($this->config);
+ $packagefile = new PEAR_PackageFile($this->config);
$pf = &$packagefile->fromPackageFile($descfile, PEAR_VALIDATE_NORMAL);
return $this->_postProcessChecks($pf);
}
*/
function infoFromString($data)
{
- $packagefile = &new PEAR_PackageFile($this->config);
+ $packagefile = new PEAR_PackageFile($this->config);
$pf = &$packagefile->fromXmlString($data, PEAR_VALIDATE_NORMAL, false);
return $this->_postProcessChecks($pf);
}
function infoFromAny($info)
{
if (is_string($info) && file_exists($info)) {
- $packagefile = &new PEAR_PackageFile($this->config);
+ $packagefile = new PEAR_PackageFile($this->config);
$pf = &$packagefile->fromAnyFile($info, PEAR_VALIDATE_NORMAL);
if (PEAR::isError($pf)) {
$errs = $pf->getUserinfo();
function xmlFromInfo($pkginfo)
{
$config = &PEAR_Config::singleton();
- $packagefile = &new PEAR_PackageFile($config);
+ $packagefile = new PEAR_PackageFile($config);
$pf = &$packagefile->fromArray($pkginfo);
$gen = &$pf->getDefaultGenerator();
return $gen->toXml(PEAR_VALIDATE_PACKAGING);
function validatePackageInfo($info, &$errors, &$warnings, $dir_prefix = '')
{
$config = &PEAR_Config::singleton();
- $packagefile = &new PEAR_PackageFile($config);
+ $packagefile = new PEAR_PackageFile($config);
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
if (strpos($info, '<?xml') !== false) {
$pf = &$packagefile->fromXmlString($info, PEAR_VALIDATE_NORMAL, '');
* @param string $save_dir (optional) directory to save file in
* @param mixed $callback (optional) function/method to call for status
* updates
- *
- * @return string Returns the full path of the downloaded file or a PEAR
- * error on failure. If the error is caused by
- * socket-related errors, the error object will
- * have the fsockopen error code available through
- * getCode().
+ * @param false|string|array $lastmodified header values to check against
+ * for caching
+ * use false to return the header
+ * values from this download
+ * @param false|array $accept Accept headers to send
+ * @param false|string $channel Channel to use for retrieving
+ * authentication
+ *
+ * @return mixed Returns the full path of the downloaded file or a PEAR
+ * error on failure. If the error is caused by
+ * socket-related errors, the error object will
+ * have the fsockopen error code available through
+ * getCode(). If caching is requested, then return the header
+ * values.
+ * If $lastmodified was given and the there are no changes,
+ * boolean false is returned.
*
* @access public
- * @deprecated in favor of PEAR_Downloader::downloadHttp()
*/
- function downloadHttp($url, &$ui, $save_dir = '.', $callback = null)
- {
+ function downloadHttp(
+ $url, &$ui, $save_dir = '.', $callback = null, $lastmodified = null,
+ $accept = false, $channel = false
+ ) {
if (!class_exists('PEAR_Downloader')) {
require_once 'PEAR/Downloader.php';
}
- return PEAR_Downloader::downloadHttp($url, $ui, $save_dir, $callback);
+ return PEAR_Downloader::_downloadHttp(
+ $this, $url, $ui, $save_dir, $callback, $lastmodified,
+ $accept, $channel
+ );
}
}
require_once 'PEAR/Config.php';
-require_once 'PEAR/PackageFile.php';
\ No newline at end of file
+require_once 'PEAR/PackageFile.php';
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Config.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
}
}
+// Default for metadata_dir
+if (getenv('PHP_PEAR_METADATA_DIR')) {
+ define('PEAR_CONFIG_DEFAULT_METADATA_DIR', getenv('PHP_PEAR_METADATA_DIR'));
+} else {
+ define('PEAR_CONFIG_DEFAULT_METADATA_DIR', '');
+}
+
// Default for ext_dir
if (getenv('PHP_PEAR_EXTENSION_DIR')) {
define('PEAR_CONFIG_DEFAULT_EXT_DIR', getenv('PHP_PEAR_EXTENSION_DIR'));
$PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'www');
}
+// Default for man_dir
+if (getenv('PHP_PEAR_MAN_DIR')) {
+ define('PEAR_CONFIG_DEFAULT_MAN_DIR', getenv('PHP_PEAR_MAN_DIR'));
+} else {
+ if (defined('PHP_MANDIR')) { // Added in PHP5.3.7
+ define('PEAR_CONFIG_DEFAULT_MAN_DIR', PHP_MANDIR);
+ } else {
+ define('PEAR_CONFIG_DEFAULT_MAN_DIR', PHP_PREFIX . DIRECTORY_SEPARATOR .
+ 'local' . DIRECTORY_SEPARATOR .'man');
+ }
+}
+
// Default for test_dir
if (getenv('PHP_PEAR_TEST_DIR')) {
define('PEAR_CONFIG_DEFAULT_TEST_DIR', getenv('PHP_PEAR_TEST_DIR'));
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
'prompt' => 'PEAR www files directory',
'group' => 'File Locations (Advanced)',
),
+ 'man_dir' => array(
+ 'type' => 'directory',
+ 'default' => PEAR_CONFIG_DEFAULT_MAN_DIR,
+ 'doc' => 'directory where unix manual pages are installed',
+ 'prompt' => 'Systems manpage files directory',
+ 'group' => 'File Locations (Advanced)',
+ ),
'test_dir' => array(
'type' => 'directory',
'default' => PEAR_CONFIG_DEFAULT_TEST_DIR,
'prompt' => 'php.ini location',
'group' => 'File Locations (Advanced)',
),
+ 'metadata_dir' => array(
+ 'type' => 'directory',
+ 'default' => PEAR_CONFIG_DEFAULT_METADATA_DIR,
+ 'doc' => 'directory where metadata files are installed (registry, filemap, channels, ...)',
+ 'prompt' => 'PEAR metadata directory',
+ 'group' => 'File Locations (Advanced)',
+ ),
// Maintainers
'username' => array(
'type' => 'string',
*
* @see PEAR_Config::singleton
*/
- function PEAR_Config($user_file = '', $system_file = '', $ftp_file = false,
+ function __construct($user_file = '', $system_file = '', $ftp_file = false,
$strict = true)
{
- $this->PEAR();
+ parent::__construct();
PEAR_Installer_Role::initializeConfig($this);
$sl = DIRECTORY_SEPARATOR;
if (empty($user_file)) {
$this->configuration['default'][$key] = $info['default'];
}
- $this->_registry['default'] = &new PEAR_Registry($this->configuration['default']['php_dir']);
+ $this->_registry['default'] = new PEAR_Registry(
+ $this->configuration['default']['php_dir'], false, false,
+ $this->configuration['default']['metadata_dir']);
$this->_registry['default']->setConfig($this, false);
$this->_regInitialized['default'] = false;
//$GLOBALS['_PEAR_Config_instance'] = &$this;
/**
* Return the default locations of user and system configuration files
- * @static
*/
- function getDefaultConfigFiles()
+ public static function getDefaultConfigFiles()
{
$sl = DIRECTORY_SEPARATOR;
if (OS_WINDOWS) {
*
* @return object an existing or new PEAR_Config instance
*
- * @access public
- *
* @see PEAR_Config::PEAR_Config
*/
- function &singleton($user_file = '', $system_file = '', $strict = true)
+ public static function &singleton($user_file = '', $system_file = '', $strict = true)
{
if (is_object($GLOBALS['_PEAR_Config_instance'])) {
return $GLOBALS['_PEAR_Config_instance'];
}
- $t_conf = &new PEAR_Config($user_file, $system_file, false, $strict);
+ $t_conf = new PEAR_Config($user_file, $system_file, false, $strict);
if ($t_conf->_errorsFound > 0) {
return $t_conf->lastError;
}
$this->configuration[$layer] = $data;
$this->_setupChannels();
if (!$this->_noRegistry && ($phpdir = $this->get('php_dir', $layer, 'pear.php.net'))) {
- $this->_registry[$layer] = &new PEAR_Registry($phpdir);
+ $this->_registry[$layer] = new PEAR_Registry(
+ $phpdir, false, false,
+ $this->get('metadata_dir', $layer, 'pear.php.net'));
$this->_registry[$layer]->setConfig($this, false);
$this->_regInitialized[$layer] = false;
} else {
return PEAR::raiseError('PEAR_RemoteInstaller must be installed to use remote config');
}
- $this->_ftp = &new PEAR_FTP;
+ $this->_ftp = new PEAR_FTP;
$this->_ftp->pushErrorHandling(PEAR_ERROR_RETURN);
$e = $this->_ftp->init($path);
if (PEAR::isError($e)) {
$this->_setupChannels();
if (!$this->_noRegistry && ($phpdir = $this->get('php_dir', $layer, 'pear.php.net'))) {
- $this->_registry[$layer] = &new PEAR_Registry($phpdir);
+ $this->_registry[$layer] = new PEAR_Registry(
+ $phpdir, false, false,
+ $this->get('metadata_dir', $layer, 'pear.php.net'));
$this->_registry[$layer]->setConfig($this, false);
$this->_regInitialized[$layer] = false;
} else {
* @param array
* @param array
* @return array
- * @static
*/
- function arrayMergeRecursive($arr2, $arr1)
+ public static function arrayMergeRecursive($arr2, $arr1)
{
$ret = array();
foreach ($arr2 as $key => $data) {
}
$size = filesize($file);
- $rt = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
fclose($fp);
$contents = file_get_contents($file);
if (empty($contents)) {
return $this->raiseError('Configuration file "' . $file . '" is empty');
}
- set_magic_quotes_runtime($rt);
-
$version = false;
if (preg_match('/^#PEAR_Config\s+(\S+)\s+/si', $contents, $matches)) {
$version = $matches[1];
if ($key == 'preferred_mirror') {
$reg = &$this->getRegistry();
if (is_object($reg)) {
- $chan = &$reg->getChannel($channel);
+ $chan = $reg->getChannel($channel);
if (PEAR::isError($chan)) {
return $channel;
}
if ($key == 'preferred_mirror') {
$reg = &$this->getRegistry();
if (is_object($reg)) {
- $chan = &$reg->getChannel($channel);
+ $chan = $reg->getChannel($channel);
if (PEAR::isError($chan)) {
return $channel;
}
if ($ret !== null) {
$reg = &$this->getRegistry($layer);
if (is_object($reg)) {
- $chan = &$reg->getChannel($channel);
+ $chan = $reg->getChannel($channel);
if (PEAR::isError($chan)) {
return $channel;
}
$reg = &$this->getRegistry($layer);
if (is_object($reg)) {
- $chan = &$reg->getChannel($channel ? $channel : 'pear.php.net');
+ $chan = $reg->getChannel($channel ? $channel : 'pear.php.net');
if (PEAR::isError($chan)) {
return false;
}
if ($key == 'php_dir' && !$this->_noRegistry) {
if (!isset($this->_registry[$layer]) ||
$value != $this->_registry[$layer]->install_dir) {
- $this->_registry[$layer] = &new PEAR_Registry($value);
+ $this->_registry[$layer] = new PEAR_Registry($value);
$this->_regInitialized[$layer] = false;
$this->_registry[$layer]->setConfig($this, false);
}
if (!is_object($this->_registry[$layer])) {
if ($phpdir = $this->get('php_dir', $layer, 'pear.php.net')) {
- $this->_registry[$layer] = &new PEAR_Registry($phpdir);
+ $this->_registry[$layer] = new PEAR_Registry(
+ $phpdir, false, false,
+ $this->get('metadata_dir', $layer, 'pear.php.net'));
$this->_registry[$layer]->setConfig($this, false);
$this->_regInitialized[$layer] = false;
} else {
require_once 'PEAR/REST/' . $version . '.php';
}
- $remote = &new $class($this, $options);
+ $remote = new $class($this, $options);
return $remote;
}
continue;
}
$this->_registry[$layer] =
- &new PEAR_Registry($this->get('php_dir', $layer, 'pear.php.net'));
+ new PEAR_Registry(
+ $this->get('php_dir', $layer, 'pear.php.net'), false, false,
+ $this->get('metadata_dir', $layer, 'pear.php.net'));
$this->_registry[$layer]->setConfig($this, false);
$this->_regInitialized[$layer] = false;
}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Dependency2.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @param array format of PEAR_Registry::parsedPackageName()
* @param int installation state (one of PEAR_VALIDATE_*)
*/
- function PEAR_Dependency2(&$config, $installoptions, $package,
+ function __construct(&$config, $installoptions, $package,
$state = PEAR_VALIDATE_INSTALLING)
{
$this->_config = &$config;
*/
function getPEARVersion()
{
- return '1.9.4';
+ return '1.10.1';
}
function validatePearinstallerDependency($dep)
* @param boolean whether this is a required dependency
* @param array a list of downloaded packages to be installed, if any
* @param boolean if true, then deps on pear.php.net that fail will also check
- * against pecl.php.net packages to accomodate extensions that have
+ * against pecl.php.net packages to accommodate extensions that have
* moved to pecl.php.net from pear.php.net
*/
function validatePackageDependency($dep, $required, $params, $depv1 = false)
if (!class_exists('PEAR_Downloader_Package')) {
require_once 'PEAR/Downloader/Package.php';
}
- $dp = &new PEAR_Downloader_Package($dl);
+ $dp = new PEAR_Downloader_Package($dl);
$dp->setPackageFile($downloaded[$i]);
- $params[$i] = &$dp;
+ $params[$i] = $dp;
}
// check cache
require_once 'PEAR/Downloader/Package.php';
}
- $dp = &new PEAR_Downloader_Package($dl);
+ $dp = new PEAR_Downloader_Package($dl);
if (is_object($pkg)) {
$dp->setPackageFile($pkg);
} else {
}
foreach ($ds as $d) {
- $checker = &new PEAR_Dependency2($this->_config, $this->_options,
+ $checker = new PEAR_Dependency2($this->_config, $this->_options,
array('channel' => $channel, 'package' => $package), $this->_state);
$dep = $d['dep'];
$required = $d['type'] == 'required';
return array(sprintf($msg, $this->_registry->parsedPackageNameToString(
$this->_currentPackage, true)));
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: DependencyDB.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Tomas V.V.Cox <cox@idec.net.com>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @param PEAR_Config
* @param string|false full path to the dependency database, or false to use default
* @return PEAR_DependencyDB|PEAR_Error
- * @static
*/
- function &singleton(&$config, $depdb = false)
+ public static function &singleton(&$config, $depdb = false)
{
$phpdir = $config->get('php_dir', null, 'pear.php.net');
if (!isset($GLOBALS['_PEAR_DEPENDENCYDB_INSTANCE'][$phpdir])) {
$this->_registry = &$this->_config->getRegistry();
if (!$depdb) {
- $this->_depdb = $this->_config->get('php_dir', null, 'pear.php.net') .
- DIRECTORY_SEPARATOR . '.depdb';
+ $dir = $this->_config->get('metadata_dir', null, 'pear.php.net');
+ if (!$dir) {
+ $dir = $this->_config->get('php_dir', null, 'pear.php.net');
+ }
+ $this->_depdb = $dir . DIRECTORY_SEPARATOR . '.depdb';
} else {
$this->_depdb = $depdb;
}
return $err;
}
- $rt = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
clearstatcache();
fclose($fp);
$data = unserialize(file_get_contents($this->_depdb));
- set_magic_quotes_runtime($rt);
$this->_cache = $data;
return $data;
}
return PEAR::raiseError("Could not open dependencies file `".$this->_depdb."' for writing");
}
- $rt = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
fwrite($fp, serialize($deps));
- set_magic_quotes_runtime($rt);
fclose($fp);
$this->_unlock();
$this->_cache = $deps;
);
}
}
-}
\ No newline at end of file
+}
* @author Martin Jansen <mj@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Downloader.php 313024 2011-07-06 19:51:24Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.3.0
*/
* @author Martin Jansen <mj@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.3.0
*/
*/
var $_downloadDir;
+ /**
+ * List of methods that can be called both statically and non-statically.
+ * @var array
+ */
+ protected static $bivalentMethods = array(
+ 'setErrorHandling' => true,
+ 'raiseError' => true,
+ 'throwError' => true,
+ 'pushErrorHandling' => true,
+ 'popErrorHandling' => true,
+ 'downloadHttp' => true,
+ );
+
/**
* @param PEAR_Frontend_*
* @param array
* @param PEAR_Config
*/
- function PEAR_Downloader(&$ui, $options, &$config)
+ function __construct($ui = null, $options = array(), $config = null)
{
- parent::PEAR_Common();
+ parent::__construct();
$this->_options = $options;
- $this->config = &$config;
- $this->_preferredState = $this->config->get('preferred_state');
+ if ($config !== null) {
+ $this->config = &$config;
+ $this->_preferredState = $this->config->get('preferred_state');
+ }
$this->ui = &$ui;
if (!$this->_preferredState) {
// don't inadvertantly use a non-set preferred_state
$this->_preferredState = null;
}
- if (isset($this->_options['installroot'])) {
- $this->config->setInstallRoot($this->_options['installroot']);
+ if ($config !== null) {
+ if (isset($this->_options['installroot'])) {
+ $this->config->setInstallRoot($this->_options['installroot']);
+ }
+ $this->_registry = &$config->getRegistry();
}
- $this->_registry = &$config->getRegistry();
if (isset($this->_options['alldeps']) || isset($this->_options['onlyreqdeps'])) {
$this->_installed = $this->_registry->listAllPackages();
* @param PEAR_Downloader
* @return PEAR_Downloader_Package
*/
- function &newDownloaderPackage(&$t)
+ function newDownloaderPackage(&$t)
{
if (!class_exists('PEAR_Downloader_Package')) {
require_once 'PEAR/Downloader/Package.php';
}
- $a = &new PEAR_Downloader_Package($t);
+ $a = new PEAR_Downloader_Package($t);
return $a;
}
if (!class_exists('PEAR_Dependency2')) {
require_once 'PEAR/Dependency2.php';
}
- $z = &new PEAR_Dependency2($c, $i, $p, $s);
+ $z = new PEAR_Dependency2($c, $i, $p, $s);
return $z;
}
$channelschecked = array();
// convert all parameters into PEAR_Downloader_Package objects
foreach ($params as $i => $param) {
- $params[$i] = &$this->newDownloaderPackage($this);
+ $params[$i] = $this->newDownloaderPackage($this);
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$err = $params[$i]->initialize($param);
PEAR::staticPopErrorHandling();
require_once 'System.php';
}
- $curchannel = &$this->_registry->getChannel($params[$i]->getChannel());
+ $curchannel = $this->_registry->getChannel($params[$i]->getChannel());
if (PEAR::isError($curchannel)) {
PEAR::staticPopErrorHandling();
return $this->raiseError($curchannel);
$a = $this->downloadHttp($url, $this->ui, $dir, null, $curchannel->lastModified());
PEAR::staticPopErrorHandling();
- if (PEAR::isError($a) || !$a) {
+ if ($a === false) {
+ //channel.xml not modified
+ break;
+ } else if (PEAR::isError($a)) {
// Attempt fallback to https automatically
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$a = $this->downloadHttp('https://' . $mirror .
} while (false);
}
- $chan = &$this->_registry->getChannel($parr['channel']);
+ $chan = $this->_registry->getChannel($parr['channel']);
if (PEAR::isError($chan)) {
return $chan;
}
$curchannel = $this->config->get('default_channel');
if (isset($dep['uri'])) {
$xsdversion = '2.0';
- $chan = &$this->_registry->getChannel('__uri');
+ $chan = $this->_registry->getChannel('__uri');
if (PEAR::isError($chan)) {
return $chan;
}
} while (false);
}
- $chan = &$this->_registry->getChannel($remotechannel);
+ $chan = $this->_registry->getChannel($remotechannel);
if (PEAR::isError($chan)) {
return $chan;
}
}
if (isset($dep['uri'])) {
- $info = &$this->newDownloaderPackage($this);
+ $info = $this->newDownloaderPackage($this);
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$err = $info->initialize($dep);
PEAR::staticPopErrorHandling();
* use false to return the header values from this download
* @param false|array $accept Accept headers to send
* @param false|string $channel Channel to use for retrieving authentication
- * @return string|array Returns the full path of the downloaded file or a PEAR
- * error on failure. If the error is caused by
- * socket-related errors, the error object will
- * have the fsockopen error code available through
- * getCode(). If caching is requested, then return the header
- * values.
+ * @return mixed Returns the full path of the downloaded file or a PEAR
+ * error on failure. If the error is caused by
+ * socket-related errors, the error object will
+ * have the fsockopen error code available through
+ * getCode(). If caching is requested, then return the header
+ * values.
+ * If $lastmodified was given and the there are no changes,
+ * boolean false is returned.
*
* @access public
*/
- function downloadHttp($url, &$ui, $save_dir = '.', $callback = null, $lastmodified = null,
- $accept = false, $channel = false)
- {
+ public static function _downloadHttp(
+ $object, $url, &$ui, $save_dir = '.', $callback = null, $lastmodified = null,
+ $accept = false, $channel = false
+ ) {
static $redirect = 0;
// always reset , so we are clean case of error
$wasredirect = $redirect;
$port = isset($info['port']) ? $info['port'] : null;
$path = isset($info['path']) ? $info['path'] : null;
- if (isset($this)) {
- $config = &$this->config;
+ if ($object !== null) {
+ $config = $object->config;
} else {
$config = &PEAR_Config::singleton();
}
}
$request .= $ifmodifiedsince .
- "User-Agent: PEAR/1.9.4/PHP/" . PHP_VERSION . "\r\n";
+ "User-Agent: PEAR/1.10.1/PHP/" . PHP_VERSION . "\r\n";
- if (isset($this)) { // only pass in authentication for non-static calls
+ if ($object !== null) { // only pass in authentication for non-static calls
$username = $config->get('username', null, $channel);
$password = $config->get('password', null, $channel);
if ($username && $password) {
}
$redirect = $wasredirect + 1;
- return $this->downloadHttp($headers['location'],
+ return static::_downloadHttp($object, $headers['location'],
$ui, $save_dir, $callback, $lastmodified, $accept);
}
}
return $dest_file;
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Package.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
/**
* @param PEAR_Downloader
*/
- function PEAR_Downloader_Package(&$downloader)
+ function __construct(&$downloader)
{
$this->_downloader = &$downloader;
$this->_config = &$this->_downloader->config;
/**
* Remove packages to be downloaded that are already installed
* @param array of PEAR_Downloader_Package objects
- * @static
*/
- function removeInstalled(&$params)
+ public static function removeInstalled(&$params)
{
if (!isset($params[0])) {
return;
if ($param->_installRegistry->packageExists($package, $channel)) {
$packageVersion = $param->_installRegistry->packageInfo($package, 'version', $channel);
if (version_compare($packageVersion, $param->getVersion(), '==')) {
- if (!isset($options['force'])) {
+ if (!isset($options['force']) && !isset($options['packagingroot'])) {
$info = $param->getParsedPackage();
unset($info['version']);
unset($info['state']);
$params[$i] = false;
}
} elseif (!isset($options['force']) && !isset($options['upgrade']) &&
- !isset($options['soft'])) {
+ !isset($options['soft']) && !isset($options['packagingroot'])) {
$info = $param->getParsedPackage();
$param->_downloader->log(1, 'Skipping package "' .
$param->getShortName() .
* @param array $errorparams empty array
* @return array array of stupid duplicated packages in PEAR_Downloader_Package obejcts
*/
- function detectStupidDuplicates($params, &$errorparams)
+ public static function detectStupidDuplicates($params, &$errorparams)
{
$existing = array();
foreach ($params as $i => $param) {
/**
* @param array
* @param bool ignore install groups - for final removal of dupe packages
- * @static
*/
- function removeDuplicates(&$params, $ignoreGroups = false)
+ public static function removeDuplicates(&$params, $ignoreGroups = false)
{
$pnames = array();
foreach ($params as $i => $param) {
}
/**
- * @static
*/
- function mergeDependencies(&$params)
+ public static function mergeDependencies(&$params)
{
$bundles = $newparams = array();
foreach ($params as $i => $param) {
$obj->setExplicitState($s);
}
- $obj = &new PEAR_Downloader_Package($params[$i]->getDownloader());
+ $obj = new PEAR_Downloader_Package($params[$i]->getDownloader());
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
if (PEAR::isError($dir = $dl->getDownloadDir())) {
PEAR::popErrorHandling();
return $dir;
}
-
- $e = $obj->_fromFile($a = $dir . DIRECTORY_SEPARATOR . $file);
+ $a = $dir . DIRECTORY_SEPARATOR . $file;
+ $e = $obj->_fromFile($a);
PEAR::popErrorHandling();
if (PEAR::isError($e)) {
if (!isset($options['soft'])) {
continue;
}
- $j = &$obj;
- if (!PEAR_Downloader_Package::willDownload($j,
- array_merge($params, $newparams)) && !$param->isInstalled($j)) {
- $newparams[] = &$j;
+ if (!PEAR_Downloader_Package::willDownload($obj,
+ array_merge($params, $newparams)) && !$param->isInstalled($obj)) {
+ $newparams[] = $obj;
}
}
}
// convert the dependencies into PEAR_Downloader_Package objects for the next time around
$params[$i]->_downloadDeps = array();
foreach ($newdeps as $dep) {
- $obj = &new PEAR_Downloader_Package($params[$i]->getDownloader());
+ $obj = new PEAR_Downloader_Package($params[$i]->getDownloader());
if ($s = $params[$i]->explicitState()) {
$obj->setExplicitState($s);
}
}
}
- $j = &$obj;
- $newparams[] = &$j;
+ $newparams[] = $obj;
}
}
/**
- * @static
*/
- function willDownload($param, $params)
+ public static function willDownload($param, $params)
{
if (!is_array($params)) {
return false;
*/
function &getPackagefileObject(&$c, $d)
{
- $a = &new PEAR_PackageFile($c, $d);
+ $a = new PEAR_PackageFile($c, $d);
return $a;
}
if ($this->_rawpackagefile) {
require_once 'Archive/Tar.php';
- $tar = &new Archive_Tar($file);
+ $tar = new Archive_Tar($file);
$packagexml = $tar->extractInString('package2.xml');
if (!$packagexml) {
$packagexml = $tar->extractInString('package.xml');
return $info;
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 2004-2008 Greg Beaver
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: ErrorStack.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR_ErrorStack
*/
* $local_stack = new PEAR_ErrorStack('MyPackage');
* </code>
* @author Greg Beaver <cellog@php.net>
- * @version 1.9.4
+ * @version 1.10.1
* @package PEAR_ErrorStack
* @category Debugging
* @copyright 2004-2008 Greg Beaver
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: ErrorStack.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR_ErrorStack
*/
class PEAR_ErrorStack {
* @access protected
*/
var $_contextCallback = false;
-
+
/**
* If set to a valid callback, this will be called every time an error
* is pushed onto the stack. The return value will be used to determine
* whether to allow an error to be pushed or logged.
- *
+ *
* The return value must be one an PEAR_ERRORSTACK_* constant
* @see PEAR_ERRORSTACK_PUSHANDLOG, PEAR_ERRORSTACK_PUSH, PEAR_ERRORSTACK_LOG
* @var false|string|array
* @access protected
*/
var $_errorCallback = array();
-
+
/**
* PEAR::Log object for logging errors
* @var false|Log
* @access protected
*/
var $_logger = false;
-
+
/**
* Error messages - designed to be overridden
* @var array
* @abstract
*/
var $_errorMsgs = array();
-
+
/**
* Set up a new error stack
- *
+ *
* @param string $package name of the package this error stack represents
* @param callback $msgCallback callback used for error message generation
* @param callback $contextCallback callback used for context generation,
* defaults to {@link getFileLine()}
* @param boolean $throwPEAR_Error
*/
- function PEAR_ErrorStack($package, $msgCallback = false, $contextCallback = false,
+ function __construct($package, $msgCallback = false, $contextCallback = false,
$throwPEAR_Error = false)
{
$this->_package = $package;
* defaults to {@link getFileLine()}
* @param boolean $throwPEAR_Error
* @param string $stackClass class to instantiate
- * @static
+ *
* @return PEAR_ErrorStack
*/
- function &singleton($package, $msgCallback = false, $contextCallback = false,
- $throwPEAR_Error = false, $stackClass = 'PEAR_ErrorStack')
- {
+ public static function &singleton(
+ $package, $msgCallback = false, $contextCallback = false,
+ $throwPEAR_Error = false, $stackClass = 'PEAR_ErrorStack'
+ ) {
if (isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) {
return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package];
}
/**
* Set up a PEAR::Log object for all error stacks that don't have one
* @param Log $log
- * @static
*/
- function setDefaultLogger(&$log)
+ public static function setDefaultLogger(&$log)
{
if (is_object($log) && method_exists($log, 'log') ) {
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER'] = &$log;
} elseif (is_callable($log)) {
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER'] = &$log;
- }
+ }
}
/**
* messages for a singleton
* @param array|string Callback function/method
* @param string Package name, or false for all packages
- * @static
*/
- function setDefaultCallback($callback = false, $package = false)
+ public static function setDefaultCallback($callback = false, $package = false)
{
if (!is_callable($callback)) {
$callback = false;
* @see PEAR_ERRORSTACK_PUSHANDLOG, PEAR_ERRORSTACK_PUSH, PEAR_ERRORSTACK_LOG
* @see staticPopCallback(), pushCallback()
* @param string|array $cb
- * @static
*/
- function staticPushCallback($cb)
+ public static function staticPushCallback($cb)
{
array_push($GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'], $cb);
}
* Remove a temporary overriding error callback
* @see staticPushCallback()
* @return array|string|false
- * @static
*/
- function staticPopCallback()
+ public static function staticPopCallback()
{
$ret = array_pop($GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK']);
if (!is_array($GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'])) {
* to find error context
* @return PEAR_Error|array if compatibility mode is on, a PEAR_Error is also
* thrown. see docs for {@link push()}
- * @static
*/
- function staticPush($package, $code, $level = 'error', $params = array(),
- $msg = false, $repackage = false, $backtrace = false)
- {
+ public static function staticPush(
+ $package, $code, $level = 'error', $params = array(),
+ $msg = false, $repackage = false, $backtrace = false
+ ) {
$s = &PEAR_ErrorStack::singleton($package);
if ($s->_contextCallback) {
if (!$backtrace) {
* @param string|false Package name to check for errors
* @param string Level name to check for a particular severity
* @return boolean
- * @static
*/
- function staticHasErrors($package = false, $level = false)
+ public static function staticHasErrors($package = false, $level = false)
{
if ($package) {
if (!isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) {
* @param boolean $merge Set to return a flat array, not organized by package
* @param array $sortfunc Function used to sort a merged array - default
* sorts by time, and should be good for most cases
- * @static
+ *
* @return array
*/
- function staticGetErrors($purge = false, $level = false, $merge = false,
- $sortfunc = array('PEAR_ErrorStack', '_sortErrors'))
- {
+ public static function staticGetErrors(
+ $purge = false, $level = false, $merge = false,
+ $sortfunc = array('PEAR_ErrorStack', '_sortErrors')
+ ) {
$ret = array();
if (!is_callable($sortfunc)) {
$sortfunc = array('PEAR_ErrorStack', '_sortErrors');
* Error sorting function, sorts by time
* @access private
*/
- function _sortErrors($a, $b)
+ public static function _sortErrors($a, $b)
{
if ($a['time'] == $b['time']) {
return 0;
* @param unused
* @param integer backtrace frame.
* @param array Results of debug_backtrace()
- * @static
*/
- function getFileLine($code, $params, $backtrace = null)
+ public static function getFileLine($code, $params, $backtrace = null)
{
if ($backtrace === null) {
return false;
* @param PEAR_ErrorStack
* @param array
* @param string|false Pre-generated error message template
- * @static
+ *
* @return string
*/
- function getErrorMessage(&$stack, $err, $template = false)
+ public static function getErrorMessage(&$stack, $err, $template = false)
{
if ($template) {
$mainmsg = $template;
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Exception.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.3.3
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.3.3
*
+++ /dev/null
-<?php
-if ($skipmsg) {
- $a = &new $ec($code, $mode, $options, $userinfo);
-} else {
- $a = &new $ec($message, $code, $mode, $options, $userinfo);
-}
-?>
\ No newline at end of file
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Frontend.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
/**
* Retrieve the frontend object
* @return PEAR_Frontend_CLI|PEAR_Frontend_Web|PEAR_Frontend_Gtk
- * @static
*/
- function &singleton($type = null)
+ public static function &singleton($type = null)
{
if ($type === null) {
if (!isset($GLOBALS['_PEAR_FRONTEND_SINGLETON'])) {
* _ => DIRECTORY_SEPARATOR (PEAR_Frontend_CLI is in PEAR/Frontend/CLI.php)
* @param string $uiclass full class name
* @return PEAR_Frontend
- * @static
*/
- function &setFrontendClass($uiclass)
+ public static function &setFrontendClass($uiclass)
{
if (is_object($GLOBALS['_PEAR_FRONTEND_SINGLETON']) &&
is_a($GLOBALS['_PEAR_FRONTEND_SINGLETON'], $uiclass)) {
}
if (class_exists($uiclass)) {
- $obj = &new $uiclass;
+ $obj = new $uiclass;
// quick test to see if this class implements a few of the most
// important frontend methods
if (is_a($obj, 'PEAR_Frontend')) {
* Frontends are expected to be a descendant of PEAR_Frontend
* @param PEAR_Frontend
* @return PEAR_Frontend
- * @static
*/
- function &setFrontendObject($uiobject)
+ public static function &setFrontendObject($uiobject)
{
if (is_object($GLOBALS['_PEAR_FRONTEND_SINGLETON']) &&
is_a($GLOBALS['_PEAR_FRONTEND_SINGLETON'], get_class($uiobject))) {
/**
* @param string $path relative or absolute include path
* @return boolean
- * @static
*/
- function isIncludeable($path)
+ public static function isIncludeable($path)
{
if (file_exists($path) && is_readable($path)) {
return true;
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: CLI.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
'normal' => '',
);
- function PEAR_Frontend_CLI()
+ function __construct()
{
- parent::PEAR();
+ parent::__construct();
$term = getenv('TERM'); //(cox) $_ENV is empty for me in 4.1.1
if (function_exists('posix_isatty') && !posix_isatty(1)) {
// output is being redirected to a file or through a pipe
{
print $text;
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Installer.php 313024 2011-07-06 19:51:24Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
*
* @access public
*/
- function PEAR_Installer(&$ui)
+ function __construct(&$ui)
{
- parent::PEAR_Common();
+ parent::__construct($ui, array(), null);
$this->setFrontendObject($ui);
$this->debug = $this->config->get('verbose');
}
foreach ($atts as $tag => $raw) {
$tag = str_replace(array($pkg->getTasksNs() . ':', '-'), array('', '_'), $tag);
$task = "PEAR_Task_$tag";
- $task = &new $task($this->config, $this, PEAR_TASK_INSTALL);
+ $task = new $task($this->config, $this, PEAR_TASK_INSTALL);
if (!$task->isScript()) { // scripts are only handled after installation
$task->init($raw, $attribs, $pkg->getLastInstalledVersion());
$res = $task->startSession($pkg, $contents, $final_dest_file);
if (!empty($res)) {
$new = $this->_registry->getPackage($result[1], $result[0]);
$this->file_operations[$key] = false;
- $this->log(3, "file $data[0] was scheduled for removal from {$this->pkginfo->getName()} but is owned by {$new->getChannel()}/{$new->getName()}, removal has been cancelled.");
+ $pkginfoName = $this->pkginfo->getName();
+ $newChannel = $new->getChannel();
+ $newPackage = $new->getName();
+ $this->log(3, "file $data[0] was scheduled for removal from $pkginfoName but is owned by $newChannel/$newPackage, removal has been cancelled.");
}
}
}
return parent::mkDirHier($dir);
}
- // }}}
- // {{{ download()
-
- /**
- * Download any files and their dependencies, if necessary
- *
- * @param array a mixed list of package names, local files, or package.xml
- * @param PEAR_Config
- * @param array options from the command line
- * @param array this is the array that will be populated with packages to
- * install. Format of each entry:
- *
- * <code>
- * array('pkg' => 'package_name', 'file' => '/path/to/local/file',
- * 'info' => array() // parsed package.xml
- * );
- * </code>
- * @param array this will be populated with any error messages
- * @param false private recursion variable
- * @param false private recursion variable
- * @param false private recursion variable
- * @deprecated in favor of PEAR_Downloader
- */
- function download($packages, $options, &$config, &$installpackages,
- &$errors, $installed = false, $willinstall = false, $state = false)
- {
- // trickiness: initialize here
- parent::PEAR_Downloader($this->ui, $options, $config);
- $ret = parent::download($packages);
- $errors = $this->getErrorMsgs();
- $installpackages = $this->getDownloadedPackages();
- trigger_error("PEAR Warning: PEAR_Installer::download() is deprecated " .
- "in favor of PEAR_Downloader class", E_USER_WARNING);
- return $ret;
- }
-
// }}}
// {{{ _parsePackageXml()
$pkgname = $pkg->getName();
$channel = $pkg->getChannel();
- if (isset($this->_options['packagingroot'])) {
- $regdir = $this->_prependPath(
- $this->config->get('php_dir', null, 'pear.php.net'),
- $this->_options['packagingroot']);
-
- $packrootphp_dir = $this->_prependPath(
- $this->config->get('php_dir', null, $channel),
- $this->_options['packagingroot']);
- }
if (isset($options['installroot'])) {
$this->config->setInstallRoot($options['installroot']);
$this->config->setInstallRoot(false);
$this->_registry = &$this->config->getRegistry();
if (isset($this->_options['packagingroot'])) {
- $installregistry = &new PEAR_Registry($regdir);
+ $regdir = $this->_prependPath(
+ $this->config->get('php_dir', null, 'pear.php.net'),
+ $this->_options['packagingroot']);
+
+ $metadata_dir = $this->config->get('metadata_dir', null, 'pear.php.net');
+ if ($metadata_dir) {
+ $metadata_dir = $this->_prependPath(
+ $metadata_dir,
+ $this->_options['packagingroot']);
+ }
+ $packrootphp_dir = $this->_prependPath(
+ $this->config->get('php_dir', null, $channel),
+ $this->_options['packagingroot']);
+
+ $installregistry = new PEAR_Registry($regdir, false, false, $metadata_dir);
if (!$installregistry->channelExists($channel, true)) {
// we need to fake a channel-discover of this channel
$chanobj = $this->_registry->getChannel($channel, true);
}
}
- $pfk = &new PEAR_PackageFile($this->config);
+ $pfk = new PEAR_PackageFile($this->config);
$parentpkg = &$pfk->fromArray($parentreg);
$installregistry->updatePackage2($parentpkg);
}
{
require_once 'PEAR/Builder.php';
$this->log(1, "$this->source_files source files, building");
- $bob = &new PEAR_Builder($this->ui);
+ $bob = new PEAR_Builder($this->ui);
$bob->debug = $this->debug;
$built = $bob->build($filelist, array(&$this, '_buildCallback'));
if (PEAR::isError($built)) {
require_once 'PEAR/Dependency2.php';
}
- $depchecker = &new PEAR_Dependency2($this->config, $options,
+ $depchecker = new PEAR_Dependency2($this->config, $options,
array('channel' => $channel, 'package' => $package),
PEAR_VALIDATE_UNINSTALLING);
$e = $depchecker->validatePackageUninstall($this);
}
// }}}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Role.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
*
* Never call this directly, it is called by the PEAR_Config constructor
* @param PEAR_Config
- * @access private
- * @static
*/
- function initializeConfig(&$config)
+ public static function initializeConfig(&$config)
{
if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
PEAR_Installer_Role::registerRoles();
* @param string role name
* @param PEAR_Config
* @return PEAR_Installer_Role_Common
- * @static
*/
- function &factory($pkg, $role, &$config)
+ public static function &factory($pkg, $role, &$config)
{
if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
PEAR_Installer_Role::registerRoles();
* @param string
* @param bool clear cache
* @return array
- * @static
*/
- function getValidRoles($release, $clear = false)
+ public static function getValidRoles($release, $clear = false)
{
if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
PEAR_Installer_Role::registerRoles();
* roles are actually fully bundled releases of a package
* @param bool clear cache
* @return array
- * @static
*/
- function getInstallableRoles($clear = false)
+ public static function getInstallableRoles($clear = false)
{
if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
PEAR_Installer_Role::registerRoles();
* so a tests file tests/file.phpt is installed into PackageName/tests/filepath.php
* @param bool clear cache
* @return array
- * @static
*/
- function getBaseinstallRoles($clear = false)
+ public static function getBaseinstallRoles($clear = false)
{
if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
PEAR_Installer_Role::registerRoles();
* like the "php" role.
* @param bool clear cache
* @return array
- * @static
*/
- function getPhpRoles($clear = false)
+ public static function getPhpRoles($clear = false)
{
if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
PEAR_Installer_Role::registerRoles();
* included.
*
* @return bool TRUE on success, a PEAR error on failure
- * @access public
- * @static
*/
- function registerRoles($dir = null)
+ public static function registerRoles($dir = null)
{
$GLOBALS['_PEAR_INSTALLER_ROLES'] = array();
$parser = new PEAR_XMLParser;
* @author Greg Beaver <cellog@php.net>
* @copyright 2007-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Cfg.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.7.0
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 2007-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.7.0
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2006 The PHP Group
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Common.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2006 The PHP Group
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
/**
* @param PEAR_Config
*/
- function PEAR_Installer_Role_Common(&$config)
+ function __construct(&$config)
{
$this->config = $config;
}
return $roleInfo['phpextension'];
}
}
-?>
\ No newline at end of file
+?>
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Data.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Doc.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Ext.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
--- /dev/null
+<?php
+/**
+ * PEAR_Installer_Role_Man
+ *
+ * PHP versions 4 and 5
+ *
+ * @category pear
+ * @package PEAR
+ * @author Hannes Magnusson <bjori@php.net>
+ * @copyright 2011 The Authors
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version SVN: $Id: $
+ * @link http://pear.php.net/package/PEAR
+ * @since File available since Release 1.10.0
+ */
+
+/**
+ * @category pear
+ * @package PEAR
+ * @author Hannes Magnusson <bjori@php.net>
+ * @copyright 2011 The Authors
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version Release: 1.10.1
+ * @link http://pear.php.net/package/PEAR
+ * @since Class available since Release 1.10.0
+ */
+class PEAR_Installer_Role_Man extends PEAR_Installer_Role_Common {}
+?>
--- /dev/null
+<role version="1.0">
+ <releasetypes>php</releasetypes>
+ <releasetypes>extsrc</releasetypes>
+ <releasetypes>extbin</releasetypes>
+ <releasetypes>zendextsrc</releasetypes>
+ <releasetypes>zendextbin</releasetypes>
+ <installable>1</installable>
+ <locationconfig>man_dir</locationconfig>
+ <honorsbaseinstall>1</honorsbaseinstall>
+ <unusualbaseinstall />
+ <phpfile />
+ <executable />
+ <phpextension />
+ <config_vars />
+</role>
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Php.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Script.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Src.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Test.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 2007-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Www.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.7.0
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 2007-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.7.0
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: PackageFile.php 313024 2011-07-06 19:51:24Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @param string @tmpdir Optional temporary directory for uncompressing
* files
*/
- function PEAR_PackageFile(&$config, $debug = false)
+ function __construct(&$config, $debug = false)
{
$this->_config = $config;
$this->_debug = $debug;
$info = PEAR::raiseError("Cannot open '$info' for parsing");
return $info;
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: v1.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @var PEAR_PackageFile_v1
*/
var $_packagefile;
- function PEAR_PackageFile_Generator_v1(&$packagefile)
+ function __construct(&$packagefile)
{
$this->_packagefile = &$packagefile;
}
function getPackagerVersion()
{
- return '1.9.4';
+ return '1.10.1';
}
/**
// }}}
$packagexml = $this->toPackageFile($where, PEAR_VALIDATE_PACKAGING, 'package.xml', true);
if ($packagexml) {
- $tar =& new Archive_Tar($dest_package, $compress);
+ $tar = new Archive_Tar($dest_package, $compress);
$tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors
// ----- Creates with the package.xml file
$ok = $tar->createModify(array($packagexml), '', $where);
*/
function _fixXmlEncoding($string)
{
- if (version_compare(phpversion(), '5.0.0', 'lt')) {
- $string = utf8_encode($string);
- }
return strtr($string, array(
'&' => '&',
'>' => '>',
);
$ret = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
$ret .= "<!DOCTYPE package SYSTEM \"http://pear.php.net/dtd/package-1.0\">\n";
- $ret .= "<package version=\"1.0\" packagerversion=\"1.9.4\">\n" .
+ $ret .= "<package version=\"1.0\" packagerversion=\"1.10.1\">\n" .
" <name>$pkginfo[package]</name>";
if (isset($pkginfo['extends'])) {
$ret .= "\n<extends>$pkginfo[extends]</extends>";
}
if (count($min)) {
// get the highest minimum
- $min = array_pop($a = array_flip($min));
+ $a = array_flip($min);
+ $min = array_pop($a);
} else {
$min = false;
}
if (count($max)) {
// get the lowest maximum
- $max = array_shift($a = array_flip($max));
+ $a = array_flip($max);
+ $max = array_shift($a);
} else {
$max = false;
}
}
if (count($min)) {
// get the highest minimum
- $min = array_pop($a = array_flip($min));
+ $a = array_flip($min);
+ $min = array_pop($a);
} else {
$min = false;
}
if (count($max)) {
// get the lowest maximum
- $max = array_shift($a = array_flip($max));
+ $a = array_flip($max);
+ $max = array_shift($a);
} else {
$max = false;
}
return $ret;
}
}
-?>
\ No newline at end of file
+?>
* @author Stephan Schmidt (original XML_Serializer code)
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: v2.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Stephan Schmidt (original XML_Serializer code)
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
http://pear.php.net/dtd/package-2.0.xsd',
), // attributes of the root tag
'attributesArray' => 'attribs', // all values in this key will be treated as attributes
- 'contentName' => '_content', // this value will be used directly as content, instead of creating a new tag, may only be used in conjuction with attributesArray
+ 'contentName' => '_content', // this value will be used directly as content, instead of creating a new tag, may only be used in conjunction with attributesArray
'beautifyFilelist' => false,
'encoding' => 'UTF-8',
);
/**
* @param PEAR_PackageFile_v2
*/
- function PEAR_PackageFile_Generator_v2(&$packagefile)
+ function __construct(&$packagefile)
{
$this->_packagefile = &$packagefile;
if (isset($this->_packagefile->encoding)) {
*/
function getPackagerVersion()
{
- return '1.9.4';
+ return '1.10.1';
}
/**
array($this->_packagefile->getTasksNs() . ':', '-'),
array('', '_'), $tag);
$task = "PEAR_Task_$tag";
- $task = &new $task($this->_packagefile->_config,
+ $task = new $task($this->_packagefile->_config,
$this->_packagefile->_logger,
PEAR_TASK_PACKAGE);
$task->init($raw, $atts, null);
$name = $pf1 !== null ? 'package2.xml' : 'package.xml';
$packagexml = $this->toPackageFile($where, PEAR_VALIDATE_PACKAGING, $name);
if ($packagexml) {
- $tar =& new Archive_Tar($dest_package, $compress);
+ $tar = new Archive_Tar($dest_package, $compress);
$tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors
// ----- Creates with the package.xml file
$ok = $tar->createModify(array($packagexml), '', $where);
$this->options['beautifyFilelist'] = true;
}
- $arr['attribs']['packagerversion'] = '1.9.4';
+ $arr['attribs']['packagerversion'] = '1.10.1';
if ($this->serialize($arr, $options)) {
return $this->_serializedData . "\n";
}
}
if (is_scalar($tag['content']) || is_null($tag['content'])) {
- if ($this->options['encoding'] == 'UTF-8' &&
- version_compare(phpversion(), '5.0.0', 'lt')
- ) {
- $tag['content'] = utf8_encode($tag['content']);
- }
-
if ($replaceEntities === true) {
$replaceEntities = XML_UTIL_ENTITIES_XML;
}
}
return $tag;
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: v1.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
$code = xml_get_error_code($xp);
$line = xml_get_current_line_number($xp);
xml_parser_free($xp);
- $a = &PEAR::raiseError(sprintf("XML error: %s at line %d",
+ $a = PEAR::raiseError(sprintf("XML error: %s at line %d",
$str = xml_error_string($code), $line), 2);
return $a;
}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: v2.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* a subclass
* @return PEAR_PackageFile_v2
*/
- function &parse($data, $file, $archive = false, $class = 'PEAR_PackageFile_v2')
+ function parse($data, $file = null, $archive = false, $class = 'PEAR_PackageFile_v2')
{
- if (PEAR::isError($err = parent::parse($data, $file))) {
+ if (PEAR::isError($err = parent::parse($data))) {
return $err;
}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: v1.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @param bool determines whether to return a PEAR_Error object, or use the PEAR_ErrorStack
* @param string Name of Error Stack class to use.
*/
- function PEAR_PackageFile_v1()
+ function __construct()
{
- $this->_stack = &new PEAR_ErrorStack('PEAR_PackageFile_v1');
+ $this->_stack = new PEAR_ErrorStack('PEAR_PackageFile_v1');
$this->_stack->setErrorMessageTemplate($this->_getErrorMessage());
$this->_isValid = 0;
}
if (!class_exists('PEAR_PackageFile_Generator_v1')) {
require_once 'PEAR/PackageFile/Generator/v1.php';
}
- $a = &new PEAR_PackageFile_Generator_v1($this);
+ $a = new PEAR_PackageFile_Generator_v1($this);
return $a;
}
if (!class_exists('Archive_Tar')) {
require_once 'Archive/Tar.php';
}
- $tar = &new Archive_Tar($this->_archiveFile);
+ $tar = new Archive_Tar($this->_archiveFile);
$tar->pushErrorHandling(PEAR_ERROR_RETURN);
if ($file != 'package.xml' && $file != 'package2.xml') {
$file = $this->getPackage() . '-' . $this->getVersion() . '/' . $file;
$look_for = $token;
continue 2;
case T_STRING:
- if (version_compare(zend_version(), '2.0', '<')) {
- if (in_array(strtolower($data),
- array('public', 'private', 'protected', 'abstract',
- 'interface', 'implements', 'throw')
- )) {
- $this->_validateWarning(PEAR_PACKAGEFILE_ERROR_PHP5,
- array($file));
- }
- }
if ($look_for == T_CLASS) {
$current_class = $data;
$current_class_level = $brace_level;
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: v2.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
/**
* The constructor merely sets up the private error stack
*/
- function PEAR_PackageFile_v2()
+ function __construct()
{
$this->_stack = new PEAR_ErrorStack('PEAR_PackageFile_v2', false, null);
$this->_isValid = false;
}
+ /**
+ * PHP 4 style constructor for backwards compatibility.
+ * Used by PEAR_PackageFileManager2
+ */
+ public function PEAR_PackageFile_v2()
+ {
+ $this->__construct();
+ }
+
/**
* To make unit-testing easier
* @param PEAR_Frontend_*
*/
function &getPEARDownloader(&$i, $o, &$c)
{
- $z = &new PEAR_Downloader($i, $o, $c);
+ $z = new PEAR_Downloader($i, $o, $c);
return $z;
}
if (!class_exists('PEAR_Dependency2')) {
require_once 'PEAR/Dependency2.php';
}
- $z = &new PEAR_Dependency2($c, $o, $p, $s);
+ $z = new PEAR_Dependency2($c, $o, $p, $s);
return $z;
}
$atts = $filelist[$name];
foreach ($tasks as $tag => $raw) {
$task = $this->getTask($tag);
- $task = &new $task($this->_config, $common, PEAR_TASK_INSTALL);
+ $task = new $task($this->_config, $common, PEAR_TASK_INSTALL);
if ($task->isScript()) {
$ret[] = $filelist[$name]['installed_as'];
}
$atts = $filelist[$name];
foreach ($tasks as $tag => $raw) {
$taskname = $this->getTask($tag);
- $task = &new $taskname($this->_config, $common, PEAR_TASK_INSTALL);
+ $task = new $taskname($this->_config, $common, PEAR_TASK_INSTALL);
if (!$task->isScript()) {
continue; // scripts are only handled after installation
}
$contents['dir']['file'] = array($contents['dir']['file']);
}
foreach ($contents['dir']['file'] as $file) {
+ if (!isset($file['attribs']['name'])) {
+ continue;
+ }
$name = $file['attribs']['name'];
if (!$preserve) {
$file = $file['attribs'];
return implode('', file($file));
}
} else { // tgz
- $tar = &new Archive_Tar($this->_archiveFile);
+ $tar = new Archive_Tar($this->_archiveFile);
$tar->pushErrorHandling(PEAR_ERROR_RETURN);
if ($file != 'package.xml' && $file != 'package2.xml') {
$file = $this->getPackage() . '-' . $this->getVersion() . '/' . $file;
if (!class_exists('PEAR_PackageFile_Generator_v2')) {
require_once 'PEAR/PackageFile/Generator/v2.php';
}
- $a = &new PEAR_PackageFile_Generator_v2($this);
+ $a = new PEAR_PackageFile_Generator_v2($this);
return $a;
}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Validator.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a8
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a8
* @access private
isset($test['dependencies']['required']) &&
isset($test['dependencies']['required']['pearinstaller']) &&
isset($test['dependencies']['required']['pearinstaller']['min']) &&
- version_compare('1.9.4',
+ '1.10.1' != '@package' . '_version@' &&
+ version_compare('1.10.1',
$test['dependencies']['required']['pearinstaller']['min'], '<')
) {
$this->_pearVersionTooLow($test['dependencies']['required']['pearinstaller']['min']);
$this->_stack->push(__FUNCTION__, 'error',
array('version' => $version),
'This package.xml requires PEAR version %version% to parse properly, we are ' .
- 'version 1.9.4');
+ 'version 1.10.1');
}
function _invalidTagOrder($oktags, $actual, $root)
if (!is_array($info)) {
$info = array($info);
}
- $pkg = &new PEAR_PackageFile($this->_pf->_config);
+ $pkg = new PEAR_PackageFile($this->_pf->_config);
foreach ($info as $package) {
if (!file_exists($dir_prefix . DIRECTORY_SEPARATOR . $package)) {
$this->_fileNotFound($dir_prefix . DIRECTORY_SEPARATOR . $package);
$pn = $this->_pf->getPackage();
$this->_stack->push(__FUNCTION__, 'warning',
array('file' => $file, 'package' => $pn),
- 'in %file%: Could not process file for unkown reasons,' .
+ 'in %file%: Could not process file for unknown reasons,' .
' possibly a PHP parse error in %file% from %package%');
}
}
$look_for = $token;
continue 2;
case T_STRING:
- if (version_compare(zend_version(), '2.0', '<')) {
- if (in_array(strtolower($data),
- array('public', 'private', 'protected', 'abstract',
- 'interface', 'implements', 'throw')
- )
- ) {
- if (isset($this->_stack)) {
- $this->_stack->push(__FUNCTION__, 'warning', array(
- 'file' => $file),
- 'Error, PHP5 token encountered in %file%,' .
- ' analysis should be in PHP5');
- } else {
- PEAR::raiseError('Error: PHP5 token encountered in ' . $file .
- 'packaging should be done in PHP 5');
- return false;
- }
- }
- }
-
if ($look_for == T_CLASS) {
$current_class = $data;
$current_class_level = $brace_level;
continue 2;
case T_DOUBLE_COLON:
$token = $tokens[$i - 1][0];
- if (!($token == T_WHITESPACE || $token == T_STRING || $token == T_STATIC)) {
+ if (!($token == T_WHITESPACE || $token == T_STRING || $token == T_STATIC || $token == T_VARIABLE)) {
if (isset($this->_stack)) {
$this->_stack->push(__FUNCTION__, 'warning', array('file' => $file),
'Parser error: invalid PHP found in file "%file%"');
return $providesret;
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: rw.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a8
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a8
*/
}
}
foreach ($info as $i => $maintainer) {
- if ($maintainer['user'] == $handle) {
+ if (is_array($maintainer) && $maintainer['user'] == $handle) {
$found = $i;
break 2;
}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Packager.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
}
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
- $pkg = &new PEAR_PackageFile($this->config, $this->debug);
+ $pkg = new PEAR_PackageFile($this->config, $this->debug);
$pf = &$pkg->fromPackageFile($pkgfile, PEAR_VALIDATE_NORMAL);
$main = &$pf;
PEAR::staticPopErrorHandling();
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: REST.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
var $config;
var $_options;
- function PEAR_REST(&$config, $options = array())
+ function __construct(&$config, $options = array())
{
$this->config = &$config;
$this->_options = $options;
}
if (isset($headers['content-type'])) {
- switch ($headers['content-type']) {
+ $content_type = explode(";", $headers['content-type']);
+ $content_type = $content_type[0];
+ switch ($content_type) {
case 'text/xml' :
case 'application/xml' :
case 'text/plain' :
- if ($headers['content-type'] === 'text/plain') {
+ if ($content_type === 'text/plain') {
$check = substr($content, 0, 5);
if ($check !== '<?xml') {
break;
}
}
+ if (!is_writeable($cache_dir)) {
+ // If writing to the cache dir is not going to work, silently do nothing.
+ // An ugly hack, but retains compat with PEAR 1.9.1 where many commands
+ // work fine as non-root user (w/out write access to default cache dir).
+ return true;
+ }
+
if ($cacheid === null && $nochange) {
$cacheid = unserialize(implode('', file($cacheidfile)));
}
return PEAR::raiseError("Could not write $file.");
}
} else { // update file
- $cachefile_lstat = lstat($file);
- $cachefile_fp = @fopen($file, 'wb');
+ $cachefile_fp = @fopen($file, 'r+b'); // do not truncate file
if (!$cachefile_fp) {
return PEAR::raiseError("Could not open $file for writing.");
}
- $cachefile_fstat = fstat($cachefile_fp);
- if (
- $cachefile_lstat['mode'] == $cachefile_fstat['mode'] &&
- $cachefile_lstat['ino'] == $cachefile_fstat['ino'] &&
- $cachefile_lstat['dev'] == $cachefile_fstat['dev'] &&
- $cachefile_fstat['nlink'] === 1
- ) {
+ if (OS_WINDOWS) {
+ $not_symlink = !is_link($file); // see bug #18834
+ } else {
+ $cachefile_lstat = lstat($file);
+ $cachefile_fstat = fstat($cachefile_fp);
+ $not_symlink = $cachefile_lstat['mode'] == $cachefile_fstat['mode']
+ && $cachefile_lstat['ino'] == $cachefile_fstat['ino']
+ && $cachefile_lstat['dev'] == $cachefile_fstat['dev']
+ && $cachefile_fstat['nlink'] === 1;
+ }
+
+ if ($not_symlink) {
+ ftruncate($cachefile_fp, 0); // NOW truncate
if (fwrite($cachefile_fp, $contents, $len) < $len) {
fclose($cachefile_fp);
return PEAR::raiseError("Could not write $file.");
}
$request .= $ifmodifiedsince .
- "User-Agent: PEAR/1.9.4/PHP/" . PHP_VERSION . "\r\n";
+ "User-Agent: PEAR/1.10.1/PHP/" . PHP_VERSION . "\r\n";
$username = $this->config->get('username', null, $channel);
$password = $this->config->get('password', null, $channel);
return $data;
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: 10.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a12
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a12
*/
* @var PEAR_REST
*/
var $_rest;
- function PEAR_REST_10($config, $options = array())
+ function __construct($config, $options = array())
{
- $this->_rest = &new PEAR_REST($config, $options);
+ $this->_rest = new PEAR_REST($config, $options);
}
/**
return 1;
}
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: 11.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.3
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.3
*/
*/
var $_rest;
- function PEAR_REST_11($config, $options = array())
+ function __construct($config, $options = array())
{
- $this->_rest = &new PEAR_REST($config, $options);
+ $this->_rest = new PEAR_REST($config, $options);
}
function listAll($base, $dostable, $basic = true, $searchpackage = false, $searchsummary = false, $channel = false)
return array_slice($states, $i + 1);
}
}
-?>
\ No newline at end of file
+?>
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: 13.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a12
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a12
*/
return $this->_returnDownloadURL($base, $package, $release, $info, $found, $skippedphp, $channel);
}
+
+ /**
+ * List package upgrades but take the PHP version into account.
+ */
+ function listLatestUpgrades($base, $pref_state, $installed, $channel, &$reg)
+ {
+ $packagelist = $this->_rest->retrieveData($base . 'p/packages.xml', false, false, $channel);
+ if (PEAR::isError($packagelist)) {
+ return $packagelist;
+ }
+
+ $ret = array();
+ if (!is_array($packagelist) || !isset($packagelist['p'])) {
+ return $ret;
+ }
+
+ if (!is_array($packagelist['p'])) {
+ $packagelist['p'] = array($packagelist['p']);
+ }
+
+ foreach ($packagelist['p'] as $package) {
+ if (!isset($installed[strtolower($package)])) {
+ continue;
+ }
+
+ $inst_version = $reg->packageInfo($package, 'version', $channel);
+ $inst_state = $reg->packageInfo($package, 'release_state', $channel);
+ PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
+ $info = $this->_rest->retrieveData($base . 'r/' . strtolower($package) .
+ '/allreleases2.xml', false, false, $channel);
+ PEAR::popErrorHandling();
+ if (PEAR::isError($info)) {
+ continue; // no remote releases
+ }
+
+ if (!isset($info['r'])) {
+ continue;
+ }
+
+ $release = $found = false;
+ if (!is_array($info['r']) || !isset($info['r'][0])) {
+ $info['r'] = array($info['r']);
+ }
+
+ // $info['r'] is sorted by version number
+ usort($info['r'], array($this, '_sortReleasesByVersionNumber'));
+ foreach ($info['r'] as $release) {
+ if ($inst_version && version_compare($release['v'], $inst_version, '<=')) {
+ // not newer than the one installed
+ break;
+ }
+ if (version_compare($release['m'], phpversion(), '>')) {
+ // skip dependency releases that require a PHP version
+ // newer than our PHP version
+ continue;
+ }
+
+ // new version > installed version
+ if (!$pref_state) {
+ // every state is a good state
+ $found = true;
+ break;
+ } else {
+ $new_state = $release['s'];
+ // if new state >= installed state: go
+ if (in_array($new_state, $this->betterStates($inst_state, true))) {
+ $found = true;
+ break;
+ } else {
+ // only allow to lower the state of package,
+ // if new state >= preferred state: go
+ if (in_array($new_state, $this->betterStates($pref_state, true))) {
+ $found = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (!$found) {
+ continue;
+ }
+
+ $relinfo = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/' .
+ $release['v'] . '.xml', false, false, $channel);
+ if (PEAR::isError($relinfo)) {
+ return $relinfo;
+ }
+
+ $ret[$package] = array(
+ 'version' => $release['v'],
+ 'state' => $release['s'],
+ 'filesize' => $relinfo['f'],
+ );
+ }
+
+ return $ret;
+ }
}
\ No newline at end of file
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Registry.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
*
* @access public
*/
- function PEAR_Registry($pear_install_dir = PEAR_INSTALL_DIR, $pear_channel = false,
- $pecl_channel = false)
+ function __construct($pear_install_dir = PEAR_INSTALL_DIR, $pear_channel = false,
+ $pecl_channel = false, $pear_metadata_dir = '')
{
- parent::PEAR();
- $this->setInstallDir($pear_install_dir);
+ parent::__construct();
+ $this->setInstallDir($pear_install_dir, $pear_metadata_dir);
$this->_pearChannel = $pear_channel;
$this->_peclChannel = $pecl_channel;
$this->_config = false;
}
- function setInstallDir($pear_install_dir = PEAR_INSTALL_DIR)
+ function setInstallDir($pear_install_dir = PEAR_INSTALL_DIR, $pear_metadata_dir = '')
{
$ds = DIRECTORY_SEPARATOR;
$this->install_dir = $pear_install_dir;
- $this->channelsdir = $pear_install_dir.$ds.'.channels';
- $this->statedir = $pear_install_dir.$ds.'.registry';
- $this->filemap = $pear_install_dir.$ds.'.filemap';
- $this->lockfile = $pear_install_dir.$ds.'.lock';
+ if (!$pear_metadata_dir) {
+ $pear_metadata_dir = $pear_install_dir;
+ }
+ $this->channelsdir = $pear_metadata_dir.$ds.'.channels';
+ $this->statedir = $pear_metadata_dir.$ds.'.registry';
+ $this->filemap = $pear_metadata_dir.$ds.'.filemap';
+ $this->lockfile = $pear_metadata_dir.$ds.'.lock';
}
function hasWriteAccess()
{
$this->_config = &$config;
if ($resetInstallDir) {
- $this->setInstallDir($config->get('php_dir'));
+ $this->setInstallDir($config->get('php_dir'), $config->get('metadata_dir'));
}
}
$initializing = true;
if (!$this->_config) { // never used?
$file = OS_WINDOWS ? 'pear.ini' : '.pearrc';
- $this->_config = &new PEAR_Config($this->statedir . DIRECTORY_SEPARATOR .
+ $this->_config = new PEAR_Config($this->statedir . DIRECTORY_SEPARATOR .
$file);
$this->_config->setRegistry($this);
$this->_config->set('php_dir', $this->install_dir);
$this->_dependencyDB = &PEAR_DependencyDB::singleton($this->_config);
if (PEAR::isError($this->_dependencyDB)) {
// attempt to recover by removing the dep db
- if (file_exists($this->_config->get('php_dir', null, 'pear.php.net') .
+ if (file_exists($this->_config->get('metadata_dir', null, 'pear.php.net') .
DIRECTORY_SEPARATOR . '.depdb')) {
- @unlink($this->_config->get('php_dir', null, 'pear.php.net') .
+ @unlink($this->_config->get('metadata_dir', null, 'pear.php.net') .
DIRECTORY_SEPARATOR . '.depdb');
}
}
clearstatcache();
- $rt = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
$fsize = filesize($this->filemap);
fclose($fp);
$data = file_get_contents($this->filemap);
- set_magic_quotes_runtime($rt);
$tmp = unserialize($data);
if (!$tmp && $fsize > 7) {
return $this->raiseError('PEAR_Registry: invalid filemap data', PEAR_REGISTRY_ERROR_FORMAT, null, null, $data);
return null;
}
- $rt = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
clearstatcache();
$this->_closePackageFile($fp);
$data = file_get_contents($this->_packageFileName($package, $channel));
- set_magic_quotes_runtime($rt);
$data = unserialize($data);
if ($key === null) {
return $data;
return null;
}
- $rt = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
clearstatcache();
$this->_closeChannelFile($fp);
$data = file_get_contents($this->_channelFileName($channel));
- set_magic_quotes_runtime($rt);
$data = unserialize($data);
return $data;
}
$a = $this->_config;
if (!$a) {
- $this->_config = &new PEAR_Config;
+ $this->_config = new PEAR_Config;
$this->_config->set('php_dir', $this->statedir);
}
require_once 'PEAR/PackageFile.php';
}
- $pkg = &new PEAR_PackageFile($this->_config);
+ $pkg = new PEAR_PackageFile($this->_config);
$pf = &$pkg->fromArray($info);
return $pf;
}
* @param bool whether to strictly return raw channels (no aliases)
* @return PEAR_ChannelFile|PEAR_Error
*/
- function &getChannel($channel, $noaliases = false)
+ function getChannel($channel, $noaliases = false)
{
if (PEAR::isError($e = $this->_lock(LOCK_SH))) {
return $e;
}
- $ret = &$this->_getChannel($channel, $noaliases);
+ $ret = $this->_getChannel($channel, $noaliases);
$this->_unlock();
if (!$ret) {
return PEAR::raiseError('Unknown channel: ' . $channel);
}
return $ret;
}
-}
\ No newline at end of file
+}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: RunTest.php 313024 2011-07-06 19:51:24Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.3.3
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.3.3
*/
var $ini_overwrites = array(
'output_handler=',
'open_basedir=',
- 'safe_mode=0',
'disable_functions=',
'output_buffering=Off',
'display_errors=1',
'error_append_string=',
'auto_prepend_file=',
'auto_append_file=',
- 'magic_quotes_runtime=0',
'xdebug.default_enable=0',
'allow_url_fopen=1',
);
* An object that supports the PEAR_Common->log() signature, or null
* @param PEAR_Common|null
*/
- function PEAR_RunTest($logger = null, $options = array())
+ function __construct($logger = null, $options = array())
{
if (!defined('E_DEPRECATED')) {
define('E_DEPRECATED', 0);
function system_with_timeout($commandline, $env = null, $stdin = null)
{
$data = '';
- if (version_compare(phpversion(), '5.0.0', '<')) {
- $proc = proc_open($commandline, array(
- 0 => array('pipe', 'r'),
- 1 => array('pipe', 'w'),
- 2 => array('pipe', 'w')
- ), $pipes);
- } else {
- $proc = proc_open($commandline, array(
- 0 => array('pipe', 'r'),
- 1 => array('pipe', 'w'),
- 2 => array('pipe', 'w')
- ), $pipes, null, $env, array('suppress_errors' => true));
- }
+ $proc = proc_open($commandline, array(
+ 0 => array('pipe', 'r'),
+ 1 => array('pipe', 'w'),
+ 2 => array('pipe', 'w')
+ ), $pipes, null, $env, array('suppress_errors' => true));
if (!$proc) {
return false;
function _preparePhpBin($php, $file, $ini_settings)
{
$file = escapeshellarg($file);
- // This was fixed in php 5.3 and is not needed after that
- if (OS_WINDOWS && version_compare(PHP_VERSION, '5.3', '<')) {
- $cmd = '"'.escapeshellarg($php).' '.$ini_settings.' -f ' . $file .'"';
- } else {
- $cmd = $php . $ini_settings . ' -f ' . $file;
- }
+ $cmd = $php . $ini_settings . ' -f ' . $file;
return $cmd;
}
*/
function run($file, $ini_settings = array(), $test_number = 1)
{
- if (isset($this->_savephp)) {
- $this->_php = $this->_savephp;
- unset($this->_savephp);
- }
+ $this->_restorePHPBinary();
+
if (empty($this->_options['cgi'])) {
// try to see if php-cgi is in the path
$res = $this->system_with_timeout('php-cgi -v');
}
return 'SKIPPED';
}
- $this->_savephp = $this->_php;
+ $this->_savePHPBinary();
$this->_php = $this->_options['cgi'];
}
}
chdir($cwd); // in case the test moves us around
- $this->_testCleanup($section_text, $temp_clean);
-
/* when using CGI, strip the headers from the output */
$output = $this->_stripHeadersCGI($output);
$output .= "\n====EXPECTHEADERS FAILURE====:\n$changed";
}
}
+
+ $this->_testCleanup($section_text, $temp_clean);
+
// Does the output match what is expected?
do {
if (isset($section_text['EXPECTF']) || isset($section_text['EXPECTREGEX'])) {
$expectf = isset($section_text['EXPECTF']) ? $wanted_re : null;
$data = $this->generate_diff($wanted, $output, $returns, $expectf);
$res = $this->_writeLog($diff_filename, $data);
+ if (isset($this->_options['showdiff'])) {
+ $this->_logger->log(0, "========DIFF========");
+ $this->_logger->log(0, $data);
+ $this->_logger->log(0, "========DONE========");
+ }
if (PEAR::isError($res)) {
return $res;
}
function _testCleanup($section_text, $temp_clean)
{
if ($section_text['CLEAN']) {
+ $this->_restorePHPBinary();
+
// perform test cleanup
$this->save_text($temp_clean, $section_text['CLEAN']);
$output = $this->system_with_timeout("$this->_php $temp_clean 2>&1");
}
}
}
+
+ function _savePHPBinary()
+ {
+ $this->_savephp = $this->_php;
+ }
+
+ function _restorePHPBinary()
+ {
+ if (isset($this->_savephp))
+ {
+ $this->_php = $this->_savephp;
+ unset($this->_savephp);
+ }
+ }
}
*
* PHP versions 4 and 5
*
- * @category pear
- * @package PEAR
- * @author Greg Beaver <cellog@php.net>
- * @copyright 1997-2009 The Authors
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Common.php 313023 2011-07-06 19:17:11Z dufuz $
- * @link http://pear.php.net/package/PEAR
- * @since File available since Release 1.4.0a1
+ * @category pear
+ * @package PEAR
+ * @author Greg Beaver <cellog@php.net>
+ * @copyright 1997-2009 The Authors
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://pear.php.net/package/PEAR
+ * @since File available since Release 1.4.0a1
*/
/**#@+
* Error codes for task validation routines
* This will first replace any instance of @data-dir@ in the test.php file
* with the path to the current data directory. Then, it will include the
* test.php file and run the script it contains to configure the package post-installation.
- * @category pear
- * @package PEAR
- * @author Greg Beaver <cellog@php.net>
- * @copyright 1997-2009 The Authors
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
- * @link http://pear.php.net/package/PEAR
- * @since Class available since Release 1.4.0a1
+ *
+ * @category pear
+ * @package PEAR
+ * @author Greg Beaver <cellog@php.net>
+ * @copyright 1997-2009 The Authors
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version Release: 1.10.1
+ * @link http://pear.php.net/package/PEAR
+ * @since Class available since Release 1.4.0a1
* @abstract
*/
class PEAR_Task_Common
* changes directly to disk
*
* Child task classes must override this property.
+ *
* @access protected
*/
- var $type = 'simple';
+ protected $type = 'simple';
/**
* Determines which install phase this task is executed under
*/
- var $phase = PEAR_TASK_INSTALL;
+ public $phase = PEAR_TASK_INSTALL;
/**
* @access protected
*/
- var $config;
+ protected $config;
/**
* @access protected
*/
- var $registry;
+ protected $registry;
/**
* @access protected
*/
- var $logger;
+ public $logger;
/**
* @access protected
*/
- var $installphase;
+ protected $installphase;
/**
* @param PEAR_Config
* @param PEAR_Common
*/
- function PEAR_Task_Common(&$config, &$logger, $phase)
+ function __construct(&$config, &$logger, $phase)
{
$this->config = &$config;
$this->registry = &$config->getRegistry();
/**
* Validate the basic contents of a task tag.
+ *
* @param PEAR_PackageFile_v2
* @param array
* @param PEAR_Config
* @param array the entire parsed <file> tag
+ *
* @return true|array On error, return an array in format:
- * array(PEAR_TASK_ERROR_???[, param1][, param2][, ...])
+ * array(PEAR_TASK_ERROR_???[, param1][, param2][, ...])
+ *
+ * For PEAR_TASK_ERROR_MISSING_ATTRIB, pass the attribute name in
+ * For PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, pass the attribute name and
+ * an array of legal values in
*
- * For PEAR_TASK_ERROR_MISSING_ATTRIB, pass the attribute name in
- * For PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, pass the attribute name and an array
- * of legal values in
- * @static
* @abstract
*/
- function validateXml($pkg, $xml, $config, $fileXml)
+ public static function validateXml($pkg, $xml, $config, $fileXml)
{
}
/**
* Initialize a task instance with the parameters
- * @param array raw, parsed xml
- * @param array attributes from the <file> tag containing this task
- * @param string|null last installed version of this package
+ *
+ * @param array raw, parsed xml
+ * @param array attributes from the <file> tag containing this task
+ * @param string|null last installed version of this package
* @abstract
*/
- function init($xml, $fileAttributes, $lastVersion)
+ public function init($xml, $fileAttributes, $lastVersion)
{
}
/**
- * Begin a task processing session. All multiple tasks will be processed after each file
- * has been successfully installed, all simple tasks should perform their task here and
- * return any errors using the custom throwError() method to allow forward compatibility
+ * Begin a task processing session. All multiple tasks will be processed
+ * after each file has been successfully installed, all simple tasks should
+ * perform their task here and return any errors using the custom
+ * throwError() method to allow forward compatibility
*
* This method MUST NOT write out any changes to disk
- * @param PEAR_PackageFile_v2
- * @param string file contents
- * @param string the eventual final file location (informational only)
- * @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail
- * (use $this->throwError), otherwise return the new contents
+ *
+ * @param PEAR_PackageFile_v2
+ * @param string file contents
+ * @param string the eventual final file location (informational only)
+ * @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail
+ * (use $this->throwError), otherwise return the new contents
* @abstract
*/
- function startSession($pkg, $contents, $dest)
+ public function startSession($pkg, $contents, $dest)
{
}
/**
- * This method is used to process each of the tasks for a particular multiple class
- * type. Simple tasks need not implement this method.
- * @param array an array of tasks
- * @access protected
- * @static
- * @abstract
+ * This method is used to process each of the tasks for a particular
+ * multiple class type. Simple tasks need not implement this method.
+ *
+ * @param array an array of tasks
+ * @access protected
*/
- function run($tasks)
+ public static function run($tasks)
{
}
/**
- * @static
* @final
*/
- function hasPostinstallTasks()
+ public static function hasPostinstallTasks()
{
return isset($GLOBALS['_PEAR_TASK_POSTINSTANCES']);
}
- /**
- * @static
- * @final
- */
- function runPostinstallTasks()
- {
- foreach ($GLOBALS['_PEAR_TASK_POSTINSTANCES'] as $class => $tasks) {
- $err = call_user_func(array($class, 'run'),
- $GLOBALS['_PEAR_TASK_POSTINSTANCES'][$class]);
- if ($err) {
- return PEAR_Task_Common::throwError($err);
- }
- }
- unset($GLOBALS['_PEAR_TASK_POSTINSTANCES']);
+ /**
+ * @final
+ */
+ public static function runPostinstallTasks()
+ {
+ foreach ($GLOBALS['_PEAR_TASK_POSTINSTANCES'] as $class => $tasks) {
+ $err = call_user_func(
+ array($class, 'run'),
+ $GLOBALS['_PEAR_TASK_POSTINSTANCES'][$class]
+ );
+ if ($err) {
+ return PEAR_Task_Common::throwError($err);
+ }
+ }
+ unset($GLOBALS['_PEAR_TASK_POSTINSTANCES']);
}
/**
* Determines whether a role is a script
* @return bool
*/
- function isScript()
+ public function isScript()
{
- return $this->type == 'script';
+ return $this->type == 'script';
}
- function throwError($msg, $code = -1)
+ public function throwError($msg, $code = -1)
{
include_once 'PEAR.php';
+
return PEAR::raiseError($msg, $code);
}
}
-?>
\ No newline at end of file
*
* PHP versions 4 and 5
*
- * @category pear
- * @package PEAR
- * @author Greg Beaver <cellog@php.net>
- * @copyright 1997-2009 The Authors
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Postinstallscript.php 313023 2011-07-06 19:17:11Z dufuz $
- * @link http://pear.php.net/package/PEAR
- * @since File available since Release 1.4.0a1
+ * @category pear
+ * @package PEAR
+ * @author Greg Beaver <cellog@php.net>
+ * @copyright 1997-2009 The Authors
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://pear.php.net/package/PEAR
+ * @since File available since Release 1.4.0a1
*/
/**
* Base class
*
* Note that post-install scripts are handled separately from installation, by the
* "pear run-scripts" command
- * @category pear
- * @package PEAR
- * @author Greg Beaver <cellog@php.net>
- * @copyright 1997-2009 The Authors
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
- * @link http://pear.php.net/package/PEAR
- * @since Class available since Release 1.4.0a1
+ *
+ * @category pear
+ * @package PEAR
+ * @author Greg Beaver <cellog@php.net>
+ * @copyright 1997-2009 The Authors
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version Release: 1.10.1
+ * @link http://pear.php.net/package/PEAR
+ * @since Class available since Release 1.4.0a1
*/
class PEAR_Task_Postinstallscript extends PEAR_Task_Common
{
- var $type = 'script';
- var $_class;
- var $_params;
- var $_obj;
+ public $type = 'script';
+ public $_class;
+ public $_params;
+ public $_obj;
/**
*
* @var PEAR_PackageFile_v2
*/
- var $_pkg;
- var $_contents;
- var $phase = PEAR_TASK_INSTALL;
+ public $_pkg;
+ public $_contents;
+ public $phase = PEAR_TASK_INSTALL;
/**
* Validate the raw xml at parsing-time.
*
* This also attempts to validate the script to make sure it meets the criteria
* for a post-install script
- * @param PEAR_PackageFile_v2
- * @param array The XML contents of the <postinstallscript> tag
- * @param PEAR_Config
- * @param array the entire parsed <file> tag
- * @static
+ *
+ * @param PEAR_PackageFile_v2
+ * @param array The XML contents of the <postinstallscript> tag
+ * @param PEAR_Config
+ * @param array the entire parsed <file> tag
*/
- function validateXml($pkg, $xml, $config, $fileXml)
+ public static function validateXml($pkg, $xml, $config, $fileXml)
{
if ($fileXml['role'] != 'php') {
- return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' .
- $fileXml['name'] . '" must be role="php"');
+ return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'.
+ $fileXml['name'].'" must be role="php"', );
}
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$file = $pkg->getFileContents($fileXml['name']);
if (PEAR::isError($file)) {
PEAR::popErrorHandling();
- return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' .
- $fileXml['name'] . '" is not valid: ' .
- $file->getMessage());
+
+ return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'.
+ $fileXml['name'].'" is not valid: '.
+ $file->getMessage(), );
} elseif ($file === null) {
- return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' .
- $fileXml['name'] . '" could not be retrieved for processing!');
+ return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'.
+ $fileXml['name'].'" could not be retrieved for processing!', );
} else {
$analysis = $pkg->analyzeSourceCode($file, true);
if (!$analysis) {
PEAR::popErrorHandling();
$warnings = '';
foreach ($pkg->getValidationWarnings() as $warn) {
- $warnings .= $warn['message'] . "\n";
+ $warnings .= $warn['message']."\n";
}
- return array(PEAR_TASK_ERROR_INVALID, 'Analysis of post-install script "' .
- $fileXml['name'] . '" failed: ' . $warnings);
+
+ return array(PEAR_TASK_ERROR_INVALID, 'Analysis of post-install script "'.
+ $fileXml['name'].'" failed: '.$warnings, );
}
if (count($analysis['declared_classes']) != 1) {
PEAR::popErrorHandling();
- return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' .
- $fileXml['name'] . '" must declare exactly 1 class');
+
+ return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'.
+ $fileXml['name'].'" must declare exactly 1 class', );
}
$class = $analysis['declared_classes'][0];
- if ($class != str_replace(array('/', '.php'), array('_', ''),
- $fileXml['name']) . '_postinstall') {
+ if ($class != str_replace(
+ array('/', '.php'), array('_', ''),
+ $fileXml['name']
+ ).'_postinstall') {
PEAR::popErrorHandling();
- return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' .
- $fileXml['name'] . '" class "' . $class . '" must be named "' .
- str_replace(array('/', '.php'), array('_', ''),
- $fileXml['name']) . '_postinstall"');
+
+ return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'.
+ $fileXml['name'].'" class "'.$class.'" must be named "'.
+ str_replace(
+ array('/', '.php'), array('_', ''),
+ $fileXml['name']
+ ).'_postinstall"', );
}
if (!isset($analysis['declared_methods'][$class])) {
PEAR::popErrorHandling();
- return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' .
- $fileXml['name'] . '" must declare methods init() and run()');
+
+ return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'.
+ $fileXml['name'].'" must declare methods init() and run()', );
}
$methods = array('init' => 0, 'run' => 1);
foreach ($analysis['declared_methods'][$class] as $method) {
}
if (count($methods)) {
PEAR::popErrorHandling();
- return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' .
- $fileXml['name'] . '" must declare methods init() and run()');
+
+ return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'.
+ $fileXml['name'].'" must declare methods init() and run()', );
}
}
PEAR::popErrorHandling();
$definedparams = array();
- $tasksNamespace = $pkg->getTasksNs() . ':';
- if (!isset($xml[$tasksNamespace . 'paramgroup']) && isset($xml['paramgroup'])) {
+ $tasksNamespace = $pkg->getTasksNs().':';
+ if (!isset($xml[$tasksNamespace.'paramgroup']) && isset($xml['paramgroup'])) {
// in order to support the older betas, which did not expect internal tags
// to also use the namespace
$tasksNamespace = '';
}
- if (isset($xml[$tasksNamespace . 'paramgroup'])) {
- $params = $xml[$tasksNamespace . 'paramgroup'];
+ if (isset($xml[$tasksNamespace.'paramgroup'])) {
+ $params = $xml[$tasksNamespace.'paramgroup'];
if (!is_array($params) || !isset($params[0])) {
$params = array($params);
}
foreach ($params as $param) {
- if (!isset($param[$tasksNamespace . 'id'])) {
- return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' .
- $fileXml['name'] . '" <paramgroup> must have ' .
- 'an ' . $tasksNamespace . 'id> tag');
+ if (!isset($param[$tasksNamespace.'id'])) {
+ return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'.
+ $fileXml['name'].'" <paramgroup> must have '.
+ 'an '.$tasksNamespace.'id> tag', );
}
- if (isset($param[$tasksNamespace . 'name'])) {
- if (!in_array($param[$tasksNamespace . 'name'], $definedparams)) {
- return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' .
- $fileXml['name'] . '" ' . $tasksNamespace .
- 'paramgroup> id "' . $param[$tasksNamespace . 'id'] .
- '" parameter "' . $param[$tasksNamespace . 'name'] .
- '" has not been previously defined');
+ if (isset($param[$tasksNamespace.'name'])) {
+ if (!in_array($param[$tasksNamespace.'name'], $definedparams)) {
+ return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'.
+ $fileXml['name'].'" '.$tasksNamespace.
+ 'paramgroup> id "'.$param[$tasksNamespace.'id'].
+ '" parameter "'.$param[$tasksNamespace.'name'].
+ '" has not been previously defined', );
}
- if (!isset($param[$tasksNamespace . 'conditiontype'])) {
- return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' .
- $fileXml['name'] . '" ' . $tasksNamespace .
- 'paramgroup> id "' . $param[$tasksNamespace . 'id'] .
- '" must have a ' . $tasksNamespace .
- 'conditiontype> tag containing either "=", ' .
- '"!=", or "preg_match"');
+ if (!isset($param[$tasksNamespace.'conditiontype'])) {
+ return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'.
+ $fileXml['name'].'" '.$tasksNamespace.
+ 'paramgroup> id "'.$param[$tasksNamespace.'id'].
+ '" must have a '.$tasksNamespace.
+ 'conditiontype> tag containing either "=", '.
+ '"!=", or "preg_match"', );
}
- if (!in_array($param[$tasksNamespace . 'conditiontype'],
- array('=', '!=', 'preg_match'))) {
- return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' .
- $fileXml['name'] . '" ' . $tasksNamespace .
- 'paramgroup> id "' . $param[$tasksNamespace . 'id'] .
- '" must have a ' . $tasksNamespace .
- 'conditiontype> tag containing either "=", ' .
- '"!=", or "preg_match"');
+ if (!in_array(
+ $param[$tasksNamespace.'conditiontype'],
+ array('=', '!=', 'preg_match')
+ )) {
+ return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'.
+ $fileXml['name'].'" '.$tasksNamespace.
+ 'paramgroup> id "'.$param[$tasksNamespace.'id'].
+ '" must have a '.$tasksNamespace.
+ 'conditiontype> tag containing either "=", '.
+ '"!=", or "preg_match"', );
}
- if (!isset($param[$tasksNamespace . 'value'])) {
- return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' .
- $fileXml['name'] . '" ' . $tasksNamespace .
- 'paramgroup> id "' . $param[$tasksNamespace . 'id'] .
- '" must have a ' . $tasksNamespace .
- 'value> tag containing expected parameter value');
+ if (!isset($param[$tasksNamespace.'value'])) {
+ return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'.
+ $fileXml['name'].'" '.$tasksNamespace.
+ 'paramgroup> id "'.$param[$tasksNamespace.'id'].
+ '" must have a '.$tasksNamespace.
+ 'value> tag containing expected parameter value', );
}
}
- if (isset($param[$tasksNamespace . 'instructions'])) {
- if (!is_string($param[$tasksNamespace . 'instructions'])) {
- return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' .
- $fileXml['name'] . '" ' . $tasksNamespace .
- 'paramgroup> id "' . $param[$tasksNamespace . 'id'] .
- '" ' . $tasksNamespace . 'instructions> must be simple text');
+ if (isset($param[$tasksNamespace.'instructions'])) {
+ if (!is_string($param[$tasksNamespace.'instructions'])) {
+ return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'.
+ $fileXml['name'].'" '.$tasksNamespace.
+ 'paramgroup> id "'.$param[$tasksNamespace.'id'].
+ '" '.$tasksNamespace.'instructions> must be simple text', );
}
}
- if (!isset($param[$tasksNamespace . 'param'])) {
+ if (!isset($param[$tasksNamespace.'param'])) {
continue; // <param> is no longer required
}
- $subparams = $param[$tasksNamespace . 'param'];
+ $subparams = $param[$tasksNamespace.'param'];
if (!is_array($subparams) || !isset($subparams[0])) {
$subparams = array($subparams);
}
foreach ($subparams as $subparam) {
- if (!isset($subparam[$tasksNamespace . 'name'])) {
- return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' .
- $fileXml['name'] . '" parameter for ' .
- $tasksNamespace . 'paramgroup> id "' .
- $param[$tasksNamespace . 'id'] . '" must have ' .
- 'a ' . $tasksNamespace . 'name> tag');
+ if (!isset($subparam[$tasksNamespace.'name'])) {
+ return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'.
+ $fileXml['name'].'" parameter for '.
+ $tasksNamespace.'paramgroup> id "'.
+ $param[$tasksNamespace.'id'].'" must have '.
+ 'a '.$tasksNamespace.'name> tag', );
}
- if (!preg_match('/[a-zA-Z0-9]+/',
- $subparam[$tasksNamespace . 'name'])) {
- return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' .
- $fileXml['name'] . '" parameter "' .
- $subparam[$tasksNamespace . 'name'] .
- '" for ' . $tasksNamespace . 'paramgroup> id "' .
- $param[$tasksNamespace . 'id'] .
- '" is not a valid name. Must contain only alphanumeric characters');
+ if (!preg_match(
+ '/[a-zA-Z0-9]+/',
+ $subparam[$tasksNamespace.'name']
+ )) {
+ return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'.
+ $fileXml['name'].'" parameter "'.
+ $subparam[$tasksNamespace.'name'].
+ '" for '.$tasksNamespace.'paramgroup> id "'.
+ $param[$tasksNamespace.'id'].
+ '" is not a valid name. Must contain only alphanumeric characters', );
}
- if (!isset($subparam[$tasksNamespace . 'prompt'])) {
- return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' .
- $fileXml['name'] . '" parameter "' .
- $subparam[$tasksNamespace . 'name'] .
- '" for ' . $tasksNamespace . 'paramgroup> id "' .
- $param[$tasksNamespace . 'id'] .
- '" must have a ' . $tasksNamespace . 'prompt> tag');
+ if (!isset($subparam[$tasksNamespace.'prompt'])) {
+ return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'.
+ $fileXml['name'].'" parameter "'.
+ $subparam[$tasksNamespace.'name'].
+ '" for '.$tasksNamespace.'paramgroup> id "'.
+ $param[$tasksNamespace.'id'].
+ '" must have a '.$tasksNamespace.'prompt> tag', );
}
- if (!isset($subparam[$tasksNamespace . 'type'])) {
- return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' .
- $fileXml['name'] . '" parameter "' .
- $subparam[$tasksNamespace . 'name'] .
- '" for ' . $tasksNamespace . 'paramgroup> id "' .
- $param[$tasksNamespace . 'id'] .
- '" must have a ' . $tasksNamespace . 'type> tag');
+ if (!isset($subparam[$tasksNamespace.'type'])) {
+ return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'.
+ $fileXml['name'].'" parameter "'.
+ $subparam[$tasksNamespace.'name'].
+ '" for '.$tasksNamespace.'paramgroup> id "'.
+ $param[$tasksNamespace.'id'].
+ '" must have a '.$tasksNamespace.'type> tag', );
}
- $definedparams[] = $param[$tasksNamespace . 'id'] . '::' .
- $subparam[$tasksNamespace . 'name'];
+ $definedparams[] = $param[$tasksNamespace.'id'].'::'.
+ $subparam[$tasksNamespace.'name'];
}
}
}
+
return true;
}
/**
* Initialize a task instance with the parameters
- * @param array raw, parsed xml
- * @param array attributes from the <file> tag containing this task
- * @param string|null last installed version of this package, if any (useful for upgrades)
+ * @param array $xml raw, parsed xml
+ * @param array $fileattribs attributes from the <file> tag containing
+ * this task
+ * @param string|null $lastversion last installed version of this package,
+ * if any (useful for upgrades)
*/
- function init($xml, $fileattribs, $lastversion)
+ public function init($xml, $fileattribs, $lastversion)
{
$this->_class = str_replace('/', '_', $fileattribs['name']);
$this->_filename = $fileattribs['name'];
- $this->_class = str_replace ('.php', '', $this->_class) . '_postinstall';
+ $this->_class = str_replace('.php', '', $this->_class).'_postinstall';
$this->_params = $xml;
$this->_lastversion = $lastversion;
}
*
* @access private
*/
- function _stripNamespace($params = null)
+ public function _stripNamespace($params = null)
{
if ($params === null) {
$params = array();
if (is_array($param)) {
$param = $this->_stripNamespace($param);
}
- $params[str_replace($this->_pkg->getTasksNs() . ':', '', $i)] = $param;
+ $params[str_replace($this->_pkg->getTasksNs().':', '', $i)] = $param;
}
$this->_params = $params;
} else {
if (is_array($param)) {
$param = $this->_stripNamespace($param);
}
- $newparams[str_replace($this->_pkg->getTasksNs() . ':', '', $i)] = $param;
+ $newparams[str_replace($this->_pkg->getTasksNs().':', '', $i)] = $param;
}
+
return $newparams;
}
}
/**
- * Unlike other tasks, the installed file name is passed in instead of the file contents,
- * because this task is handled post-installation
- * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
- * @param string file name
+ * Unlike other tasks, the installed file name is passed in instead of the
+ * file contents, because this task is handled post-installation
+ *
+ * @param mixed $pkg PEAR_PackageFile_v1|PEAR_PackageFile_v2
+ * @param string $contents file name
+ *
* @return bool|PEAR_Error false to skip this file, PEAR_Error to fail
- * (use $this->throwError)
+ * (use $this->throwError)
*/
- function startSession($pkg, $contents)
+ public function startSession($pkg, $contents)
{
if ($this->installphase != PEAR_TASK_INSTALL) {
return false;
// remove the tasks: namespace if present
$this->_pkg = $pkg;
$this->_stripNamespace();
- $this->logger->log(0, 'Including external post-installation script "' .
- $contents . '" - any errors are in this script');
+ $this->logger->log(
+ 0, 'Including external post-installation script "'.
+ $contents.'" - any errors are in this script'
+ );
include_once $contents;
if (class_exists($this->_class)) {
$this->logger->log(0, 'Inclusion succeeded');
} else {
- return $this->throwError('init of post-install script class "' . $this->_class
- . '" failed');
+ return $this->throwError(
+ 'init of post-install script class "'.$this->_class
+ .'" failed'
+ );
}
- $this->_obj = new $this->_class;
- $this->logger->log(1, 'running post-install script "' . $this->_class . '->init()"');
+ $this->_obj = new $this->_class();
+ $this->logger->log(1, 'running post-install script "'.$this->_class.'->init()"');
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$res = $this->_obj->init($this->config, $pkg, $this->_lastversion);
PEAR::popErrorHandling();
if ($res) {
$this->logger->log(0, 'init succeeded');
} else {
- return $this->throwError('init of post-install script "' . $this->_class .
- '->init()" failed');
+ return $this->throwError(
+ 'init of post-install script "'.$this->_class.
+ '->init()" failed'
+ );
}
$this->_contents = $contents;
+
return true;
}
/**
* No longer used
- * @see PEAR_PackageFile_v2::runPostinstallScripts()
- * @param array an array of tasks
- * @param string install or upgrade
+ *
+ * @see PEAR_PackageFile_v2::runPostinstallScripts()
+ * @param array an array of tasks
+ * @param string install or upgrade
* @access protected
- * @static
*/
- function run()
+ public static function run()
{
}
}
-?>
\ No newline at end of file
*
* PHP versions 4 and 5
*
- * @category pear
- * @package PEAR
- * @author Greg Beaver <cellog@php.net>
- * @copyright 1997-2009 The Authors
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: rw.php 313023 2011-07-06 19:17:11Z dufuz $
- * @link http://pear.php.net/package/PEAR
- * @since File available since Release 1.4.0a10
+ * @category pear
+ * @package PEAR
+ * @author Greg Beaver <cellog@php.net>
+ * @copyright 1997-2009 The Authors
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://pear.php.net/package/PEAR
+ * @since File available since Release 1.4.0a10
*/
/**
* Base class
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a10
*/
*
* @var PEAR_PackageFile_v2_rw
*/
- var $_pkg;
+ public $_pkg;
/**
* Enter description here...
*
- * @param PEAR_PackageFile_v2_rw $pkg
- * @param PEAR_Config $config
- * @param PEAR_Frontend $logger
- * @param array $fileXml
+ * @param PEAR_PackageFile_v2_rw $pkg Package
+ * @param PEAR_Config $config Config
+ * @param PEAR_Frontend $logger Logger
+ * @param array $fileXml XML
+ *
* @return PEAR_Task_Postinstallscript_rw
*/
- function PEAR_Task_Postinstallscript_rw(&$pkg, &$config, &$logger, $fileXml)
+ function __construct(&$pkg, &$config, &$logger, $fileXml)
{
- parent::PEAR_Task_Common($config, $logger, PEAR_TASK_PACKAGE);
+ parent::__construct($config, $logger, PEAR_TASK_PACKAGE);
$this->_contents = $fileXml;
$this->_pkg = &$pkg;
$this->_params = array();
}
- function validate()
+ public function validate()
{
return $this->validateXml($this->_pkg, $this->_params, $this->config, $this->_contents);
}
- function getName()
+ public function getName()
{
return 'postinstallscript';
}
*
* Use {@link addConditionTypeGroup()} to add a <paramgroup> containing
* a <conditiontype> tag
- * @param string $id <paramgroup> id as seen by the script
- * @param array|false $params array of getParam() calls, or false for no params
+ *
+ * @param string $id <paramgroup> id as seen by the script
+ * @param array|false $params array of getParam() calls, or false for no params
* @param string|false $instructions
*/
- function addParamGroup($id, $params = false, $instructions = false)
+ public function addParamGroup($id, $params = false, $instructions = false)
{
if ($params && isset($params[0]) && !isset($params[1])) {
$params = $params[0];
}
$stuff =
array(
- $this->_pkg->getTasksNs() . ':id' => $id,
+ $this->_pkg->getTasksNs().':id' => $id,
);
if ($instructions) {
- $stuff[$this->_pkg->getTasksNs() . ':instructions'] = $instructions;
+ $stuff[$this->_pkg->getTasksNs().':instructions'] = $instructions;
}
if ($params) {
- $stuff[$this->_pkg->getTasksNs() . ':param'] = $params;
+ $stuff[$this->_pkg->getTasksNs().':param'] = $params;
}
- $this->_params[$this->_pkg->getTasksNs() . ':paramgroup'][] = $stuff;
+ $this->_params[$this->_pkg->getTasksNs().':paramgroup'][] = $stuff;
}
/**
- * add a complex <paramgroup> to the post-install script with conditions
+ * Add a complex <paramgroup> to the post-install script with conditions
*
* This inserts a <paramgroup> with
*
*
* Use {@link addParamGroup()} to add a simple <paramgroup>
*
- * @param string $id <paramgroup> id as seen by the script
- * @param string $oldgroup <paramgroup> id of the section referenced by
- * <conditiontype>
- * @param string $param name of the <param> from the older section referenced
- * by <contitiontype>
- * @param string $value value to match of the parameter
- * @param string $conditiontype one of '=', '!=', 'preg_match'
- * @param array|false $params array of getParam() calls, or false for no params
+ * @param string $id <paramgroup> id as seen by the script
+ * @param string $oldgroup <paramgroup> id of the section referenced by
+ * <conditiontype>
+ * @param string $param name of the <param> from the older section referenced
+ * by <contitiontype>
+ * @param string $value value to match of the parameter
+ * @param string $conditiontype one of '=', '!=', 'preg_match'
+ * @param array|false $params array of getParam() calls, or false for no params
* @param string|false $instructions
*/
- function addConditionTypeGroup($id, $oldgroup, $param, $value, $conditiontype = '=',
- $params = false, $instructions = false)
- {
+ public function addConditionTypeGroup($id,
+ $oldgroup,
+ $param,
+ $value,
+ $conditiontype = '=',
+ $params = false,
+ $instructions = false
+ ) {
if ($params && isset($params[0]) && !isset($params[1])) {
$params = $params[0];
}
$stuff = array(
- $this->_pkg->getTasksNs() . ':id' => $id,
+ $this->_pkg->getTasksNs().':id' => $id,
);
if ($instructions) {
- $stuff[$this->_pkg->getTasksNs() . ':instructions'] = $instructions;
+ $stuff[$this->_pkg->getTasksNs().':instructions'] = $instructions;
}
- $stuff[$this->_pkg->getTasksNs() . ':name'] = $oldgroup . '::' . $param;
- $stuff[$this->_pkg->getTasksNs() . ':conditiontype'] = $conditiontype;
- $stuff[$this->_pkg->getTasksNs() . ':value'] = $value;
+ $stuff[$this->_pkg->getTasksNs().':name'] = $oldgroup.'::'.$param;
+ $stuff[$this->_pkg->getTasksNs().':conditiontype'] = $conditiontype;
+ $stuff[$this->_pkg->getTasksNs().':value'] = $value;
if ($params) {
- $stuff[$this->_pkg->getTasksNs() . ':param'] = $params;
+ $stuff[$this->_pkg->getTasksNs().':param'] = $params;
}
- $this->_params[$this->_pkg->getTasksNs() . ':paramgroup'][] = $stuff;
+ $this->_params[$this->_pkg->getTasksNs().':paramgroup'][] = $stuff;
}
- function getXml()
+ public function getXml()
{
return $this->_params;
}
/**
* Use to set up a param tag for use in creating a paramgroup
- * @static
+ *
+ * @param mixed $name Name of parameter
+ * @param mixed $prompt Prompt
+ * @param string $type Type, defaults to 'string'
+ * @param mixed $default Default value
+ *
+ * @return array
*/
- function getParam($name, $prompt, $type = 'string', $default = null)
- {
+ public static function getParam(
+ $name, $prompt, $type = 'string', $default = null
+ ) {
if ($default !== null) {
return
array(
- $this->_pkg->getTasksNs() . ':name' => $name,
- $this->_pkg->getTasksNs() . ':prompt' => $prompt,
- $this->_pkg->getTasksNs() . ':type' => $type,
- $this->_pkg->getTasksNs() . ':default' => $default
+ $this->_pkg->getTasksNs().':name' => $name,
+ $this->_pkg->getTasksNs().':prompt' => $prompt,
+ $this->_pkg->getTasksNs().':type' => $type,
+ $this->_pkg->getTasksNs().':default' => $default,
);
}
+
return
array(
- $this->_pkg->getTasksNs() . ':name' => $name,
- $this->_pkg->getTasksNs() . ':prompt' => $prompt,
- $this->_pkg->getTasksNs() . ':type' => $type,
+ $this->_pkg->getTasksNs().':name' => $name,
+ $this->_pkg->getTasksNs().':prompt' => $prompt,
+ $this->_pkg->getTasksNs().':type' => $type,
);
}
}
-?>
\ No newline at end of file
*
* PHP versions 4 and 5
*
- * @category pear
- * @package PEAR
- * @author Greg Beaver <cellog@php.net>
- * @copyright 1997-2009 The Authors
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Replace.php 313023 2011-07-06 19:17:11Z dufuz $
- * @link http://pear.php.net/package/PEAR
- * @since File available since Release 1.4.0a1
+ * @category pear
+ * @package PEAR
+ * @author Greg Beaver <cellog@php.net>
+ * @copyright 1997-2009 The Authors
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://pear.php.net/package/PEAR
+ * @since File available since Release 1.4.0a1
*/
/**
* Base class
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
class PEAR_Task_Replace extends PEAR_Task_Common
{
- var $type = 'simple';
- var $phase = PEAR_TASK_PACKAGEANDINSTALL;
- var $_replacements;
+ public $type = 'simple';
+ public $phase = PEAR_TASK_PACKAGEANDINSTALL;
+ public $_replacements;
/**
* Validate the raw xml at parsing-time.
- * @param PEAR_PackageFile_v2
- * @param array raw, parsed xml
- * @param PEAR_Config
- * @static
+ *
+ * @param PEAR_PackageFile_v2
+ * @param array raw, parsed xml
+ * @param PEAR_Config
*/
- function validateXml($pkg, $xml, $config, $fileXml)
+ public static function validateXml($pkg, $xml, $config, $fileXml)
{
if (!isset($xml['attribs'])) {
return array(PEAR_TASK_ERROR_NOATTRIBS);
if ($xml['attribs']['type'] == 'pear-config') {
if (!in_array($xml['attribs']['to'], $config->getKeys())) {
return array(PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, 'to', $xml['attribs']['to'],
- $config->getKeys());
+ $config->getKeys(), );
}
} elseif ($xml['attribs']['type'] == 'php-const') {
if (defined($xml['attribs']['to'])) {
return true;
} else {
return array(PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, 'to', $xml['attribs']['to'],
- array('valid PHP constant'));
+ array('valid PHP constant'), );
}
} elseif ($xml['attribs']['type'] == 'package-info') {
- if (in_array($xml['attribs']['to'],
+ if (in_array(
+ $xml['attribs']['to'],
array('name', 'summary', 'channel', 'notes', 'extends', 'description',
'release_notes', 'license', 'release-license', 'license-uri',
'version', 'api-version', 'state', 'api-state', 'release_date',
- 'date', 'time'))) {
+ 'date', 'time', )
+ )) {
return true;
} else {
return array(PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, 'to', $xml['attribs']['to'],
array('name', 'summary', 'channel', 'notes', 'extends', 'description',
'release_notes', 'license', 'release-license', 'license-uri',
'version', 'api-version', 'state', 'api-state', 'release_date',
- 'date', 'time'));
+ 'date', 'time', ), );
}
} else {
return array(PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, 'type', $xml['attribs']['type'],
- array('pear-config', 'package-info', 'php-const'));
+ array('pear-config', 'package-info', 'php-const'), );
}
+
return true;
}
* Initialize a task instance with the parameters
* @param array raw, parsed xml
* @param unused
+ * @param unused
*/
- function init($xml, $attribs)
+ public function init($xml, $attribs, $lastVersion = null)
{
$this->_replacements = isset($xml['attribs']) ? array($xml) : $xml;
}
* Do a package.xml 1.0 replacement, with additional package-info fields available
*
* See validateXml() source for the complete list of allowed fields
- * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
- * @param string file contents
- * @param string the eventual final file location (informational only)
+ *
+ * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
+ * @param string file contents
+ * @param string the eventual final file location (informational only)
* @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail
- * (use $this->throwError), otherwise return the new contents
+ * (use $this->throwError), otherwise return the new contents
*/
- function startSession($pkg, $contents, $dest)
+ public function startSession($pkg, $contents, $dest)
{
$subst_from = $subst_to = array();
foreach ($this->_replacements as $a) {
$to = $chan->getServer();
} else {
$this->logger->log(0, "$dest: invalid pear-config replacement: $a[to]");
+
return false;
}
} else {
}
if (is_null($to)) {
$this->logger->log(0, "$dest: invalid pear-config replacement: $a[to]");
+
return false;
}
} elseif ($a['type'] == 'php-const') {
$to = constant($a['to']);
} else {
$this->logger->log(0, "$dest: invalid php-const replacement: $a[to]");
+
return false;
}
} else {
$to = $t;
} else {
$this->logger->log(0, "$dest: invalid package-info replacement: $a[to]");
+
return false;
}
}
$subst_to[] = $to;
}
}
- $this->logger->log(3, "doing " . sizeof($subst_from) .
- " substitution(s) for $dest");
+ $this->logger->log(
+ 3, "doing ".sizeof($subst_from).
+ " substitution(s) for $dest"
+ );
if (sizeof($subst_from)) {
$contents = str_replace($subst_from, $subst_to, $contents);
}
+
return $contents;
}
}
-?>
\ No newline at end of file
*
* PHP versions 4 and 5
*
- * @category pear
- * @package PEAR
- * @author Greg Beaver <cellog@php.net>
- * @copyright 1997-2009 The Authors
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: rw.php 313023 2011-07-06 19:17:11Z dufuz $
- * @link http://pear.php.net/package/PEAR
- * @since File available since Release 1.4.0a10
+ * @category pear
+ * @package PEAR
+ * @author Greg Beaver <cellog@php.net>
+ * @copyright 1997-2009 The Authors
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://pear.php.net/package/PEAR
+ * @since File available since Release 1.4.0a10
*/
/**
* Base class
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a10
*/
class PEAR_Task_Replace_rw extends PEAR_Task_Replace
{
- function PEAR_Task_Replace_rw(&$pkg, &$config, &$logger, $fileXml)
+ public function __construct(&$pkg, &$config, &$logger, $fileXml)
{
- parent::PEAR_Task_Common($config, $logger, PEAR_TASK_PACKAGE);
+ parent::__construct($config, $logger, PEAR_TASK_PACKAGE);
$this->_contents = $fileXml;
$this->_pkg = &$pkg;
$this->_params = array();
}
- function validate()
+ public function validate()
{
return $this->validateXml($this->_pkg, $this->_params, $this->config, $this->_contents);
}
- function setInfo($from, $to, $type)
+ public function setInfo($from, $to, $type)
{
$this->_params = array('attribs' => array('from' => $from, 'to' => $to, 'type' => $type));
}
- function getName()
+ public function getName()
{
return 'replace';
}
- function getXml()
+ public function getXml()
{
return $this->_params;
}
}
-?>
\ No newline at end of file
*
* PHP versions 4 and 5
*
- * @category pear
- * @package PEAR
- * @author Greg Beaver <cellog@php.net>
- * @copyright 1997-2009 The Authors
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Unixeol.php 313023 2011-07-06 19:17:11Z dufuz $
- * @link http://pear.php.net/package/PEAR
- * @since File available since Release 1.4.0a1
+ * @category pear
+ * @package PEAR
+ * @author Greg Beaver <cellog@php.net>
+ * @copyright 1997-2009 The Authors
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://pear.php.net/package/PEAR
+ * @since File available since Release 1.4.0a1
*/
/**
* Base class
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
class PEAR_Task_Unixeol extends PEAR_Task_Common
{
- var $type = 'simple';
- var $phase = PEAR_TASK_PACKAGE;
- var $_replacements;
+ public $type = 'simple';
+ public $phase = PEAR_TASK_PACKAGE;
+ public $_replacements;
/**
* Validate the raw xml at parsing-time.
- * @param PEAR_PackageFile_v2
- * @param array raw, parsed xml
- * @param PEAR_Config
- * @static
+ *
+ * @param PEAR_PackageFile_v2
+ * @param array raw, parsed xml
+ * @param PEAR_Config
*/
- function validateXml($pkg, $xml, $config, $fileXml)
+ public static function validateXml($pkg, $xml, $config, $fileXml)
{
if ($xml != '') {
return array(PEAR_TASK_ERROR_INVALID, 'no attributes allowed');
}
+
return true;
}
* Initialize a task instance with the parameters
* @param array raw, parsed xml
* @param unused
+ * @param unused
*/
- function init($xml, $attribs)
+ public function init($xml, $attribs, $lastVersion = null)
{
}
* Replace all line endings with line endings customized for the current OS
*
* See validateXml() source for the complete list of allowed fields
- * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
- * @param string file contents
- * @param string the eventual final file location (informational only)
+ *
+ * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
+ * @param string file contents
+ * @param string the eventual final file location (informational only)
* @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail
- * (use $this->throwError), otherwise return the new contents
+ * (use $this->throwError), otherwise return the new contents
*/
- function startSession($pkg, $contents, $dest)
+ public function startSession($pkg, $contents, $dest)
{
$this->logger->log(3, "replacing all line endings with \\n in $dest");
+
return preg_replace("/\r\n|\n\r|\r|\n/", "\n", $contents);
}
}
-?>
\ No newline at end of file
*
* PHP versions 4 and 5
*
- * @category pear
- * @package PEAR
- * @author Greg Beaver <cellog@php.net>
- * @copyright 1997-2009 The Authors
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: rw.php 313023 2011-07-06 19:17:11Z dufuz $
- * @link http://pear.php.net/package/PEAR
- * @since File available since Release 1.4.0a10
+ * @category pear
+ * @package PEAR
+ * @author Greg Beaver <cellog@php.net>
+ * @copyright 1997-2009 The Authors
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://pear.php.net/package/PEAR
+ * @since File available since Release 1.4.0a10
*/
/**
* Base class
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a10
*/
class PEAR_Task_Unixeol_rw extends PEAR_Task_Unixeol
{
- function PEAR_Task_Unixeol_rw(&$pkg, &$config, &$logger, $fileXml)
+ function __construct(&$pkg, &$config, &$logger, $fileXml)
{
- parent::PEAR_Task_Common($config, $logger, PEAR_TASK_PACKAGE);
+ parent::__construct($config, $logger, PEAR_TASK_PACKAGE);
$this->_contents = $fileXml;
$this->_pkg = &$pkg;
$this->_params = array();
}
- function validate()
+ public function validate()
{
return true;
}
- function getName()
+ public function getName()
{
return 'unixeol';
}
- function getXml()
+ public function getXml()
{
return '';
}
}
-?>
\ No newline at end of file
+?>
*
* PHP versions 4 and 5
*
- * @category pear
- * @package PEAR
- * @author Greg Beaver <cellog@php.net>
- * @copyright 1997-2009 The Authors
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Windowseol.php 313023 2011-07-06 19:17:11Z dufuz $
- * @link http://pear.php.net/package/PEAR
- * @since File available since Release 1.4.0a1
+ * @category pear
+ * @package PEAR
+ * @author Greg Beaver <cellog@php.net>
+ * @copyright 1997-2009 The Authors
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://pear.php.net/package/PEAR
+ * @since File available since Release 1.4.0a1
*/
/**
* Base class
require_once 'PEAR/Task/Common.php';
/**
* Implements the windows line endsings file task.
- * @category pear
- * @package PEAR
- * @author Greg Beaver <cellog@php.net>
- * @copyright 1997-2009 The Authors
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
- * @link http://pear.php.net/package/PEAR
- * @since Class available since Release 1.4.0a1
+ *
+ * @category pear
+ * @package PEAR
+ * @author Greg Beaver <cellog@php.net>
+ * @copyright 1997-2009 The Authors
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version Release: 1.10.1
+ * @link http://pear.php.net/package/PEAR
+ * @since Class available since Release 1.4.0a1
*/
class PEAR_Task_Windowseol extends PEAR_Task_Common
{
- var $type = 'simple';
- var $phase = PEAR_TASK_PACKAGE;
- var $_replacements;
+ public $type = 'simple';
+ public $phase = PEAR_TASK_PACKAGE;
+ public $_replacements;
/**
* Validate the raw xml at parsing-time.
- * @param PEAR_PackageFile_v2
- * @param array raw, parsed xml
- * @param PEAR_Config
- * @static
+ *
+ * @param PEAR_PackageFile_v2
+ * @param array raw, parsed xml
+ * @param PEAR_Config
*/
- function validateXml($pkg, $xml, $config, $fileXml)
+ public static function validateXml($pkg, $xml, $config, $fileXml)
{
if ($xml != '') {
return array(PEAR_TASK_ERROR_INVALID, 'no attributes allowed');
}
+
return true;
}
* Initialize a task instance with the parameters
* @param array raw, parsed xml
* @param unused
+ * @param unused
*/
- function init($xml, $attribs)
+ public function init($xml, $attribs, $lastVersion = null)
{
}
* Replace all line endings with windows line endings
*
* See validateXml() source for the complete list of allowed fields
- * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
- * @param string file contents
- * @param string the eventual final file location (informational only)
+ *
+ * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
+ * @param string file contents
+ * @param string the eventual final file location (informational only)
* @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail
- * (use $this->throwError), otherwise return the new contents
+ * (use $this->throwError), otherwise return the new contents
*/
- function startSession($pkg, $contents, $dest)
+ public function startSession($pkg, $contents, $dest)
{
$this->logger->log(3, "replacing all line endings with \\r\\n in $dest");
+
return preg_replace("/\r\n|\n\r|\r|\n/", "\r\n", $contents);
}
}
-?>
\ No newline at end of file
*
* PHP versions 4 and 5
*
- * @category pear
- * @package PEAR
- * @author Greg Beaver <cellog@php.net>
- * @copyright 1997-2009 The Authors
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: rw.php 313023 2011-07-06 19:17:11Z dufuz $
- * @link http://pear.php.net/package/PEAR
- * @since File available since Release 1.4.0a10
+ * @category pear
+ * @package PEAR
+ * @author Greg Beaver <cellog@php.net>
+ * @copyright 1997-2009 The Authors
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://pear.php.net/package/PEAR
+ * @since File available since Release 1.4.0a10
*/
/**
* Base class
require_once 'PEAR/Task/Windowseol.php';
/**
* Abstracts the windowseol task xml.
- * @category pear
- * @package PEAR
- * @author Greg Beaver <cellog@php.net>
- * @copyright 1997-2009 The Authors
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
- * @link http://pear.php.net/package/PEAR
- * @since Class available since Release 1.4.0a10
+ *
+ * @category pear
+ * @package PEAR
+ * @author Greg Beaver <cellog@php.net>
+ * @copyright 1997-2009 The Authors
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version Release: 1.10.1
+ * @link http://pear.php.net/package/PEAR
+ * @since Class available since Release 1.4.0a10
*/
class PEAR_Task_Windowseol_rw extends PEAR_Task_Windowseol
{
- function PEAR_Task_Windowseol_rw(&$pkg, &$config, &$logger, $fileXml)
+ function __construct(&$pkg, &$config, &$logger, $fileXml)
{
- parent::PEAR_Task_Common($config, $logger, PEAR_TASK_PACKAGE);
+ parent::__construct($config, $logger, PEAR_TASK_PACKAGE);
$this->_contents = $fileXml;
$this->_pkg = &$pkg;
$this->_params = array();
}
- function validate()
+ public function validate()
{
return true;
}
- function getName()
+ public function getName()
{
return 'windowseol';
}
- function getXml()
+ public function getXml()
{
return '';
}
}
-?>
\ No newline at end of file
+?>
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Validate.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* to the PEAR naming convention, so the method is final and static.
* @param string
* @final
- * @static
*/
- function validGroupName($name)
+ public static function validGroupName($name)
{
return (bool) preg_match('/^' . _PEAR_COMMON_PACKAGE_NAME_PREG . '\\z/', $name);
}
* Determine whether $state represents a valid stability level
* @param string
* @return bool
- * @static
* @final
*/
- function validState($state)
+ public static function validState($state)
{
return in_array($state, array('snapshot', 'devel', 'alpha', 'beta', 'stable'));
}
/**
* Get a list of valid stability levels
* @return array
- * @static
* @final
*/
- function getValidStates()
+ public static function getValidStates()
{
return array('snapshot', 'devel', 'alpha', 'beta', 'stable');
}
* by version_compare
* @param string
* @return bool
- * @static
* @final
*/
- function validVersion($ver)
+ public static function validVersion($ver)
{
return (bool) preg_match(PEAR_COMMON_PACKAGE_VERSION_PREG, $ver);
}
$this->_packagexml->getExtends()) {
$version = $this->_packagexml->getVersion() . '';
$name = $this->_packagexml->getPackage();
- $test = array_shift($a = explode('.', $version));
+ $a = explode('.', $version);
+ $test = array_shift($a);
if ($test == '0') {
return true;
}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2006 The PHP Group
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: PECL.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a5
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a5
*/
* @author Stephan Schmidt (original XML_Unserializer code)
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license New BSD License
- * @version CVS: $Id: XMLParser.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @author Stephan Schmidt (original XML_Unserializer code)
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
$this->encoding = 'UTF-8';
}
- if (version_compare(phpversion(), '5.0.0', 'lt') && $this->encoding == 'UTF-8') {
- $data = utf8_decode($data);
- $this->encoding = 'ISO-8859-1';
- }
-
$xp = xml_parser_create($this->encoding);
xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, 0);
xml_set_object($xp, $this);
+++ /dev/null
-<?php
-/**
- * This is only meant for PHP 5 to get rid of certain strict warning
- * that doesn't get hidden since it's in the shutdown function
- */
-class PEAR5
-{
- /**
- * If you have a class that's mostly/entirely static, and you need static
- * properties, you can use this method to simulate them. Eg. in your method(s)
- * do this: $myVar = &PEAR5::getStaticProperty('myclass', 'myVar');
- * You MUST use a reference, or they will not persist!
- *
- * @access public
- * @param string $class The calling classname, to prevent clashes
- * @param string $var The variable to retrieve.
- * @return mixed A reference to the variable. If not set it will be
- * auto initialised to NULL.
- */
- static function &getStaticProperty($class, $var)
- {
- static $properties;
- if (!isset($properties[$class])) {
- $properties[$class] = array();
- }
-
- if (!array_key_exists($var, $properties[$class])) {
- $properties[$class][$var] = null;
- }
-
- return $properties[$class][$var];
- }
-}
\ No newline at end of file
+++ /dev/null
-PEAR - The PEAR Installer
-=========================
-
-What is the PEAR Installer? What is PEAR?
-
-PEAR is the PHP Extension and Application Repository, found at
-http://pear.php.net. The PEAR Installer is this software, which
-contains executable files and PHP code that is used to download
-and install PEAR code from pear.php.net.
-
-PEAR contains useful software libraries and applications such as
-MDB2 (database abstraction), HTML_QuickForm (HTML forms management),
-PhpDocumentor (auto-documentation generator), DB_DataObject
-(Data Access Abstraction), and many hundreds more. Browse all
-available packages at http://pear.php.net, the list is constantly
-growing and updating to reflect improvements in the PHP language.
-
-DOCUMENTATION
-=============
-
-Documentation for PEAR can be found at http://pear.php.net/manual/.
-Installation documentation can be found in the INSTALL file included
-in this tarball.
-
-WARNING: DO NOT RUN PEAR WITHOUT INSTALLING IT - if you downloaded this
-tarball manually, you MUST install it. Read the instructions in INSTALL
-prior to use.
-
-
-Happy PHPing, we hope PEAR will be a great tool for your development work!
-
-$Id: README 313023 2011-07-06 19:17:11Z dufuz $
\ No newline at end of file
--- /dev/null
+*************************
+PEAR - The PEAR Installer
+*************************
+.. image:: https://travis-ci.org/pear/pear-core.svg?branch=stable
+ :target: https://travis-ci.org/pear/pear-core
+
+=========================================
+What is the PEAR Installer? What is PEAR?
+=========================================
+PEAR is the PHP Extension and Application Repository, found at
+http://pear.php.net.
+
+The **PEAR Installer** is this software, which contains executable
+files and PHP code that is used to **download and install** PEAR code
+from pear.php.net.
+
+PEAR contains useful **software libraries and applications** such as
+MDB2 (database abstraction), HTML_QuickForm (HTML forms management),
+PhpDocumentor (auto-documentation generator), DB_DataObject
+(Data Access Abstraction), and many hundreds more.
+Browse all available packages at http://pear.php.net, the list is
+constantly growing and updating to reflect improvements in the PHP language.
+
+.. warning::
+ Do not run PEAR without installing it - if you downloaded this
+ tarball manually, you MUST install it. Read the instructions in INSTALL
+ prior to use.
+
+
+=============
+Documentation
+=============
+Documentation for PEAR can be found at http://pear.php.net/manual/.
+Installation documentation can be found in the INSTALL file included
+in this tarball.
+
+
+=====
+Tests
+=====
+Run the tests without installation as follows::
+
+ $ ./scripts/pear.sh run-tests -r tests
+
+You should have the ``Text_Diff`` package installed to get nicer error output.
+
+To run the tests with another PHP version, modify ``php_bin`` and set the
+``PHP_PEAR_PHP_BIN`` environment variable::
+
+ $ pear config-set php_bin /usr/local/bin/php7
+ $ PHP_PEAR_PHP_BIN=/usr/local/bin/php7 ./scripts/pear.sh run-tests -r tests
+
+Happy PHPing, we hope PEAR will be a great tool for your development work!
+
+
+Test dependencies
+=================
+* ``zlib``
+
+
+=========
+Releasing
+=========
+Create a PEAR package as well as phars for pear-less installation::
+
+ $ rm -f PEAR-*.tgz
+ $ pear package package2.xml
+ $ cd go-pear-tarballs
+ $ rm -f PEAR-*
+ $ cp ../PEAR-*.tgz .
+ $ gunzip PEAR-*.tgz
+ $ pear download -Z Archive_Tar Console_Getopt Structures_Graph XML_Util
+ $ mkdir src && cd src
+ $ for i in ../*.tar; do tar xvf $i; done
+ $ mv *\/* .
+ $ cd ../../
+ $ php make-gopear-phar.php
+ $ php make-installpear-nozlib-phar.php
+
+(Or simply run ``build-release.sh``).
+
+``go-pear.phar`` is contains the PEAR installer installer that asks questions
+where to install it.
+It is available from http://pear.php.net/go-pear.phar.
+
+``install-pear-nozlib.phar`` installs PEAR automatically without asking
+anything.
+It is shipped with PHP itself.
* @author Tomas V.V.Cox <cox@idecnet.com>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: System.php 313024 2011-07-06 19:51:24Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
* @author Tomas V.V. Cox <cox@idecnet.com>
* @copyright 1997-2006 The PHP Group
* @license http://opensource.org/licenses/bsd-license.php New BSD License
-* @version Release: 1.9.4
+* @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
* @static
* @param string $short_options the allowed option short-tags
* @param string $long_options the allowed option long-tags
* @return array the given options and there values
- * @static
- * @access private
*/
- function _parseArgs($argv, $short_options, $long_options = null)
+ public static function _parseArgs($argv, $short_options, $long_options = null)
{
if (!is_array($argv) && $argv !== null) {
+ /*
+ // Quote all items that are a short option
+ $av = preg_split('/(\A| )--?[a-z0-9]+[ =]?((?<!\\\\)((,\s*)|((?<!,)\s+))?)/i', $argv, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE);
+ $offset = 0;
+ foreach ($av as $a) {
+ $b = trim($a[0]);
+ if ($b{0} == '"' || $b{0} == "'") {
+ continue;
+ }
+
+ $escape = escapeshellarg($b);
+ $pos = $a[1] + $offset;
+ $argv = substr_replace($argv, $escape, $pos, strlen($b));
+ $offset += 2;
+ }
+ */
+
// Find all items, quoted or otherwise
preg_match_all("/(?:[\"'])(.*?)(?:['\"])|([^\s]+)/", $argv, $av);
$argv = $av[1];
$argv[$k] = trim($a) ;
}
}
+
return Console_Getopt::getopt2($argv, $short_options, $long_options);
}
*
* @param mixed $error a PEAR error or a string with the error message
* @return bool false
- * @static
- * @access private
*/
- function raiseError($error)
+ protected static function raiseError($error)
{
if (PEAR::isError($error)) {
$error = $error->getMessage();
* @param integer $aktinst starting deep of the lookup
* @param bool $silent if true, do not emit errors.
* @return array the structure of the dir
- * @static
- * @access private
*/
- function _dirToStruct($sPath, $maxinst, $aktinst = 0, $silent = false)
+ protected static function _dirToStruct($sPath, $maxinst, $aktinst = 0, $silent = false)
{
$struct = array('dirs' => array(), 'files' => array());
if (($dir = @opendir($sPath)) === false) {
* @static
* @see System::_dirToStruct()
*/
- function _multipleToStruct($files)
+ protected static function _multipleToStruct($files)
{
$struct = array('dirs' => array(), 'files' => array());
settype($files, 'array');
* @static
* @access public
*/
- function rm($args)
+ public static function rm($args)
{
$opts = System::_parseArgs($args, 'rf'); // "f" does nothing but I like it :-)
if (PEAR::isError($opts)) {
* The -p option will create parent directories
* @param string $args the name of the director(y|ies) to create
* @return bool True for success
- * @static
- * @access public
*/
- function mkDir($args)
+ public static function mkDir($args)
{
$opts = System::_parseArgs($args, 'pm:');
if (PEAR::isError($opts)) {
*
* @param string $args the arguments
* @return boolean true on success
- * @static
- * @access public
*/
- function &cat($args)
+ public static function &cat($args)
{
$ret = null;
$files = array();
* @param string $args The arguments
* @return mixed the full path of the created (file|dir) or false
* @see System::tmpdir()
- * @static
- * @access public
*/
- function mktemp($args = null)
+ public static function mktemp($args = null)
{
static $first_time = true;
$opts = System::_parseArgs($args, 't:d');
/**
* Remove temporary files created my mkTemp. This function is executed
* at script shutdown time
- *
- * @static
- * @access private
*/
- function _removeTmpFiles()
+ public static function _removeTmpFiles()
{
if (count($GLOBALS['_System_temp_files'])) {
$delete = $GLOBALS['_System_temp_files'];
* Note: php.ini-recommended removes the "E" from the variables_order setting,
* making unavaible the $_ENV array, that s why we do tests with _ENV
*
- * @static
* @return string The temporary directory on the system
*/
- function tmpdir()
+ public static function tmpdir()
{
if (OS_WINDOWS) {
if ($var = isset($_ENV['TMP']) ? $_ENV['TMP'] : getenv('TMP')) {
* @param mixed $fallback Value to return if $program is not found
*
* @return mixed A string with the full path or false if not found
- * @static
* @author Stig Bakken <ssb@php.net>
*/
- function which($program, $fallback = false)
+ public static function which($program, $fallback = false)
{
// enforce API
if (!is_string($program) || '' == $program) {
$path_elements[] = dirname($program);
$program = basename($program);
} else {
- // Honor safe mode
- if (!ini_get('safe_mode') || !$path = ini_get('safe_mode_exec_dir')) {
- $path = getenv('PATH');
- if (!$path) {
- $path = getenv('Path'); // some OSes are just stupid enough to do this
- }
+ $path = getenv('PATH');
+ if (!$path) {
+ $path = getenv('Path'); // some OSes are just stupid enough to do this
}
+
$path_elements = explode(PATH_SEPARATOR, $path);
}
if (strpos($program, '.') !== false) {
array_unshift($exe_suffixes, '');
}
- // is_executable() is not available on windows for PHP4
- $pear_is_executable = (function_exists('is_executable')) ? 'is_executable' : 'is_file';
} else {
$exe_suffixes = array('');
- $pear_is_executable = 'is_executable';
}
foreach ($exe_suffixes as $suff) {
foreach ($path_elements as $dir) {
$file = $dir . DIRECTORY_SEPARATOR . $program . $suff;
- if (@$pear_is_executable($file)) {
+ if (is_executable($file)) {
return $file;
}
}
*
* @param mixed Either array or string with the command line
* @return array Array of found files
- * @static
- *
*/
- function find($args)
+ public static function find($args)
{
if (!is_array($args)) {
$args = preg_split('/\s+/', $args, -1, PREG_SPLIT_NO_EMPTY);
-@ECHO OFF
-
-REM ----------------------------------------------------------------------
-REM PHP version 5
-REM ----------------------------------------------------------------------
-REM Copyright (c) 1997-2010 The Authors
-REM ----------------------------------------------------------------------
-REM http://opensource.org/licenses/bsd-license.php New BSD License
-REM ----------------------------------------------------------------------
-REM Authors: Alexander Merz (alexmerz@php.net)
-REM ----------------------------------------------------------------------
-REM
-REM Last updated 12/29/2004 ($Id$ is not replaced if the file is binary)
-
-REM change this lines to match the paths of your system
-REM -------------------
-
-
-REM Test to see if this is a raw pear.bat (uninstalled version)
-SET TMPTMPTMPTMPT=@includ
-SET PMTPMTPMT=%TMPTMPTMPTMPT%e_path@
-FOR %%x IN ("@include_path@") DO (if %%x=="%PMTPMTPMT%" GOTO :NOTINSTALLED)
-
-REM Check PEAR global ENV, set them if they do not exist
-IF "%PHP_PEAR_INSTALL_DIR%"=="" SET "PHP_PEAR_INSTALL_DIR=@include_path@"
-IF "%PHP_PEAR_BIN_DIR%"=="" SET "PHP_PEAR_BIN_DIR=@bin_dir@"
-IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=@php_bin@"
-
-GOTO :INSTALLED
-
-:NOTINSTALLED
-ECHO WARNING: This is a raw, uninstalled pear.bat
-
-REM Check to see if we can grab the directory of this file (Windows NT+)
-IF %~n0 == pear (
-FOR %%x IN (cli\php.exe php.exe) DO (if "%%~$PATH:x" NEQ "" (
-SET "PHP_PEAR_PHP_BIN=%%~$PATH:x"
-echo Using PHP Executable "%PHP_PEAR_PHP_BIN%"
-"%PHP_PEAR_PHP_BIN%" -v
-GOTO :NEXTTEST
-))
-GOTO :FAILAUTODETECT
-:NEXTTEST
-IF "%PHP_PEAR_PHP_BIN%" NEQ "" (
-
-REM We can use this PHP to run a temporary php file to get the dirname of pear
-
-echo ^<?php $s=getcwd^(^);chdir^($a=dirname^(__FILE__^).'\\'^);if^(stristr^($a,'\\scripts'^)^)$a=dirname^(dirname^($a^)^).'\\';$f=fopen^($s.'\\~a.a','wb'^);echo$s.'\\~a.a';fwrite^($f,$a^);fclose^($f^);chdir^($s^);?^> > ~~getloc.php
-"%PHP_PEAR_PHP_BIN%" ~~getloc.php
-set /p PHP_PEAR_BIN_DIR=fakeprompt < ~a.a
-DEL ~a.a
-DEL ~~getloc.php
-set "PHP_PEAR_INSTALL_DIR=%PHP_PEAR_BIN_DIR%pear"
-
-REM Make sure there is a pearcmd.php at our disposal
-
-IF NOT EXIST %PHP_PEAR_INSTALL_DIR%\pearcmd.php (
-IF EXIST %PHP_PEAR_INSTALL_DIR%\scripts\pearcmd.php COPY %PHP_PEAR_INSTALL_DIR%\scripts\pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php
-IF EXIST pearcmd.php COPY pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php
-IF EXIST %~dp0\scripts\pearcmd.php COPY %~dp0\scripts\pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php
-)
-)
-GOTO :INSTALLED
-) ELSE (
-REM Windows Me/98 cannot succeed, so allow the batch to fail
-)
-:FAILAUTODETECT
-echo WARNING: failed to auto-detect pear information
-:INSTALLED
-
-REM Check Folders and files
-IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%" GOTO PEAR_INSTALL_ERROR
-IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" GOTO PEAR_INSTALL_ERROR2
-IF NOT EXIST "%PHP_PEAR_BIN_DIR%" GOTO PEAR_BIN_ERROR
-IF NOT EXIST "%PHP_PEAR_PHP_BIN%" GOTO PEAR_PHPBIN_ERROR
-
-REM launch pearcmd
-GOTO RUN
-:PEAR_INSTALL_ERROR
-ECHO PHP_PEAR_INSTALL_DIR is not set correctly.
-ECHO Please fix it using your environment variable or modify
-ECHO the default value in pear.bat
-ECHO The current value is:
-ECHO %PHP_PEAR_INSTALL_DIR%
-GOTO END
-:PEAR_INSTALL_ERROR2
-ECHO PHP_PEAR_INSTALL_DIR is not set correctly.
-ECHO pearcmd.php could not be found there.
-ECHO Please fix it using your environment variable or modify
-ECHO the default value in pear.bat
-ECHO The current value is:
-ECHO %PHP_PEAR_INSTALL_DIR%
-GOTO END
-:PEAR_BIN_ERROR
-ECHO PHP_PEAR_BIN_DIR is not set correctly.
-ECHO Please fix it using your environment variable or modify
-ECHO the default value in pear.bat
-ECHO The current value is:
-ECHO %PHP_PEAR_BIN_DIR%
-GOTO END
-:PEAR_PHPBIN_ERROR
-ECHO PHP_PEAR_PHP_BIN is not set correctly.
-ECHO Please fix it using your environment variable or modify
-ECHO the default value in pear.bat
-ECHO The current value is:
-ECHO %PHP_PEAR_PHP_BIN%
-GOTO END
-:RUN
-"%PHP_PEAR_PHP_BIN%" -C -d date.timezone=UTC -d output_buffering=1 -d safe_mode=0 -d open_basedir="" -d auto_prepend_file="" -d auto_append_file="" -d variables_order=EGPCS -d register_argc_argv="On" -d "include_path='%PHP_PEAR_INSTALL_DIR%'" -f "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" -- %1 %2 %3 %4 %5 %6 %7 %8 %9
-:END
+@ECHO OFF\r
+\r
+REM ----------------------------------------------------------------------\r
+REM PHP version 5\r
+REM ----------------------------------------------------------------------\r
+REM Copyright (c) 1997-2010 The Authors\r
+REM ----------------------------------------------------------------------\r
+REM http://opensource.org/licenses/bsd-license.php New BSD License\r
+REM ----------------------------------------------------------------------\r
+REM Authors: Alexander Merz (alexmerz@php.net)\r
+REM ----------------------------------------------------------------------\r
+REM\r
+REM Last updated 12/29/2004 ($Id$ is not replaced if the file is binary)\r
+\r
+REM change this lines to match the paths of your system\r
+REM -------------------\r
+\r
+\r
+REM Test to see if this is a raw pear.bat (uninstalled version)\r
+SET TMPTMPTMPTMPT=@includ\r
+SET PMTPMTPMT=%TMPTMPTMPTMPT%e_path@\r
+FOR %%x IN ("@include_path@") DO (if %%x=="%PMTPMTPMT%" GOTO :NOTINSTALLED)\r
+\r
+REM Check PEAR global ENV, set them if they do not exist\r
+IF "%PHP_PEAR_INSTALL_DIR%"=="" SET "PHP_PEAR_INSTALL_DIR=@include_path@"\r
+IF "%PHP_PEAR_BIN_DIR%"=="" SET "PHP_PEAR_BIN_DIR=@bin_dir@"\r
+IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=@php_bin@"\r
+\r
+GOTO :INSTALLED\r
+\r
+:NOTINSTALLED\r
+ECHO WARNING: This is a raw, uninstalled pear.bat\r
+\r
+REM Check to see if we can grab the directory of this file (Windows NT+)\r
+IF %~n0 == pear (\r
+FOR %%x IN (cli\php.exe php.exe) DO (if "%%~$PATH:x" NEQ "" (\r
+SET "PHP_PEAR_PHP_BIN=%%~$PATH:x"\r
+echo Using PHP Executable "%PHP_PEAR_PHP_BIN%"\r
+"%PHP_PEAR_PHP_BIN%" -v\r
+GOTO :NEXTTEST\r
+))\r
+GOTO :FAILAUTODETECT\r
+:NEXTTEST\r
+IF "%PHP_PEAR_PHP_BIN%" NEQ "" (\r
+\r
+REM We can use this PHP to run a temporary php file to get the dirname of pear\r
+\r
+echo ^<?php $s=getcwd^(^);chdir^($a=dirname^(__FILE__^).'\\'^);if^(stristr^($a,'\\scripts'^)^)$a=dirname^(dirname^($a^)^).'\\';$f=fopen^($s.'\\~a.a','wb'^);echo$s.'\\~a.a';fwrite^($f,$a^);fclose^($f^);chdir^($s^);?^> > ~~getloc.php\r
+"%PHP_PEAR_PHP_BIN%" ~~getloc.php\r
+set /p PHP_PEAR_BIN_DIR=fakeprompt < ~a.a\r
+DEL ~a.a\r
+DEL ~~getloc.php\r
+set "PHP_PEAR_INSTALL_DIR=%PHP_PEAR_BIN_DIR%pear"\r
+\r
+REM Make sure there is a pearcmd.php at our disposal\r
+\r
+IF NOT EXIST %PHP_PEAR_INSTALL_DIR%\pearcmd.php (\r
+IF EXIST %PHP_PEAR_INSTALL_DIR%\scripts\pearcmd.php COPY %PHP_PEAR_INSTALL_DIR%\scripts\pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php\r
+IF EXIST pearcmd.php COPY pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php\r
+IF EXIST %~dp0\scripts\pearcmd.php COPY %~dp0\scripts\pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php\r
+)\r
+)\r
+GOTO :INSTALLED\r
+) ELSE (\r
+REM Windows Me/98 cannot succeed, so allow the batch to fail\r
+)\r
+:FAILAUTODETECT\r
+echo WARNING: failed to auto-detect pear information\r
+:INSTALLED\r
+\r
+REM Check Folders and files\r
+IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%" GOTO PEAR_INSTALL_ERROR\r
+IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" GOTO PEAR_INSTALL_ERROR2\r
+IF NOT EXIST "%PHP_PEAR_BIN_DIR%" GOTO PEAR_BIN_ERROR\r
+IF NOT EXIST "%PHP_PEAR_PHP_BIN%" GOTO PEAR_PHPBIN_ERROR\r
+\r
+REM launch pearcmd\r
+GOTO RUN\r
+:PEAR_INSTALL_ERROR\r
+ECHO PHP_PEAR_INSTALL_DIR is not set correctly.\r
+ECHO Please fix it using your environment variable or modify\r
+ECHO the default value in pear.bat\r
+ECHO The current value is:\r
+ECHO %PHP_PEAR_INSTALL_DIR%\r
+GOTO END\r
+:PEAR_INSTALL_ERROR2\r
+ECHO PHP_PEAR_INSTALL_DIR is not set correctly.\r
+ECHO pearcmd.php could not be found there.\r
+ECHO Please fix it using your environment variable or modify\r
+ECHO the default value in pear.bat\r
+ECHO The current value is:\r
+ECHO %PHP_PEAR_INSTALL_DIR%\r
+GOTO END\r
+:PEAR_BIN_ERROR\r
+ECHO PHP_PEAR_BIN_DIR is not set correctly.\r
+ECHO Please fix it using your environment variable or modify\r
+ECHO the default value in pear.bat\r
+ECHO The current value is:\r
+ECHO %PHP_PEAR_BIN_DIR%\r
+GOTO END\r
+:PEAR_PHPBIN_ERROR\r
+ECHO PHP_PEAR_PHP_BIN is not set correctly.\r
+ECHO Please fix it using your environment variable or modify\r
+ECHO the default value in pear.bat\r
+ECHO The current value is:\r
+ECHO %PHP_PEAR_PHP_BIN%\r
+GOTO END\r
+:RUN\r
+"%PHP_PEAR_PHP_BIN%" -C -d date.timezone=UTC -d output_buffering=1 -d safe_mode=0 -d open_basedir="" -d auto_prepend_file="" -d auto_append_file="" -d variables_order=EGPCS -d register_argc_argv="On" -d "include_path='%PHP_PEAR_INSTALL_DIR%'" -f "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" -- %1 %2 %3 %4 %5 %6 %7 %8 %9\r
+:END\r
@ECHO ON
\ No newline at end of file
*
* PHP versions 4 and 5
*
- * @category pear
- * @package PEAR
- * @author Stig Bakken <ssb@php.net>
- * @author Tomas V.V.Cox <cox@idecnet.com>
- * @copyright 1997-2009 The Authors
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: pearcmd.php 313023 2011-07-06 19:17:11Z dufuz $
- * @link http://pear.php.net/package/PEAR
+ * @category pear
+ * @package PEAR
+ * @author Stig Bakken <ssb@php.net>
+ * @author Tomas V.V.Cox <cox@idecnet.com>
+ * @copyright 1997-2009 The Authors
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://pear.php.net/package/PEAR
*/
-ob_end_clean();
+@ob_end_clean();
if (!defined('PEAR_RUNTYPE')) {
// this is defined in peclcmd.php as 'pecl'
define('PEAR_RUNTYPE', 'pear');
/**
* @nodep Gtk
*/
-if ('@include_path@' != '@'.'include_path'.'@') {
- ini_set('include_path', '@include_path@');
+//the space is needed for windows include paths with trailing backslash
+// http://pear.php.net/bugs/bug.php?id=19482
+if ('@include_path@ ' != '@'.'include_path'.'@ ') {
+ ini_set('include_path', trim('@include_path@ '). PATH_SEPARATOR . get_include_path());
$raw = false;
} else {
// this is a raw, uninstalled pear, either a cvs checkout, or php distro
$raw = true;
}
@ini_set('allow_url_fopen', true);
-if (!ini_get('safe_mode')) {
- @set_time_limit(0);
-}
+@set_time_limit(0);
ob_implicit_flush(true);
@ini_set('track_errors', true);
@ini_set('html_errors', false);
-@ini_set('magic_quotes_runtime', false);
$_PEAR_PHPDIR = '#$%^&*';
set_error_handler('error_handler');
// remove this next part when we stop supporting that crap-ass PHP 4.2
if (!isset($_SERVER['argv']) && !isset($argv) && !isset($HTTP_SERVER_VARS['argv'])) {
- echo 'ERROR: either use the CLI php executable, or set register_argc_argv=On in php.ini';
+ echo 'ERROR: either use the CLI php executable, ' .
+ 'or set register_argc_argv=On in php.ini';
exit(1);
}
$fetype = 'CLI';
if ($progname == 'gpear' || $progname == 'pear-gtk') {
- $fetype = 'Gtk';
+ $fetype = 'Gtk2';
} else {
foreach ($opts as $opt) {
if ($opt[0] == 'G') {
- $fetype = 'Gtk';
+ $fetype = 'Gtk2';
}
}
}
-//Check if Gtk and PHP >= 5.1.0
-if ($fetype == 'Gtk' && version_compare(phpversion(), '5.1.0', '>=')) {
- $fetype = 'Gtk2';
-}
$pear_user_config = '';
$pear_system_config = '';
foreach ($opts as $opt) {
switch ($opt[0]) {
- case 'c':
- $pear_user_config = $opt[1];
- break;
- case 'C':
- $pear_system_config = $opt[1];
- break;
+ case 'c':
+ $pear_user_config = $opt[1];
+ break;
+ case 'C':
+ $pear_system_config = $opt[1];
+ break;
}
}
if (PEAR::isError($config)) {
$_file = '';
if ($pear_user_config !== false) {
- $_file .= $pear_user_config;
+ $_file .= $pear_user_config;
}
if ($pear_system_config !== false) {
- $_file .= '/' . $pear_system_config;
+ $_file .= '/' . $pear_system_config;
}
if ($_file == '/') {
$_file = 'The default config file';
$_PEAR_PHPDIR = $config->get('php_dir');
$ui->setConfig($config);
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError"));
-if (ini_get('safe_mode')) {
- $ui->outputData('WARNING: running in safe mode requires that all files created ' .
- 'be the same uid as the current script. PHP reports this script is uid: ' .
- @getmyuid() . ', and current user is: ' . @get_current_user());
-}
$verbose = $config->get("verbose");
$cmdopts = array();
$found = false;
foreach ($opts as $opt) {
if ($opt[0] == 'd' || $opt[0] == 'D') {
- $found = true; // the user knows what they are doing, and are setting config values
+ // the user knows what they are doing, and are setting config values
+ $found = true;
}
}
if (!$found) {
// no prior runs, try to install PEAR
- if (strpos(dirname(__FILE__), 'scripts')) {
- $packagexml = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'package2.xml';
- $pearbase = dirname(dirname(__FILE__));
+ $parent = dirname(__FILE__);
+ if (strpos($parent, 'scripts')) {
+ $grandparent = dirname($parent);
+ $packagexml = $grandparent . DIRECTORY_SEPARATOR . 'package2.xml';
+ $pearbase = $grandparent;
} else {
- $packagexml = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'package2.xml';
- $pearbase = dirname(__FILE__);
+ $packagexml = $parent . DIRECTORY_SEPARATOR . 'package2.xml';
+ $pearbase = $parent;
}
if (file_exists($packagexml)) {
$options[1] = array(
$config->set('data_dir', $pearbase . DIRECTORY_SEPARATOR . 'data');
$config->set('doc_dir', $pearbase . DIRECTORY_SEPARATOR . 'docs');
$config->set('test_dir', $pearbase . DIRECTORY_SEPARATOR . 'tests');
- $config->set('ext_dir', $pearbase . DIRECTORY_SEPARATOR . 'extensions');
+ $config->set(
+ 'ext_dir',
+ $pearbase . DIRECTORY_SEPARATOR . 'extensions'
+ );
$config->set('bin_dir', $pearbase);
$config->mergeConfigFile($pearbase . 'pear.ini', false);
$config->store();
foreach ($opts as $opt) {
$param = !empty($opt[1]) ? $opt[1] : true;
switch ($opt[0]) {
- case 'd':
- if ($param === true) {
- die('Invalid usage of "-d" option, expected -d config_value=value, ' .
- 'received "-d"' . "\n");
- }
- $possible = explode('=', $param);
- if (count($possible) != 2) {
- die('Invalid usage of "-d" option, expected -d config_value=value, received "' .
- $param . '"' . "\n");
- }
- list($key, $value) = explode('=', $param);
- $config->set($key, $value, 'user');
- break;
- case 'D':
- if ($param === true) {
- die('Invalid usage of "-d" option, expected -d config_value=value, ' .
- 'received "-d"' . "\n");
- }
- $possible = explode('=', $param);
- if (count($possible) != 2) {
- die('Invalid usage of "-d" option, expected -d config_value=value, received "' .
- $param . '"' . "\n");
- }
- list($key, $value) = explode('=', $param);
- $config->set($key, $value, 'system');
- break;
- case 's':
- $store_user_config = true;
- break;
- case 'S':
- $store_system_config = true;
- break;
- case 'u':
- $config->remove($param, 'user');
- break;
- case 'v':
- $config->set('verbose', $config->get('verbose') + 1);
- break;
- case 'q':
- $config->set('verbose', $config->get('verbose') - 1);
- break;
- case 'V':
- usage(null, 'version');
- case 'c':
- case 'C':
- break;
- default:
- // all non pear params goes to the command
- $cmdopts[$opt[0]] = $param;
- break;
+ case 'd':
+ if ($param === true) {
+ die(
+ 'Invalid usage of "-d" option, expected -d config_value=value, ' .
+ 'received "-d"' . "\n"
+ );
+ }
+ $possible = explode('=', $param);
+ if (count($possible) != 2) {
+ die(
+ 'Invalid usage of "-d" option, expected ' .
+ '-d config_value=value, received "' . $param . '"' . "\n"
+ );
+ }
+ list($key, $value) = explode('=', $param);
+ $config->set($key, $value, 'user');
+ break;
+ case 'D':
+ if ($param === true) {
+ die(
+ 'Invalid usage of "-d" option, expected ' .
+ '-d config_value=value, received "-d"' . "\n"
+ );
+ }
+ $possible = explode('=', $param);
+ if (count($possible) != 2) {
+ die(
+ 'Invalid usage of "-d" option, expected ' .
+ '-d config_value=value, received "' . $param . '"' . "\n"
+ );
+ }
+ list($key, $value) = explode('=', $param);
+ $config->set($key, $value, 'system');
+ break;
+ case 's':
+ $store_user_config = true;
+ break;
+ case 'S':
+ $store_system_config = true;
+ break;
+ case 'u':
+ $config->remove($param, 'user');
+ break;
+ case 'v':
+ $config->set('verbose', $config->get('verbose') + 1);
+ break;
+ case 'q':
+ $config->set('verbose', $config->get('verbose') - 1);
+ break;
+ case 'V':
+ usage(null, 'version');
+ case 'c':
+ case 'C':
+ break;
+ default:
+ // all non pear params goes to the command
+ $cmdopts[$opt[0]] = $param;
+ break;
}
}
exit;
}
-if ($fetype == 'Gtk' || $fetype == 'Gtk2') {
+if ($fetype == 'Gtk2') {
if (!$config->validConfiguration()) {
- PEAR::raiseError('CRITICAL ERROR: no existing valid configuration files found in files ' .
- "'$pear_user_config' or '$pear_system_config', please copy an existing configuration" .
- 'file to one of these locations, or use the -c and -s options to create one');
+ PEAR::raiseError(
+ "CRITICAL ERROR: no existing valid configuration files found in " .
+ "files '$pear_user_config' or '$pear_system_config', " .
+ "please copy an existing configuration file to one of these " .
+ "locations, or use the -c and -s options to create one"
+ );
}
Gtk::main();
-} else do {
- if ($command == 'help') {
- usage(null, @$options[1][1]);
- }
-
- if (!$config->validConfiguration()) {
- PEAR::raiseError('CRITICAL ERROR: no existing valid configuration files found in files ' .
- "'$pear_user_config' or '$pear_system_config', please copy an existing configuration" .
- 'file to one of these locations, or use the -c and -s options to create one');
- }
+} else {
+ do {
+ if ($command == 'help') {
+ usage(null, isset($options[1][1]) ? $options[1][1] : null);
+ }
- PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
- $cmd = PEAR_Command::factory($command, $config);
- PEAR::popErrorHandling();
- if (PEAR::isError($cmd)) {
- usage(null, @$options[1][0]);
- }
+ if (!$config->validConfiguration()) {
+ PEAR::raiseError(
+ "CRITICAL ERROR: no existing valid configuration files found " .
+ "in files '$pear_user_config' or '$pear_system_config', " .
+ "please copy an existing configuration file to one of " .
+ "these locations, or use the -c and -s options to create one"
+ );
+ }
- $short_args = $long_args = null;
- PEAR_Command::getGetoptArgs($command, $short_args, $long_args);
- array_shift($options[1]);
- $tmp = Console_Getopt::getopt2($options[1], $short_args, $long_args);
+ PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
+ $cmd = PEAR_Command::factory($command, $config);
+ PEAR::popErrorHandling();
+ if (PEAR::isError($cmd)) {
+ usage(null, isset($options[1][0]) ? $options[1][0] : null);
+ }
- if (PEAR::isError($tmp)) {
- break;
- }
+ $short_args = $long_args = null;
+ PEAR_Command::getGetoptArgs($command, $short_args, $long_args);
+ array_shift($options[1]);
+ $tmp = Console_Getopt::getopt2($options[1], $short_args, $long_args);
- list($tmpopt, $params) = $tmp;
- $opts = array();
- foreach ($tmpopt as $foo => $tmp2) {
- list($opt, $value) = $tmp2;
- if ($value === null) {
- $value = true; // options without args
+ if (PEAR::isError($tmp)) {
+ break;
}
- if (strlen($opt) == 1) {
- $cmdoptions = $cmd->getOptions($command);
- foreach ($cmdoptions as $o => $d) {
- if (isset($d['shortopt']) && $d['shortopt'] == $opt) {
- $opts[$o] = $value;
- }
+ list($tmpopt, $params) = $tmp;
+ $opts = array();
+ foreach ($tmpopt as $foo => $tmp2) {
+ list($opt, $value) = $tmp2;
+ if ($value === null) {
+ $value = true; // options without args
}
- } else {
- if (substr($opt, 0, 2) == '--') {
- $opts[substr($opt, 2)] = $value;
+
+ if (strlen($opt) == 1) {
+ $cmdoptions = $cmd->getOptions($command);
+ foreach ($cmdoptions as $o => $d) {
+ if (isset($d['shortopt']) && $d['shortopt'] == $opt) {
+ $opts[$o] = $value;
+ }
+ }
+ } else {
+ if (substr($opt, 0, 2) == '--') {
+ $opts[substr($opt, 2)] = $value;
+ }
}
}
- }
- $ok = $cmd->run($command, $opts, $params);
- if ($ok === false) {
- PEAR::raiseError("unknown command `$command'");
- }
+ $ok = $cmd->run($command, $opts, $params);
+ if ($ok === false) {
+ PEAR::raiseError("unknown command `$command'");
+ }
- if (PEAR::isError($ok)) {
- PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError"));
- PEAR::raiseError($ok);
- }
-} while (false);
+ if (PEAR::isError($ok)) {
+ PEAR::setErrorHandling(
+ PEAR_ERROR_CALLBACK, array($ui, "displayFatalError")
+ );
+ PEAR::raiseError($ok);
+ }
+ } while (false);
+}
// {{{ usage()
+/**
+ * Display usage information
+ *
+ * @param mixed $error Optional error message
+ * @param mixed $helpsubject Optional subject/command to display help for
+ *
+ * @return void
+ */
function usage($error = null, $helpsubject = null)
{
global $progname, $all_commands;
"Usage: $progname [options] command [command-options] <parameters>\n".
"Type \"$progname help options\" to list all options.\n".
"Type \"$progname help shortcuts\" to list all command shortcuts.\n".
- "Type \"$progname help <command>\" to get the help for the specified command.";
+ "Type \"$progname help version\" or ".
+ "\"$progname version\" to list version information.\n".
+ "Type \"$progname help <command>\" to get the help ".
+ "for the specified command.";
}
fputs($stdout, "$put\n");
fclose($stdout);
exit(1);
}
+/**
+ * Return help string for specified command
+ *
+ * @param string $command Command to return help for
+ *
+ * @return void
+ */
function cmdHelp($command)
{
global $progname, $all_commands, $config;
// }}}
-function error_handler($errno, $errmsg, $file, $line, $vars) {
- if ((defined('E_STRICT') && $errno & E_STRICT) || (defined('E_DEPRECATED') &&
- $errno & E_DEPRECATED) || !error_reporting()) {
- if (defined('E_STRICT') && $errno & E_STRICT) {
+/**
+ * error_handler
+ *
+ * @param mixed $errno Error number
+ * @param mixed $errmsg Message
+ * @param mixed $file Filename
+ * @param mixed $line Line number
+ * @param mixed $vars Variables
+ *
+ * @access public
+ * @return boolean
+ */
+function error_handler($errno, $errmsg, $file, $line, $vars)
+{
+ if ($errno & E_STRICT
+ || $errno & E_DEPRECATED
+ || !error_reporting()
+ ) {
+ if ($errno & E_STRICT) {
return; // E_STRICT
}
- if (defined('E_DEPRECATED') && $errno & E_DEPRECATED) {
+ if ($errno & E_DEPRECATED) {
return; // E_DEPRECATED
}
- if ($GLOBALS['config']->get('verbose') < 4) {
+ if (!error_reporting() && isset($GLOBALS['config']) && $GLOBALS['config']->get('verbose') < 4) {
return false; // @silenced error, show all if debug is high enough
}
}
$errortype = array (
+ E_DEPRECATED => 'Deprecated Warning',
E_ERROR => "Error",
E_WARNING => "Warning",
E_PARSE => "Parsing Error",
+ E_STRICT => 'Strict Warning',
E_NOTICE => "Notice",
E_CORE_ERROR => "Core Error",
E_CORE_WARNING => "Core Warning",
* mode: php
* End:
*/
-// vim600:syn=php
\ No newline at end of file
+// vim600:syn=php
-@ECHO OFF
-
-REM ----------------------------------------------------------------------
-REM PHP version 5
-REM ----------------------------------------------------------------------
-REM Copyright (c) 1997-2004 The PHP Group
-REM ----------------------------------------------------------------------
-REM This source file is subject to version 3.0 of the PHP license,
-REM that is bundled with this package in the file LICENSE, and is
-REM available at through the world-wide-web at
-REM http://www.php.net/license/3_0.txt.
-REM If you did not receive a copy of the PHP license and are unable to
-REM obtain it through the world-wide-web, please send a note to
-REM license@php.net so we can mail you a copy immediately.
-REM ----------------------------------------------------------------------
-REM Authors: Alexander Merz (alexmerz@php.net)
-REM ----------------------------------------------------------------------
-REM
-REM $Id: peardev.bat,v 1.6 2007-09-03 03:00:17 cellog Exp $
-
-REM change this lines to match the paths of your system
-REM -------------------
-
-
-REM Test to see if this is a raw pear.bat (uninstalled version)
-SET TMPTMPTMPTMPT=@includ
-SET PMTPMTPMT=%TMPTMPTMPTMPT%e_path@
-FOR %%x IN ("@include_path@") DO (if %%x=="%PMTPMTPMT%" GOTO :NOTINSTALLED)
-
-REM Check PEAR global ENV, set them if they do not exist
-IF "%PHP_PEAR_INSTALL_DIR%"=="" SET "PHP_PEAR_INSTALL_DIR=@include_path@"
-IF "%PHP_PEAR_BIN_DIR%"=="" SET "PHP_PEAR_BIN_DIR=@bin_dir@"
-IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=@php_bin@"
-GOTO :INSTALLED
-
-:NOTINSTALLED
-ECHO WARNING: This is a raw, uninstalled pear.bat
-
-REM Check to see if we can grab the directory of this file (Windows NT+)
-IF %~n0 == pear (
-FOR %%x IN (cli\php.exe php.exe) DO (if "%%~$PATH:x" NEQ "" (
-SET "PHP_PEAR_PHP_BIN=%%~$PATH:x"
-echo Using PHP Executable "%PHP_PEAR_PHP_BIN%"
-"%PHP_PEAR_PHP_BIN%" -v
-GOTO :NEXTTEST
-))
-GOTO :FAILAUTODETECT
-:NEXTTEST
-IF "%PHP_PEAR_PHP_BIN%" NEQ "" (
-
-REM We can use this PHP to run a temporary php file to get the dirname of pear
-
-echo ^<?php $s=getcwd^(^);chdir^($a=dirname^(__FILE__^).'\\'^);if^(stristr^($a,'\\scripts'^)^)$a=dirname^(dirname^($a^)^).'\\';$f=fopen^($s.'\\~a.a','wb'^);echo$s.'\\~a.a';fwrite^($f,$a^);fclose^($f^);chdir^($s^);?^> > ~~getloc.php
-"%PHP_PEAR_PHP_BIN%" ~~getloc.php
-set /p PHP_PEAR_BIN_DIR=fakeprompt < ~a.a
-DEL ~a.a
-DEL ~~getloc.php
-set "PHP_PEAR_INSTALL_DIR=%PHP_PEAR_BIN_DIR%pear"
-
-REM Make sure there is a pearcmd.php at our disposal
-
-IF NOT EXIST %PHP_PEAR_INSTALL_DIR%\pearcmd.php (
-IF EXIST %PHP_PEAR_INSTALL_DIR%\scripts\pearcmd.php COPY %PHP_PEAR_INSTALL_DIR%\scripts\pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php
-IF EXIST pearcmd.php COPY pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php
-IF EXIST %~dp0\scripts\pearcmd.php COPY %~dp0\scripts\pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php
-)
-)
-GOTO :INSTALLED
-) ELSE (
-REM Windows Me/98 cannot succeed, so allow the batch to fail
-)
-:FAILAUTODETECT
-echo WARNING: failed to auto-detect pear information
-:INSTALLED
-
-REM Check Folders and files
-IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%" GOTO PEAR_INSTALL_ERROR
-IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" GOTO PEAR_INSTALL_ERROR2
-IF NOT EXIST "%PHP_PEAR_BIN_DIR%" GOTO PEAR_BIN_ERROR
-IF NOT EXIST "%PHP_PEAR_PHP_BIN%" GOTO PEAR_PHPBIN_ERROR
-REM launch pearcmd
-GOTO RUN
-:PEAR_INSTALL_ERROR
-ECHO PHP_PEAR_INSTALL_DIR is not set correctly.
-ECHO Please fix it using your environment variable or modify
-ECHO the default value in pear.bat
-ECHO The current value is:
-ECHO %PHP_PEAR_INSTALL_DIR%
-GOTO END
-:PEAR_INSTALL_ERROR2
-ECHO PHP_PEAR_INSTALL_DIR is not set correctly.
-ECHO pearcmd.php could not be found there.
-ECHO Please fix it using your environment variable or modify
-ECHO the default value in pear.bat
-ECHO The current value is:
-ECHO %PHP_PEAR_INSTALL_DIR%
-GOTO END
-:PEAR_BIN_ERROR
-ECHO PHP_PEAR_BIN_DIR is not set correctly.
-ECHO Please fix it using your environment variable or modify
-ECHO the default value in pear.bat
-ECHO The current value is:
-ECHO %PHP_PEAR_BIN_DIR%
-GOTO END
-:PEAR_PHPBIN_ERROR
-ECHO PHP_PEAR_PHP_BIN is not set correctly.
-ECHO Please fix it using your environment variable or modify
-ECHO the default value in pear.bat
-ECHO The current value is:
-ECHO %PHP_PEAR_PHP_BIN%
-GOTO END
-:RUN
-"%PHP_PEAR_PHP_BIN%" -C -d date.timezone=UTC -d memory_limit="-1" -d safe_mode=0 -d register_argc_argv="On" -d auto_prepend_file="" -d auto_append_file="" -d variables_order=EGPCS -d open_basedir="" -d output_buffering=1 -d "include_path='%PHP_PEAR_INSTALL_DIR%'" -f "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" -- %1 %2 %3 %4 %5 %6 %7 %8 %9
-:END
+@ECHO OFF\r
+\r
+REM ----------------------------------------------------------------------\r
+REM PHP version 5\r
+REM ----------------------------------------------------------------------\r
+REM Copyright (c) 1997-2004 The PHP Group\r
+REM ----------------------------------------------------------------------\r
+REM This source file is subject to version 3.0 of the PHP license,\r
+REM that is bundled with this package in the file LICENSE, and is\r
+REM available at through the world-wide-web at\r
+REM http://www.php.net/license/3_0.txt.\r
+REM If you did not receive a copy of the PHP license and are unable to\r
+REM obtain it through the world-wide-web, please send a note to\r
+REM license@php.net so we can mail you a copy immediately.\r
+REM ----------------------------------------------------------------------\r
+REM Authors: Alexander Merz (alexmerz@php.net)\r
+REM ----------------------------------------------------------------------\r
+REM\r
+REM $Id: peardev.bat,v 1.6 2007-09-03 03:00:17 cellog Exp $\r
+\r
+REM change this lines to match the paths of your system\r
+REM -------------------\r
+\r
+\r
+REM Test to see if this is a raw pear.bat (uninstalled version)\r
+SET TMPTMPTMPTMPT=@includ\r
+SET PMTPMTPMT=%TMPTMPTMPTMPT%e_path@\r
+FOR %%x IN ("@include_path@") DO (if %%x=="%PMTPMTPMT%" GOTO :NOTINSTALLED)\r
+\r
+REM Check PEAR global ENV, set them if they do not exist\r
+IF "%PHP_PEAR_INSTALL_DIR%"=="" SET "PHP_PEAR_INSTALL_DIR=@include_path@"\r
+IF "%PHP_PEAR_BIN_DIR%"=="" SET "PHP_PEAR_BIN_DIR=@bin_dir@"\r
+IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=@php_bin@"\r
+GOTO :INSTALLED\r
+\r
+:NOTINSTALLED\r
+ECHO WARNING: This is a raw, uninstalled pear.bat\r
+\r
+REM Check to see if we can grab the directory of this file (Windows NT+)\r
+IF %~n0 == pear (\r
+FOR %%x IN (cli\php.exe php.exe) DO (if "%%~$PATH:x" NEQ "" (\r
+SET "PHP_PEAR_PHP_BIN=%%~$PATH:x"\r
+echo Using PHP Executable "%PHP_PEAR_PHP_BIN%"\r
+"%PHP_PEAR_PHP_BIN%" -v\r
+GOTO :NEXTTEST\r
+))\r
+GOTO :FAILAUTODETECT\r
+:NEXTTEST\r
+IF "%PHP_PEAR_PHP_BIN%" NEQ "" (\r
+\r
+REM We can use this PHP to run a temporary php file to get the dirname of pear\r
+\r
+echo ^<?php $s=getcwd^(^);chdir^($a=dirname^(__FILE__^).'\\'^);if^(stristr^($a,'\\scripts'^)^)$a=dirname^(dirname^($a^)^).'\\';$f=fopen^($s.'\\~a.a','wb'^);echo$s.'\\~a.a';fwrite^($f,$a^);fclose^($f^);chdir^($s^);?^> > ~~getloc.php\r
+"%PHP_PEAR_PHP_BIN%" ~~getloc.php\r
+set /p PHP_PEAR_BIN_DIR=fakeprompt < ~a.a\r
+DEL ~a.a\r
+DEL ~~getloc.php\r
+set "PHP_PEAR_INSTALL_DIR=%PHP_PEAR_BIN_DIR%pear"\r
+\r
+REM Make sure there is a pearcmd.php at our disposal\r
+\r
+IF NOT EXIST %PHP_PEAR_INSTALL_DIR%\pearcmd.php (\r
+IF EXIST %PHP_PEAR_INSTALL_DIR%\scripts\pearcmd.php COPY %PHP_PEAR_INSTALL_DIR%\scripts\pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php\r
+IF EXIST pearcmd.php COPY pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php\r
+IF EXIST %~dp0\scripts\pearcmd.php COPY %~dp0\scripts\pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php\r
+)\r
+)\r
+GOTO :INSTALLED\r
+) ELSE (\r
+REM Windows Me/98 cannot succeed, so allow the batch to fail\r
+)\r
+:FAILAUTODETECT\r
+echo WARNING: failed to auto-detect pear information\r
+:INSTALLED\r
+\r
+REM Check Folders and files\r
+IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%" GOTO PEAR_INSTALL_ERROR\r
+IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" GOTO PEAR_INSTALL_ERROR2\r
+IF NOT EXIST "%PHP_PEAR_BIN_DIR%" GOTO PEAR_BIN_ERROR\r
+IF NOT EXIST "%PHP_PEAR_PHP_BIN%" GOTO PEAR_PHPBIN_ERROR\r
+REM launch pearcmd\r
+GOTO RUN\r
+:PEAR_INSTALL_ERROR\r
+ECHO PHP_PEAR_INSTALL_DIR is not set correctly.\r
+ECHO Please fix it using your environment variable or modify\r
+ECHO the default value in pear.bat\r
+ECHO The current value is:\r
+ECHO %PHP_PEAR_INSTALL_DIR%\r
+GOTO END\r
+:PEAR_INSTALL_ERROR2\r
+ECHO PHP_PEAR_INSTALL_DIR is not set correctly.\r
+ECHO pearcmd.php could not be found there.\r
+ECHO Please fix it using your environment variable or modify\r
+ECHO the default value in pear.bat\r
+ECHO The current value is:\r
+ECHO %PHP_PEAR_INSTALL_DIR%\r
+GOTO END\r
+:PEAR_BIN_ERROR\r
+ECHO PHP_PEAR_BIN_DIR is not set correctly.\r
+ECHO Please fix it using your environment variable or modify\r
+ECHO the default value in pear.bat\r
+ECHO The current value is:\r
+ECHO %PHP_PEAR_BIN_DIR%\r
+GOTO END\r
+:PEAR_PHPBIN_ERROR\r
+ECHO PHP_PEAR_PHP_BIN is not set correctly.\r
+ECHO Please fix it using your environment variable or modify\r
+ECHO the default value in pear.bat\r
+ECHO The current value is:\r
+ECHO %PHP_PEAR_PHP_BIN%\r
+GOTO END\r
+:RUN\r
+"%PHP_PEAR_PHP_BIN%" -C -d date.timezone=UTC -d memory_limit="-1" -d safe_mode=0 -d register_argc_argv="On" -d auto_prepend_file="" -d auto_append_file="" -d variables_order=EGPCS -d open_basedir="" -d output_buffering=1 -d "include_path='%PHP_PEAR_INSTALL_DIR%'" -f "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" -- %1 %2 %3 %4 %5 %6 %7 %8 %9\r
+:END\r
@ECHO ON
\ No newline at end of file
-@ECHO OFF
-
-REM ----------------------------------------------------------------------
-REM PHP version 5
-REM ----------------------------------------------------------------------
-REM Copyright (c) 1997-2004 The PHP Group
-REM ----------------------------------------------------------------------
-REM This source file is subject to version 3.0 of the PHP license,
-REM that is bundled with this package in the file LICENSE, and is
-REM available at through the world-wide-web at
-REM http://www.php.net/license/3_0.txt.
-REM If you did not receive a copy of the PHP license and are unable to
-REM obtain it through the world-wide-web, please send a note to
-REM license@php.net so we can mail you a copy immediately.
-REM ----------------------------------------------------------------------
-REM Authors: Alexander Merz (alexmerz@php.net)
-REM ----------------------------------------------------------------------
-REM
-REM Last updated 02/08/2004 ($Id$ is not replaced if the file is binary)
-
-REM change this lines to match the paths of your system
-REM -------------------
-
-
-REM Test to see if this is a raw pear.bat (uninstalled version)
-SET TMPTMPTMPTMPT=@includ
-SET PMTPMTPMT=%TMPTMPTMPTMPT%e_path@
-FOR %%x IN ("@include_path@") DO (if %%x=="%PMTPMTPMT%" GOTO :NOTINSTALLED)
-
-REM Check PEAR global ENV, set them if they do not exist
-IF "%PHP_PEAR_INSTALL_DIR%"=="" SET "PHP_PEAR_INSTALL_DIR=@include_path@"
-IF "%PHP_PEAR_BIN_DIR%"=="" SET "PHP_PEAR_BIN_DIR=@bin_dir@"
-IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=@php_bin@"
-GOTO :INSTALLED
-
-:NOTINSTALLED
-ECHO WARNING: This is a raw, uninstalled pear.bat
-
-REM Check to see if we can grab the directory of this file (Windows NT+)
-IF %~n0 == pear (
-FOR %%x IN (cli\php.exe php.exe) DO (if "%%~$PATH:x" NEQ "" (
-SET "PHP_PEAR_PHP_BIN=%%~$PATH:x"
-echo Using PHP Executable "%PHP_PEAR_PHP_BIN%"
-"%PHP_PEAR_PHP_BIN%" -v
-GOTO :NEXTTEST
-))
-GOTO :FAILAUTODETECT
-:NEXTTEST
-IF "%PHP_PEAR_PHP_BIN%" NEQ "" (
-
-REM We can use this PHP to run a temporary php file to get the dirname of pear
-
-echo ^<?php $s=getcwd^(^);chdir^($a=dirname^(__FILE__^).'\\'^);if^(stristr^($a,'\\scripts'^)^)$a=dirname^(dirname^($a^)^).'\\';$f=fopen^($s.'\\~a.a','wb'^);echo$s.'\\~a.a';fwrite^($f,$a^);fclose^($f^);chdir^($s^);?^> > ~~getloc.php
-"%PHP_PEAR_PHP_BIN%" ~~getloc.php
-set /p PHP_PEAR_BIN_DIR=fakeprompt < ~a.a
-DEL ~a.a
-DEL ~~getloc.php
-set "PHP_PEAR_INSTALL_DIR=%PHP_PEAR_BIN_DIR%pear"
-
-REM Make sure there is a pearcmd.php at our disposal
-
-IF NOT EXIST %PHP_PEAR_INSTALL_DIR%\pearcmd.php (
-IF EXIST %PHP_PEAR_INSTALL_DIR%\scripts\pearcmd.php COPY %PHP_PEAR_INSTALL_DIR%\scripts\pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php
-IF EXIST pearcmd.php COPY pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php
-IF EXIST %~dp0\scripts\pearcmd.php COPY %~dp0\scripts\pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php
-)
-)
-GOTO :INSTALLED
-) ELSE (
-REM Windows Me/98 cannot succeed, so allow the batch to fail
-)
-:FAILAUTODETECT
-echo WARNING: failed to auto-detect pear information
-:INSTALLED
-
-REM Check Folders and files
-IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%" GOTO PEAR_INSTALL_ERROR
-IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" GOTO PEAR_INSTALL_ERROR2
-IF NOT EXIST "%PHP_PEAR_BIN_DIR%" GOTO PEAR_BIN_ERROR
-IF NOT EXIST "%PHP_PEAR_PHP_BIN%" GOTO PEAR_PHPBIN_ERROR
-REM launch pearcmd
-GOTO RUN
-:PEAR_INSTALL_ERROR
-ECHO PHP_PEAR_INSTALL_DIR is not set correctly.
-ECHO Please fix it using your environment variable or modify
-ECHO the default value in pear.bat
-ECHO The current value is:
-ECHO %PHP_PEAR_INSTALL_DIR%
-GOTO END
-:PEAR_INSTALL_ERROR2
-ECHO PHP_PEAR_INSTALL_DIR is not set correctly.
-ECHO pearcmd.php could not be found there.
-ECHO Please fix it using your environment variable or modify
-ECHO the default value in pear.bat
-ECHO The current value is:
-ECHO %PHP_PEAR_INSTALL_DIR%
-GOTO END
-:PEAR_BIN_ERROR
-ECHO PHP_PEAR_BIN_DIR is not set correctly.
-ECHO Please fix it using your environment variable or modify
-ECHO the default value in pear.bat
-ECHO The current value is:
-ECHO %PHP_PEAR_BIN_DIR%
-GOTO END
-:PEAR_PHPBIN_ERROR
-ECHO PHP_PEAR_PHP_BIN is not set correctly.
-ECHO Please fix it using your environment variable or modify
-ECHO the default value in pear.bat
-ECHO The current value is:
-ECHO %PHP_PEAR_PHP_BIN%
-GOTO END
-:RUN
-"%PHP_PEAR_PHP_BIN%" -C -n -d date.timezone=UTC -d output_buffering=1 -d safe_mode=0 -d "include_path='%PHP_PEAR_INSTALL_DIR%'" -d register_argc_argv="On" -d variables_order=EGPCS -f "%PHP_PEAR_INSTALL_DIR%\peclcmd.php" -- %1 %2 %3 %4 %5 %6 %7 %8 %9
-:END
+@ECHO OFF\r
+\r
+REM ----------------------------------------------------------------------\r
+REM PHP version 5\r
+REM ----------------------------------------------------------------------\r
+REM Copyright (c) 1997-2004 The PHP Group\r
+REM ----------------------------------------------------------------------\r
+REM This source file is subject to version 3.0 of the PHP license,\r
+REM that is bundled with this package in the file LICENSE, and is\r
+REM available at through the world-wide-web at\r
+REM http://www.php.net/license/3_0.txt.\r
+REM If you did not receive a copy of the PHP license and are unable to\r
+REM obtain it through the world-wide-web, please send a note to\r
+REM license@php.net so we can mail you a copy immediately.\r
+REM ----------------------------------------------------------------------\r
+REM Authors: Alexander Merz (alexmerz@php.net)\r
+REM ----------------------------------------------------------------------\r
+REM\r
+REM Last updated 02/08/2004 ($Id$ is not replaced if the file is binary)\r
+\r
+REM change this lines to match the paths of your system\r
+REM -------------------\r
+\r
+\r
+REM Test to see if this is a raw pear.bat (uninstalled version)\r
+SET TMPTMPTMPTMPT=@includ\r
+SET PMTPMTPMT=%TMPTMPTMPTMPT%e_path@\r
+FOR %%x IN ("@include_path@") DO (if %%x=="%PMTPMTPMT%" GOTO :NOTINSTALLED)\r
+\r
+REM Check PEAR global ENV, set them if they do not exist\r
+IF "%PHP_PEAR_INSTALL_DIR%"=="" SET "PHP_PEAR_INSTALL_DIR=@include_path@"\r
+IF "%PHP_PEAR_BIN_DIR%"=="" SET "PHP_PEAR_BIN_DIR=@bin_dir@"\r
+IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=@php_bin@"\r
+GOTO :INSTALLED\r
+\r
+:NOTINSTALLED\r
+ECHO WARNING: This is a raw, uninstalled pear.bat\r
+\r
+REM Check to see if we can grab the directory of this file (Windows NT+)\r
+IF %~n0 == pear (\r
+FOR %%x IN (cli\php.exe php.exe) DO (if "%%~$PATH:x" NEQ "" (\r
+SET "PHP_PEAR_PHP_BIN=%%~$PATH:x"\r
+echo Using PHP Executable "%PHP_PEAR_PHP_BIN%"\r
+"%PHP_PEAR_PHP_BIN%" -v\r
+GOTO :NEXTTEST\r
+))\r
+GOTO :FAILAUTODETECT\r
+:NEXTTEST\r
+IF "%PHP_PEAR_PHP_BIN%" NEQ "" (\r
+\r
+REM We can use this PHP to run a temporary php file to get the dirname of pear\r
+\r
+echo ^<?php $s=getcwd^(^);chdir^($a=dirname^(__FILE__^).'\\'^);if^(stristr^($a,'\\scripts'^)^)$a=dirname^(dirname^($a^)^).'\\';$f=fopen^($s.'\\~a.a','wb'^);echo$s.'\\~a.a';fwrite^($f,$a^);fclose^($f^);chdir^($s^);?^> > ~~getloc.php\r
+"%PHP_PEAR_PHP_BIN%" ~~getloc.php\r
+set /p PHP_PEAR_BIN_DIR=fakeprompt < ~a.a\r
+DEL ~a.a\r
+DEL ~~getloc.php\r
+set "PHP_PEAR_INSTALL_DIR=%PHP_PEAR_BIN_DIR%pear"\r
+\r
+REM Make sure there is a pearcmd.php at our disposal\r
+\r
+IF NOT EXIST %PHP_PEAR_INSTALL_DIR%\pearcmd.php (\r
+IF EXIST %PHP_PEAR_INSTALL_DIR%\scripts\pearcmd.php COPY %PHP_PEAR_INSTALL_DIR%\scripts\pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php\r
+IF EXIST pearcmd.php COPY pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php\r
+IF EXIST %~dp0\scripts\pearcmd.php COPY %~dp0\scripts\pearcmd.php %PHP_PEAR_INSTALL_DIR%\pearcmd.php\r
+)\r
+)\r
+GOTO :INSTALLED\r
+) ELSE (\r
+REM Windows Me/98 cannot succeed, so allow the batch to fail\r
+)\r
+:FAILAUTODETECT\r
+echo WARNING: failed to auto-detect pear information\r
+:INSTALLED\r
+\r
+REM Check Folders and files\r
+IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%" GOTO PEAR_INSTALL_ERROR\r
+IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" GOTO PEAR_INSTALL_ERROR2\r
+IF NOT EXIST "%PHP_PEAR_BIN_DIR%" GOTO PEAR_BIN_ERROR\r
+IF NOT EXIST "%PHP_PEAR_PHP_BIN%" GOTO PEAR_PHPBIN_ERROR\r
+REM launch pearcmd\r
+GOTO RUN\r
+:PEAR_INSTALL_ERROR\r
+ECHO PHP_PEAR_INSTALL_DIR is not set correctly.\r
+ECHO Please fix it using your environment variable or modify\r
+ECHO the default value in pear.bat\r
+ECHO The current value is:\r
+ECHO %PHP_PEAR_INSTALL_DIR%\r
+GOTO END\r
+:PEAR_INSTALL_ERROR2\r
+ECHO PHP_PEAR_INSTALL_DIR is not set correctly.\r
+ECHO pearcmd.php could not be found there.\r
+ECHO Please fix it using your environment variable or modify\r
+ECHO the default value in pear.bat\r
+ECHO The current value is:\r
+ECHO %PHP_PEAR_INSTALL_DIR%\r
+GOTO END\r
+:PEAR_BIN_ERROR\r
+ECHO PHP_PEAR_BIN_DIR is not set correctly.\r
+ECHO Please fix it using your environment variable or modify\r
+ECHO the default value in pear.bat\r
+ECHO The current value is:\r
+ECHO %PHP_PEAR_BIN_DIR%\r
+GOTO END\r
+:PEAR_PHPBIN_ERROR\r
+ECHO PHP_PEAR_PHP_BIN is not set correctly.\r
+ECHO Please fix it using your environment variable or modify\r
+ECHO the default value in pear.bat\r
+ECHO The current value is:\r
+ECHO %PHP_PEAR_PHP_BIN%\r
+GOTO END\r
+:RUN\r
+"%PHP_PEAR_PHP_BIN%" -C -n -d date.timezone=UTC -d output_buffering=1 -d safe_mode=0 -d "include_path='%PHP_PEAR_INSTALL_DIR%'" -d register_argc_argv="On" -d variables_order=EGPCS -f "%PHP_PEAR_INSTALL_DIR%\peclcmd.php" -- %1 %2 %3 %4 %5 %6 %7 %8 %9\r
+:END\r
@ECHO ON
\ No newline at end of file
* @author Tomas V.V.Cox <cox@idecnet.com>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: peclcmd.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
*/
/**
* @nodep Gtk
*/
-if ('@include_path@' != '@'.'include_path'.'@') {
- ini_set('include_path', '@include_path@');
+//the space is needed for windows include paths with trailing backslash
+// http://pear.php.net/bugs/bug.php?id=19482
+if ('@include_path@ ' != '@'.'include_path'.'@ ') {
+ ini_set('include_path', trim('@include_path@ '). PATH_SEPARATOR . get_include_path());
$raw = false;
} else {
// this is a raw, uninstalled pear, either a cvs checkout, or php distro
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.9.31.3531 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.9.31.3532 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>