Alternc  latest
Alternc logiel libre pour l'hébergement
 All Classes Namespaces Files Functions Variables Pages
m_dom Class Reference

Classe de gestion des domaines de l'hébergé. More...

Public Member Functions

 m_dom ()
 Constructeur. More...
 
 get_panel_url_list ()
 
 hook_menu ()
 hook function called by the menu class to add menu to the left panel More...
 
 domains_type_lst ()
 Retourne un tableau contenant les types de domaines. More...
 
 domains_type_enable_values ()
 
 domains_type_target_values ($type=null)
 
 import_manual_dns_zone ($zone, $domain, $detect_redirect=true, $save=false)
 
 import_manual_dns_entry ($zone, $domain, $detect_redirect=true, $save=false)
 
 is_it_a_redirect ($url)
 
 domains_type_regenerate ($name)
 
 domains_type_get ($name)
 
 domains_type_del ($name)
 
 domains_type_update ($name, $description, $target, $entry, $compatibility, $enable, $only_dns, $need_dns, $advanced, $create_tmpdir, $create_targetdir)
 
 sub_domain_change_status ($sub_id, $status)
 
 enum_domains ($uid=-1)
 Retourne un tableau contenant les domaines d'un membre. More...
 
 del_domain_cancel ($dom)
 
 del_domain ($dom)
 Efface un domaine du membre courant, et tous ses sous-domaines. More...
 
 domshort ($dom, $sub="")
 
 add_domain ($domain, $dns, $noerase=false, $force=false, $isslave=false, $slavedom="")
 Installe un domaine sur le compte courant. More...
 
 create_default_subdomains ($domain, $target_domain="")
 
 domdefaultdir ($domain)
 
 dump_axfr ($domain, $ns= 'localhost')
 
 lst_default_subdomains ()
 
 update_default_subdomains ($arr)
 
 update_one_default ($domain_type, $sub, $domain_type_parameter, $concerned, $enabled, $id=null)
 
 del_default_type ($id)
 
 whois ($domain)
 Retourne les entrées DNS du domaine $domain issues du WHOIS. More...
 
 checkmx ($domaine, $ref_domain= '')
 vérifie la presence d'un champs mx valide sur un serveur DNS $domaine est le domaine dont on veux véririfer les MX $ref_domaine est le domaine avec lequel on veux comparer les MX si $ref_domaine == '', on prend les MX par default More...
 
 get_domain_all ($dom)
 retourne TOUTES les infos d'un domaine More...
 
 get_sub_domain_all ($sub_domain_id)
 Retourne TOUTES les infos d'un sous domaine du compte courant. More...
 
 check_type_value ($type, $value)
 
 can_create_subdomain ($dom, $sub, $type, $sub_domain_id=0)
 Check the compatibility of the POSTed parameters with the chosen domain type. More...
 
 set_sub_domain ($dom, $sub, $type, $dest, $sub_domain_id=0)
 Modifier les information du sous-domaine demandé. More...
 
 del_sub_domain ($sub_domain_id)
 Supprime le sous-domaine demandé More...
 
 set_ttl ($dom_id, $ttl)
 
 edit_domain ($dom, $dns, $gesmx, $force=false, $ttl=86400)
 Modifie les information du domaine précisé. More...
 
 enum_slave_ip ()
 Return the list of ip addresses and classes that are allowed access to domain list through AXFR Transfers from the bind server. More...
 
 add_slave_ip ($ip, $class="32")
 Add an ip address (or a ip class) to the list of allowed slave ip access list. More...
 
 del_slave_ip ($ip)
 Remove an ip address (or a ip class) from the list of allowed slave ip access list. More...
 
 check_slave_account ($login, $pass)
 Check for a slave account. More...
 
 echo_domain_list ($integrity=false)
 Out (echo) the complete hosted domain list : More...
 
 get_domain_list ($uid=-1)
 Returns the complete hosted domain list : More...
 
 get_domain_all_summary ()
 
 get_domain_byid ($dom_id)
 Returns the name of a domain for the current user, from it's domain_id. More...
 
 get_domain_byname ($domain)
 Returns the id of a domain for the current user, from it's domain name. More...
 
 count_domains_all ()
 Count all domains, for all users. More...
 
 enum_slave_account ()
 Return the list of allowed slave accounts. More...
 
 add_slave_account ($login, $pass)
 Add a slave account that will be allowed to access the domain list. More...
 
 del_slave_account ($login)
 Remove a slave account. More...
 
 lock ()
 Try to lock a domain private. More...
 
 unlock ()
 Unlock the cron for domain management return true private. More...
 
 hook_dom_add_mx_domain ($dom_id)
 Declare that a domain's emails are hosted in this server : This adds 2 MX entries in this domain (if required) More...
 
 admin_del_member ()
 Delete an account (all his domains) More...
 
 hook_quota_get ()
 Returns the used quota for the $name service for the current user. More...
 
 alternc_export_conf ()
 Returns the global domain(s) configuration(s) of a particular user No parameters needed. More...
 
 generation_parameters ($id=null, $only_apache=true)
 Return an array with all the needed parameters to generate conf of a vhost. More...
 
 generation_domains_type ()
 Return an array with all informations of the domains_type used to generate Apache conf. More...
 
 generate_conf_oldhook ($action, $lst_sub, $sub_obj=null)
 Launch old fashionned hooks as there was in AlternC 1.0 : do we still need that? More...
 
 generate_apacheconf ($p=null)
 Generate apache configuration. More...
 
 generation_todo ()
 Return an array with the list of id of sub_domains waiting for an action. More...
 
 subdomain_modif_are_done ($sub_domain_id, $action)
 
 set_dns_action ($domain, $dns_action)
 
 set_dns_result ($domain, $dns_result)
 
 get_problems ($domain)
 List if there is problems in the domains. More...
 
 default_domain_type ()
 

Static Public Member Functions

static get_sub_domain_id_and_member_by_name ($fqdn)
 

Public Attributes

 $domains
 $domains : Cache des domaines du membre private More...
 
 $dns
 $dns : Liste des dns trouvés par la fonction whois private More...
 
 $webmail
 Flag : a-t-on trouvé un sous-domaine Webmail pour ce domaine ? private. More...
 
 $fic_lock_cron = "/var/run/alternc/cron.lock"
 Systéme de verrouillage du cron Ce fichier permet de verrouiller le cron en attendant la validation du domaine par update_domains.sh private. More...
 
 $islocked = false
 Le cron a-t-il été bloqué ? Il faut appeler les fonctions privées lock et unlock entre les appels aux domaines. More...
 
 $type_local = "VHOST"
 
 $type_url = "URL"
 
 $type_ip = "IP"
 
 $type_webmail = "WEBMAIL"
 
 $type_ipv6 = "IPV6"
 
 $type_cname = "CNAME"
 
 $type_txt = "TXT"
 
 $type_defmx = "DEFMX"
 
 $type_defmx2 = "DEFMX2"
 
 $action_insert = "0"
 
 $action_update = "1"
 
 $action_delete = "2"
 
 $tld_no_check_at_all = "1"
 
 $cache_domains_type_lst = false
 

Private Member Functions

 import_manual_dns_entry_doit ($entry)
 
 import_manual_dns_prep_zone ($domain)
 

Detailed Description

Classe de gestion des domaines de l'hébergé.

Cette classe permet de gérer les domaines / sous-domaines, redirections dns et mx des domaines d'un membre hébergé.

Definition at line 31 of file m_dom.php.

Member Function Documentation

m_dom::add_domain (   $domain,
  $dns,
  $noerase = false,
  $force = false,
  $isslave = false,
  $slavedom = "" 
)

Installe un domaine sur le compte courant.

Si le domaine existe déjé ou est interdit, ou est celui du serveur, l'installation est refusée. Si l'hébergement DNS est demandé, la fonction checkhostallow vérifiera que le domaine peut étre installé conformément aux demandes des super-admin. Si le dns n'est pas demandé, le domaine peut étre installé s'il est en seconde main d'un tld (exemple : test.eu.org ou test.com, mais pas toto.test.org ou test.test.asso.fr)

Chaque classe peut définir une fonction add_dom($dom) qui sera appellée lors de l'installation d'un nouveau domaine.

Parameters
boolean$dns1 ou 0 pour héberger le DNS du domaine ou pas.
boolean$noerase1 ou 0 pour rendre le domaine inamovible ou non
boolean$force1 ou 0, si 1, n'effectue pas les tests de DNS. force ne devrait étre utilisé que par le super-admin.
Returns
boolean Retourne FALSE si une erreur s'est produite, TRUE sinon.

Definition at line 694 of file m_dom.php.

References $cuid, $db, $domain, $force, $hooks, $id, $msg, $t, checkfqdn(), checkhostallow(), checkhostallow_nodns(), create_default_subdomains(), and whois().

Referenced by import_manual_dns_prep_zone().

694  {
695  global $db, $msg, $quota, $L_FQDN, $tld, $cuid, $hooks;
696  $msg->log("dom", "add_domain", $domain);
697 
698  // Locked ?
699  if (!$this->islocked) {
700  $msg->raise("ERROR", "dom", _("--- Program error --- No lock on the domains!"));
701  return false;
702  }
703  // Verifie que le domaine est rfc-compliant
704  $domain = strtolower($domain);
705  $t = checkfqdn($domain);
706  if ($t) {
707  $msg->raise("ERROR", "dom", _("The domain name is syntaxically incorrect"));
708  return false;
709  }
710  // Interdit les domaines clés (table forbidden_domains) sauf en cas FORCE
711  $db->query("SELECT domain FROM forbidden_domains WHERE domain= ? ;", array($domain));
712  if ($db->num_rows() && !$force) {
713  $msg->raise("ERROR", "dom", _("The requested domain is forbidden in this server, please contact the administrator"));
714  return false;
715  }
716  if ($domain == $L_FQDN || $domain == "www.$L_FQDN") {
717  $msg->raise("ERROR", "dom", _("This domain is the server's domain! You cannot host it on your account!"));
718  return false;
719  }
720  $db->query("SELECT compte FROM domaines WHERE domaine= ?;", array($domain));
721  if ($db->num_rows()) {
722  $msg->raise("ERROR", "dom", _("The domain already exist"));
723  return false;
724  }
725  $db->query("SELECT compte FROM `sub_domaines` WHERE sub != \"\" AND concat( sub, \".\", domaine )= ? OR domaine= ?;", array($domain, $domain));
726  if ($db->num_rows()) {
727  $msg->raise("ERROR", "dom", _("The domain already exist"));
728  return false;
729  }
730  $this->dns = $this->whois($domain);
731  if (!$force) {
732  $v = checkhostallow($domain, $this->dns);
733  if ($v == -1) {
734  $msg->raise("ERROR", "dom", _("The last member of the domain name is incorrect or cannot be hosted in that server"));
735  return false;
736  }
737  if ($dns && $v == -2) {
738  $msg->raise("ALERT", "dom", _("The domain cannot be found in the whois database"));
739  return false;
740  }
741  if ($dns && $v == -3) {
742  $msg->raise("ALERT", "dom", _("The domain cannot be found in the whois database"));
743  return false;
744  }
745 
746  if ($dns) {
747  $dns = "1";
748  } else {
749  $dns = "0";
750  }
751  // mode 5 : force DNS to NO.
752  if ($tld[$v] == 5) {
753  $dns = 0;
754  }
755  // It must be a real domain (no subdomain)
756  if (!$dns) {
758  if ($v) {
759  $msg->raise("ERROR", "dom", _("The requested domain is forbidden in this server, please contact the administrator"));
760  return false;
761  }
762  }
763  }
764  // Check the quota :
765  if (!$quota->cancreate("dom")) {
766  $msg->raise("ALERT", "dom", _("Your domain quota is over, you cannot create more domain names"));
767  return false;
768  }
769  if ($noerase) {
770  $noerase = "1";
771  } else {
772  $noerase = "0";
773  }
774  if ($dns) {
775  $gesmx = "1";
776  } else {
777  $gesmx = "0"; // do not host mx by default if not hosting the DNS
778  }
779  $db->query("INSERT INTO domaines (compte,domaine,gesdns,gesmx,noerase,dns_action) VALUES (?, ?, ?, ?, ?, 'UPDATE');", array($cuid,$domain,$dns,$gesmx,$noerase));
780  if (!($id = $db->lastid())) {
781  $msg->raise("ERROR", "dom", _("An unexpected error occured when creating the domain"));
782  return false;
783  }
784 
785  if ($isslave) {
786  $isslave = true;
787  $db->query("SELECT domaine FROM domaines WHERE compte= ? AND domaine= ?;", array($cuid, $slavedom));
788  $db->next_record();
789  if (!$db->Record["domaine"]) {
790  $msg->raise("ERROR", "dom", _("Domain '%s' not found"), $slavedom);
791  $isslave = false;
792  }
793  // Point to the master domain :
794  $this->create_default_subdomains($domain, $slavedom);
795  }
796  if (!$isslave) {
798  }
799 
800  // TODO: Old hooks, FIXME: when unused remove them
801  $hooks->invoke("alternc_add_domain", array($domain));
802  if ($isslave) {
803  $hooks->invoke("alternc_add_slave_domain", array($domain));
804  }
805  // New Hooks:
806  $hooks->invoke("hook_dom_add_domain", array($id));
807  if ($gesmx) {
808  $hooks->invoke("hook_dom_add_mx_domain", array($id));
809  }
810  if ($isslave) {
811  $hooks->invoke("hook_dom_add_slave_domain", array($id, $slavedom));
812  }
813  return true;
814  }
$hooks
Definition: bootstrap.php:74
checkfqdn($fqdn)
Check that a domain name is fqdn compliant.
Definition: functions.php:258
whois($domain)
Retourne les entrées DNS du domaine $domain issues du WHOIS.
Definition: m_dom.php:940
create_default_subdomains($domain, $target_domain="")
Definition: m_dom.php:820
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
foreach($domaines_user as $domaine) $t
checkhostallow_nodns($domain)
Check that a domain can be hosted in that server, without DNS managment.
Definition: functions.php:103
$cuid
Definition: bootstrap.php:43
checkhostallow($domain, $dns)
Check if a domain can be hosted on this server : Return a negative value in case of an error...
Definition: functions.php:49
$domain
Definition: dom_import.php:36
$dns
$dns : Liste des dns trouvés par la fonction whois private
Definition: m_dom.php:43
if(!isset($is_include)) if(!$key &&!$crt) $id
m_dom::add_slave_account (   $login,
  $pass 
)

