From d7cca670cbcc32b08dbd2c89b5c7ba092d005e13 Mon Sep 17 00:00:00 2001 From: Greg Date: Wed, 20 Jun 2007 01:48:44 +0000 Subject: [PATCH] patches by Christian Boltz applied git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@3 a1433add-5e2c-0410-b055-b7f2511e0802 --- CHANGELOG.TXT | 4 ++++ VIRTUAL_VACATION/vacation.pl | 35 +++++++++++++++++++++++--------- admin/create-domain.php | 2 +- admin/list-virtual.php | 4 ++-- functions.inc.php | 16 ++++++++++++--- languages/de.lang | 16 +++++++-------- stylesheet.css | 5 +++++ templates/admin_list-domain.tpl | 1 + templates/admin_list-virtual.tpl | 6 ++++++ templates/header.tpl | 11 +++++----- templates/login.tpl | 6 ++++++ templates/overview.tpl | 6 ++++++ 12 files changed, 83 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 1f9492b0..35aa5f56 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -6,6 +6,10 @@ # Version 2.1.1 -- TBD -------------------- + - Fixed: function check_email will ignore vacation_domain if vacation==YES (GregC) + - Changed: applied patches from Christian Boltz posted at + http://www.cboltz.de/tmp/postfixadmin-3.patch, referenced at + https://sourceforge.net/tracker/index.php?func=detail&aid=1696647&group_id=191583&atid=937966 (GregC) - Added: main.php to admin dirctory (GregC) - Added: Item "Main" on admin menu (GregC) - Changed: Edit-vacation now edits for admins/superadmins (GregC) diff --git a/VIRTUAL_VACATION/vacation.pl b/VIRTUAL_VACATION/vacation.pl index 241c45b1..f94545a0 100644 --- a/VIRTUAL_VACATION/vacation.pl +++ b/VIRTUAL_VACATION/vacation.pl @@ -26,15 +26,30 @@ use DBI; use strict; use Sys::Syslog; -my $db_type = 'mysql'; -my $db_host = 'localhost'; -my $db_user = 'postfixadmin'; -my $db_pass = 'postfixadmin'; -my $db_name = 'postfix'; -my $sendmail = "/usr/sbin/sendmail"; -my $logfile = ""; # specify a file name here for example: vacation.log -my $debugfile = ""; # sepcify a file name here for example: vacation.debug -my $syslog = 0; # 1 if log entries should be sent to syslog +# values that will be set in /etc/mail/vacation/vacationrc: +our $db_type; +our $db_host; +our $db_user; +our $db_pass; +our $db_name; +our $sendmail; +our $logfile; +our $debugfile; +our $syslog; +our $logger; + +require "/etc/mail/vacation/vacationrc"; +# example config file: +# $db_type = 'mysql'; +# $db_host = 'localhost'; +# $db_user = 'postfixadmin'; +# $db_pass = 'postfixadmin'; +# $db_name = 'postfix'; +# $sendmail = "/usr/sbin/sendmail"; +# $logfile = ""; # specify a file name here for example: vacation.log +# $debugfile = ""; # sepcify a file name here for example: vacation.debug +# $syslog = 0; # 1 if log entries should be sent to syslog +# $logger = "/usr/bin/logger"; my $dbh = DBI->connect("DBI:$db_type:$db_name:$db_host", "$db_user", "$db_pass", { RaiseError => 1 }) or &exit_error($DBI::errstr); @@ -83,7 +98,7 @@ sub do_log { my ($messageid, $to, $from, $subject) = @_; my $date; if ( $syslog ) { - open (SYSLOG, "|/usr/bin/logger -p mail.info -t Vacation") or die ("Unable to open logger"); + open (SYSLOG, "|$logger -p mail.info -t Vacation") or die ("Unable to open logger"); printf SYSLOG "Orig-To: %s From: %s MessageID: %s Subject: %s", $to, $from, $messageid, $subject; close (SYSLOG); } diff --git a/admin/create-domain.php b/admin/create-domain.php index 7eae1c26..db3b82d5 100644 --- a/admin/create-domain.php +++ b/admin/create-domain.php @@ -52,7 +52,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") if ($_SERVER['REQUEST_METHOD'] == "POST") { if (isset ($_POST['fDomain'])) $fDomain = escape_string ($_POST['fDomain']); - !empty ($_POST['fDescription']) ? $fDescription = escape_string ($_POST['fDescription']) : $fDescription = "No Description"; + !empty ($_POST['fDescription']) ? $fDescription = escape_string ($_POST['fDescription']) : $fDescription = ""; if (isset ($_POST['fAliases'])) $fAliases = escape_string ($_POST['fAliases']); if (isset ($_POST['fMailboxes'])) $fMailboxes = escape_string ($_POST['fMailboxes']); !empty ($_POST['fMaxquota']) ? $fMaxquota = escape_string ($_POST['fMaxquota']) : $fMaxquota = "0"; diff --git a/admin/list-virtual.php b/admin/list-virtual.php index 49d465ea..d1fc005d 100644 --- a/admin/list-virtual.php +++ b/admin/list-virtual.php @@ -138,10 +138,10 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") if ($CONF['alias_control'] == "YES") { - $query = "SELECT address,goto,modified,active FROM alias WHERE domain='$fDomain' ORDER BY address LIMIT $fDisplay, $page_size"; + $query = "SELECT address,goto,modified,active FROM $table_alias WHERE domain='$fDomain' ORDER BY address LIMIT $fDisplay, $page_size"; if ('pgsql'==$CONF['database_type']) { - $query = "SELECT address,goto,extract(epoch from modified) as modified,active FROM alias WHERE domain='$fDomain' ORDER BY alias.address LIMIT $page_size OFFSET $fDisplay"; + $query = "SELECT address,goto,extract(epoch from modified) as modified,active FROM $table_alias WHERE domain='$fDomain' ORDER BY $table_alias.address LIMIT $page_size OFFSET $fDisplay"; } } else diff --git a/functions.inc.php b/functions.inc.php index a93d9f7e..514bc864 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -144,20 +144,30 @@ function check_email ($email) { global $CONF; + $ce_email=$email; + + //strip the vacation domain out if we are using it + if ($CONF['vacation'] == 'YES') + { + $vacation_domain = $CONF['vacation_domain']; + $ce_email = preg_replace("/@$vacation_domain/", '', $ce_email); + } + if ( isset($CONF['emailcheck_resolve_domain']) && 'YES'==$CONF['emailcheck_resolve_domain'] && 'WINDOWS'!=(strtoupper(substr(php_uname('s'), 0, 7))) ) { + // Perform non-domain-part sanity checks - if (!preg_match ('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_{|}~]+' . '@' . '[^@]+$/i', trim ($email))) + if (!preg_match ('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_{|}~]+' . '@' . '[^@]+$/i', trim ($ce_email))) { return false; } // Determine domain name $matches=array(); - if (!preg_match('|@(.+)$|',$email,$matches)) + if (!preg_match('|@(.+)$|',$ce_email,$matches)) { return false; } @@ -177,7 +187,7 @@ function check_email ($email) return false; } - if (preg_match ('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_{|}~]+' . '@' . '([-0-9A-Z]+\.)+' . '([0-9A-Z]){2,4}$/i', trim ($email))) + if (preg_match ('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_{|}~]+' . '@' . '([-0-9A-Z]+\.)+' . '([0-9A-Z]){2,4}$/i', trim ($ce_email))) { return true; } diff --git a/languages/de.lang b/languages/de.lang index 709100bd..3116beb4 100644 --- a/languages/de.lang +++ b/languages/de.lang @@ -289,14 +289,14 @@ $PALANG['pUsersVacation_button_back'] = 'Ich bin zurück'; $PALANG['pUsersVacation_result_error'] = 'Konnte Ihre Automatische Antwort nicht einstellen!'; $PALANG['pUsersVacation_result_succes'] = 'Ihre Automatische Antwort wurde gelöscht!'; -$PALANG['pCreate_dbLog_createmailbox'] = 'create mailbox'; -$PALANG['pCreate_dbLog_createalias'] = 'create alias'; -$PALANG['pDelete_dbLog_deletealias'] = 'delete alias'; -$PALANG['pDelete_dbLog_deletemailbox'] = 'delete mailbox'; +$PALANG['pCreate_dbLog_createmailbox'] = 'Mailbox hinzufügen'; +$PALANG['pCreate_dbLog_createalias'] = 'Alias hinzufügen'; +$PALANG['pDelete_dbLog_deletealias'] = 'Alias löschen'; +$PALANG['pDelete_dbLog_deletemailbox'] = 'Mailbox löschen'; -$PALANG['pEdit_dbLog_editactive'] = 'change active state'; -$PALANG['pEdit_dbLog_editalias'] = 'edit alias'; -$PALANG['pEdit_dbLog_editmailbox'] = 'edit mailbox'; +$PALANG['pEdit_dbLog_editactive'] = 'Aktiv-Status ändern'; +$PALANG['pEdit_dbLog_editalias'] = 'Alias bearbeiten'; +$PALANG['pEdit_dbLog_editmailbox'] = 'Mailbox bearbeiten'; -$PALANG['pSearch_welcome'] = 'Searching for: '; +$PALANG['pSearch_welcome'] = 'Suche nach: '; ?> diff --git a/stylesheet.css b/stylesheet.css index 96a64007..31d1275d 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -213,6 +213,11 @@ table { background: #D9FF43; /*#D6FF85;*/ /*#ffdddd;*/ } +#alias_table tr:hover, #mailbox_table tr:hover, #overview_table tr:hover, #log_table tr:hover, #admin_table tr:hover { + background: #D9FF43; /*#D6FF85;*/ /*#ffdddd;*/ +} + + #alias_table h3, #mailbox_table h3, #overview_table h3, #log_table h3, #admin_table h3 { background: silver; text-align: left; diff --git a/templates/admin_list-domain.tpl b/templates/admin_list-domain.tpl index 41972bee..cc77044b 100644 --- a/templates/admin_list-domain.tpl +++ b/templates/admin_list-domain.tpl @@ -82,4 +82,5 @@ if (sizeof ($list_domains) > 0) print "\n"; } +echo "

