PDA

View Full Version : تست وجود یک دامنه در اینترنت



m-alizadeh
شنبه 29 تیر 1387, 07:55 صبح
سلام
حقیقتش نمی دونستم این سوال رو باید کجا مطرح کنم و واسه همین به این قسمت مراجعه کردم ، امیدوارم که اشتباه نیومده باشم:
سوالم اینه: توی این سایت های فروش هاست دیدید، وقتی می خوای دامنه بخری اون سایت نام دامنه را از ما می گیره و تست می کنه تا ببینه که قبلا ثبت نشده باشه.

می خواستم بدونم این کار به چه طریقی است؟ آیا کد نویسی داره یا نه این سایت ها خود به یک سایت دیگر رجوع می کنند؟


با تشکر

merlin_vista
شنبه 29 تیر 1387, 08:47 صبح
لطفاً قبل از زدن تاپيك جستجو كنيد ++

به هر حال كدش اينه :‌
قسمت CS


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Sockets;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;


public partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Visible = false;
Label2.Visible = false;
string StrSvr, StrDomain, Resp;
// TcpClient TcpClt;
byte[] ArrDomain;
Stream TcpStr;
StreamReader TcpStrRdr;
StrSvr = "whois.internic.net";
StrDomain = TextBox1.Text.Trim() + DropDownList1.SelectedItem.Value + "\r\n";
if (DropDownList1.SelectedItem.Value == ".com" || DropDownList1.SelectedItem.Value == ".net" || DropDownList1.SelectedItem.Value == ".edu")
{
StrSvr = "whois.internic.net";
StrDomain = TextBox1.Text.Trim() + DropDownList1.SelectedItem.Value + "\r\n";
}
else if (DropDownList1.SelectedItem.Value == ".org")
{
StrSvr = "whois.publicinterestregistry.net";
StrDomain = TextBox1.Text.Trim() + DropDownList1.SelectedItem.Value + "\r\n";
}
else if (DropDownList1.SelectedItem.Value == ".biz")
{
StrSvr = "whois.neulevel.biz";
StrDomain = TextBox1.Text.Trim() + DropDownList1.SelectedItem.Value + "\r\n";
}
else if (DropDownList1.SelectedItem.Value == ".info")
{
StrSvr = "whois.afilias.info";
StrDomain = TextBox1.Text.Trim() + DropDownList1.SelectedItem.Value + "\r\n";
}
else if ((DropDownList1.SelectedItem.Value == ".ir") || (DropDownList1.SelectedItem.Value == ".co.ir") || (DropDownList1.SelectedItem.Value == ".net.ir") || (DropDownList1.SelectedItem.Value == ".org.ir"))
{
StrSvr = "whois.nic.ir";
StrDomain = TextBox1.Text.Trim() + DropDownList1.SelectedItem.Value + "\r\n";
}
TcpClient TcpClt = new TcpClient();
TcpClt.Connect(StrSvr, 43);
TcpClient objTCPCedu = new TcpClient(StrSvr, 43);
ArrDomain = Encoding.ASCII.GetBytes(StrDomain);
TcpStr = TcpClt.GetStream();
TcpStr.Write(ArrDomain, 0, StrDomain.Length);
TcpStrRdr = new StreamReader(TcpClt.GetStream(), Encoding.ASCII);
Resp = Regex.Replace(TcpStrRdr.ReadToEnd(), "\n", "<br>");
Resp = Resp.ToLower();
if (Regex.IsMatch(Resp, "no match") || Regex.IsMatch(Resp, "not found") || Regex.IsMatch(Resp, "no entries found"))
{

Label2.Text = "دامین برای ثبت آماده است";
Label2.Visible = true;
}
else
{
Label1.Text = "دامین قبلا ثبت شده است";
Label1.Visible = true;
}
TcpClt.Close();



}
}


قسمت ASPX

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" Width="95px" ></asp:TextBox>&nbsp;
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>.com</asp:ListItem>
<asp:ListItem>.net</asp:ListItem>
<asp:ListItem>.org</asp:ListItem>
<asp:ListItem>.ir</asp:ListItem>
<asp:ListItem>.co.ir</asp:ListItem>
<asp:ListItem>.net.ir</asp:ListItem>
<asp:ListItem>.org.ir</asp:ListItem>
<asp:ListItem>.edu</asp:ListItem>
<asp:ListItem>.info</asp:ListItem>
<asp:ListItem>.biz</asp:ListItem>
</asp:DropDownList><br/>
<asp:Label ID="Label1" runat="server" Font-Names="tahoma" Font-Size="X-Small" ForeColor="Red"
Visible="False"></asp:Label><asp:Label ID="Label2" runat="server" Font-Names="tahoma"
Font-Size="X-Small" ForeColor="Blue" Visible="False" ></asp:Label><br/>
<asp:Button ID="Button1" runat="server" Font-Names="tahoma" Font-Size="X-Small" OnClick="Button1_Click" Text="chek"/>
&nbsp;
</div>
</form>
</body>
</html>

najafzade
چهارشنبه 03 مهر 1387, 12:31 عصر
لطفاً قبل از زدن تاپيك جستجو كنيد ++



سلام
آقا من از این کد استفاده کردم.
اولش خیلی اجراش کند بود و بعد هم ارور داد.
عکس ارورش رو براتون گذاشتم.
اگه میشه بررسی بفرمائین

با ت