Add a slave account that will be allowed to access the domain list.

Definition at line 1816 of file m_dom.php.

References $db, $login, and $msg.

1816  {
1817  global $db, $msg;
1818  $db->query("SELECT * FROM slaveaccount WHERE login= ?", array($login));
1819  if ($db->next_record()) {
1820  $msg->raise("ERROR", "dom", _("The specified slave account already exists"));
1821  return false;
1822  }
1823  $db->query("INSERT INTO slaveaccount (login,pass) VALUES (?, ?)", array($login, $pass));
1824  return true;
1825  }
$login
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
m_dom::add_slave_ip (   $ip,
  $class = "32" 
)

Add an ip address (or a ip class) to the list of allowed slave ip access list.

Definition at line 1622 of file m_dom.php.

References $db, $f, $msg, checkip(), and SLAVE_FLAG.

1622  {
1623  global $db, $msg;
1624  if (!checkip($ip)) {
1625  $msg->raise("ERROR", "dom", _("The IP address you entered is incorrect"));
1626  return false;
1627  }
1628  $class = intval($class);
1629  if ($class < 8 || $class > 32) {
1630  $class = 32;
1631  }
1632  $db->query("SELECT * FROM slaveip WHERE ip= ? AND class= ?;", array($ip, $class));
1633  if ($db->next_record()) {
1634  $msg->raise("ERROR", "err", _("The requested domain is forbidden in this server, please contact the administrator"));
1635  return false;
1636  }
1637  $db->query("INSERT INTO slaveip (ip,class) VALUES (?, ?);", array($ip, $class));
1638  $f = fopen(SLAVE_FLAG, "w");
1639  fputs($f, "yopla");
1640  fclose($f);
1641  return true;
1642  }
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
checkip($ip)
Check that $ip is a correct 4 Dotted ip.
Definition: functions.php:210
const SLAVE_FLAG
Definition: m_dom.php:21
m_dom::admin_del_member ( )

Delete an account (all his domains)

Definition at line 1893 of file m_dom.php.

References $dom, $msg, del_domain(), and enum_domains().

1893  {
1894  global $msg;
1895  $msg->log("dom", "alternc_del_member");
1896  $li = $this->enum_domains();
1897  foreach ($li as $dom) {
1898  $this->del_domain($dom);
1899  }
1900  return true;
1901  }
$msg
Definition: config.php:155
$dom
Definition: whois_test.php:10
enum_domains($uid=-1)
Retourne un tableau contenant les domaines d'un membre.
Definition: m_dom.php:605
del_domain($dom)
Efface un domaine du membre courant, et tous ses sous-domaines.
Definition: m_dom.php:643
m_dom::alternc_export_conf ( )

Returns the global domain(s) configuration(s) of a particular user No parameters needed.

Definition at line 1926 of file m_dom.php.

References $d, $msg, $sub, enum_domains(), get_domain_all(), lock(), and unlock().

1926  {
1927  global $msg;
1928  $msg->log("dom", "export");
1929  $this->enum_domains();
1930  $str = "";
1931  foreach ($this->domains as $d) {
1932  $str.= " <domaines>\n";
1933  $str.=" <nom>" . $d . "</nom>\n";
1934  $this->lock();
1935  $s = $this->get_domain_all($d);
1936  $this->unlock();
1937  if (empty($s["dns"])) {
1938  $s["dns"] = "non";
1939  } else {
1940  $s["dns"] = "oui";
1941  }
1942  $str.=" <dns>" . $s["dns"] . "</dns>\n";
1943 
1944  if (empty($s["mx"])) {
1945  $s["mx"] = "non";
1946  } else {
1947  $s["mx"] = "oui";
1948  }
1949 
1950  $str.=" <mx>" . $s["mx"] . "</mx>\n";
1951 
1952  if (empty($s["mail"])) {
1953  $s["mail"] = "non";
1954  }
1955  $str.=" <mail>" . $s["mail"] . "</mail>\n";
1956  if (is_array($s["sub"])) {
1957  foreach ($s["sub"] as $sub) {
1958  $str.=" <subdomain>\n";
1959  $str.=" <enabled>" . $sub["enable"] . " </enabled>\n";
1960  $str.=" <destination>" . $sub["dest"] . " </destination>\n";
1961  $str.=" <type>" . $sub["type"] . " </type>\n";
1962  $str.=" </subdomain>\n";
1963  }
1964  }
1965  $str.=" </domaines>\n";
1966  }
1967  return $str;
1968  }
unlock()
Unlock the cron for domain management return true private.
Definition: m_dom.php:1863
get_domain_all($dom)
retourne TOUTES les infos d'un domaine
Definition: m_dom.php:1166
$msg
Definition: config.php:155
lock()
Try to lock a domain private.
Definition: m_dom.php:1844
$sub
enum_domains($uid=-1)
Retourne un tableau contenant les domaines d'un membre.
Definition: m_dom.php:605
$d
m_dom::can_create_subdomain (   $dom,
  $sub,
  $type,
  $sub_domain_id = 0 
)

Check the compatibility of the POSTed parameters with the chosen domain type.

Parameters
string$domFQDN of the domain name
string$subSUBdomain
Returns
boolean tell you if the subdomain can be installed there

Definition at line 1344 of file m_dom.php.

References $db, $dom, $msg, and $sub.

Referenced by set_sub_domain(), and sub_domain_change_status().

1344  {
1345  global $db, $msg;
1346 
1347  $sub_domain_id=intval($sub_domain_id);
1348  $msg->log("dom", "can_create_subdomain", $dom . "/" . $sub . "/" .$type . "/" . $sub_domain_id);
1349 
1350  // Get the compatibility list for this domain type
1351  $db->query("select upper(compatibility) as compatibility from domaines_type where upper(name)=upper(?);", array($type));
1352  if (!$db->next_record()) {
1353  return false;
1354  }
1355  $compatibility_lst = explode(",", $db->f('compatibility'));
1356 
1357  // Get the list of type of subdomains already here who have the same name
1358  $db->query("select * from sub_domaines where sub= ? and domaine= ? and not id = ? and web_action != 'DELETE' and enable not in ('DISABLED', 'DISABLE') ", array($sub, $dom, $sub_domain_id));
1359  #$db->query("select * from sub_domaines where sub='$sub' and domaine='$dom';");
1360  while ($db->next_record()) {
1361  // And if there is a domain with a incompatible type, return false
1362  if (!in_array(strtoupper($db->f('type')), $compatibility_lst)) {
1363  return false;
1364  }
1365  }
1366 
1367  // Forbidden to create a CNAME RR on the domain APEX (RFC 1912)
1368  if ($type == 'cname' && $sub == '')
1369  return false;
1370 
1371  // All is right, go ! Create ur domain !
1372  return true;
1373  }
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
$sub
$dom
Definition: whois_test.php:10
m_dom::check_slave_account (   $login,
  $pass 
)

Check for a slave account.

Definition at line 1665 of file m_dom.php.

References $db, and $login.

1665  {
1666  global $db;
1667  $db->query("SELECT * FROM slaveaccount WHERE login= ? AND pass= ?;", array($login, $pass));
1668  if ($db->next_record()) {
1669  return true;
1670  }
1671  return false;
1672  }
$login
global $db
Definition: bootstrap.php:22
m_dom::check_type_value (   $type,
  $value 
)
Parameters
integer$type
string$value

Definition at line 1267 of file m_dom.php.

References $msg, $value, checkcname(), checkip(), checkipv6(), checkuserpath(), and domains_type_target_values().

Referenced by set_sub_domain().

1267  {
1268  global $msg;
1269 
1270  // check the type we can have in domaines_type.target
1271  switch ($this->domains_type_target_values($type)) {
1272  case 'NONE':
1273  if (empty($value) or is_null($value)) {
1274  return true;
1275  }
1276  break;
1277  case 'URL':
1278  if ($value == strval($value)) {
1279  if (filter_var($value, FILTER_VALIDATE_URL)) {
1280  return true;
1281  } else {
1282  $msg->raise("ERROR", "dom", _("invalid url"));
1283  return false;
1284  }
1285  }
1286  break;
1287  case 'DIRECTORY':
1288  if (substr($value, 0, 1) != "/") {
1289  $value = "/" . $value;
1290  }
1291  if (!checkuserpath($value)) {
1292  $msg->raise("ERROR", "dom", _("The folder you entered is incorrect or does not exist"));
1293  return false;
1294  }
1295  return true;
1296  case 'IP':
1297  if (checkip($value)) {
1298  return true;
1299  } else {
1300  $msg->raise("ERROR", "dom", _("The ip address is invalid"));
1301  return false;
1302  }
1303  break;
1304  case 'IPV6':
1305  if (checkipv6($value)) {
1306  return true;
1307  } else {
1308  $msg->raise("ERROR", "dom", _("The ip address is invalid"));
1309  return false;
1310  }
1311  break;
1312  case 'DOMAIN':
1313  if (checkcname($value)) {
1314  return true;
1315  } else {
1316  $msg->raise("ERROR", "dom", _("The name you entered is incorrect or not fully qualified (it must end with a DOT, like example.com<b>.</b>)"));
1317  return false;
1318  }
1319  break;
1320  case 'TXT':
1321  if ($value == strval($value)) {
1322  return true;
1323  } else {
1324  $msg->raise("ERROR", "dom", _("The TXT value you entered is incorrect"));
1325  return false;
1326  }
1327  break;
1328  default:
1329  $msg->raise("ERROR", "dom", _("Invalid domain type selected, please check"));
1330  return false;
1331  }
1332  return false;
1333  }
$msg
Definition: config.php:155
$value
checkipv6($ip)
Check that $ip is a correct ipv6 ip.
Definition: functions.php:221
domains_type_target_values($type=null)
Definition: m_dom.php:191
checkuserpath($path)
Definition: functions.php:297
checkip($ip)
Check that $ip is a correct 4 Dotted ip.
Definition: functions.php:210
checkcname($cname)
Check that CNAME domain is correct.
Definition: functions.php:184
m_dom::checkmx (   $domaine,
  $ref_domain = '' 
)

vérifie la presence d'un champs mx valide sur un serveur DNS $domaine est le domaine dont on veux véririfer les MX $ref_domaine est le domaine avec lequel on veux comparer les MX si $ref_domaine == '', on prend les MX par default

Parameters
string$domaine

Definition at line 1109 of file m_dom.php.

Referenced by edit_domain().

1109  {
1110  global $L_DEFAULT_MX, $L_DEFAULT_SECONDARY_MX;
1111 
1112  $ref_mx = array();
1113  $mxhosts = array();
1114  if (!empty($ref_domain)) {
1115  getmxrr($ref_domain, $ref_mx);
1116  } else {
1117  $ref_mx = array($L_DEFAULT_MX, $L_DEFAULT_SECONDARY_MX);
1118  }
1119 
1120  if (empty($ref_mx)) {
1121  // No reference mx
1122  return 3;
1123  }
1124 
1125  //récupére les champs mx
1126  if (!getmxrr($domaine, $mxhosts)) {
1127  //aucun héte mx spécifié
1128  return 1;
1129  }
1130 
1131  if (empty($mxhosts)) {
1132  // no mx on the target domaine
1133  return 1;
1134  }
1135 
1136  $intersect = array_intersect($mxhosts, $ref_mx);
1137 
1138  if (empty($intersect)) {
1139  // no shared mx server
1140  return 2;
1141  }
1142 
1143  return 0;
1144  }
m_dom::count_domains_all ( )

Count all domains, for all users.

Definition at line 1785 of file m_dom.php.

References $db.

1785  {
1786  global $db;
1787  $db->query("SELECT COUNT(*) AS count FROM domaines;");
1788  if ($db->next_record()) {
1789  return $db->f('count');
1790  } else {
1791  return 0;
1792  }
1793  }
global $db
Definition: bootstrap.php:22
m_dom::create_default_subdomains (   $domain,
  $target_domain = "" 
)
Parameters
string$domain

Definition at line 820 of file m_dom.php.

References $db, $domain, $msg, $query, domdefaultdir(), and set_sub_domain().

Referenced by add_domain().

820  {
821  global $db, $msg;
822  $msg->log("dom", "create_default_subdomains", $domain);
823  $query = "SELECT sub, domain_type, domain_type_parameter FROM default_subdomains WHERE (concerned = 'SLAVE' or concerned = 'BOTH') and enabled=1;";
824  if (empty($target_domain)) {
825  $query = "SELECT sub, domain_type, domain_type_parameter FROM default_subdomains WHERE (concerned = 'MAIN' or concerned = 'BOTH') and enabled=1;";
826  }
827  $domaindir = $this->domdefaultdir($domain);
828  $db->query($query);
829  $jj = array();
830  while ($db->next_record()) {
831  $jj[] = Array("domain_type_parameter" => $db->f('domain_type_parameter'), "sub" => $db->f('sub'), "domain_type" => $db->f('domain_type'));
832  }
833  $src_var = array("%%SUB%%", "%%DOMAIN%%", "%%DOMAINDIR%%", "%%TARGETDOM%%");
834  foreach ($jj as $j) {
835  $trg_var = array($j['sub'], $domain, $domaindir, $target_domain);
836  $domain_type_parameter = str_ireplace($src_var, $trg_var, $j['domain_type_parameter']);
837  $this->set_sub_domain($domain, $j['sub'], strtolower($j['domain_type']), $domain_type_parameter);
838  }
839  }
global $db
Definition: bootstrap.php:22
domdefaultdir($domain)
Definition: m_dom.php:845
$query
Definition: 3.0.0~3.php:37
set_sub_domain($dom, $sub, $type, $dest, $sub_domain_id=0)
Modifier les information du sous-domaine demandé.
Definition: m_dom.php:1389
$msg
Definition: config.php:155
$domain
Definition: dom_import.php:36
m_dom::default_domain_type ( )

Definition at line 2224 of file m_dom.php.

