diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 52f59243..42f5d30c 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -10,8 +10,8 @@ # Last update: # $Id$ -Version 2.3 - 2009/10/24 - SVN r739 ------------------------------------ +Version ***svn*** - 2009/10/24 - SVN r***** +-------------------------------------- - automatically create quota tables for dovecot (both 1.0/1.1 and >= 1.2) - list-virtual can now handle both table formats diff --git a/INSTALL.TXT b/INSTALL.TXT index 2f65e223..49b3c2a8 100644 --- a/INSTALL.TXT +++ b/INSTALL.TXT @@ -9,7 +9,7 @@ REQUIRED!! ---------- - You are using Postfix 2.0 or higher. - You are using Apache 1.3.27 / Lighttpd 1.3.15 or higher. -- You are using PHP 5.1.2 or higher. +- You are using PHP 5.X - You are using MySQL 3.23 or higher (5.x recommended) OR PostgreSQL 7.4 (or higher) diff --git a/VIRTUAL_VACATION/vacation.pl b/VIRTUAL_VACATION/vacation.pl index 9f0f34f0..5323827f 100644 --- a/VIRTUAL_VACATION/vacation.pl +++ b/VIRTUAL_VACATION/vacation.pl @@ -56,13 +56,16 @@ # Use Log4Perl # Added better testing (and -t option) # -# 2009-06-29 Stevan Bajic +# 2009-06-29 Stevan Bajic # Add Mail::Sender for SMTP auth + more flexibility # -# 2009-07-07 Stevan Bajic +# 2009-07-07 Stevan Bajic # Add better alias lookups # Check for more heades from Anti-Virus/Anti-Spam solutions # +# 2009-08-10 Sebastian +# 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::Sender, Email::Valid MIME::Charset, Log::Log4perl, Log::Dispatch, MIME::EncWords and GetOpt::Std @@ -316,24 +319,25 @@ sub find_real_address { 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; # Recipient has vacation - if ($rv == 1) { - $realemail = $email; - $logger->debug("Found '\$email'\ has vacation active"); - } else { - my $vemail = $email; - $vemail =~ s/\@/#/g; - $vemail = $vemail . "\@" . $vacation_domain; - $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 ? OR goto = ?)}; - $stm = $dbh->prepare($query) or panic_prepare($query); - $stm->execute($email,"$vemail,%","%,$vemail","%,$vemail,%", "$vemail") or panic_execute($query,"address='$email'"); - $rv = $stm->rows; + if ($rv == 1) { + $realemail = $email; + $logger->debug("Found '\$email'\ has vacation active"); + } else { + my $vemail = $email; + $vemail =~ s/\@/#/g; + $vemail = $vemail . "\@" . $vacation_domain; + $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 ? OR goto = ?)}; + $stm = $dbh->prepare($query) or panic_prepare($query); + $stm->execute($email,"$vemail,%","%,$vemail","%,$vemail,%", "$vemail") or panic_execute($query,"address='$email'"); + $rv = $stm->rows; + # Recipient is an alias, check if mailbox has vacation if ($rv == 1) { diff --git a/backup.php b/backup.php index 6a9021ca..5f6a542f 100644 --- a/backup.php +++ b/backup.php @@ -30,7 +30,11 @@ authentication_require_role('global-admin'); // TODO: make backup supported for postgres if ('pgsql'==$CONF['database_type']) { - print '

Sorry: Backup is currently not supported for your DBMS.

'; + $smarty->assign ('tMessage', '

Sorry: Backup is currently not supported for your DBMS ('.$CONF['database_type'].').

'); + $smarty->assign ('smarty_template', 'message'); + $smarty->display ('index.tpl'); +// print '

Sorry: Backup is currently not supported for your DBMS.

