// Copyright (c) 2022 High5! // License Info: LICENSE.TXT // // File: add-alias.php // // Template File: add-alias.tpl // // Template Variables: // // message // address // domain // goto // // POST / GET Variables: // // address // domain // goto // require_once './functions.inc.php'; include './languages/' . check_language() . '.lang'; $SESSID_USERNAME = check_session(); $ROLE = check_role($SESSID_USERNAME); if ($ROLE == ADMIN_ROLE) { $list_domains = list_domains(); } else { $list_domains = list_domains($SESSID_USERNAME); } if ($_SERVER['REQUEST_METHOD'] == "GET") { $domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN); $domain_key = array_search($domain, array_column($list_domains, 'domain')); } if ($_SERVER['REQUEST_METHOD'] == "POST") { $address = strtolower(filter_input(INPUT_POST, 'address', FILTER_DEFAULT)); $domain = filter_input(INPUT_POST, 'domain', FILTER_VALIDATE_DOMAIN); $goto = strtolower(filter_input(INPUT_POST, 'goto', FILTER_DEFAULT)); $domain_key = array_search($domain, array_column($list_domains, 'domain')); $from = filter_var($address . '@' . $domain, FILTER_VALIDATE_EMAIL); if (!str_contains($goto, '@')) { $goto = $goto . "@" . $domain; } $goto = filter_var($goto, FILTER_VALIDATE_EMAIL); if ($list_domains[$domain_key]['aliases'] != 0 && $list_domains[$domain_key]['alias_count'] >= $list_domains[$domain_key]['aliases']) { $message = $LANG['Add_alias_address_text_error2']; } if (empty($address) || empty($goto)) { $message = $LANG['Add_alias_address_text_error1']; } if (empty($message) && in_array($domain, array_column($list_domains, 'domain'))) { try { $dbh = pdo_connect(); $sth = $dbh->prepare("INSERT INTO alias (address,goto,domain,created,modified) VALUES (?,?,?,NOW(),NOW())"); $sth->bindParam(1, $from, PDO::PARAM_STR); $sth->bindParam(2, $goto, PDO::PARAM_STR); $sth->bindParam(3, $domain, PDO::PARAM_STR); $sth->execute(); logging($SESSID_USERNAME, $domain, $LANG['Logging_alias_add'], "$from -> $goto"); $message = $LANG['Add_alias_result_succes'] . "
($from -> $goto)
"; $address = ''; $goto = ''; } catch(PDOException $e) { $message = $LANG['Add_alias_result_error'] . "
($from -> $goto)
"; } } } include './templates/header.tpl'; include './templates/menu.tpl'; include './templates/add-alias.tpl'; include './templates/footer.tpl'; ?>