2224  {
2225  // This function is only used to allow translation of default domain types:
2226  _("Locally hosted");
2227  _("URL redirection");
2228  _("IPv4 redirect");
2229  _("Webmail access");
2230  _("Squirrelmail Webmail access");
2231  _("Roundcube Webmail access");
2232  _("IPv6 redirect");
2233  _("CNAME DNS entry");
2234  _("TXT DNS entry");
2235  _("MX DNS entry");
2236  _("secondary MX DNS entry");
2237  _("Default mail server");
2238  _("Default backup mail server");
2239  _("AlternC panel access");
2240  }
m_dom::del_default_type (   $id)

Definition at line 913 of file m_dom.php.

References $db, $id, and $msg.

913  {
914  global $msg, $db;
915  $msg->log("dom", "del_default_type");
916 
917  if (!$db->query("delete from default_subdomains where id= ?;", array($id))) {
918  $msg->raise("ERROR", "dom", _("Could not delete default type"));
919  return false;
920  }
921 
922  return true;
923  }
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
if(!isset($is_include)) if(!$key &&!$crt) $id
m_dom::del_domain (   $dom)

Efface un domaine du membre courant, et tous ses sous-domaines.

Cette fonction efface un domaine et tous ses sous-domaines, ainsi que les autres services attachés é celui-ci. Elle appelle donc les autres classe. Chaque classe peut déclarer une fonction del_dom qui sera appellée lors de la destruction d'un domaine.

Parameters
string$domnom de domaine é effacer
Returns
boolean Retourne FALSE si une erreur s'est produite, TRUE sinon.

Definition at line 643 of file m_dom.php.

References $db, $dom, $hooks, $msg, $r, get_domain_all(), lock(), set_dns_action(), and unlock().

Referenced by admin_del_member().

643  {
644  global $db, $msg, $hooks;
645  $msg->log("dom", "del_domain", $dom);
646  $dom = strtolower($dom);
647 
648  $this->lock();
649  if (!$r = $this->get_domain_all($dom)) {
650  return false;
651  }
652  $this->unlock();
653 
654  // Call Hooks to delete the domain and the MX management:
655  // TODO : the 2 calls below are using an OLD hook call, FIXME: remove them when unused
656  $hooks->invoke("alternc_del_domain", array($dom));
657  $hooks->invoke("alternc_del_mx_domain", array($dom));
658  // New hook calls:
659  $hooks->invoke("hook_dom_del_domain", array($r["id"]));
660  $hooks->invoke("hook_dom_del_mx_domain", array($r["id"]));
661 
662  // Now mark the domain for deletion:
663  $db->query("UPDATE sub_domaines SET web_action='DELETE' WHERE domaine= ?;", array($dom));
664  $this->set_dns_action($dom, 'DELETE');
665 
666  return true;
667  }
$hooks
Definition: bootstrap.php:74
global $db
Definition: bootstrap.php:22
$r
Definition: aws_add.php:75
unlock()
Unlock the cron for domain management return true private.
Definition: m_dom.php:1863
get_domain_all($dom)
retourne TOUTES les infos d'un domaine
Definition: m_dom.php:1166
$msg
Definition: config.php:155
lock()
Try to lock a domain private.
Definition: m_dom.php:1844
$dom
Definition: whois_test.php:10
set_dns_action($domain, $dns_action)
Definition: m_dom.php:2168
m_dom::del_domain_cancel (   $dom)

Definition at line 621 of file m_dom.php.

References $classes, $cuid, $db, $dom, $msg, and set_dns_action().

621  {
622  global $db, $msg, $classes, $cuid;
623  $msg->log("dom", "del_domain_cancel", $dom);
624  $dom = strtolower($dom);
625  $db->query("UPDATE sub_domaines SET web_action='UPDATE' WHERE domaine= ?;", array($dom));
626  $this->set_dns_action($dom, 'UPDATE');
627  # TODO : some work with domain sensitive classes
628  return true;
629  }
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
$cuid
Definition: bootstrap.php:43
$classes
Definition: bootstrap.php:45
$dom
Definition: whois_test.php:10
set_dns_action($domain, $dns_action)
Definition: m_dom.php:2168
m_dom::del_slave_account (   $login)

Remove a slave account.

Definition at line 1831 of file m_dom.php.

References $db, $login, and $msg.

1831  {
1832  global $db, $msg;
1833  $db->query("DELETE FROM slaveaccount WHERE login= ?", array($login));
1834  return true;
1835  }
$login
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
m_dom::del_slave_ip (   $ip)

Remove an ip address (or a ip class) from the list of allowed slave ip access list.

Definition at line 1648 of file m_dom.php.

References $db, $f, $msg, checkip(), and SLAVE_FLAG.

1648  {
1649  global $db, $msg;
1650  if (!checkip($ip)) {
1651  $msg->raise("ERROR", "dom", _("The IP address you entered is incorrect"));
1652  return false;
1653  }
1654  $db->query("DELETE FROM slaveip WHERE ip= ?;", array($ip));
1655  $f = fopen(SLAVE_FLAG, "w");
1656  fputs($f, "yopla");
1657  fclose($f);
1658  return true;
1659  }
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
checkip($ip)
Check that $ip is a correct 4 Dotted ip.
Definition: functions.php:210
const SLAVE_FLAG
Definition: m_dom.php:21
m_dom::del_sub_domain (   $sub_domain_id)

Supprime le sous-domaine demandé

Returns
boolean Retourne FALSE si une erreur s'est produite, TRUE sinon.

Definition at line 1475 of file m_dom.php.

References $db, $msg, $r, and get_sub_domain_all().

Referenced by import_manual_dns_prep_zone(), and set_sub_domain().

1475  {
1476  global $db, $msg;
1477  $msg->log("dom", "del_sub_domain", $sub_domain_id);
1478  // Locked ?
1479  if (!$this->islocked) {
1480  $msg->raise("ERROR", "dom", _("--- Program error --- No lock on the domains!"));
1481  return false;
1482  }
1483  if (!$r = $this->get_sub_domain_all($sub_domain_id)) {
1484  $msg->raise("ERROR", "dom", _("The sub-domain does not exist"));
1485  return false;
1486  } else {
1487  $db->query("update sub_domaines set web_action='DELETE' where id= ?; ", array($sub_domain_id));
1488  $db->query("update domaines set dns_action='UPDATE' where domaine= ?;", array($r['domain']));
1489  }
1490  return true;
1491  }
global $db
Definition: bootstrap.php:22
$r
Definition: aws_add.php:75
$msg
Definition: config.php:155
get_sub_domain_all($sub_domain_id)
Retourne TOUTES les infos d'un sous domaine du compte courant.
Definition: m_dom.php:1234
m_dom::domains_type_del (   $name)

Definition at line 549 of file m_dom.php.

References $db.

549  {
550  global $db;
551  $db->query("delete domaines_type where name= ? ;", array($name));
552  return true;
553  }
global $db
Definition: bootstrap.php:22
m_dom::domains_type_enable_values ( )

Definition at line 171 of file m_dom.php.

References $cuid, $db, $msg, $r, $t, and $tab.

171  {
172  global $db, $msg, $cuid;
173  $msg->log("dom", "domains_type_target_values");
174  $db->query("desc domaines_type;");
175  $r = array();
176  while ($db->next_record()) {
177  if ($db->f('Field') == 'enable') {
178  $tab = explode(",", substr($db->f('Type'), 5, -1));
179  foreach ($tab as $t) {
180  $r[] = substr($t, 1, -1);
181  }
182  }
183  }
184  return $r;
185  }
global $db
Definition: bootstrap.php:22
$r
Definition: aws_add.php:75
$msg
Definition: config.php:155
foreach($domaines_user as $domaine) $t
$cuid
Definition: bootstrap.php:43
m_dom::domains_type_get (   $name)

Definition at line 541 of file m_dom.php.

References $db.

541  {
542  global $db;
543  $db->query("select * from domaines_type where name= ?;", array($name));
544  $db->next_record();
545  return $db->Record;
546  }
global $db
Definition: bootstrap.php:22
m_dom::domains_type_lst ( )

Retourne un tableau contenant les types de domaines.

Returns
array retourne un tableau indexé contenant la liste types de domaines authorisé. Retourne FALSE si une erreur s'est produite.

Definition at line 157 of file m_dom.php.

References $cache_domains_type_lst, $db, and $msg.

Referenced by import_manual_dns_entry_doit().

157  {
158  global $db, $msg;
159  $msg->log("dom", "domains_type_lst");
160  if (empty($this->cache_domains_type_lst)) {
161  $db->query("select * from domaines_type order by advanced;");
162  $this->cache_domains_type_lst = array();
163  while ($db->next_record()) {
164  $this->cache_domains_type_lst[strtolower($db->Record["name"])] = $db->Record;
165  }
166  }
168  }
$cache_domains_type_lst
Definition: m_dom.php:79
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
m_dom::domains_type_regenerate (   $name)

Definition at line 533 of file m_dom.php.

References $cuid, $db, and $msg.

533  {
534  global $db, $msg, $cuid;
535  $db->query("update sub_domaines set web_action='UPDATE' where lower(type) = lower(?) ;", array($name));
536  $db->query("update domaines d, sub_domaines sd set d.dns_action = 'UPDATE' where lower(sd.type)=lower(?);", array($name));
537  return true;
538  }
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
$cuid
Definition: bootstrap.php:43
m_dom::domains_type_target_values (   $type = null)
Parameters
integer$type

Definition at line 191 of file m_dom.php.

References $db, $msg, $r, $t, and $tab.

Referenced by check_type_value().

191  {
192  global $db, $msg;
193  $msg->log("dom", "domains_type_target_values");
194  if (is_null($type)) {
195  $db->query("desc domaines_type;");
196  $r = array();
197  while ($db->next_record()) {
198  if ($db->f('Field') == 'target') {
199  $tab = explode(",", substr($db->f('Type'), 5, -1));
200  foreach ($tab as $t) {
201  $r[] = substr($t, 1, -1);
202  }
203  }
204  }
205  return $r;
206  } else {
207  $db->query("select target from domaines_type where name= ? ;", array($type));
208  if (!$db->next_record()) {
209  return false;
210  }
211  return $db->f('target');
212  }
213  }
global $db
Definition: bootstrap.php:22
$r
Definition: aws_add.php:75
$msg
Definition: config.php:155
foreach($domaines_user as $domaine) $t
m_dom::domains_type_update (   $name,
  $description,
  $target,
  $entry,
  $compatibility,
  $enable,
  $only_dns,
  $need_dns,
  $advanced,
  $create_tmpdir,
  $create_targetdir 
)

Definition at line 556 of file m_dom.php.

References $db, and $msg.

556  {
557  global $msg, $db;
558  // The name MUST contain only letter and digits, it's an identifier after all ...
559  if (!preg_match("#^[a-z0-9]+$#", $name)) {
560  $msg->raise("ERROR", "dom", _("The name MUST contain only letter and digits"));
561  return false;
562  }
563  $only_dns = intval($only_dns);
564  $need_dns = intval($need_dns);
565  $advanced = intval($advanced);
566  $create_tmpdir = intval($create_tmpdir);
567  $create_targetdir = intval($create_targetdir);
568  $db->query("UPDATE domaines_type SET description= ?, target= ?, entry= ?, compatibility= ?, enable= e, need_dns= ?, only_dns= ?, advanced= ?,create_tmpdir= ?,create_targetdir= ? where name= ?;", array($description, $target, $entry, $compatibility, $enable, $need_dns, $only_dns, $advanced, $create_tmpdir, $create_targetdir, $name));
569  return true;
570  }
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
m_dom::domdefaultdir (   $domain)
Parameters
string$domain

Definition at line 845 of file m_dom.php.

References $domain, and domshort().

Referenced by create_default_subdomains().

845  {
846  return "/www/" . $this->domshort($domain);
847  }
domshort($dom, $sub="")
Definition: m_dom.php:670
$domain
Definition: dom_import.php:36
m_dom::domshort (   $dom,
  $sub = "" 
)

Definition at line 670 of file m_dom.php.

References $dom, and $sub.

Referenced by domdefaultdir().

670  {
671  return str_replace("-", "", str_replace(".", "", empty($sub) ? "" : "$sub.") . $dom);
672  }
$sub
$dom
Definition: whois_test.php:10
m_dom::dump_axfr (   $domain,
  $ns = 'localhost' 
)

Definition at line 850 of file m_dom.php.

References $domain.

850  {
851  $axfr = array();
852  exec('/usr/bin/dig AXFR "' . escapeshellcmd($domain) . '" @"' . escapeshellcmd($ns) . '"', $axfr);
853  return $axfr;
854  }
$domain
Definition: dom_import.php:36
m_dom::echo_domain_list (   $integrity = false)

Out (echo) the complete hosted domain list :

Definition at line 1677 of file m_dom.php.

References $db.

1677  {
1678  global $db;
1679  $db->query("SELECT domaine FROM domaines WHERE gesdns=1 ORDER BY domaine");
1680  $tt = "";
1681  while ($db->next_record()) {
1682  #echo $db->f("domaine")."\n";
1683  $tt.=$db->f("domaine") . "\n";
1684  }
1685  echo $tt;
1686  if ($integrity) {
1687  echo md5($tt) . "\n";
1688  }
1689  return true;
1690  }
global $db
Definition: bootstrap.php:22
m_dom::edit_domain (   $dom,
  $dns,
  $gesmx,
  $force = false,
  $ttl = 86400 
)

Modifie les information du domaine précisé.

Parameters
string$domDomaine du compte courant que l'on souhaite modifier
boolean$dnsVaut 1 ou 0 pour héberger ou pas le DNS du domaine
boolean$gesmxHéberge-t-on le emails du domaines sur ce serveur ?
boolean$forceFaut-il passer les checks DNS ou MX ? (admin only)
Returns
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.

Definition at line 1522 of file m_dom.php.

References $db, $dom, $force, $hooks, $msg, $r, $t, checkfqdn(), checkhostallow(), checkmx(), get_domain_all(), set_dns_action(), and whois().

Referenced by import_manual_dns_prep_zone(), and set_ttl().

