static function CheckCreateForErrors($domain) { global $zdbh; // Check for spaces and remove if found... $domain = strtolower(str_replace(' ', '', $domain)); // Check to make sure the domain is not blank before we go any further... if ($domain == '') { self::$blank = TRUE; return FALSE; } // Check for invalid characters in the domain... if (!self::IsValidDomainName($domain)) { self::$badname = TRUE; return FALSE; } // Check to make sure the domain is in the correct format before we go any further... if (strpos($domain, 'www.') === 0) { self::$error = TRUE; return FALSE; } // Check to see if the domain already exists in Sentora somewhere and redirect if it does.... $sql = "SELECT COUNT(*) FROM x_vhosts WHERE vh_name_vc=:domain AND vh_deleted_ts IS NULL"; $numrows = $zdbh->prepare($sql); $numrows->bindParam(':domain', $domain); if ($numrows->execute()) { if ($numrows->fetchColumn() > 0) { self::$alreadyexists = TRUE; return FALSE; } } // Check to make sure user not adding a subdomain and blocks stealing of subdomains.... // Get shared domain list $SharedDomains = array(); $a = explode(',', ctrl_options::GetSystemOption('shared_domains')); foreach ($a as $b) { $SharedDomains[] = $b; } if (substr_count($domain, ".") > 1) { $part = explode('.', $domain); foreach ($part as $check) { if (!in_array($check, $SharedDomains)) { if (strlen($check) > 13) { $sql = $zdbh->prepare("SELECT * FROM x_vhosts WHERE vh_name_vc LIKE :check AND vh_type_in !=2 AND vh_deleted_ts IS NULL"); $checkSql = '%' . $check . '%'; $sql->bindParam(':check', $checkSql); $sql->execute(); while ($rowcheckdomains = $sql->fetch()) { $subpart = explode('.', $rowcheckdomains['vh_name_vc']); foreach ($subpart as $subcheck) { if (strlen($subcheck) > 3) { if ($subcheck == $check) { if (substr($domain, -7) == substr($rowcheckdomains['vh_name_vc'], -7)) { self::$nosub = TRUE; return FALSE; } } } } } } } } } return TRUE; }