forked from poppyred/1.6.x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
domains.edit.user.inbound.php
executable file
·374 lines (284 loc) · 10.5 KB
/
domains.edit.user.inbound.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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
<?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.user.inc');
include_once('ressources/class.ini.inc');
if((isset($_GET["uid"])) && (!isset($_GET["userid"]))){$_GET["userid"]=$_GET["uid"];}
if(!GetRights_aliases2()){
$tpl=new templates();
echo "alert('". $tpl->javascript_parse_text("{ERROR_NO_PRIVS}")."');";
die();exit();
}
if(isset($_GET["popup"])){popup();exit;}
if(isset($_GET["RecipientToAdd"])){SAVE();exit;}
if(isset($_GET["usermap"])){usermap();exit;}
if(isset($_GET["RedirectDelete"])){REDIRECT_DELETE();exit;}
js();
function js(){
$page=CurrentPageName();
$tpl=new templates();
$title=$tpl->_ENGINE_parse_body("{inbound_parameters}");
$html="
function USER_RECIPT_LOAD(){
YahooWin3(650,'$page?userid={$_GET["userid"]}&popup=yes','$title');
}
function RecipientToAddCheck(e){if(checkEnter(e)){RecipientToAdd();}}
var x_RecipientToAdd= function (obj) {
var tempvalue=obj.responseText;
if(tempvalue.length>3){alert(tempvalue);}
USER_RECIPT_LOAD();
}
function RecipientToAdd(){
var UserID='{$_GET["userid"]}';
var RecipientToAdd=document.getElementById('RecipientToAdd').value;
document.getElementById('RecipientToAddID').innerHTML='<center style=width:100%><img src=img/wait_verybig.gif></center>';
var XHR = new XHRConnection();
XHR.appendData('RecipientToAdd',RecipientToAdd);
XHR.appendData('MailAlternateAddress',document.getElementById('MailAlternateAddress').value);
XHR.appendData('redirect_messages_to',document.getElementById('redirect_messages_to').value);
XHR.appendData('uid',UserID);
XHR.sendAndLoad('$page', 'GET',x_RecipientToAdd);
}
function HideRedirect(){document.getElementById('redirect_messages_to').disabled=true;}
function RedirectDelete(id){
var XHR = new XHRConnection();
XHR.appendData('RedirectDelete',id);
XHR.sendAndLoad('$page', 'GET',x_RecipientToAdd);
}
USER_RECIPT_LOAD();
";
echo $html;
}
function popup(){
$page=CurrentPageName();
writelogs("USER_ACCOUNT::{$_GET["userid"]}",__FUNCTION__,__FILE__,__LINE__);
$user=new user($_GET["userid"]);
$ou=$user->ou;
$priv=new usersMenus();
$sock=new sockets();
$recipient_bcc_maps_text='{recipient_bcc_maps_text}';
$ArticaFilterEnableRedirect=$sock->GET_INFO("ArticaFilterEnableRedirect");
$styleTDRight="style='padding:5px;font-size:13px'";
$styleTDLeft="style='padding:5px;font-size:11px'";
if($ArticaFilterEnableRedirect<>1){
$jsRedirect="HideRedirect();";
}
$html="
<table style='width:100%'>
<tr>
<td align='right' nowrap class=legend $styleTDRight>{duplicate_mailto}:</strong>
<td $styleTDLeft>" . Field_text('RecipientToAdd',$user->RecipientToAdd[0],"padding:3px;font-size:13px",null,null,null,false,"RecipientToAddCheck(event)")."</td>
<td width=1%>" . help_icon("{duplicate_mailto_text}")."</td>
</tr>
<tr>
<td align='right' nowrap class=legend $styleTDRight>{transforme_mailto}:</strong>
<td $styleTDLeft>" . Field_text('MailAlternateAddress',$user->MailAlternateAddress,
"padding:3px;font-size:13px",null,null,null,false,"RecipientToAddCheck(event)")."</td>
<td>" . help_icon("{transforme_mailto_text}")."</td>
</tr>
<tr>
<td align='right' nowrap class=legend $styleTDRight>{redirect_messages}:</strong>
<td $styleTDLeft>" . Field_text('redirect_messages_to',null,
"padding:3px;font-size:13px",null,null,null,false,"RecipientToAddCheck(event)")."</td>
<td>" . help_icon("{redirect_messages_text}")."</td>
</tr>
</table>
<br>
<div class=text-info>$recipient_bcc_maps_text</div>
<div style='width:100%;height:150px;overflow:auto' id='RecipientToAddID'></div>
<script>
$jsRedirect
LoadAjax('RecipientToAddID','$page?usermap=yes&userid={$_GET["userid"]}');
</script>
";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
function usermap(){
$user=new user($_GET["userid"]);
$end1="<td width=1% align='center'><img src='img/user-48.png'></td>";
$end11="<td align='center' style='font-size:13px'>$user->mail</td>";
if($user->RecipientToAdd[0]<>null){
$spy="<td width=1% align='center'><img src='img/user-spy-48.png'></td>
<td width=1% align='center'><img src='img/arrow-right-64.png'></td>";
$spyend="<td align='center' style='font-size:13px'>{$user->RecipientToAdd[0]}</td>
<td> </td>";
}
if($user->MailAlternateAddress<>null){
$end1="<td width=1% align='center'><img src='img/postmaster-48.png'></td>";
$end11="<td align='center' style='font-size:13px'>{$user->MailAlternateAddress}</td>";
}
$sock=new sockets();
$ArticaFilterEnableRedirect=$sock->GET_INFO("ArticaFilterEnableRedirect");
if($ArticaFilterEnableRedirect==1){
$redirects=REDIRECT_QUERIES($user->mail);
if($redirects<>null){$end11="<td align='center' style='font-size:13px'>$redirects</td>";}
}
if(is_array($user->HASH_ALL_MAILS)){
}
$html="
<hr>
<table style='width:100%'>
<tr>
<td width=1% align='center'><img src='img/user-48.png'></td>
<td width=1% align='center'><img src='img/arrow-right-64.png'></td>
$spy
$end1
</tr>
<tr>
<td align='center' style='font-size:13px'>".@implode(", ",$user->HASH_ALL_MAILS)."</td>
<td> </td>
$spyend
$end11
</tr>
</table>
<hr>
";
echo $html;
}
function REDIRECT_QUERIES($mail){
$sql="SELECT `id`,`mail` FROM `redirectmail` WHERE `from`='$mail' AND `del`=1 LIMIT 0,10";
$sock=new sockets();
$ArticaFilterRedirectExternalSQL=$sock->GET_INFO("ArticaFilterRedirectExternalSQL");
if($ArticaFilterRedirectExternalSQL==1){
$array=unserialize(base64_decode($sock->GET_INFO("ArticaFilterRedirectExternalSQLDatas")));
$bd=@mysql_connect($array["mysql_servername"],$array["mysql_username"],$array["password"]);
$ok=@mysql_select_db($array["mysql_database"]);
if(!$ok){
$des=mysql_error();
echo "<span style='color:red'>redirect: $des L.".__LINE__."</span>";
@mysql_close($bd);
return false;
}
$results=mysql_query($sql);
if(mysql_error()){$des=mysql_error();@mysql_close($bd);echo "<span style='color:red'>redirect: $des L.".__LINE__."</span>";return false;}
}else{
$q=new mysql();
$results=$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){
echo "<span style='color:red'>redirect: $des L.".__LINE__."</span>";
@mysql_close($q->mysql_connection);
return false;
}
}
$redirected=false;
$mailFromRedirect=$recipient;
while($ligne=mysql_fetch_array($results,MYSQL_ASSOC)){
$mailToRedirect=strtolower(trim($ligne["mail"]));
if($mailToRedirect==null){continue;}
$html=$html."
<tr ". CellRollOver().">
<td width=1%><img src='img/identity-24.png'></td>
<td><span style='font-size:12px'>{redirected}:$mailToRedirect</span></td>
<td>". imgtootltip("ed_delete.gif","{delete}","RedirectDelete({$ligne["id"]})")."</td>
</tr>
";
$redirected=true;
}
if(!$redirected){return null;}
return "<table>$html</table>";
}
function GetRights_aliases2(){
$usersprivs=new usersMenus();
if($usersprivs->AsSystemAdministrator){return true;}
if($usersprivs->AsAnAdministratorGeneric){return true;}
if($usersprivs->AllowEditOuSecurity){return true;}
if($usersprivs->AsMessagingOrg){return true;}
if($usersprivs->AllowEditAliases){return true;}
return false;
}
function ADD_REDIRECT_MESSAGES($uid,$email){
$ct=new user($_GET["uid"]);
$sock=new sockets();
$ArticaFilterEnableRedirect=$sock->GET_INFO("ArticaFilterEnableRedirect");
if($ArticaFilterEnableRedirect<>1){return;}
$_GET["redirect_messages_to"]=trim($_GET["redirect_messages_to"]);
$ArticaFilterRedirectExternalSQL=$sock->GET_INFO("ArticaFilterRedirectExternalSQL");
$mail=$ct->mail;
$sql="INSERT INTO `redirectmail` (`mail`,`from`,`del`) VALUES('{$_GET["redirect_messages_to"]}','$mail','1')";
if($ArticaFilterRedirectExternalSQL==1){
$array=unserialize(base64_decode($sock->GET_INFO("ArticaFilterRedirectExternalSQLDatas")));
$bd=@mysql_connect($array["mysql_servername"],$array["mysql_username"],$array["password"]);
$ok=@mysql_select_db($array["mysql_database"]);
if(!$ok){
echo __FUNCTION__."\n".mysql_error()."\nLine: ".__LINE__;
@mysql_close($bd);
return false;
}
$results=mysql_query($sql);
if(mysql_error()){
echo __FUNCTION__."\n".mysql_error()."\nLine: ".__LINE__;
return false;
}
}else{
$q=new mysql();
$results=$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){
echo __FUNCTION__."\n$q->mysql_error\nLine: ".__LINE__;
@mysql_close($q->mysql_connection);
return false;
}
}
}
function REDIRECT_DELETE(){
$sock=new sockets();
$ArticaFilterRedirectExternalSQL=$sock->GET_INFO("ArticaFilterRedirectExternalSQL");
if(!is_numeric($_GET["RedirectDelete"])){return null;}
$sql="DELETE FROM `redirectmail` WHERE id={$_GET["RedirectDelete"]}";
if($ArticaFilterRedirectExternalSQL==1){
$array=unserialize(base64_decode($sock->GET_INFO("ArticaFilterRedirectExternalSQLDatas")));
$bd=@mysql_connect($array["mysql_servername"],$array["mysql_username"],$array["password"]);
$ok=@mysql_select_db($array["mysql_database"]);
if(!$ok){
echo __FUNCTION__."\n".mysql_error()."\nLine: ".__LINE__;
@mysql_close($bd);
return false;
}
$results=mysql_query($sql);
if(mysql_error()){
echo __FUNCTION__."\n".mysql_error()."\nLine: ".__LINE__;
return false;
}
}else{
$q=new mysql();
$results=$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){
echo __FUNCTION__."\n$q->mysql_error\nLine: ".__LINE__;
@mysql_close($q->mysql_connection);
return false;
}
}
}
function SAVE(){
$RecipientToAdd=trim(strtolower($_GET["RecipientToAdd"]));
$MailAlternateAddress=trim($_GET["MailAlternateAddress"]);
$ct=new user($_GET["uid"]);
if($RecipientToAdd==null){$ct->del_all_bcc();}
if($_GET["redirect_messages_to"]<>null){
ADD_REDIRECT_MESSAGES($_GET["uid"],$_GET["redirect_messages_to"]);
}
if($RecipientToAdd<>null){
if(!preg_match("#(.+?)@(.+)#",$RecipientToAdd)){
$tpl=new templates();
echo $tpl->_ENGINE_parse_body('{ERROR_INVALID_EMAIL_ADDR}:'.$RecipientToAdd);
exit;
}
$ct=new user($_GET["uid"]);
$ct->add_bcc($_GET["RecipientToAdd"]);
}
if($MailAlternateAddress<>null){
if(preg_match("#^(.+?)@(.+?);#",$MailAlternateAddress,$re)){
$MailAlternateAddress=$re[1];
}
if(!preg_match("#(.+?)@(.+)#",$MailAlternateAddress)){
$tpl=new templates();
echo $tpl->_ENGINE_parse_body('{ERROR_INVALID_EMAIL_ADDR}:'.$MailAlternateAddress);
exit;
}
}
$ct->MailAlternateAddress=$MailAlternateAddress;
$ct->SaveMailAlternateAddress();
}
?>