using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Mvc;
namespace WitBird.Whois.Web.Controllers
{
public class WhoisController : Controller
{
//域名查询端口
private const int Port = 43;
[HttpGet]
public ActionResult Search(string domain)
{
Models.Domain model = new Models.Domain();
//域名为空直接返回
if (string.IsNullOrEmpty(domain))
{
model.Name = "";
return View(model);
}
else
{
//不包含“.”刚默认查询com
if (!domain.Contains("."))
{
domain = domain + ".com";
}
model.Name = domain;
}
//去掉空格,转换成小写
domain = domain.Trim().ToLower();
//检测域名格式
Regex regex = new Regex(DomainServer.RegexValue, RegexOptions.IgnoreCase);
Match match = regex.Match(domain);
if (match.Success)
{
//检测域名后缀
string suffix = match.Groups["root"].Value;
public string FomartMonth(string datetime)
{
if (datetime.Contains("jan"))
{
datetime = datetime.Replace("jan", "1月");
}
if (datetime.Contains("feb"))
{
datetime = datetime.Replace("feb", "2月");
}
if (datetime.Contains("mar"))
{
datetime = datetime.Replace("mar", "3月");
}
if (datetime.Contains("apr"))
{
datetime = datetime.Replace("apr", "4月");
}
if (datetime.Contains("may"))
{
datetime = datetime.Replace("may", "5月");
}
if (datetime.Contains("jun"))
{
datetime = datetime.Replace("jun", "6月");
}
if (datetime.Contains("jul"))
{
datetime = datetime.Replace("jul", "7月");
} if (datetime.Contains("aug"))
{
datetime = datetime.Replace("aug", "8月");
}
if (datetime.Contains("sep"))
{
datetime = datetime.Replace("sep", "9月");
}
if (datetime.Contains("oct"))
{
datetime = datetime.Replace("oct", "10月");
}
if (datetime.Contains("nov"))
{
datetime = datetime.Replace("nov", "11月");
}
if (datetime.Contains("dec"))
{
datetime = datetime.Replace("dec", "12月");
}
return datetime;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WitBird.Whois.Web.Controllers
{
public class DomainServer
{
public const string RegexValue = @"^[a-zA-Z0-9\-]+(?<root>\.(cn|com.cn|net.cn|org.cn|gov.cn|de|com|net|org|cc|me|biz|info|io|wang)?)$";