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 = "<none>";
$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 = <none>\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 = "<none>";
- $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 = <STDIN>;
/* 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) . "<br>\n";
exit;
}
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 . "<br>\n";
+ echo _("Default preference file not found!") . "<br>\n";
+ echo _("Please contact your system administrator and report this error.") . "<br>\n";
+ exit;
+ } else if (!@copy($default_pref, $filename)) {
+ echo _("Error opening ") . $default_pref . '<br>';
+ echo _("Could not create initial preference file!") . "<br>\n";
+ echo _("Please contact your system administrator and report this error.") . "<br>\n";
exit;
}
}
$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. */
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);
$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) . '<br>';
+ echo _("Could not create hashed directory structure!") . "<br>\n";
+ echo _("Please contact your system administrator and report this error.") . "<br>\n";
+ exit;
+ }
}
}