['label' => 'All', 'where' => ''], 'starred' => ['label' => 'Starred', 'icon' => 'fa-star', 'where' => 'domains.domain_favorite = 1'], 'soon' => ['label' => "Expiring in $soon_days days", 'icon' => 'fa-hourglass-half', 'where' => "domains.domain_expire BETWEEN CURDATE() AND CURDATE() + INTERVAL $soon_days DAY"], 'expired' => ['label' => 'Expired', 'icon' => 'fa-calendar-times', 'where' => 'domains.domain_expire < CURDATE()'], 'noauto' => ['label' => 'No auto-renew', 'icon' => 'fa-hand-paper', 'where' => 'domains.domain_auto_renew = 0'], 'mail' => ['label' => 'Email gaps', 'icon' => 'fa-envelope-open-text', 'where' => domainMailGapSql()], ]; $show = isset($shows[$_GET['show'] ?? '']) ? ($_GET['show'] ?? '') : ''; $show_query = $shows[$show]['where'] ? 'AND ' . $shows[$show]['where'] : ''; $expire_days = $_GET['expire_days'] ?? ''; $expire_query = ''; if ($expire_days === 'expired') { $expire_query = 'AND domains.domain_expire < CURDATE()'; } elseif (intval($expire_days) > 0) { $expire_query = 'AND domains.domain_expire BETWEEN CURDATE() AND CURDATE() + INTERVAL ' . intval($expire_days) . ' DAY'; } // Only these sort - filter_header.php will hand through any lowercase word, and // an unknown column takes the page down with a mysqli exception $sortable_columns = ['domain_name' => 'domains.domain_name', 'domain_expire' => 'domains.domain_expire', 'registrar_name' => 'registrar.vendor_name', 'client_name' => 'client_name', 'domain_created_at' => 'domains.domain_created_at', 'domain_refreshed_at' => 'domains.domain_refreshed_at']; if (!isset($sortable_columns[$sort])) { $sort = 'domain_name'; } // Domains without an expiry go last whichever way the expiry is sorted $sort_sql = ($sort === 'domain_expire' ? 'domains.domain_expire IS NULL, ' : '') . $sortable_columns[$sort] . " $order"; [$domain_columns, $domain_joins] = domainSelectSql(); $search_query = "AND (domains.domain_name LIKE '%$q%' OR domains.domain_description LIKE '%$q%' OR domains.domain_notes LIKE '%$q%' OR registrar.vendor_name LIKE '%$q%' OR dnshost.vendor_name LIKE '%$q%' OR mailhost.vendor_name LIKE '%$q%' OR webhost.vendor_name LIKE '%$q%' OR client_name LIKE '%$q%' OR domains.domain_id IN (SELECT domain_id FROM domain_tags JOIN tags USING (tag_id) WHERE tag_name LIKE '%$q%'))"; $scope_query = clientScopeSql('domain_client_id'); $filters = "$archive_query $tag_query $vendor_query $search_query $expire_query $scope_query $client_query"; $sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS $domain_columns FROM domains $domain_joins WHERE $filters $show_query ORDER BY domains.domain_favorite DESC, $sort_sql, domains.domain_name ASC LIMIT $record_from, $record_to"); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); $domains = []; while ($row = mysqli_fetch_assoc($sql)) { $domains[intval($row['domain_id'])] = $row; } $domains_tags = tagsForRecords('domain', array_keys($domains)); // How many of each, for the pills - everything in scope, before the pill itself $count_sql = []; foreach ($shows as $key => $s) { $count_sql[] = $key === '' ? 'COUNT(*)' : "COALESCE(SUM({$s['where']}), 0)"; } $row = mysqli_fetch_row(mysqli_query($mysqli, "SELECT " . implode(', ', $count_sql) . " FROM domains $domain_joins WHERE $filters")); $counts = []; foreach (array_keys($shows) as $i => $key) { $counts[$key] = intval($row[$i]); } $filter_url = function ($changes) { $params = array_merge($_GET, $changes); unset($params['page']); return '?' . http_build_query(array_filter($params, function ($v) { return $v !== '' && $v !== null; })); }; // Vendors for the filter - the ones registering or hosting a domain in this scope $sql_vendors_filter = mysqli_query($mysqli, "SELECT DISTINCT vendor_id, vendor_name, vendor_description, vendor_client_id FROM vendors JOIN domains ON vendor_id IN (domain_registrar, domain_dnshost, domain_webhost, domain_mailhost) LEFT JOIN clients ON client_id = domain_client_id WHERE $archive_query $scope_query $client_query ORDER BY vendor_name ASC"); // Vendors the bulk "set registrar or host" offers - the client's and ours, or only ours across clients $bulk_vendor_options = $can_edit ? domainVendorChoices($client_url ? $client_id : 0) : []; ?>

Domains

0) { ?>
Archived
text-nowrap table-light"> $row) { $row_client_id = intval($row['domain_client_id']); $domain_name = escapeHtml($row['domain_name']); $domain_description = escapeHtml($row['domain_description']); $domain_favorite = intval($row['domain_favorite']); $domain_archived_at = escapeHtml($row['domain_archived_at']); $domain_tags = $domains_tags[$domain_id] ?? []; $expiry = domainExpiry($row['domain_expire'], $row['domain_auto_renew']); $quick_url = "modals/domain/domain.php?id=$domain_id"; ?>
Domain Expires Registrar and hosts Email Client
Archived
' . $who . '' : '-' ?> 1])) ?>
'domains', 'icon' => 'fa-globe', 'filtered' => $q || $tag_query || $vendor_query || $expire_query, 'views' => ['show'], 'view' => emptyStatePill($shows, $show, '', ['soon', 'expired', 'noauto', 'mail']), 'text' => 'Their domain names, where each is registered and when it expires.', 'actions' => $can_edit ? [['label' => 'New Domain', 'modal' => "modals/domain/domain_add.php?$client_url", 'size' => 'lg']] : [], ]; require_once "../includes/filter_footer.php"; ?>