예제 #1
0
 /**
  * returns a pre-filled form to modify primary records
  *
  *@access public
  *@param array $params list of params
  *@return string HTML pre-filled form
  */
 function printModifyForm($params)
 {
     global $config, $lang;
     global $l;
     global $hiddenfields;
     list($advanced, $ipv6, $nbrows) = $params;
     if ($nbrows < 1) {
         $nbrows = 1;
     }
     $this->error = "";
     $result = "";
     $deletecount = 0;
     $result .= sprintf("<script type='text/javascript'>function v(t){" . "n=t.value;if(n.substr(-1)==='.')return;" . "zonename=document.forms[0]['zonename'].value;" . "if(n.match(zonename+'\$')==zonename)" . "alert('%s '+n+'.'+zonename+'%s')}</script>\n", $l['str_js_dotvalidate1'], $l['str_js_dotvalidate2']);
     // TODO use zoneid instead of zonename & zonetype
     $result .= sprintf('<form method="POST">%s', $hiddenfields);
     $result .= sprintf('<input type="hidden" name="zonename" value="%s">', $this->zonename);
     $result .= sprintf('<input type="hidden" name="zonetype" value="%s">', $this->zonetype);
     $result .= sprintf('<input type="hidden" name="modified" value="1">');
     // if advanced, say it to modified - in case
     // of temporary use of advanced interface, not in
     // user prefs.
     if ($advanced) {
         $result .= sprintf('<input type="hidden" name="advanced" value="1">');
     }
     # BEGIN SOA-PARAMS
     $modifyheader = '<h3 class="boxheader">%s</h3>';
     if ($advanced) {
         $soafmt = '<p>%s</p>' . '<table class="globalparams"><tr>' . '<td class="left">%s</td>' . '<td><input type="text" name="%s" value="%s">%s</td>' . '</tr></table>';
         // print global params ($TTL)
         $result .= sprintf($modifyheader, $l['str_primary_global_params']);
         $fixed = $this->FixSOAParam($this->defaultttl, 86400);
         $result .= sprintf($soafmt, $l['str_primary_ttl_explanation'], $l['str_primary_default_ttl'], 'defaultttl', $this->defaultttl, $fixed);
         // print SOA params
         $result .= sprintf($modifyheader, $l['str_primary_soa_params']);
         # refresh should be min 24h
         $fixed = $this->FixSOAParam($this->refresh, 86400);
         $result .= sprintf($soafmt, $l['str_primary_refresh_interval_expl'], $l['str_primary_refresh_period'], 'soarefresh', $this->refresh, $fixed);
         # retry should be min 3h
         $fixed = $this->FixSOAParam($this->retry, 10800);
         $result .= sprintf($soafmt, $l['str_primary_retry_interval_expl'], $l['str_primary_retry_interval'], 'soaretry', $this->retry, $fixed);
         # expiry should be min 1000h (~42d)
         $fixed = $this->FixSOAParam($this->expiry, 3600000);
         $result .= sprintf($soafmt, $l['str_primary_expire_time_expl'], $l['str_primary_expire_time'], 'soaexpire', $this->expiry, $fixed);
         # minimum should be max 3h
         $fixed = $this->FixSOAParam($this->minimum, 10800, 1);
         $result .= sprintf($soafmt, $l['str_primary_negative_caching_expl'], $l['str_primary_negative_caching'], 'soaminimum', $this->minimum, $fixed);
     }
     # END SOA-PARAMS
     # BEGIN NS-RECORDS
     // retrieve NS names
     $nsxnames = GetListOfServerNames();
     $nsxnamesmandatory = GetListOfServerNames(1);
     $nsxnamesoptional = array();
     if (count($this->ns) == 0) {
         $nsxnamesoptional = array_diff($nsxnames, $nsxnamesmandatory);
     }
     $result .= sprintf('<h3 class="boxheader">%s</h3>', $l['str_primary_name_server_title']);
     $result .= '<p>';
     $result .= sprintf($l['str_primary_name_server_expl_with_sample_x'], $nsxnames[0]);
     $result .= "</p>\n";
     $result .= sprintf('<table><tr><th>%s</th>', $l['str_primary_name']);
     if ($advanced) {
         $result .= '<th>TTL</th>';
     }
     $result .= sprintf('<th>%s</th>', $l['str_delete']);
     $result .= "</tr>\n";
     $usednsxnames = array();
     $keys = array_keys($this->ns);
     while ($key = array_shift($keys)) {
         $result .= sprintf('<tr><td>%s</td>', $key);
         if ($advanced) {
             $result .= sprintf('<td>%s</td>', $this->PrintTTL($this->nsttl[$key]));
         }
         $result .= '<td>';
         // if ns is mandatory, never delete it
         $keytocompare = substr($key, 0, -1);
         if (!in_array($keytocompare, $nsxnamesmandatory)) {
             $deletecount++;
             $result .= sprintf('<input type="checkbox" name="delete%d" value="ns(%s-%s)">', $deletecount, $key, $this->nsid[$key]);
         } else {
             array_push($usednsxnames, $keytocompare);
         }
         $result .= "</td></tr>\n";
     }
     // compare $usednsxnames and $nsxnamesmandatory. If differences, add missing ones.
     $missingns = array_diff($nsxnamesmandatory, $usednsxnames);
     $nscounter = 0;
     while ($missingnsname = array_pop($missingns)) {
         $nscounter++;
         $result .= sprintf('<tr><td><input type="hidden" name="ns%d" value="%s">%s</td>', $nscounter, $missingnsname, $missingnsname);
         if ($advanced) {
             $result .= sprintf('<td><input type="text" name="nsttl%d" size="8" value="%s"></td>', $nscounter, $l['str_primary_default']);
         }
         $result .= "<td></td></tr>\n";
     }
     $nscounter++;
     for ($count = 1; $count <= $nbrows; $count++) {
         $result .= sprintf('<tr><td><input type="text" onchange="v(this)" name="ns%d" value="%s"></td>', $nscounter, isset($nsxnamesoptional[$count]) ? $nsxnamesoptional[$count] : '');
         if ($advanced) {
             $result .= sprintf('<td><input type="text" name="nsttl%d" size="8" value="%s"></td>', $nscounter, $l['str_primary_default']);
         }
         $nscounter++;
         $result .= '</tr>';
     }
     $result .= '</table>';
     # END NS-RECORDS
     if ($this->reversezone) {
         $v6 = preg_match("/\\.ip6\\.(arpa|int)\$/", $this->zonename);
         $result .= sprintf('<h3 class="boxheader">%s</h3>', $l['str_primary_ptr_title']);
         $result .= sprintf('<p>%s</p><p>%s:<br><tt>%s</tt></p><p>%s<p>', $l['str_primary_ptr_expl'], $l['str_primary_ptr_sample'], $l['str_primary_ptr_sample_content'], $l['str_primary_ptr_ipv6_note']);
         $result .= '<table><tr><td class="left">';
         $result .= sprintf($l['str_primary_ptr_record_modify_a_x'], $v6 ? "AAAA" : "A", $config->sitename);
         $result .= '</td><td><input type=checkbox name="modifya"></td></tr></table>';
         $result .= '<table><tr><th>';
         $result .= sprintf($l['str_primary_ptr_ip_under_x'], $this->zonename);
         $result .= sprintf('</th><th>%s</th>', $l['str_primary_name']);
         if ($advanced) {
             $result .= '<th>TTL</th>';
         }
         $result .= sprintf('<th>%s</th>', $l['str_delete']);
         $counter = 0;
         while (isset($this->ptr[$counter])) {
             $deletecount++;
             $result .= sprintf('<tr><td>%s</td><td>%s</td>', $this->ptr[$counter], $this->ptrname[$counter]);
             if ($advanced) {
                 $result .= sprintf('<td>%s</td>', $this->PrintTTL($this->ptrttl[$counter]));
             }
             $result .= sprintf('<td><input type="checkbox" name="delete%d" value="ptr(%s/%s-%s)"></td></tr>', $deletecount, $this->ptr[$counter], $this->ptrid[$counter], $this->ptrname[$counter]);
             $counter++;
         }
         $counter = 0;
         $keys = array_keys($this->ptr);
         while ($key = array_shift($keys)) {
             $deletecount++;
             $counter++;
         }
         $ptrcounter = 0;
         for ($count = 1; $count <= $nbrows; $count++) {
             $ptrcounter++;
             $result .= '<tr>';
             $result .= sprintf('<td><input type="text" name="ptr%d"></td>', $ptrcounter);
             $result .= sprintf('<td><input type="text" name="ptrname%d"></td>', $ptrcounter);
             if ($advanced) {
                 $result .= sprintf('<td><input type="text" name="ptrttl%d" size="8" value="%s"</td>', $ptrcounter, $l['str_primary_default']);
             }
             $result .= '<td></td></tr>';
         }
         $result .= '</table>';
         if ($advanced) {
             $result .= sprintf('%s', $l['str_primary_ptr_generate']);
             $result .= '<table><tr><td>$GENERATE ';
             $result .= '<input type="text" name="gen1">-<input type="text" name="gen2"> ';
             $result .= 'PTR <input type="text" name="gen3"></td></tr></table>';
         }
         if (!ereg('in-addr.arpa$', $this->zonename)) {
             # BEGIN SUB-RECORDS
             $result .= sprintf('<h3 class="boxheader">%s</h3', $l['str_primary_sub_zones_title']);
             $result .= sprintf('<p>%s</p>', sprintf($l['str_primary_sub_zones_expl_on_x_x'], $config->sitename, $this->zonename));
             $result .= '<table>';
             $result .= sprintf('<tr><th>%s</th><th>NS</th>', $l['str_primary_sub_zones_zone']);
             if ($advanced) {
                 $result .= '<th>TTL';
             }
             $result .= sprintf('<th>%s</th>', $l['str_delete']);
             $counter = 0;
             while (isset($this->subns[$counter])) {
                 if (strstr($this->subns[$counter], "-") !== FALSE) {
                     $counter++;
                     continue;
                 }
                 $deletecount++;
                 $result .= sprintf('<tr><td>%s</td><td>%s</td>', $this->subns[$counter], $this->subnsa[$counter]);
                 if ($advanced) {
                     $result .= sprintf('<td>%s</td>', $this->PrintTTL($this->subnsttl[$counter]));
                 }
                 $result .= sprintf('<td><input type="checkbox" name="delete%d" value="subns(%s/%s)"></td></tr>', $deletecount, $this->subns[$counter], $this->subnsid[$counter]);
                 $counter++;
             }
             $subnscounter = 0;
             for ($count = 1; $count <= $nbrows; $count++) {
                 $subnscounter++;
                 $result .= sprintf('<tr><td><input type="text" name="subns%d"></td>', $subnscounter);
                 $result .= sprintf('<td><input type="text" name="subnsa%d"></td>', $subnscounter);
                 if ($advanced) {
                     $result .= sprintf('<td><input type="text" name="subnsttl%d" size="8" value="%s"></td>', $subnscounter, $l['str_primary_default']);
                 }
             }
             $result .= "</table>\n";
             # END SUB-RECORDS
         } else {
             # BEGIN REVSUB-RECORDS
             $result .= sprintf('<h3 class="boxheader">%s</h3>', $l['str_primary_reverse_sub_zones_title']);
             $result .= sprintf('<p>%s<br>%s<br>%s</p>', sprintf($l['str_primary_reverse_sub_zones_delegation_x'], $config->sitename), sprintf($l['str_primary_reverse_sub_zones_delegation_expl_x_x'], $this->zonename, $config->sitename), $l['str_primary_reverse_sub_zones_delegation_how']);
             $result .= sprintf('<table><tr><th>%s</th>', $l['str_primary_reverse_sub_zone_range']);
             $result .= sprintf('<th>%s</th>', sprintf($l['str_primary_reverse_sub_zone_delegated_to_user_x'], ""));
             $result .= sprintf('<th>TTL</th><th>%s</th></tr>', $l['str_delete']);
             $counter = 0;
             while (isset($this->delegatefromto[$counter])) {
                 $deletecount++;
                 $result .= '<tr>';
                 list($from, $to) = split('-', $this->delegatefromto[$counter]);
                 $result .= sprintf('<td>%s&nbsp;%s%s%s</td>', $l['str_primary_reverse_sub_zone_range_from'], $from, $l['str_primary_reverse_sub_zone_range_to'], $to);
                 $result .= sprintf('<td>%s</td>', $this->delegateuser[$counter]);
                 if ($advanced) {
                     $result .= sprintf('<td>%s</td>', $this->PrintTTL($this->delegatettl[$counter]));
                 }
                 $result .= sprintf('<td><input type="checkbox" name="delete%d" value="delegate(%d)"></td>', $deletecount, $this->delegatefromto[$counter]);
                 $result .= '</tr>';
                 $counter++;
             }
             $subnscounter = 0;
             for ($count = 1; $count <= $nbrows; $count++) {
                 $subnscounter++;
                 $result .= '<tr><td>';
                 $result .= sprintf('%s&nbsp;<input type="text" size="3" name="delegatefrom%d">', $l['str_primary_reverse_sub_zone_range_from'], $subnscounter);
                 $result .= sprintf('%s&nbsp;<input type="text" size="3" name="delegateto%d">', $l['str_primary_reverse_sub_zone_range_to'], $subnscounter);
                 $result .= '</td><td>';
                 $result .= sprintf('&nbsp;<input type="text" size="10" name="delegateuser%d"></td>', $subnscounter);
                 if ($advanced) {
                     $result .= sprintf('<td><input type="text" name="delegatettl%d" size="8" value="%s"></td>', $subnscounter, $l['str_primary_default']);
                 }
                 $result .= "</tr>\n";
             }
             $result .= "</table>\n";
             # BEGIN REVSUB-RECORDS
         }
     } else {
         // not reverse zone
         # BEGIN MX-RECORDS
         $result .= sprintf('<h3 class="boxheader">%s</h3>', $l['str_primary_mail_exchanger_title']);
         $result .= sprintf('<p>%s<br>%s</p>', sprintf($l['str_primary_mx_expl_with_sample_x'], $this->zonename), $l['str_primary_mx_expl_for_pref']);
         $result .= sprintf('<table><tr><th>%s</th><th>%s</th><th>%s</th>', $l['str_primary_name'], $l['str_primary_mx_pref'], $l['str_primary_mx_name']);
         if ($advanced) {
             $result .= '<th>TTL</th>';
         }
         $result .= sprintf('<th>%s</th></tr>', $l['str_delete']);
         $counter = 0;
         while (isset($this->mx[$counter])) {
             $deletecount++;
             $result .= '<tr>';
             $result .= sprintf('<td>%s</td>', $this->mxsrc[$counter]);
             $result .= sprintf('<td>%s</td>', $this->mxpref[$counter]);
             $result .= sprintf('<td>%s</td>', $this->mx[$counter]);
             if ($advanced) {
                 $result .= sprintf('<td>%s</td>', $this->PrintTTL($this->mxttl[$counter]));
             }
             $result .= sprintf('<td><input type="checkbox" name="delete%d" value="mx(%s/%s-%s)"></td>', $deletecount, $this->mxsrc[$counter], $this->mxid[$counter], $this->mx[$counter]);
             $result .= '</tr>';
             $counter++;
         }
         $counter = 0;
         $keys = array_keys($this->mx);
         while ($key = array_shift($keys)) {
             $deletecount++;
             $counter++;
         }
         $mxcounter = 0;
         for ($count = 1; $count <= $nbrows; $count++) {
             $mxcounter++;
             $result .= '<tr>';
             $result .= sprintf('<td><input type="text" onchange="v(this)" name="mxsrc%d"></td>', $mxcounter);
             $result .= sprintf('<td><input type="text" size="5" maxlength="5" name="mxpref%d"></td>', $mxcounter);
             $result .= sprintf('<td><input type="text" onchange="v(this)" name="mx%d"></td>', $mxcounter);
             if ($advanced) {
                 $result .= sprintf('<td><input type="text" name="mxttl%d" size="8" value="%s"></td>', $mxcounter, $l['str_primary_default']);
             }
             $result .= '<td></td></tr>';
         }
         $result .= '</table>';
         # END MX-RECORDS
         # BEGIN A-RECORDS
         $result .= sprintf('<h3 class="boxheader">%s</h3>', $l['str_primary_a_record_title']);
         $result .= sprintf('<p>%s<br>%s</p>', sprintf($l['str_primary_a_record_what_you_want_before_x_x_x'], $this->zonename, $this->zonename, $this->zonename), $l['str_primary_a_record_expl']);
         $result .= '<table><tr>';
         $result .= sprintf('<td class="left">%s</td>', sprintf($l['str_primary_a_record_modify_ptr_x'], $config->sitename));
         $result .= '<td><input type=checkbox name="modifyptr"></td></tr></table>';
         $result .= sprintf('<table><th>%s</th><th>IP</th>', $l['str_primary_name']);
         if ($advanced) {
             $result .= '<th>TTL</th>';
         }
         $result .= sprintf('<th>%s</th>', $l['str_delete']);
         $counter = 0;
         while (isset($this->a[$counter])) {
             $deletecount++;
             $result .= '<tr>';
             $result .= sprintf('<td>%s</td><td>%s</td>', $this->a[$counter], $this->aip[$counter]);
             if ($advanced) {
                 $result .= sprintf('<td>%s</td>', $this->PrintTTL($this->attl[$counter]));
             }
             $result .= sprintf('<td><input type="checkbox" name="delete%d" value="a(%s/%s-%s)"></td>', $deletecount, $this->a[$counter], $this->aid[$counter], $this->aip[$counter]);
             $result .= '</tr>';
             $counter++;
         }
         $counter = 0;
         $keys = array_keys($this->a);
         while ($key = array_shift($keys)) {
             $deletecount++;
             $counter++;
         }
         $acounter = 0;
         for ($count = 1; $count <= $nbrows; $count++) {
             $acounter++;
             $result .= '<tr>';
             $result .= sprintf('<td><input type="text" onchange="v(this)" name="aname%d"></td>', $acounter);
             $result .= sprintf('<td><input type="text" name="a%d"></td>', $acounter);
             if ($advanced) {
                 $result .= sprintf('<td><input type="text" name="attl%d" size="8" value="%s"></td>', $acounter, $l['str_primary_default']);
             }
             $result .= '<td></td></tr>';
         }
         $result .= '</table>';
         # END A-RECORDS
         # BEGIN AAAA-RECORDS
         if ($this->user->ipv6) {
             $result .= '
     <h3 class="boxheader">' . $l['str_primary_ipv6_record_title'] . '</h3>
     <p>' . sprintf($l['str_primary_ipv6_record_expl_before_x_x_x'], $this->zonename, $this->zonename, $this->zonename) . '<br>
     ' . $l['str_primary_ipv6_record_expl_zone_and_round_robin'] . '
     </p>
     <table>
     <tr><td class="left">' . sprintf($l['str_primary_ipv6_record_modify_reverse_x'], $config->sitename) . '</td><td><input type=checkbox name="modifyptripv6"></td></tr>
     </table>
     <table>
     <th>' . $l['str_primary_name'] . '<th>IPv6';
             if ($advanced) {
                 $result .= '<th>TTL';
             }
             $result .= '<th>' . $l['str_delete'] . '
     ';
             $counter = 0;
             while (isset($this->aaaa[$counter])) {
                 $deletecount++;
                 // if advanced, print TTL fields
                 $result .= '<tr>
           <td>' . $this->aaaa[$counter] . '</td>
           <td>' . $this->aaaaip[$counter] . '</td>';
                 if ($advanced) {
                     $result .= '<td>' . $this->PrintTTL($this->aaaattl[$counter]) . '</td>
         ';
                 }
                 $result .= '
           <td><input type="checkbox" name="delete' . $deletecount . '" value="aaaa(' . $this->aaaa[$counter] . '/' . $this->aaaaid[$counter] . ')"></td></tr>
       ';
                 $counter++;
             }
             $counter = 0;
             $keys = array_keys($this->aaaa);
             while ($key = array_shift($keys)) {
                 $deletecount++;
                 $counter++;
             }
             $aaaacounter = 0;
             for ($count = 1; $count <= $nbrows; $count++) {
                 $aaaacounter++;
                 $result .= '
       <tr><td><input type="text" onchange="v(this)" name="aaaaname' . $aaaacounter . '"></td>
           <td><input type="text" name="aaaa' . $aaaacounter . '"></td>';
                 if ($advanced) {
                     $result .= '
         <td><input type="text" name="aaaattl' . $aaaacounter . '" size="8" value="' . $l['str_primary_default'] . '"></td>
         ';
                 }
                 $result .= '<td></td></tr>';
             }
             $result .= '
     </table>
     ';
         }
         // end IPv6
         # END AAAA-RECORDS
         # BEGIN CNAME-RECORDS
         $result .= '
   <h3 class="boxheader">' . $l['str_primary_cname_title'] . '</h3>
   <p>' . $l['str_primary_cname_expl'] . '
   </p>
   <table>
   <th>' . $l['str_primary_cname_alias'] . '
   <th>' . $l['str_primary_cname_name_a_record'];
         if ($advanced) {
             $result .= '<th>TTL';
         }
         $result .= '<th>' . $l['str_delete'] . '
         ';
         $counter = 0;
         $keys = array_keys($this->cname);
         while ($key = array_shift($keys)) {
             $deletecount++;
             $result .= '<tr>
         <td>' . $key . '</td>
         <td> ' . $this->cname[$key] . '</td>';
             if ($advanced) {
                 $result .= '
       <td>' . $this->PrintTTL($this->cnamettl[$key]) . '</td>
       ';
             }
             $result .= '
         <td><input type="checkbox" name="delete' . $deletecount . '" value="cname(' . $key . '-' . $this->cnameid[$key] . ')"></td></tr>
     ';
         }
         $cnamecounter = 0;
         for ($count = 1; $count <= $nbrows; $count++) {
             $cnamecounter++;
             $result .= '
       <tr>
       <td><input
        type="text" onchange="v(this)" name="cname' . $cnamecounter . '"></td>
         <td><input
         type="text" onchange="v(this)" name="cnamea' . $cnamecounter . '">
       </td>';
             if ($advanced) {
                 $result .= '
       <td><input type="text" name="cnamettl' . $cnamecounter . '"
       size="8" value="' . $l['str_primary_default'] . '"></td>
       ';
             }
             $result .= '<td></td></tr>';
         }
         $result .= '
   </table>
   ';
         # END CNAME-RECORDS
         # BEGIN TXT-RECORDS
         if ($this->user->txtrecords) {
             $result .= '
     <h3 class="boxheader">' . $l['str_primary_txt_record_title'] . '</h3>
     <p>' . sprintf($l['str_primary_txt_record_expl_x_x_x'], $this->zonename, $this->zonename, $this->zonename) . '
     </p>
     <table>
     <th>' . $l['str_primary_name'] . '<th>TXT';
             if ($advanced) {
                 $result .= '<th>TTL';
             }
             $result .= '<th>' . $l['str_delete'];
             $counter = 0;
             while (isset($this->txt[$counter])) {
                 $deletecount++;
                 // if advanced, print TTL fields
                 $result .= '<tr>
           <td>' . $this->txt[$counter] . '</td>
           <td>' . $this->txtdata[$counter] . '</td>';
                 if ($advanced) {
                     $result .= '<td>' . $this->PrintTTL($this->txtttl[$counter]) . '</td>
         ';
                 }
                 $result .= '
           <td><input type="checkbox" name="delete' . $deletecount . '" value="txt(' . $this->txt[$counter] . '/' . $this->txtid[$counter] . ')"></td></tr>
       ';
                 $counter++;
             }
             $counter = 0;
             $keys = array_keys($this->txt);
             while ($key = array_shift($keys)) {
                 $deletecount++;
                 $counter++;
             }
             $txtcounter = 0;
             for ($count = 1; $count <= $nbrows; $count++) {
                 $txtcounter++;
                 $result .= '
       <tr><td><input type="text" onchange="v(this)" name="txt' . $txtcounter . '"></td>
           <td><input type="text" name="txtstring' . $txtcounter . '"></td>';
                 if ($advanced) {
                     $result .= '
         <td><input type="text" name="txtttl' . $txtcounter . '" size="8" value="' . $l['str_primary_default'] . '"></td>
         ';
                 }
                 $result .= '<td></td></tr>';
             }
             $result .= '
     </table>
     ';
         }
         # END TXT-RECORDS
         # BEGIN SRV-RECORDS
         if ($this->user->srvrecords) {
             $result .= '
     <h3 class="boxheader">' . $l['str_primary_srv_record_title'] . '</h3>
     <p>' . sprintf($l['str_primary_srv_record_expl']) . '
     </p>
     <table>
     <th>' . $l['str_primary_name'] . '<th>' . $l['str_primary_srv_priority'] . '<th>' . $l['str_primary_srv_weight'] . '<th>' . $l['str_primary_srv_port'] . '<th>SRV';
             if ($advanced) {
                 $result .= '<th>TTL';
             }
             $result .= '<th>' . $l['str_delete'];
             $counter = 0;
             while (isset($this->srvname[$counter])) {
                 $deletecount++;
                 // if advanced, print TTL fields
                 $result .= '<tr>
       <td>' . $this->srvname[$counter] . '</td>
       <td>' . $this->srvpriority[$counter] . '</td>
       <td>' . $this->srvweight[$counter] . '</td>
       <td>' . $this->srvport[$counter] . '</td>
       <td>' . $this->srvvalue[$counter] . '</td>';
                 if ($advanced) {
                     $result .= '<td>' . $this->PrintTTL($this->srvttl[$counter]) . '</td>
         ';
                 }
                 $result .= '
       <td><input type="checkbox" name="delete' . $deletecount . '" value="srv(' . $this->srvname[$counter] . '-' . $this->srvid[$counter] . ')"></td></tr>
       ';
                 $counter++;
             }
             $srvcounter = 0;
             for ($count = 1; $count <= $nbrows; $count++) {
                 $srvcounter++;
                 $result .= '
         <tr><td><input type="text" onchange="v(this)" name="srvname' . $srvcounter . '"></td>
         <td><input type="text" size="3" name="srvpriority' . $srvcounter . '"></td>
         <td><input type="text" size="3" name="srvweight' . $srvcounter . '"></td>
         <td><input type="text" size="5" name="srvport' . $srvcounter . '"></td>
         <td><input type="text" name="srvvalue' . $srvcounter . '"></td>';
                 if ($advanced) {
                     $result .= '
         <td><input type="text" name="srvttl' . $srvcounter . '" size="8" value="' . $l['str_primary_default'] . '"></td>';
                 }
                 $result .= '<td></td></tr>';
             }
             $result .= '
     </table>
     ';
         }
         # END SRV-RECORDS
         # BEGIN SUBNS-RECORDS
         $result .= '
     <h3 class="boxheader">' . $l['str_primary_sub_zones_title'] . '</h3>
     <p>
     ' . sprintf($l['str_primary_sub_zones_expl_on_x_x'], $config->sitename, $this->zonename) . '
     </p>
     <table>
     <th>' . $l['str_primary_sub_zones_zone'] . '<th>NS';
         if ($advanced) {
             $result .= '<th>TTL';
         }
         $result .= '<th>' . $l['str_delete'] . '
   ';
         $counter = 0;
         while (isset($this->subns[$counter])) {
             $deletecount++;
             $result .= '<tr>
         <td>' . $this->subns[$counter] . '</td>
         <td>' . $this->subnsa[$counter] . '</td>
         ';
             if ($advanced) {
                 $result .= '
       <td>' . $this->PrintTTL($this->subnsttl[$counter]) . '</td>
       ';
             }
             $result .= '<td><input type="checkbox" name="delete' . $deletecount . '" value="subns(' . $this->subns[$counter] . '/' . $this->subnsid[$counter] . ')"></td></tr>
     ';
             $counter++;
         }
         $subnscounter = 0;
         for ($count = 1; $count <= $nbrows; $count++) {
             $subnscounter++;
             $result .= '
       <tr><td><input
        type="text" name="subns' . $subnscounter . '"></td>
         <td><input type="text" onchange="v(this)" name="subnsa' . $subnscounter . '">
           </td>';
             if ($advanced) {
                 $result .= '
       <td><input type="text" name="subnsttl' . $subnscounter . '" size="8" value="' . $l['str_primary_default'] . '"></td>
       ';
             }
         }
         $result .= '</table>';
         # END SUBNS-RECORDS
         # BEGIN WWW-RECORDS
         $result .= sprintf('<h3 class="boxheader">%s</h3>', $l['str_primary_www_zones_title']);
         $result .= sprintf('<p>%s</p>', sprintf($l['str_primary_www_zones_expl_on_x_x'], $config->sitename, $this->zonename));
         $result .= '<table>';
         $result .= sprintf('<th>%s</th>', $l['str_primary_www_zones_zone']);
         $result .= sprintf('<th>%s</th>', $l['str_primary_www_address']);
         $result .= sprintf('<th>%s</th>', $l['str_primary_www_zones_type']);
         if ($advanced) {
             $result .= '<th>TTL</th>';
         }
         $result .= sprintf('<th>%s</th>', $l['str_delete']);
         $counter = 0;
         while (isset($this->www[$counter])) {
             $deletecount++;
             $result .= '<tr>';
             $result .= sprintf('<td>%s</td>', $this->www[$counter]);
             $result .= sprintf('<td>%s</td>', $this->wwwa[$counter]);
             $result .= sprintf('<td>%s</td>', $this->frameRedirect($this->wwwr[$counter]));
             if ($advanced) {
                 $result .= sprintf('<td>%s</td>', $this->PrintTTL($this->wwwttl[$counter]));
             }
             $result .= sprintf('<td><input type="checkbox" name="delete%d" value="www(%s-%s)"></td>', $deletecount, $this->www[$counter], $this->wwwid[$counter]);
             $result .= '</tr>';
             $counter++;
         }
         $wwwcounter = 0;
         for ($count = 1; $count <= $nbrows; $count++) {
             $wwwcounter++;
             $result .= '<tr>';
             $result .= sprintf('<td><input type="text" onchange="v(this)" name="www%d"></td>', $wwwcounter);
             $result .= sprintf('<td><input type="text" name="wwwa%d"></td>', $wwwcounter);
             $result .= '<td>';
             $labelfmt = '<nobr><label><input type="radio" name="wwwr%d" value="%s">%s</label></nobr><br>';
             $result .= sprintf($labelfmt, $wwwcounter, "r", $this->frameRedirect("r"));
             $result .= sprintf($labelfmt, $wwwcounter, "R", $this->frameRedirect("R"));
             $result .= sprintf($labelfmt, $wwwcounter, "F", $this->frameRedirect("F"));
             $result .= '</td>';
             if ($advanced) {
                 $result .= sprintf('<td><input type="text" name="wwwttl%d" size="8" value="%s"></td>', $wwwcounter, $l['str_primary_default']);
             }
             $result .= '</tr>';
         }
         $result .= '</table>';
         # END WWW-RECORDS
     }
     // end not reverse zone
     $result .= sprintf('<h3 class="boxheader">%s</h3>', $l['str_primary_allow_transfer_title']);
     $result .= sprintf('<p>%s</p>', $l['str_primary_allow_transfer_expl']);
     $result .= '<table>';
     $result .= sprintf('<tr><td>%s<input id="xferip" type="text" name="xferip" value="%s"></td></tr>', $l['str_primary_allow_transfer_ip_allowed'], $this->xfer == "any" ? "" : $this->xfer);
     $result .= '</table>';
     $result .= '<input type="hidden" name="valid" value="1">';
     $result .= '<table id="submit"><tr><td>';
     $result .= sprintf('<input type="submit" name="submit" value="%s">', $l['str_primary_generate_zone_button']);
     $result .= sprintf('<input type="reset" value="%s">', $l['str_primary_reset_form_button']);
     $result .= '</td></tr></table>';
     $result .= '</form>';
     return $result;
 }