'; +die; } /* SELECT attnum,attname,typname,atttypmod-4,attnotnull,atthasdef,adsrc @@ -63,10 +67,10 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") if (!$fh = fopen ($backup, 'w')) { $tMessage = "
Cannot open file ($backup)
"; - include ("templates/header.php"); - include ("templates/menu.php"); - include ("templates/message.php"); - include ("templates/footer.php"); + $smarty->assign ('tMessage', $tMessage); + $smarty->assign ('smarty_template', 'message'); + $smarty->display ('index.tpl'); +// include ("templates/message.php"); } else { @@ -82,8 +86,8 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") 'fetchmail', 'log', 'mailbox', - 'quota', - 'quota2', + 'quota', + 'quota2', 'vacation', 'vacation_notification' ); diff --git a/broadcast-message.php b/broadcast-message.php index e4d298fd..882ef7d4 100644 --- a/broadcast-message.php +++ b/broadcast-message.php @@ -31,69 +31,70 @@ require_once('common.php'); authentication_require_role('global-admin'); if ($CONF['sendmail'] != 'YES') { - header("Location: " . $CONF['postfix_admin_url'] . "/main.php"); - exit; + header("Location: " . $CONF['postfix_admin_url'] . "/main.php"); + exit; } $SESSID_USERNAME = authentication_get_username(); if ($_SERVER['REQUEST_METHOD'] == "POST") { - if (empty($_POST['subject']) || empty($_POST['message']) || empty($_POST['name'])) - { - $error = 1; - } - else - { - $table_mailbox = table_by_key('mailbox'); - $table_alias = table_by_key('alias'); + if (empty($_POST['subject']) || empty($_POST['message']) || empty($_POST['name'])) + { + $error = 1; + } + else + { + $table_mailbox = table_by_key('mailbox'); + $table_alias = table_by_key('alias'); + + $q = "select username from $table_mailbox union select goto from $table_alias " . + "where goto not in (select username from $table_mailbox)"; - $q = "select username from $table_mailbox union select goto from $table_alias " . - "where goto not in (select username from $table_mailbox)"; + $result = db_query ($q); + if ($result['rows'] > 0) + { + mb_internal_encoding("UTF-8"); + $b_name = mb_encode_mimeheader( $_POST['name'], 'UTF-8', 'Q'); + $b_subject = mb_encode_mimeheader( $_POST['subject'], 'UTF-8', 'Q'); + $b_message = base64_encode($_POST['message']); - $result = db_query ($q); - if ($result['rows'] > 0) - { - mb_internal_encoding("UTF-8"); - $b_name = mb_encode_mimeheader( $_POST['name'], 'UTF-8', 'Q'); - $b_subject = mb_encode_mimeheader( $_POST['subject'], 'UTF-8', 'Q'); - $b_message = base64_encode($_POST['message']); + $i = 0; + while ($row = db_array ($result['result'])) { + $fTo = $row[0]; + $fHeaders = 'To: ' . $fTo . "\n"; + $fHeaders .= 'From: ' . $b_name . ' <' . $CONF['admin_email'] . ">\n"; + $fHeaders .= 'Subject: ' . $b_subject . "\n"; + $fHeaders .= 'MIME-Version: 1.0' . "\n"; + $fHeaders .= 'Content-Type: text/plain; charset=UTF-8' . "\n"; + $fHeaders .= 'Content-Transfer-Encoding: base64' . "\n"; - $i = 0; - while ($row = db_array ($result['result'])) { - $fTo = $row[0]; - $fHeaders = 'To: ' . $fTo . "\n"; - $fHeaders .= 'From: ' . $b_name . ' <' . $CONF['admin_email'] . ">\n"; - $fHeaders .= 'Subject: ' . $b_subject . "\n"; - $fHeaders .= 'MIME-Version: 1.0' . "\n"; - $fHeaders .= 'Content-Type: text/plain; charset=UTF-8' . "\n"; - $fHeaders .= 'Content-Transfer-Encoding: base64' . "\n"; + $fHeaders .= $b_message; - $fHeaders .= $b_message; - - if (!smtp_mail ($fTo, $CONF['admin_email'], $fHeaders)) - { - $tMessage .= "
" . $PALANG['pSendmail_result_error'] . "
"; - } - else - { - $tMessage .= "
" . $PALANG['pSendmail_result_success'] . "
"; - } + if (!smtp_mail ($fTo, $CONF['admin_email'], $fHeaders)) + { + $tMessage .= "
" . $PALANG['pSendmail_result_error'] . "
"; } - } - include ("templates/header.php"); - include ("templates/menu.php"); - echo '

'.$PALANG['pBroadcast_success'].'

'; - include ("templates/footer.php"); - } + else + { + $tMessage .= "
" . $PALANG['pSendmail_result_success'] . "
"; + } + } + } + $smarty->assign ('tMessage', $PALANG['pBroadcast_success']); + $smarty->assign ('smarty_template', 'message'); + $smarty->display ('index.tpl'); +// echo '

'.$PALANG['pBroadcast_success'].'

'; + } } if ($_SERVER['REQUEST_METHOD'] == "GET" || $error == 1) { - include ("templates/header.php"); - include ("templates/menu.php"); - include ("templates/broadcast-message.php"); - include ("templates/footer.php"); + $smarty->assign ('error', $error); + $smarty->assign ('smarty_template', 'broadcast-message'); + $smarty->display ('index.tpl'); + +// include ("templates/broadcast-message.php"); } /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ diff --git a/calendar.js b/calendar.js new file mode 100644 index 00000000..2dfc4513 --- /dev/null +++ b/calendar.js @@ -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('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 = '' + + (this.a_tpl.yearscroll ? '' : '') + + '' + + (this.a_tpl.yearscroll ? '' : '') + + '
' + + this.a_tpl.months[d_date.getMonth()] + ' ' + d_date.getFullYear() + + '
'; + + // print weekdays titles + for (var i = 0; i < 7; i++) + s_html += ''; + s_html += '' ; + + // 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 +=''; + 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 += '' + + 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 +=''; + } + s_html +='
' + this.a_tpl.weekdays[(this.a_tpl.weekstart + i) % 7] + '
' : '>') + n_date + '
'; + + // 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 + ? '
' + : '
'; + + 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; diff --git a/common.php b/common.php index 32c98e38..e45ed89b 100644 --- a/common.php +++ b/common.php @@ -19,7 +19,7 @@ if(!defined('POSTFIXADMIN')) { # already defined if called from setup.php session_start(); - define('POSTFIXADMIN', 1); # checked in included files + define('POSTFIXADMIN', 1); # checked in included files } $incpath = dirname(__FILE__); @@ -62,4 +62,8 @@ function postfixadmin_autoload($class) { } spl_autoload_register('postfixadmin_autoload'); +//***** +require_once ("$incpath/smarty.inc.php"); +//***** /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ +?> \ No newline at end of file diff --git a/config.inc.php b/config.inc.php index da5d9b0a..15098767 100644 --- a/config.inc.php +++ b/config.inc.php @@ -29,7 +29,6 @@ $CONF['configured'] = false; // To create the hash, visit setup.php in a browser and type a password into the field, // on submission it will be echoed out to you as a hashed value. $CONF['setup_password'] = 'changeme'; - // Postfix Admin Path // Set the location of your Postfix Admin installation here. // YOU MUST ENTER THE COMPLETE URL e.g. http://domain.tld/postfixadmin @@ -58,7 +57,6 @@ $CONF['database_prefix'] = ''; // uncomment and change the following // $CONF['database_port'] = '5432'; - // Here, if you need, you can customize table names. $CONF['database_prefix'] = ''; $CONF['database_tables'] = array ( @@ -74,7 +72,7 @@ $CONF['database_tables'] = array ( 'vacation' => 'vacation', 'vacation_notification' => 'vacation_notification', 'quota' => 'quota', - 'quota2' => 'quota2', + 'quota2' => 'quota2', ); // Site Admin @@ -308,7 +306,6 @@ $CONF['show_custom_colors']=array("lightgreen","lightblue"); // Set to "" to disable this check. $CONF['recipient_delimiter'] = ""; - // Optional: // Script to run after creation of mailboxes. // Note that this may fail if PHP is run in "safe mode", or if @@ -389,12 +386,11 @@ $CONF['theme_logo'] = 'images/logo-default.png'; $CONF['theme_css'] = 'css/default.css'; // XMLRPC Interface. -// This should be only of use if you wish to use e.g the +// This should be only of use if you wish to use e.g the // Postfixadmin-Squirrelmail package // change to boolean true to enable xmlrpc $CONF['xmlrpc_enabled'] = false; - // If you want to keep most settings at default values and/or want to ensure // that future updates work without problems, you can use a separate config // file (config.local.php) instead of editing this file and override some diff --git a/configs/menu.conf b/configs/menu.conf new file mode 100644 index 00000000..92355570 --- /dev/null +++ b/configs/menu.conf @@ -0,0 +1,72 @@ +url_main = main.php +# list_admin +url_list_admin = list-admin.php +url_create_admin = create-admin.php +# list-domain +url_list_domain = list-domain.php +url_create_domain = create-domain.php +# list-virtual +url_list_virtual = list-virtual.php +url_create_mailbox = create-mailbox.php +url_create_alias = create-alias.php +url_create_alias_domain = create-alias-domain.php +# fetchmail +url_fetchmail = fetchmail.php +url_fetchmail_new_entry = fetchmail.php?new=1 +# sendmail +url_sendmail = sendmail.php +url_broadcast_message = broadcast-message.php +# password +url_password = password.php +# backup +url_backup = backup.php +# viewlog +url_viewlog = viewlog.php +# logout +url_logout = logout.php + +# user-menu +url_user_edit_alias = edit-alias.php +url_user_vacation = vacation.php +url_user_password = password.php +url_user_logout = logout.php + + +url_edit_active = edit-active.php + +tr_header = +tr_hilightoff = + +url_delete = delete.php +url_search = search.php +form_search =
+ +[main] +_txt_list_domain = pMenu_overview + +[admin_list-admin] +url_edit_active_admin = edit-active-admin.php +url_edit_admin = edit-admin.php + +[admin_list-domain] +url_edit_active_domain = edit-active-domain.php +url_edit_domain = edit-domain.php + +[DISCARDED] +_txt_main = pMenu_main +_txt_list_admin = pAdminMenu_list_admin +_txt_create_admin = pAdminMenu_create_admin +_txt_list_domain = pAdminMenu_list_domain +_txt_create_domain = pAdminMenu_create_domain +_txt_list_virtual = pAdminMenu_list_virtual +_txt_create_mailbox = pMenu_create_mailbox +_txt_create_alias = pMenu_create_alias +_txt_create_alias_domain = pMenu_create_alias_domain +_txt_fetchmail = pMenu_fetchmail +_txt_fetchmail_new_entry = pFetchmail_new_entry +_txt_logout = pMenu_logout +_txt_viewlog = pMenu_viewlog +_txt_password = pMenu_password +_txt_backup = pAdminMenu_backup +_txt_sendmail = pMenu_sendmail +_txt_broadcast_message = pAdminMenu_broadcast_message diff --git a/create-admin.php b/create-admin.php index 37163b8b..73e55b42 100644 --- a/create-admin.php +++ b/create-admin.php @@ -34,7 +34,6 @@ require_once('common.php'); authentication_require_role('global-admin'); - $list_domains = list_domains (); $tDomains = array(); @@ -51,7 +50,6 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") if (isset ($_POST['fPassword2'])) $fPassword2 = escape_string ($_POST['fPassword2']); $fDomains = array(); if (!empty ($_POST['fDomains'])) $fDomains = $_POST['fDomains']; - list ($error, $tMessage, $pAdminCreate_admin_username_text, $pAdminCreate_admin_password_text) = create_admin($fUsername, $fPassword, $fPassword2, $fDomains); if ($error != 0) { @@ -60,10 +58,14 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/admin_create-admin.php"); -include ("templates/footer.php"); +$smarty->assign ('tUsername', $tUsername); +$smarty->assign ('pAdminCreate_admin_username_text', $pAdminCreate_admin_username_text); +$smarty->assign ('pAdminCreate_admin_password_text', $pAdminCreate_admin_password_text); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('select_options', select_options ($list_domains, $tDomains)); + +$smarty->assign ('smarty_template', 'admin_create-admin'); +$smarty->display ('index.tpl'); /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> diff --git a/create-alias-domain.php b/create-alias-domain.php index b6cd498a..3d3a7cf2 100644 --- a/create-alias-domain.php +++ b/create-alias-domain.php @@ -86,11 +86,14 @@ if (isset ($_REQUEST['target_domain'])) { $fTargetDomain = escape_string ($_REQUEST['target_domain']); $fTargetDomain = strtolower ($fTargetDomain); } +//*** ????? if (isset ($_REQUEST['active'])) { $fActive = (bool)$_REQUEST['active']; } else { - $fActive = true; + $fActive = false; } +if (!isset ($_REQUEST['submit'])) + $fActive = true; if ($_SERVER['REQUEST_METHOD'] == "POST") { @@ -132,10 +135,13 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") $tMessage .= "
($fAliasDomain -> $fTargetDomain)
\n"; } - -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/create-alias-domain.php"); -include ("templates/footer.php"); +$smarty->assign ('alias_domains', (count($alias_domains) > 0)); +$smarty->assign ('select_options_alias', select_options ($alias_domains, array ($fAliasDomain))); +$smarty->assign ('select_options_target', select_options ($target_domains, array ($fTargetDomain))); +if ($fActive) $smarty->assign ('fActive', ' checked="checked"'); +if ($error == 1) $tMessage = ''.$tMessage.''; +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'create-alias-domain'); +$smarty->display ('index.tpl'); /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> diff --git a/create-alias.php b/create-alias.php index 632da73f..dd590270 100644 --- a/create-alias.php +++ b/create-alias.php @@ -124,7 +124,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") $tAddress = escape_string ($_POST['fAddress']); $tGoto = $fGoto; $tDomain = $fDomain; - $pCreate_alias_address_text = $PALANG['pCreate_alias_address_text_error2']; + $pCreate_alias_address_text = $PALANG['pCreate_alias_address_text_error2']; } if ($fActive == "on") { @@ -150,12 +150,17 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") $tDomain = $fDomain; $tMessage = $PALANG['pCreate_alias_result_success'] . "
($fAddress -> $fGoto)
\n"; } - } +} } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/create-alias.php"); -include ("templates/footer.php"); +$smarty->assign ('tAddress', $tAddress); +$smarty->assign ('select_options', select_options ($list_domains, array ($tDomain))); +$smarty->assign ('pCreate_alias_address_text', $pCreate_alias_address_text); +$smarty->assign ('tGoto', $tGoto); +$smarty->assign ('pCreate_alias_goto_text', $pCreate_alias_goto_text); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'create-alias'); +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> diff --git a/create-domain.php b/create-domain.php index b144e423..f51eed50 100644 --- a/create-domain.php +++ b/create-domain.php @@ -142,10 +142,18 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/admin_create-domain.php"); -include ("templates/footer.php"); +$smarty->assign ('tDomain', $tDomain); +$smarty->assign ('pAdminCreate_domain_domain_text', $pAdminCreate_domain_domain_text); +$smarty->assign ('tDescription', $tDescription); +$smarty->assign ('tAliases', $tAliases); +$smarty->assign ('tMailboxes', $tMailboxes); +$smarty->assign ('tMaxquota', $tMaxquota); +$smarty->assign ('select_options', select_options ($CONF ['transport_options'], array ($tTransport))); +$smarty->assign ('tDefaultaliases', ($tDefaultaliases == 'on') ? ' checked="checked"' : ''); +$smarty->assign ('tBackupmx', ($tBackupmx == 'on') ? ' checked="checked"' : ''); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'admin_create-domain'); +$smarty->display ('index.tpl'); /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> diff --git a/create-mailbox.php b/create-mailbox.php index e60c646d..bef39bb9 100644 --- a/create-mailbox.php +++ b/create-mailbox.php @@ -40,235 +40,240 @@ require_once('common.php'); authentication_require_role('admin'); $SESSID_USERNAME = authentication_get_username(); if(authentication_has_role('global-admin')) { - $list_domains = list_domains (); + $list_domains = list_domains (); } else { - $list_domains = list_domains_for_admin($SESSID_USERNAME); + $list_domains = list_domains_for_admin($SESSID_USERNAME); } $pCreate_mailbox_password_text = $PALANG['pCreate_mailbox_password_text']; -$pCreate_mailbox_name_text = $PALANG['pCreate_mailbox_name_text']; $pCreate_mailbox_quota_text = $PALANG['pCreate_mailbox_quota_text']; if ($_SERVER['REQUEST_METHOD'] == "GET") { - $fDomain = $list_domains[0]; - if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']); + $fDomain = $list_domains[0]; + if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']); - if(!in_array($fDomain, $list_domains)) { - die("Invalid domain name selected, or you tried to select a domain you are not an admin for"); - } - $tDomain = $fDomain; - $result = db_query ("SELECT * FROM $table_domain WHERE domain='$fDomain'"); - if ($result['rows'] == 1) - { - $row = db_array ($result['result']); - $tQuota = $row['maxquota']; - } + if(!in_array($fDomain, $list_domains)) { + die("Invalid domain name selected, or you tried to select a domain you are not an admin for"); + } + $tDomain = $fDomain; + $result = db_query ("SELECT * FROM $table_domain WHERE domain='$fDomain'"); + if ($result['rows'] == 1) + { + $row = db_array ($result['result']); + $tQuota = $row['maxquota']; + } } if ($_SERVER['REQUEST_METHOD'] == "POST") { - if (isset ($_POST['fUsername']) && isset ($_POST['fDomain'])) $fUsername = escape_string ($_POST['fUsername']) . "@" . escape_string ($_POST['fDomain']); - $fUsername = strtolower ($fUsername); - if (isset ($_POST['fPassword'])) $fPassword = escape_string ($_POST['fPassword']); - if (isset ($_POST['fPassword2'])) $fPassword2 = escape_string ($_POST['fPassword2']); - isset ($_POST['fName']) ? $fName = escape_string ($_POST['fName']) : $fName = ""; - if (isset ($_POST['fDomain'])) $fDomain = escape_string ($_POST['fDomain']); - isset ($_POST['fQuota']) ? $fQuota = intval($_POST['fQuota']) : $fQuota = 0; - isset ($_POST['fActive']) ? $fActive = escape_string ($_POST['fActive']) : $fActive = "1"; - if (isset ($_POST['fMail'])) $fMail = escape_string ($_POST['fMail']); + if (isset ($_POST['fUsername']) && isset ($_POST['fDomain'])) $fUsername = escape_string ($_POST['fUsername']) . "@" . escape_string ($_POST['fDomain']); + $fUsername = strtolower ($fUsername); + if (isset ($_POST['fPassword'])) $fPassword = escape_string ($_POST['fPassword']); + if (isset ($_POST['fPassword2'])) $fPassword2 = escape_string ($_POST['fPassword2']); + isset ($_POST['fName']) ? $fName = escape_string ($_POST['fName']) : $fName = ""; + if (isset ($_POST['fDomain'])) $fDomain = escape_string ($_POST['fDomain']); + isset ($_POST['fQuota']) ? $fQuota = intval($_POST['fQuota']) : $fQuota = 0; + isset ($_POST['fActive']) ? $fActive = escape_string ($_POST['fActive']) : $fActive = "1"; + if (isset ($_POST['fMail'])) $fMail = escape_string ($_POST['fMail']); - if ( (!check_owner ($SESSID_USERNAME, $fDomain)) && (!authentication_has_role('global-admin')) ) - { - $error = 1; - $tUsername = escape_string ($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error1']; - } + if ( (!check_owner ($SESSID_USERNAME, $fDomain)) && (!authentication_has_role('global-admin')) ) + { + $error = 1; + $tUsername = escape_string ($_POST['fUsername']); + $tName = $fName; + $tQuota = $fQuota; + $tDomain = $fDomain; + $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error1']; + } - if (!check_mailbox ($fDomain)) - { - $error = 1; - $tUsername = escape_string ($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error3']; - } + if (!check_mailbox ($fDomain)) + { + $error = 1; + $tUsername = escape_string ($_POST['fUsername']); + $tName = $fName; + $tQuota = $fQuota; + $tDomain = $fDomain; + $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error3']; + } - if (empty ($fUsername) or !check_email ($fUsername)) - { - $error = 1; - $tUsername = escape_string ($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error1']; - } + if (empty ($fUsername) or !check_email ($fUsername)) + { + $error = 1; + $tUsername = escape_string ($_POST['fUsername']); + $tName = $fName; + $tQuota = $fQuota; + $tDomain = $fDomain; + $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error1']; + } - $tPassGenerated = 0; - if (empty ($fPassword) or empty ($fPassword2) or ($fPassword != $fPassword2)) - { - if (empty ($fPassword) and empty ($fPassword2) and $CONF['generate_password'] == "YES") - { - $fPassword = generate_password (); - $tPassGenerated = 1; - } - else - { - $error = 1; - $tUsername = escape_string ($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_password_text = $PALANG['pCreate_mailbox_password_text_error']; - } - } + $tPassGenerated = 0; + if (empty ($fPassword) or empty ($fPassword2) or ($fPassword != $fPassword2)) + { + if (empty ($fPassword) and empty ($fPassword2) and $CONF['generate_password'] == "YES") + { + $fPassword = generate_password (); + $tPassGenerated = 1; + } + else + { + $error = 1; + $tUsername = escape_string ($_POST['fUsername']); + $tName = $fName; + $tQuota = $fQuota; + $tDomain = $fDomain; + $pCreate_mailbox_password_text = $PALANG['pCreate_mailbox_password_text_error']; + } + } - if ($CONF['quota'] == "YES") - { - if (!check_quota ($fQuota, $fDomain)) - { - $error = 1; - $tUsername = escape_string ($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_quota_text = $PALANG['pCreate_mailbox_quota_text_error']; - } - } + if ($CONF['quota'] == "YES") + { + if (!check_quota ($fQuota, $fDomain)) + { + $error = 1; + $tUsername = escape_string ($_POST['fUsername']); + $tName = $fName; + $tQuota = $fQuota; + $tDomain = $fDomain; + $pCreate_mailbox_quota_text = $PALANG['pCreate_mailbox_quota_text_error']; + } + } - $result = db_query ("SELECT * FROM $table_alias WHERE address='$fUsername'"); - if ($result['rows'] == 1) - { - $error = 1; - $tUsername = escape_string ($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error2']; - } + $result = db_query ("SELECT * FROM $table_alias WHERE address='$fUsername'"); + if ($result['rows'] == 1) + { + $error = 1; + $tUsername = escape_string ($_POST['fUsername']); + $tName = $fName; + $tQuota = $fQuota; + $tDomain = $fDomain; + $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error2']; + } - if ($error != 1) - { - $password = pacrypt ($fPassword); + if ($error != 1) + { + $password = pacrypt ($fPassword); - if ($CONF['domain_path'] == "YES") - { - if ($CONF['domain_in_mailbox'] == "YES") - { - $maildir = $fDomain . "/" . $fUsername . "/"; - } - else - { - $maildir = $fDomain . "/" . escape_string (strtolower($_POST['fUsername'])) . "/"; - } - } - else - { - $maildir = $fUsername . "/"; - } + if ($CONF['domain_path'] == "YES") + { + if ($CONF['domain_in_mailbox'] == "YES") + { + $maildir = $fDomain . "/" . $fUsername . "/"; + } + else + { + $maildir = $fDomain . "/" . escape_string (strtolower($_POST['fUsername'])) . "/"; + } + } + else + { + $maildir = $fUsername . "/"; + } - if (!empty ($fQuota)) - { - $quota = multiply_quota ($fQuota); - } - else - { - $quota = 0; - } + if (!empty ($fQuota)) + { + $quota = multiply_quota ($fQuota); + } + else + { + $quota = 0; + } - if ($fActive == "on") - { - $sqlActive = db_get_boolean(True); - } - else - { - $sqlActive = db_get_boolean(False); - } - if ('pgsql'==$CONF['database_type']) - { - db_query('BEGIN'); - } + if ($fActive == "on") + { + $sqlActive = db_get_boolean(True); + } + else + { + $sqlActive = db_get_boolean(False); + } + if ('pgsql'==$CONF['database_type']) + { + db_query('BEGIN'); + } - $result = db_query ("INSERT INTO $table_alias (address,goto,domain,created,modified,active) VALUES ('$fUsername','$fUsername','$fDomain',NOW(),NOW(),'$sqlActive')"); - if ($result['rows'] != 1) - { - $tDomain = $fDomain; - $tMessage = $PALANG['pAlias_result_error'] . "
($fUsername -> $fUsername)
"; - } + $result = db_query ("INSERT INTO $table_alias (address,goto,domain,created,modified,active) VALUES ('$fUsername','$fUsername','$fDomain',NOW(),NOW(),'$sqlActive')"); + if ($result['rows'] != 1) + { + $tDomain = $fDomain; + $tMessage = $PALANG['pAlias_result_error'] . "
($fUsername -> $fUsername)
"; + } + // apparently uppercase usernames really confuse some IMAP clients. + $fUsername = strtolower($fUsername); + $local_part = ''; + if(preg_match('/^(.*)@/', $fUsername, $matches)) { + $local_part = $matches[1]; + } - // apparently uppercase usernames really confuse some IMAP clients. - $fUsername = strtolower($fUsername); - $local_part = ''; - if(preg_match('/^(.*)@/', $fUsername, $matches)) { - $local_part = $matches[1]; - } + $result = db_query ("INSERT INTO $table_mailbox (username,password,name,maildir,local_part,quota,domain,created,modified,active) VALUES ('$fUsername','$password','$fName','$maildir','$local_part','$quota','$fDomain',NOW(),NOW(),'$sqlActive')"); + if ($result['rows'] != 1 || !mailbox_postcreation($fUsername,$fDomain,$maildir, $quota)) + { + $tDomain = $fDomain; + $tMessage .= $PALANG['pCreate_mailbox_result_error'] . "
($fUsername)
"; + db_query('ROLLBACK'); + } + else + { + db_query('COMMIT'); + db_log ($SESSID_USERNAME, $fDomain, 'create_mailbox', "$fUsername"); + $tDomain = $fDomain; - $result = db_query ("INSERT INTO $table_mailbox (username,password,name,maildir,local_part,quota,domain,created,modified,active) VALUES ('$fUsername','$password','$fName','$maildir','$local_part','$quota','$fDomain',NOW(),NOW(),'$sqlActive')"); - if ($result['rows'] != 1 || !mailbox_postcreation($fUsername,$fDomain,$maildir, $quota)) - { - $tDomain = $fDomain; - $tMessage .= $PALANG['pCreate_mailbox_result_error'] . "
($fUsername)
"; - db_query('ROLLBACK'); - } - else - { - db_query('COMMIT'); - db_log ($SESSID_USERNAME, $fDomain, 'create_mailbox', "$fUsername"); - $tDomain = $fDomain; + $tQuota = $CONF['maxquota']; - $tQuota = $CONF['maxquota']; + if ($fMail == "on") + { + $fTo = $fUsername; + $fFrom = $SESSID_USERNAME; + $fHeaders = "To: " . $fTo . "\n"; + $fHeaders .= "From: " . $fFrom . "\n"; - if ($fMail == "on") - { - $fTo = $fUsername; - $fFrom = $SESSID_USERNAME; - $fHeaders = "To: " . $fTo . "\n"; - $fHeaders .= "From: " . $fFrom . "\n"; + $fHeaders .= "Subject: " . encode_header ($PALANG['pSendmail_subject_text']) . "\n"; + $fHeaders .= "MIME-Version: 1.0\n"; + $fHeaders .= "Content-Type: text/plain; charset=utf-8\n"; + $fHeaders .= "Content-Transfer-Encoding: 8bit\n"; + + $fHeaders .= $CONF['welcome_text']; - $fHeaders .= "Subject: " . encode_header ($PALANG['pSendmail_subject_text']) . "\n"; - $fHeaders .= "MIME-Version: 1.0\n"; - $fHeaders .= "Content-Type: text/plain; charset=utf-8\n"; - $fHeaders .= "Content-Transfer-Encoding: 8bit\n"; + if (!smtp_mail ($fTo, $fFrom, $fHeaders)) + { + $tMessage .= "
" . $PALANG['pSendmail_result_error'] . "
"; + } + else + { + $tMessage .= "
" . $PALANG['pSendmail_result_success'] . "
"; + } + } - $fHeaders .= $CONF['welcome_text']; + $tShowpass = ""; + if ( $tPassGenerated == 1 || $CONF['show_password'] == "YES") $tShowpass = " / $fPassword"; - if (!smtp_mail ($fTo, $fFrom, $fHeaders)) - { - $tMessage .= "
" . $PALANG['pSendmail_result_error'] . "
"; - } - else - { - $tMessage .= "
" . $PALANG['pSendmail_result_success'] . "
"; - } - } + if (create_mailbox_subfolders($fUsername,$fPassword)) + { + $tMessage .= $PALANG['pCreate_mailbox_result_success'] . "
($fUsername$tShowpass)"; + } else { + $tMessage .= $PALANG['pCreate_mailbox_result_succes_nosubfolders'] . "
($fUsername$tShowpass)"; + } - $tShowpass = ""; - if ( $tPassGenerated == 1 || $CONF['show_password'] == "YES") $tShowpass = " / $fPassword"; - - if (create_mailbox_subfolders($fUsername,$fPassword)) - { - $tMessage .= $PALANG['pCreate_mailbox_result_success'] . "
($fUsername$tShowpass)"; - } else { - $tMessage .= $PALANG['pCreate_mailbox_result_succes_nosubfolders'] . "
($fUsername$tShowpass)"; - } - - } - } + } + } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/create-mailbox.php"); -include ("templates/footer.php"); +$smarty->assign ('tUsername', $tUsername); +$smarty->assign ('select_options', select_options ($list_domains, array ($tDomain))); +$smarty->assign ('pCreate_mailbox_username_text', $pCreate_mailbox_username_text); +$smarty->assign ('pCreate_mailbox_password_text', $pCreate_mailbox_password_text); +$smarty->assign ('tName', $tName); +$smarty->assign ('tQuota', $tQuota); +$smarty->assign ('pCreate_mailbox_quota_text', $pCreate_mailbox_quota_text); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'create-mailbox'); +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> diff --git a/css/calendar.css b/css/calendar.css new file mode 100644 index 00000000..a3ddcae5 --- /dev/null +++ b/css/calendar.css @@ -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; +} diff --git a/css/default.css b/css/default.css index 33c9c013..9000f535 100644 --- a/css/default.css +++ b/css/default.css @@ -98,14 +98,14 @@ ul.flash-error { font-size: 13px; } -#menu { +#menu, #tabbar { width: 750px; margin: 0 auto; padding-top: 10px; white-space: nowrap; } -#menu ul { +#menu ul, #tabbar ul { padding: 0; margin: 0; margin-left:auto; @@ -113,18 +113,18 @@ ul.flash-error { list-style: none; } -#menu li { +#menu li, #tabbar li { float: left; background: #efefef; margin-right: 3px; border-top: 4px solid #aaaaaa; } -#menu li:hover, #menu li.sfhover { +#menu li:hover, #menu li.sfhover, #tabbar li:hover, #tabbar li.sfhover { background: #BFFF00; } -#menu li ul { +#menu li ul, #tabbar li ul { position: absolute; width: auto; left: -999em; @@ -132,12 +132,12 @@ ul.flash-error { border:2px solid white; border-top:none; } -#menu li:hover ul, #menu li.sfhover ul { +#menu li:hover ul, #menu li.sfhover ul, #tabbar li:hover ul, #tabbar li.sfhover ul { left: auto; } -#menu li ul li { +#menu li ul li, #tabbar li ul li { float: none; margin-right: 0px; border-top:2px solid white;; @@ -145,22 +145,20 @@ ul.flash-error { } - - -#menu a { +#menu a, #tabbar a { display: block; width: auto; padding: 20px 5px 5px 5px; color: #888888; } -#menu a:hover { +#menu a:hover, #tabbar a:hover { color: #888888; } -#menu li ul li a { +#menu li ul li a, #tabbar li ul li a { padding: 5px 5px 5px 5px; } @@ -240,12 +238,6 @@ ul.flash-error { line-height: 30px; } -#nav_bar { - text-align: right; - width: 750px; - margin: 0 auto; -} - #alias_domain_table, #alias_table, #mailbox_table, #overview_table, #log_table, #admin_table { width: 750px; margin: 0px auto; @@ -281,6 +273,10 @@ ul.flash-error { margin: 0; } +#alias_domain_table td, #alias_table td, #mailbox_table td, #overview_table td, #log_table td, #admin_table td { +text-align : left; +} + #footer { width: 750px; margin: 20px auto; @@ -313,3 +309,9 @@ div.setup { div.setup li { padding-bottom:1em; } + +div.nav_bar { + text-align: left; + width: 750px; + margin: 0 auto; +} diff --git a/debian/changelog b/debian/changelog index 00598104..3933bf90 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,3 @@ -postfixadmin (2.3) unstable; urgency=low - - * New 'upstream' release. - - -- David Goodwin Mon, 27 Jul 2009 22:08:26 +0100 - postfixadmin (2.3rc7) unstable; urgency=low * Fix issue with pre.rm script diff --git a/delete.php b/delete.php index 4cce53a6..1430608f 100644 --- a/delete.php +++ b/delete.php @@ -114,63 +114,61 @@ elseif ($fTable == "alias" or $fTable == "mailbox") else { if ($CONF['database_type'] == "pgsql") db_query('BEGIN'); - /* there may be no aliases to delete */ - $result = db_query("SELECT * FROM $table_alias WHERE address = '$fDelete' AND domain = '$fDomain'"); - if($result['rows'] == 1) { - $result = db_query ("DELETE FROM $table_alias WHERE address='$fDelete' AND domain='$fDomain'"); - db_log ($SESSID_USERNAME, $fDomain, 'delete_alias', $fDelete); - } - - /* is there a mailbox? if do delete it from orbit; it's the only way to be sure */ - $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$fDelete' AND domain='$fDomain'"); - if ($result['rows'] == 1) - { - $result = db_query ("DELETE FROM $table_mailbox WHERE username='$fDelete' AND domain='$fDomain'"); - $postdel_res=mailbox_postdeletion($fDelete,$fDomain); - if ($result['rows'] != 1 || !$postdel_res) + /* there may be no aliases to delete */ + $result = db_query("SELECT * FROM $table_alias WHERE address = '$fDelete' AND domain = '$fDomain'"); + if($result['rows'] == 1) { + $result = db_query ("DELETE FROM $table_alias WHERE address='$fDelete' AND domain='$fDomain'"); + db_log ($SESSID_USERNAME, $fDomain, 'delete_alias', $fDelete); + } + /* is there a mailbox? if do delete it from orbit; it's the only way to be sure */ + $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$fDelete' AND domain='$fDomain'"); + if ($result['rows'] == 1) { - $error = 1; - $tMessage = $PALANG['pDelete_delete_error'] . "$fDelete ("; - if ($result['rows']!=1) + $result = db_query ("DELETE FROM $table_mailbox WHERE username='$fDelete' AND domain='$fDomain'"); + $postdel_res=mailbox_postdeletion($fDelete,$fDomain); + if ($result['rows'] != 1 || !$postdel_res) { - $tMessage.='mailbox'; - if (!$postdel_res) $tMessage.=', '; + $error = 1; + $tMessage = $PALANG['pDelete_delete_error'] . "$fDelete ("; + if ($result['rows']!=1) + { + $tMessage.='mailbox'; + if (!$postdel_res) $tMessage.=', '; + } + if (!$postdel_res) + { + $tMessage.='post-deletion'; + } + $tMessage.=')'; } - if (!$postdel_res) - { - $tMessage.='post-deletion'; - } - $tMessage.=')'; + db_log ($SESSID_USERNAME, $fDomain, 'delete_mailbox', $fDelete); + } + $result = db_query("SELECT * FROM $table_vacation WHERE email = '$fDelete' AND domain = '$fDomain'"); + if($result['rows'] == 1) { + db_query ("DELETE FROM $table_vacation WHERE email='$fDelete' AND domain='$fDomain'"); + db_query ("DELETE FROM $table_vacation_notification WHERE on_vacation ='$fDelete' "); /* should be caught by cascade, if PgSQL */ } - db_log ($SESSID_USERNAME, $fDomain, 'delete_mailbox', $fDelete); } - $result = db_query("SELECT * FROM $table_vacation WHERE email = '$fDelete' AND domain = '$fDomain'"); - if($result['rows'] == 1) { - db_query ("DELETE FROM $table_vacation WHERE email='$fDelete' AND domain='$fDomain'"); - db_query ("DELETE FROM $table_vacation_notification WHERE on_vacation ='$fDelete' "); /* should be caught by cascade, if PgSQL */ - } - } - if ($error != 1) - { - if ($CONF['database_type'] == "pgsql") db_query('COMMIT'); - header ("Location: list-virtual.php?domain=$fDomain"); - exit; - } else { - $tMessage .= $PALANG['pDelete_delete_error'] . "$fDelete (physical mail)!"; - if ($CONF['database_type'] == "pgsql") db_query('ROLLBACK'); - } + if ($error != 1) + { + if ($CONF['database_type'] == "pgsql") db_query('COMMIT'); + header ("Location: list-virtual.php?domain=$fDomain"); + exit; + } else { + $tMessage .= $PALANG['pDelete_delete_error'] . "$fDelete (physical mail)!"; + if ($CONF['database_type'] == "pgsql") db_query('ROLLBACK'); + } } else { flash_error($PALANG['invalid_parameter']); } +$smarty->assign ('smarty_template', 'message'); +$smarty->assign ('tMessage', $tMessage); +$smarty->display ('index.tpl'); -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/message.php"); -include ("templates/footer.php"); /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> diff --git a/edit-active-admin.php b/edit-active-admin.php index bf3938ec..d59bb50d 100644 --- a/edit-active-admin.php +++ b/edit-active-admin.php @@ -50,11 +50,10 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") exit; } } +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'message'); +$smarty->display ('index.tpl'); -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/message.php"); -include ("templates/footer.php"); /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ diff --git a/edit-active-domain.php b/edit-active-domain.php index 01db6546..fa56f50a 100644 --- a/edit-active-domain.php +++ b/edit-active-domain.php @@ -50,10 +50,10 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/message.php"); -include ("templates/footer.php"); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'message'); +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> diff --git a/edit-active.php b/edit-active.php index 8170828b..e56e82d3 100644 --- a/edit-active.php +++ b/edit-active.php @@ -112,9 +112,9 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/message.php"); -include ("templates/footer.php"); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'message'); +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> diff --git a/edit-admin.php b/edit-admin.php index 8671836b..a761cf9c 100644 --- a/edit-admin.php +++ b/edit-admin.php @@ -21,8 +21,8 @@ * * tAllDomains * tDomains - * tActive - * tSadmin + * tActive_checked + * tSadmin_checked * * Form POST \ GET Variables: * @@ -131,29 +131,33 @@ if (isset($_GET['username'])) $username = escape_string ($_GET['username']); $tAllDomains = list_domains(); $tDomains = list_domains_for_admin ($username); -$tActive = ''; +$tActive_checked = ''; $tPassword = $admin_details['password']; if($admin_details['active'] == 't' || $admin_details['active'] == 1) { - $tActive = $admin_details['active']; + $tActive_checked = ' checked="checked"'; } -$tSadmin = '0'; +$tSadmin_checked = ''; $result = db_query ("SELECT * FROM $table_domain_admins WHERE username='$username'"); // could/should be multiple matches to query; if ($result['rows'] >= 1) { $result = $result['result']; while($row = db_array($result)) { if ($row['domain'] == 'ALL') { - $tSadmin = '1'; + $tSadmin_checked = ' checked="checked"'; $tDomains = array(); /* empty the list, they're an admin */ } } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/admin_edit-admin.php"); -include ("templates/footer.php"); +$smarty->assign ('username', $username); +$smarty->assign ('pAdminEdit_admin_password_text', $pAdminEdit_admin_password_text); +$smarty->assign ('tActive_checked', $tActive_checked); +$smarty->assign ('tSadmin_checked', $tSadmin_checked); +$smarty->assign ('select_options', select_options ($tAllDomains, $tDomains)); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'admin_edit-admin'); +$smarty->display ('index.tpl'); /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> diff --git a/edit-alias.php b/edit-alias.php index 1a96b33c..2e6709fa 100644 --- a/edit-alias.php +++ b/edit-alias.php @@ -35,139 +35,149 @@ authentication_require_role('admin'); $SESSID_USERNAME = authentication_get_username(); if($CONF['alias_control_admin'] == 'NO' && !authentication_has_role('global-admin')) { - die("Check config.inc.php - domain administrators do not have the ability to edit user's aliases (alias_control_admin)"); + die("Check config.inc.php - domain administrators do not have the ability to edit user's aliases (alias_control_admin)"); } /* retrieve existing alias record for the user first... may be via GET or POST */ + $fAddress = safepost('address', safeget('address')); # escaped below $fDomain = escape_string(preg_replace("/.*@/", "", $fAddress)); $fAddress = escape_string($fAddress); # escaped now if ($fAddress == "") { - die("Required parameters not present"); + die("Required parameters not present"); } /* Check the user is able to edit the domain's aliases */ -if(!check_owner($SESSID_USERNAME, $fDomain) && !authentication_has_role('global-admin')) -{ - die("You lack permission to do this. yes."); -} -$table_alias = table_by_key('alias'); -$alias_list = array(); -$orig_alias_list = array(); -$result = db_query ("SELECT * FROM $table_alias WHERE address='$fAddress' AND domain='$fDomain'"); -if ($result['rows'] == 1) -{ - $row = db_array ($result['result']); - $tGoto = $row['goto']; + if(!check_owner($SESSID_USERNAME, $fDomain) && !authentication_has_role('global-admin')) + { + die("You lack permission to do this. yes."); + } - $orig_alias_list = explode(',', $tGoto); - $alias_list = $orig_alias_list; - //. if we are not a global admin, and special_alias_control is NO, hide the alias that's the mailbox name. - if($CONF['special_alias_control'] == 'NO' && !authentication_has_role('global-admin')) { - /* Has a mailbox as well? Remove the address from $tGoto in order to edit just the real aliases */ - $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$fAddress' AND domain='$fDomain'"); - if ($result['rows'] == 1) - { - $alias_list = array(); // empty it, repopulated again below - foreach($orig_alias_list as $alias) { - if(strtolower($alias) == strtolower($fAddress)) { - // mailbox address is dropped if they don't have special_alias_control enabled, and/or not a global-admin - } - else { - $alias_list[] = $alias; - } - } - } - } + $table_alias = table_by_key('alias'); + $alias_list = array(); + $orig_alias_list = array(); + $result = db_query ("SELECT * FROM $table_alias WHERE address='$fAddress' AND domain='$fDomain'"); + if ($result['rows'] == 1) + { + $row = db_array ($result['result']); + $tGoto = $row['goto']; + $orig_alias_list = explode(',', $tGoto); + $alias_list = $orig_alias_list; + //. if we are not a global admin, and special_alias_control is NO, hide the alias that's the mailbox name. + if($CONF['special_alias_control'] == 'NO' && !authentication_has_role('global-admin')) { + + /* Has a mailbox as well? Remove the address from $tGoto in order to edit just the real aliases */ + $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$fAddress' AND domain='$fDomain'"); + if ($result['rows'] == 1) + { + $alias_list = array(); // empty it, repopulated again below + foreach($orig_alias_list as $alias) { + if(strtolower($alias) == strtolower($fAddress)) { + // mailbox address is dropped if they don't have special_alias_control enabled, and/or not a global-admin + } + else { + $alias_list[] = $alias; + } + } + } + } } else { - die("Invalid alias"); + die("Invalid alias"); } if ($_SERVER['REQUEST_METHOD'] == "POST") { - $pEdit_alias_goto = $PALANG['pEdit_alias_goto']; + $pEdit_alias_goto = $PALANG['pEdit_alias_goto']; + + if (isset ($_POST['fGoto'])) $fGoto = escape_string ($_POST['fGoto']); + $fGoto = strtolower ($fGoto); - if (isset ($_POST['fGoto'])) $fGoto = escape_string ($_POST['fGoto']); - $fGoto = strtolower ($fGoto); + if (!check_alias_owner ($SESSID_USERNAME, $fAddress)) + { + $error = 1; + $tGoto = $fGoto; + $tMessage = $PALANG['pEdit_alias_result_error']; + } - if (!check_alias_owner ($SESSID_USERNAME, $fAddress)) - { - $error = 1; - $tGoto = $fGoto; - $tMessage = $PALANG['pEdit_alias_result_error']; - } + $goto = preg_replace ('/\\\r\\\n/', ',', $fGoto); + $goto = preg_replace ('/\r\n/', ',', $goto); + $goto = preg_replace ('/[\s]+/i', '', $goto); + $goto = preg_replace ('/,*$|^,*/', '', $goto); + $goto = preg_replace ('/,,*/', ',', $goto); - $goto = preg_replace ('/\\\r\\\n/', ',', $fGoto); - $goto = preg_replace ('/\r\n/', ',', $goto); - $goto = preg_replace ('/[\s]+/i', '', $goto); - $goto = preg_replace ('/,*$|^,*/', '', $goto); - $goto = preg_replace ('/,,*/', ',', $goto); + if (empty ($goto) && !authentication_has_role('global-admin')) + { + $error = 1; + $tGoto = $_POST['fGoto']; + $tMessage = $PALANG['pEdit_alias_goto_text_error1']; + } - if (empty ($goto) && !authentication_has_role('global-admin')) - { - $error = 1; - $tGoto = $_POST['fGoto']; - $tMessage = $PALANG['pEdit_alias_goto_text_error1']; - } + $new_aliases = array(); + if ($error != 1) + { + $new_aliases = explode(',', $goto); + } + $new_aliases = array_unique($new_aliases); - $new_aliases = array(); - if ($error != 1) - { - $new_aliases = explode(',', $goto); - } - $new_aliases = array_unique($new_aliases); + foreach($new_aliases as $address) { + if (in_array($address, $CONF['default_aliases'])) continue; + if (empty($address)) continue; # TODO: should never happen - remove after 2.2 release + if (!check_email($address)) + { + $error = 1; + $tGoto = $goto; + $tMessage = $PALANG['pEdit_alias_goto_text_error2'] . "$address"; + } + } + + $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$fAddress' AND domain='$fDomain'"); + if ($result['rows'] == 1) + { + if($CONF['alias_control_admin'] == 'NO' && !authentication_has_role('global-admin')) { + // if original record had a mailbox alias, so ensure the updated one does too. + if(in_array($orig_alias_list, $fAddress)) { + $new_aliases[] = $fAddress; + } + } - foreach($new_aliases as $address) { - if (in_array($address, $CONF['default_aliases'])) continue; - if (empty($address)) continue; # TODO: should never happen - remove after 2.2 release - if (!check_email($address)) - { - $error = 1; - $tGoto = $goto; - $tMessage = $PALANG['pEdit_alias_goto_text_error2'] . "$address"; - } - } + } + // duplicates suck, mmkay.. + $new_aliases = array_unique($new_aliases); - $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$fAddress' AND domain='$fDomain'"); - if ($result['rows'] == 1) - { - if($CONF['alias_control_admin'] == 'NO' && !authentication_has_role('global-admin')) { - // if original record had a mailbox alias, so ensure the updated one does too. - if(in_array($orig_alias_list, $fAddress)) { - $new_aliases[] = $fAddress; - } - } - } - // duplicates suck, mmkay.. - $new_aliases = array_unique($new_aliases); + $goto = implode(',', $new_aliases); - $goto = implode(',', $new_aliases); + if ($error != 1) + { + $goto = escape_string($goto); + $result = db_query ("UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$fAddress' AND domain='$fDomain'"); + if ($result['rows'] != 1) + { + $tMessage = $PALANG['pEdit_alias_result_error']; + } + else + { + db_log ($SESSID_USERNAME, $fDomain, 'edit_alias', "$fAddress -> $goto"); - if ($error != 1) - { - $goto = escape_string($goto); - $result = db_query ("UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$fAddress' AND domain='$fDomain'"); - if ($result['rows'] != 1) - { - $tMessage = $PALANG['pEdit_alias_result_error']; - } - else - { - db_log ($SESSID_USERNAME, $fDomain, 'edit_alias', "$fAddress -> $goto"); - header ("Location: list-virtual.php?domain=$fDomain"); - exit; - } - } + header ("Location: list-virtual.php?domain=$fDomain"); + exit; + } + } } $fAddress = htmlentities($fAddress, ENT_QUOTES); $fDomain = htmlentities($fDomain, ENT_QUOTES); -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/edit-alias.php"); -include ("templates/footer.php"); + +$array = preg_split ('/,/', $tGoto); +// TOCHECK +$array = $alias_list; + +$smarty->assign ('fAddress', $fAddress); +$smarty->assign ('array', $array); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'edit-alias'); +$smarty->display ('index.tpl'); /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> diff --git a/edit-domain.php b/edit-domain.php index e1177fe8..3041d145 100644 --- a/edit-domain.php +++ b/edit-domain.php @@ -113,10 +113,18 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/admin_edit-domain.php"); -include ("templates/footer.php"); +$smarty->assign ('domain', $domain); +$smarty->assign ('tDescription', htmlspecialchars($tDescription, ENT_QUOTES)); +$smarty->assign ('tAliases', $tAliases); +$smarty->assign ('tMailboxes', $tMailboxes); +$smarty->assign ('tMaxquota', $tMaxquota); +$smarty->assign ('select_options', select_options ($CONF ['transport_options'], array ($tTransport))); +if ($tBackupmx) $smarty->assign ('tBackupmx', ' checked="checked"'); +if ($tActive) $smarty->assign ('tActive', ' checked="checked"'); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'admin_edit-domain'); +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> diff --git a/edit-mailbox.php b/edit-mailbox.php index d08dd80d..b5351413 100644 --- a/edit-mailbox.php +++ b/edit-mailbox.php @@ -175,9 +175,18 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/edit-mailbox.php"); -include ("templates/footer.php"); +$smarty->assign ('fUsername', $fUsername); +$smarty->assign ('fPassword', $user_details ['password']); +//$smarty->assign ('pEdit_mailbox_username_text', $pEdit_mailbox_username_text); +$smarty->assign ('pEdit_mailbox_password_text', $pEdit_mailbox_password_text); +$smarty->assign ('tName', htmlspecialchars ($tName,ENT_QUOTES)); +$smarty->assign ('pEdit_mailbox_name_text', $pEdit_mailbox_name_text); +$smarty->assign ('tMaxquota', $tMaxquota); +$smarty->assign ('tQuota', $tQuota); +$smarty->assign ('pEdit_mailbox_quota_text', $pEdit_mailbox_quota_text); +if ($tActive) $smarty->assign ('tActive', ' checked="checked"'); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'edit-mailbox'); +$smarty->display ('index.tpl'); /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> diff --git a/edit-vacation.php b/edit-vacation.php index 49159a9a..cfc90b3f 100644 --- a/edit-vacation.php +++ b/edit-vacation.php @@ -1,207 +1,222 @@ - +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: */ +?> diff --git a/fetchmail.php b/fetchmail.php index 93873903..54d4d2d8 100644 --- a/fetchmail.php +++ b/fetchmail.php @@ -242,11 +242,143 @@ function _inp_bool($val){ function _inp_password($val){ return base64_encode($val); } +//***** +$headers=array(); +foreach(array_keys($fm_struct) as $row){ + list($editible,$view,$type)=$fm_struct[$row]; + $title = $PALANG['pFetchmail_field_' . $row]; + $comment = $PALANG['pFetchmail_desc_' . $row]; + if ($view){ + $headers[]=$title; +// $headers[]=array($editible, $view, $type, $title, $comment); + } +} +function fetchmail_edit_row($data=array()) +{ + global $fm_struct,$fm_defaults,$PALANG; + $id = $data["id"]; + $_id = $data["id"] * 100 + 1; + $ret = ""; + $ret .= ''; + # TODO: $formvars possibly contains db-specific boolean values + # TODO: no problems with MySQL, to be tested with PgSQL + # TODO: undefined values may also occour + foreach($fm_struct as $key=>$struct){ + list($editible,$view,$type)=$struct; + $title = $PALANG['pFetchmail_field_' . $key]; + $comment = $PALANG['pFetchmail_desc_' . $key]; + if ($editible){ + $ret.=""; + $ret.="\n"; + } + elseif($view){ + $func="_view_".$type; + $val=isset($data[$key]) + ?(function_exists($func) + ?$func($data[$key]) + :nl2br($data[$key]) + ) + :"--x--"; + $ret.=""; + $ret.="\n"; + } + } + $ret.="\n"; + $ret.="

