drisate Posted May 15, 2012 Share Posted May 15, 2012 Hey guys i need to find the DNS of a hudge list of domains to check if there pointing at my server or not. This is what i did: $str = 'AAL-T.COM<br> AADQ.CA<br> ACADEMIENOUVELLEGENERATION.COM<br> AEFMQ.CA<br> AEFMQ.COM<br> AEFMQ.ORG<br> AERO-ATELIER.COM<br>'; // [...] $line = explode('<br>', strtolower($str)); foreach($line as $domain){ $dns = dns_get_record($domain, DNS_NS); sort($dns); echo "<strong>$domain</strong><br>"; foreach ($dns as $record) { echo $record['target']."<br/>"; } echo '<hr>'; } ?> For some reason the first loop outputs the target right but every other domain after if ruturns empty ... am i missing something? Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 15, 2012 Share Posted May 15, 2012 What exactly does the output look like? Quote Link to comment Share on other sites More sharing options...
drisate Posted May 15, 2012 Author Share Posted May 15, 2012 It looks like this: aal-t.com ns1.loumic.com ns2-r3-chicago.webserversystems.com ns2.loumic.com ------------------------------------------------------- aadq.ca ------------------------------------------------------- academienouvellegeneration.com ------------------------------------------------------- aefmq.ca ------------------------------------------------------- aefmq.com ------------------------------------------------------- aefmq.org ------------------------------------------------------- aero-atelier.com ------------------------------------------------------- Quote Link to comment Share on other sites More sharing options...
drisate Posted May 15, 2012 Author Share Posted May 15, 2012 nobody? Quote Link to comment Share on other sites More sharing options...
drisate Posted May 16, 2012 Author Share Posted May 16, 2012 Ok so if nobody can help me get dns_get_record() to work ... is there an alternate way of doing this? Quote Link to comment Share on other sites More sharing options...
rythemton Posted May 16, 2012 Share Posted May 16, 2012 You may not be getting any responses because as far as I can tell, it should be working. What do you get if you 'print_r( $dns )' before the second foreach loop? What do you get if you remove the sort? Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 16, 2012 Share Posted May 16, 2012 What is the DNS_NS flag? What if you DNS_ALL or ANY? Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted May 16, 2012 Share Posted May 16, 2012 Hey guys i need to find the DNS of a hudge list of domains to check if there pointing at my server or not. This is what i did: $str = 'AAL-T.COM<br> AADQ.CA<br> ACADEMIENOUVELLEGENERATION.COM<br> AEFMQ.CA<br> AEFMQ.COM<br> AEFMQ.ORG<br> AERO-ATELIER.COM<br>'; // [...] $line = explode('<br>', strtolower($str)); foreach($line as $domain){ $dns = dns_get_record($domain, DNS_NS); sort($dns); echo "<strong>$domain</strong><br>"; foreach ($dns as $record) { echo $record['target']."<br/>"; } echo '<hr>'; } ?> For some reason the first loop outputs the target right but every other domain after if ruturns empty ... am i missing something? $str = 'AAL-T.COM<br> AADQ.CA<br> ACADEMIENOUVELLEGENERATION.COM<br> AEFMQ.CA<br> AEFMQ.COM<br> AEFMQ.ORG<br> AERO-ATELIER.COM<br>'; is different than: $str = 'AAL-T.COM<br>AADQ.CA<br>ACADEMIENOUVELLEGENERATION.COM<br>AEFMQ.CA<br>AEFMQ.COM<br>AEFMQ.ORG<br>AERO-ATELIER.COM<br>'; Your method is redundant to begin with as you should just create an array of domains to check in the first place: $lines = array( 'AAL-T.COM', 'AADQ.CA', 'ACADEMIENOUVELLEGENERATION.COM', 'AEFMQ.CA', 'AEFMQ.COM', 'AEFMQ.ORG', 'AERO-ATELIER.COM' ); That will work. Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 16, 2012 Share Posted May 16, 2012 He's probably getting the list from another file, that has nothing to do with how the rest of the code is working, as he's seen that his array works. Quote Link to comment Share on other sites More sharing options...
drisate Posted May 16, 2012 Author Share Posted May 16, 2012 thx your right it works now :-) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.