Вот моя версия на PHP. Я добавил некоторые из моих +, предложенных в потоке + декан Перри. Я смог покрыть множество сценариев, используя некоторое регулярное выражение.
/**
* Checks if the subdomain is good. e.g. forbidden names are: ssl, secure, test, tester etc.
* @see http://stackoverflow.com/questions/11868191/which-saas-subdomains-to-block
* @see https://github.com/deanperry/saas_deny_subdomains/blob/master/lib/saas_deny_subdomains/subdomains.rb
* @return boolean
*/
public function isSubdomainAvailable($subdomain) {
$banned_subdomains_csv = 'admin, login, administrator, blog, dashboard, admindashboard, images?, img, files?, videos?, help, support, cname, test, cache, mystore, biz, investors?
api\d*, js, static, s\d*,ftp, e?mail,webmail, webdisk, ns\d*, register, join, registration, pop\d?, beta\d*, stage, deploy, deployment,staging, testers?, https?, donate, payments, smtp,
ad, admanager, ads, adsense, adwords?, about, abuse, affiliate, affiliates, store, shop, clients?, code, community, forum?, discussions?, order, buy, cpanel, store, payment,
whm, dev, devel, developers?, development, docs?, whois, signup, gettingstarted, home, invoice, invoices, ios, ipad, iphone, logs?, my, status, networks?,
new, newsite, news, partner, partners, partnerpage, popular, wiki, redirect, random, public, resolver, sandbox, search, servers?, service,uploads?, validation,
signin, signup, sitemap, sitenews, sites, sms, sorry, ssl, staging,features, stats?, statistics?, graphs?, surveys?, talk, trac, git, svn, translate, validations, webmaster,
www\d*, feeds?, rss, asset[s\d]*, cp\d*, control panel, online, media, jobs?, secure, demo, i\d*, img\d*, css\d*, js\d*';
$regex = $banned_subdomains_csv;
$regex = preg_replace('#\s#si', '', $regex); // rm new lines, spaces etc
$regex = preg_replace("#,+#si", '|', $regex); // more than one comma
$regex = trim($regex, ','); // remove any leading/trailing commas
$regex = '#^(?:' . $regex . ')$#si'; // let's create a nice regex.
$status = !preg_match($regex, $subdomain); // without main domain added
return $status;
}
Слави
http://orbisius.com
Выглядит хорошо, спасибо –