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

@@ -178,4 +178,6 @@ thirdparty/pear/package-PEAR.xml
thirdparty/pear/README thirdparty/pear/README
thirdparty/pear/template.spec thirdparty/pear/template.spec
thirdparty/pear/UDDI.php thirdparty/pear/UDDI.php
thirdparty/propel-generator/classes/propel/engine/builder/sql/sqlite/SqliteDataSQLBuilder.php
thirdparty/propel-generator/classes/propel/engine/platform/SqlitePlatform.php
thirdparty/tcpdf thirdparty/tcpdf

View File

@@ -45,7 +45,7 @@ class HTMLPurifier_ChildDef_Custom extends HTMLPurifier_ChildDef
protected function _compileRegex() protected function _compileRegex()
{ {
$raw = str_replace(' ', '', $this->dtd_regex); $raw = str_replace(' ', '', $this->dtd_regex);
if ($raw{0} != '(') { if ($raw[0] != '(') {
$raw = "($raw)"; $raw = "($raw)";
} }
$el = '[#a-zA-Z0-9_.-]+'; $el = '[#a-zA-Z0-9_.-]+';

View File

@@ -784,17 +784,17 @@ class HTMLPurifier_Config
* @param array $array $_GET or $_POST array to import * @param array $array $_GET or $_POST array to import
* @param string|bool $index Index/name that the config variables are in * @param string|bool $index Index/name that the config variables are in
* @param array|bool $allowed List of allowed namespaces/directives * @param array|bool $allowed List of allowed namespaces/directives
* @param bool $mq_fix Boolean whether or not to enable magic quotes fix * @param bool $mq_fix Boolean whether or not to enable magic quotes fix (DEPRECATED, now is always in false)
* @param HTMLPurifier_ConfigSchema $schema Schema to use, if not global copy * @param HTMLPurifier_ConfigSchema $schema Schema to use, if not global copy
* *
* @return array * @return array
*/ */
public static function prepareArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true, $schema = null) public static function prepareArrayFromForm($array, $index = false, $allowed = true, $mq_fix = false, $schema = null)
{ {
if ($index !== false) { if ($index !== false) {
$array = (isset($array[$index]) && is_array($array[$index])) ? $array[$index] : array(); $array = (isset($array[$index]) && is_array($array[$index])) ? $array[$index] : array();
} }
$mq = $mq_fix && function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc(); $mq = $mq_fix;
$allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed, $schema); $allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed, $schema);
$ret = array(); $ret = array();

View File

@@ -43,8 +43,8 @@ class HTMLPurifier_Printer_HTMLDefinition extends HTMLPurifier_Printer
$ret .= $this->element('caption', 'Doctype'); $ret .= $this->element('caption', 'Doctype');
$ret .= $this->row('Name', $doctype->name); $ret .= $this->row('Name', $doctype->name);
$ret .= $this->row('XML', $doctype->xml ? 'Yes' : 'No'); $ret .= $this->row('XML', $doctype->xml ? 'Yes' : 'No');
$ret .= $this->row('Default Modules', implode($doctype->modules, ', ')); $ret .= $this->row('Default Modules', implode(', ', $doctype->modules));
$ret .= $this->row('Default Tidy Modules', implode($doctype->tidyModules, ', ')); $ret .= $this->row('Default Tidy Modules', implode(', ', $doctype->tidyModules));
$ret .= $this->end('table'); $ret .= $this->end('table');
return $ret; return $ret;
} }

View File

