Skip to content

Commit 06d2770

Browse files
committed
Handle unresolved domains in IP display
Update both PHP and JavaScript to show 'N/A' and a tooltip when a domain cannot be resolved to an IP address. This improves user feedback by clearly indicating unresolved domains in the domains table.
1 parent 2e0f2fd commit 06d2770

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

src/public/domains.php

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,13 @@
171171
<tr>
172172
<td><?= htmlspecialchars($d->domain) ?></td>
173173
<td><?= htmlspecialchars($d->provider) ?></td>
174-
<td><?= htmlspecialchars(@gethostbyname($d->domain)) ?></td>
174+
<?php
175+
$ip = gethostbyname($d->domain);
176+
$resolved = $ip === $d->domain ? null : $ip;
177+
?>
178+
<td title="<?= $resolved ? '' : 'Domain could not be resolved' ?>">
179+
<?= $resolved ?? 'N/A' ?>
180+
</td>
175181
<td class="actions">
176182
<button class="small secondary"><i class="ti ti-eye"></i> Show</button>
177183
<button class="small"><i class="ti ti-edit"></i> Edit</button>
@@ -366,24 +372,27 @@
366372
});
367373

368374

369-
function appendDomainRow(d) {
370-
const tbody = table.querySelector('tbody');
375+
function appendDomainRow(d) {
376+
const tbody = table.querySelector('tbody');
371377

372-
const placeholder = tbody.querySelector('tr[data-placeholder]');
373-
if (placeholder) placeholder.remove();
378+
const placeholder = tbody.querySelector('tr[data-placeholder]');
379+
if (placeholder) placeholder.remove();
374380

375-
const row = document.createElement('tr');
376-
row.innerHTML = `
377-
<td>${d.domain}</td>
378-
<td>${d.provider}</td>
379-
<td>${d.ip}</td>
380-
<td class="actions">
381-
<button class="small secondary"><i class="ti ti-eye"></i> Show</button>
382-
<button class="small"><i class="ti ti-edit"></i> Edit</button>
383-
<button class="small danger"><i class="ti ti-trash"></i> Delete</button>
384-
</td>`;
385-
tbody.appendChild(row);
386-
}
381+
const row = document.createElement('tr');
382+
383+
const ip = d.ip && d.ip !== d.domain ? d.ip : 'N/A';
384+
const ipTitle = ip === 'N/A' ? 'Domain could not be resolved' : '';
385+
row.innerHTML = `
386+
<td>${d.domain}</td>
387+
<td>${d.provider}</td>
388+
<td title="${ipTitle}">${ip}</td>
389+
<td class="actions">
390+
<button class="small secondary"><i class="ti ti-eye"></i> Show</button>
391+
<button class="small"><i class="ti ti-edit"></i> Edit</button>
392+
<button class="small danger"><i class="ti ti-trash"></i> Delete</button>
393+
</td>`;
394+
tbody.appendChild(row);
395+
}
387396

388397
// Handle "Show" button click
389398
table.addEventListener('click', e => {

0 commit comments

Comments
 (0)