{$PALANG['pAdminMenu_create_domain']}"; ?> diff --git a/templates/admin_list-virtual.tpl b/templates/admin_list-virtual.tpl index 7b0d3468..32e2d6f9 100644 --- a/templates/admin_list-virtual.tpl +++ b/templates/admin_list-virtual.tpl @@ -62,7 +62,11 @@ if (sizeof ($tAlias) > 0) { print " \n"; print " " . $tAlias[$i]['address'] . "\n"; + if ($CONF['alias_goto_limit'] > 0) { print " " . ereg_replace (",", "
", preg_replace('/^(([^,]+,){'.$CONF['alias_goto_limit'].'})[^,]+,.*/','$1[and '. (substr_count ($tAlias[$i]['goto'], ',') - $CONF['alias_goto_limit'] + 1) .' more...]',$tAlias[$i]['goto'])) . "\n"; + } else { + print " " . ereg_replace (",", "
", $tAlias[$i]['goto']) . "\n"; + } print " " . $tAlias[$i]['modified'] . "\n"; $active = ($tAlias[$i]['active'] == 1) ? $PALANG['YES'] : $PALANG['NO']; print " " . $active . "\n"; @@ -73,6 +77,7 @@ if (sizeof ($tAlias) > 0) } print "\n"; } + print "

