Changeset 2665


Ignore:
Timestamp:
03/04/10 17:16:13 (5 years ago)
Author:
benjamin
Message:

adding slave domain management

Location:
alternc/trunk/bureau
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • alternc/trunk/bureau/admin/dom_add.php

    r2559 r2665  
    3636?> 
    3737<h3><?php __("Domain hosting"); ?></h3> 
     38<hr /> 
    3839<?php 
    3940if (!$quota->cancreate("dom")) { ?> 
     
    4546?> 
    4647<form method="post" action="dom_doadd.php" id="main"> 
    47 <table><tr><td> 
    48 <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" /> 
    49 </td></tr><tr><td></td><td><input type="submit" class="inb" name="submit" value="<?php __("Add this domain"); ?>" /></td></tr> 
    50 </table> 
    5148<p> 
    52 <input type="checkbox" name="dns" class="inc" value="1" id="yndns" <?php if ($dns=="1") echo "checked=\"checked\""; ?> /><br /> 
    53 <label for="yndns"><?php __("host my dns here"); ?></label> 
     49<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" /> 
    5450</p> 
     51<p> 
     52  <input type="checkbox" name="dns" class="inc" value="1" id="yndns" <?php if ($dns=="1") echo "checked=\"checked\""; ?> />&nbsp;<label for="yndns"><?php __("host my dns here"); ?></label> 
     53</p> 
     54<?php 
     55  $q = $quota->getquota("dom"); 
     56if ($q["u"]>0) { 
     57?>  
     58<p> 
     59    <?php __("Do you want to point this domain to another domain already installed in your account?"); ?> 
     60<br /> 
     61    <input type="radio" id="newisslave0" name="newisslave" value="0" checked="checked" /><label for="newisslave0"><?php __("No: This domain will have its own folder."); ?></label> 
     62<br /> 
     63    <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"> 
     64 <option value=""><?php __("-- Choose a domain --"); ?></option> 
     65<?php 
     66$dl=$dom->get_domain_list(); 
     67  $ddl=array(); 
     68  foreach($dl as $d) { 
     69    $ddl[$d]=$d; 
     70  } 
     71  eoption($ddl,"slavedom"); 
     72?></select> 
     73<br /> 
     74</p> 
     75    <?php } ?> 
     76 
     77<p> 
     78  <input type="submit" class="inb" name="submit" value="<?php __("Add this domain"); ?>" /> 
     79</p> 
     80 
    5581<p class="error"> 
    5682<small> 
  • alternc/trunk/bureau/admin/dom_doadd.php

    r2559 r2665  
    3434        "newdomain"    => array ("post", "string", ""), 
    3535        "dns"          => array ("post", "string", ""), 
     36        "newisslave"   => array ("post", "integer" ,0),  
     37        "slavedom"     => array ("post", "string" ,0),  
    3638); 
    3739getFields($fields); 
     
    3941$dom->lock(); 
    4042 
    41 if (!$dom->add_domain($newdomain,$dns)) { 
     43if (!$dom->add_domain($newdomain,$dns,0,0,$newisslave,$slavedom)) { 
    4244        $error=$err->errstr(); 
    4345        include("dom_add.php"); 
  • alternc/trunk/bureau/admin/dom_edit.php

    r2660 r2665  
    9898                        <input type="hidden" name="action" value="add" /> 
    9999<?php __("Create a subdomain:"); ?> 
    100 <input type="text" class="int" name="sub" style="text-align:right" value="" size="22" id="sub" /><code>.<?php echo $domain; ?></code></td> 
     100<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> 
    101101                </tr> 
    102102                <tr> 
     
    106106<script type="text/javascript"> 
    107107<!-- 
    108   document.write("&nbsp;<input type=\"button\" name=\"bff\" onclick=\"browseforfolder('main.sub_local');\" value=\" Choisir un r&eacute;pertoire... \" class=\"bff\">"); 
     108  document.write("&nbsp;<input type=\"button\" name=\"bff\" onclick=\"browseforfolder('main.sub_local');\" value=\" <?php __("Choose a folder..."); ?> \" class=\"bff\">"); 
    109109//  --> 
    110110</script> 
  • alternc/trunk/bureau/admin/dom_subedit.php

    r2559 r2665  
    4444 
    4545?> 
    46 <h3><?php __("Editing subdomain"); ?> http://<?php ecif($sub,$sub."."); echo $domain; ?> : </h3> 
     46<h3><?php __("Editing subdomain"); ?> http://<?php ecif($sub,$sub."."); echo $domain; ?></h3> 
    4747<?php 
    4848        if ($error) { 
     
    5353?> 
    5454<hr /> 
     55<br /> 
    5556<!-- ***************************************** 
    5657                 gestion du sous-domaine 
    5758 --> 
    58 <h3><?php __("Sub-domain"); ?> http://<?php ecif($sub,$sub."."); echo $domain; ?></h3> 
    5959<form action="dom_subdoedit.php" method="post" id="main" name="main"> 
    6060        <table border="0"> 
     
    6969<script type="text/javascript"> 
    7070<!-- 
    71   document.write("&nbsp;<input type=\"button\" name=\"bff\" onclick=\"browseforfolder('main.sub_local');\" value=\" ... \" class=\"inb\">"); 
     71  document.write("&nbsp;<input type=\"button\" name=\"bff\" onclick=\"browseforfolder('main.sub_local');\" value=\" <?php __("Choose a folder..."); ?> \" class=\"bff\">"); 
    7272//  --> 
    7373</script> 
     
    8989                <td>&nbsp;</td> 
    9090        </tr> 
    91         <tr> 
    92                 <td><input type="submit" class="inb" name="submit" value="<?php __("Validate this change"); ?>" /></td> 
    93                 <td><input type="button" class="inb" name="back" value="<?php __("Cancel"); ?>" onclick="history.back();" /></td> 
    94         </tr> 
    9591        </table> 
     92<br /> 
     93<input type="submit" class="inb" name="submit" value="<?php __("Validate this change"); ?>" /> 
     94<input type="button" class="inb" name="back" value="<?php __("Cancel"); ?>" onclick="history.back();" /> 
    9695</form> 
    9796<?php include_once("foot.php"); ?> 
  • alternc/trunk/bureau/admin/styles/style.css

    r2660 r2665  
    9696        background-color: #CFE3F1; 
    9797        cursor: pointer; 
     98        margin-right: 4px; 
    9899} 
    99100.inb:hover { 
     
    145146        background-color: white; 
    146147        font-family: Verdana, Arial, Helvetica, sans-serif; 
    147         font-size: 10px; 
    148         padding-left: 2px; 
    149         padding-right: 2px; 
     148        font-size: 11px; 
     149        padding: 2px; 
    150150        color: black; 
    151151} 
     
    214214#content { 
    215215        display: block; 
    216         width: 740px; 
     216        width: 730px; 
    217217        padding-left: 10px; 
     218        padding-right: 10px; 
    218219        vertical-align: top; 
    219220} 
     
    351352 
    352353} 
     354 
     355#newdomwww { 
     356    border-right: 0; 
     357    padding-right: 0; 
     358} 
     359#newdomain { 
     360    border-left: 0; 
     361    padding-left: 0; 
     362} 
     363#sub { 
     364    border-right: 0; 
     365    padding-right: 0; 
     366} 
     367#newsubname { 
     368    border-left: 0; 
     369    padding-left: 0; 
     370} 
  • alternc/trunk/bureau/class/functions.php

    r2623 r2665  
    399399} 
    400400 
     401/* select_values($arr,$cur) echo des <option> du tableau $values ou de la table sql $values 
     402   selectionne $current par defaut. Par defaut prends les champs 0 comme id et 1 comme 
     403   donnees pour la table. sinon utilise $info[0] et $info[1]. 
     404*/ 
     405function eoption($values,$cur,$info="") { 
     406  if (is_array($values)) { 
     407    foreach ($values as $k=>$v) { 
     408      echo "<option value=\"$k\""; 
     409      if ($k==$cur) echo " selected=\"selected\""; 
     410      echo ">".$v."</option>"; 
     411    } 
     412  } 
     413} 
     414 
    401415 
    402416?> 
  • alternc/trunk/bureau/class/m_dom.php

    r2664 r2665  
    179179   $ @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon. 
    180180  */ 
    181   function add_domain($domain,$dns,$noerase=0,$force=0) { 
     181  function add_domain($domain,$dns,$noerase=0,$force=0,$isslave,$slavedom) { 
    182182    global $db,$err,$quota,$classes,$L_MX,$L_FQDN,$tld,$cuid,$bro; 
    183183    $err->log("dom","add_domain",$domain); 
     
    258258    $db->query("insert into domaines_standby (compte,domaine,mx,gesdns,gesmx,action) values ('$cuid','$domain','$L_MX','$dns','$mx',0);"); // INSERT 
    259259 
    260     // Creation du repertoire dans www 
    261     $dest_root = $bro->get_userid_root($cuid); 
    262     $domshort=str_replace("-","",str_replace(".","",$domain)); 
    263  
    264     if (! is_dir($dest_root . "/". $domshort)) { 
    265       mkdir($dest_root . "/". $domshort); 
    266     } 
    267  
    268     // Creation des 3 sous-domaines par défaut : Vide, www et mail 
    269     $this->set_sub_domain($domain, '',     $this->type_url,     'add', 'http://www.'.$domain); 
    270     $this->set_sub_domain($domain, 'www',  $this->type_local,   'add', '/'. $domshort); 
    271     $this->set_sub_domain($domain, 'mail', $this->type_webmail, 'add', ''); 
     260    if ($isslave) { 
     261      $isslave=true; 
     262      $db->query("SELECT domaine FROM domaines WHERE compte='$cuid' AND domaine='$slavedom';"); 
     263      $db->next_record(); 
     264      if (!$db->Record["domaine"]) { 
     265        $err->raise("dom",1,$slavedom); 
     266        $isslave=false; 
     267      } 
     268      // Point to the master domain :  
     269      $this->set_sub_domain($domain, '',     $this->type_url,'add', 'http://www.'.$slavedom); 
     270      $this->set_sub_domain($domain, 'www',  $this->type_url,'add', 'http://www.'.$slavedom); 
     271      $this->set_sub_domain($domain, 'mail', $this->type_url,'add', 'http://mail.'.$slavedom);       
     272    } 
     273    if (!$isslave) { 
     274      // Creation du repertoire dans www 
     275      $dest_root = $bro->get_userid_root($cuid); 
     276      $domshort=str_replace("-","",str_replace(".","",$domain)); 
     277       
     278      if (! is_dir($dest_root . "/". $domshort)) { 
     279        mkdir($dest_root . "/". $domshort); 
     280      } 
     281       
     282      // Creation des 3 sous-domaines par défaut : Vide, www et mail 
     283      $this->set_sub_domain($domain, '',     $this->type_url,     'add', 'http://www.'.$domain); 
     284      $this->set_sub_domain($domain, 'www',  $this->type_local,   'add', '/'. $domshort); 
     285      $this->set_sub_domain($domain, 'mail', $this->type_webmail, 'add', ''); 
     286    } 
    272287    // DEPENDANCE : 
    273288    // Lancement de add_dom sur les classes domain_sensitive : 
    274      // Declenchons les autres classes.     
     289    // Declenchons les autres classes.     
    275290    foreach($classes as $c) { 
    276291      if (method_exists($GLOBALS[$c],"alternc_add_domain")) { 
     
    283298      } 
    284299    } 
    285    return true; 
     300    if ($isslave) { 
     301      foreach($classes as $c) { 
     302        if (method_exists($GLOBALS[$c],"alternc_add_slave_domain")) { 
     303          $GLOBALS[$c]->alternc_add_slave_domain($domain,$slavedom); 
     304        } 
     305      }  
     306    } 
     307    return true; 
    286308  } 
    287309 
     
    949971  } 
    950972 
     973 
     974  /* ----------------------------------------------------------------- */ 
     975  /** 
     976   * Returns the complete hosted domain list :  
     977   */ 
     978  function get_domain_list() { 
     979        global $db,$err; 
     980        $res=array(); 
     981        $db->query("SELECT domaine FROM domaines WHERE gesdns=1 ORDER BY domaine"); 
     982        while ($db->next_record()) { 
     983                $res[]=$db->f("domaine"); 
     984        } 
     985        return $res; 
     986  } 
     987 
     988 
    951989  /* ----------------------------------------------------------------- */ 
    952990  /** 
  • alternc/trunk/bureau/class/m_mail.php

    r2621 r2665  
    692692    $db->query("INSERT INTO mail_domain (mail,alias,uid) VALUES ('$dom','$dom', '$cuid');"); 
    693693    $this->add_mail($dom,"postmaster",0,"",$mem->user["mail"]); 
     694    return true; 
     695  } 
     696 
     697 
     698  /* ----------------------------------------------------------------- */ 
     699  /** hook function called by AlternC when a domain is created for  
     700   * the current user account using the SLAVE DOMAIN feature 
     701   * This function create a CATCHALL to the master domain 
     702   * @param string $dom Domain that has just been created 
     703   * @param string $master Master domain 
     704   * @access private 
     705   */ 
     706  function alternc_add_slave_domain($dom,$slave) { 
     707    global $err; 
     708    $err->log("mail","alternc_add_slave_domain",$dom); 
     709    $this->add_mail($dom,"",0,"","@".$slave); 
    694710    return true; 
    695711  } 
Note: See TracChangeset for help on using the changeset viewer.