PMCORE-3844

This commit is contained in:
Julio Cesar Laura Avendaño
2022-05-26 14:56:23 +00:00
committed by Mauricio Veliz
parent 7bb67a97bd
commit 9f1b738093
82 changed files with 300 additions and 552 deletions

View File

@@ -742,7 +742,7 @@ class DB_Error extends PEAR_Error
*
* @see PEAR_Error
*/
function DB_Error($code = DB_ERROR, $mode = PEAR_ERROR_RETURN,
function __construct($code = DB_ERROR, $mode = PEAR_ERROR_RETURN,
$level = E_USER_NOTICE, $debuginfo = null)
{
if (is_int($code)) {
@@ -794,7 +794,7 @@ class DB_result
* @param resource $result result resource id
* @param array $options assoc array with optional result options
*/
function DB_result(&$dbh, $result, $options = array())
function __construct(&$dbh, $result, $options = array())
{
$this->dbh = &$dbh;
$this->result = $result;
@@ -1093,7 +1093,7 @@ class DB_row
*
* @param resource row data as array
*/
function DB_row(&$arr)
function __construct(&$arr)
{
foreach ($arr as $key => $value) {
$this->$key = &$arr[$key];

View File

@@ -146,7 +146,7 @@ class DB_common extends PEAR
/**
* Constructor
*/
function DB_common()
function __construct()
{
$this->PEAR('DB_Error');
}
@@ -167,7 +167,7 @@ class DB_common extends PEAR
function quoteString($string)
{
$string = $this->quote($string);
if ($string{0} == "'") {
if ($string[0] == "'") {
return substr($string, 1, -1);
}
return $string;

View File

@@ -115,7 +115,7 @@ class DB_mysqli extends DB_common
*
* @access public
*/
function DB_mysqli()
function __construct()
{
$this->DB_common();
$this->phptype = 'mysqli';
@@ -168,7 +168,6 @@ class DB_mysqli extends DB_common
$this->dsn = $dsninfo;
$conn = false;
@ini_set('track_errors', true);
if ($this->getOption('ssl') === true) {
$init = mysqli_init();
@@ -201,17 +200,16 @@ class DB_mysqli extends DB_common
);
}
@ini_restore('track_errors');
if (!$conn) {
$lastError = error_get_last();
if (($err = @mysqli_connect_error()) != '') {
return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null,
null, $err);
} elseif (empty($php_errormsg)) {
} elseif (empty($lastError['message'])) {
return $this->raiseError(DB_ERROR_CONNECT_FAILED);
} else {
return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null,
null, $php_errormsg);
null, $lastError['message']);
}
}

View File

@@ -65,7 +65,7 @@ class DB_oci8 extends DB_common
// }}}
// {{{ constructor
function DB_oci8()
function __construct()
{
$this->DB_common();
$this->phptype = 'oci8';
@@ -501,7 +501,7 @@ class DB_oci8 extends DB_common
if ($this->manip_query[(int)$stmt]) {
$tmp = DB_OK;
} else {
$tmp =& new DB_result($this, $stmt);
$tmp = new DB_result($this, $stmt);
}
return $tmp;
}

View File

@@ -50,7 +50,7 @@ class DB_odbc extends DB_common
// }}}
// {{{ constructor
function DB_odbc()
function __construct()
{
$this->DB_common();
$this->phptype = 'odbc';

View File

@@ -51,7 +51,7 @@ class DB_pgsql extends DB_common
// }}}
// {{{ constructor
function DB_pgsql()
function __construct()
{
$this->DB_common();
$this->phptype = 'pgsql';
@@ -127,13 +127,13 @@ class DB_pgsql extends DB_common
if ($ini) {
$conn = @$connect_function($connstr);
} else {
ini_set('track_errors', 1);
$conn = @$connect_function($connstr);
ini_set('track_errors', $ini);
}
if ($conn == false) {
$lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Connection error.';
return $this->raiseError(DB_ERROR_CONNECT_FAILED, null,
null, null, strip_tags($php_errormsg));
null, null, strip_tags($errorMessage));
}
$this->connection = $conn;
return DB_OK;

View File

@@ -42,7 +42,7 @@ class Log_composite extends Log
*
* @access public
*/
function Log_composite($name, $ident = '', $conf = array(),
function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
$this->_ident = $ident;

View File

@@ -64,7 +64,7 @@ class Log_console extends Log
* @param int $level Log messages up to and including this level.
* @access public
*/
function Log_console($name, $ident = '', $conf = array(),
function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
if(!class_exists('G')){

View File

@@ -66,7 +66,7 @@ class Log_daemon extends Log
* @param int $maxLevel Maximum level at which to log.
* @access public
*/
function Log_daemon($name, $ident = '', $conf = array(),
function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
/* Ensure we have a valid integer value for $name. */

View File

@@ -51,7 +51,7 @@ class Log_display extends Log
* @param int $level Log messages up to and including this level.
* @access public
*/
function Log_display($name = '', $ident = '', $conf = array(),
function __construct($name = '', $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
if(!class_exists('G')){

View File

@@ -49,7 +49,7 @@ class Log_error_log extends Log
* @param int $level Log messages up to and including this level.
* @access public
*/
function Log_error_log($name, $ident = '', $conf = array(),
function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
if(!class_exists('G')){

View File

@@ -95,7 +95,7 @@ class Log_file extends Log
* @param int $level Log messages up to and including this level.
* @access public
*/
function Log_file($name, $ident = '', $conf = array(),
function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
if(!class_exists('G')){

View File

@@ -78,7 +78,7 @@ class Log_firebug extends Log
* @param int $level Log messages up to and including this level.
* @access public
*/
function Log_firebug($name = '', $ident = 'PHP', $conf = array(),
function __construct($name = '', $ident = 'PHP', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
if(!class_exists('G')){

View File

@@ -100,7 +100,7 @@ class Log_mail extends Log
* @param int $level Log messages up to and including this level.
* @access public
*/
function Log_mail($name, $ident = '', $conf = array(),
function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
if(!class_exists('G')){

View File

@@ -71,7 +71,7 @@ class Log_mcal extends Log
* @param int $level Log messages up to and including this level.
* @access public
*/
function Log_mcal($name, $ident = '', $conf = array(),
function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
if(!class_exists('G')){

View File

@@ -112,7 +112,7 @@ class Log_mdb2 extends Log
* @param int $level Log messages up to and including this level.
* @access public
*/
function Log_mdb2($name, $ident = '', $conf = array(),
function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
if(!class_exists('G')){

View File

@@ -27,7 +27,7 @@ class Log_null extends Log
* @param int $level Log messages up to and including this level.
* @access public
*/
function Log_null($name, $ident = '', $conf = array(),
function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
if(!class_exists('G')){

View File

@@ -47,7 +47,7 @@ class Log_observer
*
* @access public
*/
function Log_observer($priority = PEAR_LOG_INFO)
function __construct($priority = PEAR_LOG_INFO)
{
$this->_id = $this->encryptOld(microtime());
$this->_priority = $priority;
@@ -78,7 +78,7 @@ class Log_observer
* instance.
*/
if (class_exists($class)) {
$object = &new $class($priority, $conf);
$object = new $class($priority, $conf);
return $object;
}
@@ -102,9 +102,9 @@ class Log_observer
if (class_exists($class)) {
/* Support both new-style and old-style construction. */
if ($newstyle) {
$object = &new $class($priority, $conf);
$object = new $class($priority, $conf);
} else {
$object = &new $class($priority);
$object = new $class($priority);
}
return $object;
}

View File

@@ -117,7 +117,7 @@ class Log_sql extends Log
* @param int $level Log messages up to and including this level.
* @access public
*/
function Log_sql($name, $ident = '', $conf = array(),
function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
$this->_id = $this->encryptOld(microtime());

View File

@@ -46,7 +46,7 @@ class Log_syslog extends Log
* @param int $level Log messages up to and including this level.
* @access public
*/
function Log_syslog($name, $ident = '', $conf = array(),
function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
/* Ensure we have a valid integer value for $name. */

View File

@@ -69,7 +69,7 @@ class Log_win extends Log
* @param int $level Log messages up to and including this level.
* @access public
*/
function Log_win($name, $ident = '', $conf = array(),
function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
$this->_id = $this->encryptOld(microtime());

View File

@@ -83,7 +83,7 @@ class OS_Guess
var $release;
var $extra;
function OS_Guess($uname = null)
function __construct($uname = null)
{
list($this->sysname,
$this->release,
@@ -136,10 +136,10 @@ class OS_Guess
case 'Linux':
$extra = $this->_detectGlibcVersion();
// use only the first two digits from the kernel version
$release = ereg_replace('^([[:digit:]]+\.[[:digit:]]+).*', '\1', $parts[2]);
$release = preg_replace('/^([[:digit:]]+\.[[:digit:]]+).*/', '\1', $parts[2]);
break;
default:
$release = ereg_replace('-.*', '', $parts[2]);
$release = preg_replace('/-.*/', '', $parts[2]);
break;
}
@@ -167,7 +167,7 @@ class OS_Guess
$cpp = popen("/usr/bin/cpp $tmpfile", "r");
$major = $minor = 0;
while ($line = fgets($cpp, 1024)) {
if ($line{0} == '#') {
if ($line[0] == '#') {
continue;
}
if (list($major, $minor) = explode(' ', trim($line))) {
@@ -178,7 +178,7 @@ class OS_Guess
unlink($tmpfile);
if (!($major && $minor) && file_exists('/lib/libc.so.6')) {
// Let's try reading the libc.so.6 symlink
if (ereg('^libc-([.*])\.so$', basename(readlink('/lib/libc.so.6')), $matches)) {
if (preg_match('/^libc-([.*])\.so$/', basename(readlink('/lib/libc.so.6')), $matches)) {
list($major, $minor) = explode('.', $matches);
}
}

View File

@@ -121,11 +121,11 @@ class PEAR_Autoloader extends PEAR
$include_file = preg_replace('/[^a-z0-9]/i', '_', $classname);
include_once $include_file;
}
$obj =& new $classname;
$obj = new $classname;
$methods = get_class_methods($classname);
foreach ($methods as $method) {
// don't import priviate methods and constructors
if ($method{0} != '_' && $method != $classname) {
if ($method[0] != '_' && $method != $classname) {
$this->_method_map[$method] = $obj;
}
}
@@ -145,7 +145,7 @@ class PEAR_Autoloader extends PEAR
$ok = false;
$classname = strtolower($classname);
reset($this->_method_map);
while (list($method, $obj) = each($this->_method_map)) {
foreach ($this->_method_map as $method => $obj) {
if (is_object($obj) && get_class($obj) == $classname) {
unset($this->_method_map[$method]);
$ok = true;
@@ -168,7 +168,7 @@ class PEAR_Autoloader extends PEAR
* @return mixed The return value from the aggregated method, or a PEAR
* error if the called method was unknown.
*/
function __call($method, $args, &$retval)
function __call($method, $args)
{
if (empty($this->_method_map[$method]) && isset($this->_autoload_map[$method])) {
$this->addAggregateObject($this->_autoload_map[$method]);

View File

@@ -50,7 +50,7 @@ class PEAR_Builder extends PEAR_Common
*
* @access public
*/
function PEAR_Builder(&$ui)
function __construct(&$ui)
{
parent::PEAR_Common();
$this->setFrontendObject($ui);
@@ -123,7 +123,7 @@ class PEAR_Builder extends PEAR_Common
$dsp = $filter->validateInput($dsp,"path");
// msdev doesn't tell us the output directory :/
// open the dsp, find /out and use that directory
$dsptext = join(file($dsp),'');
$dsptext = implode('', file($dsp));
// this regex depends on the build platform and type having been
// correctly identified above.
@@ -280,7 +280,7 @@ class PEAR_Builder extends PEAR_Common
}
$built_files = array();
while ($ent = readdir($dp)) {
if ($ent{0} == '.' || substr($ent, -3) == '.la') {
if ($ent[0] == '.' || substr($ent, -3) == '.la') {
continue;
}
// harvest!

View File

@@ -119,7 +119,7 @@ class PEAR_Command
return PEAR::raiseError("unknown command `$command'");
}
$ui = PEAR_Command::getFrontendObject();
$obj = &new $class($ui, $config);
$obj = new $class($ui, $config);
return $obj;
}
@@ -131,7 +131,7 @@ class PEAR_Command
function &getFrontendObject()
{
if (empty($GLOBALS['_PEAR_Command_uiobject'])) {
$GLOBALS['_PEAR_Command_uiobject'] = &new $GLOBALS['_PEAR_Command_uiclass'];
$GLOBALS['_PEAR_Command_uiobject'] = new $GLOBALS['_PEAR_Command_uiclass'];
}
return $GLOBALS['_PEAR_Command_uiobject'];
}
@@ -152,7 +152,7 @@ class PEAR_Command
$file = str_replace('_', '/', $uiclass) . '.php';
@include_once $file;
if (class_exists(strtolower($uiclass))) {
$obj = &new $uiclass;
$obj = new $uiclass;
// quick test to see if this class implements a few of the most
// important frontend methods
if (method_exists($obj, 'userConfirm')) {
@@ -209,7 +209,7 @@ class PEAR_Command
$GLOBALS['_PEAR_Command_commandlist'] = array();
}
while ($entry = readdir($dp)) {
if ($entry{0} == '.' || substr($entry, -4) != '.php' || $entry == 'Common.php') {
if ($entry[0] == '.' || substr($entry, -4) != '.php' || $entry == 'Common.php') {
continue;
}
$class = "PEAR_Command_".substr($entry, 0, -4);
@@ -217,7 +217,7 @@ class PEAR_Command
include_once $file;
// List of commands
if (empty($GLOBALS['_PEAR_Command_objects'][$class])) {
$GLOBALS['_PEAR_Command_objects'][$class] = &new $class($ui, $config);
$GLOBALS['_PEAR_Command_objects'][$class] = new $class($ui, $config);
}
$implements = $GLOBALS['_PEAR_Command_objects'][$class]->getCommands();
foreach ($implements as $command => $desc) {

View File

@@ -66,7 +66,7 @@ password from your user configuration.',
*
* @access public
*/
function PEAR_Command_Auth(&$ui, &$config)
function __construct(&$ui, &$config)
{
parent::PEAR_Command_Common($ui, $config);
}

View File

@@ -51,7 +51,7 @@ Builds one or more extensions contained in a package.'
*
* @access public
*/
function PEAR_Command_Build(&$ui, &$config)
function __construct(&$ui, &$config)
{
parent::PEAR_Command_Common($ui, $config);
}
@@ -65,7 +65,7 @@ Builds one or more extensions contained in a package.'
if (sizeof($params) < 1) {
$params[0] = 'package.xml';
}
$builder = &new PEAR_Builder($this->ui);
$builder = new PEAR_Builder($this->ui);
$this->verbose = $this->config->get('verbose');
$err = $builder->build($params[0], array(&$this, 'buildCallback'));
if (PEAR::isError($err)) {

View File

@@ -13,7 +13,7 @@
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Stig S<>ther Bakken <ssb@php.net> |
// | Author: Stig S<>ther Bakken <ssb@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: Common.php,v 1.22 2003/03/18 12:06:07 ssb Exp $
@@ -68,7 +68,7 @@ class PEAR_Command_Common extends PEAR
*
* @access public
*/
function PEAR_Command_Common(&$ui, &$config)
function __construct(&$ui, &$config)
{
parent::PEAR();
$this->config = &$config;
@@ -131,10 +131,10 @@ class PEAR_Command_Common extends PEAR
return;
}
reset($this->commands[$command]);
while (list($option, $info) = each($this->commands[$command]['options'])) {
foreach ($this->commands[$command]['options'] as $option => $info) {
$larg = $sarg = '';
if (isset($info['arg'])) {
if ($info['arg']{0} == '(') {
if ($info['arg'][0] == '(') {
$larg = '==';
$sarg = '::';
$arg = substr($info['arg'], 1, -1);
@@ -195,7 +195,7 @@ class PEAR_Command_Common extends PEAR
$help = "Options:\n";
foreach ($this->commands[$command]['options'] as $k => $v) {
if (isset($v['arg'])) {
if ($v['arg']{0} == '(') {
if ($v['arg'][0] == '(') {
$arg = substr($v['arg'], 1, -1);
$sapp = " [$arg]";
$lapp = "[=$arg]";

View File

@@ -91,7 +91,7 @@ displays help for all configuration parameters.
*
* @access public
*/
function PEAR_Command_Config(&$ui, &$config)
function __construct(&$ui, &$config)
{
parent::PEAR_Command_Common($ui, $config);
}

View File

@@ -13,7 +13,7 @@
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Stig S<>ther Bakken <ssb@php.net> |
// | Author: Stig S<>ther Bakken <ssb@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: Install.php,v 1.42 2003/03/18 12:06:07 ssb Exp $
@@ -207,7 +207,7 @@ specified at once.
*
* @access public
*/
function PEAR_Command_Install(&$ui, &$config)
function __construct(&$ui, &$config)
{
parent::PEAR_Command_Common($ui, $config);
}
@@ -219,7 +219,7 @@ specified at once.
function doInstall($command, $options, $params)
{
if (empty($this->installer)) {
$this->installer = &new PEAR_Installer($this->ui);
$this->installer = new PEAR_Installer($this->ui);
}
if ($command == 'upgrade') {
$options[$command] = true;
@@ -279,7 +279,7 @@ specified at once.
function doUninstall($command, $options, $params)
{
if (empty($this->installer)) {
$this->installer = &new PEAR_Installer($this->ui);
$this->installer = new PEAR_Installer($this->ui);
}
if (sizeof($params) < 1) {
return $this->raiseError("Please supply the package(s) you want to uninstall");

View File

@@ -55,7 +55,7 @@ class PEAR_Command_Mirror extends PEAR_Command_Common
* @param object PEAR_Frontend a reference to an frontend
* @param object PEAR_Config a reference to the configuration data
*/
function PEAR_Command_Mirror(&$ui, &$config)
function __construct(&$ui, &$config)
{
parent::PEAR_Command_Common($ui, $config);
}
@@ -77,7 +77,7 @@ class PEAR_Command_Mirror extends PEAR_Command_Common
function doDownloadAll($command, $options, $params)
{
$this->config->set("php_dir", ".");
$remote = &new PEAR_Remote($this->config);
$remote = new PEAR_Remote($this->config);
$remoteInfo = $remote->call("package.listAll");
if(PEAR::isError($remoteInfo)) {
return $remoteInfo;

View File

@@ -209,7 +209,7 @@ Wrote: /usr/src/redhat/RPMS/i386/PEAR::Net_Socket-1.0-1.i386.rpm
*
* @access public
*/
function PEAR_Command_Package(&$ui, &$config)
function __construct(&$ui, &$config)
{
parent::PEAR_Command_Common($ui, $config);
}
@@ -243,7 +243,7 @@ Wrote: /usr/src/redhat/RPMS/i386/PEAR::Net_Socket-1.0-1.i386.rpm
$this->output = '';
include_once 'PEAR/Packager.php';
$pkginfofile = isset($params[0]) ? $params[0] : 'package.xml';
$packager =& new PEAR_Packager($this->config->get('php_dir'),
$packager = new PEAR_Packager($this->config->get('php_dir'),
$this->config->get('ext_dir'),
$this->config->get('doc_dir'));
$packager->debug = $this->config->get('verbose');
@@ -322,7 +322,7 @@ Wrote: /usr/src/redhat/RPMS/i386/PEAR::Net_Socket-1.0-1.i386.rpm
$obj->validatePackageInfo($info, $err, $warn);
if (!$this->_displayValidationResults($err, $warn, true)) {
$this->ui->outputData($this->output, $command);
break;
return;
}
$version = $info['version'];
$cvsversion = preg_replace('/[^a-z0-9]/i', '_', $version);
@@ -635,7 +635,7 @@ Wrote: /usr/src/redhat/RPMS/i386/PEAR::Net_Socket-1.0-1.i386.rpm
if (!$fp) {
return $this->raiseError("could not open RPM spec file template $spec_template: $php_errormsg");
}
$spec_contents = preg_replace('/@([a-z0-9_-]+)@/e', '$info["\1"]', fread($fp, filesize($spec_template)));
$spec_contents = preg_replace_callback('/@([a-z0-9_-]+)@/', function($matches) use ($info) {return $info[$matches[1]];}, fread($fp, filesize($spec_template)));
fclose($fp);
$spec_file = "$info[rpm_package]-$info[version].spec";
$wp = fopen($spec_file, "w");
@@ -652,4 +652,4 @@ Wrote: /usr/src/redhat/RPMS/i386/PEAR::Net_Socket-1.0-1.i386.rpm
// }}}
}
?>
?>

View File

@@ -70,7 +70,7 @@ installed package.'
*
* @access public
*/
function PEAR_Command_Registry(&$ui, &$config)
function __construct(&$ui, &$config)
{
parent::PEAR_Command_Common($ui, $config);
}
@@ -108,7 +108,7 @@ installed package.'
} else {
if (file_exists($params[0]) && !is_dir($params[0])) {
include_once "PEAR/Common.php";
$obj = &new PEAR_Common;
$obj = new PEAR_Common;
$info = $obj->infoFromAny($params[0]);
$headings = array('Package File', 'Install Path');
$installed = false;
@@ -181,7 +181,7 @@ installed package.'
function doShellTest($command, $options, $params)
{
$this->pushErrorHandling(PEAR_ERROR_RETURN);
$reg = &new PEAR_Registry($this->config->get('php_dir'));
$reg = new PEAR_Registry($this->config->get('php_dir'));
// "pear shell-test Foo"
if (sizeof($params) == 1) {
if (!$reg->packageExists($params[0])) {
@@ -217,10 +217,10 @@ installed package.'
"the package you want information");
}
if (@is_file($params[0])) {
$obj = &new PEAR_Common();
$obj = new PEAR_Common();
$info = $obj->infoFromAny($params[0]);
} else {
$reg = &new PEAR_Registry($this->config->get('php_dir'));
$reg = new PEAR_Registry($this->config->get('php_dir'));
$info = $reg->packageInfo($params[0]);
}
if (PEAR::isError($info)) {

View File

@@ -133,7 +133,7 @@ class PEAR_Common extends PEAR
*
* @access public
*/
function PEAR_Common()
function __construct()
{
parent::PEAR();
$this->config = &PEAR_Config::singleton();
@@ -503,7 +503,7 @@ class PEAR_Common extends PEAR
switch ($this->prev_element) {
case 'package':
// XXX should we check the package name here?
$this->pkginfo['package'] = ereg_replace('[^a-zA-Z0-9._]', '_', $data);
$this->pkginfo['package'] = preg_replace('/[^a-zA-Z0-9._]/', '_', $data);
break;
case 'maintainer':
$this->current_maintainer['name'] = $data;
@@ -527,7 +527,7 @@ class PEAR_Common extends PEAR
$this->current_maintainer['role'] = $data;
break;
case 'version':
$data = ereg_replace ('[^a-zA-Z0-9._\-]', '_', $data);
$data = preg_replace ('/[^a-zA-Z0-9._\-]/', '_', $data);
if ($this->in_changelog) {
$this->current_release['version'] = $data;
} else {
@@ -680,7 +680,7 @@ class PEAR_Common extends PEAR
if ($name == 'package.xml') {
$xml = $name;
break;
} elseif (ereg('package.xml$', $name, $match)) {
} elseif (preg_match('/package.xml$/', $name, $match)) {
$xml = $match[0];
break;
}
@@ -1187,7 +1187,7 @@ class PEAR_Common extends PEAR
foreach ($methods as $method) {
$function = "$class::$method";
$key = "function;$function";
if ($method{0} == '_' || !strcasecmp($method, $class) ||
if ($method[0] == '_' || !strcasecmp($method, $class) ||
isset($this->pkginfo['provides'][$key])) {
continue;
}
@@ -1197,7 +1197,7 @@ class PEAR_Common extends PEAR
}
foreach ($srcinfo['declared_functions'] as $function) {
$key = "function;$function";
if ($function{0} == '_' || isset($this->pkginfo['provides'][$key])) {
if ($function[0] == '_' || isset($this->pkginfo['provides'][$key])) {
continue;
}
$this->pkginfo['provides'][$key] =
@@ -1661,7 +1661,9 @@ class PEAR_Common extends PEAR
if (!$wp = @fopen($dest_file, 'wb')) {
fclose($fp);
if ($callback) {
call_user_func($callback, 'writefailed', array($dest_file, $php_errormsg));
$lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Error writing the file.';
call_user_func($callback, 'writefailed', array($dest_file, $errorMessage));
}
return PEAR::raiseError("could not open $dest_file for writing");
}
@@ -1682,7 +1684,9 @@ class PEAR_Common extends PEAR
if (!@fwrite($wp, $data)) {
fclose($fp);
if ($callback) {
call_user_func($callback, 'writefailed', array($dest_file, $php_errormsg));
$lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Error writing the file.';
call_user_func($callback, 'writefailed', array($dest_file, $errorMessage));
}
return PEAR::raiseError("$dest_file: write failed ($php_errormsg)");
}

View File

@@ -388,7 +388,7 @@ class PEAR_Config extends PEAR
*
* @see PEAR_Config::singleton
*/
function PEAR_Config($user_file = '', $system_file = '')
function __construct($user_file = '', $system_file = '')
{
$this->PEAR();
$sl = DIRECTORY_SEPARATOR;
@@ -445,7 +445,7 @@ class PEAR_Config extends PEAR
return $GLOBALS['_PEAR_Config_instance'];
}
$GLOBALS['_PEAR_Config_instance'] =
&new PEAR_Config($user_file, $system_file);
new PEAR_Config($user_file, $system_file);
return $GLOBALS['_PEAR_Config_instance'];
}

View File

@@ -45,7 +45,7 @@ class PEAR_Dependency
* @param object Registry object
* @return void
*/
function PEAR_Dependency(&$registry)
function __construct(&$registry)
{
$this->registry = &$registry;
}

View File

@@ -13,7 +13,7 @@
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Stig S<>ther Bakken <ssb@php.net> |
| Author: Stig S<>ther Bakken <ssb@php.net> |
+----------------------------------------------------------------------+
$Id: CLI.php,v 1.31 2003/04/03 23:12:40 ssb Exp $
@@ -43,7 +43,7 @@ class PEAR_Frontend_CLI extends PEAR
// {{{ constructor
function PEAR_Frontend_CLI()
function __construct()
{
parent::PEAR();
$term = getenv('TERM'); //(cox) $_ENV is empty for me in 4.1.1

View File

@@ -109,12 +109,12 @@ class PEAR_Installer extends PEAR_Common
*
* @access public
*/
function PEAR_Installer(&$ui)
function __construct(&$ui)
{
parent::PEAR_Common();
$this->setFrontendObject($ui);
$this->debug = $this->config->get('verbose');
$this->registry = &new PEAR_Registry($this->config->get('php_dir'));
$this->registry = new PEAR_Registry($this->config->get('php_dir'));
}
// }}}
@@ -500,7 +500,7 @@ class PEAR_Installer extends PEAR_Common
$options['installroot'] = substr($options['installroot'], 0, -1);
}
$php_dir = $this->_prependPath($php_dir, $options['installroot']);
$this->registry = &new PEAR_Registry($php_dir);
$this->registry = new PEAR_Registry($php_dir);
$this->installroot = $options['installroot'];
} else {
$registry = &$this->registry;
@@ -578,7 +578,7 @@ class PEAR_Installer extends PEAR_Common
$dp = opendir($tmpdir);
do {
$pkgdir = readdir($dp);
} while ($pkgdir{0} == '.');
} while ($pkgdir[0] == '.');
$descfile = $tmpdir . DIRECTORY_SEPARATOR . $pkgdir . DIRECTORY_SEPARATOR . 'package.xml';
$flag_old_format = true;
@@ -681,8 +681,8 @@ class PEAR_Installer extends PEAR_Common
}
// don't want strange characters
$pkgname = ereg_replace ('[^a-zA-Z0-9._]', '_', $pkginfo['package']);
$pkgversion = ereg_replace ('[^a-zA-Z0-9._\-]', '_', $pkginfo['version']);
$pkgname = preg_replace ('/[^a-zA-Z0-9._]/', '_', $pkginfo['package']);
$pkgversion = preg_replace ('/[^a-zA-Z0-9._\-]/', '_', $pkginfo['version']);
$tmp_path = dirname($descfile);
if (substr($pkgfile, -4) != '.xml') {
$tmp_path .= DIRECTORY_SEPARATOR . $pkgname . '-' . $pkgversion;
@@ -714,7 +714,7 @@ class PEAR_Installer extends PEAR_Common
if ($this->source_files > 0 && empty($options['nobuild'])) {
$this->log(1, "$this->source_files source files, building");
$bob = &new PEAR_Builder($this->ui);
$bob = new PEAR_Builder($this->ui);
$bob->debug = $this->debug;
$built = $bob->build($descfile, array(&$this, '_buildCallback'));
if (PEAR::isError($built)) {
@@ -778,7 +778,7 @@ class PEAR_Installer extends PEAR_Common
} else {
$this->installroot = '';
}
$this->registry = &new PEAR_Registry($php_dir);
$this->registry = new PEAR_Registry($php_dir);
// Delete the files
if (PEAR::isError($err = $this->_deletePackageFiles($package))) {
@@ -799,7 +799,7 @@ class PEAR_Installer extends PEAR_Common
function checkDeps(&$pkginfo)
{
$depchecker = &new PEAR_Dependency($this->registry);
$depchecker = new PEAR_Dependency($this->registry);
$error = $errors = '';
$failed_deps = array();
if (is_array($pkginfo['release_deps'])) {
@@ -811,7 +811,7 @@ class PEAR_Installer extends PEAR_Common
}
$n = count($failed_deps);
if ($n > 0) {
$depinstaller =& new PEAR_Installer($this->ui);
$depinstaller = new PEAR_Installer($this->ui);
$to_install = array();
for ($i = 0; $i < $n; $i++) {
if (isset($failed_deps[$i]['type'])) {

View File

@@ -34,7 +34,7 @@ class PEAR_Packager extends PEAR_Common
{
// {{{ constructor
function PEAR_Packager()
function __construct()
{
parent::PEAR_Common();
}
@@ -131,7 +131,7 @@ class PEAR_Packager extends PEAR_Common
// TAR the Package -------------------------------------------
$ext = $compress ? '.tgz' : '.tar';
$dest_package = $oldcwd . DIRECTORY_SEPARATOR . $pkgver . $ext;
$tar =& new Archive_Tar($dest_package, $compress);
$tar = new Archive_Tar($dest_package, $compress);
$tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors
// ----- Creates with the package.xml file
$ok = $tar->createModify($newpkgfile, '', $tmpdir);
@@ -171,7 +171,7 @@ if (!function_exists('md5_file')) {
return $md5;
}
public function encryptOld($string)
function encryptOld($string)
{
return md5($string);
}

View File

@@ -89,7 +89,7 @@ class PEAR_Registry extends PEAR
*
* @access public
*/
function PEAR_Registry($pear_install_dir = PEAR_INSTALL_DIR)
function __construct($pear_install_dir = PEAR_INSTALL_DIR)
{
parent::PEAR();
$ds = DIRECTORY_SEPARATOR;
@@ -236,7 +236,9 @@ class PEAR_Registry extends PEAR
{
$fp = @fopen($this->filemap, 'r');
if (!$fp) {
return $this->raiseError('PEAR_Registry: could not open filemap', PEAR_REGISTRY_ERROR_FILE, null, null, $php_errormsg);
$lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Error opening filemap.';
return $this->raiseError('PEAR_Registry: could not open filemap', PEAR_REGISTRY_ERROR_FILE, null, null, $errorMessage);
}
$fsize = filesize($this->filemap);
$data = fread($fp, $fsize);
@@ -286,8 +288,9 @@ class PEAR_Registry extends PEAR
$this->lock_fp = @fopen($this->lockfile, $open_mode);
if (!is_resource($this->lock_fp)) {
$lastError = error_get_last();
return $this->raiseError("could not create lock file" .
(isset($php_errormsg) ? ": " . $php_errormsg : ""));
(isset($lastError['message']) ? ": " . $lastError['message'] : ""));
}
if (!(int)flock($this->lock_fp, $mode)) {
switch ($mode) {
@@ -357,7 +360,7 @@ class PEAR_Registry extends PEAR
return $pkglist;
}
while ($ent = readdir($dp)) {
if ($ent{0} == '.' || substr($ent, -4) != '.reg') {
if ($ent[0] == '.' || substr($ent, -4) != '.reg') {
continue;
}
$pkglist[] = substr($ent, 0, -4);
@@ -507,7 +510,7 @@ class PEAR_Registry extends PEAR
if (is_array($path)) {
static $notempty;
if (empty($notempty)) {
$notempty = create_function('$a','return !empty($a);');
$notempty = function($a){return !empty($a);};
}
$pkgs = array();
foreach ($path as $name => $attrs) {

View File

@@ -40,7 +40,7 @@ class PEAR_Remote extends PEAR
// {{{ PEAR_Remote(config_object)
function PEAR_Remote(&$config)
function __construct(&$config)
{
$this->PEAR();
$this->config = &$config;
@@ -111,14 +111,7 @@ class PEAR_Remote extends PEAR
if ($this->cache !== null && $this->cache['age'] < $cachettl) {
return $this->cache['content'];
};
if (extension_loaded("xmlrpc")) {
$result = call_user_func_array(array(&$this, 'call_epi'), $args);
if (!PEAR::isError($result)) {
$this->saveCache($_args, $result);
};
return $result;
}
if (!@include_once("XML/RPC.php")) {
return $this->raiseError("For this remote PEAR operation you need to install the XML_RPC package");
}
@@ -167,133 +160,6 @@ class PEAR_Remote extends PEAR
// }}}
// {{{ call_epi(method, [args...])
function call_epi($method)
{
do {
if (extension_loaded("xmlrpc")) {
break;
}
if (OS_WINDOWS) {
$ext = 'dll';
} elseif (PHP_OS == 'HP-UX') {
$ext = 'sl';
} elseif (PHP_OS == 'AIX') {
$ext = 'a';
} else {
$ext = 'so';
}
$ext = OS_WINDOWS ? 'dll' : 'so';
@dl("xmlrpc-epi.$ext");
if (extension_loaded("xmlrpc")) {
break;
}
@dl("xmlrpc.$ext");
if (extension_loaded("xmlrpc")) {
break;
}
return $this->raiseError("unable to load xmlrpc extension");
} while (false);
$params = func_get_args();
array_shift($params);
$method = str_replace("_", ".", $method);
$request = xmlrpc_encode_request($method, $params);
$server_host = $this->config->get("master_server");
if (empty($server_host)) {
return $this->raiseError("PEAR_Remote::call: no master_server configured");
}
$server_port = 80;
$fp = @fsockopen($server_host, $server_port);
if (!$fp) {
return $this->raiseError("PEAR_Remote::call: fsockopen(`$server_host', $server_port) failed");
}
$len = strlen($request);
$req_headers = "Host: $server_host:$server_port\r\n" .
"Content-type: text/xml\r\n" .
"Content-length: $len\r\n";
$username = $this->config->get('username');
$password = $this->config->get('password');
if ($username && $password) {
$req_headers .= "Cookie: PEAR_USER=$username; PEAR_PW=$password\r\n";
$tmp = base64_encode("$username:$password");
$req_headers .= "Authorization: Basic $tmp\r\n";
}
if ($this->cache !== null) {
$maxAge = '?maxAge='.$this->cache['lastChange'];
} else {
$maxAge = '';
};
if ($this->config->get('verbose') > 3) {
print "XMLRPC REQUEST HEADERS:\n";
var_dump($req_headers);
print "XMLRPC REQUEST BODY:\n";
var_dump($request);
}
fwrite($fp, ("POST /xmlrpc.php$maxAge HTTP/1.0\r\n$req_headers\r\n$request"));
$response = '';
$line1 = fgets($fp, 2048);
if (!preg_match('!^HTTP/[0-9\.]+ (\d+) (.*)!', $line1, $matches)) {
return $this->raiseError("PEAR_Remote: invalid HTTP response from XML-RPC server");
}
switch ($matches[1]) {
case "200": // OK
break;
case "304": // Not Modified
return $this->cache['content'];
case "401": // Unauthorized
if ($username && $password) {
return $this->raiseError("PEAR_Remote: authorization failed", 401);
} else {
return $this->raiseError("PEAR_Remote: authorization required, please log in first", 401);
}
default:
return $this->raiseError("PEAR_Remote: unexpected HTTP response", (int)$matches[1], null, null, "$matches[1] $matches[2]");
}
while (trim(fgets($fp, 2048)) != ''); // skip rest of headers
while ($chunk = fread($fp, 10240)) {
$response .= $chunk;
}
fclose($fp);
if ($this->config->get('verbose') > 3) {
print "XMLRPC RESPONSE:\n";
var_dump($response);
}
$ret = xmlrpc_decode($response);
if (is_array($ret) && isset($ret['__PEAR_TYPE__'])) {
if ($ret['__PEAR_TYPE__'] == 'error') {
if (isset($ret['__PEAR_CLASS__'])) {
$class = $ret['__PEAR_CLASS__'];
} else {
$class = "PEAR_Error";
}
if ($ret['code'] === '') $ret['code'] = null;
if ($ret['message'] === '') $ret['message'] = null;
if ($ret['userinfo'] === '') $ret['userinfo'] = null;
if (strtolower($class) == 'db_error') {
$ret = $this->raiseError(PEAR::errorMessage($ret['code']),
$ret['code'], null, null,
$ret['userinfo']);
} else {
$ret = $this->raiseError($ret['message'], $ret['code'],
null, null, $ret['userinfo']);
}
}
} elseif (is_array($ret) && sizeof($ret) == 1 && is_array($ret[0]) &&
!empty($ret[0]['faultString']) &&
!empty($ret[0]['faultCode'])) {
extract($ret[0]);
$faultString = "XML-RPC Server Fault: " .
str_replace("\n", " ", $faultString);
return $this->raiseError($faultString, $faultCode);
}
return $ret;
}
// }}}
// {{{ _encode
// a slightly extended version of XML_RPC_encode

View File

@@ -228,7 +228,7 @@ class PearSystem
} 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