Revision: 702
http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=702&view=rev
Author: Sebastian2009
Date: 2009-08-10 13:40:32 +0000 (Mon, 10 Aug 2009)
Log Message:
-----------
- get in sync with mainline, rev. 701
- added the ability to choose a range of date for vacation notification. Adjusted a SQL query in perl script and added nifty calendar. There are two additional fields in table vacation needed. Fix of upgrade.php still pending, as this will change db layout and I haven't got any PostgreSQL databases for testing.
Modified Paths:
--------------
branches/postfixadmin-smarty/VIRTUAL_VACATION/vacation.pl
branches/postfixadmin-smarty/backup.php
branches/postfixadmin-smarty/config.inc.php
branches/postfixadmin-smarty/debian/changelog
branches/postfixadmin-smarty/debian/control
branches/postfixadmin-smarty/debian/rules
branches/postfixadmin-smarty/edit-vacation.php
branches/postfixadmin-smarty/functions.inc.php
branches/postfixadmin-smarty/languages/de.lang
branches/postfixadmin-smarty/languages/en.lang
branches/postfixadmin-smarty/list-virtual.php
branches/postfixadmin-smarty/templates/edit-vacation.tpl
branches/postfixadmin-smarty/upgrade.php
branches/postfixadmin-smarty/users/password.php
branches/postfixadmin-smarty/variables.inc.php
Added Paths:
-----------
branches/postfixadmin-smarty/calendar.js
branches/postfixadmin-smarty/css/calendar.css
branches/postfixadmin-smarty/images/calendar/
branches/postfixadmin-smarty/images/calendar/cal.gif
branches/postfixadmin-smarty/images/calendar/next_mon.gif
branches/postfixadmin-smarty/images/calendar/next_year.gif
branches/postfixadmin-smarty/images/calendar/no_cal.gif
branches/postfixadmin-smarty/images/calendar/pixel.gif
branches/postfixadmin-smarty/images/calendar/prev_mon.gif
branches/postfixadmin-smarty/images/calendar/prev_year.gif
branches/postfixadmin-smarty/images/calendar/shade_bl.png
branches/postfixadmin-smarty/images/calendar/shade_bm.png
branches/postfixadmin-smarty/images/calendar/shade_br.png
branches/postfixadmin-smarty/images/calendar/shade_mr.png
branches/postfixadmin-smarty/images/calendar/shade_tr.png
Modified: branches/postfixadmin-smarty/VIRTUAL_VACATION/vacation.pl
===================================================================
--- branches/postfixadmin-smarty/VIRTUAL_VACATION/vacation.pl 2009-08-04 20:45:21 UTC (rev 701)
+++ branches/postfixadmin-smarty/VIRTUAL_VACATION/vacation.pl 2009-08-10 13:40:32 UTC (rev 702)
@@ -56,15 +56,24 @@
# Use Log4Perl
# Added better testing (and -t option)
#
+# 2009-06-29 Stevan Bajic <stevan@...>
+# Add Mail::Sender for SMTP auth + more flexibility
+#
+# 2009-07-07 Stevan Bajic <stevan@...>
+# Add better alias lookups
+# Check for more heades from Anti-Virus/Anti-Spam solutions
+# 2009-08-10 Sebastian <reg9009 at yahoo dot de>
+# Adjust SQL query for vacation timeframe. It is now possible to set from/until date for vacation message.
+#
# Requirements - the following perl modules are required:
# DBD::Pg or DBD::mysql
-# Mail::Sendmail, Email::Valid MIME::Charset, Log::Log4perl, Log::Dispatch, MIME::EncWords and GetOpt::Std
+# Mail::Sender, Email::Valid MIME::Charset, Log::Log4perl, Log::Dispatch, MIME::EncWords and GetOpt::Std
#
# You may install these via CPAN, or through your package tool.
# CPAN: 'perl -MCPAN -e shell', then 'install Module::Whatever'
#
# On Debian based systems :
-# libmail-sendmail-perl
+# libmail-sender-perl
# libdbd-pg-perl
# libemail-valid-perl
# libmime-perl
@@ -87,6 +96,16 @@
# http://dag.wieers.com/home-made/apt/packages.php
#
+use DBI;
+use MIME::Base64;
+use MIME::EncWords qw(:all);
+use Email::Valid;
+use strict;
+use Mail::Sender;
+use Getopt::Std;
+use Log::Log4perl qw(get_logger :levels);
+use File::Basename;
+
# ========== begin configuration ==========
# IMPORTANT: If you put passwords into this script, then remember
@@ -95,32 +114,43 @@
# db_type - uncomment one of these
our $db_type = 'Pg';
-#my $db_type = 'mysql';
+#our $db_type = 'mysql';
# leave empty for connection via UNIX socket
our $db_host = '';
# connection details
-our $db_username = 'dg';
-our $db_password = 'gingerdog';
+our $db_username = 'user';
+our $db_password = 'password';
our $db_name = 'postfix';
our $vacation_domain = 'autoreply.example.org';
# smtp server used to send vacation e-mails
our $smtp_server = 'localhost';
+our $smtp_server_port = 25;
+# SMTP authentication protocol used for sending.
+# Can be 'PLAIN', 'LOGIN', 'CRAM-MD5' or 'NTLM'
+# Leave it blank if you don't use authentification
+our $smtp_auth = undef;
+# username used to login to the server
+our $smtp_authid = 'someuser';
+# password used to login to the server
+our $smtp_authpwd = 'somepass';
+
# Set to 1 to enable logging to syslog.
our $syslog = 0;
# path to logfile, when empty logging is supressed
# change to e.g. /dev/null if you want nothing logged.
-# if we can't write to this, we try /tmp/vacation.log instead
-our $logfile='/var/spool/vacation/vacation.log';
+# if we can't write to this, and $log_to_file is 1 (below) the script will abort.
+our $logfile='/var/log/vacation.log';
# 2 = debug + info, 1 = info only, 0 = error only
our $log_level = 2;
+# Whether to log to file or not, 0 = do not write to a log file
+our $log_to_file = 0;
-
# notification interval, in seconds
# set to 0 to notify only once
# e.g. 1 day ...
@@ -129,27 +159,24 @@
our $interval = 0;
# instead of changing this script, you can put your settings to /etc/mail/postfixadmin/vacation.conf
-# just use perl syntax there to fill the variables listed above (without the "our" keyword). Example:
+# or /etc/postfixadmin/vacation.conf just use Perl syntax there to fill the variables listed above
+# (without the "our" keyword). Example:
# $db_username = 'mail';
if (-f "/etc/mail/postfixadmin/vacation.conf") {
- require "/etc/mail/postfixadmin/vacation.conf";
+ require "/etc/mail/postfixadmin/vacation.conf";
+} elsif (-f "/etc/postfixadmin/vacation.conf") {
+ require "/etc/postfixadmin/vacation.conf";
}
# =========== end configuration ===========
-if ( ! -w $logfile ) {
- $logfile = "/tmp/vacation.log";
+if($log_to_file == 1) {
+ if (( ! -w $logfile ) && (! -w dirname($logfile))) {
+ # Cannot log; no where to write to.
+ die("Cannot create logfile : $logfile");
+ }
}
-use DBI;
-use MIME::Base64;
-use MIME::EncWords qw(:all);
-use Email::Valid;
-use strict;
-use Mail::Sendmail;
-use Getopt::Std;
-use Log::Log4perl qw(get_logger :levels);
-
my ($from, $to, $cc, $replyto , $subject, $messageid, $lastheader, $smtp_sender, $smtp_recipient, %opts, $spam, $test_mode, $logger);
$subject='';
@@ -157,13 +184,12 @@
# Setup a logger...
#
-getopts('f:t:', \%opts) or die "Usage: $0 [-t yes] -f sender -- recipient\n -t for testing only\n";
+getopts('f:t:', \%opts) or die "Usage: $0 [-t yes] -f sender -- recipient\n\t-t for testing only\n";
$opts{f} and $smtp_sender = $opts{f} or die "-f sender not present on command line";
$test_mode = 0;
$opts{t} and $test_mode = 1;
$smtp_recipient = shift or die "recipient not given on command line";
-
my $log_layout = Log::Log4perl::Layout::PatternLayout->new("%d %p> %F:%L %M - %m%n");
if($test_mode == 1) {
@@ -173,18 +199,19 @@
$appender->layout($log_layout);
$logger->add_appender($appender);
$logger->debug("Test mode enabled");
-}
-else {
- # log to file.
- my $appender = Log::Log4perl::Appender->new(
- 'Log::Dispatch::File',
- filename => $logfile,
- mode => 'append');
-
+} else {
$logger = get_logger();
- $appender->layout($log_layout);
- $logger->add_appender($appender);
+ if($log_to_file == 1) {
+ # log to file
+ my $appender = Log::Log4perl::Appender->new(
+ 'Log::Dispatch::File',
+ filename => $logfile,
+ mode => 'append');
+ $appender->layout($log_layout);
+ $logger->add_appender($appender);
+ }
+
if($syslog == 1) {
my $syslog_appender = Log::Log4perl::Appender->new(
'Log::Dispatch::Syslog',
@@ -203,7 +230,6 @@
$logger->level($DEBUG);
}
-
binmode (STDIN,':utf8');
my $dbh;
@@ -281,9 +307,6 @@
return 0;
}
-
-
-
# try and determine if email address has vacation turned on; we
# have to do alias searching, and domain aliasing resolution for this.
# If found, return ($num_matches, $real_email);
@@ -295,7 +318,7 @@
exit(1);
}
my $realemail = '';
- my $query = qq{SELECT email FROM vacation WHERE email=? and active=$db_true};
+ my $query = qq{SELECT email FROM vacation WHERE email=? and active=$db_true and activefrom <= NOW() and activeuntil >= NOW()};
my $stm = $dbh->prepare($query) or panic_prepare($query);
$stm->execute($email) or panic_execute($query,"email='$email'");
my $rv = $stm->rows;
@@ -303,54 +326,83 @@
# Recipient has vacation
if ($rv == 1) {
$realemail = $email;
- $logger->debug("Found $email has vacation active");
+ $logger->debug("Found '\$email'\ has vacation active");
} else {
- # XXX why aren't we doing a join here?
- $logger->debug("Looking for alias records that $email resolves to with vacation turned on");
- $query = qq{SELECT goto FROM alias WHERE address=?};
+ $logger->debug("Looking for alias records that \'$email\' resolves to with vacation turned on");
+ $query = qq{SELECT goto FROM alias WHERE address=? AND (goto LIKE ?,% OR goto LIKE %,? OR goto LIKE %,?,%)};
$stm = $dbh->prepare($query) or panic_prepare($query);
- $stm->execute($email) or panic_execute($query,"address='$email'");
+ $stm->execute($email,$email,$email,$email) or panic_execute($query,"address='$email'");
$rv = $stm->rows;
# Recipient is an alias, check if mailbox has vacation
if ($rv == 1) {
my @row = $stm->fetchrow_array;
my $alias = $row[0];
- $query = qq{SELECT email FROM vacation WHERE email=? and active=$db_true};
- $stm = $dbh->prepare($query) or panic_prepare($query);
- $stm->execute($alias) or panic_prepare($query,"email='$alias'");
- $rv = $stm->rows;
-
+ if ($alias =~ /,/) {
+ for (split(/\s*,\s*/, lc($alias))) {
+ my $singlealias = $_;
+ $logger->debug("Found alias \'$singlealias\' for email \'$email\'. Looking if vacation is on for alias.");
+ $query = qq{SELECT email FROM vacation WHERE email=? AND active=$db_true};
+ $stm = $dbh->prepare($query) or panic_prepare($query);
+ $stm->execute($singlealias) or panic_execute($query,"email='$singlealias'");
+ $rv = $stm->rows;
# Alias has vacation
- if ($rv == 1) {
- $realemail = $alias;
+ if ($rv == 1) {
+ $realemail = $singlealias;
+ last;
+ }
+ }
+ } else {
+ $query = qq{SELECT email FROM vacation WHERE email=? AND active=$db_true};
+ $stm = $dbh->prepare($query) or panic_prepare($query);
+ $stm->execute($alias) or panic_prepare($query,"email='$alias'");
+ $rv = $stm->rows;
+# Alias has vacation
+ if ($rv == 1) {
+ $realemail = $alias;
+ }
}
-# We still have to look for domain level aliases...
- } else {
+# We have to look for alias domain (domain1 -> domain2)
+ } else {
my ($user, $domain) = split(/@/, $email);
- $query = qq{SELECT goto FROM alias WHERE address=?};
+ $logger->debug("Looking for alias domain for $domain / $email / $user");
+ $query = qq{SELECT target_domain FROM alias_domain WHERE alias_domain=?};
$stm = $dbh->prepare($query) or panic_prepare($query);
- $stm->execute("\@$domain") or panic_execute($query,"address='\@$domain'");
+ $stm->execute($domain) or panic_execute($query,"alias_domain='$domain'");
$rv = $stm->rows;
- $logger->debug("Looking for domain level aliases for $domain / $email / $user");
-# The receipient has a domain level alias
- if ($rv == 1) {
+
+# The domain has a alias domain level alias
+ if ($rv == 1) {
my @row = $stm->fetchrow_array;
- my $wildcard_dest = $row[0];
- my ($wilduser, $wilddomain) = split(/@/, $wildcard_dest);
+ my $alias_domain_dest = $row[0];
+ ($rv, $realemail) = find_real_address ("$user\@$alias_domain_dest");
+# We still have to look for domain level aliases...
+ } else {
+ my ($user, $domain) = split(/@/, $email);
+ $logger->debug("Looking for domain level aliases for $domain / $email / $user");
+ $query = qq{SELECT goto FROM alias WHERE address=?};
+ $stm = $dbh->prepare($query) or panic_prepare($query);
+ $stm->execute("\@$domain") or panic_execute($query,"address='\@$domain'");
+ $rv = $stm->rows;
+
+# The receipient has a domain level alias
+ if ($rv == 1) {
+ my @row = $stm->fetchrow_array;
+ my $wildcard_dest = $row[0];
+ my ($wilduser, $wilddomain) = split(/@/, $wildcard_dest);
+
# Check domain alias
- if ($wilduser) {
- ($rv, $realemail) = find_real_address ($wildcard_dest);
+ if ($wilduser) {
+ ($rv, $realemail) = find_real_address ($wildcard_dest);
+ } else {
+ ($rv, $realemail) = find_real_address ("$user\@$wilddomain");
+ }
} else {
- my $new_email = $user . '@' . $wilddomain;
- ($rv, $realemail) = find_real_address ($new_email);
+ $logger->debug("No domain level alias present for $domain / $email / $user");
}
}
- else {
- $logger->debug("No domain level alias present for $domain / $email / $user");
- }
}
}
return ($rv, $realemail);
@@ -378,33 +430,46 @@
my $body = $row[1];
my $from = $email;
my $to = $orig_from;
- my $vacation_subject = encode_mimewords($subject, 'Encoding'=> 'q', 'Charset'=>'utf-8', 'Field'=>'Subject');
+ my %smtp_connection;
+ %smtp_connection = (
+ 'smtp' => $smtp_server,
+ 'port' => $smtp_server_port,
+ 'auth' => $smtp_auth,
+ 'authid' => $smtp_authid,
+ 'authpwd' => $smtp_authpwd,
+ 'skip_bad_recipients' => 'true',
+ 'encoding' => 'Base64',
+ 'ctype' => 'text/plain; charset=UTF-8',
+ 'headers' => 'Precedence: junk',
+ 'headers' => 'X-Loop: Postfix Admin Virtual Vacation',
+ );
my %mail;
+ # I believe Mail::Sender qp encodes the subject, so we no longer need to.
%mail = (
- 'smtp' => $smtp_server,
- 'Subject' => $vacation_subject,
- 'From' => $from,
- 'To' => $to,
- 'MIME-Version' => '1.0',
- 'Content-Type' => 'text/plain; charset=UTF-8',
- 'Content-Transfer-Encoding' => 'base64',
- 'Precedence' => 'junk',
- 'X-Loop' => 'Postfix Admin Virtual Vacation',
- 'Message' => encode_base64($body)
+ 'subject' => $subject,
+ 'from' => $from,
+ 'to' => $to,
+ 'msg' => encode_base64($body)
);
if($test_mode == 1) {
$logger->info("** TEST MODE ** : Vacation response sent to $to from $from subject $subject (not) sent\n");
$logger->info(%mail);
return 0;
}
- sendmail(%mail) or $logger->error("Failed to send vacation response: " . $Mail::Sendmail::error);
- $logger->debug("Vacation response sent, Mail::Sendmail said : " . $Mail::Sendmail::log);
+ $Mail::Sender::NO_X_MAILER = 1;
+ my $sender = new Mail::Sender({%smtp_connection});
+ $sender->Open({%mail});
+ $sender->SendLineEnc($body);
+ $sender->Close() or $logger->error("Failed to send vacation response: " . $sender->{'error_msg'});
+ $logger->debug("Vacation response sent to $to, from $from");
}
}
-# Remove textual stuff from a (list of) email address(es)
-# e.g. convert: "aardvark" <a@...>, "Danger Mouse" <c@...>, e@... to
-# a@..., c@..., e@...
+# Convert a (list of) email address(es) from RFC 822 style addressing to
+# RFC 821 style addressing. e.g. convert:
+# "John Jones" <JJones@...>, "Jane Doe/Sales/ACME" <JDoe@...>
+# to:
+# jjones@..., jdoe@...
sub strip_address {
my ($arg) = @_;
if(!$arg) {
@@ -413,14 +478,13 @@
my @ok;
$logger = get_logger();
my @list;
- @list = $arg =~ m/([\w\.\-\']+\@[\w\.\-]+\w+)/g;
+ @list = $arg =~ m/([\w\.\-\+\'\=_\^\|\$\/\{\}~\?\*\\&\!`\%]+\@[\w\.\-]+\w+)/g;
foreach(@list) {
#$logger->debug("Checking: $_");
my $temp = Email::Valid->address( -address => $_, -mxcheck => 0);
if($temp) {
push(@ok, $temp);
- }
- else {
+ } else {
$logger->debug("Email not valid : $Email::Valid::Details");
}
}
@@ -432,7 +496,7 @@
push(@uniq, $item) unless $seen{$item}++
}
- my $result = join(", ", @uniq);
+ my $result = lc(join(", ", @uniq));
#$logger->debug("Result: $result");
return $result;
}
@@ -457,8 +521,8 @@
my ($address) = @_;
my $logger = get_logger();
- if($address =~ /^(noreply|postmaster|mailer-daemon|listserv|majordomo|owner-|request-|bounces-)/i ||
- $address =~ /-(owner|request|bounces)\@/i ) {
+ if($address =~ /^(noreply|postmaster|mailer\-daemon|listserv|majordomo|owner\-|request\-|bounces\-)/i ||
+ $address =~ /\-(owner|request|bounces)\@/i ) {
$logger->debug("sender $address contains $1 - will not send vacation message");
exit(0);
}
@@ -483,20 +547,24 @@
elsif (/^from:\s*(.*)\n$/i) { $from = $1; $lastheader = \$from; }
elsif (/^to:\s*(.*)\n$/i) { $to = $1; $lastheader = \$to; }
elsif (/^cc:\s*(.*)\n$/i) { $cc = $1; $lastheader = \$cc; }
- elsif (/^Reply-to:\s*(.*)\s*\n$/i) { $replyto = $1; $lastheader = \$replyto; }
+ elsif (/^Reply\-to:\s*(.*)\s*\n$/i) { $replyto = $1; $lastheader = \$replyto; }
elsif (/^subject:\s*(.*)\n$/i) { $subject = $1; $lastheader = \$subject; }
- elsif (/^message-id:\s*(.*)\s*\n$/i) { $messageid = $1; $lastheader = \$messageid; }
- elsif (/^x-spam-(flag|status):\s+yes/i) { $logger->debug("x-spam-$1: yes found; exiting"); exit (0); }
- elsif (/^x-facebook-notify:/i) { $logger->debug('Mail from facebook, ignoring'); exit(0); }
+ elsif (/^message\-id:\s*(.*)\s*\n$/i) { $messageid = $1; $lastheader = \$messageid; }
+ elsif (/^x\-spam\-(flag|status):\s+yes/i) { $logger->debug("x-spam-$1: yes found; exiting"); exit (0); }
+ elsif (/^x\-facebook\-notify:/i) { $logger->debug('Mail from facebook, ignoring'); exit(0); }
elsif (/^precedence:\s+(bulk|list|junk)/i) { $logger->debug("precedence: $1 found; exiting"); exit (0); }
- elsif (/^x-loop:\s+postfix\ admin\ virtual\ vacation/i) { $logger->debug("x-loop: postfix admin virtual vacation found; exiting"); exit (0); }
- elsif (/^Auto-Submitted:\s*no/i) { next; }
- elsif (/^Auto-Submitted:/i) { $logger->debug("Auto-Submitted: something found; exiting"); exit (0); }
- elsif (/^List-(Id|Post):/i) { $logger->debug("List-$1: found; exiting"); exit (0); }
+ elsif (/^x\-loop:\s+postfix\ admin\ virtual\ vacation/i) { $logger->debug("x-loop: postfix admin virtual vacation found; exiting"); exit (0); }
+ elsif (/^Auto\-Submitted:\s*no/i) { next; }
+ elsif (/^Auto\-Submitted:/i) { $logger->debug("Auto-Submitted: something found; exiting"); exit (0); }
+ elsif (/^List\-(Id|Post):/i) { $logger->debug("List-$1: found; exiting"); exit (0); }
+ elsif (/^(x\-(barracuda\-)?spam\-status):\s+(yes)/i) { $logger->debug("$1: $3 found; exiting"); exit (0); }
+ elsif (/^(x\-dspam\-result):\s+(spam|bl[ao]cklisted)/i) { $logger->debug("$1: $2 found; exiting"); exit (0); }
+ elsif (/^(x\-(anti|avas\-)?virus\-status):\s+(infected)/i) { $logger->debug("$1: $3 found; exiting"); exit (0); }
+ elsif (/^(x\-(avas\-spam|spamtest|crm114|razor|pyzor)\-status):\s+(spam)/i) { $logger->debug("$1: $3 found; exiting"); exit (0); }
+ elsif (/^(x\-osbf\-lua\-score):\s+[0-9\/\.\-\+]+\s+\[([-S])\]/i) { $logger->debug("$1: $2 found; exiting"); exit (0); }
else {$lastheader = "" ; }
}
-
if($smtp_recipient =~ /\@$vacation_domain/) {
# the regexp used here could probably be improved somewhat, for now hope that people won't use # as a valid mailbox character.
my $tmp = $smtp_recipient;
@@ -507,7 +575,6 @@
undef $tmp;
}
-
# If either From: or To: are not set, exit
if(!$from || !$to || !$messageid || !$smtp_sender || !$smtp_recipient) {
$logger->info("One of from=$from, to=$to, messageid=$messageid, smtp sender=$smtp_sender, smtp recipient=$smtp_recipient empty");
@@ -515,7 +582,7 @@
}
$logger->debug("Email headers have to: '$to' and From: '$from'");
$to = strip_address($to);
-$from = lc ($from);
+$cc = strip_address($cc);
$from = check_and_clean_from_address($from);
if($replyto ne "") {
# if reply-to is invalid, or looks like a mailing list, then we probably don't want to send a reply.
@@ -524,37 +591,29 @@
$smtp_sender = check_and_clean_from_address($smtp_sender);
$smtp_recipient = check_and_clean_from_address($smtp_recipient);
-
if ($smtp_sender eq $smtp_recipient) {
$logger->debug("smtp sender $smtp_sender and recipient $smtp_recipient are the same; aborting");
exit(0);
}
-my $recipfound = 0;
for (split(/,\s*/, lc($to)), split(/,\s*/, lc($cc))) {
- my $destinatario = strip_address($_);
- if ($smtp_sender eq $destinatario) {
- $logger->debug("sender header $smtp_sender contains recipient $destinatario (mailing myself?)");
+ my $header_recipient = strip_address($_);
+ if ($smtp_sender eq $header_recipient) {
+ $logger->debug("sender header $smtp_sender contains recipient $header_recipient (mailing myself?)");
exit(0);
}
- if ($smtp_recipient eq $destinatario) { $recipfound++; }
}
-if (!$recipfound) {
- $logger->debug("smtp envelope recipient $smtp_recipient not found in the header recipients ($to & $cc) (therefore they were bcc'ed, so won't send vacation message)");
- exit (0);
-}
-
-
my ($rv, $email) = find_real_address($smtp_recipient);
if ($rv == 1) {
$logger->debug("Attempting to send vacation response for: $messageid to: $smtp_sender, $smtp_recipient, $email (test_mode = $test_mode)");
send_vacation_email($email, $smtp_sender, $smtp_recipient, $messageid, $test_mode);
-}
-else {
+} else {
$logger->debug("SMTP recipient $smtp_recipient which resolves to $email does not have an active vacation (rv: $rv, email: $email)");
}
0;
#/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
+
+
Modified: branches/postfixadmin-smarty/backup.php
===================================================================
--- branches/postfixadmin-smarty/backup.php 2009-08-04 20:45:21 UTC (rev 701)
+++ branches/postfixadmin-smarty/backup.php 2009-08-10 13:40:32 UTC (rev 702)
@@ -58,9 +58,9 @@
if ($_SERVER['REQUEST_METHOD'] == "GET")
{
umask (077);
- $path = (ini_get('upload_tmp_dir') != '') ? ini_get('upload_tmp_dir') : '/tmp/';
+ $path = (ini_get('upload_tmp_dir') != '') ? ini_get('upload_tmp_dir') : '/tmp';
$filename = "postfixadmin-" . date ("Ymd") . "-" . getmypid() . ".sql";
- $backup = $path . $filename;
+ $backup = $path . DIRECTORY_SEPARATOR . $filename;
$header = "#\n# Postfix Admin $version\n# Date: " . date ("D M j G:i:s T Y") . "\n#\n";
Added: branches/postfixadmin-smarty/calendar.js
===================================================================
--- branches/postfixadmin-smarty/calendar.js (rev 0)
+++ branches/postfixadmin-smarty/calendar.js 2009-08-10 13:40:32 UTC (rev 702)
@@ -0,0 +1,336 @@
+// Tigra Calendar v4.0.2 (12-01-2009) European (dd.mm.yyyy)
+// http://www.softcomplex.com/products/tigra_calendar/
+// Public Domain Software... You're welcome.
+
+// default settins
+var A_TCALDEF = {
+ 'months' : ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
+ 'weekdays' : ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
+ 'yearscroll': true, // show year scroller
+ 'weekstart': 1, // first day of week: 0-Su or 1-Mo
+ 'centyear' : 70, // 2 digit years less than 'centyear' are in 20xx, othewise in 19xx.
+ 'imgpath' : 'images/calendar/' // directory with calendar images
+}
+// date parsing function
+function f_tcalParseDate (s_date) {
+
+ var re_date = /^\s*(\d{1,2})\.(\d{1,2})\.(\d{2,4})\s*$/;
+ if (!re_date.exec(s_date))
+ return alert ("Invalid date: '" + s_date + "'.\nAccepted format is dd.mm.yyyy.")
+ var n_day = Number(RegExp.$1),
+ n_month = Number(RegExp.$2),
+ n_year = Number(RegExp.$3);
+
+ if (n_year < 100)
+ n_year += (n_year < this.a_tpl.centyear ? 2000 : 1900);
+ if (n_month < 1 || n_month > 12)
+ return alert ("Invalid month value: '" + n_month + "'.\nAllowed range is 01-12.");
+ var d_numdays = new Date(n_year, n_month, 0);
+ if (n_day > d_numdays.getDate())
+ return alert("Invalid day of month value: '" + n_day + "'.\nAllowed range for selected month is 01 - " + d_numdays.getDate() + ".");
+
+ return new Date (n_year, n_month - 1, n_day);
+}
+// date generating function
+function f_tcalGenerDate (d_date) {
+ return (
+ (d_date.getDate() < 10 ? '0' : '') + d_date.getDate() + "."
+ + (d_date.getMonth() < 9 ? '0' : '') + (d_date.getMonth() + 1) + "."
+ + d_date.getFullYear()
+ );
+}
+
+// implementation
+function tcal (a_cfg, a_tpl) {
+
+ // apply default template if not specified
+ if (!a_tpl)
+ a_tpl = A_TCALDEF;
+
+ // register in global collections
+ if (!window.A_TCALS)
+ window.A_TCALS = [];
+ if (!window.A_TCALSIDX)
+ window.A_TCALSIDX = [];
+
+ this.s_id = a_cfg.id ? a_cfg.id : A_TCALS.length;
+ window.A_TCALS[this.s_id] = this;
+ window.A_TCALSIDX[window.A_TCALSIDX.length] = this;
+
+ // assign methods
+ this.f_show = f_tcalShow;
+ this.f_hide = f_tcalHide;
+ this.f_toggle = f_tcalToggle;
+ this.f_update = f_tcalUpdate;
+ this.f_relDate = f_tcalRelDate;
+ this.f_parseDate = f_tcalParseDate;
+ this.f_generDate = f_tcalGenerDate;
+
+ // create calendar icon
+ this.s_iconId = 'tcalico_' + this.s_id;
+ this.e_icon = f_getElement(this.s_iconId);
+ if (!this.e_icon) {
+ document.write('<img src="' + a_tpl.imgpath + 'cal.gif" id="' + this.s_iconId + '" onclick="A_TCALS[\'' + this.s_id + '\'].f_toggle()" class="tcalIcon" alt="Open Calendar" />');
+ this.e_icon = f_getElement(this.s_iconId);
+ }
+ // save received parameters
+ this.a_cfg = a_cfg;
+ this.a_tpl = a_tpl;
+}
+
+function f_tcalShow (d_date) {
+
+ // find input field
+ if (!this.a_cfg.controlname)
+ throw("TC: control name is not specified");
+ if (this.a_cfg.formname) {
+ var e_form = document.forms[this.a_cfg.formname];
+ if (!e_form)
+ throw("TC: form '" + this.a_cfg.formname + "' can not be found");
+ this.e_input = e_form.elements[this.a_cfg.controlname];
+ }
+ else
+ this.e_input = f_getElement(this.a_cfg.controlname);
+
+ if (!this.e_input || !this.e_input.tagName || this.e_input.tagName != 'INPUT')
+ throw("TC: element '" + this.a_cfg.controlname + "' does not exist in "
+ + (this.a_cfg.formname ? "form '" + this.a_cfg.controlname + "'" : 'this document'));
+
+ // dynamically create HTML elements if needed
+ this.e_div = f_getElement('tcal');
+ if (!this.e_div) {
+ this.e_div = document.createElement("DIV");
+ this.e_div.id = 'tcal';
+ document.body.appendChild(this.e_div);
+ }
+ this.e_shade = f_getElement('tcalShade');
+ if (!this.e_shade) {
+ this.e_shade = document.createElement("DIV");
+ this.e_shade.id = 'tcalShade';
+ document.body.appendChild(this.e_shade);
+ }
+ this.e_iframe = f_getElement('tcalIF')
+ if (b_ieFix && !this.e_iframe) {
+ this.e_iframe = document.createElement("IFRAME");
+ this.e_iframe.style.filter = 'alpha(opacity=0)';
+ this.e_iframe.id = 'tcalIF';
+ this.e_iframe.src = this.a_tpl.imgpath + 'pixel.gif';
+ document.body.appendChild(this.e_iframe);
+ }
+
+ // hide all calendars
+ f_tcalHideAll();
+
+ // generate HTML and show calendar
+ this.e_icon = f_getElement(this.s_iconId);
+ if (!this.f_update())
+ return;
+
+ this.e_div.style.visibility = 'visible';
+ this.e_shade.style.visibility = 'visible';
+ if (this.e_iframe)
+ this.e_iframe.style.visibility = 'visible';
+
+ // change icon and status
+ this.e_icon.src = this.a_tpl.imgpath + 'no_cal.gif';
+ this.e_icon.title = 'Close Calendar';
+ this.b_visible = true;
+}
+
+function f_tcalHide (n_date) {
+ if (n_date)
+ this.e_input.value = this.f_generDate(new Date(n_date));
+
+ // no action if not visible
+ if (!this.b_visible)
+ return;
+
+ // hide elements
+ if (this.e_iframe)
+ this.e_iframe.style.visibility = 'hidden';
+ if (this.e_shade)
+ this.e_shade.style.visibility = 'hidden';
+ this.e_div.style.visibility = 'hidden';
+
+ // change icon and status
+ this.e_icon = f_getElement(this.s_iconId);
+ this.e_icon.src = this.a_tpl.imgpath + 'cal.gif';
+ this.e_icon.title = 'Open Calendar';
+ this.b_visible = false;
+}
+
+function f_tcalToggle () {
+ return this.b_visible ? this.f_hide() : this.f_show();
+}
+
+function f_tcalUpdate (d_date) {
+
+ var d_today = this.a_cfg.today ? this.f_parseDate(this.a_cfg.today) : f_tcalResetTime(new Date());
+ var d_selected = this.e_input.value == ''
+ ? (this.a_cfg.selected ? this.f_parseDate(this.a_cfg.selected) : d_today)
+ : this.f_parseDate(this.e_input.value);
+
+ // figure out date to display
+ if (!d_date)
+ // selected by default
+ d_date = d_selected;
+ else if (typeof(d_date) == 'number')
+ // get from number
+ d_date = f_tcalResetTime(new Date(d_date));
+ else if (typeof(d_date) == 'string')
+ // parse from string
+ this.f_parseDate(d_date);
+
+ if (!d_date) return false;
+
+ // first date to display
+ var d_firstday = new Date(d_date);
+ d_firstday.setDate(1);
+ d_firstday.setDate(1 - (7 + d_firstday.getDay() - this.a_tpl.weekstart) % 7);
+
+ var a_class, s_html = '<table class="ctrl"><tbody><tr>'
+ + (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, -1, 'y') + ' title="Previous Year"><img src="' + this.a_tpl.imgpath + 'prev_year.gif" /></td>' : '')
+ + '<td' + this.f_relDate(d_date, -1) + ' title="Previous Month"><img src="' + this.a_tpl.imgpath + 'prev_mon.gif" /></td><th>'
+ + this.a_tpl.months[d_date.getMonth()] + ' ' + d_date.getFullYear()
+ + '</th><td' + this.f_relDate(d_date, 1) + ' title="Next Month"><img src="' + this.a_tpl.imgpath + 'next_mon.gif" /></td>'
+ + (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, 1, 'y') + ' title="Next Year"><img src="' + this.a_tpl.imgpath + 'next_year.gif" /></td></td>' : '')
+ + '</tr></tbody></table><table><tbody><tr class="wd">';
+
+ // print weekdays titles
+ for (var i = 0; i < 7; i++)
+ s_html += '<th>' + this.a_tpl.weekdays[(this.a_tpl.weekstart + i) % 7] + '</th>';
+ s_html += '</tr>' ;
+
+ // print calendar table
+ var n_date, n_month, d_current = new Date(d_firstday);
+ while (d_current.getMonth() == d_date.getMonth() ||
+ d_current.getMonth() == d_firstday.getMonth()) {
+
+ // print row heder
+ s_html +='<tr>';
+ for (var n_wday = 0; n_wday < 7; n_wday++) {
+
+ a_class = [];
+ n_date = d_current.getDate();
+ n_month = d_current.getMonth();
+
+ // other month
+ if (d_current.getMonth() != d_date.getMonth())
+ a_class[a_class.length] = 'othermonth';
+ // weekend
+ if (d_current.getDay() == 0 || d_current.getDay() == 6)
+ a_class[a_class.length] = 'weekend';
+ // today
+ if (d_current.valueOf() == d_today.valueOf())
+ a_class[a_class.length] = 'today';
+ // selected
+ if (d_current.valueOf() == d_selected.valueOf())
+ a_class[a_class.length] = 'selected';
+
+ s_html += '<td onclick="A_TCALS[\'' + this.s_id + '\'].f_hide(' + d_current.valueOf() + ')"' + (a_class.length ? ' class="' + a_class.join(' ') + '">' : '>') + n_date + '</td>'
+
+ d_current.setDate(++n_date);
+ while (d_current.getDate() != n_date && d_current.getMonth() == n_month) {
+ alert(n_date + "\n" + d_current + "\n" + new Date());
+ d_current.setHours(d_current.getHours + 1);
+ d_current = f_tcalResetTime(d_current);
+ }
+ }
+ // print row footer
+ s_html +='</tr>';
+ }
+ s_html +='</tbody></table>';
+
+ // update HTML, positions and sizes
+ this.e_div.innerHTML = s_html;
+
+ var n_width = this.e_div.offsetWidth;
+ var n_height = this.e_div.offsetHeight;
+ var n_top = f_getPosition (this.e_icon, 'Top') + this.e_icon.offsetHeight;
+ var n_left = f_getPosition (this.e_icon, 'Left') - n_width + this.e_icon.offsetWidth;
+ if (n_left < 0) n_left = 0;
+
+ this.e_div.style.left = n_left + 'px';
+ this.e_div.style.top = n_top + 'px';
+
+ this.e_shade.style.width = (n_width + 8) + 'px';
+ this.e_shade.style.left = (n_left - 1) + 'px';
+ this.e_shade.style.top = (n_top - 1) + 'px';
+ this.e_shade.innerHTML = b_ieFix
+ ? '<table><tbody><tr><td rowspan="2" colspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_tr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td height="' + (n_height - 7) + '" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_mr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td width="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bl.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bm.png\', sizingMethod=\'scale\');" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_br.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tbody></table>'
+ : '<table><tbody><tr><td rowspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td rowspan="2"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7"><img src="' + this.a_tpl.imgpath + 'shade_tr.png"></td></tr><tr><td background="' + this.a_tpl.imgpath + 'shade_mr.png" height="' + (n_height - 7) + '"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td><img src="' + this.a_tpl.imgpath + 'shade_bl.png"></td><td background="' + this.a_tpl.imgpath + 'shade_bm.png" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td><img src="' + this.a_tpl.imgpath + 'shade_br.png"></td></tr><tbody></table>';
+
+ if (this.e_iframe) {
+ this.e_iframe.style.left = n_left + 'px';
+ this.e_iframe.style.top = n_top + 'px';
+ this.e_iframe.style.width = (n_width + 6) + 'px';
+ this.e_iframe.style.height = (n_height + 6) +'px';
+ }
+ return true;
+}
+
+function f_getPosition (e_elemRef, s_coord) {
+ var n_pos = 0, n_offset,
+ e_elem = e_elemRef;
+
+ while (e_elem) {
+ n_offset = e_elem["offset" + s_coord];
+ n_pos += n_offset;
+ e_elem = e_elem.offsetParent;
+ }
+ // margin correction in some browsers
+ if (b_ieMac)
+ n_pos += parseInt(document.body[s_coord.toLowerCase() + 'Margin']);
+ else if (b_safari)
+ n_pos -= n_offset;
+
+ e_elem = e_elemRef;
+ while (e_elem != document.body) {
+ n_offset = e_elem["scroll" + s_coord];
+ if (n_offset && e_elem.style.overflow == 'scroll')
+ n_pos -= n_offset;
+ e_elem = e_elem.parentNode;
+ }
+ return n_pos;
+}
+
+function f_tcalRelDate (d_date, d_diff, s_units) {
+ var s_units = (s_units == 'y' ? 'FullYear' : 'Month');
+ var d_result = new Date(d_date);
+ d_result['set' + s_units](d_date['get' + s_units]() + d_diff);
+ if (d_result.getDate() != d_date.getDate())
+ d_result.setDate(0);
+ return ' onclick="A_TCALS[\'' + this.s_id + '\'].f_update(' + d_result.valueOf() + ')"';
+}
+
+function f_tcalHideAll () {
+ for (var i = 0; i < window.A_TCALSIDX.length; i++)
+ window.A_TCALSIDX[i].f_hide();
+}
+
+function f_tcalResetTime (d_date) {
+ d_date.setHours(0);
+ d_date.setMinutes(0);
+ d_date.setSeconds(0);
+ d_date.setMilliseconds(0);
+ return d_date;
+}
+
+f_getElement = document.all ?
+ function (s_id) { return document.all[s_id] } :
+ function (s_id) { return document.getElementById(s_id) };
+
+if (document.addEventListener)
+ window.addEventListener('scroll', f_tcalHideAll, false);
+if (window.attachEvent)
+ window.attachEvent('onscroll', f_tcalHideAll);
+
+// global variables
+var s_userAgent = navigator.userAgent.toLowerCase(),
+ re_webkit = /WebKit\/(\d+)/i;
+var b_mac = s_userAgent.indexOf('mac') != -1,
+ b_ie5 = s_userAgent.indexOf('msie 5') != -1,
+ b_ie6 = s_userAgent.indexOf('msie 6') != -1 && s_userAgent.indexOf('opera') == -1;
+var b_ieFix = b_ie5 || b_ie6,
+ b_ieMac = b_mac && b_ie5,
+ b_safari = b_mac && re_webkit.exec(s_userAgent) && Number(RegExp.$1) < 500;
Modified: branches/postfixadmin-smarty/config.inc.php
===================================================================
--- branches/postfixadmin-smarty/config.inc.php 2009-08-04 20:45:21 UTC (rev 701)
+++ branches/postfixadmin-smarty/config.inc.php 2009-08-10 13:40:32 UTC (rev 702)
@@ -16,12 +16,6 @@
* Contains configuration options.
*/
-if (ereg ("config.inc.php", $_SERVER['PHP_SELF']))
-{
- header ("Location: login.php");
- exit;
-}
-
/*****************************************************************
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* The following line needs commenting out or removing before the
@@ -176,7 +170,7 @@
// Virtual Vacation
// If you want to use virtual vacation for you mailbox users set this to 'YES'.
-// NOTE: Make sure that you install the vacation module. http://high5.net/postfixadmin/
+// NOTE: Make sure that you install the vacation module. (See VIRTUAL-VACATION/)
$CONF['vacation'] = 'NO';
// This is the autoreply domain that you will need to set in your Postfix
// transport maps to handle virtual vacations. It does not need to be a
Added: branches/postfixadmin-smarty/css/calendar.css
===================================================================
--- branches/postfixadmin-smarty/css/calendar.css (rev 0)
+++ branches/postfixadmin-smarty/css/calendar.css 2009-08-10 13:40:32 UTC (rev 702)
@@ -0,0 +1,95 @@
+/* calendar icon */
+img.tcalIcon {
+ cursor: pointer;
+ margin-left: 1px;
+ vertical-align: middle;
+}
+/* calendar container element */
+div#tcal {
+ position: absolute;
+ visibility: hidden;
+ z-index: 100;
+ width: 158px;
+ padding: 2px 0 0 0;
+}
+/* all tables in calendar */
+div#tcal table {
+ width: 100%;
+ border: 1px solid silver;
+ border-collapse: collapse;
+ background-color: white;
+}
+/* navigation table */
+div#tcal table.ctrl {
+ border-bottom: 0;
+}
+/* navigation buttons */
+div#tcal table.ctrl td {
+ width: 15px;
+ height: 20px;
+}
+/* month year header */
+div#tcal table.ctrl th {
+ background-color: white;
+ color: black;
+ border: 0;
+}
+/* week days header */
+div#tcal th {
+ border: 1px solid silver;
+ border-collapse: collapse;
+ text-align: center;
+ padding: 3px 0;
+ font-family: tahoma, verdana, arial;
+ font-size: 10px;
+ background-color: gray;
+ color: white;
+}
+/* date cells */
+div#tcal td {
+ border: 0;
+ border-collapse: collapse;
+ text-align: center;
+ padding: 2px 0;
+ font-family: tahoma, verdana, arial;
+ font-size: 11px;
+ width: 22px;
+ cursor: pointer;
+}
+/* date highlight
+ in case of conflicting settings order here determines the priority from least to most important */
+div#tcal td.othermonth {
+ color: silver;
+}
+div#tcal td.weekend {
+ background-color: #ACD6F5;
+}
+div#tcal td.today {
+ border: 1px solid red;
+}
+div#tcal td.selected {
+ background-color: #FFB3BE;
+}
+/* iframe element used to suppress windowed controls in IE5/6 */
+iframe#tcalIF {
+ position: absolute;
+ visibility: hidden;
+ z-index: 98;
+ border: 0;
+}
+/* transparent shadow */
+div#tcalShade {
+ position: absolute;
+ visibility: hidden;
+ z-index: 99;
+}
+div#tcalShade table {
+ border: 0;
+ border-collapse: collapse;
+ width: 100%;
+}
+div#tcalShade table td {
+ border: 0;
+ border-collapse: collapse;
+ padding: 0;
+}
Modified: branches/postfixadmin-smarty/debian/changelog
===================================================================
--- branches/postfixadmin-smarty/debian/changelog 2009-08-04 20:45:21 UTC (rev 701)
+++ branches/postfixadmin-smarty/debian/changelog 2009-08-10 13:40:32 UTC (rev 702)
@@ -1,3 +1,16 @@
+postfixadmin (2.3rc7) unstable; urgency=low
+
+ * Fix issue with pre.rm script
+ * New 'upstream' release.
+
+ -- David Goodwin <david.goodwin@...> Mon, 27 Jul 2009 22:08:26 +0100
+
+postfixadmin (2.3rc6) unstable; urgency=low
+
+ * Bump version number; etc.
+
+ -- David Goodwin <david.goodwin@...> Mon, 20 Jul 2009 19:56:26 +0100
+
postfixadmin (2.3rc5) unstable; urgency=low
* Initial release (Closes: #247225)
Modified: branches/postfixadmin-smarty/debian/control
===================================================================
--- branches/postfixadmin-smarty/debian/control 2009-08-04 20:45:21 UTC (rev 701)
+++ branches/postfixadmin-smarty/debian/control 2009-08-10 13:40:32 UTC (rev 702)
@@ -3,7 +3,7 @@
Priority: optional
Maintainer: Norman Messtorff <normes@...>
Build-Depends: debhelper (>= 7), po-debconf, quilt (>= 0.46)
-Standards-Version: 3.8.1
+Standards-Version: 3.8.2
Homepage: http://postfixadmin.sourceforge.net
XS-Vcs-Svn: https://postfixadmin.svn.sourceforge.net/svnroot/postfixadmin/trunk
XS-Vcs-Browse: http://postfixadmin.svn.sourceforge.net/viewvc/postfixadmin/trunk/
Modified: branches/postfixadmin-smarty/debian/rules
===================================================================
--- branches/postfixadmin-smarty/debian/rules 2009-08-04 20:45:21 UTC (rev 701)
+++ branches/postfixadmin-smarty/debian/rules 2009-08-10 13:40:32 UTC (rev 702)
@@ -28,7 +28,7 @@
dh_install
mv debian/postfixadmin/usr/share/postfixadmin/config.inc.php debian/postfixadmin/etc/postfixadmin/config.inc.php
find debian/postfixadmin -name .svn | xargs -r rm -r
- if test "${DIST}" = "lenny" ; then cp debian/confd-link.sh debian/postfixadmin/usr/share/postfixadmin/; fi
+ cp debian/confd-link.sh debian/postfixadmin/usr/share/postfixadmin/
# Build architecture-independent files here.
binary-indep: build install
Modified: branches/postfixadmin-smarty/edit-vacation.php
===================================================================
--- branches/postfixadmin-smarty/edit-vacation.php 2009-08-04 20:45:21 UTC (rev 701)
+++ branches/postfixadmin-smarty/edit-vacation.php 2009-08-10 13:40:32 UTC (rev 702)
@@ -1,211 +1,222 @@
-<?php
-/**
- * Postfix Admin
- *
- * LICENSE
- * This source file is subject to the GPL license that is bundled with
- * this package in the file LICENSE.TXT.
- *
- * Further details on the project are available at :
- * http://www.postfixadmin.com or http://postfixadmin.sf.net
- *
- * @version $Id$
- * @license GNU GPL v2 or later.
- *
- * File: edit-vacation.php
- * Responsible for allowing users to update their vacation status.
- *
- * Template File: edit-vacation.php
- *
- * Template Variables:
- *
- * tUseremail
- * tMessage
- * tSubject
- * tBody
- *
- * Form POST \ GET Variables:
- *
- * fUsername
- * fDomain
- * fCanceltarget
- * fChange
- * fBack
- * fQuota
- * fActive
- */
-
-require_once('common.php');
-
-if($CONF['vacation'] == 'NO') {
- header("Location: " . $CONF['postfix_admin_url'] . "/list-virtual.php");
- exit(0);
-}
-
-$SESSID_USERNAME = authentication_get_username();
-$tmp = preg_split ('/@/', $SESSID_USERNAME);
-$USERID_DOMAIN = $tmp[1];
-
-// only allow admins to change someone else's 'stuff'
-if(authentication_has_role('admin')) {
- if (isset($_GET['username'])) $fUsername = escape_string ($_GET['username']);
- if (isset($_GET['domain'])) $fDomain = escape_string ($_GET['domain']);
-}
-else {
- $fUsername = $SESSID_USERNAME;
- $fDomain = $USERID_DOMAIN;
-}
-
-$vacation_domain = $CONF['vacation_domain'];
-$vacation_goto = preg_replace('/@/', '#', $fUsername);
-$vacation_goto = $vacation_goto . '@' . $vacation_domain;
-
-$fCanceltarget = $CONF['postfix_admin_url'] . "/list-virtual.php?domain=$fDomain";
-
-if ($_SERVER['REQUEST_METHOD'] == "GET")
-{
-
- $result = db_query("SELECT * FROM $table_vacation WHERE email='$fUsername'");
- if ($result['rows'] == 1)
- {
- $row = db_array($result['result']);
- $tMessage = '';
- $tSubject = $row['subject'];
- $tBody = $row['body'];
- }
-
- $tUseremail = $fUsername;
- $tDomain = $fDomain;
- if ($tSubject == '') { $tSubject = html_entity_decode($PALANG['pUsersVacation_subject_text'], ENT_QUOTES, 'UTF-8'); }
- if ($tBody == '') { $tBody = html_entity_decode($PALANG['pUsersVacation_body_text'], ENT_QUOTES, 'UTF-8'); }
-
-}
-
-if ($_SERVER['REQUEST_METHOD'] == "POST")
-{
-
- $tSubject = safepost('fSubject');
- $fSubject = escape_string ($tSubject);
- $tBody = safepost('fBody');
- $fBody = escape_string ($tBody);
- $fChange = escape_string (safepost('fChange'));
- $fBack = escape_string (safepost('fBack'));
-
- if(authentication_has_role('admin') && isset($_GET['domain'])) {
- $fDomain = escape_string ($_GET['domain']);
- }
- else {
- $fDomain = $USERID_DOMAIN;
- }
- if(authentication_has_role('admin') && isset ($_GET['username'])) {
- $fUsername = escape_string($_GET['username']);
- }
- else {
- $fUsername = authentication_get_username();
- }
-
- $tUseremail = $fUsername;
- if ($tSubject == '') { $tSubject = html_entity_decode($PALANG['pUsersVacation_subject_text'], ENT_QUOTES, 'UTF-8'); }
- if ($tBody == '') { $tBody = html_entity_decode($PALANG['pUsersVacation_body_text'], ENT_QUOTES, 'UTF-8'); }
-
- //if change, remove old one, then perhaps set new one
- if (!empty ($fBack) || !empty ($fChange))
- {
- //if we find an existing vacation entry, disable it
- $result = db_query("SELECT * FROM $table_vacation WHERE email='$fUsername'");
- if ($result['rows'] == 1)
- {
- $db_false = db_get_boolean(false);
- // retain vacation message if possible - i.e disable vacation away-ness.
- $result = db_query ("UPDATE $table_vacation SET active = $db_false WHERE email='$fUsername'");
- $result = db_query("DELETE FROM $table_vacation_notification WHERE on_vacation='$fUsername'");
-
- $result = db_query ("SELECT * FROM $table_alias WHERE address='$fUsername'");
- if ($result['rows'] == 1)
- {
- $row = db_array ($result['result']);
- $goto = $row['goto'];
- //only one of these will do something, first handles address at beginning and middle, second at end
- $goto= preg_replace ( "/$vacation_goto,/", '', $goto);
- $goto= preg_replace ( "/,$vacation_goto/", '', $goto);
- $goto= preg_replace ( "/$vacation_goto/", '', $goto);
- if($goto == '') {
- $sql = "DELETE FROM $table_alias WHERE address = '$fUsername'";
- }
- else {
- $sql = "UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$fUsername'";
- }
- $result = db_query($sql);
- if ($result['rows'] != 1)
- {
- $error = 1;
- }
- }
- }
- }
-
-
- //Set the vacation data for $fUsername
- if (!empty ($fChange))
- {
- $goto = '';
- $result = db_query ("SELECT * FROM $table_alias WHERE address='$fUsername'");
- if ($result['rows'] == 1)
- {
- $row = db_array ($result['result']);
- $goto = $row['goto'];
- }
- $Active = db_get_boolean(True);
- $notActive = db_get_boolean(False);
- // I don't think we need to care if the vacation entry is inactive or active.. as long as we don't try and
- // insert a duplicate
- $result = db_query("SELECT * FROM $table_vacation WHERE email = '$fUsername'");
- if($result['rows'] == 1) {
- $result = db_query("UPDATE $table_vacation SET active = $Active, subject = '$fSubject', body = '$fBody', created = NOW() WHERE email = '$fUsername'");
- }
- else {
- $result = db_query ("INSERT INTO $table_vacation (email,subject,body,domain,created,active) VALUES ('$fUsername','$fSubject','$fBody','$fDomain',NOW(),$Active)");
- }
-
- if ($result['rows'] != 1)
- {
- $error = 1;
- }
- if($goto == '') {
- $goto = $vacation_goto;
- $sql = "INSERT INTO $table_alias (goto, address, domain, modified) VALUES ('$goto', '$fUsername', '$fDomain', NOW())";
- }
- else {
- $goto = $goto . "," . $vacation_goto;
- $sql = "UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$fUsername'";
- }
- $result = db_query ($sql);
- if ($result['rows'] != 1)
- {
- $error = 1;
- }
- }
-}
-
-if($error == 0) {
- if(!empty ($fBack)) {
- $tMessage = $PALANG['pVacation_result_removed'];
- }
- if(!empty($fChange)) {
- $tMessage= $PALANG['pVacation_result_added'];
- }
-}
-else {
- $tMessage = $PALANG['pVacation_result_error'];
-}
-
-$smarty->assign ('tUseremail', $tUseremail);
-$smarty->assign ('tSubject', htmlentities(stripslashes($tSubject), ENT_QUOTES, 'UTF-8'));
-$smarty->assign ('tBody', htmlentities(stripslashes($tBody), ENT_QUOTES , 'UTF-8'));
-$smarty->assign ('tMessage', $tMessage);
-$smarty->assign ('fCanceltarget', $fCanceltarget);
-$smarty->assign ('smarty_template', 'edit-vacation');
-$smarty->display ('index.tpl');
-
-/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
-?>
+<?php
+/**
+ * Postfix Admin
+ *
+ * LICENSE
+ * This source file is subject to the GPL license that is bundled with
+ * this package in the file LICENSE.TXT.
+ *
+ * Further details on the project are available at :
+ * http://www.postfixadmin.com or http://postfixadmin.sf.net
+ *
+ * @version $Id$
+ * @license GNU GPL v2 or later.
+ *
+ * File: edit-vacation.php
+ * Responsible for allowing users to update their vacation status.
+ *
+ * Template File: edit-vacation.php
+ *
+ * Template Variables:
+ *
+ * tUseremail
+ * tMessage
+ * tSubject
+ * tBody
+ *
+ * Form POST \ GET Variables:
+ *
+ * fUsername
+ * fDomain
+ * fCanceltarget
+ * fChange
+ * fBack
+ * fQuota
+ * fActive
+ */
+
+require_once('common.php');
+
+if($CONF['vacation'] == 'NO') {
+ header("Location: " . $CONF['postfix_admin_url'] . "/list-virtual.php");
+ exit(0);
+}
+
+$SESSID_USERNAME = authentication_get_username();
+$tmp = preg_split ('/@/', $SESSID_USERNAME);
+$USERID_DOMAIN = $tmp[1];
+
+// only allow admins to change someone else's 'stuff'
+if(authentication_has_role('admin')) {
+ if (isset($_GET['username'])) $fUsername = escape_string ($_GET['username']);
+ if (isset($_GET['domain'])) $fDomain = escape_string ($_GET['domain']);
+}
+else {
+ $fUsername = $SESSID_USERNAME;
+ $fDomain = $USERID_DOMAIN;
+}
+
+$vacation_domain = $CONF['vacation_domain'];
+$vacation_goto = preg_replace('/@/', '#', $fUsername);
+$vacation_goto = $vacation_goto . '@' . $vacation_domain;
+
+$fCanceltarget = $CONF['postfix_admin_url'] . "/list-virtual.php?domain=$fDomain";
+
+if ($_SERVER['REQUEST_METHOD'] == "GET")
+{
+
+ $result = db_query("SELECT * FROM $table_vacation WHERE email='$fUsername'");
+ if ($result['rows'] == 1)
+ {
+ $row = db_array($result['result']);
+ $tMessage = '';
+ $tSubject = $row['subject'];
+ $tBody = $row['body'];
+ $tActiveFrom = $row['activefrom'];
+ $tActiveUntil = $row['activeuntil'];
+ }
+
+ $tUseremail = $fUsername;
+ $tDomain = $fDomain;
+ if ($tSubject == '') { $tSubject = html_entity_decode($PALANG['pUsersVacation_subject_text'], ENT_QUOTES, 'UTF-8'); }
+ if ($tBody == '') { $tBody = html_entity_decode($PALANG['pUsersVacation_body_text'], ENT_QUOTES, 'UTF-8'); }
+
+}
+
+if ($_SERVER['REQUEST_METHOD'] == "POST")
+{
+
+ $tSubject = safepost('fSubject');
+ $fSubject = escape_string ($tSubject);
+ $tBody = safepost('fBody');
+// $tActiveFrom = safepost('activefrom').' 00:00:01';
+// $tActiveUntil = safepost('activeuntil').' 23:59:59';
+ $tActiveFrom = date ("Y-m-d 00:00:00", strtotime (safepost('activefrom')));
+ $tActiveUntil = date ("Y-m-d 23:59:59", strtotime (safepost('activeuntil')));
+ $fBody = escape_string ($tBody);
+ $fChange = escape_string (safepost('fChange'));
+ $fBack = escape_string (safepost('fBack'));
+ if(authentication_has_role('admin') && isset($_GET['domain'])) {
+ $fDomain = escape_string ($_GET['domain']);
+ }
+ else {
+ $fDomain = $USERID_DOMAIN;
+ }
+ if(authentication_has_role('admin') && isset ($_GET['username'])) {
+ $fUsername = escape_string($_GET['username']);
+ }
+ else {
+ $fUsername = authentication_get_username();
+ }
+
+ $tUseremail = $fUsername;
+ if ($tSubject == '') { $tSubject = html_entity_decode($PALANG['pUsersVacation_subject_text'], ENT_QUOTES, 'UTF-8'); }
+ if ($tBody == '') { $tBody = html_entity_decode($PALANG['pUsersVacation_body_text'], ENT_QUOTES, 'UTF-8'); }
+
+ //if change, remove old one, then perhaps set new one
+ if (!empty ($fBack) || !empty ($fChange))
+ {
+ //if we find an existing vacation entry, disable it
+ $result = db_query("SELECT * FROM $table_vacation WHERE email='$fUsername'");
+ if ($result['rows'] == 1)
+ {
+ $db_false = db_get_boolean(false);
+ // retain vacation message if possible - i.e disable vacation away-ness.
+ $result = db_query ("UPDATE $table_vacation SET active = $db_false WHERE email='$fUsername'");
+ $result = db_query("DELETE FROM $table_vacation_notification WHERE on_vacation='$fUsername'");
+
+ $result = db_query ("SELECT * FROM $table_alias WHERE address='$fUsername'");
+ if ($result['rows'] == 1)
+ {
+ $row = db_array ($result['result']);
+ $goto = $row['goto'];
+ //only one of these will do something, first handles address at beginning and middle, second at end
+ $goto= preg_replace ( "/$vacation_goto,/", '', $goto);
+ $goto= preg_replace ( "/,$vacation_goto/", '', $goto);
+ $goto= preg_replace ( "/$vacation_goto/", '', $goto);
+ if($goto == '') {
+ $sql = "DELETE FROM $table_alias WHERE address = '$fUsername'";
+ }
+ else {
+ $sql = "UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$fUsername'";
+ }
+ $result = db_query($sql);
+ if ($result['rows'] != 1)
+ {
+ $error = 1;
+ }
+ }
+ }
+ }
+
+
+ //Set the vacation data for $fUsername
+ if (!empty ($fChange))
+ {
+ $goto = '';
+ $result = db_query ("SELECT * FROM $table_alias WHERE address='$fUsername'");
+ if ($result['rows'] == 1)
+ {
+ $row = db_array ($result['result']);
+ $goto = $row['goto'];
+ }
+ $Active = db_get_boolean(True);
+ $notActive = db_get_boolean(False);
+ // I don't think we need to care if the vacation entry is inactive or active.. as long as we don't try and
+ // insert a duplicate
+ $result = db_query("SELECT * FROM $table_vacation WHERE email = '$fUsername'");
+ if($result['rows'] == 1) {
+ $result = db_query("UPDATE $table_vacation SET active = $Active, subject = '$fSubject', body = '$fBody', created = NOW(), activefrom = '$tActiveFrom', activeuntil = '$tActiveUntil' WHERE email = '$fUsername'");
+ }
+ else {
+ $result = db_query ("INSERT INTO $table_vacation (email,subject,body,domain,created,active, activefrom, activeuntil) VALUES ('$fUsername','$fSubject','$fBody','$fDomain',NOW(),$Active, '$tActiveFrom', '$tActiveUntil')");
+ }
+
+ if ($result['rows'] != 1)
+ {
+ $error = 1;
+ }
+ if($goto == '') {
+ $goto = $vacation_goto;
+ $sql = "INSERT INTO $table_alias (goto, address, domain, modified, activefrom, activeuntil) VALUES ('$goto', '$fUsername', '$fDomain', NOW(), '$tActiveFrom', '$tActiveUntil')";
+ }
+ else {
+ $goto = $goto . "," . $vacation_goto;
+ $sql = "UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$fUsername'";
+ }
+ $result = db_query ($sql);
+ if ($result['rows'] != 1)
+ {
+ $error = 1;
+ }
+ }
+}
+
+if($error == 0) {
+ if(!empty ($fBack)) {
+ $tMessage = $PALANG['pVacation_result_removed'];
+ }
+ if(!empty($fChange)) {
+ $tMessage= $PALANG['pVacation_result_added'];
+ }
+}
+else {
+ $tMessage = $PALANG['pVacation_result_error'];
+}
+if (empty ($tActiveFrom))
+ $tActiveFrom = date ("Y-m-d");
+if (empty ($tActiveUntil))
+ $tActiveUntil = date ("Y-m-d");
+
+$smarty->assign ('tUseremail', $tUseremail);
+$smarty->assign ('tSubject', htmlentities(stripslashes($tSubject), ENT_QUOTES, 'UTF-8'));
+$smarty->assign ('tBody', htmlentities(stripslashes($tBody), ENT_QUOTES , 'UTF-8'));
+$smarty->assign ('tMessage', $tMessage);
+$smarty->assign ('tActiveFrom', date ("d.m.Y", strtotime ($tActiveFrom)));
+$smarty->assign ('tActiveUntil', date ("d.m.Y", strtotime ($tActiveUntil)));
+$smarty->assign ('fCanceltarget', $fCanceltarget);
+$smarty->assign ('smarty_template', 'edit-vacation');
+$smarty->display ('index.tpl');
+
+/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
+?>
Modified: branches/postfixadmin-smarty/functions.inc.php
===================================================================
--- branches/postfixadmin-smarty/functions.inc.php 2009-08-04 20:45:21 UTC (rev 701)
+++ branches/postfixadmin-smarty/functions.inc.php 2009-08-10 13:40:32 UTC (rev 702)
@@ -16,14 +16,8 @@
* Contains re-usable code.
*/
-if (ereg ("functions.inc.php", $_SERVER['PHP_SELF']))
-{
- header ("Location: login.php");
- exit;
-}
+$version = '2.3 rc7';
-$version = '2.3 rc5';
-
/**
* check_session
* Action: Check if a session already exists, if not redirect to login.php
@@ -1142,9 +1136,9 @@
}
elseif ($CONF['encrypt'] == 'system') {
- if (ereg ("\$1\$", $pw_db)) {
+ if (preg_match("/\\$1\\$/", $pw_db)) {
$split_salt = preg_split ('/\$/', $pw_db);
- $salt = $split_salt[2];
+ $salt = "\$1\$${split_salt[2]}\$";
}
else {
if (strlen($pw_db) == 0) {
@@ -1178,7 +1172,7 @@
elseif ($CONF['encrypt'] == 'authlib') {
$flavor = $CONF['authlib_default_flavor'];
$salt = substr(create_salt(), 0, 2); # courier-authlib supports only two-character salts
- if(ereg('^{.*}', $pw_db)) {
+ if(preg_match('/^{.*}/', $pw_db)) {
// we have a flavor in the db -> use it instead of default flavor
$result = split('{|}', $pw_db, 3);
$flavor = $result[1];
@@ -1191,8 +1185,10 @@
$password = '{' . $flavor . '}' . base64_encode(md5($pw, TRUE));
} elseif(stripos($flavor, 'crypt') === 0) {
$password = '{' . $flavor . '}' . crypt($pw, $salt);
+ } elseif(stripos($flavor, 'SHA') === 0) {
+ $password = '{' . $flavor . '}' . base64_encode(sha1($pw, TRUE));
} else {
- die("authlib_default_flavor '" . $flavor . "' unknown. Valid flavors are 'md5raw', 'md5' and 'crypt'");
+ die("authlib_default_flavor '" . $flavor . "' unknown. Valid flavors are 'md5raw', 'md5', 'SHA' and 'crypt'");
}
}
@@ -1519,9 +1515,9 @@
if($CONF['database_type']=='pgsql') {
// return either true or false (unquoted strings)
if($bool) {
- return 'true';
+ return 't';
}
- return 'false';
+ return 'f';
}
elseif($CONF['database_type'] == 'mysql' || $CONF['database_type'] == 'mysqli') {
if($bool) {
@@ -1561,7 +1557,7 @@
if ($error_text != "" && $ignore_errors == 0) die($error_text);
if ($error_text == "") {
- if (eregi ("^SELECT", $query))
+ if (preg_match("/^SELECT/i", $query))
{
// if $query was a SELECT statement check the number of rows with [database_type]_num_rows ().
if ($CONF['database_type'] == "mysql") $number_rows = mysql_num_rows ($result);
Added: branches/postfixadmin-smarty/images/calendar/cal.gif
===================================================================
(Binary files differ)
Property changes on: branches/postfixadmin-smarty/images/calendar/cal.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/postfixadmin-smarty/images/calendar/next_mon.gif
===================================================================
(Binary files differ)
Property changes on: branches/postfixadmin-smarty/images/calendar/next_mon.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/postfixadmin-smarty/images/calendar/next_year.gif
===================================================================
(Binary files differ)
Property changes on: branches/postfixadmin-smarty/images/calendar/next_year.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/postfixadmin-smarty/images/calendar/no_cal.gif
===================================================================
(Binary files differ)
Property changes on: branches/postfixadmin-smarty/images/calendar/no_cal.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/postfixadmin-smarty/images/calendar/pixel.gif
===================================================================
(Binary files differ)
Property changes on: branches/postfixadmin-smarty/images/calendar/pixel.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/postfixadmin-smarty/images/calendar/prev_mon.gif
===================================================================
(Binary files differ)
Property changes on: branches/postfixadmin-smarty/images/calendar/prev_mon.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/postfixadmin-smarty/images/calendar/prev_year.gif
===================================================================
(Binary files differ)
Property changes on: branches/postfixadmin-smarty/images/calendar/prev_year.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/postfixadmin-smarty/images/calendar/shade_bl.png
===================================================================
(Binary files differ)
Property changes on: branches/postfixadmin-smarty/images/calendar/shade_bl.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/postfixadmin-smarty/images/calendar/shade_bm.png
===================================================================
(Binary files differ)
Property changes on: branches/postfixadmin-smarty/images/calendar/shade_bm.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/postfixadmin-smarty/images/calendar/shade_br.png
===================================================================
(Binary files differ)
Property changes on: branches/postfixadmin-smarty/images/calendar/shade_br.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/postfixadmin-smarty/images/calendar/shade_mr.png
===================================================================
(Binary files differ)
Property changes on: branches/postfixadmin-smarty/images/calendar/shade_mr.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/postfixadmin-smarty/images/calendar/shade_tr.png
===================================================================
(Binary files differ)
Property changes on: branches/postfixadmin-smarty/images/calendar/shade_tr.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: branches/postfixadmin-smarty/languages/de.lang
===================================================================
--- branches/postfixadmin-smarty/languages/de.lang 2009-08-04 20:45:21 UTC (rev 701)
+++ branches/postfixadmin-smarty/languages/de.lang 2009-08-10 13:40:32 UTC (rev 702)
@@ -186,6 +186,8 @@
$PALANG['pVacation_result_error'] = '<span class="error_msg">Änderungen der automatischen Antwort konnten nicht gespeichert werden!</span>';
$PALANG['pVacation_result_removed'] = 'Automatische Antwort wurde abgeschaltet!';
$PALANG['pVacation_result_added'] = 'Automatische Antwort wurde aktiviert!';
+$PALANG['pUsersVacation_activefrom'] = 'Aktiv ab dem';
+$PALANG['pUsersVacation_activeuntil'] = 'Aktiv bis zum';
$PALANG['pViewlog_welcome'] = 'Zeigt die letzten 10 Aktionen für ';
$PALANG['pViewlog_timestamp'] = 'Zeitpunkt';
Modified: branches/postfixadmin-smarty/languages/en.lang
===================================================================
--- branches/postfixadmin-smarty/languages/en.lang 2009-08-04 20:45:21 UTC (rev 701)
+++ branches/postfixadmin-smarty/languages/en.lang 2009-08-10 13:40:32 UTC (rev 702)
@@ -355,6 +355,8 @@
$PALANG['pUsersVacation_button_back'] = 'Coming Back';
$PALANG['pUsersVacation_result_error'] = '<span class="error_msg">Unable to update your auto response settings!</span>';
$PALANG['pUsersVacation_result_success'] = 'Your auto response has been removed!';
+$PALANG['pUsersVacation_activefrom'] = 'Active from';
+$PALANG['pUsersVacation_activeuntil'] = 'Active until';
$PALANG['pCreate_dbLog_createmailbox'] = 'create mailbox';
$PALANG['pCreate_dbLog_createalias'] = 'create alias';
Modified: branches/postfixadmin-smarty/list-virtual.php
===================================================================
--- branches/postfixadmin-smarty/list-virtual.php 2009-08-04 20:45:21 UTC (rev 701)
+++ branches/postfixadmin-smarty/list-virtual.php 2009-08-10 13:40:32 UTC (rev 702)
@@ -33,6 +33,7 @@
authentication_require_role('admin');
+$fDomain = false;
$SESSID_USERNAME = authentication_get_username();
if (authentication_has_role('global-admin')) {
@@ -59,6 +60,12 @@
if (isset ($_POST['limit'])) $fDisplay = intval ($_POST['limit']);
}
+// store fDomain in $_SESSION so after adding/editing aliases/mailboxes we can
+// take the user back to the appropriate domain listing. (see templates/menu.php)
+if($fDomain) {
+ $_SESSION['list_virtual_sticky_domain'] = $fDomain;
+}
+
if (count($list_domains) == 0) {
# die("no domains");
header("Location: list-domain.php"); # no domains (for this admin at least) - redirect to domain list
Modified: branches/postfixadmin-smarty/templates/edit-vacation.tpl
===================================================================
--- branches/postfixadmin-smarty/templates/edit-vacation.tpl 2009-08-04 20:45:21 UTC (rev 701)
+++ branches/postfixadmin-smarty/templates/edit-vacation.tpl 2009-08-10 13:40:32 UTC (rev 702)
@@ -4,6 +4,8 @@
window.location="{/literal}{$fCanceltarget}{literal}"
}
</script>
+ <script language="JavaScript" src="calendar.js"></script>
+ <link rel="stylesheet" href="css/calendar.css">
{/literal}
<div id="edit_form">
<form name="edit-vacation" method="post" action=''>
@@ -17,6 +19,34 @@
<td> </td>
</tr>
<tr>
+ <td>{$PALANG.pUsersVacation_activefrom}:</td>
+ <td><input name="activefrom" value="{$tActiveFrom}" readonly="readonly" style="background:#eee;"/>
+{literal}
+<script language="JavaScript">
+ new tcal ({
+ 'formname': 'edit-vacation',
+ 'controlname': 'activefrom'
+ });
+</script>
+{/literal}
+ </td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{$PALANG.pUsersVacation_activeuntil}:</td>
+ <td><input name="activeuntil" value="{$tActiveUntil}" readonly="readonly" style="background:#eee;"/>
+{literal}
+<script language="JavaScript">
+ new tcal ({
+ 'formname': 'edit-vacation',
+ 'controlname': 'activeuntil'
+ });
+</script>
+{/literal}
+ </td>
+ <td> </td>
+ </tr>
+ <tr>
<td>{$PALANG.pUsersVacation_subject}:</td>
<td><textarea class="flat" rows="3" cols="60" name="fSubject" >{$tSubject}</textarea></td>
<td> </td>
Modified: branches/postfixadmin-smarty/upgrade.php
===================================================================
--- branches/postfixadmin-smarty/upgrade.php 2009-08-04 20:45:21 UTC (rev 701)
+++ branches/postfixadmin-smarty/upgrade.php 2009-08-10 13:40:32 UTC (rev 702)
@@ -1,1084 +1,1084 @@
-<?php
-if(!defined('POSTFIXADMIN')) {
- require_once('common.php');
-}
-
-/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
-
-# Note: run with upgrade.php?debug=1 to see all SQL error messages
-
-
-/**
- * Use this to check whether an object (Table, index etc) exists within a
- * PostgreSQL database.
- * @param String the object name
- * @return boolean true if it exists
- */
-function _pgsql_object_exists($name) {
- $sql = "select relname from pg_class where relname = '$name'";
- $r = db_query($sql);
- if($r['rows'] == 1) {
- return true;
- }
- return false;
-}
-
-function _pgsql_field_exists($table, $field) {
- $sql = '
- SELECT
- a.attname,
- pg_catalog.format_type(a.atttypid, a.atttypmod) AS "Datatype"
- FROM
- pg_catalog.pg_attribute a
- WHERE
- a.attnum > 0
- AND NOT a.attisdropped
- AND a.attrelid = (
- SELECT c.oid
- FROM pg_catalog.pg_class c
- LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
- WHERE c.relname ~ ' . "'^($table)\$'
- AND pg_catalog.pg_table_is_visible(c.oid)
- )
- AND a.attname = '$field' ";
- $r = db_query($sql);
- $row = db_row($r['result']);
- if($row) {
- return true;
- }
- return false;
-}
-
-function _mysql_field_exists($table, $field) {
- $sql = "SHOW COLUMNS FROM $table LIKE '$field'";
- $r = db_query($sql);
- $row = db_row($r['result']);
- if($row) {
- return true;
- }
- return false;
-}
-
-$table = table_by_key('config');
-if($CONF['database_type'] == 'pgsql') {
- // check if table already exists, if so, don't recreate it
- $r = db_query("SELECT relname FROM pg_class WHERE relname = '$table'");
- if($r['rows'] == 0) {
- $pgsql = "
- CREATE TABLE $table (
- id SERIAL,
- name VARCHAR(20) NOT NULL UNIQUE,
- value VARCHAR(20) NOT NULL,
- PRIMARY KEY(id)
- )";
- db_query_parsed($pgsql);
- }
-}
-else {
- $mysql = "
- CREATE TABLE {IF_NOT_EXISTS} $table (
- `id` {AUTOINCREMENT} {PRIMARY},
- `name` VARCHAR(20) {LATIN1} NOT NULL DEFAULT '',
- `value` VARCHAR(20) {LATIN1} NOT NULL DEFAULT '',
- UNIQUE name ( `name` )
- )
- ";
- db_query_parsed($mysql, 0, " ENGINE = MYISAM COMMENT = 'PostfixAdmin settings'");
-}
-
-$sql = "SELECT * FROM $table WHERE name = 'version'";
-
-// insert into config('version', '01');
-
-$r = db_query($sql);
-
-if($r['rows'] == 1) {
- $rs = $r['result'];
- $row = db_array($rs);
- $version = $row['value'];
-} else {
- db_query_parsed("INSERT INTO $table (name, value) VALUES ('version', '0')", 0, '');
- $version = 0;
-}
-
-_do_upgrade($version);
-
-
-function _do_upgrade($current_version) {
- global $CONF;
- $target_version = preg_replace('/[^0-9]/', '', '$Revision$');
-
- if ($current_version >= $target_version) {
- # already up to date
- echo "<p>Database is up to date</p>";
- return true;
- }
-
- echo "<p>Updating database:</p><p>- old version: $current_version; target version: $target_version</p>";
-
- for ($i = $current_version +1; $i <= $target_version; $i++) {
- $function = "upgrade_$i";
- $function_mysql = $function . "_mysql";
- $function_pgsql = $function . "_pgsql";
- if (function_exists($function)) {
- echo "<p>updating to version $i (all databases)...";
- $function();
- echo " done";
- }
- if ($CONF['database_type'] == 'mysql' || $CONF['database_type'] == 'mysqli' ) {
- if (function_exists($function_mysql)) {
- echo "<p>updating to version $i (MySQL)...";
- $function_mysql();
- echo " done";
- }
- } elseif($CONF['database_type'] == 'pgsql') {
- if (function_exists($function_pgsql)) {
- echo "<p>updating to version $i (PgSQL)...";
- $function_pgsql();
- echo " done";
- }
- }
- // Update config table so we don't run the same query twice in the future.
- $i = (int) $i;
- $table = table_by_key('config');
- $sql = "UPDATE $table SET value = $i WHERE name = 'version'";
- db_query($sql);
- };
-}
-
-/**
- * Replaces database specific parts in a query
- * @param String sql query with placeholders
- * @param int (optional) whether errors should be ignored (0=false)
- * @param String (optional) MySQL specific code to attach, useful for COMMENT= on CREATE TABLE
- * @return String sql query
- */
-
-function db_query_parsed($sql, $ignore_errors = 0, $attach_mysql = "") {
- global $CONF;
-
- if ($CONF['database_type'] == 'mysql' || $CONF['database_type'] == 'mysqli' ) {
-
- $replace = array(
- '{AUTOINCREMENT}' => 'int(11) not null auto_increment',
- '{PRIMARY}' => 'primary key',
- '{UNSIGNED}' => 'unsigned' ,
- '{FULLTEXT}' => 'FULLTEXT',
- '{BOOLEAN}' => 'tinyint(1) NOT NULL',
- '{UTF-8}' => '/*!40100 CHARACTER SET utf8 */',
- '{LATIN1}' => '/*!40100 CHARACTER SET latin1 */',
- '{IF_NOT_EXISTS}' => 'IF NOT EXISTS',
- '{RENAME_COLUMN}' => 'CHANGE COLUMN',
- );
- $sql = "$sql $attach_mysql";
-
- } elseif($CONF['database_type'] == 'pgsql') {
- $replace = array(
- '{AUTOINCREMENT}' => 'SERIAL',
- '{PRIMARY}' => 'primary key',
- '{UNSIGNED}' => '',
- '{FULLTEXT}' => '',
- '{BOOLEAN}' => 'BOOLEAN NOT NULL',
- '{UTF-8}' => '', # TODO: UTF-8 is simply ignored.
- '{LATIN1}' => '', # TODO: same for latin1
- '{IF_NOT_EXISTS}' => '', # TODO: does this work with PgSQL? NO
- '{RENAME_COLUMN}' => 'ALTER COLUMN', # PgSQL : ALTER TABLE x RENAME x TO y
- 'int(1)' => 'int',
- 'int(10)' => 'int',
- 'int(11)' => 'int',
- 'int(4)' => 'int',
- );
-
- } else {
- echo "Sorry, unsupported database type " . $conf['database_type'];
- exit;
- }
-
- $replace['{BOOL_TRUE}'] = db_get_boolean(True);
- $replace['{BOOL_FALSE}'] = db_get_boolean(False);
-
- $query = trim(str_replace(array_keys($replace), $replace, $sql));
- if (safeget('debug') != "") {
- print "<p style='color:#999'>$query";
- }
- $result = db_query($query, $ignore_errors);
- if (safeget('debug') != "") {
- print "<div style='color:#f00'>" . $result['error'] . "</div>";
- }
- return $result;
-}
-
-function _drop_index ($table, $index) {
- global $CONF;
- $tabe = table_by_key ($table);
-
- if ($CONF['database_type'] == 'mysql' || $CONF['database_type'] == 'mysqli' ) {
- return "ALTER TABLE $table DROP INDEX $index";
- } elseif($CONF['database_type'] == 'pgsql') {
- return "DROP INDEX $index"; # Index names are unique with a DB for PostgreSQL
- } else {
- echo "Sorry, unsupported database type " . $conf['database_type'];
- exit;
- }
-}
-
-function _add_index($table, $indexname, $fieldlist) {
- global $CONF;
- $tabe = table_by_key ($table);
-
- if ($CONF['database_type'] == 'mysql' || $CONF['database_type'] == 'mysqli' ) {
- return "ALTER TABLE $table ADD INDEX `$indexname` ( `$fieldlist` )";
- } elseif($CONF['database_type'] == 'pgsql') {
- $pgindexname = $table . "_" . $indexname . '_idx';
- return "CREATE INDEX $pgindexname ON $table($fieldlist);"; # Index names are unique with a DB for PostgreSQL
- } else {
- echo "Sorry, unsupported database type " . $conf['database_type'];
- exit;
- }
-
-}
-
-function upgrade_1_mysql() {
- // CREATE MYSQL DATABASE TABLES.
- $admin = table_by_key('admin');
- $alias = table_by_key('alias');
- $domain = table_by_key('domain');
- $domain_admins = table_by_key('domain_admins');
- $log = table_by_key('log');
- $mailbox = table_by_key('mailbox');
- $vacation = table_by_key('vacation');
-
- $sql = array();
- $sql[] = "
- CREATE TABLE {IF_NOT_EXISTS} $admin (
- `username` varchar(255) NOT NULL default '',
- `password` varchar(255) NOT NULL default '',
- `created` datetime NOT NULL default '0000-00-00 00:00:00',
- `modified` datetime NOT NULL default '0000-00-00 00:00:00',
- `active` tinyint(1) NOT NULL default '1',
- PRIMARY KEY (`username`)
- ) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Admins';";
-
- $sql[] = "
- CREATE TABLE {IF_NOT_EXISTS} $alias (
- `address` varchar(255) NOT NULL default '',
- `goto` text NOT NULL,
- `domain` varchar(255) NOT NULL default '',
- `created` datetime NOT NULL default '0000-00-00 00:00:00',
- `modified` datetime NOT NULL default '0000-00-00 00:00:00',
- `active` tinyint(1) NOT NULL default '1',
- PRIMARY KEY (`address`)
- ) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Aliases'; ";
-
- $sql[] = "
- CREATE TABLE {IF_NOT_EXISTS} $domain (
- `domain` varchar(255) NOT NULL default '',
- `description` varchar(255) NOT NULL default '',
- `aliases` int(10) NOT NULL default '0',
- `mailboxes` int(10) NOT NULL default '0',
- `maxquota` bigint(20) NOT NULL default '0',
- `quota` bigint(20) NOT NULL default '0',
- `transport` varchar(255) default NULL,
- `backupmx` tinyint(1) NOT NULL default '0',
- `created` datetime NOT NULL default '0000-00-00 00:00:00',
- `modified` datetime NOT NULL default '0000-00-00 00:00:00',
- `active` tinyint(1) NOT NULL default '1',
- PRIMARY KEY (`domain`)
- ) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Domains'; ";
-
- $sql[] = "
- CREATE TABLE {IF_NOT_EXISTS} $domain_admins (
- `username` varchar(255) NOT NULL default '',
- `domain` varchar(255) NOT NULL default '',
- `created` datetime NOT NULL default '0000-00-00 00:00:00',
- `active` tinyint(1) NOT NULL default '1',
- KEY username (`username`)
- ) TYPE=MyISAM COMMENT='Postfix Admin - Domain Admins';";
-
- $sql[] = "
- CREATE TABLE {IF_NOT_EXISTS} $log (
- `timestamp` datetime NOT NULL default '0000-00-00 00:00:00',
- `username` varchar(255) NOT NULL default '',
- `domain` varchar(255) NOT NULL default '',
- `action` varchar(255) NOT NULL default '',
- `data` varchar(255) NOT NULL default '',
- KEY timestamp (`timestamp`)
- ) TYPE=MyISAM COMMENT='Postfix Admin - Log';";
-
- $sql[] = "
- CREATE TABLE {IF_NOT_EXISTS} $mailbox (
- `username` varchar(255) NOT NULL default '',
- `password` varchar(255) NOT NULL default '',
- `name` varchar(255) NOT NULL default '',
- `maildir` varchar(255) NOT NULL default '',
- `quota` bigint(20) NOT NULL default '0',
- `domain` varchar(255) NOT NULL default '',
- `created` datetime NOT NULL default '0000-00-00 00:00:00',
- `modified` datetime NOT NULL default '0000-00-00 00:00:00',
- `active` tinyint(1) NOT NULL default '1',
- PRIMARY KEY (`username`)
- ) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Mailboxes';";
-
- $sql[] = "
- CREATE TABLE {IF_NOT_EXISTS} $vacation (
- email varchar(255) NOT NULL ,
- subject varchar(255) NOT NULL,
- body text NOT NULL,
- cache text NOT NULL,
- domain varchar(255) NOT NULL ,
- created datetime NOT NULL default '0000-00-00 00:00:00',
- active tinyint(4) NOT NULL default '1',
- PRIMARY KEY (email),
- KEY email (email)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 TYPE=InnoDB COMMENT='Postfix Admin - Virtual Vacation' ;";
-
- foreach($sql as $query) {
- db_query_parsed($query);
- }
-}
-
-function upgrade_2_mysql() {
- # upgrade pre-2.1 database
- # from TABLE_BACKUP_MX.TXT
- $table_domain = table_by_key ('domain');
- if(!_mysql_field_exists($table_domain, 'transport')) {
- $result = db_query_parsed("ALTER TABLE $table_domain ADD COLUMN transport VARCHAR(255) AFTER maxquota;", TRUE);
- }
- if(!_mysql_field_exists($table_domain, 'backupmx')) {
- $result = db_query_parsed("ALTER TABLE $table_domain ADD COLUMN backupmx {BOOLEAN} DEFAULT {BOOL_FALSE} AFTER transport;", TRUE);
- }
-}
-
-function upgrade_2_pgsql() {
-
- if(!_pgsql_object_exists(table_by_key('domain'))) {
- db_query_parsed("
- CREATE TABLE " . table_by_key('domain') . " (
- domain character varying(255) NOT NULL,
- description character varying(255) NOT NULL default '',
- aliases integer NOT NULL default 0,
- mailboxes integer NOT NULL default 0,
- maxquota integer NOT NULL default 0,
- quota integer NOT NULL default 0,
- transport character varying(255) default NULL,
- backupmx boolean NOT NULL default false,
- created timestamp with time zone default now(),
- modified timestamp with time zone default now(),
- active boolean NOT NULL default true,
- Constraint \"domain_key\" Primary Key (\"domain\")
- );
- CREATE INDEX domain_domain_active ON " . table_by_key('domain') . "(domain,active);
- COMMENT ON TABLE " . table_by_key('domain') . " IS 'Postfix Admin - Virtual Domains';
- ");
- }
- if(!_pgsql_object_exists(table_by_key('admin'))) {
- db_query_parsed('
- CREATE TABLE ' . table_by_key("admin") . ' (
- "username" character varying(255) NOT NULL,
- "password" character varying(255) NOT NULL default \'\',
- "created" timestamp with time zone default now(),
- "modified" timestamp with time zone default now(),
- "active" boolean NOT NULL default true,
- Constraint "admin_key" Primary Key ("username")
- );' . "
- COMMENT ON TABLE " . table_by_key('admin') . " IS 'Postfix Admin - Virtual Admins';
- ");
- }
-
- if(!_pgsql_object_exists(table_by_key('alias'))) {
- db_query_parsed('
- CREATE TABLE ' . table_by_key("alias") . ' (
- address character varying(255) NOT NULL,
- goto text NOT NULL,
- domain character varying(255) NOT NULL REFERENCES "' . table_by_key("domain") . '",
- created timestamp with time zone default now(),
- modified timestamp with time zone default now(),
- active boolean NOT NULL default true,
- Constraint "alias_key" Primary Key ("address")
- );
- CREATE INDEX alias_address_active ON ' . table_by_key("alias") . '(address,active);
- COMMENT ON TABLE ' . table_by_key("alias") . ' IS \'Postfix Admin - Virtual Aliases\';
- ');
- }
-
- if(!_pgsql_object_exists(table_by_key('domain_admins'))) {
- db_query_parsed('
- CREATE TABLE ' . table_by_key('domain_admins') . ' (
- username character varying(255) NOT NULL,
- domain character varying(255) NOT NULL REFERENCES "' . table_by_key('domain') . '",
- created timestamp with time zone default now(),
- active boolean NOT NULL default true
- );
- COMMENT ON TABLE ' . table_by_key('domain_admins') . ' IS \'Postfix Admin - Domain Admins\';
- ');
- }
-
- if(!_pgsql_object_exists(table_by_key('log'))) {
- db_query_parsed('
- CREATE TABLE ' . table_by_key('log') . ' (
- timestamp timestamp with time zone default now(),
- username character varying(255) NOT NULL default \'\',
- domain character varying(255) NOT NULL default \'\',
- action character varying(255) NOT NULL default \'\',
- data text NOT NULL default \'\'
- );
- COMMENT ON TABLE ' . table_by_key('log') . ' IS \'Postfix Admin - Log\';
- ');
- }
- if(!_pgsql_object_exists(table_by_key('mailbox'))) {
- db_query_parsed('
- CREATE TABLE ' . table_by_key('mailbox') . ' (
- username character varying(255) NOT NULL,
- password character varying(255) NOT NULL default \'\',
- name character varying(255) NOT NULL default \'\',
- maildir character varying(255) NOT NULL default \'\',
- quota integer NOT NULL default 0,
- domain character varying(255) NOT NULL REFERENCES "' . table_by_key('domain') . '",
- created timestamp with time zone default now(),
- modified timestamp with time zone default now(),
- active boolean NOT NULL default true,
- Constraint "mailbox_key" Primary Key ("username")
- );
- CREATE INDEX mailbox_username_active ON ' . table_by_key('mailbox') . '(username,active);
- COMMENT ON TABLE ' . table_by_key('mailbox') . ' IS \'Postfix Admin - Virtual Mailboxes\';
- ');
- }
-
- if(!_pgsql_object_exists(table_by_key('vacation'))) {
- db_query_parsed('
- CREATE TABLE ' . table_by_key('vacation') . ' (
- email character varying(255) PRIMARY KEY,
- subject character varying(255) NOT NULL,
- body text NOT NULL ,
- cache text NOT NULL ,
- "domain" character varying(255) NOT NULL REFERENCES "' . table_by_key('domain') . '",
- created timestamp with time zone DEFAULT now(),
- active boolean DEFAULT true NOT NULL
- );
- CREATE INDEX vacation_email_active ON ' . table_by_key('vacation') . '(email,active);');
- }
-
- if(!_pgsql_object_exists(table_by_key('vacation_notification'))) {
- db_query_parsed('
- CREATE TABLE ' . table_by_key('vacation_notification') . ' (
- on_vacation character varying(255) NOT NULL REFERENCES ' . table_by_key('vacation') . '(email) ON DELETE CASCADE,
- notified character varying(255) NOT NULL,
- notified_at timestamp with time zone NOT NULL DEFAULT now(),
- CONSTRAINT vacation_notification_pkey primary key(on_vacation,notified)
- );
- ');
- }
-
- // this handles anyone who is upgrading... (and should have no impact on new installees)
- $table_domain = table_by_key ('domain');
- $result = db_query_parsed("ALTER TABLE $table_domain ADD COLUMN transport VARCHAR(255)", TRUE);
- $result = db_query_parsed("ALTER TABLE $table_domain ADD COLUMN backupmx BOOLEAN DEFAULT false", TRUE);
-}
-
-function upgrade_3_mysql() {
- # upgrade pre-2.1 database
- # from TABLE_CHANGES.TXT
- $table_admin = table_by_key ('admin');
- $table_alias = table_by_key ('alias');
- $table_domain = table_by_key ('domain');
- $table_mailbox = table_by_key ('mailbox');
- $table_vacation = table_by_key ('vacation');
-
- if(!_mysql_field_exists($table_admin, 'created')) {
- db_query_parsed("ALTER TABLE $table_admin {RENAME_COLUMN} create_date created DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL;");
- }
- if(!_mysql_field_exists($table_admin, 'modified')) {
- db_query_parsed("ALTER TABLE $table_admin {RENAME_COLUMN} change_date modified DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL;");
- }
- if(!_mysql_field_exists($table_alias, 'created')) {
- db_query_parsed("ALTER TABLE $table_alias {RENAME_COLUMN} create_date created DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL;");
- }
- if(!_mysql_field_exists($table_alias, 'modified')) {
- db_query_parsed("ALTER TABLE $table_alias {RENAME_COLUMN} change_date modified DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL;");
- }
- if(!_mysql_field_exists($table_domain, 'created')) {
- db_query_parsed("ALTER TABLE $table_domain {RENAME_COLUMN} create_date created DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL;");
- }
- if(!_mysql_field_exists($table_domain, 'modified')) {
- db_query_parsed("ALTER TABLE $table_domain {RENAME_COLUMN} change_date modified DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL;");
- }
- if(!_mysql_field_exists($table_domain, 'aliases')) {
- db_query_parsed("ALTER TABLE $table_domain ADD COLUMN aliases INT(10) DEFAULT '-1' NOT NULL AFTER description;");
- }
- if(!_mysql_field_exists($table_domain, 'mailboxes')) {
- db_query_parsed("ALTER TABLE $table_domain ADD COLUMN mailboxes INT(10) DEFAULT '-1' NOT NULL AFTER aliases;");
- }
- if(!_mysql_field_exists($table_domain, 'maxquota')) {
- db_query_parsed("ALTER TABLE $table_domain ADD COLUMN maxquota INT(10) DEFAULT '-1' NOT NULL AFTER mailboxes;");
- }
- if(!_mysql_field_exists($table_domain, 'transport')) {
- db_query_parsed("ALTER TABLE $table_domain ADD COLUMN transport VARCHAR(255) AFTER maxquota;");
- }
- if(!_mysql_field_exists($table_domain, 'backupmx')) {
- db_query_parsed("ALTER TABLE $table_domain ADD COLUMN backupmx TINYINT(1) DEFAULT '0' NOT NULL AFTER transport;");
- }
- if(!_mysql_field_exists($table_mailbox, 'created')) {
- db_query_parsed("ALTER TABLE $table_mailbox {RENAME_COLUMN} create_date created DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL;");
- }
- if(!_mysql_field_exists($table_mailbox, 'modified')) {
- db_query_parsed("ALTER TABLE $table_mailbox {RENAME_COLUMN} change_date modified DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL;");
- }
- if(!_mysql_field_exists($table_mailbox, 'quota')) {
- db_query_parsed("ALTER TABLE $table_mailbox ADD COLUMN quota INT(10) DEFAULT '-1' NOT NULL AFTER maildir;");
- }
- if(!_mysql_field_exists($table_vacation, 'domain')) {
- db_query_parsed("ALTER TABLE $table_vacation ADD COLUMN domain VARCHAR(255) DEFAULT '' NOT NULL AFTER cache;");
- }
- if(!_mysql_field_exists($table_vacation, 'created')) {
- db_query_parsed("ALTER TABLE $table_vacation ADD COLUMN created DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL AFTER domain;");
- }
- if(!_mysql_field_exists($table_vacation, 'active')) {
- db_query_parsed("ALTER TABLE $table_vacation ADD COLUMN active TINYINT(1) DEFAULT '1' NOT NULL AFTER created;");
- }
- db_query_parsed("ALTER TABLE $table_vacation DROP PRIMARY KEY");
- db_query_parsed("ALTER TABLE $table_vacation ADD PRIMARY KEY(email)");
- db_query_parsed("UPDATE $table_vacation SET domain=SUBSTRING_INDEX(email, '@', -1) WHERE email=email;");
-}
-
-function upgrade_4_mysql() { # MySQL only
- # changes between 2.1 and moving to sourceforge
- $table_domain = table_by_key ('domain');
- $result = db_query_parsed("ALTER TABLE $table_domain ADD COLUMN quota int(10) NOT NULL default '0' AFTER maxquota", TRUE);
- # Possible errors that can be ignored:
- # - Invalid query: Table 'postfix.domain' doesn't exist
-}
-
-/**
- * Changes between 2.1 and moving to sf.net
- */
-function upgrade_4_pgsql() {
- $table_domain = table_by_key('domain');
- $table_admin = table_by_key('admin');
- $table_alias = table_by_key('alias');
- $table_domain_admins = table_by_key('domain_admins');
- $table_log = table_by_key('log');
- $table_mailbox = table_by_key('mailbox');
- $table_vacation = table_by_key('vacation');
- $table_vacation_notification = table_by_key('vacation_notification');
-
- if(!_pgsql_field_exists($table_domain, 'quota')) {
- $result = db_query_parsed("ALTER TABLE $table_domain ADD COLUMN quota int NOT NULL default '0'");
- }
-
- $result = db_query_parsed("ALTER TABLE $table_domain ALTER COLUMN domain DROP DEFAULT");
- if(!_pgsql_object_exists('domain_domain_active')) {
- $result = db_query_parsed("CREATE INDEX domain_domain_active ON $table_domain(domain,active)");
- }
-
- $result = db_query_parsed("ALTER TABLE $table_domain_admins ALTER COLUMN domain DROP DEFAULT");
- $result = db_query_parsed("ALTER TABLE $table_alias ALTER COLUMN address DROP DEFAULT");
- $result = db_query_parsed("ALTER TABLE $table_alias ALTER COLUMN domain DROP DEFAULT");
- if(!_pgsql_object_exists('alias_address_active')) {
- $result = db_query_parsed("CREATE INDEX alias_address_active ON $table_alias(address,active)");
- }
-
- $result = db_query_parsed("ALTER TABLE $table_domain_admins ALTER COLUMN username DROP DEFAULT");
- $result = db_query_parsed("ALTER TABLE $table_domain_admins ALTER COLUMN domain DROP DEFAULT");
-
- $result = db_query_parsed("
- BEGIN;
- ALTER TABLE $table_log RENAME COLUMN data TO data_old;
- ALTER TABLE $table_log ADD COLUMN data text NOT NULL default '';
- UPDATE $table_log SET data = CAST(data_old AS text);
- ALTER TABLE $table_log DROP COLUMN data_old;
- COMMIT;");
-
- $result = db_query_parsed("ALTER TABLE $table_mailbox ALTER COLUMN username DROP DEFAULT");
- $result = db_query_parsed("ALTER TABLE $table_mailbox ALTER COLUMN domain DROP DEFAULT");
-
- $result = db_query_parsed("
- BEGIN;
- ALTER TABLE $table_mailbox RENAME COLUMN domain TO domain_old;
- ALTER TABLE $table_mailbox ADD COLUMN domain varchar(255) REFERENCES $table_domain (domain);
- UPDATE $table_mailbox SET domain = domain_old;
- ALTER TABLE $table_mailbox DROP COLUMN domain_old;
- COMMIT;"
- );
- if(!_pgsql_object_exists('mailbox_username_active')) {
- db_query_parsed('CREATE INDEX mailbox_username_active ON $table_mailbox(username,active)');
- }
-
-
- $result = db_query_parsed("ALTER TABLE $table_vacation ALTER COLUMN body SET DEFAULT ''");
- if(_pgsql_field_exists($table_vacation, 'cache')) {
- $result = db_query_parsed("ALTER TABLE $table_vacation DROP COLUMN cache");
- }
-
- $result = db_query_parsed("
- BEGIN;
- ALTER TABLE $table_vacation RENAME COLUMN domain to domain_old;
- ALTER TABLE $table_vacation ADD COLUMN domain varchar(255) REFERENCES $table_domain;
- UPDATE $table_vacation SET domain = domain_old;
- ALTER TABLE $table_vacation DROP COLUMN domain_old;
- COMMIT;
- ");
-
- if(!_pgsql_object_exists('vacation_email_active')) {
- $result = db_query_parsed("CREATE INDEX vacation_email_active ON $table_vacation(email,active)");
- }
-
- if(!_pgsql_object_exists($table_vacation_notification)) {
- $result = db_query_parsed("
- CREATE TABLE $table_vacation_notification (
- on_vacation character varying(255) NOT NULL REFERENCES $table_vacation(email) ON DELETE CASCADE,
- notified character varying(255) NOT NULL,
- notified_at timestamp with time zone NOT NULL DEFAULT now(),
- CONSTRAINT vacation_notification_pkey primary key(on_vacation,notified));");
- }
-}
-
-
-# Possible errors that can be ignored:
-#
-# NO MySQL errors should be ignored below this line!
-
-
-
-/**
- * create tables
- * version: Sourceforge SVN r1 of DATABASE_MYSQL.txt
- * changes compared to DATABASE_MYSQL.txt:
- * - removed MySQL user and database creation
- * - removed creation of default superadmin
- */
-function upgrade_5_mysql() {
-
- $result = db_query_parsed("
- CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('admin') . "` (
- `username` varchar(255) NOT NULL default '',
- `password` varchar(255) NOT NULL default '',
- `created` datetime NOT NULL default '0000-00-00 00:00:00',
- `modified` datetime NOT NULL default '0000-00-00 00:00:00',
- `active` tinyint(1) NOT NULL default '1',
- PRIMARY KEY (`username`),
- KEY username (`username`)
-) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Virtual Admins'; ");
-
- $result = db_query_parsed("
- CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('alias') . "` (
- `address` varchar(255) NOT NULL default '',
- `goto` text NOT NULL,
- `domain` varchar(255) NOT NULL default '',
- `created` datetime NOT NULL default '0000-00-00 00:00:00',
- `modified` datetime NOT NULL default '0000-00-00 00:00:00',
- `active` tinyint(1) NOT NULL default '1',
- PRIMARY KEY (`address`),
- KEY address (`address`)
- ) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Virtual Aliases';
- ");
-
- $result = db_query_parsed("
- CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('domain') . "` (
- `domain` varchar(255) NOT NULL default '',
- `description` varchar(255) NOT NULL default '',
- `aliases` int(10) NOT NULL default '0',
- `mailboxes` int(10) NOT NULL default '0',
- `maxquota` int(10) NOT NULL default '0',
- `quota` int(10) NOT NULL default '0',
- `transport` varchar(255) default NULL,
- `backupmx` tinyint(1) NOT NULL default '0',
- `created` datetime NOT NULL default '0000-00-00 00:00:00',
- `modified` datetime NOT NULL default '0000-00-00 00:00:00',
- `active` tinyint(1) NOT NULL default '1',
- PRIMARY KEY (`domain`),
- KEY domain (`domain`)
- ) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Virtual Domains';
- ");
-
- $result = db_query_parsed("
- CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('domain_admins') . "` (
- `username` varchar(255) NOT NULL default '',
- `domain` varchar(255) NOT NULL default '',
- `created` datetime NOT NULL default '0000-00-00 00:00:00',
- `active` tinyint(1) NOT NULL default '1',
- KEY username (`username`)
- ) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Domain Admins';
- ");
-
- $result = db_query_parsed("
- CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('log') . "` (
- `timestamp` datetime NOT NULL default '0000-00-00 00:00:00',
- `username` varchar(255) NOT NULL default '',
- `domain` varchar(255) NOT NULL default '',
- `action` varchar(255) NOT NULL default '',
- `data` varchar(255) NOT NULL default '',
- KEY timestamp (`timestamp`)
- ) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Log';
- ");
-
- $result = db_query_parsed("
- CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('mailbox') . "` (
- `username` varchar(255) NOT NULL default '',
- `password` varchar(255) NOT NULL default '',
- `name` varchar(255) NOT NULL default '',
- `maildir` varchar(255) NOT NULL default '',
- `quota` int(10) NOT NULL default '0',
- `domain` varchar(255) NOT NULL default '',
- `created` datetime NOT NULL default '0000-00-00 00:00:00',
- `modified` datetime NOT NULL default '0000-00-00 00:00:00',
- `active` tinyint(1) NOT NULL default '1',
- PRIMARY KEY (`username`),
- KEY username (`username`)
- ) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Virtual Mailboxes';
- ");
-
- $result = db_query_parsed("
- CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('vacation') . "` (
- `email` varchar(255) NOT NULL ,
- `subject` varchar(255) NOT NULL,
- `body` text NOT NULL,
- `cache` text NOT NULL,
- `domain` varchar(255) NOT NULL,
- `created` datetime NOT NULL default '0000-00-00 00:00:00',
- `active` tinyint(1) NOT NULL default '1',
- PRIMARY KEY (`email`),
- KEY email (`email`)
- ) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Virtual Vacation';
- ");
-}
-
-/**
- * drop useless indicies (already available as primary key)
- */
-function upgrade_79_mysql() { # MySQL only
- $result = db_query_parsed(_drop_index('admin', 'username'), True);
- $result = db_query_parsed(_drop_index('alias', 'address'), True);
- $result = db_query_parsed(_drop_index('domain', 'domain'), True);
- $result = db_query_parsed(_drop_index('mailbox', 'username'), True);
-}
-
-function upgrade_81_mysql() { # MySQL only
- $table_vacation = table_by_key ('vacation');
- $table_vacation_notification = table_by_key('vacation_notification');
-
- $all_sql = split("\n", trim("
- ALTER TABLE `$table_vacation` CHANGE `email` `email` VARCHAR( 255 ) {LATIN1} NOT NULL
- ALTER TABLE `$table_vacation` CHANGE `subject` `subject` VARCHAR( 255 ) {UTF-8} NOT NULL
- ALTER TABLE `$table_vacation` CHANGE `body` `body` TEXT {UTF-8} NOT NULL
- ALTER TABLE `$table_vacation` CHANGE `cache` `cache` TEXT {LATIN1} NOT NULL
- ALTER TABLE `$table_vacation` CHANGE `domain` `domain` VARCHAR( 255 ) {LATIN1} NOT NULL
- ALTER TABLE `$table_vacation` CHANGE `active` `active` TINYINT( 1 ) NOT NULL DEFAULT '1'
- ALTER TABLE `$table_vacation` DEFAULT {LATIN1}
- ALTER TABLE `$table_vacation` ENGINE = INNODB
- "));
-
- foreach ($all_sql as $sql) {
- $result = db_query_parsed($sql, TRUE);
- }
-
-}
-
-/**
- * Make logging translatable - i.e. create alias => create_alias
- */
-function upgrade_90() {
- $result = db_query_parsed("UPDATE " . table_by_key ('log') . " SET action = REPLACE(action,' ','_')", TRUE);
- # change edit_alias_state to edit_alias_active
- $result = db_query_parsed("UPDATE " . table_by_key ('log') . " SET action = 'edit_alias_state' WHERE action = 'edit_alias_active'", TRUE);
-}
-
-/**
- * MySQL only allow quota > 2 GB
- */
-function upgrade_169_mysql() {
-
- $table_domain = table_by_key ('domain');
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|