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
//
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 = '';
//
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 = '';
function preWriteToStream(&$s) {
if ($s) {
- if ($s{0} == '.') $s = '.' . $s;
+ if ($s[0] == '.') $s = '.' . $s;
$s = str_replace("\n.","\n..",$s);
}
}
$server_msg .= substr($line, 4);
}
- if ( ((int) $err_num{0}) < 4) {
+ if ( ((int) $err_num[0]) < 4) {
return false;
}
}
for ($cnt = strlen($read); $i < $cnt; ++$i) {
- $char = strtoupper($read{$i});
+ $char = strtoupper($read[$i]);
switch ($char) {
case '(':
switch($arg_no) {
} else {
$msg->header->type0 = 'multipart';
$msg->type0 = 'multipart';
- while ($read{$i} == '(') {
+ while ($read[$i] == '(') {
$msg->addEntity($msg->parseBodyStructure($read, $i, $msg));
}
}
$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));
++$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;
$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);
}
$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);
$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 */
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
$bEscaped = false;
$k = 0;
for ($j=$iPosStart,$iCnt=strlen($read);$j<$iCnt;++$j) {
- $cChar = $read{$j};
+ $cChar = $read[$j];
switch ($cChar) {
case '\\':
$bEscaped = !$bEscaped;
*/
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;
*/
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;
/* 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;
* @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;
}
}
- 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'];
$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;
}
}
$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;
}
break;
default:
- $result .= $value{$i};
+ $result .= $value[$i];
break;
}
}
$iCnt = strlen($address);
$i = 0;
while ($i < $iCnt) {
- $cChar = $address{$i};
+ $cChar = $address[$i];
switch($cChar)
{
case '<':
$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;
}
$iDepth = 1;
$iComment = $i;
while (($iDepth > 0) && (++$iComment < $iCnt)) {
- $cCharComment = $address{$iComment};
+ $cCharComment = $address[$iComment];
switch($cCharComment) {
case '\\':
++$iComment;
// 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));
$sPersonal = $sEmail = $sGroup = '';
$aStack = $aComment = array();
foreach ($aTokens as $sToken) {
- $cChar = $sToken{0};
+ $cChar = $sToken[0];
switch ($cChar)
{
case '=':
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;
$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:') {
// 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) {
// (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";
}
/*
$ldnspacecnt = 0;
if ($mypos == $nextNewline+1) {
- while (($mypos < $length) && ($body{$mypos} == ' ')) {
+ while (($mypos < $length) && ($body[$mypos] == ' ')) {
$ldnspacecnt++;
}
}
$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));
$String = '';
$j = strlen( $chars ) - 1;
while (strlen($String) < $size) {
- $String .= $chars{mt_rand(0, $j)};
+ $String .= $chars[mt_rand(0, $j)];
}
return $String;
while($line = fgets($this->conn)) {
if ($line == ".\r\n") {
break;
- } elseif ( $line{0} == '.' ) {
+ } elseif ( $line[0] == '.' ) {
$ret .= substr($line,1);
} else {
$ret.= $line;
// 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));
}