-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdomain.php
232 lines (209 loc) · 6.8 KB
/
domain.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
<?php
require_once $_SERVER["DOCUMENT_ROOT"]."/etc/header.php";
?>
<?php if(empty($_GET['mail'])):?>
<!-- Oversigt over domænet -->
<a href="<?= HOME;?>" class=""><?= $Content->out(34);?></a>
<h1><?= $Content->out(21);?> <?= $d;?></h1>
<p>
<br/>
</p>
<ul class="list-unstyled">
<?php
$q = $con->prepare("SELECT is_list, is_alias, is_forwarding, address, COUNT(*) AS antal FROM forwardings WHERE domain LIKE (:d) GROUP BY address ORDER BY address ASC");
$q->bindParam(":d", $d);
$q->execute();
foreach($q->fetchAll(PDO::FETCH_ASSOC) as $mail){
if($mail['is_list'] == 1){
$type = $Content->out(27);
} elseif($mail['is_alias'] == 1){
$type = $Content->out(26);
} else{
$type = $Content->out(25);
}
?>
<li>
<?php if($mail['is_forwarding'] == 0){?>
<a href="<?= HOME;?>domain/<?= $d.'/'.$mail['address'];?>"><?= $mail['address']?> (<?= $type;?>)</a>
<?php } elseif($mail['is_forwarding'] == 1){?>
<?= $mail['address']?> (<?= $type;?>) <a href="<?= HOME;?>domain/<?= $d.'/'.$mail['address'];?>">
<?php if($mail['antal'] > 1){?>
<?= $Content->out(51);?>
<?php } else{?>
<?= $Content->out(50);?>
<?php }?>
</a>
<?php }?>
</li>
<?php
}
?>
<li> </li>
<li><a href="<?= HOME;?>domain/<?= $d;?>/new"><?= $Content->out(22);?></a></li>
</ul>
<?php elseif($m == "new"):?>
<!-- Opret ny -->
<a href="<?= HOME;?>domain/<?= $d;?>" class=""><?= $Content->out(33);?></a>
<h1><?= $Content->out(23);?> <?= $d;?></h1>
<p>
<br/>
</p>
<form class="domain col-md-8 col-md-offset-2" action="<?= SCRIPTS;?>domain.php" method="post">
<input type="hidden" name="method" value="post">
<input type="hidden" name="action" value="create-email">
<div class="form-group">
<label for="InputEmail"><?= $Content->out(28);?>:</label>
<input type="text" class="form-control" id="InputEmail" name="u" autocomplete="off">
</div>
<h3><?= $Content->out(29);?>:</h3>
<?= $Content->out(30);?><br/><br/>
<input type="hidden" name="d" value="dom[]"/>
<div id="targets">
<div class="form-group">
<input type="text" class="form-control" name="dom[]">
</div>
</div>
<div class="form-group text-right">
<a type="button" class="MOAR btn btn-info"><?= $Content->out(32);?></a>
<button type="button" class="submit btn btn-primary"><?= $Content->out(31);?></button>
</div>
<?= $Content->statusBox();?>
</form>
<div class="form-group TEMPLATE">
<input type="text" class="form-control template" name="dom[]">
</div>
<script type="text/javascript">
$(function(){
$(".submit").click(function(e){
e.preventDefault();
E = 0;
let Data = objectifyForm($("form.domain").serializeArray());
Data.medium = "ajax";
Data.domain = "<?= $d;?>";
if(E == 0){
call("<?= SCRIPTS;?>domain.php", Data, function(d){
statusBox(".status", d.msg, d.status);
setTimeout(function(){
window.location = "/domain/<?= $d;?>";
}, 1500);
}, ".status");
} else{
statusBox(".status", "<?= $Content->out(35);?>", "danger");
}
});
// Skal håndtere at der bliver trykket for at få en boks mere frem til at vælge hvad brugeren skal være admin for
$(".MOAR").click(function(e){
e.preventDefault();
$(".TEMPLATE").clone().appendTo("#targets");
$("#targets .template").slideDown(250);
$("#targets .template").removeClass("template");
$("#targets .TEMPLATE").removeClass("TEMPLATE");
$("input[name='d']").val(n);
});
});
</script>
<?php else:?>
<!-- Ret emailen -->
<?php
$q = $con->prepare("SELECT is_list, is_alias, is_forwarding, address, forwarding FROM forwardings WHERE address LIKE (:a)");
$q->bindParam(":a", $m);
$q->execute();
$mails = $q->fetchAll(PDO::FETCH_ASSOC);
?>
<a href="<?= HOME;?>domain/<?= $d;?>" class=""><?= $Content->out(33);?></a>
<?php if($mails[0]['is_forwarding'] == 1):?>
<h1><?= $Content->out(52);?> <?= $d;?></h1>
<?php else:?>
<h1><?= $Content->out(24);?> <?= $d;?></h1>
<?php endif;?>
<p>
<br/>
</p>
<form class="domain col-md-8 col-md-offset-2" action="<?= SCRIPTS;?>domain.php" method="post">
<input type="hidden" name="method" value="post">
<input type="hidden" name="original" id="original" value="<?= $m;?>">
<input type="hidden" name="action" value="update-email">
<div class="form-group">
<label for="InputEmail"><?= $Content->out(28);?>:</label>
<input type="text" class="form-control" id="InputEmail" name="u" autocomplete="off" value="<?= str_replace("@".$d, "", $m);?>">
</div>
<h3><?= $Content->out(29);?>:</h3>
<?= $Content->out(30);?><br/><br/>
<div id="targets">
<?php
foreach($mails as $line => $mail){
?>
<div class="form-group">
<input type="text" class="form-control" name="dom[]" value="<?= $mail['forwarding'];?>"<?= ($mail['forwarding'] == $m ? "disabled title='".$Content->out(49)."'" : "");?>>
</div>
<?php
}
?>
</div>
<div class="form-group text-right">
<a type="button" class="MOAR btn btn-info"><?= $Content->out(32);?></a>
<button type="button" class="submit btn btn-primary"><?= $Content->out(39);?></button>
<?php if($mails[0]['is_forwarding'] == 0):?>
<button type="button" class="delete btn btn-danger"><?= $Content->out(40);?></button>
<?php endif;?>
</div>
<?= $Content->statusBox();?>
</form>
<div class="form-group TEMPLATE">
<input type="text" class="form-control template" name="dom[]">
</div>
<script type="text/javascript">
$(function(){
<?php if($mails[0]['is_forwarding'] == 0):?>
$(".delete").click(function(e){
e.preventDefault();
E = 0;
let Data = {};
Data.medium = "ajax";
Data.action = "delete-email";
Data.original = validate("#original");
Data.domain = "<?= $d;?>";
if(E == 0){
call("<?= SCRIPTS;?>domain.php", Data, function(d){
statusBox(".status", d.msg, d.status);
setTimeout(function(){
window.location = "/domain/<?= $d;?>";
}, 1500);
}, ".status");
} else{
statusBox(".status", "<?= $Content->out(35);?>", "danger");
}
});
<?php endif;?>
$(".submit").click(function(e){
e.preventDefault();
E = 0;
let Data = objectifyForm($("form.domain").serializeArray());
Data.medium = "ajax";
Data.domain = "<?= $d;?>";
if(E == 0){
call("<?= SCRIPTS;?>domain.php", Data, function(d){
statusBox(".status", d.msg, d.status);
setTimeout(function(){
window.location = "/domain/<?= $d;?>";
}, 1500);
}, ".status");
} else{
statusBox(".status", "<?= $Content->out(35);?>", "danger");
}
});
// Skal håndtere at der bliver trykket for at få en boks mere frem til at vælge hvad brugeren skal være admin for
$(".MOAR").click(function(e){
e.preventDefault();
$(".TEMPLATE").clone().appendTo("#targets");
$("#targets .template").slideDown(250);
$("#targets .template").removeClass("template");
$("#targets .TEMPLATE").removeClass("TEMPLATE");
$("input[name='d']").val(n);
});
});
</script>
<?php endif;?>
<?php
include $_SERVER["DOCUMENT_ROOT"]."/etc/footer.php";
?>