1522  {
1523  global $db, $msg, $hooks;
1524  $msg->log("dom", "edit_domain", $dom . "/" . $dns . "/" . $gesmx);
1525  // Locked ?
1526  if (!$this->islocked && !$force) {
1527  $msg->raise("ERROR", "dom", _("--- Program error --- No lock on the domains!"));
1528  return false;
1529  }
1530  if ($dns == true && !$force) {
1531  $this->dns = $this->whois($dom);
1532  $v = checkhostallow($dom, $this->dns);
1533  if ($v == -1) {
1534  $msg->raise("ERROR", "dom", _("The last member of the domain name is incorrect or cannot be hosted in that server"));
1535  return false;
1536  }
1537  if ($dns && $v == -2) {
1538  $msg->raise("ALERT", "dom", _("The domain cannot be found in the Whois database"));
1539  return false;
1540  }
1541  if ($dns && $v == -3) {
1542  $msg->raise("ALERT", "dom", _("The DNS of this domain do not match the server's DNS. Please change your domain's DNS before you install it again"));
1543  return false;
1544  }
1545  }
1546 
1547  // Can't have ttl == 0. There is also a check in function_dns
1548  if ($ttl == 0) {
1549  $ttl = 86400;
1550  }
1551 
1552  $t = checkfqdn($dom);
1553  if ($t) {
1554  $msg->raise("ERROR", "dom", _("The domain name is syntaxically incorrect"));
1555  return false;
1556  }
1557  if (!$r = $this->get_domain_all($dom)) {
1558  // Le domaine n'existe pas, Failure
1559  $msg->raise("ERROR", "dom", _("The domain name %s does not exist"), $dom);
1560  return false;
1561  }
1562  if ($dns != "1") {
1563  $dns = "0";
1564  }
1565  // On vérifie que des modifications ont bien eu lieu :)
1566  if ($r["dns"] == $dns && $r["mail"] == $gesmx && $r["zonettl"] == $ttl) {
1567  $msg->raise("INFO", "dom", _("No change has been requested..."));
1568  return true;
1569  }
1570 
1571  // si gestion mx uniquement, vérification du dns externe
1572  if ($dns == "0" && $gesmx == "1" && !$force) {
1573  $vmx = $this->checkmx($dom);
1574  if ($vmx == 1) {
1575  $msg->raise("ALERT", "dom", _("There is no MX record pointing to this server, and you are asking us to host the mail here. Make sure to update your MX entries or no mail will be received"));
1576  }
1577 
1578  if ($vmx == 2) {
1579  // Serveur non spécifié parmi les champx mx
1580  $msg->raise("ALERT", "dom", _("There is no MX record pointing to this server, and you are asking us to host the mail here. Make sure to update your MX entries or no mail will be received"));
1581  }
1582  }
1583 
1584  if ($gesmx && !$r["mail"]) {
1585  $hooks->invoke("hook_dom_add_mx_domain", array($r["id"]));
1586  }
1587 
1588  if (!$gesmx && $r["mail"]) { // on a dissocié le MX : on détruit donc l'entree dans LDAP
1589  $hooks->invoke("hook_dom_del_mx_domain", array($r["id"]));
1590  }
1591 
1592  $db->query("UPDATE domaines SET gesdns= ?, gesmx= ?, zonettl= ? WHERE domaine= ?", array($dns, $gesmx, $ttl, $dom));
1593  $this->set_dns_action($dom, 'UPDATE');
1594 
1595  return true;
1596  }
$hooks
Definition: bootstrap.php:74
checkfqdn($fqdn)
Check that a domain name is fqdn compliant.
Definition: functions.php:258
whois($domain)
Retourne les entrées DNS du domaine $domain issues du WHOIS.
Definition: m_dom.php:940
global $db
Definition: bootstrap.php:22
$r
Definition: aws_add.php:75
get_domain_all($dom)
retourne TOUTES les infos d'un domaine
Definition: m_dom.php:1166
$msg
Definition: config.php:155
foreach($domaines_user as $domaine) $t
checkhostallow($domain, $dns)
Check if a domain can be hosted on this server : Return a negative value in case of an error...
Definition: functions.php:49
$dns
$dns : Liste des dns trouvés par la fonction whois private
Definition: m_dom.php:43
$dom
Definition: whois_test.php:10
checkmx($domaine, $ref_domain= '')
vérifie la presence d'un champs mx valide sur un serveur DNS $domaine est le domaine dont on veux vér...
Definition: m_dom.php:1109
set_dns_action($domain, $dns_action)
Definition: m_dom.php:2168
m_dom::enum_domains (   $uid = -1)

Retourne un tableau contenant les domaines d'un membre.

Par défaut le membre connecté

Returns
array retourne un tableau indexé contenant la liste des domaines hébergés sur le compte courant. Retourne FALSE si une erreur s'est produite.

Definition at line 605 of file m_dom.php.

References $cuid, $db, $domains, $msg, and $uid.

Referenced by admin_del_member(), alternc_export_conf(), and hook_menu().

605  {
606  global $db, $msg, $cuid;
607  $msg->log("dom", "enum_domains");
608  if ($uid == -1) {
609  $uid = $cuid;
610  }
611  $db->query("SELECT * FROM domaines WHERE compte= ? ORDER BY domaine ASC;", array($uid));
612  $this->domains = array();
613  if ($db->num_rows() > 0) {
614  while ($db->next_record()) {
615  $this->domains[] = $db->f("domaine");
616  }
617  }
618  return $this->domains;
619  }
$uid
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
$cuid
Definition: bootstrap.php:43
$domains
$domains : Cache des domaines du membre private
Definition: m_dom.php:37
m_dom::enum_slave_account ( )

Return the list of allowed slave accounts.

Definition at line 1799 of file m_dom.php.

References $db, and $res.

1799  {
1800  global $db;
1801  $db->query("SELECT * FROM slaveaccount;");
1802  $res = array();
1803  while ($db->next_record()) {
1804  $res[] = $db->Record;
1805  }
1806  if (!count($res)) {
1807  return false;
1808  }
1809  return $res;
1810  }
global $db
Definition: bootstrap.php:22
$res
Definition: index.php:125
m_dom::enum_slave_ip ( )

Return the list of ip addresses and classes that are allowed access to domain list through AXFR Transfers from the bind server.

Definition at line 1605 of file m_dom.php.

References $db, $msg, and $res.

1605  {
1606  global $db, $msg;
1607  $db->query("SELECT * FROM slaveip;");
1608  if (!$db->next_record()) {
1609  return false;
1610  }
1611  $res = array();
1612  do {
1613  $res[] = $db->Record;
1614  } while ($db->next_record());
1615  return $res;
1616  }
global $db
Definition: bootstrap.php:22
$res
Definition: index.php:125
$msg
Definition: config.php:155
m_dom::generate_apacheconf (   $p = null)

Generate apache configuration.

Die if a specific FQDN have 2 vhost conf.

Definition at line 2087 of file m_dom.php.

References $p, generation_domains_type(), generation_parameters(), and getuserpath().

2087  {
2088  // Get the parameters
2089  $lst = $this->generation_parameters($p);
2090 
2091  $gdt = $this->generation_domains_type();
2092 
2093  // Initialize duplicate check
2094  $check_dup = array();
2095 
2096  $ret = '';
2097  foreach ($lst as $p) {
2098  // Check if duplicate
2099  if (in_array($p['fqdn'], $check_dup)) {
2100  die("Error: duplicate fqdn : " . $p['fqdn']);
2101  } else {
2102  $check_dup[] = $p['fqdn'];
2103  }
2104 
2105  // Get the needed template
2106  $tpl = $gdt[$p['type']] ['tpl'];
2107 
2108  // Replace needed vars
2109  $tpl = strtr($tpl, array(
2110  "%%LOGIN%%" => $p['login'],
2111  "%%fqdn%%" => $p['fqdn'],
2112  "%%document_root%%" => getuserpath($p['login']) . $p['valeur'],
2113  "%%account_root%%" => getuserpath($p['login']),
2114  "%%redirect%%" => $p['valeur'],
2115  "%%UID%%" => $p['uid'],
2116  "%%GID%%" => $p['uid'],
2117  "%%mail_account%%" => $p['mail'],
2118  "%%user%%" => "FIXME",
2119  ));
2120 
2121  // Security check
2122  if ($p['uid'] < 1999) { // if UID is not an AlternC uid
2123  $ret.= "# ERROR: Sub_id: " . $p['sub_id'] . "- The uid seem to be dangerous\n";
2124  continue;
2125  }
2126 
2127  // Return the conf
2128  $ret.= "# Sub_id: " . $p['sub_id'] . "\n" . $tpl;
2129  }
2130 
2131  return $ret;
2132  }
generation_parameters($id=null, $only_apache=true)
Return an array with all the needed parameters to generate conf of a vhost.
Definition: m_dom.php:1977
getuserpath($user=null)
get the home of the user
Definition: functions.php:329
$p
Definition: bro_editor.php:46
generation_domains_type()
Return an array with all informations of the domains_type used to generate Apache conf...
Definition: m_dom.php:2035
m_dom::generate_conf_oldhook (   $action,
  $lst_sub,
  $sub_obj = null 
)

Launch old fashionned hooks as there was in AlternC 1.0 : do we still need that?

Definition at line 2056 of file m_dom.php.

References generation_parameters(), and null.

2056  {
2057  if (is_null($sub_obj)) {
2058  $sub_obj = $this->generation_parameters(null, false);
2059  }
2060  if (!isset($lst_sub[strtoupper($action)]) || empty($lst_sub[strtoupper($action)])) {
2061  return false;
2062  }
2063 
2064  $lst_by_type = $lst_sub[strtoupper($action)];
2065 
2066  foreach ($lst_by_type as $type => $lid_arr) {
2067  $script = "/etc/alternc/functions_hosting/hosting_" . strtolower($type) . ".sh";
2068  if (!@is_executable($script)) {
2069  continue;
2070  }
2071  foreach ($lid_arr as $lid) {
2072  $o = $sub_obj[$lid];
2073  $cmd = $script . " " . escapeshellcmd(strtolower($action)) . " ";
2074  $cmd .= escapeshellcmd($o['fqdn']) . " " . escapeshellcmd($o['valeur']);
2075 
2076  system($cmd);
2077  }
2078  } // foreach $lst_by_type
2079  }
generation_parameters($id=null, $only_apache=true)
Return an array with all the needed parameters to generate conf of a vhost.
Definition: m_dom.php:1977
PR null
Definition: lang-css.js:1
m_dom::generation_domains_type ( )

Return an array with all informations of the domains_type used to generate Apache conf.

Die if templates missing. Warning: an Apache domains_type must have 'only_dns' == TRUE

Definition at line 2035 of file m_dom.php.

References $d, $dom, and ALTERNC_APACHE2_GEN_TMPL_DIR.

Referenced by generate_apacheconf().

2035  {
2036  global $dom;
2037  $d = array();
2038  foreach ($dom->domains_type_lst() as $k => $v) {
2039  if ($v['only_dns'] == true) {
2040  continue;
2041  }
2042  if (!$j = file_get_contents(ALTERNC_APACHE2_GEN_TMPL_DIR . '/' . strtolower($k) . '.conf')) {
2043  die("Error: missing file for $k");
2044  }
2045  $d[$k] = $v;
2046  $d[$k]['tpl'] = $j;
2047  }
2048  return $d;
2049  }
const ALTERNC_APACHE2_GEN_TMPL_DIR
Definition: config.php:92
$dom
Definition: whois_test.php:10
$d
m_dom::generation_parameters (   $id = null,
  $only_apache = true 
)

Return an array with all the needed parameters to generate conf of a vhost.

If no parameters, return the parameters for ALL the vhost. Optionnal parameters: id of the sub_domaines

2016_05_18 : this comments was here before escaping the request... is there still something to do here ? // BUG BUG BUG FIXME // Suppression de comptes -> membres existe pas -> domaines a supprimer ne sont pas lister

Definition at line 1977 of file m_dom.php.

References $db, $id, $msg, $query, and $r.

Referenced by generate_apacheconf(), and generate_conf_oldhook().

1977  {
1978  global $db, $msg;
1979  $msg->log("dom", "generation_parameters");
1980  $params = "";
1981  /** 2016_05_18 : this comments was here before escaping the request... is there still something to do here ?
1982  * // BUG BUG BUG FIXME
1983  * // Suppression de comptes -> membres existe pas -> domaines a supprimer ne sont pas lister
1984  */
1985  $query = "
1986  select
1987  sd.id as sub_id,
1988  lower(sd.type) as type,
1989  m.login,
1990  m.uid as uid,
1991  if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) as fqdn,
1992  concat_ws('@',m.login,v.value) as mail,
1993  sd.valeur
1994  from
1995  sub_domaines sd left join membres m on sd.compte=m.uid,
1996  variable v,
1997  domaines_type dt
1998  where
1999  v.name='mailname_bounce'
2000  and lower(dt.name) = lower(sd.type)";
2001  $query_args = array();
2002 
2003  if (!is_null($id) && intval($id) == $id) {
2004  $query .= " AND sd.id = ? ";
2005  array_push($query_args, intval($id));
2006  }
2007  if ($only_apache) {
2008  $query .=" and dt.only_dns is false ";
2009  }
2010 
2011  $query .= "
2012  order by
2013  m.login,
2014  sd.domaine,
2015  sd.sub;";
2016 
2017 
2018  $db->query($query, $query_args);
2019 
2020  $r = array();
2021  while ($db->next_record()) {
2022  $r[$db->Record['sub_id']] = $db->Record;
2023  }
2024  return $r;
2025  }
global $db
Definition: bootstrap.php:22
$r
Definition: aws_add.php:75
$query
Definition: 3.0.0~3.php:37
$msg
Definition: config.php:155
if(!isset($is_include)) if(!$key &&!$crt) $id
m_dom::generation_todo ( )

Return an array with the list of id of sub_domains waiting for an action.

Definition at line 2138 of file m_dom.php.

References $db, $msg, and $r.

