$sql="SELECT domain_id FROM web_domain WHERE (domain = '".$app->db->quote($domain)."' AND type IN ('alias', 'vhost')) OR (domain = '%.".$app->db->quote($domain)."' AND type IN ('subdomain', 'vhostsubdomain'))";

$sql="SELECT domain_id FROM web_domain WHERE (domain = '".$app->db->quote($domain)."' AND type IN ('alias', 'vhost')) OR (domain LIKE '%.".$app->db->quote($domain)."' AND type IN ('subdomain', 'vhostsubdomain'))";