" . $PALANG['pMenu_create_alias'] . "\n"; if (sizeof ($tMailbox) > 0) { @@ -141,5 +146,6 @@ if (sizeof ($tMailbox) > 0) } print "\n"; } + print "

" . $PALANG['pMenu_create_mailbox'] . "\n"; /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> diff --git a/templates/header.tpl b/templates/header.tpl index 606e927e..c8b01a78 100644 --- a/templates/header.tpl +++ b/templates/header.tpl @@ -11,8 +11,11 @@ \n"; -if (file_exists (realpath ("../stylesheet.css"))) print "\n"; +if (file_exists (realpath ("./stylesheet.css"))) { + print "\n"; +} elseif (file_exists (realpath ("../stylesheet.css"))) { + print "\n"; +} ?> Postfix Admin - <?php print $_SERVER['HTTP_HOST']; ?> @@ -23,9 +26,7 @@ if (file_exists (realpath ("./stylesheet.css"))) { print "\n"; print "\n"; -} - -if (file_exists (realpath ("../stylesheet.css"))) +} elseif (file_exists (realpath ("../stylesheet.css"))) { print "\n"; print "\n"; diff --git a/templates/login.tpl b/templates/login.tpl index 6f58bf10..6a7a1991 100644 --- a/templates/login.tpl +++ b/templates/login.tpl @@ -23,4 +23,10 @@ + + + diff --git a/templates/overview.tpl b/templates/overview.tpl index 8075c63e..21107caa 100644 --- a/templates/overview.tpl +++ b/templates/overview.tpl @@ -60,7 +60,11 @@ if (sizeof ($tAlias) > 0) { print " \n"; print " " . $tAlias[$i]['address'] . "\n"; + if ($CONF['alias_goto_limit'] > 0) { print " " . ereg_replace (",", "
", preg_replace('/^(([^,]+,){'.$CONF['alias_goto_limit'].'})[^,]+,.*/','$1[and '. (substr_count ($tAlias[$i]['goto'], ',') - $CONF['alias_goto_limit'] + 1) .' more...]',$tAlias[$i]['goto'])) . "\n"; + } else { + print " " . ereg_replace (",", "
", $tAlias[$i]['goto']) . "\n"; + } print " " . $tAlias[$i]['modified'] . "\n"; if ($CONF['special_alias_control'] == 'YES') @@ -94,6 +98,7 @@ if (sizeof ($tAlias) > 0) print "\n"; } + print "

" . $PALANG['pMenu_create_alias'] . "\n"; if (sizeof ($tMailbox) > 0) { @@ -156,5 +161,6 @@ if (sizeof ($tMailbox) > 0) } print "\n"; } + print "

" . $PALANG['pMenu_create_mailbox'] . "\n"; /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?>