2138  {
2139  global $db, $msg;
2140  $msg->log("dom", "generation_todo");
2141  $db->query("select id as sub_id, web_action, type from sub_domaines where web_action !='ok';");
2142  $r = array();
2143  while ($db->next_record()) {
2144  $r[strtoupper($db->Record['web_action'])][strtoupper($db->Record['type'])][] = $db->f('sub_id');
2145  }
2146  return $r;
2147  }
global $db
Definition: bootstrap.php:22
$r
Definition: aws_add.php:75
$msg
Definition: config.php:155
m_dom::get_domain_all (   $dom)

retourne TOUTES les infos d'un domaine

Parameters
string$domDomaine dont on souhaite les informations
Returns
array Retourne toutes les infos du domaine sous la forme d'un tableau associatif comme suit :
 $r["name"] =  Nom fqdn
 $r["dns"]  =  Gestion du dns ou pas ?
 $r["mx"]   =  Valeur du champs MX si "dns"=true
 $r["mail"] =  Heberge-t-on le mail ou pas ? (si "dns"=false)
 $r["nsub"] =  Nombre de sous-domaines
 $r["sub"]  =  tableau associatif des sous-domaines
 $r["sub"][0-(nsub-1)]["name"] = nom du sous-domaine (NON-complet)
 $r["sub"][0-(nsub-1)]["dest"] = Destination (url, ip, local ...)
 $r["sub"][0-(nsub-1)]["type"] = Type (0-n) de la redirection.
 
Retourne FALSE si une erreur s'est produite.

Definition at line 1166 of file m_dom.php.

References $cuid, $db, $dom, $i, $msg, $r, $t, and checkfqdn().

Referenced by alternc_export_conf(), del_domain(), edit_domain(), get_problems(), import_manual_dns_prep_zone(), and set_ttl().

1166  {
1167  global $db, $msg, $cuid;
1168  $msg->log("dom", "get_domain_all", $dom);
1169  // Locked ?
1170  if (!$this->islocked) {
1171  $msg->raise("ERROR", "dom", _("--- Program error --- No lock on the domains!"));
1172  return false;
1173  }
1174  $t = checkfqdn($dom);
1175  if ($t) {
1176  $msg->raise("ERROR", "dom", _("The domain name is syntaxically incorrect"));
1177  return false;
1178  }
1179  $r = array();
1180  $r["name"] = $dom;
1181  $db->query("SELECT * FROM domaines WHERE compte= ? AND domaine= ?;", array($cuid, $dom));
1182  if ($db->num_rows() == 0) {
1183  $msg->raise("ERROR", "dom", sprintf(_("Domain '%s' not found"), $dom));
1184  return false;
1185  }
1186  $db->next_record();
1187  $r["id"] = $db->Record["id"];
1188  $r["dns"] = $db->Record["gesdns"];
1189  $r["dns_action"] = $db->Record["dns_action"];
1190  $r["dns_result"] = $db->Record["dns_result"];
1191  $r["mail"] = $db->Record["gesmx"];
1192  $r["zonettl"] = $db->Record["zonettl"];
1193  $r['noerase'] = $db->Record['noerase'];
1194  $db->free();
1195  $db->query("SELECT COUNT(*) AS cnt FROM sub_domaines WHERE compte= ? AND domaine= ?;", array($cuid, $dom));
1196  $db->next_record();
1197  $r["nsub"] = $db->Record["cnt"];
1198  $db->free();
1199  #$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) ORDER BY sd.sub,sd.type");
1200  $db->query("SELECT sd.*, dt.description AS type_desc, dt.only_dns, dt.advanced FROM sub_domaines sd LEFT JOIN domaines_type dt on UPPER(dt.name)=UPPER(sd.type) WHERE compte= ? AND domaine= ? ORDER BY dt.advanced,sd.sub,sd.type ;", array($cuid, $dom));
1201  // Pas de webmail, on le cochera si on le trouve.
1202  $r["sub"] = array();
1203  for ($i = 0; $i < $r["nsub"]; $i++) {
1204  $db->next_record();
1205  $r["sub"][$i] = array();
1206  $r["sub"][$i]["id"] = $db->Record["id"];
1207  $r["sub"][$i]["name"] = $db->Record["sub"];
1208  $r["sub"][$i]["dest"] = $db->Record["valeur"];
1209  $r["sub"][$i]["type"] = $db->Record["type"];
1210  $r["sub"][$i]["enable"] = $db->Record["enable"];
1211  $r["sub"][$i]["type_desc"] = $db->Record["type_desc"];
1212  $r["sub"][$i]["only_dns"] = $db->Record["only_dns"];
1213  $r["sub"][$i]["web_action"] = $db->Record["web_action"];
1214  $r["sub"][$i]["advanced"] = $db->Record["advanced"];
1215  $r["sub"][$i]["fqdn"] = ((!empty($r["sub"][$i]["name"])) ? $r["sub"][$i]["name"] . "." : "") . $r["name"];
1216  }
1217  $db->free();
1218  return $r;
1219  } // get_domain_all
checkfqdn($fqdn)
Check that a domain name is fqdn compliant.
Definition: functions.php:258
global $db
Definition: bootstrap.php:22
$r
Definition: aws_add.php:75
$i
$msg
Definition: config.php:155
foreach($domaines_user as $domaine) $t
$cuid
Definition: bootstrap.php:43
$dom
Definition: whois_test.php:10
m_dom::get_domain_all_summary ( )
Returns
array

Definition at line 1720 of file m_dom.php.

References $db, and $res.

1720  {
1721  global $db;
1722  $res = array();
1723  $db->query("SELECT domaine, gesdns, gesmx, dns_action, zonettl FROM domaines ORDER BY domaine");
1724  while ($db->next_record()) {
1725  $res[$db->f("domaine")] = array(
1726  "gesdns" => $db->f("gesdns"),
1727  "gesmx" => $db->f("gesmx"),
1728  "dns_action" => $db->f("dns_action"),
1729  "zonettl" => $db->f("zonettl"),
1730  );
1731  }
1732  return $res;
1733  }
global $db
Definition: bootstrap.php:22
$res
Definition: index.php:125
m_dom::get_domain_byid (   $dom_id)

Returns the name of a domain for the current user, from it's domain_id.

Parameters
$dom_idinteger the domain_id to search for
Returns
string the domain name, or false with an error raised.

Definition at line 1740 of file m_dom.php.

References $cuid, $db, $domain, and $msg.

Referenced by hook_dom_add_mx_domain(), and set_ttl().

1740  {
1741  global $db, $msg, $cuid;
1742  $dom_id = intval($dom_id);
1743  $db->query("SELECT domaine FROM domaines WHERE id= ? AND compte= ?;", array($dom_id, $cuid));
1744  if ($db->next_record()) {
1745  $domain = $db->f("domaine");
1746  if (!$domain) {
1747  $msg->raise("ERROR", "dom", _("This domain is not installed in your account"));
1748  return false;
1749  } else {
1750  return $domain;
1751  }
1752  } else {
1753  $msg->raise("ERROR", "dom", _("This domain is not installed in your account"));
1754  return false;
1755  }
1756  }
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
$cuid
Definition: bootstrap.php:43
$domain
Definition: dom_import.php:36
m_dom::get_domain_byname (   $domain)

Returns the id of a domain for the current user, from it's domain name.

Parameters
$domainstring the domain name to search for
Returns
integer the domain id, or false with an error raised.

Definition at line 1763 of file m_dom.php.

References $cuid, $db, $domain, $id, and $msg.

Referenced by import_manual_dns_entry_doit().

1763  {
1764  global $db, $msg, $cuid;
1765  $domain = trim($domain);
1766  $db->query("SELECT id FROM domaines WHERE domaine= ? AND compte= ?;", array($domain, $cuid));
1767  if ($db->next_record()) {
1768  $id = $db->f("id");
1769  if (!$id) {
1770  $msg->raise("ERROR", "dom", _("This domain is not installed in your account"));
1771  return false;
1772  } else {
1773  return $id;
1774  }
1775  } else {
1776  $msg->raise("ERROR", "dom", _("This domain is not installed in your account"));
1777  return false;
1778  }
1779  }
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
$cuid
Definition: bootstrap.php:43
$domain
Definition: dom_import.php:36
if(!isset($is_include)) if(!$key &&!$crt) $id
m_dom::get_domain_list (   $uid = -1)

Returns the complete hosted domain list :

Definition at line 1696 of file m_dom.php.

References $db, $query, $res, and $uid.

1696  {
1697  global $db;
1698  $uid = intval($uid);
1699  $res = array();
1700  $sql = "";
1701 
1702  $query = "SELECT domaine FROM domaines WHERE gesdns=1 ";
1703  $query_args = array();
1704  if ($uid != -1) {
1705  $query .= " AND compte= ? ";
1706  array_push($query_args, $uid);
1707  }
1708  $query .= " ORDER BY domaine;";
1709  $db->query($query, $query_args);
1710  while ($db->next_record()) {
1711  $res[] = $db->f("domaine");
1712  }
1713  return $res;
1714  }
$uid
global $db
Definition: bootstrap.php:22
$query
Definition: 3.0.0~3.php:37
$res
Definition: index.php:125
m_dom::get_panel_url_list ( )

Definition at line 92 of file m_dom.php.

References $db, $msg, and $t.

92  {
93  global $db, $msg;
94  $msg->log("dom", "get_panel_url_list");
95  $db->query("SELECT sd.id as sub_id, if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) as fqdn from sub_domaines sd where type = 'PANEL';");
96  $t = array();
97  while ($db->next_record()) {
98  $t[intval($db->f('sub_id'))] = $db->f('fqdn');
99  }
100  return $t;
101  }
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
foreach($domaines_user as $domaine) $t
m_dom::get_problems (   $domain)

List if there is problems in the domains.

Problems can appear when editing domains type properties

Definition at line 2186 of file m_dom.php.

References $domain, $sub, get_domain_all(), lock(), and unlock().

2186  {
2187  $this->lock();
2188  $da = $this->get_domain_all($domain);
2189  $this->unlock();
2190 
2191  $errors = array();
2192  // Check if there is more than 1 apache conf
2193  // by subdomain
2194  $tmp = array();
2195  foreach ($da['sub'] as $sub) {
2196  if ($sub['web_action'] != 'OK') {
2197  continue;
2198  }
2199  if (!$sub['only_dns']) {
2200  if (!isset($tmp[$sub['fqdn']])) {
2201  $tmp[$sub['fqdn']] = 0;
2202  }
2203  $tmp[$sub['fqdn']] ++;
2204  if ($tmp[$sub['fqdn']] >= 2) {
2205  $errors[$sub['fqdn']] = sprintf(_("Problem on %s: there is more than 1 web configuration going to be generated for this sub-domain."), $sub['fqdn']);
2206  }
2207  }
2208  }
2209 
2210  // Check if we know each type of subdomain
2211  // Example: we may not know WEBMAIL if we upgrade from a previous setup
2212  foreach ($da['sub'] as $sub) {
2213  if (is_null($sub['type_desc'])) {
2214  $errors[$sub['fqdn']] = sprintf(_("Problem on %s: we do not know domain's type <b>%s</b>."), $sub['fqdn'], $sub['type']);
2215  }
2216  }
2217 
2218  // TODO: add a full compatibility check.
2219 
2220  return $errors;
2221  }
unlock()
Unlock the cron for domain management return true private.
Definition: m_dom.php:1863
get_domain_all($dom)
retourne TOUTES les infos d'un domaine
Definition: m_dom.php:1166
lock()
Try to lock a domain private.
Definition: m_dom.php:1844
$sub
$domain
Definition: dom_import.php:36
m_dom::get_sub_domain_all (   $sub_domain_id)

Retourne TOUTES les infos d'un sous domaine du compte courant.

Parameters
integersub_domain_id id du subdomain
Returns
array Retourne un tableau associatif contenant les informations du sous-domaine demandé.
 $r["name"]= nom du sous-domaine (NON-complet)
 $r["dest"]= Destination (url, ip, local ...)
 
$r["type"]= Type (0-n) de la redirection. Retourne FALSE si une erreur s'est produite.

Definition at line 1234 of file m_dom.php.

References $cuid, $db, $msg, and $r.

Referenced by del_sub_domain(), and sub_domain_change_status().

1234  {
1235  global $db, $msg, $cuid;
1236  $msg->log("dom", "get_sub_domain_all", $sub_domain_id);
1237  // Locked ?
1238  if (!$this->islocked) {
1239  $msg->raise("ERROR", "dom", _("--- Program error --- No lock on the domains!"));
1240  return false;
1241  }
1242  $db->query("select sd.*, dt.description as type_desc, dt.only_dns, dt.advanced from sub_domaines sd, domaines_type dt where compte= ? and sd.id= ? and upper(dt.name)=upper(sd.type) ORDER BY dt.advanced, sd.sub;", array($cuid, $sub_domain_id));
1243  if ($db->num_rows() == 0) {
1244  $msg->raise("ERROR", "dom", _("The sub-domain does not exist"));
1245  return false;
1246  }
1247  $db->next_record();
1248  $r = array();
1249  $r["id"] = $db->Record["id"];
1250  $r["name"] = $db->Record["sub"];
1251  $r["domain"] = $db->Record["domaine"];
1252  $r["dest"] = $db->Record["valeur"];
1253  $r["enable"] = $db->Record["enable"];
1254  $r["type"] = $db->Record["type"];
1255  $r["type_desc"] = $db->Record["type_desc"];
1256  $r["only_dns"] = $db->Record["only_dns"];
1257  $r["web_action"] = $db->Record["web_action"];
1258  $db->free();
1259  return $r;
1260  } // get_sub_domain_all
global $db
Definition: bootstrap.php:22
$r
Definition: aws_add.php:75
$msg
Definition: config.php:155
$cuid
Definition: bootstrap.php:43
static m_dom::get_sub_domain_id_and_member_by_name (   $fqdn)
static
Parameters
string$fqdn

Definition at line 107 of file m_dom.php.

References $db, and $msg.

107  {
108  global $db, $msg;
109  $msg->log("dom", "get_sub_domain_by_name");
110  $db->query("select sd.* from sub_domaines sd where if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) = ?;", array($fqdn));
111  if (!$db->next_record()) {
112  return false;
113  }
114  return array('sub_id' => intval($db->f('id')), 'member_id' => intval($db->f('compte')));
115  }
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
m_dom::hook_dom_add_mx_domain (   $dom_id)

