-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathamavis.bypass.php
144 lines (108 loc) · 3.75 KB
/
amavis.bypass.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
include_once('ressources/class.templates.inc');
include_once('ressources/class.ldap.inc');
include_once('ressources/class.users.menus.inc');
include_once('ressources/class.artica.inc');
include_once('ressources/class.ini.inc');
include_once('ressources/class.amavis.inc');
$user=new usersMenus();
if($user->AsPostfixAdministrator==false){
$tpl=new templates();
echo "alert('". $tpl->javascript_parse_text("{ERROR_NO_PRIVS}")."');";
die();exit();
}
if(isset($_GET["add-ip"])){add_ip();exit;}
if(isset($_GET["ip-list"])){ip_list();exit;}
if(isset($_GET["del-ip"])){ip_del();exit;}
page();
//EnableAmavisInMasterCF
function page(){
$page=CurrentPageName();
$tpl=new templates();
$check_client_access_ip_explain=$tpl->javascript_parse_text("{check_client_access_ip_explain}");
$html="<div class=explain>{amavis_bypass_servers_explain}</div>
<center>". button("{add}","AddAmavisBypass()")."</center>
<hr>
<div id='amavisbypassList' style='width:100%;height:350px;overflow:auto'></div>
<script>
function RefreshAmavisdByPass(){
LoadAjax('amavisbypassList','$page?ip-list=yes');
}
var x_AddAmavisBypass= function (obj) {
var response=obj.responseText;
if(response){alert(response);}
RefreshAmavisdByPass();
}
function AddAmavisBypass(){
var ip=prompt('$check_client_access_ip_explain');
if(ip){
var XHR = new XHRConnection();
XHR.appendData('add-ip',ip);
document.getElementById('amavisbypassList').innerHTML='<img src=\"img/wait_verybig.gif\">';
XHR.sendAndLoad('$page', 'GET',x_AddAmavisBypass);
}
}
function DeleteAmavisBypass(ip){
var XHR = new XHRConnection();
XHR.appendData('del-ip',ip);
document.getElementById('amavisbypassList').innerHTML='<img src=\"img/wait_verybig.gif\">';
XHR.sendAndLoad('$page', 'GET',x_AddAmavisBypass);
}
RefreshAmavisdByPass();
</script>";
echo $tpl->_ENGINE_parse_body($html);
}
function add_ip(){
$sql="INSERT INTO amavisd_bypass (`ip_addr`) VALUES('{$_GET["add-ip"]}')";
$q=new mysql();
$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){echo $q->mysql_error;}
$sock=new sockets();
$sock->getFrameWork("cmd.php?postfix-smtp-sender-restrictions=master");
$sock->getFrameWork("cmd.php?amavis-restart=yes");
}
function ip_del(){
$sql="DELETE FROM amavisd_bypass WHERE `ip_addr`='{$_GET["del-ip"]}'";
$q=new mysql();
$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){echo $q->mysql_error;}
$sock=new sockets();
$sock->getFrameWork("cmd.php?postfix-smtp-sender-restrictions=master");
$sock->getFrameWork("cmd.php?amavis-restart=yes");
}
function ip_list(){
$page=CurrentPageName();
$tpl=new templates();
$sock=new sockets();
$EnableAmavisInMasterCF=$sock->GET_INFO("EnableAmavisInMasterCF");
$html="<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>
<thead class='thead'>
<tr>
<th>{ip_addr}</th>
<th> </th>
</tr>
</thead>
<tbody class='tbody'>";
$sql="SELECT * FROM amavisd_bypass ORDER BY ip_addr";
$q=new mysql();
$results=$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){
if(preg_match("#doesn't exist#",$q->mysql_error)){$q->BuildTables();$results=$q->QUERY_SQL($sql,"artica_backup");}
if(!$q->ok){
echo $q->mysql_error;return;
}
}
while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
if($classtr=="oddRow"){$classtr=null;}else{$classtr="oddRow";}
$delete=imgtootltip("delete-32.png","{delete}","DeleteAmavisBypass('{$ligne["ip_addr"]}')");
$color="black";
if($EnableAmavisInMasterCF<>1){$color="#CCCCCC";}
$html=$html . "
<tr class=$classtr>
<td width=99% style='font-size:16px;color:$color' nowrap>{$ligne["ip_addr"]}</td>
<td width=1%>$delete</td>
</tr>";
}
$html=$html."</table>";
echo $tpl->_ENGINE_parse_body($html);
}