diff --git a/htdocs/admin.php b/htdocs/admin.php deleted file mode 100644 index 3fa6be1..0000000 --- a/htdocs/admin.php +++ /dev/null @@ -1,84 +0,0 @@ - 1, 'message' => "Voulez vous vraiment supprimer le compte $account ?"); - $alerts[] = array('type' => 1, 'message' => "
getName()."&viewonly=1\"> / getName()."&viewonly=1\">Annuler
"); -} - -if (!empty($_POST['alias'])) { - $alias = htmlentities(strip_tags($_POST['alias']),ENT_NOQUOTES); - $alerts[] = array('type' => 1, 'message' => "Voulez vous vraiment supprimer l'alias $alias ?"); - $alerts[] = array('type' => 1, 'message' => "
getName()."&viewonly=2\"> / getName()."&viewonly=2\">Annuler
"); -} - -if (!empty($_POST['delete'])) { - $account = htmlentities(strip_tags($_POST['delete']),ENT_NOQUOTES); - $alerts[] = array('type' => 1, 'message' => "Suppression du compte $account..."); - try { - $domain->delAccount($account); - $alerts[] = array('type' => 0, 'message' => "Suppression effectué."); - } catch (Exception $e) { - $alerts[] = array('type' => 2, 'message' => $e->getMessage()); - } -} - -if (!empty($_POST['delalias'])) { - $alias = htmlentities(strip_tags($_POST['delalias']),ENT_NOQUOTES); - $alerts[] = array('type' => 1, 'message' => "Suppression de l'alias $alias..."); - try { - $domain->delAlias($alias); - $alerts[] = array('type' => 0, 'message' => "Suppression effectué."); - } catch (Exception $e) { - $alerts[] = array('type' => 2, 'message' => $e->getMessage()); - } -} - -if (!empty($_POST['isactive']) && $server->isSuperAdmin()) { - $active = ($_POST['isactive'] == "TRUE") ? true : false; - try { - $domain->update($active); - header('Location: admin.php?domain='.$domain->getName()); - } catch (Exception $e) { - $alerts[] = array('type' => 2, 'message' => $e->getMessage()); - } -} - -if ( (!isset($_GET['viewonly'])) || ($_GET['viewonly']==1) ) { - -print $twig->render('list_account.html', array( - 'page_name' => $config['global']['name'] - ,'alerts' => $alerts - ,'login' => $server->getLogin() - ,'isSuperAdmin' => $server->isSuperAdmin() - ,'domain' => $domain->getName() - ,'active' => $domain->isActive() - ,'accounts' => $domain->getAccounts() - ,'view' => 'account' -)); - -} elseif ( (isset($_GET['viewonly'])) && ($_GET['viewonly']==2) ) { - -print $twig->render('list_alias.html', array( - 'page_name' => $config['global']['name'] - ,'alerts' => $alerts - ,'login' => $server->getLogin() - ,'isSuperAdmin' => $server->isSuperAdmin() - ,'domain' => $domain->getName() - ,'active' => $domain->isActive() - ,'aliases' => $domain->getAlias() - ,'view' => 'alias' -)); - -} diff --git a/htdocs/alias.php b/htdocs/alias.php deleted file mode 100644 index 598668e..0000000 --- a/htdocs/alias.php +++ /dev/null @@ -1,54 +0,0 @@ -getName() : htmlentities(strip_tags($_POST['cn']),ENT_NOQUOTES); - $actif = (!empty($_POST['isactive'])) ? true : false; - $mailaccept = array_filter($_POST['mailaccept'], function($value) { - if (!empty($value)) { - return true; - } else { - return false; - } - }); - array_walk($mailaccept, function(&$item,$key) { - if (!empty($item)) { - global $domain; - $item = "$item". "@".$domain->getName(); - } - }); - $maildrop = $_POST['maildrop']; - - try { - if (!empty($_GET['alias'])) { - $alerts[] = array('type' => 1, 'message' => "Modification en cours..."); - $alias->update($actif,$mailaccept,$maildrop); - header('Location: alias.php?domain='.$domain->getName().'&alias='.$alias->getName()); - } else { - $alerts[] = array('type' => 1, 'message' => "Ajout en cours..."); - $domain->addAlias($cn,$actif,$mailaccept,$maildrop); - $alerts[] = array('type' => 0, 'message' => "Ajout effectué"); - $alerts[] = array('type' => 0, 'message' => ''); - } - } catch (Exception $e) { - $alerts[] = array('type' => 2, 'message' => $e->getMessage()); - } - -} - -print $twig->render('alias.html', array( - 'page_name' => $config['global']['name'] - ,'alerts' => $alerts - ,'login' => $server->getLogin() - ,'isSuperAdmin' => $server->isSuperAdmin() - ,'domain' => $domain->getName() - ,'name' => !empty($alias) ? $alias->getName() : NULL - ,'active' => !empty($alias) ? $alias->isActive() : true - ,'aliases' => !empty($alias) ? $alias->getAliases() : NULL - ,'maildrops' => !empty($alias) ? $alias->getRedirections() : NULL -)); diff --git a/htdocs/auth.php b/htdocs/auth.php deleted file mode 100644 index 4c8bc27..0000000 --- a/htdocs/auth.php +++ /dev/null @@ -1,38 +0,0 @@ -login($password); - $_SESSION['login'] = $server->getLogin(); - header("location: superadmin.php\n\n"); - exit(0); - } catch (Exception $e) { - $alerts[] = array('type' => 2, 'message' => $e->getMessage()); - } -} - -print $twig->render('login.html', array( - 'page_name' => $config['global']['name'].' - Login' - ,'alerts' => $alerts - ,'logout' => $logout -)); - -ob_end_flush(); diff --git a/htdocs/compte.php b/htdocs/compte.php deleted file mode 100644 index 4a88897..0000000 --- a/htdocs/compte.php +++ /dev/null @@ -1,55 +0,0 @@ - 2, 'message' => "Erreur, vous avez tape deux mots de passe differents"); - exit(1); - } - - $uid = (!empty($_GET['account'])) ? $account->getUid() : htmlentities(strip_tags($_POST['uid']),ENT_NOQUOTES); - $cn = htmlentities(strip_tags($_POST['cn']),ENT_NOQUOTES); - $password = (!empty($_POST['pass1'])) ? $_POST['pass1'] : NULL; - $actif = (!empty($_POST['isactive'])) ? true : false; - $admin = (!empty($_POST['isadmin'])) ? true : false; - $courier = (!empty($_POST['courieractive'])) ? true : false; - $webmail = (!empty($_POST['webmailactive'])) ? true : false; - $authsmtp = (!empty($_POST['authsmtpactive'])) ? true : false; - - try { - if (!empty($_GET['account'])) { - $alerts[] = array('type' => 1, 'message' => "Modification en cours..."); - $account->update($cn,$password,$actif,$admin,$actif,$courier,$webmail,$authsmtp); - header('Location: compte.php?domain='.$domain->getName().'&account='.$account->getUid()); - } else { - $alerts[] = array('type' => 1, 'message' => "Ajout en cours..."); - $domain->addAccount($uid,$cn,$password,$actif,$admin,$actif,$courier,$webmail,$authsmtp); - $alerts[] = array('type' => 0, 'message' => 'Ajout effectué '); - } - } catch (Exception $e) { - $alerts[] = array('type' => 2, 'message' => $e->getMessage()); - } -} - -print $twig->render('account.html', array( - 'page_name' => $config['global']['name'] - ,'alerts' => $alerts - ,'login' => $server->getLogin() - ,'isSuperAdmin' => $server->isSuperAdmin() - ,'domain' => $domain->getName() - ,'uid' => !empty($account) ? $account->getUid() : NULL - ,'name' => !empty($account) ? $account->getName() : NULL - ,'aliases' => !empty($account) ? $account->getAliases() : array() - ,'maildrops' => !empty($account) ? $account->getRedirections() : array() - ,'active' => !empty($account) ? $account->isActive() : true - ,'admin' => !empty($account) ? $account->isAdmin() : false - ,'courier' => !empty($account) ? $account->isCourier() : true - ,'webmail' => !empty($account) ? $account->isWebmail() : true - ,'authsmtp' => !empty($account) ? $account->isAuthSmtp() : true -)); diff --git a/htdocs/domaine.php b/htdocs/domaine.php deleted file mode 100644 index 158dbf0..0000000 --- a/htdocs/domaine.php +++ /dev/null @@ -1,36 +0,0 @@ -isSuperAdmin()) { - $alerts[] = array('type' => 2, 'message' => "Vous n'avez pas les droits pour cette page"); -# EvoLog::log("Access denied on domaine.php"); - exit(1); -} - -$domain = NULL; - -if (!empty($_POST['domain'])) { - $domain = htmlentities(strip_tags($_POST['domain']),ENT_NOQUOTES); - - $alerts[] = array('type' => 1, 'message' => "Ajout en cours du domaine $domain ..."); - - try { - $active = (!empty($_POST['isactive'])) ? true : false; - $server->addDomain($domain, $active); - $alerts[] = array('type' => 0, 'message' => "Ajout effectué."); - } catch (Exception $e_ad) { - $alerts[] = array('type' => 2, 'message' => $e_ad->getMessage()); - } -} - -print $twig->render('add_domain.html', array( - 'page_name' => $config['global']['name'] - ,'alerts' => $alerts - ,'login' => $server->getLogin() - ,'isSuperAdmin' => $server->isSuperAdmin() -)); diff --git a/htdocs/help.php b/htdocs/help.php deleted file mode 100644 index e4c321c..0000000 --- a/htdocs/help.php +++ /dev/null @@ -1,15 +0,0 @@ -render('help.html', array( - 'page_name' => $config['global']['name'] - ,'alerts' => $alerts - ,'login' => $server->getLogin() - ,'isSuperAdmin' => $server->isSuperAdmin() - ,'notif_mail' => $config['global']['mail'] -)); diff --git a/htdocs/index.php b/htdocs/index.php index 097ea04..f4a0344 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -3,11 +3,18 @@ session_name('EVOADMIN_SESS'); session_start(); -if (isset($_SESSION['login'])) { - header("Location: superadmin.php\n\n"); - exit(0); -} else { - header("Location: auth.php\n\n"); - exit(0); -} +spl_autoload_register(function ($class) { + if (file_exists("lib/$class.php")) { + require_once("lib/$class.php"); + } + $class = strtolower($class); + if (file_exists("lib/class.$class.php")) { + require_once("lib/class.$class.php"); + } +}); + +DefaultController::init(); +FormController::init(); +PageController::init(); + ?> diff --git a/htdocs/lib/DefaultController.php b/htdocs/lib/DefaultController.php new file mode 100644 index 0000000..a65e9a7 --- /dev/null +++ b/htdocs/lib/DefaultController.php @@ -0,0 +1,43 @@ + 2, 'message' => $e->getMessage()); + } + } else { + if (!empty($_POST['login'])) { + try { + $input = filter_input_array(INPUT_POST, array( + 'login' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_HIGH) + ,'password' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_HIGH) + )); + self::$server = new LdapServer($input['login'], self::$config['ldap']); + self::$server->login($input['password']); + self::$logged = true; + $_SESSION['login'] = self::$server->getLogin(); + } catch (Exception $e) { + self::$alerts[] = array('type' => 2, 'message' => $e->getMessage()); + } + } + } + } + + protected static function needSuperAdmin() { + if (!self::$server->isSuperAdmin()) { + self::$alerts[] = array('type' => 2, 'message' => "Super Adminsitrateur seulement !"); + return false; + } else { return true; } + } +} diff --git a/htdocs/lib/FormController.php b/htdocs/lib/FormController.php new file mode 100644 index 0000000..698f0f1 --- /dev/null +++ b/htdocs/lib/FormController.php @@ -0,0 +1,231 @@ + 2, 'message' => $e->getMessage()); + } + + if (!empty(self::$form['delete'])) { + switch(self::$form['delete']) { + case 'domain': + FormController::delDomain(); + break; + case 'account': + FormController::delAccount(); + break; + case 'alias': + FormController::delAlias(); + break; + } + } else if (!empty(self::$form['add'])) { + switch(self::$form['add']) { + case 'domain': + FormController::addDomain(); + break; + case 'account': + FormController::addAccount(); + break; + case 'alias': + FormController::addAlias(); + break; + } + } else if (!empty(self::$form['update'])) { + switch(self::$form['update']) { + case 'domain': + FormController::updateDomain(); + break; + case 'account': + FormController::updateAccount(); + break; + case 'alias': + FormController::updateAlias(); + break; + } + } + } + } + + private static function filterPassword() { + if (count(self::$form['password']) != 2 || self::$form['password'][0] != self::$form['password'][1]) { + self::$alerts[] = array('type' => 2, 'message' => "Confirmation du mot de passe inccorrecte !"); + return false; + + } + self::$form['password'] = self::$form['password'][0]; + self::$form['password'] = filter_var(self::$form['password'], FILTER_CALLBACK, array('options' => function($value) { + return trim($value); + })); + } + + private static function filterType($type) { + if (in_array($type, array('domain', 'account', 'alias'))) { + return $type; + } else { return NULL; } + } + + private static function filterPost() { + self::$form = filter_input_array(INPUT_POST, array( + 'add' => array('filter' => FILTER_CALLBACK, 'options' => 'self::filterType') + ,'delete' => array('filter' => FILTER_CALLBACK, 'options' => 'self::filterType') + ,'update' => array('filter' => FILTER_CALLBACK, 'options' => 'self::filterType') + ,'domain' => FILTER_SANITIZE_URL + ,'account' => FILTER_SANITIZE_EMAIL + ,'alias' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_HIGH) + ,'uid' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_HIGH) + ,'cn' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_HIGH) + ,'password' => array('filter' => FILTER_DEFAULT, 'flags' => FILTER_FORCE_ARRAY) + ,'isactive' => FILTER_VALIDATE_BOOLEAN + ,'isadmin' => FILTER_VALIDATE_BOOLEAN + ,'courieractive' => FILTER_VALIDATE_BOOLEAN + ,'webmailactive' => FILTER_VALIDATE_BOOLEAN + ,'authsmtpactive' => FILTER_VALIDATE_BOOLEAN + ,'maildrop' => array('filter' => FILTER_DEFAULT, 'flags' => FILTER_FORCE_ARRAY) + ,'mailaccept' => array('filter' => FILTER_DEFAULT, 'flags' => FILTER_FORCE_ARRAY) + ), true); + + if (!empty(self::$form['password'])) { self::filterPassword(); } + + unset($_POST); + //die(var_dump(self::$form)); + } + + private static function addDomain() { + if (self::needSuperAdmin()) { + if (!empty(self::$form['cn'])) { + try { + self::$alerts[] = array('type' => 1, 'message' => 'Ajout en cours du domaine '.self::$form['cn'].' ...'); + self::$server->addDomain(self::$form['cn'], self::$form['isactive']); + self::$alerts[] = array('type' => 0, 'message' => "Ajout effectué."); + } catch (Exception $e_ad) { + self::$alerts[] = array('type' => 2, 'message' => $e_ad->getMessage()); + } + } + } + } + + private static function updateDomain() { + if (self::needSuperAdmin()) { + try { + self::$domain->update(self::$form['isactive']); + } catch (Exception $e_ad) { + self::$alerts[] = array('type' => 2, 'message' => $e_ad->getMessage()); + } + } + } + + private static function delDomain() { + if (self::needSuperAdmin()) { + self::$alerts[] = array('type' => 1, 'message' => 'Suppression du domaine '.self::$form['cn'].' ...'); + try { + self::$server->delDomain(self::$form['cn']); + self::$alerts[] = array('type' => 0, 'message' => 'Suppression effectué.'); + } catch (Exception $e_ad) { + self::$alerts[] = array('type' => 2, 'message' => $e_ad->getMessage()); + } + } + } + + private static function delAccount() { + self::$alerts[] = array('type' => 1, 'message' => 'Suppression du compte '.self::$form['uid'].'...'); + try { + self::$domain->delAccount(self::$form['uid']); + self::$alerts[] = array('type' => 0, 'message' => "Suppression effectué."); + } catch (Exception $e) { + self::$alerts[] = array('type' => 2, 'message' => $e->getMessage()); + } + } + + private static function delAlias() { + self::$alerts[] = array('type' => 1, 'message' => 'Suppression de l\'alias '.self::$form['cn'].'...'); + try { + self::$domain->delAlias(self::$form['cn']); + self::$alerts[] = array('type' => 0, 'message' => "Suppression effectué."); + } catch (Exception $e) { + self::$alerts[] = array('type' => 2, 'message' => $e->getMessage()); + } + } + + private static function addAccount() { + try { + self::$alerts[] = array('type' => 1, 'message' => "Ajout en cours..."); + self::$domain->addAccount( + self::$form['uid'] + ,self::$form['cn'] + ,self::$form['password'] + ,self::$form['isactive'] + ,self::$form['isadmin'] + ,self::$form['isactive'] + ,self::$form['courieractive'] + ,self::$form['webmailactive'] + ,self::$form['authsmtpactive'] + ); + self::$alerts[] = array('type' => 0, 'message' => 'Ajout effectué'); + } catch (Exception $e) { + self::$alerts[] = array('type' => 2, 'message' => $e->getMessage()); + } + } + + private static function updateAccount() { + try { + self::$alerts[] = array('type' => 1, 'message' => "Modification en cours..."); + self::$account->update( + self::$form['cn'] + ,self::$form['password'] + ,self::$form['isactive'] + ,self::$form['isadmin'] + ,self::$form['isactive'] + ,self::$form['courieractive'] + ,self::$form['webmailactive'] + ,self::$form['authsmtpactive'] + ); + self::$alerts[] = array('type' => 0, 'message' => "Modification effectué."); + } catch (Exception $e) { + self::$alerts[] = array('type' => 2, 'message' => $e->getMessage()); + } + } + + private static function addAlias() { + try { + self::$alerts[] = array('type' => 1, 'message' => "Ajout en cours..."); + self::$domain->addAlias( + self::$form['cn'] + ,self::$form['isactive'] + ,self::$form['mailaccept'] + ,self::$form['maildrop'] + ); + self::$alerts[] = array('type' => 0, 'message' => "Ajout effectué"); + } catch (Exception $e) { + self::$alerts[] = array('type' => 2, 'message' => $e->getMessage()); + } + } + + private static function updateAlias() { + try { + self::$alerts[] = array('type' => 1, 'message' => "Modification en cours..."); + self::$alias->update( + self::$form['isactive'] + ,self::$form['mailaccept'] + ,self::$form['maildrop'] + ); + self::$alerts[] = array('type' => 0, 'message' => "Modification effectué."); + } catch (Exception $e) { + self::$alerts[] = array('type' => 2, 'message' => $e->getMessage()); + } + + } +} diff --git a/htdocs/lib/PageController.php b/htdocs/lib/PageController.php new file mode 100644 index 0000000..286f736 --- /dev/null +++ b/htdocs/lib/PageController.php @@ -0,0 +1,206 @@ + false + )); + + ob_start(); + + if (self::$logged) { + PageController::filterGet(); + PageController::ldap(); + if (!empty(self::$params['page'])) { + switch(self::$params['page']) { + case 'logout': + PageController::logout(); + break; + case 'help': + PageController::help(); + break; + } + } else { + PageController::choosePage(); + } + } else { + PageController::login(); + } + + ob_end_flush(); + } + + private static function filterGet() { + $allowed_params = array('_all', '_add'); + $static_pages = array('logout', 'help'); + + self::$params['page'] = !empty($_GET['page']) && in_array($_GET['page'], $static_pages) ? $_GET['page'] : NULL; + if (!empty($_GET['domain']) && in_array($_GET['domain'], $allowed_params)) { self::$params['domain'] = $_GET['domain']; } + if (!empty($_GET['account']) && in_array($_GET['account'], $allowed_params)) { self::$params['account'] = $_GET['account']; } + if (!empty($_GET['alias']) && in_array($_GET['alias'], $allowed_params)) { self::$params['alias'] = $_GET['alias']; } + self::$params = array_merge(filter_input_array(INPUT_GET, array( + 'domain' => FILTER_SANITIZE_URL + ,'account' => FILTER_SANITIZE_EMAIL + ,'alias' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_HIGH) + ), true) + , self::$params); + + unset($_GET); + //die(var_dump(self::$params)); + } + + private static function ldap() { + // Get content from LDAP + try { + if (!empty(self::$params['domain']) && self::$params['domain'] != '_all' && self::$params['domain'] != '_add') { + self::$domain = new LdapDomain(self::$server, self::$params['domain']); + if (!empty(self::$params['account']) && self::$params['account'] != '_all' && self::$params['account'] != '_add') { + self::$account = new LdapAccount(self::$domain, self::$params['account']); + } + if (!empty(self::$params['alias']) && self::$params['alias'] != '_all' && self::$params['alias'] != '_add') { + self::$alias = new LdapAlias(self::$domain, self::$params['alias']); + } + } + } catch (Exception $e) { + self::$alerts[] = array('type' => 2, 'message' => $e->getMessage()); + } + } + + private static function login() { + print self::$twig->render('login.html', array( + 'page_name' => self::$config['global']['name'].' - Login' + ,'alerts' => self::$alerts + ,'logout' => false + )); + } + + private static function logout() { + session_unset('EVOADMIN_SESS'); + session_destroy(); + print self::$twig->render('login.html', array( + 'page_name' => self::$config['global']['name'].' - Login' + ,'alerts' => self::$alerts + ,'logout' => true + )); + } + + private static function help() { + print self::$twig->render('help.html', array( + 'page_name' => self::$config['global']['name'] + ,'alerts' => self::$alerts + ,'login' => self::$server->getLogin() + ,'isSuperAdmin' => self::$server->isSuperAdmin() + ,'notif_mail' => self::$config['global']['mail'] + )); + } + + private static function choosePage() { + if (empty(self::$params['domain'])) { + self::$params['domain'] = '_all'; + } + if (self::$params['domain'] == '_all') { + PageController::listDomains(); + } else if (self::$params['domain'] == '_add') { + PageController::addDomain(); + } else { + if (empty(self::$params['account']) && empty(self::$params['alias'])) { self::$params['account'] = '_all'; } + if (!empty(self::$params['account'])) { + if (self::$params['account'] == '_all') { + PageController::listAccounts(); + } else { + PageController::Account(); + } + } else if (!empty(self::$params['alias']) && empty(self::$params['account'])) { + if (self::$params['alias'] == '_all') { + PageController::listAlias(); + } else { + PageController::Alias(); + } + } + } + } + + private static function addDomain() { + if (self::needSuperAdmin("Vous n'avez pas le droit d'ajouter un domaine !")) { + print self::$twig->render('add_domain.html', array( + 'page_name' => self::$config['global']['name'] + ,'alerts' => self::$alerts + ,'login' => self::$server->getLogin() + ,'isSuperAdmin' => self::$server->isSuperAdmin() + )); + } + } + + private static function listDomains() { + print self::$twig->render('list_domain.html', array( + 'page_name' => self::$config['global']['name'] + ,'alerts' => self::$alerts + ,'login' => self::$server->getLogin() + ,'isSuperAdmin' => self::$server->isSuperAdmin() + ,'domains' => self::$server->getDomains() + )); + } + + private static function listAccounts() { + print self::$twig->render('list_account.html', array( + 'page_name' => self::$config['global']['name'] + ,'alerts' => self::$alerts + ,'login' => self::$server->getLogin() + ,'isSuperAdmin' => self::$server->isSuperAdmin() + ,'domain' => self::$domain->getName() + ,'active' => self::$domain->isActive() + ,'accounts' => self::$domain->getAccounts() + ,'view' => 'account' + )); + } + + private static function listAlias() { + print self::$twig->render('list_alias.html', array( + 'page_name' => self::$config['global']['name'] + ,'alerts' => self::$alerts + ,'login' => self::$server->getLogin() + ,'isSuperAdmin' => self::$server->isSuperAdmin() + ,'domain' => self::$domain->getName() + ,'active' => self::$domain->isActive() + ,'aliases' => self::$domain->getAlias() + ,'view' => 'alias' + )); + } + + private static function Account() { + print self::$twig->render('account.html', array( + 'page_name' => self::$config['global']['name'] + ,'alerts' => self::$alerts + ,'login' => self::$server->getLogin() + ,'isSuperAdmin' => self::$server->isSuperAdmin() + ,'domain' => self::$domain->getName() + ,'uid' => !empty(self::$account) ? self::$account->getUid() : NULL + ,'name' => !empty(self::$account) ? self::$account->getName() : NULL + ,'aliases' => !empty(self::$account) ? self::$account->getAliases() : array() + ,'maildrops' => !empty(self::$account) ? self::$account->getRedirections() : array() + ,'active' => !empty(self::$account) ? self::$account->isActive() : true + ,'admin' => !empty(self::$account) ? self::$account->isAdmin() : false + ,'courier' => !empty(self::$account) ? self::$account->isCourier() : true + ,'webmail' => !empty(self::$account) ? self::$account->isWebmail() : true + ,'authsmtp' => !empty(self::$account) ? self::$account->isAuthSmtp() : true + )); + } + + private static function Alias() { + print self::$twig->render('alias.html', array( + 'page_name' => self::$config['global']['name'] + ,'alerts' => self::$alerts + ,'login' => self::$server->getLogin() + ,'isSuperAdmin' => self::$server->isSuperAdmin() + ,'domain' => self::$domain->getName() + ,'name' => !empty(self::$alias) ? self::$alias->getName() : NULL + ,'active' => !empty(self::$alias) ? self::$alias->isActive() : true + ,'aliases' => !empty(self::$alias) ? self::$alias->getAliases() : NULL + ,'maildrops' => !empty(self::$alias) ? self::$alias->getRedirections() : NULL + )); + } +} diff --git a/htdocs/lib/auth.php b/htdocs/lib/auth.php deleted file mode 100644 index 5c00015..0000000 --- a/htdocs/lib/auth.php +++ /dev/null @@ -1,28 +0,0 @@ -'.$e->getMessage().''; - exit(1); - } -} diff --git a/htdocs/lib/class.mailnotify.php b/htdocs/lib/class.mailnotify.php index f2772c9..f79fa54 100644 --- a/htdocs/lib/class.mailnotify.php +++ b/htdocs/lib/class.mailnotify.php @@ -1,5 +1,7 @@ false -)); - -$alerts = array(); diff --git a/htdocs/superadmin.php b/htdocs/superadmin.php deleted file mode 100644 index d3b7d06..0000000 --- a/htdocs/superadmin.php +++ /dev/null @@ -1,33 +0,0 @@ - 1, 'message' => "Voulez vous vraiment supprimer le domaine $domain ?"); - $alerts[] = array('type' => 1, 'message' => "
/ Annuler
"); -} - -if (!empty($_POST['delete'])) { - $domain = htmlentities(strip_tags($_POST['delete']),ENT_NOQUOTES); - $alerts[] = array('type' => 1, 'message' => "Suppression du domaine $domain ..."); - try { - $server->delDomain($domain); - $alerts[] = array('type' => 0, 'message' => 'Suppression effectué.'); - } catch (Exception $e_ad) { - $alerts[] = array('type' => 2, 'message' => $e_ad->getMessage()); - } -} - -print $twig->render('list_domain.html', array( - 'page_name' => $config['global']['name'] - ,'alerts' => $alerts - ,'login' => $server->getLogin() - ,'isSuperAdmin' => $server->isSuperAdmin() - ,'domains' => $server->getDomains() -)); diff --git a/htdocs/tpl/page/account.html b/htdocs/tpl/page/account.html index cb7fd77..fb81a7d 100644 --- a/htdocs/tpl/page/account.html +++ b/htdocs/tpl/page/account.html @@ -8,16 +8,21 @@

{% if uid is null %}Ajout d'un compte{% else %}Modification du compte {{ uid }}{% endif %}

-
+ +
{% if uid is null %} +
@{{ domain }}
+ {% else %} + + {% endif %}
@@ -28,13 +33,13 @@
-
+
-
+
diff --git a/htdocs/tpl/page/add_domain.html b/htdocs/tpl/page/add_domain.html index ad190e8..d39ab5a 100644 --- a/htdocs/tpl/page/add_domain.html +++ b/htdocs/tpl/page/add_domain.html @@ -6,11 +6,12 @@
{% include 'notif.html' %}

Ajout d'un domaine

- + +
-
+
diff --git a/htdocs/tpl/page/alias.html b/htdocs/tpl/page/alias.html index 95273c2..71fdd8b 100644 --- a/htdocs/tpl/page/alias.html +++ b/htdocs/tpl/page/alias.html @@ -8,16 +8,21 @@

{% if name is null %}Ajout d'un alias{% else %}Modification de l'alias {{ name }}{% endif %}

- + +
{% if name is null %} +
+ {% else %} + + {% endif %} {% for alias in aliases %} diff --git a/htdocs/tpl/page/domain.html b/htdocs/tpl/page/domain.html index 0f5183c..9cff8ed 100644 --- a/htdocs/tpl/page/domain.html +++ b/htdocs/tpl/page/domain.html @@ -7,7 +7,9 @@ {% include 'notif.html' %}
- + + + {% if isSuperAdmin %} {% if active %}     @@ -15,21 +17,12 @@     {% endif %} {% endif %} -     - - +     +     +     +    
-
-
-
- - -
-
{% block list %}{% endblock %} diff --git a/htdocs/tpl/page/list_account.html b/htdocs/tpl/page/list_account.html index 24e1f75..c75d24e 100644 --- a/htdocs/tpl/page/list_account.html +++ b/htdocs/tpl/page/list_account.html @@ -4,7 +4,8 @@

Liste des comptes :


-
+ + @@ -22,7 +23,7 @@ {% for account in accounts %} - + {% if account.active %} {% else %} @@ -50,7 +51,7 @@ {% endif %} {% endfor %} diff --git a/htdocs/tpl/page/list_alias.html b/htdocs/tpl/page/list_alias.html index 6dea79e..04e03a3 100644 --- a/htdocs/tpl/page/list_alias.html +++ b/htdocs/tpl/page/list_alias.html @@ -4,7 +4,8 @@

Liste des alias/groupe de diffusion :


- + +
{{ account.name }} <{{account.uid }}>{{ account.name }} <{{account.uid }}>{{ account.quota }} - +
@@ -16,13 +17,13 @@ {% for alias in aliases %} - + {% if alias.active %} {% else %} {% endif %} - + {% endfor %}
{{ alias.name }}
{{ alias.name }}
diff --git a/htdocs/tpl/page/list_domain.html b/htdocs/tpl/page/list_domain.html index 310fc24..5f3c885 100644 --- a/htdocs/tpl/page/list_domain.html +++ b/htdocs/tpl/page/list_domain.html @@ -7,7 +7,8 @@ {% include 'notif.html' %}

Liste des domaines administrables :


-
+ + @@ -23,7 +24,7 @@ + {% if domain.active %} {% else %} @@ -33,7 +34,7 @@ - + {% endfor %} diff --git a/htdocs/tpl/page/login.html b/htdocs/tpl/page/login.html index cc862b5..a72d4dd 100644 --- a/htdocs/tpl/page/login.html +++ b/htdocs/tpl/page/login.html @@ -11,7 +11,7 @@
Responsive image
- +
diff --git a/htdocs/tpl/page/nav.html b/htdocs/tpl/page/nav.html index bfb1cb1..00cdd7d 100644 --- a/htdocs/tpl/page/nav.html +++ b/htdocs/tpl/page/nav.html @@ -6,17 +6,17 @@
{{ domain.name }}
{{ domain.name }}{{ domain.NbMailAccounts }} {{ domain.NbMailAlias }} {{ domain.getQuota }}