'; } /** * Generates the hosts table HTML for display. * * @return string */ public static function getHostsTableHtml() { $hostsFile = HOSTS_ACL . '/HOSTS'; $entries = file($hostsFile, FILE_IGNORE_NEW_LINES); $hostsTableHtml = ''; if (count($entries) > 0) { $halfCount = ceil(count($entries) / 2); $entriesColumn1 = array_slice($entries, 0, $halfCount); $entriesColumn2 = array_slice($entries, $halfCount); $hostsTableHtml .= '
'; // Column 1 $hostsTableHtml .= '
'; foreach ($entriesColumn1 as $index => $entry) { $lineNumber = $index; // Correct line number for column 1 $fields = explode(' ', $entry); $domain = isset($fields[0]) ? $fields[0] : ''; $key = isset($fields[1]) ? $fields[1] : ''; $hostsTableHtml .= self::generateHostsTableRow($lineNumber, $domain, $key); } $hostsTableHtml .= '
Domain Key Actions
'; // Column 2 $hostsTableHtml .= '
'; foreach ($entriesColumn2 as $index => $entry) { $lineNumber = $index + $halfCount; // Correct line number for column 2 $fields = explode(' ', $entry); $domain = isset($fields[0]) ? $fields[0] : ''; $key = isset($fields[1]) ? $fields[1] : ''; $hostsTableHtml .= self::generateHostsTableRow($lineNumber, $domain, $key); } $hostsTableHtml .= '
Domain Key Actions
'; } else { $hostsTableHtml = "No entries found."; } return $hostsTableHtml; } }