Changeset 2821


Ignore:
Timestamp:
01/29/11 18:58:19 (2 years ago)
Author:
fufroma
Message:

Update domains, l'aventure continue

Location:
alternc/trunk
Files:
6 edited

Legend:

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

    r2817 r2821  
    9595 --> 
    9696<table class="tlist"> 
    97 <tr><th colspan="2"><?php __("Actions"); ?></th><th><?php __("Subdomain"); ?></th><th><?php __("Type");?></th><th><?php __("Place"); ?></th></tr> 
     97<tr><th colspan="2"><?php __("Actions"); ?></th><th><?php __("Subdomain"); ?></th><th><?php __("Type");?></th><th><?php __("Place"); ?></th><th><?php __("Enable")?></th><th><?php __("Pending");?></tr> 
    9898<?php 
    9999$col=1; 
     
    111111                <td><?php __($r['sub'][$i]['type_desc']);?></td> 
    112112                <td><?php echo $r["sub"][$i]['type'] === 'LOCAL' ? '<a href="bro_main.php?R='.urlencode($r["sub"][$i]["dest"]).'">'.htmlspecialchars($r["sub"][$i]["dest"]).'</a>' : htmlspecialchars($r["sub"][$i]["dest"]); ?>&nbsp;</td> 
     113                <td><?php  
     114      switch ($r['sub'][$i]['enable']) { 
     115        case 'ENABLED': 
     116          __("Enabled"); 
     117          break; 
     118        case 'ENABLE': 
     119          __("Activation pending"); 
     120          break; 
     121        case 'DISABLED': 
     122          __("Disabled"); 
     123          break; 
     124        case 'DISABLE': 
     125          __("Desactivation pending"); 
     126          break; 
     127      }?></td> 
     128                <td><?php  
     129      switch ($r['sub'][$i]['web_action']) { 
     130        case 'UPDATE': 
     131          __("Update pending"); 
     132          break; 
     133        case 'DELETE': 
     134          __("Deletion pending"); 
     135          break; 
     136        case 'OK': 
     137        default: 
     138          __("Up to date"); 
     139          break; 
     140      }?></td> 
     141             
    113142        </tr> 
    114143<?php } ?> 
  • alternc/trunk/bureau/class/m_dom.php

    r2817 r2821  
    647647    $r["nsub"]=$db->Record["cnt"]; 
    648648    $db->free(); 
    649     $db->query("select sd.*, dt.description as type_desc from sub_domaines sd, domaines_type dt where compte='$cuid' and domaine='$dom' and upper(dt.name)=upper(sd.type)"); 
     649    $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 upper(dt.name)=upper(sd.type)"); 
    650650    // Pas de webmail, on le cochera si on le trouve. 
    651651    $this->webmail=0; 
     
    656656      $r["sub"][$i]["dest"]=$db->Record["valeur"]; 
    657657      $r["sub"][$i]["type"]=$db->Record["type"]; 
     658      $r["sub"][$i]["enable"]=$db->Record["enable"]; 
    658659      $r["sub"][$i]["type_desc"]=$db->Record["type_desc"]; 
     660      $r["sub"][$i]["only_dns"]=$db->Record["only_dns"]; 
     661      $r["sub"][$i]["web_action"]=$db->Record["web_action"]; 
    659662/* 
    660663      if ($db->Record["type"]==3) { // Webmail 
     
    704707    } 
    705708*/ 
    706     $db->query("select sd.*, dt.description as type_desc 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);"); 
     709    $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);"); 
    707710    if ($db->num_rows()==0) { 
    708711      $err->raise("dom",14); 
     
    713716    $r["name"]=$db->Record["sub"]; 
    714717    $r["dest"]=$db->Record["valeur"]; 
    715     $r["type"]=$db->Record["type"]; 
     718    $r["enable"]=$db->Record["enable"]; 
    716719    $r["type_desc"]=$db->Record["type_desc"]; 
     720    $r["only_dns"]=$db->Record["only_dns"]; 
     721    $r["web_action"]=$db->Record["web_action"]; 
    717722    $db->free(); 
    718723    return $r; 
     
    738743        return false; 
    739744        } 
     745        return true; 
    740746        break; 
    741747      case 'IP':  
     
    759765 
    760766 
    761   function can_create_subdomain($dom,$sub,$type) { 
     767  function can_create_subdomain($dom,$sub,$type,$value_old='') { 
    762768    global $db,$err,$cuid; 
    763769    $err->log("dom","can_create_subdomain",$dom."/".$sub); 
     
    769775 
    770776    # Get the list of type of subdomains already here who have the same name 
    771     $db->query("select distinct type from sub_domaines where sub='$sub' and domaine='$dom';"); 
     777    $db->query("select * from sub_domaines where sub='$sub' and domaine='$dom' and not (type='$type' and valeur='$value_old')"); 
     778    #$db->query("select * from sub_domaines where sub='$sub' and domaine='$dom';"); 
    772779    while ($db->next_record()) { 
    773780      # And if there is a domain with a incompatible type, return false 
     
    829836    } 
    830837 
    831     if (! $this->can_create_subdomain($dom,$sub,$type)) { 
     838    if (! $this->can_create_subdomain($dom,$sub,$type,$value_old)) { 
    832839      # TODO have a real error code 
    833840      $err->raise("dom", 654); 
  • alternc/trunk/install/upgrades/1.0.sql

    r2820 r2821  
    3535alter table domaines add column dns_action enum ('OK','UPDATE','DELETE') NOT NULL default 'UPDATE'; 
    3636alter table domaines add column dns_result varchar(255) not null default ''; 
    37 alter table sub_domaines add column web_action enum ('OK','UPDATE','ENABLE','DISABLE','DELETE') NOT NULL default 'UPDATE'; 
    38 alter table sub add column dns_result varchar(255) not null default ''; 
     37alter table sub_domaines add column web_action enum ('OK','UPDATE','DELETE') NOT NULL default 'UPDATE'; 
     38alter table sub_domaines add column dns_result varchar(255) not null default ''; 
     39alter table sub_domaines add column enable enum ('ENABLED', 'ENABLE', 'DISABLED', 'DISABLE') NOT NULL DEFAULT 'ENABLED'; 
    3940drop table sub_domaines_standby; 
    4041drop table domaines_standby; 
  • alternc/trunk/src/dns.sh

    r2819 r2821  
    9494    file=$( 
    9595        echo -e "$file" 
    96         $MYSQL_DO "select distinct replace(replace(dt.entry,'%TARGET%',sd.valeur), '%SUB%', if(length(sd.sub)>0,sd.sub,'@')) as entry from sub_domaines sd,domaines_type dt where sd.type=dt.name and sd.domaine='$domain' order by entry ;" 
     96        $MYSQL_DO "select distinct replace(replace(dt.entry,'%TARGET%',sd.valeur), '%SUB%', if(length(sd.sub)>0,sd.sub,'@')) as entry from sub_domaines sd,domaines_type dt where sd.type=dt.name and sd.domaine='$domain' and sd.enable in ('ENABLE', 'ENABLED') order by entry ;" 
    9797    ) 
    98  
    9998 
    10099    # Get some usefull vars 
  • alternc/trunk/src/hosting_functions_v2.sh

    r2820 r2821  
    114114 
    115115    local FQDN=$2 
     116    local TYPE=$3 # no use here, but one day, maybe... So here he is 
    116117    local USER=$(get_account_by_domain $FQDN) 
    117118    local user_letter=`print_user_letter "$USER"` 
  • alternc/trunk/src/update_domains.sh

    r2820 r2821  
    4343# Sub_domaines we want to delete 
    4444# sub_domaines.web_action = delete 
    45 for sub in $( $MYSQL_DO "select if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) from sub_domaines sd where web_action ='DELETE';") ; do 
    46     host_delete $sub 
     45for sub in $( $MYSQL_DO "select concat_ws('|µ',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),sd.type) from sub_domaines sd where web_action ='DELETE';") ; do 
     46    host_delete $(echo $sub|tr '|µ' ' ') 
    4747    # TODO Update the entry in the DB with the result and the action 
    4848done 
     
    5252params=$( $MYSQL_DO " 
    5353  select concat_ws('|µ',lower(sd.type), if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine), valeur)  
    54   from sub_domaines sd, domaines_type dt 
     54  from sub_domaines sd 
    5555  where sd.web_action ='UPDATE' 
    56   and lower(sd.type) = lower(dt.name) 
    57   and dt.only_dns = false 
    5856  ;") 
    5957for sub in $params;do 
    6058    host_create $(echo $sub|tr '|µ' ' ') 
    61     # TODO Update the entry in the DB with the result and the action 
     59    $MYSQL_DO "update sub_domaines sd set web_action='OK',web_result='$?' where concat_ws('|µ',lower(sd.type),if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),valeur)='$sub'" 
    6260done 
    6361 
    6462# Domaine to enable 
    65 for sub in $( $MYSQL_DO "select if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) from sub_domaines sd where sd.web_action ='ENABLE' ;");do 
    66     host_enable $sub 
    67     # TODO Update the entry in the DB with the result and the action 
     63for sub in $( $MYSQL_DO "select concat_ws('|µ',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),lower(sd.type)) from sub_domaines sd where sd.enable ='ENABLE' ;");do 
     64    host_enable $(echo $sub|tr '|µ' ' ') 
     65    $MYSQL_DO "update sub_domaines sd set enable='ENABLED' where concat_ws('|µ',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),lower(sd.type)) = '$sub';" 
    6866done 
    6967 
    7068# Domains to disable 
    71 for sub in $( $MYSQL_DO "select if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) from sub_domaines sd where sd.web_action ='DISABLE' ;");do 
    72     host_disable $sub 
    73     # TODO Update the entry in the DB with the result and the action 
     69for sub in $( $MYSQL_DO "select concat_ws('|µ',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),lower(sd.type)) from sub_domaines sd where sd.enable ='DISABLE' ;");do 
     70    host_disable $(echo $sub|tr '|µ' ' ') 
     71    $MYSQL_DO "update sub_domaines sd set enable='DISABLED' where concat_ws('|µ',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),lower(sd.type)) = '$sub';" 
    7472done 
    7573 
Note: See TracChangeset for help on using the changeset viewer.