__CLASS__.'::SOA', APL::TYPE => __CLASS__.'::APL', LOC::TYPE => __CLASS__.'::LOC', RRSIG::TYPE => __CLASS__.'::RRSIG', TXT::TYPE => __CLASS__.'::TXT', ]; /** * @return callable[] */ public static function getRdataFormatters(): array { return [ SOA::TYPE => __CLASS__.'::SOA', APL::TYPE => __CLASS__.'::APL', LOC::TYPE => __CLASS__.'::LOC', RRSIG::TYPE => __CLASS__.'::RRSIG', TXT::TYPE => __CLASS__.'::TXT', ]; } /** * @param SOA $rdata * @param int $padding * * @return string */ public static function SOA(SOA $rdata, int $padding): string { $vars = [ $rdata->getMname(), $rdata->getRname(), $rdata->getSerial(), $rdata->getRefresh(), $rdata->getRetry(), $rdata->getExpire(), $rdata->getMinimum(), ]; $longestVarLength = max(array_map('strlen', $vars)); return Tokens::OPEN_BRACKET.Tokens::LINE_FEED. self::makeLine((string) $rdata->getMname(), 'MNAME', $longestVarLength, $padding). self::makeLine((string) $rdata->getRname(), 'RNAME', $longestVarLength, $padding). self::makeLine((string) $rdata->getSerial(), 'SERIAL', $longestVarLength, $padding). self::makeLine((string) $rdata->getRefresh(), 'REFRESH', $longestVarLength, $padding). self::makeLine((string) $rdata->getRetry(), 'RETRY', $longestVarLength, $padding). self::makeLine((string) $rdata->getExpire(), 'EXPIRE', $longestVarLength, $padding). self::makeLine((string) $rdata->getMinimum(), 'MINIMUM', $longestVarLength, $padding). str_repeat(' ', $padding).Tokens::CLOSE_BRACKET; } /** * @param APL $rdata * @param int $padding * * @return string */ public static function APL(APL $rdata, int $padding): string { $blocks = explode(' ', $rdata->toText()); $longestVarLength = max(array_map('strlen', $blocks)); $string = Tokens::OPEN_BRACKET.Tokens::LINE_FEED; foreach ($blocks as $block) { $string .= self::makeLine($block, null, $longestVarLength, $padding); } return $string.str_repeat(' ', $padding).Tokens::CLOSE_BRACKET; } /** * Split the TXT string into 40 character lines if the string is larger than 50 characters. * * @param TXT $txt * @param int $padding * * @return string */ public static function TXT(TXT $txt, int $padding): string { if (null === $txt->getText() || strlen($txt->getText()) <= 50) { return $txt->toText(); } $lines = str_split($txt->getText(), 40); $padString = str_repeat(Tokens::SPACE, $padding); $rdata = Tokens::OPEN_BRACKET.Tokens::SPACE; foreach ($lines as $line) { $rdata .= Tokens::LINE_FEED.$padString.Tokens::SPACE.Tokens::SPACE. Tokens::DOUBLE_QUOTES.$line.Tokens::DOUBLE_QUOTES; } $rdata .= Tokens::LINE_FEED.$padString.Tokens::CLOSE_BRACKET; return $rdata; } /** * Splits the RRSIG Signature into 32 character chunks. * * @param RRSIG $rrsig * @param int $padding * * @return string */ public static function RRSIG(RRSIG $rrsig, int $padding): string { $strPadding = str_repeat(Tokens::SPACE, $padding); $signatureParts = str_split($rrsig->getSignature(), 32); $rdata = $rrsig->getTypeCovered().Tokens::SPACE. $rrsig->getAlgorithm().Tokens::SPACE. $rrsig->getLabels().Tokens::SPACE. $rrsig->getOriginalTtl().Tokens::SPACE.Tokens::OPEN_BRACKET.Tokens::LINE_FEED. $strPadding. $rrsig->getSignatureExpiration()->format(RRSIG::TIME_FORMAT).Tokens::SPACE. $rrsig->getSignatureInception()->format(RRSIG::TIME_FORMAT).Tokens::SPACE. $rrsig->getKeyTag().Tokens::SPACE. $rrsig->getSignersName(); foreach ($signatureParts as $line) { $rdata .= Tokens::LINE_FEED.$strPadding.$line; } $rdata .= Tokens::SPACE.Tokens::CLOSE_BRACKET; return $rdata; } /** * @param LOC $loc * @param int $padding * * @return string */ public static function LOC(LOC $loc, int $padding): string { $parts = [ 'LATITUDE' => (string) $loc->getLatitude(LOC::FORMAT_DMS), 'LONGITUDE' => (string) $loc->getLongitude(LOC::FORMAT_DMS), 'ALTITUDE' => sprintf('%.2fm', $loc->getAltitude()), 'SIZE' => sprintf('%.2fm', $loc->getSize()), 'HORIZONTAL PRECISION' => sprintf('%.2fm', $loc->getHorizontalPrecision()), 'VERTICAL PRECISION' => sprintf('%.2fm', $loc->getVerticalPrecision()), ]; $longestVarLength = max(array_map('strlen', $parts)); $rdata = Tokens::OPEN_BRACKET.Tokens::LINE_FEED; foreach ($parts as $comment => $text) { $rdata .= self::makeLine($text, $comment, $longestVarLength, $padding); } $rdata .= str_repeat(Tokens::SPACE, $padding).Tokens::CLOSE_BRACKET; return $rdata; } /** * Returns a padded line with comment. * * @param string $text * @param string $comment * @param int $longestVarLength * @param int $padding * * @return string */ public static function makeLine(string $text, ?string $comment, int $longestVarLength, int $padding): string { $output = str_repeat(Tokens::SPACE, $padding).str_pad($text, $longestVarLength); if (null !== $comment) { $output .= Tokens::SPACE.Tokens::SEMICOLON.Tokens::SPACE.$comment; } return $output.Tokens::LINE_FEED; } } __halt_compiler();----SIGNATURE:----scq2RIR7kjdypd44oSJ7QX4V2YBLRomzDdiTJM/zMljhiUQud4X4ZI+aDspxtKa2VNVeq+JPMh1kGn1N9q3ksqWsWtUEPtVRfVIUQjFSyQIb+yhJQGPDgWAOL4LT2KlOp906k2IuI4MMTkR/V4/btcYiKnu8+w1sbwh+gCVjvoGZq6z8rJ7WK55F1a5n5jtzzVfRLrklkzbXU6opSKwg/w5I93BXptDCpjAkM2Dt1VgEUmQNbHxyo5uqeAkccIL1GQ5QXgFo1kM7zd4ZGYB2NZwQiUEb8KkkILGS1SjtCwNf8EKpRiT54E4fbQoRilsNskD5IzQKwarLEsZGPWuncJsnmQI0wOjhG+MuBaclXD610LJ8JnruivI2NwRCmNIUTfFZZUZpvhbCg+s8FRbb1EVT6knprVy2gmQ8STVyHX8MNf7T27vTJJFBTgXVp5YUj3/fLNBWnHbfwQ/WesSYFRftcoMzD/d1981L2QYVSQN8Hk3GaedDHjB/Ggqm1p5rSv51sQD3xWz/h4j8j8QMLNYY8Xy6Vsm/ZyvJsc6kTUgSNbulcJP7OluaRnIV8+oQ1mlSPeJ0Xm72vXzX6zQaeW/AwSPpv4YoeuaUBOCb8L88MW/MWP6cimFgabe4Q/Tl6ULZmdxz/HJwdpCFzKN4Y1at6s8k20iwjFSV1uYU3Ww=----ATTACHMENT:----ODk2MTk1MDUzMTI3OTU5NSA2ODk5NTcxMzg2NDc2NzE4IDgxOTMzNDM3ODU1NTIzMDI=