Add pear modules, mail and net_smtp via composer (#93)
Add pear modules, mail and net_smtp via composer, remove php 5.6 build due to phpunit 6
This commit is contained in:
6
lib/composer/vendor/pear/console_getopt/.gitignore
vendored
Normal file
6
lib/composer/vendor/pear/console_getopt/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
# composer related
|
||||
composer.lock
|
||||
composer.phar
|
||||
vendor
|
||||
README.html
|
||||
dist/
|
||||
9
lib/composer/vendor/pear/console_getopt/.travis.yml
vendored
Normal file
9
lib/composer/vendor/pear/console_getopt/.travis.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
language: php
|
||||
php:
|
||||
- 7
|
||||
- 5.6
|
||||
- 5.5
|
||||
- 5.4
|
||||
sudo: false
|
||||
script:
|
||||
- pear run-tests -r tests/
|
||||
360
lib/composer/vendor/pear/console_getopt/Console/Getopt.php
vendored
Normal file
360
lib/composer/vendor/pear/console_getopt/Console/Getopt.php
vendored
Normal file
@@ -0,0 +1,360 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||
/**
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 1997-2004 The PHP Group
|
||||
*
|
||||
* This source file is subject to version 3.0 of the PHP license,
|
||||
* that is bundled with this package in the file LICENSE, and is
|
||||
* available through the world-wide-web at the following url:
|
||||
* http://www.php.net/license/3_0.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.
|
||||
*
|
||||
* @category Console
|
||||
* @package Console_Getopt
|
||||
* @author Andrei Zmievski <andrei@php.net>
|
||||
* @license http://www.php.net/license/3_0.txt PHP 3.0
|
||||
* @version CVS: $Id$
|
||||
* @link http://pear.php.net/package/Console_Getopt
|
||||
*/
|
||||
|
||||
require_once 'PEAR.php';
|
||||
|
||||
/**
|
||||
* Command-line options parsing class.
|
||||
*
|
||||
* @category Console
|
||||
* @package Console_Getopt
|
||||
* @author Andrei Zmievski <andrei@php.net>
|
||||
* @license http://www.php.net/license/3_0.txt PHP 3.0
|
||||
* @link http://pear.php.net/package/Console_Getopt
|
||||
*/
|
||||
class Console_Getopt
|
||||
{
|
||||
|
||||
/**
|
||||
* Parses the command-line options.
|
||||
*
|
||||
* The first parameter to this function should be the list of command-line
|
||||
* arguments without the leading reference to the running program.
|
||||
*
|
||||
* The second parameter is a string of allowed short options. Each of the
|
||||
* option letters can be followed by a colon ':' to specify that the option
|
||||
* requires an argument, or a double colon '::' to specify that the option
|
||||
* takes an optional argument.
|
||||
*
|
||||
* The third argument is an optional array of allowed long options. The
|
||||
* leading '--' should not be included in the option name. Options that
|
||||
* require an argument should be followed by '=', and options that take an
|
||||
* option argument should be followed by '=='.
|
||||
*
|
||||
* The return value is an array of two elements: the list of parsed
|
||||
* options and the list of non-option command-line arguments. Each entry in
|
||||
* the list of parsed options is a pair of elements - the first one
|
||||
* specifies the option, and the second one specifies the option argument,
|
||||
* if there was one.
|
||||
*
|
||||
* Long and short options can be mixed.
|
||||
*
|
||||
* Most of the semantics of this function are based on GNU getopt_long().
|
||||
*
|
||||
* @param array $args an array of command-line arguments
|
||||
* @param string $short_options specifies the list of allowed short options
|
||||
* @param array $long_options specifies the list of allowed long options
|
||||
* @param boolean $skip_unknown suppresses Console_Getopt: unrecognized option
|
||||
*
|
||||
* @return array two-element array containing the list of parsed options and
|
||||
* the non-option arguments
|
||||
*/
|
||||
public static function getopt2($args, $short_options, $long_options = null, $skip_unknown = false)
|
||||
{
|
||||
return Console_Getopt::doGetopt(2, $args, $short_options, $long_options, $skip_unknown);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function expects $args to start with the script name (POSIX-style).
|
||||
* Preserved for backwards compatibility.
|
||||
*
|
||||
* @param array $args an array of command-line arguments
|
||||
* @param string $short_options specifies the list of allowed short options
|
||||
* @param array $long_options specifies the list of allowed long options
|
||||
*
|
||||
* @see getopt2()
|
||||
* @return array two-element array containing the list of parsed options and
|
||||
* the non-option arguments
|
||||
*/
|
||||
public static function getopt($args, $short_options, $long_options = null, $skip_unknown = false)
|
||||
{
|
||||
return Console_Getopt::doGetopt(1, $args, $short_options, $long_options, $skip_unknown);
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual implementation of the argument parsing code.
|
||||
*
|
||||
* @param int $version Version to use
|
||||
* @param array $args an array of command-line arguments
|
||||
* @param string $short_options specifies the list of allowed short options
|
||||
* @param array $long_options specifies the list of allowed long options
|
||||
* @param boolean $skip_unknown suppresses Console_Getopt: unrecognized option
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function doGetopt($version, $args, $short_options, $long_options = null, $skip_unknown = false)
|
||||
{
|
||||
// in case you pass directly readPHPArgv() as the first arg
|
||||
if (PEAR::isError($args)) {
|
||||
return $args;
|
||||
}
|
||||
|
||||
if (empty($args)) {
|
||||
return array(array(), array());
|
||||
}
|
||||
|
||||
$non_opts = $opts = array();
|
||||
|
||||
settype($args, 'array');
|
||||
|
||||
if ($long_options) {
|
||||
sort($long_options);
|
||||
}
|
||||
|
||||
/*
|
||||
* Preserve backwards compatibility with callers that relied on
|
||||
* erroneous POSIX fix.
|
||||
*/
|
||||
if ($version < 2) {
|
||||
if (isset($args[0]{0}) && $args[0]{0} != '-') {
|
||||
array_shift($args);
|
||||
}
|
||||
}
|
||||
|
||||
reset($args);
|
||||
while (list($i, $arg) = each($args)) {
|
||||
/* The special element '--' means explicit end of
|
||||
options. Treat the rest of the arguments as non-options
|
||||
and end the loop. */
|
||||
if ($arg == '--') {
|
||||
$non_opts = array_merge($non_opts, array_slice($args, $i + 1));
|
||||
break;
|
||||
}
|
||||
|
||||
if ($arg{0} != '-' || (strlen($arg) > 1 && $arg{1} == '-' && !$long_options)) {
|
||||
$non_opts = array_merge($non_opts, array_slice($args, $i));
|
||||
break;
|
||||
} elseif (strlen($arg) > 1 && $arg{1} == '-') {
|
||||
$error = Console_Getopt::_parseLongOption(substr($arg, 2),
|
||||
$long_options,
|
||||
$opts,
|
||||
$args,
|
||||
$skip_unknown);
|
||||
if (PEAR::isError($error)) {
|
||||
return $error;
|
||||
}
|
||||
} elseif ($arg == '-') {
|
||||
// - is stdin
|
||||
$non_opts = array_merge($non_opts, array_slice($args, $i));
|
||||
break;
|
||||
} else {
|
||||
$error = Console_Getopt::_parseShortOption(substr($arg, 1),
|
||||
$short_options,
|
||||
$opts,
|
||||
$args,
|
||||
$skip_unknown);
|
||||
if (PEAR::isError($error)) {
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array($opts, $non_opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse short option
|
||||
*
|
||||
* @param string $arg Argument
|
||||
* @param string[] $short_options Available short options
|
||||
* @param string[][] &$opts
|
||||
* @param string[] &$args
|
||||
* @param boolean $skip_unknown suppresses Console_Getopt: unrecognized option
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function _parseShortOption($arg, $short_options, &$opts, &$args, $skip_unknown)
|
||||
{
|
||||
for ($i = 0; $i < strlen($arg); $i++) {
|
||||
$opt = $arg{$i};
|
||||
$opt_arg = null;
|
||||
|
||||
/* Try to find the short option in the specifier string. */
|
||||
if (($spec = strstr($short_options, $opt)) === false || $arg{$i} == ':') {
|
||||
if ($skip_unknown === true) {
|
||||
break;
|
||||
}
|
||||
|
||||
$msg = "Console_Getopt: unrecognized option -- $opt";
|
||||
return PEAR::raiseError($msg);
|
||||
}
|
||||
|
||||
if (strlen($spec) > 1 && $spec{1} == ':') {
|
||||
if (strlen($spec) > 2 && $spec{2} == ':') {
|
||||
if ($i + 1 < strlen($arg)) {
|
||||
/* Option takes an optional argument. Use the remainder of
|
||||
the arg string if there is anything left. */
|
||||
$opts[] = array($opt, substr($arg, $i + 1));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* Option requires an argument. Use the remainder of the arg
|
||||
string if there is anything left. */
|
||||
if ($i + 1 < strlen($arg)) {
|
||||
$opts[] = array($opt, substr($arg, $i + 1));
|
||||
break;
|
||||
} else if (list(, $opt_arg) = each($args)) {
|
||||
/* Else use the next argument. */;
|
||||
if (Console_Getopt::_isShortOpt($opt_arg)
|
||||
|| Console_Getopt::_isLongOpt($opt_arg)) {
|
||||
$msg = "option requires an argument --$opt";
|
||||
return PEAR::raiseError("Console_Getopt: " . $msg);
|
||||
}
|
||||
} else {
|
||||
$msg = "option requires an argument --$opt";
|
||||
return PEAR::raiseError("Console_Getopt: " . $msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$opts[] = array($opt, $opt_arg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an argument is a short option
|
||||
*
|
||||
* @param string $arg Argument to check
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected static function _isShortOpt($arg)
|
||||
{
|
||||
return strlen($arg) == 2 && $arg[0] == '-'
|
||||
&& preg_match('/[a-zA-Z]/', $arg[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an argument is a long option
|
||||
*
|
||||
* @param string $arg Argument to check
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected static function _isLongOpt($arg)
|
||||
{
|
||||
return strlen($arg) > 2 && $arg[0] == '-' && $arg[1] == '-' &&
|
||||
preg_match('/[a-zA-Z]+$/', substr($arg, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse long option
|
||||
*
|
||||
* @param string $arg Argument
|
||||
* @param string[] $long_options Available long options
|
||||
* @param string[][] &$opts
|
||||
* @param string[] &$args
|
||||
*
|
||||
* @return void|PEAR_Error
|
||||
*/
|
||||
protected static function _parseLongOption($arg, $long_options, &$opts, &$args, $skip_unknown)
|
||||
{
|
||||
@list($opt, $opt_arg) = explode('=', $arg, 2);
|
||||
|
||||
$opt_len = strlen($opt);
|
||||
|
||||
for ($i = 0; $i < count($long_options); $i++) {
|
||||
$long_opt = $long_options[$i];
|
||||
$opt_start = substr($long_opt, 0, $opt_len);
|
||||
|
||||
$long_opt_name = str_replace('=', '', $long_opt);
|
||||
|
||||
/* Option doesn't match. Go on to the next one. */
|
||||
if ($long_opt_name != $opt) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$opt_rest = substr($long_opt, $opt_len);
|
||||
|
||||
/* Check that the options uniquely matches one of the allowed
|
||||
options. */
|
||||
if ($i + 1 < count($long_options)) {
|
||||
$next_option_rest = substr($long_options[$i + 1], $opt_len);
|
||||
} else {
|
||||
$next_option_rest = '';
|
||||
}
|
||||
|
||||
if ($opt_rest != '' && $opt{0} != '=' &&
|
||||
$i + 1 < count($long_options) &&
|
||||
$opt == substr($long_options[$i+1], 0, $opt_len) &&
|
||||
$next_option_rest != '' &&
|
||||
$next_option_rest{0} != '=') {
|
||||
|
||||
$msg = "Console_Getopt: option --$opt is ambiguous";
|
||||
return PEAR::raiseError($msg);
|
||||
}
|
||||
|
||||
if (substr($long_opt, -1) == '=') {
|
||||
if (substr($long_opt, -2) != '==') {
|
||||
/* Long option requires an argument.
|
||||
Take the next argument if one wasn't specified. */;
|
||||
if (!strlen($opt_arg) && !(list(, $opt_arg) = each($args))) {
|
||||
$msg = "Console_Getopt: option requires an argument --$opt";
|
||||
return PEAR::raiseError($msg);
|
||||
}
|
||||
|
||||
if (Console_Getopt::_isShortOpt($opt_arg)
|
||||
|| Console_Getopt::_isLongOpt($opt_arg)) {
|
||||
$msg = "Console_Getopt: option requires an argument --$opt";
|
||||
return PEAR::raiseError($msg);
|
||||
}
|
||||
}
|
||||
} else if ($opt_arg) {
|
||||
$msg = "Console_Getopt: option --$opt doesn't allow an argument";
|
||||
return PEAR::raiseError($msg);
|
||||
}
|
||||
|
||||
$opts[] = array('--' . $opt, $opt_arg);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($skip_unknown === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
return PEAR::raiseError("Console_Getopt: unrecognized option --$opt");
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely read the $argv PHP array across different PHP configurations.
|
||||
* Will take care on register_globals and register_argc_argv ini directives
|
||||
*
|
||||
* @return mixed the $argv PHP array or PEAR error if not registered
|
||||
*/
|
||||
public static function readPHPArgv()
|
||||
{
|
||||
global $argv;
|
||||
if (!is_array($argv)) {
|
||||
if (!@is_array($_SERVER['argv'])) {
|
||||
if (!@is_array($GLOBALS['HTTP_SERVER_VARS']['argv'])) {
|
||||
$msg = "Could not read cmd args (register_argc_argv=Off?)";
|
||||
return PEAR::raiseError("Console_Getopt: " . $msg);
|
||||
}
|
||||
return $GLOBALS['HTTP_SERVER_VARS']['argv'];
|
||||
}
|
||||
return $_SERVER['argv'];
|
||||
}
|
||||
return $argv;
|
||||
}
|
||||
|
||||
}
|
||||
25
lib/composer/vendor/pear/console_getopt/LICENSE
vendored
Normal file
25
lib/composer/vendor/pear/console_getopt/LICENSE
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
Copyright (c) 2001-2015, The PEAR developers
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
26
lib/composer/vendor/pear/console_getopt/README.rst
vendored
Normal file
26
lib/composer/vendor/pear/console_getopt/README.rst
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
*******************************************
|
||||
Console_Getopt - Command-line option parser
|
||||
*******************************************
|
||||
|
||||
This is a PHP implementation of "getopt" supporting both short and long options.
|
||||
It helps parsing command line options in your PHP script.
|
||||
|
||||
Homepage: http://pear.php.net/package/Console_Getopt
|
||||
|
||||
.. image:: https://travis-ci.org/pear/Console_Getopt.svg?branch=master
|
||||
:target: https://travis-ci.org/pear/Console_Getopt
|
||||
|
||||
|
||||
Alternatives
|
||||
============
|
||||
|
||||
* Console_CommandLine__ (recommended)
|
||||
* Console_GetoptPlus__
|
||||
|
||||
__ http://pear.php.net/package/Console_CommandLine
|
||||
__ http://pear.php.net/package/Console_GetoptPlus
|
||||
|
||||
|
||||
License
|
||||
=======
|
||||
BSD-2-Clause
|
||||
35
lib/composer/vendor/pear/console_getopt/composer.json
vendored
Normal file
35
lib/composer/vendor/pear/console_getopt/composer.json
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"authors": [
|
||||
{
|
||||
"email": "andrei@php.net",
|
||||
"name": "Andrei Zmievski",
|
||||
"role": "Lead"
|
||||
},
|
||||
{
|
||||
"email": "stig@php.net",
|
||||
"name": "Stig Bakken",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"email": "cellog@php.net",
|
||||
"name": "Greg Beaver",
|
||||
"role": "Helper"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Console": "./"
|
||||
}
|
||||
},
|
||||
"description": "More info available on: http://pear.php.net/package/Console_Getopt",
|
||||
"include-path": [
|
||||
"./"
|
||||
],
|
||||
"license": "BSD-2-Clause",
|
||||
"name": "pear/console_getopt",
|
||||
"support": {
|
||||
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Console_Getopt",
|
||||
"source": "https://github.com/pear/Console_Getopt"
|
||||
},
|
||||
"type": "library"
|
||||
}
|
||||
269
lib/composer/vendor/pear/console_getopt/package.xml
vendored
Normal file
269
lib/composer/vendor/pear/console_getopt/package.xml
vendored
Normal file
@@ -0,0 +1,269 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<package packagerversion="1.9.2" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<name>Console_Getopt</name>
|
||||
<channel>pear.php.net</channel>
|
||||
<summary>Command-line option parser</summary>
|
||||
<description>This is a PHP implementation of "getopt" supporting both
|
||||
short and long options.</description>
|
||||
<lead>
|
||||
<name>Andrei Zmievski</name>
|
||||
<user>andrei</user>
|
||||
<email>andrei@php.net</email>
|
||||
<active>no</active>
|
||||
</lead>
|
||||
<developer>
|
||||
<name>Stig Bakken</name>
|
||||
<user>ssb</user>
|
||||
<email>stig@php.net</email>
|
||||
<active>no</active>
|
||||
</developer>
|
||||
<helper>
|
||||
<name>Greg Beaver</name>
|
||||
<user>cellog</user>
|
||||
<email>cellog@php.net</email>
|
||||
<active>yes</active>
|
||||
</helper>
|
||||
|
||||
<date>2015-07-20</date>
|
||||
<time>22:21:23</time>
|
||||
<version>
|
||||
<release>1.4.1</release>
|
||||
<api>1.4.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://opensource.org/licenses/bsd-license.php">BSD-2-Clause</license>
|
||||
|
||||
<notes>
|
||||
* Fix unit test on PHP 7 [cweiske]
|
||||
</notes>
|
||||
|
||||
<contents>
|
||||
<dir name="/">
|
||||
<dir name="Console">
|
||||
<file name="Getopt.php" role="php" />
|
||||
</dir>
|
||||
<dir name="tests">
|
||||
<file role="test" name="001-getopt.phpt" />
|
||||
<file role="test" name="bug10557.phpt" />
|
||||
<file role="test" name="bug11068.phpt" />
|
||||
<file role="test" name="bug13140.phpt" />
|
||||
</dir>
|
||||
</dir>
|
||||
</contents>
|
||||
|
||||
<compatible>
|
||||
<name>PEAR</name>
|
||||
<channel>pear.php.net</channel>
|
||||
<min>1.4.0</min>
|
||||
<max>1.999.999</max>
|
||||
</compatible>
|
||||
|
||||
<dependencies>
|
||||
<required>
|
||||
<php>
|
||||
<min>5.4.0</min>
|
||||
</php>
|
||||
<pearinstaller>
|
||||
<min>1.8.0</min>
|
||||
</pearinstaller>
|
||||
</required>
|
||||
</dependencies>
|
||||
|
||||
<phprelease />
|
||||
|
||||
<changelog>
|
||||
|
||||
<release>
|
||||
<date>2015-07-20</date>
|
||||
<version>
|
||||
<release>1.4.1</release>
|
||||
<api>1.4.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://opensource.org/licenses/bsd-license.php">BSD-2-Clause</license>
|
||||
<notes>
|
||||
* Fix unit test on PHP 7 [cweiske]
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
<release>
|
||||
<date>2015-02-22</date>
|
||||
<version>
|
||||
<release>1.4.0</release>
|
||||
<api>1.4.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://opensource.org/licenses/bsd-license.php">BSD-2-Clause</license>
|
||||
<notes>
|
||||
* Change license to BSD-2-Clause
|
||||
* Set minimum PHP version to 5.4.0
|
||||
* Mark static methods with "static" keyword
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
<release>
|
||||
<date>2011-03-07</date>
|
||||
<version>
|
||||
<release>1.3.1</release>
|
||||
<api>1.3.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
* Change the minimum PEAR installer dep to be lower
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
<release>
|
||||
<date>2010-12-11</date>
|
||||
<time>20:20:13</time>
|
||||
<version>
|
||||
<release>1.3.0</release>
|
||||
<api>1.3.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
* Implement Request #13140: [PATCH] to skip unknown parameters. [patch by rquadling, improved on by dufuz]
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
<release>
|
||||
<date>2007-06-12</date>
|
||||
<version>
|
||||
<release>1.2.3</release>
|
||||
<api>1.2.1</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
* fix Bug #11068: No way to read plain "-" option [cardoe]
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>
|
||||
<release>1.2.2</release>
|
||||
<api>1.2.1</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2007-02-17</date>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
* fix Bug #4475: An ambiguous error occurred when specifying similar longoption name.
|
||||
* fix Bug #10055: Not failing properly on short options missing required values
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>
|
||||
<release>1.2.1</release>
|
||||
<api>1.2.1</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2006-12-08</date>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
Fixed bugs #4448 (Long parameter values truncated with longoption parameter) and #7444 (Trailing spaces after php closing tag)
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>
|
||||
<release>1.2</release>
|
||||
<api>1.2</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2003-12-11</date>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
Fix to preserve BC with 1.0 and allow correct behaviour for new users
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>
|
||||
<release>1.0</release>
|
||||
<api>1.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2002-09-13</date>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
Stable release
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>
|
||||
<release>0.11</release>
|
||||
<api>0.11</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>beta</release>
|
||||
<api>beta</api>
|
||||
</stability>
|
||||
<date>2002-05-26</date>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
POSIX getopt compatibility fix: treat first element of args
|
||||
array as command name
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>
|
||||
<release>0.10</release>
|
||||
<api>0.10</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>beta</release>
|
||||
<api>beta</api>
|
||||
</stability>
|
||||
<date>2002-05-12</date>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
Packaging fix
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>
|
||||
<release>0.9</release>
|
||||
<api>0.9</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>beta</release>
|
||||
<api>beta</api>
|
||||
</stability>
|
||||
<date>2002-05-12</date>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
Initial release
|
||||
</notes>
|
||||
</release>
|
||||
</changelog>
|
||||
</package>
|
||||
63
lib/composer/vendor/pear/console_getopt/tests/001-getopt.phpt
vendored
Normal file
63
lib/composer/vendor/pear/console_getopt/tests/001-getopt.phpt
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
--TEST--
|
||||
Console_Getopt
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'Console/Getopt.php';
|
||||
PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s\n\n");
|
||||
|
||||
function test($argstr, $optstr) {
|
||||
$argv = preg_split('/[[:space:]]+/', $argstr);
|
||||
if (PEAR::isError($options = Console_Getopt::getopt($argv, $optstr))) {
|
||||
return;
|
||||
}
|
||||
$opts = $options[0];
|
||||
$non_opts = $options[1];
|
||||
$i = 0;
|
||||
print "options: ";
|
||||
foreach ($opts as $o => $d) {
|
||||
if ($i++ > 0) {
|
||||
print ", ";
|
||||
}
|
||||
print $d[0] . '=' . $d[1];
|
||||
}
|
||||
print "\n";
|
||||
print "params: " . implode(", ", $non_opts) . "\n";
|
||||
print "\n";
|
||||
}
|
||||
|
||||
test("-abc", "abc");
|
||||
test("-abc foo", "abc");
|
||||
test("-abc foo", "abc:");
|
||||
test("-abc foo bar gazonk", "abc");
|
||||
test("-abc foo bar gazonk", "abc:");
|
||||
test("-a -b -c", "abc");
|
||||
test("-a -b -c", "abc:");
|
||||
test("-abc", "ab:c");
|
||||
test("-abc foo -bar gazonk", "abc");
|
||||
?>
|
||||
--EXPECT--
|
||||
options: a=, b=, c=
|
||||
params:
|
||||
|
||||
options: a=, b=, c=
|
||||
params: foo
|
||||
|
||||
options: a=, b=, c=foo
|
||||
params:
|
||||
|
||||
options: a=, b=, c=
|
||||
params: foo, bar, gazonk
|
||||
|
||||
options: a=, b=, c=foo
|
||||
params: bar, gazonk
|
||||
|
||||
options: a=, b=, c=
|
||||
params:
|
||||
|
||||
Console_Getopt: option requires an argument --c
|
||||
|
||||
options: a=, b=c
|
||||
params:
|
||||
|
||||
options: a=, b=, c=
|
||||
params: foo, -bar, gazonk
|
||||
22
lib/composer/vendor/pear/console_getopt/tests/bug10557.phpt
vendored
Normal file
22
lib/composer/vendor/pear/console_getopt/tests/bug10557.phpt
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
Console_Getopt [bug 10557]
|
||||
--SKIPIF--
|
||||
--FILE--
|
||||
<?php
|
||||
$_SERVER['argv'] =
|
||||
$argv = array('hi', '-fjjohnston@mail.com', '--to', '--mailpack', '--debug');
|
||||
require_once 'Console/Getopt.php';
|
||||
$ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'f:t:',
|
||||
array('from=','to=','mailpack=','direction=','verbose','debug'));
|
||||
if(PEAR::isError($ret))
|
||||
{
|
||||
echo $ret->getMessage()."\n";
|
||||
echo 'FATAL';
|
||||
exit;
|
||||
}
|
||||
|
||||
print_r($ret);
|
||||
?>
|
||||
--EXPECT--
|
||||
Console_Getopt: option requires an argument --to
|
||||
FATAL
|
||||
44
lib/composer/vendor/pear/console_getopt/tests/bug11068.phpt
vendored
Normal file
44
lib/composer/vendor/pear/console_getopt/tests/bug11068.phpt
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
--TEST--
|
||||
Console_Getopt [bug 11068]
|
||||
--SKIPIF--
|
||||
--FILE--
|
||||
<?php
|
||||
$_SERVER['argv'] =
|
||||
$argv = array('hi', '-fjjohnston@mail.com', '--to', 'hi', '-');
|
||||
require_once 'Console/Getopt.php';
|
||||
$ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'f:t:',
|
||||
array('from=','to=','mailpack=','direction=','verbose','debug'));
|
||||
if(PEAR::isError($ret))
|
||||
{
|
||||
echo $ret->getMessage()."\n";
|
||||
echo 'FATAL';
|
||||
exit;
|
||||
}
|
||||
|
||||
print_r($ret);
|
||||
?>
|
||||
--EXPECT--
|
||||
Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => f
|
||||
[1] => jjohnston@mail.com
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[0] => --to
|
||||
[1] => hi
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[0] => -
|
||||
)
|
||||
|
||||
)
|
||||
75
lib/composer/vendor/pear/console_getopt/tests/bug13140.phpt
vendored
Normal file
75
lib/composer/vendor/pear/console_getopt/tests/bug13140.phpt
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
--TEST--
|
||||
Console_Getopt [bug 13140]
|
||||
--SKIPIF--
|
||||
--FILE--
|
||||
<?php
|
||||
$_SERVER['argv'] = $argv =
|
||||
array('--bob', '--foo' , '-bar', '--test', '-rq', 'thisshouldbehere');
|
||||
|
||||
require_once 'Console/Getopt.php';
|
||||
$cg = new Console_GetOpt();
|
||||
|
||||
print_r($cg->getopt2($cg->readPHPArgv(), 't', array('test'), true));
|
||||
print_r($cg->getopt2($cg->readPHPArgv(), 'bar', array('foo'), true));
|
||||
?>
|
||||
--EXPECT--
|
||||
Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => --test
|
||||
[1] =>
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[0] => thisshouldbehere
|
||||
)
|
||||
|
||||
)
|
||||
Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => --foo
|
||||
[1] =>
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[0] => b
|
||||
[1] =>
|
||||
)
|
||||
|
||||
[2] => Array
|
||||
(
|
||||
[0] => a
|
||||
[1] =>
|
||||
)
|
||||
|
||||
[3] => Array
|
||||
(
|
||||
[0] => r
|
||||
[1] =>
|
||||
)
|
||||
|
||||
[4] => Array
|
||||
(
|
||||
[0] => r
|
||||
[1] =>
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[0] => thisshouldbehere
|
||||
)
|
||||
|
||||
)
|
||||
4
lib/composer/vendor/pear/mail/.gitignore
vendored
Normal file
4
lib/composer/vendor/pear/mail/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
# composer related
|
||||
composer.lock
|
||||
composer.phar
|
||||
vendor
|
||||
19
lib/composer/vendor/pear/mail/.travis.yml
vendored
Normal file
19
lib/composer/vendor/pear/mail/.travis.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
language: php
|
||||
sudo: false
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- nightly
|
||||
install:
|
||||
- pear list
|
||||
- pear channel-update pear.php.net
|
||||
- pear upgrade --force pear/pear
|
||||
- pear list
|
||||
- pear upgrade --force xml_util
|
||||
- pear install --force --alldeps package.xml
|
||||
- pear list
|
||||
script:
|
||||
- pear run-tests -d tests/
|
||||
29
lib/composer/vendor/pear/mail/LICENSE
vendored
Normal file
29
lib/composer/vendor/pear/mail/LICENSE
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
Copyright (c) 1997-2017, Chuck Hagenbuch
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
267
lib/composer/vendor/pear/mail/Mail.php
vendored
Normal file
267
lib/composer/vendor/pear/mail/Mail.php
vendored
Normal file
@@ -0,0 +1,267 @@
|
||||
<?php
|
||||
/**
|
||||
* PEAR's Mail:: interface.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 1997-2017, Chuck Hagenbuch & Richard Heyes
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Mail
|
||||
* @package Mail
|
||||
* @author Chuck Hagenbuch <chuck@horde.org>
|
||||
* @copyright 1997-2017 Chuck Hagenbuch
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
|
||||
* @version CVS: $Id$
|
||||
* @link http://pear.php.net/package/Mail/
|
||||
*/
|
||||
|
||||
require_once 'PEAR.php';
|
||||
|
||||
/**
|
||||
* PEAR's Mail:: interface. Defines the interface for implementing
|
||||
* mailers under the PEAR hierarchy, and provides supporting functions
|
||||
* useful in multiple mailer backends.
|
||||
*
|
||||
* @version $Revision$
|
||||
* @package Mail
|
||||
*/
|
||||
class Mail
|
||||
{
|
||||
/**
|
||||
* Line terminator used for separating header lines.
|
||||
* @var string
|
||||
*/
|
||||
public $sep = "\r\n";
|
||||
|
||||
/**
|
||||
* Provides an interface for generating Mail:: objects of various
|
||||
* types
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public static function factory($driver, $params = array())
|
||||
{
|
||||
$driver = strtolower($driver);
|
||||
@include_once 'Mail/' . $driver . '.php';
|
||||
$class = 'Mail_' . $driver;
|
||||
if (class_exists($class)) {
|
||||
$mailer = new $class($params);
|
||||
return $mailer;
|
||||
} else {
|
||||
return PEAR::raiseError('Unable to find class for driver ' . $driver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Mail::send() function using php's built-in mail()
|
||||
* command.
|
||||
*
|
||||
* @param mixed $recipients Either a comma-seperated list of recipients
|
||||
* (RFC822 compliant), or an array of recipients,
|
||||
* each RFC822 valid. This may contain recipients not
|
||||
* specified in the headers, for Bcc:, resending
|
||||
* messages, etc.
|
||||
*
|
||||
* @param array $headers The array of headers to send with the mail, in an
|
||||
* associative array, where the array key is the
|
||||
* header name (ie, 'Subject'), and the array value
|
||||
* is the header value (ie, 'test'). The header
|
||||
* produced from those values would be 'Subject:
|
||||
* test'.
|
||||
*
|
||||
* @param string $body The full text of the message body, including any
|
||||
* Mime parts, etc.
|
||||
*
|
||||
* @return mixed Returns true on success, or a PEAR_Error
|
||||
* containing a descriptive error message on
|
||||
* failure.
|
||||
*
|
||||
* @deprecated use Mail_mail::send instead
|
||||
*/
|
||||
public function send($recipients, $headers, $body)
|
||||
{
|
||||
if (!is_array($headers)) {
|
||||
return PEAR::raiseError('$headers must be an array');
|
||||
}
|
||||
|
||||
$result = $this->_sanitizeHeaders($headers);
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
// if we're passed an array of recipients, implode it.
|
||||
if (is_array($recipients)) {
|
||||
$recipients = implode(', ', $recipients);
|
||||
}
|
||||
|
||||
// get the Subject out of the headers array so that we can
|
||||
// pass it as a seperate argument to mail().
|
||||
$subject = '';
|
||||
if (isset($headers['Subject'])) {
|
||||
$subject = $headers['Subject'];
|
||||
unset($headers['Subject']);
|
||||
}
|
||||
|
||||
// flatten the headers out.
|
||||
list(, $text_headers) = Mail::prepareHeaders($headers);
|
||||
|
||||
return mail($recipients, $subject, $body, $text_headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize an array of mail headers by removing any additional header
|
||||
* strings present in a legitimate header's value. The goal of this
|
||||
* filter is to prevent mail injection attacks.
|
||||
*
|
||||
* @param array $headers The associative array of headers to sanitize.
|
||||
*/
|
||||
protected function _sanitizeHeaders(&$headers)
|
||||
{
|
||||
foreach ($headers as $key => $value) {
|
||||
$headers[$key] =
|
||||
preg_replace('=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i',
|
||||
null, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Take an array of mail headers and return a string containing
|
||||
* text usable in sending a message.
|
||||
*
|
||||
* @param array $headers The array of headers to prepare, in an associative
|
||||
* array, where the array key is the header name (ie,
|
||||
* 'Subject'), and the array value is the header
|
||||
* value (ie, 'test'). The header produced from those
|
||||
* values would be 'Subject: test'.
|
||||
*
|
||||
* @return mixed Returns false if it encounters a bad address,
|
||||
* otherwise returns an array containing two
|
||||
* elements: Any From: address found in the headers,
|
||||
* and the plain text version of the headers.
|
||||
*/
|
||||
protected function prepareHeaders($headers)
|
||||
{
|
||||
$lines = array();
|
||||
$from = null;
|
||||
|
||||
foreach ($headers as $key => $value) {
|
||||
if (strcasecmp($key, 'From') === 0) {
|
||||
include_once 'Mail/RFC822.php';
|
||||
$parser = new Mail_RFC822();
|
||||
$addresses = $parser->parseAddressList($value, 'localhost', false);
|
||||
if (is_a($addresses, 'PEAR_Error')) {
|
||||
return $addresses;
|
||||
}
|
||||
|
||||
$from = $addresses[0]->mailbox . '@' . $addresses[0]->host;
|
||||
|
||||
// Reject envelope From: addresses with spaces.
|
||||
if (strstr($from, ' ')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$lines[] = $key . ': ' . $value;
|
||||
} elseif (strcasecmp($key, 'Received') === 0) {
|
||||
$received = array();
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $line) {
|
||||
$received[] = $key . ': ' . $line;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$received[] = $key . ': ' . $value;
|
||||
}
|
||||
// Put Received: headers at the top. Spam detectors often
|
||||
// flag messages with Received: headers after the Subject:
|
||||
// as spam.
|
||||
$lines = array_merge($received, $lines);
|
||||
} else {
|
||||
// If $value is an array (i.e., a list of addresses), convert
|
||||
// it to a comma-delimited string of its elements (addresses).
|
||||
if (is_array($value)) {
|
||||
$value = implode(', ', $value);
|
||||
}
|
||||
$lines[] = $key . ': ' . $value;
|
||||
}
|
||||
}
|
||||
|
||||
return array($from, join($this->sep, $lines));
|
||||
}
|
||||
|
||||
/**
|
||||
* Take a set of recipients and parse them, returning an array of
|
||||
* bare addresses (forward paths) that can be passed to sendmail
|
||||
* or an smtp server with the rcpt to: command.
|
||||
*
|
||||
* @param mixed Either a comma-seperated list of recipients
|
||||
* (RFC822 compliant), or an array of recipients,
|
||||
* each RFC822 valid.
|
||||
*
|
||||
* @return mixed An array of forward paths (bare addresses) or a PEAR_Error
|
||||
* object if the address list could not be parsed.
|
||||
*/
|
||||
protected function parseRecipients($recipients)
|
||||
{
|
||||
include_once 'Mail/RFC822.php';
|
||||
|
||||
// if we're passed an array, assume addresses are valid and
|
||||
// implode them before parsing.
|
||||
if (is_array($recipients)) {
|
||||
$recipients = implode(', ', $recipients);
|
||||
}
|
||||
|
||||
// Parse recipients, leaving out all personal info. This is
|
||||
// for smtp recipients, etc. All relevant personal information
|
||||
// should already be in the headers.
|
||||
$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')) {
|
||||
return $addresses;
|
||||
}
|
||||
|
||||
$recipients = array();
|
||||
if (is_array($addresses)) {
|
||||
foreach ($addresses as $ob) {
|
||||
$recipients[] = $ob->mailbox . '@' . $ob->host;
|
||||
}
|
||||
}
|
||||
|
||||
return $recipients;
|
||||
}
|
||||
|
||||
}
|
||||
929
lib/composer/vendor/pear/mail/Mail/RFC822.php
vendored
Normal file
929
lib/composer/vendor/pear/mail/Mail/RFC822.php
vendored
Normal file
@@ -0,0 +1,929 @@
|
||||
<?php
|
||||
/**
|
||||
* RFC 822 Email address list validation Utility
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 2001-2017, Chuck Hagenbuch & Richard Heyes
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Mail
|
||||
* @package Mail
|
||||
* @author Richard Heyes <richard@phpguru.org>
|
||||
* @author Chuck Hagenbuch <chuck@horde.org
|
||||
* @copyright 2001-2017 Richard Heyes
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
|
||||
* @version CVS: $Id$
|
||||
* @link http://pear.php.net/package/Mail/
|
||||
*/
|
||||
|
||||
/**
|
||||
* RFC 822 Email address list validation Utility
|
||||
*
|
||||
* What is it?
|
||||
*
|
||||
* This class will take an address string, and parse it into it's consituent
|
||||
* parts, be that either addresses, groups, or combinations. Nested groups
|
||||
* are not supported. The structure it returns is pretty straight forward,
|
||||
* and is similar to that provided by the imap_rfc822_parse_adrlist(). Use
|
||||
* print_r() to view the structure.
|
||||
*
|
||||
* How do I use it?
|
||||
*
|
||||
* $address_string = 'My Group: "Richard" <richard@localhost> (A comment), ted@example.com (Ted Bloggs), Barney;';
|
||||
* $structure = Mail_RFC822::parseAddressList($address_string, 'example.com', true)
|
||||
* print_r($structure);
|
||||
*
|
||||
* @author Richard Heyes <richard@phpguru.org>
|
||||
* @author Chuck Hagenbuch <chuck@horde.org>
|
||||
* @version $Revision$
|
||||
* @license BSD
|
||||
* @package Mail
|
||||
*/
|
||||
class Mail_RFC822 {
|
||||
|
||||
/**
|
||||
* The address being parsed by the RFC822 object.
|
||||
* @var string $address
|
||||
*/
|
||||
var $address = '';
|
||||
|
||||
/**
|
||||
* The default domain to use for unqualified addresses.
|
||||
* @var string $default_domain
|
||||
*/
|
||||
var $default_domain = 'localhost';
|
||||
|
||||
/**
|
||||
* Should we return a nested array showing groups, or flatten everything?
|
||||
* @var boolean $nestGroups
|
||||
*/
|
||||
var $nestGroups = true;
|
||||
|
||||
/**
|
||||
* Whether or not to validate atoms for non-ascii characters.
|
||||
* @var boolean $validate
|
||||
*/
|
||||
var $validate = true;
|
||||
|
||||
/**
|
||||
* The array of raw addresses built up as we parse.
|
||||
* @var array $addresses
|
||||
*/
|
||||
var $addresses = array();
|
||||
|
||||
/**
|
||||
* The final array of parsed address information that we build up.
|
||||
* @var array $structure
|
||||
*/
|
||||
var $structure = array();
|
||||
|
||||
/**
|
||||
* The current error message, if any.
|
||||
* @var string $error
|
||||
*/
|
||||
var $error = null;
|
||||
|
||||
/**
|
||||
* An internal counter/pointer.
|
||||
* @var integer $index
|
||||
*/
|
||||
var $index = null;
|
||||
|
||||
/**
|
||||
* The number of groups that have been found in the address list.
|
||||
* @var integer $num_groups
|
||||
* @access public
|
||||
*/
|
||||
var $num_groups = 0;
|
||||
|
||||
/**
|
||||
* A variable so that we can tell whether or not we're inside a
|
||||
* Mail_RFC822 object.
|
||||
* @var boolean $mailRFC822
|
||||
*/
|
||||
var $mailRFC822 = true;
|
||||
|
||||
/**
|
||||
* A limit after which processing stops
|
||||
* @var int $limit
|
||||
*/
|
||||
var $limit = null;
|
||||
|
||||
/**
|
||||
* Sets up the object. The address must either be set here or when
|
||||
* calling parseAddressList(). One or the other.
|
||||
*
|
||||
* @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.
|
||||
* @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
|
||||
*
|
||||
* @return object Mail_RFC822 A new Mail_RFC822 object.
|
||||
*/
|
||||
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;
|
||||
if (isset($nest_groups)) $this->nestGroups = $nest_groups;
|
||||
if (isset($validate)) $this->validate = $validate;
|
||||
if (isset($limit)) $this->limit = $limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the whole process. The address must either be set here
|
||||
* or when creating the object. One or the other.
|
||||
*
|
||||
* @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.
|
||||
* @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
|
||||
*
|
||||
* @return array A structured array of addresses.
|
||||
*/
|
||||
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);
|
||||
return $obj->parseAddressList();
|
||||
}
|
||||
|
||||
if (isset($address)) $this->address = $address;
|
||||
if (isset($default_domain)) $this->default_domain = $default_domain;
|
||||
if (isset($nest_groups)) $this->nestGroups = $nest_groups;
|
||||
if (isset($validate)) $this->validate = $validate;
|
||||
if (isset($limit)) $this->limit = $limit;
|
||||
|
||||
$this->structure = array();
|
||||
$this->addresses = array();
|
||||
$this->error = null;
|
||||
$this->index = null;
|
||||
|
||||
// Unfold any long lines in $this->address.
|
||||
$this->address = preg_replace('/\r?\n/', "\r\n", $this->address);
|
||||
$this->address = preg_replace('/\r\n(\t| )+/', ' ', $this->address);
|
||||
|
||||
while ($this->address = $this->_splitAddresses($this->address));
|
||||
|
||||
if ($this->address === false || isset($this->error)) {
|
||||
require_once 'PEAR.php';
|
||||
return PEAR::raiseError($this->error);
|
||||
}
|
||||
|
||||
// Validate each address individually. If we encounter an invalid
|
||||
// address, stop iterating and return an error immediately.
|
||||
foreach ($this->addresses as $address) {
|
||||
$valid = $this->_validateAddress($address);
|
||||
|
||||
if ($valid === false || isset($this->error)) {
|
||||
require_once 'PEAR.php';
|
||||
return PEAR::raiseError($this->error);
|
||||
}
|
||||
|
||||
if (!$this->nestGroups) {
|
||||
$this->structure = array_merge($this->structure, $valid);
|
||||
} else {
|
||||
$this->structure[] = $valid;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->structure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits an address into separate addresses.
|
||||
*
|
||||
* @param string $address The addresses to split.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
protected function _splitAddresses($address)
|
||||
{
|
||||
if (!empty($this->limit) && count($this->addresses) == $this->limit) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($this->_isGroup($address) && !isset($this->error)) {
|
||||
$split_char = ';';
|
||||
$is_group = true;
|
||||
} elseif (!isset($this->error)) {
|
||||
$split_char = ',';
|
||||
$is_group = false;
|
||||
} elseif (isset($this->error)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Split the string based on the above ten or so lines.
|
||||
$parts = explode($split_char, $address);
|
||||
$string = $this->_splitCheck($parts, $split_char);
|
||||
|
||||
// If a group...
|
||||
if ($is_group) {
|
||||
// If $string does not contain a colon outside of
|
||||
// brackets/quotes etc then something's fubar.
|
||||
|
||||
// First check there's a colon at all:
|
||||
if (strpos($string, ':') === false) {
|
||||
$this->error = 'Invalid address: ' . $string;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now check it's outside of brackets/quotes:
|
||||
if (!$this->_splitCheck(explode(':', $string), ':')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We must have a group at this point, so increase the counter:
|
||||
$this->num_groups++;
|
||||
}
|
||||
|
||||
// $string now contains the first full address/group.
|
||||
// Add to the addresses array.
|
||||
$this->addresses[] = array(
|
||||
'address' => trim($string),
|
||||
'group' => $is_group
|
||||
);
|
||||
|
||||
// Remove the now stored address from the initial line, the +1
|
||||
// is to account for the explode character.
|
||||
$address = trim(substr($address, strlen($string) + 1));
|
||||
|
||||
// If the next char is a comma and this was a group, then
|
||||
// there are more addresses, otherwise, if there are any more
|
||||
// chars, then there is another address.
|
||||
if ($is_group && substr($address, 0, 1) == ','){
|
||||
$address = trim(substr($address, 1));
|
||||
return $address;
|
||||
|
||||
} elseif (strlen($address) > 0) {
|
||||
return $address;
|
||||
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
// If you got here then something's off
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for a group at the start of the string.
|
||||
*
|
||||
* @param string $address The address to check.
|
||||
* @return boolean Whether or not there is a group at the start of the string.
|
||||
*/
|
||||
protected function _isGroup($address)
|
||||
{
|
||||
// First comma not in quotes, angles or escaped:
|
||||
$parts = explode(',', $address);
|
||||
$string = $this->_splitCheck($parts, ',');
|
||||
|
||||
// Now we have the first address, we can reliably check for a
|
||||
// group by searching for a colon that's not escaped or in
|
||||
// quotes or angle brackets.
|
||||
if (count($parts = explode(':', $string)) > 1) {
|
||||
$string2 = $this->_splitCheck($parts, ':');
|
||||
return ($string2 !== $string);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A common function that will check an exploded string.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
protected function _splitCheck($parts, $char)
|
||||
{
|
||||
$string = $parts[0];
|
||||
|
||||
for ($i = 0; $i < count($parts); $i++) {
|
||||
if ($this->_hasUnclosedQuotes($string)
|
||||
|| $this->_hasUnclosedBrackets($string, '<>')
|
||||
|| $this->_hasUnclosedBrackets($string, '[]')
|
||||
|| $this->_hasUnclosedBrackets($string, '()')
|
||||
|| substr($string, -1) == '\\') {
|
||||
if (isset($parts[$i + 1])) {
|
||||
$string = $string . $char . $parts[$i + 1];
|
||||
} else {
|
||||
$this->error = 'Invalid address spec. Unclosed bracket or quotes';
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$this->index = $i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a string has unclosed quotes or not.
|
||||
*
|
||||
* @param string $string The string to check.
|
||||
* @return boolean True if there are unclosed quotes inside the string,
|
||||
* false otherwise.
|
||||
*/
|
||||
protected function _hasUnclosedQuotes($string)
|
||||
{
|
||||
$string = trim($string);
|
||||
$iMax = strlen($string);
|
||||
$in_quote = false;
|
||||
$i = $slashes = 0;
|
||||
|
||||
for (; $i < $iMax; ++$i) {
|
||||
switch ($string[$i]) {
|
||||
case '\\':
|
||||
++$slashes;
|
||||
break;
|
||||
|
||||
case '"':
|
||||
if ($slashes % 2 == 0) {
|
||||
$in_quote = !$in_quote;
|
||||
}
|
||||
// Fall through to default action below.
|
||||
|
||||
default:
|
||||
$slashes = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $in_quote;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a string has an unclosed brackets or not. IMPORTANT:
|
||||
* This function handles both angle brackets and square brackets;
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
protected function _hasUnclosedBrackets($string, $chars)
|
||||
{
|
||||
$num_angle_start = substr_count($string, $chars[0]);
|
||||
$num_angle_end = substr_count($string, $chars[1]);
|
||||
|
||||
$this->_hasUnclosedBracketsSub($string, $num_angle_start, $chars[0]);
|
||||
$this->_hasUnclosedBracketsSub($string, $num_angle_end, $chars[1]);
|
||||
|
||||
if ($num_angle_start < $num_angle_end) {
|
||||
$this->error = 'Invalid address spec. Unmatched quote or bracket (' . $chars . ')';
|
||||
return false;
|
||||
} else {
|
||||
return ($num_angle_start > $num_angle_end);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sub function that is used only by hasUnclosedBrackets().
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
protected function _hasUnclosedBracketsSub($string, &$num, $char)
|
||||
{
|
||||
$parts = explode($char, $string);
|
||||
for ($i = 0; $i < count($parts); $i++){
|
||||
if (substr($parts[$i], -1) == '\\' || $this->_hasUnclosedQuotes($parts[$i]))
|
||||
$num--;
|
||||
if (isset($parts[$i + 1]))
|
||||
$parts[$i + 1] = $parts[$i] . $char . $parts[$i + 1];
|
||||
}
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to begin checking the address.
|
||||
*
|
||||
* @param string $address The address to validate.
|
||||
* @return mixed False on failure, or a structured array of address information on success.
|
||||
*/
|
||||
protected function _validateAddress($address)
|
||||
{
|
||||
$is_group = false;
|
||||
$addresses = array();
|
||||
|
||||
if ($address['group']) {
|
||||
$is_group = true;
|
||||
|
||||
// Get the group part of the name
|
||||
$parts = explode(':', $address['address']);
|
||||
$groupname = $this->_splitCheck($parts, ':');
|
||||
$structure = array();
|
||||
|
||||
// And validate the group part of the name.
|
||||
if (!$this->_validatePhrase($groupname)){
|
||||
$this->error = 'Group name did not validate.';
|
||||
return false;
|
||||
} else {
|
||||
// Don't include groups if we are not nesting
|
||||
// them. This avoids returning invalid addresses.
|
||||
if ($this->nestGroups) {
|
||||
$structure = new stdClass;
|
||||
$structure->groupname = $groupname;
|
||||
}
|
||||
}
|
||||
|
||||
$address['address'] = ltrim(substr($address['address'], strlen($groupname . ':')));
|
||||
}
|
||||
|
||||
// If a group then split on comma and put into an array.
|
||||
// Otherwise, Just put the whole address in an array.
|
||||
if ($is_group) {
|
||||
while (strlen($address['address']) > 0) {
|
||||
$parts = explode(',', $address['address']);
|
||||
$addresses[] = $this->_splitCheck($parts, ',');
|
||||
$address['address'] = trim(substr($address['address'], strlen(end($addresses) . ',')));
|
||||
}
|
||||
} else {
|
||||
$addresses[] = $address['address'];
|
||||
}
|
||||
|
||||
// Trim the whitespace from all of the address strings.
|
||||
array_map('trim', $addresses);
|
||||
|
||||
// Validate each mailbox.
|
||||
// Format could be one of: name <geezer@domain.com>
|
||||
// geezer@domain.com
|
||||
// geezer
|
||||
// ... or any other format valid by RFC 822.
|
||||
for ($i = 0; $i < count($addresses); $i++) {
|
||||
if (!$this->validateMailbox($addresses[$i])) {
|
||||
if (empty($this->error)) {
|
||||
$this->error = 'Validation failed for: ' . $addresses[$i];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Nested format
|
||||
if ($this->nestGroups) {
|
||||
if ($is_group) {
|
||||
$structure->addresses = $addresses;
|
||||
} else {
|
||||
$structure = $addresses[0];
|
||||
}
|
||||
|
||||
// Flat format
|
||||
} else {
|
||||
if ($is_group) {
|
||||
$structure = array_merge($structure, $addresses);
|
||||
} else {
|
||||
$structure = $addresses;
|
||||
}
|
||||
}
|
||||
|
||||
return $structure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a phrase.
|
||||
*
|
||||
* @param string $phrase The phrase to check.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
protected function _validatePhrase($phrase)
|
||||
{
|
||||
// Splits on one or more Tab or space.
|
||||
$parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
$phrase_parts = array();
|
||||
while (count($parts) > 0){
|
||||
$phrase_parts[] = $this->_splitCheck($parts, ' ');
|
||||
for ($i = 0; $i < $this->index + 1; $i++)
|
||||
array_shift($parts);
|
||||
}
|
||||
|
||||
foreach ($phrase_parts as $part) {
|
||||
// If quoted string:
|
||||
if (substr($part, 0, 1) == '"') {
|
||||
if (!$this->_validateQuotedString($part)) {
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Otherwise it's an atom:
|
||||
if (!$this->_validateAtom($part)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate an atom which from rfc822 is:
|
||||
* atom = 1*<any CHAR except specials, SPACE and CTLs>
|
||||
*
|
||||
* If validation ($this->validate) has been turned off, then
|
||||
* validateAtom() doesn't actually check anything. This is so that you
|
||||
* can split a list of addresses up before encoding personal names
|
||||
* (umlauts, etc.), for example.
|
||||
*
|
||||
* @param string $atom The string to check.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
protected function _validateAtom($atom)
|
||||
{
|
||||
if (!$this->validate) {
|
||||
// Validation has been turned off; assume the atom is okay.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for any char from ASCII 0 - ASCII 127
|
||||
if (!preg_match('/^[\\x00-\\x7E]+$/i', $atom, $matches)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for specials:
|
||||
if (preg_match('/[][()<>@,;\\:". ]/', $atom)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for control characters (ASCII 0-31):
|
||||
if (preg_match('/[\\x00-\\x1F]+/', $atom)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate quoted string, which is:
|
||||
* quoted-string = <"> *(qtext/quoted-pair) <">
|
||||
*
|
||||
* @param string $qstring The string to check
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
protected function _validateQuotedString($qstring)
|
||||
{
|
||||
// Leading and trailing "
|
||||
$qstring = substr($qstring, 1, -1);
|
||||
|
||||
// Perform check, removing quoted characters first.
|
||||
return !preg_match('/[\x0D\\\\"]/', preg_replace('/\\\\./', '', $qstring));
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a mailbox, which is:
|
||||
* mailbox = addr-spec ; simple address
|
||||
* / phrase route-addr ; name and route-addr
|
||||
*
|
||||
* @param string &$mailbox The string to check.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
public function validateMailbox(&$mailbox)
|
||||
{
|
||||
// A couple of defaults.
|
||||
$phrase = '';
|
||||
$comment = '';
|
||||
$comments = array();
|
||||
|
||||
// Catch any RFC822 comments and store them separately.
|
||||
$_mailbox = $mailbox;
|
||||
while (strlen(trim($_mailbox)) > 0) {
|
||||
$parts = explode('(', $_mailbox);
|
||||
$before_comment = $this->_splitCheck($parts, '(');
|
||||
if ($before_comment != $_mailbox) {
|
||||
// First char should be a (.
|
||||
$comment = substr(str_replace($before_comment, '', $_mailbox), 1);
|
||||
$parts = explode(')', $comment);
|
||||
$comment = $this->_splitCheck($parts, ')');
|
||||
$comments[] = $comment;
|
||||
|
||||
// +2 is for the brackets
|
||||
$_mailbox = substr($_mailbox, strpos($_mailbox, '('.$comment)+strlen($comment)+2);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($comments as $comment) {
|
||||
$mailbox = str_replace("($comment)", '', $mailbox);
|
||||
}
|
||||
|
||||
$mailbox = trim($mailbox);
|
||||
|
||||
// Check for name + route-addr
|
||||
if (substr($mailbox, -1) == '>' && substr($mailbox, 0, 1) != '<') {
|
||||
$parts = explode('<', $mailbox);
|
||||
$name = $this->_splitCheck($parts, '<');
|
||||
|
||||
$phrase = trim($name);
|
||||
$route_addr = trim(substr($mailbox, strlen($name.'<'), -1));
|
||||
|
||||
if ($this->_validatePhrase($phrase) === false || ($route_addr = $this->_validateRouteAddr($route_addr)) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only got addr-spec
|
||||
} else {
|
||||
// First snip angle brackets if present.
|
||||
if (substr($mailbox, 0, 1) == '<' && substr($mailbox, -1) == '>') {
|
||||
$addr_spec = substr($mailbox, 1, -1);
|
||||
} else {
|
||||
$addr_spec = $mailbox;
|
||||
}
|
||||
|
||||
if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Construct the object that will be returned.
|
||||
$mbox = new stdClass();
|
||||
|
||||
// Add the phrase (even if empty) and comments
|
||||
$mbox->personal = $phrase;
|
||||
$mbox->comment = isset($comments) ? $comments : array();
|
||||
|
||||
if (isset($route_addr)) {
|
||||
$mbox->mailbox = $route_addr['local_part'];
|
||||
$mbox->host = $route_addr['domain'];
|
||||
$route_addr['adl'] !== '' ? $mbox->adl = $route_addr['adl'] : '';
|
||||
} else {
|
||||
$mbox->mailbox = $addr_spec['local_part'];
|
||||
$mbox->host = $addr_spec['domain'];
|
||||
}
|
||||
|
||||
$mailbox = $mbox;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function validates a route-addr which is:
|
||||
* route-addr = "<" [route] addr-spec ">"
|
||||
*
|
||||
* Angle brackets have already been removed at the point of
|
||||
* getting to this function.
|
||||
*
|
||||
* @param string $route_addr The string to check.
|
||||
* @return mixed False on failure, or an array containing validated address/route information on success.
|
||||
*/
|
||||
protected function _validateRouteAddr($route_addr)
|
||||
{
|
||||
// Check for colon.
|
||||
if (strpos($route_addr, ':') !== false) {
|
||||
$parts = explode(':', $route_addr);
|
||||
$route = $this->_splitCheck($parts, ':');
|
||||
} else {
|
||||
$route = $route_addr;
|
||||
}
|
||||
|
||||
// If $route is same as $route_addr then the colon was in
|
||||
// quotes or brackets or, of course, non existent.
|
||||
if ($route === $route_addr){
|
||||
unset($route);
|
||||
$addr_spec = $route_addr;
|
||||
if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Validate route part.
|
||||
if (($route = $this->_validateRoute($route)) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$addr_spec = substr($route_addr, strlen($route . ':'));
|
||||
|
||||
// Validate addr-spec part.
|
||||
if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($route)) {
|
||||
$return['adl'] = $route;
|
||||
} else {
|
||||
$return['adl'] = '';
|
||||
}
|
||||
|
||||
$return = array_merge($return, $addr_spec);
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a route, which is:
|
||||
* route = 1#("@" domain) ":"
|
||||
*
|
||||
* @param string $route The string to check.
|
||||
* @return mixed False on failure, or the validated $route on success.
|
||||
*/
|
||||
protected function _validateRoute($route)
|
||||
{
|
||||
// Split on comma.
|
||||
$domains = explode(',', trim($route));
|
||||
|
||||
foreach ($domains as $domain) {
|
||||
$domain = str_replace('@', '', trim($domain));
|
||||
if (!$this->_validateDomain($domain)) return false;
|
||||
}
|
||||
|
||||
return $route;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a domain, though this is not quite what
|
||||
* you expect of a strict internet domain.
|
||||
*
|
||||
* domain = sub-domain *("." sub-domain)
|
||||
*
|
||||
* @param string $domain The string to check.
|
||||
* @return mixed False on failure, or the validated domain on success.
|
||||
*/
|
||||
protected function _validateDomain($domain)
|
||||
{
|
||||
// Note the different use of $subdomains and $sub_domains
|
||||
$subdomains = explode('.', $domain);
|
||||
|
||||
while (count($subdomains) > 0) {
|
||||
$sub_domains[] = $this->_splitCheck($subdomains, '.');
|
||||
for ($i = 0; $i < $this->index + 1; $i++)
|
||||
array_shift($subdomains);
|
||||
}
|
||||
|
||||
foreach ($sub_domains as $sub_domain) {
|
||||
if (!$this->_validateSubdomain(trim($sub_domain)))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Managed to get here, so return input.
|
||||
return $domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a subdomain:
|
||||
* subdomain = domain-ref / domain-literal
|
||||
*
|
||||
* @param string $subdomain The string to check.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
protected function _validateSubdomain($subdomain)
|
||||
{
|
||||
if (preg_match('|^\[(.*)]$|', $subdomain, $arr)){
|
||||
if (!$this->_validateDliteral($arr[1])) return false;
|
||||
} else {
|
||||
if (!$this->_validateAtom($subdomain)) return false;
|
||||
}
|
||||
|
||||
// Got here, so return successful.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a domain literal:
|
||||
* domain-literal = "[" *(dtext / quoted-pair) "]"
|
||||
*
|
||||
* @param string $dliteral The string to check.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
protected function _validateDliteral($dliteral)
|
||||
{
|
||||
return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) && ((! isset($matches[1])) || $matches[1] != '\\');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate an addr-spec.
|
||||
*
|
||||
* addr-spec = local-part "@" domain
|
||||
*
|
||||
* @param string $addr_spec The string to check.
|
||||
* @return mixed False on failure, or the validated addr-spec on success.
|
||||
*/
|
||||
protected function _validateAddrSpec($addr_spec)
|
||||
{
|
||||
$addr_spec = trim($addr_spec);
|
||||
|
||||
// Split on @ sign if there is one.
|
||||
if (strpos($addr_spec, '@') !== false) {
|
||||
$parts = explode('@', $addr_spec);
|
||||
$local_part = $this->_splitCheck($parts, '@');
|
||||
$domain = substr($addr_spec, strlen($local_part . '@'));
|
||||
|
||||
// No @ sign so assume the default domain.
|
||||
} else {
|
||||
$local_part = $addr_spec;
|
||||
$domain = $this->default_domain;
|
||||
}
|
||||
|
||||
if (($local_part = $this->_validateLocalPart($local_part)) === false) return false;
|
||||
if (($domain = $this->_validateDomain($domain)) === false) return false;
|
||||
|
||||
// Got here so return successful.
|
||||
return array('local_part' => $local_part, 'domain' => $domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate the local part of an address:
|
||||
* local-part = word *("." word)
|
||||
*
|
||||
* @param string $local_part
|
||||
* @return mixed False on failure, or the validated local part on success.
|
||||
*/
|
||||
protected function _validateLocalPart($local_part)
|
||||
{
|
||||
$parts = explode('.', $local_part);
|
||||
$words = array();
|
||||
|
||||
// Split the local_part into words.
|
||||
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] !== '"')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->_validatePhrase(trim($word)) === false) return false;
|
||||
}
|
||||
|
||||
// Managed to get here, so return the input.
|
||||
return $local_part;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an approximate count of how many addresses are in the
|
||||
* given string. This is APPROXIMATE as it only splits based on a
|
||||
* comma which has no preceding backslash. Could be useful as
|
||||
* large amounts of addresses will end up producing *large*
|
||||
* structures when used with parseAddressList().
|
||||
*
|
||||
* @param string $data Addresses to count
|
||||
* @return int Approximate count
|
||||
*/
|
||||
public function approximateCount($data)
|
||||
{
|
||||
return count(preg_split('/(?<!\\\\),/', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a email validating function separate to the rest of the
|
||||
* class. It simply validates whether an email is of the common
|
||||
* internet form: <user>@<domain>. This can be sufficient for most
|
||||
* people. Optional stricter mode can be utilised which restricts
|
||||
* mailbox characters allowed to alphanumeric, full stop, hyphen
|
||||
* and underscore.
|
||||
*
|
||||
* @param string $data Address to check
|
||||
* @param boolean $strict Optional stricter mode
|
||||
* @return mixed False if it fails, an indexed array
|
||||
* username/domain if it matches
|
||||
*/
|
||||
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)) {
|
||||
return array($matches[1], $matches[2]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
168
lib/composer/vendor/pear/mail/Mail/mail.php
vendored
Normal file
168
lib/composer/vendor/pear/mail/Mail/mail.php
vendored
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/**
|
||||
* internal PHP-mail() implementation of the PEAR Mail:: interface.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 2010-2017, Chuck Hagenbuch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Mail
|
||||
* @package Mail
|
||||
* @author Chuck Hagenbuch <chuck@horde.org>
|
||||
* @copyright 2010-2017 Chuck Hagenbuch
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
|
||||
* @version CVS: $Id$
|
||||
* @link http://pear.php.net/package/Mail/
|
||||
*/
|
||||
|
||||
/**
|
||||
* internal PHP-mail() implementation of the PEAR Mail:: interface.
|
||||
* @package Mail
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Mail_mail extends Mail {
|
||||
|
||||
/**
|
||||
* Any arguments to pass to the mail() function.
|
||||
* @var string
|
||||
*/
|
||||
var $_params = '';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Instantiates a new Mail_mail:: object based on the parameters
|
||||
* passed in.
|
||||
*
|
||||
* @param array $params Extra arguments for the mail() function.
|
||||
*/
|
||||
public function __construct($params = null)
|
||||
{
|
||||
// The other mail implementations accept parameters as arrays.
|
||||
// In the interest of being consistent, explode an array into
|
||||
// a string of parameter arguments.
|
||||
if (is_array($params)) {
|
||||
$this->_params = join(' ', $params);
|
||||
} else {
|
||||
$this->_params = $params;
|
||||
}
|
||||
|
||||
/* Because the mail() function may pass headers as command
|
||||
* line arguments, we can't guarantee the use of the standard
|
||||
* "\r\n" separator. Instead, we use the system's native line
|
||||
* separator. */
|
||||
if (defined('PHP_EOL')) {
|
||||
$this->sep = PHP_EOL;
|
||||
} else {
|
||||
$this->sep = (strpos(PHP_OS, 'WIN') === false) ? "\n" : "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Mail_mail::send() function using php's built-in mail()
|
||||
* command.
|
||||
*
|
||||
* @param mixed $recipients Either a comma-seperated list of recipients
|
||||
* (RFC822 compliant), or an array of recipients,
|
||||
* each RFC822 valid. This may contain recipients not
|
||||
* specified in the headers, for Bcc:, resending
|
||||
* messages, etc.
|
||||
*
|
||||
* @param array $headers The array of headers to send with the mail, in an
|
||||
* associative array, where the array key is the
|
||||
* header name (ie, 'Subject'), and the array value
|
||||
* is the header value (ie, 'test'). The header
|
||||
* produced from those values would be 'Subject:
|
||||
* test'.
|
||||
*
|
||||
* @param string $body The full text of the message body, including any
|
||||
* Mime parts, etc.
|
||||
*
|
||||
* @return mixed Returns true on success, or a PEAR_Error
|
||||
* containing a descriptive error message on
|
||||
* failure.
|
||||
*/
|
||||
public function send($recipients, $headers, $body)
|
||||
{
|
||||
if (!is_array($headers)) {
|
||||
return PEAR::raiseError('$headers must be an array');
|
||||
}
|
||||
|
||||
$result = $this->_sanitizeHeaders($headers);
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
// If we're passed an array of recipients, implode it.
|
||||
if (is_array($recipients)) {
|
||||
$recipients = implode(', ', $recipients);
|
||||
}
|
||||
|
||||
// Get the Subject out of the headers array so that we can
|
||||
// pass it as a seperate argument to mail().
|
||||
$subject = '';
|
||||
if (isset($headers['Subject'])) {
|
||||
$subject = $headers['Subject'];
|
||||
unset($headers['Subject']);
|
||||
}
|
||||
|
||||
// Also remove the To: header. The mail() function will add its own
|
||||
// To: header based on the contents of $recipients.
|
||||
unset($headers['To']);
|
||||
|
||||
// Flatten the headers out.
|
||||
$headerElements = $this->prepareHeaders($headers);
|
||||
if (is_a($headerElements, 'PEAR_Error')) {
|
||||
return $headerElements;
|
||||
}
|
||||
list(, $text_headers) = $headerElements;
|
||||
|
||||
// We only use mail()'s optional fifth parameter if the additional
|
||||
// parameters have been provided and we're not running in safe mode.
|
||||
if (empty($this->_params) || ini_get('safe_mode')) {
|
||||
$result = mail($recipients, $subject, $body, $text_headers);
|
||||
} else {
|
||||
$result = mail($recipients, $subject, $body, $text_headers,
|
||||
$this->_params);
|
||||
}
|
||||
|
||||
// If the mail() function returned failure, we need to create a
|
||||
// PEAR_Error object and return it instead of the boolean result.
|
||||
if ($result === false) {
|
||||
$result = PEAR::raiseError('mail() returned failure');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
142
lib/composer/vendor/pear/mail/Mail/mock.php
vendored
Normal file
142
lib/composer/vendor/pear/mail/Mail/mock.php
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
* Mock implementation
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 2010-2017, Chuck Hagenbuch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Mail
|
||||
* @package Mail
|
||||
* @author Chuck Hagenbuch <chuck@horde.org>
|
||||
* @copyright 2010-2017 Chuck Hagenbuch
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
|
||||
* @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$
|
||||
*/
|
||||
class Mail_mock extends Mail {
|
||||
|
||||
/**
|
||||
* Array of messages that have been sent with the mock.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $sentMessages = array();
|
||||
|
||||
/**
|
||||
* Callback before sending mail.
|
||||
*
|
||||
* @var callback
|
||||
*/
|
||||
protected $_preSendCallback;
|
||||
|
||||
/**
|
||||
* Callback after sending mai.
|
||||
*
|
||||
* @var callback
|
||||
*/
|
||||
protected $_postSendCallback;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Instantiates a new Mail_mock:: object based on the parameters
|
||||
* passed in. It looks for the following parameters, both optional:
|
||||
* preSendCallback Called before an email would be sent.
|
||||
* postSendCallback Called after an email would have been sent.
|
||||
*
|
||||
* @param array Hash containing any parameters.
|
||||
*/
|
||||
public function __construct($params)
|
||||
{
|
||||
if (isset($params['preSendCallback']) &&
|
||||
is_callable($params['preSendCallback'])) {
|
||||
$this->_preSendCallback = $params['preSendCallback'];
|
||||
}
|
||||
|
||||
if (isset($params['postSendCallback']) &&
|
||||
is_callable($params['postSendCallback'])) {
|
||||
$this->_postSendCallback = $params['postSendCallback'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Mail_mock::send() function. Silently discards all
|
||||
* mail.
|
||||
*
|
||||
* @param mixed $recipients Either a comma-seperated list of recipients
|
||||
* (RFC822 compliant), or an array of recipients,
|
||||
* each RFC822 valid. This may contain recipients not
|
||||
* specified in the headers, for Bcc:, resending
|
||||
* messages, etc.
|
||||
*
|
||||
* @param array $headers The array of headers to send with the mail, in an
|
||||
* associative array, where the array key is the
|
||||
* header name (ie, 'Subject'), and the array value
|
||||
* is the header value (ie, 'test'). The header
|
||||
* produced from those values would be 'Subject:
|
||||
* test'.
|
||||
*
|
||||
* @param string $body The full text of the message body, including any
|
||||
* Mime parts, etc.
|
||||
*
|
||||
* @return mixed Returns true on success, or a PEAR_Error
|
||||
* containing a descriptive error message on
|
||||
* failure.
|
||||
*/
|
||||
public function send($recipients, $headers, $body)
|
||||
{
|
||||
if ($this->_preSendCallback) {
|
||||
call_user_func_array($this->_preSendCallback,
|
||||
array(&$this, $recipients, $headers, $body));
|
||||
}
|
||||
|
||||
$entry = array('recipients' => $recipients, 'headers' => $headers, 'body' => $body);
|
||||
$this->sentMessages[] = $entry;
|
||||
|
||||
if ($this->_postSendCallback) {
|
||||
call_user_func_array($this->_postSendCallback,
|
||||
array(&$this, $recipients, $headers, $body));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
85
lib/composer/vendor/pear/mail/Mail/null.php
vendored
Normal file
85
lib/composer/vendor/pear/mail/Mail/null.php
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* Null implementation of the PEAR Mail interface
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 2010-2017, Phil Kernick
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Mail
|
||||
* @package Mail
|
||||
* @author Phil Kernick <philk@rotfl.com.au>
|
||||
* @copyright 2010-2017 Phil Kernick
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
|
||||
* @version CVS: $Id$
|
||||
* @link http://pear.php.net/package/Mail/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Null implementation of the PEAR Mail:: interface.
|
||||
* @access public
|
||||
* @package Mail
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Mail_null extends Mail {
|
||||
|
||||
/**
|
||||
* Implements Mail_null::send() function. Silently discards all
|
||||
* mail.
|
||||
*
|
||||
* @param mixed $recipients Either a comma-seperated list of recipients
|
||||
* (RFC822 compliant), or an array of recipients,
|
||||
* each RFC822 valid. This may contain recipients not
|
||||
* specified in the headers, for Bcc:, resending
|
||||
* messages, etc.
|
||||
*
|
||||
* @param array $headers The array of headers to send with the mail, in an
|
||||
* associative array, where the array key is the
|
||||
* header name (ie, 'Subject'), and the array value
|
||||
* is the header value (ie, 'test'). The header
|
||||
* produced from those values would be 'Subject:
|
||||
* test'.
|
||||
*
|
||||
* @param string $body The full text of the message body, including any
|
||||
* Mime parts, etc.
|
||||
*
|
||||
* @return mixed Returns true on success, or a PEAR_Error
|
||||
* containing a descriptive error message on
|
||||
* failure.
|
||||
*/
|
||||
public function send($recipients, $headers, $body)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
199
lib/composer/vendor/pear/mail/Mail/sendmail.php
vendored
Normal file
199
lib/composer/vendor/pear/mail/Mail/sendmail.php
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
/**
|
||||
* Sendmail implementation of the PEAR Mail interface.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 2010-2017, Chuck Hagenbuch & Jon Parise
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Mail
|
||||
* @package Mail
|
||||
* @author Jon Parise <jon@php.net>
|
||||
* @author Chuck Hagenbuch <chuck@horde.org>
|
||||
* @copyright 2010-2017 Chuck Hagenbuch
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
|
||||
* @version CVS: $Id$
|
||||
* @link http://pear.php.net/package/Mail/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sendmail implementation of the PEAR Mail:: interface.
|
||||
* @access public
|
||||
* @package Mail
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Mail_sendmail extends Mail {
|
||||
|
||||
/**
|
||||
* The location of the sendmail or sendmail wrapper binary on the
|
||||
* filesystem.
|
||||
* @var string
|
||||
*/
|
||||
var $sendmail_path = '/usr/sbin/sendmail';
|
||||
|
||||
/**
|
||||
* Any extra command-line parameters to pass to the sendmail or
|
||||
* sendmail wrapper binary.
|
||||
* @var string
|
||||
*/
|
||||
var $sendmail_args = '-i';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Instantiates a new Mail_sendmail:: object based on the parameters
|
||||
* passed in. It looks for the following parameters:
|
||||
* sendmail_path The location of the sendmail binary on the
|
||||
* filesystem. Defaults to '/usr/sbin/sendmail'.
|
||||
*
|
||||
* sendmail_args Any extra parameters to pass to the sendmail
|
||||
* or sendmail wrapper binary.
|
||||
*
|
||||
* If a parameter is present in the $params array, it replaces the
|
||||
* default.
|
||||
*
|
||||
* @param array $params Hash containing any parameters different from the
|
||||
* defaults.
|
||||
*/
|
||||
public function __construct($params)
|
||||
{
|
||||
if (isset($params['sendmail_path'])) {
|
||||
$this->sendmail_path = $params['sendmail_path'];
|
||||
}
|
||||
if (isset($params['sendmail_args'])) {
|
||||
$this->sendmail_args = $params['sendmail_args'];
|
||||
}
|
||||
|
||||
/*
|
||||
* Because we need to pass message headers to the sendmail program on
|
||||
* the commandline, we can't guarantee the use of the standard "\r\n"
|
||||
* separator. Instead, we use the system's native line separator.
|
||||
*/
|
||||
if (defined('PHP_EOL')) {
|
||||
$this->sep = PHP_EOL;
|
||||
} else {
|
||||
$this->sep = (strpos(PHP_OS, 'WIN') === false) ? "\n" : "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Mail::send() function using the sendmail
|
||||
* command-line binary.
|
||||
*
|
||||
* @param mixed $recipients Either a comma-seperated list of recipients
|
||||
* (RFC822 compliant), or an array of recipients,
|
||||
* each RFC822 valid. This may contain recipients not
|
||||
* specified in the headers, for Bcc:, resending
|
||||
* messages, etc.
|
||||
*
|
||||
* @param array $headers The array of headers to send with the mail, in an
|
||||
* associative array, where the array key is the
|
||||
* header name (ie, 'Subject'), and the array value
|
||||
* is the header value (ie, 'test'). The header
|
||||
* produced from those values would be 'Subject:
|
||||
* test'.
|
||||
*
|
||||
* @param string $body The full text of the message body, including any
|
||||
* Mime parts, etc.
|
||||
*
|
||||
* @return mixed Returns true on success, or a PEAR_Error
|
||||
* containing a descriptive error message on
|
||||
* failure.
|
||||
*/
|
||||
public function send($recipients, $headers, $body)
|
||||
{
|
||||
if (!is_array($headers)) {
|
||||
return PEAR::raiseError('$headers must be an array');
|
||||
}
|
||||
|
||||
$result = $this->_sanitizeHeaders($headers);
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$recipients = $this->parseRecipients($recipients);
|
||||
if (is_a($recipients, 'PEAR_Error')) {
|
||||
return $recipients;
|
||||
}
|
||||
$recipients = implode(' ', array_map('escapeshellarg', $recipients));
|
||||
|
||||
$headerElements = $this->prepareHeaders($headers);
|
||||
if (is_a($headerElements, 'PEAR_Error')) {
|
||||
return $headerElements;
|
||||
}
|
||||
list($from, $text_headers) = $headerElements;
|
||||
|
||||
/* Since few MTAs are going to allow this header to be forged
|
||||
* unless it's in the MAIL FROM: exchange, we'll use
|
||||
* Return-Path instead of From: if it's set. */
|
||||
if (!empty($headers['Return-Path'])) {
|
||||
$from = $headers['Return-Path'];
|
||||
}
|
||||
|
||||
if (!isset($from)) {
|
||||
return PEAR::raiseError('No from address given.');
|
||||
} elseif (strpos($from, ' ') !== false ||
|
||||
strpos($from, ';') !== false ||
|
||||
strpos($from, '&') !== false ||
|
||||
strpos($from, '`') !== false) {
|
||||
return PEAR::raiseError('From address specified with dangerous characters.');
|
||||
}
|
||||
|
||||
$from = escapeshellarg($from); // Security bug #16200
|
||||
|
||||
$mail = @popen($this->sendmail_path . (!empty($this->sendmail_args) ? ' ' . $this->sendmail_args : '') . " -f$from -- $recipients", 'w');
|
||||
if (!$mail) {
|
||||
return PEAR::raiseError('Failed to open sendmail [' . $this->sendmail_path . '] for execution.');
|
||||
}
|
||||
|
||||
// Write the headers following by two newlines: one to end the headers
|
||||
// section and a second to separate the headers block from the body.
|
||||
fputs($mail, $text_headers . $this->sep . $this->sep);
|
||||
|
||||
fputs($mail, $body);
|
||||
$result = pclose($mail);
|
||||
if (version_compare(phpversion(), '4.2.3') == -1) {
|
||||
// With older php versions, we need to shift the pclose
|
||||
// result to get the exit code.
|
||||
$result = $result >> 8 & 0xFF;
|
||||
}
|
||||
|
||||
if ($result != 0) {
|
||||
return PEAR::raiseError('sendmail returned error code ' . $result,
|
||||
$result);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
461
lib/composer/vendor/pear/mail/Mail/smtp.php
vendored
Normal file
461
lib/composer/vendor/pear/mail/Mail/smtp.php
vendored
Normal file
@@ -0,0 +1,461 @@
|
||||
<?php
|
||||
/**
|
||||
* SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 2010-2017, Chuck Hagenbuch & Jon Parise
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request
|
||||
* @author Jon Parise <jon@php.net>
|
||||
* @author Chuck Hagenbuch <chuck@horde.org>
|
||||
* @copyright 2010-2017 Chuck Hagenbuch
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
|
||||
* @version CVS: $Id$
|
||||
* @link http://pear.php.net/package/Mail/
|
||||
*/
|
||||
|
||||
/** Error: Failed to create a Net_SMTP object */
|
||||
define('PEAR_MAIL_SMTP_ERROR_CREATE', 10000);
|
||||
|
||||
/** Error: Failed to connect to SMTP server */
|
||||
define('PEAR_MAIL_SMTP_ERROR_CONNECT', 10001);
|
||||
|
||||
/** Error: SMTP authentication failure */
|
||||
define('PEAR_MAIL_SMTP_ERROR_AUTH', 10002);
|
||||
|
||||
/** Error: No From: address has been provided */
|
||||
define('PEAR_MAIL_SMTP_ERROR_FROM', 10003);
|
||||
|
||||
/** Error: Failed to set sender */
|
||||
define('PEAR_MAIL_SMTP_ERROR_SENDER', 10004);
|
||||
|
||||
/** Error: Failed to add recipient */
|
||||
define('PEAR_MAIL_SMTP_ERROR_RECIPIENT', 10005);
|
||||
|
||||
/** Error: Failed to send data */
|
||||
define('PEAR_MAIL_SMTP_ERROR_DATA', 10006);
|
||||
|
||||
/**
|
||||
* SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class.
|
||||
* @access public
|
||||
* @package Mail
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Mail_smtp extends Mail {
|
||||
|
||||
/**
|
||||
* SMTP connection object.
|
||||
*
|
||||
* @var object
|
||||
* @access private
|
||||
*/
|
||||
var $_smtp = null;
|
||||
|
||||
/**
|
||||
* The list of service extension parameters to pass to the Net_SMTP
|
||||
* mailFrom() command.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $_extparams = array();
|
||||
|
||||
/**
|
||||
* The SMTP host to connect to.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $host = 'localhost';
|
||||
|
||||
/**
|
||||
* The port the SMTP server is on.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
var $port = 25;
|
||||
|
||||
/**
|
||||
* Should SMTP authentication be used?
|
||||
*
|
||||
* This value may be set to true, false or the name of a specific
|
||||
* authentication method.
|
||||
*
|
||||
* If the value is set to true, the Net_SMTP package will attempt to use
|
||||
* the best authentication method advertised by the remote SMTP server.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
var $auth = false;
|
||||
|
||||
/**
|
||||
* The username to use if the SMTP server requires authentication.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $username = '';
|
||||
|
||||
/**
|
||||
* The password to use if the SMTP server requires authentication.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $password = '';
|
||||
|
||||
/**
|
||||
* Hostname or domain that will be sent to the remote SMTP server in the
|
||||
* HELO / EHLO message.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $localhost = 'localhost';
|
||||
|
||||
/**
|
||||
* SMTP connection timeout value. NULL indicates no timeout.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
var $timeout = null;
|
||||
|
||||
/**
|
||||
* Turn on Net_SMTP debugging?
|
||||
*
|
||||
* @var boolean $debug
|
||||
*/
|
||||
var $debug = false;
|
||||
|
||||
/**
|
||||
* Indicates whether or not the SMTP connection should persist over
|
||||
* multiple calls to the send() method.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
var $persist = false;
|
||||
|
||||
/**
|
||||
* Use SMTP command pipelining (specified in RFC 2920) if the SMTP server
|
||||
* supports it. This speeds up delivery over high-latency connections. By
|
||||
* default, use the default value supplied by Net_SMTP.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
var $pipelining;
|
||||
|
||||
/**
|
||||
* The list of socket options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $socket_options = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Instantiates a new Mail_smtp:: object based on the parameters
|
||||
* passed in. It looks for the following parameters:
|
||||
* host The server to connect to. Defaults to localhost.
|
||||
* port The port to connect to. Defaults to 25.
|
||||
* auth SMTP authentication. Defaults to none.
|
||||
* username The username to use for SMTP auth. No default.
|
||||
* password The password to use for SMTP auth. No default.
|
||||
* localhost The local hostname / domain. Defaults to localhost.
|
||||
* timeout The SMTP connection timeout. Defaults to none.
|
||||
* verp Whether to use VERP or not. Defaults to false.
|
||||
* DEPRECATED as of 1.2.0 (use setMailParams()).
|
||||
* debug Activate SMTP debug mode? Defaults to false.
|
||||
* persist Should the SMTP connection persist?
|
||||
* pipelining Use SMTP command pipelining
|
||||
*
|
||||
* If a parameter is present in the $params array, it replaces the
|
||||
* default.
|
||||
*
|
||||
* @param array Hash containing any parameters different from the
|
||||
* defaults.
|
||||
*/
|
||||
public function __construct($params)
|
||||
{
|
||||
if (isset($params['host'])) $this->host = $params['host'];
|
||||
if (isset($params['port'])) $this->port = $params['port'];
|
||||
if (isset($params['auth'])) $this->auth = $params['auth'];
|
||||
if (isset($params['username'])) $this->username = $params['username'];
|
||||
if (isset($params['password'])) $this->password = $params['password'];
|
||||
if (isset($params['localhost'])) $this->localhost = $params['localhost'];
|
||||
if (isset($params['timeout'])) $this->timeout = $params['timeout'];
|
||||
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']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor implementation to ensure that we disconnect from any
|
||||
* potentially-alive persistent SMTP connections.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->disconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Mail::send() function using SMTP.
|
||||
*
|
||||
* @param mixed $recipients Either a comma-seperated list of recipients
|
||||
* (RFC822 compliant), or an array of recipients,
|
||||
* each RFC822 valid. This may contain recipients not
|
||||
* specified in the headers, for Bcc:, resending
|
||||
* messages, etc.
|
||||
*
|
||||
* @param array $headers The array of headers to send with the mail, in an
|
||||
* associative array, where the array key is the
|
||||
* header name (e.g., 'Subject'), and the array value
|
||||
* is the header value (e.g., 'test'). The header
|
||||
* produced from those values would be 'Subject:
|
||||
* test'.
|
||||
*
|
||||
* @param string $body The full text of the message body, including any
|
||||
* MIME parts, etc.
|
||||
*
|
||||
* @return mixed Returns true on success, or a PEAR_Error
|
||||
* containing a descriptive error message on
|
||||
* failure.
|
||||
*/
|
||||
public function send($recipients, $headers, $body)
|
||||
{
|
||||
$result = $this->send_or_fail($recipients, $headers, $body);
|
||||
|
||||
/* If persistent connections are disabled, destroy our SMTP object. */
|
||||
if ($this->persist === false) {
|
||||
$this->disconnect();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function send_or_fail($recipients, $headers, $body)
|
||||
{
|
||||
/* If we don't already have an SMTP object, create one. */
|
||||
$result = $this->getSMTPObject();
|
||||
if (PEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (!is_array($headers)) {
|
||||
return PEAR::raiseError('$headers must be an array');
|
||||
}
|
||||
|
||||
$this->_sanitizeHeaders($headers);
|
||||
|
||||
$headerElements = $this->prepareHeaders($headers);
|
||||
if (is_a($headerElements, 'PEAR_Error')) {
|
||||
$this->_smtp->rset();
|
||||
return $headerElements;
|
||||
}
|
||||
list($from, $textHeaders) = $headerElements;
|
||||
|
||||
/* Since few MTAs are going to allow this header to be forged
|
||||
* unless it's in the MAIL FROM: exchange, we'll use
|
||||
* Return-Path instead of From: if it's set. */
|
||||
if (!empty($headers['Return-Path'])) {
|
||||
$from = $headers['Return-Path'];
|
||||
}
|
||||
|
||||
if (!isset($from)) {
|
||||
$this->_smtp->rset();
|
||||
return PEAR::raiseError('No From: address has been provided',
|
||||
PEAR_MAIL_SMTP_ERROR_FROM);
|
||||
}
|
||||
|
||||
$params = null;
|
||||
if (!empty($this->_extparams)) {
|
||||
foreach ($this->_extparams as $key => $val) {
|
||||
$params .= ' ' . $key . (is_null($val) ? '' : '=' . $val);
|
||||
}
|
||||
}
|
||||
if (PEAR::isError($res = $this->_smtp->mailFrom($from, ltrim($params)))) {
|
||||
$error = $this->_error("Failed to set sender: $from", $res);
|
||||
$this->_smtp->rset();
|
||||
return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_SENDER);
|
||||
}
|
||||
|
||||
$recipients = $this->parseRecipients($recipients);
|
||||
if (is_a($recipients, 'PEAR_Error')) {
|
||||
$this->_smtp->rset();
|
||||
return $recipients;
|
||||
}
|
||||
|
||||
foreach ($recipients as $recipient) {
|
||||
$res = $this->_smtp->rcptTo($recipient);
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
$error = $this->_error("Failed to add recipient: $recipient", $res);
|
||||
$this->_smtp->rset();
|
||||
return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_RECIPIENT);
|
||||
}
|
||||
}
|
||||
|
||||
/* Send the message's headers and the body as SMTP data. */
|
||||
$res = $this->_smtp->data($body, $textHeaders);
|
||||
list(,$args) = $this->_smtp->getResponse();
|
||||
|
||||
if (preg_match("/ queued as (.*)/", $args, $queued)) {
|
||||
$this->queued_as = $queued[1];
|
||||
}
|
||||
|
||||
/* we need the greeting; from it we can extract the authorative name of the mail server we've really connected to.
|
||||
* ideal if we're connecting to a round-robin of relay servers and need to track which exact one took the email */
|
||||
$this->greeting = $this->_smtp->getGreeting();
|
||||
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
$error = $this->_error('Failed to send data', $res);
|
||||
$this->_smtp->rset();
|
||||
return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_DATA);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to the SMTP server by instantiating a Net_SMTP object.
|
||||
*
|
||||
* @return mixed Returns a reference to the Net_SMTP object on success, or
|
||||
* a PEAR_Error containing a descriptive error message on
|
||||
* failure.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
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->port,
|
||||
$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) {
|
||||
return PEAR::raiseError('Failed to create a Net_SMTP object',
|
||||
PEAR_MAIL_SMTP_ERROR_CREATE);
|
||||
}
|
||||
|
||||
/* Configure the SMTP connection. */
|
||||
if ($this->debug) {
|
||||
$this->_smtp->setDebug(true);
|
||||
}
|
||||
|
||||
/* Attempt to connect to the configured SMTP server. */
|
||||
if (PEAR::isError($res = $this->_smtp->connect($this->timeout))) {
|
||||
$error = $this->_error('Failed to connect to ' .
|
||||
$this->host . ':' . $this->port,
|
||||
$res);
|
||||
return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_CONNECT);
|
||||
}
|
||||
|
||||
/* Attempt to authenticate if authentication has been enabled. */
|
||||
if ($this->auth) {
|
||||
$method = is_string($this->auth) ? $this->auth : '';
|
||||
|
||||
if (PEAR::isError($res = $this->_smtp->auth($this->username,
|
||||
$this->password,
|
||||
$method))) {
|
||||
$error = $this->_error("$method authentication failure",
|
||||
$res);
|
||||
$this->_smtp->rset();
|
||||
return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_AUTH);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_smtp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add parameter associated with a SMTP service extension.
|
||||
*
|
||||
* @param string Extension keyword.
|
||||
* @param string Any value the keyword needs.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public function addServiceExtensionParameter($keyword, $value = null)
|
||||
{
|
||||
$this->_extparams[$keyword] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect and destroy the current SMTP connection.
|
||||
*
|
||||
* @return boolean True if the SMTP connection no longer exists.
|
||||
*
|
||||
* @since 1.1.9
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
/* If we have an SMTP object, disconnect and destroy it. */
|
||||
if (is_object($this->_smtp) && $this->_smtp->disconnect()) {
|
||||
$this->_smtp = null;
|
||||
}
|
||||
|
||||
/* We are disconnected if we no longer have an SMTP object. */
|
||||
return ($this->_smtp === null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a standardized string describing the current SMTP error.
|
||||
*
|
||||
* @param string $text Custom string describing the error context.
|
||||
* @param object $error Reference to the current PEAR_Error object.
|
||||
*
|
||||
* @return string A string describing the current SMTP error.
|
||||
*
|
||||
* @since 1.1.7
|
||||
*/
|
||||
protected function _error($text, $error)
|
||||
{
|
||||
/* Split the SMTP response into a code and a response string. */
|
||||
list($code, $response) = $this->_smtp->getResponse();
|
||||
|
||||
/* Build our standardized error string. */
|
||||
return $text
|
||||
. ' [SMTP: ' . $error->getMessage()
|
||||
. " (code: $code, response: $response)]";
|
||||
}
|
||||
|
||||
}
|
||||
504
lib/composer/vendor/pear/mail/Mail/smtpmx.php
vendored
Normal file
504
lib/composer/vendor/pear/mail/Mail/smtpmx.php
vendored
Normal file
@@ -0,0 +1,504 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* SMTP MX
|
||||
*
|
||||
* SMTP MX implementation of the PEAR Mail interface. Requires the Net_SMTP class.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 2010-2017 gERD Schaufelberger
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Mail
|
||||
* @package Mail_smtpmx
|
||||
* @author gERD Schaufelberger <gerd@php-tools.net>
|
||||
* @copyright 2010-2017 gERD Schaufelberger
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
|
||||
* @version CVS: $Id$
|
||||
* @link http://pear.php.net/package/Mail/
|
||||
*/
|
||||
|
||||
require_once 'Net/SMTP.php';
|
||||
|
||||
/**
|
||||
* SMTP MX implementation of the PEAR Mail interface. Requires the Net_SMTP class.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @author gERD Schaufelberger <gerd@php-tools.net>
|
||||
* @package Mail
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Mail_smtpmx extends Mail {
|
||||
|
||||
/**
|
||||
* SMTP connection object.
|
||||
*
|
||||
* @var object
|
||||
* @access private
|
||||
*/
|
||||
var $_smtp = null;
|
||||
|
||||
/**
|
||||
* The port the SMTP server is on.
|
||||
* @var integer
|
||||
* @see getservicebyname()
|
||||
*/
|
||||
var $port = 25;
|
||||
|
||||
/**
|
||||
* Hostname or domain that will be sent to the remote SMTP server in the
|
||||
* HELO / EHLO message.
|
||||
*
|
||||
* @var string
|
||||
* @see posix_uname()
|
||||
*/
|
||||
var $mailname = 'localhost';
|
||||
|
||||
/**
|
||||
* SMTP connection timeout value. NULL indicates no timeout.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
var $timeout = 10;
|
||||
|
||||
/**
|
||||
* use either PEAR:Net_DNS or getmxrr
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
var $withNetDns = true;
|
||||
|
||||
/**
|
||||
* PEAR:Net_DNS_Resolver
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
var $resolver;
|
||||
|
||||
/**
|
||||
* Whether to use VERP or not. If not a boolean, the string value
|
||||
* will be used as the VERP separators.
|
||||
*
|
||||
* @var mixed boolean or string
|
||||
*/
|
||||
var $verp = false;
|
||||
|
||||
/**
|
||||
* Whether to use VRFY or not.
|
||||
*
|
||||
* @var boolean $vrfy
|
||||
*/
|
||||
var $vrfy = false;
|
||||
|
||||
/**
|
||||
* Switch to test mode - don't send emails for real
|
||||
*
|
||||
* @var boolean $debug
|
||||
*/
|
||||
var $test = false;
|
||||
|
||||
/**
|
||||
* Turn on Net_SMTP debugging?
|
||||
*
|
||||
* @var boolean $peardebug
|
||||
*/
|
||||
var $debug = false;
|
||||
|
||||
/**
|
||||
* internal error codes
|
||||
*
|
||||
* translate internal error identifier to PEAR-Error codes and human
|
||||
* readable messages.
|
||||
*
|
||||
* @var boolean $debug
|
||||
* @todo as I need unique error-codes to identify what exactly went wrond
|
||||
* I did not use intergers as it should be. Instead I added a "namespace"
|
||||
* for each code. This avoids conflicts with error codes from different
|
||||
* classes. How can I use unique error codes and stay conform with PEAR?
|
||||
*/
|
||||
var $errorCode = array(
|
||||
'not_connected' => array(
|
||||
'code' => 1,
|
||||
'msg' => 'Could not connect to any mail server ({HOST}) at port {PORT} to send mail to {RCPT}.'
|
||||
),
|
||||
'failed_vrfy_rcpt' => array(
|
||||
'code' => 2,
|
||||
'msg' => 'Recipient "{RCPT}" could not be veryfied.'
|
||||
),
|
||||
'failed_set_from' => array(
|
||||
'code' => 3,
|
||||
'msg' => 'Failed to set sender: {FROM}.'
|
||||
),
|
||||
'failed_set_rcpt' => array(
|
||||
'code' => 4,
|
||||
'msg' => 'Failed to set recipient: {RCPT}.'
|
||||
),
|
||||
'failed_send_data' => array(
|
||||
'code' => 5,
|
||||
'msg' => 'Failed to send mail to: {RCPT}.'
|
||||
),
|
||||
'no_from' => array(
|
||||
'code' => 5,
|
||||
'msg' => 'No from address has be provided.'
|
||||
),
|
||||
'send_data' => array(
|
||||
'code' => 7,
|
||||
'msg' => 'Failed to create Net_SMTP object.'
|
||||
),
|
||||
'no_mx' => array(
|
||||
'code' => 8,
|
||||
'msg' => 'No MX-record for {RCPT} found.'
|
||||
),
|
||||
'no_resolver' => array(
|
||||
'code' => 9,
|
||||
'msg' => 'Could not start resolver! Install PEAR:Net_DNS or switch off "netdns"'
|
||||
),
|
||||
'failed_rset' => array(
|
||||
'code' => 10,
|
||||
'msg' => 'RSET command failed, SMTP-connection corrupt.'
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Instantiates a new Mail_smtp:: object based on the parameters
|
||||
* passed in. It looks for the following parameters:
|
||||
* mailname The name of the local mail system (a valid hostname which matches the reverse lookup)
|
||||
* port smtp-port - the default comes from getservicebyname() and should work fine
|
||||
* timeout The SMTP connection timeout. Defaults to 30 seconds.
|
||||
* vrfy Whether to use VRFY or not. Defaults to false.
|
||||
* verp Whether to use VERP or not. Defaults to false.
|
||||
* test Activate test mode? Defaults to false.
|
||||
* debug Activate SMTP and Net_DNS debug mode? Defaults to false.
|
||||
* netdns whether to use PEAR:Net_DNS or the PHP build in function getmxrr, default is true
|
||||
*
|
||||
* If a parameter is present in the $params array, it replaces the
|
||||
* default.
|
||||
*
|
||||
* @access public
|
||||
* @param array Hash containing any parameters different from the
|
||||
* defaults.
|
||||
* @see _Mail_smtpmx()
|
||||
*/
|
||||
function __construct($params)
|
||||
{
|
||||
if (isset($params['mailname'])) {
|
||||
$this->mailname = $params['mailname'];
|
||||
} else {
|
||||
// try to find a valid mailname
|
||||
if (function_exists('posix_uname')) {
|
||||
$uname = posix_uname();
|
||||
$this->mailname = $uname['nodename'];
|
||||
}
|
||||
}
|
||||
|
||||
// port number
|
||||
if (isset($params['port'])) {
|
||||
$this->_port = $params['port'];
|
||||
} else {
|
||||
$this->_port = getservbyname('smtp', 'tcp');
|
||||
}
|
||||
|
||||
if (isset($params['timeout'])) $this->timeout = $params['timeout'];
|
||||
if (isset($params['verp'])) $this->verp = $params['verp'];
|
||||
if (isset($params['test'])) $this->test = $params['test'];
|
||||
if (isset($params['peardebug'])) $this->test = $params['peardebug'];
|
||||
if (isset($params['netdns'])) $this->withNetDns = $params['netdns'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor wrapper for PHP4
|
||||
*
|
||||
* @access public
|
||||
* @param array Hash containing any parameters different from the defaults
|
||||
* @see __construct()
|
||||
*/
|
||||
function Mail_smtpmx($params)
|
||||
{
|
||||
$this->__construct($params);
|
||||
register_shutdown_function(array(&$this, '__destruct'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor implementation to ensure that we disconnect from any
|
||||
* potentially-alive persistent SMTP connections.
|
||||
*/
|
||||
function __destruct()
|
||||
{
|
||||
if (is_object($this->_smtp)) {
|
||||
$this->_smtp->disconnect();
|
||||
$this->_smtp = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Mail::send() function using SMTP direct delivery
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $recipients in RFC822 style or array
|
||||
* @param array $headers The array of headers to send with the mail.
|
||||
* @param string $body The full text of the message body,
|
||||
* @return mixed Returns true on success, or a PEAR_Error
|
||||
*/
|
||||
function send($recipients, $headers, $body)
|
||||
{
|
||||
if (!is_array($headers)) {
|
||||
return PEAR::raiseError('$headers must be an array');
|
||||
}
|
||||
|
||||
$result = $this->_sanitizeHeaders($headers);
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
// Prepare headers
|
||||
$headerElements = $this->prepareHeaders($headers);
|
||||
if (is_a($headerElements, 'PEAR_Error')) {
|
||||
return $headerElements;
|
||||
}
|
||||
list($from, $textHeaders) = $headerElements;
|
||||
|
||||
// use 'Return-Path' if possible
|
||||
if (!empty($headers['Return-Path'])) {
|
||||
$from = $headers['Return-Path'];
|
||||
}
|
||||
if (!isset($from)) {
|
||||
return $this->_raiseError('no_from');
|
||||
}
|
||||
|
||||
// Prepare recipients
|
||||
$recipients = $this->parseRecipients($recipients);
|
||||
if (is_a($recipients, 'PEAR_Error')) {
|
||||
return $recipients;
|
||||
}
|
||||
|
||||
foreach ($recipients as $rcpt) {
|
||||
list($user, $host) = explode('@', $rcpt);
|
||||
|
||||
$mx = $this->_getMx($host);
|
||||
if (is_a($mx, 'PEAR_Error')) {
|
||||
return $mx;
|
||||
}
|
||||
|
||||
if (empty($mx)) {
|
||||
$info = array('rcpt' => $rcpt);
|
||||
return $this->_raiseError('no_mx', $info);
|
||||
}
|
||||
|
||||
$connected = false;
|
||||
foreach ($mx as $mserver => $mpriority) {
|
||||
$this->_smtp = new Net_SMTP($mserver, $this->port, $this->mailname);
|
||||
|
||||
// configure the SMTP connection.
|
||||
if ($this->debug) {
|
||||
$this->_smtp->setDebug(true);
|
||||
}
|
||||
|
||||
// attempt to connect to the configured SMTP server.
|
||||
$res = $this->_smtp->connect($this->timeout);
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
$this->_smtp = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
// connection established
|
||||
if ($res) {
|
||||
$connected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$connected) {
|
||||
$info = array(
|
||||
'host' => implode(', ', array_keys($mx)),
|
||||
'port' => $this->port,
|
||||
'rcpt' => $rcpt,
|
||||
);
|
||||
return $this->_raiseError('not_connected', $info);
|
||||
}
|
||||
|
||||
// Verify recipient
|
||||
if ($this->vrfy) {
|
||||
$res = $this->_smtp->vrfy($rcpt);
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
$info = array('rcpt' => $rcpt);
|
||||
return $this->_raiseError('failed_vrfy_rcpt', $info);
|
||||
}
|
||||
}
|
||||
|
||||
// mail from:
|
||||
$args['verp'] = $this->verp;
|
||||
$res = $this->_smtp->mailFrom($from, $args);
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
$info = array('from' => $from);
|
||||
return $this->_raiseError('failed_set_from', $info);
|
||||
}
|
||||
|
||||
// rcpt to:
|
||||
$res = $this->_smtp->rcptTo($rcpt);
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
$info = array('rcpt' => $rcpt);
|
||||
return $this->_raiseError('failed_set_rcpt', $info);
|
||||
}
|
||||
|
||||
// Don't send anything in test mode
|
||||
if ($this->test) {
|
||||
$result = $this->_smtp->rset();
|
||||
$res = $this->_smtp->rset();
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
return $this->_raiseError('failed_rset');
|
||||
}
|
||||
|
||||
$this->_smtp->disconnect();
|
||||
$this->_smtp = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Send data
|
||||
$res = $this->_smtp->data($body, $textHeaders);
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
$info = array('rcpt' => $rcpt);
|
||||
return $this->_raiseError('failed_send_data', $info);
|
||||
}
|
||||
|
||||
$this->_smtp->disconnect();
|
||||
$this->_smtp = null;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recieve mx rexords for a spciefied host
|
||||
*
|
||||
* The MX records
|
||||
*
|
||||
* @access private
|
||||
* @param string $host mail host
|
||||
* @return mixed sorted
|
||||
*/
|
||||
function _getMx($host)
|
||||
{
|
||||
$mx = array();
|
||||
|
||||
if ($this->withNetDns) {
|
||||
$res = $this->_loadNetDns();
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
return $res;
|
||||
}
|
||||
|
||||
$response = $this->resolver->query($host, 'MX');
|
||||
if (!$response) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($response->answer as $rr) {
|
||||
if ($rr->type == 'MX') {
|
||||
$mx[$rr->exchange] = $rr->preference;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$mxHost = array();
|
||||
$mxWeight = array();
|
||||
|
||||
if (!getmxrr($host, $mxHost, $mxWeight)) {
|
||||
return false;
|
||||
}
|
||||
for ($i = 0; $i < count($mxHost); ++$i) {
|
||||
$mx[$mxHost[$i]] = $mxWeight[$i];
|
||||
}
|
||||
}
|
||||
|
||||
asort($mx);
|
||||
return $mx;
|
||||
}
|
||||
|
||||
/**
|
||||
* initialize PEAR:Net_DNS_Resolver
|
||||
*
|
||||
* @access private
|
||||
* @return boolean true on success
|
||||
*/
|
||||
function _loadNetDns()
|
||||
{
|
||||
if (is_object($this->resolver)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!include_once 'Net/DNS.php') {
|
||||
return $this->_raiseError('no_resolver');
|
||||
}
|
||||
|
||||
$this->resolver = new Net_DNS_Resolver();
|
||||
if ($this->debug) {
|
||||
$this->resolver->test = 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* raise standardized error
|
||||
*
|
||||
* include additional information in error message
|
||||
*
|
||||
* @access private
|
||||
* @param string $id maps error ids to codes and message
|
||||
* @param array $info optional information in associative array
|
||||
* @see _errorCode
|
||||
*/
|
||||
function _raiseError($id, $info = array())
|
||||
{
|
||||
$code = $this->errorCode[$id]['code'];
|
||||
$msg = $this->errorCode[$id]['msg'];
|
||||
|
||||
// include info to messages
|
||||
if (!empty($info)) {
|
||||
$search = array();
|
||||
$replace = array();
|
||||
|
||||
foreach ($info as $key => $value) {
|
||||
array_push($search, '{' . strtoupper($key) . '}');
|
||||
array_push($replace, $value);
|
||||
}
|
||||
|
||||
$msg = str_replace($search, $replace, $msg);
|
||||
}
|
||||
|
||||
return PEAR::raiseError($msg, $code);
|
||||
}
|
||||
|
||||
}
|
||||
53
lib/composer/vendor/pear/mail/README.rst
vendored
Normal file
53
lib/composer/vendor/pear/mail/README.rst
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
****
|
||||
Mail
|
||||
****
|
||||
Class that provides multiple interfaces for sending emails.
|
||||
|
||||
PEAR's Mail package defines an interface for implementing mailers under the
|
||||
PEAR hierarchy.
|
||||
It also provides supporting functions useful to multiple mailer backends.
|
||||
|
||||
Currently supported backends include:
|
||||
|
||||
- PHP's native ``mail()`` function
|
||||
- sendmail
|
||||
- SMTP
|
||||
|
||||
This package also provides a `RFC 822`__ email address list validation utility class.
|
||||
|
||||
Use Mail in combination with `Mail_Mime`__ to send HTML emails or emails with
|
||||
attachments - have a look at the example__.
|
||||
|
||||
__ https://tools.ietf.org/html/rfc822
|
||||
__ http://pear.php.net/package/Mail_Mime
|
||||
__ http://pear.php.net/manual/en/package.mail.mail-mime.example.php
|
||||
|
||||
============
|
||||
Installation
|
||||
============
|
||||
|
||||
PEAR
|
||||
====
|
||||
::
|
||||
|
||||
$ pear install mail
|
||||
|
||||
Composer
|
||||
========
|
||||
::
|
||||
|
||||
$ composer require pear/mail
|
||||
|
||||
=====
|
||||
Links
|
||||
=====
|
||||
Homepage
|
||||
http://pear.php.net/package/Mail
|
||||
Source code
|
||||
https://github.com/pear/Mail
|
||||
Issue tracker
|
||||
http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Mail
|
||||
Unit test status
|
||||
https://travis-ci.org/pear/Mail
|
||||
Packagist
|
||||
https://packagist.org/packages/pear/mail
|
||||
46
lib/composer/vendor/pear/mail/composer.json
vendored
Normal file
46
lib/composer/vendor/pear/mail/composer.json
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"authors": [
|
||||
{
|
||||
"email": "chuck@horde.org",
|
||||
"name": "Chuck Hagenbuch",
|
||||
"role": "Lead"
|
||||
},
|
||||
{
|
||||
"email": "richard@phpguru.org",
|
||||
"name": "Richard Heyes",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"email": "alec@alec.pl",
|
||||
"name": "Aleksander Machniak",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Mail": "./"
|
||||
}
|
||||
},
|
||||
"description": "Class that provides multiple interfaces for sending emails.",
|
||||
"homepage": "http://pear.php.net/package/Mail",
|
||||
"include-path": [
|
||||
"./"
|
||||
],
|
||||
"license": "BSD-2-Clause",
|
||||
"name": "pear/mail",
|
||||
"support": {
|
||||
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Mail",
|
||||
"source": "https://github.com/pear/Mail"
|
||||
},
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": ">=5.2.1",
|
||||
"pear/pear-core-minimal": "~1.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"pear/pear": "*"
|
||||
},
|
||||
"suggest": {
|
||||
"pear/net_smtp": "Install optionally via your project's composer.json"
|
||||
}
|
||||
}
|
||||
79
lib/composer/vendor/pear/mail/package.xml
vendored
Normal file
79
lib/composer/vendor/pear/mail/package.xml
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<package packagerversion="1.9.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<name>Mail</name>
|
||||
<channel>pear.php.net</channel>
|
||||
<summary>Class that provides multiple interfaces for sending emails</summary>
|
||||
<description>PEAR's Mail package defines an interface for implementing mailers under the PEAR hierarchy. It also provides supporting functions useful to multiple mailer backends. Currently supported backends include: PHP's native mail() function, sendmail, and SMTP. This package also provides a RFC822 email address list validation utility class.</description>
|
||||
<lead>
|
||||
<name>Chuck Hagenbuch</name>
|
||||
<user>chagenbu</user>
|
||||
<email>chuck@horde.org</email>
|
||||
<active>no</active>
|
||||
</lead>
|
||||
<developer>
|
||||
<name>Richard Heyes</name>
|
||||
<user>richard</user>
|
||||
<email>richard@phpguru.org</email>
|
||||
<active>no</active>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Aleksander Machniak</name>
|
||||
<user>alec</user>
|
||||
<email>alec@alec.pl</email>
|
||||
<active>yes</active>
|
||||
</developer>
|
||||
<date>2017-04-11</date>
|
||||
<version>
|
||||
<release>1.4.1</release>
|
||||
<api>1.3.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="https://opensource.org/licenses/BSD-3-Clause">New BSD License</license>
|
||||
<notes>
|
||||
* Loosen recognition of "queued as" server response (PR #10)
|
||||
|
||||
* Bug #20463: domain-literal parsing error
|
||||
* Bug #20513: Mail_smtp::send() doesn't close socket for smtp connection
|
||||
</notes>
|
||||
<contents>
|
||||
<dir baseinstalldir="/" name="/">
|
||||
<file baseinstalldir="/" name="LICENSE" role="doc" />
|
||||
<file baseinstalldir="/" name="Mail/mail.php" role="php" />
|
||||
<file baseinstalldir="/" name="Mail/mock.php" role="php" />
|
||||
<file baseinstalldir="/" name="Mail/null.php" role="php" />
|
||||
<file baseinstalldir="/" name="Mail/RFC822.php" role="php" />
|
||||
<file baseinstalldir="/" name="Mail/sendmail.php" role="php" />
|
||||
<file baseinstalldir="/" name="Mail/smtp.php" role="php" />
|
||||
<file baseinstalldir="/" name="Mail/smtpmx.php" role="php" />
|
||||
<file baseinstalldir="/" name="Mail.php" role="php" />
|
||||
<file baseinstalldir="/" name="tests/9137.phpt" role="test" />
|
||||
<file baseinstalldir="/" name="tests/9137_2.phpt" role="test" />
|
||||
<file baseinstalldir="/" name="tests/13659.phpt" role="test" />
|
||||
<file baseinstalldir="/" name="tests/bug17178.phpt" role="test" />
|
||||
<file baseinstalldir="/" name="tests/bug17317.phpt" role="test" />
|
||||
<file baseinstalldir="/" name="tests/rfc822.phpt" role="test" />
|
||||
<file baseinstalldir="/" name="tests/smtp_error.phpt" role="test" />
|
||||
</dir>
|
||||
</contents>
|
||||
<dependencies>
|
||||
<required>
|
||||
<php>
|
||||
<min>5.2.1</min>
|
||||
</php>
|
||||
<pearinstaller>
|
||||
<min>1.5.6</min>
|
||||
</pearinstaller>
|
||||
</required>
|
||||
<optional>
|
||||
<package>
|
||||
<name>Net_SMTP</name>
|
||||
<channel>pear.php.net</channel>
|
||||
<min>1.4.1</min>
|
||||
</package>
|
||||
</optional>
|
||||
</dependencies>
|
||||
<phprelease />
|
||||
</package>
|
||||
25
lib/composer/vendor/pear/mail/tests/13659.phpt
vendored
Normal file
25
lib/composer/vendor/pear/mail/tests/13659.phpt
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
Mail: Test for bug #13659
|
||||
--FILE--
|
||||
<?php
|
||||
//require_once dirname(__FILE__) . '/../Mail/RFC822.php';
|
||||
require_once 'Mail/RFC822.php';
|
||||
require_once 'PEAR.php';
|
||||
|
||||
$address = '"Test Student" <test@mydomain.com> (test)';
|
||||
$parser = new Mail_RFC822();
|
||||
$result = $parser->parseAddressList($address, 'anydomain.com', TRUE);
|
||||
|
||||
if (!PEAR::isError($result) && is_array($result) && is_object($result[0]))
|
||||
if ($result[0]->personal == '"Test Student"' &&
|
||||
$result[0]->mailbox == "test" &&
|
||||
$result[0]->host == "mydomain.com" &&
|
||||
is_array($result[0]->comment) && $result[0]->comment[0] == 'test')
|
||||
{
|
||||
print("OK");
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
OK
|
||||
33
lib/composer/vendor/pear/mail/tests/9137.phpt
vendored
Normal file
33
lib/composer/vendor/pear/mail/tests/9137.phpt
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
--TEST--
|
||||
Mail: Test for bug #9137
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once dirname(__FILE__) . '/../Mail/RFC822.php';
|
||||
require_once 'PEAR.php';
|
||||
|
||||
$addresses = array(
|
||||
array('name' => 'John Doe', 'email' => 'test@example.com'),
|
||||
array('name' => 'John Doe\\', 'email' => 'test@example.com'),
|
||||
array('name' => 'John "Doe', 'email' => 'test@example.com'),
|
||||
array('name' => 'John "Doe\\', 'email' => 'test@example.com'),
|
||||
);
|
||||
|
||||
for ($i = 0; $i < count($addresses); $i++) {
|
||||
// construct the address
|
||||
$address = "\"" . addslashes($addresses[$i]['name']) . "\" ".
|
||||
"<".$addresses[$i]['email'].">";
|
||||
|
||||
$parsedAddresses = Mail_RFC822::parseAddressList($address);
|
||||
if (is_a($parsedAddresses, 'PEAR_Error')) {
|
||||
echo $address." :: Failed to validate\n";
|
||||
} else {
|
||||
echo $address." :: Parsed\n";
|
||||
}
|
||||
}
|
||||
|
||||
--EXPECT--
|
||||
"John Doe" <test@example.com> :: Parsed
|
||||
"John Doe\\" <test@example.com> :: Parsed
|
||||
"John \"Doe" <test@example.com> :: Parsed
|
||||
"John \"Doe\\" <test@example.com> :: Parsed
|
||||
35
lib/composer/vendor/pear/mail/tests/9137_2.phpt
vendored
Normal file
35
lib/composer/vendor/pear/mail/tests/9137_2.phpt
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
--TEST--
|
||||
Mail: Test for bug #9137, take 2
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once dirname(__FILE__) . '/../Mail/RFC822.php';
|
||||
require_once 'PEAR.php';
|
||||
|
||||
$addresses = array(
|
||||
array('raw' => '"John Doe" <test@example.com>'),
|
||||
array('raw' => '"John Doe' . chr(92) . '" <test@example.com>'),
|
||||
array('raw' => '"John Doe' . chr(92) . chr(92) . '" <test@example.com>'),
|
||||
array('raw' => '"John Doe' . chr(92) . chr(92) . chr(92) . '" <test@example.com>'),
|
||||
array('raw' => '"John Doe' . chr(92) . chr(92) . chr(92) . chr(92) . '" <test@example.com>'),
|
||||
array('raw' => '"John Doe <test@example.com>'),
|
||||
);
|
||||
|
||||
for ($i = 0; $i < count($addresses); $i++) {
|
||||
// construct the address
|
||||
$address = $addresses[$i]['raw'];
|
||||
$parsedAddresses = Mail_RFC822::parseAddressList($address);
|
||||
if (PEAR::isError($parsedAddresses)) {
|
||||
echo $address." :: Failed to validate\n";
|
||||
} else {
|
||||
echo $address." :: Parsed\n";
|
||||
}
|
||||
}
|
||||
|
||||
--EXPECT--
|
||||
"John Doe" <test@example.com> :: Parsed
|
||||
"John Doe\" <test@example.com> :: Failed to validate
|
||||
"John Doe\\" <test@example.com> :: Parsed
|
||||
"John Doe\\\" <test@example.com> :: Failed to validate
|
||||
"John Doe\\\\" <test@example.com> :: Parsed
|
||||
"John Doe <test@example.com> :: Failed to validate
|
||||
8
lib/composer/vendor/pear/mail/tests/Makefile
vendored
Normal file
8
lib/composer/vendor/pear/mail/tests/Makefile
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
clean:
|
||||
rm -f *.log *.php *.diff *.exp *.out
|
||||
|
||||
|
||||
|
||||
test:
|
||||
cd .. && pear run-tests tests/*.phpt && cd tests;
|
||||
11
lib/composer/vendor/pear/mail/tests/bug17178.phpt
vendored
Executable file
11
lib/composer/vendor/pear/mail/tests/bug17178.phpt
vendored
Executable file
@@ -0,0 +1,11 @@
|
||||
--TEST--
|
||||
Mail_RFC822::parseAddressList does not accept RFC-valid group syntax
|
||||
--FILE--
|
||||
<?php
|
||||
require "Mail/RFC822.php";
|
||||
|
||||
var_dump(Mail_RFC822::parseAddressList("empty-group:;","invalid",false,false));
|
||||
|
||||
--EXPECT--
|
||||
array(0) {
|
||||
}
|
||||
19
lib/composer/vendor/pear/mail/tests/bug17317.phpt
vendored
Executable file
19
lib/composer/vendor/pear/mail/tests/bug17317.phpt
vendored
Executable file
@@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
Mail_RFC822::parseAddressList invalid periods in mail address
|
||||
--FILE--
|
||||
<?php
|
||||
require "Mail/RFC822.php";
|
||||
|
||||
$result[] = Mail_RFC822::parseAddressList('.name@example.com');
|
||||
$result[] = Mail_RFC822::parseAddressList('name.@example.com');
|
||||
$result[] = Mail_RFC822::parseAddressList('name..name@example.com');
|
||||
|
||||
foreach ($result as $r) {
|
||||
if (is_a($r, 'PEAR_Error')) {
|
||||
echo "OK\n";
|
||||
}
|
||||
}
|
||||
--EXPECT--
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
107
lib/composer/vendor/pear/mail/tests/rfc822.phpt
vendored
Normal file
107
lib/composer/vendor/pear/mail/tests/rfc822.phpt
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
--TEST--
|
||||
Mail_RFC822: Address Parsing
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'Mail/RFC822.php';
|
||||
|
||||
$parser = new Mail_RFC822();
|
||||
|
||||
/* A simple, bare address. */
|
||||
$address = 'user@example.com';
|
||||
print_r($parser->parseAddressList($address, null, true, true));
|
||||
|
||||
/* Address groups. */
|
||||
$address = 'My Group: "Richard" <richard@localhost> (A comment), ted@example.com (Ted Bloggs), Barney;';
|
||||
print_r($parser->parseAddressList($address, null, true, true));
|
||||
|
||||
/* A valid address with spaces in the local part. */
|
||||
$address = '<"Jon Parise"@php.net>';
|
||||
print_r($parser->parseAddressList($address, null, true, true));
|
||||
|
||||
/* An invalid address with spaces in the local part. */
|
||||
$address = '<Jon Parise@php.net>';
|
||||
$result = $parser->parseAddressList($address, null, true, true);
|
||||
if (is_a($result, 'PEAR_Error')) echo $result->getMessage() . "\n";
|
||||
|
||||
/* A valid address with an uncommon TLD. */
|
||||
$address = 'jon@host.longtld';
|
||||
$result = $parser->parseAddressList($address, null, true, true);
|
||||
if (is_a($result, 'PEAR_Error')) echo $result->getMessage() . "\n";
|
||||
|
||||
--EXPECT--
|
||||
Array
|
||||
(
|
||||
[0] => stdClass Object
|
||||
(
|
||||
[personal] =>
|
||||
[comment] => Array
|
||||
(
|
||||
)
|
||||
|
||||
[mailbox] => user
|
||||
[host] => example.com
|
||||
)
|
||||
|
||||
)
|
||||
Array
|
||||
(
|
||||
[0] => stdClass Object
|
||||
(
|
||||
[groupname] => My Group
|
||||
[addresses] => Array
|
||||
(
|
||||
[0] => stdClass Object
|
||||
(
|
||||
[personal] => "Richard"
|
||||
[comment] => Array
|
||||
(
|
||||
[0] => A comment
|
||||
)
|
||||
|
||||
[mailbox] => richard
|
||||
[host] => localhost
|
||||
)
|
||||
|
||||
[1] => stdClass Object
|
||||
(
|
||||
[personal] =>
|
||||
[comment] => Array
|
||||
(
|
||||
[0] => Ted Bloggs
|
||||
)
|
||||
|
||||
[mailbox] => ted
|
||||
[host] => example.com
|
||||
)
|
||||
|
||||
[2] => stdClass Object
|
||||
(
|
||||
[personal] =>
|
||||
[comment] => Array
|
||||
(
|
||||
)
|
||||
|
||||
[mailbox] => Barney
|
||||
[host] => localhost
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
Array
|
||||
(
|
||||
[0] => stdClass Object
|
||||
(
|
||||
[personal] =>
|
||||
[comment] => Array
|
||||
(
|
||||
)
|
||||
|
||||
[mailbox] => "Jon Parise"
|
||||
[host] => php.net
|
||||
)
|
||||
|
||||
)
|
||||
Validation failed for: <Jon Parise@php.net>
|
||||
30
lib/composer/vendor/pear/mail/tests/smtp_error.phpt
vendored
Normal file
30
lib/composer/vendor/pear/mail/tests/smtp_error.phpt
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
Mail: SMTP Error Reporting
|
||||
--SKIPIF--
|
||||
<?php
|
||||
|
||||
require_once 'PEAR/Registry.php';
|
||||
$registry = new PEAR_Registry();
|
||||
|
||||
if (!$registry->packageExists('Net_SMTP')) die("skip\n");
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'Mail.php';
|
||||
|
||||
/* Reference a bogus SMTP server address to guarantee a connection failure. */
|
||||
$params = array('host' => 'bogus.host.tld');
|
||||
|
||||
/* Create our SMTP-based mailer object. */
|
||||
$mailer = Mail::factory('smtp', $params);
|
||||
|
||||
/* Attempt to send an empty message in order to trigger an error. */
|
||||
$e = $mailer->send(array(), array(), '');
|
||||
if (is_a($e, 'PEAR_Error')) {
|
||||
$err = $e->getMessage();
|
||||
if (preg_match('/Failed to connect to bogus.host.tld:25 \[SMTP: Failed to connect socket:.*/i', $err)) {
|
||||
echo "OK";
|
||||
}
|
||||
}
|
||||
|
||||
--EXPECT--
|
||||
OK
|
||||
17
lib/composer/vendor/pear/mail/tests/validateQuotedString.php
vendored
Normal file
17
lib/composer/vendor/pear/mail/tests/validateQuotedString.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
require_once '../Mail/RFC822.php';
|
||||
$address_string = '"Joe Doe \(from Somewhere\)" <doe@example.com>, postmaster@example.com, root';
|
||||
// $address_string = "Joe Doe from Somewhere <doe@example.com>, postmaster@example.com, root";
|
||||
echo $address_string . "\n";
|
||||
|
||||
$address_array = Mail_RFC822::parseAddressList($address_string, "example.com");
|
||||
if (!is_array($address_array) || count($address_array) < 1) {
|
||||
die("something is wrong\n");
|
||||
}
|
||||
|
||||
foreach ($address_array as $val) {
|
||||
echo "mailbox : " . $val->mailbox . "\n";
|
||||
echo "host : " . $val->host . "\n";
|
||||
echo "personal: " . $val->personal . "\n";
|
||||
}
|
||||
print_r($address_array);
|
||||
15
lib/composer/vendor/pear/net_smtp/.gitignore
vendored
Normal file
15
lib/composer/vendor/pear/net_smtp/.gitignore
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
.DS_Store
|
||||
Net_SMTP-*.tgz
|
||||
|
||||
# Tests
|
||||
run-tests.log
|
||||
/tests/*.diff
|
||||
/tests/*.exp
|
||||
/tests/*.log
|
||||
/tests/*.out
|
||||
/tests/config.php
|
||||
|
||||
# composer related
|
||||
composer.lock
|
||||
composer.phar
|
||||
vendor
|
||||
11
lib/composer/vendor/pear/net_smtp/.travis.yml
vendored
Normal file
11
lib/composer/vendor/pear/net_smtp/.travis.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
language: php
|
||||
install:
|
||||
- pear install package.xml
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- nightly
|
||||
script: pear run-tests -d tests/
|
||||
69
lib/composer/vendor/pear/net_smtp/LICENSE
vendored
Normal file
69
lib/composer/vendor/pear/net_smtp/LICENSE
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
--------------------------------------------------------------------
|
||||
The PHP License, version 3.01
|
||||
Copyright (c) 2002-2015 Jon Parise and Chuck Hagenbuch.
|
||||
All rights reserved.
|
||||
--------------------------------------------------------------------
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, is permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
3. The name "PHP" must not be used to endorse or promote products
|
||||
derived from this software without prior written permission. For
|
||||
written permission, please contact group@php.net.
|
||||
|
||||
4. Products derived from this software may not be called "PHP", nor
|
||||
may "PHP" appear in their name, without prior written permission
|
||||
from group@php.net. You may indicate that your software works in
|
||||
conjunction with PHP by saying "Foo for PHP" instead of calling
|
||||
it "PHP Foo" or "phpfoo"
|
||||
|
||||
5. The PHP Group may publish revised and/or new versions of the
|
||||
license from time to time. Each version will be given a
|
||||
distinguishing version number.
|
||||
Once covered code has been published under a particular version
|
||||
of the license, you may always continue to use it under the terms
|
||||
of that version. You may also choose to use such covered code
|
||||
under the terms of any subsequent version of the license
|
||||
published by the PHP Group. No one other than the PHP Group has
|
||||
the right to modify the terms applicable to covered code created
|
||||
under this License.
|
||||
|
||||
6. Redistributions of any form whatsoever must retain the following
|
||||
acknowledgment:
|
||||
"This product includes PHP software, freely available from
|
||||
<http://www.php.net/software/>".
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
|
||||
ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
|
||||
DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
--------------------------------------------------------------------
|
||||
|
||||
This software consists of voluntary contributions made by many
|
||||
individuals on behalf of the PHP Group.
|
||||
|
||||
The PHP Group can be contacted via Email at group@php.net.
|
||||
|
||||
For more information on the PHP Group and the PHP project,
|
||||
please see <http://www.php.net>.
|
||||
|
||||
PHP includes the Zend Engine, freely available at
|
||||
<http://www.zend.com>.
|
||||
1256
lib/composer/vendor/pear/net_smtp/Net/SMTP.php
vendored
Normal file
1256
lib/composer/vendor/pear/net_smtp/Net/SMTP.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
lib/composer/vendor/pear/net_smtp/README.rst
vendored
Symbolic link
1
lib/composer/vendor/pear/net_smtp/README.rst
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
docs/guide.txt
|
||||
48
lib/composer/vendor/pear/net_smtp/composer.json
vendored
Normal file
48
lib/composer/vendor/pear/net_smtp/composer.json
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"authors": [
|
||||
{
|
||||
"email": "jon@php.net",
|
||||
"name": "Jon Parise",
|
||||
"homepage": "http://www.indelible.org",
|
||||
"role": "Lead"
|
||||
},
|
||||
{
|
||||
"email": "chuck@horde.org",
|
||||
"name": "Chuck Hagenbuch",
|
||||
"role": "Lead"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Net": "./"
|
||||
}
|
||||
},
|
||||
"description": "An implementation of the SMTP protocol",
|
||||
"keywords": [
|
||||
"smtp",
|
||||
"mail",
|
||||
"email"
|
||||
],
|
||||
"include-path": [
|
||||
"./"
|
||||
],
|
||||
"license": "PHP-3.01",
|
||||
"name": "pear/net_smtp",
|
||||
"homepage": "http://pear.github.io/Net_SMTP/",
|
||||
"support": {
|
||||
"issues": "https://github.com/pear/Net_SMTP/issues",
|
||||
"source": "https://github.com/pear/Net_SMTP"
|
||||
},
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"pear/pear-core-minimal": "*",
|
||||
"pear/net_socket": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "*"
|
||||
},
|
||||
"suggest": {
|
||||
"pear/auth_sasl": "Install optionally via your project's composer.json"
|
||||
}
|
||||
}
|
||||
16
lib/composer/vendor/pear/net_smtp/docs/docutils.conf
vendored
Normal file
16
lib/composer/vendor/pear/net_smtp/docs/docutils.conf
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
[general]
|
||||
source-link: no
|
||||
no-datestamp: yes
|
||||
generator: off
|
||||
strip-comments: yes
|
||||
toc-backlinks: no
|
||||
|
||||
[standalone reader]
|
||||
docinfo_xform: no
|
||||
|
||||
[html4css1 writer]
|
||||
stylesheet-path: docutils.css
|
||||
embed-stylesheet: yes
|
||||
field-name-limit: 20
|
||||
cloak-email-addresses: yes
|
||||
initial-header-level: 2
|
||||
108
lib/composer/vendor/pear/net_smtp/docs/docutils.css
vendored
Normal file
108
lib/composer/vendor/pear/net_smtp/docs/docutils.css
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
body {
|
||||
font-family: Verdana, Helvetica, Arial, sans-serif;
|
||||
font-size: 0.8em;
|
||||
letter-spacing: 0.01em;
|
||||
line-height: 1.5em;
|
||||
text-align: justify;
|
||||
margin: 0 auto;
|
||||
width: 48em;
|
||||
}
|
||||
|
||||
a:link, a:visited {
|
||||
color: #00c;
|
||||
padding-bottom: 0;
|
||||
text-decoration: none;
|
||||
border-bottom: 1px solid #dbd5c5;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
padding-bottom: 0;
|
||||
border-bottom: 2px solid #dbd5c5;
|
||||
}
|
||||
|
||||
h1, h2, h3 {
|
||||
font-family: Georgia, "Times New Roman", Times, serif;
|
||||
font-weight: normal;
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2.1em;
|
||||
letter-spacing: -0.02em;
|
||||
margin-top: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.6em;
|
||||
font-style: italic;
|
||||
margin: 30px 0 10px 0;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.3em;
|
||||
font-style: italic;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
li {
|
||||
line-height: 135%;
|
||||
}
|
||||
|
||||
ul, ol {
|
||||
margin: 0 0 1em 2em;
|
||||
padding: 0 0 0 1em;
|
||||
}
|
||||
|
||||
hr {
|
||||
background-color: #ccc;
|
||||
border: 0px none;
|
||||
color: #eee;
|
||||
height: 1px;
|
||||
margin: 30px 0px;
|
||||
}
|
||||
|
||||
blockquote, pre {
|
||||
background-color: #f9f9f9;
|
||||
border: 1px solid #eee;
|
||||
border-left: 2px solid #ccc;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
color: #666;
|
||||
line-height: 1.3em;
|
||||
}
|
||||
|
||||
pre {
|
||||
line-height: normal;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
pre.code-block {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
tt, pre, code, samp, kbd {
|
||||
color: #333;
|
||||
font-family: Consolas, 'Lucida Console', monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
label em {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
form {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.code-block .err { border: 1px solid #FF0000 } /* Error */
|
||||
.code-block .k,.kn { color: #369 } /* Keywords */
|
||||
.code-block .c,.cm,.cp,.c1 { color: #666; font-style: italic } /* Comments */
|
||||
.code-block .n { color: #000 } /* Names */
|
||||
.code-block .p { color: #000 } /* Punctuation */
|
||||
.code-block .nc,.nf,.nn { color: #333; font-weight: bold } /* Symbol Names */
|
||||
.code-block .s { color: #933 } /* Literal.String */
|
||||
.code-block .sd { color: #666 } /* Literal.String.Doc */
|
||||
267
lib/composer/vendor/pear/net_smtp/docs/guide.txt
vendored
Normal file
267
lib/composer/vendor/pear/net_smtp/docs/guide.txt
vendored
Normal file
@@ -0,0 +1,267 @@
|
||||
======================
|
||||
The Net_SMTP Package
|
||||
======================
|
||||
|
||||
--------------------
|
||||
User Documentation
|
||||
--------------------
|
||||
|
||||
:Author: Jon Parise
|
||||
:Contact: jon@php.net
|
||||
|
||||
.. contents:: Table of Contents
|
||||
.. section-numbering::
|
||||
|
||||
Dependencies
|
||||
============
|
||||
|
||||
The ``PEAR_Error`` Class
|
||||
------------------------
|
||||
|
||||
The Net_SMTP package uses the `PEAR_Error`_ class for all of its `error
|
||||
handling`_.
|
||||
|
||||
The ``Net_Socket`` Package
|
||||
--------------------------
|
||||
|
||||
The Net_Socket_ package is used as the basis for all network communications.
|
||||
Connection options can be specified via the `$socket_options` construction
|
||||
parameter::
|
||||
|
||||
$socket_options = array('ssl' => array('verify_peer_name' => false));
|
||||
$smtp = new Net_SMTP($host, null, null, false, 0, $socket_options);
|
||||
|
||||
**Note:** PHP 5.6 introduced `OpenSSL changes`_. Peer certificate verification
|
||||
is now enabled by default. Although not recommended, `$socket_options` can be
|
||||
used to disable peer verification (as shown above).
|
||||
|
||||
.. _OpenSSL changes: http://php.net/manual/en/migration56.openssl.php
|
||||
|
||||
The ``Auth_SASL`` Package
|
||||
-------------------------
|
||||
|
||||
The `Auth_SASL`_ package is an optional dependency. If it is available, the
|
||||
Net_SMTP package will be able to support the DIGEST-MD5_ and CRAM-MD5_ SMTP
|
||||
authentication methods. Otherwise, only the LOGIN_ and PLAIN_ methods will
|
||||
be available.
|
||||
|
||||
Error Handling
|
||||
==============
|
||||
|
||||
All of the Net_SMTP class's public methods return a PEAR_Error_ object if an
|
||||
error occurs. The standard way to check for a PEAR_Error object is by using
|
||||
`PEAR::isError()`_::
|
||||
|
||||
if (PEAR::isError($error = $smtp->connect())) {
|
||||
die($error->getMessage());
|
||||
}
|
||||
|
||||
.. _PEAR::isError(): http://pear.php.net/manual/en/core.pear.pear.iserror.php
|
||||
|
||||
SMTP Authentication
|
||||
===================
|
||||
|
||||
The Net_SMTP package supports the SMTP authentication standard (as defined
|
||||
by RFC-2554_). The Net_SMTP package supports the following authentication
|
||||
methods, in order of preference:
|
||||
|
||||
.. _RFC-2554: http://www.ietf.org/rfc/rfc2554.txt
|
||||
|
||||
DIGEST-MD5
|
||||
----------
|
||||
|
||||
The DIGEST-MD5 authentication method uses `RSA Data Security Inc.`_'s MD5
|
||||
Message Digest algorithm. It is considered the most secure method of SMTP
|
||||
authentication.
|
||||
|
||||
**Note:** The DIGEST-MD5 authentication method is only supported if the
|
||||
AUTH_SASL_ package is available.
|
||||
|
||||
.. _RSA Data Security Inc.: http://www.rsasecurity.com/
|
||||
|
||||
CRAM-MD5
|
||||
--------
|
||||
|
||||
The CRAM-MD5 authentication method has been superseded by the DIGEST-MD5_
|
||||
method in terms of security. It is provided here for compatibility with
|
||||
older SMTP servers that may not support the newer DIGEST-MD5 algorithm.
|
||||
|
||||
**Note:** The CRAM-MD5 authentication method is only supported if the
|
||||
AUTH_SASL_ package is available.
|
||||
|
||||
LOGIN
|
||||
-----
|
||||
|
||||
The LOGIN authentication method encrypts the user's password using the
|
||||
Base64_ encoding scheme. Because decrypting a Base64-encoded string is
|
||||
trivial, LOGIN is not considered a secure authentication method and should
|
||||
be avoided.
|
||||
|
||||
.. _Base64: http://www.php.net/manual/en/function.base64-encode.php
|
||||
|
||||
PLAIN
|
||||
-----
|
||||
|
||||
The PLAIN authentication method sends the user's password in plain text.
|
||||
This method of authentication is not secure and should be avoided.
|
||||
|
||||
Secure Connections
|
||||
==================
|
||||
|
||||
If `secure socket transports`_ have been enabled in PHP, it is possible to
|
||||
establish a secure connection to the remote SMTP server::
|
||||
|
||||
$smtp = new Net_SMTP('ssl://mail.example.com', 465);
|
||||
|
||||
This example connects to ``mail.example.com`` on port 465 (a common SMTPS
|
||||
port) using the ``ssl://`` transport.
|
||||
|
||||
.. _secure socket transports: http://www.php.net/transports
|
||||
|
||||
Sending Data
|
||||
============
|
||||
|
||||
Message data is sent using the ``data()`` method. The data can be supplied
|
||||
as a single string or as an open file resource.
|
||||
|
||||
If a string is provided, it is passed through the `data quoting`_ system and
|
||||
sent to the socket connection as a single block. These operations are all
|
||||
memory-based, so sending large messages may result in high memory usage.
|
||||
|
||||
If an open file resource is provided, the ``data()`` method will read the
|
||||
message data from the file line-by-line. Each chunk will be quoted and sent
|
||||
to the socket connection individually, reducing the overall memory overhead of
|
||||
this data sending operation.
|
||||
|
||||
Header data can be specified separately from message body data by passing it
|
||||
as the optional second parameter to ``data()``. This is especially useful
|
||||
when an open file resource is being used to supply message data because it
|
||||
allows header fields (like *Subject:*) to be built dynamically at runtime.
|
||||
|
||||
::
|
||||
|
||||
$smtp->data($fp, "Subject: My Subject");
|
||||
|
||||
Data Quoting
|
||||
============
|
||||
|
||||
By default, all outbound string data is quoted in accordance with SMTP
|
||||
standards. This means that all native Unix (``\n``) and Mac (``\r``) line
|
||||
endings are converted to Internet-standard CRLF (``\r\n``) line endings.
|
||||
Also, because the SMTP protocol uses a single leading period (``.``) to signal
|
||||
an end to the message data, single leading periods in the original data
|
||||
string are "doubled" (e.g. "``..``").
|
||||
|
||||
These string transformation can be expensive when large blocks of data are
|
||||
involved. For example, the Net_SMTP package is not aware of MIME parts (it
|
||||
just sees the MIME message as one big string of characters), so it is not
|
||||
able to skip non-text attachments when searching for characters that may
|
||||
need to be quoted.
|
||||
|
||||
Because of this, it is possible to extend the Net_SMTP class in order to
|
||||
implement your own custom quoting routine. Just create a new class based on
|
||||
the Net_SMTP class and reimplement the ``quotedata()`` method::
|
||||
|
||||
require 'Net_SMTP.php';
|
||||
|
||||
class Net_SMTP_custom extends Net_SMTP
|
||||
{
|
||||
function quotedata($data)
|
||||
{
|
||||
/* Perform custom data quoting */
|
||||
}
|
||||
}
|
||||
|
||||
Note that the ``$data`` parameter will be passed to the ``quotedata()``
|
||||
function `by reference`_. This means that you can operate directly on
|
||||
``$data``. It also the overhead of copying a large ``$data`` string to and
|
||||
from the ``quotedata()`` method.
|
||||
|
||||
.. _by reference: http://www.php.net/manual/en/language.references.pass.php
|
||||
|
||||
Server Responses
|
||||
================
|
||||
|
||||
The Net_SMTP package retains the server's last response for further
|
||||
inspection. The ``getResponse()`` method returns a 2-tuple (two element
|
||||
array) containing the server's response code as an integer and the response's
|
||||
arguments as a string.
|
||||
|
||||
Upon a successful connection, the server's greeting string is available via
|
||||
the ``getGreeting()`` method.
|
||||
|
||||
Debugging
|
||||
=========
|
||||
|
||||
The Net_SMTP package contains built-in debugging output routines (disabled by
|
||||
default). Debugging output must be explicitly enabled via the ``setDebug()``
|
||||
method::
|
||||
|
||||
$smtp->setDebug(true);
|
||||
|
||||
The debugging messages will be sent to the standard output stream by default.
|
||||
If you need more control over the output, you can optionally install your own
|
||||
debug handler.
|
||||
|
||||
::
|
||||
|
||||
function debugHandler($smtp, $message)
|
||||
{
|
||||
echo "[$smtp->host] $message\n";
|
||||
}
|
||||
|
||||
$smtp->setDebug(true, "debugHandler");
|
||||
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
Basic Use
|
||||
---------
|
||||
|
||||
The following script demonstrates how a simple email message can be sent
|
||||
using the Net_SMTP package::
|
||||
|
||||
require 'Net/SMTP.php';
|
||||
|
||||
$host = 'mail.example.com';
|
||||
$from = 'user@example.com';
|
||||
$rcpt = array('recipient1@example.com', 'recipient2@example.com');
|
||||
$subj = "Subject: Test Message\n";
|
||||
$body = "Body Line 1\nBody Line 2";
|
||||
|
||||
/* Create a new Net_SMTP object. */
|
||||
if (! ($smtp = new Net_SMTP($host))) {
|
||||
die("Unable to instantiate Net_SMTP object\n");
|
||||
}
|
||||
|
||||
/* Connect to the SMTP server. */
|
||||
if (PEAR::isError($e = $smtp->connect())) {
|
||||
die($e->getMessage() . "\n");
|
||||
}
|
||||
|
||||
/* Send the 'MAIL FROM:' SMTP command. */
|
||||
if (PEAR::isError($smtp->mailFrom($from))) {
|
||||
die("Unable to set sender to <$from>\n");
|
||||
}
|
||||
|
||||
/* Address the message to each of the recipients. */
|
||||
foreach ($rcpt as $to) {
|
||||
if (PEAR::isError($res = $smtp->rcptTo($to))) {
|
||||
die("Unable to add recipient <$to>: " . $res->getMessage() . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the body of the message. */
|
||||
if (PEAR::isError($smtp->data($subj . "\r\n" . $body))) {
|
||||
die("Unable to send data\n");
|
||||
}
|
||||
|
||||
/* Disconnect from the SMTP server. */
|
||||
$smtp->disconnect();
|
||||
|
||||
.. _PEAR_Error: http://pear.php.net/manual/en/core.pear.pear-error.php
|
||||
.. _Net_Socket: http://pear.php.net/package/Net_Socket
|
||||
.. _Auth_SASL: http://pear.php.net/package/Auth_SASL
|
||||
|
||||
.. vim: tabstop=4 shiftwidth=4 softtabstop=4 expandtab textwidth=78 ft=rst:
|
||||
39
lib/composer/vendor/pear/net_smtp/examples/basic.php
vendored
Normal file
39
lib/composer/vendor/pear/net_smtp/examples/basic.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
require 'Net/SMTP.php';
|
||||
|
||||
$host = 'mail.example.com';
|
||||
$from = 'user@example.com';
|
||||
$rcpt = array('recipient1@example.com', 'recipient2@example.com');
|
||||
$subj = "Subject: Test Message\n";
|
||||
$body = "Body Line 1\nBody Line 2";
|
||||
|
||||
/* Create a new Net_SMTP object. */
|
||||
if (! ($smtp = new Net_SMTP($host))) {
|
||||
die("Unable to instantiate Net_SMTP object\n");
|
||||
}
|
||||
|
||||
/* Connect to the SMTP server. */
|
||||
if (PEAR::isError($e = $smtp->connect())) {
|
||||
die($e->getMessage() . "\n");
|
||||
}
|
||||
$smtp->auth('username','password');
|
||||
/* Send the 'MAIL FROM:' SMTP command. */
|
||||
if (PEAR::isError($smtp->mailFrom($from))) {
|
||||
die("Unable to set sender to <$from>\n");
|
||||
}
|
||||
|
||||
/* Address the message to each of the recipients. */
|
||||
foreach ($rcpt as $to) {
|
||||
if (PEAR::isError($res = $smtp->rcptTo($to))) {
|
||||
die("Unable to add recipient <$to>: " . $res->getMessage() . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the body of the message. */
|
||||
if (PEAR::isError($smtp->data($subj . "\r\n" . $body))) {
|
||||
die("Unable to send data\n");
|
||||
}
|
||||
|
||||
/* Disconnect from the SMTP server. */
|
||||
$smtp->disconnect();
|
||||
77
lib/composer/vendor/pear/net_smtp/package.xml
vendored
Normal file
77
lib/composer/vendor/pear/net_smtp/package.xml
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<package packagerversion="1.7.1" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
|
||||
http://pear.php.net/dtd/tasks-1.0.xsd
|
||||
http://pear.php.net/dtd/package-2.0
|
||||
http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<name>Net_SMTP</name>
|
||||
<channel>pear.php.net</channel>
|
||||
<summary>An implementation of the SMTP protocol</summary>
|
||||
<description>Provides an implementation of the SMTP protocol using PEAR's Net_Socket class.</description>
|
||||
<lead>
|
||||
<name>Jon Parise</name>
|
||||
<user>jon</user>
|
||||
<email>jon@php.net</email>
|
||||
<active>yes</active>
|
||||
</lead>
|
||||
<lead>
|
||||
<name>Chuck Hagenbuch</name>
|
||||
<user>chagenbu</user>
|
||||
<email>chuck@horde.org</email>
|
||||
<active>yes</active>
|
||||
</lead>
|
||||
<date>2017-01-14</date>
|
||||
<time>00:00:00</time>
|
||||
<version>
|
||||
<release>1.7.3</release>
|
||||
<api>1.3.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license/3_01.txt">PHP License</license>
|
||||
<notes>- Fix MIME boundary size calculation (#34)
|
||||
- Workaround E_DEPRECATED warning on Auth_SASL::factory() call (#29)
|
||||
</notes>
|
||||
<contents>
|
||||
<dir baseinstalldir="/" name="/">
|
||||
<file name="LICENSE" role="doc" />
|
||||
<dir name="docs">
|
||||
<file name="guide.txt" role="doc" />
|
||||
</dir> <!-- /docs -->
|
||||
<dir name="examples">
|
||||
<file name="basic.php" role="doc" />
|
||||
</dir> <!-- /examples -->
|
||||
<dir name="tests">
|
||||
<file name="auth.phpt" role="test" />
|
||||
<file name="basic.phpt" role="test" />
|
||||
<file name="config.php.dist" role="test" />
|
||||
<file name="quotedata.phpt" role="test" />
|
||||
</dir> <!-- /tests -->
|
||||
<file name="Net/SMTP.php" role="php" />
|
||||
</dir> <!-- / -->
|
||||
</contents>
|
||||
<dependencies>
|
||||
<required>
|
||||
<php>
|
||||
<min>5.4.0</min>
|
||||
</php>
|
||||
<pearinstaller>
|
||||
<min>1.4.3</min>
|
||||
</pearinstaller>
|
||||
<package>
|
||||
<name>Net_Socket</name>
|
||||
<channel>pear.php.net</channel>
|
||||
<min>1.0.7</min>
|
||||
</package>
|
||||
</required>
|
||||
<optional>
|
||||
<package>
|
||||
<name>Auth_SASL</name>
|
||||
<channel>pear.php.net</channel>
|
||||
<min>1.0.5</min>
|
||||
</package>
|
||||
</optional>
|
||||
</dependencies>
|
||||
<phprelease />
|
||||
</package>
|
||||
3
lib/composer/vendor/pear/net_smtp/phpdoc.sh
vendored
Executable file
3
lib/composer/vendor/pear/net_smtp/phpdoc.sh
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
phpdoc -f Net/SMTP.php -t docs/api -p -ti "Net_SMTP Package API" -dn Net_SMTP -dc Net_SMTP -ed examples
|
||||
28
lib/composer/vendor/pear/net_smtp/tests/auth.phpt
vendored
Normal file
28
lib/composer/vendor/pear/net_smtp/tests/auth.phpt
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
Net_SMTP: SMTP Authentication
|
||||
--SKIPIF--
|
||||
<?php if (!@include('config.php')) die("skip\n");
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once 'Net/SMTP.php';
|
||||
require_once 'config.php';
|
||||
|
||||
if (! ($smtp = new Net_SMTP(TEST_HOSTNAME, TEST_PORT, TEST_LOCALHOST))) {
|
||||
die("Unable to instantiate Net_SMTP object\n");
|
||||
}
|
||||
|
||||
if (PEAR::isError($e = $smtp->connect())) {
|
||||
die($e->getMessage() . "\n");
|
||||
}
|
||||
|
||||
if (PEAR::isError($e = $smtp->auth(TEST_AUTH_USER, TEST_AUTH_PASS))) {
|
||||
die("Authentication failure\n");
|
||||
}
|
||||
|
||||
$smtp->disconnect();
|
||||
|
||||
echo 'Success!';
|
||||
|
||||
--EXPECT--
|
||||
Success!
|
||||
42
lib/composer/vendor/pear/net_smtp/tests/basic.phpt
vendored
Normal file
42
lib/composer/vendor/pear/net_smtp/tests/basic.phpt
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
--TEST--
|
||||
Net_SMTP: Basic Functionality
|
||||
--SKIPIF--
|
||||
<?php if (!@include('config.php')) die("skip\n");
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once 'Net/SMTP.php';
|
||||
require_once 'config.php';
|
||||
|
||||
if (! ($smtp = new Net_SMTP(TEST_HOSTNAME, TEST_PORT, TEST_LOCALHOST))) {
|
||||
die("Unable to instantiate Net_SMTP object\n");
|
||||
}
|
||||
|
||||
if (PEAR::isError($e = $smtp->connect())) {
|
||||
die($e->getMessage() . "\n");
|
||||
}
|
||||
|
||||
if (PEAR::isError($e = $smtp->auth(TEST_AUTH_USER, TEST_AUTH_PASS))) {
|
||||
die("Authentication failure\n");
|
||||
}
|
||||
|
||||
if (PEAR::isError($smtp->mailFrom(TEST_FROM))) {
|
||||
die('Unable to set sender to <' . TEST_FROM . ">\n");
|
||||
}
|
||||
|
||||
if (PEAR::isError($res = $smtp->rcptTo(TEST_TO))) {
|
||||
die('Unable to add recipient <' . TEST_TO . '>: ' .
|
||||
$res->getMessage() . "\n");
|
||||
}
|
||||
|
||||
$headers = 'Subject: ' . TEST_SUBJECT;
|
||||
if (PEAR::isError($smtp->data(TEST_BODY, $headers))) {
|
||||
die("Unable to send data\n");
|
||||
}
|
||||
|
||||
$smtp->disconnect();
|
||||
|
||||
echo 'Success!';
|
||||
|
||||
--EXPECT--
|
||||
Success!
|
||||
15
lib/composer/vendor/pear/net_smtp/tests/config.php.dist
vendored
Normal file
15
lib/composer/vendor/pear/net_smtp/tests/config.php.dist
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Copy this file to config.php and customize the following values to
|
||||
* suit your configuration.
|
||||
*/
|
||||
|
||||
define('TEST_HOSTNAME', 'localhost');
|
||||
define('TEST_PORT', 25);
|
||||
define('TEST_LOCALHOST', 'localhost');
|
||||
define('TEST_AUTH_USER', 'jon');
|
||||
define('TEST_AUTH_PASS', 'secret');
|
||||
define('TEST_FROM', 'from@example.com');
|
||||
define('TEST_TO', 'to@example.com');
|
||||
define('TEST_SUBJECT', 'Test Subject');
|
||||
define('TEST_BODY', 'Test Body');
|
||||
70
lib/composer/vendor/pear/net_smtp/tests/quotedata.phpt
vendored
Normal file
70
lib/composer/vendor/pear/net_smtp/tests/quotedata.phpt
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
--TEST--
|
||||
Net_SMTP: quotedata()
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once 'Net/SMTP.php';
|
||||
|
||||
$tests = array(
|
||||
/* Newlines */
|
||||
"\n" => "\r\n",
|
||||
"\r\n" => "\r\n",
|
||||
"\nxx" => "\r\nxx",
|
||||
"xx\n" => "xx\r\n",
|
||||
"xx\nxx" => "xx\r\nxx",
|
||||
"\n\nxx" => "\r\n\r\nxx",
|
||||
"xx\n\nxx" => "xx\r\n\r\nxx",
|
||||
"xx\n\n" => "xx\r\n\r\n",
|
||||
"\r\nxx" => "\r\nxx",
|
||||
"xx\r\n" => "xx\r\n",
|
||||
"xx\r\nxx" => "xx\r\nxx",
|
||||
"\r\n\r\nxx" => "\r\n\r\nxx",
|
||||
"xx\r\n\r\nxx" => "xx\r\n\r\nxx",
|
||||
"xx\r\n\r\n" => "xx\r\n\r\n",
|
||||
"\r\n\nxx" => "\r\n\r\nxx",
|
||||
"\n\r\nxx" => "\r\n\r\nxx",
|
||||
"xx\r\n\nxx" => "xx\r\n\r\nxx",
|
||||
"xx\n\r\nxx" => "xx\r\n\r\nxx",
|
||||
"xx\r\n\n" => "xx\r\n\r\n",
|
||||
"xx\n\r\n" => "xx\r\n\r\n",
|
||||
"\r" => "\r\n",
|
||||
"\rxx" => "\r\nxx",
|
||||
"xx\rxx" => "xx\r\nxx",
|
||||
"xx\r" => "xx\r\n",
|
||||
"\r\r" => "\r\n\r\n",
|
||||
"\r\rxx" => "\r\n\r\nxx",
|
||||
"xx\r\rxx" => "xx\r\n\r\nxx",
|
||||
"xx\r\r" => "xx\r\n\r\n",
|
||||
"xx\rxx\nxx\r\nxx" => "xx\r\nxx\r\nxx\r\nxx",
|
||||
"\r\r\n\n" => "\r\n\r\n\r\n",
|
||||
|
||||
/* Dots */
|
||||
"." => "..",
|
||||
"xxx\n." => "xxx\r\n..",
|
||||
"xxx\n.\nxxx" => "xxx\r\n..\r\nxxx",
|
||||
"xxx.\n.xxx" => "xxx.\r\n..xxx",
|
||||
);
|
||||
|
||||
function literal($x)
|
||||
{
|
||||
return str_replace(array("\r", "\n"), array('\r', '\n'), $x);
|
||||
}
|
||||
|
||||
$smtp = new Net_SMTP();
|
||||
$error = false;
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = $input;
|
||||
$smtp->quotedata($output);
|
||||
if ($output != $expected) {
|
||||
printf("Error: '%s' => '%s' (expected: '%s')",
|
||||
literal($input), literal($output), literal($expected));
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
echo "success\n";
|
||||
}
|
||||
|
||||
--EXPECT--
|
||||
success
|
||||
6
lib/composer/vendor/pear/net_socket/.gitignore
vendored
Normal file
6
lib/composer/vendor/pear/net_socket/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
# composer related
|
||||
composer.lock
|
||||
composer.phar
|
||||
vendor
|
||||
|
||||
*.tgz
|
||||
21
lib/composer/vendor/pear/net_socket/.travis.yml
vendored
Normal file
21
lib/composer/vendor/pear/net_socket/.travis.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
language: php
|
||||
sudo: false
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
script:
|
||||
- pear list
|
||||
- pear channel-update pear.php.net
|
||||
- pear upgrade --force pear/pear-1.10.1
|
||||
- pear list
|
||||
- pear install --force package.xml
|
||||
- pear list
|
||||
- pear package
|
||||
- pear package-validate
|
||||
- pear install --force *.tgz
|
||||
- pear list
|
||||
- composer install
|
||||
- ./vendor/bin/phpunit -c phpunit.xml.dist
|
||||
9
lib/composer/vendor/pear/net_socket/LICENSE
vendored
Normal file
9
lib/composer/vendor/pear/net_socket/LICENSE
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
Copyright 1997-2017 The PHP Group
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
723
lib/composer/vendor/pear/net_socket/Net/Socket.php
vendored
Normal file
723
lib/composer/vendor/pear/net_socket/Net/Socket.php
vendored
Normal file
@@ -0,0 +1,723 @@
|
||||
<?php
|
||||
/**
|
||||
* Net_Socket
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 1997-2017 The PHP Group
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* o Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Net
|
||||
* @package Net_Socket
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Chuck Hagenbuch <chuck@horde.org>
|
||||
* @copyright 1997-2017 The PHP Group
|
||||
* @license http://opensource.org/licenses/bsd-license.php BSD-2-Clause
|
||||
* @link http://pear.php.net/packages/Net_Socket
|
||||
*/
|
||||
|
||||
require_once 'PEAR.php';
|
||||
|
||||
define('NET_SOCKET_READ', 1);
|
||||
define('NET_SOCKET_WRITE', 2);
|
||||
define('NET_SOCKET_ERROR', 4);
|
||||
|
||||
/**
|
||||
* Generalized Socket class.
|
||||
*
|
||||
* @category Net
|
||||
* @package Net_Socket
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Chuck Hagenbuch <chuck@horde.org>
|
||||
* @copyright 1997-2017 The PHP Group
|
||||
* @license http://opensource.org/licenses/bsd-license.php BSD-2-Clause
|
||||
* @link http://pear.php.net/packages/Net_Socket
|
||||
*/
|
||||
class Net_Socket extends PEAR
|
||||
{
|
||||
/**
|
||||
* Socket file pointer.
|
||||
* @var resource $fp
|
||||
*/
|
||||
public $fp = null;
|
||||
|
||||
/**
|
||||
* Whether the socket is blocking. Defaults to true.
|
||||
* @var boolean $blocking
|
||||
*/
|
||||
public $blocking = true;
|
||||
|
||||
/**
|
||||
* Whether the socket is persistent. Defaults to false.
|
||||
* @var boolean $persistent
|
||||
*/
|
||||
public $persistent = false;
|
||||
|
||||
/**
|
||||
* The IP address to connect to.
|
||||
* @var string $addr
|
||||
*/
|
||||
public $addr = '';
|
||||
|
||||
/**
|
||||
* The port number to connect to.
|
||||
* @var integer $port
|
||||
*/
|
||||
public $port = 0;
|
||||
|
||||
/**
|
||||
* Number of seconds to wait on socket operations before assuming
|
||||
* there's no more data. Defaults to no timeout.
|
||||
* @var integer|float $timeout
|
||||
*/
|
||||
public $timeout = null;
|
||||
|
||||
/**
|
||||
* Number of bytes to read at a time in readLine() and
|
||||
* readAll(). Defaults to 2048.
|
||||
* @var integer $lineLength
|
||||
*/
|
||||
public $lineLength = 2048;
|
||||
|
||||
/**
|
||||
* The string to use as a newline terminator. Usually "\r\n" or "\n".
|
||||
* @var string $newline
|
||||
*/
|
||||
public $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 (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.
|
||||
*/
|
||||
public function connect(
|
||||
$addr,
|
||||
$port = 0,
|
||||
$persistent = null,
|
||||
$timeout = null,
|
||||
$options = null
|
||||
) {
|
||||
if (is_resource($this->fp)) {
|
||||
@fclose($this->fp);
|
||||
$this->fp = null;
|
||||
}
|
||||
|
||||
if (!$addr) {
|
||||
return $this->raiseError('$addr cannot be empty');
|
||||
} else {
|
||||
if (strspn($addr, ':.0123456789') === strlen($addr)) {
|
||||
$this->addr = strpos($addr, ':') !== false ? '[' . $addr . ']' : $addr;
|
||||
} else {
|
||||
$this->addr = $addr;
|
||||
}
|
||||
}
|
||||
|
||||
$this->port = $port % 65536;
|
||||
|
||||
if ($persistent !== null) {
|
||||
$this->persistent = $persistent;
|
||||
}
|
||||
|
||||
$openfunc = $this->persistent ? 'pfsockopen' : 'fsockopen';
|
||||
$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')) {
|
||||
$context = stream_context_create($options);
|
||||
|
||||
// Since PHP 5 fsockopen doesn't allow context specification
|
||||
if (function_exists('stream_socket_client')) {
|
||||
$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);
|
||||
} else {
|
||||
$fp = @$openfunc($this->addr, $this->port, $errno,
|
||||
$errstr, $timeout, $context);
|
||||
}
|
||||
} else {
|
||||
$fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $timeout);
|
||||
}
|
||||
|
||||
if (!$fp) {
|
||||
if ($errno === 0 && !strlen($errstr) && isset($php_errormsg)) {
|
||||
$errstr = $php_errormsg;
|
||||
}
|
||||
@ini_set('track_errors', $old_track_errors);
|
||||
|
||||
return $this->raiseError($errstr, $errno);
|
||||
}
|
||||
|
||||
@ini_set('track_errors', $old_track_errors);
|
||||
$this->fp = $fp;
|
||||
$this->setTimeout();
|
||||
|
||||
return $this->setBlocking($this->blocking);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects from the peer, closes the socket.
|
||||
*
|
||||
* @access public
|
||||
* @return mixed true on success or a PEAR_Error instance otherwise
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
@fclose($this->fp);
|
||||
$this->fp = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the newline character/sequence to use.
|
||||
*
|
||||
* @param string $newline Newline character(s)
|
||||
* @return boolean True
|
||||
*/
|
||||
public function setNewline($newline)
|
||||
{
|
||||
$this->newline = $newline;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find out if the socket is in blocking mode.
|
||||
*
|
||||
* @access public
|
||||
* @return boolean The current blocking mode.
|
||||
*/
|
||||
public function isBlocking()
|
||||
{
|
||||
return $this->blocking;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the socket connection should be blocking or
|
||||
* not. A read call to a non-blocking socket will return immediately
|
||||
* 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.
|
||||
*
|
||||
* @access public
|
||||
* @return mixed true on success or a PEAR_Error instance otherwise
|
||||
*/
|
||||
public function setBlocking($mode)
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$this->blocking = $mode;
|
||||
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, optional.
|
||||
*
|
||||
* @access public
|
||||
* @return mixed True on success or false on failure or
|
||||
* a PEAR_Error instance when not connected
|
||||
*/
|
||||
public function setTimeout($seconds = null, $microseconds = null)
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* @access public
|
||||
* @return mixed on success or an PEAR_Error object otherwise
|
||||
*/
|
||||
public function setWriteBuffer($size)
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$returned = stream_set_write_buffer($this->fp, $size);
|
||||
if ($returned === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->raiseError('Cannot set write buffer.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about an existing socket resource.
|
||||
* Currently returns four entries in the result array:
|
||||
*
|
||||
* <p>
|
||||
* timed_out (bool) - The socket timed out waiting for data<br>
|
||||
* blocked (bool) - The socket was blocked<br>
|
||||
* eof (bool) - Indicates EOF event<br>
|
||||
* unread_bytes (int) - Number of bytes left in the socket buffer<br>
|
||||
* </p>
|
||||
*
|
||||
* @access public
|
||||
* @return mixed Array containing information about existing socket
|
||||
* resource or a PEAR_Error instance otherwise
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
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 mixed $size bytes of data from the socket, or a PEAR_Error if
|
||||
* not connected. If an error occurs, FALSE is returned.
|
||||
*/
|
||||
public function gets($size = null)
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
if (null === $size) {
|
||||
return @fgets($this->fp);
|
||||
} else {
|
||||
return @fgets($this->fp, $size);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a specified amount of data. This is guaranteed to return,
|
||||
* and has the added benefit of getting everything in one fread()
|
||||
* 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.
|
||||
*
|
||||
* @access public
|
||||
* @return string $size bytes of data from the socket, or a PEAR_Error if
|
||||
* not connected.
|
||||
*/
|
||||
public function read($size)
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
return @fread($this->fp, $size);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @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.
|
||||
* If the write fails, returns false.
|
||||
* If the socket times out, returns an instance of PEAR_Error.
|
||||
*/
|
||||
public function write($data, $blocksize = null)
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
if (null === $blocksize && !OS_WINDOWS) {
|
||||
$written = @fwrite($this->fp, $data);
|
||||
|
||||
// Check for timeout or lost connection
|
||||
if ($written === false) {
|
||||
$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 (null === $blocksize) {
|
||||
$blocksize = 1024;
|
||||
}
|
||||
|
||||
$pos = 0;
|
||||
$size = strlen($data);
|
||||
while ($pos < $size) {
|
||||
$written = @fwrite($this->fp, substr($data, $pos, $blocksize));
|
||||
|
||||
// Check for timeout or lost connection
|
||||
if ($written === false) {
|
||||
$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;
|
||||
}
|
||||
|
||||
return $pos;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a line of data to the socket, followed by a trailing newline.
|
||||
*
|
||||
* @param string $data Data to write
|
||||
*
|
||||
* @access public
|
||||
* @return mixed fwrite() result, or PEAR_Error when not connected
|
||||
*/
|
||||
public function writeLine($data)
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
return fwrite($this->fp, $data . $this->newline);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for end-of-file on a socket descriptor.
|
||||
*
|
||||
* Also returns true if the socket is disconnected.
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function eof()
|
||||
{
|
||||
return (!is_resource($this->fp) || feof($this->fp));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a byte of data
|
||||
*
|
||||
* @access public
|
||||
* @return integer 1 byte of data from the socket, or a PEAR_Error if
|
||||
* not connected.
|
||||
*/
|
||||
public function readByte()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
return ord(@fread($this->fp, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a word of data
|
||||
*
|
||||
* @access public
|
||||
* @return integer 1 word of data from the socket, or a PEAR_Error if
|
||||
* not connected.
|
||||
*/
|
||||
public function readWord()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$buf = @fread($this->fp, 2);
|
||||
|
||||
return (ord($buf[0]) + (ord($buf[1]) << 8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an int of data
|
||||
*
|
||||
* @access public
|
||||
* @return integer 1 int of data from the socket, or a PEAR_Error if
|
||||
* not connected.
|
||||
*/
|
||||
public function readInt()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$buf = @fread($this->fp, 4);
|
||||
|
||||
return (ord($buf[0]) + (ord($buf[1]) << 8) +
|
||||
(ord($buf[2]) << 16) + (ord($buf[3]) << 24));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a zero-terminated string of data
|
||||
*
|
||||
* @access public
|
||||
* @return string, or a PEAR_Error if
|
||||
* not connected.
|
||||
*/
|
||||
public function readString()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$string = '';
|
||||
while (($char = @fread($this->fp, 1)) !== "\x00") {
|
||||
$string .= $char;
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an IP Address and returns it in a dot formatted string
|
||||
*
|
||||
* @access public
|
||||
* @return string Dot formatted string, or a PEAR_Error if
|
||||
* not connected.
|
||||
*/
|
||||
public function readIPAddress()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$buf = @fread($this->fp, 4);
|
||||
|
||||
return sprintf('%d.%d.%d.%d', ord($buf[0]), ord($buf[1]),
|
||||
ord($buf[2]), ord($buf[3]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read until either the end of the socket or a newline, whichever
|
||||
* comes first. Strips the trailing newline from the returned data.
|
||||
*
|
||||
* @access public
|
||||
* @return string All available data up to a newline, without that
|
||||
* newline, or until the end of the socket, or a PEAR_Error if
|
||||
* not connected.
|
||||
*/
|
||||
public function readLine()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$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, $this->newline);
|
||||
}
|
||||
}
|
||||
|
||||
return $line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read until the socket closes, or until there is no more data in
|
||||
* the inner PHP buffer. If the inner buffer is empty, in blocking
|
||||
* mode we wait for at least 1 byte of data. Therefore, in
|
||||
* blocking mode, if there is no data at all to be read, this
|
||||
* function will never exit (unless the socket is closed on the
|
||||
* remote end).
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @return string All data until the socket closes, or a PEAR_Error if
|
||||
* not connected.
|
||||
*/
|
||||
public function readAll()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$data = '';
|
||||
$timeout = time() + $this->timeout;
|
||||
|
||||
while (!feof($this->fp) && (!$this->timeout || time() < $timeout)) {
|
||||
$data .= @fread($this->fp, $this->lineLength);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @access public
|
||||
* @return False if select fails, integer describing which of read/write/error
|
||||
* are ready, or PEAR_Error if not connected.
|
||||
*/
|
||||
public function select($state, $tv_sec, $tv_usec = 0)
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$read = null;
|
||||
$write = null;
|
||||
$except = null;
|
||||
if ($state & NET_SOCKET_READ) {
|
||||
$read[] = $this->fp;
|
||||
}
|
||||
if ($state & NET_SOCKET_WRITE) {
|
||||
$write[] = $this->fp;
|
||||
}
|
||||
if ($state & NET_SOCKET_ERROR) {
|
||||
$except[] = $this->fp;
|
||||
}
|
||||
if (false === ($sr = stream_select($read, $write, $except,
|
||||
$tv_sec, $tv_usec))
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = 0;
|
||||
if (count($read)) {
|
||||
$result |= NET_SOCKET_READ;
|
||||
}
|
||||
if (count($write)) {
|
||||
$result |= NET_SOCKET_WRITE;
|
||||
}
|
||||
if (count($except)) {
|
||||
$result |= NET_SOCKET_ERROR;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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
|
||||
*/
|
||||
public function enableCrypto($enabled, $type)
|
||||
{
|
||||
if (version_compare(phpversion(), '5.1.0', '>=')) {
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
return @stream_socket_enable_crypto($this->fp, $enabled, $type);
|
||||
} else {
|
||||
$msg = 'Net_Socket::enableCrypto() requires php version >= 5.1.0';
|
||||
|
||||
return $this->raiseError($msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
43
lib/composer/vendor/pear/net_socket/README.md
vendored
Normal file
43
lib/composer/vendor/pear/net_socket/README.md
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# Net_Socket - Network Socket Interface
|
||||
|
||||
[](https://travis-ci.org/pear/Net_Socket)
|
||||
|
||||
|
||||
Net_Socket is a class interface to TCP sockets. It provides blocking
|
||||
and non-blocking operation, with different reading and writing modes
|
||||
(byte-wise, block-wise, line-wise and special formats like network
|
||||
byte-order ip addresses).
|
||||
|
||||
[Homepage](http://pear.php.net/package/Net_Socket/)
|
||||
|
||||
|
||||
## Installation
|
||||
For a PEAR installation that downloads from the PEAR channel:
|
||||
|
||||
`$ pear install pear/net_socket`
|
||||
|
||||
For a PEAR installation from a previously downloaded tarball:
|
||||
|
||||
`$ pear install Net_Socket-*.tgz`
|
||||
|
||||
For a PEAR installation from a code clone:
|
||||
|
||||
`$ pear install package.xml`
|
||||
|
||||
For a local composer installation:
|
||||
|
||||
`$ composer install`
|
||||
|
||||
To add as a dependency to your composer-managed application:
|
||||
|
||||
`$composer require pear/net_socket`
|
||||
|
||||
|
||||
## Tests
|
||||
Run the tests from a local composer installation:
|
||||
|
||||
`$ ./vendor/bin/phpunit`
|
||||
|
||||
|
||||
## License
|
||||
BSD-2 license
|
||||
42
lib/composer/vendor/pear/net_socket/composer.json
vendored
Normal file
42
lib/composer/vendor/pear/net_socket/composer.json
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"authors": [
|
||||
{
|
||||
"email": "chuck@horde.org",
|
||||
"name": "Chuck Hagenbuch",
|
||||
"role": "Lead"
|
||||
},
|
||||
{
|
||||
"email": "stig@php.net",
|
||||
"name": "Stig Bakken",
|
||||
"role": "Lead"
|
||||
},
|
||||
{
|
||||
"email": "alec@php.net",
|
||||
"name": "Aleksander Machniak",
|
||||
"role": "Lead"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Net": "./"
|
||||
}
|
||||
},
|
||||
"description": "More info available on: http://pear.php.net/package/Net_Socket",
|
||||
"include-path": [
|
||||
"./"
|
||||
],
|
||||
"license": "BSD-2-Clause",
|
||||
"name": "pear/net_socket",
|
||||
"support": {
|
||||
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Net_Socket",
|
||||
"source": "https://github.com/pear/Net_Socket"
|
||||
},
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"pear/pear_exception": "@stable"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4"
|
||||
}
|
||||
}
|
||||
59
lib/composer/vendor/pear/net_socket/package.xml
vendored
Normal file
59
lib/composer/vendor/pear/net_socket/package.xml
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<package packagerversion="1.9.1" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<name>Net_Socket</name>
|
||||
<channel>pear.php.net</channel>
|
||||
<summary>Network Socket Interface</summary>
|
||||
<description>Net_Socket is a class interface to TCP sockets. It provides blocking
|
||||
and non-blocking operation, with different reading and writing modes
|
||||
(byte-wise, block-wise, line-wise and special formats like network
|
||||
byte-order ip addresses).</description>
|
||||
<lead>
|
||||
<name>Chuck Hagenbuch</name>
|
||||
<user>chagenbu</user>
|
||||
<email>chuck@horde.org</email>
|
||||
<active>no</active>
|
||||
</lead>
|
||||
<lead>
|
||||
<name>Stig Bakken</name>
|
||||
<user>ssb</user>
|
||||
<email>stig@php.net</email>
|
||||
<active>no</active>
|
||||
</lead>
|
||||
<lead>
|
||||
<name>Aleksander Machniak</name>
|
||||
<user>alec</user>
|
||||
<email>alec@php.net</email>
|
||||
<active>no</active>
|
||||
</lead>
|
||||
<date>2017-04-06</date>
|
||||
<version>
|
||||
<release>1.2.1</release>
|
||||
<api>1.2.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://www.opensource.org/licenses/bsd-license.php">BSD-2-Clause</license>
|
||||
<notes>
|
||||
* Fix BSD-2 licensing
|
||||
</notes>
|
||||
<contents>
|
||||
<dir baseinstalldir="/" name="/">
|
||||
<file baseinstalldir="/" name="Net/Socket.php" role="php" />
|
||||
<file baseinstalldir="/" name="README.md" role="doc" />
|
||||
<file baseinstalldir="/" name="LICENSE" role="doc" />
|
||||
</dir>
|
||||
</contents>
|
||||
<dependencies>
|
||||
<required>
|
||||
<php>
|
||||
<min>5.4.0</min>
|
||||
</php>
|
||||
<pearinstaller>
|
||||
<min>1.10.1</min>
|
||||
</pearinstaller>
|
||||
</required>
|
||||
</dependencies>
|
||||
<phprelease />
|
||||
</package>
|
||||
29
lib/composer/vendor/pear/net_socket/phpunit.xml.dist
vendored
Normal file
29
lib/composer/vendor/pear/net_socket/phpunit.xml.dist
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<phpunit bootstrap="vendor/autoload.php"
|
||||
cacheTokens="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
stopOnError="false"
|
||||
stopOnFailure="false"
|
||||
stopOnIncomplete="false"
|
||||
stopOnSkipped="false">
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Test Suite">
|
||||
<directory suffix=".php">tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">Net/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
<logging>
|
||||
<log type="coverage-clover" target="build/logs/clover.xml"/>
|
||||
<log type="coverage-html" target="build/coverage/"/>
|
||||
</logging>
|
||||
|
||||
</phpunit>
|
||||
26
lib/composer/vendor/pear/pear-core-minimal/README.rst
vendored
Normal file
26
lib/composer/vendor/pear/pear-core-minimal/README.rst
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
******************************
|
||||
Minimal set of PEAR core files
|
||||
******************************
|
||||
|
||||
This repository provides a set of files from ``pear-core``
|
||||
that are often used in PEAR packages.
|
||||
|
||||
It follows the `pear-core`__ repository and gets updated whenever a new
|
||||
PEAR version is released.
|
||||
|
||||
It's meant to be used as dependency for composer packages.
|
||||
|
||||
__ https://github.com/pear/pear-core
|
||||
|
||||
==============
|
||||
Included files
|
||||
==============
|
||||
- ``OS/Guess.php``
|
||||
- ``PEAR.php``
|
||||
- ``PEAR/Error.php``
|
||||
- ``PEAR/ErrorStack.php``
|
||||
- ``System.php``
|
||||
|
||||
|
||||
``PEAR/Error.php`` is a dummy file that only includes ``PEAR.php``,
|
||||
to make autoloaders work without problems.
|
||||
32
lib/composer/vendor/pear/pear-core-minimal/composer.json
vendored
Normal file
32
lib/composer/vendor/pear/pear-core-minimal/composer.json
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "pear/pear-core-minimal",
|
||||
"description": "Minimal set of PEAR core files to be used as composer dependency",
|
||||
"license": "BSD-3-Clause",
|
||||
"authors": [
|
||||
{
|
||||
"email": "cweiske@php.net",
|
||||
"name": "Christian Weiske",
|
||||
"role": "Lead"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"": "src/"
|
||||
}
|
||||
},
|
||||
"include-path": [
|
||||
"src/"
|
||||
],
|
||||
"support": {
|
||||
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=PEAR",
|
||||
"source": "https://github.com/pear/pear-core-minimal"
|
||||
},
|
||||
"type": "library",
|
||||
"require": {
|
||||
"pear/console_getopt": "~1.4",
|
||||
"pear/pear_exception": "~1.0"
|
||||
},
|
||||
"replace": {
|
||||
"rsky/pear-core-min": "self.version"
|
||||
}
|
||||
}
|
||||
337
lib/composer/vendor/pear/pear-core-minimal/src/OS/Guess.php
vendored
Normal file
337
lib/composer/vendor/pear/pear-core-minimal/src/OS/Guess.php
vendored
Normal file
@@ -0,0 +1,337 @@
|
||||
<?php
|
||||
/**
|
||||
* The OS_Guess class
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Gregory 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 PEAR 0.1
|
||||
*/
|
||||
|
||||
// {{{ uname examples
|
||||
|
||||
// php_uname() without args returns the same as 'uname -a', or a PHP-custom
|
||||
// string for Windows.
|
||||
// PHP versions prior to 4.3 return the uname of the host where PHP was built,
|
||||
// as of 4.3 it returns the uname of the host running the PHP code.
|
||||
//
|
||||
// PC RedHat Linux 7.1:
|
||||
// Linux host.example.com 2.4.2-2 #1 Sun Apr 8 20:41:30 EDT 2001 i686 unknown
|
||||
//
|
||||
// PC Debian Potato:
|
||||
// Linux host 2.4.17 #2 SMP Tue Feb 12 15:10:04 CET 2002 i686 unknown
|
||||
//
|
||||
// PC FreeBSD 3.3:
|
||||
// FreeBSD host.example.com 3.3-STABLE FreeBSD 3.3-STABLE #0: Mon Feb 21 00:42:31 CET 2000 root@example.com:/usr/src/sys/compile/CONFIG i386
|
||||
//
|
||||
// PC FreeBSD 4.3:
|
||||
// FreeBSD host.example.com 4.3-RELEASE FreeBSD 4.3-RELEASE #1: Mon Jun 25 11:19:43 EDT 2001 root@example.com:/usr/src/sys/compile/CONFIG i386
|
||||
//
|
||||
// PC FreeBSD 4.5:
|
||||
// FreeBSD host.example.com 4.5-STABLE FreeBSD 4.5-STABLE #0: Wed Feb 6 23:59:23 CET 2002 root@example.com:/usr/src/sys/compile/CONFIG i386
|
||||
//
|
||||
// PC FreeBSD 4.5 w/uname from GNU shellutils:
|
||||
// FreeBSD host.example.com 4.5-STABLE FreeBSD 4.5-STABLE #0: Wed Feb i386 unknown
|
||||
//
|
||||
// HP 9000/712 HP-UX 10:
|
||||
// HP-UX iq B.10.10 A 9000/712 2008429113 two-user license
|
||||
//
|
||||
// HP 9000/712 HP-UX 10 w/uname from GNU shellutils:
|
||||
// HP-UX host B.10.10 A 9000/712 unknown
|
||||
//
|
||||
// IBM RS6000/550 AIX 4.3:
|
||||
// AIX host 3 4 000003531C00
|
||||
//
|
||||
// AIX 4.3 w/uname from GNU shellutils:
|
||||
// AIX host 3 4 000003531C00 unknown
|
||||
//
|
||||
// SGI Onyx IRIX 6.5 w/uname from GNU shellutils:
|
||||
// IRIX64 host 6.5 01091820 IP19 mips
|
||||
//
|
||||
// SGI Onyx IRIX 6.5:
|
||||
// IRIX64 host 6.5 01091820 IP19
|
||||
//
|
||||
// SparcStation 20 Solaris 8 w/uname from GNU shellutils:
|
||||
// SunOS host.example.com 5.8 Generic_108528-12 sun4m sparc
|
||||
//
|
||||
// SparcStation 20 Solaris 8:
|
||||
// SunOS host.example.com 5.8 Generic_108528-12 sun4m sparc SUNW,SPARCstation-20
|
||||
//
|
||||
// Mac OS X (Darwin)
|
||||
// Darwin home-eden.local 7.5.0 Darwin Kernel Version 7.5.0: Thu Aug 5 19:26:16 PDT 2004; root:xnu/xnu-517.7.21.obj~3/RELEASE_PPC Power Macintosh
|
||||
//
|
||||
// Mac OS X early versions
|
||||
//
|
||||
|
||||
// }}}
|
||||
|
||||
/* TODO:
|
||||
* - define endianness, to allow matchSignature("bigend") etc.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Retrieves information about the current operating system
|
||||
*
|
||||
* This class uses php_uname() to grok information about the current OS
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 1997-2009 The Authors
|
||||
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @version Release: @package_version@
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 0.1
|
||||
*/
|
||||
class OS_Guess
|
||||
{
|
||||
var $sysname;
|
||||
var $nodename;
|
||||
var $cpu;
|
||||
var $release;
|
||||
var $extra;
|
||||
|
||||
function __construct($uname = null)
|
||||
{
|
||||
list($this->sysname,
|
||||
$this->release,
|
||||
$this->cpu,
|
||||
$this->extra,
|
||||
$this->nodename) = $this->parseSignature($uname);
|
||||
}
|
||||
|
||||
function parseSignature($uname = null)
|
||||
{
|
||||
static $sysmap = array(
|
||||
'HP-UX' => 'hpux',
|
||||
'IRIX64' => 'irix',
|
||||
);
|
||||
static $cpumap = array(
|
||||
'i586' => 'i386',
|
||||
'i686' => 'i386',
|
||||
'ppc' => 'powerpc',
|
||||
);
|
||||
if ($uname === null) {
|
||||
$uname = php_uname();
|
||||
}
|
||||
$parts = preg_split('/\s+/', trim($uname));
|
||||
$n = count($parts);
|
||||
|
||||
$release = $machine = $cpu = '';
|
||||
$sysname = $parts[0];
|
||||
$nodename = $parts[1];
|
||||
$cpu = $parts[$n-1];
|
||||
$extra = '';
|
||||
if ($cpu == 'unknown') {
|
||||
$cpu = $parts[$n - 2];
|
||||
}
|
||||
|
||||
switch ($sysname) {
|
||||
case 'AIX' :
|
||||
$release = "$parts[3].$parts[2]";
|
||||
break;
|
||||
case 'Windows' :
|
||||
switch ($parts[1]) {
|
||||
case '95/98':
|
||||
$release = '9x';
|
||||
break;
|
||||
default:
|
||||
$release = $parts[1];
|
||||
break;
|
||||
}
|
||||
$cpu = 'i386';
|
||||
break;
|
||||
case 'Linux' :
|
||||
$extra = $this->_detectGlibcVersion();
|
||||
// use only the first two digits from the kernel version
|
||||
$release = preg_replace('/^([0-9]+\.[0-9]+).*/', '\1', $parts[2]);
|
||||
break;
|
||||
case 'Mac' :
|
||||
$sysname = 'darwin';
|
||||
$nodename = $parts[2];
|
||||
$release = $parts[3];
|
||||
if ($cpu == 'Macintosh') {
|
||||
if ($parts[$n - 2] == 'Power') {
|
||||
$cpu = 'powerpc';
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Darwin' :
|
||||
if ($cpu == 'Macintosh') {
|
||||
if ($parts[$n - 2] == 'Power') {
|
||||
$cpu = 'powerpc';
|
||||
}
|
||||
}
|
||||
$release = preg_replace('/^([0-9]+\.[0-9]+).*/', '\1', $parts[2]);
|
||||
break;
|
||||
default:
|
||||
$release = preg_replace('/-.*/', '', $parts[2]);
|
||||
break;
|
||||
}
|
||||
|
||||
if (isset($sysmap[$sysname])) {
|
||||
$sysname = $sysmap[$sysname];
|
||||
} else {
|
||||
$sysname = strtolower($sysname);
|
||||
}
|
||||
if (isset($cpumap[$cpu])) {
|
||||
$cpu = $cpumap[$cpu];
|
||||
}
|
||||
return array($sysname, $release, $cpu, $extra, $nodename);
|
||||
}
|
||||
|
||||
function _detectGlibcVersion()
|
||||
{
|
||||
static $glibc = false;
|
||||
if ($glibc !== false) {
|
||||
return $glibc; // no need to run this multiple times
|
||||
}
|
||||
$major = $minor = 0;
|
||||
include_once "System.php";
|
||||
// Use glibc's <features.h> header file to
|
||||
// get major and minor version number:
|
||||
if (@file_exists('/usr/include/features.h') &&
|
||||
@is_readable('/usr/include/features.h')) {
|
||||
if (!@file_exists('/usr/bin/cpp') || !@is_executable('/usr/bin/cpp')) {
|
||||
$features_file = fopen('/usr/include/features.h', 'rb');
|
||||
while (!feof($features_file)) {
|
||||
$line = fgets($features_file, 8192);
|
||||
if (!$line || (strpos($line, '#define') === false)) {
|
||||
continue;
|
||||
}
|
||||
if (strpos($line, '__GLIBC__')) {
|
||||
// major version number #define __GLIBC__ version
|
||||
$line = preg_split('/\s+/', $line);
|
||||
$glibc_major = trim($line[2]);
|
||||
if (isset($glibc_minor)) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strpos($line, '__GLIBC_MINOR__')) {
|
||||
// got the minor version number
|
||||
// #define __GLIBC_MINOR__ version
|
||||
$line = preg_split('/\s+/', $line);
|
||||
$glibc_minor = trim($line[2]);
|
||||
if (isset($glibc_major)) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
fclose($features_file);
|
||||
if (!isset($glibc_major) || !isset($glibc_minor)) {
|
||||
return $glibc = '';
|
||||
}
|
||||
return $glibc = 'glibc' . trim($glibc_major) . "." . trim($glibc_minor) ;
|
||||
} // no cpp
|
||||
|
||||
$tmpfile = System::mktemp("glibctest");
|
||||
$fp = fopen($tmpfile, "w");
|
||||
fwrite($fp, "#include <features.h>\n__GLIBC__ __GLIBC_MINOR__\n");
|
||||
fclose($fp);
|
||||
$cpp = popen("/usr/bin/cpp $tmpfile", "r");
|
||||
while ($line = fgets($cpp, 1024)) {
|
||||
if ($line{0} == '#' || trim($line) == '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (list($major, $minor) = explode(' ', trim($line))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
pclose($cpp);
|
||||
unlink($tmpfile);
|
||||
} // features.h
|
||||
|
||||
if (!($major && $minor) && @is_link('/lib/libc.so.6')) {
|
||||
// Let's try reading the libc.so.6 symlink
|
||||
if (preg_match('/^libc-(.*)\.so$/', basename(readlink('/lib/libc.so.6')), $matches)) {
|
||||
list($major, $minor) = explode('.', $matches[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!($major && $minor)) {
|
||||
return $glibc = '';
|
||||
}
|
||||
|
||||
return $glibc = "glibc{$major}.{$minor}";
|
||||
}
|
||||
|
||||
function getSignature()
|
||||
{
|
||||
if (empty($this->extra)) {
|
||||
return "{$this->sysname}-{$this->release}-{$this->cpu}";
|
||||
}
|
||||
return "{$this->sysname}-{$this->release}-{$this->cpu}-{$this->extra}";
|
||||
}
|
||||
|
||||
function getSysname()
|
||||
{
|
||||
return $this->sysname;
|
||||
}
|
||||
|
||||
function getNodename()
|
||||
{
|
||||
return $this->nodename;
|
||||
}
|
||||
|
||||
function getCpu()
|
||||
{
|
||||
return $this->cpu;
|
||||
}
|
||||
|
||||
function getRelease()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
function getExtra()
|
||||
{
|
||||
return $this->extra;
|
||||
}
|
||||
|
||||
function matchSignature($match)
|
||||
{
|
||||
$fragments = is_array($match) ? $match : explode('-', $match);
|
||||
$n = count($fragments);
|
||||
$matches = 0;
|
||||
if ($n > 0) {
|
||||
$matches += $this->_matchFragment($fragments[0], $this->sysname);
|
||||
}
|
||||
if ($n > 1) {
|
||||
$matches += $this->_matchFragment($fragments[1], $this->release);
|
||||
}
|
||||
if ($n > 2) {
|
||||
$matches += $this->_matchFragment($fragments[2], $this->cpu);
|
||||
}
|
||||
if ($n > 3) {
|
||||
$matches += $this->_matchFragment($fragments[3], $this->extra);
|
||||
}
|
||||
return ($matches == $n);
|
||||
}
|
||||
|
||||
function _matchFragment($fragment, $value)
|
||||
{
|
||||
if (strcspn($fragment, '*?') < strlen($fragment)) {
|
||||
$reg = '/^' . str_replace(array('*', '?', '/'), array('.*', '.', '\\/'), $fragment) . '\\z/';
|
||||
return preg_match($reg, $value);
|
||||
}
|
||||
return ($fragment == '*' || !strcasecmp($fragment, $value));
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: nil
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
1113
lib/composer/vendor/pear/pear-core-minimal/src/PEAR.php
vendored
Normal file
1113
lib/composer/vendor/pear/pear-core-minimal/src/PEAR.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
14
lib/composer/vendor/pear/pear-core-minimal/src/PEAR/Error.php
vendored
Normal file
14
lib/composer/vendor/pear/pear-core-minimal/src/PEAR/Error.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Dummy file to make autoloaders work
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PEAR
|
||||
* @package PEAR
|
||||
* @author Christian Weiske <cweiske@php.net>
|
||||
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
*/
|
||||
require_once __DIR__ . '/../PEAR.php';
|
||||
?>
|
||||
979
lib/composer/vendor/pear/pear-core-minimal/src/PEAR/ErrorStack.php
vendored
Normal file
979
lib/composer/vendor/pear/pear-core-minimal/src/PEAR/ErrorStack.php
vendored
Normal file
@@ -0,0 +1,979 @@
|
||||
<?php
|
||||
/**
|
||||
* Error Stack Implementation
|
||||
*
|
||||
* This is an incredibly simple implementation of a very complex error handling
|
||||
* facility. It contains the ability
|
||||
* to track multiple errors from multiple packages simultaneously. In addition,
|
||||
* it can track errors of many levels, save data along with the error, context
|
||||
* information such as the exact file, line number, class and function that
|
||||
* generated the error, and if necessary, it can raise a traditional PEAR_Error.
|
||||
* It has built-in support for PEAR::Log, to log errors as they occur
|
||||
*
|
||||
* Since version 0.2alpha, it is also possible to selectively ignore errors,
|
||||
* through the use of an error callback, see {@link pushCallback()}
|
||||
*
|
||||
* Since version 0.3alpha, it is possible to specify the exception class
|
||||
* returned from {@link push()}
|
||||
*
|
||||
* Since version PEAR1.3.2, ErrorStack no longer instantiates an exception class. This can
|
||||
* still be done quite handily in an error callback or by manipulating the returned array
|
||||
* @category Debugging
|
||||
* @package PEAR_ErrorStack
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 2004-2008 Greg Beaver
|
||||
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @link http://pear.php.net/package/PEAR_ErrorStack
|
||||
*/
|
||||
|
||||
/**
|
||||
* Singleton storage
|
||||
*
|
||||
* Format:
|
||||
* <pre>
|
||||
* array(
|
||||
* 'package1' => PEAR_ErrorStack object,
|
||||
* 'package2' => PEAR_ErrorStack object,
|
||||
* ...
|
||||
* )
|
||||
* </pre>
|
||||
* @access private
|
||||
* @global array $GLOBALS['_PEAR_ERRORSTACK_SINGLETON']
|
||||
*/
|
||||
$GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] = array();
|
||||
|
||||
/**
|
||||
* Global error callback (default)
|
||||
*
|
||||
* This is only used if set to non-false. * is the default callback for
|
||||
* all packages, whereas specific packages may set a default callback
|
||||
* for all instances, regardless of whether they are a singleton or not.
|
||||
*
|
||||
* To exclude non-singletons, only set the local callback for the singleton
|
||||
* @see PEAR_ErrorStack::setDefaultCallback()
|
||||
* @access private
|
||||
* @global array $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK']
|
||||
*/
|
||||
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK'] = array(
|
||||
'*' => false,
|
||||
);
|
||||
|
||||
/**
|
||||
* Global Log object (default)
|
||||
*
|
||||
* This is only used if set to non-false. Use to set a default log object for
|
||||
* all stacks, regardless of instantiation order or location
|
||||
* @see PEAR_ErrorStack::setDefaultLogger()
|
||||
* @access private
|
||||
* @global array $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER']
|
||||
*/
|
||||
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER'] = false;
|
||||
|
||||
/**
|
||||
* Global Overriding Callback
|
||||
*
|
||||
* This callback will override any error callbacks that specific loggers have set.
|
||||
* Use with EXTREME caution
|
||||
* @see PEAR_ErrorStack::staticPushCallback()
|
||||
* @access private
|
||||
* @global array $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER']
|
||||
*/
|
||||
$GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'] = array();
|
||||
|
||||
/**#@+
|
||||
* One of four possible return values from the error Callback
|
||||
* @see PEAR_ErrorStack::_errorCallback()
|
||||
*/
|
||||
/**
|
||||
* If this is returned, then the error will be both pushed onto the stack
|
||||
* and logged.
|
||||
*/
|
||||
define('PEAR_ERRORSTACK_PUSHANDLOG', 1);
|
||||
/**
|
||||
* If this is returned, then the error will only be pushed onto the stack,
|
||||
* and not logged.
|
||||
*/
|
||||
define('PEAR_ERRORSTACK_PUSH', 2);
|
||||
/**
|
||||
* If this is returned, then the error will only be logged, but not pushed
|
||||
* onto the error stack.
|
||||
*/
|
||||
define('PEAR_ERRORSTACK_LOG', 3);
|
||||
/**
|
||||
* If this is returned, then the error is completely ignored.
|
||||
*/
|
||||
define('PEAR_ERRORSTACK_IGNORE', 4);
|
||||
/**
|
||||
* If this is returned, then the error is logged and die() is called.
|
||||
*/
|
||||
define('PEAR_ERRORSTACK_DIE', 5);
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* Error code for an attempt to instantiate a non-class as a PEAR_ErrorStack in
|
||||
* the singleton method.
|
||||
*/
|
||||
define('PEAR_ERRORSTACK_ERR_NONCLASS', 1);
|
||||
|
||||
/**
|
||||
* Error code for an attempt to pass an object into {@link PEAR_ErrorStack::getMessage()}
|
||||
* that has no __toString() method
|
||||
*/
|
||||
define('PEAR_ERRORSTACK_ERR_OBJTOSTRING', 2);
|
||||
/**
|
||||
* Error Stack Implementation
|
||||
*
|
||||
* Usage:
|
||||
* <code>
|
||||
* // global error stack
|
||||
* $global_stack = &PEAR_ErrorStack::singleton('MyPackage');
|
||||
* // local error stack
|
||||
* $local_stack = new PEAR_ErrorStack('MyPackage');
|
||||
* </code>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @version @package_version@
|
||||
* @package PEAR_ErrorStack
|
||||
* @category Debugging
|
||||
* @copyright 2004-2008 Greg Beaver
|
||||
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @link http://pear.php.net/package/PEAR_ErrorStack
|
||||
*/
|
||||
class PEAR_ErrorStack {
|
||||
/**
|
||||
* Errors are stored in the order that they are pushed on the stack.
|
||||
* @since 0.4alpha Errors are no longer organized by error level.
|
||||
* This renders pop() nearly unusable, and levels could be more easily
|
||||
* handled in a callback anyway
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_errors = array();
|
||||
|
||||
/**
|
||||
* Storage of errors by level.
|
||||
*
|
||||
* Allows easy retrieval and deletion of only errors from a particular level
|
||||
* @since PEAR 1.4.0dev
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_errorsByLevel = array();
|
||||
|
||||
/**
|
||||
* Package name this error stack represents
|
||||
* @var string
|
||||
* @access protected
|
||||
*/
|
||||
var $_package;
|
||||
|
||||
/**
|
||||
* Determines whether a PEAR_Error is thrown upon every error addition
|
||||
* @var boolean
|
||||
* @access private
|
||||
*/
|
||||
var $_compat = false;
|
||||
|
||||
/**
|
||||
* If set to a valid callback, this will be used to generate the error
|
||||
* message from the error code, otherwise the message passed in will be
|
||||
* used
|
||||
* @var false|string|array
|
||||
* @access private
|
||||
*/
|
||||
var $_msgCallback = false;
|
||||
|
||||
/**
|
||||
* If set to a valid callback, this will be used to generate the error
|
||||
* context for an error. For PHP-related errors, this will be a file
|
||||
* and line number as retrieved from debug_backtrace(), but can be
|
||||
* customized for other purposes. The error might actually be in a separate
|
||||
* configuration file, or in a database query.
|
||||
* @var false|string|array
|
||||
* @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 __construct($package, $msgCallback = false, $contextCallback = false,
|
||||
$throwPEAR_Error = false)
|
||||
{
|
||||
$this->_package = $package;
|
||||
$this->setMessageCallback($msgCallback);
|
||||
$this->setContextCallback($contextCallback);
|
||||
$this->_compat = $throwPEAR_Error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a single error stack for this package.
|
||||
*
|
||||
* Note that all parameters are ignored if the stack for package $package
|
||||
* has already been instantiated
|
||||
* @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
|
||||
* @param string $stackClass class to instantiate
|
||||
*
|
||||
* @return 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];
|
||||
}
|
||||
if (!class_exists($stackClass)) {
|
||||
if (function_exists('debug_backtrace')) {
|
||||
$trace = debug_backtrace();
|
||||
}
|
||||
PEAR_ErrorStack::staticPush('PEAR_ErrorStack', PEAR_ERRORSTACK_ERR_NONCLASS,
|
||||
'exception', array('stackclass' => $stackClass),
|
||||
'stack class "%stackclass%" is not a valid class name (should be like PEAR_ErrorStack)',
|
||||
false, $trace);
|
||||
}
|
||||
$GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package] =
|
||||
new $stackClass($package, $msgCallback, $contextCallback, $throwPEAR_Error);
|
||||
|
||||
return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package];
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal error handler for PEAR_ErrorStack class
|
||||
*
|
||||
* Dies if the error is an exception (and would have died anyway)
|
||||
* @access private
|
||||
*/
|
||||
function _handleError($err)
|
||||
{
|
||||
if ($err['level'] == 'exception') {
|
||||
$message = $err['message'];
|
||||
if (isset($_SERVER['REQUEST_URI'])) {
|
||||
echo '<br />';
|
||||
} else {
|
||||
echo "\n";
|
||||
}
|
||||
var_dump($err['context']);
|
||||
die($message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up a PEAR::Log object for all error stacks that don't have one
|
||||
* @param Log $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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up a PEAR::Log object for this error stack
|
||||
* @param Log $log
|
||||
*/
|
||||
function setLogger(&$log)
|
||||
{
|
||||
if (is_object($log) && method_exists($log, 'log') ) {
|
||||
$this->_logger = &$log;
|
||||
} elseif (is_callable($log)) {
|
||||
$this->_logger = &$log;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an error code => error message mapping callback
|
||||
*
|
||||
* This method sets the callback that can be used to generate error
|
||||
* messages for any instance
|
||||
* @param array|string Callback function/method
|
||||
*/
|
||||
function setMessageCallback($msgCallback)
|
||||
{
|
||||
if (!$msgCallback) {
|
||||
$this->_msgCallback = array(&$this, 'getErrorMessage');
|
||||
} else {
|
||||
if (is_callable($msgCallback)) {
|
||||
$this->_msgCallback = $msgCallback;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an error code => error message mapping callback
|
||||
*
|
||||
* This method returns the current callback that can be used to generate error
|
||||
* messages
|
||||
* @return array|string|false Callback function/method or false if none
|
||||
*/
|
||||
function getMessageCallback()
|
||||
{
|
||||
return $this->_msgCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a default callback to be used by all error stacks
|
||||
*
|
||||
* This method sets the callback that can be used to generate error
|
||||
* messages for a singleton
|
||||
* @param array|string Callback function/method
|
||||
* @param string Package name, or false for all packages
|
||||
*/
|
||||
public static function setDefaultCallback($callback = false, $package = false)
|
||||
{
|
||||
if (!is_callable($callback)) {
|
||||
$callback = false;
|
||||
}
|
||||
$package = $package ? $package : '*';
|
||||
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK'][$package] = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback that generates context information (location of error) for an error stack
|
||||
*
|
||||
* This method sets the callback that can be used to generate context
|
||||
* information for an error. Passing in NULL will disable context generation
|
||||
* and remove the expensive call to debug_backtrace()
|
||||
* @param array|string|null Callback function/method
|
||||
*/
|
||||
function setContextCallback($contextCallback)
|
||||
{
|
||||
if ($contextCallback === null) {
|
||||
return $this->_contextCallback = false;
|
||||
}
|
||||
if (!$contextCallback) {
|
||||
$this->_contextCallback = array(&$this, 'getFileLine');
|
||||
} else {
|
||||
if (is_callable($contextCallback)) {
|
||||
$this->_contextCallback = $contextCallback;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an error Callback
|
||||
* 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 of the ERRORSTACK_* constants.
|
||||
*
|
||||
* This functionality can be used to emulate PEAR's pushErrorHandling, and
|
||||
* the PEAR_ERROR_CALLBACK mode, without affecting the integrity of
|
||||
* the error stack or logging
|
||||
* @see PEAR_ERRORSTACK_PUSHANDLOG, PEAR_ERRORSTACK_PUSH, PEAR_ERRORSTACK_LOG
|
||||
* @see popCallback()
|
||||
* @param string|array $cb
|
||||
*/
|
||||
function pushCallback($cb)
|
||||
{
|
||||
array_push($this->_errorCallback, $cb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a callback from the error callback stack
|
||||
* @see pushCallback()
|
||||
* @return array|string|false
|
||||
*/
|
||||
function popCallback()
|
||||
{
|
||||
if (!count($this->_errorCallback)) {
|
||||
return false;
|
||||
}
|
||||
return array_pop($this->_errorCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a temporary overriding error callback for every package error stack
|
||||
*
|
||||
* Use this to temporarily disable all existing callbacks (can be used
|
||||
* to emulate the @ operator, for instance)
|
||||
* @see PEAR_ERRORSTACK_PUSHANDLOG, PEAR_ERRORSTACK_PUSH, PEAR_ERRORSTACK_LOG
|
||||
* @see staticPopCallback(), pushCallback()
|
||||
* @param string|array $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
|
||||
*/
|
||||
public static function staticPopCallback()
|
||||
{
|
||||
$ret = array_pop($GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK']);
|
||||
if (!is_array($GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'])) {
|
||||
$GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'] = array();
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an error to the stack
|
||||
*
|
||||
* If the message generator exists, it is called with 2 parameters.
|
||||
* - the current Error Stack object
|
||||
* - an array that is in the same format as an error. Available indices
|
||||
* are 'code', 'package', 'time', 'params', 'level', and 'context'
|
||||
*
|
||||
* Next, if the error should contain context information, this is
|
||||
* handled by the context grabbing method.
|
||||
* Finally, the error is pushed onto the proper error stack
|
||||
* @param int $code Package-specific error code
|
||||
* @param string $level Error level. This is NOT spell-checked
|
||||
* @param array $params associative array of error parameters
|
||||
* @param string $msg Error message, or a portion of it if the message
|
||||
* is to be generated
|
||||
* @param array $repackage If this error re-packages an error pushed by
|
||||
* another package, place the array returned from
|
||||
* {@link pop()} in this parameter
|
||||
* @param array $backtrace Protected parameter: use this to pass in the
|
||||
* {@link debug_backtrace()} that should be used
|
||||
* to find error context
|
||||
* @return PEAR_Error|array if compatibility mode is on, a PEAR_Error is also
|
||||
* thrown. If a PEAR_Error is returned, the userinfo
|
||||
* property is set to the following array:
|
||||
*
|
||||
* <code>
|
||||
* array(
|
||||
* 'code' => $code,
|
||||
* 'params' => $params,
|
||||
* 'package' => $this->_package,
|
||||
* 'level' => $level,
|
||||
* 'time' => time(),
|
||||
* 'context' => $context,
|
||||
* 'message' => $msg,
|
||||
* //['repackage' => $err] repackaged error array/Exception class
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
* Normally, the previous array is returned.
|
||||
*/
|
||||
function push($code, $level = 'error', $params = array(), $msg = false,
|
||||
$repackage = false, $backtrace = false)
|
||||
{
|
||||
$context = false;
|
||||
// grab error context
|
||||
if ($this->_contextCallback) {
|
||||
if (!$backtrace) {
|
||||
$backtrace = debug_backtrace();
|
||||
}
|
||||
$context = call_user_func($this->_contextCallback, $code, $params, $backtrace);
|
||||
}
|
||||
|
||||
// save error
|
||||
$time = explode(' ', microtime());
|
||||
$time = $time[1] + $time[0];
|
||||
$err = array(
|
||||
'code' => $code,
|
||||
'params' => $params,
|
||||
'package' => $this->_package,
|
||||
'level' => $level,
|
||||
'time' => $time,
|
||||
'context' => $context,
|
||||
'message' => $msg,
|
||||
);
|
||||
|
||||
if ($repackage) {
|
||||
$err['repackage'] = $repackage;
|
||||
}
|
||||
|
||||
// set up the error message, if necessary
|
||||
if ($this->_msgCallback) {
|
||||
$msg = call_user_func_array($this->_msgCallback,
|
||||
array(&$this, $err));
|
||||
$err['message'] = $msg;
|
||||
}
|
||||
$push = $log = true;
|
||||
$die = false;
|
||||
// try the overriding callback first
|
||||
$callback = $this->staticPopCallback();
|
||||
if ($callback) {
|
||||
$this->staticPushCallback($callback);
|
||||
}
|
||||
if (!is_callable($callback)) {
|
||||
// try the local callback next
|
||||
$callback = $this->popCallback();
|
||||
if (is_callable($callback)) {
|
||||
$this->pushCallback($callback);
|
||||
} else {
|
||||
// try the default callback
|
||||
$callback = isset($GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK'][$this->_package]) ?
|
||||
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK'][$this->_package] :
|
||||
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK']['*'];
|
||||
}
|
||||
}
|
||||
if (is_callable($callback)) {
|
||||
switch(call_user_func($callback, $err)){
|
||||
case PEAR_ERRORSTACK_IGNORE:
|
||||
return $err;
|
||||
break;
|
||||
case PEAR_ERRORSTACK_PUSH:
|
||||
$log = false;
|
||||
break;
|
||||
case PEAR_ERRORSTACK_LOG:
|
||||
$push = false;
|
||||
break;
|
||||
case PEAR_ERRORSTACK_DIE:
|
||||
$die = true;
|
||||
break;
|
||||
// anything else returned has the same effect as pushandlog
|
||||
}
|
||||
}
|
||||
if ($push) {
|
||||
array_unshift($this->_errors, $err);
|
||||
if (!isset($this->_errorsByLevel[$err['level']])) {
|
||||
$this->_errorsByLevel[$err['level']] = array();
|
||||
}
|
||||
$this->_errorsByLevel[$err['level']][] = &$this->_errors[0];
|
||||
}
|
||||
if ($log) {
|
||||
if ($this->_logger || $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER']) {
|
||||
$this->_log($err);
|
||||
}
|
||||
}
|
||||
if ($die) {
|
||||
die();
|
||||
}
|
||||
if ($this->_compat && $push) {
|
||||
return $this->raiseError($msg, $code, null, null, $err);
|
||||
}
|
||||
return $err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static version of {@link push()}
|
||||
*
|
||||
* @param string $package Package name this error belongs to
|
||||
* @param int $code Package-specific error code
|
||||
* @param string $level Error level. This is NOT spell-checked
|
||||
* @param array $params associative array of error parameters
|
||||
* @param string $msg Error message, or a portion of it if the message
|
||||
* is to be generated
|
||||
* @param array $repackage If this error re-packages an error pushed by
|
||||
* another package, place the array returned from
|
||||
* {@link pop()} in this parameter
|
||||
* @param array $backtrace Protected parameter: use this to pass in the
|
||||
* {@link debug_backtrace()} that should be used
|
||||
* to find error context
|
||||
* @return PEAR_Error|array if compatibility mode is on, a PEAR_Error is also
|
||||
* thrown. see docs for {@link push()}
|
||||
*/
|
||||
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) {
|
||||
if (function_exists('debug_backtrace')) {
|
||||
$backtrace = debug_backtrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $s->push($code, $level, $params, $msg, $repackage, $backtrace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an error using PEAR::Log
|
||||
* @param array $err Error array
|
||||
* @param array $levels Error level => Log constant map
|
||||
* @access protected
|
||||
*/
|
||||
function _log($err)
|
||||
{
|
||||
if ($this->_logger) {
|
||||
$logger = &$this->_logger;
|
||||
} else {
|
||||
$logger = &$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER'];
|
||||
}
|
||||
if (is_a($logger, 'Log')) {
|
||||
$levels = array(
|
||||
'exception' => PEAR_LOG_CRIT,
|
||||
'alert' => PEAR_LOG_ALERT,
|
||||
'critical' => PEAR_LOG_CRIT,
|
||||
'error' => PEAR_LOG_ERR,
|
||||
'warning' => PEAR_LOG_WARNING,
|
||||
'notice' => PEAR_LOG_NOTICE,
|
||||
'info' => PEAR_LOG_INFO,
|
||||
'debug' => PEAR_LOG_DEBUG);
|
||||
if (isset($levels[$err['level']])) {
|
||||
$level = $levels[$err['level']];
|
||||
} else {
|
||||
$level = PEAR_LOG_INFO;
|
||||
}
|
||||
$logger->log($err['message'], $level, $err);
|
||||
} else { // support non-standard logs
|
||||
call_user_func($logger, $err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pop an error off of the error stack
|
||||
*
|
||||
* @return false|array
|
||||
* @since 0.4alpha it is no longer possible to specify a specific error
|
||||
* level to return - the last error pushed will be returned, instead
|
||||
*/
|
||||
function pop()
|
||||
{
|
||||
$err = @array_shift($this->_errors);
|
||||
if (!is_null($err)) {
|
||||
@array_pop($this->_errorsByLevel[$err['level']]);
|
||||
if (!count($this->_errorsByLevel[$err['level']])) {
|
||||
unset($this->_errorsByLevel[$err['level']]);
|
||||
}
|
||||
}
|
||||
return $err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop an error off of the error stack, static method
|
||||
*
|
||||
* @param string package name
|
||||
* @return boolean
|
||||
* @since PEAR1.5.0a1
|
||||
*/
|
||||
function staticPop($package)
|
||||
{
|
||||
if ($package) {
|
||||
if (!isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) {
|
||||
return false;
|
||||
}
|
||||
return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]->pop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether there are any errors on the stack
|
||||
* @param string|array Level name. Use to determine if any errors
|
||||
* of level (string), or levels (array) have been pushed
|
||||
* @return boolean
|
||||
*/
|
||||
function hasErrors($level = false)
|
||||
{
|
||||
if ($level) {
|
||||
return isset($this->_errorsByLevel[$level]);
|
||||
}
|
||||
return count($this->_errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all errors since last purge
|
||||
*
|
||||
* @param boolean set in order to empty the error stack
|
||||
* @param string level name, to return only errors of a particular severity
|
||||
* @return array
|
||||
*/
|
||||
function getErrors($purge = false, $level = false)
|
||||
{
|
||||
if (!$purge) {
|
||||
if ($level) {
|
||||
if (!isset($this->_errorsByLevel[$level])) {
|
||||
return array();
|
||||
} else {
|
||||
return $this->_errorsByLevel[$level];
|
||||
}
|
||||
} else {
|
||||
return $this->_errors;
|
||||
}
|
||||
}
|
||||
if ($level) {
|
||||
$ret = $this->_errorsByLevel[$level];
|
||||
foreach ($this->_errorsByLevel[$level] as $i => $unused) {
|
||||
// entries are references to the $_errors array
|
||||
$this->_errorsByLevel[$level][$i] = false;
|
||||
}
|
||||
// array_filter removes all entries === false
|
||||
$this->_errors = array_filter($this->_errors);
|
||||
unset($this->_errorsByLevel[$level]);
|
||||
return $ret;
|
||||
}
|
||||
$ret = $this->_errors;
|
||||
$this->_errors = array();
|
||||
$this->_errorsByLevel = array();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether there are any errors on a single error stack, or on any error stack
|
||||
*
|
||||
* The optional parameter can be used to test the existence of any errors without the need of
|
||||
* singleton instantiation
|
||||
* @param string|false Package name to check for errors
|
||||
* @param string Level name to check for a particular severity
|
||||
* @return boolean
|
||||
*/
|
||||
public static function staticHasErrors($package = false, $level = false)
|
||||
{
|
||||
if ($package) {
|
||||
if (!isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) {
|
||||
return false;
|
||||
}
|
||||
return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]->hasErrors($level);
|
||||
}
|
||||
foreach ($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] as $package => $obj) {
|
||||
if ($obj->hasErrors($level)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all errors since last purge, organized by package
|
||||
* @since PEAR 1.4.0dev BC break! $level is now in the place $merge used to be
|
||||
* @param boolean $purge Set to purge the error stack of existing errors
|
||||
* @param string $level Set to a level name in order to retrieve only errors of a particular level
|
||||
* @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
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
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');
|
||||
}
|
||||
foreach ($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] as $package => $obj) {
|
||||
$test = $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]->getErrors($purge, $level);
|
||||
if ($test) {
|
||||
if ($merge) {
|
||||
$ret = array_merge($ret, $test);
|
||||
} else {
|
||||
$ret[$package] = $test;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($merge) {
|
||||
usort($ret, $sortfunc);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error sorting function, sorts by time
|
||||
* @access private
|
||||
*/
|
||||
public static function _sortErrors($a, $b)
|
||||
{
|
||||
if ($a['time'] == $b['time']) {
|
||||
return 0;
|
||||
}
|
||||
if ($a['time'] < $b['time']) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard file/line number/function/class context callback
|
||||
*
|
||||
* This function uses a backtrace generated from {@link debug_backtrace()}
|
||||
* and so will not work at all in PHP < 4.3.0. The frame should
|
||||
* reference the frame that contains the source of the error.
|
||||
* @return array|false either array('file' => file, 'line' => line,
|
||||
* 'function' => function name, 'class' => class name) or
|
||||
* if this doesn't work, then false
|
||||
* @param unused
|
||||
* @param integer backtrace frame.
|
||||
* @param array Results of debug_backtrace()
|
||||
*/
|
||||
public static function getFileLine($code, $params, $backtrace = null)
|
||||
{
|
||||
if ($backtrace === null) {
|
||||
return false;
|
||||
}
|
||||
$frame = 0;
|
||||
$functionframe = 1;
|
||||
if (!isset($backtrace[1])) {
|
||||
$functionframe = 0;
|
||||
} else {
|
||||
while (isset($backtrace[$functionframe]['function']) &&
|
||||
$backtrace[$functionframe]['function'] == 'eval' &&
|
||||
isset($backtrace[$functionframe + 1])) {
|
||||
$functionframe++;
|
||||
}
|
||||
}
|
||||
if (isset($backtrace[$frame])) {
|
||||
if (!isset($backtrace[$frame]['file'])) {
|
||||
$frame++;
|
||||
}
|
||||
$funcbacktrace = $backtrace[$functionframe];
|
||||
$filebacktrace = $backtrace[$frame];
|
||||
$ret = array('file' => $filebacktrace['file'],
|
||||
'line' => $filebacktrace['line']);
|
||||
// rearrange for eval'd code or create function errors
|
||||
if (strpos($filebacktrace['file'], '(') &&
|
||||
preg_match(';^(.*?)\((\d+)\) : (.*?)\\z;', $filebacktrace['file'],
|
||||
$matches)) {
|
||||
$ret['file'] = $matches[1];
|
||||
$ret['line'] = $matches[2] + 0;
|
||||
}
|
||||
if (isset($funcbacktrace['function']) && isset($backtrace[1])) {
|
||||
if ($funcbacktrace['function'] != 'eval') {
|
||||
if ($funcbacktrace['function'] == '__lambda_func') {
|
||||
$ret['function'] = 'create_function() code';
|
||||
} else {
|
||||
$ret['function'] = $funcbacktrace['function'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($funcbacktrace['class']) && isset($backtrace[1])) {
|
||||
$ret['class'] = $funcbacktrace['class'];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard error message generation callback
|
||||
*
|
||||
* This method may also be called by a custom error message generator
|
||||
* to fill in template values from the params array, simply
|
||||
* set the third parameter to the error message template string to use
|
||||
*
|
||||
* The special variable %__msg% is reserved: use it only to specify
|
||||
* where a message passed in by the user should be placed in the template,
|
||||
* like so:
|
||||
*
|
||||
* Error message: %msg% - internal error
|
||||
*
|
||||
* If the message passed like so:
|
||||
*
|
||||
* <code>
|
||||
* $stack->push(ERROR_CODE, 'error', array(), 'server error 500');
|
||||
* </code>
|
||||
*
|
||||
* The returned error message will be "Error message: server error 500 -
|
||||
* internal error"
|
||||
* @param PEAR_ErrorStack
|
||||
* @param array
|
||||
* @param string|false Pre-generated error message template
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getErrorMessage(&$stack, $err, $template = false)
|
||||
{
|
||||
if ($template) {
|
||||
$mainmsg = $template;
|
||||
} else {
|
||||
$mainmsg = $stack->getErrorMessageTemplate($err['code']);
|
||||
}
|
||||
$mainmsg = str_replace('%__msg%', $err['message'], $mainmsg);
|
||||
if (is_array($err['params']) && count($err['params'])) {
|
||||
foreach ($err['params'] as $name => $val) {
|
||||
if (is_array($val)) {
|
||||
// @ is needed in case $val is a multi-dimensional array
|
||||
$val = @implode(', ', $val);
|
||||
}
|
||||
if (is_object($val)) {
|
||||
if (method_exists($val, '__toString')) {
|
||||
$val = $val->__toString();
|
||||
} else {
|
||||
PEAR_ErrorStack::staticPush('PEAR_ErrorStack', PEAR_ERRORSTACK_ERR_OBJTOSTRING,
|
||||
'warning', array('obj' => get_class($val)),
|
||||
'object %obj% passed into getErrorMessage, but has no __toString() method');
|
||||
$val = 'Object';
|
||||
}
|
||||
}
|
||||
$mainmsg = str_replace('%' . $name . '%', $val, $mainmsg);
|
||||
}
|
||||
}
|
||||
return $mainmsg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard Error Message Template generator from code
|
||||
* @return string
|
||||
*/
|
||||
function getErrorMessageTemplate($code)
|
||||
{
|
||||
if (!isset($this->_errorMsgs[$code])) {
|
||||
return '%__msg%';
|
||||
}
|
||||
return $this->_errorMsgs[$code];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Error Message Template array
|
||||
*
|
||||
* The array format must be:
|
||||
* <pre>
|
||||
* array(error code => 'message template',...)
|
||||
* </pre>
|
||||
*
|
||||
* Error message parameters passed into {@link push()} will be used as input
|
||||
* for the error message. If the template is 'message %foo% was %bar%', and the
|
||||
* parameters are array('foo' => 'one', 'bar' => 'six'), the error message returned will
|
||||
* be 'message one was six'
|
||||
* @return string
|
||||
*/
|
||||
function setErrorMessageTemplate($template)
|
||||
{
|
||||
$this->_errorMsgs = $template;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* emulate PEAR::raiseError()
|
||||
*
|
||||
* @return PEAR_Error
|
||||
*/
|
||||
function raiseError()
|
||||
{
|
||||
require_once 'PEAR.php';
|
||||
$args = func_get_args();
|
||||
return call_user_func_array(array('PEAR', 'raiseError'), $args);
|
||||
}
|
||||
}
|
||||
$stack = &PEAR_ErrorStack::singleton('PEAR_ErrorStack');
|
||||
$stack->pushCallback(array('PEAR_ErrorStack', '_handleError'));
|
||||
?>
|
||||
622
lib/composer/vendor/pear/pear-core-minimal/src/System.php
vendored
Normal file
622
lib/composer/vendor/pear/pear-core-minimal/src/System.php
vendored
Normal file
@@ -0,0 +1,622 @@
|
||||
<?php
|
||||
/**
|
||||
* File/Directory manipulation
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* @category pear
|
||||
* @package System
|
||||
* @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
|
||||
* @since File available since Release 0.1
|
||||
*/
|
||||
|
||||
/**
|
||||
* base class
|
||||
*/
|
||||
require_once 'PEAR.php';
|
||||
require_once 'Console/Getopt.php';
|
||||
|
||||
$GLOBALS['_System_temp_files'] = array();
|
||||
|
||||
/**
|
||||
* System offers cross platform compatible system functions
|
||||
*
|
||||
* Static functions for different operations. Should work under
|
||||
* Unix and Windows. The names and usage has been taken from its respectively
|
||||
* GNU commands. The functions will return (bool) false on error and will
|
||||
* trigger the error with the PHP trigger_error() function (you can silence
|
||||
* the error by prefixing a '@' sign after the function call, but this
|
||||
* is not recommended practice. Instead use an error handler with
|
||||
* {@link set_error_handler()}).
|
||||
*
|
||||
* Documentation on this class you can find in:
|
||||
* http://pear.php.net/manual/
|
||||
*
|
||||
* Example usage:
|
||||
* if (!@System::rm('-r file1 dir1')) {
|
||||
* print "could not delete file1 or dir1";
|
||||
* }
|
||||
*
|
||||
* In case you need to to pass file names with spaces,
|
||||
* pass the params as an array:
|
||||
*
|
||||
* System::rm(array('-r', $file1, $dir1));
|
||||
*
|
||||
* @category pear
|
||||
* @package System
|
||||
* @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: @package_version@
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 0.1
|
||||
* @static
|
||||
*/
|
||||
class System
|
||||
{
|
||||
/**
|
||||
* returns the commandline arguments of a function
|
||||
*
|
||||
* @param string $argv the commandline
|
||||
* @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
|
||||
*/
|
||||
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];
|
||||
foreach ($av[2] as $k => $a) {
|
||||
if (empty($a)) {
|
||||
continue;
|
||||
}
|
||||
$argv[$k] = trim($a) ;
|
||||
}
|
||||
}
|
||||
|
||||
return Console_Getopt::getopt2($argv, $short_options, $long_options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output errors with PHP trigger_error(). You can silence the errors
|
||||
* with prefixing a "@" sign to the function call: @System::mkdir(..);
|
||||
*
|
||||
* @param mixed $error a PEAR error or a string with the error message
|
||||
* @return bool false
|
||||
*/
|
||||
protected static function raiseError($error)
|
||||
{
|
||||
if (PEAR::isError($error)) {
|
||||
$error = $error->getMessage();
|
||||
}
|
||||
trigger_error($error, E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a nested array representing the structure of a directory
|
||||
*
|
||||
* System::_dirToStruct('dir1', 0) =>
|
||||
* Array
|
||||
* (
|
||||
* [dirs] => Array
|
||||
* (
|
||||
* [0] => dir1
|
||||
* )
|
||||
*
|
||||
* [files] => Array
|
||||
* (
|
||||
* [0] => dir1/file2
|
||||
* [1] => dir1/file3
|
||||
* )
|
||||
* )
|
||||
* @param string $sPath Name of the directory
|
||||
* @param integer $maxinst max. deep of the lookup
|
||||
* @param integer $aktinst starting deep of the lookup
|
||||
* @param bool $silent if true, do not emit errors.
|
||||
* @return array the structure of the dir
|
||||
*/
|
||||
protected static function _dirToStruct($sPath, $maxinst, $aktinst = 0, $silent = false)
|
||||
{
|
||||
$struct = array('dirs' => array(), 'files' => array());
|
||||
if (($dir = @opendir($sPath)) === false) {
|
||||
if (!$silent) {
|
||||
System::raiseError("Could not open dir $sPath");
|
||||
}
|
||||
return $struct; // XXX could not open error
|
||||
}
|
||||
|
||||
$struct['dirs'][] = $sPath = realpath($sPath); // XXX don't add if '.' or '..' ?
|
||||
$list = array();
|
||||
while (false !== ($file = readdir($dir))) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
$list[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
closedir($dir);
|
||||
natsort($list);
|
||||
if ($aktinst < $maxinst || $maxinst == 0) {
|
||||
foreach ($list as $val) {
|
||||
$path = $sPath . DIRECTORY_SEPARATOR . $val;
|
||||
if (is_dir($path) && !is_link($path)) {
|
||||
$tmp = System::_dirToStruct($path, $maxinst, $aktinst+1, $silent);
|
||||
$struct = array_merge_recursive($struct, $tmp);
|
||||
} else {
|
||||
$struct['files'][] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $struct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a nested array representing the structure of a directory and files
|
||||
*
|
||||
* @param array $files Array listing files and dirs
|
||||
* @return array
|
||||
* @static
|
||||
* @see System::_dirToStruct()
|
||||
*/
|
||||
protected static function _multipleToStruct($files)
|
||||
{
|
||||
$struct = array('dirs' => array(), 'files' => array());
|
||||
settype($files, 'array');
|
||||
foreach ($files as $file) {
|
||||
if (is_dir($file) && !is_link($file)) {
|
||||
$tmp = System::_dirToStruct($file, 0);
|
||||
$struct = array_merge_recursive($tmp, $struct);
|
||||
} else {
|
||||
if (!in_array($file, $struct['files'])) {
|
||||
$struct['files'][] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $struct;
|
||||
}
|
||||
|
||||
/**
|
||||
* The rm command for removing files.
|
||||
* Supports multiple files and dirs and also recursive deletes
|
||||
*
|
||||
* @param string $args the arguments for rm
|
||||
* @return mixed PEAR_Error or true for success
|
||||
* @static
|
||||
* @access public
|
||||
*/
|
||||
public static function rm($args)
|
||||
{
|
||||
$opts = System::_parseArgs($args, 'rf'); // "f" does nothing but I like it :-)
|
||||
if (PEAR::isError($opts)) {
|
||||
return System::raiseError($opts);
|
||||
}
|
||||
foreach ($opts[0] as $opt) {
|
||||
if ($opt[0] == 'r') {
|
||||
$do_recursive = true;
|
||||
}
|
||||
}
|
||||
$ret = true;
|
||||
if (isset($do_recursive)) {
|
||||
$struct = System::_multipleToStruct($opts[1]);
|
||||
foreach ($struct['files'] as $file) {
|
||||
if (!@unlink($file)) {
|
||||
$ret = false;
|
||||
}
|
||||
}
|
||||
|
||||
rsort($struct['dirs']);
|
||||
foreach ($struct['dirs'] as $dir) {
|
||||
if (!@rmdir($dir)) {
|
||||
$ret = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($opts[1] as $file) {
|
||||
$delete = (is_dir($file)) ? 'rmdir' : 'unlink';
|
||||
if (!@$delete($file)) {
|
||||
$ret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make directories.
|
||||
*
|
||||
* The -p option will create parent directories
|
||||
* @param string $args the name of the director(y|ies) to create
|
||||
* @return bool True for success
|
||||
*/
|
||||
public static function mkDir($args)
|
||||
{
|
||||
$opts = System::_parseArgs($args, 'pm:');
|
||||
if (PEAR::isError($opts)) {
|
||||
return System::raiseError($opts);
|
||||
}
|
||||
|
||||
$mode = 0777; // default mode
|
||||
foreach ($opts[0] as $opt) {
|
||||
if ($opt[0] == 'p') {
|
||||
$create_parents = true;
|
||||
} elseif ($opt[0] == 'm') {
|
||||
// if the mode is clearly an octal number (starts with 0)
|
||||
// convert it to decimal
|
||||
if (strlen($opt[1]) && $opt[1]{0} == '0') {
|
||||
$opt[1] = octdec($opt[1]);
|
||||
} else {
|
||||
// convert to int
|
||||
$opt[1] += 0;
|
||||
}
|
||||
$mode = $opt[1];
|
||||
}
|
||||
}
|
||||
|
||||
$ret = true;
|
||||
if (isset($create_parents)) {
|
||||
foreach ($opts[1] as $dir) {
|
||||
$dirstack = array();
|
||||
while ((!file_exists($dir) || !is_dir($dir)) &&
|
||||
$dir != DIRECTORY_SEPARATOR) {
|
||||
array_unshift($dirstack, $dir);
|
||||
$dir = dirname($dir);
|
||||
}
|
||||
|
||||
while ($newdir = array_shift($dirstack)) {
|
||||
if (!is_writeable(dirname($newdir))) {
|
||||
$ret = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!mkdir($newdir, $mode)) {
|
||||
$ret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach($opts[1] as $dir) {
|
||||
if ((@file_exists($dir) || !is_dir($dir)) && !mkdir($dir, $mode)) {
|
||||
$ret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Concatenate files
|
||||
*
|
||||
* Usage:
|
||||
* 1) $var = System::cat('sample.txt test.txt');
|
||||
* 2) System::cat('sample.txt test.txt > final.txt');
|
||||
* 3) System::cat('sample.txt test.txt >> final.txt');
|
||||
*
|
||||
* Note: as the class use fopen, urls should work also (test that)
|
||||
*
|
||||
* @param string $args the arguments
|
||||
* @return boolean true on success
|
||||
*/
|
||||
public static function &cat($args)
|
||||
{
|
||||
$ret = null;
|
||||
$files = array();
|
||||
if (!is_array($args)) {
|
||||
$args = preg_split('/\s+/', $args, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
|
||||
$count_args = count($args);
|
||||
for ($i = 0; $i < $count_args; $i++) {
|
||||
if ($args[$i] == '>') {
|
||||
$mode = 'wb';
|
||||
$outputfile = $args[$i+1];
|
||||
break;
|
||||
} elseif ($args[$i] == '>>') {
|
||||
$mode = 'ab+';
|
||||
$outputfile = $args[$i+1];
|
||||
break;
|
||||
} else {
|
||||
$files[] = $args[$i];
|
||||
}
|
||||
}
|
||||
$outputfd = false;
|
||||
if (isset($mode)) {
|
||||
if (!$outputfd = fopen($outputfile, $mode)) {
|
||||
$err = System::raiseError("Could not open $outputfile");
|
||||
return $err;
|
||||
}
|
||||
$ret = true;
|
||||
}
|
||||
foreach ($files as $file) {
|
||||
if (!$fd = fopen($file, 'r')) {
|
||||
System::raiseError("Could not open $file");
|
||||
continue;
|
||||
}
|
||||
while ($cont = fread($fd, 2048)) {
|
||||
if (is_resource($outputfd)) {
|
||||
fwrite($outputfd, $cont);
|
||||
} else {
|
||||
$ret .= $cont;
|
||||
}
|
||||
}
|
||||
fclose($fd);
|
||||
}
|
||||
if (is_resource($outputfd)) {
|
||||
fclose($outputfd);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates temporary files or directories. This function will remove
|
||||
* the created files when the scripts finish its execution.
|
||||
*
|
||||
* Usage:
|
||||
* 1) $tempfile = System::mktemp("prefix");
|
||||
* 2) $tempdir = System::mktemp("-d prefix");
|
||||
* 3) $tempfile = System::mktemp();
|
||||
* 4) $tempfile = System::mktemp("-t /var/tmp prefix");
|
||||
*
|
||||
* prefix -> The string that will be prepended to the temp name
|
||||
* (defaults to "tmp").
|
||||
* -d -> A temporary dir will be created instead of a file.
|
||||
* -t -> The target dir where the temporary (file|dir) will be created. If
|
||||
* this param is missing by default the env vars TMP on Windows or
|
||||
* TMPDIR in Unix will be used. If these vars are also missing
|
||||
* c:\windows\temp or /tmp will be used.
|
||||
*
|
||||
* @param string $args The arguments
|
||||
* @return mixed the full path of the created (file|dir) or false
|
||||
* @see System::tmpdir()
|
||||
*/
|
||||
public static function mktemp($args = null)
|
||||
{
|
||||
static $first_time = true;
|
||||
$opts = System::_parseArgs($args, 't:d');
|
||||
if (PEAR::isError($opts)) {
|
||||
return System::raiseError($opts);
|
||||
}
|
||||
|
||||
foreach ($opts[0] as $opt) {
|
||||
if ($opt[0] == 'd') {
|
||||
$tmp_is_dir = true;
|
||||
} elseif ($opt[0] == 't') {
|
||||
$tmpdir = $opt[1];
|
||||
}
|
||||
}
|
||||
|
||||
$prefix = (isset($opts[1][0])) ? $opts[1][0] : 'tmp';
|
||||
if (!isset($tmpdir)) {
|
||||
$tmpdir = System::tmpdir();
|
||||
}
|
||||
|
||||
if (!System::mkDir(array('-p', $tmpdir))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$tmp = tempnam($tmpdir, $prefix);
|
||||
if (isset($tmp_is_dir)) {
|
||||
unlink($tmp); // be careful possible race condition here
|
||||
if (!mkdir($tmp, 0700)) {
|
||||
return System::raiseError("Unable to create temporary directory $tmpdir");
|
||||
}
|
||||
}
|
||||
|
||||
$GLOBALS['_System_temp_files'][] = $tmp;
|
||||
if (isset($tmp_is_dir)) {
|
||||
//$GLOBALS['_System_temp_files'][] = dirname($tmp);
|
||||
}
|
||||
|
||||
if ($first_time) {
|
||||
PEAR::registerShutdownFunc(array('System', '_removeTmpFiles'));
|
||||
$first_time = false;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove temporary files created my mkTemp. This function is executed
|
||||
* at script shutdown time
|
||||
*/
|
||||
public static function _removeTmpFiles()
|
||||
{
|
||||
if (count($GLOBALS['_System_temp_files'])) {
|
||||
$delete = $GLOBALS['_System_temp_files'];
|
||||
array_unshift($delete, '-r');
|
||||
System::rm($delete);
|
||||
$GLOBALS['_System_temp_files'] = array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path of the temporal directory set in the system
|
||||
* by looking in its environments variables.
|
||||
* 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
|
||||
*
|
||||
* @return string The temporary directory on the system
|
||||
*/
|
||||
public static function tmpdir()
|
||||
{
|
||||
if (OS_WINDOWS) {
|
||||
if ($var = isset($_ENV['TMP']) ? $_ENV['TMP'] : getenv('TMP')) {
|
||||
return $var;
|
||||
}
|
||||
if ($var = isset($_ENV['TEMP']) ? $_ENV['TEMP'] : getenv('TEMP')) {
|
||||
return $var;
|
||||
}
|
||||
if ($var = isset($_ENV['USERPROFILE']) ? $_ENV['USERPROFILE'] : getenv('USERPROFILE')) {
|
||||
return $var;
|
||||
}
|
||||
if ($var = isset($_ENV['windir']) ? $_ENV['windir'] : getenv('windir')) {
|
||||
return $var;
|
||||
}
|
||||
return getenv('SystemRoot') . '\temp';
|
||||
}
|
||||
if ($var = isset($_ENV['TMPDIR']) ? $_ENV['TMPDIR'] : getenv('TMPDIR')) {
|
||||
return $var;
|
||||
}
|
||||
return realpath('/tmp');
|
||||
}
|
||||
|
||||
/**
|
||||
* The "which" command (show the full path of a command)
|
||||
*
|
||||
* @param string $program The command to search for
|
||||
* @param mixed $fallback Value to return if $program is not found
|
||||
*
|
||||
* @return mixed A string with the full path or false if not found
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
*/
|
||||
public static function which($program, $fallback = false)
|
||||
{
|
||||
// enforce API
|
||||
if (!is_string($program) || '' == $program) {
|
||||
return $fallback;
|
||||
}
|
||||
|
||||
// full path given
|
||||
if (basename($program) != $program) {
|
||||
$path_elements[] = dirname($program);
|
||||
$program = basename($program);
|
||||
} else {
|
||||
$path = getenv('PATH');
|
||||
if (!$path) {
|
||||
$path = getenv('Path'); // some OSes are just stupid enough to do this
|
||||
}
|
||||
|
||||
$path_elements = explode(PATH_SEPARATOR, $path);
|
||||
}
|
||||
|
||||
if (OS_WINDOWS) {
|
||||
$exe_suffixes = getenv('PATHEXT')
|
||||
? explode(PATH_SEPARATOR, getenv('PATHEXT'))
|
||||
: array('.exe','.bat','.cmd','.com');
|
||||
// allow passing a command.exe param
|
||||
if (strpos($program, '.') !== false) {
|
||||
array_unshift($exe_suffixes, '');
|
||||
}
|
||||
} else {
|
||||
$exe_suffixes = array('');
|
||||
}
|
||||
|
||||
foreach ($exe_suffixes as $suff) {
|
||||
foreach ($path_elements as $dir) {
|
||||
$file = $dir . DIRECTORY_SEPARATOR . $program . $suff;
|
||||
if (is_executable($file)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* The "find" command
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* System::find($dir);
|
||||
* System::find("$dir -type d");
|
||||
* System::find("$dir -type f");
|
||||
* System::find("$dir -name *.php");
|
||||
* System::find("$dir -name *.php -name *.htm*");
|
||||
* System::find("$dir -maxdepth 1");
|
||||
*
|
||||
* Params implemented:
|
||||
* $dir -> Start the search at this directory
|
||||
* -type d -> return only directories
|
||||
* -type f -> return only files
|
||||
* -maxdepth <n> -> max depth of recursion
|
||||
* -name <pattern> -> search pattern (bash style). Multiple -name param allowed
|
||||
*
|
||||
* @param mixed Either array or string with the command line
|
||||
* @return array Array of found files
|
||||
*/
|
||||
public static function find($args)
|
||||
{
|
||||
if (!is_array($args)) {
|
||||
$args = preg_split('/\s+/', $args, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
$dir = realpath(array_shift($args));
|
||||
if (!$dir) {
|
||||
return array();
|
||||
}
|
||||
$patterns = array();
|
||||
$depth = 0;
|
||||
$do_files = $do_dirs = true;
|
||||
$args_count = count($args);
|
||||
for ($i = 0; $i < $args_count; $i++) {
|
||||
switch ($args[$i]) {
|
||||
case '-type':
|
||||
if (in_array($args[$i+1], array('d', 'f'))) {
|
||||
if ($args[$i+1] == 'd') {
|
||||
$do_files = false;
|
||||
} else {
|
||||
$do_dirs = false;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
break;
|
||||
case '-name':
|
||||
$name = preg_quote($args[$i+1], '#');
|
||||
// our magic characters ? and * have just been escaped,
|
||||
// so now we change the escaped versions to PCRE operators
|
||||
$name = strtr($name, array('\?' => '.', '\*' => '.*'));
|
||||
$patterns[] = '('.$name.')';
|
||||
$i++;
|
||||
break;
|
||||
case '-maxdepth':
|
||||
$depth = $args[$i+1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$path = System::_dirToStruct($dir, $depth, 0, true);
|
||||
if ($do_files && $do_dirs) {
|
||||
$files = array_merge($path['files'], $path['dirs']);
|
||||
} elseif ($do_dirs) {
|
||||
$files = $path['dirs'];
|
||||
} else {
|
||||
$files = $path['files'];
|
||||
}
|
||||
if (count($patterns)) {
|
||||
$dsq = preg_quote(DIRECTORY_SEPARATOR, '#');
|
||||
$pattern = '#(^|'.$dsq.')'.implode('|', $patterns).'($|'.$dsq.')#';
|
||||
$ret = array();
|
||||
$files_count = count($files);
|
||||
for ($i = 0; $i < $files_count; $i++) {
|
||||
// only search in the part of the file below the current directory
|
||||
$filepart = basename($files[$i]);
|
||||
if (preg_match($pattern, $filepart)) {
|
||||
$ret[] = $files[$i];
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
}
|
||||
6
lib/composer/vendor/pear/pear_exception/.gitignore
vendored
Normal file
6
lib/composer/vendor/pear/pear_exception/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
PEAR_Exception*.tgz
|
||||
|
||||
# composer related
|
||||
composer.lock
|
||||
composer.phar
|
||||
vendor
|
||||
7
lib/composer/vendor/pear/pear_exception/.travis.yml
vendored
Normal file
7
lib/composer/vendor/pear/pear_exception/.travis.yml
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
language: php
|
||||
php:
|
||||
- 5.6
|
||||
- 5.5
|
||||
- 5.4
|
||||
script:
|
||||
- cd tests && phpunit --coverage-text .
|
||||
27
lib/composer/vendor/pear/pear_exception/LICENSE
vendored
Normal file
27
lib/composer/vendor/pear/pear_exception/LICENSE
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
Copyright (c) 1997-2009,
|
||||
Stig Bakken <ssb@php.net>,
|
||||
Gregory Beaver <cellog@php.net>,
|
||||
Helgi Þormar Þorbjörnsson <helgi@php.net>,
|
||||
Tomas V.V.Cox <cox@idecnet.com>,
|
||||
Martin Jansen <mj@php.net>.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
456
lib/composer/vendor/pear/pear_exception/PEAR/Exception.php
vendored
Normal file
456
lib/composer/vendor/pear/pear_exception/PEAR/Exception.php
vendored
Normal file
@@ -0,0 +1,456 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
|
||||
/**
|
||||
* PEAR_Exception
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PEAR
|
||||
* @package PEAR_Exception
|
||||
* @author Tomas V. V. Cox <cox@idecnet.com>
|
||||
* @author Hans Lellelid <hans@velum.net>
|
||||
* @author Bertrand Mansion <bmansion@mamasam.com>
|
||||
* @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_Exception
|
||||
* @since File available since Release 1.0.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Base PEAR_Exception Class
|
||||
*
|
||||
* 1) Features:
|
||||
*
|
||||
* - Nestable exceptions (throw new PEAR_Exception($msg, $prev_exception))
|
||||
* - Definable triggers, shot when exceptions occur
|
||||
* - Pretty and informative error messages
|
||||
* - Added more context info available (like class, method or cause)
|
||||
* - cause can be a PEAR_Exception or an array of mixed
|
||||
* PEAR_Exceptions/PEAR_ErrorStack warnings
|
||||
* - callbacks for specific exception classes and their children
|
||||
*
|
||||
* 2) Ideas:
|
||||
*
|
||||
* - Maybe a way to define a 'template' for the output
|
||||
*
|
||||
* 3) Inherited properties from PHP Exception Class:
|
||||
*
|
||||
* protected $message
|
||||
* protected $code
|
||||
* protected $line
|
||||
* protected $file
|
||||
* private $trace
|
||||
*
|
||||
* 4) Inherited methods from PHP Exception Class:
|
||||
*
|
||||
* __clone
|
||||
* __construct
|
||||
* getMessage
|
||||
* getCode
|
||||
* getFile
|
||||
* getLine
|
||||
* getTraceSafe
|
||||
* getTraceSafeAsString
|
||||
* __toString
|
||||
*
|
||||
* 5) Usage example
|
||||
*
|
||||
* <code>
|
||||
* require_once 'PEAR/Exception.php';
|
||||
*
|
||||
* class Test {
|
||||
* function foo() {
|
||||
* throw new PEAR_Exception('Error Message', ERROR_CODE);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* function myLogger($pear_exception) {
|
||||
* echo $pear_exception->getMessage();
|
||||
* }
|
||||
* // each time a exception is thrown the 'myLogger' will be called
|
||||
* // (its use is completely optional)
|
||||
* PEAR_Exception::addObserver('myLogger');
|
||||
* $test = new Test;
|
||||
* try {
|
||||
* $test->foo();
|
||||
* } catch (PEAR_Exception $e) {
|
||||
* print $e;
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* @category PEAR
|
||||
* @package PEAR_Exception
|
||||
* @author Tomas V.V.Cox <cox@idecnet.com>
|
||||
* @author Hans Lellelid <hans@velum.net>
|
||||
* @author Bertrand Mansion <bmansion@mamasam.com>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2009 The Authors
|
||||
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @version Release: @package_version@
|
||||
* @link http://pear.php.net/package/PEAR_Exception
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PEAR_Exception extends Exception
|
||||
{
|
||||
const OBSERVER_PRINT = -2;
|
||||
const OBSERVER_TRIGGER = -4;
|
||||
const OBSERVER_DIE = -8;
|
||||
protected $cause;
|
||||
private static $_observers = array();
|
||||
private static $_uniqueid = 0;
|
||||
private $_trace;
|
||||
|
||||
/**
|
||||
* Supported signatures:
|
||||
* - PEAR_Exception(string $message);
|
||||
* - PEAR_Exception(string $message, int $code);
|
||||
* - PEAR_Exception(string $message, Exception $cause);
|
||||
* - PEAR_Exception(string $message, Exception $cause, int $code);
|
||||
* - PEAR_Exception(string $message, PEAR_Error $cause);
|
||||
* - PEAR_Exception(string $message, PEAR_Error $cause, int $code);
|
||||
* - PEAR_Exception(string $message, array $causes);
|
||||
* - PEAR_Exception(string $message, array $causes, int $code);
|
||||
*
|
||||
* @param string $message exception message
|
||||
* @param int|Exception|PEAR_Error|array|null $p2 exception cause
|
||||
* @param int|null $p3 exception code or null
|
||||
*/
|
||||
public function __construct($message, $p2 = null, $p3 = null)
|
||||
{
|
||||
if (is_int($p2)) {
|
||||
$code = $p2;
|
||||
$this->cause = null;
|
||||
} elseif (is_object($p2) || is_array($p2)) {
|
||||
// using is_object allows both Exception and PEAR_Error
|
||||
if (is_object($p2) && !($p2 instanceof Exception)) {
|
||||
if (!class_exists('PEAR_Error') || !($p2 instanceof PEAR_Error)) {
|
||||
throw new PEAR_Exception(
|
||||
'exception cause must be Exception, ' .
|
||||
'array, or PEAR_Error'
|
||||
);
|
||||
}
|
||||
}
|
||||
$code = $p3;
|
||||
if (is_array($p2) && isset($p2['message'])) {
|
||||
// fix potential problem of passing in a single warning
|
||||
$p2 = array($p2);
|
||||
}
|
||||
$this->cause = $p2;
|
||||
} else {
|
||||
$code = null;
|
||||
$this->cause = null;
|
||||
}
|
||||
parent::__construct($message, $code);
|
||||
$this->signal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an exception observer
|
||||
*
|
||||
* @param mixed $callback - A valid php callback, see php func is_callable()
|
||||
* - A PEAR_Exception::OBSERVER_* constant
|
||||
* - An array(const PEAR_Exception::OBSERVER_*,
|
||||
* mixed $options)
|
||||
* @param string $label The name of the observer. Use this if you want
|
||||
* to remove it later with removeObserver()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function addObserver($callback, $label = 'default')
|
||||
{
|
||||
self::$_observers[$label] = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an exception observer
|
||||
*
|
||||
* @param string $label Name of the observer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function removeObserver($label = 'default')
|
||||
{
|
||||
unset(self::$_observers[$label]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a unique ID for an observer
|
||||
*
|
||||
* @return int unique identifier for an observer
|
||||
*/
|
||||
public static function getUniqueId()
|
||||
{
|
||||
return self::$_uniqueid++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a signal to all observers
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function signal()
|
||||
{
|
||||
foreach (self::$_observers as $func) {
|
||||
if (is_callable($func)) {
|
||||
call_user_func($func, $this);
|
||||
continue;
|
||||
}
|
||||
settype($func, 'array');
|
||||
switch ($func[0]) {
|
||||
case self::OBSERVER_PRINT :
|
||||
$f = (isset($func[1])) ? $func[1] : '%s';
|
||||
printf($f, $this->getMessage());
|
||||
break;
|
||||
case self::OBSERVER_TRIGGER :
|
||||
$f = (isset($func[1])) ? $func[1] : E_USER_NOTICE;
|
||||
trigger_error($this->getMessage(), $f);
|
||||
break;
|
||||
case self::OBSERVER_DIE :
|
||||
$f = (isset($func[1])) ? $func[1] : '%s';
|
||||
die(printf($f, $this->getMessage()));
|
||||
break;
|
||||
default:
|
||||
trigger_error('invalid observer type', E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return specific error information that can be used for more detailed
|
||||
* error messages or translation.
|
||||
*
|
||||
* This method may be overridden in child exception classes in order
|
||||
* to add functionality not present in PEAR_Exception and is a placeholder
|
||||
* to define API
|
||||
*
|
||||
* The returned array must be an associative array of parameter => value like so:
|
||||
* <pre>
|
||||
* array('name' => $name, 'context' => array(...))
|
||||
* </pre>
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getErrorData()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exception that caused this exception to be thrown
|
||||
*
|
||||
* @return Exception|array The context of the exception
|
||||
*/
|
||||
public function getCause()
|
||||
{
|
||||
return $this->cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function must be public to call on caused exceptions
|
||||
*
|
||||
* @param array $causes Array that gets filled.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getCauseMessage(&$causes)
|
||||
{
|
||||
$trace = $this->getTraceSafe();
|
||||
$cause = array('class' => get_class($this),
|
||||
'message' => $this->message,
|
||||
'file' => 'unknown',
|
||||
'line' => 'unknown');
|
||||
if (isset($trace[0])) {
|
||||
if (isset($trace[0]['file'])) {
|
||||
$cause['file'] = $trace[0]['file'];
|
||||
$cause['line'] = $trace[0]['line'];
|
||||
}
|
||||
}
|
||||
$causes[] = $cause;
|
||||
if ($this->cause instanceof PEAR_Exception) {
|
||||
$this->cause->getCauseMessage($causes);
|
||||
} elseif ($this->cause instanceof Exception) {
|
||||
$causes[] = array('class' => get_class($this->cause),
|
||||
'message' => $this->cause->getMessage(),
|
||||
'file' => $this->cause->getFile(),
|
||||
'line' => $this->cause->getLine());
|
||||
} elseif (class_exists('PEAR_Error') && $this->cause instanceof PEAR_Error) {
|
||||
$causes[] = array('class' => get_class($this->cause),
|
||||
'message' => $this->cause->getMessage(),
|
||||
'file' => 'unknown',
|
||||
'line' => 'unknown');
|
||||
} elseif (is_array($this->cause)) {
|
||||
foreach ($this->cause as $cause) {
|
||||
if ($cause instanceof PEAR_Exception) {
|
||||
$cause->getCauseMessage($causes);
|
||||
} elseif ($cause instanceof Exception) {
|
||||
$causes[] = array('class' => get_class($cause),
|
||||
'message' => $cause->getMessage(),
|
||||
'file' => $cause->getFile(),
|
||||
'line' => $cause->getLine());
|
||||
} elseif (class_exists('PEAR_Error')
|
||||
&& $cause instanceof PEAR_Error
|
||||
) {
|
||||
$causes[] = array('class' => get_class($cause),
|
||||
'message' => $cause->getMessage(),
|
||||
'file' => 'unknown',
|
||||
'line' => 'unknown');
|
||||
} elseif (is_array($cause) && isset($cause['message'])) {
|
||||
// PEAR_ErrorStack warning
|
||||
$causes[] = array(
|
||||
'class' => $cause['package'],
|
||||
'message' => $cause['message'],
|
||||
'file' => isset($cause['context']['file']) ?
|
||||
$cause['context']['file'] :
|
||||
'unknown',
|
||||
'line' => isset($cause['context']['line']) ?
|
||||
$cause['context']['line'] :
|
||||
'unknown',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a backtrace and return it
|
||||
*
|
||||
* @return array Backtrace
|
||||
*/
|
||||
public function getTraceSafe()
|
||||
{
|
||||
if (!isset($this->_trace)) {
|
||||
$this->_trace = $this->getTrace();
|
||||
if (empty($this->_trace)) {
|
||||
$backtrace = debug_backtrace();
|
||||
$this->_trace = array($backtrace[count($backtrace)-1]);
|
||||
}
|
||||
}
|
||||
return $this->_trace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first class of the backtrace
|
||||
*
|
||||
* @return string Class name
|
||||
*/
|
||||
public function getErrorClass()
|
||||
{
|
||||
$trace = $this->getTraceSafe();
|
||||
return $trace[0]['class'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first method of the backtrace
|
||||
*
|
||||
* @return string Method/function name
|
||||
*/
|
||||
public function getErrorMethod()
|
||||
{
|
||||
$trace = $this->getTraceSafe();
|
||||
return $trace[0]['function'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the exception to a string (HTML or plain text)
|
||||
*
|
||||
* @return string String representation
|
||||
*
|
||||
* @see toHtml()
|
||||
* @see toText()
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
if (isset($_SERVER['REQUEST_URI'])) {
|
||||
return $this->toHtml();
|
||||
}
|
||||
return $this->toText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a HTML representation of the exception
|
||||
*
|
||||
* @return string HTML code
|
||||
*/
|
||||
public function toHtml()
|
||||
{
|
||||
$trace = $this->getTraceSafe();
|
||||
$causes = array();
|
||||
$this->getCauseMessage($causes);
|
||||
$html = '<table style="border: 1px" cellspacing="0">' . "\n";
|
||||
foreach ($causes as $i => $cause) {
|
||||
$html .= '<tr><td colspan="3" style="background: #ff9999">'
|
||||
. str_repeat('-', $i) . ' <b>' . $cause['class'] . '</b>: '
|
||||
. htmlspecialchars($cause['message'])
|
||||
. ' in <b>' . $cause['file'] . '</b> '
|
||||
. 'on line <b>' . $cause['line'] . '</b>'
|
||||
. "</td></tr>\n";
|
||||
}
|
||||
$html .= '<tr><td colspan="3" style="background-color: #aaaaaa; text-align: center; font-weight: bold;">Exception trace</td></tr>' . "\n"
|
||||
. '<tr><td style="text-align: center; background: #cccccc; width:20px; font-weight: bold;">#</td>'
|
||||
. '<td style="text-align: center; background: #cccccc; font-weight: bold;">Function</td>'
|
||||
. '<td style="text-align: center; background: #cccccc; font-weight: bold;">Location</td></tr>' . "\n";
|
||||
|
||||
foreach ($trace as $k => $v) {
|
||||
$html .= '<tr><td style="text-align: center;">' . $k . '</td>'
|
||||
. '<td>';
|
||||
if (!empty($v['class'])) {
|
||||
$html .= $v['class'] . $v['type'];
|
||||
}
|
||||
$html .= $v['function'];
|
||||
$args = array();
|
||||
if (!empty($v['args'])) {
|
||||
foreach ($v['args'] as $arg) {
|
||||
if (is_null($arg)) {
|
||||
$args[] = 'null';
|
||||
} else if (is_array($arg)) {
|
||||
$args[] = 'Array';
|
||||
} else if (is_object($arg)) {
|
||||
$args[] = 'Object('.get_class($arg).')';
|
||||
} else if (is_bool($arg)) {
|
||||
$args[] = $arg ? 'true' : 'false';
|
||||
} else if (is_int($arg) || is_double($arg)) {
|
||||
$args[] = $arg;
|
||||
} else {
|
||||
$arg = (string)$arg;
|
||||
$str = htmlspecialchars(substr($arg, 0, 16));
|
||||
if (strlen($arg) > 16) {
|
||||
$str .= '…';
|
||||
}
|
||||
$args[] = "'" . $str . "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
$html .= '(' . implode(', ', $args) . ')'
|
||||
. '</td>'
|
||||
. '<td>' . (isset($v['file']) ? $v['file'] : 'unknown')
|
||||
. ':' . (isset($v['line']) ? $v['line'] : 'unknown')
|
||||
. '</td></tr>' . "\n";
|
||||
}
|
||||
$html .= '<tr><td style="text-align: center;">' . ($k+1) . '</td>'
|
||||
. '<td>{main}</td>'
|
||||
. '<td> </td></tr>' . "\n"
|
||||
. '</table>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates text representation of the exception and stack trace
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toText()
|
||||
{
|
||||
$causes = array();
|
||||
$this->getCauseMessage($causes);
|
||||
$causeMsg = '';
|
||||
foreach ($causes as $i => $cause) {
|
||||
$causeMsg .= str_repeat(' ', $i) . $cause['class'] . ': '
|
||||
. $cause['message'] . ' in ' . $cause['file']
|
||||
. ' on line ' . $cause['line'] . "\n";
|
||||
}
|
||||
return $causeMsg . $this->getTraceAsString();
|
||||
}
|
||||
}
|
||||
?>
|
||||
43
lib/composer/vendor/pear/pear_exception/composer.json
vendored
Normal file
43
lib/composer/vendor/pear/pear_exception/composer.json
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "pear/pear_exception",
|
||||
"description": "The PEAR Exception base class.",
|
||||
"type": "class",
|
||||
"keywords": [
|
||||
"exception"
|
||||
],
|
||||
"homepage": "https://github.com/pear/PEAR_Exception",
|
||||
"license": "BSD-2-Clause",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Helgi Thormar",
|
||||
"email": "dufuz@php.net"
|
||||
},
|
||||
{
|
||||
"name": "Greg Beaver",
|
||||
"email": "cellog@php.net"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=4.4.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"PEAR": ""
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"include-path": [
|
||||
"."
|
||||
],
|
||||
"support": {
|
||||
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=PEAR_Exception",
|
||||
"source": "https://github.com/pear/PEAR_Exception"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "*"
|
||||
}
|
||||
}
|
||||
120
lib/composer/vendor/pear/pear_exception/package.xml
vendored
Normal file
120
lib/composer/vendor/pear/pear_exception/package.xml
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<package packagerversion="1.9.4" version="2.0"
|
||||
xmlns="http://pear.php.net/dtd/package-2.0"
|
||||
xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"
|
||||
>
|
||||
<name>PEAR_Exception</name>
|
||||
<channel>pear.php.net</channel>
|
||||
<summary>The PEAR Exception base class</summary>
|
||||
<description>PEAR_Exception PHP5 error handling mechanism</description>
|
||||
|
||||
<lead>
|
||||
<name>Christian Weiske</name>
|
||||
<user>cweiske</user>
|
||||
<email>cweiske@php.net</email>
|
||||
<active>yes</active>
|
||||
</lead>
|
||||
<lead>
|
||||
<name>Helgi Thormar</name>
|
||||
<user>dufuz</user>
|
||||
<email>dufuz@php.net</email>
|
||||
<active>no</active>
|
||||
</lead>
|
||||
<developer>
|
||||
<name>Greg Beaver</name>
|
||||
<user>cellog</user>
|
||||
<email>cellog@php.net</email>
|
||||
<active>no</active>
|
||||
</developer>
|
||||
|
||||
<date>2015-02-10</date>
|
||||
<time>21:02:23</time>
|
||||
<version>
|
||||
<release>1.0.0</release>
|
||||
<api>1.0.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://opensource.org/licenses/bsd-license.php">New BSD License</license>
|
||||
<notes>
|
||||
This package was split out from the PEAR package.
|
||||
If you use PEAR_Exception in your package and use nothing from the PEAR package
|
||||
then it's better to depend on just PEAR_Exception.
|
||||
</notes>
|
||||
<contents>
|
||||
<dir name="/">
|
||||
<file name="/PEAR/Exception.php" role="php">
|
||||
<tasks:replace from="@package_version@" to="version" type="package-info" />
|
||||
</file>
|
||||
<dir name="tests">
|
||||
<dir name="PEAR">
|
||||
<file name="ExceptionTest.php" role="test"/>
|
||||
</dir>
|
||||
</dir>
|
||||
</dir>
|
||||
</contents>
|
||||
|
||||
<dependencies>
|
||||
<required>
|
||||
<php>
|
||||
<min>5.4.0</min>
|
||||
</php>
|
||||
<pearinstaller>
|
||||
<min>1.9.5</min>
|
||||
</pearinstaller>
|
||||
</required>
|
||||
</dependencies>
|
||||
|
||||
<phprelease />
|
||||
|
||||
<changelog>
|
||||
<release>
|
||||
<version>
|
||||
<release>1.0.0</release>
|
||||
<api>1.0.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2015-02-10</date>
|
||||
<license uri="http://opensource.org/licenses/bsd-license.php">New BSD License</license>
|
||||
<notes>Release stable version</notes>
|
||||
</release>
|
||||
|
||||
<release>
|
||||
<version>
|
||||
<release>1.0.0beta2</release>
|
||||
<api>1.0.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>beta</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2014-02-21</date>
|
||||
<license uri="http://opensource.org/licenses/bsd-license.php">New BSD License</license>
|
||||
<notes>Bump up PEAR dependency.</notes>
|
||||
</release>
|
||||
|
||||
<release>
|
||||
<version>
|
||||
<release>1.0.0beta1</release>
|
||||
<api>1.0.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>beta</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2012-05-10</date>
|
||||
<license uri="http://opensource.org/licenses/bsd-license.php">New BSD License</license>
|
||||
<notes>
|
||||
This packge was split out from the PEAR package. If you use PEAR_Exception in your package
|
||||
and use nothing from the PEAR package then it's better to depend on just PEAR_Exception.
|
||||
</notes>
|
||||
</release>
|
||||
</changelog>
|
||||
</package>
|
||||
78
lib/composer/vendor/pear/pear_exception/tests/PEAR/ExceptionTest.php
vendored
Normal file
78
lib/composer/vendor/pear/pear_exception/tests/PEAR/ExceptionTest.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
$localFile = __DIR__ . '/../../PEAR/Exception.php';
|
||||
if (file_exists($localFile)) {
|
||||
require_once $localFile;
|
||||
} else {
|
||||
require_once 'PEAR/Exception.php';
|
||||
}
|
||||
|
||||
class PEAR_ExceptionTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException PEAR_Exception
|
||||
* @expectedExceptionMessage foo
|
||||
*/
|
||||
public function testThrow()
|
||||
{
|
||||
throw new PEAR_Exception('foo');
|
||||
}
|
||||
|
||||
public function testGetCauseNone()
|
||||
{
|
||||
$e = new PEAR_Exception('foo bar');
|
||||
$this->assertNull($e->getCause());
|
||||
}
|
||||
|
||||
public function testGetCauseException()
|
||||
{
|
||||
$cause = new Exception('foo bar');
|
||||
$e = new PEAR_Exception('I caught an exception', $cause);
|
||||
$this->assertNotNull($e->getCause());
|
||||
$this->assertInstanceOf('Exception', $e->getCause());
|
||||
$this->assertEquals($cause, $e->getCause());
|
||||
}
|
||||
|
||||
public function testGetCauseMessage()
|
||||
{
|
||||
$cause = new Exception('foo bar');
|
||||
$e = new PEAR_Exception('I caught an exception', $cause);
|
||||
|
||||
$e->getCauseMessage($causes);
|
||||
$this->assertEquals('I caught an exception', $causes[0]['message']);
|
||||
$this->assertEquals('foo bar', $causes[1]['message']);
|
||||
}
|
||||
|
||||
public function testGetTraceSafe()
|
||||
{
|
||||
$e = new PEAR_Exception('oops');
|
||||
$this->assertInternalType('array', $e->getTraceSafe());
|
||||
}
|
||||
|
||||
public function testGetErrorClass()
|
||||
{
|
||||
$e = new PEAR_Exception('oops');
|
||||
$this->assertEquals('PEAR_ExceptionTest', $e->getErrorClass());
|
||||
}
|
||||
|
||||
public function testGetErrorMethod()
|
||||
{
|
||||
$e = new PEAR_Exception('oops');
|
||||
$this->assertEquals('testGetErrorMethod', $e->getErrorMethod());
|
||||
}
|
||||
|
||||
public function test__toString()
|
||||
{
|
||||
$e = new PEAR_Exception('oops');
|
||||
$this->assertInternalType('string', (string) $e);
|
||||
$this->assertContains('oops', (string) $e);
|
||||
}
|
||||
|
||||
public function testToHtml()
|
||||
{
|
||||
$e = new PEAR_Exception('oops');
|
||||
$html = $e->toHtml();
|
||||
$this->assertInternalType('string', $html);
|
||||
$this->assertContains('oops', $html);
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user