راکت
حل شده

سوال مهم در مورد whois

21 پاسخ

پروژه کوچک در مورد whois انجام دادم اما الان می خواهم وقتی که با عبارت با قاعده expiry(تاریخ انقضا سایت است) رو به صورت هایتلایت نمایش بده و بقیه اطلاعات رو پاک کنه
این کد منه

$f='domain.txt';
$document=file_get_contents($f);  
$domainName1=explode(" ", $document);
$e=count($domainName1)-1;  
$domainname = $domainName1;  
$server = "whois.crsnic.net";
$port=43;
$i=0;
while ($e>$i) {  
if(($whoisinfo = fsockopen($server,$port)) == true)  
{  
$output = "";
                    fputs($whoisinfo,"$domainname[$i]
    ");
                    while(!feof($whoisinfo)) 
                        $output .= fgets($whoisinfo,128); 
                    fclose($whoisinfo); 
            }
            $check=preg_match('/Expiry/',$output,$match);
            echo "<pre>" ;
                // 
            echo $output ;
            print_r($match);
            echo  "</pre>";
            echo "--------------------------------------------------------------";
            $i++;
}
    اینم چیزی است که چاپ میکنه

       Domain Name: GOOGLE.COM
       Registry Domain ID: 2138514_DOMAIN_COM-VRSN
       Registrar WHOIS Server: whois.markmonitor.com
       Registrar URL: http://www.markmonitor.com
       Updated Date: 2018-02-21T18:36:40Z
       Creation Date: 1997-09-15T04:00:00Z
       Registry Expiry Date: 2020-09-14T04:00:00Z
       Registrar: MarkMonitor Inc.
       Registrar IANA ID: 292
       Registrar Abuse Contact Email: abusecomplaints@markmonitor.com
       Registrar Abuse Contact Phone: +1.2083895740
       Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited
       Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited
       Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited
       Domain Status: serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited
       Domain Status: serverTransferProhibited https://icann.org/epp#serverTransferProhibited
       Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited
       Name Server: NS1.GOOGLE.COM
       Name Server: NS2.GOOGLE.COM
       Name Server: NS3.GOOGLE.COM
       Name Server: NS4.GOOGLE.COM
       DNSSEC: unsigned
       URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/
    >>> Last update of whois database: 2018-11-28T16:26:32Z <<<

    For more information on Whois status codes, please visit https://icann.org/epp

    NOTICE: The expiration date displayed in this record is the date the
    registrar's sponsorship of the domain name registration in the registry is
    currently set to expire. This date does not necessarily reflect the expiration
    date of the domain name registrant's agreement with the sponsoring
    registrar.  Users may consult the sponsoring registrar's Whois database to
    view the registrar's reported date of expiration for this registration.

    TERMS OF USE: You are not authorized to access or query our Whois
    database through the use of electronic processes that are high-volume and
    automated except as reasonably necessary to register domain names or
    modify existing registrations; the Data in VeriSign Global Registry
    Services' ("VeriSign") Whois database is provided by VeriSign for
    information purposes only, and to assist persons in obtaining information
    about or related to a domain name registration record. VeriSign does not
    guarantee its accuracy. By submitting a Whois query, you agree to abide
    by the following terms of use: You agree that you may use this Data only
    for lawful purposes and that under no circumstances will you use this Data
    to: (1) allow, enable, or otherwise support the transmission of mass
    unsolicited, commercial advertising or solicitations via e-mail, telephone,
    or facsimile; or (2) enable high volume, automated, electronic processes
    that apply to VeriSign (or its computer systems). The compilation,
    repackaging, dissemination or other use of this Data is expressly
    prohibited without the prior written consent of VeriSign. You agree not to
    use electronic processes that are automated and high-volume to access or
    query the Whois database except as reasonably necessary to register
    domain names or modify existing registrations. VeriSign reserves the right
    to restrict your access to the Whois database in its sole discretion to ensure
    operational stability.  VeriSign may restrict or terminate your access to the
    Whois database for failure to abide by these terms of use. VeriSign
    reserves the right to modify these terms at any time.

    The Registry database contains ONLY .COM, .NET, .EDU domains and
    Registrars.
    Array
    (
        [0] => Expiry
    )
    --------------------------------------------------------------
ثبت پرسش جدید

پاسخ‌ها

21
مهدی
مهدی
@code2code
بهترین پاسخ

نقطه همه رو کاراکترها رو مچ میکنه با همه چی
ستاره صفر یا بیشتر از کاراکتر قبلی رو تطبیق میده
بعلاوه یک یا بیشتر از کاراکتر قبلی رو تطبیق میده مثلا
اگه بنویسیم

a.*b

ab و acb و accccb و ... رو تطبیق میده
ولی عبارت زیر

a.+b

acb و acccccb و.... رو تطبیق میده ولی ab رو تطبیق نمیده

مهدی
مهدی
@code2code

اینو بزن توی قسمت رجکس (?<=Expiry Date: )\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}Z