Declare that a domain's emails are hosted in this server : This adds 2 MX entries in this domain (if required)

Definition at line 1878 of file m_dom.php.

References $domain, $msg, get_domain_byid(), and set_sub_domain().

1878  {
1879  global $msg;
1880  $domain = $this->get_domain_byid($dom_id);
1881  $msg->log("dom", "hook_dom_add_mx_domain");
1882  $this->set_sub_domain($domain, '', $this->type_defmx, '');
1883  if (!empty($GLOBALS['L_DEFAULT_SECONDARY_MX'])) {
1884  $this->set_sub_domain($domain, '', $this->type_defmx2, '');
1885  }
1886  return true;
1887  }
set_sub_domain($dom, $sub, $type, $dest, $sub_domain_id=0)
Modifier les information du sous-domaine demandé.
Definition: m_dom.php:1389
$msg
Definition: config.php:155
$domain
Definition: dom_import.php:36
get_domain_byid($dom_id)
Returns the name of a domain for the current user, from it's domain_id.
Definition: m_dom.php:1740
m_dom::hook_menu ( )

hook function called by the menu class to add menu to the left panel

Definition at line 122 of file m_dom.php.

References $d, and enum_domains().

122  {
123  global $quota;
124  $obj = array(
125  'title' => _("Domains"),
126  'ico' => 'images/dom.png',
127  'link' => 'toggle',
128  'pos' => 20,
129  'links' => array(),
130  );
131 
132  if ($quota->cancreate("dom")) {
133  $obj['links'][] = array(
134  'ico' => 'images/new.png',
135  'txt' => _("Add a domain"),
136  'url' => "dom_add.php",
137  );
138  }
139 
140  foreach ($this->enum_domains() as $d) {
141  $obj['links'][] = array(
142  'txt' => htmlentities($d),
143  'url' => "dom_edit.php?domain=" . urlencode($d),
144  );
145  }
146 
147  return $obj;
148  }
enum_domains($uid=-1)
Retourne un tableau contenant les domaines d'un membre.
Definition: m_dom.php:605
$d
m_dom::hook_quota_get ( )

Returns the used quota for the $name service for the current user.

Parameters
$namestring name of the quota
Returns
integer the number of service used or false if an error occured private

Definition at line 1910 of file m_dom.php.

References $cuid, $db, $msg, and $q.

1910  {
1911  global $db, $msg, $cuid;
1912  $msg->log("dom", "get_quota");
1913  $q = Array("name" => "dom", "description" => _("Domain name"), "used" => 0);
1914  $db->query("SELECT COUNT(*) AS cnt FROM domaines WHERE compte= ?", array($cuid));
1915  if ($db->next_record()) {
1916  $q['used'] = $db->f("cnt");
1917  }
1918  return $q;
1919  }
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
$cuid
Definition: bootstrap.php:43
m_dom::import_manual_dns_entry (   $zone,
  $domain,
  $detect_redirect = true,
  $save = false 
)
Parameters
string$zone

Definition at line 240 of file m_dom.php.

References $domain, $msg, $val, import_manual_dns_entry_doit(), and is_it_a_redirect().

Referenced by import_manual_dns_zone().

240  {
241  global $msg;
242  $msg->log("dom", "import_manual_dns_entry");
243  $zone = trim($zone);
244  if (empty($zone)) {
245  return false;
246  }
247 
248  $domain = trim($domain);
249  if (empty($domain)) {
250  $msg->raise("ERROR", "dom", _("Missing domain name"));
251  return false;
252  }
253 
254  $val = array(
255  'status' => 'err', // can be 'ok', 'err', 'warn'
256  'comment' => 'no val',
257  'entry_old' => $zone,
258  'entry_new' => array('domain' => $domain),
259  );
260 
261  // Examples:
262  // ; hello comment
263  if (preg_match('/^;/', $zone, $ret)) {
264  $val['status'] = 'ok';
265  $val['comment'] = 'Just a comment, do not import';
266  } else
267  // Examples:
268  // $TTL 86400'
269  if (preg_match('/^\$TTL\h+(?P<ttl>[\dMHDmhd]+)/', $zone, $ret)) {
270  $val['status'] = 'ok';
271  $val['comment'] = 'Set TTL to ' . $ret['ttl'];
272  $val['entry_new']['type'] = 'set_ttl';
273  $val['entry_new']['value'] = $ret['ttl'];
274  } else
275 
276  // Examples:
277  // @ IN AAAA 127.2.1.5
278  // reseau IN AAAA 145.214.44.55
279  if (preg_match('/^(?P<sub>[\w\.@\-]*)\h*(?P<ttl>\d*)\h*IN\h+AAAA\h+(?P<target>[0-9A-F:]{2,40})/i', $zone, $ret)) {
280 
281  // Check if it is just a redirect
282  if (substr($ret['sub'], -1) == '.') { // if ending by a "." it is allready a FQDN
283  $url = "http://" . $ret['sub'];
284  } else {
285  if ($ret['sub'] == '@' || empty($ret['sub'])) {
286  $url = "http://" . $domain;
287  } else {
288  $url = "http://" . $ret['sub'] . "." . $domain;
289  }
290  }
291  if ($detect_redirect && $dst_url = $this->is_it_a_redirect($url)) {
292  $val['status'] = 'warn';
293  $val['comment'] = "Became a redirect to $dst_url";
294  $val['entry_new']['type'] = 'URL';
295  $val['entry_new']['sub'] = $ret['sub'];
296  $val['entry_new']['value'] = $dst_url;
297  } else {
298  $val['status'] = 'ok';
299  $val['comment'] = "Create entry AAAA with " . $ret['sub'] . " go to " . $ret['target'] . " with ttl " . $ret['ttl'];
300  $val['entry_new']['type'] = 'IPV6';
301  $val['entry_new']['sub'] = $ret['sub'];
302  $val['entry_new']['value'] = $ret['target'];
303  }
304  } else
305 
306 
307  // Examples:
308  // @ IN A 127.2.1.5
309  // reseau IN A 145.214.44.55
310  if (preg_match('/^(?P<sub>[\w\.@\-]*)\h*(?P<ttl>\d*)\h*IN\h+A\h+(?P<target>\d+\.\d+\.\d+\.\d+)/i', $zone, $ret)) {
311  // Check if it is just a redirect
312  if (substr($ret['sub'], -1) == '.') { // if ending by a "." it is allready a FQDN
313  $url = "http://" . $ret['sub'];
314  } else {
315  if ($ret['sub'] == '@' || empty($ret['sub'])) {
316  $url = "http://" . $domain;
317  } else {
318  $url = "http://" . $ret['sub'] . "." . $domain;
319  }
320  }
321  if ($detect_redirect && $dst_url = $this->is_it_a_redirect($url)) {
322  $val['status'] = 'warn';
323  $val['comment'] = "Became a redirect to $dst_url";
324  $val['entry_new']['type'] = 'URL';
325  $val['entry_new']['sub'] = $ret['sub'];
326  $val['entry_new']['value'] = $dst_url;
327  } else {
328  $val['status'] = 'ok';
329  $val['comment'] = "Create entry A with " . $ret['sub'] . " go to " . $ret['target'] . " with ttl " . $ret['ttl'];
330  $val['entry_new']['type'] = 'IP';
331  $val['entry_new']['sub'] = $ret['sub'];
332  $val['entry_new']['value'] = $ret['target'];
333  }
334  } else
335 
336  // Examples:
337  // @ IN NS ns.example.tld.
338  // ns 3600 IN NS 145.214.44.55
339  if (preg_match('/^(?P<sub>[\-\w\.@]*)\h*(?P<ttl>\d*)\h*IN\h+NS\h+(?P<target>[\w\.\-]+)/i', $zone, $ret)) {
340  if (empty($ret['sub']) || $ret['sub'] == '@') {
341  $val['status'] = 'warn';
342  $val['comment'] = "Won't migrate it, there will get a new value";
343  } else {
344  $val['status'] = 'ok';
345  $val['comment'] = "Create entry NS with " . $ret['sub'] . " go to " . $ret['target'] . " with ttl " . $ret['ttl'];
346  $val['entry_new']['type'] = 'FIXME-NS';
347  $val['entry_new']['sub'] = $ret['sub'];
348  $val['entry_new']['value'] = $ret['target'];
349  }
350  } else
351 
352  // Examples:
353  // agenda IN CNAME ghs.google.com.
354  // www 3600 IN CNAME @
355  if (preg_match('/^(?P<sub>[\-\w\.@]*)\h*(?P<ttl>\d*)\h*IN\h+CNAME\h+(?P<target>[@\w+\.\-]+)/i', $zone, $ret)) {
356  if (substr($ret['sub'], -1) == '.') { // if ending by a "." it is allready a FQDN
357  $url = "http://" . $ret['sub'];
358  } else {
359  if ($ret['sub'] == '@' || empty($ret['sub'])) {
360  $url = "http://" . $domain;
361  } else {
362  $url = "http://" . $ret['sub'] . "." . $domain;
363  }
364  }
365  if ($detect_redirect && $dst_url = $this->is_it_a_redirect($url)) {
366  $val['status'] = 'warn';
367  $val['comment'] = "Became a redirect to $dst_url";
368  $val['entry_new']['type'] = 'URL';
369  $val['entry_new']['sub'] = $ret['sub'];
370  $val['entry_new']['value'] = $dst_url;
371  } else {
372  $val['status'] = 'ok';
373  $val['comment'] = "Create entry CNAME with " . $ret['sub'] . " go to " . $ret['target'] . " with ttl " . $ret['ttl'];
374  $val['entry_new']['type'] = 'CNAME';
375  $val['entry_new']['sub'] = $ret['sub'];
376  $val['entry_new']['value'] = $ret['target'];
377  }
378  } else
379 
380  // Examples:
381  // @ IN MX 10 aspmx.l.google.com.
382  // arf 3600 IN MX 20 pouet.fr.
383  if (preg_match('/^(?P<sub>[\-\w\.@]*)\h*(?P<ttl>\d*)\h*IN\h+MX\h+(?P<weight>\d+)\h+(?P<target>[@\w+\.\-]+)/i', $zone, $ret)) {
384  $val['status'] = 'warn';
385  $val['comment'] = "Create entry MX with " . $ret['sub'] . " go to " . $ret['target'] . " with ttl " . $ret['ttl'] . " and weight 5 (initial weight was " . $ret['weight'] . ")";
386  $val['entry_new']['type'] = 'MX';
387  $val['entry_new']['sub'] = $ret['sub'];
388  $val['entry_new']['value'] = $ret['target'];
389  } else
390 
391  // Examples:
392  // _sip._tcp IN SRV 1 100 5061 sip.example.tld.
393  if (preg_match('/^(?P<sub>[\_\w\.@\-]+)\h+(?P<ttl>\d*)\h*IN\h+SRV\h+/i', $zone, $ret)) {
394  $val['status'] = 'err';
395  $val['comment'] = "Please add yourself the entry $zone";
396  } else
397 
398  // Examples:
399  // @ IN TXT "google-site-verification=jjjjjjjjjjjjjjjjjjjjjjjjsdsdjlksjdljdslgNj5"
400  if (preg_match('/^(?P<sub>[\_\w\.@\-]*)\h*(?P<ttl>\d*)\h*IN\h+TXT\h+\"(?P<target>.+)\"/i', $zone, $ret)) {
401  $val['status'] = 'ok';
402  $val['comment'] = "Create TXT entry with " . $ret['sub'] . " go to " . $ret['target'];
403  $val['entry_new']['type'] = 'TXT';
404  $val['entry_new']['sub'] = $ret['sub'];
405  $val['entry_new']['value'] = $ret['target'];
406  } else {
407 
408  // WTF can it be ?
409  $val['comment'] = "Unknow: $zone";
410  }
411 
412  if ($save) {
413  return $this->import_manual_dns_entry_doit($val);
414  }
415 
416  return $val;
417  }
$val
Definition: tempovars.php:15
$msg
Definition: config.php:155
$domain
Definition: dom_import.php:36
is_it_a_redirect($url)
Definition: m_dom.php:493
import_manual_dns_entry_doit($entry)
Definition: m_dom.php:420
m_dom::import_manual_dns_entry_doit (   $entry)
private

Definition at line 420 of file m_dom.php.

References $val, domains_type_lst(), get_domain_byname(), lock(), set_sub_domain(), set_ttl(), and unlock().

Referenced by import_manual_dns_entry().

420  {
421  $entry['did_it'] = 0;
422  if ($entry['status'] == 'err') {
423  return $entry;
424  }
425 
426  $val = $entry['entry_new'];
427 
428  if (empty($val['type'])) {
429  return false;
430  }
431 
432  switch ($val['type']) {
433  case "set_ttl":
434  $entry['did_it'] = $this->set_ttl($this->get_domain_byname($val['domain']), $val['value']);
435  return $entry;
436  }
437 
438  // If it is an unknown domains type
439  if (!array_key_exists(strtolower($val['type']), $this->domains_type_lst())) {
440  echo "what is this shit ?\n";
441  print_r($entry);
442  return $entry;
443  }
444 
445  // If the subdomain is @, we want an empty subdomain
446  if ($val['sub'] == '@') {
447  $val['sub'] = '';
448  }
449 
450  $this->lock();
451  $entry['did_it'] = $this->set_sub_domain($val['domain'], $val['sub'], $val['type'], $val['value']);
452  $this->unlock();
453 
454  return $entry;
455  }
$val
Definition: tempovars.php:15
get_domain_byname($domain)
Returns the id of a domain for the current user, from it's domain name.
Definition: m_dom.php:1763
unlock()
Unlock the cron for domain management return true private.
Definition: m_dom.php:1863
set_sub_domain($dom, $sub, $type, $dest, $sub_domain_id=0)
Modifier les information du sous-domaine demandé.
Definition: m_dom.php:1389
set_ttl($dom_id, $ttl)
Definition: m_dom.php:1497
domains_type_lst()
Retourne un tableau contenant les types de domaines.
Definition: m_dom.php:157
lock()
Try to lock a domain private.
Definition: m_dom.php:1844
m_dom::import_manual_dns_prep_zone (   $domain)
private

