Add Bulk and Single Refresh Domain Actions

This commit is contained in:
johnnyq
2026-07-20 18:54:01 -04:00
parent a35ef025dc
commit e134c89c3a
2 changed files with 112 additions and 0 deletions

View File

@@ -191,6 +191,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<i class="fas fa-fw fa-trash mr-2"></i>Delete
</button>
<?php } else { ?>
<button class="dropdown-item"
type="submit" form="bulkActions" name="bulk_refresh_domains">
<i class="fas fa-fw fa-sync-alt mr-2"></i>Refresh Records
</button>
<div class="dropdown-divider"></div>
<button class="dropdown-item text-danger confirm-link"
type="submit" form="bulkActions" name="bulk_archive_domains">
<i class="fas fa-fw fa-archive mr-2"></i>Archive
@@ -359,6 +364,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
data-modal-url="modals/domain/domain_edit.php?<?= $client_url ?>&id=<?= $domain_id ?>">
<i class="fas fa-fw fa-edit mr-2"></i>Edit
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="post.php?refresh_domain=<?php echo $domain_id; ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-sync-alt mr-2"></i>Refresh Records
</a>
<?php if ($session_user_role == 3) { ?>
<?php if ($domain_archived_at) { ?>
<div class="dropdown-divider"></div>

View File

@@ -156,6 +156,48 @@ if (isset($_POST['edit_domain'])) {
}
if (isset($_GET['refresh_domain'])) {
validateCSRFToken($_GET['csrf_token']);
enforceUserPermission('module_support', 2);
$domain_id = intval($_GET['refresh_domain']);
// Get Name and Client ID for logging and alert message
$sql = mysqli_query($mysqli,"SELECT domain_name, domain_client_id FROM domains WHERE domain_id = $domain_id");
$row = mysqli_fetch_assoc($sql);
$domain_name = escapeSql($row['domain_name']);
$client_id = intval($row['domain_client_id']);
enforceClientAccess();
// Lookup expiry date
$expire = getDomainExpirationDate($domain_name);
if (strtotime($expire)) {
$expire = "'" . $expire . "'";
} else {
$expire = 'NULL';
}
// NS, MX, A and WHOIS records/data
$records = getDnsRecords($domain_name);
$a = escapeSql($records['a']);
$ns = escapeSql($records['ns']);
$mx = escapeSql($records['mx']);
$txt = escapeSql($records['txt']);
$whois = escapeSql($records['whois']);
mysqli_query($mysqli,"UPDATE domains SET domain_expire = $expire, domain_ip = '$a', domain_name_servers = '$ns', domain_mail_servers = '$mx', domain_txt = '$txt', domain_raw_whois = '$whois' WHERE domain_id = $domain_id");
logAudit("Domain", "Refresh", "$session_name refreshed records for domain $domain_name", $client_id, $domain_id);
flashAlert("Refreshed records for <strong>$domain_name</strong>");
redirect();
}
if (isset($_GET['archive_domain'])) {
validateCSRFToken($_GET['csrf_token']);
@@ -352,6 +394,67 @@ if (isset($_POST['bulk_delete_domains'])) {
}
if (isset($_POST['bulk_refresh_domains'])) {
validateCSRFToken($_POST['csrf_token']);
enforceUserPermission('module_support', 2);
if (isset($_POST['domain_ids'])) {
// WHOIS lookups are slow - don't time out mid-batch
set_time_limit(0);
// Get Selected Count
$count = count($_POST['domain_ids']);
// Cycle through array and refresh each record
foreach ($_POST['domain_ids'] as $domain_id) {
$domain_id = intval($domain_id);
// Get Name and Client ID for logging and alert message
$sql = mysqli_query($mysqli,"SELECT domain_name, domain_client_id FROM domains WHERE domain_id = $domain_id");
$row = mysqli_fetch_assoc($sql);
$domain_name = escapeSql($row['domain_name']);
$client_id = intval($row['domain_client_id']);
enforceClientAccess();
// Lookup expiry date
$expire = getDomainExpirationDate($domain_name);
if (strtotime($expire)) {
$expire = "'" . $expire . "'";
} else {
$expire = 'NULL';
}
// NS, MX, A and WHOIS records/data
$records = getDnsRecords($domain_name);
$a = escapeSql($records['a']);
$ns = escapeSql($records['ns']);
$mx = escapeSql($records['mx']);
$txt = escapeSql($records['txt']);
$whois = escapeSql($records['whois']);
mysqli_query($mysqli,"UPDATE domains SET domain_expire = $expire, domain_ip = '$a', domain_name_servers = '$ns', domain_mail_servers = '$mx', domain_txt = '$txt', domain_raw_whois = '$whois' WHERE domain_id = $domain_id");
logAudit("Domain", "Refresh", "$session_name refreshed records for domain $domain_name", $client_id, $domain_id);
// Be gentle on WHOIS servers
sleep(1);
}
logAudit("Domain", "Bulk Refresh", "$session_name refreshed records for $count domain(s)", $client_id);
flashAlert("Refreshed records for <strong>$count</strong> domain(s)");
}
redirect();
}
if (isset($_POST['export_domains_csv'])) {
validateCSRFToken($_POST['csrf_token']);