Project

General

Profile

Download (8.47 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / services_dnsmasq_domainoverride_edit.php @ a1b66bec

1
<?php
2
/*
3
       services_dnsmasq_domainoverride_edit.php
4
       part of m0n0wall (http://m0n0.ch/wall)
5

    
6
       Copyright (C) 2003-2005 Bob Zoller <bob@kludgebox.com> and Manuel Kasper <mk@neon1.net>.
7
       All rights reserved.
8

    
9
       Redistribution and use in source and binary forms, with or without
10
       modification, are permitted provided that the following conditions are met:
11

    
12
       1. Redistributions of source code must retain the above copyright notice,
13
          this list of conditions and the following disclaimer.
14

    
15
       2. Redistributions in binary form must reproduce the above copyright
16
          notice, this list of conditions and the following disclaimer in the
17
          documentation and/or other materials provided with the distribution.
18

    
19
       THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
       INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
       AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
       AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
       OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
       SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
       INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
       CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
       ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
       POSSIBILITY OF SUCH DAMAGE.
29
*/
30
/*
31
	pfSense_MODULE:	dnsforwarder
32
*/
33

    
34
##|+PRIV
35
##|*IDENT=page-services-dnsforwarder-editdomainoverride
36
##|*NAME=Services: DNS Forwarder: Edit Domain Override page
37
##|*DESCR=Allow access to the 'Services: DNS Forwarder: Edit Domain Override' page.
38
##|*MATCH=services_dnsmasq_domainoverride_edit.php*
39
##|-PRIV
40

    
41
require("guiconfig.inc");
42

    
43
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/services_dnsmasq.php');
44

    
45
if (!is_array($config['dnsmasq']['domainoverrides'])) {
46
       $config['dnsmasq']['domainoverrides'] = array();
47
}
48
$a_domainOverrides = &$config['dnsmasq']['domainoverrides'];
49

    
50
if (is_numericint($_GET['id']))
51
	$id = $_GET['id'];
52
if (isset($_POST['id']) && is_numericint($_POST['id']))
53
	$id = $_POST['id'];
54

    
55
if (isset($id) && $a_domainOverrides[$id]) {
56
       $pconfig['domain'] = $a_domainOverrides[$id]['domain'];
57
       if (is_ipaddr($a_domainOverrides[$id]['ip']) && ($a_domainOverrides[$id]['ip'] != '#')) {
58
              $pconfig['ip'] = $a_domainOverrides[$id]['ip'];
59
       }
60
       else {
61
             $dnsmasqpieces = explode('@', $a_domainOverrides[$id]['ip'], 2);
62
             $pconfig['ip'] = $dnsmasqpieces[0];
63
             $pconfig['dnssrcip'] = $dnsmasqpieces[1];
64
       }
65
       $pconfig['descr'] = $a_domainOverrides[$id]['descr'];
66
}
67

    
68
if ($_POST) {
69

    
70
       unset($input_errors);
71
       $pconfig = $_POST;
72

    
73
       /* input validation */
74
       $reqdfields = explode(" ", "domain ip");
75
       $reqdfieldsn = array(gettext("Domain"),gettext("IP address"));
76

    
77
       do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
78

    
79
       function String_Begins_With($needle, $haystack) {
80
           return (substr($haystack, 0, strlen($needle))==$needle);
81
       }
82

    
83
       if (String_Begins_With(_msdcs, $_POST['domain'])) {
84
               $subdomainstr = substr($_POST['domain'], 7);
85
               if ($subdomainstr && !is_domain($subdomainstr)) {
86
                  $input_errors[] = gettext("A valid domain must be specified after _msdcs.");
87
               }
88
       }
89
       elseif ($_POST['domain'] && !is_domain($_POST['domain'])) {
90
               $input_errors[] = gettext("A valid domain must be specified.");
91
       }
92
       if ($_POST['ip'] && !is_ipaddr($_POST['ip']) && ($_POST['ip'] != '#') && ($_POST['ip'] != '!')) {
93
              $input_errors[] = gettext("A valid IP address must be specified, or # for an exclusion or ! to not forward at all.");
94
       }
95
       if ($_POST['dnssrcip'] && !in_array($_POST['dnssrcip'], get_configured_ip_addresses())) {
96
              $input_errors[] = gettext("An interface IP address must be specified for the DNS query source.");
97
       }
98
       if (!$input_errors) {
99
			$doment = array();
100
			$doment['domain'] = $_POST['domain'];
101
                       if (empty($_POST['dnssrcip']))
102
                                $doment['ip'] = $_POST['ip'];
103
                       else
104
                               $doment['ip'] = $_POST['ip'] . "@" . $_POST['dnssrcip'];
105
			$doment['descr'] = $_POST['descr'];
106

    
107
			if (isset($id) && $a_domainOverrides[$id])
108
				$a_domainOverrides[$id] = $doment;
109
			else
110
				$a_domainOverrides[] = $doment;
111

    
112
			$retval = services_dnsmasq_configure();
113

    
114
			write_config();
115

    
116
			header("Location: services_dnsmasq.php");
117
			exit;
118
       }
119
}
120

    
121
$pgtitle = array(gettext("Services"),gettext("DNS forwarder"),gettext("Edit Domain Override"));
122
$shortcut_section = "resolver";
123
include("head.inc");
124

    
125
?>
126

    
127
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
128
<?php include("fbegin.inc"); ?>
129
<?php if ($input_errors) print_input_errors($input_errors); ?>
130
            <form action="services_dnsmasq_domainoverride_edit.php" method="post" name="iform" id="iform">
131
              <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="domain override">
132
                               <tr>
133
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Domain");?></td>
134
                  <td width="78%" class="vtable">
135
                    <?=$mandfldhtml;?><input name="domain" type="text" class="formfld unknown" id="domain" size="40" value="<?=htmlspecialchars($pconfig['domain']);?>" />
136
                    <br /> <span class="vexpl"><?=gettext("Domain to override (NOTE: this does not have to be a valid TLD!)"); ?><br />
137
                    <?=gettext("e.g."); ?> <em><?=gettext("test"); ?></em> <?=gettext("or"); ?> <em>mycompany.localdomain</em> <?=gettext("or"); ?> <em>1.168.192.in-addr.arpa</em> </span></td>
138
                </tr>
139
                               <tr>
140
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("IP address");?></td>
141
                  <td width="78%" class="vtable">
142
                    <?=$mandfldhtml;?><input name="ip" type="text" class="formfld unknown" id="ip" size="40" value="<?=htmlspecialchars($pconfig['ip']);?>" />
143
                    <br /> <span class="vexpl"><?=gettext("IP address of the authoritative DNS server for this domain"); ?><br />
144
                    <?=gettext("e.g."); ?> <em>192.168.100.100</em><br /><?=gettext("Or enter # for an exclusion to pass through this host/subdomain to standard nameservers instead of a previous override."); ?><br /><?=gettext("Or enter ! for lookups for this host/subdomain to NOT be forwarded anywhere."); ?></span></td>
145
                </tr>
146
                               <tr>
147
                  <td width="22%" valign="top" class="vncell"><?=gettext("Source IP");?></td>
148
                  <td width="78%" class="vtable">
149
                    <?=$mandfldhtml;?><input name="dnssrcip" type="text" class="formfld unknown" id="dnssrcip" size="40" value="<?=htmlspecialchars($pconfig['dnssrcip']);?>" />
150
                    <br /> <span class="vexpl"><?=gettext("Source IP address for queries to the DNS server for the override domain."); ?><br />
151
                    <?=gettext("Leave blank unless your DNS server is accessed through a VPN tunnel."); ?></span></td>
152
                </tr>
153
                               <tr>
154
                  <td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
155
                  <td width="78%" class="vtable">
156
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
157
                    <br /> <span class="vexpl"><?=gettext("You may enter a description here".
158
                    " for your reference (not parsed).");?></span></td>
159
                </tr>
160
                <tr>
161
                  <td width="22%" valign="top">&nbsp;</td>
162
                  <td width="78%">
163
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
164
                    <input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
165
                    <?php if (isset($id) && $a_domainOverrides[$id]): ?>
166
                    <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
167
                    <?php endif; ?>
168
                  </td>
169
                </tr>
170
              </table>
171
</form>
172
<?php include("fend.inc"); ?>
173
</body>
174
</html>
(157-157/256)