'.$PALANG['pMenu_fetchmail'] . '

"; + $func="_edit_".$type; + if (! function_exists($func)) + $func="_edit_text"; + $val=isset($data[$key]) + ?$data[$key] + :(! is_array($fm_defaults[$key]) + ?$fm_defaults[$key] + :'' + ); + $fm_defaults_key = ""; if (isset($fm_defaults[$key])) $fm_defaults_key = $fm_defaults[$key]; + $ret.=$func($_id++,$key,$fm_defaults_key,$val); + $ret.=" ${comment}
${title}: ".$val; + $ret.=" ${comment}
+   + + "; + if ($id){ + $ret.=""; + } + $ret.="
\n"; + $ret.="

\n"; + $ret.="\n"; + $ret.="\n"; + return $ret; +} +function _edit_text($id,$key,$def_vals,$val=""){ + $val=htmlspecialchars($val); + return ""; +} -include ("./templates/header.php"); -include ("./templates/menu.php"); -include ("./templates/fetchmail.php"); -include ("./templates/footer.php"); +function _edit_password($id,$key,$def_vals,$val=""){ + $val=preg_replace("{.}","*",$val); + return ""; +} + +function _edit_num($id,$key,$def_vals,$val=""){ + $val=(int)($val); + return ""; +} + +function _edit_bool($id,$key,$def_vals,$val=""){ + $ret="${val}"; +} + +function _edit_enum($id,$key,$def_vals,$val=""){ + $ret="' . $output; + if ($labels) $_output .= ''; + $_output .= $separator; + + return $_output; +} + +?> diff --git a/smarty/libs/plugins/function.html_image.php b/smarty/libs/plugins/function.html_image.php new file mode 100644 index 00000000..9abae72e --- /dev/null +++ b/smarty/libs/plugins/function.html_image.php @@ -0,0 +1,142 @@ + + * Name: html_image
+ * Date: Feb 24, 2003
+ * Purpose: format HTML tags for the image
+ * Input:
+ * - file = file (and path) of image (required) + * - height = image height (optional, default actual height) + * - width = image width (optional, default actual width) + * - basedir = base directory for absolute paths, default + * is environment variable DOCUMENT_ROOT + * - path_prefix = prefix for path output (optional, default empty) + * + * Examples: {html_image file="/images/masthead.gif"} + * Output: + * @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image} + * (Smarty online manual) + * @author Monte Ohrt + * @author credits to Duda - wrote first image function + * in repository, helped with lots of functionality + * @version 1.0 + * @param array + * @param Smarty + * @return string + * @uses smarty_function_escape_special_chars() + */ +function smarty_function_html_image($params, &$smarty) +{ + require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); + + $alt = ''; + $file = ''; + $height = ''; + $width = ''; + $extra = ''; + $prefix = ''; + $suffix = ''; + $path_prefix = ''; + $server_vars = ($smarty->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS']; + $basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : ''; + foreach($params as $_key => $_val) { + switch($_key) { + case 'file': + case 'height': + case 'width': + case 'dpi': + case 'path_prefix': + case 'basedir': + $$_key = $_val; + break; + + case 'alt': + if(!is_array($_val)) { + $$_key = smarty_function_escape_special_chars($_val); + } else { + $smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); + } + break; + + case 'link': + case 'href': + $prefix = ''; + $suffix = ''; + break; + + default: + if(!is_array($_val)) { + $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; + } else { + $smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); + } + break; + } + } + + if (empty($file)) { + $smarty->trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE); + return; + } + + if (substr($file,0,1) == '/') { + $_image_path = $basedir . $file; + } else { + $_image_path = $file; + } + + if(!isset($params['width']) || !isset($params['height'])) { + if(!$_image_data = @getimagesize($_image_path)) { + if(!file_exists($_image_path)) { + $smarty->trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE); + return; + } else if(!is_readable($_image_path)) { + $smarty->trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE); + return; + } else { + $smarty->trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE); + return; + } + } + if ($smarty->security && + ($_params = array('resource_type' => 'file', 'resource_name' => $_image_path)) && + (require_once(SMARTY_CORE_DIR . 'core.is_secure.php')) && + (!smarty_core_is_secure($_params, $smarty)) ) { + $smarty->trigger_error("html_image: (secure) '$_image_path' not in secure directory", E_USER_NOTICE); + } + + if(!isset($params['width'])) { + $width = $_image_data[0]; + } + if(!isset($params['height'])) { + $height = $_image_data[1]; + } + + } + + if(isset($params['dpi'])) { + if(strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) { + $dpi_default = 72; + } else { + $dpi_default = 96; + } + $_resize = $dpi_default/$params['dpi']; + $width = round($width * $_resize); + $height = round($height * $_resize); + } + + return $prefix . ''.$alt.'' . $suffix; +} + +/* vim: set expandtab: */ + +?> diff --git a/smarty/libs/plugins/function.html_options.php b/smarty/libs/plugins/function.html_options.php new file mode 100644 index 00000000..cebadde4 --- /dev/null +++ b/smarty/libs/plugins/function.html_options.php @@ -0,0 +1,122 @@ + + * Name: html_options
+ * Input:
+ * - name (optional) - string default "select" + * - values (required if no options supplied) - array + * - options (required if no values supplied) - associative array + * - selected (optional) - string default not set + * - output (required if not options supplied) - array + * Purpose: Prints the list of

+ * {html_radios values=$ids output=$names}
+ * {html_radios values=$ids name='box' separator='
' output=$names} + * {html_radios values=$ids checked=$checked separator='
' output=$names} + *
+ * @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios} + * (Smarty online manual) + * @author Christopher Kvarme + * @author credits to Monte Ohrt + * @version 1.0 + * @param array + * @param Smarty + * @return string + * @uses smarty_function_escape_special_chars() + */ +function smarty_function_html_radios($params, &$smarty) +{ + require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); + + $name = 'radio'; + $values = null; + $options = null; + $selected = null; + $separator = ''; + $labels = true; + $label_ids = false; + $output = null; + $extra = ''; + + foreach($params as $_key => $_val) { + switch($_key) { + case 'name': + case 'separator': + $$_key = (string)$_val; + break; + + case 'checked': + case 'selected': + if(is_array($_val)) { + $smarty->trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING); + } else { + $selected = (string)$_val; + } + break; + + case 'labels': + case 'label_ids': + $$_key = (bool)$_val; + break; + + case 'options': + $$_key = (array)$_val; + break; + + case 'values': + case 'output': + $$_key = array_values((array)$_val); + break; + + case 'radios': + $smarty->trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', E_USER_WARNING); + $options = (array)$_val; + break; + + case 'assign': + break; + + default: + if(!is_array($_val)) { + $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; + } else { + $smarty->trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE); + } + break; + } + } + + if (!isset($options) && !isset($values)) + return ''; /* raise error here? */ + + $_html_result = array(); + + if (isset($options)) { + + foreach ($options as $_key=>$_val) + $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids); + + } else { + + foreach ($values as $_i=>$_key) { + $_val = isset($output[$_i]) ? $output[$_i] : ''; + $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids); + } + + } + + if(!empty($params['assign'])) { + $smarty->assign($params['assign'], $_html_result); + } else { + return implode("\n",$_html_result); + } + +} + +function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids) { + $_output = ''; + if ($labels) { + if($label_ids) { + $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!', '_', $name . '_' . $value)); + $_output .= '