adding slave domain management
This commit is contained in:
parent
929f1808ba
commit
18022b34fb
|
@ -35,6 +35,7 @@ if (!isset($dns)) $dns="1";
|
|||
|
||||
?>
|
||||
<h3><?php __("Domain hosting"); ?></h3>
|
||||
<hr />
|
||||
<?php
|
||||
if (!$quota->cancreate("dom")) { ?>
|
||||
<p class="error"><?php echo _("You cannot add any new domain, your quota is over.")." "._("Contact your administrator for more information."); ?></p>
|
||||
|
@ -44,14 +45,39 @@ exit();
|
|||
if ($error) echo "<p class=\"error\">$error</p>";
|
||||
?>
|
||||
<form method="post" action="dom_doadd.php" id="main">
|
||||
<table><tr><td>
|
||||
<b><label for="newdomain"><?php __("Domain name"); ?> : www.</label></b></td><td><input type="text" class="int" id="newdomain" name="newdomain" value="<?php echo $newdomain ?>" size="32" maxlength="255" />
|
||||
</td></tr><tr><td></td><td><input type="submit" class="inb" name="submit" value="<?php __("Add this domain"); ?>" /></td></tr>
|
||||
</table>
|
||||
<p>
|
||||
<input type="checkbox" name="dns" class="inc" value="1" id="yndns" <?php if ($dns=="1") echo "checked=\"checked\""; ?> /><br />
|
||||
<label for="yndns"><?php __("host my dns here"); ?></label>
|
||||
<label for="newdomain"><b><?php __("Domain name"); ?> :</b></label> <span class="int" id="newdomwww">www.</span><input type="text" class="int" id="newdomain" name="newdomain" value="<?php echo $newdomain ?>" size="32" maxlength="255" />
|
||||
</p>
|
||||
<p>
|
||||
<input type="checkbox" name="dns" class="inc" value="1" id="yndns" <?php if ($dns=="1") echo "checked=\"checked\""; ?> /> <label for="yndns"><?php __("host my dns here"); ?></label>
|
||||
</p>
|
||||
<?php
|
||||
$q = $quota->getquota("dom");
|
||||
if ($q["u"]>0) {
|
||||
?>
|
||||
<p>
|
||||
<?php __("Do you want to point this domain to another domain already installed in your account?"); ?>
|
||||
<br />
|
||||
<input type="radio" id="newisslave0" name="newisslave" value="0" checked="checked" /><label for="newisslave0"><?php __("No: This domain will have its own folder."); ?></label>
|
||||
<br />
|
||||
<input type="radio" id="newisslave1" name="newisslave" value="1" /><label for="newisslave1"><?php __("Yes, redirect this new domain to this one: "); ?></label> <select name="slavedom" id="slavedom" class="inl">
|
||||
<option value=""><?php __("-- Choose a domain --"); ?></option>
|
||||
<?php
|
||||
$dl=$dom->get_domain_list();
|
||||
$ddl=array();
|
||||
foreach($dl as $d) {
|
||||
$ddl[$d]=$d;
|
||||
}
|
||||
eoption($ddl,"slavedom");
|
||||
?></select>
|
||||
<br />
|
||||
</p>
|
||||
<?php } ?>
|
||||
|
||||
<p>
|
||||
<input type="submit" class="inb" name="submit" value="<?php __("Add this domain"); ?>" />
|
||||
</p>
|
||||
|
||||
<p class="error">
|
||||
<small>
|
||||
<?php __("If you don't want to host in our server the DNS of your domain, don't check the box 'host my dns here'. If you don't know what it mean, leave it checked."); ?></small></p>
|
||||
|
|
|
@ -33,12 +33,14 @@ include_once("head.php");
|
|||
$fields = array (
|
||||
"newdomain" => array ("post", "string", ""),
|
||||
"dns" => array ("post", "string", ""),
|
||||
"newisslave" => array ("post", "integer" ,0),
|
||||
"slavedom" => array ("post", "string" ,0),
|
||||
);
|
||||
getFields($fields);
|
||||
|
||||
$dom->lock();
|
||||
|
||||
if (!$dom->add_domain($newdomain,$dns)) {
|
||||
if (!$dom->add_domain($newdomain,$dns,0,0,$newisslave,$slavedom)) {
|
||||
$error=$err->errstr();
|
||||
include("dom_add.php");
|
||||
exit();
|
||||
|
|
|
@ -97,7 +97,7 @@ for($i=0;$i<$r["nsub"];$i++) {
|
|||
<input type="hidden" name="domain" value="<?php echo $r["name"]; ?>" />
|
||||
<input type="hidden" name="action" value="add" />
|
||||
<?php __("Create a subdomain:"); ?>
|
||||
<input type="text" class="int" name="sub" style="text-align:right" value="" size="22" id="sub" /><code>.<?php echo $domain; ?></code></td>
|
||||
<input type="text" class="int" name="sub" style="text-align:right" value="" size="22" id="sub" /><span class="int" id="newsubname">.<?php echo $domain; ?></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="radio" id="local" class="inc" name="type" value="<?php echo $dom->type_local; ?>" checked="checked" onclick="document.main.sub_local.focus();" />
|
||||
|
@ -105,7 +105,7 @@ for($i=0;$i<$r["nsub"];$i++) {
|
|||
<td><input type="text" class="int" name="sub_local" id="sub_local" value="/" size="28" />
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
document.write(" <input type=\"button\" name=\"bff\" onclick=\"browseforfolder('main.sub_local');\" value=\" Choisir un répertoire... \" class=\"bff\">");
|
||||
document.write(" <input type=\"button\" name=\"bff\" onclick=\"browseforfolder('main.sub_local');\" value=\" <?php __("Choose a folder..."); ?> \" class=\"bff\">");
|
||||
// -->
|
||||
</script>
|
||||
</td>
|
||||
|
|
|
@ -43,7 +43,7 @@ if (!$r=$dom->get_sub_domain_all($domain,$sub)) {
|
|||
$dom->unlock();
|
||||
|
||||
?>
|
||||
<h3><?php __("Editing subdomain"); ?> http://<?php ecif($sub,$sub."."); echo $domain; ?> : </h3>
|
||||
<h3><?php __("Editing subdomain"); ?> http://<?php ecif($sub,$sub."."); echo $domain; ?></h3>
|
||||
<?php
|
||||
if ($error) {
|
||||
echo "<p class=\"erroe\">$error</p>";
|
||||
|
@ -52,10 +52,10 @@ $dom->unlock();
|
|||
}
|
||||
?>
|
||||
<hr />
|
||||
<br />
|
||||
<!-- *****************************************
|
||||
gestion du sous-domaine
|
||||
-->
|
||||
<h3><?php __("Sub-domain"); ?> http://<?php ecif($sub,$sub."."); echo $domain; ?></h3>
|
||||
<form action="dom_subdoedit.php" method="post" id="main" name="main">
|
||||
<table border="0">
|
||||
<tr>
|
||||
|
@ -68,7 +68,7 @@ $dom->unlock();
|
|||
<td><input type="text" class="int" name="sub_local" id="sub_local" value="<?php ecif($r["type"]==0,$r["dest"],"/"); ?>" size="40" />
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
document.write(" <input type=\"button\" name=\"bff\" onclick=\"browseforfolder('main.sub_local');\" value=\" ... \" class=\"inb\">");
|
||||
document.write(" <input type=\"button\" name=\"bff\" onclick=\"browseforfolder('main.sub_local');\" value=\" <?php __("Choose a folder..."); ?> \" class=\"bff\">");
|
||||
// -->
|
||||
</script>
|
||||
</td>
|
||||
|
@ -88,10 +88,9 @@ $dom->unlock();
|
|||
<label for="webmail"><?php __("Webmail access"); ?></label></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="submit" class="inb" name="submit" value="<?php __("Validate this change"); ?>" /></td>
|
||||
<td><input type="button" class="inb" name="back" value="<?php __("Cancel"); ?>" onclick="history.back();" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<input type="submit" class="inb" name="submit" value="<?php __("Validate this change"); ?>" />
|
||||
<input type="button" class="inb" name="back" value="<?php __("Cancel"); ?>" onclick="history.back();" />
|
||||
</form>
|
||||
<?php include_once("foot.php"); ?>
|
||||
|
|
|
@ -95,6 +95,7 @@ hr {
|
|||
color: black;
|
||||
background-color: #CFE3F1;
|
||||
cursor: pointer;
|
||||
margin-right: 4px;
|
||||
}
|
||||
.inb:hover {
|
||||
background-color: #BFD3E1;
|
||||
|
@ -144,9 +145,8 @@ hr {
|
|||
border: 1px dotted black;
|
||||
background-color: white;
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 10px;
|
||||
padding-left: 2px;
|
||||
padding-right: 2px;
|
||||
font-size: 11px;
|
||||
padding: 2px;
|
||||
color: black;
|
||||
}
|
||||
|
||||
|
@ -213,8 +213,9 @@ img {
|
|||
|
||||
#content {
|
||||
display: block;
|
||||
width: 740px;
|
||||
width: 730px;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
|
@ -350,3 +351,20 @@ a:hover {
|
|||
font-size: 12px;
|
||||
|
||||
}
|
||||
|
||||
#newdomwww {
|
||||
border-right: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
#newdomain {
|
||||
border-left: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
#sub {
|
||||
border-right: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
#newsubname {
|
||||
border-left: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
|
|
@ -398,5 +398,19 @@ function duration_list($name, $selected=0) {
|
|||
return $res;
|
||||
}
|
||||
|
||||
/* select_values($arr,$cur) echo des <option> du tableau $values ou de la table sql $values
|
||||
selectionne $current par defaut. Par defaut prends les champs 0 comme id et 1 comme
|
||||
donnees pour la table. sinon utilise $info[0] et $info[1].
|
||||
*/
|
||||
function eoption($values,$cur,$info="") {
|
||||
if (is_array($values)) {
|
||||
foreach ($values as $k=>$v) {
|
||||
echo "<option value=\"$k\"";
|
||||
if ($k==$cur) echo " selected=\"selected\"";
|
||||
echo ">".$v."</option>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
@ -178,7 +178,7 @@ class m_dom {
|
|||
* force ne devrait être utilisé que par le super-admin.
|
||||
$ @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon.
|
||||
*/
|
||||
function add_domain($domain,$dns,$noerase=0,$force=0) {
|
||||
function add_domain($domain,$dns,$noerase=0,$force=0,$isslave,$slavedom) {
|
||||
global $db,$err,$quota,$classes,$L_MX,$L_FQDN,$tld,$cuid,$bro;
|
||||
$err->log("dom","add_domain",$domain);
|
||||
$mx="1";
|
||||
|
@ -257,6 +257,20 @@ class m_dom {
|
|||
$db->query("insert into domaines (compte,domaine,mx,gesdns,gesmx,noerase) values ('$cuid','$domain','$L_MX','$dns','$mx','$noerase');");
|
||||
$db->query("insert into domaines_standby (compte,domaine,mx,gesdns,gesmx,action) values ('$cuid','$domain','$L_MX','$dns','$mx',0);"); // INSERT
|
||||
|
||||
if ($isslave) {
|
||||
$isslave=true;
|
||||
$db->query("SELECT domaine FROM domaines WHERE compte='$cuid' AND domaine='$slavedom';");
|
||||
$db->next_record();
|
||||
if (!$db->Record["domaine"]) {
|
||||
$err->raise("dom",1,$slavedom);
|
||||
$isslave=false;
|
||||
}
|
||||
// Point to the master domain :
|
||||
$this->set_sub_domain($domain, '', $this->type_url,'add', 'http://www.'.$slavedom);
|
||||
$this->set_sub_domain($domain, 'www', $this->type_url,'add', 'http://www.'.$slavedom);
|
||||
$this->set_sub_domain($domain, 'mail', $this->type_url,'add', 'http://mail.'.$slavedom);
|
||||
}
|
||||
if (!$isslave) {
|
||||
// Creation du repertoire dans www
|
||||
$dest_root = $bro->get_userid_root($cuid);
|
||||
$domshort=str_replace("-","",str_replace(".","",$domain));
|
||||
|
@ -269,6 +283,7 @@ class m_dom {
|
|||
$this->set_sub_domain($domain, '', $this->type_url, 'add', 'http://www.'.$domain);
|
||||
$this->set_sub_domain($domain, 'www', $this->type_local, 'add', '/'. $domshort);
|
||||
$this->set_sub_domain($domain, 'mail', $this->type_webmail, 'add', '');
|
||||
}
|
||||
// DEPENDANCE :
|
||||
// Lancement de add_dom sur les classes domain_sensitive :
|
||||
// Declenchons les autres classes.
|
||||
|
@ -282,6 +297,13 @@ class m_dom {
|
|||
$GLOBALS[$c]->alternc_add_mx_domain($domain);
|
||||
}
|
||||
}
|
||||
if ($isslave) {
|
||||
foreach($classes as $c) {
|
||||
if (method_exists($GLOBALS[$c],"alternc_add_slave_domain")) {
|
||||
$GLOBALS[$c]->alternc_add_slave_domain($domain,$slavedom);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -948,6 +970,22 @@ class m_dom {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/**
|
||||
* Returns the complete hosted domain list :
|
||||
*/
|
||||
function get_domain_list() {
|
||||
global $db,$err;
|
||||
$res=array();
|
||||
$db->query("SELECT domaine FROM domaines WHERE gesdns=1 ORDER BY domaine");
|
||||
while ($db->next_record()) {
|
||||
$res[]=$db->f("domaine");
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/**
|
||||
* Return the list of allowed slave accounts
|
||||
|
|
|
@ -695,6 +695,22 @@ class m_mail {
|
|||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/** hook function called by AlternC when a domain is created for
|
||||
* the current user account using the SLAVE DOMAIN feature
|
||||
* This function create a CATCHALL to the master domain
|
||||
* @param string $dom Domain that has just been created
|
||||
* @param string $master Master domain
|
||||
* @access private
|
||||
*/
|
||||
function alternc_add_slave_domain($dom,$slave) {
|
||||
global $err;
|
||||
$err->log("mail","alternc_add_slave_domain",$dom);
|
||||
$this->add_mail($dom,"",0,"","@".$slave);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/**
|
||||
* Returns the used quota for the $name service for the current user.
|
||||
|
|
Loading…
Reference in New Issue