Projet

Général

Profil

Télécharger (7,23 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / services_unbound_domainoverride_edit.php @ 62424bdb

1
<?php
2
/*
3
    services_unbound_domainoverride_edit.php
4
    part of the pfSense project (https://www.pfsense.org)
5
    Copyright (C) 2014 Warren Baker (warren@decoy.co.za)
6
    All rights reserved.
7
	
8
    Copyright (C) 2003-2005 Bob Zoller <bob@kludgebox.com> and Manuel Kasper <mk@neon1.net>.
9
    All rights reserved.
10

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

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

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

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

    
36
##|+PRIV
37
##|*IDENT=page-services-dnsresolver-editdomainoverride
38
##|*NAME=Services: DNS Resolver: Edit Domain Override page
39
##|*DESCR=Allow access to the 'Services: DNS Resolver: Edit Domain Override' page.
40
##|*MATCH=services_unbound_domainoverride_edit.php*
41
##|-PRIV
42

    
43
require("guiconfig.inc");
44

    
45
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/services_unbound.php');
46

    
47
if (!is_array($config['unbound']['domainoverrides']))
48
       $config['unbound']['domainoverrides'] = array();
49

    
50
$a_domainOverrides = &$config['unbound']['domainoverrides'];
51

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

    
57
if (isset($id) && $a_domainOverrides[$id]) {
58
    $pconfig['domain'] = $a_domainOverrides[$id]['domain'];
59
    $pconfig['ip'] = $a_domainOverrides[$id]['ip'];
60
    $pconfig['descr'] = $a_domainOverrides[$id]['descr'];
61
}
62

    
63
if ($_POST) {
64

    
65
    unset($input_errors);
66
    $pconfig = $_POST;
67

    
68
    /* input validation */
69
    $reqdfields = explode(" ", "domain ip");
70
    $reqdfieldsn = array(gettext("Domain"),gettext("IP address"));
71

    
72
    do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
73

    
74
    function String_Begins_With($needle, $haystack) {
75
        return (substr($haystack, 0, strlen($needle))==$needle);
76
    }
77

    
78
    if (String_Begins_With(_msdcs, $_POST['domain'])) {
79
        $subdomainstr = substr($_POST['domain'], 7);
80
        if ($subdomainstr && !is_domain($subdomainstr))
81
            $input_errors[] = gettext("A valid domain must be specified after _msdcs.");
82
    } elseif ($_POST['domain'] && !is_domain($_POST['domain']))
83
        $input_errors[] = gettext("A valid domain must be specified.");
84

    
85
    if ($_POST['ip']) {
86
        if (strpos($_POST['ip'],'@') !== false) {
87
            $ip_details = explode("@", $_POST['ip']);
88
            if (!is_ipaddr($ip_details[0]) && !is_port($ip_details[1]))
89
                $input_errors[] = gettext("A valid IP address and port must be specified, for example 192.168.100.10@5353.");
90
        } else if (!is_ipaddr($_POST['ip']))
91
            $input_errors[] = gettext("A valid IP address must be specified, for example 192.168.100.10.");
92
    }
93

    
94
    if (!$input_errors) {
95
        $doment = array();
96
        $doment['domain'] = $_POST['domain'];
97
        $doment['ip'] = $_POST['ip'];
98
        $doment['descr'] = $_POST['descr'];
99

    
100
        if (isset($id) && $a_domainOverrides[$id])
101
            $a_domainOverrides[$id] = $doment;
102
        else
103
            $a_domainOverrides[] = $doment;
104

    
105
        mark_subsystem_dirty('unbound');
106

    
107
        write_config();
108

    
109
        header("Location: services_unbound.php");
110
        exit;
111
    }
112
}
113

    
114
$pgtitle = array(gettext("Services"),gettext("DNS Resolver"),gettext("Edit Domain Override"));
115
$shortcut_section = "resolver";
116
include("head.inc");
117

    
118
?>
119

    
120
<body>
121
<?php include("fbegin.inc"); ?>
122
<?php if ($input_errors) print_input_errors($input_errors); ?>
123
    <form action="services_unbound_domainoverride_edit.php" method="post" name="iform" id="iform">
124
        <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="domain override">
125
            <tr>
126
                <td width="22%" valign="top" class="vncellreq"><?=gettext("Domain");?></td>
127
                <td width="78%" class="vtable">
128
                    <?=$mandfldhtml;?><input name="domain" type="text" class="formfld unknown" id="domain" size="40" value="<?=htmlspecialchars($pconfig['domain']);?>" /><br />
129
                    <span class="vexpl">
130
                        <?=gettext("Domain to override (NOTE: this does not have to be a valid TLD!)"); ?><br />
131
                        <?=gettext("e.g."); ?> <em><?=gettext("test"); ?></em> <?=gettext("or"); ?> <em>mycompany.localdomain</em> <?=gettext("or"); ?> <em>1.168.192.in-addr.arpa</em>
132
                    </span>
133
                </td>
134
            </tr>
135
            <tr>
136
                <td width="22%" valign="top" class="vncellreq"><?=gettext("IP address");?></td>
137
                <td width="78%" class="vtable">
138
                    <?=$mandfldhtml;?><input name="ip" type="text" class="formfld unknown" id="ip" size="40" value="<?=htmlspecialchars($pconfig['ip']);?>" /><br />
139
                    <span class="vexpl">
140
                    <?=gettext("IP address of the authoritative DNS server for this domain"); ?><br />
141
                    <?=gettext("e.g."); ?> <em>192.168.100.100</em><br />
142
                    <?=gettext("To use a nondefault port for communication, append an '@' with the port number."); ?><br />
143
                    </span>
144
                </td>
145
            </tr>
146
            <tr>
147
                <td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
148
                <td width="78%" class="vtable">
149
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" /><br />
150
                    <span class="vexpl">
151
                        <?=gettext("You may enter a description here for your reference (not parsed).");?>
152
                    </span>
153
                </td>
154
            </tr>
155
            <tr>
156
                <td width="22%" valign="top">&nbsp;</td>
157
                <td width="78%">
158
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
159
                    <input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
160
                    <?php if (isset($id) && $a_domainOverrides[$id]): ?>
161
                    <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
162
                    <?php endif; ?>
163
                </td>
164
            </tr>
165
        </table>
166
    </form>
167
<?php include("fend.inc"); ?>
168
</body>
169
</html>
(173-173/256)