forked from poppyred/1.6.x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ufdbguard.smtp.notif.php
executable file
·186 lines (161 loc) · 8.27 KB
/
ufdbguard.smtp.notif.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
<?php
header("Pragma: no-cache");
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate");
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.system.network.inc');
include_once('ressources/class.squid.inc');
$user=new usersMenus();
if($user->AsDansGuardianAdministrator==false){
$tpl=new templates();
echo "alert('". $tpl->javascript_parse_text("{ERROR_NO_PRIVS}")."');";
die();exit();
}
if(isset($_POST["ENABLED"])){Save();exit;}
if(isset($_GET["js"])){js();exit;}
page();
function js(){
header("content-type: application/x-javascript");
$t=$_GET["t"];
$page=CurrentPageName();
$tpl=new templates();
$title=$tpl->javascript_parse_text("{smtp_notifications}");
echo "LoadWinORG2('705','$page','$title')";
}
function page(){
$users=new usersMenus();
$ini=new Bs_IniHandler();
$page=CurrentPageName();
$tpl=new templates();
$sock=new sockets();
$ini->loadString($sock->getFrameWork("cmd.php?SmtpNotificationConfigRead=yes"));
if($ini->_params["SMTP"]["smtp_server_port"]==null){$ini->_params["SMTP"]["smtp_server_port"]=25;}
if($ini->_params["SMTP"]["smtp_sender"]==null){$users=new usersMenus();$ini->_params["SMTP"]["smtp_sender"]="artica@$users->fqdn";}
$t=time();
$UfdbguardSMTPNotifs=unserialize(base64_decode($sock->GET_INFO("UfdbguardSMTPNotifs")));
if(!isset($UfdbguardSMTPNotifs["ENABLED"])){$UfdbguardSMTPNotifs["ENABLED"]=0;}
if(!is_numeric($UfdbguardSMTPNotifs["ENABLED"])){$UfdbguardSMTPNotifs["ENABLED"]=0;}
$UseRemoteUfdbguardService=$sock->GET_INFO("UseRemoteUfdbguardService");
if(!is_numeric($UseRemoteUfdbguardService)){$UseRemoteUfdbguardService=0;}
if(!isset($UfdbguardSMTPNotifs["smtp_server_name"])){$UfdbguardSMTPNotifs["smtp_server_name"]=$ini->_params["SMTP"]["smtp_server_name"];}
if(!isset($UfdbguardSMTPNotifs["smtp_server_port"])){$UfdbguardSMTPNotifs["smtp_server_port"]=$ini->_params["SMTP"]["smtp_server_port"];}
if(!isset($UfdbguardSMTPNotifs["smtp_sender"])){$UfdbguardSMTPNotifs["smtp_server_port"]=$ini->_params["SMTP"]["smtp_sender"];}
if(!isset($UfdbguardSMTPNotifs["smtp_dest"])){$UfdbguardSMTPNotifs["smtp_dest"]=$ini->_params["SMTP"]["smtp_dest"];}
if(!isset($UfdbguardSMTPNotifs["smtp_auth_user"])){$UfdbguardSMTPNotifs["smtp_dest"]=$ini->_params["SMTP"]["smtp_auth_user"];}
if(!isset($UfdbguardSMTPNotifs["smtp_auth_passwd"])){$UfdbguardSMTPNotifs["smtp_auth_passwd"]=$ini->_params["SMTP"]["smtp_auth_passwd"];}
if(!isset($UfdbguardSMTPNotifs["tls_enabled"])){$UfdbguardSMTPNotifs["tls_enabled"]=$ini->_params["SMTP"]["tls_enabled"];}
if(!isset($UfdbguardSMTPNotifs["ssl_enabled"])){$UfdbguardSMTPNotifs["ssl_enabled"]=$ini->_params["SMTP"]["ssl_enabled"];}
if(!is_numeric($UfdbguardSMTPNotifs["smtp_server_port"])){$UfdbguardSMTPNotifs["smtp_server_port"]=25;}
//Switchdiv
$html="
<div class=explain style='font-size:14px'>{smtp_ufdbguard_notifications_text}</div>
<div id='notif1-$t'></div>
<table style='width:99%' class=form id='main-form-$t'>
<tr>
<td nowrap class=legend style='font-size:14px'>{smtp_enabled}:</strong></td>
<td>" . Field_checkbox("ENABLED",1,$UfdbguardSMTPNotifs["ENABLED"],"SMTPNotifArticaEnableSwitch$t()")."</td>
</tr>
<tr>
<td nowrap class=legend style='font-size:14px'>{smtp_server_name}:</strong></td>
<td>" . Field_text('smtp_server_name',trim($UfdbguardSMTPNotifs["smtp_server_name"]),'font-size:14px;padding:3px;width:250px')."</td>
</tr>
<tr>
<td nowrap class=legend style='font-size:14px'>{smtp_server_port}:</strong></td>
<td>" . Field_text('smtp_server_port',trim($UfdbguardSMTPNotifs["smtp_server_port"]),'font-size:14px;padding:3px;width:40px')."</td>
</tr>
<tr>
<td nowrap class=legend style='font-size:14px'>{smtp_sender}:</strong></td>
<td>" . Field_text('smtp_sender',trim($UfdbguardSMTPNotifs["smtp_sender"]),'font-size:14px;padding:3px;width:290px')."</td>
</tr>
<tr>
<td nowrap class=legend style='font-size:14px'>{smtp_dest}:</strong></td>
<td>" . Field_text('smtp_dest',trim($UfdbguardSMTPNotifs["smtp_dest"]),'font-size:14px;padding:3px;width:290px')."</td>
</tr>
<tr>
<td nowrap class=legend style='font-size:14px'>{smtp_auth_user}:</strong></td>
<td>" . Field_text('smtp_auth_user',trim($UfdbguardSMTPNotifs["smtp_auth_user"]),'font-size:14px;padding:3px;width:200px')."</td>
</tr>
<tr>
<td nowrap class=legend style='font-size:14px'>{smtp_auth_passwd}:</strong></td>
<td>" . Field_password("smtp_auth_passwd-$t",trim($UfdbguardSMTPNotifs["smtp_auth_passwd"]),'font-size:14px;padding:3px;width:100px')."</td>
</tr>
<tr>
<td nowrap class=legend style='font-size:14px'>{tls_enabled}:</strong></td>
<td>" . Field_checkbox("tls_enabled",1,$UfdbguardSMTPNotifs["tls_enabled"])."</td>
</tr>
<tr>
<td nowrap class=legend style='font-size:14px'>{UseSSL}:</strong></td>
<td>" . Field_checkbox("ssl_enabled",1,$UfdbguardSMTPNotifs["ssl_enabled"])."</td>
</tr>
<tr>
<td align='right' colspan=2>".button('{apply}',"SaveArticaSMTPNotifValues$t();",16)."</td>
</tr>
</tr>
</table>
<script>
var x_SaveArticaSMTPNotifValues$t= function (obj) {
var results=obj.responseText;
document.getElementById('notif1-$t').innerHTML='';
if(results.length>0){alert(results);}
RefreshTab('main_ufdbguard_config');
}
function SaveArticaSMTPNotifValues$t(){
var UseRemoteUfdbguardService=$UseRemoteUfdbguardService;
if(UseRemoteUfdbguardService==1){return;}
var XHR = new XHRConnection();
var pp=encodeURIComponent(document.getElementById('smtp_auth_passwd-$t').value);
if(document.getElementById('ENABLED').checked){XHR.appendData('ENABLED',1);}else {XHR.appendData('ENABLED',0);}
if(document.getElementById('tls_enabled').checked){XHR.appendData('tls_enabled',1);}else {XHR.appendData('tls_enabled',0);}
if(document.getElementById('ssl_enabled').checked){XHR.appendData('ssl_enabled',1);}else {XHR.appendData('ssl_enabled',0);}
XHR.appendData('smtp_server_name',document.getElementById('smtp_server_name').value);
XHR.appendData('smtp_server_port',document.getElementById('smtp_server_port').value);
XHR.appendData('smtp_sender',document.getElementById('smtp_sender').value);
XHR.appendData('smtp_dest',document.getElementById('smtp_dest').value);
XHR.appendData('smtp_auth_user',document.getElementById('smtp_auth_user').value);
XHR.appendData('smtp_auth_passwd',pp);
XHR.appendData('smtp_notifications','yes');
AnimateDiv('notif1-$t');
XHR.sendAndLoad('$page', 'POST',x_SaveArticaSMTPNotifValues$t);
}
function SMTPNotifArticaEnableSwitch$t(){
document.getElementById('smtp_auth_passwd-$t').disabled=true;
document.getElementById('smtp_auth_user').disabled=true;
document.getElementById('smtp_dest').disabled=true;
document.getElementById('smtp_sender').disabled=true;
document.getElementById('smtp_server_port').disabled=true;
document.getElementById('smtp_server_name').disabled=true;
document.getElementById('tls_enabled').disabled=true;
document.getElementById('ssl_enabled').disabled=true;
if(!document.getElementById('ENABLED').checked){return;}
document.getElementById('smtp_auth_passwd-$t').disabled=false;
document.getElementById('smtp_auth_user').disabled=false;
document.getElementById('smtp_dest').disabled=false;
document.getElementById('smtp_sender').disabled=false;
document.getElementById('smtp_server_port').disabled=false;
document.getElementById('smtp_server_name').disabled=false;
document.getElementById('tls_enabled').disabled=false;
document.getElementById('ssl_enabled').disabled=false;
var UseRemoteUfdbguardService=$UseRemoteUfdbguardService;
if(UseRemoteUfdbguardService==1){
DisableFieldsFromId('main-form-$t');
}
}
SMTPNotifArticaEnableSwitch$t();
</script>";
echo $tpl->_ENGINE_parse_body($html);
}
function Save(){
$_POST["smtp_auth_passwd"]=url_decode_special_tool($_POST["smtp_auth_passwd"]);
$sock=new sockets();
$sock=new sockets();
$UfdbguardSMTPNotifs=unserialize(base64_decode($sock->GET_INFO("UfdbguardSMTPNotifs")));
while (list ($num, $ligne) = each ($_POST) ){
$UfdbguardSMTPNotifs[$num]=$ligne;
}
$sock->SaveConfigFile(base64_encode(serialize($UfdbguardSMTPNotifs)), "UfdbguardSMTPNotifs");
}