Stop using curly braces
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 6 Feb 2021 07:22:06 +0000 (07:22 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 6 Feb 2021 07:22:06 +0000 (07:22 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14892 7612ce4b-ef26-0410-bec9-ea0150e637f0

class/deliver/Deliver.class.php
class/deliver/Deliver_SMTP.class.php
class/mime/Message.class.php
class/mime/Rfc822Header.class.php
class/template/Template.class.php
functions/strings.php
plugins/mail_fetch/class.mail_fetch.php
src/configtest.php

index 95ae3e257c0d90fd2e1f94ec2a38febf4280af9b..daa52c239056e516218a98a3f8f236f7b301990e 100644 (file)
@@ -892,7 +892,7 @@ class Deliver {
         if (!$allow_fold_after_header_name
          && ($header_name_end_pos = strpos($header, ':'))
          && strlen($header) > $header_name_end_pos + 1
-         && in_array($header{$header_name_end_pos + 1}, $whitespace))
+         && in_array($header[$header_name_end_pos + 1], $whitespace))
             $header_name_end_pos++;
 
         // if using an indent string, reduce wrap limits by its size
@@ -1073,7 +1073,7 @@ class Deliver {
                     //
                     if (strlen($header) > $pos + 1) {
                         $header = substr($header, $pos + 1);
-                        if (!in_array($header{0}, $whitespace))
+                        if (!in_array($header[0], $whitespace))
                             $header = ' ' . $indent . $header;
                     } else {
                         $header = '';
@@ -1098,7 +1098,7 @@ class Deliver {
             //
             if (strlen($header) > strlen($hard_wrapped_line)) {
                 $header = substr($header, strlen($hard_wrapped_line));
-                if (!in_array($header{0}, $whitespace))
+                if (!in_array($header[0], $whitespace))
                     $header = ' ' . $indent . $header;
             } else {
                 $header = '';
index 7f522bb5868f71f67147b25f1f61262e80e65f73..8ba785213ba5c293b02d16f78753262942f03515 100644 (file)
@@ -57,7 +57,7 @@ class Deliver_SMTP extends Deliver {
 
     function preWriteToStream(&$s) {
         if ($s) {
-            if ($s{0} == '.')   $s = '.' . $s;
+            if ($s[0] == '.')   $s = '.' . $s;
             $s = str_replace("\n.","\n..",$s);
         }
     }
@@ -408,7 +408,7 @@ class Deliver_SMTP extends Deliver {
             $server_msg .= substr($line, 4);
         }
 
-        if ( ((int) $err_num{0}) < 4) {
+        if ( ((int) $err_num[0]) < 4) {
             return false;
         }
 
index ff8325a0ea530ddc040001d2754813371464cfff..bc2545c4ba3f310bbb715fa085361c7a80221c96 100644 (file)
@@ -352,7 +352,7 @@ class Message {
         }
 
         for ($cnt = strlen($read); $i < $cnt; ++$i) {
-            $char = strtoupper($read{$i});
+            $char = strtoupper($read[$i]);
             switch ($char) {
                 case '(':
                     switch($arg_no) {
@@ -367,7 +367,7 @@ class Message {
                             } else {
                                 $msg->header->type0 = 'multipart';
                                 $msg->type0 = 'multipart';
-                                while ($read{$i} == '(') {
+                                while ($read[$i] == '(') {
                                     $msg->addEntity($msg->parseBodyStructure($read, $i, $msg));
                                 }
                             }
@@ -400,7 +400,7 @@ class Message {
                                 $msg->type1 = $arg_a[1];
                                 $rfc822_hdr = new Rfc822Header();
                                 $msg->rfc822_header = $msg->parseEnvelope($read, $i, $rfc822_hdr);
-                                while (($i < $cnt) && ($read{$i} != '(')) {
+                                while (($i < $cnt) && ($read[$i] != '(')) {
                                     ++$i;
                                 }
                                 $msg->addEntity($msg->parseBodyStructure($read, $i,$msg));
@@ -463,9 +463,9 @@ class Message {
                     ++$arg_no;
                     break;
                 case '0':
-                case is_numeric($read{$i}):
+                case is_numeric($read[$i]):
                     /* process integers */
-                    if ($read{$i} == ' ') { break; }
+                    if ($read[$i] == ' ') { break; }
                     ++$arg_no;
                     if (preg_match('/^([0-9]+).*/',substr($read,$i), $regs)) {
                         $i += strlen($regs[1])-1;
@@ -527,11 +527,11 @@ class Message {
         $properties = array();
         $prop_name = '';
 
-        for (; $read{$i} != ')'; ++$i) {
+        for (; $read[$i] != ')'; ++$i) {
             $arg_s = '';
-            if ($read{$i} == '"') {
+            if ($read[$i] == '"') {
                 $arg_s = $this->parseQuote($read, $i);
-            } else if ($read{$i} == '{') {
+            } else if ($read[$i] == '{') {
                 $arg_s = $this->parseLiteral($read, $i);
             }
 
@@ -622,8 +622,8 @@ class Message {
         $arg_no = 0;
         $arg_a = array();
         ++$i;
-        for ($cnt = strlen($read); ($i < $cnt) && ($read{$i} != ')'); ++$i) {
-            $char = strtoupper($read{$i});
+        for ($cnt = strlen($read); ($i < $cnt) && ($read[$i] != ')'); ++$i) {
+            $char = strtoupper($read[$i]);
             switch ($char) {
                 case '"':
                     $arg_a[] = $this->parseQuote($read, $i);
@@ -652,8 +652,8 @@ class Message {
                     $addr_a = array();
                     $group = '';
                     $a=0;
-                    for (; $i < $cnt && $read{$i} != ')'; ++$i) {
-                        if ($read{$i} == '(') {
+                    for (; $i < $cnt && $read[$i] != ')'; ++$i) {
+                        if ($read[$i] == '(') {
                             $addr = $this->parseAddress($read, $i);
                             if (($addr->host == '') && ($addr->mailbox != '')) {
                                 /* start of group */
@@ -751,11 +751,11 @@ class Message {
         while (true) {
             $iPos = strpos($read,'"',$iPos);
             if (!$iPos) break;
-            if ($iPos && $read{$iPos -1} != '\\') {
+            if ($iPos && $read[$iPos -1] != '\\') {
                 $s = substr($read,$i,($iPos-$i));
                 $i = $iPos;
                 break;
-            } else if ($iPos > 1 && $read{$iPos -1} == '\\' && $read{$iPos-2} == '\\') {
+            } else if ($iPos > 1 && $read[$iPos -1] == '\\' && $read[$iPos-2] == '\\') {
                 // This is an unique situation where the fast detection of the string
                 // fails. If the quote string ends with \\ then we need to iterate
                 // through the entire string to make sure we detect the unexcaped
@@ -764,7 +764,7 @@ class Message {
                 $bEscaped = false;
                 $k = 0;
                  for ($j=$iPosStart,$iCnt=strlen($read);$j<$iCnt;++$j) {
-                    $cChar = $read{$j};
+                    $cChar = $read[$j];
                     switch ($cChar) {
                         case '\\':
                            $bEscaped = !$bEscaped;
@@ -803,8 +803,8 @@ class Message {
      */
     function parseAddress($read, &$i) {
         $arg_a = array();
-        for (; $read{$i} != ')'; ++$i) {
-            $char = strtoupper($read{$i});
+        for (; $read[$i] != ')'; ++$i) {
+            $char = strtoupper($read[$i]);
             switch ($char) {
                 case '"': $arg_a[] = $this->parseQuote($read, $i); break;
                 case '{': $arg_a[] = $this->parseLiteral($read, $i); break;
@@ -838,8 +838,8 @@ class Message {
      */
     function parseDisposition($read, &$i) {
         $arg_a = array();
-        for (; $read{$i} != ')'; ++$i) {
-            switch ($read{$i}) {
+        for (; $read[$i] != ')'; ++$i) {
+            switch ($read[$i]) {
                 case '"': $arg_a[] = $this->parseQuote($read, $i); break;
                 case '{': $arg_a[] = $this->parseLiteral($read, $i); break;
                 case '(': $arg_a[] = $this->parseProperties($read, $i); break;
@@ -865,8 +865,8 @@ class Message {
         /* no idea how to process this one without examples */
         $arg_a = array();
 
-        for (; $read{$i} != ')'; ++$i) {
-            switch ($read{$i}) {
+        for (; $read[$i] != ')'; ++$i) {
+            switch ($read[$i]) {
                 case '"': $arg_a[] = $this->parseQuote($read, $i); break;
                 case '{': $arg_a[] = $this->parseLiteral($read, $i); break;
                 case '(': $arg_a[] = $this->parseProperties($read, $i); break;
@@ -890,8 +890,8 @@ class Message {
      * @return integer
      */
     function parseParenthesis($read, $i) {
-        for ($i++; $read{$i} != ')'; ++$i) {
-            switch ($read{$i}) {
+        for ($i++; $read[$i] != ')'; ++$i) {
+            switch ($read[$i]) {
                 case '"': $this->parseQuote($read, $i); break;
                 case '{': $this->parseLiteral($read, $i); break;
                 case '(': $this->parseProperties($read, $i); break;
@@ -944,7 +944,7 @@ class Message {
                 }
             }
 
-            if ((($line{0} == '-') || $rfc822_header)  && isset($boundaries[0])) {
+            if ((($line[0] == '-') || $rfc822_header)  && isset($boundaries[0])) {
                 $cnt = count($boundaries)-1;
                 $bnd = $boundaries[$cnt]['bnd'];
                 $bndreg = $boundaries[$cnt]['bndreg'];
@@ -954,7 +954,7 @@ class Message {
                     $bndlen = strlen($reg[1]);
                     $bndend = false;
                     if (strlen($line) > ($bndlen + 3)) {
-                        if (($line{$bndlen+2} == '-') && ($line{$bndlen+3} == '-')) {
+                        if (($line[$bndlen+2] == '-') && ($line[$bndlen+3] == '-')) {
                             $bndend = true;
                         }
                     }
index 8cf7f40b07c501fd057c6961102c2b001cdace98..2cbabeee7a8bad6d6b195a48025784158a404c93 100644 (file)
@@ -192,24 +192,24 @@ class Rfc822Header {
         $result = '';
         $cnt = strlen($value);
         for ($i = 0; $i < $cnt; ++$i) {
-            switch ($value{$i}) {
+            switch ($value[$i]) {
                 case '"':
                     $result .= '"';
-                    while ((++$i < $cnt) && ($value{$i} != '"')) {
-                        if ($value{$i} == '\\') {
+                    while ((++$i < $cnt) && ($value[$i] != '"')) {
+                        if ($value[$i] == '\\') {
                             $result .= '\\';
                             ++$i;
                         }
-                        $result .= $value{$i};
+                        $result .= $value[$i];
                     }
                     if($i < $cnt) {
-                        $result .= $value{$i};
+                        $result .= $value[$i];
                     }
                     break;
                 case '(':
                     $depth = 1;
                     while (($depth > 0) && (++$i < $cnt)) {
-                        switch($value{$i}) {
+                        switch($value[$i]) {
                             case '\\':
                                 ++$i;
                                 break;
@@ -225,7 +225,7 @@ class Rfc822Header {
                     }
                     break;
                 default:
-                    $result .= $value{$i};
+                    $result .= $value[$i];
                     break;
             }
         }
@@ -379,7 +379,7 @@ class Rfc822Header {
         $iCnt = strlen($address);
         $i = 0;
         while ($i < $iCnt) {
-            $cChar = $address{$i};
+            $cChar = $address[$i];
             switch($cChar)
             {
             case '<':
@@ -398,11 +398,11 @@ class Rfc822Header {
                 $iEnd = strpos($address,$cChar,$i+1);
                 if ($iEnd) {
                    // skip escaped quotes
-                   $prev_char = $address{$iEnd-1};
+                   $prev_char = $address[$iEnd-1];
                    while ($prev_char === '\\' && substr($address,$iEnd-2,2) !== '\\\\') {
                        $iEnd = strpos($address,$cChar,$iEnd+1);
                        if ($iEnd) {
-                          $prev_char = $address{$iEnd-1};
+                          $prev_char = $address[$iEnd-1];
                        } else {
                           $prev_char = false;
                        }
@@ -429,7 +429,7 @@ class Rfc822Header {
                     $iDepth = 1;
                     $iComment = $i;
                     while (($iDepth > 0) && (++$iComment < $iCnt)) {
-                        $cCharComment = $address{$iComment};
+                        $cCharComment = $address[$iComment];
                         switch($cCharComment) {
                             case '\\':
                                 ++$iComment;
@@ -455,7 +455,7 @@ class Rfc822Header {
                 // check the next token in case comments appear in the middle of email addresses
                 $prevToken = end($aTokens);
                 if (!in_array($prevToken,$aSpecials,true)) {
-                    if ($i+1<strlen($address) && !in_array($address{$i+1},$aSpecials,true)) {
+                    if ($i+1<strlen($address) && !in_array($address[$i+1],$aSpecials,true)) {
                         $iEnd = strpos($address,' ',$i+1);
                         if ($iEnd) {
                             $sNextToken = trim(substr($address,$i+1,$iEnd - $i -1));
@@ -561,7 +561,7 @@ class Rfc822Header {
         $sPersonal = $sEmail = $sGroup = '';
         $aStack = $aComment = array();
         foreach ($aTokens as $sToken) {
-            $cChar = $sToken{0};
+            $cChar = $sToken[0];
             switch ($cChar)
             {
             case '=':
@@ -768,7 +768,7 @@ class Rfc822Header {
             if ($pos > 0)  {
                 $key = trim(substr($prop, 0, $pos));
                 $val = trim(substr($prop, $pos+1));
-                if (strlen($val) > 0 && $val{0} == '"') {
+                if (strlen($val) > 0 && $val[0] == '"') {
                     $val = substr($val, 1, -1);
                 }
                 $propResultArray[$key] = $val;
@@ -806,7 +806,7 @@ class Rfc822Header {
         $value_a = explode(',', $value);
         foreach ($value_a as $val) {
             $val = trim($val);
-            if ($val{0} == '<') {
+            if ($val[0] == '<') {
                 $val = substr($val, 1, -1);
             }
             if (substr($val, 0, 7) == 'mailto:') {
index 27c02030ebbf7c97aeba4504d0bd7f6f0c264589..785b4aa1d895f4caa5c93a386721b65166e56b27 100644 (file)
@@ -1018,7 +1018,7 @@ class Template
         // return list of all files in a directory (and that
         // of any ancestors)
         //
-        if ($filename{strlen($filename) - 1} == '/') {
+        if ($filename[strlen($filename) - 1] == '/') {
 
             $return_array = array();
             foreach ($this->template_file_cache as $file => $file_info) {
index cd1e3160a64863e87bb70b3d94e411eb6315f005..c2a33e07accbd63cff647da18b81c78461a735ec 100644 (file)
@@ -136,7 +136,7 @@ function &sqBodyWrap (&$body, $wrap) {
        // (i.e. try to preserve original paragraph breaks)
        // unless they occur at the very beginning of the text
        if ((sq_substr($body,$pos,1) == "\n" ) && (sq_strlen($outString) != 0)) {
-           $outStringLast = $outString{sq_strlen($outString) - 1};
+           $outStringLast = $outString[sq_strlen($outString) - 1];
            if ($outStringLast != "\n") {
                $outString .= "\n";
            }
@@ -227,7 +227,7 @@ function &sqBodyWrap (&$body, $wrap) {
 /*
                      $ldnspacecnt = 0;
                      if ($mypos == $nextNewline+1) {
-                        while (($mypos < $length) && ($body{$mypos} == ' ')) {
+                        while (($mypos < $length) && ($body[$mypos] == ' ')) {
                          $ldnspacecnt++;
                         }
                      }
@@ -236,9 +236,9 @@ function &sqBodyWrap (&$body, $wrap) {
                    $firstword = sq_substr($body,$mypos,sq_strpos($body,' ',$mypos) - $mypos);
                    //if ($dowrap || $ldnspacecnt > 1 || ($firstword && (
                    if (!$smartwrap || $firstword && (
-                                        $firstword{0} == '-' ||
-                                        $firstword{0} == '+' ||
-                                        $firstword{0} == '*' ||
+                                        $firstword[0] == '-' ||
+                                        $firstword[0] == '+' ||
+                                        $firstword[0] == '*' ||
                                         sq_substr($firstword,0,1) == sq_strtoupper(sq_substr($firstword,0,1)) ||
                                         strpos($firstword,':'))) {
                         $outString .= sq_substr($body,$pos,($lastRealChar - $pos+1));
@@ -713,7 +713,7 @@ function GenerateRandomString($size, $chars, $flags = 0) {
     $String = '';
     $j = strlen( $chars ) - 1;
     while (strlen($String) < $size) {
-        $String .= $chars{mt_rand(0, $j)};
+        $String .= $chars[mt_rand(0, $j)];
     }
 
     return $String;
index 8996760ca308c488254e723e3927b894b52b4fc6..ac915ea2162e7906184b948ebf3f284a95a2a06a 100644 (file)
@@ -367,7 +367,7 @@ class mail_fetch {
             while($line = fgets($this->conn)) {
                 if ($line == ".\r\n") {
                     break;
-                } elseif ( $line{0} == '.' ) {
+                } elseif ( $line[0] == '.' ) {
                     $ret .= substr($line,1);
                 } else {
                     $ret.= $line;
index 036c485bb0689cd01591413f7b1361b849725512..7f1ce94b7fcfb2cef4508a1ce2f0be5fb7f63143 100644 (file)
@@ -644,7 +644,7 @@ if($useSendmail) {
 
     // check for SMTP code; should be 2xx to allow us access
     $smtpline = fgets($stream, 1024);
-    if(((int) $smtpline{0}) > 3) {
+    if(((int) $smtpline[0]) > 3) {
         do_err("Error connecting to SMTP server. Server error: ".
                 sm_encode_html_special_chars($smtpline));
     }