global $prefs_are_cached, $prefs_cache;
if ( isset($prefs_are_cached) && $prefs_are_cached) {
- return;
+ return $prefs_cache;
}
sqsession_unregister('prefs_cache');
sqsession_register($prefs_cache, 'prefs_cache');
sqsession_register($prefs_are_cached, 'prefs_are_cached');
+ return $prefs_cache;
}
/**
$result = do_hook_function('get_pref_override',array($username,$string));
if (!$result) {
- cachePrefValues($data_dir, $username);
+ $prefs_cache = cachePrefValues($data_dir, $username);
if (isset($prefs_cache[$string])) {
$result = $prefs_cache[$string];
} else {
/**
* Save the preferences for this user.
*/
-function savePrefValues($data_dir, $username) {
- global $prefs_cache;
+function savePrefValues($data_dir, $username, $prefs_cache) {
$filename = getHashedFile($username, $data_dir, "$username.pref");
+ if (!is_array($prefs_cache) || count($prefs_cache) == 0) {
+ include_once(SM_PATH . 'functions/display_messages.php');
+ logout_error( _("Houston we have a problem, the preference cache is lost!!!."));
+ exit;
+ }
+
/* Open the file for writing, or else display an error to the user. */
if(!$file = @fopen($filename.'.tmp', 'w'))
{
function removePref($data_dir, $username, $string) {
global $prefs_cache;
- cachePrefValues($data_dir, $username);
-
if (isset($prefs_cache[$string])) {
unset($prefs_cache[$string]);
}
- savePrefValues($data_dir, $username);
+ savePrefValues($data_dir, $username,$prefs_cache);
}
/**
function setPref($data_dir, $username, $string, $value) {
global $prefs_cache;
- cachePrefValues($data_dir, $username);
if (isset($prefs_cache[$string]) && ($prefs_cache[$string] == $value)) {
return;
}
if ($value === '') {
- removePref($data_dir, $username, $string);
- return;
+ unset($prefs_cache[$string]);
+ } else {
+ $prefs_cache[$string] = $value;
}
-
- $prefs_cache[$string] = $value;
- savePrefValues($data_dir, $username);
+ savePrefValues($data_dir, $username, $prefs_cache);
}
/**
}
}
-
- $subject = processSubject(decodeHeader($msg['SUBJECT']), $indent_array[$msg['ID']]);
+ $subject_full = decodeHeader($msg['SUBJECT']);
+ $subject = processSubject($subject_full, $indent_array[$msg['ID']]);
echo html_tag( 'tr','','','','VALIGN="top"') . "\n";
$td_str .= '<a href="read_body.php?mailbox='.$urlMailbox
. '&passed_id='. $msg["ID"]
. '&startMessage='.$start_msg.$searchstr.'"';
- $td_str .= ' ' .concat_hook_function('subject_link');
- if ($subject != $msg['SUBJECT']) {
+ do_hook("subject_link");
+ if ($subject != $subject_full) {
$title = get_html_translation_table(HTML_SPECIALCHARS);
$title = array_flip($title);
- $title = strtr($msg['SUBJECT'], $title);
+ $title = strtr($subject_full, $title);
$title = str_replace('"', "''", $title);
$td_str .= " title=\"$title\"";
}
if (!is_object($msg)) {
include_once(SM_PATH . 'functions/display_messages.php');
global $color, $mailbox;
+ /* removed urldecode because $_GET is auto urldecoded ??? */
displayPageHeader( $color, $mailbox );
echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n\n" .
'<CENTER>';
if (is_array($string)) {
$string = implode("\n", $string);
}
-
+
if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
$string = $languages[$squirrelmail_language]['XTRA_CODE']('decodeheader', $string);
$aString[$i] = '';
while (preg_match('/^(.*)=\?([^?]*)\?(Q|B)\?([^?]*)\?=(.*)$/Ui',$chunk,$res)) {
//$aString[$i] .= $res[1];
- //echo "match ". $res[5] . "<br>";
+ //echo "$chunk match ". $res[5] . "<br>";
$encoding = ucfirst($res[3]);
switch ($encoding)
{
$replace = charset_decode($res[2], $replace);
} else {
if ($htmlsave) {
- $replace = htmlspecialchars($res[4]);
+ $replace = htmlspecialchars($replace);
}
}
$aString[$i] .= $replace;
}
++$i;
}
- if ($htmlsave) {
- return implode(' ',$aString);
- } else {
- return implode (' ',$aString);
- }
+ return implode (' ',$aString);
+
}
/*
function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
return $languages[$squirrelmail_language]['XTRA_CODE']('encodeheader', $string);
}
+ if (strtolower($default_charset) == 'iso-8859-1') {
+ $string = str_replace("\240",' ',$string);
+ }
// Encode only if the string contains 8-bit characters or =?
$j = strlen($string);
- $l = strstr($string, '=?'); // Must be encoded ?
$max_l = 75 - strlen($default_charset) - 7;
$aRet = array();
$ret = '';
- $enc = false;
+ $iEncStart = $enc_init = false;
$cur_l = $iOffset = 0;
for($i = 0; $i < $j; ++$i) {
- switch($string{$i}) {
- case '=':
- $cur_l+=3;
- if ($cur_l > $max_l) {
- if ($enc) {
- $aRet[] = "=?$default_charset?Q?$ret?=";
- $enc = false;
- } else {
- $aRet[] = substr($string,$iOffset,$i-$iOffset+1);
- }
- $iOffset = $i+1;
- $cur_l = 3;
- $ret = '';
- }
- $ret .= '=3D';
- break;
- case '?':
- $cur_l+=3;
- if ($cur_l > $max_l) {
- if ($enc) {
- $aRet[] = "=?$default_charset?Q?$ret?=";
- $enc = false;
- } else {
- $aRet[] = substr($string,$iOffset,$i-$iOffset+1);
- }
- $iOffset = $i+1;
- $cur_l = 3;
- $ret = '';
- }
- $ret .= '=3F';
- break;
- case '_':
- $cur_l+=3;
- if ($cur_l > $max_l) {
- if ($enc) {
- $aRet[] = "=?$default_charset?Q?$ret?=";
- $enc = false;
- } else {
- $aRet[] = substr($string,$iOffset,$i-$iOffset+1);
- }
- $iOffset = $i+1;
- $cur_l = 3;
- $ret = '';
- }
- $ret .= '=5F';
- break;
- case ' ':
+ switch($string{$i})
+ {
+ case '=':
+ case '<':
+ case '>':
+ case ',':
+ case '?':
+ case '_':
+ if ($iEncStart === false) {
+ $iEncStart = $i;
+ }
+ $cur_l+=3;
+ if ($cur_l > ($max_l-2)) {
+ $aRet[] = substr($string,$iOffset,$iEncStart-$iOffset);
+ $aRet[] = "=?$default_charset?Q?$ret?=";
+ $iOffset = $i;
+ $cur_l = 0;
+ $ret = '';
+ $iEncStart = false;
+ } else {
+ $ret .= sprintf("=%02X",ord($string{$i}));
+ }
+ break;
+ case '(':
+ case ')':
+ if ($iEncStart !== false) {
+ $aRet[] = substr($string,$iOffset,$iEncStart-$iOffset);
+ $aRet[] = "=?$default_charset?Q?$ret?=";
+ $iOffset = $i;
+ $cur_l = 0;
+ $ret = '';
+ $iEncStart = false;
+ }
+ break;
+ case ' ':
+ if ($iEncStart !== false) {
$cur_l++;
if ($cur_l > $max_l) {
- if ($enc) {
- $aRet[] = "=?$default_charset?Q?$ret?=";
- $enc = false;
- } else {
- $aRet[] = substr($string,$iOffset,$i-$iOffset+1);
- }
- $iOffset = $i+1;
- $cur_l = 1;
- $ret = '';
- }
- $ret .= '_';
- break;
- default:
- $k = ord($string{$i});
- if ($k > 126) {
- $enc = true;
- $s = sprintf("=%02X", $k);
- $cur_l += strlen($s);
- if ($cur_l > $max_l) {
+ $aRet[] = substr($string,$iOffset,$iEncStart-$iOffset);
+ $aRet[] = "=?$default_charset?Q?$ret?=";
+ $iOffset = $i;
+ $cur_l = 0;
+ $ret = '';
+ $iEncStart = false;
+ } else {
+ $ret .= '_';
+ }
+ }
+ break;
+ default:
+ $k = ord($string{$i});
+ if ($k > 126) {
+ if ($iEncStart === false) {
+ $iEncStart = $i;
+ }
+ $cur_l += 3;
+ if ($cur_l > ($max_l-2)) {
+ if ($iEncStart !== false) {
+ $aRet[] = substr($string,$iOffset,$iEncStart-$iOffset);
$aRet[] = "=?$default_charset?Q?$ret?=";
- $cur_l = strlen($s);
- $ret = '';
- $l = false;
- $enc = false;
- $iOffset = $i+1;
- }
- $ret .= $s;
- $l = TRUE;
- } else {
+ } else {
+ $aRet[] = substr($string,$iOffset,$i-$iOffset);
+ }
+ $cur_l = 3;
+ $ret = '';
+ $iOffset = $i;
+ }
+ $enc_init = true;
+ $ret .= sprintf("=%02X", $k);
+ } else {
+ if ($iEncStart !== false) {
$cur_l++;
if ($cur_l > $max_l) {
- if ($enc) {
- $aRet[] = "=?$default_charset?Q?$ret?=";
- $enc = false;
- } else {
- $aRet[] = substr($ret,$iOffset,$i-$iOffset+1);
- }
- $iOffset = $i+1;
- $l = false;
- $cur_l = 1;
+ $aRet[] = substr($string,$iOffset,$iEncStart-$iOffset);
+ $aRet[] = "=?$default_charset?Q?$ret?=";
+ $iEncStart = false;
+ $iOffset = $i;
+ $cur_l = 0;
$ret = '';
- }
- $ret .= $string{$i};
+ } else {
+ $ret .= $string{$i};
+ }
}
- break;
+ }
+ break;
}
}
- if ($enc) {
- $string = implode('',$aRet) . "=?$default_charset?Q?$ret?=";
+ if ($enc_init) {
+ if ($iEncStart !== false) {
+ $aRet[] = substr($string,$iOffset,$iEncStart-$iOffset);
+ $aRet[] = "=?$default_charset?Q?$ret?=";
+ } else {
+ $aRet[] = substr($string,$iOffset);
+ }
+ $string = implode('',$aRet);
}
-
return $string;
}