e9ddc55b6f
Migrated to mysqli
561 lines
26 KiB
PHP
561 lines
26 KiB
PHP
<?php
|
|
/* NFOs */
|
|
/**
|
|
* Postfix-Mail-Account Management Script
|
|
*
|
|
* Coder: - R.T. @ preisroboter.de (tiebel@preisroboter.de)
|
|
- Jonny007-MKD (me@jonny007-mkd.de)
|
|
- Scott Moody
|
|
* Codestyle: Quick & Dirty ( & Tidied up) (but still works fine ;) )
|
|
* "Copyrights": GNU / GPL
|
|
*
|
|
* Just change the VARs to your environment (DB) and
|
|
* restrict the access on this file with e.g. htaccess
|
|
**/
|
|
|
|
/* Var-Setup */
|
|
define('db_server','localhost');
|
|
define('db_name','mail');
|
|
define('db_user','mail');
|
|
define('db_pwd','GwH_s8gJW:FvKV8RywoENMOAUJbGQyF:');
|
|
$lang = 'de';
|
|
|
|
/* Functions */
|
|
function query($sql) {
|
|
global $cid, $mysql_result;
|
|
echo $sql;
|
|
if($sql) return $mysql_result = $cid->query($sql);
|
|
//else die(mysql_error());
|
|
}
|
|
|
|
function fetch($res) {
|
|
global $mysql_result;
|
|
if($res) return $res->fetch_all(MYSQLI_BOTH);
|
|
else return false;
|
|
}
|
|
|
|
function connect() {
|
|
global $cid,$db;
|
|
$cid = new mysqli(db_server, db_user, db_pwd, db_name);
|
|
if ($cid->connect_errno) die("Verbindung fehlgeschlagen: " . $mysqli->connect_error);
|
|
}
|
|
|
|
function disconnect() {
|
|
global $cid;
|
|
if(!($cid->close())) die("Fehler beim Trennen der Verbindung!");
|
|
}
|
|
|
|
function pw_encode($password, $rounds=10000) {
|
|
$salt = substr ( str_shuffle ( './0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ) , 0, 22 );
|
|
return crypt ($password, '$5$rounds=' . $rounds . '$' . $salt);
|
|
}
|
|
|
|
|
|
/* Initialize */
|
|
connect();
|
|
$do = array_key_exists('do', $_REQUEST) ? $_REQUEST['do'] : false;
|
|
$id = array_key_exists('id', $_REQUEST) ? $_REQUEST['id'] : false;
|
|
$new = array_key_exists('new', $_REQUEST) ? $_REQUEST['new'] : false;
|
|
$del = array_key_exists('del', $_REQUEST) ? $_REQUEST['del'] : false;
|
|
$chg = array_key_exists('chg', $_REQUEST) ? $_REQUEST['chg'] : false;
|
|
$ack = array_key_exists('ack', $_REQUEST) ? $_REQUEST['ack'] : false;
|
|
$domain = array_key_exists('domain' , $_REQUEST) ? $_REQUEST['domain' ] : false;
|
|
$source = array_key_exists('source' , $_REQUEST) ? $_REQUEST['source' ] : false;
|
|
$usr = array_key_exists('usr' , $_REQUEST) ? $_REQUEST['usr' ] : false;
|
|
$pwd = array_key_exists('pwd' , $_REQUEST) ? $_REQUEST['pwd' ] : false;
|
|
$dest = array_key_exists('dest' , $_REQUEST) ? $_REQUEST['dest' ] : false;
|
|
$enabled = array_key_exists('enabled', $_REQUEST) ? $_REQUEST['enabled'] : false;
|
|
$ndomain = array_key_exists('ndomain', $_REQUEST) ? $_REQUEST['ndomain'] : false;
|
|
$orderby = array_key_exists('orderby', $_REQUEST) ? $_REQUEST['orderby'] : false;
|
|
$sel = array_key_exists('sel' , $_REQUEST) ? $_REQUEST['sel' ] : false;
|
|
|
|
$fetch_list = $cid->query("SELECT * FROM `domains` ORDER BY `domain` ASC");
|
|
$orderbysql = $orderby ? ' ORDER BY '.$orderby.';' : ';';
|
|
$selectsql = $sel ? ' AND domain_id = '.$sel : '';
|
|
## Query Aliases ##
|
|
$sql[1] = "SELECT alias_id, source_username, source_domain, destinations, enabled FROM view_aliases";
|
|
if ($sel) $sql[1] .= " WHERE domain_id=" . ($sel+0);
|
|
$sql[1] .= $orderbysql;
|
|
|
|
## Query Domains ##
|
|
$sql[2] = "SELECT * FROM domains " . $orderbysql;
|
|
|
|
## Query Users ##
|
|
$sql[3] = "SELECT account_id, user, domain FROM view_accounts";
|
|
if ($sel) $sql[3] .= " WHERE domain_id=" . ($sel+0);
|
|
$sql[3] .= $orderbysql;
|
|
|
|
## Insert Alias Query ##
|
|
if(($domain <> "") && ($dest <> "")) $sql[4] = "INSERT INTO aliases (source_username, source_domain, destination, enabled) VALUES ('$source','$domain','$dest',1);";
|
|
|
|
## Insert Domain Query ##
|
|
if($ndomain <> "") {
|
|
$sql0 = "SELECT domain FROM domains WHERE domain = '$ndomain';";
|
|
$qr = query($sql0);
|
|
if($qr->num_rows() < 1) $sql[5] = "INSERT INTO domains (domain) VALUES ('$ndomain');";
|
|
}
|
|
|
|
## Insert User Query ##
|
|
if(($domain <> "") && ($usr <> "") && ($pwd <> "")) {
|
|
$sql1 = "SELECT domain_id, user, password FROM accounts WHERE domain = $domain AND username = '$usr';";
|
|
$qr = query($sql1);
|
|
if($qr->num_rows() < 1) $sql[6] = "INSERT INTO accounts (domain, username, password, enabled) VALUES ('$domain','$usr','".pw_encode($pwd)."',1);";
|
|
}
|
|
|
|
## Delete Query ##
|
|
if(($del <> "") && ($id <> "") && ($ack == 'Yes')) {
|
|
switch ($del) {
|
|
case 1: $sql = "DELETE FROM aliases WHERE id = $id;"; break;
|
|
case 2: $sql = "DELETE FROM domains WHERE id = $id;"; break;
|
|
case 3: $sql = "DELETE FROM accounts WHERE id = $id;"; break;
|
|
}
|
|
|
|
$qry = query($sql);
|
|
}
|
|
|
|
## Update Alias Query##
|
|
if(($chg == 1) && ($id <> "") && ($domain <> "") && ($dest <> "") && ($ack == 'Save')) {
|
|
$sql = "UPDATE aliases SET source_domain = '".$domain."', source_username = '".$source."', destination = '".$dest."', enabled = '".$enabled."' WHERE id = ".$id.";";
|
|
$qry = query($sql);
|
|
}
|
|
|
|
## Update Domain Query ##
|
|
if(($chg == 2) && ($id <> "") && ($domain <> "") && ($ack == 'Save')) {
|
|
$sql = "UPDATE domains SET domain='".$domain."' WHERE id = ".$id.";";
|
|
$qry = query($sql);
|
|
}
|
|
|
|
## Update User Query ##
|
|
if(($chg == 3) && ($id <> "") && ($domain <> "") && ($usr <> "") && ($pwd <> "") && ($ack == 'Save')) {
|
|
$sql = "UPDATE accounts SET domain ='".$domain."', username ='".$usr."', password = '".pw_encode($pwd)."' WHERE id = ".$id.";";
|
|
$qry = query($sql);
|
|
}
|
|
if($do) { $qry = query($sql[$do]);
|
|
if($qry) $result = true;
|
|
else $result = false;
|
|
}
|
|
|
|
|
|
|
|
/* Code */
|
|
?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<title>Mail-Control</title>
|
|
<meta name="AUTHOR" content="RT" />
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
|
|
<style type="text/css">
|
|
<!--
|
|
body {
|
|
font-family: Verdana;
|
|
}
|
|
#head {
|
|
font-weight: bold;
|
|
font-size: 1.2em;
|
|
}
|
|
#topLinks {
|
|
margin: 1em;
|
|
}
|
|
#topLinks a {
|
|
color: #000;
|
|
}
|
|
#topLinks a:hover, #topLinks a:focus {
|
|
color: #444;
|
|
}
|
|
#listing td, #listing th {
|
|
border-left: 1px solid #000; border-bottom: 1px solid #000;
|
|
}
|
|
table {
|
|
margin: auto
|
|
}
|
|
.table {
|
|
border: 1px solid #000;
|
|
text-align: center;
|
|
vertical-align: middle;
|
|
horizontal-align: center;
|
|
margin: auto;
|
|
width: 1000px;
|
|
}
|
|
.align-center {
|
|
border: 1px solid #EEE;
|
|
margin: auto;
|
|
width: auto;
|
|
padding: 5px;
|
|
overflow: visible;
|
|
}
|
|
.align-left {
|
|
text-align: left;
|
|
}
|
|
.align-right {
|
|
text-align: right;
|
|
}
|
|
input[type=text], input[type=password], select {
|
|
width: 200px;
|
|
background: #EFEFEF;
|
|
border: 1px solid #AAA;
|
|
}
|
|
select {
|
|
width: 203px;
|
|
}
|
|
input[type=text]:focus, input[type=password]:focus, select:focus {^
|
|
background: #F9F9F9;
|
|
border: 1px solid #555;
|
|
}
|
|
.rowcolor0 {
|
|
background: #EFEFEF;
|
|
}
|
|
.rowcolor1 {
|
|
background: #E0E0E0;
|
|
}
|
|
th {
|
|
background: #BBB;
|
|
}
|
|
a {
|
|
color: #555;
|
|
text-decoration: none;
|
|
}
|
|
img {
|
|
border: 0;
|
|
margin: 2px
|
|
}
|
|
#orderedby {
|
|
background-color: #888;
|
|
text-decoration: underline;
|
|
}
|
|
a:hover, a:focus {
|
|
color: #111;
|
|
text-decoration: underline;
|
|
}
|
|
#behindPwd {
|
|
color: #00F;
|
|
text-decoration: underline;
|
|
font-size: 0.7em;
|
|
}
|
|
-->
|
|
</style>
|
|
<script type="text/javascript">
|
|
<!--
|
|
function onBodyLoad() {
|
|
window.onload = "create();";
|
|
window.setTimeout(create, 1000);
|
|
return true;
|
|
}
|
|
function create() {
|
|
mc = {
|
|
do: '<?php echo $do; ?>',
|
|
sel: '<?php echo $sel; ?>',
|
|
changeSel: function(sel) {
|
|
document.location.href = '<?php echo '?do='.$do.'&sel=\'+sel+\'&orderby='.$orderby ?>';
|
|
},
|
|
togglePwd: function(beh) {
|
|
//var beh = document.getElementById("behindPwd")
|
|
var inp = document.getElementById("pwdInput")
|
|
if (inp.type == 'password') {
|
|
inp.type = 'text';
|
|
beh.innerHTML = '<?php echo('hide password'); ?>';
|
|
} else {
|
|
inp.type = 'password';
|
|
beh.innerHTML = '<?php echo('show password'); ?>';
|
|
}
|
|
},
|
|
setDomain: function(domain) {
|
|
document.getElementById("behindSource").innerHTML = '@' + domain;
|
|
}
|
|
};
|
|
}
|
|
-->
|
|
</script>
|
|
</head>
|
|
<body onload="onBodyLoad();">
|
|
<div style="text-align: center;">
|
|
<h2>Mail-Control v1.3</h2>
|
|
<form id="selection" action=""><div>
|
|
<select name="sel_domain" id="sel_domain" onchange="mc.changeSel(this.value)">
|
|
<option value=""><?php echo('All') ?></option>
|
|
<?php
|
|
while ($dlist = $fetch_list->fetch_assoc()) {
|
|
if ($dlist['id'] == $sel) echo ' <option value="'. $dlist['id'] .'" selected="selected">'. $dlist['domain'] .'</option>';
|
|
else echo ' <option value="'. $dlist['id'] .'">'. $dlist['domain'].'</option>';
|
|
}
|
|
?>
|
|
</select>
|
|
</div></form>
|
|
<div id="topLinks">
|
|
<a href="<?php echo '?do=1&sel='.$sel ?>" id="aliases_link"><strong><?php echo('Aliases') ?></strong></a> ǀ <a href="<?php echo '?do=2&sel='.$sel ?>" id="domains_link"><strong><?php echo('Domains') ?></strong></a> ǀ <a href="<?php echo '?do=3&sel='.$sel ?>" id="user_link"><strong><?php echo('User') ?></strong></a>
|
|
</div>
|
|
</div>
|
|
<hr />
|
|
<div>
|
|
<?php
|
|
switch($new) {
|
|
case 1:
|
|
$sql = "SELECT id,domain FROM domains;";
|
|
$qry = query($sql);
|
|
$out = ' <div style="text-align: center;"><span id="head">New Alias</span><br /><form action="?do=4&sel='.$sel.'&orderby='.$orderby.'" method="post">';
|
|
$out.= '<table class="align-center"><tr><td class="align-right">Domain:</td>';
|
|
$out.= '<td class="align-left"><select name="domain" size="1">';
|
|
foreach(fetch($qry) as $row) {
|
|
$out.= '<option value="'.$row[0].'" onclick="mc.setDomain(this.innerHTML)"';
|
|
$out.= ($row[0]==$sel) ? 'selected="selected">' :'>';
|
|
$out.= $row[1].'</option>';
|
|
}
|
|
$out.= '</select></td></tr>';
|
|
$out.= '<tr><td class="align-right">Source:</td><td class="align-left"><input type="text" id="src" name="src" size="20"></input><span id="behindSource">@Domain</span></td></tr>';
|
|
$out.= '<tr><td class="align-right">Destination:</td><td class="align-left"><input type="text" id="dest" name="dest" size="20"></input></td></tr>';
|
|
$out.= '<tr><td class="align-right"><input type="button" ';
|
|
$out .= 'onclick="var d=prompt(\'Insert domain\');';
|
|
switch($sel) {
|
|
case 2:
|
|
$out .= 'd=\'ns-\'+d+\'-\';'; break;
|
|
case 1:
|
|
$out .= 'd=\'wi-\'+d+\'-\';'; break;
|
|
default:
|
|
$out .= 'd=\'-\'+d+\'-\';'; break;
|
|
}
|
|
$out .= 'if (d){document.querySelector(\'#src\').value=d+Math.floor((Math.random() * 89999) + 10000);
|
|
';
|
|
$out .= 'document.querySelector(\'#dest\').value=\'nospam@jonny007-mkd.de\';}';
|
|
$out .= '" value="NS"></input></td><td class="align-left"><input type="submit" value="Ok"></input></td></tr>';
|
|
$out.= '</table></form></div>';
|
|
break;
|
|
case 2:
|
|
$out = '<div style="text-align: center;"><span id="head">New Domain</span><form action="?do=5&sel='.$sel.'&orderby='.$orderby.'" method="post">';
|
|
$out.= '<table class="align-center"><tr><td class="align-right">Name:</td><td class="align-left"><input type="text" name="new_domain" size="20"></input></td></tr>';
|
|
$out.= '<tr><td class="align-right"><input type="reset" value="Zurüksetzen"></input></td><td class="align-left"><input type="submit" value="Ok"></input></td></tr>';
|
|
$out.= '</table></form></div>';
|
|
break;
|
|
case 3:
|
|
$sql = "SELECT id,domain FROM domains;";
|
|
$qry = query($sql);
|
|
$out = '<div style="text-align: center;"><span id="head">New User</span><form action="?do=6&sel='.$sel.'&orderby='.$orderby.'" method="post">';
|
|
$out.= '<table class="align-center"><tr><td class="align-right">Domain:</td>';
|
|
$out.= '<td class="align-left"><select name="domain" size="1">';
|
|
foreach(fetch($qry) as $row) {
|
|
$out.= '<option value="'.$row[0].'" onclick="mc.setDomain(this.innerHTML)"';
|
|
$out.= ($row[0]==$sel) ? 'selected="selected">' : '>';
|
|
$out.=$row[1].'</option>';
|
|
}
|
|
$out.= '</select></td></tr>';
|
|
$out.= '<tr><td class="align-right">Username:</td><td class="align-left"><input type="text" name="usr" size="20"></input><span id="behindSource">@Domain</span></td></tr>';
|
|
$out.= '<tr><td class="align-right">Password:</td><td class="align-left"><input type="password" id="pwdInput" name="pwd" size="20"></input> <span id="behindPwd" onclick="mc.togglePwd(this);">show password</span></td></tr>';
|
|
$out.= '<tr><td class="align-right"><input type="reset" value="Zurüksetzen"></input></td><td class="align-left"><input type="submit" value="Ok"></input></td></tr>';
|
|
$out.= '</table></form></div>';
|
|
break;
|
|
}
|
|
|
|
switch($do) {
|
|
case 1:
|
|
$thname = array('Action','ID','Source','Domain','Destination','Enabled');
|
|
$thback = array('','alias_id','source','source_domain','destinations','enabled');
|
|
$out.= '<div><div style="text-align: center;"><div id="head">Alias Management</div><a href="?new=1&sel='.$sel.'&orderby='.$orderby.'">New Alias</a></div><br /><br />';
|
|
$out.='<table width="80%" class="table" rules="all"><tr>';
|
|
for ($a=0;$a<count($thname);$a++) {
|
|
$idordered = ($orderby==$thback[$a]&&!($sel&&$thname[$a]=='Domain')) ? '" id="orderedby' : '';
|
|
$link = (($thback[$a])&&!($orderby==$thback[$a])&&!($sel&&$thname[$a]=='Domain')) ? '<a href="?do='.$do.'&orderby='.$thback[$a].$idordered.'&sel='.$sel.'">' : '';
|
|
$endlink = ($link) ? '</a>' : '';
|
|
$out.='<th class="'.$thname[$a].$idordered.'">'.$link.$thname[$a].$endlink.'</th>';
|
|
}
|
|
$out.='</tr>';
|
|
foreach(fetch($qry) as $row) {
|
|
$i++;
|
|
$rowcolor = ($i%2==0) ? 'rowcolor0' : 'rowcolor1';
|
|
$out.='<tr class="'.$rowcolor.'"><td class="Aktion">';
|
|
if ($row[0] > 0) $out.='<a href="?chg=1&id='.$row[0].'&sel='.$sel.'&orderby='.$orderby.'" title="Change this record"><img src="edit.gif" alt="Edit" width="16" height="16"/></a><a href="?del=1&id='.$row[0].'&sel='.$sel.'" title="Delete this record"><img src="delete.gif" alt="Delete" width="16" height="16"/></a>';
|
|
$out.='</td><td class="ID">'.$row[0].'</td><td class="Domain">'.$row[1].'</td><td class="Quelle">'.$row[2].'</td><td class="Ziel">'.$row[3].'</td><td class="Enabled">'.$row[4].'</td></tr>';
|
|
}
|
|
$out.='</table></div>';
|
|
break;
|
|
case 2:
|
|
$thname = array('Action','ID','Name');
|
|
$thback = array('','id','domain');
|
|
$out.='<div><div style="text-align: center;"><div id="head">Domain Management</div><a href="?new=2&sel='.$sel.'&orderby='.$orderby.'">New Domain</a></div><br /><br />';
|
|
$out.='<table width="40%" class="table" rules="all"><tr>';
|
|
for ($a=0;$a<count($thname);$a++) {
|
|
$idordered = ($orderby==$thback[$a]) ? '" id="orderedby' : '';
|
|
$link = (($thback[$a])&&!($orderby==$thback[$a])) ? '<a href="?do='.$do.'&sel='.$sel.'&orderby='.$thback[$a].$idordered.'">' : '';
|
|
$endlink = ($link) ? '</a>' : '';
|
|
$out.='<th class="'.$thname[$a].$idordered.'">'.$link.$thname[$a].$endlink.'</th>';
|
|
}
|
|
$out.='</tr>';
|
|
foreach(fetch($qry) as $row) {
|
|
$i++;
|
|
$rowcolor = ($i%2==0) ? 'rowcolor0' : 'rowcolor1';
|
|
$out.='<tr class="'.$rowcolor.'"><td><a href="?chg=2&id='.$row[0].'&sel='.$sel.'&orderby='.$orderby.'" title="Change this record"><img src="edit.gif" alt="Edit" width="16" height="16"/></a><a href="?del=2&id='.$row[0].'&sel='.$sel.'" title="Delete this record"><img src="delete.gif" alt="Delete" width="16" height="16"/></a></td><td>'.$row[0].'</td><td>'.$row[1].'</td></tr>';
|
|
}
|
|
$out.='</table></div>';
|
|
break;
|
|
case 3:
|
|
$thname = array('Action','ID','User','Domain');
|
|
$thback = array("","account_id","user","domain");
|
|
$out.='<div><div style="text-align: center;"><div id="head">User Management</div><a href="?new=3&sel='.$sel.'&orderby='.$orderby.'">New User</a></div><br /><br />';
|
|
$out.='<table width="60%" class="table" rules="all"><tr>';
|
|
for ($a=0;$a<count($thname);$a++) {
|
|
$idordered = ($orderby==$thback[$a]) ? '" id="orderedby' : '';
|
|
$link = (($thback[$a])&&!($orderby==$thback[$a])) ? '<a href="?do='.$do.'&sel='.$sel.'&orderby='.$thback[$a].$idordered.'">' : '';
|
|
$endlink = ($link) ? '</a>' : '';
|
|
$out.='<th class="'.$thname[$a].$idordered.'">'.$link.$thname[$a].$endlink.'</th>';
|
|
}
|
|
$out.='</tr>';
|
|
foreach(fetch($qry) as $row) {
|
|
$i++;
|
|
$rowcolor = ($i%2==0) ? 'rowcolor0' : 'rowcolor1';
|
|
$out.='<tr class="'.$rowcolor.'"><td><a href="?chg=3&id='.$row[0].'&sel='.$sel.'&orderby='.$orderby.'" title="Change this record"><img src="edit.gif" alt="Edit" width="16" height="16"/></a><a href="?del=3&id='.$row[0].'&sel='.$sel.'" title="Delete this record"><img src="delete.gif" alt="Delete" width="16" height="16"/></a></td><td>'.$row[0].'</td><td>'.$row[1].'</td><td>'.$row[2].'</td></tr>';
|
|
}
|
|
$out.='</table></div>';
|
|
break;
|
|
case 4:
|
|
if($result == true) {
|
|
$out = '<div style="text-align: center;"><b>Alias was added...</b></div>';
|
|
$out .= '<div style="text-align: center;"><a href="?do=1&sel='.$sel.'&orderby='.$orderby.'">Back</a></div>';
|
|
$out .= "<script type=\"text/javascript\"><!--\nsetTimeout(function(){document.location = \"?do=1&sel=".$sel.'&orderby='.$orderby."\"},1000)\n--></script>";
|
|
} else {
|
|
$out = '<div style="text-align: center;"><h3>ERROR adding Alias</h3></div>';
|
|
$out .= '<div style="text-align: center;"><a href="?do=1&sel='.$sel.'&orderby='.$orderby.'" onclick="history.back(); return false;">Back</a></div>';
|
|
}
|
|
break;
|
|
case 5:
|
|
if($result == true) {
|
|
$out = '<div style="text-align: center;"><b>Domain was added...</b></div>';
|
|
$out .= '<div style="text-align: center;"><a href="?do=2&sel='.$sel.'&orderby='.$orderby.'">Back</a></div>';
|
|
$out .= "<script type=\"text/javascript\"><!--\nsetTimeout(function(){document.location = \"?do=2&sel=".$sel.'&orderby='.$orderby."\"},1000)\n--></script>";
|
|
} else {
|
|
$out = '<div style="text-align: center;"><h3>ERROR adding Domain</h3></div>';
|
|
$out .= '<div style="text-align: center;"><a href="?do=2&sel='.$sel.'&orderby='.$orderby.'" onclick="history.back(); return false;">Back</a></div>';
|
|
}
|
|
break;
|
|
case 6:
|
|
if($result == true) {
|
|
$out = '<div style="text-align: center;"><b>User was added...</b></div>';
|
|
$out .= '<div style="text-align: center;"><a href="?do=3&sel='.$sel.'&orderby='.$orderby.'">Back</a></div>';
|
|
$out .= "<script type=\"text/javascript\"><!--\nsetTimeout(function(){document.location = \"?do=3&sel=".$sel.'&orderby='.$orderby."\"},1000)\n--></script>";
|
|
} else {
|
|
$out = '<div style="text-align: center;"><h3>ERROR adding User</h3></div>';
|
|
$out .= '<div style="text-align: center;"><a href="?do=3&sel='.$sel.'&orderby='.$orderby.'" onclick="history.back(); return false;">Back</a></div>';
|
|
}
|
|
break;
|
|
}
|
|
|
|
switch($del) {
|
|
case 1:
|
|
if($ack == "") {
|
|
$out = '<div style="text-align: center;"><h3>Delete this alias?</h3><form action = "?del='.$del.'&id='.$id.'&sel='.$sel.'&orderby='.$orderby.'" method="post">';
|
|
$out.= '<div><input type="submit" name="ack" value="No"></input> ǀ <input type="submit"name="ack" value="Yes"></input></div></form></div>';
|
|
} else if($ack == 'Yes') {
|
|
$out = '<div style="text-align: center;"><b>Alias was deleted...</b><br /><a href="?do=1">Back</a></div>';
|
|
$out .= "<script type=\"text/javascript\"><!--\nsetTimeout(function(){document.location = \"?do=1&sel=".$sel.'&orderby='.$orderby."\"},1000)\n--></script>";
|
|
} else {
|
|
$out = '<div style="text-align: center;"><a href="?do=1&sel='.$sel.'&orderby='.$orderby.'">Back</a></div>';
|
|
$out .= "<script type=\"text/javascript\"><!--\nsetTimeout(function(){document.location = \"?do=1&sel=".$sel.'&orderby='.$orderby."\"},500)\n--></script>";
|
|
}
|
|
break;
|
|
|
|
case 2:
|
|
if($ack == "") {
|
|
$out = '<div style="text-align: center;"><h3>Delete this domain?</h3><form action = "?del='.$del.'&id='.$id.'&sel='.$sel.'&orderby='.$orderby.'" method="post">' . "\n";
|
|
$out.= '<div><input type="submit" name="ack" value="No" /> ǀ <input type="submit" name="ack" value="Yes" /></div></form></div>';
|
|
} else if($ack == 'Yes') {
|
|
$out = '<div style="text-align: center;"><b>Domain was deleted...</b><br /><a href="?do=2&sel='.$sel.'&orderby='.$orderby.'">Back</a></div>';
|
|
$out .= "<script type=\"text/javascript\"><!--\nsetTimeout(function(){document.location = \"?do=2&sel=".$sel.'&orderby='.$orderby."\"},1000)\n--></script>";
|
|
} else {
|
|
$out = '<div style="text-align: center;"><a href="?do=2&sel='.$sel.'&orderby='.$orderby.'">Back</a></div>';
|
|
$out .= "<script type=\"text/javascript\"><!--\nsetTimeout(function(){document.location = \"?do=2&sel=".$sel.'&orderby='.$orderby."\"},500)\n--></script>";
|
|
}
|
|
break;
|
|
|
|
case 3:
|
|
if($ack == "") {
|
|
$out = '<div style="text-align: center;"><h3>Delete this user?</h3><form action = "?del='.$del.'&id='.$id.'&sel='.$sel.'&orderby='.$orderby.'" method="post">' . "\n";
|
|
$out.= '<div><input type="submit" name="ack" value="No" /> ǀ <input type="submit" name="ack" value="Yes" /></div></form></div>';
|
|
} else if($ack == 'Yes') {
|
|
$out = '<div style="text-align: center;"><b>User was deleted...</b><br /><a href="?do=3&sel='.$sel.'&orderby='.$orderby.'">Back</a></div>';
|
|
$out .= "<script type=\"text/javascript\"><!--\nsetTimeout(function(){document.location = \"?do=3&sel=".$sel.'&orderby='.$orderby."\"},1000)\n--></script>";
|
|
} else {
|
|
$out = '<div style="text-align: center;"><a href="?do=3">Back</a></div>';
|
|
$out .= "<script type=\"text/javascript\"><!--\nsetTimeout(function(){document.location = \"?do=3&sel=".$sel.'&orderby='.$orderby."\"},500)\n--></script>";
|
|
}
|
|
break;
|
|
}
|
|
|
|
switch($chg) {
|
|
case 1:
|
|
$sql = "SELECT id,domain FROM domains;";
|
|
$qry = query($sql);
|
|
$sql = "SELECT id,source_username,source_domain,destination,enabled FROM aliases WHERE id=".$id.";";
|
|
$qry2 = query($sql);
|
|
$details = fetch($qry2);
|
|
if($ack == "") {
|
|
$out = '<div style="text-align: center;"><span id="head">Edit Alias:</span><form action="?chg='.$chg.'&id='.$id.'&sel='.$sel.'&orderby='.$orderby.'" method="post">';
|
|
$out.= '<table class="align-center">';
|
|
$out.= '<tr><td class="align-right">Domain:</td><td class="align-left"><select name="domain" size="1">';
|
|
foreach(fetch($qry) as $row) {
|
|
$selected = ($row[0] == $details['source_domain']) ? ' selected="selected"' : '';
|
|
$out.= '<option value="'.$row[0].'" onclick="mc.setDomain(this.innerHTML)"'.$selected.'>'.$row[1].'</option>';
|
|
}
|
|
$out.= '</select></td></tr>';
|
|
$out.= '<tr><td class="align-right">Source:</td><td class="align-left"><input type="text" name="src" size="20" value="'.$details['source_username'].'"></input><span id="behindSource">@Domain</span></td></tr>';
|
|
$out.= '<tr><td class="align-right">Target:</td><td class="align-left"><input type="text" name="dest" size="20" value="'.$details['destination'].'"></input></td></tr>';
|
|
$out.= '<tr><td class="align-right">Enabled:</td><td class="align-left"><input type="text" name="enabled" size="1" value="'.$details['enabled'].'"></input></td></tr>';
|
|
$out.= '<tr><td class="align-right"><input type="submit" name="ack" value="Cancel"></input></td><td class="align-left"><input type="submit" name="ack" value="Save"></input></td></tr></table></form></div>';
|
|
} else if($ack == 'Save') {
|
|
$out = '<div style="text-align: center;"><b>Alias was changed...</b><br /><a href="?do=1">Back</a></div>';
|
|
$out .= "<script type=\"text/javascript\"><!--\nsetTimeout(function(){document.location = \"?do=1&sel=".$sel.'&orderby='.$orderby."\"},1000)\n--></script>";
|
|
} else {
|
|
$out = '<div style="text-align: center;"><a href="?do=1&sel='.$sel.'&orderby='.$orderby.'">Back </a></div>';
|
|
$out .= "<script type=\"text/javascript\"><!--\nsetTimeout(function(){document.location = \"?do=1&sel=".$sel.'&orderby='.$orderby."\"},500)\n--></script>";
|
|
}
|
|
break;
|
|
case 2:
|
|
$sql = "SELECT domain FROM domains WHERE id=".$id.";";
|
|
$qry = query($sql);
|
|
if($ack == "") {
|
|
$dom = fetch($qry);
|
|
$out = '<div style="text-align: center;"><span id="head">Edit Domain</span><form action = "?chg='.$chg.'&id='.$id.'&sel='.$sel.'&orderby='.$orderby.'" method="post">';
|
|
$out.= '<table class="align-center">';
|
|
$out.= '<tr><td class="align-right">Domain:</td><td class="align-left"><input type="text" name="domain" size="20" value="'.$dom['domain'].'"></input>';
|
|
$out.= '</td></tr>';
|
|
$out.= '<tr><td class="align-right"><input type="submit" name="ack" value="Cancel"></input></td>
|
|
<td class="align-left"><input type="submit" name="ack" value="Save"></input></td></tr></table></form></div>';
|
|
} else if($ack == 'Save') {
|
|
$out = '<div style="text-align: center;"><b>Domain was changed...</b><br /><a href="?do=2&sel='.$sel.'&orderby='.$orderby.'">Back</a></div>';
|
|
$out .= "<script type=\"text/javascript\"><!--\nsetTimeout(function(){document.location = \"?do=2&sel=".$sel.'&orderby='.$orderby."\"},1000)\n--></script>";
|
|
} else {
|
|
$out = '<div style="text-align: center;"><a href="?do=2&sel='.$sel.'&orderby='.$orderby.'">Back</a></div>';
|
|
$out .= "<script type=\"text/javascript\"><!--\nsetTimeout(function(){document.location = \"?do=2&sel=".$sel.'&orderby='.$orderby."\"},500)\n--></script>";
|
|
}
|
|
break;
|
|
case 3:
|
|
$sql = "SELECT id,domain FROM domains;";
|
|
$qry = query($sql);
|
|
$sql = "SELECT username,domain,enabled FROM accounts WHERE id=".$id.";";
|
|
$qry2 = query($sql);
|
|
$details = fetch($qry2);
|
|
var_dump($details['domain']);
|
|
if($ack == "") {
|
|
$out = '<div style="text-align: center;"><span id="head">Edit User</span><form action="?chg='.$chg.'&id='.$id.'&sel='.$sel.'&orderby='.$orderby.'" method="post">';
|
|
$out.= '<table class="align-center">';
|
|
$out.= '<tr><td class="align-right">Domain:</td><td class="align-left"><select name="domain" size="1">';
|
|
foreach(fetch($qry) as $row) {
|
|
$selected = ($details['domain'] == $row[0]) ? ' selected="selected"' : '';
|
|
$out.= '<option value="'.$row[0].'" onclick="mc.setDomain(this.innerHTML)"'.$selected.'>'.$row[1].'</option>';
|
|
}
|
|
|
|
$out.= '</select></td></tr>';
|
|
$out.= '<tr><td class="align-right">Name:</td><td class="align-left"><input type="text"name="usr" size="20" value="'.$details['username'].'"></input><span id="behindSource">@Domain</span></td></tr>';
|
|
$out.= '<tr><td class="align-right">Password:</td><td class="align-left"><input type="password" id="pwdInput" name="pwd" size="20" value="" onclick="if(this.value==\'******\')this.value=\'\'"></input> <span id="behindPwd" onclick="mc.togglePwd(this);">show password</span></td></tr>';
|
|
$out.= '<tr><td class="align-right"><input type="submit" name="ack" value="Cancel"></input></td><td class="align-left"><input type="submit" name="ack" value="Save"></input></td></tr></table></form></div>';
|
|
} else if($ack == 'Save') {
|
|
$out = '<div style="text-align: center;"><b>User was changed...</b><br /><a href="?do=3&sel='.$sel.'&orderby='.$orderby.'">Back</a></div>';
|
|
$out .= "<script type=\"text/javascript\"><!--\nsetTimeout(function(){document.location = \"?do=3&sel=".$sel.'&orderby='.$orderby."\"},1000)\n--></script>";
|
|
} else {
|
|
$out = '<div style="text-align: center;"><a href="?do=3&sel='.$sel.'&orderby='.$orderby.'">Back</a></div>';
|
|
$out .= "<script type=\"text/javascript\"><!--\nsetTimeout(function(){document.location = \"?do=3&sel=".$sel.'&orderby='.$orderby."\"},500)\n--></script>";
|
|
}
|
|
break;
|
|
}
|
|
echo $out;
|
|
?>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
|