Beispiel #1
0
 /**
  * Resolve WHOIS data for domain.
  *
  * @param Request $request
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  * @throws \Exception
  */
 public function index(Request $request)
 {
     $domain = $request->input('domain');
     $isAvailable = false;
     $response = '';
     if ($domain) {
         $whoisServersJson = base_path('vendor/helgesverre/domain-availability/src/data/servers.json');
         $whoisClient = new SimpleWhoisClient();
         $dataLoader = new JsonLoader($whoisServersJson);
         $service = new DomainAvailability($whoisClient, $dataLoader);
         $isAvailable = $service->isAvailable($domain);
         $response = $whoisClient->getResponse();
     }
     return view('whois.form', compact('domain', 'isAvailable', 'response'));
 }
<div>
    <form style="margin: 10px;" action="" method="get">
        <label for="domain">Domain Name</label>
        <input type="text" name="domain" id="domain">
        <input type="submit" value="Go">
    </form>

    <table border="1" cellpadding="5">
        <tr>
            <td>Status</td>
            <td>
                <?php 
try {
    if (isset($_GET["domain"])) {
        if ($service->isAvailable($_GET["domain"])) {
            echo "<span style='color:green;'>Available</span>";
        } else {
            echo "<span style='color:red;'>Unavailable</span>";
        }
    }
} catch (\Exception $e) {
    echo $e->getMessage();
}
?>
            </td>
        </tr>
        <tr>
            <td>WHOIS Server</td>
            <td><?php 
echo $whoisClient->getServer();