You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
postfixadmin/modify.php

92 lines
2.3 KiB
PHP

<?php
include "my_lib.php";
$sessid = check_session();
$url = "main.php?" . session_name() . "=" . session_id();
$modify = $_GET[modify];
if (!empty($_POST[submit])) {
$goto = $_POST[goto];
if (empty($goto)) {
print_header();
print_menu();
print "<hr>\n";
print "<p class=error>\n";
print "You didn't enter anything at <b>To:</b>.\n";
print_footer();
exit;
}
$goto = preg_replace('/\r\n/', ',', $goto);
$goto = preg_replace('/\,*$/', '', $goto);
$array = preg_split('/,/', $goto);
for ($i = 0; $i < sizeof($array); $i++) {
if (in_array("$array[$i]", $default_aliases)) continue;
if (empty($array[$i])) continue;
if (!check_email($array[$i])) {
print_header();
print_menu();
print "<hr>\n";
print "<p class=error>\n";
print "The email address <b>$array[$i]</b> is not a valid email address, please go back.\n";
print_footer();
exit;
}
}
$result = db_query ("UPDATE alias SET goto='$goto', change_date=NOW() WHERE address='$modify' AND domain='$sessid[domain]'");
if ($result[rows] == 1) {
header("Location: $url");
} else {
print_header();
print_menu();
print "<hr>\n";
print "<p class=error>\n";
print "<b>Unable</b> to update: <i>$address</i> -> <i>$goto</i> in the alias table!\n";
print_footer();
exit;
}
}
$query = "SELECT * FROM alias WHERE address='$modify' AND domain='$sessid[domain]'";
$result = db_query ("$query");
if ($result[rows] == 1) {
$row = mysql_fetch_array ($result[result]);
} else {
print_header();
print_menu();
print "<hr>\n";
print "<p class=error>\n";
print "Unable to find the alias!\n";
print_footer();
exit;
}
print_header();
print_menu();
print "<hr>\n";
?>
Change an alias for your domain.
<p>
<form name=modify method=post>
<table class=form>
<tr><td>Alias:</td><td><?php print "$modify"; ?></td></tr>
<tr><td colspan=2>&nbsp;</td></tr>
<tr><td colspan=2 align=center><b>Enter your email aliases below. One per line!</b></td></tr>
<tr><td valign=top>To:</td><td><textarea rows=24 cols=80 name=goto>
<?php
$array = preg_split('/,/', $row[goto]);
for ($i = 0 ; $i < sizeof($array) ; $i++) {
if (empty($array[$i])) continue;
print "$array[$i]\n";
}
?>
</textarea></td></tr>
<tr><td colspan=2 align=center><input type=submit name=submit value='Enter'></td></tr>
</table>
</form>
<?php
print_footer();
?>