Revision 839ae1c2
src/etc/inc/util.inc | ||
---|---|---|
3300 | 3300 |
* RESULT |
3301 | 3301 |
* Array containing list of aliases. |
3302 | 3302 |
* If $type is unspecified, all aliases are returned. |
3303 |
* If $type is a string, all aliases of the type specified in $type are returned. |
|
3304 |
* If $type is an array, all aliases of any type specified in any element of $type are returned. |
|
3303 |
* If $type is a comma-separated string, all aliases of the type(s) specified in $type are returned. |
|
3305 | 3304 |
*/ |
3306 |
function get_alias_list($type = null) { |
|
3307 |
$result = array(); |
|
3308 |
foreach (config_get_path('aliases/alias', []) as $alias) { |
|
3309 |
if ($type === null) { |
|
3310 |
$result[] = $alias['name']; |
|
3311 |
} else if (is_array($type)) { |
|
3312 |
if (in_array($alias['type'], $type)) { |
|
3313 |
$result[] = $alias['name']; |
|
3314 |
} |
|
3315 |
} else if ($type === $alias['type']) { |
|
3305 |
function get_alias_list($type = '') { |
|
3306 |
$requested_types = []; |
|
3307 |
if (!empty($type)) { |
|
3308 |
if (!is_string($type)) { |
|
3309 |
return []; |
|
3310 |
} |
|
3311 |
$requested_types = explode(',', $type); |
|
3312 |
} |
|
3313 |
|
|
3314 |
$aliases = config_get_path('aliases/alias', []); |
|
3315 |
foreach ($aliases as $alias) { |
|
3316 |
if (empty($requested_types) || in_array($alias['type'], $requested_types)) { |
|
3316 | 3317 |
$result[] = $alias['name']; |
3317 | 3318 |
} |
3318 | 3319 |
} |
src/usr/local/www/firewall_nat_1to1_edit.php | ||
---|---|---|
313 | 313 |
|
314 | 314 |
// ---------- Autocomplete -------------------------------------------------------------------- |
315 | 315 |
|
316 |
var addressarray = <?= json_encode(get_alias_list(array("host", "network", "urltable"))) ?>;
|
|
316 |
var addressarray = <?= json_encode(get_alias_list('host,network,urltable')) ?>;
|
|
317 | 317 |
|
318 | 318 |
$('#dst').autocomplete({ |
319 | 319 |
source: addressarray |
src/usr/local/www/firewall_nat_edit.php | ||
---|---|---|
577 | 577 |
} |
578 | 578 |
} |
579 | 579 |
|
580 |
var customarray = <?= json_encode(get_alias_list(array("port", "url_ports", "urltable_ports"))) ?>;
|
|
580 |
var customarray = <?= json_encode(get_alias_list('port,url_ports,urltable_ports')) ?>;
|
|
581 | 581 |
|
582 | 582 |
function check_for_aliases() { |
583 | 583 |
// if External port range is an alias, then disallow |
... | ... | |
761 | 761 |
nordr_change(); |
762 | 762 |
|
763 | 763 |
// --------- Autocomplete ----------------------------------------------------------------------------------------- |
764 |
var addressarray = <?= json_encode(get_alias_list(array("host", "network", "urltable"))) ?>;
|
|
765 |
var customarray = <?= json_encode(get_alias_list(array("port", "url_ports", "urltable_ports"))) ?>;
|
|
764 |
var addressarray = <?= json_encode(get_alias_list('host,network,urltable')) ?>;
|
|
765 |
var customarray = <?= json_encode(get_alias_list('port,url_ports,urltable_ports')) ?>;
|
|
766 | 766 |
|
767 | 767 |
$('#localip, #src, #dst').autocomplete({ |
768 | 768 |
source: addressarray |
src/usr/local/www/firewall_nat_out_edit.php | ||
---|---|---|
404 | 404 |
poolopts_change(); |
405 | 405 |
|
406 | 406 |
// --------- Autocomplete ----------------------------------------------------------------------------------------- |
407 |
var addressarray = <?= json_encode(get_alias_list(array("host", "network", "urltable"))) ?>;
|
|
408 |
var customarray = <?= json_encode(get_alias_list(array("port", "url_ports", "urltable_ports"))) ?>;
|
|
407 |
var addressarray = <?= json_encode(get_alias_list('host,network,urltable')) ?>;
|
|
408 |
var customarray = <?= json_encode(get_alias_list('port,url_ports,urltable_ports')) ?>;
|
|
409 | 409 |
|
410 | 410 |
$('#destination, #source, #target').autocomplete({ |
411 | 411 |
source: addressarray |
src/usr/local/www/firewall_rules_edit.php | ||
---|---|---|
2171 | 2171 |
|
2172 | 2172 |
// ---------- Autocomplete -------------------------------------------------------------------- |
2173 | 2173 |
|
2174 |
var addressarray = <?= json_encode(get_alias_list(array("host", "network", "url", "urltable"))) ?>;
|
|
2175 |
var customarray = <?= json_encode(get_alias_list(array("port", "url_ports", "urltable_ports"))) ?>;
|
|
2174 |
var addressarray = <?= json_encode(get_alias_list('host,network,url,urltable')) ?>;
|
|
2175 |
var customarray = <?= json_encode(get_alias_list('port,url_ports,urltable_ports')) ?>;
|
|
2176 | 2176 |
|
2177 | 2177 |
$('#src, #dst').autocomplete({ |
2178 | 2178 |
source: addressarray |
src/usr/local/www/services_radvd.php | ||
---|---|---|
527 | 527 |
checkLastRow(); |
528 | 528 |
|
529 | 529 |
// --------- Autocomplete ----------------------------------------------------------------------------------------- |
530 |
var addressarray = <?= json_encode(get_alias_list(array("host", "network", "urltable"))) ?>;
|
|
530 |
var addressarray = <?= json_encode(get_alias_list('host,network,urltable')) ?>;
|
|
531 | 531 |
|
532 | 532 |
$('#radns1, #radns2, #radns3, #radns4').autocomplete({ |
533 | 533 |
source: addressarray |
src/usr/local/www/system_routes_edit.php | ||
---|---|---|
285 | 285 |
//<![CDATA[ |
286 | 286 |
events.push(function() { |
287 | 287 |
// --------- Autocomplete ----------------------------------------------------------------------------------------- |
288 |
var addressarray = <?= json_encode(get_alias_list(array("host", "network"))) ?>;
|
|
288 |
var addressarray = <?= json_encode(get_alias_list('host,network')) ?>;
|
|
289 | 289 |
|
290 | 290 |
$('#network').autocomplete({ |
291 | 291 |
source: addressarray |
Also available in: Unified diff
Refactor get_alias_list()
It now uses CSVs for multiple types instead of an array.