/static/AddNewRecords.php

https://bitbucket.org/droidzone/dns-manager · PHP · 282 lines · 273 code · 7 blank · 2 comment · 8 complexity · 203afadf0a0cbc7a70a4b15739748074 MD5 · raw file

  1. <?php
  2. global $DATASAVED, $DATAUNSAVED_ALERT;
  3. $DATASAVED=false;
  4. global $DEBUGON;
  5. if ($DEBUGON)
  6. {
  7. debug_print_backtrace();
  8. var_dump($_POST);
  9. }
  10. $CONF_FILE=$_POST['CONF_FILE'];
  11. $MAIN_DOMAINNAME=$domain=$_POST['MAIN_DOMAINNAME'];
  12. $MAIN_NS=$_POST['MAIN_NS'];
  13. $MAIN_ADMINMAIL=$_POST['MAIN_ADMINMAIL'];
  14. $DOMAIN_SERIAL=$_POST['DOMAIN_SERIAL'];
  15. $DOMAIN_REFRESH=$_POST['DOMAIN_REFRESH'];
  16. $DOMAIN_RETRY=$_POST['DOMAIN_RETRY'];
  17. $DOMAIN_EXPIRE=$_POST['DOMAIN_EXPIRE'];
  18. $DOMAIN_NEGTTL=$_POST['DOMAIN_NEGTTL'];
  19. $DOMAIN_REFRESH=$_POST['DOMAIN_REFRESH'];
  20. global $MENU_NAME,$MENU_URL;
  21. $MENU_NAME=array("Domains","Add new records");
  22. BreadCrumb();
  23. #Close the DIV tags of the Main page.
  24. print '
  25. <div class="page-header">
  26. <h3>Add new records</h3>
  27. </div>
  28. <div>
  29. <h4>Domain Name:'.$MAIN_DOMAINNAME.'</h4>
  30. <h5>Zone file: '.$CONF_FILE.'</h5>
  31. ';
  32. #print_r($_POST);
  33. print '
  34. <form action="" method="post" name="FormProcessor">
  35. <input type="hidden" name="FORMSENDER" value="AddNewRecords">
  36. <input type="hidden" name="MAIN_DOMAINNAME" value="'.$MAIN_DOMAINNAME.'">
  37. <input type="hidden" name="CONF_FILE" value="'.$CONF_FILE.'">
  38. <input type="hidden" name="MAIN_NS" value="'.$MAIN_NS.'">
  39. <input type="hidden" name="MAIN_ADMINMAIL" value="'.$MAIN_ADMINMAIL.'">
  40. <input type="hidden" name="DOMAIN_SERIAL" value="'.$DOMAIN_SERIAL.'">
  41. <input type="hidden" name="DOMAIN_REFRESH" value="'.$DOMAIN_REFRESH.'">
  42. <input type="hidden" name="DOMAIN_RETRY" value="'.$DOMAIN_RETRY.'">
  43. <input type="hidden" name="DOMAIN_EXPIRE" value="'.$DOMAIN_EXPIRE.'">
  44. <input type="hidden" name="DOMAIN_NEGTTL" value="'.$DOMAIN_NEGTTL.'">
  45. <input type="hidden" name="DOMAIN_REFRESH" value="'.$DOMAIN_REFRESH.'">';
  46. $i=0;
  47. if (isset($_POST['NS']))
  48. {
  49. foreach ($_POST['NS'] as &$value) {
  50. print '
  51. <input type="hidden" name="NS['.$i.']" value="'.$value.'">';
  52. $lastNS=$i;
  53. $i++;
  54. }
  55. print '<input type="hidden" name="lastNS" value="'.$lastNS.'">';
  56. }
  57. $MX_PREF=$_POST['MX_PREF'];
  58. $MX_VAL=$_POST['MX_VAL'];
  59. $i=0;
  60. foreach ($_POST['MX_PREF'] as &$value) {
  61. print '
  62. <input type="hidden" name="MX_PREF['.$i.']" value="'.$MX_PREF[$i].'">
  63. <input type="hidden" name="MX_VAL['.$i.']" value="'.$MX_VAL[$i].'">';
  64. $lastMX=$i;
  65. $i++;
  66. }
  67. print '<input type="hidden" name="lastMX" value="'.$lastMX.'">';
  68. $A_REC=$_POST['A_REC'];
  69. $A_VAL=$_POST['A_VAL'];
  70. $i=0;
  71. foreach ($_POST['A_VAL'] as &$value) {
  72. print '
  73. <input type="hidden" name="A_REC['.$i.']" value="'.$A_REC[$i].'">
  74. <input type="hidden" name="A_VAL['.$i.']" value="'.$A_VAL[$i].'">';
  75. $lastA=$i;
  76. $i++;
  77. }
  78. print '<input type="hidden" name="lastA" value="'.$lastA.'">';
  79. $TXT_PREF=$_POST['TXT_PREF'];
  80. $TXT_VAL=$_POST['TXT_VAL'];
  81. $i=0;
  82. foreach ($_POST['TXT_VAL'] as &$value) {
  83. print '
  84. <input type="hidden" name="TXT_PREF['.$i.']" value="'.$TXT_PREF[$i].'">
  85. <input type="hidden" name="TXT_VAL['.$i.']" value=\''.$TXT_VAL[$i].'\'>';
  86. $lastTXT=$i;
  87. $i++;
  88. }
  89. print '<input type="hidden" name="lastTXT" value="'.$lastTXT.'">';
  90. $i=0;
  91. $CN_VAL=$_POST['CN_VAL'];
  92. $CN_PREF=$_POST['CN_PREF'];
  93. $CN_NAME=$_POST['CN_NAME'];
  94. foreach ($_POST['CN_VAL'] as &$value) {
  95. print '
  96. <input type="hidden" name="CN_VAL['.$i.']" value="'.$CN_VAL[$i].'">
  97. <input type="hidden" name="CN_PREF['.$i.']" value="'.$CN_PREF[$i].'">
  98. <input type="hidden" name="CN_NAME['.$i.']" value="'.$CN_NAME[$i].'">
  99. ';
  100. $lastCN=$i;
  101. $i++;
  102. }
  103. print '<input type="hidden" name="lastCN" value="'.$lastCN.'">';
  104. $i=0;
  105. print '
  106. <form action="" method="post" name="FormProcessor">
  107. NS Records
  108. <table class="table">
  109. <thead>
  110. <tr>
  111. <th>#</th>
  112. <th>Type</th>
  113. <th>Value</th>
  114. </tr>
  115. </thead>
  116. <tbody>
  117. ';
  118. if (!isset($lastNS))
  119. {
  120. $lastNS=0;
  121. }
  122. for ($i=($lastNS+1);$i<=($lastNS+1+5);$i++)
  123. {
  124. print '
  125. <tr>
  126. <td>'.$i.'</td>
  127. <td>NS</td>
  128. <td>
  129. <input type="text" name="NS['.$i.']" value="">
  130. </td>
  131. </tr>';
  132. }
  133. print '
  134. </tbody>
  135. </table>
  136. MX Records
  137. <table class="table">
  138. <thead>
  139. <tr>
  140. <th>#</th>
  141. <th>Type</th>
  142. <th>Preference</th>
  143. <th>Value</th>
  144. </tr>
  145. </thead>
  146. <tbody>
  147. ';
  148. for ($i=($lastMX+1);$i<=($lastMX+1+3);$i++)
  149. {
  150. print '
  151. <tr>
  152. <td>'.$i.'</td>
  153. <td>MX</td>
  154. <td>
  155. <input type="text" name="MX_PREF['.$i.']" value="">
  156. </td>
  157. <td>
  158. <input type="text" name="MX_VAL['.$i.']" value="">
  159. </td>
  160. </tr>';
  161. }
  162. print '
  163. </tbody>
  164. </table>
  165. A Records
  166. <table class="table">
  167. <thead>
  168. <tr>
  169. <th>#</th>
  170. <th>Type</th>
  171. <th>Record Value (Eg: denver, for denver.mysite.com)</th>
  172. <th>Value (IP address)</th>
  173. </tr>
  174. </thead>
  175. <tbody>
  176. ';
  177. for ($i=($lastA+1);$i<=($lastA+1+5);$i++)
  178. {
  179. print '
  180. <tr>
  181. <td>'.$i.'</td>
  182. <td>A</td>
  183. <td>
  184. <input type="text" name="A_REC['.$i.']" value="">
  185. </td>
  186. <td>
  187. <input type="text" name="A_VAL['.$i.']" value="">
  188. </td>
  189. </tr>';
  190. }
  191. print '
  192. </tbody>
  193. </table>
  194. CNAME Records
  195. <table class="table">
  196. <thead>
  197. <tr>
  198. <th>#</th>
  199. <th>Type</th>
  200. <th>Preference (Eg: 3600) </th>
  201. <th>Value (Eg: * or mail. etc)</th>
  202. <th>CNAME entry (Other hostname)</th>
  203. </tr>
  204. </thead>
  205. <tbody>
  206. ';
  207. for ($i=($lastCN+1);$i<=($lastCN+1+5);$i++)
  208. {
  209. print '
  210. <tr>
  211. <td>'.$i.'</td>
  212. <td>CNAME</td>
  213. <td>
  214. <input type="text" name="CN_VAL['.$i.']" value="">
  215. </td>
  216. <td>
  217. <input type="text" name="CN_PREF['.$i.']" value="">
  218. </td>
  219. <td>
  220. <input type="text" name="CN_NAME['.$i.']" value="">
  221. </td>
  222. </tr>';
  223. }
  224. print '
  225. </tbody>
  226. </table>
  227. TXT Records
  228. <table class="table">
  229. <thead>
  230. <tr>
  231. <th>#</th>
  232. <th>Type</th>
  233. <th>Preference (Eg: 3600) </th>
  234. <th>Value (Eg: "v=spf1 a:hermes.joelns.com" )</th>
  235. </tr>
  236. </thead>
  237. <tbody>
  238. ';
  239. for ($i=($lastTXT+1);$i<=($lastTXT+1+2);$i++)
  240. {
  241. print '
  242. <tr>
  243. <td>'.$i.'</td>
  244. <td>TXT</td>
  245. <td>
  246. <input type="text" name="TXT_PREF['.$i.']" value="">
  247. </td>
  248. <td>
  249. <input type="text" name="TXT_VAL['.$i.']" value="">
  250. </td>
  251. </tr>';
  252. }
  253. print '
  254. </tbody>
  255. </table>
  256. <div class="row"></div>
  257. </div>
  258. <div class="alert alert-danger hidden-phone">
  259. <a class="close" data-dismiss="alert">×</a>
  260. <b>Note!</b> Updating DNS does not automatically commit changes to zonefiles. You need to "Save Changes" to commit them.
  261. </div>
  262. <button type="submit" class="btn btn-primary" name="update_dns">Update DNS</button>
  263. <button type="reset" class="btn btn-primary" name="Reset">Reset</button>
  264. <button type="submit" class="btn btn-primary" name="cancel_edits">Cancel Edits</button>
  265. </div>
  266. </form>
  267. </div>';
  268. print '</body></html>';
  269. ?>