Init
This commit is contained in:
commit
e5ef238c8a
1 changed files with 619 additions and 0 deletions
619
mail_control.php
Normal file
619
mail_control.php
Normal file
|
@ -0,0 +1,619 @@
|
|||
<?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','{USER}');
|
||||
define('db_pwd','{PASSWORD}');
|
||||
$tbl_aliases = 'virtual_aliases';
|
||||
$tbl_domains = 'virtual_domains';
|
||||
$tbl_users = 'virtual_users';
|
||||
$lang = 'de';
|
||||
|
||||
/* Functions */
|
||||
function query($sql) {
|
||||
global $cid;
|
||||
if($sql) return mysql_query($sql,$cid);
|
||||
//else die(mysql_error());
|
||||
}
|
||||
|
||||
function fetch($res) {
|
||||
if($res) return mysql_fetch_array($res);
|
||||
else return false;
|
||||
}
|
||||
|
||||
function connect() {
|
||||
global $cid,$db;
|
||||
$cid = mysql_connect(db_server,db_user,db_pwd);
|
||||
if($cid) $db = mysql_select_db(db_name,$cid);
|
||||
else die(mysql_error());
|
||||
}
|
||||
|
||||
function disconnect() {
|
||||
global $cid;
|
||||
if(!(mysql_close($cid))) 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);
|
||||
}
|
||||
|
||||
/* LocalLanguage */
|
||||
if ($lang) {
|
||||
$LLA = array();
|
||||
if ($lang == 'de') {
|
||||
$LLA['de']['hide password'] = 'verstecke Passwort';
|
||||
$LLA['de']['show password'] = 'zeige Passwort';
|
||||
$LLA['de']['All'] = 'Alle';
|
||||
$LLA['de']['Alias Management'] = 'Alias-Verwaltung';
|
||||
$LLA['de']['New Alias'] = 'Alias hinzufügen';
|
||||
$LLA['de']['Action'] = 'Aktion';
|
||||
$LLA['de']['Source'] = 'Quelle';
|
||||
$LLA['de']['Destination'] = 'Ziel';
|
||||
$LLA['de']['Enabled'] = 'Aktiviert';
|
||||
$LLA['de']['Domain Management'] = 'Domain-Verwaltung';
|
||||
$LLA['de']['User Management'] = 'User-Verwaltung';
|
||||
$LLA['de']['New Domain'] = 'Domain hinzufügen';
|
||||
$LLA['de']['Change this record'] = 'Diesen Eintrag ändern';
|
||||
$LLA['de']['Delete this record'] = 'Diesen Eintrag löschen';
|
||||
$LLA['de']['Reset'] = 'Zurücksetzen';
|
||||
$LLA['de']['New User'] = 'User hinzufügen';
|
||||
$LLA['de']['Username'] = 'Benutzername';
|
||||
$LLA['de']['Password'] = 'Passwort';
|
||||
$LLA['de']['ERROR adding Alias'] = 'Fehler beim Hinzufügen eines Aliases';
|
||||
$LLA['de']['ERROR adding Domain'] = 'Fehler beim Hinzufügen einer Domain';
|
||||
$LLA['de']['ERROR adding User'] = 'Fehler beim Hinzufügen eines Users';
|
||||
$LLA['de']['Back'] = 'Zurück';
|
||||
$LLA['de']['was added...'] = ' wurde hinzugefügt...';
|
||||
$LLA['de']['Delete this alias?'] = 'Diesen Alias wirklich löschen?';
|
||||
$LLA['de']['Delete this domain?'] = 'Diese Domain wirklich löschen?';
|
||||
$LLA['de']['Delete this user?'] = 'Diesen User wirklich löschen?';
|
||||
$LLA['de']['was deleted...'] = 'wurde gelöscht';
|
||||
$LLA['de']['was changed...'] = 'wurde geändert...';
|
||||
$LLA['de']['No'] = 'Nein';
|
||||
$LLA['de']['Yes'] = 'Ja';
|
||||
$LLA['de']['Edit Alias'] = 'Alias bearbeiten';
|
||||
$LLA['de']['Edit Domain'] = 'Domain bearbeiten';
|
||||
$LLA['de']['Edit User'] = 'User bearbeiten';
|
||||
$LLA['de']['Target'] = 'Ziel';
|
||||
$LLA['de']['Cancel'] = 'Abbrechen';
|
||||
$LLA['de']['Speichern'] = 'Save';
|
||||
$LLA['de']['Reset'] = 'Zurüksetzen';
|
||||
}
|
||||
/*
|
||||
also available:
|
||||
- Aliases
|
||||
- Domains
|
||||
- User
|
||||
- ID
|
||||
- Domain
|
||||
- Name
|
||||
- Ok
|
||||
leave one alias out in the language conf and the original one will be used.
|
||||
*/
|
||||
}
|
||||
|
||||
function echoAl($al) {
|
||||
global $LLA, $lang;
|
||||
if (!$LLA[$lang]) {echo 'aaaa'; return false;}
|
||||
if (!$LLA[$lang]) {echo $al; return false;}
|
||||
if (!$LLA[$lang][$al]) {echo $al; return false;}
|
||||
echo $LLA[$lang][$al];
|
||||
return true;
|
||||
}
|
||||
|
||||
function retAl($al) {
|
||||
global $LLA, $lang;
|
||||
if (!$LLA[$lang]) return 'bbbb';
|
||||
if (!$LLA[$lang]) return $al;
|
||||
if (!$LLA[$lang][$al]) return $al;
|
||||
return $LLA[$lang][$al];
|
||||
}
|
||||
|
||||
/* Initialize */
|
||||
connect();
|
||||
$do = $_REQUEST['do'];
|
||||
$id = $_REQUEST['id'];
|
||||
$new = $_REQUEST['new'];
|
||||
$del = $_REQUEST['del'];
|
||||
$chg = $_REQUEST['chg'];
|
||||
$ack = $_REQUEST['ack'];
|
||||
$domain = $_REQUEST['domain'];
|
||||
$source = $_REQUEST['src'];
|
||||
$usr = $_REQUEST['usr'];
|
||||
$pwd = $_REQUEST['pwd'];
|
||||
$dest = $_REQUEST['dest'];
|
||||
$enabled = $_REQUEST['enabled'];
|
||||
$ndomain = $_REQUEST['new_domain'];
|
||||
$orderby = $_REQUEST['orderby'];
|
||||
$sel = $_GET['sel'];
|
||||
|
||||
$fetch_list = mysql_query("SELECT * FROM `" . $tbl_domains . "` ORDER BY `name` ASC");
|
||||
$orderbysql = $orderby ? ' ORDER BY '.$orderby.';' : ';';
|
||||
$selectsql = $sel ? ' AND ' . $tbl_domains . '.id = '.$sel : '';
|
||||
## Query Aliases ##
|
||||
$sql[1] = "SELECT " . $tbl_aliases . ".id, " . $tbl_aliases . ".source, " . $tbl_domains . ".name, " . $tbl_aliases . ".destination, " . $tbl_aliases . ".enabled FROM " . $tbl_aliases . ", " . $tbl_domains . " WHERE " . $tbl_aliases . ".domain_id = " . $tbl_domains . ".id".$selectsql.$orderbysql;
|
||||
|
||||
## Query Domains ##
|
||||
$sql[2] = "SELECT * FROM " . $tbl_domains . $orderbysql;
|
||||
|
||||
## Query Users ##
|
||||
$sql[3] = "SELECT " . $tbl_users . ".id, " . $tbl_domains . ".name, " . $tbl_users . ".user FROM " . $tbl_users . ", " . $tbl_domains . " WHERE " . $tbl_users . ".domain_id = " . $tbl_domains . ".id".$selectsql.$orderbysql;
|
||||
|
||||
## Insert Alias Query ##
|
||||
if(($domain <> "") && ($dest <> "")) $sql[4] = "INSERT INTO " . $tbl_aliases . " (domain_id, source, destination, enabled) VALUES ('$domain','$source','$dest',1);";
|
||||
|
||||
## Insert Domain Query ##
|
||||
if($ndomain <> "") {
|
||||
$sql0 = "SELECT name FROM " . $tbl_domains . " WHERE name = '$ndomain';";
|
||||
$qr = query($sql0);
|
||||
if(mysql_num_rows($qr) < 1) $sql[5] = "INSERT INTO " . $tbl_domains . " (name) VALUES ('$ndomain');";
|
||||
}
|
||||
|
||||
## Insert User Query ##
|
||||
if(($domain <> "") && ($usr <> "") && ($pwd <> "")) {
|
||||
$sql1 = "SELECT domain_id, user, password FROM " . $tbl_users . " WHERE domain_id = $domain AND user = '$usr' AND password = '".pw_encode($pwd)."';";
|
||||
$qr = query($sql1);
|
||||
if(mysql_num_rows($qr) < 1) $sql[6] = "INSERT INTO " . $tbl_users . " (domain_id, user, password) VALUES (NULL,'$domain','$usr','".pw_encode($pwd)."');
|
||||
";
|
||||
}
|
||||
|
||||
## Delete Query ##
|
||||
if(($del <> "") && ($id <> "") && ($ack == retAl('Yes'))) {
|
||||
$sql = "DELETE FROM ".$tbl[$del]." WHERE id = $id;";
|
||||
query($sql);
|
||||
}
|
||||
|
||||
## Update Alias Query##
|
||||
if(($chg == 1) && ($id <> "") && ($domain <> "") && ($dest <> "") && ($ack == retAl('Save'))) {
|
||||
$sql = "UPDATE ".$tbl[$chg]." SET domain_id = '".$domain."', source = '".$source."', destination = '".$dest."', enabled = '".$enabled."' WHERE id = ".$id.";";
|
||||
query($sql);
|
||||
}
|
||||
|
||||
## Update Domain Query ##
|
||||
if(($chg == 2) && ($id <> "") && ($domain <> "") && ($ack == retAl('Save'))) {
|
||||
$sql = "UPDATE ".$tbl[$chg]." SET name='".$domain."' WHERE id = ".$id.";";
|
||||
query($sql);
|
||||
}
|
||||
|
||||
## Update User Query ##
|
||||
if(($chg == 3) && ($id <> "") && ($domain <> "") && ($usr <> "") && ($pwd <> "") && ($ack == retAl('Save'))) {
|
||||
$sql = "UPDATE ".$tbl[$chg]." SET domain_id ='".$domain."', user ='".$usr."', password = '".pw_encode($pwd)."' WHERE id = ".$id.";";
|
||||
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 echoAl('hide password'); ?>';
|
||||
} else {
|
||||
inp.type = 'password';
|
||||
beh.innerHTML = '<?php echoAl('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 echoAl('All') ?></option>
|
||||
<?php
|
||||
while ($dlist = mysql_fetch_array($fetch_list)) {
|
||||
if ($dlist['id'] == $sel) echo ' <option value="'. $dlist['id'] .'" selected="selected">'. $dlist['name'] .'</option>';
|
||||
else echo ' <option value="'. $dlist['id'] .'">'. $dlist['name'].'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div></form>
|
||||
<div id="topLinks">
|
||||
<a href="<?php echo '?do=1&sel='.$sel ?>" id="aliases_link"><strong><?php echoAl('Aliases') ?></strong></a> ǀ <a href="<?php echo '?do=2&sel='.$sel ?>" id="domains_link"><strong><?php echoAl('Domains') ?></strong></a> ǀ <a href="<?php echo '?do=3&sel='.$sel ?>" id="user_link"><strong><?php echoAl('User') ?></strong></a>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div>
|
||||
<?php
|
||||
switch($new) {
|
||||
case 1:
|
||||
$sql = "SELECT id,name FROM " . $tbl_domains . ";";
|
||||
$qry = query($sql);
|
||||
$out = ' <div style="text-align: center;"><span id="head">'.retAl('New Alias').'</span><br /><form action="?do=4&sel='.$sel.'&orderby='.$orderby.'" method="post">';
|
||||
$out.= '<table class="align-center"><tr><td class="align-right">'.retAl('Domain').':</td>';
|
||||
$out.= '<td class="align-left"><select name="domain" size="1">';
|
||||
while($row = fetch($qry)) {
|
||||
$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">'.retAl('Source').':</td><td class="align-left"><input type="text" id="src" name="src" size="20"></input><span id="behindSource">@'.retAl('Domain').'</span></td></tr>';
|
||||
$out.= '<tr><td class="align-right">'.retAl('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="'.retAl('Ok').'"></input></td></tr>';
|
||||
$out.= '</table></form></div>';
|
||||
break;
|
||||
case 2:
|
||||
$out = '<div style="text-align: center;"><span id="head">'.retAl('New Domain').'</span><form action="?do=5&sel='.$sel.'&orderby='.$orderby.'" method="post">';
|
||||
$out.= '<table class="align-center"><tr><td class="align-right">'.retAl('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="'.retAl(''.retAl('Zurüksetzen').'').'"></input></td><td class="align-left"><input type="submit" value="'.retAl('Ok').'"></input></td></tr>';
|
||||
$out.= '</table></form></div>';
|
||||
break;
|
||||
case 3:
|
||||
$sql = "SELECT id,name FROM " . $tbl_domains . ";";
|
||||
$qry = query($sql);
|
||||
$out = '<div style="text-align: center;"><span id="head">'.retAl('New User').'</span><form action="?do=6&sel='.$sel.'&orderby='.$orderby.'" method="post">';
|
||||
$out.= '<table class="align-center"><tr><td class="align-right">'.retAl('Domain').':</td>';
|
||||
$out.= '<td class="align-left"><select name="domain" size="1">';
|
||||
while($row = fetch($qry)) {
|
||||
$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">'.retAl('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">'.retAl('Password').':</td><td class="align-left"><input type="password" id="pwdInput" name="pwd" size="20"></input> <span id="behindPwd" onclick="mc.togglePwd(this);">'.retAl('show password').'</span></td></tr>';
|
||||
$out.= '<tr><td class="align-right"><input type="reset" value="'.retAl('Zurüksetzen').'"></input></td><td class="align-left"><input type="submit" value="'.retAl('Ok').'"></input></td></tr>';
|
||||
$out.= '</table></form></div>';
|
||||
break;
|
||||
}
|
||||
|
||||
switch($do) {
|
||||
case 1:
|
||||
$thname = array(retAl('Action'),retAl('ID'),retAl('Source'),retAl('Domain'),retAl('Destination'),retAl('Enabled'));
|
||||
$thback = array('','id','source','domain_id','destination','enabled');
|
||||
$out.= '<div><div style="text-align: center;"><div id="head">'.retAl('Alias Management').'</div><a href="?new=1&sel='.$sel.'&orderby='.$orderby.'">'.retAl('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>';
|
||||
while($row = fetch($qry)) {
|
||||
$i++;
|
||||
$rowcolor = ($i%2==0) ? 'rowcolor0' : 'rowcolor1';
|
||||
$out.='<tr class="'.$rowcolor.'"><td class="Aktion"><a href="?chg=1&id='.$row[0].'&sel='.$sel.'&orderby='.$orderby.'" title="'.retAl('Change this record').'"><img src="http://www.motechsystems.com/images/icons/edit.gif" alt="Edit"/></a><a href="?del=1&id='.$row[0].'&sel='.$sel.'" title="'.retAl('Delete this record').'"><img src="http://www.motechsystems.com/images/icons/delete.gif" alt="Delete"/></a></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(retAl('Action'),retAl('ID'),retAl('Name'));
|
||||
$thback = array('','id','name');
|
||||
$out.='<div><div style="text-align: center;"><div id="head">'.retAl('Domain Management').'</div><a href="?new=2&sel='.$sel.'&orderby='.$orderby.'">'.retAl('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>';
|
||||
while($row = fetch($qry)) {
|
||||
$i++;
|
||||
$rowcolor = ($i%2==0) ? 'rowcolor0' : 'rowcolor1';
|
||||
$out.='<tr class="'.$rowcolor.'"><td><a href="?chg=2&id='.$row[0].'&sel='.$sel.'&orderby='.$orderby.'" title="'.retAl('Change this record').'"><img src="http://www.motechsystems.com/images/icons/edit.gif" alt="Edit"/></a><a href="?del=2&id='.$row[0].'&sel='.$sel.'" title="'.retAl('Delete this record').'"><img src="http://www.motechsystems.com/images/icons/delete.gif" alt="Delete"/></a></td><td>'.$row[0].'</td><td>'.$row[1].'</td></tr>';
|
||||
}
|
||||
$out.='</table></div>';
|
||||
break;
|
||||
case 3:
|
||||
$thname = array(retAl('Action'),retAl('ID'),retAl('Domain'),retAl('User'));
|
||||
$thback = array("","id","domain_id","user");
|
||||
$out.='<div><div style="text-align: center;"><div id="head">'.retAl('User Management').'</div><a href="?new=3&sel='.$sel.'&orderby='.$orderby.'">'.retAl('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>';
|
||||
while($row = fetch($qry)) {
|
||||
$i++;
|
||||
$rowcolor = ($i%2==0) ? 'rowcolor0' : 'rowcolor1';
|
||||
$out.='<tr class="'.$rowcolor.'"><td><a href="?chg=3&id='.$row[0].'&sel='.$sel.'&orderby='.$orderby.'" title="'.retAl('Change this record').'"><img src="http://www.motechsystems.com/images/icons/edit.gif" alt="Edit"/></a><a href="?del=3&id='.$row[0].'&sel='.$sel.'" title="'.retAl('Delete this record').'"><img src="http://www.motechsystems.com/images/icons/delete.gif" alt="Delete"/></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>'.retAl('Alias').' '.retAl('was added...').'</b></div>';
|
||||
$out .= '<div style="text-align: center;"><a href="?do=1&sel='.$sel.'&orderby='.$orderby.'">'.retAl('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>'.retAl('ERROR adding Alias').'</h3></div>';
|
||||
$out .= '<div style="text-align: center;"><a href="?do=1&sel='.$sel.'&orderby='.$orderby.'" onclick="history.back(); return false;">'.retAl('Back').'</a></div>';
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if($result == true) {
|
||||
$out = '<div style="text-align: center;"><b>'.retAl('Domain').' '.retAl('was added...').'</b></div>';
|
||||
$out .= '<div style="text-align: center;"><a href="?do=2&sel='.$sel.'&orderby='.$orderby.'">'.retAl('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>'.retAl('ERROR adding Domain').'</h3></div>';
|
||||
$out .= '<div style="text-align: center;"><a href="?do=2&sel='.$sel.'&orderby='.$orderby.'" onclick="history.back(); return false;">'.retAl('Back').'</a></div>';
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if($result == true) {
|
||||
$out = '<div style="text-align: center;"><b>'.retAl('User').' '.retAl('was added...').'</b></div>';
|
||||
$out .= '<div style="text-align: center;"><a href="?do=3&sel='.$sel.'&orderby='.$orderby.'">'.retAl('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>'.retAl('ERROR adding User').'</h3></div>';
|
||||
$out .= '<div style="text-align: center;"><a href="?do=3&sel='.$sel.'&orderby='.$orderby.'" onclick="history.back(); return false;">'.retAl('Back').'</a></div>';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
switch($del) {
|
||||
case 1:
|
||||
if($ack == "") {
|
||||
$out = '<div style="text-align: center;"><h3>'.retAl('Delete this alias?').'</h3><form action = "?del='.$del.'&id='.$id.'&sel='.$sel.'&orderby='.$orderby.'" method="post">';
|
||||
$out.= '<div><input type="submit" name="ack" value="'.retAl('No').'"></input> |#448; <input type="submit"name="ack" value="'.retAl('Yes').'"></input></div></form></div>';
|
||||
} else if($ack == retAl('Yes')) {
|
||||
$out = '<div style="text-align: center;"><b>'.retAl('Alias').' '.retAl('was deleted...').'</b><br /><a href="?do=1">'.retAl('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.'">'.retAl('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>'.retAl('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="'.retAl('No').'" /> |#448; <input type="submit" name="ack" value="'.retAl('Yes').'" /></div></form></div>';
|
||||
} else if($ack == retAl('Yes')) {
|
||||
$out = '<div style="text-align: center;"><b>'.retAl('Domain').' '.retAl('was deleted...').'</b><br /><a href="?do=2&sel='.$sel.'&orderby='.$orderby.'">'.retAl('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.'">'.retAl('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>'.retAl('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="'.retAl('No').'" /> ǀ <input type="submit" name="ack" value="'.retAl('Yes').'" /></div></form></div>';
|
||||
} else if($ack == retAl('Yes')) {
|
||||
$out = '<div style="text-align: center;"><b>'.retAl('User').' '.retAl('was deleted...').'</b><br /><a href="?do=3&sel='.$sel.'&orderby='.$orderby.'">'.retAl('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">'.retAl('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,name FROM " . $tbl_domains . ";";
|
||||
$qry = query($sql);
|
||||
$sql = "SELECT * FROM " . $tbl_aliases . " WHERE id=".$id.";";
|
||||
$qry2 = query($sql);
|
||||
$details = fetch($qry2);
|
||||
if($ack == "") {
|
||||
$out = '<div style="text-align: center;"><span id="head">'.retAl('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">'.retAl('Domain').':</td><td class="align-left"><select name="domain" size="1">';
|
||||
while($row = fetch($qry)) {
|
||||
$selected = ($row[0] == $details['domain_id']) ? ' 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">'.retAl('Source').':</td><td class="align-left"><input type="text" name="src" size="20" value="'.$details['source'].'"></input><span id="behindSource">@Domain</span></td></tr>';
|
||||
$out.= '<tr><td class="align-right">'.retAl('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">'.retAl('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="'.retAl('Cancel').'"></input></td><td class="align-left"><input type="submit" name="ack" value="'.retAl('Save').'"></input></td></tr></table></form></div>';
|
||||
} else if($ack == retAl('Save')) {
|
||||
$out = '<div style="text-align: center;"><b>'.retAl('Alias').' '.('was changed...').'</b><br /><a href="?do=1">'.retAl('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.'">'.retAl('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 name FROM " . $tbl_domains . " WHERE id=".$id.";";
|
||||
$qry = query($sql);
|
||||
if($ack == "") {
|
||||
$dom = fetch($qry);
|
||||
$out = '<div style="text-align: center;"><span id="head">'.retAl('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">'.retAl('Domain').':</td><td class="align-left"><input type="text" name="domain" size="20" value="'.$dom['name'].'"></input>';
|
||||
$out.= '</td></tr>';
|
||||
$out.= '<tr><td class="align-right"><input type="submit" name="ack" value="'.retAl('Cancel').'"></input></td>
|
||||
<td class="align-left"><input type="submit" name="ack" value="'.retAl('Save').'"></input></td></tr></table></form></div>';
|
||||
} else if($ack == retAl('Save')) {
|
||||
$out = '<div style="text-align: center;"><b>'.retAl('Domain').' '.('was changed...').'</b><br /><a href="?do=2&sel='.$sel.'&orderby='.$orderby.'">'.retAl('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.'">'.retAl('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,name FROM " . $tbl_domains . ";";
|
||||
$qry = query($sql);
|
||||
$sql = "SELECT * FROM " . $tbl_users . " WHERE id=".$id.";";
|
||||
$qry2 = query($sql);
|
||||
$details = fetch($qry2);
|
||||
if($ack == "") {
|
||||
$out = '<div style="text-align: center;"><span id="head">'.retAl('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">'.retAl('Domain').':</td><td class="align-left"><select name="domain" size="1">';
|
||||
while($row = fetch($qry)) {
|
||||
$selected = ($details['domain_id'] == $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">'.retAl('Name').':</td><td class="align-left"><input type="text"name="usr" size="20" value="'.$details['user'].'"></input><span id="behindSource">@Domain</span></td></tr>';
|
||||
$out.= '<tr><td class="align-right">'.retAl('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);">'.retAl('show password').'</span></td></tr>';
|
||||
$out.= '<tr><td class="align-right"><input type="submit" name="ack" value="'.retAl('Cancel').'"></input></td><td class="align-left"><input type="submit" name="ack" value="'.retAl('Save').'"></input></td></tr></table></form></div>';
|
||||
} else if($ack == retAl('Save')) {
|
||||
$out = '<div style="text-align: center;"><b>'.retAl('User').' '.('was changed...').'</b><br /><a href="?do=3&sel='.$sel.'&orderby='.$orderby.'">'.retAl('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.'">'.retAl('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>
|
||||
|
Loading…
Reference in a new issue