SF.net SVN: postfixadmin:[1317] trunk
Brought to you by:
christian_boltz,
gingerdog
From: <chr...@us...> - 2012-01-10 00:30:07
|
Revision: 1317 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1317&view=rev Author: christian_boltz Date: 2012-01-10 00:30:01 +0000 (Tue, 10 Jan 2012) Log Message: ----------- create-alias.php: - deleted, obsoleted by edit.php?table=alias functions.inc.php: - drop function check_alias() - it was only used by create-alias.php (AliasHandler has a similar function create_allowed(), which is a copy of check_alias() with superfluous {...} removed) configs/menu.conf - replace create-alias.php with edit.php?table=alias - append "?" to url_create_mailbox to avoid temporary change in menu.tpl (create-mailbox is the only one which still needs ? instead of &) templates/list-virtual.tpl: - use {#url_create_alias#} instead of hardcoded create-alias.php templates/menu.tpl: - $url_domain: url-escape domain, use & instead of ? Modified Paths: -------------- trunk/configs/menu.conf trunk/functions.inc.php trunk/templates/list-virtual.tpl trunk/templates/menu.tpl Removed Paths: ------------- trunk/create-alias.php Modified: trunk/configs/menu.conf =================================================================== --- trunk/configs/menu.conf 2012-01-10 00:07:09 UTC (rev 1316) +++ trunk/configs/menu.conf 2012-01-10 00:30:01 UTC (rev 1317) @@ -7,8 +7,8 @@ url_edit_domain = edit.php?table=domain # list-virtual url_list_virtual = list-virtual.php -url_create_mailbox = create-mailbox.php -url_create_alias = create-alias.php +url_create_mailbox = create-mailbox.php? +url_create_alias = edit.php?table=alias url_create_alias_domain = edit.php?table=aliasdomain # fetchmail url_fetchmail = fetchmail.php Deleted: trunk/create-alias.php =================================================================== --- trunk/create-alias.php 2012-01-10 00:07:09 UTC (rev 1316) +++ trunk/create-alias.php 2012-01-10 00:30:01 UTC (rev 1317) @@ -1,203 +0,0 @@ -<?php -/** - * Postfix Admin - * - * LICENSE - * - * This source file is subject to the GPL license that is bundled with - * this package in the file LICENSE.TXT. - * - * Further details on the project are available at : - * http://www.postfixadmin.com or http://postfixadmin.sf.net - * - * File: create-alias.php - * Template File: create-alias.tpl - * Responsible for allowing for the creation of mail aliases. - * - * @version $Id$ - * @license GNU GPL v2 or later. - * - * Template Variables: - * - * tAddress - * tGoto - * tDomain - * - * Form POST \ GET Variables: - * - * fAddress - * fGoto - * fDomain - * - */ - -require_once('common.php'); - -authentication_require_role('admin'); -$username = authentication_get_username(); -$SESSID_USERNAME = $username; -if(authentication_has_role('global-admin')) { - $list_domains = list_domains (); -} -else { - $list_domains = list_domains_for_admin ($username); -} - -$pCreate_alias_address_text_error = ""; - -if ($_SERVER['REQUEST_METHOD'] == "GET") -{ - if (isset ($_GET['domain'])) { - $tDomain = escape_string ($_GET['domain']); - } -} - -if ($_SERVER['REQUEST_METHOD'] == "POST") -{ - if (isset ($_POST['fAddress']) && isset ($_POST['fDomain'])) { - $fAddress = escape_string($_POST['fAddress']) . "@" . escape_string ($_POST['fDomain']); - $fAddress = strtolower ($fAddress); - } - - if (isset ($_POST['fGoto'])) { - $fGoto = escape_string ($_POST['fGoto']); - $fGoto = strtolower ($fGoto); - } - if(isset($_POST['fActive'])) { - $fActive = escape_string ($_POST['fActive']); - } - else { - $fActive = "1"; - } - - if(isset($_POST['fDomain'])) { - $fDomain = escape_string ($_POST['fDomain']); - } - -# TODO: Doesn't work with multiple aliases - fix or discard... -# if(!preg_match ('/@/',$fGoto)) { -# $fGoto = $fGoto . "@" . escape_string ($_POST['fDomain']); -# } - - if(!(authentication_has_role('global-admin') || - check_owner ($SESSID_USERNAME, $fDomain) )) - { - $error = 1; - $tAddress = escape_string ($_POST['fAddress']); - $tGoto = $fGoto; - $tDomain = $fDomain; - $pCreate_alias_address_text_error = $PALANG['pCreate_alias_address_text_error1']; - } - - if(!check_alias($fDomain)) { - $error = 1; - $tAddress = escape_string ($_POST['fAddress']); - $tGoto = $fGoto; - $tDomain = $fDomain; - $pCreate_alias_address_text_error = $PALANG['pCreate_alias_address_text_error3']; - } - - if(empty ($fAddress) || !check_email ($fAddress)) { - $error = 1; - $tAddress = escape_string ($_POST['fAddress']); - $tGoto = $fGoto; - $tDomain = $fDomain; - $pCreate_alias_address_text_error = $PALANG['pCreate_alias_address_text_error1']; - } - - // Begin check alias email - $goto = preg_replace ('/\\\r\\\n/', ',', $fGoto); - $goto = preg_replace ('/\r\n/', ',', $goto); - $goto = preg_replace ('/,[\s]+/i', ',', $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']; - flash_error($PALANG['pEdit_alias_goto_text_error1']); - } - - $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; - flash_error($PALANG['pEdit_alias_goto_text_error2'] . "$address"); - } - } - - $goto = implode(',', $new_aliases); - $fGoto = escape_string($goto); - // End check alias mail - - if (empty($fGoto)) { - $error = 1; - $tAddress = escape_string ($_POST['fAddress']); - $tGoto = $fGoto; - $tDomain = $fDomain; - flash_error($PALANG['pCreate_alias_address_text_error1']); - } - - if (escape_string($_POST['fAddress']) == "*") { - $fAddress = "@" . escape_string ($_POST['fDomain']); - } - - $result = db_query ("SELECT * FROM $table_alias WHERE address='$fAddress'"); - if ($result['rows'] == 1) - { - $error = 1; - $tAddress = escape_string ($_POST['fAddress']); - $tGoto = $fGoto; - $tDomain = $fDomain; - $pCreate_alias_address_text_error = $PALANG['pCreate_alias_address_text_error2']; - } - - if ($fActive == "on") { - $sqlActive = db_get_boolean(True); - } - else { - $sqlActive = db_get_boolean(False); - } - - if ($error != 1) { - if (preg_match('/^\*@(.*)$/', $fGoto, $match)) { - $fGoto = "@" . $match[1]; - } - - $result = db_query ("INSERT INTO $table_alias (address,goto,domain,created,modified,active) VALUES ('$fAddress','$fGoto','$fDomain',NOW(),NOW(),'$sqlActive')"); - if ($result['rows'] != 1) { - $tDomain = $fDomain; - flash_error($PALANG['pCreate_alias_result_error'] . "<br />($fAddress -> $fGoto)<br />\n"); - } - else { - db_log ($fDomain, 'create_alias', "$fAddress -> $fGoto"); - - $tDomain = $fDomain; - flash_info($PALANG['pCreate_alias_result_success'] . "<br />($fAddress -> $fGoto)<br />\n"); - } - } else { # on error - $tAddress = htmlentities($_POST['fAddress']); - $tGoto = htmlentities($_POST['fGoto']); - $tDomain = htmlentities($_POST['fDomain']); - } -} - -$smarty->assign ('mode', 'create'); -$smarty->assign ('tAddress', $tAddress); -$smarty->assign ('select_options', select_options ($list_domains, array ($tDomain)), false); -$smarty->assign ('pCreate_alias_address_text_error', $pCreate_alias_address_text_error, false); -$smarty->assign ('tGoto', $tGoto, false); -$smarty->assign ('smarty_template', 'edit-alias'); -$smarty->display ('index.tpl'); - -/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ -?> Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2012-01-10 00:07:09 UTC (rev 1316) +++ trunk/functions.inc.php 2012-01-10 00:30:01 UTC (rev 1317) @@ -577,29 +577,6 @@ // -// check_alias -// Action: Checks if the domain is still able to create aliases. -// Call: check_alias (string domain) -// -function check_alias ($domain) { - $limit = get_domain_properties ($domain); - if ($limit['aliases'] == 0) { - # 0 = unlimited, -1 = disabled - return true; - } - if ($limit['aliases'] < 0) { - return false; - } - if ($limit['alias_count'] >= $limit['aliases']) { - return false; - } else { - return true; - } -} - - - -// // check_mailbox // Action: Checks if the domain is still able to create mailboxes. // Call: check_mailbox (string domain) Modified: trunk/templates/list-virtual.tpl =================================================================== --- trunk/templates/list-virtual.tpl 2012-01-10 00:07:09 UTC (rev 1316) +++ trunk/templates/list-virtual.tpl 2012-01-10 00:30:01 UTC (rev 1317) @@ -45,7 +45,7 @@ </table> {$nav_bar_alias.bottom} {if $tCanAddAlias} - <br /><a href="create-alias.php?domain={$fDomain|escape:"url"}" class="button">{$PALANG.pMenu_create_alias}</a><br /> + <br /><a href="{#url_create_alias#}&domain={$fDomain|escape:"url"}" class="button">{$PALANG.pMenu_create_alias}</a><br /> {/if} {/if} {if $tab=='all'}<br />{/if} Modified: trunk/templates/menu.tpl =================================================================== --- trunk/templates/menu.tpl 2012-01-10 00:07:09 UTC (rev 1316) +++ trunk/templates/menu.tpl 2012-01-10 00:30:01 UTC (rev 1317) @@ -3,7 +3,7 @@ {if !empty($smarty.get) && !empty($smarty.get.domain)} {*** zuweisung muss eleganter gehen ***} {assign var="url_domain" value=$smarty.get.domain} - {assign var="url_domain" value="?domain=$url_domain"} + {assign var="url_domain" value="&domain={$url_domain|escape:url}"} {/if} {/strip} <div id="menu"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |