Fixes #1247 : The web interface now shows a great form to choose do we host dns (yes/no) and do we host emails (yes/no). + Enforce access rights limits on 'ALL' or 'ADMIN' or 'NONE' for domain types

This commit is contained in:
Benjamin Sonntag 2011-06-03 17:42:37 +00:00
parent 64a47c7db4
commit fdc8ec1dde
15 changed files with 10892 additions and 15332 deletions

View File

@ -97,16 +97,23 @@ if ($r['dns_action']=='UPDATE') {?>
<tr><th colspan="2"> </th><th><?php __("Subdomain"); ?></th><th><?php __("Type");?></th><th><?php __("Status")?></th></tr>
<?php
$col=1;
$dt=$dom->domains_type_lst();
for($i=0;$i<$r["nsub"];$i++) {
$col=3-$col;
?>
<tr class="lst<?php echo $col; ?>">
<?php if ( $r['sub'][$i]['web_action'] =='DELETE') { echo "<td colspan=2 />"; } else { ?>
<td class="center">
<?php if (!(!$isinvited && $dt[strtolower($r["sub"][$i]["type"])]["enable"] != "ALL" )) { ?>
<div class="ina"><a href="dom_subedit.php?domain=<?php echo urlencode($r["name"]) ?>&amp;sub=<?php echo urlencode($r["sub"][$i]["name"]) ?>&amp;type=<?php echo urlencode($r["sub"][$i]["type"]) ?>&amp;value=<?php echo urlencode($r["sub"][$i]['dest'])?>"><img src="images/edit.png" alt="<?php __("Edit"); ?>" /><?php __("Edit"); ?></a></div>
<?php } ?>
</td><td class="center">
<?php if (!(!$isinvited && $dt[strtolower($r["sub"][$i]["type"])]["enable"] != "ALL" )) { ?>
<div class="ina"><a href="dom_subdel.php?domain=<?php echo urlencode($r["name"]) ?>&amp;sub=<?php echo urlencode($r["sub"][$i]["name"]) ?>&amp;type=<?php echo urlencode($r["sub"][$i]["type"]) ?>&amp;value=<?php echo urlencode($r["sub"][$i]['dest'])?>"><img src="images/delete.png" alt="<?php __("Delete"); ?>" /><?php __("Delete"); ?></a></div>
<?php } ?>
</td>
<?php } // end IF ==DELETE ?>
<td><a href="http://<?php ecif($r["sub"][$i]["name"],$r["sub"][$i]["name"]."."); echo $r["name"] ?>" target="_blank"><?php ecif($r["sub"][$i]["name"],$r["sub"][$i]["name"]."."); echo $r["name"] ?></a></td>
@ -163,7 +170,6 @@ sub_domains_edit($domain);
<br />
<?php $mem->show_help("edit_domain"); ?>
<p>&nbsp;</p>
<p>&nbsp;</p>
<!-- *****************************************
modification des parametres dns
-->
@ -172,41 +178,38 @@ if (!$r['noerase']) {
?>
<hr />
<h3><?php __("DNS parameters"); ?></h3>
<h3><?php __("DNS & Email parameters"); ?></h3>
<form action="dom_editdns.php?domain=<?php echo urlencode($r["name"]) ?>" method="post" id="fdns" name="fdns">
<table border="1" cellpadding="6" cellspacing="0">
<tr><td colspan="2"><?php __("Manage the DNS on the server ?"); ?></td></tr>
<tr>
<td align="center" width="65%"><input type="radio" id="yesdns" class="inc" name="dns" value="1"<?php cbox($r["dns"]); ?> onclick="dnson();" />&nbsp;<label for="yesdns"><?php __("Yes"); ?></label></td>
<td align="center" width="35%"><input type="radio" id="nodns" class="inc" name="dns" value="0"<?php cbox(!$r["dns"]); ?> onclick="dnsoff();" />&nbsp;<label for="nodns"><?php __("No"); ?></label></td>
</tr>
<tr>
<td width="65%" valign="top">
<p>
<?php printf(_("help_dns_mx %s %s"),$L_MX,$L_HOSTING); ?>
</p>
<label for="mx"><?php __("MX Field"); ?> : </label><input type="text" class="int" name="mx" id="mx" value="<?php if ($r["dns"]) echo $r["mx"]; else echo $L_MX; ?>" <?php if (!$r["dns"]) echo "disabled=\"disabled\""; ?> />
</td>
<td width="35%" valign="top">
<p>
<?php __("help_dns_mail"); ?></p>
<p>
<input type="radio" id="emailon" class="inc" name="email" id="emailon" value="1"<?php cbox($r["mail"]); ?> <?php if ($r["dns"]) echo "disabled=\"disabled\""; ?>/><label for="emailon"><?php __("Yes"); ?></label>
<br />
<input type="radio" id="emailoff" class="inc" name="email" id="emailoff" value="0"<?php cbox(!$r["mail"]); ?> <?php if ($r["dns"]) echo "disabled=\"disabled\""; ?>/><label for="emailoff"><?php __("No"); ?></label>
</p>
<p> <?php __("Warning: If you set this to 'no', all your email accounts and aliases on this domain will be immediately deleted."); ?>
</p>
</td>
<table class="tlist">
<tr>
<td><?php __("Manage the DNS on the server ?"); ?></td>
<td>
<input type="radio" id="yesdns" class="inc" name="dns" value="1"<?php cbox($r["dns"]); ?> />&nbsp;<label for="yesdns"><?php __("Yes"); ?></label>
</td><td><input type="radio" id="nodns" class="inc" name="dns" value="0"<?php cbox(!$r["dns"]); ?> />&nbsp;<label for="nodns"><?php __("No"); ?></label>
</td>
</tr>
<tr class="trbtn"><td colspan="2"><input type="submit" class="inb" name="submit" value="<?php __("Submit the changes"); ?>" /></td></tr>
</table>
<table class="tlist">
<tr>
<td>
<?php __("Manage the Emails Addresses of this domain on the server?"); ?>
</td>
<td>
<input type="radio" id="yesemail" class="inc" name="email" value="1"<?php cbox($r["mail"]); ?> />&nbsp;<label for="yesemail"><?php __("Yes"); ?></label>
</td><td><input type="radio" id="noemail" class="inc" name="email" value="0"<?php cbox(!$r["mail"]); ?> />&nbsp;<label for="noemail"><?php __("No"); ?></label>
</td>
</table>
<div style="padding-left: 30px; padding-bottom: 20px" class="error"> <?php __("Warning: If you set this to 'no', all your email accounts and aliases on this domain will be immediately deleted."); ?></div>
<input type="submit" class="inb" name="submit" value="<?php __("Submit the changes"); ?>" />
</form>
<!-- *****************************************
destruction du domaine
-->
<p>&nbsp</p>
<hr />
<h3><?php __("Domain removal"); ?></h3>
<br />
<?php printf(_("help_domain_del %s"),$domain); ?><br />
<form action="dom_dodel.php?domain=<?php echo urlencode($domain) ?>" method="post">
@ -214,6 +217,8 @@ if (!$r['noerase']) {
<input type="submit" class="inb" name="detruire" value="<?php printf(_("Delete %s from this server"),$domain); ?>" />
</p>
</form>
<br />
<hr />
<?php } // noerase ?>
<script type="text/javascript">

View File

@ -33,22 +33,13 @@ include_once("head.php");
$fields = array (
"domain" => array ("request", "string", ""),
"dns" => array ("request", "integer", 1),
"mx" => array ("request", "string", ""),
"email" => array ("request", "integer", 0),
"email" => array ("request", "integer", 1),
);
getFields($fields);
$dom->lock();
if ($dns!="1") {
// On fixe mx :
if ($email=="1") {
$mx=$L_MX;
} else {
$mx="";
}
}
if (!$dom->edit_domain($domain,$dns,$mx)) {
if (!$dom->edit_domain($domain,$dns,$email)) {
$error=$err->errstr();
include("dom_edit.php");
$dom->unlock();

View File

@ -38,12 +38,21 @@ $fields = array (
);
getFields($fields);
$dt=$dom->domains_type_lst();
if (!$isinvited && $dt[strtolower($type)]["enable"] != "ALL" ) {
__("This page is restricted to authorized staff");
exit();
}
$dom->lock();
if (!$r=$dom->get_sub_domain_all($domain,$sub,$type)) {
$error=$err->errstr();
}
$dom->unlock();
?>
<h3><?php printf(_("Deleting subdomain %s"),"http://".ife($sub,$sub.".").$domain); ?> : </h3>
<?php

View File

@ -38,6 +38,13 @@ $fields = array (
);
getFields($fields);
$dt=$dom->domains_type_lst();
if (!$isinvited && $dt[strtolower($type)]["enable"] != "ALL" ) {
__("This page is restricted to authorized staff");
exit();
}
$dom->lock();
if (!$dom->del_sub_domain($domain,$sub,$type,$value)) {

View File

@ -50,6 +50,14 @@ $value=$$dynamicvar;
$dom->lock();
$dt=$dom->domains_type_lst();
if (!$isinvited && $dt[strtolower($type)]["enable"] != "ALL" ) {
__("This page is restricted to authorized staff");
exit();
}
$r=$dom->set_sub_domain($domain,$sub,$type,$value, $type_old, $sub_old, $value_old);
$dom->unlock();

View File

@ -41,6 +41,14 @@ getFields($fields);
$dom->lock();
$domroot=$dom->get_domain_all($domain);
$dt=$dom->domains_type_lst();
if (!$isinvited && $dt[strtolower($type)]["enable"] != "ALL" ) {
__("This page is restricted to authorized staff");
exit();
}
if (!$noread) {
if (!$r=$dom->get_sub_domain_all($domain,$sub,$type,$value)) {
$error=$err->errstr();

View File

@ -50,7 +50,12 @@ if (file_exists($lang_date_picker))
<body>
<?
$oldid=intval(isset($_COOKIE['oldid'])?$_COOKIE['oldid']:'');
$isinvited=false;
if ($admin->enabled) $isinvited=true;
if ($oldid && $oldid!=$cuid) {
$isinvited=true;
echo "<div align=center><p class='error'>";
__("Administrator session. you may <a href='adm_login.php'>return to your account</a> or <a href='adm_cancel.php'>cancel this feature</a>");
echo "</p></div>";

View File

@ -73,8 +73,8 @@ class m_dom {
var $type_ipv6 = "IPV6";
var $type_cname = "CNAME";
var $type_txt = "TXT";
var $type_mx = "DEFMX";
var $type_mx2 = "DEFMX2";
var $type_defmx = "DEFMX";
var $type_defmx2 = "DEFMX2";
var $action_insert = "0";
var $action_update= "1";
@ -107,7 +107,7 @@ class m_dom {
$db->query("select * from domaines_type order by advanced;");
$this->domains_type_lst=false;
while ($db->next_record()) {
$this->domains_type_lst[] = $db->Record;
$this->domains_type_lst[strtolower($db->Record["name"])] = $db->Record;
}
return $this->domains_type_lst;
}
@ -312,7 +312,7 @@ class m_dom {
function add_domain($domain,$dns,$noerase=0,$force=0,$isslave=0,$slavedom="") {
global $db,$err,$quota,$classes,$L_MX,$L_FQDN,$tld,$cuid,$bro;
$err->log("dom","add_domain",$domain);
$mx="1";
// Locked ?
if (!$this->islocked) {
$err->raise("dom",3);
@ -380,7 +380,7 @@ class m_dom {
return false;
}
if ($noerase) $noerase="1"; else $noerase="0";
$db->query("insert into domaines (compte,domaine,mx,gesdns,gesmx,noerase,dns_action) values ('$cuid','$domain','$L_MX','$dns','$mx','$noerase','UPDATE');");
$db->query("insert into domaines (compte,domaine,gesdns,gesmx,noerase,dns_action) values ('$cuid','$domain','$dns','1','$noerase','UPDATE');");
if ($isslave) {
$isslave=true;
@ -410,13 +410,6 @@ class m_dom {
$this->set_sub_domain($domain, 'mail', $this->type_webmail, '');
}
if ($mx) {
$this->set_sub_domain($domain, '', $this->type_defmx, '');
if (! empty($GLOBALS['L_DEFAULT_SECONDARY_MX'])) {
$this->set_sub_domain($domain, '', $this->type_defmx2, '');
}
}
// DEPENDANCE :
// Lancement de add_dom sur les classes domain_sensitive :
// Declenchons les autres classes.
@ -845,7 +838,7 @@ class m_dom {
// TODO : j'ai viré le type action, valider que plus personne ne l'utilise (quatrieme argument)
function set_sub_domain($dom,$sub,$type,$dest, $type_old=null,$sub_old=null,$value_old=null) {
global $db,$err,$cuid;
$err->log("dom","set_sub_domain",$dom."/".$sub);
$err->log("dom","set_sub_domain",$dom."/".$sub."/".$type."/".$dest);
// Locked ?
if (!$this->islocked) {
$err->raise("dom",3);
@ -939,15 +932,14 @@ class m_dom {
*
* @param string $dom Domaine du compte courant que l'on souhaite modifier
* @param integer $dns Vaut 1 ou 0 pour héberger ou pas le DNS du domaine
* @param integer $mx Nom fqdn du serveur mx, si le mx local est précisé,
* on héberge alors les mails du domaine.
* @param integer $gesmx Héberge-t-on le emails du domaines sur ce serveur ?
* @param boolean $force Faut-il passer les checks DNS ou MX ? (admin only)
* @return boolean appelle $mail->add_dom ou $ma->del_dom si besoin, en
* fonction du champs MX. Retourne FALSE si une erreur s'est produite,
* TRUE sinon.
*
*/
function edit_domain($dom,$dns,$mx,$force=0) {
function edit_domain($dom,$dns,$gesmx,$force=0) {
global $db,$err,$L_MX,$classes,$cuid;
$err->log("dom","edit_domain",$dom);
// Locked ?
@ -983,55 +975,50 @@ class m_dom {
}
if ($dns!="1") $dns="0";
// On vérifie que des modifications ont bien eu lieu :)
if ($r["dns"]==$dns && $r["mx"]==$mx) {
if ($r["dns"]==$dns && $r["mail"]==$gesmx) {
$err->raise("dom",15);
return false;
}
// MX ?
if ($mx==$L_MX)
$gesmx="1";
else
$gesmx="0";
//si gestion mx uniquement, vérification du dns externe
if ($dns=="0" && $gesmx=="1" && !$force) {
$vmx = $this->checkmx($dom,$mx);
if ($vmx == 1) {
// Aucun champ mx de spécifié sur le dns
$err->raise("dom",25);
return false;
$err->raise("dom",25);
return false;
}
if ($vmx == 2) {
// Serveur non spécifié parmi les champx mx
$err->raise("dom",25);
return false;
$err->raise("dom",25);
return false;
}
}
// OK, des modifs ont été faites, on valide :
// DEPENDANCE :
if ($gesmx && !$r["mail"]) { // on a associé le MX : on cree donc l'entree dans LDAP
if ($gesmx && !$r["mail"]) { // on a associé le MX : on cree donc l'entree dans MySQL
// Lancement de add_dom sur les classes domain_sensitive :
foreach($classes as $c) {
if (method_exists($GLOBALS[$c],"alternc_add_mx_domain")) {
$GLOBALS[$c]->alternc_add_mx_domain($dom);
}
if (method_exists($GLOBALS[$c],"alternc_add_mx_domain")) {
$GLOBALS[$c]->alternc_add_mx_domain($dom);
}
}
}
if (!$gesmx && $r["mail"]) { // on a dissocié le MX : on détruit donc l'entree dans LDAP
// Lancement de del_dom sur les classes domain_sensitive :
foreach($classes as $c) {
if (method_exists($GLOBALS[$c],"alternc_del_mx_domain")) {
$GLOBALS[$c]->alternc_del_mx_domain($dom);
}
if (method_exists($GLOBALS[$c],"alternc_del_mx_domain")) {
$GLOBALS[$c]->alternc_del_mx_domain($dom);
}
}
}
$db->query("UPDATE domaines SET gesdns='$dns', mx='$mx', gesmx='$gesmx' WHERE domaine='$dom'");
$db->query("UPDATE domaines set dns_action='UPDATE' where domaine='$dom';");
return true;
} // edit_domain
@ -1229,6 +1216,23 @@ class m_dom {
return true;
}
/* ----------------------------------------------------------------- */
/**
* Declare that a domain's emails are hosted in this server :
* This adds 2 MX entries in this domain (if required)
*/
function alternc_add_mx_domain($domain) {
global $err;
$err->log("dom","alternc_add_mx_domain");
$this->set_sub_domain($domain, '', $this->type_defmx, '');
if (! empty($GLOBALS['L_DEFAULT_SECONDARY_MX'])) {
$this->set_sub_domain($domain, '', $this->type_defmx2, '');
}
return true;
}
/* ----------------------------------------------------------------- */
/**
* Efface un compte (tous ses domaines)
@ -1243,6 +1247,7 @@ class m_dom {
return true;
}
/* ----------------------------------------------------------------- */
/**
* Returns the used quota for the $name service for the current user.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -837,3 +837,9 @@ msgstr "Entr
msgid "secondary MX DNS entry"
msgstr "Entrée DNS MX secondaire"
msgid "Default mail server"
msgstr "Serveur de mail par défaut"
msgid "Default backup mail server"
msgstr "Serveur de mail de secours"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff