diff --git a/conf/config.php b/conf/config.php index e2658da..acb7b49 100644 --- a/conf/config.php +++ b/conf/config.php @@ -27,6 +27,8 @@ $oriconf['cache'] = '/home/evoadmin/www/cache.sqlite'; $oriconf['known_host'] = '/home/evoadmin/www/known_host'; $oriconf['ftpadmin'] = FALSE; $oriconf['bindadmin'] = FALSE; +$oriconf['php_versions'] = array(); +$oriconf['quota'] = FALSE; $oriconf['noreplication'] = array('srv00.example.com', 'srv01.example.com', 'srv02.example.com'); $oriconf['postponedreplication'] = array('srv00.example.com', 'srv01.example.com', 'srv02.example.com'); diff --git a/htdocs/index.php b/htdocs/index.php index f635d96..47fe6f4 100755 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -68,6 +68,10 @@ if (!array_key_exists('auth', $_SESSION) || $_SESSION['auth']!=1) { include_once EVOADMIN_BASE . '../inc/destroy.php'; +} elseif (preg_match('#^/dbadmin/?$#', $uri, $params)) { + + include_once EVOADMIN_BASE . '../inc/dbadmin.php'; + } else { die ("Cette page n'existe pas !!!"); } diff --git a/inc/accounts.php b/inc/accounts.php index beed466..384782c 100644 --- a/inc/accounts.php +++ b/inc/accounts.php @@ -52,6 +52,14 @@ function web_add($form, $admin_mail) { } } + if (array_key_exists('php_versions', $conf) && count($conf['php_versions']) > 1) { + $exec_cmd .= sprintf(' -r %s', $conf['php_versions'][$form->getField('php_version')->getValue()]); + } + + if ($conf['quota']) { + $exec_cmd .= sprintf(' -q %s:%s', $form->getField('quota_soft')->getValue(), $form->getField('quota_hard')->getValue()); + } + $exec_cmd .= sprintf(' -l %s %s %s 2>&1', $admin_mail, $form->getField('username')->getValue(), $form->getField('domain')->getValue()); @@ -63,11 +71,10 @@ function web_add($form, $admin_mail) { if ( $form->getField('domain_alias')->getValue() ) { $domain_alias = preg_split('/,/', $form->getField('domain_alias')->getValue()); foreach ( $domain_alias as $domain ) { - $exec_cmd = 'web-add.sh add-alias '.$form->getField('username')->getValue().' '; + $exec_cmd = 'web-add-multi.sh add-alias '.$form->getField('username')->getValue().' '; $domain = trim($domain); - $exec_cmd .= $domain.' '.$master.' '.$slave; + $exec_cmd .= $domain.' '. $server_list; sudoexec($exec_cmd, $exec_output, $exec_return); - //domain_add($form, gethostbyname($master), false); } $exec_return |= $exec_return2; // $exec_return == 0 if $exec_return == 0 && $exec_return2 == 0 array_push($exec_output, $exec_output2); @@ -339,6 +346,19 @@ if ($conf['bindadmin']) { $form->addField('use_gmail_mxs', new CheckboxInputFormField("Utilisation des serveurs Gmail en MX ?", FALSE)); } +if (array_key_exists('php_versions', $conf) && count($conf['php_versions']) > 1) { + $form->addField('php_version', new SelectFormField("Version de PHP", FALSE, $conf['php_versions'])); +} + +if ($conf['quota']) { + $field_quota_soft = new TextInputFormField("Quota soft (GiB, entier)", TRUE); + $field_quota_soft->setValue('1'); + $form->addField('quota_soft', $field_quota_soft); + $field_quota_hard = new TextInputFormField("Quota hard (GiB, entier)", TRUE); + $field_quota_hard->setValue('2'); + $form->addField('quota_hard', $field_quota_hard); +} + /* Traitement du formulaire */ if(!empty($_POST)) { $form->isCurrentPage(TRUE); diff --git a/inc/dbadmin.php b/inc/dbadmin.php new file mode 100644 index 0000000..d3d4c59 --- /dev/null +++ b/inc/dbadmin.php @@ -0,0 +1,45 @@ + + * @author Thomas Martin + * @author Sebastien Palma + * @version 1.0 + */ + +global $conf; + +if (!$conf['dbadmin']) + http_redirect('/'); + +$cmd = 'dbadmin.sh list'; + +if(!is_superadmin()) { + $cmd .= ' ' . $_SESSION['user']; +} +sudoexec($cmd, $data_output, $exec_return); + +/* + * Put command output to db_list array. + */ + +$db_list = array(); +foreach ($data_output as $data_line) { + $data_split = explode(':', $data_line); + array_push($db_list, array( + 'owner' => $data_split[0], + 'database' => $data_split[1]) + ); +} + +include_once EVOADMIN_BASE . '../tpl/header.tpl.php'; +include_once EVOADMIN_BASE . '../tpl/menu.tpl.php'; +include_once EVOADMIN_BASE . '../tpl/dbadmin.tpl.php'; +include_once EVOADMIN_BASE . '../tpl/footer.tpl.php'; +?> diff --git a/inc/webadmin-edit.php b/inc/webadmin-edit.php index a3308a6..4ed6741 100644 --- a/inc/webadmin-edit.php +++ b/inc/webadmin-edit.php @@ -71,6 +71,15 @@ if (isset($_GET['del']) ) { } else print "

La suppression a échouée. Veuillez contacter votre administrateur.

"; + } + else { + $exec_cmd = 'web-add.sh del-alias ' . $serveralias['domain'] . ' ' . $serveralias['alias']; + sudoexec($exec_cmd, $exec_output, $exec_return); + if ($exec_return == 0) { + printf ('

Alias %s est supprimé.

', $serveralias['alias']); + } else + print "

La suppression a échouée. Veuillez contacter votre administrateur.

"; + } printf ('

Retour à la liste des alias

', $_SERVER['REDIRECT_URL']); print ""; @@ -171,9 +180,33 @@ if (isset($_GET['del']) ) { } } + else { + $serveralias = array ( + 'domain' => htmlspecialchars(basename($_SERVER['REDIRECT_URL'])), + 'alias' => $form->getField('domain_alias')->getValue(), + ); + + $account_name=$serveralias['domain']; + + $exec_cmd = 'web-add.sh add-alias ' . $serveralias['domain'] . ' ' . $serveralias['alias']; + sudoexec($exec_cmd, $exec_output, $exec_return); + if ($exec_return == 0) { + //domain_add($serveralias['alias'], gethostbyname($master) , false); TODO avec l'IP du load balancer + print "
"; + printf ('

L\'alias %s du domaine %s a bien été créé

', $serveralias['alias'], $serveralias['domain']); + printf ('

Retour à la liste des alias

', $_SERVER['REDIRECT_URL']); + print "
"; + } + else { + print "
"; + printf ('

Echec dans la creation de l\'alias %s du domaine %s

', $serveralias['alias'], $serveralias['domain']); + printf ('

Retour à la liste des alias

', $_SERVER['REDIRECT_URL']); + print "
"; + } + } } } else { - + print "

Ajout d'un serveralias


"; print "
"; print "
"; print " Ajout d'un serveralias"; @@ -212,6 +245,26 @@ if (isset($_GET['del']) ) { $alias_list = $bdd->list_serveralias($domain); } + else { + $cmd = 'web-add.sh list-vhost'; + if(!is_superadmin()) { + $cmd = sprintf('%s %s', $cmd, $_SESSION['user']); + } + sudoexec($cmd, $data_output, $exec_return); + + /* Récupération de cette liste dans le tableau $vhost_list */ + $vhost_list = array(); + foreach($data_output as $data_line) { + $data_split = explode(':', $data_line); + if ($data_split[0] == $domain && $data_split[3] != '') { + $alias_split = explode(',', $data_split[3]); + foreach($alias_split as $alias) { + $alias_array['alias'] = $alias; + array_push($alias_list, $alias_array); + } + } + } + } include_once EVOADMIN_BASE . '../tpl/header.tpl.php'; include_once EVOADMIN_BASE . '../tpl/menu.tpl.php'; diff --git a/inc/webadmin.php b/inc/webadmin.php index e41cc19..1fec4c7 100644 --- a/inc/webadmin.php +++ b/inc/webadmin.php @@ -22,6 +22,7 @@ global $conf; if (!$conf['cluster']) { $cmd = 'web-add.sh list-vhost'; + if(!is_superadmin()) { $cmd = sprintf('%s %s', $cmd, $_SESSION['user']); } @@ -31,12 +32,46 @@ if (!$conf['cluster']) { $vhost_list = array(); foreach($data_output as $data_line) { $data_split = explode(':', $data_line); - array_push($vhost_list, array( - 'owner' => $data_split[0], - 'configid' => $data_split[1], - 'server_name' => $data_split[2], - 'server_alias' => $data_split[3]) - ); + + if (strstr($data_split[4],'K')) { + $taille_utilise = number_format(($data_split[4]/1024), 2, '.', '').'M'; + $taille_utilise_mo = $taille_utilise; + if ($taille_utilise >= 1024) { + $taille_utilise = number_format(($taille_utilise/1024), 2, '.', '').'G'; + } + } else if ($data_split[4] >= 1024) { + $taille_utilise_mo = $data_split[4]; + $taille_utilise = number_format(($data_split[4]/1024), 2, '.', '').'G'; + } else { + $taille_utilise_mo = $data_split[4]; + $taille_utilise = $data_split[4]; + } + + $quota_bas_mo = $data_split[5]; + $quota_bas = number_format(($data_split[5]/1024), 2, '.', '').'G'; + $quota_haut = number_format(($data_split[6]/1024), 2, '.', '').'G'; + $occupation = number_format((($taille_utilise_mo/$quota_bas_mo)*100), 2, '.', ''); + if ($occupation >= 90) { + $occupation = ''.$occupation.'%'; + } else if ($occupation >= 80) { + $occupation = ''.$occupation.'%'; + } else if ($occupation >= 70) { + $occupation = ''.$occupation.'%'; + } else { + $occupation = $occupation.'%'; + } + array_push($vhost_list, array( + 'owner' => $data_split[0], + 'configid' => $data_split[1], + 'server_name' => $data_split[2], + 'server_alias' => $data_split[3], + 'size' => $taille_utilise, + 'quota_soft' => $quota_bas, + 'quota_hard' => $quota_haut, + 'occupation' => $occupation, + 'php_version' => $data_split[7], + 'is_enabled' => $data_split[8]) + ); } } diff --git a/tpl/dbadmin.tpl.php b/tpl/dbadmin.tpl.php new file mode 100644 index 0000000..fc9eddd --- /dev/null +++ b/tpl/dbadmin.tpl.php @@ -0,0 +1,42 @@ + + * @author Thomas Martin + * @author Sebastien Palma + * @version 1.0 + */ + +?> +
+

Bases de données


+ + 0) { ?> + + + + + + + + + '; + printf('', preg_replace("/'/", "", $db_info['owner'])); + printf('', $db_info['database']); + print ''; + } ?> + +
PropriétaireBases de données
  %s  %s
+Aucune base existante !
'; + } +?> + \ No newline at end of file diff --git a/tpl/menu.tpl.php b/tpl/menu.tpl.php index 381b5cf..39b9bc9 100644 --- a/tpl/menu.tpl.php +++ b/tpl/menu.tpl.php @@ -25,6 +25,9 @@
  • Ajout FTP
  • Comptes FTP
  • + +
  • Bases de données
  • +
  • Déconnexion

  • diff --git a/tpl/webadmin-edit.tpl.php b/tpl/webadmin-edit.tpl.php index f2686c1..146dfdc 100644 --- a/tpl/webadmin-edit.tpl.php +++ b/tpl/webadmin-edit.tpl.php @@ -16,7 +16,6 @@

    Server Alias

    0) { @@ -59,6 +58,5 @@ } - } ?> diff --git a/tpl/webadmin.tpl.php b/tpl/webadmin.tpl.php index 546f3a9..647e139 100755 --- a/tpl/webadmin.tpl.php +++ b/tpl/webadmin.tpl.php @@ -25,6 +25,21 @@ print 'Propriétaire'; } ?> Domaine + Alias'; + } + if($conf['quota']) { + print ' Utilisé '; + print ' Soft '; + print ' Hard '; + print ' Occupation '; + } + if (array_key_exists('php_versions', $conf) && count($conf['php_versions']) > 1) { + print ' PHP '; + } + ?> +  Actif  +  Action  Bdd @@ -32,12 +47,8 @@ Replication Master Slave - Alias'; - } ?> - + + '); else printf('%s', $vhost_info['slave']); + } + + printf('%s', preg_replace('/,/','
    ',$vhost_info['server_alias'])); + + if ($conf['quota']) { + printf('%s', $vhost_info['size']); + printf('%s', $vhost_info['quota_soft']); + printf('%s', $vhost_info['quota_hard']); + printf('%s', $vhost_info['occupation']); } - else { - printf('%s', $vhost_info['server_alias']); + if (array_key_exists('php_versions', $conf) && count($conf['php_versions']) > 1) { + printf('%s', preg_replace("/^(\d)(\d)$/", '\1.\2', $vhost_info['php_version'])); } + printf('%s', $vhost_info['is_enabled']); if (is_superadmin()) { printf('Lister/Modifier', $vhost_info['owner']);