PageRenderTime 51ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/ipplan/user/modifydnsrecordform.php

#
PHP | 155 lines | 106 code | 19 blank | 30 comment | 5 complexity | 273f91390349cef252b730cdeb117776 MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. // IPplan v4.92a
  3. // Aug 24, 2001
  4. //
  5. // Modified by Tony D. Koehn Feburary 2003
  6. //
  7. // This program is free software; you can redistribute it and/or modify
  8. // it under the terms of the GNU General Public License as published by
  9. // the Free Software Foundation; either version 2 of the License, or
  10. // (at your option) any later version.
  11. //
  12. // This program is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. // GNU General Public License for more details.
  16. //
  17. // You should have received a copy of the GNU General Public License
  18. // along with this program; if not, write to the Free Software
  19. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. //
  21. require_once("../ipplanlib.php");
  22. require_once("/usr/share/php/adodb/adodb.inc.php");
  23. require_once("../class.dbflib.php");
  24. require_once("../layout/class.layout");
  25. require_once("../auth.php");
  26. require_once("../class.xptlib.php");
  27. $auth = new SQLAuthenticator(REALM, REALMERROR);
  28. // And now perform the authentication
  29. $grps=$auth->authenticate();
  30. // save the last customer used
  31. // must set path else Netscape gets confused!
  32. setcookie("ipplanCustomer","$cust",time() + 10000000, "/");
  33. // set language
  34. isset($_COOKIE["ipplanLanguage"]) && myLanguage($_COOKIE['ipplanLanguage']);
  35. //setdefault("window",array("bgcolor"=>"white"));
  36. //setdefault("table",array("cellpadding"=>"0"));
  37. //setdefault("text",array("size"=>"2"));
  38. $title=my_("Add / Edit DNS Host");
  39. newhtml($p);
  40. insert($p, $h = wheader("IPPlan - $title"));
  41. insert($h, script("", array("type"=>"text/javascript", "src"=>"../cookies.js")));
  42. insert($h, script("", array("type"=>"text/javascript", "src"=>"../phpserializer.js")));
  43. insert($h, script("", array("type"=>"text/javascript", "src"=>"../ipplanlib.js")));
  44. $w=myheading($p, $title, true);
  45. // explicitly cast variables as security measure against SQL injection
  46. list($cust, $dataid, $zoneid, $action, $domain, $sortorder, $host, $recordtype, $iphostname) = myRegister("I:cust I:dataid I:zoneid S:action S:domain I:sortorder S:host S:recordtype S:iphostname");
  47. if (!$_GET) {
  48. myError($w,$p, my_("You cannot reload or bookmark this page!"));
  49. }
  50. // basic sequence is connect, search, interpret search
  51. // result, close connection
  52. $ds=new IPplanDbf() or myError($w,$p, my_("Could not connect to database"));
  53. insert($w,heading(3, my_("Host Record for domain: ").$domain));
  54. insert($w, $f = form(array("name"=>"ENTRY",
  55. "method"=>"post",
  56. "action"=>"modifydnsrecord.php")));
  57. insert($f, $con=container("fieldset",array("class"=>"fieldset")));
  58. insert($con, $legend=container("legend",array("class"=>"legend")));
  59. insert($legend, text(my_("DNS record")));
  60. // Use the same form for adding or editing. Setup page & variables based on action.
  61. if ($action=='add') {
  62. $host="";
  63. $RecordType="A";
  64. $iphostname="";
  65. insert($con,hidden(array("name"=>"action", "value"=>"add")));
  66. insert($con,hidden(array("name"=>"zoneid", "value"=>"$zoneid")));
  67. $myTitle="Add";
  68. }
  69. else {
  70. insert($con,hidden(array("name"=>"action", "value"=>"edit")));
  71. insert($con,hidden(array("name"=>"zoneid", "value"=>"$zoneid")));
  72. insert($con,hidden(array("name"=>"dataid", "value"=>"$dataid")));
  73. $myTitle="Edit";
  74. }
  75. insert($con,hidden(array("name"=>"domain", "value"=>"$domain")));
  76. insert($con,hidden(array("name"=>"cust", "value"=>"$cust")));
  77. myFocus($p, "ENTRY", "host");
  78. insert($con,textbr(my_("Host Name")));
  79. insert($con,block("<small><i>"));
  80. insert($con,textbr(my_("Terminate Fully Qualified Domand Name's (FQDN) with a . eg. mywwwserver.com. to signify 'This domain'")));
  81. insert($con,block("</small></i>"));
  82. insert($con,input_text(array("name"=>"host",
  83. "value"=>"$host",
  84. "size"=>"40",
  85. "maxlength"=>"253")));
  86. insert($con,anchor("JavaScript:thisdomain()",
  87. my_("This domain")));
  88. // add some javascript magic to follow a link if field is completed
  89. insert($p, script('
  90. function thisdomain() {
  91. document.ENTRY.host.value="'.$domain.'.";
  92. } ', array("language"=>"JavaScript", "type"=>"text/javascript")));
  93. insert($con,textbrbr(my_("Record Type")));
  94. insert($con,selectbox(array("A"=>"A",
  95. "CNAME"=>"CNAME",
  96. "MX"=>"MX",
  97. "TXT"=>"TXT",
  98. "KEY"=>"KEY",
  99. "SRV"=>"SRV",
  100. "NS"=>"NS",
  101. "AFSDB"=>"AFSDB"),
  102. array("name"=>"recordtype"), $recordtype));
  103. insert($con,textbrbr(my_("IP / Hostname")));
  104. insert($con,block("<small><i>"));
  105. insert($con,textbr(my_("For MX records, format is \"preference hostname\", eg. \"10 mymailserver.com.\"")));
  106. insert($con,block("</small></i>"));
  107. insert($con,input_text(array("name"=>"iphostname",
  108. "value"=>"$iphostname",
  109. "size"=>"40",
  110. "maxlength"=>"250")));
  111. insert($con,textbrbr(my_("Sort Order")));
  112. insert($con,input_text(array("name"=>"sortorder",
  113. "value"=>"$sortorder",
  114. "size"=>"6",
  115. "maxlength"=>"6")));
  116. insert($f,submit(array("value"=>my_("Save"))));
  117. insert($f,freset(array("value"=>my_("Clear"))));
  118. myCopyPaste($f, "ipplanCPdnsrecord", "ENTRY");
  119. // create the export view form
  120. $export = new exportForm();
  121. $export->setInfo(array(array("customer_ID", "customer_description", "data_ID", "domain", "sort_order", "host", "record_type", "ip_hostname"),
  122. array($cust, $ds->getCustomerDescrip($cust), $dataid, $domain, $sortorder, $host, $recordtype, $iphostname)));
  123. $export->createExportForm($w, NULL);
  124. printhtml($p);
  125. ?>