diff --git a/language/az.php b/language/az.php index a71670ff2a..872fd8cba7 100755 --- a/language/az.php +++ b/language/az.php @@ -458,6 +458,7 @@ 'Current password is incorrect' => 'Cari parol doğru deyil', 'Details' => 'Detallar', 'Don\'t save account passwords between logins' => 'Girişlərin arasında hesabın şifrəni saxlamamaq', + 'Do you want to log out?' => 'Çıxmaq istəyirsiniz?', 'Drafts' => 'Layihələr', 'Enter your passwords below to gain access to these services during this session.' => 'Seansın zamanı bu xidmətlərə giriş əldə etmək üçün şifrəni daxil edin.', 'Failed to authenticate to the SMTP server' => 'SMTP-serverdə əslliyin yoxlamasını yerinə yetirmək müvəffəq olmadı', diff --git a/language/de.php b/language/de.php index 9ef5394ea4..41cc521090 100755 --- a/language/de.php +++ b/language/de.php @@ -455,6 +455,7 @@ 'Current password is incorrect' => 'Aktuelles Passwort ist falsch', 'Details' => 'Details', 'Don\'t save account passwords between logins' => 'Passwort nicht speichern zwischen den Logins', + 'Do you want to log out?' => 'Möchten Sie sich abmelden?', 'Drafts' => 'Entwürfe', 'Enter your passwords below to gain access to these services during this session.' => 'Gebe dein Passwort ein um Zugriff auf die Dienste während dieser Sitzung zu erhalten', 'Failed to authenticate to the SMTP server' => 'Authentifizierung am SMTP Server fehlgeschlagen', diff --git a/language/en.php b/language/en.php index d77bb4db80..f3db3f0a10 100755 --- a/language/en.php +++ b/language/en.php @@ -5,7 +5,6 @@ return array( 'interface_lang' => 'en', 'interface_direction' => 'ltr', - 'Main' => false, 'Username' => false, 'Password' => false, @@ -455,6 +454,7 @@ 'Current password is incorrect' => false, 'Details' => false, 'Don\'t save account passwords between logins' => false, + 'Do you want to log out?' => false, 'Drafts' => false, 'Enter your passwords below to gain access to these services during this session.' => false, 'Failed to authenticate to the SMTP server' => false, @@ -646,4 +646,4 @@ 'Junk' => false, 'Trash' => false, 'You have %d scheduled messages that won\'t be executed if you quit' => false, -); +); \ No newline at end of file diff --git a/language/es.php b/language/es.php index d7082406e5..58915526c4 100755 --- a/language/es.php +++ b/language/es.php @@ -455,6 +455,7 @@ 'Current password is incorrect' => 'La contraseña en curso es incorrecta', 'Details' => 'Detalles', 'Don\'t save account passwords between logins' => 'No salvar contraseñas de cuenta entre ingresos', + 'Do you want to log out?' => '¿Desea cerrar sesión?', 'Drafts' => 'Borradores', 'Enter your passwords below to gain access to these services during this session.' => 'Digite su contraseña de abajo para ganar acceso a estos servicios durante la sesión', 'Failed to authenticate to the SMTP server' => 'No pude autenticar con el servidor SMTP', diff --git a/language/et.php b/language/et.php index cac12ca267..c868df111f 100755 --- a/language/et.php +++ b/language/et.php @@ -459,6 +459,7 @@ 'Current password is incorrect' => 'Praegune salasõna ei ole õige', 'Details' => 'Detailne teave', 'Don\'t save account passwords between logins' => 'Ära salvesta salasõnu sisselogimiste vahel', + 'Do you want to log out?' => 'Kas soovite välja logida?', 'Drafts' => 'Kavandid', 'Enter your passwords below to gain access to these services during this session.' => 'Selleks et saada selles sessioonis ligipääsu nendele teenustele sisesta alljärgnevalt oma salasõna', 'Failed to authenticate to the SMTP server' => 'Autentimine SMTP serveris ebaõnnestus', @@ -636,4 +637,4 @@ 'Junk' => false, 'Trash' => false, 'You have %d scheduled messages that won\'t be executed if you quit' => false, -); +); \ No newline at end of file diff --git a/language/fa.php b/language/fa.php index 5aca3419c8..fb9866402a 100755 --- a/language/fa.php +++ b/language/fa.php @@ -250,6 +250,7 @@ "Hide From Combined Pages"=>"پنهان کردن از صفحات ترکیبی", "Save Settings"=>"تنظیمات را ذخیره کن", "Settings are not saved permanently on the server unless you explicitly allow it. If you don\'t save your settings, any changes made since you last logged in will be deleted when your session expires or you logout. You must re-enter your password for security purposes to save your settings permanently."=>"تنظیمات برای همیشه در سرور ذخیره نمی شوند ، مگر اینکه صریحاً اجازه آن را بدهید. اگر تنظیمات خود را ذخیره نکنید ، با اتمام جلسه یا خارج شدن از سیستم ، هر تغییری که از آخرین ورود به سیستم انجام داده اید ، حذف خواهد شد. برای ذخیره تنظیمات خود باید دوباره رمز ورود خود را برای اهداف امنیتی وارد کنید.", + "Do you want to log out?" => "می‌خواهید خارج شوید؟", "Add a Repository"=>"مخزن اضافه کنید", "Disconnect"=>"قطع شدن", "Already connected"=>"قبلاً متصل شده اید", diff --git a/language/fr.php b/language/fr.php index 6aaf8b08c9..6bbb9e3e46 100755 --- a/language/fr.php +++ b/language/fr.php @@ -455,6 +455,7 @@ 'Current password is incorrect' => 'Le mot de passe actuel est incorrect', 'Details' => 'Détails', 'Don\'t save account passwords between logins' => 'Ne pas sauvegarder les mots de passe des comptes entre les connexions', + 'Do you want to log out?' => 'Voulez-vous vous déconnecter ?', 'Drafts' => 'Brouillons', 'Enter your passwords below to gain access to these services during this session.' => 'Entrez vos mots de passe ci-dessous pour accéder à ces services pendant cette session', 'Failed to authenticate to the SMTP server' => 'Échec de l\'authentification auprès du serveur SMTP', diff --git a/language/hu.php b/language/hu.php index ded277242d..54aa89673f 100755 --- a/language/hu.php +++ b/language/hu.php @@ -455,6 +455,7 @@ 'Current password is incorrect' => 'A jelenlegi jelszó hibás', 'Details' => 'Részletek', 'Don\'t save account passwords between logins' => 'Ne mentse el a jelszavakat bejelentkezések között', + 'Do you want to log out?' => 'Ki akar jelentkezni?', 'Drafts' => 'Piszkozatok', 'Enter your passwords below to gain access to these services during this session.' => 'Adja meg jelszavát, hogy hozzáférjen ezekhez a szolgáltatásokhoz a munkamenet során.', 'Failed to authenticate to the SMTP server' => 'Sikertelen azonosítás az SMTP kiszolgálón', @@ -628,4 +629,4 @@ 'Junk' => false, 'Trash' => false, 'You have %d scheduled messages that won\'t be executed if you quit' => false, -); +); \ No newline at end of file diff --git a/language/id.php b/language/id.php index 05d2a44b1c..f720d4cba3 100755 --- a/language/id.php +++ b/language/id.php @@ -463,6 +463,7 @@ 'Details' => 'Rincian', 'Don\'t save account passwords between logins' => 'Jangan menyimpan kata sandi akun diantara sesi masuk', 'Drafts' => 'Konsep', + 'Do you want to log out?' => 'Apakah Anda ingin keluar?', 'Enter your passwords below to gain access to these services during this session.' => 'Masukkan kata sandi Anda di bawah untuk mendapatkan akses ke layanan berikut selama sesi ini.', 'Failed to authenticate to the SMTP server' => 'Gagal untuk meng-otentikasi ke server SMTP', 'Feed deleted' => 'Feed dihapus', @@ -635,4 +636,4 @@ 'Junk' => false, 'Trash' => false, 'You have %d scheduled messages that won\'t be executed if you quit' => false, -); +); \ No newline at end of file diff --git a/language/it.php b/language/it.php index d00269e86f..9caeaed280 100755 --- a/language/it.php +++ b/language/it.php @@ -455,6 +455,7 @@ 'Current password is incorrect' => 'La password attuale non è corretta', 'Details' => 'Dettagli', 'Don\'t save account passwords between logins' => 'Non salvare le password degli account tra un accesso e l\'altro', + 'Do you want to log out?' => 'Vuoi uscire?', 'Drafts' => 'Bozze', 'Enter your passwords below to gain access to these services during this session.' => 'Inserisci le tue password di seguito per accedere a questi servizi durante questa sessione.', 'Failed to authenticate to the SMTP server' => 'Impossibile autenticarsi al server SMTP', diff --git a/language/ja.php b/language/ja.php index 3fc6287b7b..d9e80055fd 100755 --- a/language/ja.php +++ b/language/ja.php @@ -455,6 +455,7 @@ 'Current password is incorrect' => false, 'Details' => false, 'Don\'t save account passwords between logins' => 'ログインパスワードを保存しない', + 'Do you want to log out?' => 'ログアウトしますか?', 'Drafts' => false, 'Enter your passwords below to gain access to these services during this session.' => false, 'Failed to authenticate to the SMTP server' => 'SMTPサーバーの認証に失敗しました', @@ -628,4 +629,4 @@ 'Junk' => false, 'Trash' => false, 'You have %d scheduled messages that won\'t be executed if you quit' => false, -); +); \ No newline at end of file diff --git a/language/nl.php b/language/nl.php index 0d5713a38d..285264dadd 100755 --- a/language/nl.php +++ b/language/nl.php @@ -455,6 +455,7 @@ 'Current password is incorrect' => 'Huidige wachtwoord is fout', 'Details' => 'Details', 'Don\'t save account passwords between logins' => 'Account wachtwoord niet opslaan tussen logins', + 'Do you want to log out?' => 'Wilt u uitloggen?', 'Drafts' => false, 'Enter your passwords below to gain access to these services during this session.' => 'Geef uw wachtwoord hieronder in om toegang tot deze services te krijgen tijdens de sessie', 'Failed to authenticate to the SMTP server' => 'Authenticatie met de SMPT-server mislukt', @@ -628,4 +629,4 @@ 'Junk' => false, 'Trash' => false, 'You have %d scheduled messages that won\'t be executed if you quit' => false, -); +); \ No newline at end of file diff --git a/language/pt-BR.php b/language/pt-BR.php index b7c70e7f64..6ab88e0723 100755 --- a/language/pt-BR.php +++ b/language/pt-BR.php @@ -454,6 +454,7 @@ 'Current password is incorrect' => 'Senha atual está incorreta', 'Details' => 'Detalhes', 'Don\'t save account passwords between logins' => 'Não salvar senhas de contas entre sessões', + 'Do you want to log out?' => 'Deseja sair?', 'Drafts' => 'Rascunhos', 'Enter your passwords below to gain access to these services during this session.' => 'Entre abaixo suas senhas para ter acesso a esses serviços durante esta sessão.', 'Failed to authenticate to the SMTP server' => 'Falha ao autenticar no servidor de SMTP', @@ -627,4 +628,4 @@ 'Junk' => false, 'Trash' => false, 'You have %d scheduled messages that won\'t be executed if you quit' => false, -); +); \ No newline at end of file diff --git a/language/ro.php b/language/ro.php index fdb185c430..87ec1b7b8d 100755 --- a/language/ro.php +++ b/language/ro.php @@ -454,6 +454,7 @@ 'Current password is incorrect' => false, 'Details' => false, 'Don\'t save account passwords between logins' => 'Nu salvați parolele între conectări', + 'Do you want to log out?' => 'Doriți să vă deconectați?', 'Drafts' => 'Ciorne', 'Enter your passwords below to gain access to these services during this session.' => false, 'Failed to authenticate to the SMTP server' => 'Eroare de autentificare la serverul SMTP', @@ -627,4 +628,4 @@ 'Junk' => false, 'Trash' => false, 'You have %d scheduled messages that won\'t be executed if you quit' => false, -); +); \ No newline at end of file diff --git a/language/ru.php b/language/ru.php index 498ba1b00a..14392e185b 100755 --- a/language/ru.php +++ b/language/ru.php @@ -456,6 +456,7 @@ 'Current password is incorrect' => 'Текущий пароль не верен', 'Details' => 'Детали', 'Don\'t save account passwords between logins' => 'Не сохранять пароль аккаунта между входами', + 'Do you want to log out?' => 'Вы хотите выйти?', 'Drafts' => 'Черновики', 'Enter your passwords below to gain access to these services during this session.' => 'Введите Ваш пароль ниже чтобы получить пароль к этим службам во время этого сеанса', 'Failed to authenticate to the SMTP server' => 'Невозможно аутентифицироваться на SMTP сервере', @@ -629,4 +630,4 @@ 'Junk' => false, 'Trash' => false, 'You have %d scheduled messages that won\'t be executed if you quit' => false, -); +); \ No newline at end of file diff --git a/language/zh-Hans.php b/language/zh-Hans.php index 334d4223cf..b675b936f1 100644 --- a/language/zh-Hans.php +++ b/language/zh-Hans.php @@ -1,6 +1,6 @@ '当前密码错误', 'Details' => '详情', 'Don\'t save account passwords between logins' => '不要保存登录密码', + 'Do you want to log out?' => '您是否要退出?', 'Drafts' => '草稿', 'Enter your passwords below to gain access to these services during this session.' => '在下方键入密码以获得在本次会话中对这些服务的使用权限。', 'Failed to authenticate to the SMTP server' => '验证 SMTP 服务器失败', @@ -649,4 +650,4 @@ 'Junk' => '垃圾', 'Trash' => '已删除', 'You have %d scheduled messages that won\'t be executed if you quit' => false, -); +); \ No newline at end of file diff --git a/modules/core/site.js b/modules/core/site.js index d74fe67713..4b6c2af7dd 100644 --- a/modules/core/site.js +++ b/modules/core/site.js @@ -682,7 +682,8 @@ function Message_List() { } }); } - if (element) { + // apply JS pagination only on aggregate folders; imap ones already have the messages sorted + if (hm_list_path().substring(0, 5) != 'imap_' && element) { $(row, msg_rows).insertBefore(element); } else { @@ -1291,7 +1292,7 @@ var Hm_Folders = { }, folder_list_events: function() { - $('.imap_folder_link').on("click", function() { return expand_imap_folders($(this).data('target')); }); + $('.imap_folder_link').on("click", function() { return expand_imap_folders($(this)); }); $('.src_name').on("click", function() { var class_name = $(this).data('source'); var icon_element = $(this).find('.bi'); @@ -1434,7 +1435,7 @@ var Hm_Utils = { }, confirm_logout: function() { - if ($('#unsaved_changes').val() == 0) { + if (! $('#unsaved_changes').length || $('#unsaved_changes').val() == 0) { document.getElementById('logout_without_saving').click(); } else { @@ -1987,6 +1988,9 @@ $(function() { /* fire up the job scheduler */ Hm_Timer.fire(); + + /* show any pending notices */ + Hm_Utils.show_sys_messages(); /* load folder list */ if (hm_is_logged() && (!reloaded && !Hm_Folders.load_from_local_storage())) { @@ -2034,6 +2038,13 @@ $(function() { $('form:not(.search_terms)').areYouSure(); } + $(document).on('paste', '.warn_on_paste', function (e) { + const paste = (e.clipboardData || window.clipboardData).getData('text'); + if (hasLeadingOrTrailingSpaces(paste)) { + Hm_Utils.add_sys_message(hm_trans('Pasted text has leading or trailing spaces'), 'danger'); + } + }); + fixLtrInRtl() }); @@ -2707,27 +2718,31 @@ const observeMessageTextMutationAndHandleExternalResources = (inline) => { }; var setup_nexter_date = function(callback) { + var scopedElement = function (el, selector) { + return $(el).parent().parent().find(selector); + } $(document).on('click', '.nexter_date_picker', function(e) { document.querySelector('.nexter_input_date').showPicker(); }); $(document).on('click', '.nexter_date_helper', function(e) { e.preventDefault(); - $('.nexter_input').val($(this).attr('data-value')).trigger('change'); + scopedElement(this, '.nexter_input').val($(this).attr('data-value')).trigger('change'); }); $(document).on('input', '.nexter_input_date', function(e) { var now = new Date(); now.setMinutes(now.getMinutes() + 1); $(this).attr('min', now.toJSON().slice(0, 16)); + var date_picker = scopedElement(this, '.nexter_date_picker'); if (new Date($(this).val()).getTime() <= now.getTime()) { - $('.nexter_date_picker').css('border', '1px solid red'); + date_picker.css('border', '1px solid red'); } else { - $('.nexter_date_picker').css({'border': 'unset', 'border-top': '1px solid #ddd'}); + date_picker.css({'border': 'unset', 'border-top': '1px solid #ddd'}); } }); $(document).on('change', '.nexter_input_date', function(e) { if ($(this).val() && new Date().getTime() < new Date($(this).val()).getTime()) { - $('.nexter_input').val($(this).val()).trigger('change'); + scopedElement(this, '.nexter_input').val($(this).val()).trigger('change'); } }); $(document).on('change', '.nexter_input', callback); -} +} \ No newline at end of file diff --git a/modules/imap/functions.php b/modules/imap/functions.php index 460fd99b26..cada790a31 100644 --- a/modules/imap/functions.php +++ b/modules/imap/functions.php @@ -114,6 +114,8 @@ function prepare_imap_message_list($msgs, $mod, $type) { function format_imap_folder_section($folders, $id, $output_mod, $with_input = false) { $results = ''; return $results; @@ -244,7 +249,7 @@ function format_imap_message_list($msg_list, $output_module, $parent_list=false, } $flags = array(); - if (!stristr($msg['flags'], 'seen')) { + if (!mb_stristr($msg['flags'], 'seen')) { $flags[] = 'unseen'; if ($icon != 'sent') { $icon = 'env_closed'; @@ -258,7 +263,7 @@ function format_imap_message_list($msg_list, $output_module, $parent_list=false, $icon = 'sent'; } foreach (array('attachment', 'deleted', 'flagged', 'answered', 'draft') as $flag) { - if (stristr($msg['flags'], $flag)) { + if (mb_stristr($msg['flags'], $flag)) { $flags[] = $flag; } } @@ -415,7 +420,7 @@ function format_msg_part_row($id, $vals, $output_mod, $level, $part, $dl_args, $ 'multipartmixed', 'messagerfc822', ); - $lc_type = strtolower($vals['type']).strtolower($vals['subtype']); + $lc_type = mb_strtolower($vals['type']).mb_strtolower($vals['subtype']); if ($simple_view) { if (filter_message_part($vals)) { return ''; @@ -441,8 +446,8 @@ function format_msg_part_row($id, $vals, $output_mod, $level, $part, $dl_args, $ if ($use_icons && array_key_exists($lc_type, $icons)) { $icon = $icons[$lc_type]; } - elseif ($use_icons && array_key_exists(strtolower($vals['type']), $icons)) { - $icon = $icons[strtolower($vals['type'])]; + elseif ($use_icons && array_key_exists(mb_strtolower($vals['type']), $icons)) { + $icon = $icons[mb_strtolower($vals['type'])]; } if ($icon) { $res .= ' '; @@ -451,11 +456,11 @@ function format_msg_part_row($id, $vals, $output_mod, $level, $part, $dl_args, $ $res .= ' '; } if (in_array($lc_type, $allowed, true)) { - $res .= ''.$output_mod->html_safe(strtolower($vals['type'])). - ' / '.$output_mod->html_safe(strtolower($vals['subtype'])).''; + $res .= ''.$output_mod->html_safe(mb_strtolower($vals['type'])). + ' / '.$output_mod->html_safe(mb_strtolower($vals['subtype'])).''; } else { - $res .= $output_mod->html_safe(strtolower($vals['type'])).' / '.$output_mod->html_safe(strtolower($vals['subtype'])); + $res .= $output_mod->html_safe(mb_strtolower($vals['type'])).' / '.$output_mod->html_safe(mb_strtolower($vals['subtype'])); } if ($mobile) { $res .= '
'.$output_mod->html_safe($size); @@ -465,8 +470,8 @@ function format_msg_part_row($id, $vals, $output_mod, $level, $part, $dl_args, $ else { $res .= ''.$output_mod->html_safe($size); if (!$simple_view) { - $res .= ''.(isset($vals['encoding']) ? $output_mod->html_safe(strtolower($vals['encoding'])) : ''). - ''.(isset($vals['attributes']['charset']) && trim($vals['attributes']['charset']) ? $output_mod->html_safe(strtolower($vals['attributes']['charset'])) : ''); + $res .= ''.(isset($vals['encoding']) ? $output_mod->html_safe(mb_strtolower($vals['encoding'])) : ''). + ''.(isset($vals['attributes']['charset']) && trim($vals['attributes']['charset']) ? $output_mod->html_safe(mb_strtolower($vals['attributes']['charset'])) : ''); } $res .= ''.$output_mod->html_safe(decode_fld($desc)).''; $res .= ''.$output_mod->trans('Download').''; @@ -768,10 +773,10 @@ function merge_imap_search_results($ids, $search_type, $session, $hm_cache, $fol $msgs = array_slice($msgs, 0, $limit); } foreach ($imap->get_message_list($msgs) as $msg) { - if (array_key_exists('content-type', $msg) && stristr($msg['content-type'], 'multipart/mixed')) { + if (array_key_exists('content-type', $msg) && mb_stristr($msg['content-type'], 'multipart/mixed')) { $msg['flags'] .= ' \Attachment'; } - if (stristr($msg['flags'], 'deleted')) { + if (mb_stristr($msg['flags'], 'deleted')) { continue; } $msg['server_id'] = $id; @@ -866,7 +871,7 @@ function imap_move_same_server($ids, $action, $hm_cache, $dest_path) { $imap = Hm_IMAP_List::connect($server_id, $cache); foreach ($ids[$server_id] as $folder => $msgs) { if (imap_authed($imap) && $imap->select_mailbox(hex2bin($folder))) { - if ($imap->message_action(strtoupper($action), $msgs, hex2bin($dest_path[2]))) { + if ($imap->message_action(mb_strtoupper($action), $msgs, hex2bin($dest_path[2]))) { foreach ($msgs as $msg) { $moved[] = sprintf('imap_%s_%s_%s', $server_id, $msg, $folder); } @@ -899,7 +904,7 @@ function imap_move_different_server($ids, $action, $dest_path, $hm_cache) { foreach ($msg_ids as $msg_id) { $detail = $imap->get_message_list(array($msg_id)); if (array_key_exists($msg_id, $detail)) { - if (stristr($detail[$msg_id]['flags'], 'seen')) { + if (mb_stristr($detail[$msg_id]['flags'], 'seen')) { $seen = true; } else { @@ -913,7 +918,7 @@ function imap_move_different_server($ids, $action, $dest_path, $hm_cache) { if (!$seen) { $imap->message_action('UNREAD', array($msg_id)); } - if ($dest_imap->append_start(hex2bin($dest_path[2]), strlen($msg), $seen)) { + if ($dest_imap->append_start(hex2bin($dest_path[2]), mb_strlen($msg), $seen)) { $dest_imap->append_feed($msg."\r\n"); if ($dest_imap->append_end()) { if ($action == 'move') { @@ -998,11 +1003,11 @@ function get_imap_mime_extension($type, $subtype) { */ if (!hm_exists('get_imap_part_name')) { function get_imap_part_name($struct, $uid, $part_id, $no_default=false) { - $extension = get_imap_mime_extension(strtolower($struct['type']), strtolower($struct['subtype'])); + $extension = get_imap_mime_extension(mb_strtolower($struct['type']), mb_strtolower($struct['subtype'])); if (array_key_exists('file_attributes', $struct) && is_array($struct['file_attributes']) && array_key_exists('attachment', $struct['file_attributes']) && is_array($struct['file_attributes']['attachment'])) { for ($i=0;$idump() as $name => $val) { - if (substr($name, 0, 19) == 'reply_details_imap_') { + if (mb_substr($name, 0, 19) == 'reply_details_imap_') { $msgs[$name] = $val['ts']; } } @@ -1072,15 +1077,15 @@ function imap_authed($imap) { if (!hm_exists('process_sort_arg')) { function process_sort_arg($sort, $default = 'arrival') { if (!$sort) { - $default = strtoupper($default); + $default = mb_strtoupper($default); return array($default, true); } $rev = false; - if (substr($sort, 0, 1) == '-') { + if (mb_substr($sort, 0, 1) == '-') { $rev = true; - $sort = substr($sort, 1); + $sort = mb_substr($sort, 1); } - $sort = strtoupper($sort); + $sort = mb_strtoupper($sort); if ($sort == 'ARRIVAL' || $sort == 'DATE') { $rev = $rev ? false : true; } @@ -1095,7 +1100,7 @@ function imap_server_type($id) { $type = 'IMAP'; $details = Hm_IMAP_List::dump($id); if (is_array($details) && array_key_exists('type', $details)) { - $type = strtoupper($details['type']); + $type = mb_strtoupper($details['type']); } return $type; }} @@ -1110,7 +1115,7 @@ function get_list_headers($headers) { 'list-subscribe', 'list-archive', 'list-post', 'list-help'); foreach (lc_headers($headers) as $name => $val) { if (in_array($name, $list_headers, true)) { - $res[substr($name, 5)] = process_list_fld($val); + $res[mb_substr($name, 5)] = process_list_fld($val); } } return $res; @@ -1129,7 +1134,7 @@ function process_list_fld($fld) { $res['links'][] = $val; } elseif (preg_match("/^mailto/", $val)) { - $res['email'][] = substr($val, 7); + $res['email'][] = mb_substr($val, 7); } else { $res['values'][] = $val; @@ -1221,7 +1226,7 @@ function prep_folder_name($imap, $folder, $decode_folder=false, $parent=false) { if ($parent) { $folder = sprintf('%s%s%s', $parent, $ns['delim'], $folder); } - if ($folder && $ns['prefix'] && mb_substr($folder, 0, strlen($ns['prefix'])) !== $ns['prefix']) { + if ($folder && $ns['prefix'] && mb_substr($folder, 0, mb_strlen($ns['prefix'])) !== $ns['prefix']) { $folder = sprintf('%s%s', $ns['prefix'], $folder); } return $folder; @@ -1296,7 +1301,7 @@ function snooze_message($imap, $msg_id, $folder, $snooze_tag) { if (!count($imap->get_mailbox_status($snooze_folder))) { $imap->create_mailbox($snooze_folder); } - if ($imap->select_mailbox($snooze_folder) && $imap->append_start($snooze_folder, strlen($msg))) { + if ($imap->select_mailbox($snooze_folder) && $imap->append_start($snooze_folder, mb_strlen($msg))) { $imap->append_feed($msg."\r\n"); if ($imap->append_end()) { if ($imap->select_mailbox($folder) && $imap->message_action('DELETE', array($msg_id))) { @@ -1308,7 +1313,7 @@ function snooze_message($imap, $msg_id, $folder, $snooze_tag) { } else { $snooze_headers = parse_nexter_header($matches[0], 'X-Snoozed'); $original_folder = $snooze_headers['from']; - if ($imap->select_mailbox($original_folder) && $imap->append_start($original_folder, strlen($msg))) { + if ($imap->select_mailbox($original_folder) && $imap->append_start($original_folder, mb_strlen($msg))) { $imap->append_feed($msg."\r\n"); if ($imap->append_end()) { if ($imap->select_mailbox($snooze_folder) && $imap->message_action('DELETE', array($msg_id))) { @@ -1324,6 +1329,7 @@ function snooze_message($imap, $msg_id, $folder, $snooze_tag) { /** * @subpackage imap/functions */ + if (!hm_exists('snooze_dropdown')) { function snooze_dropdown($output, $unsnooze = false) { $values = nexter_formats(); @@ -1399,7 +1405,7 @@ function connect_to_imap_server($address, $name, $port, $user, $pass, $tls, $ima } } - $server = Hm_IMAP_List::get($imap_server_id, false); + $server = Hm_IMAP_List::get($imap_server_id, true); if ($enableSieve && $imap_sieve_host && @@ -1469,4 +1475,5 @@ function save_sent_msg($handler, $imap_id, $imap, $imap_details, $msg, $msg_id, } } return $uid; -}} +} +} \ No newline at end of file diff --git a/modules/imap/handler_modules.php b/modules/imap/handler_modules.php index bf2a1782c6..5ae825a615 100644 --- a/modules/imap/handler_modules.php +++ b/modules/imap/handler_modules.php @@ -53,7 +53,7 @@ public function process() { 'name' => 'mail.mime', 'type' => 'message/rfc822', 'no_encoding' => true, - 'size' => strlen($content) + 'size' => mb_strlen($content) ); $draft_id = next_draft_key($this->session); // This needs to be replaced with something that works with the new attachment @@ -312,8 +312,6 @@ public function process() { $imap_details = Hm_IMAP_List::dump($imap_id); $sent_folder = false; if (imap_authed($imap)) { - $uid = save_sent_msg($this, $imap_id, $imap, $imap_details, $msg, $mime->get_headers()['Message-Id']); - if ($uid) { if ($uid && $this->user_config->get('review_sent_email_setting', false)) { $this->out('redirect_url', '?page=message&uid='.$uid.'&list_path=imap_'.$imap_id.'_'.bin2hex($sent_folder)); } @@ -454,7 +452,7 @@ public function process() { $part_struct = array_shift($struct); $encoding = false; if (array_key_exists('encoding', $part_struct)) { - $encoding = trim(strtolower($part_struct['encoding'])); + $encoding = trim(mb_strtolower($part_struct['encoding'])); } $stream_size = $imap->start_message_stream($uid, $msg_id); if ($stream_size > 0) { @@ -517,7 +515,7 @@ public function process() { $part_struct = array_shift($struct); $encoding = false; if (array_key_exists('encoding', $part_struct)) { - $encoding = trim(strtolower($part_struct['encoding'])); + $encoding = trim(mb_strtolower($part_struct['encoding'])); } $stream_size = $imap->start_message_stream($uid, $msg_id); if ($stream_size > 0) { @@ -646,7 +644,7 @@ public function process() { $attachment_id = get_attachment_id_for_mail_parser($imap, $uid, $this->request->get['imap_msg_part']); if ($attachment_id !== false) { $msg = remove_attachment($attachment_id, $msg); - if ($imap->append_start($folder, strlen($msg))) { + if ($imap->append_start($folder, mb_strlen($msg))) { $imap->append_feed($msg."\r\n"); if ($imap->append_end()) { if ($imap->message_action('DELETE', array($uid))) { @@ -692,6 +690,20 @@ public function process() { $this->session->set('imap_prefetched_ids', array_unique($prefetched, SORT_NUMERIC)); } $with_subscription = isset($this->request->post['subscription_state']) && $this->request->post['subscription_state']; + $cache = Hm_IMAP_List::get_cache($this->cache, $form['imap_server_id']); + $imap = Hm_IMAP_List::connect($form['imap_server_id'], $cache); + if (imap_authed($imap)) { + $quota_root = $imap->get_quota_root($folder ? $folder : 'INBOX'); + $quota = $imap->get_quota($quota_root[0]['name']); + if ($quota) { + $current = floatval($quota[0]['current']); + $max = floatval($quota[0]['max']); + if ($max > 0) { + $this->out('quota', ceil(($current / $max) * 100)); + $this->out('quota_max', $max / 1024); + } + } + } if ($page_cache) { $this->out('imap_expanded_folder_data', $page_cache); $this->out('imap_expanded_folder_id', $form['imap_server_id']); @@ -699,8 +711,6 @@ public function process() { $this->out('with_input', $with_subscription); return; } - $cache = Hm_IMAP_List::get_cache($this->cache, $form['imap_server_id']); - $imap = Hm_IMAP_List::connect($form['imap_server_id'], $cache); if (imap_authed($imap)) { $only_subscribed = $this->user_config->get('only_subscribed_folders_setting', false); if ($with_subscription) { @@ -736,7 +746,7 @@ public function process() { $filter = 'ALL'; if ($this->get('list_filter')) { - $filter = strtoupper($this->get('list_filter')); + $filter = mb_strtoupper($this->get('list_filter')); } $keyword = $this->get('list_keyword', ''); list($sort, $rev) = process_sort_arg($this->get('list_sort'), $this->user_config->get('default_sort_order_setting', 'arrival')); @@ -898,7 +908,15 @@ public function process() { if ($this->user_config->get('original_folder_setting', false)) { $archive_folder .= '/'.$form_folder; if (!count($imap->get_mailbox_status($archive_folder))) { - $imap->create_mailbox($archive_folder); + if (! $imap->create_mailbox($archive_folder)) { + $debug = $imap->show_debug(true, true, true); + if (! empty($debug['debug'])) { + Hm_Msgs::add('ERR' . array_pop($debug['debug'])); + } else { + Hm_Msgs::add('ERRCould not create configured archive folder for the original folder of the message'); + } + $errors++; + } } } @@ -1109,7 +1127,7 @@ public function process() { } } else { - if (!$imap->message_action(strtoupper($form['action_type']), $uids)) { + if (!$imap->message_action(mb_strtoupper($form['action_type']), $uids)) { $errs++; } else { @@ -1502,7 +1520,7 @@ class Hm_Handler_load_imap_servers_from_config extends Hm_Handler_Module { */ public function process() { Hm_IMAP_List::init($this->user_config, $this->session); - $has_default = false; + $default_server_id = false; foreach (Hm_IMAP_List::getAll() as $id => $server) { if ($this->session->loaded) { if (array_key_exists('expiration', $server)) { @@ -1511,31 +1529,34 @@ public function process() { } } if (array_key_exists('default', $server) && $server['default']) { - $has_default = true; + $default_server_id = $id; } } - if (!$has_default) { - $auth_server = $this->session->get('imap_auth_server_settings', array()); - if (!empty($auth_server)) { - if (array_key_exists('name', $auth_server)) { - $name = $auth_server['name']; - } - else { - $name = $this->config->get('imap_auth_name', 'Default'); - } - $imap_details = array( - 'name' => $name, - 'default' => true, - 'server' => $auth_server['server'], - 'port' => $auth_server['port'], - 'tls' => $auth_server['tls'], - 'user' => $auth_server['username'], - 'pass' => $auth_server['password'] - ); - if (! empty($auth_server['sieve_config_host'])) { - $imap_details['sieve_config_host'] = $auth_server['sieve_config_host']; - } + $auth_server = $this->session->get('imap_auth_server_settings', array()); + if (!empty($auth_server)) { + if (array_key_exists('name', $auth_server)) { + $name = $auth_server['name']; + } + else { + $name = $this->config->get('imap_auth_name', 'Default'); + } + $imap_details = array( + 'name' => $name, + 'default' => true, + 'server' => $auth_server['server'], + 'port' => $auth_server['port'], + 'tls' => $auth_server['tls'], + 'user' => $auth_server['username'], + 'pass' => $auth_server['password'] + ); + if (! empty($auth_server['sieve_config_host'])) { + $imap_details['sieve_config_host'] = $auth_server['sieve_config_host']; + } + if (!$default_server_id) { Hm_IMAP_List::add($imap_details); + } else { + // Perhaps something as changed + Hm_IMAP_List::edit($default_server_id, $imap_details); } } } @@ -1557,7 +1578,7 @@ public function process() { $updated = 0; foreach ($active as $server_id) { $server = Hm_IMAP_List::dump($server_id, true); - if (array_key_exists('auth', $server) && $server['auth'] == 'xoauth2') { + if ( $server && array_key_exists('auth', $server) && $server['auth'] == 'xoauth2') { $results = imap_refresh_oauth2_token($server, $this->config); if (!empty($results)) { if (Hm_IMAP_List::update_oauth2_token($server_id, $results[1], $results[0])) { @@ -1858,11 +1879,11 @@ public function process() { } } } - if (isset($msg_struct_current['subtype']) && strtolower($msg_struct_current['subtype'] == 'html')) { + if (isset($msg_struct_current['subtype']) && mb_strtolower($msg_struct_current['subtype'] == 'html')) { $msg_text = add_attached_images($msg_text, $form['imap_msg_uid'], $msg_struct, $imap); } $save_reply_text = false; - if ($part == 0 || (isset($msg_struct_current['type']) && strtolower($msg_struct_current['type'] == 'text'))) { + if ($part == 0 || (isset($msg_struct_current['type']) && mb_strtolower($msg_struct_current['type'] == 'text'))) { $save_reply_text = true; } $msg_headers = $imap->get_message_headers($form['imap_msg_uid']); diff --git a/modules/imap/output_modules.php b/modules/imap/output_modules.php index 0c3d772f57..0acb0e4f93 100644 --- a/modules/imap/output_modules.php +++ b/modules/imap/output_modules.php @@ -96,7 +96,7 @@ protected function output() { if (array_key_exists('envelope', $struct) && is_array($struct['envelope']) && count($struct['envelope']) > 0) { $txt .= format_imap_envelope($struct['envelope'], $this); } - if (isset($struct['subtype']) && strtolower($struct['subtype']) == 'html') { + if (isset($struct['subtype']) && mb_strtolower($struct['subtype']) == 'html') { $allowed = $this->get('header_allow_images'); $msgText = $this->get('msg_text'); // Everything in the message starting with src="http:// or src="https:// or src='http:// or src='https:// @@ -110,8 +110,8 @@ protected function output() { $txt .= format_msg_html($msgText, $allowed); } - elseif (isset($struct['type']) && strtolower($struct['type']) == 'image') { - $txt .= format_msg_image($this->get('msg_text'), strtolower($struct['subtype'])); + elseif (isset($struct['type']) && mb_strtolower($struct['type']) == 'image') { + $txt .= format_msg_image($this->get('msg_text'), mb_strtolower($struct['subtype'])); } else { if ($this->get('imap_msg_part') === "0") { @@ -179,10 +179,10 @@ protected function output() { $txt .= ''; foreach ($small_headers as $fld) { foreach ($headers as $name => $value) { - if ($fld == strtolower($name)) { + if ($fld == mb_strtolower($name)) { if ($fld == 'subject') { $txt .= ''; @@ -285,7 +285,7 @@ protected function output() { } } else { - if (strtolower($name) == 'flags') { + if (mb_strtolower($name) == 'flags') { $name = $this->trans('Tags'); $value = str_replace('\\', '', $value); $new_value = array(); @@ -302,7 +302,7 @@ protected function output() { } } foreach ($headers as $name => $value) { - if (!in_array(strtolower($name), $small_headers)) { + if (!in_array(mb_strtolower($name), $small_headers)) { if (is_array($value)) { foreach ($value as $line) { $txt .= ''; @@ -340,7 +340,7 @@ protected function output() { $txt .= '
'. ''.$this->trans('All headers').''. ''; - if (!isset($headers['Flags']) || !stristr($headers['Flags'], 'draft')) { + if (!isset($headers['Flags']) || !mb_stristr($headers['Flags'], 'draft')) { $txt .= ' | '.$this->trans('Reply').''; if ($size > 1) { $txt .= ' | '.$this->trans('Reply-all').''; @@ -356,7 +356,7 @@ protected function output() { else { $txt .= ' | '.$this->trans('raw').''; } - if (isset($headers['Flags']) && stristr($headers['Flags'], 'flagged')) { + if (isset($headers['Flags']) && mb_stristr($headers['Flags'], 'flagged')) { $txt .= ' | '; $txt .= ''.$this->trans('Unflag').''; } @@ -373,7 +373,6 @@ protected function output() { if (isset($headers['X-Schedule'])) { $txt .= ' | ' . schedule_dropdown($this, true); } - $is_draft = isset($headers['Flags']) && stristr($headers['Flags'], 'draft'); if ($this->get('sieve_filters_enabled') && !$is_draft && isset($headers['X-Snoozed'])) { $txt .= ' | ' . snooze_dropdown($this, isset($headers['X-Snoozed'])); @@ -464,8 +463,8 @@ protected function output() { $disabled = ''; $pass_value = ''; } - $res .= '
'; - $res .= '
'; + $res .= '
'; + $res .= ''; $res .= ''; $res .= ''; $res .= '
'; @@ -946,7 +945,7 @@ protected function output() { $res = array(); if ($this->get('imap_mailbox_page')) { $details = $this->get('imap_folder_detail'); - $type = stripos($details['name'], 'Sent') !== false ? 'sent' : false; + $type = mb_stripos($details['name'], 'Sent') !== false ? 'sent' : false; prepare_imap_message_list($this->get('imap_mailbox_page'), $this, $type); if ($details['offset'] == 0) { $page_num = 1; @@ -1007,7 +1006,7 @@ protected function output() { $flagged = false; $details = $this->get('reply_details', array()); if (is_array($details) && array_key_exists('msg_headers', $details) && array_key_exists('Flags', $details['msg_headers'])) { - if (stristr($details['msg_headers']['Flags'], 'flagged')) { + if (mb_stristr($details['msg_headers']['Flags'], 'flagged')) { $flagged = true; } } @@ -1367,7 +1366,7 @@ protected function output() {
'; } $res .= '
'; - + return $res; } } diff --git a/modules/smtp/modules.php b/modules/smtp/modules.php index 20b591d36b..bc18a221c4 100644 --- a/modules/smtp/modules.php +++ b/modules/smtp/modules.php @@ -357,7 +357,7 @@ public function process() { if ($this->get('is_mobile', false)) { $compose_type = 0; } - if (is_array($this->get('compose_draft')) && strlen(trim(join('', $this->get('compose_draft')))) == 0 && array_key_exists('compose_to', $this->request->get)) { + if (is_array($this->get('compose_draft')) && mb_strlen(trim(join('', $this->get('compose_draft')))) == 0 && array_key_exists('compose_to', $this->request->get)) { $draft = array(); foreach (parse_mailto($this->request->get['compose_to']) as $name => $val) { if (!$val) { @@ -545,7 +545,7 @@ public function process() { $profiles = $this->user_config->get('profiles'); $profile_value = $this->request->post['profile_value']; - if (!strstr($profile_value, '.')) { + if (!mb_strstr($profile_value, '.')) { Hm_Msgs::add('ERRPlease create a profile for saving sent messages'); return; } @@ -567,7 +567,7 @@ function get_mime_type($filename) { $idx = explode('.', $filename); $count_explode = count($idx); - $idx = strtolower($idx[$count_explode - 1]); + $idx = mb_strtolower($idx[$count_explode - 1]); $mimet = array( 'txt' => 'text/plain', @@ -852,7 +852,7 @@ public function process() { continue; } if (is_dir($file->getPath()) && $file->getPath() != $attachment_dir){ - if (strpos($file->getPath(), 'chunks-') !== False) { + if (mb_strpos($file->getPath(), 'chunks-') !== False) { rrmdir($file->getPath()); } } @@ -952,7 +952,7 @@ protected function output() { if ($file->isDir()){ continue; } - if (strpos($file->getPathname(), '.part') !== False) { + if (mb_strpos($file->getPathname(), '.part') !== False) { $num_chunks++; $size_in_kbs += filesize($file->getPathname()); $files[] = $file->getPathname(); @@ -1150,7 +1150,7 @@ protected function output() { $imap_server = Hm_IMAP_List::get($imap_server_id, false); $reply_from = process_address_fld($reply['msg_headers']['From']); - if ($reply_type == 'reply_all' && $reply_from[0]['email'] != $imap_server['user'] && strpos($to, $reply_from[0]['email']) === false) { + if ($reply_type == 'reply_all' && $reply_from[0]['email'] != $imap_server['user'] && mb_strpos($to, $reply_from[0]['email']) === false) { $to .= ', '.$reply_from[0]['label'].' '.$reply_from[0]['email']; } } @@ -1624,8 +1624,8 @@ function smtp_server_dropdown($data, $output_mod, $recip, $selected_id=false) { $smtp_profiles = profiles_by_smtp_id($profiles, $vals['id']); if (count($smtp_profiles) > 0) { foreach ($smtp_profiles as $index => $profile) { - $res .= '
'; - if (isset($headers['Flags']) && stristr($headers['Flags'], 'flagged')) { + if (isset($headers['Flags']) && mb_stristr($headers['Flags'], 'flagged')) { $txt .= ' '; } $txt .= $this->html_safe($value).'