License updated to GPLv3

🧲 New features
Custom user role permissions
Employee edit form updated
Employee daily task list
Attendance and employee distribution charts on dashboard
Improvements to company structure and company assets module
Improved tables for displaying data in several modules
Faster data loading (specially for employee module)
Initials based profile pictures
Re-designed login page
Re-designed user profile page
Improvements to filtering
New REST endpoints for employee qualifications

🐛 Bug fixes
Fixed, issue with managers being able to create performance reviews for employees who are not their direct reports
Fixed, issues related to using full profile image instead of using smaller version of profile image
Changing third gender to other
Improvements and fixes for internal frontend data caching
This commit is contained in:
Thilina Pituwala
2020-10-31 19:02:37 +01:00
parent 86b8345505
commit b1df0037db
29343 changed files with 867614 additions and 2191082 deletions

View File

@@ -3,20 +3,17 @@
/**
* PHP Version 5
*
* Copyright (c) 1997-2004 The PHP Group
* Copyright (c) 2001-2015, The PEAR developers
*
* This source file is subject to version 3.0 of the PHP license,
* This source file is subject to the BSD-2-Clause 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.
* http://opensource.org/licenses/bsd-license.php.
*
* @category Console
* @package Console_Getopt
* @author Andrei Zmievski <andrei@php.net>
* @license http://www.php.net/license/3_0.txt PHP 3.0
* @license http://opensource.org/licenses/bsd-license.php BSD-2-Clause
* @version CVS: $Id$
* @link http://pear.php.net/package/Console_Getopt
*/
@@ -29,7 +26,7 @@ require_once 'PEAR.php';
* @category Console
* @package Console_Getopt
* @author Andrei Zmievski <andrei@php.net>
* @license http://www.php.net/license/3_0.txt PHP 3.0
* @license http://opensource.org/licenses/bsd-license.php BSD-2-Clause
* @link http://pear.php.net/package/Console_Getopt
*/
class Console_Getopt
@@ -126,13 +123,13 @@ class Console_Getopt
* erroneous POSIX fix.
*/
if ($version < 2) {
if (isset($args[0]{0}) && $args[0]{0} != '-') {
if (isset($args[0][0]) && $args[0][0] != '-') {
array_shift($args);
}
}
reset($args);
while (list($i, $arg) = each($args)) {
for ($i = 0; $i < count($args); $i++) {
$arg = $args[$i];
/* The special element '--' means explicit end of
options. Treat the rest of the arguments as non-options
and end the loop. */
@@ -141,13 +138,14 @@ class Console_Getopt
break;
}
if ($arg{0} != '-' || (strlen($arg) > 1 && $arg{1} == '-' && !$long_options)) {
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} == '-') {
} elseif (strlen($arg) > 1 && $arg[1] == '-') {
$error = Console_Getopt::_parseLongOption(substr($arg, 2),
$long_options,
$opts,
$i,
$args,
$skip_unknown);
if (PEAR::isError($error)) {
@@ -161,6 +159,7 @@ class Console_Getopt
$error = Console_Getopt::_parseShortOption(substr($arg, 1),
$short_options,
$opts,
$i,
$args,
$skip_unknown);
if (PEAR::isError($error)) {
@@ -178,19 +177,20 @@ class Console_Getopt
* @param string $arg Argument
* @param string[] $short_options Available short options
* @param string[][] &$opts
* @param string[] &$args
* @param int &$argIdx
* @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)
protected static function _parseShortOption($arg, $short_options, &$opts, &$argIdx, $args, $skip_unknown)
{
for ($i = 0; $i < strlen($arg); $i++) {
$opt = $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 (($spec = strstr($short_options, $opt)) === false || $arg[$i] == ':') {
if ($skip_unknown === true) {
break;
}
@@ -199,8 +199,8 @@ class Console_Getopt
return PEAR::raiseError($msg);
}
if (strlen($spec) > 1 && $spec{1} == ':') {
if (strlen($spec) > 2 && $spec{2} == ':') {
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. */
@@ -213,7 +213,8 @@ class Console_Getopt
if ($i + 1 < strlen($arg)) {
$opts[] = array($opt, substr($arg, $i + 1));
break;
} else if (list(, $opt_arg) = each($args)) {
} else if (isset($args[++$argIdx])) {
$opt_arg = $args[$argIdx];
/* Else use the next argument. */;
if (Console_Getopt::_isShortOpt($opt_arg)
|| Console_Getopt::_isLongOpt($opt_arg)) {
@@ -263,11 +264,12 @@ class Console_Getopt
* @param string $arg Argument
* @param string[] $long_options Available long options
* @param string[][] &$opts
* @param string[] &$args
* @param int &$argIdx
* @param string[] $args
*
* @return void|PEAR_Error
*/
protected static function _parseLongOption($arg, $long_options, &$opts, &$args, $skip_unknown)
protected static function _parseLongOption($arg, $long_options, &$opts, &$argIdx, $args, $skip_unknown)
{
@list($opt, $opt_arg) = explode('=', $arg, 2);
@@ -294,11 +296,11 @@ class Console_Getopt
$next_option_rest = '';
}
if ($opt_rest != '' && $opt{0} != '=' &&
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} != '=') {
$next_option_rest[0] != '=') {
$msg = "Console_Getopt: option --$opt is ambiguous";
return PEAR::raiseError($msg);
@@ -308,9 +310,12 @@ class Console_Getopt
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 (!strlen($opt_arg)) {
if (!isset($args[++$argIdx])) {
$msg = "Console_Getopt: option requires an argument --$opt";
return PEAR::raiseError($msg);
}
$opt_arg = $args[$argIdx];
}
if (Console_Getopt::_isShortOpt($opt_arg)
@@ -357,4 +362,4 @@ class Console_Getopt
return $argv;
}
}
}

View File

@@ -21,13 +21,12 @@ short and long options.</description>
<name>Greg Beaver</name>
<user>cellog</user>
<email>cellog@php.net</email>
<active>yes</active>
<active>no</active>
</helper>
<date>2015-07-20</date>
<time>22:21:23</time>
<date>2019-11-20</date>
<version>
<release>1.4.1</release>
<release>1.4.3</release>
<api>1.4.0</api>
</version>
<stability>
@@ -37,7 +36,8 @@ short and long options.</description>
<license uri="http://opensource.org/licenses/bsd-license.php">BSD-2-Clause</license>
<notes>
* Fix unit test on PHP 7 [cweiske]
* PR #4: Fix PHP 7.4 deprecation: array/string curly braces access
* PR #5: fix phplint warnings
</notes>
<contents>
@@ -76,6 +76,39 @@ short and long options.</description>
<changelog>
<release>
<date>2019-11-20</date>
<version>
<release>1.4.3</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>
* PR #4: Fix PHP 7.4 deprecation: array/string curly braces access
* PR #5: fix phplint warnings
</notes>
</release>
<release>
<date>2019-02-06</date>
<version>
<release>1.4.2</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>
* Remove use of each(), which is removed in PHP 8
</notes>
</release>
<release>
<date>2015-07-20</date>
<version>

View File

@@ -1,15 +0,0 @@
.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

View File

@@ -1,11 +0,0 @@
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/

View File

@@ -1,69 +1,23 @@
--------------------------------------------------------------------
The PHP License, version 3.01
Copyright (c) 2002-2015 Jon Parise and Chuck Hagenbuch.
All rights reserved.
--------------------------------------------------------------------
Copyright 2002-2017 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:
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. 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.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
6. Redistributions of any form whatsoever must retain the following
acknowledgment:
"This product includes PHP software, freely available from
<http://www.php.net/software/>".
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 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>.
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.

View File

@@ -3,15 +3,33 @@
// +----------------------------------------------------------------------+
// | PHP Version 5 and 7 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2015 Jon Parise and Chuck Hagenbuch |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.01 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_01.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// | Copyright (c) 1997-2019 Jon Parise and 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. |
// | |
// | 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. |
// +----------------------------------------------------------------------+
// | Authors: Chuck Hagenbuch <chuck@horde.org> |
// | Jon Parise <jon@php.net> |
@@ -29,6 +47,7 @@ require_once 'Net/Socket.php';
* @author Chuck Hagenbuch <chuck@horde.org>
* @author Jon Parise <jon@php.net>
* @author Damian Alejandro Fernandez Sosa <damlists@cnba.uba.ar>
* @license http://opensource.org/licenses/bsd-license.php BSD-2-Clause
*
* @example basic.php A basic implementation of the Net_SMTP package.
*/
@@ -142,17 +161,20 @@ class Net_SMTP
* $smtp = new Net_SMTP('ssl://mail.host.com', 465);
* $smtp->connect();
*
* @param string $host The server to connect to.
* @param integer $port The port to connect to.
* @param string $localhost The value to give when sending EHLO or HELO.
* @param boolean $pipelining Use SMTP command pipelining
* @param integer $timeout Socket I/O timeout in seconds.
* @param array $socket_options Socket stream_context_create() options.
* @param string $host The server to connect to.
* @param integer $port The port to connect to.
* @param string $localhost The value to give when sending EHLO or HELO.
* @param boolean $pipelining Use SMTP command pipelining
* @param integer $timeout Socket I/O timeout in seconds.
* @param array $socket_options Socket stream_context_create() options.
* @param string $gssapi_principal GSSAPI service principal name
* @param string $gssapi_cname GSSAPI credentials cache
*
* @since 1.0
*/
public function __construct($host = null, $port = null, $localhost = null,
$pipelining = false, $timeout = 0, $socket_options = null
$pipelining = false, $timeout = 0, $socket_options = null,
$gssapi_principal=null, $gssapi_cname=null
) {
if (isset($host)) {
$this->host = $host;
@@ -164,10 +186,17 @@ class Net_SMTP
$this->localhost = $localhost;
}
$this->pipelining = $pipelining;
$this->socket = new Net_Socket();
$this->socket_options = $socket_options;
$this->timeout = $timeout;
$this->pipelining = $pipelining;
$this->socket = new Net_Socket();
$this->socket_options = $socket_options;
$this->timeout = $timeout;
$this->gssapi_principal = $gssapi_principal;
$this->gssapi_cname = $gssapi_cname;
/* If PHP krb5 extension is loaded, we enable GSSAPI method. */
if (extension_loaded('krb5')) {
$this->setAuthMethod('GSSAPI', array($this, 'authGSSAPI'));
}
/* Include the Auth_SASL package. If the package is available, we
* enable the authentication methods that depend upon it. */
@@ -179,6 +208,7 @@ class Net_SMTP
/* These standard authentication methods are always available. */
$this->setAuthMethod('LOGIN', array($this, 'authLogin'), false);
$this->setAuthMethod('PLAIN', array($this, 'authPlain'), false);
$this->setAuthMethod('XOAUTH2', array($this, 'authXOAuth2'), false);
}
/**
@@ -852,6 +882,129 @@ class Net_SMTP
return true;
}
/**
* Authenticates the user using the GSSAPI method.
*
* PHP krb5 extension is required,
* service principal and credentials cache must be set.
*
* @param string $uid The userid to authenticate as.
* @param string $pwd The password to authenticate with.
* @param string $authz The optional authorization proxy identifier.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
*/
protected function authGSSAPI($uid, $pwd, $authz = '')
{
if (PEAR::isError($error = $this->put('AUTH', 'GSSAPI'))) {
return $error;
}
/* 334: Continue authentication request */
if (PEAR::isError($error = $this->parseResponse(334))) {
/* 503: Error: already authenticated */
if ($this->code === 503) {
return true;
}
return $error;
}
if (!$this->gssapi_principal) {
return PEAR::raiseError('No Kerberos service principal set', 2);
}
if (!empty($this->gssapi_cname)) {
putenv('KRB5CCNAME=' . $this->gssapi_cname);
}
try {
$ccache = new KRB5CCache();
if (!empty($this->gssapi_cname)) {
$ccache->open($this->gssapi_cname);
}
$gssapicontext = new GSSAPIContext();
$gssapicontext->acquireCredentials($ccache);
$token = '';
$success = $gssapicontext->initSecContext($this->gssapi_principal, null, null, null, $token);
$token = base64_encode($token);
}
catch (Exception $e) {
return PEAR::raiseError('GSSAPI authentication failed: ' . $e->getMessage());
}
if (PEAR::isError($error = $this->put($token))) {
return $error;
}
/* 334: Continue authentication request */
if (PEAR::isError($error = $this->parseResponse(334))) {
return $error;
}
$response = $this->arguments[0];
try {
$challenge = base64_decode($response);
$gssapicontext->unwrap($challenge, $challenge);
$gssapicontext->wrap($challenge, $challenge, true);
}
catch (Exception $e) {
return PEAR::raiseError('GSSAPI authentication failed: ' . $e->getMessage());
}
if (PEAR::isError($error = $this->put(base64_encode($challenge)))) {
return $error;
}
/* 235: Authentication successful */
if (PEAR::isError($error = $this->parseResponse(235))) {
return $error;
}
return true;
}
/**
* Authenticates the user using the XOAUTH2 method.
*
* @param string $uid The userid to authenticate as.
* @param string $token The access token to authenticate with.
* @param string $authz The optional authorization proxy identifier.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
* @since 1.9.0
*/
public function authXOAuth2($uid, $token, $authz, $conn)
{
$auth = base64_encode("user=$uid\1auth=$token\1\1");
if (PEAR::isError($error = $this->put('AUTH', 'XOAUTH2 ' . $auth))) {
return $error;
}
/* 235: Authentication successful or 334: Continue authentication */
if (PEAR::isError($error = $this->parseResponse([235, 334]))) {
return $error;
}
/* 334: Continue authentication request */
if ($this->code === 334) {
/* Send an empty line as response to 334 */
if (PEAR::isError($error = $this->put(''))) {
return $error;
}
/* Expect 235: Authentication successful */
if (PEAR::isError($error = $this->parseResponse(235))) {
return $error;
}
}
return true;
}
/**
* Send the HELO command.
*
@@ -1018,7 +1171,6 @@ class Net_SMTP
* about the server's fixed maximum message size". */
$limit = (isset($this->esmtp['SIZE'])) ? $this->esmtp['SIZE'] : 0;
if ($limit > 0 && $size >= $limit) {
$this->disconnect();
return PEAR::raiseError('Message size exceeds server limit');
}

View File

@@ -35,7 +35,7 @@ parameter::
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
.. _OpenSSL changes: https://php.net/manual/en/migration56.openssl.php
The ``Auth_SASL`` Package
-------------------------
@@ -56,7 +56,7 @@ error occurs. The standard way to check for a PEAR_Error object is by using
die($error->getMessage());
}
.. _PEAR::isError(): http://pear.php.net/manual/en/core.pear.pear.iserror.php
.. _PEAR::isError(): https://pear.php.net/manual/en/core.pear.pear.iserror.php
SMTP Authentication
===================
@@ -65,19 +65,36 @@ 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
.. _RFC-2554: https://www.ietf.org/rfc/rfc2554.txt
GSSAPI
------
The GSSAPI authentication method uses Kerberos 5 protocol (RFC-4120_).
Does not use user/password.
Requires Service Principal ``gssapi_principal`` parameter and
has an optional Credentials Cache ``gssapi_cname`` parameter.
Requires DNS and Key Distribution Center (KDC) setup.
It is considered the most secure method of SMTP authentication.
**Note:** The GSSAPI authentication method is only supported
if the krb5_ php extension is available.
.. _RFC-4120: https://tools.ietf.org/html/rfc4120
.. _krb5: https://pecl.php.net/package/krb5
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.
Message Digest algorithm. It is considered a more secure method of SMTP
authentication than PLAIN or LOGIN, while still vulnerable to MitM attacks
without TLS/SSL.
**Note:** The DIGEST-MD5 authentication method is only supported if the
AUTH_SASL_ package is available.
.. _RSA Data Security Inc.: http://www.rsasecurity.com/
.. _RSA Data Security Inc.: https://www.rsasecurity.com/
CRAM-MD5
--------
@@ -97,7 +114,7 @@ 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
.. _Base64: https://www.php.net/manual/en/function.base64-encode.php
PLAIN
-----
@@ -105,6 +122,14 @@ PLAIN
The PLAIN authentication method sends the user's password in plain text.
This method of authentication is not secure and should be avoided.
XOAUTH2
-------
The XOAUTH2 authentication method sends a username and an OAuth2 access token
as per `Gmail's SASL XOAUTH2 documentation`__.
.. __: https://developers.google.com/gmail/imap/xoauth2-protocol#smtp_protocol_exchange
Secure Connections
==================
@@ -116,7 +141,7 @@ establish a secure connection to the remote SMTP server::
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
.. _secure socket transports: https://www.php.net/transports
Sending Data
============
@@ -177,7 +202,7 @@ 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
.. _by reference: https://www.php.net/manual/en/language.references.pass.php
Server Responses
================
@@ -260,8 +285,8 @@ using the Net_SMTP package::
/* 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
.. _PEAR_Error: https://pear.php.net/manual/en/core.pear.pear-error.php
.. _Net_Socket: https://pear.php.net/package/Net_Socket
.. _Auth_SASL: https://pear.php.net/package/Auth_SASL
.. vim: tabstop=4 shiftwidth=4 softtabstop=4 expandtab textwidth=78 ft=rst:

View File

@@ -3,7 +3,7 @@
{
"email": "jon@php.net",
"name": "Jon Parise",
"homepage": "http://www.indelible.org",
"homepage": "https://www.indelible.org",
"role": "Lead"
},
{
@@ -26,9 +26,9 @@
"include-path": [
"./"
],
"license": "PHP-3.01",
"license": "BSD-2-Clause",
"name": "pear/net_smtp",
"homepage": "http://pear.github.io/Net_SMTP/",
"homepage": "https://pear.github.io/Net_SMTP/",
"support": {
"issues": "https://github.com/pear/Net_SMTP/issues",
"source": "https://github.com/pear/Net_SMTP"
@@ -36,8 +36,8 @@
"type": "library",
"require": {
"php": ">=5.4.0",
"pear/pear-core-minimal": "*",
"pear/net_socket": "*"
"pear/pear-core-minimal": "@stable",
"pear/net_socket": "@stable"
},
"require-dev": {
"phpunit/phpunit": "*"

View File

@@ -1,16 +0,0 @@
[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

View File

@@ -1,108 +0,0 @@
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 */

View File

@@ -1,267 +0,0 @@
======================
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:

View File

@@ -1,39 +0,0 @@
<?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();

View File

@@ -1,77 +0,0 @@
<?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&apos;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>

View File

@@ -1,3 +0,0 @@
#!/bin/sh
phpdoc -f Net/SMTP.php -t docs/api -p -ti "Net_SMTP Package API" -dn Net_SMTP -dc Net_SMTP -ed examples

View File

@@ -1,28 +0,0 @@
--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!

View File

@@ -1,42 +0,0 @@
--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!

View File

@@ -1,15 +0,0 @@
<?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');

View File

@@ -1,70 +0,0 @@
--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

View File

@@ -2,5 +2,3 @@
composer.lock
composer.phar
vendor
*.tgz

View File

@@ -1,21 +1,6 @@
language: php
sudo: false
install:
- pear install package.xml
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
script: pear package

View File

@@ -1,9 +0,0 @@
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.

View File

@@ -2,41 +2,27 @@
/**
* Net_Socket
*
* PHP Version 5
* PHP Version 4
*
* LICENSE:
* Copyright (c) 1997-2013 The PHP Group
*
* Copyright (c) 1997-2017 The PHP Group
* All rights reserved.
* This source file is subject to version 2.0 of the PHP license,
* that is bundled with this package in the file LICENSE, and is
* available at through the world-wide-web at
* http://www.php.net/license/2_02.txt.
* If you did not receive a copy of the PHP license and are unable to
* obtain it through the world-wide-web, please send a note to
* license@php.net so we can mail you a copy immediately.
*
* 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.
* Authors: Stig Bakken <ssb@php.net>
* Chuck Hagenbuch <chuck@horde.org>
*
* @category Net
* @package Net_Socket
* @author Stig Bakken <ssb@php.net>
* @author Chuck Hagenbuch <chuck@horde.org>
* @copyright 1997-2017 The PHP Group
* @license http://opensource.org/licenses/bsd-license.php BSD-2-Clause
* @copyright 1997-2003 The PHP Group
* @license http://www.php.net/license/2_02.txt PHP 2.02
* @link http://pear.php.net/packages/Net_Socket
*/
@@ -53,8 +39,8 @@ define('NET_SOCKET_ERROR', 4);
* @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
* @copyright 1997-2003 The PHP Group
* @license http://www.php.net/license/2_02.txt PHP 2.02
* @link http://pear.php.net/packages/Net_Socket
*/
class Net_Socket extends PEAR
@@ -63,75 +49,71 @@ class Net_Socket extends PEAR
* Socket file pointer.
* @var resource $fp
*/
public $fp = null;
var $fp = null;
/**
* Whether the socket is blocking. Defaults to true.
* @var boolean $blocking
*/
public $blocking = true;
var $blocking = true;
/**
* Whether the socket is persistent. Defaults to false.
* @var boolean $persistent
*/
public $persistent = false;
var $persistent = false;
/**
* The IP address to connect to.
* @var string $addr
*/
public $addr = '';
var $addr = '';
/**
* The port number to connect to.
* @var integer $port
*/
public $port = 0;
var $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;
var $timeout = null;
/**
* Number of bytes to read at a time in readLine() and
* readAll(). Defaults to 2048.
* @var integer $lineLength
*/
public $lineLength = 2048;
var $lineLength = 2048;
/**
* The string to use as a newline terminator. Usually "\r\n" or "\n".
* @var string $newline
*/
public $newline = "\r\n";
var $newline = "\r\n";
/**
* Connect to the specified port. If called when the socket is
* already connected, it disconnects and connects again.
*
* @param string $addr IP address or host name (may be with protocol prefix).
* @param integer $port TCP port number.
* @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.
* @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
) {
function connect($addr, $port = 0, $persistent = null,
$timeout = null, $options = null)
{
if (is_resource($this->fp)) {
@fclose($this->fp);
$this->fp = null;
@@ -139,12 +121,10 @@ class Net_Socket extends PEAR
if (!$addr) {
return $this->raiseError('$addr cannot be empty');
} else if (strspn($addr, ':.0123456789') == strlen($addr)) {
$this->addr = strpos($addr, ':') !== false ? '['.$addr.']' : $addr;
} else {
if (strspn($addr, ':.0123456789') === strlen($addr)) {
$this->addr = strpos($addr, ':') !== false ? '[' . $addr . ']' : $addr;
} else {
$this->addr = $addr;
}
$this->addr = $addr;
}
$this->port = $port % 65536;
@@ -154,8 +134,8 @@ class Net_Socket extends PEAR
}
$openfunc = $this->persistent ? 'pfsockopen' : 'fsockopen';
$errno = 0;
$errstr = '';
$errno = 0;
$errstr = '';
$old_track_errors = @ini_set('track_errors', 1);
@@ -175,29 +155,27 @@ class Net_Socket extends PEAR
}
$addr = $this->addr . ':' . $this->port;
$fp = @stream_socket_client($addr, $errno, $errstr,
$timeout, $flags, $context);
$fp = stream_socket_client($addr, $errno, $errstr,
$timeout, $flags, $context);
} else {
$fp = @$openfunc($this->addr, $this->port, $errno,
$errstr, $timeout, $context);
$errstr, $timeout, $context);
}
} else {
$fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $timeout);
}
if (!$fp) {
if ($errno === 0 && !strlen($errstr) && isset($php_errormsg)) {
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);
}
@@ -207,7 +185,7 @@ class Net_Socket extends PEAR
* @access public
* @return mixed true on success or a PEAR_Error instance otherwise
*/
public function disconnect()
function disconnect()
{
if (!is_resource($this->fp)) {
return $this->raiseError('not connected');
@@ -215,20 +193,18 @@ class Net_Socket extends PEAR
@fclose($this->fp);
$this->fp = null;
return true;
}
/**
* Set the newline character/sequence to use.
*
* @param string $newline Newline character(s)
* @param string $newline Newline character(s)
* @return boolean True
*/
public function setNewline($newline)
function setNewline($newline)
{
$this->newline = $newline;
return true;
}
@@ -238,7 +214,7 @@ class Net_Socket extends PEAR
* @access public
* @return boolean The current blocking mode.
*/
public function isBlocking()
function isBlocking()
{
return $this->blocking;
}
@@ -254,7 +230,7 @@ class Net_Socket extends PEAR
* @access public
* @return mixed true on success or a PEAR_Error instance otherwise
*/
public function setBlocking($mode)
function setBlocking($mode)
{
if (!is_resource($this->fp)) {
return $this->raiseError('not connected');
@@ -262,7 +238,6 @@ class Net_Socket extends PEAR
$this->blocking = $mode;
stream_set_blocking($this->fp, (int)$this->blocking);
return true;
}
@@ -270,29 +245,30 @@ class Net_Socket extends PEAR
* Sets the timeout value on socket descriptor,
* expressed in the sum of seconds and microseconds
*
* @param integer $seconds Seconds.
* @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)
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);
$seconds = (int) $this->timeout;
$microseconds = (int) (($this->timeout - $seconds) * 1000000);
} else {
$this->timeout = $seconds + $microseconds / 1000000;
$this->timeout = $seconds + $microseconds/1000000;
}
if ($this->timeout > 0) {
return stream_set_timeout($this->fp, (int)$seconds, (int)$microseconds);
} else {
return stream_set_timeout($this->fp, (int) $seconds, (int) $microseconds);
}
else {
return false;
}
}
@@ -306,17 +282,16 @@ class Net_Socket extends PEAR
* @access public
* @return mixed on success or an PEAR_Error object otherwise
*/
public function setWriteBuffer($size)
function setWriteBuffer($size)
{
if (!is_resource($this->fp)) {
return $this->raiseError('not connected');
}
$returned = stream_set_write_buffer($this->fp, $size);
if ($returned === 0) {
if ($returned == 0) {
return true;
}
return $this->raiseError('Cannot set write buffer.');
}
@@ -335,7 +310,7 @@ class Net_Socket extends PEAR
* @return mixed Array containing information about existing socket
* resource or a PEAR_Error instance otherwise
*/
public function getStatus()
function getStatus()
{
if (!is_resource($this->fp)) {
return $this->raiseError('not connected');
@@ -356,13 +331,13 @@ class Net_Socket extends PEAR
* @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)
function gets($size = null)
{
if (!is_resource($this->fp)) {
return $this->raiseError('not connected');
}
if (null === $size) {
if (is_null($size)) {
return @fgets($this->fp);
} else {
return @fgets($this->fp, $size);
@@ -378,10 +353,10 @@ class Net_Socket extends PEAR
* @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
* @return $size bytes of data from the socket, or a PEAR_Error if
* not connected.
*/
public function read($size)
function read($size)
{
if (!is_resource($this->fp)) {
return $this->raiseError('not connected');
@@ -393,7 +368,7 @@ class Net_Socket extends PEAR
/**
* Write a specified amount of data.
*
* @param string $data Data to write.
* @param string $data Data to write.
* @param integer $blocksize Amount of data to write at once.
* NULL means all at once.
*
@@ -404,17 +379,17 @@ class Net_Socket extends PEAR
* If the write fails, returns false.
* If the socket times out, returns an instance of PEAR_Error.
*/
public function write($data, $blocksize = null)
function write($data, $blocksize = null)
{
if (!is_resource($this->fp)) {
return $this->raiseError('not connected');
}
if (null === $blocksize && !OS_WINDOWS) {
if (is_null($blocksize) && !OS_WINDOWS) {
$written = @fwrite($this->fp, $data);
// Check for timeout or lost connection
if ($written === false) {
if ($written===false) {
$meta_data = $this->getStatus();
if (!is_array($meta_data)) {
@@ -428,17 +403,17 @@ class Net_Socket extends PEAR
return $written;
} else {
if (null === $blocksize) {
if (is_null($blocksize)) {
$blocksize = 1024;
}
$pos = 0;
$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) {
if ($written===false) {
$meta_data = $this->getStatus();
if (!is_array($meta_data)) {
@@ -467,7 +442,7 @@ class Net_Socket extends PEAR
* @access public
* @return mixed fwrite() result, or PEAR_Error when not connected
*/
public function writeLine($data)
function writeLine($data)
{
if (!is_resource($this->fp)) {
return $this->raiseError('not connected');
@@ -484,7 +459,7 @@ class Net_Socket extends PEAR
* @access public
* @return bool
*/
public function eof()
function eof()
{
return (!is_resource($this->fp) || feof($this->fp));
}
@@ -493,10 +468,10 @@ class Net_Socket extends PEAR
* Reads a byte of data
*
* @access public
* @return integer 1 byte of data from the socket, or a PEAR_Error if
* @return 1 byte of data from the socket, or a PEAR_Error if
* not connected.
*/
public function readByte()
function readByte()
{
if (!is_resource($this->fp)) {
return $this->raiseError('not connected');
@@ -509,17 +484,16 @@ class Net_Socket extends PEAR
* Reads a word of data
*
* @access public
* @return integer 1 word of data from the socket, or a PEAR_Error if
* @return 1 word of data from the socket, or a PEAR_Error if
* not connected.
*/
public function readWord()
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));
}
@@ -530,16 +504,15 @@ class Net_Socket extends PEAR
* @return integer 1 int of data from the socket, or a PEAR_Error if
* not connected.
*/
public function readInt()
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));
(ord($buf[2]) << 16) + (ord($buf[3]) << 24));
}
/**
@@ -549,17 +522,16 @@ class Net_Socket extends PEAR
* @return string, or a PEAR_Error if
* not connected.
*/
public function readString()
function readString()
{
if (!is_resource($this->fp)) {
return $this->raiseError('not connected');
}
$string = '';
while (($char = @fread($this->fp, 1)) !== "\x00") {
while (($char = @fread($this->fp, 1)) != "\x00") {
$string .= $char;
}
return $string;
}
@@ -567,19 +539,18 @@ class Net_Socket extends PEAR
* Reads an IP Address and returns it in a dot formatted string
*
* @access public
* @return string Dot formatted string, or a PEAR_Error if
* @return Dot formatted string, or a PEAR_Error if
* not connected.
*/
public function readIPAddress()
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]));
ord($buf[2]), ord($buf[3]));
}
/**
@@ -587,11 +558,11 @@ class Net_Socket extends PEAR
* comes first. Strips the trailing newline from the returned data.
*
* @access public
* @return string All available data up to a newline, without that
* @return 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()
function readLine()
{
if (!is_resource($this->fp)) {
return $this->raiseError('not connected');
@@ -607,7 +578,6 @@ class Net_Socket extends PEAR
return rtrim($line, $this->newline);
}
}
return $line;
}
@@ -624,19 +594,16 @@ class Net_Socket extends PEAR
* @return string All data until the socket closes, or a PEAR_Error if
* not connected.
*/
public function readAll()
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)) {
while (!feof($this->fp)) {
$data .= @fread($this->fp, $this->lineLength);
}
return $data;
}
@@ -644,22 +611,22 @@ class Net_Socket extends PEAR
* 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 $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)
function select($state, $tv_sec, $tv_usec = 0)
{
if (!is_resource($this->fp)) {
return $this->raiseError('not connected');
}
$read = null;
$write = null;
$read = null;
$write = null;
$except = null;
if ($state & NET_SOCKET_READ) {
$read[] = $this->fp;
@@ -671,8 +638,7 @@ class Net_Socket extends PEAR
$except[] = $this->fp;
}
if (false === ($sr = stream_select($read, $write, $except,
$tv_sec, $tv_usec))
) {
$tv_sec, $tv_usec))) {
return false;
}
@@ -686,16 +652,15 @@ class Net_Socket extends PEAR
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
* @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()
* @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
@@ -705,17 +670,15 @@ class Net_Socket extends PEAR
* A PEAR_Error object is returned if the socket is not
* connected
*/
public function enableCrypto($enabled, $type)
function enableCrypto($enabled, $type)
{
if (version_compare(phpversion(), '5.1.0', '>=')) {
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);
}
}

View File

@@ -1,43 +0,0 @@
# Net_Socket - Network Socket Interface
[![Build Status](https://travis-ci.org/pear/Net_Socket.svg?branch=master)](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

View File

@@ -25,7 +25,7 @@
"include-path": [
"./"
],
"license": "BSD-2-Clause",
"license": "PHP License",
"name": "pear/net_socket",
"support": {
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Net_Socket",
@@ -33,10 +33,9 @@
},
"type": "library",
"require": {
"php": ">=5.4.0",
"pear/pear_exception": "@stable"
"pear/pear_exception": "*"
},
"require-dev": {
"phpunit/phpunit": "^4"
"phpunit/phpunit": "*"
}
}
}

View File

@@ -11,7 +11,7 @@
<name>Chuck Hagenbuch</name>
<user>chagenbu</user>
<email>chuck@horde.org</email>
<active>no</active>
<active>yes</active>
</lead>
<lead>
<name>Stig Bakken</name>
@@ -23,35 +23,34 @@
<name>Aleksander Machniak</name>
<user>alec</user>
<email>alec@php.net</email>
<active>no</active>
<active>yes</active>
</lead>
<date>2017-04-06</date>
<date>2013-05-24</date>
<time>20:00:00</time>
<version>
<release>1.2.1</release>
<api>1.2.0</api>
<release>1.0.14</release>
<api>1.0.10</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://www.opensource.org/licenses/bsd-license.php">BSD-2-Clause</license>
<license uri="http://www.php.net/license/2_02.txt">PHP License</license>
<notes>
* Fix BSD-2 licensing
- Fix connecting when host is specified with protocol prefix e.g. ssl://
</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" />
<file baseinstalldir="/" md5sum="057d5c52b2dd9cfb2a458d532d95cfbb" name="Net/Socket.php" role="php" />
</dir>
</contents>
<dependencies>
<required>
<php>
<min>5.4.0</min>
<min>4.3.0</min>
</php>
<pearinstaller>
<min>1.10.1</min>
<min>1.4.0b1</min>
</pearinstaller>
</required>
</dependencies>

View File

@@ -1,29 +0,0 @@
<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>

View File

@@ -195,9 +195,22 @@ class OS_Guess
}
$major = $minor = 0;
include_once "System.php";
if (@is_link('/lib64/libc.so.6')) {
// Let's try reading the libc.so.6 symlink
if (preg_match('/^libc-(.*)\.so$/', basename(readlink('/lib64/libc.so.6')), $matches)) {
list($major, $minor) = explode('.', $matches[1]);
}
} else if (@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]);
}
}
// Use glibc's <features.h> header file to
// get major and minor version number:
if (@file_exists('/usr/include/features.h') &&
if (!($major && $minor) &&
@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');
@@ -240,7 +253,7 @@ class OS_Guess
fclose($fp);
$cpp = popen("/usr/bin/cpp $tmpfile", "r");
while ($line = fgets($cpp, 1024)) {
if ($line{0} == '#' || trim($line) == '') {
if ($line[0] == '#' || trim($line) == '') {
continue;
}
@@ -252,13 +265,6 @@ class OS_Guess
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 = '';
}

View File

@@ -170,7 +170,7 @@ class PEAR
$destructor = "_$classname";
if (method_exists($this, $destructor)) {
global $_PEAR_destructor_object_list;
$_PEAR_destructor_object_list[] = &$this;
$_PEAR_destructor_object_list[] = $this;
if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
register_shutdown_function("_PEAR_call_destructors");
$GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
@@ -542,7 +542,7 @@ class PEAR
count($object->_expected_errors) > 0 &&
count($exp = end($object->_expected_errors))
) {
if ($exp[0] == "*" ||
if ($exp[0] === "*" ||
(is_int(reset($exp)) && in_array($code, $exp)) ||
(is_string(reset($exp)) && in_array($message, $exp))
) {
@@ -598,11 +598,11 @@ class PEAR
protected static function _throwError($object, $message = null, $code = null, $userinfo = null)
{
if ($object !== null) {
$a = &$object->raiseError($message, $code, null, null, $userinfo);
$a = $object->raiseError($message, $code, null, null, $userinfo);
return $a;
}
$a = &PEAR::raiseError($message, $code, null, null, $userinfo);
$a = PEAR::raiseError($message, $code, null, null, $userinfo);
return $a;
}
@@ -766,6 +766,28 @@ class PEAR
return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);
}
/**
* Get SOURCE_DATE_EPOCH environment variable
* See https://reproducible-builds.org/specs/source-date-epoch/
*
* @return int
* @access public
*/
static function getSourceDateEpoch()
{
if ($source_date_epoch = getenv('SOURCE_DATE_EPOCH')) {
if (preg_match('/^\d+$/', $source_date_epoch)) {
return (int) $source_date_epoch;
} else {
// "If the value is malformed, the build process SHOULD exit with a non-zero error code."
self::raiseError("Invalid SOURCE_DATE_EPOCH: $source_date_epoch");
exit(1);
}
} else {
return time();
}
}
}
function _PEAR_call_destructors()
@@ -782,7 +804,7 @@ function _PEAR_call_destructors()
$_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list);
}
while (list($k, $objref) = each($_PEAR_destructor_object_list)) {
foreach ($_PEAR_destructor_object_list as $k => $objref) {
$classname = get_class($objref);
while ($classname) {
$destructor = "_$classname";

View File

@@ -676,7 +676,7 @@ class PEAR_ErrorStack {
* @return boolean
* @since PEAR1.5.0a1
*/
function staticPop($package)
static function staticPop($package)
{
if ($package) {
if (!isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) {

View File

@@ -74,7 +74,7 @@ class System
$offset = 0;
foreach ($av as $a) {
$b = trim($a[0]);
if ($b{0} == '"' || $b{0} == "'") {
if ($b[0] == '"' || $b[0] == "'") {
continue;
}
@@ -265,7 +265,7 @@ class System
} 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') {
if (strlen($opt[1]) && $opt[1][0] == '0') {
$opt[1] = octdec($opt[1]);
} else {
// convert to int
@@ -315,7 +315,7 @@ class System
* 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)
* Note: as the class use fopen, urls should work also
*
* @param string $args the arguments
* @return boolean true on success
@@ -480,7 +480,7 @@ class System
if ($var = isset($_ENV['TMPDIR']) ? $_ENV['TMPDIR'] : getenv('TMPDIR')) {
return $var;
}
return realpath('/tmp');
return realpath(function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : '/tmp');
}
/**
@@ -527,8 +527,14 @@ class System
foreach ($exe_suffixes as $suff) {
foreach ($path_elements as $dir) {
$file = $dir . DIRECTORY_SEPARATOR . $program . $suff;
if (is_executable($file)) {
// It's possible to run a .bat on Windows that is_executable
// would return false for. The is_executable check is meaningless...
if (OS_WINDOWS) {
return $file;
} else {
if (is_executable($file)) {
return $file;
}
}
}
}
@@ -619,4 +625,4 @@ class System
}
return $files;
}
}
}

View File

@@ -21,9 +21,7 @@
"php": ">=4.4.0"
},
"autoload": {
"psr-0": {
"PEAR": ""
}
"classmap": ["PEAR/"]
},
"extra": {
"branch-alias": {