2022-08-18 14:01:52 +02:00
|
|
|
<?php
|
|
|
|
//
|
|
|
|
// OpenSMTPD Admin
|
|
|
|
// by Mischa Peters <mischa at high5 dot nl>
|
|
|
|
// Copyright (c) 2022 High5!
|
|
|
|
// License Info: LICENSE.TXT
|
|
|
|
//
|
|
|
|
// File: edit-alias.php
|
|
|
|
//
|
|
|
|
// Template File: users_edit-alias.tpl
|
|
|
|
//
|
|
|
|
// Template Variables:
|
|
|
|
//
|
|
|
|
// tMessage
|
|
|
|
// tGoto
|
|
|
|
//
|
|
|
|
// Form POST \ GET Variables:
|
|
|
|
//
|
|
|
|
// fAddress
|
|
|
|
// fDomain
|
|
|
|
// fGoto
|
|
|
|
//
|
|
|
|
require("../variables.inc.php");
|
|
|
|
require("../config.inc.php");
|
|
|
|
require("../functions.inc.php");
|
|
|
|
include("../languages/" . check_language() . ".lang");
|
|
|
|
|
|
|
|
$USERID_USERNAME = check_user_session();
|
|
|
|
$USERID_DOMAIN = substr(strrchr($USERID_USERNAME, "@"), 1);
|
|
|
|
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
|
|
|
$result = db_query("SELECT * FROM alias WHERE address='$USERID_USERNAME'");
|
|
|
|
if ($result['rows'] == 1) {
|
|
|
|
$row = db_array($result['result']);
|
|
|
|
$tGoto = preg_replace('/vmail/', '', $row['goto']);
|
|
|
|
#$tGoto = $row['goto'];
|
|
|
|
} else {
|
2022-09-03 11:30:40 +02:00
|
|
|
$tMessage = $LANG['Edit_alias_address_error'];
|
2022-08-18 14:01:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
2022-09-03 11:30:40 +02:00
|
|
|
$pEdit_alias_goto = $LANG['Edit_alias_goto'];
|
2022-08-18 14:01:52 +02:00
|
|
|
|
|
|
|
if (isset($_POST['fGoto'])) $fGoto = escape_string($_POST['fGoto']);
|
|
|
|
$fGoto = strtolower($fGoto);
|
|
|
|
|
|
|
|
$goto = preg_replace('/\\\r\\\n/', ',', $fGoto);
|
|
|
|
$goto = preg_replace('/\r\n/', ',', $fGoto);
|
|
|
|
$goto = preg_replace('/[\s]+/i', '', $goto);
|
|
|
|
$goto = preg_replace('/\,*$/', '', $goto);
|
|
|
|
$array = preg_split('/,/', $goto);
|
|
|
|
for ($i = 0; $i < count($array); $i++) {
|
|
|
|
if (in_array("$array[$i]", $CONF['default_aliases'])) continue;
|
|
|
|
if (empty($array[$i])) continue;
|
|
|
|
if (!check_email($array[$i])) {
|
|
|
|
$error = 1;
|
|
|
|
$tGoto = $goto;
|
2022-09-03 11:30:40 +02:00
|
|
|
$tMessage = $LANG['Edit_alias_goto_text_error2'] . "$array[$i]</font>";
|
2022-08-18 14:01:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($error != 1) {
|
|
|
|
if (empty($goto)) {
|
|
|
|
$goto = "vmail";
|
|
|
|
} else {
|
|
|
|
$goto = "vmail," . $goto;
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = db_query("UPDATE alias SET goto='$goto',modified=NOW() WHERE address='$USERID_USERNAME'");
|
|
|
|
if ($result['rows'] != 1) {
|
2022-09-03 11:30:40 +02:00
|
|
|
$tMessage = $LANG['Edit_alias_result_error'];
|
2022-08-18 14:01:52 +02:00
|
|
|
} else {
|
|
|
|
db_log($USERID_USERNAME, $USERID_DOMAIN, "edit alias", "$USERID_USERNAME -> $goto");
|
|
|
|
|
|
|
|
header("Location: main.php");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
include("../templates/header.tpl");
|
|
|
|
include("../templates/users_menu.tpl");
|
|
|
|
include("../templates/users_edit-alias.tpl");
|
|
|
|
include("../templates/footer.tpl");
|
|
|
|
?>
|