Manipulation des sub_domains via leur id et non plus via le couple sub/type/value
Corrige le bug de suppression de deux sub_domains ayant des valeurs identiques
This commit is contained in:
parent
52cda8789e
commit
769d090705
|
@ -6,7 +6,7 @@ include_once("head.php");
|
|||
# Function to create/edit subdomain
|
||||
# Take the values of the subdomain in arguments
|
||||
|
||||
function sub_domains_edit($domain, $sub=false,$type=false,$value=false) {
|
||||
function sub_domains_edit($domain, $sub_domain_id=false) {
|
||||
global $admin, $err, $oldid, $isedit;
|
||||
|
||||
$dom=new m_dom();
|
||||
|
@ -21,7 +21,10 @@ if (! empty($sub)) {
|
|||
}
|
||||
}
|
||||
*/
|
||||
$sd=$dom->get_sub_domain_all($domain,$sub,$type,$value);
|
||||
$sd=$dom->get_sub_domain_all($sub_domain_id);
|
||||
|
||||
$type=$sd['type'];
|
||||
$sub=$sd['name'];
|
||||
|
||||
$dom->unlock();
|
||||
?>
|
||||
|
@ -30,10 +33,8 @@ $dom->unlock();
|
|||
<table border="0">
|
||||
<tr>
|
||||
<td>
|
||||
<input type="hidden" name="domain" value="<?php ehe($domain); ?>" />
|
||||
<input type="hidden" name="sub_old" value="<?php ehe($sub); ?>" />
|
||||
<input type="hidden" name="type_old" value="<?php ehe($type); ?>" />
|
||||
<input type="hidden" name="value_old" value="<?php ehe($value); ?>" />
|
||||
<input type="hidden" name="domain" value="<?php ehe($domain) ?>" />
|
||||
<input type="hidden" name="sub_domain_id" value="<?php echo $sub_domain_id ?>" />
|
||||
<input type="hidden" name="action" value="add" />
|
||||
<?php
|
||||
if ($isedit) {
|
||||
|
|
|
@ -122,13 +122,13 @@ for($i=0;$i<$r["nsub"];$i++) {
|
|||
<?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"]) ?>&sub=<?php echo urlencode($r["sub"][$i]["name"]) ?>&type=<?php echo urlencode($r["sub"][$i]["type"]) ?>&value=<?php echo urlencode($r["sub"][$i]['dest'])?>"><img src="images/edit.png" alt="<?php __("Edit"); ?>" /><?php __("Edit"); ?></a></div>
|
||||
<div class="ina"><a href="dom_subedit.php?sub_domain_id=<?php echo urlencode($r["sub"][$i]["id"]) ?>"><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"]) ?>&sub=<?php echo urlencode($r["sub"][$i]["name"]) ?>&type=<?php echo urlencode($r["sub"][$i]["type"]) ?>&value=<?php echo urlencode($r["sub"][$i]['dest'])?>"><img src="images/delete.png" alt="<?php __("Delete"); ?>" /><?php __("Delete"); ?></a></div>
|
||||
<div class="ina"><a href="dom_subdel.php?sub_domain_id=<?php echo urlencode($r["sub"][$i]["id"]) ?>"><img src="images/delete.png" alt="<?php __("Delete"); ?>" /><?php __("Delete"); ?></a></div>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<?php } // end IF ==DELETE ?>
|
||||
|
|
|
@ -31,10 +31,7 @@ require_once("../class/config.php");
|
|||
include_once("head.php");
|
||||
|
||||
$fields = array (
|
||||
"domain" => array ("request", "string", ""),
|
||||
"sub" => array ("request", "string", ""),
|
||||
"type" => array ("request", "string", ""),
|
||||
"value" => array ("request", "string", ""),
|
||||
"sub_domain_id" => array ("request", "integer", ""),
|
||||
);
|
||||
getFields($fields);
|
||||
|
||||
|
@ -46,15 +43,13 @@ if (!$isinvited && $dt[strtolower($type)]["enable"] != "ALL" ) {
|
|||
|
||||
|
||||
$dom->lock();
|
||||
if (!$r=$dom->get_sub_domain_all($domain,$sub,$type)) {
|
||||
if (!$r=$dom->get_sub_domain_all($sub_domain_id)) {
|
||||
$error=$err->errstr();
|
||||
}
|
||||
$dom->unlock();
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<h3><?php printf(_("Deleting subdomain %s"),"http://".ife($sub,$sub.".").$domain); ?> : </h3>
|
||||
<h3><?php printf(_("Deleting subdomain %s"),"http://".ife($r['name'],$r['name'].".").$r['domain']); ?> : </h3>
|
||||
<?php
|
||||
if (isset($error) && $error) {
|
||||
echo "<p class=\"error\">$error</p>";
|
||||
|
@ -69,12 +64,9 @@ $dom->unlock();
|
|||
-->
|
||||
<form action="dom_subdodel.php" method="post">
|
||||
<p class="error">
|
||||
<input type="hidden" name="domain" value="<?php echo $domain ?>" />
|
||||
<input type="hidden" name="sub" value="<?php echo $sub ?>" />
|
||||
<input type="hidden" name="type" value="<?php echo $type ?>" />
|
||||
<input type="hidden" name="value" value="<?php echo $value ?>" />
|
||||
<input type="hidden" name="sub_domain_id" value="<?php echo $sub_domain_id ?>" />
|
||||
<?php __("WARNING : Confirm the deletion of the subdomain"); ?> : </p>
|
||||
<p><?php ecif($sub,$sub."."); echo $domain; ?></p>
|
||||
<p><?php ecif($r['name'],$r['name']."."); echo $r['domain']; ?></p>
|
||||
<blockquote>
|
||||
<input type="submit" class="inb" name="confirm" value="<?php __("Yes"); ?>" />
|
||||
<input type="button" class="inb" name="cancel" value="<?php __("No"); ?>" onclick="history.back();" />
|
||||
|
|
|
@ -31,10 +31,7 @@ require_once("../class/config.php");
|
|||
include_once("head.php");
|
||||
|
||||
$fields = array (
|
||||
"domain" => array ("request", "string", ""),
|
||||
"sub" => array ("request", "string", ""),
|
||||
"type" => array ("request", "string", ""),
|
||||
"value" => array ("request", "string", ""),
|
||||
"sub_domain_id" => array ("request", "integer", ""),
|
||||
);
|
||||
getFields($fields);
|
||||
|
||||
|
@ -46,15 +43,18 @@ if (!$isinvited && $dt[strtolower($type)]["enable"] != "ALL" ) {
|
|||
|
||||
|
||||
$dom->lock();
|
||||
if (!$r=$dom->get_sub_domain_all($sub_domain_id)) {
|
||||
$error=$err->errstr();
|
||||
}
|
||||
|
||||
if (!$dom->del_sub_domain($domain,$sub,$type,$value)) {
|
||||
if (!$dom->del_sub_domain($sub_domain_id)) {
|
||||
$error=$err->errstr();
|
||||
}
|
||||
|
||||
$dom->unlock();
|
||||
|
||||
?>
|
||||
<h3><?php echo sprintf(_("Deleting the subdomain %s:"),"http://".(($sub)?$sub.".":$sub).$domain); ?></h3>
|
||||
<h3><?php echo sprintf(_("Deleting the subdomain %s:"),"http://".(($r['name'])?$r['name'].".":$r['name']).$r['domain']); ?></h3>
|
||||
<hr id="topbar"/>
|
||||
<br />
|
||||
<?php
|
||||
|
@ -69,5 +69,5 @@ $dom->unlock();
|
|||
echo "<p class=\"error\">".$error."</p>";
|
||||
}
|
||||
?>
|
||||
<p><span class="ina"><a href="dom_edit.php?domain=<?php echo urlencode($domain) ?>"><?php __("Click here to continue"); ?></a></span></p>
|
||||
<p><span class="ina"><a href="dom_edit.php?domain=<?php echo urlencode($r['domain']) ?>"><?php __("Click here to continue"); ?></a></span></p>
|
||||
<?php include_once("foot.php"); ?>
|
||||
|
|
|
@ -32,10 +32,8 @@ require_once("../class/config.php");
|
|||
$fields = array (
|
||||
"domain" => array ("request", "string", ""),
|
||||
"sub" => array ("request", "string", ""),
|
||||
"sub_old" => array ("request", "string", ""),
|
||||
"type" => array ("request", "string", $dom->type_local),
|
||||
"type_old" => array ("request", "string", ""),
|
||||
"value_old" => array ("request", "string", ""),
|
||||
"sub_domain_id" => array ("request", "integer", ""),
|
||||
);
|
||||
getFields($fields);
|
||||
|
||||
|
@ -58,7 +56,7 @@ if ( (!isset($isinvited) || !$isinvited) && $dt[strtolower($type)]["enable"] !=
|
|||
|
||||
|
||||
|
||||
$r=$dom->set_sub_domain($domain,$sub,$type,$value, $type_old, $sub_old, $value_old);
|
||||
$r=$dom->set_sub_domain($domain,$sub,$type,$value, $sub_domain_id);
|
||||
|
||||
$dom->unlock();
|
||||
|
||||
|
|
|
@ -32,15 +32,11 @@ include_once("head.php");
|
|||
|
||||
|
||||
$fields = array (
|
||||
"domain" => array ("request", "string", ""),
|
||||
"sub" => array ("request", "string", ""),
|
||||
"type" => array ("request", "string", $dom->type_local),
|
||||
"value" => array ("request", "string", ""),
|
||||
"sub_domain_id" => array ("request", "integer", ""),
|
||||
);
|
||||
getFields($fields);
|
||||
|
||||
$dom->lock();
|
||||
$domroot=$dom->get_domain_all($domain);
|
||||
|
||||
$dt=$dom->domains_type_lst();
|
||||
if (!$isinvited && $dt[strtolower($type)]["enable"] != "ALL" ) {
|
||||
|
@ -48,16 +44,17 @@ if (!$isinvited && $dt[strtolower($type)]["enable"] != "ALL" ) {
|
|||
exit();
|
||||
}
|
||||
|
||||
|
||||
if (!isset($noread) || !$noread) {
|
||||
if (!$r=$dom->get_sub_domain_all($domain,$sub,$type,$value)) {
|
||||
if (!$r=$dom->get_sub_domain_all($sub_domain_id)) {
|
||||
$error=$err->errstr();
|
||||
}
|
||||
}
|
||||
|
||||
$domroot=$dom->get_domain_all($r['domain']);
|
||||
|
||||
echo "<h3>";
|
||||
__("Editing subdomain");
|
||||
echo " http://"; ecif($sub,$sub."."); echo $domain."</h3>";
|
||||
echo " http://"; ecif($r['name'],$r['name']."."); echo $r['domain']."</h3>";
|
||||
if (isset($error) && $error) {
|
||||
echo "<p class=\"error\">$error</p>";
|
||||
include_once("foot.php");
|
||||
|
@ -71,7 +68,8 @@ $dom->unlock();
|
|||
<?php
|
||||
$isedit=true;
|
||||
require_once('dom_edit.inc.php');
|
||||
sub_domains_edit($domain,$sub,$type,$value);
|
||||
printvar($r);
|
||||
sub_domains_edit($r['domain'],$sub_domain_id);
|
||||
|
||||
include_once("foot.php");
|
||||
?>
|
||||
|
|
|
@ -768,6 +768,7 @@ class m_dom {
|
|||
for($i=0;$i<$r["nsub"];$i++) {
|
||||
$db->next_record();
|
||||
$r["sub"][$i]=array();
|
||||
$r["sub"][$i]["id"]=$db->Record["id"];
|
||||
$r["sub"][$i]["name"]=$db->Record["sub"];
|
||||
$r["sub"][$i]["dest"]=$db->Record["valeur"];
|
||||
$r["sub"][$i]["type"]=$db->Record["type"];
|
||||
|
@ -785,8 +786,7 @@ class m_dom {
|
|||
/**
|
||||
* Retourne TOUTES les infos d'un sous domaine du compte courant.
|
||||
*
|
||||
* @param string $dom Domaine fqdn concerné
|
||||
* @param string $sub Sous-domaine dont on souhaite les informations
|
||||
* @param integer sub_domain_id id du subdomain
|
||||
* @return arrray Retourne un tableau associatif contenant les
|
||||
* informations du sous-domaine demandé.<pre>
|
||||
* $r["name"]= nom du sous-domaine (NON-complet)
|
||||
|
@ -795,29 +795,27 @@ class m_dom {
|
|||
* $r["type"]= Type (0-n) de la redirection.
|
||||
* Retourne FALSE si une erreur s'est produite.
|
||||
*/
|
||||
function get_sub_domain_all($dom,$sub, $type="", $value='') {
|
||||
function get_sub_domain_all($sub_domain_id) {
|
||||
global $db,$err,$cuid;
|
||||
$err->log("dom","get_sub_domain_all",$dom."/".$sub);
|
||||
$err->log("dom","get_sub_domain_all",$sub_domain_id);
|
||||
// Locked ?
|
||||
if (!$this->islocked) {
|
||||
$err->raise("dom",_("--- Program error --- No lock on the domains!"));
|
||||
return false;
|
||||
}
|
||||
$t=checkfqdn($dom);
|
||||
if ($t) {
|
||||
$err->raise("dom",_("The domain name is syntaxically incorrect"));
|
||||
return false;
|
||||
}
|
||||
$db->query("select sd.*, dt.description as type_desc, dt.only_dns from sub_domaines sd, domaines_type dt where compte='$cuid' and domaine='$dom' and sub='$sub' and ( length('$type')=0 or type='$type') and (length('$value')=0 or '$value'=valeur) and upper(dt.name)=upper(sd.type);");
|
||||
$db->query("select sd.*, dt.description as type_desc, dt.only_dns from sub_domaines sd, domaines_type dt where compte='$cuid' and sd.id='$sub_domain_id' and upper(dt.name)=upper(sd.type);");
|
||||
if ($db->num_rows()==0) {
|
||||
$err->raise("dom",_("The sub-domain does not exist"));
|
||||
return false;
|
||||
}
|
||||
$db->next_record();
|
||||
$r=array();
|
||||
$r["id"]=$db->Record["id"];
|
||||
$r["name"]=$db->Record["sub"];
|
||||
$r["domain"]=$db->Record["domaine"];
|
||||
$r["dest"]=$db->Record["valeur"];
|
||||
$r["enable"]=$db->Record["enable"];
|
||||
$r["type"]=$db->Record["type"];
|
||||
$r["type_desc"]=$db->Record["type_desc"];
|
||||
$r["only_dns"]=$db->Record["only_dns"];
|
||||
$r["web_action"]=$db->Record["web_action"];
|
||||
|
@ -825,7 +823,6 @@ class m_dom {
|
|||
return $r;
|
||||
} // get_sub_domain_all
|
||||
|
||||
|
||||
function check_type_value($type, $value) {
|
||||
global $db,$err,$cuid;
|
||||
|
||||
|
@ -904,7 +901,7 @@ class m_dom {
|
|||
* @param string $sub SUBdomain
|
||||
* @return boolean tell you if the subdomain can be installed there
|
||||
*/
|
||||
function can_create_subdomain($dom,$sub,$type,$type_old='', $value_old='') {
|
||||
function can_create_subdomain($dom,$sub,$type,$sub_domain_id='null') {
|
||||
global $db,$err,$cuid;
|
||||
$err->log("dom","can_create_subdomain",$dom."/".$sub);
|
||||
|
||||
|
@ -914,7 +911,7 @@ class m_dom {
|
|||
$compatibility_lst = explode(",",$db->f('compatibility'));
|
||||
|
||||
// Get the list of type of subdomains already here who have the same name
|
||||
$db->query("select * from sub_domaines where sub='$sub' and domaine='$dom' and not (type='$type_old' and valeur='$value_old') and web_action != 'DELETE'");
|
||||
$db->query("select * from sub_domaines where sub='$sub' and domaine='$dom' and not id = $sub_domain_id and web_action != 'DELETE'");
|
||||
#$db->query("select * from sub_domaines where sub='$sub' and domaine='$dom';");
|
||||
while ($db->next_record()) {
|
||||
// And if there is a domain with a incompatible type, return false
|
||||
|
@ -941,7 +938,7 @@ class m_dom {
|
|||
* de $type (url, ip, dossier...)
|
||||
* @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon.
|
||||
*/
|
||||
function set_sub_domain($dom,$sub,$type,$dest, $type_old=null,$sub_old=null,$value_old=null) {
|
||||
function set_sub_domain($dom,$sub,$type,$dest, $sub_domain_id=null) {
|
||||
global $db,$err,$cuid,$bro;
|
||||
$err->log("dom","set_sub_domain",$dom."/".$sub."/".$type."/".$dest);
|
||||
// Locked ?
|
||||
|
@ -974,13 +971,13 @@ class m_dom {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (! $this->can_create_subdomain($dom,$sub,$type,$type_old,$value_old)) {
|
||||
if (! $this->can_create_subdomain($dom,$sub,$type,$sub_domain_id)) {
|
||||
$err->raise("dom", _("The parameters for this subdomain and domain type are invalid. Please check for subdomain entries incompatibility"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! is_null($type_old )) { // It's not a creation, it's an edit. Delete the old one
|
||||
$db->query("update sub_domaines set web_action='DELETE' where domaine='$dom' and sub='$sub_old' and upper(type)=upper('$type_old') and valeur='$value_old';");
|
||||
if (! is_null($sub_domain_id )) { // It's not a creation, it's an edit. Delete the old one
|
||||
$this->del_sub_domain($sub_domain_id);
|
||||
}
|
||||
|
||||
// Re-create the one we want
|
||||
|
@ -1030,25 +1027,20 @@ class m_dom {
|
|||
* @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon.
|
||||
*
|
||||
*/
|
||||
function del_sub_domain($dom,$sub,$type,$value='') {
|
||||
function del_sub_domain($sub_domain_id) {
|
||||
global $db,$err,$cuid;
|
||||
$err->log("dom","del_sub_domain",$dom."/".$sub);
|
||||
$err->log("dom","del_sub_domain",$sub_domain_id);
|
||||
// Locked ?
|
||||
if (!$this->islocked) {
|
||||
$err->raise("dom",_("--- Program error --- No lock on the domains!"));
|
||||
return false;
|
||||
}
|
||||
$t=checkfqdn($dom);
|
||||
if ($t) {
|
||||
$err->raise("dom",_("The domain name is syntaxically incorrect"));
|
||||
return false;
|
||||
}
|
||||
if (!$r=$this->get_sub_domain_all($dom,$sub,$type)) {
|
||||
if (!$r=$this->get_sub_domain_all($sub_domain_id)) {
|
||||
$err->raise("dom",_("The sub-domain does not exist"));
|
||||
return false;
|
||||
} else {
|
||||
$db->query("update sub_domaines set web_action='DELETE' where domaine='$dom' and sub='$sub' and type='$type' and ( length('$value')=0 or valeur='$value') ");
|
||||
$db->query("update domaines set dns_action='UPDATE' where domaine='$dom';");
|
||||
$db->query("update sub_domaines set web_action='DELETE' where id='$sub_domain_id'; ");
|
||||
$db->query("update domaines set dns_action='UPDATE' where domaine='".$r['domain']."';");
|
||||
}
|
||||
return true;
|
||||
} // del_sub_domain
|
||||
|
|
Loading…
Reference in New Issue