예제 #2
0
    /**
     * Take params send by "printmodifyform", do integrity 
     * checks,checkDig & call $this->updateDb
     *
     *@access public
     *@param array $params array of params: primary, xfer & xferIP
     *@return string HTML output
     */
    function PrintModified($params)
    {
        global $db, $config, $html, $l;
        list($primary, $xfer, $xferip) = $params;
        $content = "";
        $localerror = 0;
        if (empty($primary)) {
            $localerror = 1;
            $content .= sprintf($html->string_error, $l['str_secondary_you_must_provide_a_primary']) . '<br >';
        }
        // if primary modified ==> try to dig
        if ($primary != $this->masters) {
            // check primary integrity
            if (!checkPrimary($primary)) {
                $localerror = 1;
                $content .= sprintf($html->string_error, $l['str_secondary_your_primary_should_be_an_ip'] . "<br >" . $l['str_secondary_if_you_want_two_primary']) . '<br >';
            } else {
                // remove last ';' if present
                if (substr($primary, -1) == ';') {
                    $primary = substr($primary, 0, -1);
                }
                // split $primary into IPs
                $server = split(';', $primary);
                reset($server);
                while ($ipserver = array_pop($server)) {
                    $dig = checkDig($ipserver, $this->zonename);
                    if ($dig != 'NOERROR') {
                        switch ($dig) {
                            case "NOERROR":
                                $msg = $l['str_dig_result_NOERROR'];
                                break;
                            case "FORMERR":
                                $msg = $l['str_dig_result_FORMERR'];
                                break;
                            case "SERVFAIL":
                                $msg = $l['str_dig_result_SERVFAIL'];
                                break;
                            case "NXDOMAIN":
                                $msg = $l['str_dig_result_NXDOMAIN'];
                                break;
                            case "NOTIMP":
                                $msg = $l['str_dig_result_NOTIMP'];
                                break;
                            case "REFUSED":
                                $msg = $l['str_dig_result_REFUSED'];
                                break;
                            case "YXDOMAIN":
                                $msg = $l['str_dig_result_YXDOMAIN'];
                                break;
                            case "YXRRSET":
                                $msg = $l['str_dig_result_YXRRSET'];
                                break;
                            case "NXRRSET":
                                $msg = $l['str_dig_result_NXRRSET'];
                                break;
                            case "NOTAUTH":
                                $msg = $l['str_dig_result_NOTAUTH'];
                                break;
                            case "NOTZONE":
                                $msg = $l['str_dig_result_NOTZONE'];
                                break;
                            case "BADSIG":
                                $msg = $l['str_dig_result_BADSIG'];
                                break;
                            case "BADKEY":
                                $msg = $l['str_dig_result_BADKEY'];
                                break;
                            case "BADTIME":
                                $msg = $l['str_dig_result_BADTIME'];
                                break;
                        }
                        if (!empty($msg)) {
                            $dig = '"' . $dig . '" (' . $msg . ')';
                        }
                        $content .= sprintf($html->string_warning, sprintf($l['str_trying_to_dig_from_x_returned_status_x'], $ipserver, $dig));
                        $content .= " " . sprintf($l['str_secondary_non_blocking_warning_x_will_not_serve'], $config->sitename) . '<br >';
                    }
                }
            }
        }
        // check xferip
        if (!empty($xferip)) {
            if (!checkPrimary($xferip)) {
                $localerror = 1;
                $content .= sprintf($html->string_error, $l['str_secondary_invalid_list_of_allowtransfer']) . '<br >';
            }
            $xfer = 'others';
        } else {
            if ($xfer == 'others') {
                $xfer = 'master';
            }
        }
        switch ($xfer) {
            case "all":
                $xferip = 'any';
                break;
            case "master":
                $xferip = $primary;
                break;
            case "others":
                // remove last ';' if present
                if (substr($xferip, -1) == ';') {
                    $xferip = substr($xferip, 0, -1);
                }
                // suppress duplicate entry of $primary if already in $xferip
                $xferarray = split(';', $xferip);
                $xferiparray = array();
                reset($xferarray);
                while ($xferitem = array_pop($xferarray)) {
                    if ($xferitem != $primary) {
                        array_push($xferiparray, $xferitem);
                    }
                }
                $xferip = implode(";", $xferiparray);
                $xferip = $primary . ';' . $xferip;
                break;
            default:
                $xferip = "any";
        }
        if (!$localerror) {
            // updatedb
            if (!$this->updateDb($primary, $xferip)) {
                $content .= $this->error;
            } else {
                // flag status='M' to be generated & reloaded
                $ret = $this->flagModified($this->zoneid);
                if (!empty($ret)) {
                    $result .= $ret;
                } else {
                    // retrieve list of ns names
                    $nsxnames = GetListOfServerNames();
                    // retrieve list of ns addresses
                    $nsxips = GetListOfServerIPs();
                    // retrieve list of ns transfer IPs
                    $nsxferips = GetListOfServerTransferIPs();
                    $nsxferips = array_merge($nsxferips, $nsxips);
                    $nsxferips = array_unique($nsxferips);
                    $content .= '
     <h3 class=boxheader>' . sprintf($l['str_secondary_zone_successfully_modified_on_x'], $config->sitename) . '</h3>
     ' . $l['str_secondary_after_modif_be_sure_to'] . ':<ul>
     <li>' . $l['str_secondary_after_modif_add_lines_to_zonefile'] . ':<br>
     <pre>
';
                    while (list($notwanted, $nsxname) = each($nsxnames)) {
                        $content .= $this->zonename . '. IN NS ' . $nsxname . '.
';
                    }
                    $content .= '
    </pre>
    
    <li>' . $l['str_secondary_after_modif_add_to_configfile'] . ':
    <p >
    <pre>
// 
// ' . $l['str_secondary_after_modif_comment_in_sample_1'] . '
// ' . $l['str_secondary_after_modif_comment_in_sample_2'] . '
//
zone "' . $this->zonename . '" {
 type master;
 file "' . $this->zonename . '";
 allow-transfer {
  ';
                    while (list($notwanted, $nsxferip) = each($nsxferips)) {
                        $content .= $nsxferip . '; ';
                    }
                    $content .= '
 };
};
</pre>
     <li>' . $l['str_secondary_after_modif_set_firewall'] . '
     <li>' . sprintf($l['str_secondary_after_modif_delegate_x_to'], $this->zonename) . ': ';
                    reset($nsxnames);
                    $serverlist = '';
                    while (list($notwanted, $nsxname) = each($nsxnames)) {
                        $serverlist .= ' <b>' . $nsxname . '</b>; ';
                    }
                    $serverlist = substr($serverlist, 0, -1);
                    $content .= $serverlist . '
     </ul>
    
     <p>' . $l['str_secondary_reload_info'] . '<p>

     ';
                }
                // else no error
            }
            // else updatedb
        } else {
            // $error
            // nothing has been modified, go back and solve troubles
            // or print form again
        }
        return $content;
    }