(?<=Expiry Date: )\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}Z
مهدی
مهدی
@code2code

معذرت میخوام اشتباه نوشته بودم یه لحظه هول هولکی نوشتم اصلاح شد
اینی که الان نوشتم ینی هرچی که فرمتش تایم و بعد از Expiry Date: میاد
اونی که قبلش نوشته بودم ینی اینکه اون عبارت نباشه ولی اینی که الان نوشتم ینی بعد Expiry Date: بیاد

شاید پاسخ شما همین‌جا باشد

مهدی
مهدی
@code2code

d(?=r)

ینی اینکه d هایی که حتما بعدشون r باشه (در واقع ؟= به الگویی که قبل الگویی که مشخص کردیم اشاره داره)

(?<=r)d

میگه d هایی که بعد r بیان
این حالت و حالتی که ؟! میذاریم که معکوسه خیلی کاربرد داره

مهدی
مهدی
@code2code

واسه دامین هم همون کار رو کن

(?<=Domain Name: ).*
masoud net
masoud net
@netwons

d(?=r)
(?<=r)d
این دوی که شما توضیح دادید متوجه نشدم و rوd رو از کجا آوردید

(?<=Domain Name: ).* چطوری دقیق بنویسم چون میخواهم سر پسوند سایتها کارهایی رو انجام بدم

مهدی
مهدی
@code2code

شما چند تا اکانت داری؟
d و r دو تا حرف فرضیه میشه با هر چیز دیگه ای جایگزین بشه
میتونی واسه سایت به شکل زیر نویسی(بر اساس اون google.com)
‍حرف i رو اینجا واسه این نوشتم که به بزرگی کوچیکی حساس نباشه

'/(?<=Domain Name: )(\w{2,}\.(com|org|ir|biz))$/i'
masoud net
masoud net
@netwons

آموزش حرفه ای عبارت با قاعده رو ندارید نه این هایی که در سایتها قرار دادن
خوب و حرفه ای

masoud net
masoud net
@netwons

@code2code

من الان این کدو نوشتم اما ایراد میگیره
من میخوام بگم که اگه پسوند ir بود$server='whois.nic.ir';در غیر این صورت $server = "whois.crsnic.net"; باشد اماهر کاری کردن فقط این سرور رو اجرا میکنه$server = "whois.crsnic.net";
کد:

$f='domain.txt';  
$document=file_get_contents($f);  
$domainName1=explode(" ", $document);  
$e=count($domainName1)-1;  
$domainname = $domainName1;  
//$server = "whois.crsnic.net";  
$port=43;  
$i=0;  
$output = "";  
while ($e>$i) {  
$w=preg_match('/(w{2,}.(ir))$/i', $output,$match);  
if($w)){  
$server='whois.nic.ir';  
}else{  
$server = "whois.crsnic.net"; }  
if(($whoisinfo = fsockopen($server,$port)) == true) {  
$output = "";  
fputs($whoisinfo,"$domainname[$i] ");  
while(!feof($whoisinfo))  
$output .= fgets($whoisinfo,128);  
fclose($whoisinfo);  
} $c=preg_match('/(?<=Domain Name: ).*/m', $output,$match);  
//print_r($match);  
echo '<br>'.'<b>'.'Domain Name:'.'</b>'.implode(',', $match).' &nbsp&nbsp ';  
$check=preg_match('/(?<=Expiry Date: )d{4}-d{2}-d{2}Td{2}:d{2}:d{2}Z/m',$output,$match);  
//echo "<pre>" ;  
//echo $output ;  
//print_r($match);  
echo '<b>'.' Expiry:'.'</b>'.implode(',', $match).'<br>';  
//echo "</pre>";  
echo "--------------------------------------------------------------";  
$i++;  
}
مهدی
مهدی
@code2code

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

^(\w{2,}(\.\w{2,}|)\.(ir))$

w نشون دهنده حرفه
این سایت خیلی خوبه هم میتونی کد php جنریت کنی هم اینکه چک کنی کداتو
https://regex101.com/r/ErBq5V/1/
https://regex101.com/r/ErBq5V/1/codegen?language=php

