fix PHP 8 Fatal error Array and string offset access syntax with curly braces is no longer supported

This commit is contained in:
Ralf Becker 2021-03-21 21:13:07 +01:00
parent 52e8aff9ae
commit ab9c089f70
11 changed files with 23 additions and 20 deletions

View File

@ -1595,7 +1595,10 @@ class adLDAPUsers extends \adLDAPUsers
return mb_convert_encoding($password, 'UTF-16LE', $this->adldap->charset); return mb_convert_encoding($password, 'UTF-16LE', $this->adldap->charset);
} }
$encoded=""; $encoded="";
for ($i=0; $i <strlen($password); $i++){ $encoded.="{$password{$i}}\000"; } for ($i=0; $i <strlen($password); $i++)
{
$encoded .= $password[$i]."\000";
}
return $encoded; return $encoded;
} }

View File

@ -719,11 +719,11 @@ class Widget
$min = ord('A'); $min = ord('A');
$max = ord('Z') - $min + 1; $max = ord('Z') - $min + 1;
$num = 1+ord($chrs{0})-$min; $num = 1+ord($chrs[0])-$min;
if (strlen($chrs) > 1) if (strlen($chrs) > 1)
{ {
$num *= 1 + $max - $min; $num *= 1 + $max - $min;
$num += 1+ord($chrs{1})-$min; $num += 1+ord($chrs[1])-$min;
} }
return $num; return $num;
} }

View File

@ -32,7 +32,7 @@ class Referer
if (!$referer) $referer = urldecode($_SERVER['HTTP_REFERER']); if (!$referer) $referer = urldecode($_SERVER['HTTP_REFERER']);
$webserver_url = $GLOBALS['egw_info']['server']['webserver_url']; $webserver_url = $GLOBALS['egw_info']['server']['webserver_url'];
if (empty($webserver_url) || $webserver_url{0} == '/') // url is just a path if (empty($webserver_url) || $webserver_url[0] === '/') // url is just a path
{ {
$referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer); // removing the domain part $referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer); // removing the domain part
} }

View File

