Annonceindlæg fra Computerworld it-jobbank
21. december 2007 - 08:55
#1
Hej Zaittam, Jeg har tidligere skrevet dette lille PHP script. Jeg håber det løser dit problem. Du skal blot kalde checkDomain, men uden .dk,.com eller lign. Programmer check selv de fleste typer domainer og viser om det er ledigt. ex. checkDomain("cintix"), så får du en liste med domainer. Hvor du kan se cintix.dk er optaget. Hilsen Michael. <?php function checkDomain($domainname) { $whoisservers = array( 'dk' => 'whois.dk-hostmaster.dk', 'com' => 'rs.internic.net', 'net' => 'rs.internic.net', 'org' => 'whois.networksolutions.com', 'info' => 'whois.afilias.net', 'biz' => 'whois.biz', 'se' => 'whois.nic-se.se', 'co.uk' => 'whois.nic.uk'); $whoisservers_prices = array( 'dk' => '65,-', 'com' => '99,-', 'net' => '99,-', 'org' => '99,-', 'info' => '99,-', 'biz' => '99,-', 'se' => '99,-', 'co.uk' => '99,-'); $whoisservers_subscriptions = array( 'dk' => '36,-', 'com' => '225,-', 'net' => '225,-', 'org' => '225,-', 'info' => '225,-', 'biz' => '225,-', 'se' => '350,-', 'co.uk' => '225,-'); $whoisservers_years = array( 'dk' => '1', 'com' => '2', 'net' => '2', 'org' => '2', 'info' => '2', 'biz' => '2', 'se' => '3', 'co.uk' => '2'); $colorcode = "#fffff"; echo '<table width="90%" border="0" cellpadding="0" cellspacing="0" align="center">' . "\n"; echo " <tr >\n"; echo ' <th align="left" style="font-size: 11px;background-color: ' . $colorcode . ';">'; echo 'V?lg'; echo " </th>\n"; echo ' <th align="left" style="font-size: 11px;background-color: ' . $colorcode . ';">'; echo 'domain'; echo " </th>\n"; echo ' <th align="left" style="font-size: 11px;background-color: ' . $colorcode . ';">'; echo 'Status'; echo " </th>\n"; echo ' <th align="left" style="font-size: 11px;background-color: ' . $colorcode . ';">'; echo 'Oprettelse'; echo " </th>\n"; echo ' <th align="left" style="font-size: 11px;background-color: ' . $colorcode . ';">'; echo 'Pris pr. ?r'; echo " </th>\n"; echo ' <th align="left" style="font-size: 11px;background-color: ' . $colorcode . ';">'; echo '?r der forud faktureres'; echo " </th>\n"; echo " </tr>\n"; $count=10; while (list($domain,$whoisserver) = each($whoisservers)){ $count++; $colorcode = (round($count % 2) > 0)? "#f1f1f1" : "#ffffff"; echo " <tr >\n"; echo ' <td style="font-size: 11px;background-color: ' . $colorcode . ';">'; echo ' <input type="checkbox" name="domain[]" value="' . $domain . '" />'; echo " </td>\n"; echo ' <td style="font-size: 11px;background-color: ' . $colorcode . ';">'; echo $domainname . '.' . $domain; echo " </td>\n"; echo ' <td style="font-size: 11px;background-color: ' . $colorcode . ';">'; echo (lookup($domainname . "." . $domain,$whoisserver) == true) ? '<div class="taken">Optaget</div>' : '<div class="free">Led ig</div>'; echo " </td>\n"; echo ' <td style="font-size: 11px;background-color: ' . $colorcode . ';">'; echo $whoisservers_prices[$domain]; echo " </td>\n"; echo ' <td style="font-size: 11px;background-color: ' . $colorcode . ';">'; echo $whoisservers_subscriptions[$domain]; echo " </td>\n"; echo ' <td style="font-size: 11px;background-color: ' . $colorcode . ';">'; echo $whoisservers_years[$domain]; echo " </td>\n"; echo " </tr>\n"; ob_flush(); flush(); } echo "</table>\n\n"; ob_flush(); flush(); return $whosrv; } function lookup($dom,$whoisserver) { if (!$whoisserver) return ''; $fp = fsockopen($whoisserver,43,$errno, $errstr,3 ); fputs($fp,$dom."\r\n"); $string = ''; while(!feof($fp)) $string .= fgets($fp,128); fclose($fp); $reg = "/Whois Server: (.*?)\n/i"; preg_match_all($reg, $string, $matches); if(isset($matches[1][0])) $secondtry = $matches[1][0]; if(isset($secondtry)) { $fp = fsockopen($secondtry,43); fputs($fp, $dom."\r\n"); $string = ''; while(!feof($fp)) $string .= fgets($fp,128); fclose($fp); } if(ereg('(No match|No entries found|NOT FOUND|Not found)',$string)) { return false; }else{ return true; } } ?>