예제 #1
0
 /**
  * Extract domain name and extension from FQDN
  *
  * @param string $hostname
  * @return array (name, extension)
  */
 public static function Parse($domain)
 {
     $domain = FQDN::Sanitize($domain);
     list($name, $extension) = explode(".", $domain, 2);
     // FAIL11
     if (empty($name) || empty($extension)) {
         throw new Exception(sprintf(_("Failed to parse domain name: %s"), $domain));
     }
     return array($name, $extension);
 }
예제 #2
0
<?php

require_once 'src/prepend.inc.php';
@set_time_limit(999999);
if (Client::Load($_SESSION['userid'])->GetSettingValue('domain_preorder') != 1) {
    CoreUtils::Redirect("index.php");
}
if ($_POST) {
    $Validator = new Validator();
    $lines = explode("\n", $post_domains);
    $post_domainname = FQDN::Sanitize($post_domainname);
    list($domain_name, $extension) = FQDN::Parse($post_domainname);
    $expiredate = trim($post_dt);
    // Validate date. Sucks.
    if (!preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}\$/", $expiredate) || !strtotime($expiredate)) {
        throw new ApplicationException(sprintf(_("Incorrect expiration date.")));
    }
    // Validate domain name
    if (!$Validator->IsDomain($post_domainname)) {
        throw new Exception(sprintf(_("Incorrect domain name: %s"), $post_domainname));
    }
    if (!$Registries[$extension]) {
        try {
            $Registry = RegistryModuleFactory::GetInstance()->GetRegistryByExtension($extension);
        } catch (Exception $e) {
            throw new ApplicationException($e->getMessage());
        }
        $Manifest = $Registry->GetManifest();
        if ($Manifest->GetRegistryOptions()->ability->preregistration != 1) {
            throw new ApplicationException(sprintf(_("Module %s does not support domain pre-registration."), $Registry->GetModuleName()));
        }