مهدی
مهدی
@code2code
^(\w{2,}(\.\w{2,}|)\.(ir))$
masoud net
masoud net
@netwons

@code2code

اقا مهدی سلام
این (.*) یا(.+) در عبارت با قاعده به چه معناست؟

masoud net
masoud net
@netwons

@code2code

سلام
یک سوال
اینجا همه چیز درسته اما دوبار همه چیز رو چاپ میکنه میشه مشکلشو بفرمایید

$f='domainir.txt';
$document=file_get_contents($f);
$domainName1=explode("
", $document);
$e=count($domainName1)-1;
$domainname = $domainName1; 
$server = "whois.nic.ir";
$port=43;
$i=0;
$output = "";               
while ($e>$i) {
                       echo $domainname[$i];    
        if(($whoisinfo = fsockopen($server,$port)) == true)
            {
                $output = "";
                    fputs($whoisinfo,"$domainname[$i]
");
                    while(!feof($whoisinfo)) 
                        $output .= fgets($whoisinfo,128); 
                    fclose($whoisinfo); 
            }
            $c=preg_match('/(domain:s{1,}w{2,}.ir)$/m', $output,$match);
            $rr=implode(',', $match);
            echo $rr[$i];
            //echo '<br>'.'<b>'.'Domain Name:'.'</b>'.implode(',', $match).'  &nbsp&nbsp  ';
            $check=preg_match('/(expire-date:s{1,}d{4}-d{2}-d{2})$/m',$output,$match);
            //print_r($match);
            echo implode(',', $match);
            //echo "<pre>" ;
                // 
            //echo $output ;
            //print_r($match);
            //echo '<b>'.'  Expiry:'.'</b>'.implode(',', $match).'<br>';
            //echo  "</pre>";
            echo "<br>"."--------------------------------------------------------------"."<br>";
            $i++;
}

اینم جوابش:
roocket.irdexpire-date: 2021-03-17,expire-date: 2021-03-17

مهدی
مهدی
@code2code

کدتو قسمت echo ها چقدر هم ریخته است ...
$rr[$i] مطئنی درسته؟

masoud net
masoud net
@netwons

@code2code
این$i قرار دادم که دوبار ننویسه و در دومین ها با این کار یک بار مینویسه اما در expiryاین کارو کردم نشد

مهدی
مهدی
@code2code

والا من اومدم کدتونو تست کنم که گویا همین حلقه گیر داره
تا جایی که من میدونم کد رجکس مشکلی نداره
به نظرم بیشتر رو نحوه اکو کردنتون چک کنید ببینید جایی مشکل نداره بازیم میگم
$rr=implode(',', $match);
echo $rr[$i];
rr یه رشته است شما هر بار یه حرفشو چاپ میکنید با این کار...

masoud net
masoud net
@netwons

الان به این شکل هم می نویسم
‍‍‍```
$file="domain.txt";
$document=file_get_contents($file);
$line=explode("\n", $document);
//foreach ($line as $key=>$f ) {
//echo '<b>'.$key.'</b>'.'<br>';
$ch=curl_init("https://who.is/whois/roocket.ir");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,true);
$response=curl_exec($ch);
$e= $response;
$c=preg_match('/(domain:\s{1,}\w{2,}.ir)$/m', $e,$match);
$rr=implode(',', $match);
echo $rr;
$check=preg_match('/(expire-date:\s{1,}\d{4}-\d{2}-\d{2})$/m',$e,$match);
$rrr=implode(',', $match);
echo $rrr;
//$key++;
//}


به این شکل نمایش میده
domain: roocket.ir,domain:  roocket.irexpire-date:  2021-03-17,expire-date: 2021-03-17
مهدی
مهدی
@code2code

کدای رجکس رو توی پرانتز میذاری دو بار مچ میکنه () چون پرانتز یه گروهو رو مچ میکنه در واقع تو هر پرانتزی که میذاری یه عضو اضافه میکنی به آرایه مچ

$file="domain.txt";
$document=file_get_contents($file);
$line=explode("\n", $document);

$ch=curl_init("https://who.is/whois/roocket.ir");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,true);
$response=curl_exec($ch);
$e= $response;
$c=preg_match('/domain:\s+\w{2,}.ir$/m', $e,$match);
$rr=implode(',', $match);
echo $rr;
$check=preg_match('/expire-date:\s+\d{4}-\d{2}-\d{2}$/m',$e,$match);
$rrr=implode(',', $match);
echo $rrr;

برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام