return $string;
$string = preg_replace_callback("/([\201-\237])/",
- create_function ('$matches', 'return \'&#\' . ord($matches[1]) . \';\';'),
- $string);
+ (check_php_version(5, 3, 0)
+ ? function($matches) { return '&#' . ord($matches[1]) . ';'; }
+ : create_function ('$matches', 'return \'&#\' . ord($matches[1]) . \';\';')
+ ),
+ $string);
/* I don't want to use 0xA0 (\240) in any ranges. RH73 may dislike it */
$string = str_replace("\240", ' ', $string);
$string = preg_replace_callback("/([\241-\377])/",
- create_function ('$matches', 'return \'&#\' . ord($matches[1]) . \';\';'),
- $string);
+ (check_php_version(5, 3, 0)
+ ? function($matches) { return '&#' . ord($matches[1]) . ';'; }
+ : create_function ('$matches', 'return \'&#\' . ord($matches[1]) . \';\';')
+ ),
+ $string);
return $string;
}
// decode four byte unicode characters
$string = preg_replace_callback("/([\360-\367])([\200-\277])([\200-\277])([\200-\277])/",
- create_function ('$matches', 'return \'&#\'.((ord($matches[1])-240)*262144+(ord($matches[2])-128)*4096+(ord($matches[3])-128)*64+(ord($matches[4])-128)).\';\';'),
- $string);
+ (check_php_version(5, 3, 0)
+ ? function($matches) { return '&#'.((ord($matches[1])-240)*262144+(ord($matches[2])-128)*4096+(ord($matches[3])-128)*64+(ord($matches[4])-128)).';'; }
+ : create_function ('$matches', 'return \'&#\'.((ord($matches[1])-240)*262144+(ord($matches[2])-128)*4096+(ord($matches[3])-128)*64+(ord($matches[4])-128)).\';\';')
+ ),
+ $string);
// decode three byte unicode characters
$string = preg_replace_callback("/([\340-\357])([\200-\277])([\200-\277])/",
- create_function ('$matches', 'return \'&#\'.((ord($matches[1])-224)*4096+(ord($matches[2])-128)*64+(ord($matches[3])-128)).\';\';'),
- $string);
+ (check_php_version(5, 3, 0)
+ ? function($matches) { return '&#'.((ord($matches[1])-224)*4096+(ord($matches[2])-128)*64+(ord($matches[3])-128)).';'; }
+ : create_function ('$matches', 'return \'&#\'.((ord($matches[1])-224)*4096+(ord($matches[2])-128)*64+(ord($matches[3])-128)).\';\';')
+ ),
+ $string);
// decode two byte unicode characters
$string = preg_replace_callback("/([\300-\337])([\200-\277])/",
- create_function ('$matches', 'return \'&#\'.((ord($matches[1])-192)*64+(ord($matches[2])-128)).\';\';'),
- $string);
+ (check_php_version(5, 3, 0)
+ ? function($matches) { return '&#'.((ord($matches[1])-192)*64+(ord($matches[2])-128)).';'; }
+ : create_function ('$matches', 'return \'&#\'.((ord($matches[1])-192)*64+(ord($matches[2])-128)).\';\';')
+ ),
+ $string);
// remove broken unicode
$string = preg_replace("/[\200-\237]|\240|[\241-\377]/",'?',$string);
case 'TO':
case 'CC':
if(!$walk) {
- array_walk($msgs, create_function('&$v,&$k,$f',
- '$v[$f] = (isset($v[$f])) ? $v[$f] : "";
- $addr = reset(parseRFC822Address($v[$f],1));
- $sPersonal = (isset($addr[SQM_ADDR_PERSONAL]) && $addr[SQM_ADDR_PERSONAL]) ?
- $addr[SQM_ADDR_PERSONAL] : "";
- $sEmail = ($addr[SQM_ADDR_HOST]) ?
- $addr[SQM_ADDR_MAILBOX] . "@".$addr[SQM_ADDR_HOST] :
- $addr[SQM_ADDR_HOST];
- $v[$f] = ($sPersonal) ? decodeHeader($sPersonal, true, false):$sEmail;'),$sSortField);
+ if (check_php_version(5, 3, 0))
+ $walk_function = function(&$v,&$k,$f) {
+ $v[$f] = (isset($v[$f])) ? $v[$f] : "";
+ $addr = reset(parseRFC822Address($v[$f],1));
+ $sPersonal = (isset($addr[SQM_ADDR_PERSONAL]) && $addr[SQM_ADDR_PERSONAL]) ?
+ $addr[SQM_ADDR_PERSONAL] : "";
+ $sEmail = ($addr[SQM_ADDR_HOST]) ?
+ $addr[SQM_ADDR_MAILBOX] . "@".$addr[SQM_ADDR_HOST] :
+ $addr[SQM_ADDR_HOST];
+ $v[$f] = ($sPersonal) ? decodeHeader($sPersonal, true, false):$sEmail;
+ };
+ else
+ $walk_function = create_function('&$v,&$k,$f',
+ '$v[$f] = (isset($v[$f])) ? $v[$f] : "";
+ $addr = reset(parseRFC822Address($v[$f],1));
+ $sPersonal = (isset($addr[SQM_ADDR_PERSONAL]) && $addr[SQM_ADDR_PERSONAL]) ?
+ $addr[SQM_ADDR_PERSONAL] : "";
+ $sEmail = ($addr[SQM_ADDR_HOST]) ?
+ $addr[SQM_ADDR_MAILBOX] . "@".$addr[SQM_ADDR_HOST] :
+ $addr[SQM_ADDR_HOST];
+ $v[$f] = ($sPersonal) ? decodeHeader($sPersonal, true, false):$sEmail;');
+ array_walk($msgs, $walk_function, $sSortField);
$walk = true;
}
// nobreak
case 'SUBJECT':
if(!$walk) {
- array_walk($msgs, create_function('&$v,&$k,$f',
- '$v[$f] = (isset($v[$f])) ? $v[$f] : "";
- $v[$f] = strtolower(decodeHeader(trim($v[$f]), true, false));
- $v[$f] = (preg_match("/^(?:(?:vedr|sv|re|aw|fw|fwd|\[\w\]):\s*)*\s*(.*)$/si", $v[$f], $matches)) ?
- $matches[1] : $v[$f];'),$sSortField);
+ if (check_php_version(5, 3, 0))
+ $walk_function = function(&$v,&$k,$f) {
+ $v[$f] = (isset($v[$f])) ? $v[$f] : "";
+ $v[$f] = strtolower(decodeHeader(trim($v[$f]), true, false));
+ $v[$f] = (preg_match("/^(?:(?:vedr|sv|re|aw|fw|fwd|\[\w\]):\s*)*\s*(.*)$/si", $v[$f], $matches)) ?
+ $matches[1] : $v[$f];
+ };
+ else
+ $walk_function = create_function('&$v,&$k,$f',
+ '$v[$f] = (isset($v[$f])) ? $v[$f] : "";
+ $v[$f] = strtolower(decodeHeader(trim($v[$f]), true, false));
+ $v[$f] = (preg_match("/^(?:(?:vedr|sv|re|aw|fw|fwd|\[\w\]):\s*)*\s*(.*)$/si", $v[$f], $matches)) ?
+ $matches[1] : $v[$f];');
+ array_walk($msgs, $walk_function, $sSortField);
$walk = true;
}
foreach ($msgs as $item) {
case 'DATE':
case 'INTERNALDATE':
if(!$walk) {
- array_walk($msgs, create_function('&$v,$k,$f',
- '$v[$f] = (isset($v[$f])) ? $v[$f] : "";
- $v[$f] = getTimeStamp(explode(" ",$v[$f]));'),$sSortField);
+ if (check_php_version(5, 3, 0))
+ $walk_function = function(&$v,$k,$f) {
+ $v[$f] = (isset($v[$f])) ? $v[$f] : "";
+ $v[$f] = getTimeStamp(explode(" ",$v[$f]));
+ };
+ else
+ $walk_function = create_function('&$v,$k,$f',
+ '$v[$f] = (isset($v[$f])) ? $v[$f] : "";
+ $v[$f] = getTimeStamp(explode(" ",$v[$f]));');
+ array_walk($msgs, $walk_function, $sSortField);
$walk = true;
}
// nobreak;