From 0c4ea746b855bd996a57bc7eca33925172cc23f8 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Thu, 22 May 2008 21:42:40 +0000 Subject: [PATCH] oops, missed this one -thanks cboltz git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@366 a1433add-5e2c-0410-b055-b7f2511e0802 --- create-alias-domain.php | 111 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 create-alias-domain.php diff --git a/create-alias-domain.php b/create-alias-domain.php new file mode 100644 index 00000000..23393906 --- /dev/null +++ b/create-alias-domain.php @@ -0,0 +1,111 @@ + 0) { + while ($row = db_array ($result['result'])) + { + $list_aliases[ $row['alias_domain'] ] = $row['target_domain']; + } +} + +if (isset ($_REQUEST['alias_domain'])) { + $fAliasDomain = escape_string ($_REQUEST['alias_domain']); + $fAliasDomain = strtolower ($fAliasDomain); +} +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; +} + +if ($_SERVER['REQUEST_METHOD'] == "POST") +{ + if(!authentication_has_role ('global-admin') && + !(check_owner ($SESSID_USERNAME, $fAliasDomain) && + check_owner ($SESSID_USERNAME, $fTargetDomain))) + { + $error = 1; + $tMessage = $PALANG['pCreate_alias_domain_error1']; + } + + if (isset($list_aliases[$fAliasDomain]) || // alias_domain is unique (primary key, a domain can't be an alias for multiple others) + in_array($fAliasDomain,$list_aliases) || // an alias_domain can't be a target_domain for a third domain. + isset($list_aliases[$fTargetDomain]) || // same as above, other way around + ($fAliasDomain == $fTargetDomain) || // i really don't have to + empty($fAliasDomain) || empty($fTargetDomain)) // explain this, do i? + { + $error = 1; + $tMessage = $PALANG['pCreate_alias_domain_error2']; + } + + $sqlActive = db_get_boolean($fActive); + + if ($error != 1) { + $result = db_query ("INSERT INTO $table_alias_domain (alias_domain,target_domain,created,modified,active) VALUES ('$fAliasDomain','$fTargetDomain',NOW(),NOW(),'$sqlActive')"); + if ($result['rows'] != 1) { + $error = 1; + $tMessage = $PALANG['pCreate_alias_domain_error3']; + } + else { + db_log ($SESSID_USERNAME, $fAliasDomain, 'create_alias_domain', "$fAliasDomain -> $fTargetDomain"); + + $tMessage = $PALANG['pCreate_alias_domain_success']; + } + } + + $tMessage .= "
($fAliasDomain -> $fTargetDomain)
\n"; +} + +include ("templates/header.php"); +include ("templates/menu.php"); +include ("templates/create-alias-domain.php"); +include ("templates/footer.php"); +?>