-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathalias_edit.php
executable file
·106 lines (104 loc) · 4.98 KB
/
alias_edit.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
<?php
require 'inc/functions.php';
require 'inc/common_header.php';
securePage();
require 'inc/bind.php';
?>
<html>
<head>
<?php
require 'inc/header.php';
$alias = filter_var( $_GET['alias'] , FILTER_SANITIZE_STRING );
$filter = "(mail=$alias)";
$part = explode( "@" , $alias );
$domain = $part[1];
$dn = "mail=" . $alias . ",ou=Aliases,domainName=" . $domain . "," . LDAP_DOMAINDN;
$getCurrent = ldap_search( $ds , $dn , $filter );
$current = ldap_get_entries( $ds , $getCurrent );
unset( $current['count'] );
// Submit
if( isset( $_POST['submit'] ) ) {
if( ! empty( $_POST['description'] ) ) {
$description = filter_var( $_POST['description'] , FILTER_SANITIZE_STRING );
} else {
$description = NULL;
}
ldap_modify( $ds , $dn , array( "description" => $description ) );
if( ! empty( $_POST['addAddress'] ) ) {
$add = filter_var( $_POST['addAddress'] , FILTER_VALIDATE_EMAIL );
ldap_mod_add( $ds , $dn , array( "mailforwardingaddress" => $add ) );
}
$saved = TRUE;
$getCurrent = ldap_search( $ds , $dn , $filter );
$current = ldap_get_entries( $ds , $getCurrent );
plugins_process( "alias_edit" , "submit" );
}
// Remove
if( isset( $_GET['delete'] ) ) {
$delete = filter_var( $_GET['delete'] , FILTER_VALIDATE_EMAIL );
ldap_mod_del( $ds , $dn , array( "mailforwardingaddress" => $delete ) );
header( "Location: alias_edit.php?alias=" . $alias );
}
?>
</head>
<body>
<?php require 'inc/topbar.php'; ?>
<div class="container">
<div class="row">
<div class="col">
<h1>Edit Aliases</h1>
<?php
if( isset( $saved ) ) {
echo "<div class='alert alert-success'>Changes saved!</div>";
}
?>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="alias.php">Alias</a></li>
<li class="breadcrumb-item active" aria-current="page"><?php echo $alias; ?></li>
</ol>
</nav>
<form method="post">
<div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Description</span></div>
<?php
$filter = "(mail=" . $alias . ")";
$findAlias = ldap_search( $ds , LDAP_BASEDN , $filter );
$aliasDetail = ldap_get_entries( $ds , $findAlias );
if( ! empty( $aliasDetail[0]['description'] ) ) {
$description = $aliasDetail[0]['description'][0];
} else {
$description = "";
}
?>
<input type="text" name="description" value="<?php echo $description; ?>" class="form-control">
<span class="input-group-btn"><button type="submit" name="submit" class="btn btn-success"><i class="fas fa-save"></i></button></span>
</div>
<p></p>
<table class="table table-border table-stripped">
<tr>
<th colspan="2">Forwarding Address:</th>
</tr>
<?php
unset( $current[0]['mailforwardingaddress']['count'] );
if( isset( $current[0]['mailforwardingaddress'] ) ) {
foreach( $current[0]['mailforwardingaddress'] as $address ) {
echo "<tr>";
echo '<td>' . $address . "</td>";
echo "<td width='1'><a href='alias_edit.php?alias=$alias&delete=" . $address . "' class='btn btn-danger'><i class='fas fa-trash'></i></a></td>";
echo "</tr>";
}
}
?>
<tr>
<td><input type="text" name="addAddress" class="form-control"></td>
<td width="1"><button type="submit" name="submit" class="btn btn-success"><i class="fas fa-plus"></i></td>
</tr>
</table>
<?php plugins_process( "alias_edit" , "form" ); ?>
</form>
</div>
</div>
</div>
</body>
</html>