forked from poppyred/1.6.x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
postfix.security.rules.php
executable file
·262 lines (196 loc) · 6.9 KB
/
postfix.security.rules.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<?php
include_once('ressources/class.templates.inc');
include_once('ressources/class.ldap.inc');
include_once('ressources/class.users.menus.inc');
include_once('ressources/class.main_cf.inc');
include_once('ressources/class.html.pages.inc');
$usersmenus=new usersMenus();
if($usersmenus->AsMailBoxAdministrator==false){header('location:users.index.php');exit;}
if(isset($_GET["js"])){js();exit;}
if(isset($_GET["popup"])){page_popup();exit;}
if(isset($_GET["postfix_security_rules"])){echo postfix_security_rules();exit;}
function js(){
$usersmenus=new usersMenus();
if($usersmenus->AsPostfixAdministrator==false){echo "alert('no privileges');";die();}
$page=CurrentPageName();
$addons=file_get_contents("postfix.js");
$tpl=new templates();
$title=$tpl->_ENGINE_parse_body('{security_rules}');
$html="
$addons
function LoadPSFirstPage(){
YahooWinT('700','$page?popup=yes','$title');
}
LoadPSFirstPage();";
echo $html;
}
function page_popup(){
$html="
<H1>{security_rules}</H1>
<div id='postfix_security_rules'>" . RoundedLightWhite(postfix_security_rules()) . "</div>
";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
page();
function page(){
$main=new main_cf();
$html="
<script type=\"text/javascript\" language=\"javascript\" src=\"postfix.js\"></script>
<div id='postfix_security_rules'>" . RoundedLightGrey(postfix_security_rules()) . "</div>";
$tpl=new template_users('{security_rules}',$html);
echo $tpl->web_page;
}
function postfix_security_rules(){
$html="<table width=100%>
<tr>
<td colspan=3><p>{security_rules_explain}</p></td>
</tr>
" . Listen($main).array_mynetworks($main).TLS().
smtpd_reject_unlisted_recipient().
smtpd_helo_required().restrictions_classes().
RegexRules().
Antispam().
Antivirus().
procmail()."
</table>";
$tpl=new templates();
return $tpl->_ENGINE_parse_body($html);
}
function restrictions_classes(){
$html="<input type='button' value='{postfix_restrictions_classes} »' OnClick=\"javascript:MyHref('postfix.restrictions.classes.php');\">";
return BuildTable("16-infos.png",'{postfix_restrictions_classes}',$html);
}
function procmail(){
}
function TLS(){
$main=new main_cf();
$config="javascript:Loadjs('postfix.tls.php');";
if($main->main_array["smtpd_tls_security_level"]<>'none'){
if($main->main_array["smtp_tls_note_starttls_offer"]=="yes"){
$smtp_tls_note_starttls_offer="{logging}: {smtp_tls_note_starttls_offer} ({enabled})";
}else{$smtp_tls_note_starttls_offer="{logging}: {smtp_tls_note_starttls_offer} ({disabled})";}
$html="<table style='width:100%;'>
<tr>
<td width=1% valign='top'><img src='img/fw_bold.gif'></td>
<td style='padding-left:5px'><a href=\"$config\">smtpd_tls_security_level = {$main->main_array["smtpd_tls_security_level"]}</a></td>
</tr
<tr>
<td width=1% valign='top'><img src='img/fw_bold.gif'></td>
<td style='padding-left:5px'><a href=\"$config\">{logging}: " . $main->array_field_tls_logging[$main->main_array["smtpd_tls_loglevel"]] ."</a></td>
</tr>
<tr>
<td width=1% valign='top'><img src='img/fw_bold.gif'></td>
<td style='padding-left:5px'><a href=\"$config\">$smtp_tls_note_starttls_offer</a></td>
</tr>
</table>";
return BuildTable("status_ok.png",'{tls_title}',$html);
}else{
return BuildTable("16-infos.png",'{tls_title}',"<a href='$config'>{disable}</a>");
}
}
function Antispam(){
$p=new HtmlPages();
if($p->kas_installed==true){
return BuildTable("status_ok.png",'Kaspersky Anti-Spam ','{installed}');
}else{return BuildTable("status_critical.png",'Kaspersky Anti-Spam ','{not_installed}');}
}
function Antivirus(){
$p=new HtmlPages();
if($p->aveserver_installed==true){
return BuildTable("status_ok.png",'Kaspersky Antivirus ','{installed}');
}else{return BuildTable("status_critical.png",'Kaspersky Antivirus ','{not_installed}');}
}
function RegexRules(){
include_once('ressources/class.main_cf_filtering.inc');
$main=new main_header_check();
$count=count($main->main_table);
$html="<a href='smtp.rules.php'>{postfix_inrules_regex}: <strong>$count</strong></a>";
return BuildTable("status_ok.png",'{check_in_headers}',$html,"MyHref('smtp.rules.php');");
}
function Listen(){
$main=new main_cf();
$array=$main->array_inet_interfaces;
if(!is_array($array)){
writelogs("Error it seems that array_inet_interfaces is empty !!?? ",__FUNCTION__,__FILE__);
$array_mynetworks_text='{error}';
$array_mynetworks_img='status_critical.png';
}else{
$array_mynetworks_img='status_ok.png';
$array_mynetworks_text=implode(', ',$array);
}
return BuildTable($array_mynetworks_img,'{daemon_listen_ip}',$array_mynetworks_text);
}
function array_mynetworks(){
$main=new main_cf();
$array_mynetworks=$main->array_mynetworks;
if(!is_array($array_mynetworks)){
$array_mynetworks_text='{error_no_array_mynetworks}';
$array_mynetworks_img='status_critical.png';
}else{
$array_mynetworks_img='status_ok.png';
$array_mynetworks_text=implode(', ',$array_mynetworks) . '<span class=caption> {Authorized networks text}</span>';
}
return BuildTable($array_mynetworks_img,'{Authorized networks}',$array_mynetworks_text);
}
function BuildTable($img,$title,$text,$link=null){
if($link<>null){
$link=imgtootltip('edit.gif','{apply}',$link);
}
$style="style='border-bottom:1px dotted #8E8785;'";
return "<tr>
<td $style width=1% valign='top'><img src='img/arrow-down-18.gif'></td>
<td $style nowrap align='right' style='padding-left:4px' valign='top'><strong>$title</strong>:</td>
<td $style valign='top'>
<table class=none>
<tr>
<td width=1% valign='top'><img src='img/$img'></td>
<td valign='top'>$text</td>
</tr>
</table>
<td width=1%' valign='top'>$link</td>
</td>
</tr>";
}
function smtpd_reject_unlisted_recipient(){
$main=new main_cf();
if($main->main_array["smtpd_reject_unlisted_recipient"]=='yes'){
$img="ok16.png";
$img2="status_ok.png";
$text="{enabled}";
}else{
$img="icon_mini_off.gif";
$img2="status_critical.png";
$text="{disabled}";
}
$text="
<table style='width:100%;' >
<tr>
<td width=1% valign='top'><img src='img/fw_bold.gif'>
<td style='padding-left:5px'><img src='img/$img'>
<td width=99%><strong>$text</strong></td>
</tr>
</table>";
return BuildTable("$img2",'{smtpd_reject_unlisted_recipient}',$text,"LoadSmtpdRejectUnlistedRecipient();");
}
function smtpd_helo_required(){
$main=new main_cf();
if($main->main_array["smtpd_helo_required"]=='yes'){
$img="ok16.png";
$img2="status_ok.png";
$text="{enabled}";
}else{
$img="icon_mini_off.gif";
$img2="status_critical.png";
$text="{disabled}";
}
$text="
<table style='width:100%;' >
<tr>
<td width=1% valign='top'><img src='img/fw_bold.gif'>
<td style='padding-left:5px'><img src='img/$img'>
<td width=99%><strong>$text</strong></td>
</tr>
</table>";
return BuildTable("$img2",'{smtpd_helo_required}',$text,"LoadSmtpdHeloRequired();");
}