@@ -75,7 +75,7 @@ class HTMLPurifier_TagTransform_Font extends HTMLPurifier_TagTransform
if (isset($attr['size'])) { if (isset($attr['size'])) {
// normalize large numbers // normalize large numbers
if ($attr['size'] !== '') { if ($attr['size'] !== '') {
if ($attr['size']{0} == '+' || $attr['size']{0} == '-') { if ($attr['size'][0] == '+' || $attr['size'][0] == '-') {
$size = (int)$attr['size']; $size = (int)$attr['size'];
if ($size < -2) { if ($size < -2) {
$attr['size'] = '-2'; $attr['size'] = '-2';

View File

@@ -22,13 +22,7 @@
include_once 'creole/SQLException.php'; include_once 'creole/SQLException.php';
include_once 'creole/Connection.php'; include_once 'creole/Connection.php';
// static: use ProcessMaker\Core\System;
// track errors is used by drivers to get better error messages
// make sure it's set.
@ini_set('track_errors', true);
use ProcessMaker\Core\System;
/** /**
* This is the class that manages the database drivers. * This is the class that manages the database drivers.

View File

@@ -76,8 +76,6 @@ class OCI8Connection extends ConnectionCommon implements Connection
? 'oci_pconnect' ? 'oci_pconnect'
: 'oci_connect'; : 'oci_connect';
$encoding = !empty($dsninfo['encoding']) ? $dsninfo['encoding'] : null; $encoding = !empty($dsninfo['encoding']) ? $dsninfo['encoding'] : null;
@ini_set( 'track_errors', true );
if ( $hostspec && $port ) if ( $hostspec && $port )
{ {

View File

@@ -53,9 +53,7 @@ class PgSQLConnection extends ConnectionCommon implements Connection {
* @return void * @return void
*/ */
function connect($dsninfo, $flags = 0) function connect($dsninfo, $flags = 0)
{ {
global $php_errormsg;
if (!extension_loaded('pgsql')) { if (!extension_loaded('pgsql')) {
throw new SQLException('pgsql extension not loaded'); throw new SQLException('pgsql extension not loaded');
} }
@@ -100,9 +98,13 @@ class PgSQLConnection extends ConnectionCommon implements Connection {
} }
if (!$conn) { if (!$conn) {
// Set message error
$lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Connection error.';
// hide the password from connstr // hide the password from connstr
$cleanconnstr = preg_replace('/password=\'.*?\'($|\s)/', 'password=\'*********\'', $connstr); $cleanconnstr = preg_replace('/password=\'.*?\'($|\s)/', 'password=\'*********\'', $connstr);
throw new SQLException('Could not connect', $php_errormsg, $cleanconnstr); throw new SQLException('Could not connect', $errorMessage, $cleanconnstr);
} }
$this->dblink = $conn; $this->dblink = $conn;

View File

@@ -137,7 +137,7 @@ class PgSQLResultSet extends ResultSetCommon implements ResultSet {
$res[] = $this->strToArray(implode(',', $subarr[$in_subarr])); $res[] = $this->strToArray(implode(',', $subarr[$in_subarr]));
$in_subarr--; $in_subarr--;
} }
} elseif ($tok{0} === '{') { // we're inside a new sub-array } elseif ($tok[0] === '{') { // we're inside a new sub-array
if ('}' !== substr($tok, -1, 1)) { if ('}' !== substr($tok, -1, 1)) {
$in_subarr++; $in_subarr++;
// if sub-array has more than one element // if sub-array has more than one element

View File

@@ -143,7 +143,7 @@ class SQLStatementExtractor {
trigger_error("substring(), Endindex out of bounds must be $startpos<n<".($len-1), E_USER_ERROR); trigger_error("substring(), Endindex out of bounds must be $startpos<n<".($len-1), E_USER_ERROR);
} }
if ($startpos === $endpos) { if ($startpos === $endpos) {
return (string) $string{$startpos}; return (string) $string[$startpos];
} else { } else {
$len = $endpos-$startpos; $len = $endpos-$startpos;
} }

View File

@@ -386,7 +386,7 @@ class pakeApp
$files = preg_replace('/^'.preg_quote(realpath($target_dir), '/').'/', '', $files); $files = preg_replace('/^'.preg_quote(realpath($target_dir), '/').'/', '', $files);
// remove leading / // remove leading /
$files = array_map(create_function('$f', 'return 0 === strpos($f, DIRECTORY_SEPARATOR) ? substr($f, 1) : $f;'), $files); $files = array_map(function($f){return 0 === strpos($f, DIRECTORY_SEPARATOR) ? substr($f, 1) : $f;}, $files);
} }
return $files; return $files;

View File

@@ -409,7 +409,6 @@ if (false !== strpos(PHP_SAPI, 'cgi'))
// PHP ini settings // PHP ini settings
set_time_limit(0); set_time_limit(0);
ini_set('track_errors', true);
ini_set('html_errors', false); ini_set('html_errors', false);
// define stream constants // define stream constants

View File

@@ -72,7 +72,7 @@ class pakeGetopt
if (is_string($args)) if (is_string($args))
{ {
// hack to split arguments with spaces : --test="with some spaces" // hack to split arguments with spaces : --test="with some spaces"
$args = preg_replace('/(\'|")(.+?)\\1/e', "str_replace(' ', '=PLACEHOLDER=', '\\2')", $args); $args = preg_replace_callback('/(\'|")(.+?)\\1/', function($matches){return str_replace(' ', '=PLACEHOLDER=', $matches['2']);}, $args);
$args = preg_split('/\s+/', $args); $args = preg_split('/\s+/', $args);
$args = str_replace('=PLACEHOLDER=', ' ', $args); $args = str_replace('=PLACEHOLDER=', ' ', $args);
} }

View File

@@ -874,7 +874,7 @@
$ret = array(); $ret = array();
foreach($keys as $key) { foreach($keys as $key) {
list($unused,$val) = each($vals); list($unused,$val) = self::each($vals);
// This is the good part! If a key already exists, but it's part of a // This is the good part! If a key already exists, but it's part of a
// sequence (an int), just keep addin numbers until we find a fresh one. // sequence (an int), just keep addin numbers until we find a fresh one.
if (isset($ret[$key]) and is_int($key)) { if (isset($ret[$key]) and is_int($key)) {
@@ -887,4 +887,23 @@
return $ret; return $ret;
} }
/**
* Legacy "each" function, because was removed in PHP v8.x
*
* @param $array
* @return array|bool
*/
private static function each($array) {
$key = key($array);
$value = current($array);
$each = is_null($key) ? false : [
1 => $value,
'value' => $value,
0 => $key,
'key' => $key,
];
next($array);
return $each;
}
} }

View File

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

View File

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

View File

@@ -115,7 +115,7 @@ class DB_mysqli extends DB_common
* *
* @access public * @access public
*/ */
function DB_mysqli() function __construct()
{ {
$this->DB_common(); $this->DB_common();
$this->phptype = 'mysqli'; $this->phptype = 'mysqli';
@@ -168,7 +168,6 @@ class DB_mysqli extends DB_common
$this->dsn = $dsninfo; $this->dsn = $dsninfo;
$conn = false; $conn = false;
@ini_set('track_errors', true);
if ($this->getOption('ssl') === true) { if ($this->getOption('ssl') === true) {
$init = mysqli_init(); $init = mysqli_init();
@@ -201,17 +200,16 @@ class DB_mysqli extends DB_common
); );
} }
@ini_restore('track_errors');
if (!$conn) { if (!$conn) {
$lastError = error_get_last();
if (($err = @mysqli_connect_error()) != '') { if (($err = @mysqli_connect_error()) != '') {
return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null,
null, $err); null, $err);
} elseif (empty($php_errormsg)) { } elseif (empty($lastError['message'])) {
return $this->raiseError(DB_ERROR_CONNECT_FAILED); return $this->raiseError(DB_ERROR_CONNECT_FAILED);
} else { } else {
return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, 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 // {{{ constructor
function DB_oci8() function __construct()
{ {
$this->DB_common(); $this->DB_common();
$this->phptype = 'oci8'; $this->phptype = 'oci8';
@@ -501,7 +501,7 @@ class DB_oci8 extends DB_common
if ($this->manip_query[(int)$stmt]) { if ($this->manip_query[(int)$stmt]) {
$tmp = DB_OK; $tmp = DB_OK;
} else { } else {
$tmp =& new DB_result($this, $stmt); $tmp = new DB_result($this, $stmt);
} }
return $tmp; return $tmp;
} }

View File

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

View File

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

View File

@@ -42,7 +42,7 @@ class Log_composite extends Log
* *
* @access public * @access public
*/ */
function Log_composite($name, $ident = '', $conf = array(), function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG) $level = PEAR_LOG_DEBUG)
{ {
$this->_ident = $ident; $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. * @param int $level Log messages up to and including this level.
* @access public * @access public
*/ */
function Log_console($name, $ident = '', $conf = array(), function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG) $level = PEAR_LOG_DEBUG)
{ {
if(!class_exists('G')){ if(!class_exists('G')){

View File

@@ -66,7 +66,7 @@ class Log_daemon extends Log
* @param int $maxLevel Maximum level at which to log. * @param int $maxLevel Maximum level at which to log.
* @access public * @access public
*/ */
function Log_daemon($name, $ident = '', $conf = array(), function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG) $level = PEAR_LOG_DEBUG)
{ {
/* Ensure we have a valid integer value for $name. */ /* 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. * @param int $level Log messages up to and including this level.
* @access public * @access public
*/ */
function Log_display($name = '', $ident = '', $conf = array(), function __construct($name = '', $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG) $level = PEAR_LOG_DEBUG)
{ {
if(!class_exists('G')){ 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. * @param int $level Log messages up to and including this level.
* @access public * @access public
*/ */
function Log_error_log($name, $ident = '', $conf = array(), function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG) $level = PEAR_LOG_DEBUG)
{ {
if(!class_exists('G')){ 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. * @param int $level Log messages up to and including this level.
* @access public * @access public
*/ */
function Log_file($name, $ident = '', $conf = array(), function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG) $level = PEAR_LOG_DEBUG)
{ {
if(!class_exists('G')){ 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. * @param int $level Log messages up to and including this level.
* @access public * @access public
*/ */
function Log_firebug($name = '', $ident = 'PHP', $conf = array(), function __construct($name = '', $ident = 'PHP', $conf = array(),
$level = PEAR_LOG_DEBUG) $level = PEAR_LOG_DEBUG)
{ {
if(!class_exists('G')){ 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. * @param int $level Log messages up to and including this level.
* @access public * @access public
*/ */
function Log_mail($name, $ident = '', $conf = array(), function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG) $level = PEAR_LOG_DEBUG)
{ {
if(!class_exists('G')){ 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. * @param int $level Log messages up to and including this level.
* @access public * @access public
*/ */
function Log_mcal($name, $ident = '', $conf = array(), function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG) $level = PEAR_LOG_DEBUG)
{ {
if(!class_exists('G')){ 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. * @param int $level Log messages up to and including this level.
* @access public * @access public
*/ */
function Log_mdb2($name, $ident = '', $conf = array(), function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG) $level = PEAR_LOG_DEBUG)
{ {
if(!class_exists('G')){ 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. * @param int $level Log messages up to and including this level.
* @access public * @access public
*/ */
function Log_null($name, $ident = '', $conf = array(), function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG) $level = PEAR_LOG_DEBUG)
{ {
if(!class_exists('G')){ if(!class_exists('G')){

View File

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

View File

@@ -117,7 +117,7 @@ class Log_sql extends Log
* @param int $level Log messages up to and including this level. * @param int $level Log messages up to and including this level.
* @access public * @access public
*/ */
function Log_sql($name, $ident = '', $conf = array(), function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG) $level = PEAR_LOG_DEBUG)
{ {
$this->_id = $this->encryptOld(microtime()); $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. * @param int $level Log messages up to and including this level.
* @access public * @access public
*/ */
function Log_syslog($name, $ident = '', $conf = array(), function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG) $level = PEAR_LOG_DEBUG)
{ {
/* Ensure we have a valid integer value for $name. */ /* 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. * @param int $level Log messages up to and including this level.
* @access public * @access public
*/ */
function Log_win($name, $ident = '', $conf = array(), function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG) $level = PEAR_LOG_DEBUG)
{ {
$this->_id = $this->encryptOld(microtime()); $this->_id = $this->encryptOld(microtime());

View File

@@ -83,7 +83,7 @@ class OS_Guess
var $release; var $release;
var $extra; var $extra;
function OS_Guess($uname = null) function __construct($uname = null)
{ {
list($this->sysname, list($this->sysname,
$this->release, $this->release,
@@ -136,10 +136,10 @@ class OS_Guess
case 'Linux': case 'Linux':
$extra = $this->_detectGlibcVersion(); $extra = $this->_detectGlibcVersion();
// use only the first two digits from the kernel version // 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; break;
default: default:
$release = ereg_replace('-.*', '', $parts[2]); $release = preg_replace('/-.*/', '', $parts[2]);
break; break;
} }
@@ -167,7 +167,7 @@ class OS_Guess
$cpp = popen("/usr/bin/cpp $tmpfile", "r"); $cpp = popen("/usr/bin/cpp $tmpfile", "r");
$major = $minor = 0; $major = $minor = 0;
while ($line = fgets($cpp, 1024)) { while ($line = fgets($cpp, 1024)) {
if ($line{0} == '#') { if ($line[0] == '#') {
continue; continue;
} }
if (list($major, $minor) = explode(' ', trim($line))) { if (list($major, $minor) = explode(' ', trim($line))) {
@@ -178,7 +178,7 @@ class OS_Guess
unlink($tmpfile); unlink($tmpfile);
if (!($major && $minor) && file_exists('/lib/libc.so.6')) { if (!($major && $minor) && file_exists('/lib/libc.so.6')) {
// Let's try reading the libc.so.6 symlink // 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); 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_file = preg_replace('/[^a-z0-9]/i', '_', $classname);
include_once $include_file; include_once $include_file;
} }
$obj =& new $classname; $obj = new $classname;
$methods = get_class_methods($classname); $methods = get_class_methods($classname);
foreach ($methods as $method) { foreach ($methods as $method) {
// don't import priviate methods and constructors // don't import priviate methods and constructors
if ($method{0} != '_' && $method != $classname) { if ($method[0] != '_' && $method != $classname) {
$this->_method_map[$method] = $obj; $this->_method_map[$method] = $obj;
} }
} }
@@ -145,7 +145,7 @@ class PEAR_Autoloader extends PEAR
$ok = false; $ok = false;
$classname = strtolower($classname); $classname = strtolower($classname);
reset($this->_method_map); 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) { if (is_object($obj) && get_class($obj) == $classname) {
unset($this->_method_map[$method]); unset($this->_method_map[$method]);
$ok = true; $ok = true;
@@ -168,7 +168,7 @@ class PEAR_Autoloader extends PEAR
* @return mixed The return value from the aggregated method, or a PEAR * @return mixed The return value from the aggregated method, or a PEAR
* error if the called method was unknown. * 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])) { if (empty($this->_method_map[$method]) && isset($this->_autoload_map[$method])) {
$this->addAggregateObject($this->_autoload_map[$method]); $this->addAggregateObject($this->_autoload_map[$method]);

View File

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

View File

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

View File

@@ -66,7 +66,7 @@ password from your user configuration.',
* *
* @access public * @access public
*/ */
function PEAR_Command_Auth(&$ui, &$config) function __construct(&$ui, &$config)
{ {
parent::PEAR_Command_Common($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 * @access public
*/ */
function PEAR_Command_Build(&$ui, &$config) function __construct(&$ui, &$config)
{ {
parent::PEAR_Command_Common($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) { if (sizeof($params) < 1) {
$params[0] = 'package.xml'; $params[0] = 'package.xml';
} }
$builder = &new PEAR_Builder($this->ui); $builder = new PEAR_Builder($this->ui);
$this->verbose = $this->config->get('verbose'); $this->verbose = $this->config->get('verbose');
$err = $builder->build($params[0], array(&$this, 'buildCallback')); $err = $builder->build($params[0], array(&$this, 'buildCallback'));
if (PEAR::isError($err)) { if (PEAR::isError($err)) {

View File

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

View File

@@ -91,7 +91,7 @@ displays help for all configuration parameters.
* *
* @access public * @access public
*/ */
function PEAR_Command_Config(&$ui, &$config) function __construct(&$ui, &$config)
{ {
parent::PEAR_Command_Common($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 | // | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. | // | 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 $ // $Id: Install.php,v 1.42 2003/03/18 12:06:07 ssb Exp $
@@ -207,7 +207,7 @@ specified at once.
* *
* @access public * @access public
*/ */
function PEAR_Command_Install(&$ui, &$config) function __construct(&$ui, &$config)
{ {
parent::PEAR_Command_Common($ui, $config); parent::PEAR_Command_Common($ui, $config);
} }
@@ -219,7 +219,7 @@ specified at once.
function doInstall($command, $options, $params) function doInstall($command, $options, $params)
{ {
if (empty($this->installer)) { if (empty($this->installer)) {
$this->installer = &new PEAR_Installer($this->ui); $this->installer = new PEAR_Installer($this->ui);
} }
if ($command == 'upgrade') { if ($command == 'upgrade') {
$options[$command] = true; $options[$command] = true;
@@ -279,7 +279,7 @@ specified at once.
function doUninstall($command, $options, $params) function doUninstall($command, $options, $params)
{ {
if (empty($this->installer)) { if (empty($this->installer)) {
$this->installer = &new PEAR_Installer($this->ui); $this->installer = new PEAR_Installer($this->ui);
} }
if (sizeof($params) < 1) { if (sizeof($params) < 1) {
return $this->raiseError("Please supply the package(s) you want to uninstall"); 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_Frontend a reference to an frontend
* @param object PEAR_Config a reference to the configuration data * @param object PEAR_Config a reference to the configuration data
*/ */
function PEAR_Command_Mirror(&$ui, &$config) function __construct(&$ui, &$config)
{ {
parent::PEAR_Command_Common($ui, $config); parent::PEAR_Command_Common($ui, $config);
} }
@@ -77,7 +77,7 @@ class PEAR_Command_Mirror extends PEAR_Command_Common
function doDownloadAll($command, $options, $params) function doDownloadAll($command, $options, $params)
{ {
$this->config->set("php_dir", "."); $this->config->set("php_dir", ".");
$remote = &new PEAR_Remote($this->config); $remote = new PEAR_Remote($this->config);
$remoteInfo = $remote->call("package.listAll"); $remoteInfo = $remote->call("package.listAll");
if(PEAR::isError($remoteInfo)) { if(PEAR::isError($remoteInfo)) {
return $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 * @access public
*/ */
function PEAR_Command_Package(&$ui, &$config) function __construct(&$ui, &$config)
{ {
parent::PEAR_Command_Common($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 = ''; $this->output = '';
include_once 'PEAR/Packager.php'; include_once 'PEAR/Packager.php';
$pkginfofile = isset($params[0]) ? $params[0] : 'package.xml'; $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('ext_dir'),
$this->config->get('doc_dir')); $this->config->get('doc_dir'));
$packager->debug = $this->config->get('verbose'); $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); $obj->validatePackageInfo($info, $err, $warn);
if (!$this->_displayValidationResults($err, $warn, true)) { if (!$this->_displayValidationResults($err, $warn, true)) {
$this->ui->outputData($this->output, $command); $this->ui->outputData($this->output, $command);
break; return;
} }
$version = $info['version']; $version = $info['version'];
$cvsversion = preg_replace('/[^a-z0-9]/i', '_', $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) { if (!$fp) {
return $this->raiseError("could not open RPM spec file template $spec_template: $php_errormsg"); 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); fclose($fp);
$spec_file = "$info[rpm_package]-$info[version].spec"; $spec_file = "$info[rpm_package]-$info[version].spec";
$wp = fopen($spec_file, "w"); $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 * @access public
*/ */
function PEAR_Command_Registry(&$ui, &$config) function __construct(&$ui, &$config)
{ {
parent::PEAR_Command_Common($ui, $config); parent::PEAR_Command_Common($ui, $config);
} }
@@ -108,7 +108,7 @@ installed package.'
} else { } else {
if (file_exists($params[0]) && !is_dir($params[0])) { if (file_exists($params[0]) && !is_dir($params[0])) {
include_once "PEAR/Common.php"; include_once "PEAR/Common.php";
$obj = &new PEAR_Common; $obj = new PEAR_Common;
$info = $obj->infoFromAny($params[0]); $info = $obj->infoFromAny($params[0]);
$headings = array('Package File', 'Install Path'); $headings = array('Package File', 'Install Path');
$installed = false; $installed = false;
@@ -181,7 +181,7 @@ installed package.'
function doShellTest($command, $options, $params) function doShellTest($command, $options, $params)
{ {
$this->pushErrorHandling(PEAR_ERROR_RETURN); $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" // "pear shell-test Foo"
if (sizeof($params) == 1) { if (sizeof($params) == 1) {
if (!$reg->packageExists($params[0])) { if (!$reg->packageExists($params[0])) {
@@ -217,10 +217,10 @@ installed package.'
"the package you want information"); "the package you want information");
} }
if (@is_file($params[0])) { if (@is_file($params[0])) {
$obj = &new PEAR_Common(); $obj = new PEAR_Common();
$info = $obj->infoFromAny($params[0]); $info = $obj->infoFromAny($params[0]);
} else { } else {
$reg = &new PEAR_Registry($this->config->get('php_dir')); $reg = new PEAR_Registry($this->config->get('php_dir'));
$info = $reg->packageInfo($params[0]); $info = $reg->packageInfo($params[0]);
} }
if (PEAR::isError($info)) { if (PEAR::isError($info)) {

View File

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

View File

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

View File

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

View File

@@ -13,7 +13,7 @@
| obtain it through the world-wide-web, please send a note to | | obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. | | 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 $ $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 // {{{ constructor
function PEAR_Frontend_CLI() function __construct()
{ {
parent::PEAR(); parent::PEAR();
$term = getenv('TERM'); //(cox) $_ENV is empty for me in 4.1.1 $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 * @access public
*/ */
function PEAR_Installer(&$ui) function __construct(&$ui)
{ {
parent::PEAR_Common(); parent::PEAR_Common();
$this->setFrontendObject($ui); $this->setFrontendObject($ui);
$this->debug = $this->config->get('verbose'); $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); $options['installroot'] = substr($options['installroot'], 0, -1);
} }
$php_dir = $this->_prependPath($php_dir, $options['installroot']); $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']; $this->installroot = $options['installroot'];
} else { } else {
$registry = &$this->registry; $registry = &$this->registry;
@@ -578,7 +578,7 @@ class PEAR_Installer extends PEAR_Common
$dp = opendir($tmpdir); $dp = opendir($tmpdir);
do { do {
$pkgdir = readdir($dp); $pkgdir = readdir($dp);
} while ($pkgdir{0} == '.'); } while ($pkgdir[0] == '.');
$descfile = $tmpdir . DIRECTORY_SEPARATOR . $pkgdir . DIRECTORY_SEPARATOR . 'package.xml'; $descfile = $tmpdir . DIRECTORY_SEPARATOR . $pkgdir . DIRECTORY_SEPARATOR . 'package.xml';
$flag_old_format = true; $flag_old_format = true;
@@ -681,8 +681,8 @@ class PEAR_Installer extends PEAR_Common
} }
// don't want strange characters // don't want strange characters
$pkgname = ereg_replace ('[^a-zA-Z0-9._]', '_', $pkginfo['package']); $pkgname = preg_replace ('/[^a-zA-Z0-9._]/', '_', $pkginfo['package']);
$pkgversion = ereg_replace ('[^a-zA-Z0-9._\-]', '_', $pkginfo['version']); $pkgversion = preg_replace ('/[^a-zA-Z0-9._\-]/', '_', $pkginfo['version']);
$tmp_path = dirname($descfile); $tmp_path = dirname($descfile);
if (substr($pkgfile, -4) != '.xml') { if (substr($pkgfile, -4) != '.xml') {
$tmp_path .= DIRECTORY_SEPARATOR . $pkgname . '-' . $pkgversion; $tmp_path .= DIRECTORY_SEPARATOR . $pkgname . '-' . $pkgversion;
@@ -714,7 +714,7 @@ class PEAR_Installer extends PEAR_Common
if ($this->source_files > 0 && empty($options['nobuild'])) { if ($this->source_files > 0 && empty($options['nobuild'])) {
$this->log(1, "$this->source_files source files, building"); $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; $bob->debug = $this->debug;
$built = $bob->build($descfile, array(&$this, '_buildCallback')); $built = $bob->build($descfile, array(&$this, '_buildCallback'));
if (PEAR::isError($built)) { if (PEAR::isError($built)) {
@@ -778,7 +778,7 @@ class PEAR_Installer extends PEAR_Common
} else { } else {
$this->installroot = ''; $this->installroot = '';
} }
$this->registry = &new PEAR_Registry($php_dir); $this->registry = new PEAR_Registry($php_dir);
// Delete the files // Delete the files
if (PEAR::isError($err = $this->_deletePackageFiles($package))) { if (PEAR::isError($err = $this->_deletePackageFiles($package))) {
@@ -799,7 +799,7 @@ class PEAR_Installer extends PEAR_Common
function checkDeps(&$pkginfo) function checkDeps(&$pkginfo)
{ {
$depchecker = &new PEAR_Dependency($this->registry); $depchecker = new PEAR_Dependency($this->registry);
$error = $errors = ''; $error = $errors = '';
$failed_deps = array(); $failed_deps = array();
if (is_array($pkginfo['release_deps'])) { if (is_array($pkginfo['release_deps'])) {
@@ -811,7 +811,7 @@ class PEAR_Installer extends PEAR_Common
} }
$n = count($failed_deps); $n = count($failed_deps);
if ($n > 0) { if ($n > 0) {
$depinstaller =& new PEAR_Installer($this->ui); $depinstaller = new PEAR_Installer($this->ui);
$to_install = array(); $to_install = array();
for ($i = 0; $i < $n; $i++) { for ($i = 0; $i < $n; $i++) {
if (isset($failed_deps[$i]['type'])) { if (isset($failed_deps[$i]['type'])) {

View File

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

View File

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

View File

@@ -40,7 +40,7 @@ class PEAR_Remote extends PEAR
// {{{ PEAR_Remote(config_object) // {{{ PEAR_Remote(config_object)
function PEAR_Remote(&$config) function __construct(&$config)
{ {
$this->PEAR(); $this->PEAR();
$this->config = &$config; $this->config = &$config;
@@ -111,14 +111,7 @@ class PEAR_Remote extends PEAR
if ($this->cache !== null && $this->cache['age'] < $cachettl) { if ($this->cache !== null && $this->cache['age'] < $cachettl) {
return $this->cache['content']; 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")) { if (!@include_once("XML/RPC.php")) {
return $this->raiseError("For this remote PEAR operation you need to install the XML_RPC package"); 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 // {{{ _encode
// a slightly extended version of XML_RPC_encode // a slightly extended version of XML_RPC_encode

View File

@@ -228,7 +228,7 @@ class PearSystem
} elseif($opt[0] == 'm') { } elseif($opt[0] == 'm') {
// if the mode is clearly an octal number (starts with 0) // if the mode is clearly an octal number (starts with 0)
// convert it to decimal // 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]); $opt[1] = octdec($opt[1]);
} else { } else {
// convert to int // convert to int

View File

@@ -924,7 +924,7 @@ class Phing {
// This is a bit of a hack, but works better than previous solution of assuming // This is a bit of a hack, but works better than previous solution of assuming
// data_dir is on the include_path. // data_dir is on the include_path.
$data_dir = '@DATA-DIR@'; $data_dir = '@DATA-DIR@';
if ($data_dir{0} != '@') { // if we're using PEAR then the @ DATA-DIR @ token will have been substituted. if ($data_dir[0] != '@') { // if we're using PEAR then the @ DATA-DIR @ token will have been substituted.
$data_path = $data_dir . DIRECTORY_SEPARATOR . $path; $data_path = $data_dir . DIRECTORY_SEPARATOR . $path;
if (file_exists($data_path)) { if (file_exists($data_path)) {
return $data_path; return $data_path;
@@ -1106,11 +1106,8 @@ class Phing {
private static function setIni() { private static function setIni() {
error_reporting(E_ALL); error_reporting(E_ALL);
set_time_limit(0); set_time_limit(0);
ini_set('magic_quotes_gpc', 'off');
ini_set('short_open_tag', 'off'); ini_set('short_open_tag', 'off');
ini_set('default_charset', 'iso-8859-1'); ini_set('default_charset', 'iso-8859-1');
ini_set('register_globals', 'off');
ini_set('allow_call_time_pass_reference', 'on');
} }
/** /**

View File

@@ -139,16 +139,15 @@ class Capsule {
$iniSet($inclDir, $path); $iniSet($inclDir, $path);
} }
} }
@ini_set('track_errors', true);
include $__template; include $__template;
@ini_restore('track_errors');
// restore the include path // restore the include path
ini_set('include_path', $__old_inc_path); ini_set('include_path', $__old_inc_path);
if (!empty($php_errormsg)) { $lastError = error_get_last();
throw new Exception("Unable to parse template " . $__template . ": " . $php_errormsg); if (!empty($lastError['message'])) {
throw new Exception("Unable to parse template " . $__template . ": " . $lastError['message']);
} }
} }
@@ -200,9 +199,9 @@ class Capsule {
* @return string "Best guess" path for this file. * @return string "Best guess" path for this file.
*/ */
protected function resolvePath($file, $basepath) { protected function resolvePath($file, $basepath) {
if ( !($file{0} == DIRECTORY_SEPARATOR || $file{0} == '/') if ( !($file[0] == DIRECTORY_SEPARATOR || $file[0] == '/')
// also account for C:\ style path // also account for C:\ style path
&& !($file{1} == ':' && ($file{2} == DIRECTORY_SEPARATOR || $file{2} == '/'))) { && !($file[1] == ':' && ($file[2] == DIRECTORY_SEPARATOR || $file[2] == '/'))) {
if ($basepath != null) { if ($basepath != null) {
$file = $basepath . DIRECTORY_SEPARATOR . $file; $file = $basepath . DIRECTORY_SEPARATOR . $file;
} }

View File

@@ -68,7 +68,6 @@ define( 'ARCHIVE_ZIP_PARAM_EXTRACT_AS_STRING', 'extract_as_string' );
define( 'ARCHIVE_ZIP_PARAM_NO_COMPRESSION', 'no_compression' ); define( 'ARCHIVE_ZIP_PARAM_NO_COMPRESSION', 'no_compression' );
define( 'ARCHIVE_ZIP_PARAM_BY_NAME', 'by_name' ); define( 'ARCHIVE_ZIP_PARAM_BY_NAME', 'by_name' );
define( 'ARCHIVE_ZIP_PARAM_BY_INDEX', 'by_index' ); define( 'ARCHIVE_ZIP_PARAM_BY_INDEX', 'by_index' );
define( 'ARCHIVE_ZIP_PARAM_BY_EREG', 'by_ereg' );
define( 'ARCHIVE_ZIP_PARAM_BY_PREG', 'by_preg' ); define( 'ARCHIVE_ZIP_PARAM_BY_PREG', 'by_preg' );
define( 'ARCHIVE_ZIP_PARAM_PRE_EXTRACT', 'callback_pre_extract' ); define( 'ARCHIVE_ZIP_PARAM_PRE_EXTRACT', 'callback_pre_extract' );
@@ -349,7 +348,7 @@ class Archive_Zip
/** /**
* This method extract the files and folders which are in the zip archive. * This method extract the files and folders which are in the zip archive.
* It can extract all the archive or a part of the archive by using filter * It can extract all the archive or a part of the archive by using filter
* feature (extract by name, by index, by ereg, by preg). The extraction * feature (extract by name, by index, by preg). The extraction
* can occur in the current path or an other path. * can occur in the current path or an other path.
* All the advanced features are activated by the use of variable * All the advanced features are activated by the use of variable
* parameters. * parameters.
@@ -369,8 +368,6 @@ class Archive_Zip
* or an array of file/dir names to extract from the archive. * or an array of file/dir names to extract from the archive.
* 'by_index' : A string with range of indexes separated by ',', * 'by_index' : A string with range of indexes separated by ',',
* (sample "1,3-5,12"). * (sample "1,3-5,12").
* 'by_ereg' : A regular expression (ereg) that must match the extracted
* filename.
* 'by_preg' : A regular expression (preg) that must match the extracted * 'by_preg' : A regular expression (preg) that must match the extracted
* filename. * filename.
* 'callback_pre_extract' : A callback function that will be called before * 'callback_pre_extract' : A callback function that will be called before
@@ -407,7 +404,6 @@ class Archive_Zip
'set_chmod' => 0, 'set_chmod' => 0,
'by_name' => '', 'by_name' => '',
'by_index' => '', 'by_index' => '',
'by_ereg' => '',
'by_preg' => '') ) != 1) { 'by_preg' => '') ) != 1) {
return 0; return 0;
} }
@@ -436,8 +432,6 @@ class Archive_Zip
* or an array of file/dir names to delete from the archive. * or an array of file/dir names to delete from the archive.
* 'by_index' : A string with range of indexes separated by ',', * 'by_index' : A string with range of indexes separated by ',',
* (sample "1,3-5,12"). * (sample "1,3-5,12").
* 'by_ereg' : A regular expression (ereg) that must match the extracted
* filename.
* 'by_preg' : A regular expression (preg) that must match the extracted * 'by_preg' : A regular expression (preg) that must match the extracted
* filename. * filename.
* *
@@ -459,7 +453,6 @@ class Archive_Zip
if ($this->_check_parameters($p_params, if ($this->_check_parameters($p_params,
array ('by_name' => '', array ('by_name' => '',
'by_index' => '', 'by_index' => '',
'by_ereg' => '',
'by_preg' => '') ) != 1) { 'by_preg' => '') ) != 1) {
return 0; return 0;
} }
@@ -467,7 +460,6 @@ class Archive_Zip
// ----- Check that at least one rule is set // ----- Check that at least one rule is set
if ( ($p_params['by_name'] == '') if ( ($p_params['by_name'] == '')
&& ($p_params['by_index'] == '') && ($p_params['by_index'] == '')
&& ($p_params['by_ereg'] == '')
&& ($p_params['by_preg'] == '')) { && ($p_params['by_preg'] == '')) {
$this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER,
'At least one filtering rule must' 'At least one filtering rule must'
@@ -663,7 +655,7 @@ class Archive_Zip
// ----- Extract error constants from all const. // ----- Extract error constants from all const.
for (reset($v_const_list); for (reset($v_const_list);
list($v_key, $v_value) = each($v_const_list);) { list($v_key, $v_value) = self::each($v_const_list);) {
if (substr($v_key, 0, strlen('ARCHIVE_ZIP_ERR_')) if (substr($v_key, 0, strlen('ARCHIVE_ZIP_ERR_'))
=='ARCHIVE_ZIP_ERR_') { =='ARCHIVE_ZIP_ERR_') {
$v_error_list[$v_key] = $v_value; $v_error_list[$v_key] = $v_value;
@@ -1843,15 +1835,6 @@ class Archive_Zip
} }
} }
// ----- Look for extract by ereg rule
else if ( (isset($p_params[ARCHIVE_ZIP_PARAM_BY_EREG]))
&& ($p_params[ARCHIVE_ZIP_PARAM_BY_EREG] != "")) {
if (ereg($p_params[ARCHIVE_ZIP_PARAM_BY_EREG], $v_header['stored_filename'])) {
$v_extract = true;
}
}
// ----- Look for extract by preg rule // ----- Look for extract by preg rule
else if ( (isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG])) else if ( (isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG]))
&& ($p_params[ARCHIVE_ZIP_PARAM_BY_PREG] != "")) { && ($p_params[ARCHIVE_ZIP_PARAM_BY_PREG] != "")) {
@@ -2726,16 +2709,6 @@ class Archive_Zip
} }
} }
// ----- Look for extract by ereg rule
else if ( (isset($p_params[ARCHIVE_ZIP_PARAM_BY_EREG]))
&& ($p_params[ARCHIVE_ZIP_PARAM_BY_EREG] != "")) {
if (ereg($p_params[ARCHIVE_ZIP_PARAM_BY_EREG],
$v_header_list[$v_nb_extracted]['stored_filename'])) {
$v_found = true;
}
}
// ----- Look for extract by preg rule // ----- Look for extract by preg rule
else if ( (isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG])) else if ( (isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG]))
&& ($p_params[ARCHIVE_ZIP_PARAM_BY_PREG] != "")) { && ($p_params[ARCHIVE_ZIP_PARAM_BY_PREG] != "")) {
@@ -3230,7 +3203,7 @@ class Archive_Zip
} }
// ----- Check that all the params are valid // ----- Check that all the params are valid
for (reset($p_params); list($v_key, $v_value) = each($p_params); ) { for (reset($p_params); list($v_key, $v_value) = self::each($p_params); ) {
if (!isset($p_default[$v_key])) { if (!isset($p_default[$v_key])) {
$this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER,
'Unsupported parameter with key \''.$v_key.'\''); 'Unsupported parameter with key \''.$v_key.'\'');
@@ -3240,17 +3213,17 @@ class Archive_Zip
} }
// ----- Set the default values // ----- Set the default values
for (reset($p_default); list($v_key, $v_value) = each($p_default); ) { for (reset($p_default); list($v_key, $v_value) = self::each($p_default); ) {
if (!isset($p_params[$v_key])) { if (!isset($p_params[$v_key])) {
$p_params[$v_key] = $p_default[$v_key]; $p_params[$v_key] = $p_default[$v_key];
} }
} }
// ----- Check specific parameters // ----- Check specific parameters
$v_callback_list = array ('callback_pre_add','callback_post_add', $v_callback_list = array ('callback_pre_add','callback_post_add',
'callback_pre_extract','callback_post_extract'); 'callback_pre_extract','callback_post_extract');
for ($i=0; $i<sizeof($v_callback_list); $i++) { for ($i=0; $i<sizeof($v_callback_list); $i++) {
$v_key=$v_callback_list[$i]; $v_key=$v_callback_list[$i];
if ( (isset($p_params[$v_key])) && ($p_params[$v_key] != '')) { if ( (isset($p_params[$v_key])) && ($p_params[$v_key] != '')) {
if (!function_exists($p_params[$v_key])) { if (!function_exists($p_params[$v_key])) {
$this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE, $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE,
@@ -3596,6 +3569,25 @@ class Archive_Zip
return G::encryptCrc32($string); return G::encryptCrc32($string);
} }
/**
* Legacy "each" function, because was removed in PHP v8.x
*
* @param $array
* @return array|bool
*/
private static function each($array) {
$key = key($array);
$value = current($array);
$each = is_null($key) ? false : [
1 => $value,
'value' => $value,
0 => $key,
'key' => $key,
];
next($array);
return $each;
}
} }
// End of class // End of class

View File

@@ -90,7 +90,7 @@ class RegexpMapper implements FileNameMapper {
$groups = (array) $this->reg->getGroups(); $groups = (array) $this->reg->getGroups();
// replace \1 with value of $groups[1] and return the modified "to" string // replace \1 with value of $groups[1] and return the modified "to" string
return preg_replace('/\\\([\d]+)/e', "\$groups[$1]", $this->to); return preg_replace_callback('/\\\([\d]+)/', function($matches)use($groups){return $matches[$groups[$matches[1]]];}, $this->to);
} }
} }

View File

@@ -142,7 +142,7 @@ class BufferedReader extends Reader {
// Get next buffered char ... // Get next buffered char ...
// handle case where buffer is read-in, but is empty. The next readChar() will return -1 EOF, // handle case where buffer is read-in, but is empty. The next readChar() will return -1 EOF,
// so we just return empty string (char) at this point. (Probably could also return -1 ...?) // so we just return empty string (char) at this point. (Probably could also return -1 ...?)
$ch = ($this->buffer !== "") ? $this->buffer{$this->bufferPos} : ''; $ch = ($this->buffer !== "") ? $this->buffer[$this->bufferPos] : '';
$this->bufferPos++; $this->bufferPos++;
if ( $this->bufferPos >= strlen($this->buffer) ) { if ( $this->bufferPos >= strlen($this->buffer) ) {
$this->buffer = null; $this->buffer = null;

View File

@@ -105,7 +105,9 @@ class FileReader extends Reader {
if (false === @fclose($this->fd)) { if (false === @fclose($this->fd)) {
// FAILED. // FAILED.
$msg = "Cannot fclose " . $this->file->__toString() . " $php_errormsg"; $lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Error closing the file.';
$msg = "Cannot fclose " . $this->file->__toString() . " $errorMessage";
throw new IOException($msg); throw new IOException($msg);
} else { } else {
$this->fd = null; $this->fd = null;
@@ -114,23 +116,16 @@ class FileReader extends Reader {
} }
function open() { function open() {
global $php_errormsg;
if ($this->fd === null) { if ($this->fd === null) {
$this->fd = @fopen($this->file->getAbsolutePath(), "rb"); $this->fd = @fopen($this->file->getAbsolutePath(), "rb");
} }
if ($this->fd === false) { if ($this->fd === false) {
// fopen FAILED. // fopen FAILED.
// Add error from php to end of log message. $php_errormsg. // Add error from php to end of log message.
$msg = "Cannot fopen ".$this->file->getAbsolutePath().". $php_errormsg"; $lastError = error_get_last();
throw new IOException($msg); $errorMessage = $lastError['message'] ?? 'Error opening the file.';
} $msg = "Cannot fopen ".$this->file->getAbsolutePath().". $errorMessage";
if (false) {
// Locks don't seem to work on windows??? HELP!!!!!!!!!
// if (FALSE === @flock($fp, LOCK_EX)) { // FAILED.
$msg = "Cannot acquire flock on $file. $php_errormsg";
throw new IOException($msg); throw new IOException($msg);
} }
@@ -161,7 +156,9 @@ class FileReader extends Reader {
$fileSize = $this->file->length(); $fileSize = $this->file->length();
if ($fileSize === false) { if ($fileSize === false) {
$msg = "Cannot get filesize of " . $this->file->__toString() . " $php_errormsg"; $lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Error reading the file.';
$msg = "Cannot get filesize of " . $this->file->__toString() . " $errorMessage";
throw new IOException($msg); throw new IOException($msg);
} }
$rBuffer = fread($this->fd, $fileSize); $rBuffer = fread($this->fd, $fileSize);

View File

@@ -206,7 +206,9 @@ abstract class FileSystem {
$mtime = @filemtime($strPath); $mtime = @filemtime($strPath);
if (false === $mtime) { if (false === $mtime) {
// FAILED. Log and return err. // FAILED. Log and return err.
$msg = "FileSystem::Filemtime() FAILED. Cannot can not get modified time of $strPath. $php_errormsg"; $lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Error getting file time.';
$msg = "FileSystem::Filemtime() FAILED. Cannot can not get modified time of $strPath. $errorMessage";
throw new Exception($msg); throw new Exception($msg);
} else { } else {
return (int) $mtime; return (int) $mtime;
@@ -224,7 +226,9 @@ abstract class FileSystem {
if ($fs !== false) { if ($fs !== false) {
return $fs; return $fs;
} else { } else {
$msg = "FileSystem::Read() FAILED. Cannot get filesize of $strPath. $php_errormsg"; $lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Error getting file size.';
$msg = "FileSystem::Read() FAILED. Cannot get filesize of $strPath. $errorMessage";
throw new Exception($msg); throw new Exception($msg);
} }
} }
@@ -320,7 +324,9 @@ abstract class FileSystem {
$src = $f1->getAbsolutePath(); $src = $f1->getAbsolutePath();
$dest = $f2->getAbsolutePath(); $dest = $f2->getAbsolutePath();
if (false === @rename($src, $dest)) { if (false === @rename($src, $dest)) {
$msg = "Rename FAILED. Cannot rename $src to $dest. $php_errormsg"; $lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Error renaming the file.';
$msg = "Rename FAILED. Cannot rename $src to $dest. $errorMessage";
throw new Exception($msg); throw new Exception($msg);
} }
} }
@@ -336,7 +342,9 @@ abstract class FileSystem {
$path = $f->getPath(); $path = $f->getPath();
$success = @touch($path, $time); $success = @touch($path, $time);
if (!$success) { if (!$success) {
throw new Exception("Could not create directory due to: $php_errormsg"); $lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Error setting last modified time.';
throw new Exception("Could not create directory due to: $errorMessage");
} }
} }
@@ -377,13 +385,14 @@ abstract class FileSystem {
* @throws Exception if file cannot be copied. * @throws Exception if file cannot be copied.
*/ */
function copy(PhingFile $src, PhingFile $dest) { function copy(PhingFile $src, PhingFile $dest) {
global $php_errormsg;
$srcPath = $src->getAbsolutePath(); $srcPath = $src->getAbsolutePath();
$destPath = $dest->getAbsolutePath(); $destPath = $dest->getAbsolutePath();
if (false === @copy($srcPath, $destPath)) { // Copy FAILED. Log and return err. if (false === @copy($srcPath, $destPath)) { // Copy FAILED. Log and return err.
// Add error from php to end of log message. $php_errormsg. // Add error from php to end of log message.
$msg = "FileSystem::copy() FAILED. Cannot copy $srcPath to $destPath. $php_errormsg"; $lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Error copying the file.';
$msg = "FileSystem::copy() FAILED. Cannot copy $srcPath to $destPath. $errorMessage";
throw new Exception($msg); throw new Exception($msg);
} }
@@ -409,7 +418,9 @@ abstract class FileSystem {
function chmod($pathname, $mode) { function chmod($pathname, $mode) {
$str_mode = decoct($mode); // Show octal in messages. $str_mode = decoct($mode); // Show octal in messages.
if (false === @chmod($pathname, $mode)) {// FAILED. if (false === @chmod($pathname, $mode)) {// FAILED.
$msg = "FileSystem::chmod() FAILED. Cannot chmod $pathname. Mode $str_mode. $php_errormsg"; $lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Error changing the permission.';
$msg = "FileSystem::chmod() FAILED. Cannot chmod $pathname. Mode $str_mode. $errorMessage";
throw new Exception($msg); throw new Exception($msg);
} }
} }
@@ -454,9 +465,10 @@ abstract class FileSystem {
* @throws Exception - if an error is encountered. * @throws Exception - if an error is encountered.
*/ */
function unlink($file) { function unlink($file) {
global $php_errormsg;
if (false === @unlink($file)) { if (false === @unlink($file)) {
$msg = "FileSystem::unlink() FAILED. Cannot unlink '$file'. $php_errormsg"; $lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Error deleting the file.';
$msg = "FileSystem::unlink() FAILED. Cannot unlink '$file'. $errorMessage";
throw new Exception($msg); throw new Exception($msg);
} }
} }
@@ -476,8 +488,10 @@ abstract class FileSystem {
// the build. Use this error instead of checking for Windows as the OS. // the build. Use this error instead of checking for Windows as the OS.
if (false === @symlink($target, $link)) { if (false === @symlink($target, $link)) {
// Add error from php to end of log message. $php_errormsg. // Add error from php to end of log message.
$msg = "FileSystem::Symlink() FAILED. Cannot symlink '$target' to '$link'. $php_errormsg"; $lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Error creating symlink.';
$msg = "FileSystem::Symlink() FAILED. Cannot symlink '$target' to '$link'. $errorMessage";
throw new Exception($msg); throw new Exception($msg);
} }
@@ -491,8 +505,6 @@ abstract class FileSystem {
* @return void * @return void
*/ */
function touch($file, $time = null) { function touch($file, $time = null) {
global $php_errormsg;
if (null === $time) { if (null === $time) {
$error = @touch($file); $error = @touch($file);
} else { } else {
@@ -500,8 +512,10 @@ abstract class FileSystem {
} }
if (false === $error) { // FAILED. if (false === $error) { // FAILED.
// Add error from php to end of log message. $php_errormsg. // Add error from php to end of log message.
$msg = "FileSystem::touch() FAILED. Cannot touch '$file'. $php_errormsg"; $lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Error touching the file.';
$msg = "FileSystem::touch() FAILED. Cannot touch '$file'. $errorMessage";
throw new Exception($msg); throw new Exception($msg);
} }
} }
@@ -516,14 +530,14 @@ abstract class FileSystem {
* @return void * @return void
*/ */
function rmdir($dir, $children = false) { function rmdir($dir, $children = false) {
global $php_errormsg;
// If children=FALSE only delete dir if empty. // If children=FALSE only delete dir if empty.
if (false === $children) { if (false === $children) {
if (false === @rmdir($dir)) { // FAILED. if (false === @rmdir($dir)) { // FAILED.
// Add error from php to end of log message. $php_errormsg. // Add error from php to end of log message.
$msg = "FileSystem::rmdir() FAILED. Cannot rmdir $dir. $php_errormsg"; $lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Error deleting directory.';
$msg = "FileSystem::rmdir() FAILED. Cannot rmdir $dir. $errorMessage";
throw new Exception($msg); throw new Exception($msg);
} }
@@ -532,8 +546,9 @@ abstract class FileSystem {
$handle = @opendir($dir); $handle = @opendir($dir);
if (false === $handle) { // Error. if (false === $handle) { // Error.
$lastError = error_get_last();
$msg = "FileSystem::rmdir() FAILED. Cannot opendir() $dir. $php_errormsg"; $errorMessage = $lastError['message'] ?? 'Error opening directory.';
$msg = "FileSystem::rmdir() FAILED. Cannot opendir() $dir. $errorMessage";
throw new Exception($msg); throw new Exception($msg);
} else { // Read from handle. } else { // Read from handle.
@@ -584,8 +599,10 @@ abstract class FileSystem {
@closedir($handle); @closedir($handle);
if (false === @rmdir($dir)) { // FAILED. if (false === @rmdir($dir)) { // FAILED.
// Add error from php to end of log message. $php_errormsg. // Add error from php to end of log message.
$msg = "FileSystem::rmdir() FAILED. Cannot rmdir $dir. $php_errormsg"; $lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Error removing directory.';
$msg = "FileSystem::rmdir() FAILED. Cannot rmdir $dir. $errorMessage";
throw new Exception($msg); throw new Exception($msg);
} }
@@ -603,8 +620,6 @@ abstract class FileSystem {
* @throws Exception if there is an error performing operation. * @throws Exception if there is an error performing operation.
*/ */
function umask($mode) { function umask($mode) {
global $php_errormsg;
// CONSIDERME: // CONSIDERME:
// Throw a warning if mode is 0. PHP converts illegal octal numbers to // Throw a warning if mode is 0. PHP converts illegal octal numbers to
// 0 so 0 might not be what the user intended. // 0 so 0 might not be what the user intended.
@@ -612,8 +627,10 @@ abstract class FileSystem {
$str_mode = decoct($mode); // Show octal in messages. $str_mode = decoct($mode); // Show octal in messages.
if (false === @umask($mode)) { // FAILED. if (false === @umask($mode)) { // FAILED.
// Add error from php to end of log message. $php_errormsg. // Add error from php to end of log message.
$msg = "FileSystem::Umask() FAILED. Value $mode. $php_errormsg"; $lastError = error_get_last();
$errorMessage = $lastError['message'] ?? 'Error setting unmask.';
$msg = "FileSystem::Umask() FAILED. Value $mode. $errorMessage";
throw new Exception($msg); throw new Exception($msg);
} }
} }
@@ -637,11 +654,11 @@ abstract class FileSystem {
$mtime2 = filemtime($file2); $mtime2 = filemtime($file2);
if ($mtime1 === false) { // FAILED. Log and return err. if ($mtime1 === false) { // FAILED. Log and return err.
// Add error from php to end of log message. $php_errormsg. // Add error from php to end of log message.
$msg = "FileSystem::compareMTimes() FAILED. Cannot can not get modified time of $file1."; $msg = "FileSystem::compareMTimes() FAILED. Cannot can not get modified time of $file1.";
throw new Exception($msg); throw new Exception($msg);
} elseif ($mtime2 === false) { // FAILED. Log and return err. } elseif ($mtime2 === false) { // FAILED. Log and return err.
// Add error from php to end of log message. $php_errormsg. // Add error from php to end of log message.
$msg = "FileSystem::compareMTimes() FAILED. Cannot can not get modified time of $file2."; $msg = "FileSystem::compareMTimes() FAILED. Cannot can not get modified time of $file2.";
throw new Exception($msg); throw new Exception($msg);
} else { // Worked. Log and return compare. } else { // Worked. Log and return compare.

View File

@@ -75,8 +75,8 @@ class UnixFileSystem extends FileSystem {
// Resolve home directories. We assume /home is where all home // Resolve home directories. We assume /home is where all home
// directories reside, b/c there is no other way to do this with // directories reside, b/c there is no other way to do this with
// PHP AFAIK. // PHP AFAIK.
if ($strPathname{0} === "~") { if ($strPathname[0] === "~") {
if ($strPathname{1} === "/") { // like ~/foo => /home/user/foo if ($strPathname[1] === "/") { // like ~/foo => /home/user/foo
$strPathname = "/home/" . get_current_user() . substr($strPathname, 1); $strPathname = "/home/" . get_current_user() . substr($strPathname, 1);
} else { // like ~foo => /home/foo } else { // like ~foo => /home/foo
$pos = strpos($strPathname, "/"); $pos = strpos($strPathname, "/");
@@ -88,7 +88,7 @@ class UnixFileSystem extends FileSystem {
$n = strlen($strPathname); $n = strlen($strPathname);
$prevChar = 0; $prevChar = 0;
for ($i=0; $i < $n; $i++) { for ($i=0; $i < $n; $i++) {
$c = $strPathname{$i}; $c = $strPathname[$i];
if (($prevChar === '/') && ($c === '/')) { if (($prevChar === '/') && ($c === '/')) {
return self::normalizer($strPathname, $n, $i - 1); return self::normalizer($strPathname, $n, $i - 1);
} }
@@ -109,7 +109,7 @@ class UnixFileSystem extends FileSystem {
return $pathname; return $pathname;
} }
$n = (int) $len; $n = (int) $len;
while (($n > 0) && ($pathname{$n-1} === '/')) { while (($n > 0) && ($pathname[$n-1] === '/')) {
$n--; $n--;
} }
if ($n === 0) { if ($n === 0) {
@@ -122,7 +122,7 @@ class UnixFileSystem extends FileSystem {
} }
$prevChar = 0; $prevChar = 0;
for ($i = $offset; $i < $n; $i++) { for ($i = $offset; $i < $n; $i++) {
$c = $pathname{$i}; $c = $pathname[$i];
if (($prevChar === '/') && ($c === '/')) { if (($prevChar === '/') && ($c === '/')) {
continue; continue;
} }
@@ -140,7 +140,7 @@ class UnixFileSystem extends FileSystem {
if (strlen($pathname === 0)) { if (strlen($pathname === 0)) {
return 0; return 0;
} }
return (($pathname{0} === '/') ? 1 : 0); return (($pathname[0] === '/') ? 1 : 0);
} }
/** /**
@@ -154,7 +154,7 @@ class UnixFileSystem extends FileSystem {
return $parent; return $parent;
} }
if ($child{0} === '/') { if ($child[0] === '/') {
if ($parent === '/') { if ($parent === '/') {
return $child; return $child;
} }
@@ -194,7 +194,7 @@ class UnixFileSystem extends FileSystem {
function getBooleanAttributes(&$f = null) { function getBooleanAttributes(&$f = null) {
//$rv = getBooleanAttributes0($f); //$rv = getBooleanAttributes0($f);
$name = $f->getName(); $name = $f->getName();
$hidden = (strlen($name) > 0) && ($name{0} == '.'); $hidden = (strlen($name) > 0) && ($name[0] == '.');
return ($hidden ? $this->BA_HIDDEN : 0); return ($hidden ? $this->BA_HIDDEN : 0);
} }

View File

@@ -48,7 +48,7 @@ class Win32FileSystem extends FileSystem {
} }
function slashify($p) { function slashify($p) {
if ((strlen($p) > 0) && ($p{0} != $this->slash)) { if ((strlen($p) > 0) && ($p[0] != $this->slash)) {
return $this->slash.$p; return $this->slash.$p;
} }
else { else {
@@ -81,13 +81,13 @@ class Win32FileSystem extends FileSystem {
*/ */
function normalizePrefix($strPath, $len, $sb) { function normalizePrefix($strPath, $len, $sb) {
$src = 0; $src = 0;
while (($src < $len) && $this->isSlash($strPath{$src})) { while (($src < $len) && $this->isSlash($strPath[$src])) {
$src++; $src++;
} }
$c = ""; $c = "";
if (($len - $src >= 2) if (($len - $src >= 2)
&& $this->isLetter($c = $strPath{$src}) && $this->isLetter($c = $strPath[$src])
&& $strPath{$src + 1} === ':') { && $strPath[$src + 1] === ':') {
/* Remove leading slashes if followed by drive specifier. /* Remove leading slashes if followed by drive specifier.
* This hack is necessary to support file URLs containing drive * This hack is necessary to support file URLs containing drive
* specifiers (e.g., "file://c:/path"). As a side effect, * specifiers (e.g., "file://c:/path"). As a side effect,
@@ -99,8 +99,8 @@ class Win32FileSystem extends FileSystem {
else { else {
$src = 0; $src = 0;
if (($len >= 2) if (($len >= 2)
&& $this->isSlash($strPath{0}) && $this->isSlash($strPath[0])
&& $this->isSlash($strPath{1})) { && $this->isSlash($strPath[1])) {
/* UNC pathname: Retain first slash; leave src pointed at /* UNC pathname: Retain first slash; leave src pointed at
* second slash so that further slashes will be collapsed * second slash so that further slashes will be collapsed
* into the second slash. The result will be a pathname * into the second slash. The result will be a pathname
@@ -138,15 +138,15 @@ class Win32FileSystem extends FileSystem {
// Remove redundant slashes from the remainder of the path, forcing all // Remove redundant slashes from the remainder of the path, forcing all
// slashes into the preferred slash // slashes into the preferred slash
while ($src < $len) { while ($src < $len) {
$c = $strPath{$src++}; $c = $strPath[$src++];
if ($this->isSlash($c)) { if ($this->isSlash($c)) {
while (($src < $len) && $this->isSlash($strPath{$src})) { while (($src < $len) && $this->isSlash($strPath[$src])) {
$src++; $src++;
} }
if ($src === $len) { if ($src === $len) {
/* Check for trailing separator */ /* Check for trailing separator */
$sn = (int) strlen($sb); $sn = (int) strlen($sb);
if (($sn == 2) && ($sb{1} === ':')) { if (($sn == 2) && ($sb[1] === ':')) {
// "z:\\" // "z:\\"
$sb .= $slash; $sb .= $slash;
break; break;
@@ -156,7 +156,7 @@ class Win32FileSystem extends FileSystem {
$sb .= $slash; $sb .= $slash;
break; break;
} }
if (($sn === 1) && ($this->isSlash($sb{0}))) { if (($sn === 1) && ($this->isSlash($sb[0]))) {
/* "\\\\" is not collapsed to "\\" because "\\\\" marks /* "\\\\" is not collapsed to "\\" because "\\\\" marks
the beginning of a UNC pathname. Even though it is the beginning of a UNC pathname. Even though it is
not, by itself, a valid UNC pathname, we leave it as not, by itself, a valid UNC pathname, we leave it as
@@ -194,7 +194,7 @@ class Win32FileSystem extends FileSystem {
$altSlash = $this->altSlash; $altSlash = $this->altSlash;
$prev = 0; $prev = 0;
for ($i = 0; $i < $n; $i++) { for ($i = 0; $i < $n; $i++) {
$c = $strPath{$i}; $c = $strPath[$i];
if ($c === $altSlash) { if ($c === $altSlash) {
return $this->normalizer($strPath, $n, ($prev === $slash) ? $i - 1 : $i); return $this->normalizer($strPath, $n, ($prev === $slash) ? $i - 1 : $i);
} }
@@ -219,8 +219,8 @@ class Win32FileSystem extends FileSystem {
if ($n === 0) { if ($n === 0) {
return 0; return 0;
} }
$c0 = $path{0}; $c0 = $path[0];
$c1 = ($n > 1) ? $path{1} : $c1 = ($n > 1) ? $path[1] :
0; 0;
if ($c0 === $slash) { if ($c0 === $slash) {
if ($c1 === $slash) { if ($c1 === $slash) {
@@ -230,7 +230,7 @@ class Win32FileSystem extends FileSystem {
} }
if ($this->isLetter($c0) && ($c1 === ':')) { if ($this->isLetter($c0) && ($c1 === ':')) {
if (($n > 2) && ($path{2}) === $slash) { if (($n > 2) && ($path[2]) === $slash) {
return 3; // Absolute local pathname "z:\\foo" */ return 3; // Absolute local pathname "z:\\foo" */
} }
return 2; // Directory-relative "z:foo" return 2; // Directory-relative "z:foo"
@@ -253,8 +253,8 @@ class Win32FileSystem extends FileSystem {
} }
$c = $child; $c = $child;
if (($cn > 1) && ($c{0} === $slash)) { if (($cn > 1) && ($c[0] === $slash)) {
if ($c{1} === $slash) { if ($c[1] === $slash) {
// drop prefix when child is a UNC pathname // drop prefix when child is a UNC pathname
$c = substr($c, 2); $c = substr($c, 2);
} }
@@ -265,7 +265,7 @@ class Win32FileSystem extends FileSystem {
} }
$p = $parent; $p = $parent;
if ($p{$pn - 1} === $slash) { if ($p[$pn - 1] === $slash) {
$p = substr($p, 0, $pn - 1); $p = substr($p, 0, $pn - 1);
} }
return $p.$this->slashify($c); return $p.$this->slashify($c);
@@ -277,7 +277,7 @@ class Win32FileSystem extends FileSystem {
function fromURIPath($strPath) { function fromURIPath($strPath) {
$p = (string) $strPath; $p = (string) $strPath;
if ((strlen($p) > 2) && ($p{2} === ':')) { if ((strlen($p) > 2) && ($p[2] === ':')) {
// "/c:/foo" --> "c:/foo" // "/c:/foo" --> "c:/foo"
$p = substr($p,1); $p = substr($p,1);
@@ -299,12 +299,12 @@ class Win32FileSystem extends FileSystem {
function isAbsolute(PhingFile $f) { function isAbsolute(PhingFile $f) {
$pl = (int) $f->getPrefixLength(); $pl = (int) $f->getPrefixLength();
$p = (string) $f->getPath(); $p = (string) $f->getPath();
return ((($pl === 2) && ($p{0} === $this->slash)) || ($pl === 3) || ($pl === 1 && $p{0} === $this->slash)); return ((($pl === 2) && ($p[0] === $this->slash)) || ($pl === 3) || ($pl === 1 && $p[0] === $this->slash));
} }
/** private */ /** private */
function _driveIndex($d) { function _driveIndex($d) {
$d = (string) $d{0}; $d = (string) $d[0];
if ((ord($d) >= ord('a')) && (ord($d) <= ord('z'))) { if ((ord($d) >= ord('a')) && (ord($d) <= ord('z'))) {
return ord($d) - ord('a'); return ord($d) - ord('a');
} }
@@ -316,7 +316,7 @@ class Win32FileSystem extends FileSystem {
/** private */ /** private */
function _getDriveDirectory($drive) { function _getDriveDirectory($drive) {
$drive = (string) $drive{0}; $drive = (string) $drive[0];
$i = (int) $this->_driveIndex($drive); $i = (int) $this->_driveIndex($drive);
if ($i < 0) { if ($i < 0) {
return null; return null;
@@ -348,7 +348,7 @@ class Win32FileSystem extends FileSystem {
$path = $f->getPath(); $path = $f->getPath();
$pl = (int) $f->getPrefixLength(); $pl = (int) $f->getPrefixLength();
if (($pl === 2) && ($path{0} === $this->slash)) { if (($pl === 2) && ($path[0] === $this->slash)) {
return path; // UNC return path; // UNC
} }
@@ -375,7 +375,7 @@ class Win32FileSystem extends FileSystem {
if (($ud !== null) && StringHelper::startsWith($ud, $path)) { if (($ud !== null) && StringHelper::startsWith($ud, $path)) {
return (string) ($up . $this->slashify(substr($path,2))); return (string) ($up . $this->slashify(substr($path,2)));
} }
$drive = (string) $path{0}; $drive = (string) $path[0];
$dir = (string) $this->_getDriveDirectory($drive); $dir = (string) $this->_getDriveDirectory($drive);
$np = (string) ""; $np = (string) "";

View File

@@ -81,7 +81,7 @@ class Properties {
if($line == "") if($line == "")
continue; continue;
if ($line{0} == '#' or $line{0} == ';') { if ($line[0] == '#' or $line[0] == ';') {
// it's a comment, so continue to next line // it's a comment, so continue to next line
continue; continue;
} else { } else {

View File

@@ -194,7 +194,7 @@ class PEAR_PackageFileManager_Fileset {
*/ */
function setDir($dir, $contents) function setDir($dir, $contents)
{ {
while(list($one,$two) = each($contents)) { foreach ($contents as $one => $two) {
if (isset($dir[$one])) { if (isset($dir[$one])) {
$dir[$one] = $this->setDir($dir[$one], $contents[$one]); $dir[$one] = $this->setDir($dir[$one], $contents[$one]);
} else { } else {

View File

@@ -138,10 +138,10 @@ class CVSPassTask extends TaskPhing {
/** /**
* "Encode" the password. * "Encode" the password.
*/ */
private final function mangle($password){ private function mangle($password){
$buf = ""; $buf = "";
for ($i = 0, $plen = strlen($password); $i < $plen; $i++) { for ($i = 0, $plen = strlen($password); $i < $plen; $i++) {
$buf .= chr(self::$shifts[ord($password{$i})]); $buf .= chr(self::$shifts[ord($password[$i])]);
} }
return $buf; return $buf;
} }

View File

@@ -412,7 +412,7 @@ class PropertyTask extends TaskPhing {
if ($pos === (strlen($value) - 1)) { if ($pos === (strlen($value) - 1)) {
array_push($fragments, '$'); array_push($fragments, '$');
$prev = $pos + 1; $prev = $pos + 1;
} elseif ($value{$pos+1} !== '{' ) { } elseif ($value[$pos+1] !== '{' ) {
// the string positions were changed to value-1 to correct // the string positions were changed to value-1 to correct
// a fatal error coming from function substring() // a fatal error coming from function substring()

View File

@@ -355,8 +355,8 @@ class Path extends DataType {
* replacements. * replacements.
*/ */
protected static function translateFileSep(&$buffer, $pos) { protected static function translateFileSep(&$buffer, $pos) {
if ($buffer{$pos} == '/' || $buffer{$pos} == '\\') { if ($buffer[$pos] == '/' || $buffer[$pos] == '\\') {
$buffer{$pos} = DIRECTORY_SEPARATOR; $buffer[$pos] = DIRECTORY_SEPARATOR;
return true; return true;
} }
return false; return false;

View File

@@ -131,11 +131,11 @@ class FileUtils {
// deal with absolute files // deal with absolute files
if (StringHelper::startsWith($fs->getSeparator(), $filename) || if (StringHelper::startsWith($fs->getSeparator(), $filename) ||
(strlen($filename) >= 2 && Character::isLetter($filename{0}) && $filename{1} === ':')) { (strlen($filename) >= 2 && Character::isLetter($filename[0]) && $filename[1] === ':')) {
return new PhingFile($this->normalize($filename)); return new PhingFile($this->normalize($filename));
} }
if (strlen($filename) >= 2 && Character::isLetter($filename{0}) && $filename{1} === ':') { if (strlen($filename) >= 2 && Character::isLetter($filename[0]) && $filename[1] === ':') {
return new PhingFile($this->normalize($filename)); return new PhingFile($this->normalize($filename));
} }
@@ -182,7 +182,7 @@ class FileUtils {
// make sure we are dealing with an absolute path // make sure we are dealing with an absolute path
if (!StringHelper::startsWith(DIRECTORY_SEPARATOR, $path) if (!StringHelper::startsWith(DIRECTORY_SEPARATOR, $path)
&& !(strlen($path) >= 2 && Character::isLetter($path{0}) && $path{1} === ':')) { && !(strlen($path) >= 2 && Character::isLetter($path[0]) && $path[1] === ':')) {
throw new IOException("$path is not an absolute path"); throw new IOException("$path is not an absolute path");
} }
@@ -191,7 +191,7 @@ class FileUtils {
// Eliminate consecutive slashes after the drive spec // Eliminate consecutive slashes after the drive spec
if (strlen($path) >= 2 && Character::isLetter($path{0}) && $path{1} === ':') { if (strlen($path) >= 2 && Character::isLetter($path[0]) && $path[1] === ':') {
$dosWithDrive = true; $dosWithDrive = true;
$ca = str_replace('/', '\\', $path); $ca = str_replace('/', '\\', $path);
@@ -221,7 +221,7 @@ class FileUtils {
if (strlen($path) == 1) { if (strlen($path) == 1) {
$root = DIRECTORY_SEPARATOR; $root = DIRECTORY_SEPARATOR;
$path = ""; $path = "";
} else if ($path{1} == DIRECTORY_SEPARATOR) { } else if ($path[1] == DIRECTORY_SEPARATOR) {
// UNC drive // UNC drive
$root = DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR; $root = DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR;
$path = substr($path, 2); $path = substr($path, 2);

View File

@@ -179,7 +179,7 @@ class PathTokenizer {
if (strlen($token) === 1 && Character::isLetter($token{0}) if (strlen($token) === 1 && Character::isLetter($token[0])
&& $this->dosStyleFilesystem && $this->dosStyleFilesystem

View File

@@ -60,7 +60,7 @@ class StringHelper {
$ret=array(); $ret=array();
$len=strlen($str); $len=strlen($str);
for ($i=0; $i < $len; $i++) { for ($i=0; $i < $len; $i++) {
$ret[] = $str{$i}; $ret[] = $str[$i];
} }
return $ret; return $ret;
} }
@@ -177,7 +177,7 @@ class StringHelper {
trigger_error("substring(), Endindex out of bounds must be $startpos<n<".($len-1), E_USER_ERROR); trigger_error("substring(), Endindex out of bounds must be $startpos<n<".($len-1), E_USER_ERROR);
} }
if ($startpos === $endpos) { if ($startpos === $endpos) {
return (string) $string{$startpos}; return (string) $string[$startpos];
} else { } else {
$len = $endpos-$startpos; $len = $endpos-$startpos;
} }

View File

@@ -91,7 +91,7 @@ abstract class DataModelBuilder {
// This is a slight hack to workaround camel case inconsistencies for the DDL classes. // This is a slight hack to workaround camel case inconsistencies for the DDL classes.
// Basically, we want to turn ?.?.?.sqliteDDLBuilder into ?.?.?.SqliteDDLBuilder // Basically, we want to turn ?.?.?.sqliteDDLBuilder into ?.?.?.SqliteDDLBuilder
$lastdotpos = strrpos($classpath, '.'); $lastdotpos = strrpos($classpath, '.');
if ($lastdotpos) $classpath{$lastdotpos+1} = strtoupper($classpath{$lastdotpos+1}); if ($lastdotpos) $classpath[$lastdotpos+1] = strtoupper($classpath[$lastdotpos+1]);
else ucfirst($classpath); else ucfirst($classpath);
return Phing::import($classpath); return Phing::import($classpath);

View File

@@ -1,47 +0,0 @@
<?php
/*
* $Id: SqliteDataSQLBuilder.php 3752 2007-04-11 09:11:18Z fabien $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://propel.phpdb.org>.
*/
require_once 'propel/engine/builder/sql/DataSQLBuilder.php';
/**
* SQLite class for building data dump SQL.
*
* @author Hans Lellelid <hans@xmpl.org>
* @package propel.engine.builder.sql.sqlite
*/
class SqliteDataSQLBuilder extends DataSQLBuilder {
/**
* Returns string processed by sqlite_udf_encode_binary() to ensure that binary contents will be handled correctly by sqlite.
* @param mixed $blob Blob or string
* @return string encoded text
*/
protected function getBlobSql($blob)
{
// they took magic __toString() out of PHP5.0.0; this sucks
if (is_object($blob)) {
$blob = $blob->__toString();
}
return "'" . sqlite_udf_encode_binary($blob) . "'";
}
}

View File

@@ -178,7 +178,7 @@ class XmlToAppData extends AbstractHandler
$this->isForReferenceOnly = ($isForRefOnly !== null ? (strtolower($isForRefOnly) === "true") : true); // defaults to TRUE $this->isForReferenceOnly = ($isForRefOnly !== null ? (strtolower($isForRefOnly) === "true") : true); // defaults to TRUE
} }
if ($xmlFile{0} != '/') { if ($xmlFile[0] != '/') {
$f = new PhingFile($this->currentXmlFile); $f = new PhingFile($this->currentXmlFile);
$xf = new PhingFile($f->getParent(), $xmlFile); $xf = new PhingFile($f->getParent(), $xmlFile);
$xmlFile = $xf->getPath(); $xmlFile = $xf->getPath();

View File

@@ -1,92 +0,0 @@
<?php
/*
* $Id: SqlitePlatform.php 3752 2007-04-11 09:11:18Z fabien $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://propel.phpdb.org>.
*/
require_once 'propel/engine/platform/DefaultPlatform.php';
/**
* SQLite Platform implementation.
*
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 536 $
* @package propel.engine.platform
*/
class SqlitePlatform extends DefaultPlatform {
/**
* Initializes db specific domain mapping.
*/
protected function initialize()
{
parent::initialize();
$this->setSchemaDomainMapping(new Domain(PropelTypes::NUMERIC, "DECIMAL"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, "MEDIUMTEXT"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::DATE, "DATETIME"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::BINARY, "BLOB"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::VARBINARY, "MEDIUMBLOB"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARBINARY, "LONGBLOB"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::BLOB, "LONGBLOB"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::CLOB, "LONGTEXT"));
}
/**
* @see Platform#getAutoIncrement()
* @link http://www.sqlite.org/autoinc.html
*/
public function getAutoIncrement()
{
return "PRIMARY KEY";
}
/**
* @see Platform#getMaxColumnNameLength()
*/
public function getMaxColumnNameLength()
{
return 1024;
}
/**
* @see Platform#hasSize(String)
*/
public function hasSize($sqlType) {
return !("MEDIUMTEXT" == $sqlType || "LONGTEXT" == $sqlType
|| "BLOB" == $sqlType || "MEDIUMBLOB" == $sqlType
|| "LONGBLOB" == $sqlType);
}
/**
* Escape the string for RDBMS.
* @param string $text
* @return string
*/
public function escapeText($text) {
return sqlite_escape_string($text);
}
/**
* @see Platform::quoteIdentifier()
*/
public function quoteIdentifier($text)
{
return '[' . $text . ']';
}
}

View File

@@ -369,7 +369,7 @@ abstract class AbstractPropelDataModelTask extends TaskPhing {
// This is a slight hack to workaround camel case inconsistencies for the DDL classes. // This is a slight hack to workaround camel case inconsistencies for the DDL classes.
// Basically, we want to turn ?.?.?.sqliteDDLBuilder into ?.?.?.SqliteDDLBuilder // Basically, we want to turn ?.?.?.sqliteDDLBuilder into ?.?.?.SqliteDDLBuilder
$lastdotpos = strrpos($classpath, '.'); $lastdotpos = strrpos($classpath, '.');
if ($lastdotpos) $classpath{$lastdotpos+1} = strtoupper($classpath{$lastdotpos+1}); if ($lastdotpos) $classpath[$lastdotpos+1] = strtoupper($classpath[$lastdotpos+1]);
else ucfirst($classpath); else ucfirst($classpath);
if (empty($classpath)) { if (empty($classpath)) {

View File

@@ -61,7 +61,7 @@ class MatchValidator implements BasicValidator
private function prepareRegexp($exp) private function prepareRegexp($exp)
{ {
// remove surrounding '/' marks so that they don't get escaped in next step // remove surrounding '/' marks so that they don't get escaped in next step
if ($exp{0} !== '/' || $exp{strlen($exp)-1} !== '/' ) { if ($exp[0] !== '/' || $exp[strlen($exp)-1] !== '/' ) {
$exp = '/' . $exp . '/'; $exp = '/' . $exp . '/';
} }

View File

@@ -59,7 +59,7 @@ class NotMatchValidator implements BasicValidator
private function prepareRegexp($exp) private function prepareRegexp($exp)
{ {
// remove surrounding '/' marks so that they don't get escaped in next step // remove surrounding '/' marks so that they don't get escaped in next step
if ($exp{0} !== '/' || $exp{strlen($exp)-1} !== '/' ) { if ($exp[0] !== '/' || $exp[strlen($exp)-1] !== '/' ) {
$exp = '/' . $exp . '/'; $exp = '/' . $exp . '/';
} }

View File

@@ -199,7 +199,7 @@ class AppProxy extends HttpProxyController
@ob_flush(); @ob_flush();
@flush(); @flush();
@ob_end_flush(); @ob_end_flush();
ob_implicit_flush(1); ob_implicit_flush(true);
} }
/** /**

View File

@@ -25,7 +25,7 @@ function postNote($httpData)
@ob_flush(); @ob_flush();
@flush(); @flush();
@ob_end_flush(); @ob_end_flush();
ob_implicit_flush(1); ob_implicit_flush(true);
//send notification in background //send notification in background
$noteRecipientsList = array(); $noteRecipientsList = array();