예제 #3
0
파일: zones.php 프로젝트: RzeszowPL/freedns
 if ($config->usergroups) {
     $allzones = $group->listallzones($zone);
     $user->error = $group->error;
 } else {
     $allzones = $user->listallzones($zone);
 }
 if (empty($user->error)) {
     $content = '<table id="listzonestable">
 <tr>
 <td style="width:30%" class="boxheader">' . $l['str_zone'] . '</td>
 <td class="boxheader">' . $l['str_name_server'] . '</td>
 <td class="boxheader">' . $l['str_serial'] . '</td>
 <td class="boxheader">' . $l['str_view'] . '</td>
 </tr>';
     // retrieve & generate our name servers list
     $ourservernames = GetListOfServerNames();
     $ourserverlist = array();
     while ($servername = array_pop($ourservernames)) {
         array_push($ourserverlist, $servername . ".");
     }
     while ($otherzone = array_pop($allzones)) {
         $newzone = new Zone($otherzone[0], $otherzone[1], $otherzone[2]);
         if ($newzone->zonetype == 'P') {
             $primary = new Primary($newzone->zonename, $newzone->zonetype, $user->userid);
             $nameservers = array_keys($primary->ns);
         } else {
             $secondary = new Secondary($newzone->zonename, $newzone->zonetype, $user->userid);
             $masters = split(';', $secondary->masters);
             $nameservers = array_merge($masters, $ourserverlist);
         }
         $urlpar = $link . '&amp;zonename=' . $newzone->zonename . '&amp;zonetype=' . $newzone->zonetype;