Definition at line 458 of file m_dom.php.

References $d, $domain, $msg, add_domain(), del_sub_domain(), edit_domain(), get_domain_all(), lock(), and unlock().

Referenced by import_manual_dns_zone().

458  {
459  global $msg;
460  // Prepare a domain to be importer :
461  // * create the domain
462  // * delete all automatic subdomain
463  // * set no mx
464  $this->lock();
465 
466  // function add_domain($domain,$dns,$noerase=0,$force=0,$isslave=0,$slavedom="")
467  if (!$this->add_domain($domain, true, false, true)) {
468  $msg->raise("ERROR", 'dom', "Error adding domain");
469  return false;
470  }
471 
472  // Set no mx
473  $this->edit_domain($domain, true, false);
474 
475  $d = $this->get_domain_all($domain);
476  foreach ($d['sub'] as $sd) {
477  $this->del_sub_domain($sd['id']);
478  }
479 
480  $this->unlock();
481 
482  return true;
483  }
edit_domain($dom, $dns, $gesmx, $force=false, $ttl=86400)
Modifie les information du domaine précisé.
Definition: m_dom.php:1522
unlock()
Unlock the cron for domain management return true private.
Definition: m_dom.php:1863
get_domain_all($dom)
retourne TOUTES les infos d'un domaine
Definition: m_dom.php:1166
$msg
Definition: config.php:155
add_domain($domain, $dns, $noerase=false, $force=false, $isslave=false, $slavedom="")
Installe un domaine sur le compte courant.
Definition: m_dom.php:694
del_sub_domain($sub_domain_id)
Supprime le sous-domaine demandé
Definition: m_dom.php:1475
lock()
Try to lock a domain private.
Definition: m_dom.php:1844
$domain
Definition: dom_import.php:36
$d
m_dom::import_manual_dns_zone (   $zone,
  $domain,
  $detect_redirect = true,
  $save = false 
)

Definition at line 216 of file m_dom.php.

References $domain, $msg, $val, import_manual_dns_entry(), and import_manual_dns_prep_zone().

216  {
217  global $msg;
218  if ($save) {
219  if (!$this->import_manual_dns_prep_zone($domain)) {
220  $msg->raise("ERROR", 'dom', _("Err: failed to prepare the zone"));
221  return false;
222  }
223  }
224 
225  $val = array();
226  foreach (explode("\n", $zone) as $z) {
227  $z = trim($z);
228  if (empty($z)) {
229  continue;
230  }
231  $val[] = $this->import_manual_dns_entry($z, $domain, $detect_redirect, $save);
232  }
233  return $val;
234  }
$val
Definition: tempovars.php:15
$msg
Definition: config.php:155
import_manual_dns_entry($zone, $domain, $detect_redirect=true, $save=false)
Definition: m_dom.php:240
import_manual_dns_prep_zone($domain)
Definition: m_dom.php:458
$domain
Definition: dom_import.php:36
m_dom::is_it_a_redirect (   $url)
Parameters
string$url

Definition at line 493 of file m_dom.php.

Referenced by import_manual_dns_entry().

493  {
494  try {
495  $params = array('http' => array(
496  'method' => 'HEAD',
497  'ignore_errors' => true
498  ));
499 
500  $context = stream_context_create($params);
501  $fp = @fopen($url, 'rb', false, $context);
502  $result = @stream_get_contents($fp);
503 
504  if ($result === false) {
505  throw new Exception("Could not read data from {$url}");
506  }
507  if (strstr($http_response_header[0], '301') || strstr($http_response_header[0], '302')) {
508  // This is a redirection
509  if (preg_match('/Location:\h+(?P<target>[\-\w:\/.\?\=.]+)/', implode("\n", $http_response_header), $ret)) {
510  // check if it is a redirection to himself
511  preg_match('/\/\/(?P<host>[\w\.\-]+)\//', ( substr($url, -1) == '/' ? $url : $url . '/'), $original_cname);
512  preg_match('/\/\/(?P<host>[\w\.\-]+)\//', $ret['target'], $target_url);
513  if (isset($target_url['host']) && ( $target_url['host'] == $original_cname['host'] )) { // if it's a redirection to himself (sub pages, http to https...)
514  return false; // do not do a redirection (we must point to the server)
515  }
516 
517  // If it is a redirection to a sub directory
518  // (we know it is a redirection to a sub directory because it's not a complete URI)
519  if (substr($ret['target'], 0, 4) != 'http') {
520  return 'http://' . $original_cname['host'] . '/' . $ret['target'];
521  }
522  return $ret['target'];
523  }
524  } else { // it isn't a redirection
525  return false;
526  }
527  } catch (Exception $e) {
528  return false;
529  }
530  }
m_dom::lock ( )

Try to lock a domain private.

Definition at line 1844 of file m_dom.php.

References $msg.

Referenced by alternc_export_conf(), del_domain(), get_problems(), import_manual_dns_entry_doit(), import_manual_dns_prep_zone(), and set_ttl().

1844  {
1845  global $msg;
1846  $msg->log("dom", "lock");
1847  if ($this->islocked) {
1848  $msg->raise("ERROR", "dom", _("--- Program error --- Lock already obtained!"));
1849  }
1850  while (file_exists($this->fic_lock_cron)) {
1851  sleep(2);
1852  }
1853  $this->islocked = true;
1854  return true;
1855  }
$msg
Definition: config.php:155
m_dom::lst_default_subdomains ( )

Definition at line 857 of file m_dom.php.

References $c, $db, and $msg.

857  {
858  global $db, $msg;
859  $msg->log("dom", "lst_default_subdomains");
860  $c = array();
861  $db->query("select * from default_subdomains;");
862 
863  while ($db->next_record()) {
864  $c[] = array('id' => $db->f('id'),
865  'sub' => $db->f('sub'),
866  'domain_type' => $db->f('domain_type'),
867  'domain_type_parameter' => $db->f('domain_type_parameter'),
868  'concerned' => $db->f('concerned'),
869  'enabled' => $db->f('enabled')
870  );
871  }
872 
873  return $c;
874  }
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
$c
Definition: bootstrap.php:47
m_dom::m_dom ( )

Constructeur.

Definition at line 85 of file m_dom.php.

References variable_get().

85  {
86  global $L_FQDN;
87  $this->tld_no_check_at_all = variable_get('tld_no_check_at_all', 0, 'Disable ALL check on the TLD (users will be able to add any domain)', array('desc' => 'Disabled', 'type' => 'boolean'));
88  variable_get('mailname_bounce', $L_FQDN, 'FQDN of the mail server, used to create vhost virtual mail_adress.', array('desc' => 'FQDN', 'type' => 'string'));
89  }
variable_get($name, $default=null, $createit_comment=null)
Return a persistent variable.
Definition: variables.php:85
m_dom::set_dns_action (   $domain,
  $dns_action 
)
Parameters
string$dns_action

Definition at line 2168 of file m_dom.php.

References $db, and $domain.

Referenced by del_domain(), del_domain_cancel(), edit_domain(), and sub_domain_change_status().

2168  {
2169  global $db;
2170  $db->query("UPDATE domaines SET dns_action= ? WHERE domaine= ?; ", array($dns_action, $domain));
2171  return true;
2172  }
global $db
Definition: bootstrap.php:22
$domain
Definition: dom_import.php:36
m_dom::set_dns_result (   $domain,
  $dns_result 
)

Definition at line 2175 of file m_dom.php.

References $db, and $domain.

2175  {
2176  global $db;
2177  $db->query("UPDATE domaines SET dns_result= ? WHERE domaine= ?; ", array($dns_result, $domain));
2178  return true;
2179  }
global $db
Definition: bootstrap.php:22
$domain
Definition: dom_import.php:36
m_dom::set_sub_domain (   $dom,
  $sub,
  $type,
  $dest,
  $sub_domain_id = 0 
)

Modifier les information du sous-domaine demandé.

Note : si le sous-domaine $sub.$dom n'existe pas, il est créé.
Note : TODO : vérification de concordance de $dest

Parameters
string$domDomaine dont on souhaite modifier/ajouter un sous domaine
string$subSous domaine é modifier / créer
integer$typeType de sous-domaine (local, ip, url ...)
string$destDestination du sous-domaine, dépend de la valeur de $type (url, ip, dossier...)
Returns
boolean Retourne FALSE si une erreur s'est produite, TRUE sinon.

Definition at line 1389 of file m_dom.php.

References $bro, $cuid, $db, $dom, $msg, $sub, $t, can_create_subdomain(), check_type_value(), checkfqdn(), and del_sub_domain().

Referenced by create_default_subdomains(), hook_dom_add_mx_domain(), and import_manual_dns_entry_doit().

1389  {
1390  global $db, $msg, $cuid, $bro;
1391  $msg->log("dom", "set_sub_domain", $dom . "/" . $sub . "/" . $type . "/" . $dest);
1392  // Locked ?
1393  if (!$this->islocked) {
1394  $msg->raise("ERROR", "dom", _("--- Program error --- No lock on the domains!"));
1395  return false;
1396  }
1397  $dest = trim($dest);
1398  $sub = trim(trim($sub), ".");
1399  $dom = strtolower($dom);
1400  $sub = strtolower($sub);
1401 
1402  // if (!(($sub == '*') || ($sub=="") || (preg_match('/([a-z0-9][\.\-a-z0-9]*)?[a-z0-9]/', $sub)))) {
1403  $fqdn = checkfqdn($sub);
1404  // Special cases : * (all subdomains at once) and '' empty subdomain are allowed.
1405  if (($sub != '*' && $sub != '') && !($fqdn == 0 || $fqdn == 4)) {
1406  $msg->raise("ALERT", "dom", _("There is some forbidden characters in the sub domain (only A-Z 0-9 and - are allowed)"));
1407  return false;
1408  }
1409 
1410  if (!$this->check_type_value($type, $dest)) {
1411  //plutot verifier si la chaine d'erreur est vide avant de raise sinon sa veut dire que l(erruer est deja remonté
1412  // error raised by check_type_value
1413  return false;
1414  }
1415 
1416  // On a épuré $dir des problémes eventuels ... On est en DESSOUS du dossier de l'utilisateur.
1417  if (($t = checkfqdn($dom))) {
1418  $msg->raise("ERROR", "dom", _("The domain name is syntaxically incorrect"));
1419  return false;
1420  }
1421 
1422  if (!$this->can_create_subdomain($dom, $sub, $type, $sub_domain_id)) {
1423  $msg->raise("ERROR", "dom", _("The parameters for this subdomain and domain type are invalid. Please check for subdomain entries incompatibility"));
1424  return false;
1425  }
1426 
1427  if ($sub_domain_id!=0) { // It's not a creation, it's an edit. Delete the old one
1428  $this->del_sub_domain($sub_domain_id);
1429  }
1430 
1431  // Re-create the one we want
1432  if (!$db->query("INSERT INTO sub_domaines (compte,domaine,sub,valeur,type,web_action) VALUES (?, ?, ?, ?, ?, 'UPDATE');", array( $cuid , $dom , $sub , $dest , $type ))) {
1433  echo "query failed: " . $db->Error;
1434  return false;
1435  }
1436 
1437  // Create TMP dir and TARGET dir if needed by the domains_type
1438  $dest_root = $bro->get_userid_root($cuid);
1439  //$domshort = $this->domshort($dom, $sub);
1440  $db->query("select create_tmpdir, create_targetdir from domaines_type where name = ?;", array($type));
1441  $db->next_record();
1442  if ($db->f('create_tmpdir')) {
1443  if (!is_dir($dest_root . "/tmp")) {
1444  if (!@mkdir($dest_root . "/tmp", 0777, true)) {
1445  $msg->raise("ERROR", "dom", _("Cannot write to the destination folder"));
1446  }
1447  }
1448  }
1449  if ($db->f('create_targetdir')) {
1450  $dirr = $dest_root . $dest;
1451  $dirr = str_replace('//', '/', $dirr);
1452 
1453  if (!is_dir($dirr)) {
1454  $old = umask(0);
1455  if (!@mkdir($dirr, 0770, true)) {
1456  $msg->raise("ERROR", "dom", _("Cannot write to the destination folder"));
1457  }
1458  umask($old);
1459  }
1460  }
1461 
1462  // Tell to update the DNS file
1463  $db->query("update domaines set dns_action='UPDATE' where domaine= ?;", array($dom));
1464 
1465  return true;
1466  }
checkfqdn($fqdn)
Check that a domain name is fqdn compliant.
Definition: functions.php:258
$bro
Definition: bootstrap.php:151
global $db
Definition: bootstrap.php:22
check_type_value($type, $value)
Definition: m_dom.php:1267
$msg
Definition: config.php:155
foreach($domaines_user as $domaine) $t
del_sub_domain($sub_domain_id)
Supprime le sous-domaine demandé
Definition: m_dom.php:1475
$cuid
Definition: bootstrap.php:43
can_create_subdomain($dom, $sub, $type, $sub_domain_id=0)
Check the compatibility of the POSTed parameters with the chosen domain type.
Definition: m_dom.php:1344
$sub
$dom
Definition: whois_test.php:10
m_dom::set_ttl (   $dom_id,
  $ttl 
)
Parameters
integer$dom_id

Definition at line 1497 of file m_dom.php.

References $d, $msg, edit_domain(), get_domain_all(), get_domain_byid(), lock(), and unlock().

Referenced by import_manual_dns_entry_doit().

1497  {
1498  global $msg;
1499  $msg->log("dom", "set_ttl", "$dom_id / $ttl");
1500  $this->lock();
1501  $domaine = $this->get_domain_byid($dom_id);
1502  $d = $this->get_domain_all($domaine);
1503 
1504  $j = $this->edit_domain($domaine, $d['dns'], $d['mail'], false, $ttl);
1505  $this->unlock();
1506  return $j;
1507  }
edit_domain($dom, $dns, $gesmx, $force=false, $ttl=86400)
Modifie les information du domaine précisé.
Definition: m_dom.php:1522
unlock()
Unlock the cron for domain management return true private.
Definition: m_dom.php:1863
get_domain_all($dom)
retourne TOUTES les infos d'un domaine
Definition: m_dom.php:1166
$msg
Definition: config.php:155
lock()
Try to lock a domain private.
Definition: m_dom.php:1844
get_domain_byid($dom_id)
Returns the name of a domain for the current user, from it's domain_id.
Definition: m_dom.php:1740
$d
m_dom::sub_domain_change_status (   $sub_id,
  $status 
)

