From 3a94810fcfcb858fb18933816735139f5d816f92 Mon Sep 17 00:00:00 2001 From: thomppj Date: Sun, 23 Dec 2001 21:01:40 +0000 Subject: [PATCH] Various fixes. ---------------------------------------------------------------------- git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1893 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- config/conf.pl | 110 ++++++++++++++---------------- data/index.php | 22 +++--- functions/prefs.php | 50 ++++++++++---- plugins/sent_subfolders/setup.php | 2 +- 4 files changed, 104 insertions(+), 80 deletions(-) diff --git a/config/conf.pl b/config/conf.pl index b5a63cbf..7ef30647 100755 --- a/config/conf.pl +++ b/config/conf.pl @@ -1945,77 +1945,69 @@ sub set_defaults { print "\n"; if ($server eq "cyrus") { - $default_folder_prefix = ""; - $trash_folder = "INBOX.Trash"; - $sent_folder = "INBOX.Sent"; - $draft_folder = "INBOX.Drafts"; - $show_prefix_option = false; - $default_sub_of_inbox = true; - $show_contain_subfolders_option = false; - $imap_server_type = "cyrus"; - - print " default_folder_prefix = none\n"; - print " trash_folder = INBOX.Trash\n"; - print " sent_folder = INBOX.Sent\n"; - print " draft_folder = INBOX.Drafts\n"; - print " show_prefix_option = false\n"; - print " default_sub_of_inbox = true\n"; - print "show_contain_subfolders_option = false\n"; - print " imap_server_type = cyrus\n"; + $default_folder_prefix = ""; + $trash_folder = "INBOX.Trash"; + $sent_folder = "INBOX.Sent"; + $draft_folder = "INBOX.Drafts"; + $show_prefix_option = false; + $default_sub_of_inbox = true; + $show_contain_subfolders_option = false; + $imap_server_type = "cyrus"; + $disp_default_folder_prefix = ""; $continue = 1; } elsif ($server eq "uw") { - $default_folder_prefix = "mail/"; - $trash_folder = "Trash"; - $sent_folder = "Sent"; - $draft_folder = "Drafts"; - $show_prefix_option = true; - $default_sub_of_inbox = false; - $show_contain_subfolders_option = true; - $imap_server_type = "uw"; - - print " default_folder_prefix = mail/\n"; - print " trash_folder = Trash\n"; - print " sent_folder = Sent\n"; - print " draft_folder = Drafts\n"; - print " show_prefix_option = true\n"; - print " default_sub_of_inbox = false\n"; - print "show_contain_subfolders_option = true\n"; - print " imap_server_type = uw\n"; - + $default_folder_prefix = "mail/"; + $trash_folder = "Trash"; + $sent_folder = "Sent"; + $draft_folder = "Drafts"; + $show_prefix_option = true; + $default_sub_of_inbox = false; + $show_contain_subfolders_option = true; + $imap_server_type = "uw"; + $disp_default_folder_prefix = $default_folder_prefix; + $continue = 1; } elsif ($server eq "exchange") { - $default_folder_prefix = ""; - $default_sub_of_inbox = true; - $trash_folder = "INBOX/Deleted Items"; - $sent_folder = "INBOX/Sent Items"; - $drafts_folder = "INBOX/Drafts"; - $show_prefix_option = false; - $show_contain_subfolders_option = false; - $imap_server_type = "exchange"; - - print " default_folder_prefix = \n"; - print " default_sub_of_inbox = true\n"; - print " trash_folder = \"INBOX/Deleted Items\"\n"; - print " sent_folder = \"INBOX/Sent Items\"\n"; - print " draft_folder = \"INBOX/Drafts\"\n"; - print " show_prefix_option = false\n"; - print " show_contain_subfolders_option = false\n"; - print " imap_server_type = exchange\n"; + $default_folder_prefix = ""; + $default_sub_of_inbox = true; + $trash_folder = "INBOX/Deleted Items"; + $sent_folder = "INBOX/Sent Items"; + $drafts_folder = "INBOX/Drafts"; + $show_prefix_option = false; + $show_contain_subfolders_option = false; + $imap_server_type = "exchange"; + $disp_default_folder_prefix = ""; - $continue = 1; + $continue = 1; } elsif ($server eq "courier") { - $imap_server_type = "courier"; + $default_folder_prefix = "mail/"; + $trash_folder = "Trash"; + $sent_folder = "Sent"; + $draft_folder = "Drafts"; + $show_prefix_option = true; + $default_sub_of_inbox = false; + $show_contain_subfolders_option = true; + $imap_server_type = "courier"; + $disp_default_folder_prefix = $default_folder_prefix; - print " imap_server_type = courier\n"; - $continue = 1; - } elsif ($server eq "quit") { - $continue = 1; + } elsif ($server eq "quit") { + $continue = 1; } else { + $disp_default_folder_prefix = $default_folder_prefix; print "Unrecognized server: $server\n"; - print "\n"; + print "\n"; } + + print " default_folder_prefix = $disp_default_folder_prefix\n"; + print " trash_folder = $trash_folder\n"; + print " sent_folder = $sent_folder\n"; + print " draft_folder = $draft_folder\n"; + print " show_prefix_option = $show_prefix_option\n"; + print " default_sub_of_inbox = $default_sub_of_inbox\n"; + print "show_contain_subfolders_option = $show_contain_subfolders_option\n"; + print " imap_server_type = $imap_server_type\n"; } print "\nPress any key to continue..."; $tmp = ; diff --git a/data/index.php b/data/index.php index 9d9ed2ca..b86832a0 100644 --- a/data/index.php +++ b/data/index.php @@ -1,14 +1,20 @@ diff --git a/functions/prefs.php b/functions/prefs.php index e71d4e05..d14d46a1 100644 --- a/functions/prefs.php +++ b/functions/prefs.php @@ -30,13 +30,13 @@ function cachePrefValues($data_dir, $username) { /* Calculate the filename for the user's preference file */ $filename = getHashedFile($username, $data_dir, "$username.pref"); - /* A call to checkForPrefs here should take eliminate the need for - /* this to be called throughout the rest of the SquirrelMail code. + /* A call to checkForPrefs here should take eliminate the need for */ + /* this to be called throughout the rest of the SquirrelMail code. */ checkForPrefs($data_dir, $username, $filename); /* Make sure that the preference file now DOES exist. */ if (!file_exists($filename)) { - printf (_("Preference file, %s, does not exist. Log out, and log back in to create a default preference file."), $filename); + echo sprintf (_("Preference file, %s, does not exist. Log out, and log back in to create a default preference file."), $filename) . "
\n"; exit; } @@ -146,13 +146,29 @@ function setPref($data_dir, $username, $string, $value) { function checkForPrefs($data_dir, $username, $filename = '') { /* First, make sure we have the filename. */ if ($filename == '') { - $filename = getHashedFile($username, $data_dir, "$username.pref"); + $filename = getHashedFile($username, $data_dir, '$username.pref'); } - + /* Then, check if the file exists. */ - if (!file_exists($filename) ) { - if (!copy($data_dir . 'default_pref', $filename)) { - echo _("Error opening ") . $filename; + if (!@file_exists($filename) ) { + /* First, check the $data_dir for the default preference file. */ + $default_pref = $data_dir . 'default_pref'; + + /* If it is not there, check the internal data directory. */ + if (!@file_exists($default_pref)) { + $default_pref = '../data/default_pref'; + } + + /* Otherwise, report an error. */ + if (!file_exists($default_pref)) { + echo _("Error opening ") . $default_pref . "
\n"; + echo _("Default preference file not found!") . "
\n"; + echo _("Please contact your system administrator and report this error.") . "
\n"; + exit; + } else if (!@copy($default_pref, $filename)) { + echo _("Error opening ") . $default_pref . '
'; + echo _("Could not create initial preference file!") . "
\n"; + echo _("Please contact your system administrator and report this error.") . "
\n"; exit; } } @@ -203,9 +219,9 @@ function getHashedFile($username, $dir, $datafile, $hash_search = true) { $result = "$real_hash_dir/$datafile"; /* Check for this file in the real hash directory. */ - if ($hash_search && !file_exists($result)) { + if ($hash_search && !@file_exists($result)) { /* First check the base directory, the most common location. */ - if (file_exists("$dir/$datafile")) { + if (@file_exists("$dir/$datafile")) { rename("$dir/$datafile", $result); /* Then check the full range of possible hash directories. */ @@ -228,6 +244,11 @@ function getHashedFile($username, $dir, $datafile, $hash_search = true) { function getHashedDir($username, $dir, $hash_dirs = '') { global $dir_hash_level; + /* Remove trailing slash from $dir if found */ + if (substr($dir, -1) == '/') { + $dir = substr($dir, 0, strlen($dir) - 1); + } + /* If necessary, populate the hash dir variable. */ if ($hash_dirs == '') { $hash_dirs = computeHashDirs($username); @@ -237,8 +258,13 @@ function getHashedDir($username, $dir, $hash_dirs = '') { $real_hash_dir = $dir; for ($h = 0; $h < $dir_hash_level; ++$h) { $real_hash_dir .= '/' . $hash_dirs[$h]; - if (!is_dir($real_hash_dir)) { - mkdir($real_hash_dir, 0770); + if (!@is_dir($real_hash_dir)) { + if (!@mkdir($real_hash_dir, 0770)) { + echo sprintf(_("Error creating directory %s."), $real_hash_dir) . '
'; + echo _("Could not create hashed directory structure!") . "
\n"; + echo _("Please contact your system administrator and report this error.") . "
\n"; + exit; + } } } diff --git a/plugins/sent_subfolders/setup.php b/plugins/sent_subfolders/setup.php index 4e98bd0a..9f20b11e 100644 --- a/plugins/sent_subfolders/setup.php +++ b/plugins/sent_subfolders/setup.php @@ -148,7 +148,7 @@ function sent_subfolders_update_sentfolder() { global $sent_subfolders_base, $sent_subfolders_setting; global $username, $data_dir, $key, $imapServerAddress, $imapPort; global $use_sent_subfolders, $move_to_sent; - + if ($use_sent_subfolders && $move_to_sent) { $year = date('Y'); $month = date('m'); -- 2.25.1