SF.net SVN: postfixadmin:[757] trunk
Brought to you by:
christian_boltz,
gingerdog
From: <Seb...@us...> - 2009-11-05 14:55:51
|
Revision: 757 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=757&view=rev Author: Sebastian2009 Date: 2009-11-05 14:55:39 +0000 (Thu, 05 Nov 2009) Log Message: ----------- - big merge of Postfixadmin smarty into trunk Modified Paths: -------------- branches/postfixadmin-smarty/DOCUMENTS/DOVECOT.txt trunk/CHANGELOG.TXT trunk/INSTALL.TXT trunk/VIRTUAL_VACATION/vacation.pl trunk/backup.php trunk/broadcast-message.php trunk/common.php trunk/config.inc.php trunk/create-admin.php trunk/create-alias-domain.php trunk/create-alias.php trunk/create-domain.php trunk/create-mailbox.php trunk/css/default.css trunk/debian/changelog trunk/delete.php trunk/edit-active-admin.php trunk/edit-active-domain.php trunk/edit-active.php trunk/edit-admin.php trunk/edit-alias.php trunk/edit-domain.php trunk/edit-mailbox.php trunk/edit-vacation.php trunk/fetchmail.php trunk/functions.inc.php trunk/languages/de.lang trunk/languages/en.lang trunk/list-admin.php trunk/list-domain.php trunk/list-virtual.php trunk/login.php trunk/main.php trunk/model/AliasHandler.php trunk/model/UserHandler.php trunk/model/VacationHandler.php trunk/motd-users.txt trunk/motd.txt trunk/password.php trunk/search.php trunk/sendmail.php trunk/upgrade.php trunk/users/edit-alias.php trunk/users/login.php trunk/users/main.php trunk/users/password.php trunk/users/vacation.php trunk/variables.inc.php trunk/viewlog.php trunk/xmlrpc.php Added Paths: ----------- trunk/calendar.js trunk/configs/ trunk/configs/menu.conf trunk/css/calendar.css trunk/smarty/ trunk/smarty/libs/ trunk/smarty/libs/Config_File.class.php trunk/smarty/libs/Smarty.class.php trunk/smarty/libs/Smarty_Compiler.class.php trunk/smarty/libs/debug.tpl trunk/smarty/libs/internals/ trunk/smarty/libs/internals/core.assemble_plugin_filepath.php trunk/smarty/libs/internals/core.assign_smarty_interface.php trunk/smarty/libs/internals/core.create_dir_structure.php trunk/smarty/libs/internals/core.display_debug_console.php trunk/smarty/libs/internals/core.get_include_path.php trunk/smarty/libs/internals/core.get_microtime.php trunk/smarty/libs/internals/core.get_php_resource.php trunk/smarty/libs/internals/core.is_secure.php trunk/smarty/libs/internals/core.is_trusted.php trunk/smarty/libs/internals/core.load_plugins.php trunk/smarty/libs/internals/core.load_resource_plugin.php trunk/smarty/libs/internals/core.process_cached_inserts.php trunk/smarty/libs/internals/core.process_compiled_include.php trunk/smarty/libs/internals/core.read_cache_file.php trunk/smarty/libs/internals/core.rm_auto.php trunk/smarty/libs/internals/core.rmdir.php trunk/smarty/libs/internals/core.run_insert_handler.php trunk/smarty/libs/internals/core.smarty_include_php.php trunk/smarty/libs/internals/core.write_cache_file.php trunk/smarty/libs/internals/core.write_compiled_include.php trunk/smarty/libs/internals/core.write_compiled_resource.php trunk/smarty/libs/internals/core.write_file.php trunk/smarty/libs/plugins/ trunk/smarty/libs/plugins/block.textformat.php trunk/smarty/libs/plugins/compiler.assign.php trunk/smarty/libs/plugins/function.assign_debug_info.php trunk/smarty/libs/plugins/function.config_load.php trunk/smarty/libs/plugins/function.counter.php trunk/smarty/libs/plugins/function.cycle.php trunk/smarty/libs/plugins/function.debug.php trunk/smarty/libs/plugins/function.eval.php trunk/smarty/libs/plugins/function.fetch.php trunk/smarty/libs/plugins/function.html_checkboxes.php trunk/smarty/libs/plugins/function.html_image.php trunk/smarty/libs/plugins/function.html_options.php trunk/smarty/libs/plugins/function.html_radios.php trunk/smarty/libs/plugins/function.html_select_date.php trunk/smarty/libs/plugins/function.html_select_time.php trunk/smarty/libs/plugins/function.html_table.php trunk/smarty/libs/plugins/function.mailto.php trunk/smarty/libs/plugins/function.math.php trunk/smarty/libs/plugins/function.popup.php trunk/smarty/libs/plugins/function.popup_init.php trunk/smarty/libs/plugins/modifier.capitalize.php trunk/smarty/libs/plugins/modifier.cat.php trunk/smarty/libs/plugins/modifier.count_characters.php trunk/smarty/libs/plugins/modifier.count_paragraphs.php trunk/smarty/libs/plugins/modifier.count_sentences.php trunk/smarty/libs/plugins/modifier.count_words.php trunk/smarty/libs/plugins/modifier.date_format.php trunk/smarty/libs/plugins/modifier.debug_print_var.php trunk/smarty/libs/plugins/modifier.default.php trunk/smarty/libs/plugins/modifier.escape.php trunk/smarty/libs/plugins/modifier.indent.php trunk/smarty/libs/plugins/modifier.lower.php trunk/smarty/libs/plugins/modifier.needle.php trunk/smarty/libs/plugins/modifier.nl2br.php trunk/smarty/libs/plugins/modifier.regex_replace.php trunk/smarty/libs/plugins/modifier.replace.php trunk/smarty/libs/plugins/modifier.spacify.php trunk/smarty/libs/plugins/modifier.string_format.php trunk/smarty/libs/plugins/modifier.strip.php trunk/smarty/libs/plugins/modifier.strip_tags.php trunk/smarty/libs/plugins/modifier.truncate.php trunk/smarty/libs/plugins/modifier.upper.php trunk/smarty/libs/plugins/modifier.wordwrap.php trunk/smarty/libs/plugins/outputfilter.trimwhitespace.php trunk/smarty/libs/plugins/shared.escape_special_chars.php trunk/smarty/libs/plugins/shared.make_timestamp.php trunk/smarty.inc.php trunk/templates/admin_create-admin.tpl trunk/templates/admin_create-domain.tpl trunk/templates/admin_edit-admin.tpl trunk/templates/admin_edit-domain.tpl trunk/templates/admin_list-admin.tpl trunk/templates/admin_list-domain.tpl trunk/templates/broadcast-message.tpl trunk/templates/create-alias-domain.tpl trunk/templates/create-alias.tpl trunk/templates/create-mailbox.tpl trunk/templates/edit-alias.tpl trunk/templates/edit-mailbox.tpl trunk/templates/edit-vacation.tpl trunk/templates/fetchmail.tpl trunk/templates/footer.tpl trunk/templates/header.tpl trunk/templates/index.tpl trunk/templates/list-virtual.tpl trunk/templates/list-virtual_alias.tpl trunk/templates/list-virtual_alias_domain.tpl trunk/templates/list-virtual_mailbox.tpl trunk/templates/login.tpl trunk/templates/main.tpl trunk/templates/menu.tpl trunk/templates/message.tpl trunk/templates/motd-users.txt trunk/templates/motd.txt trunk/templates/overview-get.tpl trunk/templates/password.tpl trunk/templates/search.tpl trunk/templates/sendmail.tpl trunk/templates/users_edit-alias.tpl trunk/templates/users_login.tpl trunk/templates/users_main.tpl trunk/templates/users_menu.tpl trunk/templates/users_password.tpl trunk/templates/users_vacation.tpl trunk/templates/viewlog.tpl trunk/templates_c/ Removed Paths: ------------- trunk/templates/admin_create-admin.php trunk/templates/admin_create-domain.php trunk/templates/admin_edit-admin.php trunk/templates/admin_edit-domain.php trunk/templates/admin_list-admin.php trunk/templates/admin_list-domain.php trunk/templates/broadcast-message.php trunk/templates/create-alias-domain.php trunk/templates/create-alias.php trunk/templates/create-mailbox.php trunk/templates/edit-alias.php trunk/templates/edit-mailbox.php trunk/templates/edit-vacation.php trunk/templates/fetchmail.php trunk/templates/footer.php trunk/templates/header.php trunk/templates/index.php trunk/templates/list-virtual.php trunk/templates/login.php trunk/templates/main.php trunk/templates/menu.php trunk/templates/message.php trunk/templates/overview-get.php trunk/templates/password.php trunk/templates/search.php trunk/templates/sendmail.php trunk/templates/users_edit-alias.php trunk/templates/users_login.php trunk/templates/users_main.php trunk/templates/users_menu.php trunk/templates/users_password.php trunk/templates/users_vacation.php trunk/templates/viewlog.php Modified: branches/postfixadmin-smarty/DOCUMENTS/DOVECOT.txt =================================================================== --- branches/postfixadmin-smarty/DOCUMENTS/DOVECOT.txt 2009-11-03 21:58:40 UTC (rev 756) +++ branches/postfixadmin-smarty/DOCUMENTS/DOVECOT.txt 2009-11-05 14:55:39 UTC (rev 757) @@ -21,9 +21,10 @@ 1. Dovecot setup ----------------- -default_mail_env = maildir:/usr/local/virtual/%u/ +default_mail_env = maildir:/var/mail/vmail/%u/ auth default { + mechanisms plain userdb sql { # Path for SQL configuration file, see doc/dovecot-sql-example.conf args = /etc/dovecot-mysql.conf @@ -45,6 +46,7 @@ setup. Things you may need to change are db_password, uid and gid: connect = host=localhost dbname=postfix user=postfix password=postfix +driver = mysql # Default password scheme. # depends on your $CONF['encrypt'] setting: Modified: trunk/CHANGELOG.TXT =================================================================== --- trunk/CHANGELOG.TXT 2009-11-03 21:58:40 UTC (rev 756) +++ trunk/CHANGELOG.TXT 2009-11-05 14:55:39 UTC (rev 757) @@ -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 Modified: trunk/INSTALL.TXT =================================================================== --- trunk/INSTALL.TXT 2009-11-03 21:58:40 UTC (rev 756) +++ trunk/INSTALL.TXT 2009-11-05 14:55:39 UTC (rev 757) @@ -9,7 +9,7 @@ ---------- - 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) Modified: trunk/VIRTUAL_VACATION/vacation.pl =================================================================== --- trunk/VIRTUAL_VACATION/vacation.pl 2009-11-03 21:58:40 UTC (rev 756) +++ trunk/VIRTUAL_VACATION/vacation.pl 2009-11-05 14:55:39 UTC (rev 757) @@ -56,13 +56,16 @@ # Use Log4Perl # Added better testing (and -t option) # -# 2009-06-29 Stevan Bajic <st...@ba...> +# 2009-06-29 Stevan Bajic <stevan at bajic.ch> # Add Mail::Sender for SMTP auth + more flexibility # -# 2009-07-07 Stevan Bajic <st...@ba...> +# 2009-07-07 Stevan Bajic <stevan at bajic.ch> # 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::Sender, Email::Valid MIME::Charset, Log::Log4perl, Log::Dispatch, MIME::EncWords and GetOpt::Std @@ -316,25 +319,26 @@ 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) { my @row = $stm->fetchrow_array; Modified: trunk/backup.php =================================================================== --- trunk/backup.php 2009-11-03 21:58:40 UTC (rev 756) +++ trunk/backup.php 2009-11-05 14:55:39 UTC (rev 757) @@ -30,7 +30,11 @@ // TODO: make backup supported for postgres if ('pgsql'==$CONF['database_type']) { - print '<p>Sorry: Backup is currently not supported for your DBMS.</p>'; + $smarty->assign ('tMessage', '<p>Sorry: Backup is currently not supported for your DBMS ('.$CONF['database_type'].').</p>'); + $smarty->assign ('smarty_template', 'message'); + $smarty->display ('index.tpl'); +// print '<p>Sorry: Backup is currently not supported for your DBMS.</p>'; +die; } /* SELECT attnum,attname,typname,atttypmod-4,attnotnull,atthasdef,adsrc @@ -63,10 +67,10 @@ if (!$fh = fopen ($backup, 'w')) { $tMessage = "<div class=\"error_msg\">Cannot open file ($backup)</div>"; - 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 @@ 'fetchmail', 'log', 'mailbox', - 'quota', - 'quota2', + 'quota', + 'quota2', 'vacation', 'vacation_notification' ); Modified: trunk/broadcast-message.php =================================================================== --- trunk/broadcast-message.php 2009-11-03 21:58:40 UTC (rev 756) +++ trunk/broadcast-message.php 2009-11-05 14:55:39 UTC (rev 757) @@ -31,69 +31,70 @@ 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 .= "<br />" . $PALANG['pSendmail_result_error'] . "<br />"; - } - else - { - $tMessage .= "<br />" . $PALANG['pSendmail_result_success'] . "<br />"; - } + if (!smtp_mail ($fTo, $CONF['admin_email'], $fHeaders)) + { + $tMessage .= "<br />" . $PALANG['pSendmail_result_error'] . "<br />"; } - } - include ("templates/header.php"); - include ("templates/menu.php"); - echo '<p>'.$PALANG['pBroadcast_success'].'</p>'; - include ("templates/footer.php"); - } + else + { + $tMessage .= "<br />" . $PALANG['pSendmail_result_success'] . "<br />"; + } + } + } + $smarty->assign ('tMessage', $PALANG['pBroadcast_success']); + $smarty->assign ('smarty_template', 'message'); + $smarty->display ('index.tpl'); +// echo '<p>'.$PALANG['pBroadcast_success'].'</p>'; + } } 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: */ Added: trunk/calendar.js =================================================================== --- trunk/calendar.js (rev 0) +++ trunk/calendar.js 2009-11-05 14:55:39 UTC (rev 757) @@ -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: trunk/common.php =================================================================== --- trunk/common.php 2009-11-03 21:58:40 UTC (rev 756) +++ trunk/common.php 2009-11-05 14:55:39 UTC (rev 757) @@ -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 @@ } 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 Modified: trunk/config.inc.php =================================================================== --- trunk/config.inc.php 2009-11-03 21:58:40 UTC (rev 756) +++ trunk/config.inc.php 2009-11-05 14:55:39 UTC (rev 757) @@ -29,7 +29,6 @@ // 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 @@ // 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 @@ 'vacation' => 'vacation', 'vacation_notification' => 'vacation_notification', 'quota' => 'quota', - 'quota2' => 'quota2', + 'quota2' => 'quota2', ); // Site Admin @@ -308,7 +306,6 @@ // 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_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 Added: trunk/configs/menu.conf =================================================================== --- trunk/configs/menu.conf (rev 0) +++ trunk/configs/menu.conf 2009-11-05 14:55:39 UTC (rev 757) @@ -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 class="header"> +tr_hilightoff = <tr class="hilightoff" onmouseover="className='hilighton';" onmouseout="className='hilightoff';"> + +url_delete = delete.php +url_search = search.php +form_search = <form name="search" method="post" action="search.php"><input name="search" size="10" /></form> + +[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 Modified: trunk/create-admin.php =================================================================== --- trunk/create-admin.php 2009-11-03 21:58:40 UTC (rev 756) +++ trunk/create-admin.php 2009-11-05 14:55:39 UTC (rev 757) @@ -34,7 +34,6 @@ require_once('common.php'); authentication_require_role('global-admin'); - $list_domains = list_domains (); $tDomains = array(); @@ -51,7 +50,6 @@ 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 @@ } } -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: */ ?> Modified: trunk/create-alias-domain.php =================================================================== --- trunk/create-alias-domain.php 2009-11-03 21:58:40 UTC (rev 756) +++ trunk/create-alias-domain.php 2009-11-05 14:55:39 UTC (rev 757) @@ -86,11 +86,14 @@ $fTargetDomain = escape_string ($_REQUEST['target_domain']); $fTargetDomain = strtolower ($fTargetDomain); } +//*** ????? if (isset ($_REQUEST['active'])) { $fActive = (bool)$_REQUEST['active']; } else { + $fActive = false; +} +if (!isset ($_REQUEST['submit'])) $fActive = true; -} if ($_SERVER['REQUEST_METHOD'] == "POST") { @@ -132,10 +135,13 @@ $tMessage .= "<br />($fAliasDomain -> $fTargetDomain)<br />\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 = '<span class="error_msg">'.$tMessage.'</span>'; +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'create-alias-domain'); +$smarty->display ('index.tpl'); /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> Modified: trunk/create-alias.php =================================================================== --- trunk/create-alias.php 2009-11-03 21:58:40 UTC (rev 756) +++ trunk/create-alias.php 2009-11-05 14:55:39 UTC (rev 757) @@ -124,7 +124,7 @@ $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 @@ $tDomain = $fDomain; $tMessage = $PALANG['pCreate_alias_result_success'] . "<br />($fAddress -> $fGoto)<br />\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: */ ?> Modified: trunk/create-domain.php =================================================================== --- trunk/create-domain.php 2009-11-03 21:58:40 UTC (rev 756) +++ trunk/create-domain.php 2009-11-05 14:55:39 UTC (rev 757) @@ -142,10 +142,18 @@ } } -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: */ ?> Modified: trunk/create-mailbox.php =================================================================== --- trunk/create-mailbox.php 2009-11-03 21:58:40 UTC (rev 756) +++ trunk/create-mailbox.php 2009-11-05 14:55:39 UTC (rev 757) @@ -40,235 +40,240 @@ 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'] . "<br />($fUsername -> $fUsername)</br />"; - } + $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'] . "<br />($fUsername -> $fUsername)</br />"; + } + // 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'] . "<br />($fUsername)<br />"; + 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'] . "<br />($fUsername)<br />"; - 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 .= "<br />" . $PALANG['pSendmail_result_error'] . "<br />"; + } + else + { + $tMessage .= "<br />" . $PALANG['pSendmail_result_success'] . "<br />"; + } + } - $fHeaders .= $CONF['welcome_text']; + $tShowpass = ""; + if ( $tPassGenerated == 1 || $CONF['show_password'] == "YES") $tShowpass = " / $fPassword"; - if (!smtp_mail ($fTo, $fFrom, $fHeaders)) - { - $tMessage .= "<br />" . $PALANG['pSendmail_result_error'] . "<br />"; - } - else - { - $tMessage .= "<br />" . $PALANG['pSendmail_result_success'] . "<br />"; - } - } + if (create_mailbox_subfolders($fUsername,$fPassword)) + { + $tMessage .= $PALANG['pCreate_mailbox_result_success'] . "<br />($fUsername$tShowpass)"; + } else { + $tMessage .= $PALANG['pCreate_mailbox_result_succes_nosubfolders'] . "<br />($fUsername$tShowpass)"; + } - $tShowpass = ""; - if ( $tPassGenerated == 1 || $CONF['show_password'] == "YES") $tShowpass = " / $fPassword"; + } + } +} - if (create_mailbox_subfolders($fUsername,$fPassword)) - { - $tMessage .= $PALANG['pCreate_mailbox_result_success'] . "<br />($fUsername$tShowpass)"; - } else { - $tMessage .= $PALANG['pCreate_mailbox_result_succes_nosubfolders'] . "<br />($fUsername$tShowpass)"; - } +$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'); - } - } -} -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/create-mailbox.php"); -include ("templates/footer.php"); - /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> Added: trunk/css/calendar.css =================================================================== --- trunk/css/calendar.css (rev 0) +++ trunk/css/calendar.css 2009-11-05 14:55:39 UTC (rev 757) @@ -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; + colo... [truncated message content] |