Refactoring of configuration loading
Use one INI file instead of multiple PHP files
This commit is contained in:
parent
8938ed91da
commit
d7e7a368b1
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,4 +1,2 @@
|
||||||
*.swp
|
*.swp
|
||||||
htdocs/config/conf.php
|
config/config.ini
|
||||||
htdocs/config/connect.php
|
|
||||||
htdocs/lib/hook.php
|
|
||||||
|
|
21
config/config-sample.ini
Normal file
21
config/config-sample.ini
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
; The configuration for evoadmin-mail
|
||||||
|
;
|
||||||
|
; You need to copy and edit config-sample.ini to config.ini.
|
||||||
|
; This INI file is loaded by evoadmin-mail and contains the
|
||||||
|
; following configurations :
|
||||||
|
;
|
||||||
|
; * Global settings
|
||||||
|
; * LDAP settings
|
||||||
|
;
|
||||||
|
|
||||||
|
[global]
|
||||||
|
name = "Evoadmin Mail XXX";
|
||||||
|
mail = "evoadmin-mail@example.com"
|
||||||
|
|
||||||
|
[ldap]
|
||||||
|
host = "127.0.0.1"
|
||||||
|
port = 389
|
||||||
|
base = "dc=example,dc=com"
|
||||||
|
admin_dn = "cn=admin,dc=example,dc=com"
|
||||||
|
admin_pass = "xxxxxxx"
|
||||||
|
superadmin[] = "evoadmin"
|
|
@ -84,9 +84,6 @@ if (!empty($_POST['isactive']) && $server->isSuperAdmin()) {
|
||||||
<a href="compte.php?domain=<?php print $domain->getName() ?>"><button type="button" class="btn btn-primary">Ajouter un nouveau compte</button></a>
|
<a href="compte.php?domain=<?php print $domain->getName() ?>"><button type="button" class="btn btn-primary">Ajouter un nouveau compte</button></a>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// only for mail mode
|
|
||||||
if (($conf['admin']['what'] == 1) || ($conf['admin']['what'] == 3)) {
|
|
||||||
|
|
||||||
$viewonly1= ( (isset($_GET['viewonly'])) && ($_GET['viewonly']==2) ) ? "" : "selected='selected'";
|
$viewonly1= ( (isset($_GET['viewonly'])) && ($_GET['viewonly']==2) ) ? "" : "selected='selected'";
|
||||||
$viewonly2= ( (isset($_GET['viewonly'])) && ($_GET['viewonly']==2) ) ? "selected='selected'" : "";
|
$viewonly2= ( (isset($_GET['viewonly'])) && ($_GET['viewonly']==2) ) ? "selected='selected'" : "";
|
||||||
?>
|
?>
|
||||||
|
@ -105,7 +102,6 @@ if (!empty($_POST['isactive']) && $server->isSuperAdmin()) {
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
}
|
|
||||||
|
|
||||||
if ( (!isset($_GET['viewonly'])) || ($_GET['viewonly']==1) ) {
|
if ( (!isset($_GET['viewonly'])) || ($_GET['viewonly']==1) ) {
|
||||||
|
|
||||||
|
|
|
@ -68,9 +68,7 @@ if (isset($_GET['alias'])) {
|
||||||
foreach($alias->getAliases() as $mailaccept) {
|
foreach($alias->getAliases() as $mailaccept) {
|
||||||
print "<tr><td align='right'>Mail accepté en entrée :</td>
|
print "<tr><td align='right'>Mail accepté en entrée :</td>
|
||||||
<td align='left'><input type='text' name='mailaccept[]' size='30' value='".$mailaccept."' />";
|
<td align='left'><input type='text' name='mailaccept[]' size='30' value='".$mailaccept."' />";
|
||||||
if (!$conf['domaines']['onlyone']) {
|
|
||||||
print "@" .$domain->getName();
|
print "@" .$domain->getName();
|
||||||
}
|
|
||||||
|
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
}
|
}
|
||||||
|
@ -78,25 +76,19 @@ if (isset($_GET['alias'])) {
|
||||||
print "<tr><td align='right'>Création d'un nouveau mail accepté en entrée :</td>
|
print "<tr><td align='right'>Création d'un nouveau mail accepté en entrée :</td>
|
||||||
<td align='left'><input type='text' name='mailaccept[]'
|
<td align='left'><input type='text' name='mailaccept[]'
|
||||||
size='30'/>";
|
size='30'/>";
|
||||||
if (!$conf['domaines']['onlyone']) {
|
|
||||||
print "@" .$domain->getName();
|
print "@" .$domain->getName();
|
||||||
}
|
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
print "<tr><td align='right'>Création d'un nouveau mail accepté en entrée :</td>
|
print "<tr><td align='right'>Création d'un nouveau mail accepté en entrée :</td>
|
||||||
<td align='left'><input type='text' name='mailaccept[]'
|
<td align='left'><input type='text' name='mailaccept[]'
|
||||||
size='30'/>";
|
size='30'/>";
|
||||||
if (!$conf['domaines']['onlyone']) {
|
|
||||||
print "@" .$domain->getName();
|
print "@" .$domain->getName();
|
||||||
}
|
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
print "<tr><td align='right'>Création d'un nouveau mail accepté en entrée :</td>
|
print "<tr><td align='right'>Création d'un nouveau mail accepté en entrée :</td>
|
||||||
<td align='left'><input type='text' name='mailaccept[]'
|
<td align='left'><input type='text' name='mailaccept[]'
|
||||||
size='30'/>";
|
size='30'/>";
|
||||||
if (!$conf['domaines']['onlyone']) {
|
|
||||||
print "@" .$domain->getName();
|
print "@" .$domain->getName();
|
||||||
}
|
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
foreach($alias->getRedirections() as $red) {
|
foreach($alias->getRedirections() as $red) {
|
||||||
|
@ -152,45 +144,35 @@ if (isset($_GET['alias'])) {
|
||||||
<tr><td align="right">Alias :</td>
|
<tr><td align="right">Alias :</td>
|
||||||
<td align="left"><input type='text' name='mailaccept[]'/>
|
<td align="left"><input type='text' name='mailaccept[]'/>
|
||||||
<?php
|
<?php
|
||||||
if (!$conf['domaines']['onlyone']) {
|
|
||||||
print "@" .$domain->getName();
|
print "@" .$domain->getName();
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
|
||||||
<tr><td align="right">Alias :</td>
|
<tr><td align="right">Alias :</td>
|
||||||
<td align="left"><input type='text' name='mailaccept[]'/>
|
<td align="left"><input type='text' name='mailaccept[]'/>
|
||||||
<?php
|
<?php
|
||||||
if (!$conf['domaines']['onlyone']) {
|
|
||||||
print "@" .$domain->getName();
|
print "@" .$domain->getName();
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
|
||||||
<tr><td align="right">Alias :</td>
|
<tr><td align="right">Alias :</td>
|
||||||
<td align="left"><input type='text' name='mailaccept[]'/>
|
<td align="left"><input type='text' name='mailaccept[]'/>
|
||||||
<?php
|
<?php
|
||||||
if (!$conf['domaines']['onlyone']) {
|
|
||||||
print "@" .$domain->getName();
|
print "@" .$domain->getName();
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
|
||||||
<tr><td align="right">Alias :</td>
|
<tr><td align="right">Alias :</td>
|
||||||
<td align="left"><input type='text' name='mailaccept[]'/>
|
<td align="left"><input type='text' name='mailaccept[]'/>
|
||||||
<?php
|
<?php
|
||||||
if (!$conf['domaines']['onlyone']) {
|
|
||||||
print "@" .$domain->getName();
|
print "@" .$domain->getName();
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
|
||||||
<tr><td align="right">Alias :</td>
|
<tr><td align="right">Alias :</td>
|
||||||
<td align="left"><input type='text' name='mailaccept[]'/>
|
<td align="left"><input type='text' name='mailaccept[]'/>
|
||||||
<?php
|
<?php
|
||||||
if (!$conf['domaines']['onlyone']) {
|
|
||||||
print "@" .$domain->getName();
|
print "@" .$domain->getName();
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ if (!empty($_POST['login'])) {
|
||||||
try {
|
try {
|
||||||
$login = htmlentities(strip_tags($_POST['login']),ENT_NOQUOTES);
|
$login = htmlentities(strip_tags($_POST['login']),ENT_NOQUOTES);
|
||||||
$password = htmlentities(strip_tags($_POST['password']),ENT_NOQUOTES);
|
$password = htmlentities(strip_tags($_POST['password']),ENT_NOQUOTES);
|
||||||
$server = new LdapServer($login, LDAP_BASE, LDAP_ADMIN_DN, LDAP_ADMIN_PASS, LDAP_URI);
|
$server = new LdapServer($login, $config['ldap']);
|
||||||
$server->login($password);
|
$server->login($password);
|
||||||
$_SESSION['login'] = $server->getLogin();
|
$_SESSION['login'] = $server->getLogin();
|
||||||
header("location: superadmin.php\n\n");
|
header("location: superadmin.php\n\n");
|
||||||
|
|
|
@ -76,9 +76,7 @@ if (isset($_GET['account'])) {
|
||||||
print "<label for='mailaccept[]' class='col-sm-3 control-label'>Mail accepté en entrée : </label>";
|
print "<label for='mailaccept[]' class='col-sm-3 control-label'>Mail accepté en entrée : </label>";
|
||||||
print "<div class='col-sm-7'><input type='text' name='mailaccept[]' value='".$aliase."' class='form-control' /></div>";
|
print "<div class='col-sm-7'><input type='text' name='mailaccept[]' value='".$aliase."' class='form-control' /></div>";
|
||||||
print "<div class='col-sm-2 control-label'>";
|
print "<div class='col-sm-2 control-label'>";
|
||||||
if (!$conf['domaines']['onlyone']) {
|
|
||||||
print "@" .$domain->getName();
|
print "@" .$domain->getName();
|
||||||
}
|
|
||||||
print "</div>";
|
print "</div>";
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
|
||||||
|
@ -88,9 +86,7 @@ if (isset($_GET['account'])) {
|
||||||
print "<label for='mailaccept[]' class='col-sm-3 control-label'>Création d'un nouveau mail accepté en entrée : </label>";
|
print "<label for='mailaccept[]' class='col-sm-3 control-label'>Création d'un nouveau mail accepté en entrée : </label>";
|
||||||
print "<div class='col-sm-7'><input type='text' name='mailaccept[]' value='' class='form-control' /></div>";
|
print "<div class='col-sm-7'><input type='text' name='mailaccept[]' value='' class='form-control' /></div>";
|
||||||
print "<div class='col-sm-2 control-label'>";
|
print "<div class='col-sm-2 control-label'>";
|
||||||
if (!$conf['domaines']['onlyone']) {
|
|
||||||
print "@" .$domain->getName();
|
print "@" .$domain->getName();
|
||||||
}
|
|
||||||
print "</div>";
|
print "</div>";
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
|
||||||
|
@ -165,7 +161,7 @@ if (isset($_GET['account'])) {
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="uid" class="col-sm-3 control-label">Login [*] :</label>
|
<label for="uid" class="col-sm-3 control-label">Login [*] :</label>
|
||||||
<div class="col-sm-7"><input type="text" name="uid" class="form-control" /></div>
|
<div class="col-sm-7"><input type="text" name="uid" class="form-control" /></div>
|
||||||
<div class="col-sm-2 control-label"><?php if (!$conf['domaines']['onlyone']) { print "@" .$domain->getName(); } ?></div>
|
<div class="col-sm-2 control-label"><?php print "@" .$domain->getName(); ?></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -190,19 +186,19 @@ if (isset($_GET['account'])) {
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="alias" class="col-sm-3 control-label">Alias :</label>
|
<label for="alias" class="col-sm-3 control-label">Alias :</label>
|
||||||
<div class="col-sm-7"><input type="text" name="alias[0]" class="form-control" /></div>
|
<div class="col-sm-7"><input type="text" name="alias[0]" class="form-control" /></div>
|
||||||
<div class="col-sm-2 control-label"><?php if (!$conf['domaines']['onlyone']) { print "@" .$domain->getName(); } ?></div>
|
<div class="col-sm-2 control-label"><?php print "@" .$domain->getName(); ?></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="alias[1]" class="col-sm-3 control-label">Alias :</label>
|
<label for="alias[1]" class="col-sm-3 control-label">Alias :</label>
|
||||||
<div class="col-sm-7"><input type="text" name="alias[1]" class="form-control" /></div>
|
<div class="col-sm-7"><input type="text" name="alias[1]" class="form-control" /></div>
|
||||||
<div class="col-sm-2 control-label"><?php if (!$conf['domaines']['onlyone']) { print "@" .$domain->getName(); } ?></div>
|
<div class="col-sm-2 control-label"><?php print "@" .$domain->getName(); ?></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="alias[2]" class="col-sm-3 control-label">Alias :</label>
|
<label for="alias[2]" class="col-sm-3 control-label">Alias :</label>
|
||||||
<div class="col-sm-7"><input type="text" name="alias[2]" class="form-control" /></div>
|
<div class="col-sm-7"><input type="text" name="alias[2]" class="form-control" /></div>
|
||||||
<div class="col-sm-2 control-label"><?php if (!$conf['domaines']['onlyone']) { print "@" .$domain->getName(); } ?></div>
|
<div class="col-sm-2 control-label"><?php print "@" .$domain->getName(); ?></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr><h5>Cochez les cases pour choisir les autorisations du compte.</h5>
|
<hr><h5>Cochez les cases pour choisir les autorisations du compte.</h5>
|
||||||
|
@ -227,7 +223,7 @@ if (isset($_GET['account'])) {
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="authsmtpactive" class="col-sm-3 control-label">Authentification SMTP :</label>
|
<label for="authsmtpactive" class="col-sm-3 control-label">Authentification SMTP :</label>
|
||||||
<div class="col-sm-7"><input type='checkbox' name='authsmtpactive' <?php if ($conf['evoadmin']['useauthsmtp']) print "checked" ?> class="form-control move-left" /></div>
|
<div class="col-sm-7"><input type='checkbox' name='authsmtpactive' class="form-control move-left" /></div>
|
||||||
<div class="col-sm-3 control-label"></div>
|
<div class="col-sm-3 control-label"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -235,7 +231,7 @@ if (isset($_GET['account'])) {
|
||||||
<!--
|
<!--
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="amavisBypassSpamChecks" class="col-sm-3 control-label">Désactivation Antispam :</label>
|
<label for="amavisBypassSpamChecks" class="col-sm-3 control-label">Désactivation Antispam :</label>
|
||||||
<div class="col-sm-7"><input type='checkbox' name='amavisBypassSpamChecks' <?php //if ($conf['evoadmin']['amavisBypassSpamChecks']) print "checked" ?> class="form-control move-left" /></div>
|
<div class="col-sm-7"><input type='checkbox' name='amavisBypassSpamChecks' class="form-control move-left" /></div>
|
||||||
<div class="col-sm-2 control-label"></div>
|
<div class="col-sm-2 control-label"></div>
|
||||||
</div>
|
</div>
|
||||||
-->
|
-->
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// Email pour les notifications
|
|
||||||
$conf['admin']['mail'] = 'admin@example.com';
|
|
||||||
// login des superadmins
|
|
||||||
// Note: utile uniquement si domaines/driver=ldap, laisser vide sinon...
|
|
||||||
$conf['admin']['logins'] = array('foo');
|
|
||||||
// What do you want?
|
|
||||||
// 0 = nothing...
|
|
||||||
// 1 = only mail accounts
|
|
||||||
// 2 = only samba accounts
|
|
||||||
// 3 = mail and samba accounts
|
|
||||||
$conf['admin']['what'] = 3;
|
|
||||||
// use hook.php instead of hook-dist.php
|
|
||||||
$conf['admin']['use_hook'] = false;
|
|
||||||
// enable quota
|
|
||||||
$conf['admin']['quota'] = true;
|
|
||||||
|
|
||||||
// compatibilite LDAP
|
|
||||||
$conf['evoadmin']['version'] = 3;
|
|
||||||
$conf['url']['webroot'] = '/evoadmin';
|
|
||||||
|
|
||||||
$conf['domaines']['onlyone'] = true;
|
|
||||||
$conf['domaines']['driver'] = 'file';
|
|
||||||
$conf['domaines']['file']['all'] = array('example.com');
|
|
||||||
$conf['domaines']['file']['gid'] = 1000;
|
|
||||||
// Pack Mail "virtuel"... attention
|
|
||||||
// uniquement possible si $conf['admin']['what']=1 !!
|
|
||||||
//$conf['domaines']['ldap']['virtual'] = false;
|
|
||||||
|
|
||||||
// Mode cluster
|
|
||||||
// Uniquement en mode mail seul et des utilisateurs virtuels
|
|
||||||
$conf['evoadmin']['cluster'] = true;
|
|
||||||
|
|
||||||
// auth SMTP by default ?
|
|
||||||
$conf['evoadmin']['useauthsmtp'] = false;
|
|
||||||
|
|
||||||
// Si comptes virtuels
|
|
||||||
$conf['unix']['uid'] = 2022;
|
|
||||||
|
|
||||||
// Si pas virtuel
|
|
||||||
$conf['unix']['minuid'] = 1000;
|
|
||||||
$conf['unix']['mingid'] = 1000;
|
|
||||||
|
|
||||||
$conf['html']['title'] = "Interface d'administration XXX";
|
|
||||||
|
|
||||||
// gestion des logs
|
|
||||||
$conf['log']['priority'] = PEAR_LOG_DEBUG;
|
|
||||||
$conf['log']['name'] = '/var/log/evoXXX.log';
|
|
||||||
$conf['log']['software'] = 'evoXXX';
|
|
||||||
$conf['log']['enabled'] = true;
|
|
||||||
|
|
||||||
// samba
|
|
||||||
$conf['samba']['dn'] = 'DOMAINNAME';
|
|
||||||
$conf['samba']['sid'] = 'S-1-5-21-XXX-XXX-XXX';
|
|
||||||
$conf['samba']['admin_default'] = false;
|
|
|
@ -1,30 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Secrete parameters
|
|
||||||
*
|
|
||||||
* $Id: connect-dist.php,v 1.3 2007-05-22 21:12:23 reg Exp $
|
|
||||||
*
|
|
||||||
* @author Gregory Colpart <reg@evolix.fr>
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define("LDAP_URI","ldap://127.0.0.1");
|
|
||||||
$ldap_servers = array('ldap://127.0.0.1', 'ldap://12');
|
|
||||||
define("LDAP_BASE","dc=example,dc=com");
|
|
||||||
define("LDAP_ADMIN_DN","cn=admin,dc=example,dc=com");
|
|
||||||
define("LDAP_ADMIN_PASS","xxxxx");
|
|
||||||
|
|
||||||
define("SUDOBIN","/usr/bin/sudo");
|
|
||||||
define("SUDOSCRIPT","/usr/share/scripts/evoadmin.sh");
|
|
||||||
define("SUDOPASS","xxxxxx");
|
|
||||||
|
|
||||||
define ('SERVEUR', "localhost");
|
|
||||||
|
|
||||||
define('SERVEUR','localhost');
|
|
||||||
define('SERVEURPORT',3306);
|
|
||||||
define('BASE','horde');
|
|
||||||
define('NOM', 'horde');
|
|
||||||
define('PASSE', 'xxxx');
|
|
||||||
|
|
||||||
?>
|
|
|
@ -30,7 +30,7 @@ include('inc/debut.php');
|
||||||
|
|
||||||
<hr><h2>FAQ</h2>
|
<hr><h2>FAQ</h2>
|
||||||
|
|
||||||
Cette Foire-Aux-Questions (FAQ) devrait répondre à vos questions. Au fil du temps, de nouvelles questions/réponses seront ajoutées. Posez vos questions à <a href="mailto:<?php print $conf['admin']['mail'];?>"><?php print $conf['admin']['mail'];?></a>.
|
Cette Foire-Aux-Questions (FAQ) devrait répondre à vos questions. Au fil du temps, de nouvelles questions/réponses seront ajoutées. Posez vos questions à <a href="mailto:<?php print $config['global']['mail'];?>"><?php print $config['global']['mail'];?></a>.
|
||||||
|
|
||||||
<p>Qu'est-ce qu'une syntaxe valide pour un compte mail ?</p>
|
<p>Qu'est-ce qu'une syntaxe valide pour un compte mail ?</p>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
|
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
|
||||||
<meta name="robots" content="noindex,nofollow"/>
|
<meta name="robots" content="noindex,nofollow"/>
|
||||||
<meta name="referrer" content="same-origin"/>
|
<meta name="referrer" content="same-origin"/>
|
||||||
<title><?php print $conf['html']['title']; ?></title>
|
<title><?php print $config['global']['name']; ?></title>
|
||||||
<link rel="stylesheet" href="css/main.css" type="text/css"/>
|
<link rel="stylesheet" href="css/main.css" type="text/css"/>
|
||||||
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
|
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous"/>
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous"/>
|
||||||
|
|
|
@ -8,7 +8,7 @@ if (empty($_SESSION['login'])) {
|
||||||
exit(0);
|
exit(0);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
$server = new LdapServer($_SESSION['login'], LDAP_BASE, LDAP_ADMIN_DN, LDAP_ADMIN_PASS, LDAP_URI);
|
$server = new LdapServer($_SESSION['login'], $config['ldap']);
|
||||||
if (!empty($_GET['domain'])) {
|
if (!empty($_GET['domain'])) {
|
||||||
$domain = htmlentities(strip_tags($_GET['domain']),ENT_NOQUOTES);
|
$domain = htmlentities(strip_tags($_GET['domain']),ENT_NOQUOTES);
|
||||||
$domain = new LdapDomain($server, $domain);
|
$domain = new LdapDomain($server, $domain);
|
||||||
|
|
|
@ -70,7 +70,6 @@ class LdapDomain extends LdapServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addAccount($uid,$name,$password,$active=false,$admin=false,$accountactive=false,$courieractive=false,$webmailactive=false,$authsmtpactive=false,$amavisBypassSpamChecks=false) {
|
public function addAccount($uid,$name,$password,$active=false,$admin=false,$accountactive=false,$courieractive=false,$webmailactive=false,$authsmtpactive=false,$amavisBypassSpamChecks=false) {
|
||||||
global $conf;
|
|
||||||
if (!preg_match('/^([a-z0-9][a-z0-9\-\.\_]{0,28}[a-z0-9])$/', $uid)) {
|
if (!preg_match('/^([a-z0-9][a-z0-9\-\.\_]{0,28}[a-z0-9])$/', $uid)) {
|
||||||
throw new Exception("Erreur, <u>$name</u> est un nom invalide.");
|
throw new Exception("Erreur, <u>$name</u> est un nom invalide.");
|
||||||
}
|
}
|
||||||
|
@ -78,7 +77,7 @@ class LdapDomain extends LdapServer {
|
||||||
$info[LdapAccount::$dn] = $mail;
|
$info[LdapAccount::$dn] = $mail;
|
||||||
$info["cn"] = $name;
|
$info["cn"] = $name;
|
||||||
$info["homeDirectory"] = "/home/vmail/" .$this->getName(). "/" .$uid. "/";
|
$info["homeDirectory"] = "/home/vmail/" .$this->getName(). "/" .$uid. "/";
|
||||||
$info["uidNumber"] = $conf['unix']['uid'];
|
$info["uidNumber"] = 2022;
|
||||||
$info["gidNumber"] = $this->getGid();
|
$info["gidNumber"] = $this->getGid();
|
||||||
$info["isActive"] = ($active) ? 'TRUE' : 'FALSE';
|
$info["isActive"] = ($active) ? 'TRUE' : 'FALSE';
|
||||||
$info["isAdmin"] = ($admin) ? 'TRUE' : 'FALSE';
|
$info["isAdmin"] = ($admin) ? 'TRUE' : 'FALSE';
|
||||||
|
|
|
@ -54,24 +54,24 @@ class LdapServer {
|
||||||
return '{SSHA}'.base64_encode(mhash(MHASH_SHA1, $pass.$salt).$salt);
|
return '{SSHA}'.base64_encode(mhash(MHASH_SHA1, $pass.$salt).$salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct($login, $base, $adminDN, $adminPass, $uri='ldap://127.0.0.1') {
|
public function __construct($login, $config) {
|
||||||
global $conf;
|
$uri = 'ldap://'.$config['host'].':'.$config['port'];
|
||||||
$this->login = $login;
|
$this->login = $login;
|
||||||
if (!$this->conn = ldap_connect($uri)) {
|
if (!$this->conn = ldap_connect($uri)) {
|
||||||
throw new Exception("Impossible de se connecter au serveur LDAP $uri");
|
throw new Exception("Impossible de se connecter au serveur LDAP ".$config['host']);
|
||||||
}
|
}
|
||||||
if (!ldap_set_option($this->conn, LDAP_OPT_PROTOCOL_VERSION, 3)) {
|
if (!ldap_set_option($this->conn, LDAP_OPT_PROTOCOL_VERSION, 3)) {
|
||||||
throw new Exception("Impossible de modifier la version du protocole LDAP à 3");
|
throw new Exception("Impossible de modifier la version du protocole LDAP à 3");
|
||||||
}
|
}
|
||||||
if (!ldap_bind($this->conn, $adminDN, $adminPass)) {
|
if (!ldap_bind($this->conn, $config['admin_dn'], $config['admin_pass'])) {
|
||||||
throw new Exception("Authentification LDAP échoué !");
|
throw new Exception("Authentification LDAP échoué !");
|
||||||
}
|
}
|
||||||
if (in_array($this->login, $conf['admin']['logins'])) {
|
if (in_array($this->login, $config['superadmin'])) {
|
||||||
$this->superadmin = true;
|
$this->superadmin = true;
|
||||||
$this->base = $base;
|
$this->base = $config['base'];
|
||||||
} else {
|
} else {
|
||||||
$mydomain = preg_replace('/.*@/', '', $login);
|
$mydomain = preg_replace('/.*@/', '', $login);
|
||||||
$this->base = LdapDomain::$dn.'='.$mydomain.','.$base;
|
$this->base = LdapDomain::$dn.'='.$mydomain.','.$config['base'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
const CONFIG_FILE = './config/conf.php';
|
|
||||||
const CONNECT_FILE = './config/connect.php';
|
|
||||||
|
|
||||||
spl_autoload_register(function ($class) {
|
spl_autoload_register(function ($class) {
|
||||||
$class = strtolower($class);
|
$class = strtolower($class);
|
||||||
include_once("lib/class.$class.php");
|
include_once("lib/class.$class.php");
|
||||||
});
|
});
|
||||||
|
|
||||||
if (file_exists(CONFIG_FILE)) {
|
$config = parse_ini_file('../config/config.ini', true);
|
||||||
require_once(CONFIG_FILE);
|
|
||||||
global $conf;
|
|
||||||
if ($conf['domaines']['driver'] == 'ldap') {
|
|
||||||
if (file_exists(CONNECT_FILE)) {
|
|
||||||
require_once(CONNECT_FILE);
|
|
||||||
} else {
|
|
||||||
# EvoLog::log('You must create '.CONNECT_FILE);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
# EvoLog::log('You must create '.CONFIG_FILE);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// classic mail notification
|
|
||||||
// (you can customize it in hook.php)
|
|
||||||
function mailnotify($info,$domain,$pass) {
|
|
||||||
|
|
||||||
global $conf;
|
|
||||||
|
|
||||||
$gecos = $info["cn"];
|
|
||||||
$unixlogin = $info["uid"];
|
|
||||||
|
|
||||||
//mail de notification
|
|
||||||
$sujet = "Creation du compte $unixlogin" ;
|
|
||||||
$to = $conf['admin']['mail'];
|
|
||||||
|
|
||||||
$entete = "From: ".$conf['admin']['mail']."\n";
|
|
||||||
$entete .= "MIME-Version: 1.0\n";
|
|
||||||
$entete .= "Content-type: text/plain; charset=utf-8\n";
|
|
||||||
$entete .= "Content-Transfer-Encoding: quoted-printable\n";
|
|
||||||
|
|
||||||
$contenu = "Bonjour $gecos,\n\n";
|
|
||||||
$contenu .= "Un nouveau compte vient d'être créé pour vous.\n";
|
|
||||||
$contenu .= "Votre identifiant est : $unixlogin\n";
|
|
||||||
$contenu .= "Votre mot de passe : " .$pass. "\n\n";
|
|
||||||
$contenu .= "Cordialement,\n";
|
|
||||||
$contenu .= "--\nL'équipe informatique";
|
|
||||||
mail($to,$sujet,$contenu,$entete);
|
|
||||||
}
|
|
||||||
|
|
||||||
// classic domain notification
|
|
||||||
// (you can customize it in hook.php)
|
|
||||||
function domainnotify($domain) {
|
|
||||||
|
|
||||||
global $conf;
|
|
||||||
|
|
||||||
//mail de notification
|
|
||||||
$sujet = "Creation du domaine $domain" ;
|
|
||||||
$to = $conf['admin']['mail'];
|
|
||||||
|
|
||||||
$entete = "From: ".$conf['admin']['mail']."\n";
|
|
||||||
$entete .= "MIME-Version: 1.0\n";
|
|
||||||
$entete .= "Content-type: text/plain; charset=utf-8\n";
|
|
||||||
$entete .= "Content-Transfer-Encoding: quoted-printable\n";
|
|
||||||
|
|
||||||
$contenu = "Bonjour,\n\n";
|
|
||||||
$contenu .= "Un nouveau domaine vient d'être créé : $domain\n";
|
|
||||||
$contenu .= "Assurez vous bien que la configuration DNS et MX\n";
|
|
||||||
$contenu .= "soit bien en place.\n\n";
|
|
||||||
$contenu .= "Cordialement,\n";
|
|
||||||
$contenu .= "--\nL'équipe informatique";
|
|
||||||
mail($to,$sujet,$contenu,$entete);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue