-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdomain_new.php
executable file
·112 lines (104 loc) · 4.69 KB
/
domain_new.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
<?php
require 'inc/functions.php';
require 'inc/common_header.php';
securePage();
if( isset( $_POST['submit'] ) ) {
$cn = filter_var( $_POST['cn'] , FILTER_SANITIZE_STRING );
$domain = filter_var( $_POST['domain'] , FILTER_SANITIZE_STRING );
$disclaimer = filter_var( $_POST['disclaimer'] , FILTER_SANITIZE_STRING );
if( ! empty( $disclaimer ) ) {
$info['disclaimer'] = $disclaimer;
}
if( isset( $_POST['accountstatus'] ) ) {
$accountstatus = "active";
} else {
$accountstatus = "inactive";
}
require 'inc/bind.php';
$info['cn'] = $cn;
$info['objectClass'] = "mailDomain";
$info['domainCurrentUserNumber'] = 0;
$info['domainCurrentQuotaSize'] = 0;
$info['accountStatus'] = $accountstatus;
$info['accountSetting'][0] = "minPasswordLength:8";
$info['accountSetting'][1] = "defaultQuota:1024";
$info['enabledService'][0] = "mail";
$info['enabledService'][1] = "smtp";
$info['enabledService'][2] = "smtps";
$info['enabledService'][3] = "smtptsl";
$info['mtaTransport'] = "dovecot";
$info['domainName'] = $domain;
// Create the object
$r = ldap_add( $ds , "domainName=$domain," . LDAP_DOMAINDN , $info );
// Create OUs
$ou['objectclass'][0] = "organizationalUnit";
$ou['objectclass'][1] = "top";
$ou['ou'] = "Aliases";
ldap_add( $ds , "ou=Aliases," . "domainName=$domain," . LDAP_DOMAINDN , $ou );
$ou['ou'] = "Users";
ldap_add( $ds , "ou=Users," . "domainName=$domain," . LDAP_DOMAINDN , $ou );
$ou['ou'] = "Computers";
ldap_add( $ds , "ou=Computers," . "domainName=$domain," . LDAP_DOMAINDN , $ou );
$ou['ou'] = "Externals";
ldap_add( $ds , "ou=Externals," . "domainName=$domain," . LDAP_DOMAINDN , $ou );
$ou['ou'] = "Groups";
ldap_add( $ds , "ou=Groups," . "domainName=$domain," . LDAP_DOMAINDN , $ou );
plugins_process( "domain_new" , "submit" );
watchdog( "Adding domain `" . $domain . "`" );
header( "Location:domains.php?added" );
}
?>
<html>
<head>
<?php
require 'inc/header.php';
?>
</head>
<body>
<?php require 'inc/topbar.php'; ?>
<div class="container">
<div class="row">
<div class="col">
<form method="post">
<h1>New Domain</h1>
<?php
if( isset( $domainAlreadyExists ) ) {
echo "<div class='alert alert-danger'><strong>ERROR:</strong> This domain already exists!</div>";
}
if( isset( $domainAdded ) ) {
echo "<div class='alert alert-success'>This domain created!</div>";
}
?>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="domains.php">Domains</a></li>
<li class="breadcrumb-item active" aria-current="page">New</li>
</ol>
</nav>
<div class="form-check">
<input class="form-check-input" checked type="checkbox" value="" id="accountstatus" name="accountstatus">
<label class="form-check-label" for="accountstatus">
Enable this domain
</label>
</div>
<div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Company/Organization Name:</span></div>
<input required name="cn" class="form-control">
</div>
<div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Domain Name:</span></div>
<input required name="domain" class="form-control">
</div>
<p> </p>
<div class="mb-3">
<label for="disclaimer" class="form-label">Disclaimer:</label>
<textarea class="form-control" id="disclaimer" rows="3" name="disclaimer"></textarea>
</div>
<?php plugins_process( "domain_new" , "form" ); ?>
<p><button type="submit" name="submit" class="btn btn-success"><i class='fas fa-save'></i> Save</button></p>
</form>
</div>
</div>
</div>
</body>
</html>