Definition at line 573 of file m_dom.php.

References $db, $msg, can_create_subdomain(), get_sub_domain_all(), and set_dns_action().

573  {
574  global $db, $msg;
575  $msg->log("dom", "sub_domain_change_status");
576  $sub_id = intval($sub_id);
577  $status = strtoupper($status);
578  if (!in_array($status, array('ENABLE', 'DISABLE'))) {
579  return false;
580  }
581 
582  $jh = $this->get_sub_domain_all($sub_id);
583  if ($status == 'ENABLE') { // check compatibility with existing sub_domains
584  if (!$this->can_create_subdomain($jh['domain'], $jh['name'], $jh['type'], $sub_id)) {
585  $msg->raise("ERROR", "dom", _("The parameters for this subdomain and domain type are invalid. Please check for subdomain entries incompatibility"));
586  return false;
587  }
588  }
589 
590  $db->query("update sub_domaines set enable= ? where id = ? ;", array($status, intval($sub_id)));
591  $this->set_dns_action($jh['domain'], 'UPDATE');
592 
593  return true;
594  }
global $db
Definition: bootstrap.php:22
$msg
Definition: config.php:155
can_create_subdomain($dom, $sub, $type, $sub_domain_id=0)
Check the compatibility of the POSTed parameters with the chosen domain type.
Definition: m_dom.php:1344
get_sub_domain_all($sub_domain_id)
Retourne TOUTES les infos d'un sous domaine du compte courant.
Definition: m_dom.php:1234
set_dns_action($domain, $dns_action)
Definition: m_dom.php:2168
m_dom::subdomain_modif_are_done (   $sub_domain_id,
  $action 
)

Definition at line 2150 of file m_dom.php.

References $db.

2150  {
2151  global $db;
2152  $sub_domain_id = intval($sub_domain_id);
2153  switch (strtolower($action)) {
2154  case "delete":
2155  $sql = "DELETE FROM sub_domaines WHERE id =$sub_domain_id;";
2156  break;
2157  default:
2158  $sql = "UPDATE sub_domaines SET web_action='OK' WHERE id='$sub_domain_id'; ";
2159  }
2160  $db->query($sql);
2161  return true;
2162  }
global $db
Definition: bootstrap.php:22
m_dom::unlock ( )

Unlock the cron for domain management return true private.

Definition at line 1863 of file m_dom.php.

References $msg.

Referenced by alternc_export_conf(), del_domain(), get_problems(), import_manual_dns_entry_doit(), import_manual_dns_prep_zone(), and set_ttl().

1863  {
1864  global $msg;
1865  $msg->log("dom", "unlock");
1866  if (!$this->islocked) {
1867  $msg->raise("ERROR", "dom", _("--- Program error --- No lock on the domains!"));
1868  }
1869  $this->islocked = false;
1870  return true;
1871  }
$msg
Definition: config.php:155
m_dom::update_default_subdomains (   $arr)

Definition at line 877 of file m_dom.php.

References $msg, $ok, null, and update_one_default().

877  {
878  global $msg;
879  $msg->log("dom", "update_default_subdomains");
880  $ok = true;
881  foreach ($arr as $a) {
882  if (!isset($a['id'])) {
883  $a['id'] = null;
884  }
885  if (!empty($a['sub']) || !empty($a['domain_type_parameter'])) {
886 
887  if (!isset($a['enabled'])) {
888  $a['enabled'] = 0;
889  }
890  if (!$this->update_one_default($a['domain_type'], $a['sub'], $a['domain_type_parameter'], $a['concerned'], $a['enabled'], $a['id'])) {
891  $ok = false;
892  }
893  }
894  }
895  return $ok;
896  }
update_one_default($domain_type, $sub, $domain_type_parameter, $concerned, $enabled, $id=null)
Definition: m_dom.php:899
PR null
Definition: lang-css.js:1
$msg
Definition: config.php:155
if(!isset($delete)) $ok
Definition: ssl_delete.php:41
m_dom::update_one_default (   $domain_type,
  $sub,
  $domain_type_parameter,
  $concerned,
  $enabled,
  $id = null 
)

Definition at line 899 of file m_dom.php.

References $db, $id, $msg, $sub, and null.

Referenced by update_default_subdomains().

899  {
900  global $db, $msg;
901  $msg->log("dom", "update_one_default");
902 
903  if ($id == null) {
904  $db->query("INSERT INTO default_subdomains values ('', ?, ?, ?, ?, ?);", array($sub, $domain_type, $domain_type_parameter, $concerned, $enabled));
905  } else {
906  $db->query("UPDATE default_subdomains set sub= ?, domain_type= ?, domain_type_parameter= ?, concerned= ?, enabled= ? where id= ?;", array($sub, $domain_type, $domain_type_parameter, $concerned, $enabled, $id));
907  }
908  return true;
909  //update
910  }
global $db
Definition: bootstrap.php:22
PR null
Definition: lang-css.js:1
$msg
Definition: config.php:155
$sub
if(!isset($is_include)) if(!$key &&!$crt) $id
m_dom::whois (   $domain)

Retourne les entrées DNS du domaine $domain issues du WHOIS.

Cette fonction effectue un appel WHOIS($domain) sur Internet, et extrait du whois les serveurs DNS du domaine demandé. En fonction du TLD, on sait (ou pas) faire le whois correspondant. Actuellement, les tld suivants sont supportés : .com .net .org .be .info .ca .cx .fr .biz .name

Parameters
string$domainDomaine fqdn dont on souhaite les serveurs DNS
Returns
array Retourne un tableau indexé avec les NOMS fqdn des dns du domaine demandé. Retourne FALSE si une erreur s'est produite.

Definition at line 940 of file m_dom.php.

References $domain, $found, $msg, and elseif.

Referenced by add_domain(), and edit_domain().

940  {
941  global $msg;
942  $msg->log("dom", "whois", $domain);
943  // pour ajouter un nouveau TLD, utiliser le code ci-dessous.
944  // echo "whois : $domain<br />";
945  preg_match("#.*\.([^\.]*)#", $domain, $out);
946  $ext = $out[1];
947  // pour ajouter un nouveau TLD, utiliser le code ci-dessous.
948  // echo "ext: $ext<br />";
949 
950  $serveur = "";
951  if (($fp = @fsockopen("whois.iana.org", 43)) > 0) {
952  fputs($fp, "$domain\r\n");
953  $found = false;
954  $state = 0;
955  while (!feof($fp)) {
956  $ligne = fgets($fp, 128);
957  if (preg_match('#^whois:#', $ligne)) {
958  $serveur = preg_replace('/whois:\ */', '', $ligne, 1);
959  }
960  }
961  }
962  $serveur = str_replace(array(" ", "\n"), "", $serveur);
963 
964  $egal = "";
965  switch ($ext) {
966  case "net":
967  $egal = "=";
968  break;
969  case "name":
970  $egal = "domain = ";
971  break;
972  }
973  $serveurList = array();
974  // pour ajouter un nouveau TLD, utiliser le code ci-dessous.
975  // echo "serveur : $serveur <br />";
976  if (($fp = @fsockopen($serveur, 43)) > 0) {
977  fputs($fp, "$egal$domain\r\n");
978  $found = false;
979  $state = 0;
980  while (!feof($fp)) {
981  $ligne = fgets($fp, 128);
982  // pour ajouter un nouveau TLD, utiliser le code ci-dessous.
983  // echo "| $ligne<br />";
984  switch ($ext) {
985  case "org":
986  case "com":
987  case "net":
988  case "info":
989  case "biz":
990  case "name":
991  case "cc":
992  if (preg_match("#Name Server:#", $ligne)) {
993  $found = true;
994  $tmp = strtolower(str_replace(chr(10), "", str_replace(chr(13), "", str_replace(" ", "", str_replace("Name Server:", "", $ligne)))));
995  if ($tmp) {
996  $serveurList[] = $tmp;
997  }
998  }
999  break;
1000  case "co":
1001  if (preg_match("#Name Server:#", $ligne)) {
1002  $found = true;
1003  $tmp = strtolower(str_replace(chr(10), "", str_replace(chr(13), "", str_replace(" ", "", str_replace("Name Server:", "", $ligne)))));
1004  if ($tmp)
1005  $serveurList[] = $tmp;
1006  }
1007  break;
1008  case "cx":
1009  $ligne = str_replace(chr(10), "", str_replace(chr(13), "", str_replace(" ", "", $ligne)));
1010  if ($ligne == "" && $state == 1) {
1011  $state = 2;
1012  }
1013  if ($state == 1) {
1014  $serveurList[] = strtolower($ligne);
1015  }
1016  if ($ligne == "Nameservers:" && $state == 0) {
1017  $state = 1;
1018  $found = true;
1019  }
1020  break;
1021  case "eu":
1022  case "be":
1023  $ligne = preg_replace("/^ *([^ ]*) \(.*\)$/", "\\1", trim($ligne));
1024  $tmp="";
1025  if ($found) {
1026  $tmp = trim($ligne);
1027  }
1028  if ($tmp) {
1029  $serveurList[] = $tmp;
1030  }
1031  if ($ligne == "Nameservers:") {
1032  $state = 1;
1033  $found = true;
1034  }
1035  break;
1036  case "im":
1037  if (preg_match('/Name Server:/', $ligne)) {
1038  $found = true;
1039  // weird regexp (trailing garbage after name server), but I could not make it work otherwise
1040  $tmp = strtolower(preg_replace('/Name Server: ([^ ]+)\..$/', "\\1", $ligne));
1041  $tmp = preg_replace('/[^-_a-z0-9\.]/', '', $tmp);
1042  if ($tmp) {
1043  $serveurList[] = $tmp;
1044  }
1045  }
1046  break;
1047  case "it":
1048  if (preg_match("#nserver:#", $ligne)) {
1049  $found = true;
1050  $tmp = strtolower(preg_replace("/nserver:\s*[^ ]*\s*([^\s]*)$/", "\\1", $ligne));
1051  if ($tmp) {
1052  $serveurList[] = $tmp;
1053  }
1054  }
1055  break;
1056  case "fr":
1057  case "re":
1058  if (preg_match("#nserver:#", $ligne)) {
1059  $found = true;
1060  $tmp = strtolower(preg_replace("#nserver:\s*([^\s]*)\s*.*$#", "\\1", $ligne));
1061  if ($tmp) {
1062  $serveurList[] = $tmp;
1063  }
1064  }
1065  break;
1066  case "ca":
1067  case "ws";
1068  if (preg_match('#Name servers#', $ligne)) {
1069  // found the server
1070  $state = 1;
1071  } elseif ($state) {
1072  if (preg_match('#^[^%]#', $ligne) && $ligne = preg_replace('#[[:space:]]#', "", $ligne)) {
1073  // first non-whitespace line is considered to be the nameservers themselves
1074  $found = true;
1075  $serveurList[] = $ligne;
1076  }
1077  }
1078  break;
1079  case "coop":
1080  if (preg_match('#Host Name:\s*([^\s]+)#', $ligne, $matches)) {
1081  $found = true;
1082  $serveurList[] = $matches[1];
1083  }
1084  } // switch
1085  } // while
1086  fclose($fp);
1087  } else {
1088  $msg->raise("ALERT", "dom", _("The Whois database is unavailable, please try again later"));
1089  return array();
1090  }
1091 
1092  if ($found) {
1093  return $serveurList;
1094  } else {
1095  $msg->raise("ALERT", "dom", _("The domain cannot be found in the Whois database"));
1096  return array();
1097  }
1098  } // whois
$found
Definition: aws_del.php:29
$msg
Definition: config.php:155
if(empty($site_name)) elseif($piwik->site_add($site_name, $site_urls))
$domain
Definition: dom_import.php:36

Member Data Documentation

m_dom::$action_delete = "2"

Definition at line 77 of file m_dom.php.

m_dom::$action_insert = "0"

Definition at line 75 of file m_dom.php.

m_dom::$action_update = "1"

Definition at line 76 of file m_dom.php.

m_dom::$cache_domains_type_lst = false

Definition at line 79 of file m_dom.php.

Referenced by domains_type_lst().

m_dom::$dns

$dns : Liste des dns trouvés par la fonction whois private

Definition at line 43 of file m_dom.php.

m_dom::$domains

$domains : Cache des domaines du membre private

Definition at line 37 of file m_dom.php.

Referenced by enum_domains().

m_dom::$fic_lock_cron = "/var/run/alternc/cron.lock"

Systéme de verrouillage du cron Ce fichier permet de verrouiller le cron en attendant la validation du domaine par update_domains.sh private.

Definition at line 57 of file m_dom.php.

m_dom::$islocked = false

Le cron a-t-il été bloqué ? Il faut appeler les fonctions privées lock et unlock entre les appels aux domaines.

private

Definition at line 65 of file m_dom.php.

m_dom::$tld_no_check_at_all = "1"

Definition at line 78 of file m_dom.php.

m_dom::$type_cname = "CNAME"

Definition at line 71 of file m_dom.php.

m_dom::$type_defmx = "DEFMX"

Definition at line 73 of file m_dom.php.

m_dom::$type_defmx2 = "DEFMX2"

Definition at line 74 of file m_dom.php.

m_dom::$type_ip = "IP"

Definition at line 68 of file m_dom.php.

m_dom::$type_ipv6 = "IPV6"

Definition at line 70 of file m_dom.php.

m_dom::$type_local = "VHOST"

Definition at line 66 of file m_dom.php.

m_dom::$type_txt = "TXT"

Definition at line 72 of file m_dom.php.

m_dom::$type_url = "URL"

Definition at line 67 of file m_dom.php.

m_dom::$type_webmail = "WEBMAIL"

Definition at line 69 of file m_dom.php.

m_dom::$webmail

Flag : a-t-on trouvé un sous-domaine Webmail pour ce domaine ? private.

Definition at line 49 of file m_dom.php.


The documentation for this class was generated from the following file: