/static/PrintZoneFile.php

https://bitbucket.org/droidzone/dns-manager · PHP · 176 lines · 151 code · 14 blank · 11 comment · 28 complexity · a3c3952db49c9077d386545c0a717ab8 MD5 · raw file

  1. <?php
  2. #global $DEBUGON;
  3. $DEBUGON=true;
  4. if ($DEBUGON)
  5. {
  6. debug_print_backtrace();
  7. var_dump($_POST);
  8. }
  9. $MAIN_DOMAINNAME=$domain=$_POST['MAIN_DOMAINNAME'];
  10. $MAIN_NS=$_POST['MAIN_NS'];
  11. $MAIN_ADMINMAIL=$_POST['MAIN_ADMINMAIL'];
  12. $DOMAIN_SERIAL=$_POST['DOMAIN_SERIAL'];
  13. $DOMAIN_REFRESH=$_POST['DOMAIN_REFRESH'];
  14. $DOMAIN_RETRY=$_POST['DOMAIN_RETRY'];
  15. $DOMAIN_EXPIRE=$_POST['DOMAIN_EXPIRE'];
  16. $DOMAIN_NEGTTL=$_POST['DOMAIN_NEGTTL'];
  17. $DOMAIN_REFRESH=$_POST['DOMAIN_REFRESH'];
  18. $CONF_FILE=$_POST['CONF_FILE'];
  19. global $MENU_NAME,$MENU_URL;
  20. $MENU_NAME=array("Domains","DNS Records","View zonefile");
  21. BreadCrumb();
  22. print '
  23. <h3>Zone file:</h3>
  24. ';
  25. print '<p>';
  26. #Actual Data
  27. print $domain. ".". str_repeat('&nbsp;', 5)."IN".spc(5)."SOA".spc(5).$MAIN_NS.spc(5).$MAIN_ADMINMAIL."\t".' (';
  28. print '<br />';
  29. print spc(25).$DOMAIN_SERIAL.spc(10).'; Serial';
  30. print '<br />';
  31. print spc(25).$DOMAIN_REFRESH.spc(10).'; Refresh';
  32. print '<br />';
  33. print spc(25).$DOMAIN_RETRY.spc(10).'; Retry';
  34. print '<br />';
  35. print spc(25).$DOMAIN_EXPIRE.spc(10).'; Expire';
  36. print '<br />';
  37. print spc(25).$DOMAIN_NEGTTL.spc(3).')'.spc(10).'; Negative Cache TTL';
  38. print '<br />;<br />';
  39. $arr=$_POST['NS'];
  40. #print 'Count is '.count($arr);
  41. foreach ($_POST['NS'] as &$value) {
  42. print $domain. ".". spc(5)."IN".spc(5).'NS'.spc(5).$value.'<br />';
  43. }
  44. if (isset($_POST['MX_PREF']) && isset($_POST['MX_VAL'] ) ) {
  45. $i=0;
  46. $MX_PREF=$_POST['MX_PREF'];
  47. $MX_VAL=$_POST['MX_VAL'];
  48. foreach ($_POST['MX_PREF'] as &$value) {
  49. if ( $MX_PREF[$i] != "" && $MX_VAL[$i] != "") {
  50. print $domain. ".". spc(5)."IN".spc(5).'MX'.spc(5).$MX_PREF[$i].spc(5).$MX_VAL[$i].'<br />';
  51. $i++;
  52. }
  53. }
  54. }
  55. $A_REC=$_POST['A_REC'];
  56. $A_VAL=$_POST['A_VAL'];
  57. $i=0;
  58. foreach ($_POST['A_VAL'] as $key => $value) {
  59. //foreach ($_POST['A_VAL'] as &$value) {
  60. //print "<h3>Entered A..</h3>";
  61. //print "<p>Key is ".$key.". Rec is ".$A_REC[$key]." Value is ".$A_VAL[$key]."</p>";
  62. if ( isset($A_VAL[$key]) ) {
  63. if ( $A_VAL[$key] !== "") {
  64. //print "<h4>Entered if block</h4>";
  65. $domain=rtrim($domain, ".");
  66. if ( $A_REC[$key] !== "") {
  67. print $A_REC[$key].".".$domain. ".". spc(5)."IN".spc(5).'A'.spc(5).$A_VAL[$key].'<br />';
  68. } else {
  69. print $domain. ".". spc(5)."IN".spc(5).'A'.spc(5).$A_VAL[$key].'<br />';
  70. }
  71. }
  72. }
  73. }
  74. if (isset( $_POST['TXT_PREF']) && isset($_POST['TXT_VAL'] )) {
  75. $TXT_PREF=$_POST['TXT_PREF'];
  76. $TXT_VAL=$_POST['TXT_VAL'];
  77. $i=0;
  78. foreach ($_POST['TXT_VAL'] as &$value) {
  79. if ( $TXT_PREF[$i] != "" && $TXT_VAL[$i] != "") {
  80. print $domain. ".". spc(5).$TXT_PREF[$i]. spc(5)."IN".spc(5).'TXT'.spc(5).$TXT_VAL[$i].'<br />';
  81. $i++;
  82. }
  83. }
  84. }
  85. if (isset( $_POST['CN_PREF']) && isset($_POST['CN_VAL']) && isset($_POST['CN_NAME'] )) {
  86. $CN_PREF=$_POST['CN_PREF'];
  87. $CN_VAL=$_POST['CN_VAL'];
  88. $CN_NAME=$_POST['CN_NAME'];
  89. $i=0;
  90. foreach ($_POST['CN_VAL'] as &$value) {
  91. if ( $CN_VAL[$i] != "" && $CN_PREF[$i] != "" && $CN_NAME[$i] != "") {
  92. print $CN_VAL[$i].".".$domain. ".". spc(5).$CN_PREF[$i]. spc(5)."IN".spc(5).'CNAME'.spc(5).$CN_NAME[$i].'<br />';
  93. $i++;
  94. }
  95. }
  96. }
  97. print '</p>
  98. <p>
  99. <form action="" method="post" name="FormProcessor">
  100. <input type="hidden" name="MAIN_DOMAINNAME" value="'.$MAIN_DOMAINNAME.'">
  101. <input type="hidden" name="CONF_FILE" value="'.$CONF_FILE.'">
  102. <input type="hidden" name="MAIN_NS" value="'.$MAIN_NS.'">
  103. <input type="hidden" name="MAIN_ADMINMAIL" value="'.$MAIN_ADMINMAIL.'">
  104. <input type="hidden" name="DOMAIN_SERIAL" value="'.$DOMAIN_SERIAL.'">
  105. <input type="hidden" name="DOMAIN_REFRESH" value="'.$DOMAIN_REFRESH.'">
  106. <input type="hidden" name="DOMAIN_RETRY" value="'.$DOMAIN_RETRY.'">
  107. <input type="hidden" name="DOMAIN_EXPIRE" value="'.$DOMAIN_EXPIRE.'">
  108. <input type="hidden" name="DOMAIN_NEGTTL" value="'.$DOMAIN_NEGTTL.'">
  109. <input type="hidden" name="DOMAIN_REFRESH" value="'.$DOMAIN_REFRESH.'">';
  110. $i=0;
  111. foreach ($_POST['NS'] as &$value) {
  112. print '
  113. <input type="hidden" name="NS['.$i.']" value="'.$value.'">';
  114. $i++;
  115. }
  116. $i=0;
  117. foreach ($_POST['MX_PREF'] as &$value) {
  118. print '
  119. <input type="hidden" name="MX_PREF['.$i.']" value="'.$MX_PREF[$i].'">
  120. <input type="hidden" name="MX_VAL['.$i.']" value="'.$MX_VAL[$i].'">';
  121. $i++;
  122. }
  123. $i=0;
  124. foreach ($_POST['A_VAL'] as $key => $value) {
  125. //foreach ($_POST['A_VAL'] as &$value) {
  126. //print "<h3>Entered A..</h3>";
  127. //print "<p>Key is ".$key.". Rec is ".$A_REC[$key]." Value is ".$A_VAL[$key]."</p>";
  128. if ( isset($A_VAL[$key]) ) {
  129. if ( $A_VAL[$key] !== "") {
  130. //print "<h4>Entered if block</h4>";
  131. $A_REC[$key] = rtrim ( $A_REC[$key], "." );
  132. print '
  133. <input type="hidden" name="A_REC['.$key.']" value="'.$A_REC[$key].'">
  134. <input type="hidden" name="A_VAL['.$key.']" value="'.$A_VAL[$key].'">';
  135. }
  136. }
  137. }
  138. $i=0;
  139. foreach ($_POST['TXT_VAL'] as &$value) {
  140. print '
  141. <input type="hidden" name="TXT_PREF['.$i.']" value="'.$TXT_PREF[$i].'">
  142. <input type="hidden" name="TXT_VAL['.$i.']" value=\''.$TXT_VAL[$i].'\'>';
  143. $i++;
  144. }
  145. $i=0;
  146. foreach ($_POST['CN_VAL'] as &$value) {
  147. print '
  148. <input type="hidden" name="CN_VAL['.$i.']" value="'.$CN_VAL[$i].'">
  149. <input type="hidden" name="CN_PREF['.$i.']" value="'.$CN_PREF[$i].'">
  150. <input type="hidden" name="CN_NAME['.$i.']" value="'.$CN_NAME[$i].'">
  151. ';
  152. $i++;
  153. }
  154. $i=0;
  155. print '
  156. <button type="submit" class="btn btn-primary" name="update_dns" value="Return">Return</button>
  157. </form>
  158. </p>
  159. ';
  160. print '</body></html>';
  161. ?>