|
215 | 215 | foreach($lines as $line){ |
216 | 216 | $line = trim($line); |
217 | 217 | if ($line != '' && substr($line, 0, 1) != ';'){ |
218 | | - if(strpos($line, ";") !== FALSE) $line = substr($line, 0, strpos($line, ";")); |
219 | | - if(strpos($line, "(") !== FALSE) $line = substr($line, 0, strpos($line, "(")); |
220 | | - if(strpos($line, ")") !== FALSE) $line = substr($line, 0, strpos($line, ")")); |
| 218 | + if(strpos($line, ";") !== FALSE) { |
| 219 | + if (!preg_match("/v=DKIM|v=DMARC/",$line)) { |
| 220 | + $line = substr($line, 0, strpos($line, ";")); |
| 221 | + } |
| 222 | + } |
| 223 | + if(strpos($line, "(") !== FALSE ) { |
| 224 | + if (!preg_match("/v=DKIM/",$line)) { |
| 225 | + $line = substr($line, 0, strpos($line, "(")); |
| 226 | + } |
| 227 | + } |
| 228 | + if(strpos($line, ")") !== FALSE ) { |
| 229 | + if (!preg_match("/v=DKIM/",$line)) { |
| 230 | + $line = substr($line, 0, strpos($line, ")")); |
| 231 | + } |
| 232 | + } |
| 233 | + |
221 | 234 | $line = trim($line); |
222 | 235 | if ($line != ''){ |
223 | 236 | $sPattern = '/\s+/m'; |
|
253 | 266 |
|
254 | 267 | $parts = explode(' ', $line); |
255 | 268 |
|
256 | | - // make all elements lowercase |
| 269 | + // make elements lowercase |
| 270 | + $dkim=@($parts[3]=='"v=DKIM1;')?true:false; |
| 271 | + $dmarc=@($parts[3]=='"v=DMARC1;')?true:false; |
| 272 | + |
257 | 273 | $new_parts = array(); |
258 | 274 | foreach($parts as $part){ |
259 | | - $new_parts[] = strtolower($part); |
| 275 | + if(!$dkim && !$dmarc) { |
| 276 | + $new_parts[] = strtolower($part); |
| 277 | + } else { |
| 278 | + $new_parts[] = $part; |
| 279 | + } |
260 | 280 | } |
261 | 281 | unset($parts); |
262 | 282 | $parts = $new_parts; |
|
557 | 577 | $i++; |
558 | 578 | } |
559 | 579 |
|
560 | | - /* |
561 | | - $i = 0; |
562 | | - $r = 0; |
563 | | - $s = 0; |
564 | | - $dns_rr = array(); |
565 | | - foreach ($lines as $line) |
566 | | - { |
567 | | - $line = trim($line); |
568 | | - if ($line != '' && substr($line,0,1) != ';' && substr($line,0,1) != '$') |
569 | | - { |
570 | | - $line = str_replace("\n",NULL,$line); |
571 | | - $i++; |
572 | | -
|
573 | | - // TODO - Find a better way to parse the SOA record. Lazy checking. |
574 | | - if ($i <= 7) |
575 | | - { |
576 | | - if ($i > 1) |
577 | | - { |
578 | | - $s++; |
579 | | - $line = str_replace("\t",NULL,$line); |
580 | | - if (!empty($line)) |
581 | | - { |
582 | | - print(strpos(";",$line)); |
583 | | - $line = substr($line,0,strpos($line,";")); |
584 | | - if ($s == 1) |
585 | | - $soa['serial'] = $line; |
586 | | - else if ($s == 2) |
587 | | - $soa['refresh'] = $line; |
588 | | - else if ($s == 3) |
589 | | - $soa['retry'] = $line; |
590 | | - else if ($s == 4) |
591 | | - $soa['expire'] = $line; |
592 | | - else if ($s == 5) |
593 | | - $soa['minimum'] = $line; |
594 | | -
|
595 | | - } |
596 | | - } |
597 | | - else |
598 | | - { |
599 | | - $line = str_replace("\t",",",$line); |
600 | | - $line = str_replace(" ",",",$line); |
601 | | - $recs = explode(",",$line); |
602 | | -
|
603 | | - foreach ($recs as $key => $rec) |
604 | | - { |
605 | | - $rec = trim($rec); |
606 | | - if($rec == '') continue; |
607 | | - //name type data aux ttl active |
608 | | - if ($key == 0) |
609 | | - { |
610 | | - if ($rec == '@') |
611 | | - { |
612 | | - $rec = $name; |
613 | | - } |
614 | | -
|
615 | | - $soa['name'] = $rec; |
616 | | - } |
617 | | -
|
618 | | - if ($key != 0 && strtolower($rec) == 'soa') |
619 | | - { |
620 | | - $typekeys[$s] = $key; |
621 | | - } |
622 | | - else if ($key > $typekey[$r]) |
623 | | - { |
624 | | - if ($rec != "" && $rec != "(") |
625 | | - { |
626 | | - $rec = explode(" ",$rec); |
627 | | -
|
628 | | - $soa['ns'] = $servers[0]['server_name']; |
629 | | - $soa['mbox'] = $rec[1]; |
630 | | - } |
631 | | - } |
632 | | - } |
633 | | - } |
634 | | - } |
635 | | - else |
636 | | - { |
637 | | - $line = str_replace("\n","",trim($line)); |
638 | | -
|
639 | | - if (!empty($line)) |
640 | | - { |
641 | | -
|
642 | | - preg_match_all('/(.*?)\s*IN\s*(A|CNAME|MX|TXT|NS|AAAA)\s*(.*)/',$line, $recs); |
643 | | -
|
644 | | - if ($recs[1][0] == '@' || trim($recs[1][0]) == "") |
645 | | - { |
646 | | - $recs[1][0] = $name; |
647 | | - } |
648 | | - $dns_rr[$r]['name'] = $recs[1][0]; |
649 | | - $dns_rr[$r]['type'] = $recs[2][0]; |
650 | | - if (strtolower($dns_rr[$r]['type'])=='mx') |
651 | | - { |
652 | | - $recs[3][0] = str_replace(" ","\t",$recs[3][0]); |
653 | | - $mx[$r] = explode("\t",$recs[3][0]); |
654 | | - for ($m=1;$m<count($mx[$r]);$m++) |
655 | | - { |
656 | | - if (!empty($mx[$r][$m])) |
657 | | - $dns_rr[$r]['data'] = $mx[$r][$m]; |
658 | | - } |
659 | | -
|
660 | | - $dns_rr[$r]['aux'] = $mx[$r][0]; |
661 | | - } |
662 | | - else if (strtolower($dns_rr[$r]['type'])=='txt') |
663 | | - { |
664 | | - $dns_rr[$r]['data'] = substr($recs[3][0],1,(strlen($recs[3][0])-2)); |
665 | | - } |
666 | | - else |
667 | | - { |
668 | | - $dns_rr[$r]['data'] = $recs[3][0]; |
669 | | - } |
670 | | -
|
671 | | - if (strtolower($dns_rr[$r]['type'])=='ns' && strtolower($dns_rr[$r]['name'])==$name) |
672 | | - { |
673 | | - unset($dns_rr[$r]); |
674 | | - } |
675 | | -
|
676 | | - $r++; |
677 | | - } |
678 | | - } |
679 | | -
|
680 | | - } |
681 | | - } |
682 | | - */ |
683 | | - |
684 | 580 | foreach ($servers as $server){ |
685 | 581 | $dns_rr[$r]['name'] = $soa['name']; |
686 | 582 | $dns_rr[$r]['type'] = 'NS'; |
|
0 commit comments