Ejemplo n.º 1
0
 /**
  * Modifie les information du domaine précisé.
  *
  * @param string $dom Domaine du compte courant que l'on souhaite modifier
  * @param boolean $dns Vaut 1 ou 0 pour héberger ou pas le DNS du domaine
  * @param boolean $gesmx Héberge-t-on le emails du domaines sur ce serveur ?
  * @param boolean $force Faut-il passer les checks DNS ou MX ? (admin only)
  * @return 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.
  *
  */
 function edit_domain($dom, $dns, $gesmx, $force = false, $ttl = 3600)
 {
     global $db, $err, $L_MX, $classes, $cuid, $hooks;
     $err->log("dom", "edit_domain", $dom . "/" . $dns . "/" . $gesmx);
     // Locked ?
     if (!$this->islocked && !$force) {
         $err->raise("dom", _("--- Program error --- No lock on the domains!"));
         return false;
     }
     if ($dns == true && !$force) {
         $this->dns = $this->whois($dom);
         $v = checkhostallow($dom, $this->dns);
         if ($v == -1) {
             $err->raise("dom", _("The last member of the domain name is incorrect or cannot be hosted in that server"));
             return false;
         }
         if ($dns && $v == -2) {
             $err->raise("dom", _("The domain cannot be found in the Whois database"));
             return false;
         }
         if ($dns && $v == -3) {
             $err->raise("dom", _("The DNS of this domain do not match the server's DNS. Please change your domain's DNS before you install it again"));
             return false;
         }
     }
     # Can't have ttl == 0. There is also a check in function_dns
     if ($ttl == 0) {
         $ttl = 3600;
     }
     $t = checkfqdn($dom);
     if ($t) {
         $err->raise("dom", _("The domain name is syntaxically incorrect"));
         return false;
     }
     if (!($r = $this->get_domain_all($dom))) {
         // Le domaine n'existe pas, Failure
         $err->raise("dom", _("The domain name %s does not exist"), $dom);
         return false;
     }
     if ($dns != "1") {
         $dns = "0";
     }
     // On vérifie que des modifications ont bien eu lieu :)
     if ($r["dns"] == $dns && $r["mail"] == $gesmx && $r["zonettl"] == $ttl) {
         $err->raise("dom", _("No change has been requested..."));
         return true;
     }
     //si gestion mx uniquement, vérification du dns externe
     if ($dns == "0" && $gesmx == "1" && !$force) {
         $vmx = $this->checkmx($dom);
         if ($vmx == 1) {
             $err->raise("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"));
         }
         if ($vmx == 2) {
             // Serveur non spécifié parmi les champx mx
             $err->raise("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"));
         }
     }
     if ($gesmx && !$r["mail"]) {
         $hooks->invoke("hook_dom_add_mx_domain", array($r["id"]));
     }
     if (!$gesmx && $r["mail"]) {
         // on a dissocié le MX : on détruit donc l'entree dans LDAP
         $hooks->invoke("hook_dom_del_mx_domain", array($r["id"]));
     }
     $db->query("UPDATE domaines SET gesdns='{$dns}', gesmx='{$gesmx}', zonettl='{$ttl}' WHERE domaine='{$dom}'");
     $this->set_dns_action($dom, 'UPDATE');
     return true;
 }
Ejemplo n.º 2
0
// FIXME where does $opt come from ??
switch ($opt) {
    case "m":
        if (!filter_var($val, FILTER_VALIDATE_EMAIL)) {
            usage("The email you entered is syntaxically incorrect");
            exit(1);
        }
        $cond = "WHERE concat(address.address,'@',domaines.domaine) ='" . $val . "'";
        break;
    case "l":
        $login = strtolower($val);
        if (!preg_match("#^[a-z0-9]+\$#", $login)) {
            //FIXME use an alternc function for that
            usage("the login you entered is syntaxically incorrect");
            exit(1);
        }
        $cond = "join membres on domaines.compte = membres.uid WHERE membres.login = '******'";
        break;
    case "d":
        if (checkfqdn($val) != 0) {
            usage("The domain you entered is syntaxically incorrect");
            exit(1);
        }
        $cond = "WHERE domaines.domaine = '" . mysql_real_escape_string($val) . "'";
        break;
    default:
        usage();
        exit(1);
}
FixQuotaDovecot($cond);
exit(0);
Ejemplo n.º 3
0
function checkmail($mail, $force = 0)
{
    // Retourne 0 si tout va bien, sinon retourne un code erreur...
    // 6 si le mail contient aucun ou plus d'un @
    // 1 2 3 ou 4 si le domaine est incorrect.
    // 5 s'il y a caractères interdits dans la partie gauche du @
    if ($force == 0 && trim($mail) == "") {
        return 0;
    }
    $t = explode("@", $mail);
    if (count($t) != 2) {
        return 6;
    }
    $c = checkfqdn($t[1]);
    if ($c) {
        return $c;
    }
    // Verification de la partie gauche :
    if (!checkloginmail($t[0])) {
        return 5;
    }
    return 0;
}
Ejemplo n.º 4
0
/**
 * Check that $url is a correct url (http:// or https:// or ftp://) 
 * 
 * @param type $url
 * @return boolean
 */
function checkurl($url)
{
    // TODO : add a path/file check
    if (substr($url, 0, 7) != "http://" && substr($url, 0, 8) != "https://" && substr($url, 0, 6) != "ftp://") {
        return false;
    }
    if (substr($url, 0, 7) == "http://") {
        $fq = substr($url, 7);
    }
    if (substr($url, 0, 8) == "https://") {
        $fq = substr($url, 8);
    }
    if (substr($url, 0, 6) == "ftp://") {
        $fq = substr($url, 6);
    }
    $f = explode("/", $fq);
    if (!is_array($f)) {
        $f = array($f);
    }
    $t = checkfqdn($f[0]);
    if ($t) {
        return false;
    }
    return true;
}