From d47b2518bd5b1544e3b7577b59f323b29737eb12 Mon Sep 17 00:00:00 2001 From: fidian Date: Tue, 10 Oct 2000 13:11:12 +0000 Subject: [PATCH] Adds a config option to invert the time for Solaris machines in the US. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@783 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- config/conf.pl | 30 ++++++++++++++++++++++++++++-- config/config_default.php | 9 ++++++++- functions/date.php | 7 ++++++- functions/smtp.php | 2 ++ 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/config/conf.pl b/config/conf.pl index 0b5aac51..cd4fc0a3 100755 --- a/config/conf.pl +++ b/config/conf.pl @@ -279,6 +279,7 @@ while (($command ne "q") && ($command ne "Q")) { print "7. SMTP Port : $WHT$smtpPort$NRM\n"; } print "8. Server : $WHT$imap_server_type$NRM\n"; + print "9. Invert Time : $WHT$invert_time$NRM\n"; print "\n"; print "R Return to Main Menu\n"; } elsif ($menu == 3) { @@ -431,6 +432,7 @@ while (($command ne "q") && ($command ne "Q")) { elsif ($command == 6) { $smtpServerAddress = command16 (); } elsif ($command == 7) { $smtpPort = command17 (); } elsif ($command == 8) { $imap_server_type = command18 (); } + elsif ($command == 9) { $invert_time = command19 (); } } elsif ($menu == 3) { if ($command == 1) { $default_folder_prefix = command21 (); } elsif ($command == 2) { $show_prefix_option = command22 (); } @@ -626,7 +628,7 @@ sub command17 { } # imap_server_type sub command18 { - print "Eash IMAP server has its own quirks. As much as we tried to stick\n"; + print "Each IMAP server has its own quirks. As much as we tried to stick\n"; print "to standards, it doesn't help much if the IMAP server doesn't follow\n"; print "the same principles. We have made some work-arounds for some of\n"; print "these servers. If you would like to use them, please select your\n"; @@ -646,6 +648,29 @@ sub command18 { return $new_imap_server_type; } +# invert_time +sub command19 { + print "Sometimes the date of messages sent is messed up (off by a few hours\n"; + print "on some machines). Typically this happens if the system doesn't support\n"; + print "tm_gmtoff. It will happen only if your time zone is \"negative\".\n"; + print "This most often occurs on Solaris 7 machines in the United States.\n"; + print "By default, this is off. It should be kept off unless problems surface\n"; + print "about the time that messages are sent.\n"; + print " no = Do NOT fix time -- almost always correct\n"; + print " yes = Fix the time for this system\n"; + + $YesNo = 'n'; + $YesNo = 'y' if ($invert_time eq "true"); + + print "Fix the time for this system (y/n) [$WHT$YesNo$NRM]: $WHT"; + + $new_invert_time = ; + $new_invert_time =~ tr/yn//cd; + return "true" if ($new_invert_time eq "y"); + return "false" if ($new_invert_time eq "n"); + return $invert_time; +} + # MOTD sub command71 { print "\nYou can now create the welcome message that is displayed\n"; @@ -1451,8 +1476,9 @@ sub save_data { print FILE "\t\$useSendmail = $useSendmail;\n"; print FILE "\t\$smtpServerAddress = \"$smtpServerAddress\";\n"; print FILE "\t\$smtpPort = $smtpPort;\n"; - print FILE "\t\$sendmail_path = \"$sendmail_path\";\n"; + print FILE "\t\$sendmail_path = \"$sendmail_path\";\n"; print FILE "\t\$imap_server_type = \"$imap_server_type\";\n"; + print FILE "\t\$invert_time = $invert_time;\n"; print FILE "\n"; diff --git a/config/config_default.php b/config/config_default.php index 0d29759d..b8bbcb92 100644 --- a/config/config_default.php +++ b/config/config_default.php @@ -163,7 +163,7 @@ $attachment_dir = $data_dir; -// This is the default size of the left folder list. Default is 200, +// This is the default size of the folder list. Default is 200, // but you can set it to whatever you wish. $default_left_size = 200; @@ -261,4 +261,11 @@ $default_unseen_notify = 2; $default_unseen_type = 1; + + // If you are running on a machine that doesn't have the tm_gmtoff + // value in your time structure and if you are in a time zone that + // has a negative offset, you need to set this value to 1. + // This is typically people in the US that are running Solaris 7. + + $invert_time = false; ?> diff --git a/functions/date.php b/functions/date.php index 6dfc4ba1..9f9f48d1 100644 --- a/functions/date.php +++ b/functions/date.php @@ -58,6 +58,8 @@ /** now find what the server is at **/ $current = date("Z", time()); + if ($invert_time) + $current = - $current; $stamp = (int)$stamp - (int)$gmt + (int)$current; return $stamp; @@ -69,7 +71,10 @@ function getDateString($stamp) { $now = time(); - $midnight = $now - ($now % 86400) - 86400 - date("Z", $now); + $dateZ = date("Z", $now); + if ($invert_time) + $dateZ = - $dateZ; + $midnight = $now - ($now % 86400) - 86400 - $dateZ; if ($midnight < $stamp) { // Today diff --git a/functions/smtp.php b/functions/smtp.php index c6e1825c..6edb4488 100644 --- a/functions/smtp.php +++ b/functions/smtp.php @@ -93,6 +93,8 @@ /* Time offset for correct timezone */ function timezone () { $diff_second = date("Z"); + if ($invert_time) + $diff_second = - $diff_second; if ($diff_second > 0) $sign = "+"; else -- 2.25.1