87 |
87 |
}
|
88 |
88 |
}
|
89 |
89 |
|
|
90 |
/* Validate imported hosts or networks */
|
|
91 |
switch ($_POST['type']) {
|
|
92 |
|
|
93 |
case "host" :
|
|
94 |
if ($_POST['aliasimport']) {
|
|
95 |
$toimport = split("\n", $_POST['aliasimport']);
|
|
96 |
foreach ($toimport as $impip) {
|
|
97 |
if (!is_ipaddr(trim($impip)))
|
|
98 |
$input_errors[] = "$impip is not an ip address. Please correct the error to continue";
|
|
99 |
}
|
|
100 |
}
|
|
101 |
break;
|
|
102 |
|
|
103 |
case "network" :
|
|
104 |
if ($_POST['aliasimport']) {
|
|
105 |
$toimport = split("\n", $_POST['aliasimport']);
|
|
106 |
foreach ($toimport as $impip) {
|
|
107 |
list($impip, $mask) = split('/',$impip);
|
|
108 |
if (!is_ipaddr(trim($impip)))
|
|
109 |
$input_errors[] = "$impip is not an ip address. Please correct the error to continue";
|
|
110 |
if (!is_numeric(trim($mask)) or ($mask > 32) or ($mask < 0))
|
|
111 |
$input_errors[] = "The field '$mask' must contain a valid CIDR range.";
|
|
112 |
}
|
|
113 |
}
|
|
114 |
break;
|
|
115 |
}
|
|
116 |
|
|
117 |
/* create details for each ip. IPs also gets arranged better in config.xml */
|
|
118 |
$final_address_details .= "Entry added" . " ";
|
|
119 |
$final_address_details .= date('r');
|
|
120 |
$final_address_details .= "||";
|
|
121 |
|
|
122 |
|
90 |
123 |
if ($_POST['aliasimport']) {
|
91 |
|
$toimport = split("\n", $_POST['aliasimport']);
|
92 |
|
foreach ($toimport as $impip) {
|
93 |
|
if (!is_ipaddr(trim($impip)))
|
94 |
|
$input_errors[] = "$impip is not an ip address. Please correct the error to continue";
|
|
124 |
$detail = "";
|
|
125 |
$myips = "";
|
|
126 |
$toimport2 = split("\n", $_POST['aliasimport']);
|
|
127 |
foreach($toimport2 as $impip2){
|
|
128 |
if ($impip2 !== ""){
|
|
129 |
$myips .= trim($impip2) . " ";
|
|
130 |
$detail .= $final_address_details;
|
|
131 |
}
|
95 |
132 |
}
|
96 |
|
}
|
|
133 |
}
|
|
134 |
$myips = substr($myips,0,-1);
|
97 |
135 |
|
98 |
136 |
if (!$input_errors) {
|
99 |
137 |
$alias = array();
|
100 |
|
$alias['address'] = str_replace("\n", " ", $_POST['aliasimport']);
|
101 |
138 |
$alias['name'] = $_POST['name'];
|
102 |
|
$alias['type'] = "network";
|
|
139 |
$alias['address'] = $myips; /* str_replace("\n", " ", $_POST['aliasimport']); */
|
|
140 |
$alias['type'] = $_POST['type'];
|
103 |
141 |
$alias['descr'] = $_POST['descr'];
|
|
142 |
$alias['detail'] = $detail;
|
104 |
143 |
$a_aliases[] = $alias;
|
105 |
144 |
write_config();
|
106 |
|
|
107 |
145 |
pfSenseHeader("firewall_aliases.php");
|
108 |
|
|
109 |
146 |
exit;
|
110 |
147 |
}
|
111 |
148 |
}
|
... | ... | |
135 |
172 |
<br /> <span class="vexpl">You may enter a description here
|
136 |
173 |
for your reference (not parsed).</span></td>
|
137 |
174 |
</tr>
|
|
175 |
<tr>
|
|
176 |
<td width="22%" valign="top" class="vncellreq">Type</td>
|
|
177 |
<td width="78%" class="vtable">
|
|
178 |
<select name="type" class="formselect" id="type">
|
|
179 |
<?php
|
|
180 |
$types = explode(",", "Host(s), Network(s)");
|
|
181 |
$vals = explode(" ", "host network");
|
|
182 |
$j = 0; for ($j = 0; $j < count($vals); $j++): ?>
|
|
183 |
<option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['type']) echo "selected";?>>
|
|
184 |
<?=htmlspecialchars($types[$j]);?>
|
|
185 |
</option>
|
|
186 |
<?php endfor; ?>
|
|
187 |
</select>
|
|
188 |
<br /> <span class="vexpl">
|
|
189 |
Select which type you will import</span></td>
|
|
190 |
</td>
|
|
191 |
</tr>
|
|
192 |
|
138 |
193 |
<tr>
|
139 |
194 |
<td valign="top" class="vncellreq">Aliases to import</td>
|
140 |
195 |
<td class="vtable"><textarea name="aliasimport" ROWS="15" COLS="40"><?php echo $_POST['aliasimport']; ?></textarea>
|
141 |
196 |
<br /> <span class="vexpl">Paste in the aliases to import separated by a carriage return. Common examples are lists of IPs, networks, blacklists, etc.
|
142 |
|
<br /> The list may contain only IP addresses. </span></td>
|
|
197 |
<br /> The Host list may contain only IP addresses. Network IP/CIDR only</span></td>
|
143 |
198 |
</tr>
|
144 |
199 |
<tr>
|
145 |
200 |
<td width="22%" valign="top"> </td>
|