} $a_clones =& $config['wireless']['clone']; function clone_inuse($num) { global $config, $a_clones; $iflist = get_configured_interface_list(false, true); foreach ($iflist as $if) { if ($config['interfaces'][$if]['if'] == $a_clones[$num]['cloneif']) { return true; } } return false; } if ($_GET['act'] == "del") { /* check if still in use */ if (clone_inuse($_GET['id'])) { $input_errors[] = gettext("This wireless clone cannot be deleted because it is assigned as an interface."); } else { mwexec("/sbin/ifconfig " . $a_clones[$_GET['id']]['cloneif'] . " destroy"); unset($a_clones[$_GET['id']]); write_config(); header("Location: interfaces_wireless.php"); exit; } } $pgtitle = array(gettext("Interfaces"), gettext("Wireless")); $shortcut_section = "wireless"; include "head.inc"; if ($input_errors) { print_input_errors($input_errors); }
$iflist = get_configured_interface_list(false, true); foreach ($iflist as $if) { if ($config['interfaces'][$if]['if'] == $cloneif) { return true; } } return false; } if (!isset($config['wireless']['clone']) || !is_array($config['wireless']['clone'])) { $a_clones = array(); } else { $a_clones =& $config['wireless']['clone']; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (!empty($_POST['action']) && $_POST['action'] == "del" && !empty($a_clones[$_POST['id']])) { if (clone_inuse($a_clones[$_POST['id']]['cloneif'])) { /* check if still in use */ $input_errors[] = gettext("This wireless clone cannot be deleted because it is assigned as an interface."); } else { mwexec("/sbin/ifconfig " . escapeshellarg($a_clones[$_POST['id']]['cloneif']) . " destroy"); unset($a_clones[$_POST['id']]); write_config(); header("Location: interfaces_wireless.php"); exit; } } } include "head.inc"; legacy_html_escape_form_data($a_clones); $main_buttons = array(array('href' => 'interfaces_wireless_edit.php', 'label' => gettext('Add'))); ?>
if (!$clone['cloneif']) { $clone_id = 1; do { $clone_exists = false; $clone['cloneif'] = "{$_POST['if']}_wlan{$clone_id}"; foreach ($a_clones as $existing) { if ($clone['cloneif'] == $existing['cloneif']) { $clone_exists = true; $clone_id++; break; } } } while ($clone_exists); } if (isset($id) && $a_clones[$id]) { if (clone_inuse($id)) { if ($clone['if'] != $a_clones[$id]['if']) { $input_errors[] = gettext("This wireless clone cannot be modified because it is still assigned as an interface."); } else { if ($clone['mode'] != $a_clones[$id]['mode']) { $input_errors[] = gettext("Use the configuration page for the assigned interface to change the mode."); } } } } if (!$input_errors) { if (!interface_wireless_clone($clone['cloneif'], $clone)) { $input_errors[] = sprintf(gettext('Error creating interface with mode %1$s. The %2$s interface may not support creating more clones with the selected mode.'), $wlan_modes[$clone['mode']], $clone['if']); } else { if (isset($id) && $a_clones[$id]) { if ($clone['if'] != $a_clones[$id]['if']) {
} if (empty($clone['cloneif'])) { $clone_id = 1; do { $clone_exists = false; $clone['cloneif'] = "{$pconfig['if']}_wlan{$clone_id}"; foreach ($a_clones as $existing) { if ($clone['cloneif'] == $existing['cloneif']) { $clone_exists = true; $clone_id++; break; } } } while ($clone_exists); } if (isset($id) && clone_inuse($a_clones[$id]['cloneif'])) { if ($clone['if'] != $a_clones[$id]['if']) { $input_errors[] = gettext("This wireless clone cannot be modified because it is still assigned as an interface."); } elseif ($clone['mode'] != $a_clones[$id]['mode']) { $input_errors[] = gettext("Use the configuration page for the assigned interface to change the mode."); } } if (count($input_errors) == 0) { if (!interface_wireless_clone($clone['cloneif'], $clone)) { $input_errors[] = sprintf(gettext('Error creating interface with mode %s. The %s interface may not support creating more clones with the selected mode.'), $wlan_modes[$clone['mode']], $clone['if']); } else { if (isset($id)) { if ($clone['if'] != $a_clones[$id]['if']) { mwexec("/sbin/ifconfig " . escapeshellarg($a_clones[$id]['cloneif']) . " destroy"); } $a_clones[$id] = $clone;