-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforwarders.php
95 lines (82 loc) · 2.94 KB
/
forwarders.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title></title>
</head>
<body onload="listForwarders()">
<a href="index.html">Tornar</a></br>
<form name="frmEmail" method="post">
<table width="400" border="0">
<tr>
<td>Forwarder:</td>
<td><input id="emailalias" name="emailalias" size="20" type="text" value="" />@domain.com</td>
</tr>
<tr>
<td>Forward to </td>
<td><input id="destemail" name="destemail" size="20" type="text" value="default@domain.com" /></td>
</tr>
<tr>
<td colspan="2" align="center"><hr /><!-- <input name="submit" type="submit" value="Create Forward" /> --><button onclick="addForwarder()" type="button" >Add</button></td></tr>
</table>
</form>
<div id="myDiv"></div>
<script>
function addForwarder()
{
xmlhttp=new XMLHttpRequest();
xmlhttp.open("POST","parser.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var address=document.getElementById("emailalias").value + "@domain.com";
var forwardto=document.getElementById("destemail").value;
var args = encodeURIComponent("&domain=domain.com&email="+address+"&fwdopt=fwd&fwdemail="+forwardto);
xmlhttp.send("cpanel_xmlapi_module=Email&cpanel_xmlapi_func=addforward&args=" + args);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("emailalias").value="";
listForwarders();
}
}
}
function delForwarder(args)
{
xmlhttp=new XMLHttpRequest();
xmlhttp.open("POST","parser_api1.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("cpanel_xmlapi_module=Email&cpanel_xmlapi_func=delforward&args=" + args);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
listForwarders();
}
}
}
function listForwarders()
{
var domain = "";
xmlhttp=new XMLHttpRequest();
xmlhttp.open("POST","parser.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var args = encodeURIComponent("&domain="+domain);
xmlhttp.send("cpanel_xmlapi_module=Email&cpanel_xmlapi_func=listforwards&args=" + args);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
xmlDoc=xmlhttp.responseXML;
txt="<table><tr><th>Address</th><th>Forward to</th><th></th></tr>";
x=xmlDoc.getElementsByTagName("data");
for (i=0;i<x.length;i++)
{
alias = x[i].getElementsByTagName("html_dest");
mailto = x[i].getElementsByTagName("html_forward");
txt=txt + '<tr><td>' + alias[0].textContent + '</td><td>' + mailto[0].textContent + '</td><td><button name="' + x[i].getElementsByTagName("uri_dest")[0].textContent + '%3D' + x[i].getElementsByTagName("uri_forward")[0].textContent +'" onclick="delForwarder(this.name)" type="button" >Del</button></td></tr>';
}
txt=txt + "</table>";
document.getElementById("myDiv").innerHTML=txt;
}
}
}
</script>
</body>
</html>