@ -213,7 +213,7 @@ class WebDAV extends HTTP_WebDAV_Server_Filesystem
if (!$new) { if (!$new) {
if ($options["overwrite"]) { if ($options["overwrite"]) {
$stat = $this->DELETE(array("path" => $options["dest"])); $stat = $this->DELETE(array("path" => $options["dest"]));
if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) { if (($stat[0] != "2") && (substr($stat, 0, 3) != "404")) {
return $stat; return $stat;
} }
} else { } else {

View File

@ -2049,7 +2049,7 @@ class HTTP_WebDAV_Server
} }
$this->http_status($http_stat); $this->http_status($http_stat);
if ($http_stat{0} == 2) { // 2xx states are ok if ($http_stat[0] == 2) { // 2xx states are ok
if ($options["timeout"]) { if ($options["timeout"]) {
// if multiple timeout values were given we take the first only // if multiple timeout values were given we take the first only
if (is_array($options["timeout"])) { if (is_array($options["timeout"])) {
@ -2347,10 +2347,10 @@ class HTTP_WebDAV_Server
$uuid = md5(microtime().getmypid()); // this should be random enough for now $uuid = md5(microtime().getmypid()); // this should be random enough for now
// set variant and version fields for 'true' random uuid // set variant and version fields for 'true' random uuid
$uuid{12} = "4"; $uuid[12] = "4";
$n = 8 + (ord($uuid{16}) & 3); $n = 8 + (ord($uuid[16]) & 3);
$hex = "0123456789abcdef"; $hex = "0123456789abcdef";
$uuid{16} = $hex{$n}; $uuid[16] = $hex[$n];
// return formated uuid // return formated uuid
return substr($uuid, 0, 8)."-" return substr($uuid, 0, 8)."-"
@ -2385,7 +2385,7 @@ class HTTP_WebDAV_Server
function _if_header_lexer($string, &$pos) function _if_header_lexer($string, &$pos)
{ {
// skip whitespace // skip whitespace
while (ctype_space($string{$pos})) { while (ctype_space($string[$pos])) {
++$pos; ++$pos;
} }
@ -2395,7 +2395,7 @@ class HTTP_WebDAV_Server
} }
// get next character // get next character
$c = $string{$pos++}; $c = $string[$pos++];
// now it depends on what we found // now it depends on what we found
switch ($c) { switch ($c) {
@ -2408,7 +2408,7 @@ class HTTP_WebDAV_Server
case "[": case "[":
//Etags are enclosed in [...] //Etags are enclosed in [...]
if ($string{$pos} == "W") { if ($string[$pos] == "W") {
$type = "ETAG_WEAK"; $type = "ETAG_WEAK";
$pos += 2; $pos += 2;
} else { } else {
@ -2887,7 +2887,7 @@ class HTTP_WebDAV_Server
{ {
//error_log("merge called :\n$parent \n$child\n" . function_backtrace()); //error_log("merge called :\n$parent \n$child\n" . function_backtrace());
//error_log("merge :\n".print_r($this->_mergePaths($this->_SERVER["SCRIPT_NAME"], $this->path)true)); //error_log("merge :\n".print_r($this->_mergePaths($this->_SERVER["SCRIPT_NAME"], $this->path)true));
if ($child{0} == '/') { if ($child[0] == '/') {
return self::_unslashify($parent).$child; return self::_unslashify($parent).$child;
} else { } else {
return self::_slashify($parent).$child; return self::_slashify($parent).$child;

View File

@ -676,7 +676,7 @@ class HTTP_WebDAV_Server_Filesystem extends HTTP_WebDAV_Server
if (!$new) { if (!$new) {
if ($options["overwrite"]) { if ($options["overwrite"]) {
$stat = $this->DELETE(array("path" => $options["dest"])); $stat = $this->DELETE(array("path" => $options["dest"]));
if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) { if (($stat[0] != "2") && (substr($stat, 0, 3) != "404")) {
return $stat; return $stat;
} }
} else { } else {

View File

@ -1434,7 +1434,7 @@ function calendar_upgrade1_0_1_008()
$order = 0; $order = 0;
foreach($config_data['fields'] as $name => $data) foreach($config_data['fields'] as $name => $data)
{ {
if ($name{0} == '#' && !$data['disabled']) // real not-disabled custom field if ($name[0] === '#' && !$data['disabled']) // real not-disabled custom field
{ {
$customfields[substr($name,1)] = array( $customfields[substr($name,1)] = array(
'type' => 'text', 'type' => 'text',

View File

@ -112,7 +112,7 @@ class importexport_helper_functions {
// offset given? // offset given?
if ( isset( $offset ) && strlen( $offset == 5 ) ) { if ( isset( $offset ) && strlen( $offset == 5 ) ) {
$operator = $offset{0}; $operator = $offset[0];
$ohour = 60 * 60 * (int)substr( $offset, 1, 2 ); $ohour = 60 * 60 * (int)substr( $offset, 1, 2 );
$omin = 60 * (int)substr( $offset, 3, 2 ); $omin = 60 * (int)substr( $offset, 3, 2 );
if ( $operator == '+' ) $timestamp += $ohour + $omin; if ( $operator == '+' ) $timestamp += $ohour + $omin;

View File

@ -339,7 +339,7 @@ class importexport_schedule_ui
*/ */
private static function is__writable($path) private static function is__writable($path)
{ {
if ($path{strlen($path)-1}=='/') if ($path[strlen($path)-1] === '/')
{ {
// recursively return a temporary file path // recursively return a temporary file path
return self::is__writable($path.uniqid(mt_rand()).'.tmp'); return self::is__writable($path.uniqid(mt_rand()).'.tmp');

View File

@ -783,7 +783,7 @@ class resources_bo
// now we are interested only on resources booked by theses events // now we are interested only on resources booked by theses events
if (isset($event['participants']) && is_array($event['participants'])){ if (isset($event['participants']) && is_array($event['participants'])){
foreach($event['participants'] as $part_key => $part_detail){ foreach($event['participants'] as $part_key => $part_detail){
if ($part_key{0}=='r') if ($part_key[0] === 'r')
{ //now we gatta resource here { //now we gatta resource here
//need to check the quantity of this resource //need to check the quantity of this resource
$resource_id=substr($part_key,1); $resource_id=substr($part_key,1);
@ -872,7 +872,7 @@ class resources_bo
// now we are interested only on resources booked by theses events // now we are interested only on resources booked by theses events
if (isset($event['participants']) && is_array($event['participants'])){ if (isset($event['participants']) && is_array($event['participants'])){
foreach($event['participants'] as $part_key => $part_detail){ foreach($event['participants'] as $part_key => $part_detail){
if ($part_key{0}=='r') if ($part_key[0] === 'r')
{ {
$resource_id=substr($part_key,1); $resource_id=substr($part_key,1);
if ($resource_id != $_res_id) continue; if ($resource_id != $_res_id) continue;

View File

@ -545,7 +545,7 @@ class timesheet_bo extends Api\Storage
{ {
$union_order[] = 'ts_'.$type . ' ' . $sort; $union_order[] = 'ts_'.$type . ' ' . $sort;
$union_order[] = 'is_sum_'.$type; $union_order[] = 'is_sum_'.$type;
$sum_extra_cols[$type]{0} = '1'; $sum_extra_cols[$type][0] = '1';
// the $type sum // the $type sum
parent::search($criteria,array( parent::search($criteria,array(
(string)$sum_ts_id[$type],"''","''","''",'MIN(ts_start)','SUM(ts_duration) AS ts_duration', (string)$sum_ts_id[$type],"''","''","''",'MIN(ts_start)','SUM(ts_duration) AS ts_duration',